text stringlengths 1 1.05M |
|---|
INCLUDE "clib_cfg.asm"
SECTION code_l
PUBLIC l_btoul
; ascii binary string to unsigned long
; whitespace is not skipped
; char consumption stops on overflow
;
; enter : de = char *buffer
;
; exit : bc = & next char to interpret in buffer
; dehl = unsigned result (0 on invalid input)
; carry set on unsigned overflow
;
; uses : af, bc, de, hl
IF __CLIB_OPT_TXT2NUM_SELECT & $01
EXTERN l_fast_btoul
defc l_btoul = l_fast_btoul
ELSE
EXTERN l_small_btoul
defc l_btoul = l_small_btoul
ENDIF
|
; A175540: a(n) = A067076(n) + n.
; 1,3,5,8,10,13,15,18,22,24,28,31,33,36,40,44,46,50,53,55,59,62,66,71,74,76,79,81,84,92,95,99,101,107,109,113,117,120,124,128,130,136,138,141,143,150,157,160,162,165,169,171,177,181,185,189,191,195,198,200,206
mov $9,$0
mov $11,2
lpb $11
mov $0,$9
sub $11,1
add $0,$11
mov $2,$0
mov $5,$0
mov $6,$0
cal $0,40 ; The prime numbers.
add $2,$0
mov $3,$5
sub $3,2
add $4,$2
sub $4,$3
mov $7,$11
mov $8,$6
mul $8,2
mov $10,$4
add $10,$8
lpb $7
mov $1,$10
sub $7,1
lpe
lpe
sub $1,7
div $1,2
add $1,1
|
/*
==============================================================================
KratosStructuralApplication
A library based on:
Kratos
A General Purpose Software for Multi-Physics Finite Element Analysis
Version 1.0 (Released on march 05, 2007).
Copyright 2007
Pooyan Dadvand, Riccardo Rossi, Janosch Stascheit, Felix Nagel
pooyan@cimne.upc.edu
rrossi@cimne.upc.edu
janosch.stascheit@rub.de
nagel@sd.rub.de
- CIMNE (International Center for Numerical Methods in Engineering),
Gran Capita' s/n, 08034 Barcelona, Spain
- Ruhr-University Bochum, Institute for Structural Mechanics, Germany
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following condition:
Distribution of this code for any commercial purpose is permissible
ONLY BY DIRECT ARRANGEMENT WITH THE COPYRIGHT OWNERS.
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==============================================================================
*/
/* **************************************************************************************
*
* Last Modified by: $Author: hbui $
* Date: $Date: 24 Oct 2014 $
* Revision: $Revision: 1.1 $
*
* ***************************************************************************************/
// System includes
// External includes
#include <boost/timer.hpp>
// Project includes
#include "includes/define.h"
#include "line_pressure_isogeometric_2d.h"
#include "utilities/math_utils.h"
#include "structural_application/custom_utilities/sd_math_utils.h"
#include "isogeometric_application/isogeometric_application.h"
//#define DEBUG_LEVEL1
namespace Kratos
{
//***********************************************************************************
//***********************************************************************************
// -------- //
// PUBLIC //
// -------- //
// Constructor
LinePressureIsogeometric2D::LinePressureIsogeometric2D()
{
}
// Constructor
LinePressureIsogeometric2D::LinePressureIsogeometric2D( IndexType NewId, GeometryType::Pointer pGeometry )
: LineForceIsogeometric( NewId, pGeometry )
{
}
// Constructor
LinePressureIsogeometric2D::LinePressureIsogeometric2D( IndexType NewId, GeometryType::Pointer pGeometry,
PropertiesType::Pointer pProperties )
: LineForceIsogeometric( NewId, pGeometry, pProperties )
{
}
//***********************************************************************************
//***********************************************************************************
Condition::Pointer LinePressureIsogeometric2D::Create( IndexType NewId,
NodesArrayType const& ThisNodes,
PropertiesType::Pointer pProperties ) const
{
return Condition::Pointer( new LinePressureIsogeometric2D( NewId, GetGeometry().Create( ThisNodes ), pProperties ) );
}
//***********************************************************************************
//***********************************************************************************
Condition::Pointer LinePressureIsogeometric2D::Create( IndexType NewId,
GeometryType::Pointer pGeom,
PropertiesType::Pointer pProperties ) const
{
return Condition::Pointer( new LinePressureIsogeometric2D( NewId, pGeom, pProperties ) );
}
//***********************************************************************************
//***********************************************************************************
// Destructor
LinePressureIsogeometric2D::~LinePressureIsogeometric2D()
{
}
//***********************************************************************************
//***********************************************************************************
void LinePressureIsogeometric2D::GetDofList( DofsVectorType& ConditionalDofList,
const ProcessInfo& rCurrentProcessInfo ) const
{
ConditionalDofList.resize( 0 );
for ( unsigned int i = 0; i < GetGeometry().size(); ++i )
{
ConditionalDofList.push_back( GetGeometry()[i].pGetDof( DISPLACEMENT_X ) );
ConditionalDofList.push_back( GetGeometry()[i].pGetDof( DISPLACEMENT_Y ) );
}
}
//***********************************************************************************
void LinePressureIsogeometric2D::CalculateDampingMatrix(MatrixType& rDampMatrix, const ProcessInfo& rCurrentProcessInfo)
{
KRATOS_TRY
rDampMatrix.resize(0,0,false);
KRATOS_CATCH("")
}
//***********************************************************************************
//***********************************************************************************
//***********************************************************************************
//***********************************************************************************
void LinePressureIsogeometric2D::CalculateAll( MatrixType& rLeftHandSideMatrix,
VectorType& rRightHandSideVector,
const ProcessInfo& rCurrentProcessInfo,
bool CalculateStiffnessMatrixFlag,
bool CalculateResidualVectorFlag )
{
KRATOS_TRY
const unsigned int number_of_nodes = GetGeometry().size();
const unsigned int dim = 2;
unsigned int MatSize = number_of_nodes * dim;
//resizing as needed the LHS
if ( CalculateStiffnessMatrixFlag == true ) //calculation of the matrix is required
{
if ( rLeftHandSideMatrix.size1() != MatSize )
rLeftHandSideMatrix.resize( MatSize, MatSize, false );
noalias( rLeftHandSideMatrix ) = ZeroMatrix( MatSize, MatSize ); //resetting LHS
}
//resizing as needed the RHS
if ( CalculateResidualVectorFlag == true ) //calculation of the matrix is required
{
if ( rRightHandSideVector.size() != MatSize )
rRightHandSideVector.resize( MatSize, false );
rRightHandSideVector = ZeroVector( MatSize ); //resetting RHS
}
//reading integration points
const GeometryType::IntegrationPointsArrayType& integration_points =
mpIsogeometricGeometry->IntegrationPoints(mThisIntegrationMethod);
//calculating shape function values and local gradients
GeometryType::ShapeFunctionsGradientsType DN_De;
Matrix Ncontainer;
mpIsogeometricGeometry->CalculateShapeFunctionsIntegrationPointsValuesAndLocalGradients(
Ncontainer,
DN_De,
integration_points
);
#ifdef DEBUG_LEVEL1
KRATOS_WATCH(mThisIntegrationMethod)
KRATOS_WATCH(integration_points.size())
KRATOS_WATCH(typeid(*mpIsogeometricGeometry).name())
KRATOS_WATCH(mpIsogeometricGeometry->size())
std::cout << "At condition " << Id() << ":";
for (int i = 0; i < mpIsogeometricGeometry->size(); ++i)
std::cout << " " << (*mpIsogeometricGeometry)[i].Id();
std::cout << std::endl;
KRATOS_WATCH(Ncontainer)
#endif
const double& P = this->GetValue(PRESSURE);
// KRATOS_WATCH(P)
// loop over integration points
Vector Load( dim );
Vector t( dim );
Vector G( dim );
double dL;
for ( unsigned int PointNumber = 0; PointNumber < integration_points.size(); ++PointNumber )
{
// compute integration weight
double IntegrationWeight = integration_points[PointNumber].Weight();
IntegrationWeight *= GetProperties()[THICKNESS];
// compute length
noalias( t ) = ZeroVector( dim );//tangential vector
noalias( G ) = ZeroVector( dim );
for ( unsigned int n = 0; n < GetGeometry().size(); ++n )
{
t[0] += GetGeometry().GetPoint( n ).X0() * DN_De[PointNumber]( n, 0 );
t[1] += GetGeometry().GetPoint( n ).Y0() * DN_De[PointNumber]( n, 0 );
G[0] += GetGeometry().GetPoint( n ).X0() * Ncontainer( PointNumber, n );
G[1] += GetGeometry().GetPoint( n ).Y0() * Ncontainer( PointNumber, n );
}
dL = norm_2(t);
//calculating load
Load[0] = -P*t[1];
Load[1] = P*t[0];
// contribute to RIGHT HAND SIDE VECTOR
if ( CalculateResidualVectorFlag == true ) //calculation of the matrix is required
{
for ( unsigned int prim = 0; prim < GetGeometry().size(); ++prim )
for ( unsigned int i = 0; i < dim; ++i )
rRightHandSideVector( prim * dim + i ) +=
Ncontainer( PointNumber, prim ) * Load( i ) * IntegrationWeight;
}
}
#ifdef DEBUG_LEVEL1
KRATOS_WATCH(rRightHandSideVector)
#endif
KRATOS_CATCH( "" )
}
} // Namespace Kratos.
#undef DEBUG_LEVEL1
|
; A053726: "Flag numbers": number of dots that can be arranged in successive rows of K, K-1, K, K-1, K, ..., K-1, K (assuming there is a total of L > 1 rows of size K > 1).
; Submitted by Jamie Morken
; 5,8,11,13,14,17,18,20,23,25,26,28,29,32,33,35,38,39,41,43,44,46,47,48,50,53,56,58,59,60,61,62,63,65,67,68,71,72,73,74,77,78,80,81,83,85,86,88,89,92,93,94,95,98,101,102,103,104,105,107,108,109,110,111,113,116,118,119,122,123,124,125,127,128,130,131,133,134,137,138,140,143,144,145,146,148,149,150,151,152,153,155,158,160,161,162,163,164,165,167
add $0,2
mov $1,3
mov $2,1
lpb $0
mov $3,$2
lpb $3
add $2,2
mov $4,$1
gcd $4,$2
cmp $4,1
sub $3,$4
lpe
sub $0,1
add $2,2
mul $1,$2
lpe
mov $0,$2
div $0,2
add $0,1
|
; A252489: Index of the largest prime which divides n(n+1).
; 1,2,2,3,3,4,4,2,3,5,5,6,6,4,3,7,7,8,8,4,5,9,9,3,6,6,4,10,10,11,11,5,7,7,4,12,12,8,6,13,13,14,14,5,9,15,15,4,4,7,7,16,16,5,5,8,10,17,17,18,18,11,4,6,6,19,19,9,9,20,20,21,21,12,8,8,6,22,22,3,13,23,23,7,14,14,10,24,24,6,9,11,15,15,8,25,25,5,5,26
seq $0,28387 ; a(n) = n + (n+1)^2.
seq $0,61395 ; Let p be the largest prime factor of n; if p is the k-th prime then set a(n) = k; a(1) = 0 by convention.
|
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r8
push %rax
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x5858, %rax
nop
nop
nop
nop
nop
add $15694, %rbp
mov (%rax), %r8w
nop
xor %rdx, %rdx
lea addresses_WT_ht+0x1af38, %rsi
lea addresses_WT_ht+0xbcd8, %rdi
clflush (%rsi)
nop
nop
nop
add $36729, %r14
mov $25, %rcx
rep movsw
nop
xor $47158, %rcx
lea addresses_D_ht+0x39b0, %r14
nop
nop
nop
nop
nop
add $19237, %rcx
mov (%r14), %rdi
nop
nop
nop
nop
cmp $13538, %r8
lea addresses_UC_ht+0xba8, %rcx
clflush (%rcx)
cmp $42752, %rsi
mov (%rcx), %rdx
nop
nop
nop
sub $26912, %r14
lea addresses_WC_ht+0x6b38, %r14
nop
nop
sub %rdi, %rdi
movl $0x61626364, (%r14)
nop
nop
nop
and %rdi, %rdi
lea addresses_WC_ht+0x8f94, %rsi
lea addresses_WT_ht+0x14338, %rdi
and $29128, %rax
mov $79, %rcx
rep movsw
nop
nop
sub $59899, %rbp
lea addresses_WT_ht+0x12338, %rsi
lea addresses_normal_ht+0x1ab38, %rdi
nop
add $10893, %r8
mov $120, %rcx
rep movsl
nop
nop
nop
add %rbp, %rbp
lea addresses_UC_ht+0xec38, %rsi
nop
nop
nop
inc %rax
mov (%rsi), %ecx
nop
nop
nop
nop
nop
inc %rax
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r15
push %r8
push %rcx
push %rdx
// Store
lea addresses_normal+0x1d470, %rcx
clflush (%rcx)
nop
add $21712, %rdx
movb $0x51, (%rcx)
and $41270, %r8
// Store
lea addresses_RW+0xab38, %r8
nop
nop
nop
nop
nop
inc %r12
mov $0x5152535455565758, %r10
movq %r10, (%r8)
nop
nop
nop
nop
nop
sub $56565, %r10
// Load
lea addresses_PSE+0xb88c, %r8
nop
nop
dec %r15
mov (%r8), %cx
nop
nop
nop
nop
nop
sub %r15, %r15
// Faulty Load
lea addresses_RW+0xab38, %r11
nop
nop
nop
dec %r10
mov (%r11), %dx
lea oracles, %r11
and $0xff, %rdx
shlq $12, %rdx
mov (%r11,%rdx,1), %rdx
pop %rdx
pop %rcx
pop %r8
pop %r15
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_RW', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_normal', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_RW', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_PSE', 'same': False, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_RW', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 4, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'58': 648}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 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 2017 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See https://github.com/danielaparker/jsoncons for latest version
#ifndef JSONCONS_SER_JSON_HPP
#define JSONCONS_SER_JSON_HPP
#include <iostream>
#include <string>
#include <tuple>
#include <memory>
#include <istream> // std::basic_istream
#include <jsoncons/ser_traits.hpp>
#include <jsoncons/json_cursor.hpp>
namespace jsoncons {
// decode_json
template <class T, class CharT>
typename std::enable_if<is_basic_json_class<T>::value,T>::type
decode_json(const std::basic_string<CharT>& s,
const basic_json_decode_options<CharT>& options = basic_json_decode_options<CharT>())
{
jsoncons::json_decoder<T> decoder;
basic_json_reader<CharT, string_source<CharT>> reader(s, decoder, options);
reader.read();
return decoder.get_result();
}
template <class T, class CharT>
typename std::enable_if<!is_basic_json_class<T>::value,T>::type
decode_json(const std::basic_string<CharT>& s,
const basic_json_decode_options<CharT>& options = basic_json_decode_options<CharT>())
{
basic_json_cursor<CharT> cursor(s, options);
std::error_code ec;
T val = ser_traits<T>::decode(cursor, basic_json<CharT>(), ec);
if (ec)
{
JSONCONS_THROW(ser_error(ec, cursor.context().line(), cursor.context().column()));
}
return val;
}
template <class T, class CharT>
typename std::enable_if<is_basic_json_class<T>::value,T>::type
decode_json(std::basic_istream<CharT>& is,
const basic_json_decode_options<CharT>& options = basic_json_decode_options<CharT>())
{
jsoncons::json_decoder<T> decoder;
basic_json_reader<CharT, stream_source<CharT>> reader(is, decoder, options);
reader.read();
return decoder.get_result();
}
template <class T, class CharT>
typename std::enable_if<!is_basic_json_class<T>::value,T>::type
decode_json(std::basic_istream<CharT>& is,
const basic_json_decode_options<CharT>& options = basic_json_decode_options<CharT>())
{
basic_json_cursor<CharT> cursor(is, options);
std::error_code ec;
T val = ser_traits<T>::decode(cursor, basic_json<CharT>(), ec);
if (ec)
{
JSONCONS_THROW(ser_error(ec, cursor.context().line(), cursor.context().column()));
}
return val;
}
template <class T, class CharT, class ImplementationPolicy, class Allocator>
T decode_json(const std::basic_string<CharT>& s,
const basic_json_decode_options<CharT>& options,
const basic_json<CharT,ImplementationPolicy,Allocator>& context_j)
{
basic_json_cursor<CharT> cursor(s, options);
std::error_code ec;
T val = ser_traits<T>::decode(cursor, context_j, ec);
if (ec)
{
JSONCONS_THROW(ser_error(ec, cursor.context().line(), cursor.context().column()));
}
return val;
}
template <class T, class CharT, class ImplementationPolicy, class Allocator>
T decode_json(std::basic_istream<CharT>& is,
const basic_json_decode_options<CharT>& options,
const basic_json<CharT,ImplementationPolicy,Allocator>& context_j)
{
basic_json_cursor<CharT> cursor(is, options);
std::error_code ec;
T val = ser_traits<T>::decode(cursor, context_j, ec);
if (ec)
{
JSONCONS_THROW(ser_error(ec, cursor.context().line(), cursor.context().column()));
}
return val;
}
#if !defined(JSONCONS_NO_DEPRECATED)
template <class T, class CharT, class ImplementationPolicy, class Allocator>
JSONCONS_DEPRECATED_MSG("Instead, use decode_json(const std::basic_string<CharT>&, const basic_json_decode_options<CharT>&, const basic_json<CharT,ImplementationPolicy,Allocator>&)")
T decode_json(const basic_json<CharT,ImplementationPolicy,Allocator>& context_j,
const std::basic_string<CharT>& s,
const basic_json_decode_options<CharT>& options = basic_json_decode_options<CharT>())
{
basic_json_cursor<CharT> cursor(s, options);
std::error_code ec;
T val = ser_traits<T>::decode(cursor, context_j, ec);
if (ec)
{
JSONCONS_THROW(ser_error(ec, cursor.context().line(), cursor.context().column()));
}
return val;
}
template <class T, class CharT, class ImplementationPolicy, class Allocator>
JSONCONS_DEPRECATED_MSG("Instead, use decode_json(const std::basic_istream<CharT>&, const basic_json_decode_options<CharT>&, const basic_json<CharT,ImplementationPolicy,Allocator>&)")
T decode_json(const basic_json<CharT,ImplementationPolicy,Allocator>& context_j,
std::basic_istream<CharT>& is,
const basic_json_decode_options<CharT>& options = basic_json_decode_options<CharT>())
{
basic_json_cursor<CharT> cursor(is, options);
std::error_code ec;
T val = ser_traits<T>::decode(cursor, context_j, ec);
if (ec)
{
JSONCONS_THROW(ser_error(ec, cursor.context().line(), cursor.context().column()));
}
return val;
}
#endif
// encode_json
// to string
template <class T, class CharT>
void encode_json(const T& val,
std::basic_string<CharT>& s,
indenting line_indent = indenting::no_indent)
{
encode_json(val, s, basic_json_encode_options<CharT>(), line_indent);
}
template <class T, class CharT>
typename std::enable_if<is_basic_json_class<T>::value>::type
encode_json(const T& val,
std::basic_string<CharT>& s,
const basic_json_encode_options<CharT>& options,
indenting line_indent = indenting::no_indent)
{
if (line_indent == indenting::indent)
{
basic_json_encoder<CharT,jsoncons::string_result<std::basic_string<CharT>>> encoder(s, options);
val.dump(encoder);
}
else
{
basic_json_compressed_encoder<CharT, jsoncons::string_result<std::basic_string<CharT>>> encoder(s, options);
val.dump(encoder);
}
}
template <class T, class CharT>
typename std::enable_if<!is_basic_json_class<T>::value>::type
encode_json(const T& val,
std::basic_string<CharT>& s,
const basic_json_encode_options<CharT>& options,
indenting line_indent = indenting::no_indent)
{
if (line_indent == indenting::indent)
{
basic_json_encoder<CharT,jsoncons::string_result<std::basic_string<CharT>>> encoder(s, options);
encode_json(val, encoder);
}
else
{
basic_json_compressed_encoder<CharT, jsoncons::string_result<std::basic_string<CharT>>> encoder(s, options);
encode_json(val, encoder);
}
}
// to stream
template <class T, class CharT>
void encode_json(const T& val,
std::basic_ostream<CharT>& os,
indenting line_indent = indenting::no_indent)
{
encode_json(val, os, basic_json_encode_options<CharT>(), line_indent);
}
template <class T, class CharT>
typename std::enable_if<is_basic_json_class<T>::value>::type
encode_json(const T& val,
std::basic_ostream<CharT>& os,
const basic_json_encode_options<CharT>& options,
indenting line_indent = indenting::no_indent)
{
if (line_indent == indenting::indent)
{
basic_json_encoder<CharT> encoder(os, options);
val.dump(encoder);
}
else
{
basic_json_compressed_encoder<CharT> encoder(os, options);
val.dump(encoder);
}
}
template <class T, class CharT>
typename std::enable_if<!is_basic_json_class<T>::value>::type
encode_json(const T& val,
std::basic_ostream<CharT>& os,
const basic_json_encode_options<CharT>& options,
indenting line_indent = indenting::no_indent)
{
if (line_indent == indenting::indent)
{
basic_json_encoder<CharT> encoder(os, options);
encode_json(val, encoder);
}
else
{
basic_json_compressed_encoder<CharT> encoder(os, options);
encode_json(val, encoder);
}
}
template <class T, class CharT>
void encode_json(const T& val,
basic_json_content_handler<CharT>& encoder)
{
std::error_code ec;
ser_traits<T>::encode(val, encoder, basic_json<CharT>(), ec);
if (ec)
{
JSONCONS_THROW(ser_error(ec));
}
encoder.flush();
}
template <class T, class CharT, class ImplementationPolicy, class Allocator>
typename std::enable_if<!is_basic_json_class<T>::value>::type
encode_json(const T& val,
std::basic_string<CharT>& s,
const basic_json_encode_options<CharT>& options,
indenting line_indent,
const basic_json<CharT,ImplementationPolicy,Allocator>& context_j)
{
if (line_indent == indenting::indent)
{
basic_json_encoder<CharT,jsoncons::string_result<std::basic_string<CharT>>> encoder(s, options);
encode_json(val, encoder, context_j);
}
else
{
basic_json_compressed_encoder<CharT,jsoncons::string_result<std::basic_string<CharT>>> encoder(s, options);
encode_json(val, encoder, context_j);
}
}
template <class T, class CharT, class ImplementationPolicy, class Allocator>
typename std::enable_if<!is_basic_json_class<T>::value>::type
encode_json(const T& val,
std::basic_ostream<CharT>& os,
const basic_json_encode_options<CharT>& options,
indenting line_indent,
const basic_json<CharT,ImplementationPolicy,Allocator>& context_j)
{
if (line_indent == indenting::indent)
{
basic_json_encoder<CharT> encoder(os, options);
encode_json(val, encoder, context_j);
}
else
{
basic_json_compressed_encoder<CharT> encoder(os, options);
encode_json(val, encoder, context_j);
}
}
template <class T, class CharT, class ImplementationPolicy, class Allocator>
typename std::enable_if<!is_basic_json_class<T>::value>::type
encode_json(const T& val,
basic_json_content_handler<CharT>& encoder,
const basic_json<CharT, ImplementationPolicy, Allocator>& context_j)
{
std::error_code ec;
ser_traits<T>::encode(val, encoder, context_j, ec);
if (ec)
{
JSONCONS_THROW(ser_error(ec));
}
encoder.flush();
}
#if !defined(JSONCONS_NO_DEPRECATED)
template <class T, class CharT, class ImplementationPolicy, class Allocator>
JSONCONS_DEPRECATED_MSG("Instead, use encode_json(const T&,basic_json_content_handler<CharT>&,const basic_json<CharT, ImplementationPolicy, Allocator>&)")
void encode_json(const basic_json<CharT, ImplementationPolicy, Allocator>& context_j,
const T& val,
basic_json_content_handler<CharT>& encoder)
{
std::error_code ec;
ser_traits<T>::encode(val, encoder, context_j, ec);
if (ec)
{
JSONCONS_THROW(ser_error(ec));
}
encoder.flush();
}
template <class T, class CharT, class ImplementationPolicy, class Allocator>
JSONCONS_DEPRECATED_MSG("Instead, use encode_json(const T& val,std::basic_ostream<CharT>&,const basic_json_encode_options<CharT>&,indenting,const basic_json<CharT,ImplementationPolicy,Allocator>&)")
void encode_json(const basic_json<CharT,ImplementationPolicy,Allocator>& context_j,
const T& val,
std::basic_ostream<CharT>& os,
const basic_json_encode_options<CharT>& options = basic_json_encode_options<CharT>(),
indenting line_indent = indenting::no_indent)
{
if (line_indent == indenting::indent)
{
basic_json_encoder<CharT> encoder(os, options);
encode_json(context_j, val, encoder);
}
else
{
basic_json_compressed_encoder<CharT> encoder(os, options);
encode_json(context_j, val, encoder);
}
}
template <class T, class CharT, class ImplementationPolicy, class Allocator>
JSONCONS_DEPRECATED_MSG("Instead, use encode_json(const T& val,std::basic_ostream<CharT>&,const basic_json_encode_options<CharT>&,indenting,const basic_json<CharT,ImplementationPolicy,Allocator>&)")
void encode_json(const basic_json<CharT,ImplementationPolicy,Allocator>& context_j,
const T& val,
std::basic_ostream<CharT>& os,
indenting line_indent)
{
if (line_indent == indenting::indent)
{
basic_json_encoder<CharT> encoder(os, basic_json_encode_options<CharT>());
encode_json(context_j, val, encoder);
}
else
{
basic_json_compressed_encoder<CharT> encoder(os, basic_json_encode_options<CharT>());
encode_json(context_j, val, encoder);
}
}
template <class T, class CharT, class ImplementationPolicy, class Allocator>
JSONCONS_DEPRECATED_MSG("Instead, use encode_json(const T& val,std::basic_string<CharT>&,const basic_json_encode_options<CharT>&,indenting,const basic_json<CharT,ImplementationPolicy,Allocator>&)")
void encode_json(const basic_json<CharT,ImplementationPolicy,Allocator>& context_j,
const T& val,
std::basic_string<CharT>& s,
const basic_json_encode_options<CharT>& options = basic_json_encode_options<CharT>(),
indenting line_indent = indenting::no_indent)
{
if (line_indent == indenting::indent)
{
basic_json_encoder<CharT,jsoncons::string_result<std::basic_string<CharT>>> encoder(s, options);
encode_json(context_j, val, encoder);
}
else
{
basic_json_compressed_encoder<CharT,jsoncons::string_result<std::basic_string<CharT>>> encoder(s, options);
encode_json(context_j, val, encoder);
}
}
template <class T, class CharT, class ImplementationPolicy, class Allocator>
JSONCONS_DEPRECATED_MSG("Instead, use encode_json(const T& val,std::basic_string<CharT>&,const basic_json_encode_options<CharT>&,indenting,const basic_json<CharT,ImplementationPolicy,Allocator>&)")
void encode_json(const basic_json<CharT,ImplementationPolicy,Allocator>& context_j,
const T& val,
std::basic_string<CharT>& s,
indenting line_indent)
{
if (line_indent == indenting::indent)
{
basic_json_encoder<CharT,jsoncons::string_result<std::basic_string<CharT>>> encoder(s, basic_json_encode_options<CharT>());
encode_json(context_j, val, encoder);
}
else
{
basic_json_compressed_encoder<CharT,jsoncons::string_result<std::basic_string<CharT>>> encoder(s, basic_json_encode_options<CharT>());
encode_json(context_j, val, encoder);
}
}
#endif
}
#endif
|
#include "AboutPage.hpp"
#include "common/Modes.hpp"
#include "common/Version.hpp"
#include "debug/Log.hpp"
#include "util/LayoutCreator.hpp"
#include "util/RemoveScrollAreaBackground.hpp"
#include "widgets/helper/SignalLabel.hpp"
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
#include <QTextEdit>
#include <QTextStream>
#include <QVBoxLayout>
#define PIXMAP_WIDTH 500
namespace chatterino {
AboutPage::AboutPage()
: SettingsPage("About", ":/settings/about.svg")
{
LayoutCreator<AboutPage> layoutCreator(this);
auto scroll = layoutCreator.emplace<QScrollArea>();
auto widget = scroll.emplaceScrollAreaWidget();
removeScrollAreaBackground(scroll.getElement(), widget.getElement());
auto layout = widget.setLayoutType<QVBoxLayout>();
{
QPixmap pixmap;
pixmap.load(":/settings/aboutlogo.png");
auto logo = layout.emplace<QLabel>().assign(&this->logo_);
logo->setPixmap(pixmap);
logo->setFixedSize(PIXMAP_WIDTH,
PIXMAP_WIDTH * pixmap.height() / pixmap.width());
logo->setScaledContents(true);
// this does nothing
// QPalette palette;
// palette.setColor(QPalette::Text, Qt::white);
// palette.setColor(QPalette::Link, "#a5cdff");
// palette.setColor(QPalette::LinkVisited, "#a5cdff");
/*auto xd = layout.emplace<QGroupBox>("Created by...");
{
auto created = xd.emplace<QLabel>();
{
created->setText("Created by <a
href=\"https://github.com/fourtf\">fourtf</a><br>" "with big help from
pajlada."); created->setTextFormat(Qt::RichText);
created->setTextInteractionFlags(Qt::TextBrowserInteraction |
Qt::LinksAccessibleByKeyboard |
Qt::LinksAccessibleByKeyboard);
created->setOpenExternalLinks(true);
// created->setPalette(palette);
}
// auto github = xd.emplace<QLabel>();
// {
// github->setText(
// "<a
href=\"https://github.com/fourtf/chatterino2\">Chatterino on
// Github</a>");
// github->setTextFormat(Qt::RichText);
// github->setTextInteractionFlags(Qt::TextBrowserInteraction |
// Qt::LinksAccessibleByKeyboard |
// Qt::LinksAccessibleByKeyboard);
// github->setOpenExternalLinks(true);
// // github->setPalette(palette);
// }
}*/
auto versionInfo = layout.emplace<QGroupBox>("Version");
{
auto version = Version::instance();
QString text = QString("%1 (commit %2%3)")
.arg(version.fullVersion())
.arg("<a "
"href=\"https://github.com/Chatterino/"
"chatterino2/commit/" +
version.commitHash() + "\">" +
version.commitHash() + "</a>")
.arg(Modes::instance().isNightly
? ", " + version.dateOfBuild()
: "");
auto versionLabel = versionInfo.emplace<QLabel>(text);
versionLabel->setOpenExternalLinks(true);
versionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse |
Qt::LinksAccessibleByMouse);
}
auto licenses =
layout.emplace<QGroupBox>("Open source software used...");
{
auto form = licenses.emplace<QFormLayout>();
addLicense(form.getElement(), "Qt Framework", "https://www.qt.io",
":/licenses/qt_lgpl-3.0.txt");
addLicense(form.getElement(), "Boost", "https://www.boost.org/",
":/licenses/boost_boost.txt");
addLicense(form.getElement(), "Fmt", "http://fmtlib.net/",
":/licenses/fmt_bsd2.txt");
addLicense(form.getElement(), "LibCommuni",
"https://github.com/communi/libcommuni",
":/licenses/libcommuni_BSD3.txt");
addLicense(form.getElement(), "OpenSSL", "https://www.openssl.org/",
":/licenses/openssl.txt");
addLicense(form.getElement(), "RapidJson", "http://rapidjson.org/",
":/licenses/rapidjson.txt");
addLicense(form.getElement(), "Pajlada/Settings",
"https://github.com/pajlada/settings",
":/licenses/pajlada_settings.txt");
addLicense(form.getElement(), "Pajlada/Signals",
"https://github.com/pajlada/signals",
":/licenses/pajlada_signals.txt");
addLicense(form.getElement(), "Websocketpp",
"https://www.zaphoyd.com/websocketpp/",
":/licenses/websocketpp.txt");
addLicense(form.getElement(), "QtKeychain",
"https://github.com/frankosterfeld/qtkeychain",
":/licenses/qtkeychain.txt");
}
auto attributions = layout.emplace<QGroupBox>("Attributions...");
{
auto l = attributions.emplace<QVBoxLayout>();
// clang-format off
l.emplace<QLabel>("EmojiOne 2 and 3 emojis provided by <a href=\"https://www.emojione.com/\">EmojiOne</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("Twemoji emojis provided by <a href=\"https://github.com/twitter/twemoji\">Twitter's Twemoji</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("Facebook emojis provided by <a href=\"https://facebook.com\">Facebook</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("Apple emojis provided by <a href=\"https://apple.com\">Apple</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("Google emojis provided by <a href=\"https://google.com\">Google</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("Messenger emojis provided by <a href=\"https://facebook.com\">Facebook</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("Emoji datasource provided by <a href=\"https://www.iamcal.com/\">Cal Henderson</a>"
"(<a href=\"https://github.com/iamcal/emoji-data/blob/master/LICENSE\">show license</a>)")->setOpenExternalLinks(true);
l.emplace<QLabel>("Twitch emote data provided by <a href=\"https://twitchemotes.com/\">twitchemotes.com</a> through the <a href=\"https://github.com/Chatterino/api\">Chatterino API</a>")->setOpenExternalLinks(true);
// clang-format on
}
// Contributors
auto contributors = layout.emplace<QGroupBox>("Contributors");
{
auto l = contributors.emplace<QVBoxLayout>();
QFile contributorsFile(":/contributors.txt");
contributorsFile.open(QFile::ReadOnly);
QTextStream stream(&contributorsFile);
stream.setCodec("UTF-8");
QString line;
while (stream.readLineInto(&line))
{
if (line.isEmpty() || line.startsWith('#'))
{
continue;
}
QStringList contributorParts = line.split("|");
if (contributorParts.size() != 4)
{
log("Missing parts in line '{}'", line);
continue;
}
QString username = contributorParts[0].trimmed();
QString url = contributorParts[1].trimmed();
QString avatarUrl = contributorParts[2].trimmed();
QString role = contributorParts[3].trimmed();
auto *usernameLabel =
new QLabel("<a href=\"" + url + "\">" + username + "</a>");
usernameLabel->setOpenExternalLinks(true);
auto *roleLabel = new QLabel(role);
auto contributorBox2 = l.emplace<QHBoxLayout>();
const auto addAvatar = [&avatarUrl, &contributorBox2] {
if (!avatarUrl.isEmpty())
{
QPixmap avatarPixmap;
avatarPixmap.load(avatarUrl);
auto avatar = contributorBox2.emplace<QLabel>();
avatar->setPixmap(avatarPixmap);
avatar->setFixedSize(64, 64);
avatar->setScaledContents(true);
}
};
const auto addLabels = [&contributorBox2, &usernameLabel,
&roleLabel] {
auto labelBox = new QVBoxLayout();
contributorBox2->addLayout(labelBox);
labelBox->addWidget(usernameLabel);
labelBox->addWidget(roleLabel);
};
addLabels();
addAvatar();
}
}
}
auto buildInfo = QStringList();
buildInfo += "Qt " QT_VERSION_STR;
#ifdef USEWINSDK
buildInfo += "Windows SDK";
#endif
#ifdef _MSC_FULL_VER
buildInfo += "MSVC " + QString::number(_MSC_FULL_VER, 10);
#endif
auto buildText = QString("Built with " + buildInfo.join(", "));
layout.emplace<QLabel>(buildText);
layout->addStretch(1);
}
void AboutPage::addLicense(QFormLayout *form, const QString &name,
const QString &website, const QString &licenseLink)
{
auto *a = new QLabel("<a href=\"" + website + "\">" + name + "</a>");
a->setOpenExternalLinks(true);
auto *b = new QLabel("<a href=\"" + licenseLink + "\">show license</a>");
QObject::connect(b, &QLabel::linkActivated, [licenseLink] {
auto *edit = new QTextEdit;
QFile file(licenseLink);
file.open(QIODevice::ReadOnly);
edit->setText(file.readAll());
edit->setReadOnly(true);
edit->show();
});
form->addRow(a, b);
}
} // namespace chatterino
|
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../inc/MarlinConfigPre.h"
#if HAS_UI_480x320
#include "ui_480x320.h"
#include "../ultralcd.h"
#include "../menu/menu.h"
#include "../../libs/numtostr.h"
#include "../../sd/cardreader.h"
#include "../../module/temperature.h"
#include "../../module/printcounter.h"
#include "../../module/planner.h"
#include "../../module/motion.h"
#if DISABLED(LCD_PROGRESS_BAR) && BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
#include "../../feature/filwidth.h"
#include "../../gcode/parser.h"
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
#include "../../feature/bedlevel/bedlevel.h"
#endif
#if !HAS_LCD_MENU
#error "Seriously? High resolution TFT screen without menu?"
#endif
static bool draw_menu_navigation = false;
void MarlinUI::tft_idle() {
#if ENABLED(TOUCH_SCREEN)
if (draw_menu_navigation) {
add_control(104, 286, PAGE_UP, imgPageUp, encoderTopLine > 0);
add_control(344, 286, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items);
add_control(224, 286, BACK, imgBack);
draw_menu_navigation = false;
}
#endif
tft.queue.async();
TERN_(TOUCH_SCREEN, touch.idle());
}
void MarlinUI::init_lcd() {
tft.init();
tft.set_font(MENU_FONT_NAME);
#ifdef SYMBOLS_FONT_NAME
tft.add_glyphs(SYMBOLS_FONT_NAME);
#endif
TERN_(TOUCH_SCREEN, touch.init());
clear_lcd();
}
bool MarlinUI::detected() { return true; }
void MarlinUI::clear_lcd() {
#if ENABLED(TOUCH_SCREEN)
touch.reset();
draw_menu_navigation = false;
#endif
tft.queue.reset();
tft.fill(0, 0, TFT_WIDTH, TFT_HEIGHT, COLOR_BACKGROUND);
}
#if ENABLED(SHOW_BOOTSCREEN)
#ifndef BOOTSCREEN_TIMEOUT
#define BOOTSCREEN_TIMEOUT 1500
#endif
#undef BOOTSCREEN_TIMEOUT
#define BOOTSCREEN_TIMEOUT 5000
void MarlinUI::show_bootscreen() {
tft.queue.reset();
tft.canvas(0, 0, TFT_WIDTH, TFT_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft.add_image(142, 130, imgBootScreen); // MarlinLogo195x59x16
#ifdef WEBSITE_URL
tft.add_text(8, 250, COLOR_WEBSITE_URL, WEBSITE_URL);
#endif
tft.queue.sync();
safe_delay(BOOTSCREEN_TIMEOUT);
clear_lcd();
}
#endif // SHOW_BOOTSCREEN
void MarlinUI::draw_kill_screen() {
tft.queue.reset();
tft.fill(0, 0, TFT_WIDTH, TFT_HEIGHT, COLOR_KILL_SCREEN_BG);
uint16_t line = 2;
menu_line(line++, COLOR_KILL_SCREEN_BG);
tft_string.set(status_message);
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
line++;
menu_line(line++, COLOR_KILL_SCREEN_BG);
tft_string.set(GET_TEXT(MSG_HALTED));
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
menu_line(line++, COLOR_KILL_SCREEN_BG);
tft_string.set(GET_TEXT(MSG_PLEASE_RESET));
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
tft.queue.sync();
}
void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
MarlinImage image = imgHotEnd;
uint16_t Color;
float currentTemperature, targetTemperature;
if (Heater >= 0) { // HotEnd
currentTemperature = thermalManager.degHotend(Heater);
targetTemperature = thermalManager.degTargetHotend(Heater);
}
#if HAS_HEATED_BED
else if (Heater == H_BED) {
currentTemperature = thermalManager.degBed();
targetTemperature = thermalManager.degTargetBed();
}
#endif // HAS_HEATED_BED
#if HAS_TEMP_CHAMBER
else if (Heater == H_CHAMBER) {
currentTemperature = thermalManager.degChamber();
#if HAS_HEATED_CHAMBER
targetTemperature = thermalManager.degTargetChamber();
#else
targetTemperature = ABSOLUTE_ZERO;
#endif
}
#endif // HAS_TEMP_CHAMBER
else return;
TERN_(TOUCH_SCREEN, if (targetTemperature >= 0) touch.add_control(HEATER, x, y, 80, 120, Heater));
tft.canvas(x, y, 80, 120);
tft.set_background(COLOR_BACKGROUND);
Color = currentTemperature < 0 ? COLOR_INACTIVE : COLOR_COLD;
if (Heater >= 0) { // HotEnd
if (currentTemperature >= 50) Color = COLOR_HOTEND;
}
#if HAS_HEATED_BED
else if (Heater == H_BED) {
if (currentTemperature >= 50) Color = COLOR_HEATED_BED;
image = targetTemperature > 0 ? imgBedHeated : imgBed;
}
#endif // HAS_HEATED_BED
#if HAS_TEMP_CHAMBER
else if (Heater == H_CHAMBER) {
if (currentTemperature >= 50) Color = COLOR_CHAMBER;
image = targetTemperature > 0 ? imgChamberHeated : imgChamber;
}
#endif // HAS_TEMP_CHAMBER
tft.add_image(8, 28, image, Color);
tft_string.set((uint8_t *)i16tostr3rj(currentTemperature + 0.5));
tft_string.add(LCD_STR_DEGREE);
tft_string.trim();
tft.add_text(tft_string.center(80) + 2, 82, Color, tft_string);
if (targetTemperature >= 0) {
tft_string.set((uint8_t *)i16tostr3rj(targetTemperature + 0.5));
tft_string.add(LCD_STR_DEGREE);
tft_string.trim();
tft.add_text(tft_string.center(80) + 2, 8, Color, tft_string);
}
}
void draw_fan_status(uint16_t x, uint16_t y, const bool blink) {
TERN_(TOUCH_SCREEN, touch.add_control(FAN, x, y, 80, 120));
tft.canvas(x, y, 80, 120);
tft.set_background(COLOR_BACKGROUND);
uint8_t fanSpeed = thermalManager.fan_speed[0];
MarlinImage image;
if (fanSpeed >= 127)
image = blink ? imgFanFast1 : imgFanFast0;
else if (fanSpeed > 0)
image = blink ? imgFanSlow1 : imgFanSlow0;
else
image = imgFanIdle;
tft.add_image(8, 20, image, COLOR_FAN);
tft_string.set((uint8_t *)ui8tostr4pctrj(thermalManager.fan_speed[0]));
tft_string.trim();
tft.add_text(tft_string.center(80) + 6, 82, COLOR_FAN, tft_string);
}
void MarlinUI::draw_status_screen() {
const bool blink = get_blink();
TERN_(TOUCH_SCREEN, touch.clear());
// heaters and fan
uint16_t i, x, y = POS_Y;
for (i = 0 ; i < ITEMS_COUNT; i++) {
x = (TFT_WIDTH / ITEMS_COUNT - 80) / 2 + (TFT_WIDTH * i / ITEMS_COUNT);
switch (i) {
#ifdef ITEM_E0
case ITEM_E0: draw_heater_status(x, y, H_E0); break;
#endif
#ifdef ITEM_E1
case ITEM_E1: draw_heater_status(x, y, H_E1); break;
#endif
#ifdef ITEM_E2
case ITEM_E2: draw_heater_status(x, y, H_E2); break;
#endif
#ifdef ITEM_BED
case ITEM_BED: draw_heater_status(x, y, H_BED); break;
#endif
#ifdef ITEM_CHAMBER
case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break;
#endif
#ifdef ITEM_FAN
case ITEM_FAN: draw_fan_status(x, y, blink); break;
#endif
}
}
// coordinates
tft.canvas(4, 132, TFT_WIDTH - 8, 34);
tft.set_background(COLOR_BACKGROUND);
tft.add_rectangle(0, 0, TFT_WIDTH - 8, 34, COLOR_AXIS_HOMED);
uint16_t color;
uint16_t offset;
bool is_homed;
tft.add_text( 16, 3, COLOR_AXIS_HOMED , "X");
tft.add_text(192, 3, COLOR_AXIS_HOMED , "Y");
tft.add_text(330, 3, COLOR_AXIS_HOMED , "Z");
is_homed = TEST(axis_homed, X_AXIS);
tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft.add_text(102 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
is_homed = TEST(axis_homed, Y_AXIS);
tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft.add_text(280 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
is_homed = TEST(axis_homed, Z_AXIS);
if (blink & !is_homed) {
tft_string.set("?");
offset = 32; // ".00"
}
else {
const float z = LOGICAL_Z_POSITION(current_position.z);
tft_string.set(ftostr52sp((int16_t)z));
tft_string.rtrim();
offset = tft_string.width();
tft_string.set(ftostr52sp(z));
offset += 32 - tft_string.width();
}
tft.add_text(455 - tft_string.width() - offset, 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, 132, TFT_WIDTH - 8, 34));
// feed rate
tft.canvas(96, 180, 100, 32);
tft.set_background(COLOR_BACKGROUND);
color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
tft.add_image(0, 0, imgFeedRate, color);
tft_string.set(i16tostr3rj(feedrate_percentage));
tft_string.add('%');
tft.add_text(36, 1, color , tft_string);
TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 96, 176, 100, 32));
// flow rate
tft.canvas(284, 180, 100, 32);
tft.set_background(COLOR_BACKGROUND);
color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
tft.add_image(0, 0, imgFlowRate, color);
tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder]));
tft_string.add('%');
tft.add_text(36, 1, color , tft_string);
TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 284, 176, 100, 32, active_extruder));
// print duration
char buffer[14];
duration_t elapsed = print_job_timer.duration();
elapsed.toDigital(buffer);
tft.canvas((TFT_WIDTH - 128) / 2, 224, 128, 29);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(buffer);
tft.add_text(tft_string.center(128), 0, COLOR_PRINT_TIME, tft_string);
// progress bar
const uint8_t progress = ui.get_progress_percent();
tft.canvas(4, 260, TFT_WIDTH - 8, 9);
tft.set_background(COLOR_PROGRESS_BG);
tft.add_rectangle(0, 0, TFT_WIDTH - 8, 9, COLOR_PROGRESS_FRAME);
if (progress)
tft.add_bar(1, 1, ((TFT_WIDTH - 10) * progress) / 100, 7, COLOR_PROGRESS_BAR);
// status message
tft.canvas(0, 280, TFT_WIDTH, 29);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(status_message);
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_STATUS_MESSAGE, tft_string);
#if ENABLED(TOUCH_SCREEN)
add_control(404, 180, menu_main, imgSettings);
TERN_(SDSUPPORT, add_control(12, 180, menu_media, imgSD, card.isMounted() && !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED));
#endif
}
// Draw a static item with no left-right margin required. Centered by default.
void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
menu_item(row);
tft_string.set(pstr, itemIndex, itemString);
if (vstr)
tft_string.add(vstr);
tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_YELLOW, tft_string);
}
// Draw a generic menu item with pre_char (if selected) and post_char
void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char) {
menu_item(row, sel);
uint8_t *string = (uint8_t *)pstr;
MarlinImage image = noImage;
switch (*string) {
case 0x01: image = imgRefresh; break; // LCD_STR_REFRESH
case 0x02: image = imgDirectory; break; // LCD_STR_FOLDER
}
uint8_t offset = MENU_TEXT_X_OFFSET;
if (image != noImage) {
string++;
offset = 42;
tft.add_image(5, 5, image, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
}
tft_string.set(string, itemIndex, itemString);
tft.add_text(offset, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
}
// Draw a menu item with a (potentially) editable value
void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) {
menu_item(row, sel);
tft_string.set(pstr, itemIndex, itemString);
tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
if (data) {
tft_string.set(data);
tft.add_text(TFT_WIDTH - MENU_TEXT_X_OFFSET - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
}
}
// Low-level draw_edit_screen can be used to draw an edit screen from anyplace
void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
ui.encoder_direction_normal();
TERN_(TOUCH_SCREEN, touch.clear());
uint16_t line = 1;
menu_line(line++);
tft_string.set(pstr, itemIndex, itemString);
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
TERN_(AUTO_BED_LEVELING_UBL, if (ui.external_control) line++); // ftostr52() will overwrite *value so *value has to be displayed first
menu_line(line);
tft_string.set(value);
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
#if ENABLED(AUTO_BED_LEVELING_UBL)
if (ui.external_control) {
menu_line(line - 1);
tft_string.set(X_LBL);
tft.add_text((TFT_WIDTH / 2 - 120), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.x)));
tft_string.trim();
tft.add_text((TFT_WIDTH / 2 - 16) - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
tft_string.set(Y_LBL);
tft.add_text((TFT_WIDTH / 2 + 16), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.y)));
tft_string.trim();
tft.add_text((TFT_WIDTH / 2 + 120) - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
}
#endif
extern screenFunc_t _manual_move_func_ptr;
if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
#define SLIDER_LENGHT 336
#define SLIDER_Y_POSITION 186
tft.canvas((TFT_WIDTH - SLIDER_LENGHT) / 2, SLIDER_Y_POSITION, SLIDER_LENGHT, 16);
tft.set_background(COLOR_BACKGROUND);
int16_t position = (SLIDER_LENGHT - 2) * ui.encoderPosition / maxEditValue;
tft.add_bar(0, 7, 1, 2, ui.encoderPosition == 0 ? COLOR_SLIDER_INACTIVE : COLOR_SLIDER);
tft.add_bar(1, 6, position, 4, COLOR_SLIDER);
tft.add_bar(position + 1, 6, SLIDER_LENGHT - 2 - position, 4, COLOR_SLIDER_INACTIVE);
tft.add_bar(SLIDER_LENGHT - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE);
#if ENABLED(TOUCH_SCREEN)
tft.add_image((SLIDER_LENGHT - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER);
touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGHT) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGHT, 32, maxEditValue);
#endif
}
#if ENABLED(TOUCH_SCREEN)
add_control(64, 256, DECREASE, imgDecrease);
add_control(352, 256, INCREASE, imgIncrease);
add_control(208, 256, CLICK, imgConfirm);
#endif
}
// The Select Screen presents a prompt and two "buttons"
void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
uint16_t line = 1;
if (string == NULL) line++;
menu_line(line++);
tft_string.set(pref);
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
if (string) {
menu_line(line++);
tft_string.set(string);
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
}
if (suff) {
menu_line(line);
tft_string.set(suff);
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
}
#if ENABLED(TOUCH_SCREEN)
add_control(88, 256, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
add_control(328, 256, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM));
#endif
}
#if ENABLED(SDSUPPORT)
void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) {
menu_item(row, sel);
if (isDir)
tft.add_image(5, 5, imgDirectory, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
tft.add_text(42, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, theCard.longest_filename());
}
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
#if ENABLED(TOUCH_SCREEN)
touch.clear();
draw_menu_navigation = false;
touch.add_control(RESUME_CONTINUE , 0, 0, TFT_WIDTH, TFT_HEIGHT);
#endif
menu_line(row);
tft_string.set(GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE));
tft_string.add('E');
tft_string.add((char)('1' + extruder));
tft_string.add(' ');
tft_string.add(i16tostr3rj(thermalManager.degHotend(extruder)));
tft_string.add(LCD_STR_DEGREE);
tft_string.add(" / ");
tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
tft_string.add(LCD_STR_DEGREE);
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
}
#endif // ADVANCED_PAUSE_FEATURE
#if ENABLED(AUTO_BED_LEVELING_UBL)
#define GRID_OFFSET_X 8
#define GRID_OFFSET_Y 8
#define GRID_WIDTH 192
#define GRID_HEIGHT 192
#define CONTROL_OFFSET 16
void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
tft.canvas(GRID_OFFSET_X, GRID_OFFSET_Y, GRID_WIDTH, GRID_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft.add_rectangle(0, 0, GRID_WIDTH, GRID_HEIGHT, COLOR_WHITE);
for (uint16_t x = 0; x < GRID_MAX_POINTS_X ; x++)
for (uint16_t y = 0; y < GRID_MAX_POINTS_Y ; y++)
if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) }))
tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 2, 2, COLOR_UBL);
tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 6, 6, COLOR_UBL);
const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
lpos = pos.asLogical();
tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2 - 43, 120, 43);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(X_LBL);
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
tft_string.set(ftostr52(lpos.x));
tft_string.trim();
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2, 120, 43);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(Y_LBL);
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
tft_string.set(ftostr52(lpos.y));
tft_string.trim();
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2 + 43, 120, 43);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(Z_LBL);
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
tft_string.trim();
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - 48) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 5, 48, 43);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(ui8tostr3rj(x_plot));
tft_string.trim();
tft.add_text(tft_string.center(48), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET + 16 - 24, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2, 48, 43);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(ui8tostr3rj(y_plot));
tft_string.trim();
tft.add_text(tft_string.center(48), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
#if ENABLED(TOUCH_SCREEN)
touch.clear();
draw_menu_navigation = false;
add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgUp);
add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT - CONTROL_OFFSET - 32, UBL, - ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgDown);
add_control(GRID_OFFSET_X + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, - ENCODER_STEPS_PER_MENU_ITEM, imgLeft);
add_control(GRID_OFFSET_X + GRID_WIDTH - CONTROL_OFFSET - 32, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM, imgRight);
add_control(320, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, CLICK, imgLeveling);
add_control(224, 286, BACK, imgBack);
#endif
}
#endif // AUTO_BED_LEVELING_UBL
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
void MarlinUI::touch_calibration() {
static uint16_t x, y;
calibrationState calibration_stage = touch.get_calibration_state();
if (calibration_stage == CALIBRATION_NONE) {
defer_status_screen(true);
clear_lcd();
calibration_stage = touch.calibration_start();
}
else {
tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND);
}
x = 20; y = 20;
touch.clear();
if (calibration_stage < CALIBRATION_SUCCESS) {
switch (calibration_stage) {
case CALIBRATION_POINT_1: tft_string.set("Top Left"); break;
case CALIBRATION_POINT_2: y = TFT_HEIGHT - 21; tft_string.set("Bottom Left"); break;
case CALIBRATION_POINT_3: x = TFT_WIDTH - 21; tft_string.set("Top Right"); break;
case CALIBRATION_POINT_4: x = TFT_WIDTH - 21; y = TFT_HEIGHT - 21; tft_string.set("Bottom Right"); break;
default: break;
}
tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND);
tft.add_bar(0, 15, 31, 1, COLOR_TOUCH_CALIBRATION);
tft.add_bar(15, 0, 1, 31, COLOR_TOUCH_CALIBRATION);
touch.add_control(CALIBRATE, 0, 0, TFT_WIDTH, TFT_HEIGHT, uint32_t(x) << 16 | uint32_t(y));
}
else {
tft_string.set(calibration_stage == CALIBRATION_SUCCESS ? "Calibration Completed" : "Calibration Failed");
defer_status_screen(false);
touch.calibration_end();
touch.add_control(BACK, 0, 0, TFT_WIDTH, TFT_HEIGHT);
}
tft.canvas(0, (TFT_HEIGHT - tft_string.font_height()) >> 1, TFT_WIDTH, tft_string.font_height());
tft.set_background(COLOR_BACKGROUND);
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
}
#endif // TOUCH_SCREEN_CALIBRATION
void menu_line(const uint8_t row, uint16_t color) {
tft.canvas(0, 4 + 45 * row, TFT_WIDTH, 43);
tft.set_background(color);
}
void menu_pause_option();
void menu_item(const uint8_t row, bool sel ) {
#if ENABLED(TOUCH_SCREEN)
if (row == 0) {
touch.clear();
draw_menu_navigation = TERN(ADVANCED_PAUSE_FEATURE, ui.currentScreen != menu_pause_option, true);
}
#endif
menu_line(row, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
TERN_(TOUCH_SCREEN, touch.add_control(sel ? CLICK : MENU_ITEM, 0, 4 + 45 * row, TFT_WIDTH, 43, encoderTopLine + row));
}
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
#include "../../feature/babystep.h"
#endif
#if HAS_BED_PROBE
#include "../../module/probe.h"
#endif
#define Z_SELECTION_Z 1
#define Z_SELECTION_Z_PROBE -1
struct MotionAxisState {
xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos;
float currentStepSize = 10.0;
int z_selection = Z_SELECTION_Z;
uint8_t e_selection = 0;
bool homming = false;
bool blocked = false;
char message[32];
};
MotionAxisState motionAxisState;
#define E_BTN_COLOR COLOR_YELLOW
#define X_BTN_COLOR COLOR_CORAL_RED
#define Y_BTN_COLOR COLOR_VIVID_GREEN
#define Z_BTN_COLOR COLOR_LIGHT_BLUE
#define BTN_WIDTH 64
#define BTN_HEIGHT 52
#define X_MARGIN 20
#define Y_MARGIN 15
static void quick_feedback() {
#if HAS_CHIRP
ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
#if BOTH(HAS_LCD_MENU, USE_BEEPER)
for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
#elif HAS_LCD_MENU
delay(10);
#endif
#endif
}
#define CUR_STEP_VALUE_WIDTH 104
static void drawCurStepValue() {
tft_string.set((uint8_t *)ftostr52sp(motionAxisState.currentStepSize));
tft_string.add("mm");
tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string);
}
static void drawCurZSelection() {
tft_string.set("Z");
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34);
tft.set_background(COLOR_BACKGROUND);
tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
tft.queue.sync();
tft_string.set("Offset");
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34);
tft.set_background(COLOR_BACKGROUND);
if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
}
}
static void drawCurESelection() {
tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft_string.set("E");
tft.add_text(0, 0, E_BTN_COLOR , tft_string);
tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection));
}
static void drawMessage(const char *msg) {
tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34);
tft.set_background(COLOR_BACKGROUND);
tft.add_text(0, 0, COLOR_YELLOW, msg);
}
static void drawAxisValue(AxisEnum axis) {
const float value =
#if HAS_BED_PROBE
axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ?
probe.offset.z :
#endif
NATIVE_TO_LOGICAL(
ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset),
axis
);
xy_int_t pos;
uint16_t color;
switch (axis) {
case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break;
case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break;
case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break;
case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break;
default: return;
}
tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(ftostr52sp(value));
tft.add_text(0, 0, color, tft_string);
}
static void moveAxis(AxisEnum axis, const int8_t direction) {
quick_feedback();
if (axis == E_AXIS && thermalManager.temp_hotend[motionAxisState.e_selection].celsius < EXTRUDE_MINTEMP) {
drawMessage("Too cold");
return;
}
const float diff = motionAxisState.currentStepSize * direction;
if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
new_probe_offset = probe.offset.z + bsDiff,
new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
, do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff
, new_probe_offset
);
if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
babystep.add_steps(Z_AXIS, babystep_increment);
if (do_probe)
probe.offset.z = new_offs;
else
TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP);
drawMessage(""); // clear the error
drawAxisValue(axis);
}
else {
drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
}
#elif HAS_BED_PROBE
// only change probe.offset.z
probe.offset.z += diff;
if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) {
current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN;
drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
}
else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) {
current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX;
drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
}
else {
drawMessage(""); // clear the error
}
drawAxisValue(axis);
#endif
return;
}
if (!ui.manual_move.processing) {
// Start with no limits to movement
float min = current_position[axis] - 1000,
max = current_position[axis] + 1000;
// Limit to software endstops, if enabled
#if HAS_SOFTWARE_ENDSTOPS
if (soft_endstops_enabled) switch (axis) {
case X_AXIS:
TERN_(MIN_SOFTWARE_ENDSTOP_X, min = soft_endstop.min.x);
TERN_(MAX_SOFTWARE_ENDSTOP_X, max = soft_endstop.max.x);
break;
case Y_AXIS:
TERN_(MIN_SOFTWARE_ENDSTOP_Y, min = soft_endstop.min.y);
TERN_(MAX_SOFTWARE_ENDSTOP_Y, max = soft_endstop.max.y);
break;
case Z_AXIS:
TERN_(MIN_SOFTWARE_ENDSTOP_Z, min = soft_endstop.min.z);
TERN_(MAX_SOFTWARE_ENDSTOP_Z, max = soft_endstop.max.z);
default: break;
}
#endif // HAS_SOFTWARE_ENDSTOPS
// Delta limits XY based on the current offset from center
// This assumes the center is 0,0
#if ENABLED(DELTA)
if (axis != Z_AXIS && axis != E_AXIS) {
max = SQRT(sq((float)(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
min = -max;
}
#endif
// Get the new position
#if IS_KINEMATIC
ui.manual_move.offset += diff;
if (direction < 0)
NOLESS(ui.manual_move.offset, min - current_position[axis]);
else
NOMORE(ui.manual_move.offset, max - current_position[axis]);
#else
current_position[axis] += diff;
if (direction < 0 && current_position[axis] < min) {
current_position[axis] = min;
drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
}
else if (direction > 0 && current_position[axis] > max) {
current_position[axis] = max;
drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
}
else {
drawMessage(""); // clear the error
}
#endif
ui.manual_move.soon(axis
#if MULTI_MANUAL
, motionAxisState.e_selection
#endif
);
}
drawAxisValue(axis);
}
static void e_plus() {
moveAxis(E_AXIS, 1);
}
static void e_minus() {
moveAxis(E_AXIS, -1);
}
static void x_minus() {
moveAxis(X_AXIS, -1);
}
static void x_plus() {
moveAxis(X_AXIS, 1);
}
static void y_plus() {
moveAxis(Y_AXIS, 1);
}
static void y_minus() {
moveAxis(Y_AXIS, -1);
}
static void z_plus() {
moveAxis(Z_AXIS, 1);
}
static void z_minus() {
moveAxis(Z_AXIS, -1);
}
static void e_select() {
motionAxisState.e_selection++;
if (motionAxisState.e_selection >= EXTRUDERS) {
motionAxisState.e_selection = 0;
}
quick_feedback();
drawCurESelection();
drawAxisValue(E_AXIS);
}
static void do_home() {
quick_feedback();
drawMessage(GET_TEXT(MSG_LEVEL_BED_HOMING));
queue.inject_P(G28_STR);
// Disable touch until home is done
touch.disable();
drawAxisValue(E_AXIS);
drawAxisValue(X_AXIS);
drawAxisValue(Y_AXIS);
drawAxisValue(Z_AXIS);
}
static void step_size() {
motionAxisState.currentStepSize = motionAxisState.currentStepSize / 10.0;
if (motionAxisState.currentStepSize < 0.0015) motionAxisState.currentStepSize = 10.0;
quick_feedback();
drawCurStepValue();
}
#if HAS_BED_PROBE
static void z_select() {
motionAxisState.z_selection *= -1;
quick_feedback();
drawCurZSelection();
drawAxisValue(Z_AXIS);
}
#endif
static void disable_steppers() {
quick_feedback();
queue.inject_P(PSTR("M84"));
}
static void drawBtn(int x, int y, const char* label, int32_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) {
uint16_t width = Images[imgBtn52Rounded].width;
uint16_t height = Images[imgBtn52Rounded].height;
if (!enabled) bgColor = COLOR_CONTROL_DISABLED;
tft.canvas(x, y, width, height);
tft.set_background(COLOR_BACKGROUND);
tft.add_image(0, 0, imgBtn52Rounded, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY);
// TODO: Make an add_text() taking a font arg
if (label != NULL) {
tft_string.set(label);
tft_string.trim();
tft.add_text(tft_string.center(width), height / 2 - tft_string.font_height() / 2, bgColor, tft_string);
}
else {
tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY);
}
if (enabled) touch.add_control(BUTTON, x, y, width, height, data);
}
void MarlinUI::move_axis_screen() {
// Reset
defer_status_screen(true);
motionAxisState.blocked = false;
touch.enable();
ui.clear_lcd();
TERN_(TOUCH_SCREEN, touch.clear());
const bool busy = printingIsActive();
// if we have baby step and we are printing, select baby step
if (busy && ENABLED(BABYSTEP_ZPROBE_OFFSET)) motionAxisState.z_selection = Z_SELECTION_Z_PROBE;
// ROW 1 -> E- Y- CurY Z+
int x = X_MARGIN, y = Y_MARGIN, spacing = 0;
drawBtn(x, y, "E+", (int32_t)e_plus, imgUp, E_BTN_COLOR, !busy);
spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2;
x += BTN_WIDTH + spacing;
drawBtn(x, y, "Y+", (int32_t)y_plus, imgUp, Y_BTN_COLOR, !busy);
// Cur Y
x += BTN_WIDTH;
motionAxisState.yValuePos.x = x + 2;
motionAxisState.yValuePos.y = y;
drawAxisValue(Y_AXIS);
x += spacing;
drawBtn(x, y, "Z+", (int32_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step
// ROW 2 -> "Ex" X- HOME X+ "Z"
y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3;
x = X_MARGIN;
spacing = (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4;
motionAxisState.eNamePos.x = x;
motionAxisState.eNamePos.y = y;
drawCurESelection();
if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (int32_t)e_select);
x += BTN_WIDTH + spacing;
drawBtn(x, y, "X-", (int32_t)x_minus, imgLeft, X_BTN_COLOR, !busy);
x += BTN_WIDTH + spacing; //imgHome is 64x64
add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (int32_t)do_home, imgHome, !busy);
x += BTN_WIDTH + spacing;
uint16_t xplus_x = x;
drawBtn(x, y, "X+", (int32_t)x_plus, imgRight, X_BTN_COLOR, !busy);
x += BTN_WIDTH + spacing;
motionAxisState.zTypePos.x = x;
motionAxisState.zTypePos.y = y;
drawCurZSelection();
#if HAS_BED_PROBE
if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (int32_t)z_select);
#endif
// ROW 3 -> E- CurX Y- Z-
y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3;
x = X_MARGIN;
spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2;
drawBtn(x, y, "E-", (int32_t)e_minus, imgDown, E_BTN_COLOR, !busy);
// Cur E
motionAxisState.eValuePos.x = x;
motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2;
drawAxisValue(E_AXIS);
// Cur X
motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos
motionAxisState.xValuePos.y = y - 10;
drawAxisValue(X_AXIS);
x += BTN_WIDTH + spacing;
drawBtn(x, y, "Y-", (int32_t)y_minus, imgDown, Y_BTN_COLOR, !busy);
x += BTN_WIDTH + spacing;
drawBtn(x, y, "Z-", (int32_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step
// Cur Z
motionAxisState.zValuePos.x = x;
motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2;
drawAxisValue(Z_AXIS);
// ROW 4 -> step_size disable steppers back
y = TFT_HEIGHT - Y_MARGIN - 32; //
x = TFT_WIDTH / 2 - CUR_STEP_VALUE_WIDTH / 2;
motionAxisState.stepValuePos.x = x;
motionAxisState.stepValuePos.y = y;
if (!busy) {
drawCurStepValue();
touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (int32_t)step_size);
}
// alinged with x+
drawBtn(xplus_x, TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT, "off", (int32_t)disable_steppers, imgCancel, COLOR_WHITE, !busy);
add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack);
}
#undef BTN_WIDTH
#undef BTN_HEIGHT
#endif // HAS_UI_480x320
|
; A229439: Number of n X 2 0..2 arrays with horizontal differences mod 3 never 1, vertical differences mod 3 never -1, and rows and columns lexicographically nondecreasing.
; 4,7,13,25,47,84,142,228,350,517,739,1027,1393,1850,2412,3094,3912,4883,6025,7357,8899,10672,12698,15000,17602,20529,23807,27463,31525,36022,40984,46442,52428,58975,66117,73889,82327,91468,101350,112012,123494,135837,149083,163275,178457,194674,211972,230398,250000,270827,292929,316357,341163,367400,395122,424384,455242,487753,521975,557967,595789,635502,677168,720850,766612,814519,864637,917033,971775,1028932,1088574,1150772,1215598,1283125,1353427,1426579,1502657,1581738,1663900,1749222
add $0,3
mov $1,2
mul $1,$0
bin $0,4
add $1,$0
sub $1,2
mov $0,$1
|
SECTION code_clib
SECTION code_stdio
PUBLIC __stdio_recv_input_raw_eatc
EXTERN STDIO_MSG_EATC
EXTERN l_jpix, l_jphl
; ALL HIGH LEVEL STDIO INPUT PASSES THROUGH __STDIO_RECV_INPUT_RAW_*
; EXCEPT FOR VFSCANF. THIS ENSURES STREAM STATE IS CORRECTLY MAINTAINED
__stdio_recv_input_raw_eatc:
; Driver consumes chars from the stream, as qualified by ignore()
;
; enter : ix = FILE *
; hl'= int (*qualify)(char c)
; bc'= reserved
; de'= reserved
; hl = max_length = max number of stream chars to consume
;
; exit : ix = FILE *
; hl'= unchanged
; bc'= unchanged
; de'= unchanged
; bc = number of chars consumed from stream in this operation
; a = next unconsumed char (if error: 0 on stream error, -1 on eof)
;
; carry set on error or eof, stream state set appropriately
bit 3,(ix+3)
jr nz, immediate_stream_error
bit 4,(ix+3)
jr nz, immediate_eof_error
bit 0,(ix+4)
jr z, _no_ungetc_ec ; if no unget char available
; examine unget char
ld a,h
or l
jr z, _ungetc_rejected_ec ; if max_length is zero only provide peek
ld a,(ix+6) ; a = unget char
exx
call l_jphl ; qualify(a)
exx
jr c, _ungetc_rejected_ec
res 0,(ix+4) ; consume the unget char
dec hl ; max_length--
call _no_ungetc_ec
_post_ungetc:
inc bc ; num chars consumed in this operation++
ret
_ungetc_rejected_ec:
ld a,(ix+6) ; a = rejected unget char
ld bc,0 ; no chars consumed in this operation
or a ; indicate no error
ret
_no_ungetc_ec:
ld a,STDIO_MSG_EATC
call l_jpix
ld a,l
jr c, error_occurred
bit 5,(ix+3)
ret nz ; if driver manages ungetc
ld (ix+6),a ; write unconsumed char to ungetc spot
set 0,(ix+4) ; indicate ungetc is present
ret
error_occurred:
; stream error or eof ?
or a
jr z, stream_error
; eof is only an error if no chars were read
set 4,(ix+3) ; set stream state to eof
ld a,b
or c
ld a,$ff
ret nz ; if at least one char was read, indicate no error
scf
ret
stream_error:
set 3,(ix+3) ; set stream state to error
scf
ret
immediate_stream_error:
xor a
jr error_exit
immediate_eof_error:
ld a,$ff
error_exit:
ld bc,0
scf
ret
|
MODULE kbhit
SECTION code_clib
PUBLIC kbhit
PUBLIC _kbhit
PUBLIC getch
PUBLIC _getch
EXTERN getk
EXTERN fgetc_cons
kbhit:
_kbhit:
IF __CPU_GBZ80__
ld hl,kbhit_key
ld a,(hl+)
ld h,(hl)
ld l,a
or h
ret nz
call getk
ld de,kbhit_key
ld a,l
ld (de),a
inc de
ld a,h
ld (de),a
ld d,h
ld e,l
ret
ELSE
ld hl,(kbhit_key) ; check if we've got a keypress pending
ld a,h
or l
ret nz ; we've got something pending
call getk ; read the keyboard
ld (kbhit_key),hl
ret
ENDIF
getch:
_getch:
IF __CPU_GBZ80__
ld hl,kbhit_key
ld a,(hl+)
ld e,a
ld d,(hl)
xor a
ld (hl-),a
ld (hl),a
ld h,d
ld l,e
ELSE
ld hl,(kbhit_key)
ld de,0
IF __CPU_INTEL__
ex de,hl
ld (kbhit_key),hl
ex de,hl
ELSE
ld (kbhit_key),de
ENDIF
ENDIF
ld a,h
or l
ret nz ; consume that keypress
; We didn't have anything, lets just read the keyboard
call fgetc_cons
ret
SECTION bss_clib
kbhit_key: defw 0
|
; ================================================================
; Example source for target 'tap'
; Tape file for ZX Spectrum and Jupiter ACE
; Copyright (c) Günter Woigk 1994 - 2017
; mailto:kio@little-bat.de
; ================================================================
; fill byte is 0x00
; #code has an additional argument: the sync byte for the block.
; The assembler calculates and appends checksum byte to each segment.
; Note: If a segment is appended without an explicite address, then the sync byte and the checksum byte
; of the preceding segment are not counted when calculating the start address of this segment.
#target tap
; sync bytes:
headerflag: equ 0
dataflag: equ 0xff
; some Basic tokens:
tCLEAR equ $FD ; token CLEAR
tLOAD equ $EF ; token LOAD
tCODE equ $AF ; token CODE
tPRINT equ $F5 ; token PRINT
tRANDOMIZE equ $F9 ; token RANDOMIZE
tUSR equ $C0 ; token USR
pixels_start equ 0x4000 ; ZXSP screen pixels
attr_start equ 0x5800 ; ZXSP screen attributes
printer_buffer equ 0x5B00 ; ZXSP printer buffer
code_start equ 24000
; ---------------------------------------------------
; ram-based, non-initialized variables
; (note: 0x5B00 is the printer buffer)
; (note: system variables at 0x5C00 were initialized by Basic)
; ---------------------------------------------------
#data VARIABLES, printer_buffer, 0x100
; define some variables here
; ---------------------------------------------------
; a Basic Loader:
; ---------------------------------------------------
#code PROG_HEADER,0,17,headerflag
defb 0 ; Indicates a Basic program
defb "mloader " ; the block name, 10 bytes long
defw variables_end-0 ; length of block = length of basic program plus variables
defw 10 ; line number for auto-start, 0x8000 if none
defw program_end-0 ; length of the basic program without variables
#code PROG_DATA,0,*,dataflag
; ZX Spectrum Basic tokens
; 10 CLEAR 23999
defb 0,10 ; line number
defb end10-($+1) ; line length
defb 0 ; statement number
defb tCLEAR ; token CLEAR
defm "23999",$0e0000bf5d00 ; number 23999, ascii & internal format
end10: defb $0d ; line end marker
; 20 LOAD "" CODE 24000
defb 0,20 ; line number
defb end20-($+1) ; line length
defb 0 ; statement number
defb tLOAD,'"','"',tCODE ; token LOAD, 2 quotes, token CODE
defm "24000",$0e0000c05d00 ; number 24000, ascii & internal format
end20: defb $0d ; line end marker
; 30 RANDOMIZE USR 24000
defb 0,30 ; line number
defb end30-($+1) ; line length
defb 0 ; statement number
defb tRANDOMIZE,tUSR ; token RANDOMIZE, token USR
defm "24000",$0e0000c05d00 ; number 24000, ascii & internal format
end30: defb $0d ; line end marker
program_end:
; ZX Spectrum Basic variables
variables_end:
; ---------------------------------------------------
; a machine code block:
; ---------------------------------------------------
#code CODE_HEADER,0,17,headerflag
defb 3 ; Indicates binary data
defb "mcode " ; the block name, 10 bytes long
defw code_end-code_start ; length of data block which follows
defw code_start ; default location for the data
defw 0 ; unused
#code CODE_DATA, code_start,*,dataflag
; Z80 assembler code and data
; set print channel to Screen:
ld a,2
call $1601
; draw
ld hl,22528
ld a,12 ; set a to 12
loop: ld b,16
row1: ld (hl),0 ; odd row
inc hl
ld (hl),127
inc hl
djnz row1
ld b,16
row2: ld (hl),127 ; even row
inc hl
ld (hl),0
inc hl
djnz row2
dec a ; dec a
jr nz,loop
ret ; return
code_end:
|
#ifndef WSDLLEXER_HPP
#define WSDLLEXER_HPP
/* $Id: wsdllexer.hpp 546704 2017-09-20 18:15:56Z gouriano $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
*
* This software/database is a "United States Government Work" under the
* terms of the United States Copyright Act. It was written as part of
* the author's official duties as a United States Government employee and
* thus cannot be copyrighted. This software/database is freely available
* to the public for use. The National Library of Medicine and the U.S.
* Government have not placed any restriction on its use or reproduction.
*
* Although all reasonable efforts have been taken to ensure the accuracy
* and reliability of the software and data, the NLM and the U.S.
* Government do not and cannot warrant the performance or results that
* may be obtained by using this software or data. The NLM and the U.S.
* Government disclaim all warranties, express or implied, including
* warranties of performance, merchantability or fitness for any particular
* purpose.
*
* Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
* Author: Andrei Gourianov
*
* File Description:
* WSDL lexer
*
* ===========================================================================
*/
#include "xsdlexer.hpp"
BEGIN_NCBI_SCOPE
class WSDLLexer : public XSDLexer
{
public:
WSDLLexer(CNcbiIstream& in, const string& name);
virtual ~WSDLLexer(void);
void UseXSDLexer(bool use)
{
m_UseXsd = use;
}
protected:
virtual TToken LookupKeyword(void) override;
private:
bool m_UseXsd;
};
/////////////////////////////////////////////////////////////////////////////
// WSDLEntityLexer
class WSDLEntityLexer : public WSDLLexer
{
public:
WSDLEntityLexer(CNcbiIstream& in, const string& name, bool autoDelete=true);
virtual ~WSDLEntityLexer(void);
protected:
CNcbiIstream* m_Str;
bool m_AutoDelete;
};
END_NCBI_SCOPE
#endif // WSDLLEXER_HPP
|
/*
* #%L
* %%
* Copyright (C) 2011 - 2017 BMW Car IT GmbH
* %%
* 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.
* #L%
*/
#include "joynr/AbstractJoynrProvider.h"
#include <cassert>
#include "joynr/CallContextStorage.h"
#include "joynr/Util.h"
namespace joynr
{
AbstractJoynrProvider::AbstractJoynrProvider()
: lockAttributeListeners(),
lockBroadcastListeners(),
lockSelectiveBroadcastListeners(),
attributeListeners(),
broadcastListeners()
{
}
AbstractJoynrProvider::~AbstractJoynrProvider()
{
}
void AbstractJoynrProvider::registerAttributeListener(
const std::string& attributeName,
std::shared_ptr<SubscriptionAttributeListener> attributeListener)
{
WriteLocker locker(lockAttributeListeners);
attributeListeners[attributeName].push_back(std::move(attributeListener));
}
void AbstractJoynrProvider::unregisterAttributeListener(
const std::string& attributeName,
std::shared_ptr<SubscriptionAttributeListener> attributeListener)
{
WriteLocker locker(lockAttributeListeners);
std::vector<std::shared_ptr<SubscriptionAttributeListener>>& listeners =
attributeListeners[attributeName];
auto listenerIt = std::find(listeners.cbegin(), listeners.cend(), attributeListener);
assert(listenerIt != listeners.cend());
listeners.erase(listenerIt);
if (listeners.empty()) {
attributeListeners.erase(attributeName);
}
}
void AbstractJoynrProvider::registerBroadcastListener(
const std::string& broadcastName,
std::shared_ptr<UnicastBroadcastListener> broadcastListener)
{
WriteLocker locker(lockSelectiveBroadcastListeners);
selectiveBroadcastListeners[broadcastName].push_back(std::move(broadcastListener));
}
void AbstractJoynrProvider::registerBroadcastListener(
std::shared_ptr<MulticastBroadcastListener> broadcastListener)
{
WriteLocker locker(lockBroadcastListeners);
broadcastListeners.push_back(std::move(broadcastListener));
}
void AbstractJoynrProvider::unregisterBroadcastListener(
const std::string& broadcastName,
std::shared_ptr<UnicastBroadcastListener> broadcastListener)
{
WriteLocker locker(lockSelectiveBroadcastListeners);
std::vector<std::shared_ptr<UnicastBroadcastListener>>& listeners =
selectiveBroadcastListeners[broadcastName];
auto listenerIt = std::find(listeners.cbegin(), listeners.cend(), broadcastListener);
assert(listenerIt != listeners.cend());
listeners.erase(listenerIt);
if (listeners.empty()) {
selectiveBroadcastListeners.erase(broadcastName);
}
}
const CallContext& AbstractJoynrProvider::getCallContext() const
{
return CallContextStorage::get();
}
} // namespace joynr
|
/*
Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* HIT_START
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvidia
* TEST: %t
* HIT_END
*/
#include <assert.h>
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <random>
#include "hip/hip_runtime.h"
#include <hip/device_functions.h>
#define HIP_ASSERT(x) (assert((x) == hipSuccess))
#define TEST_DEBUG (0)
// CPU implementation of bitextract
template <typename T>
T bit_extract(T src0, unsigned int src1, unsigned int src2) {
unsigned int bits = sizeof(T) * 8;
T offset = src1 & (bits - 1);
T width = src2 & (bits - 1);
if (width == 0) {
return 0;
} else {
return (src0 << (bits - width - offset)) >> (bits - width);
}
}
__global__ void HIP_kernel(unsigned int* out32, unsigned int* in32_0,
unsigned int* in32_1, unsigned int* in32_2,
unsigned long long int* out64, unsigned long long int* in64_0,
unsigned int* in64_1, unsigned int* in64_2) {
int x = blockDim.x * blockIdx.x + threadIdx.x;
out32[x] = __bitextract_u32(in32_0[x], in32_1[x], in32_2[x]);
out64[x] = __bitextract_u64(in64_0[x], in64_1[x], in64_2[x]);
}
using namespace std;
int main() {
unsigned int* hostOut32;
unsigned int* hostSrc032;
unsigned int* hostSrc132;
unsigned int* hostSrc232;
unsigned long long int* hostOut64;
unsigned long long int* hostSrc064;
unsigned int* hostSrc164;
unsigned int* hostSrc264;
unsigned int* deviceOut32;
unsigned int* deviceSrc032;
unsigned int* deviceSrc132;
unsigned int* deviceSrc232;
unsigned long long int* deviceOut64;
unsigned long long int* deviceSrc064;
unsigned int* deviceSrc164;
unsigned int* deviceSrc264;
hipDeviceProp_t devProp;
hipGetDeviceProperties(&devProp, 0);
cout << " System minor " << devProp.minor << endl;
cout << " System major " << devProp.major << endl;
cout << " agent prop name " << devProp.name << endl;
cout << "hip Device prop succeeded " << endl;
unsigned int wave_size = devProp.warpSize;
unsigned int num_waves_per_block = 2;
unsigned int num_threads_per_block = wave_size * num_waves_per_block;
unsigned int num_blocks = 2;
unsigned int NUM = num_threads_per_block * num_blocks;
int i;
int errors;
hostOut32 = (unsigned int*)malloc(NUM * sizeof(unsigned int));
hostSrc032 = (unsigned int*)malloc(NUM * sizeof(unsigned int));
hostSrc132 = (unsigned int*)malloc(NUM * sizeof(unsigned int));
hostSrc232 = (unsigned int*)malloc(NUM * sizeof(unsigned int));
hostOut64 = (unsigned long long int*)malloc(NUM * sizeof(unsigned long long int));
hostSrc064 = (unsigned long long int*)malloc(NUM * sizeof(unsigned long long int));
hostSrc164 = (unsigned int*)malloc(NUM * sizeof(unsigned int));
hostSrc264 = (unsigned int*)malloc(NUM * sizeof(unsigned int));
// initialize the input data
std::random_device rd;
std::uniform_int_distribution<uint32_t> uint32_src0_dist;
std::uniform_int_distribution<uint32_t> uint32_src12_dist(0,31);
std::uniform_int_distribution<uint64_t> uint64_src0_dist;
std::uniform_int_distribution<uint32_t> uint64_src12_dist(0,63);
for (i = 0; i < NUM; i++) {
hostOut32[i] = 0;
hostSrc032[i] = uint32_src0_dist(rd);
hostSrc132[i] = uint32_src12_dist(rd);
hostSrc232[i] = uint32_src12_dist(rd);
if (hostSrc132[i] + hostSrc232[i] > 32)
hostSrc232[i] = 32 - hostSrc132[i];
hostOut64[i] = 0;
hostSrc064[i] = uint64_src0_dist(rd);
hostSrc164[i] = uint64_src12_dist(rd);
hostSrc264[i] = uint64_src12_dist(rd);
}
HIP_ASSERT(hipMalloc((void**)&deviceOut32, NUM * sizeof(unsigned int)));
HIP_ASSERT(hipMalloc((void**)&deviceSrc032, NUM * sizeof(unsigned int)));
HIP_ASSERT(hipMalloc((void**)&deviceSrc132, NUM * sizeof(unsigned int)));
HIP_ASSERT(hipMalloc((void**)&deviceSrc232, NUM * sizeof(unsigned int)));
HIP_ASSERT(hipMalloc((void**)&deviceOut64, NUM * sizeof(unsigned long long int)));
HIP_ASSERT(hipMalloc((void**)&deviceSrc064, NUM * sizeof(unsigned long long int)));
HIP_ASSERT(hipMalloc((void**)&deviceSrc164, NUM * sizeof(unsigned int)));
HIP_ASSERT(hipMalloc((void**)&deviceSrc264, NUM * sizeof(unsigned int)));
HIP_ASSERT(hipMemcpy(deviceSrc032, hostSrc032, NUM * sizeof(unsigned int), hipMemcpyHostToDevice));
HIP_ASSERT(hipMemcpy(deviceSrc132, hostSrc132, NUM * sizeof(unsigned int), hipMemcpyHostToDevice));
HIP_ASSERT(hipMemcpy(deviceSrc232, hostSrc232, NUM * sizeof(unsigned int), hipMemcpyHostToDevice));
HIP_ASSERT(hipMemcpy(deviceSrc064, hostSrc064, NUM * sizeof(unsigned long long int),
hipMemcpyHostToDevice));
HIP_ASSERT(hipMemcpy(deviceSrc164, hostSrc164, NUM * sizeof(unsigned int), hipMemcpyHostToDevice));
HIP_ASSERT(hipMemcpy(deviceSrc264, hostSrc264, NUM * sizeof(unsigned int), hipMemcpyHostToDevice));
hipLaunchKernelGGL(HIP_kernel, dim3(num_blocks), dim3(num_threads_per_block),
0, 0,
deviceOut32, deviceSrc032, deviceSrc132, deviceSrc232,
deviceOut64, deviceSrc064, deviceSrc164, deviceSrc264);
HIP_ASSERT(hipMemcpy(hostOut32, deviceOut32, NUM * sizeof(unsigned int), hipMemcpyDeviceToHost));
HIP_ASSERT(hipMemcpy(hostOut64, deviceOut64,
NUM * sizeof(unsigned long long int), hipMemcpyDeviceToHost));
// verify the results
errors = 0;
for (i = 0; i < NUM; i++) {
if (hostOut32[i] != bit_extract<uint32_t>(hostSrc032[i], hostSrc132[i], hostSrc232[i])) {
errors++;
#if TEST_DEBUG
cout << "device: " << hostOut32[i] << " host: "
<< bit_extract<uint32_t>(hostSrc032[i], hostSrc132[i], hostSrc232[i])
<< " " << hostSrc032[i] << " " << hostSrc132[i] << " " << hostSrc232[i] << "\n";
#endif
}
}
if (errors != 0) {
cout << "__bitextract_u32() FAILED\n" << endl;
return -1;
} else {
cout << "__bitextract_u32() checked!" << endl;
}
errors = 0;
for (i = 0; i < NUM; i++) {
if (hostOut64[i] != bit_extract<uint64_t>(hostSrc064[i], hostSrc164[i], hostSrc264[i])) {
errors++;
#if TEST_DEBUG
cout << "device: " << hostOut64[i] << " host: "
<< bit_extract<uint64_t>(hostSrc064[i], hostSrc164[i], hostSrc264[i])
<< " " << hostSrc064[i] << " " << hostSrc164[i] << " " << hostSrc264[i] << "\n";
#endif
}
}
if (errors != 0) {
cout << "__bitextract_u64() FAILED" << endl;
return -1;
} else {
cout << "__bitextract_u64() checked!" << endl;
}
cout << "__bitextract_u32() and __bitextract_u64() PASSED!" << endl;
HIP_ASSERT(hipFree(deviceOut32));
HIP_ASSERT(hipFree(deviceSrc032));
HIP_ASSERT(hipFree(deviceSrc132));
HIP_ASSERT(hipFree(deviceSrc232));
HIP_ASSERT(hipFree(deviceOut64));
HIP_ASSERT(hipFree(deviceSrc064));
HIP_ASSERT(hipFree(deviceSrc164));
HIP_ASSERT(hipFree(deviceSrc264));
free(hostOut32);
free(hostSrc032);
free(hostSrc132);
free(hostSrc232);
free(hostOut64);
free(hostSrc064);
free(hostSrc164);
free(hostSrc264);
return errors;
}
|
processor 6502
include "vcs.h"
include "macro.h"
seg code
org $F000
Start:
CLEAN_START ; macro to safely clear memory and TIA
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Start a new frame by turning on VBLANK and VSYNC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
NextFrame:
lda #2 ; same as binary value %00000010
sta VBLANK ; turn on VBLANK
sta VSYNC ; turn on VSYNC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Generate the three lines of VSYNC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sta WSYNC ; first scanline
sta WSYNC ; second scanline
sta WSYNC ; third scanline
lda #0
sta VSYNC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Let the TIA output the recommended 37 scanlines of VBLANK
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ldx #37 ; X = 37 (to count 37 scanlines)
LoopVBlank:
sta WSYNC ; hit WSYNC and wait for the next scanline
dex ; X--
bne LoopVBlank ; loop while X != 0
lda #0
sta VBLANK ; turn off VBLANK
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Draw 192 visible scanlines (kernel)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ldx #192 ; counter for 192 visible scanlines
LoopScanline:
stx COLUBK ; set the background color
sta WSYNC ; wait for the next scanline
dex ; X--
bne LoopScanline ; loop while X != 192
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Output 30 more VBLANK lines (overscan) to complete our frame
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
lda #2 ; hit and turn on VBLANK again
sta VBLANK
ldx #30 ; counter for 30 scanlines
LoopOverscan:
sta VBLANK ; wait for the next scanline
dex ; X--
bne LoopOverscan ; loop while X != 0
jmp NextFrame
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Complete my ROM size to 4KB
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org $FFFC
.word Start
.word Start |
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r8
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x8e8a, %r8
nop
nop
nop
nop
xor $14964, %r12
mov (%r8), %r14d
nop
nop
nop
sub $48196, %r14
lea addresses_normal_ht+0x1d5aa, %rsi
lea addresses_D_ht+0x2e5c, %rdi
nop
nop
cmp %r14, %r14
mov $79, %rcx
rep movsq
nop
xor %rdi, %rdi
lea addresses_normal_ht+0x1e8a, %rcx
nop
cmp %rbx, %rbx
vmovups (%rcx), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %rdi
nop
nop
inc %rsi
lea addresses_WC_ht+0x1e68a, %r14
nop
sub %rbx, %rbx
vmovups (%r14), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %rcx
nop
nop
nop
nop
nop
add $63178, %r8
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r9
push %rbp
push %rdi
push %rdx
// Store
lea addresses_RW+0x1648a, %r11
nop
nop
nop
nop
dec %rdx
movw $0x5152, (%r11)
nop
nop
nop
nop
xor %r10, %r10
// Store
mov $0x68a, %r9
nop
nop
nop
nop
nop
xor $25509, %rdx
movw $0x5152, (%r9)
cmp %r10, %r10
// Store
lea addresses_RW+0x1b86a, %rdi
nop
nop
nop
add $34713, %r9
movw $0x5152, (%rdi)
nop
nop
nop
and %r10, %r10
// Load
lea addresses_A+0x3e8a, %r11
nop
cmp %rbp, %rbp
mov (%r11), %r10w
add %r11, %r11
// Store
lea addresses_WC+0x184ca, %r9
nop
nop
nop
sub %r10, %r10
mov $0x5152535455565758, %r13
movq %r13, %xmm0
vmovups %ymm0, (%r9)
and $19333, %rdx
// Load
lea addresses_RW+0x19d99, %rbp
nop
nop
nop
cmp %r9, %r9
mov (%rbp), %rdi
nop
dec %rdx
// Store
lea addresses_A+0x1a28a, %rdx
nop
nop
nop
nop
nop
xor $49792, %rdi
mov $0x5152535455565758, %r10
movq %r10, %xmm4
movups %xmm4, (%rdx)
nop
nop
nop
nop
nop
sub $22074, %rbp
// Faulty Load
lea addresses_A+0x3e8a, %rbp
nop
nop
nop
nop
xor $13168, %r11
mov (%rbp), %dx
lea oracles, %r11
and $0xff, %rdx
shlq $12, %rdx
mov (%r11,%rdx,1), %rdx
pop %rdx
pop %rdi
pop %rbp
pop %r9
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_RW', 'same': False, 'size': 2, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_P', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_RW', 'same': False, 'size': 2, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WC', 'same': False, 'size': 32, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_RW', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A', 'same': True, 'size': 16, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 9, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'same': True, 'size': 32, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'00': 72}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; A008455: 11th powers: a(n) = n^11.
; 0,1,2048,177147,4194304,48828125,362797056,1977326743,8589934592,31381059609,100000000000,285311670611,743008370688,1792160394037,4049565169664,8649755859375,17592186044416,34271896307633,64268410079232,116490258898219,204800000000000,350277500542221,584318301411328,952809757913927,1521681143169024,2384185791015625,3670344486987776,5559060566555523,8293509467471872,12200509765705829,17714700000000000,25408476896404831,36028797018963968,50542106513726817,70188843638032384,96549157373046875
pow $0,11
|
; Add two positive floating-point numbers
; In: HL,DE numbers to add
; Out: HL = sum HL + DE
; Pollutes: AF,DE
FADDP: CALL FCPP
JR NC,FADDPX
EX DE,HL
; Continue with FADDPX
; Add two positive floating-point numbers
; In: HL,DE numbers to add, HL >= DE
; Out: HL = sum HL + DE
; Pollutes: AF,DE
FADDPX: LD A,H
SUB D
JR Z,FADD0 ; same magnitude, cleared C flag
CP 10
JR C,FADDL ; magnitude too different, just return the bigger number
RET
FADDL0: AND A
FADDL: RR E
DEC A
JR NZ,FADDL0
LD A,L
ADC A,E ; rounding
LD L,A
RET NC
SRL A
FADD1: ADC A,0 ; rounding
LD L,A
INC H
BIT 7,H ; check overflow
RET Z
FINFTY: LD HL,MAXF ; positive maxfloat
RET
FADD0: LD A,L
ADD A,E
RRA
JR FADD1
; Round towards zero
; In: HL any floating-point number
; Out: HL same number rounded towards zero
; Pollutes: AF,B
FINT: LD A,H
AND $7F
SUB $40
JR C,FZERO ; Completely fractional
FINT2: SUB 8
RET NC ; Already integer
NEG
AND 7
JR Z,FINT0
LD B,A
LD A,$FF
FINTL: ADD A,A
DJNZ FINTL
AND L
FINT0: LD L,A
RET
FZERO: LD HL,MINF
RET
; Fractional part, remainder after division by 1
; In: HL any floating-point number
; Out: HL fractional part, with sign intact
; Pollutes: AF,AF',BC,DE
FRAC: LD A,H
AND $7F
SUB $40
RET C ; Pure fraction
PUSH HL
CALL FINT2
EX DE,HL
POP HL
JR FSUB
; Remainder after division
; In: BC dividend, HL modulus
; Out: HL remainder
; Pollutes: AF,AF',BC,DE
FMOD: PUSH BC ; Stack: dividend
PUSH HL ; Stack: dividend, modulus
CALL FDIV
CALL FINT ; integer ratio
EX DE,HL ; DE = int(BC/HL)
POP BC ; Stack: dividend; BC = modulus
CALL FMUL ; Stack: dividend
EX DE,HL
POP HL
; continue with FSUB
; Subtract two floating-point numbers
; In: HL,DE numbers to subtract, no restrictions
; Out: HL = difference HL - DE
; Pollutes: AF,AF',BC,DE
FSUB: LD A,D
XOR $80
LD D,A ; DE = -DE
; continue with FADD
; Add two floating-point numbers
; In: HL,DE numbers to add, no restrictions
; Out: HL = sum HL + DE
; Pollutes: AF,AF',BC,DE
FADD: LD B,H
LD C,D
LD A,B
XOR C
ADD A,A
EX AF,AF'
RES 7,H
RES 7,D
CALL FCPP
JR NC,FADDNS ; no swap
EX DE,HL
LD B,C
FADDNS: EX AF,AF'
JR C,FADDS
CALL FADDPX
JR FADDHB
FADDS: CALL FSUBP
FADDHB: LD A,B
AND $80
OR H
LD H,A
RET
; Compare two positive floating point numbers
; In: HL,DE numbers to compare
; Out: C flag if DE>HL, Z flag if DE=HL
; Pollutes: A
FCPP: LD A,H
CP D
RET NZ
LD A,L
CP E
RET
; Subtract two positive floating-point numbers
; In: HL,DE numbers to subtract, HL >= DE
; Out: HL = difference HL - DE
; Pollutes: AF,DE
FSUBP: LD A,H
SUB D
JR Z,FSUB0 ; same magnitude, cleared C flag
CP 10
RET NC ; magnitude too different, just return the bigger number
LD D,1
FSUBL: RR E
SUB D
JR NZ,FSUBL
LD A,L
SBC A,E ; rounding
LD L,A
JR C,FSUBL2
RET
FSUB0: LD A,L
SUB A,E
JR Z,FZERO2
FSUBL2: DEC H
BIT 7,H
JR NZ,FZERO2
ADD A,A
JR NC,FSUBL2
LD L,A
RET
; Return epsilon
FZERO2: LD HL,MINF
RET
|
; A003434: Number of iterations of phi(x) at n needed to reach 1.
; 0,1,2,2,3,2,3,3,3,3,4,3,4,3,4,4,5,3,4,4,4,4,5,4,5,4,4,4,5,4,5,5,5,5,5,4,5,4,5,5,6,4,5,5,5,5,6,5,5,5,6,5,6,4,6,5,5,5,6,5,6,5,5,6,6,5,6,6,6,5,6,5,6,5,6,5,6,5,6,6,5,6,7,5,7,5,6,6,7,5,6,6,6,6,6,6,7,5,6,6,7,6,7,6,6,6,7,5,6,6,6,6,7,5,7,6,6,6,7,6,7,6,7,6,7,5,6,7,6,6,7,6,6,6,6,7,8,6,7,6,7,6,7,6,7,6,6,6,7,6,7,6,7,6,7,6,7,6,7,7,7,5,6,7,7,7,8,6,7,7,6,6,7,6,7,7,7,7,8,6,7,6,7,7,7,6,8,7,6,6,7,7,8,7,7,6,7,6,7,7,7,7,7,7,8,7,7,7,7,6,7,7,7,7,7,6,7,6,7,7,8,6,7,7,7,7,8,6,7,7,7,7,8,6,8,7,7,7,8,7,8,7,6,7,7,7,7,7,8,7
lpb $0
cal $0,10 ; Euler totient function phi(n): count numbers <= n and prime to n.
sub $0,1
add $1,1
lpe
|
#include<stdio.h>
int main(){
int i,j,k,t;
freopen("B-large.in","r",stdin);
freopen("out.txt","w",stdout);
double c,f,x,add=0,sum=0,plus,inc;
for(scanf("%d",&t),k=1;k<=t;k++){
scanf("%lf%lf%lf",&c,&f,&x);
sum = x/2.0;
add=0;
plus=0;
inc=2.0;
while(1){
add+=c/inc;
inc+=f;
plus = add + x/inc;
if(sum>plus){
sum = plus;
}else break;
}
printf("Case #%d: %.7lf\n",k,sum);
}
return 0;
}
|
%ifdef CONFIG
{
"RegData": {
"RAX": "0x8300",
"RDI": "0xE0000007",
"RSI": "0xDFFFFFFF"
},
"MemoryRegions": {
"0x100000000": "4096"
}
}
%endif
mov rdx, 0xe0000000
mov rax, 0x61
mov [rdx + 8 * 0], rax
mov rax, 0x47
mov [rdx + 8 * 1], rax
lea rdi, [rdx + 8 * 1]
lea rsi, [rdx + 8 * 0]
std
cmpsb ; rdi cmp rsi
; cmp = 0x47 - 0x61 = 0xE6
; 0: CF - 00000001
; 1: - 00000010
; 2: PF - 00000000
; 3: 0 - 00000000
; 4: AF - 00000000
; 5: 0 - 00000000
; 6: ZF - 00000000
; 7: SF - 10000000
; ================
; 10000011
; OF: LAHF doesn't load - 0
mov rax, 0
lahf
hlt
|
; The MIT License (MIT)
;
; Copyright (c) 2018 Jiri Sramek (https://github.com/JiriS97/)
;
; Permission is hereby granted, free of charge, to any person obtaining a copy
; of this software and associated documentation files (the "Software"), to deal
; in the Software without restriction, including without limitation the rights
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the Software is
; furnished to do so, subject to the following conditions:
;
; The above copyright notice and this permission notice shall be included in
; all copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
; THE SOFTWARE.
; This project calculates the circumference of a rectangle
; export symbols
XDEF calculateCircumference
; Include derivative-specific definitions
INCLUDE 'derivative.inc'
; variable/data section
MY_ZEROPAGE: SECTION SHORT
; Insert here your data definition. For demonstration, temp_byte is used.
temp_byte: DS.B 1
; code section
MyCode: SECTION
; this assembly routine is called the C/C++ application
asm_main:
MOV #1,temp_byte ; just some demonstration code
NOP ; Insert here your own code
RTS ; return to caller
;width -> stack
;length -> H:X
;obvod -> H:X
calculateCircumference:
;LDA 4,SP
;ADD ,X ;nejde?
;length+width
PSHX ;X -> SP
PULA ;SP -> A
ADD 4,SP ;add LOW byte of length
PSHA ;store on stack
PSHH ;H -> SP
PULA ;SP -> A
ADC 4,SP ;add HIGH byte of length (offset 3+1 stored)
PSHA ;store on stack
;*2
LSL 2,SP ;rotate LOW byte of result left
ROL 1,SP ;rotate HIGH byte of result left with carry
LDHX 1,SP ;load H:X from stack
AIS #2 ;delete result from stack
RTS ;return
|
;
; display a pretty hex dump of registers & stack for debugging.
;
%define module crash
%include "api.macro"
section .text
; name, y, x, offset
%macro dumpreg 4
mov edx, (%2 << 8) + %3
call vga_compute
mov ecx, %1
mov eax, [reg_stack_top - %4]
call dump_register
%endmacro
; never returns.
global crash
crash:
mov [saved_esp], esp
mov esp, reg_stack_top
; EAX, ECX, EDX, EBX, ESP (original value), EBP, ESI, and EDI:
pushad
pushfd
mov eax, [saved_esp]
mov [reg_stack_top - 20], eax
; blank 12 lines for crash dump
mov eax, 12
.clear_loop:
call vga_blank_line
inc eax
cmp eax, 23
jle .clear_loop
; is there turkey?
mov edx, 0x0c01
call vga_compute
mov ecx, 'no t'
call vga_put_small
mov ecx, 'urke'
call vga_put_small
mov ecx, 'y :('
call vga_put_small
; display 8 main regs + eflags
dumpreg ' A:', 14, 2, 4
dumpreg ' B:', 15, 2, 16
dumpreg ' C:', 16, 2, 8
dumpreg ' D:', 17, 2, 12
dumpreg 'DI:', 18, 2, 32
dumpreg 'SI:', 19, 2, 28
dumpreg 'BP:', 20, 2, 24
dumpreg 'SP:', 21, 2, 20
dumpreg ' F:', 22, 2, 36
mov esi, [reg_stack_top - 20]
; round down to nearest paragraph
and esi, 0xfffffff0
; draw 9 lines
mov ecx, 0
.loop:
mov edx, ecx
shl edx, 8
add edx, 0x0e14
call vga_compute
call dump_memory_row
inc ecx
cmp ecx, 9
jl .loop
; display crash reason, if one was set.
mov edx, (12 << 8) + 75
call vga_compute
mov ecx, [crash_reason]
call vga_put_small
; die.
cli
hlt
; display a register (eax) named (ecx) at (edi)
dump_register:
call vga_put_small
add edi, 2
call vga_dump_eax
ret
; display a row of memory contents (esi) at (edi)
dump_memory_row:
push eax
push ebx
push ecx
mov eax, esi
call vga_dump_eax
mov ecx, ': '
call vga_put_small
mov ebx, 4
.loop:
cmp esi, [reg_stack_top - 20]
jne .no_highlight
mov ecx, 8
call vga_highlight
.no_highlight:
mov eax, [esi]
call vga_dump_eax
mov ecx, ' '
call vga_put_small
add esi, 4
dec ebx
cmp ebx, 0
jne .loop
.out:
pop ecx
pop ebx
pop eax
ret
section .bss
align 4
reg_stack:
resb 16 * 4
reg_stack_top:
section .data
saved_esp: dd 0
global crash_reason
crash_reason: dd 0
|
;init code for SNES
;much borrowed from Damian Yerrick
;some borrowed from Oziphantom
.p816
.smart
.segment "CODE"
RESET:
sei ; turn off IRQs
clc
xce ; turn off 6502 emulation mode
rep #$38 ;AXY16 and clear decimal mode.
ldx #$1fff
txs ; set the stack pointer
phk
plb ;set b to current bank, 00
; Initialize the CPU I/O registers to predictable values
lda #$4200
tcd ; temporarily move direct page to S-CPU I/O area
lda #$FF00
sta $00
stz $00
stz $02
stz $04
stz $06
stz $08
stz $0A
stz $0C
; Initialize the PPU registers to predictable values
lda #$2100
tcd ; temporarily move direct page to PPU I/O area
; first clear the regs that take a 16-bit write
lda #$0080
sta $00 ; Enable forced blank
stz $02
stz $05
stz $07
stz $09
stz $0B
stz $16
stz $24
stz $26
stz $28
stz $2A
stz $2C
stz $2E
ldx #$0030
stx $30 ; Disable color math
ldy #$00E0
sty $32 ; Clear red, green, and blue components of COLDATA
; also 0 to 2133, normal video at 224 pixels high
; now clear the regs that need 8-bit writes
A8
sta $15 ; still $80: Inc VRAM pointer after high byte write
stz $1A
stz $21
stz $23 ;window, 24,25 above
; The scroll registers $210D-$2114 need double 8-bit writes
.repeat 8, I
stz $0D+I
stz $0D+I
.endrepeat
; As do the mode 7 registers, which we set to the identity matrix
; [ $0100 $0000 ]
; [ $0000 $0100 ]
lda #$01
stz $1B
sta $1B
stz $1C
stz $1C
stz $1D
stz $1D
stz $1E
sta $1E
stz $1F
stz $1F
stz $20
stz $20
AXY16
lda #$0000
tcd ; return direct page to real zero page
;the next 17 lines adapted from code by Oziphantom
Clear_WRAM2:
A16
XY8
stz $2181 ;WRAM_ADDR_L
stz $2182 ;WRAM_ADDR_M
lda #$8008 ;fixed transfer to WRAM data 2180
sta $4300 ; and 4301
lda #.loword(DMAZero)
sta $4302 ; and 4303
ldx #^DMAZero ;bank #
stx $4304
stz $4305 ;and 4306 = size 0000 = $10000
ldx #1
stx $420B ; DMA_ENABLE, clear the 1st half of WRAM
stx $420B ; DMA_ENABLE, clear the 2nd half of WRAM
A8
XY16
;all jsl, all rtl
jsl Clear_Palette
;it will dma at NMI
jsl OAM_Clear
;it will dma at NMI
jsl Clear_VRAM
jsl Reset_VRAM_System
; just in case
; A8
lda #1
sta $420d ;fastROM
AXY16
jml Main ;should jump into the $80 bank, fast ROM
;we are still in forced blank, main code will have to turn the screen on
;some code below adapted from code by Oziphantom
Clear_Palette:
;fills the buffer with zeros
php
A8
XY16
ldx #.loword(PAL_BUFFER)
stx $2181 ;WRAM_ADDR_L
stz $2183 ;WRAM_ADDR_H
ldx #$8008 ;fixed transfer to WRAM data 2180
stx $4300 ; and 4301
ldx #.loword(DMAZero)
stx $4302 ; and 4303
lda #^DMAZero ;bank #
sta $4304
ldx #$200 ;512 bytes
stx $4305 ; and 4306
lda #1
sta $420B ; DMA_ENABLE start dma, channel 0
inc pal_update
plp
rtl ;changed for consistency
Clear_VRAM:
php
A16
XY8
ldx #$80
stx $2115 ;VRAM increment mode +1, after the 2119 write
stz $2116 ;VRAM Address
stz $4305 ; size $10000 bytes ($8000 words)
lda #$1809 ;fixed transfer (2 reg, write once) to VRAM_DATA $2118-19
sta $4300 ; and 4301
lda #.loword(DMAZero)
sta $4302 ; and 4303
ldx #^DMAZero ;bank #
stx $4304
ldx #1
stx $420B ; DMA_ENABLE start dma, channel 0
plp
rtl ;changed for consistency
DMAZero:
.word $0000
|
;********************************************************************************************************
; uC/LIB
; CUSTOM LIBRARY MODULES
;
; (c) Copyright 2004-2015; Micrium, Inc.; Weston, FL
;
; All rights reserved. Protected by international copyright laws.
;
; uC/LIB is provided in source form to registered licensees ONLY. It is
; illegal to distribute this source code to any third party unless you receive
; written permission by an authorized Micrium representative. Knowledge of
; the source code may NOT be used to develop a similar product.
;
; Please help us continue to provide the Embedded community with the finest
; software available. Your honesty is greatly appreciated.
;
; You can contact us at www.micrium.com.
;********************************************************************************************************
;********************************************************************************************************
;
; STANDARD MEMORY OPERATIONS
;
; ARM-Cortex-M4
; IAR Compiler
;
; Filename : lib_mem_a.asm
; Version : V1.38.02.00
; Programmer(s) : JDH
; BAN
;********************************************************************************************************
; Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
;
; (a) ALL standard library functions are implemented in the custom library modules :
;
; (1) \<Custom Library Directory>\lib*.*
;
; (2) \<Custom Library Directory>\Ports\<cpu>\<compiler>\lib*_a.*
;
; where
; <Custom Library Directory> directory path for custom library software
; <cpu> directory name for specific processor (CPU)
; <compiler> directory name for specific compiler
;
; (b) Product-specific library functions are implemented in individual products.
;
; (2) Assumes ARM CPU mode configured for Little Endian.
;********************************************************************************************************
;********************************************************************************************************
; PUBLIC FUNCTIONS
;********************************************************************************************************
PUBLIC Mem_Copy
;********************************************************************************************************
; CODE GENERATION DIRECTIVES
;********************************************************************************************************
RSEG CODE:CODE:NOROOT(2)
;********************************************************************************************************
; Mem_Copy()
;
; Description : Copy data octets from one buffer to another buffer.
;
; Argument(s) : pdest Pointer to destination memory buffer.
;
; psrc Pointer to source memory buffer.
;
; size Number of data buffer octets to copy.
;
; Return(s) : none.
;
; Caller(s) : Application.
;
; Note(s) : (1) Null copies allowed (i.e. 0-octet size).
;
; (2) Memory buffers NOT checked for overlapping.
;
; (3) Modulo arithmetic is used to determine whether a memory buffer starts on a 'CPU_ALIGN'
; address boundary.
;
; (4) ARM Cortex-M3 processors use a subset of the ARM Thumb-2 instruction set which does
; NOT support 16-bit conditional branch instructions but ONLY supports 8-bit conditional
; branch instructions.
;
; Therefore, branches exceeding 8-bit, signed, relative offsets :
;
; (a) CANNOT be implemented with conditional branches; but ...
; (b) MUST be implemented with non-conditional branches.
;********************************************************************************************************
; void Mem_Copy (void *pdest, ; ==> R0
; void *psrc, ; ==> R1
; CPU_SIZE_T size) ; ==> R2
Mem_Copy:
CMP R0, #0
BNE Mem_Copy_1
BX LR ; return if pdest == NULL
Mem_Copy_1:
CMP R1, #0
BNE Mem_Copy_2
BX LR ; return if psrc == NULL
Mem_Copy_2:
CMP R2, #0
BNE Mem_Copy_3
BX LR ; return if size == 0
Mem_Copy_3:
STMFD SP!, {R3-R12} ; save registers on stack
Chk_Align_32: ; check if both dest & src 32-bit aligned
AND R3, R0, #0x03
AND R4, R1, #0x03
CMP R3, R4
BNE Chk_Align_16 ; not 32-bit aligned, check for 16-bit alignment
RSB R3, R3, #0x04 ; compute 1-2-3 pre-copy bytes (to align to the next 32-bit boundary)
AND R3, R3, #0x03
Pre_Copy_1:
CMP R3, #1 ; copy 1-2-3 bytes (to align to the next 32-bit boundary)
BCC Copy_32_1 ; start real 32-bit copy
CMP R2, #1 ; check if any more data to copy
BCS Pre_Copy_1_Cont
B Mem_Copy_END ; no more data to copy (see Note #4b)
Pre_Copy_1_Cont:
LDRB R4, [R1], #1
STRB R4, [R0], #1
SUB R3, R3, #1
SUB R2, R2, #1
B Pre_Copy_1
Chk_Align_16: ; check if both dest & src 16-bit aligned
AND R3, R0, #0x01
AND R4, R1, #0x01
CMP R3, R4
BEQ Pre_Copy_2
B Copy_08_1 ; not 16-bit aligned, start 8-bit copy (see Note #4b)
Pre_Copy_2:
CMP R3, #1 ; copy 1 byte (to align to the next 16-bit boundary)
BCC Copy_16_1 ; start real 16-bit copy
LDRB R4, [R1], #1
STRB R4, [R0], #1
SUB R3, R3, #1
SUB R2, R2, #1
B Pre_Copy_2
Copy_32_1:
CMP R2, #(04*10*09) ; Copy 9 chunks of 10 32-bit words (360 octets per loop)
BCC Copy_32_2
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
SUB R2, R2, #(04*10*09)
B Copy_32_1
Copy_32_2:
CMP R2, #(04*10*01) ; Copy chunks of 10 32-bit words (40 octets per loop)
BCC Copy_32_3
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
SUB R2, R2, #(04*10*01)
B Copy_32_2
Copy_32_3:
CMP R2, #(04*01*01) ; Copy remaining 32-bit words
BCC Copy_16_1
LDR R3, [R1], #4
STR R3, [R0], #4
SUB R2, R2, #(04*01*01)
B Copy_32_3
Copy_16_1:
CMP R2, #(02*01*16) ; Copy chunks of 16 16-bit words (32 bytes per loop)
BCC Copy_16_2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
SUB R2, R2, #(02*01*16)
B Copy_16_1
Copy_16_2:
CMP R2, #(02*01*01) ; Copy remaining 16-bit words
BCC Copy_08_1
LDRH R3, [R1], #2
STRH R3, [R0], #2
SUB R2, R2, #(02*01*01)
B Copy_16_2
Copy_08_1:
CMP R2, #(01*01*16) ; Copy chunks of 16 8-bit words (16 bytes per loop)
BCC Copy_08_2
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
SUB R2, R2, #(01*01*16)
B Copy_08_1
Copy_08_2:
CMP R2, #(01*01*01) ; Copy remaining 8-bit words
BCC Mem_Copy_END
LDRB R3, [R1], #1
STRB R3, [R0], #1
SUB R2, R2, #(01*01*01)
B Copy_08_2
Mem_Copy_END:
LDMFD SP!, {R3-R12} ; restore registers from stack
BX LR ; return
END
|
IDD_DLGVERSION equ 1700
IDC_EDTVERFILE equ 2903
IDC_EDTVERPROD equ 2904
IDC_CBOVEROS equ 2905
IDC_CBOVERTYPE equ 2906
IDC_CBOVERLANG equ 2907
IDC_CBOVERCHAR equ 2908
IDC_LSTVER equ 2909
IDC_EDTVER equ 2910
IDC_EDTVERTPE equ 2911
IDC_BTNVERADD equ 2912
.const
szVerOS dd 00000004h
db 'WINDOWS32',0
dd 00000000h
db 'UNKNOWN',0
dd 00010000h
db 'DOS',0
dd 00020000h
db 'OS216',0
dd 00030000h
db 'OS232',0
dd 00040000h
db 'NT',0
dd 00000000h
db 'BASE',0
dd 00000001h
db 'WINDOWS16',0
dd 00000002h
db 'PM16',0
dd 00000003h
db 'PM32',0
dd 00010001h
db 'DOS_WINDOWS16',0
dd 00010004h
db 'DOS_WINDOWS32',0
dd 00020002h
db 'OS216_PM16',0
dd 00030003h
db 'OS232_PM32',0
dd 00040004h
db 'NT_WINDOWS32',0
dd 0,0
szVerFT dd 00000000h
db 'UNKNOWN',0
dd 00000001h
db 'APP',0
dd 00000002h
db 'DLL',0
dd 00000003h
db 'DRV',0
dd 00000004h
db 'FONT',0
dd 00000005h
db 'VXD',0
dd 00000007h
db 'STATIC_LIB',0
dd 0,0
szVerLNG dd 0409h
db 'U.S. English',0
dd 0401h
db 'Arabic',0
dd 0402h
db 'Bulgarian',0
dd 0403h
db 'Catalan',0
dd 0404h
db 'Traditional Chinese',0
dd 0405h
db 'Czech',0
dd 0406h
db 'Danish',0
dd 0407h
db 'German',0
dd 0408h
db 'Greek',0
dd 040Ah
db 'Castilian Spanish',0
dd 040Bh
db 'Finnish',0
dd 040Ch
db 'French',0
dd 040Dh
db 'Hebrew',0
dd 040Eh
db 'Hungarian',0
dd 040Fh
db 'Icelandic',0
dd 0410h
db 'Italian',0
dd 0411h
db 'Japanese',0
dd 0412h
db 'Korean',0
dd 0413h
db 'Dutch',0
dd 0414h
db 'Norwegian - Bokml',0
dd 0415h
db 'Polish',0
dd 0416h
db 'Brazilian Portuguese',0
dd 0417h
db 'Rhaeto-Romanic',0
dd 0417h
db 'Rhaeto-Romanic',0
dd 0418h
db 'Romanian',0
dd 0419h
db 'Russian',0
dd 041Ah
db 'Croato-Serbian (Latin)',0
dd 041Bh
db 'Slovak',0
dd 041Ch
db 'Albanian',0
dd 041Dh
db 'Swedish',0
dd 041Eh
db 'Thai',0
dd 041Fh
db 'Turkish',0
dd 0420h
db 'Urdu',0
dd 0421h
db 'Bahasa',0
dd 0804h
db 'Simplified Chinese',0
dd 0807h
db 'Swiss German',0
dd 0809h
db 'U.K. English',0
dd 080Ah
db 'Mexican Spanish',0
dd 080Ch
db 'Belgian French',0
dd 0810h
db 'Swiss Italian',0
dd 0813h
db 'Belgian Dutch',0
dd 0814h
db 'Norwegian - Nynorsk',0
dd 0816h
db 'Portuguese',0
dd 081Ah
db 'Serbo-Croatian (Cyrillic)',0
dd 0C0Ch
db 'Canadian French',0
dd 100Ch
db 'Swiss French',0
dd 0,0
szVerCHS dd 1200
db 'Unicode',0
dd 0
db '7-bit ASCII',0
dd 932
db 'Japan (Shift - JIS X-0208)',0
dd 949
db 'Korea (Shift - KSC 5601)',0
dd 950
db 'Taiwan (GB5)',0
dd 1250
db 'Latin-2 (Eastern European)',0
dd 1251
db 'Cyrillic',0
dd 1252
db 'Multilingual',0
dd 1253
db 'Greek',0
dd 1254
db 'Turkish',0
dd 1255
db 'Hebrew',0
dd 1256
db 'Arabic',0
dd 0,0
szVerTpe db 'CompanyName',0
db 'FileVersion',0
db 'FileDescription',0
db 'InternalName',0
db 'LegalCopyright',0
db 'LegalTrademarks',0
db 'OriginalFilename',0
db 'ProductName',0
db 'ProductVersion',0
db 0
szStringFileInfo db 'StringFileInfo',0
szVarFileInfo db 'VarFileInfo',0
szTranslation db 'Translation',0
.data
szVersionName db 'IDR_VERSION',0
defver VERSIONMEM <,1,1,0,0,0,1,0,0,0,4,0,409h,4B0h>
VERSIONITEM <"FileVersion","1.0.0.0">
VERSIONITEM <"ProductVersion","1.0.0.0">
VERSIONITEM 30 dup(<>)
.data?
szVersionTxt db 32*256 dup(?)
lpOldEditProc dd ?
hVerDlg dd ?
.code
IncrementVersion proc lpProMem:DWORD
mov eax,hDialog
.if eax && eax==hVerDlg
invoke CloseDialog
.endif
PrintDec eax , "CloseDialog"
invoke GetTypeMem,lpProMem,TPE_VERSION
PrintDec eax, "GetTypeMem"
.if eax
mov edx,[eax].PROJECT.hmem
PrintDec edx, "PROJECT.hmem"
.if edx
inc [edx].VERSIONMEM.fv3
inc [edx].VERSIONMEM.pv3
mov [eax].PROJECT.changed,TRUE
.endif
.endif
ret
IncrementVersion endp
ExportVersionNames proc uses esi edi,hMem:DWORD
invoke xGlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,1024*16
mov edi,eax
invoke GlobalLock,edi
push edi
mov esi,hMem
;#define
.if [esi].VERSIONMEM.szname && [esi].VERSIONMEM.value
invoke ExportName,addr [esi].VERSIONMEM.szname,[esi].VERSIONMEM.value,edi
lea edi,[edi+eax]
.endif
pop eax
ret
ExportVersionNames endp
ExportVersion proc uses esi edi,hMem:DWORD
invoke xGlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,1024*16
mov edi,eax
invoke GlobalLock,edi
push edi
mov esi,hMem
;Name or ID
.if [esi].VERSIONMEM.szname
invoke strcpy,edi,addr [esi].VERSIONMEM.szname
.else
invoke ResEdBinToDec,[esi].VERSIONMEM.value,edi
.endif
invoke strlen,edi
add edi,eax
mov al,' '
stosb
invoke SaveStr,edi,addr szVERSIONINFO
add edi,eax
mov al,0Dh
stosb
mov al,0Ah
stosb
;File version
invoke SaveStr,edi,addr szFILEVERSION
add edi,eax
mov al,' '
stosb
push esi
lea esi,[esi].VERSIONMEM.fv
call SaveVer
pop esi
;Product version
invoke SaveStr,edi,addr szPRODUCTVERSION
add edi,eax
mov al,' '
stosb
push esi
lea esi,[esi].VERSIONMEM.pv
call SaveVer
pop esi
;File OS
invoke SaveStr,edi,addr szFILEOS
add edi,eax
mov al,' '
stosb
mov eax,[esi].VERSIONMEM.os
call SaveHex
;File type
invoke SaveStr,edi,addr szFILETYPE
add edi,eax
mov al,' '
stosb
mov eax,[esi].VERSIONMEM.ft
call SaveHex
invoke SaveStr,edi,addr szBEGIN
add edi,eax
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,' '
stosb
stosb
invoke SaveStr,edi,addr szBLOCK
add edi,eax
mov al,' '
stosb
mov al,22h
stosb
invoke SaveStr,edi,addr szStringFileInfo
add edi,eax
mov al,22h
stosb
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,' '
stosb
stosb
invoke SaveStr,edi,addr szBEGIN
add edi,eax
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,' '
stosb
stosb
stosb
stosb
invoke SaveStr,edi,addr szBLOCK
add edi,eax
mov al,' '
stosb
mov al,22h
stosb
mov eax,[esi].VERSIONMEM.lng
invoke hexEax
invoke strcpy,edi,offset strHex+4
add edi,4
mov eax,[esi].VERSIONMEM.chs
invoke hexEax
invoke strcpy,edi,offset strHex+4
add edi,4
mov al,22h
stosb
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,' '
stosb
stosb
stosb
stosb
invoke SaveStr,edi,addr szBEGIN
add edi,eax
mov al,0Dh
stosb
mov al,0Ah
stosb
push esi
lea esi,[esi+sizeof VERSIONMEM]
.while TRUE
.break .if ![esi].VERSIONITEM.szname
.if [esi].VERSIONITEM.szvalue
mov al,' '
stosb
stosb
stosb
stosb
stosb
stosb
invoke SaveStr,edi,addr szVALUE
add edi,eax
mov al,' '
stosb
mov al,22h
stosb
invoke SaveStr,edi,addr [esi].VERSIONITEM.szname
add edi,eax
mov al,22h
stosb
mov al,','
stosb
mov al,' '
stosb
mov al,22h
stosb
invoke SaveStr,edi,addr [esi].VERSIONITEM.szvalue
add edi,eax
mov al,'\'
stosb
mov al,'0'
stosb
mov al,22h
stosb
mov al,0Dh
stosb
mov al,0Ah
stosb
.endif
lea esi,[esi+sizeof VERSIONITEM]
.endw
pop esi
mov al,' '
stosb
stosb
stosb
stosb
invoke SaveStr,edi,addr szEND
add edi,eax
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,' '
stosb
stosb
invoke SaveStr,edi,addr szEND
add edi,eax
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,' '
stosb
stosb
invoke SaveStr,edi,addr szBLOCK
add edi,eax
mov al,' '
stosb
mov al,22h
stosb
invoke SaveStr,edi,addr szVarFileInfo
add edi,eax
mov al,22h
stosb
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,' '
stosb
stosb
invoke SaveStr,edi,addr szBEGIN
add edi,eax
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,' '
stosb
stosb
stosb
stosb
invoke SaveStr,edi,addr szVALUE
add edi,eax
mov al,' '
stosb
mov al,22h
stosb
invoke SaveStr,edi,addr szTranslation
add edi,eax
mov al,22h
stosb
mov al,','
stosb
mov al,' '
stosb
mov al,'0'
stosb
mov al,'x'
stosb
mov eax,[esi].VERSIONMEM.lng
invoke hexEax
invoke strcpy,edi,offset strHex+4
add edi,4
mov al,','
stosb
mov al,' '
stosb
mov al,'0'
stosb
mov al,'x'
stosb
mov eax,[esi].VERSIONMEM.chs
invoke hexEax
invoke strcpy,edi,offset strHex+4
add edi,4
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,' '
stosb
stosb
invoke SaveStr,edi,addr szEND
add edi,eax
mov al,0Dh
stosb
mov al,0Ah
stosb
invoke SaveStr,edi,addr szEND
add edi,eax
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,0Dh
stosb
mov al,0Ah
stosb
mov al,0
stosb
pop eax
ret
SaveVer:
mov eax,[esi]
call SaveVerItem
mov eax,[esi+4]
call SaveVerItem
mov eax,[esi+8]
call SaveVerItem
mov eax,[esi+12]
call SaveVerItem
dec edi
mov al,0Dh
stosb
mov al,0Ah
stosb
retn
SaveVerItem:
invoke ResEdBinToDec,eax,edi
invoke strlen,edi
lea edi,[edi+eax]
mov al,','
stosb
retn
SaveHex:
mov word ptr [edi],'x0'
add edi,2
invoke hexEax
invoke strcpy,edi,offset strHex
add edi,8
mov al,0Dh
stosb
mov al,0Ah
stosb
retn
ExportVersion endp
SaveVersionEdit proc uses ebx esi edi,hWin:HWND
LOCAL nInx:DWORD
LOCAL buffer[512]:BYTE
invoke GetWindowLong,hWin,GWL_USERDATA
.if !eax
invoke SendMessage,hRes,PRO_ADDITEM,TPE_VERSION,FALSE
push eax
invoke RtlMoveMemory,[eax].PROJECT.hmem,offset defver,sizeof VERSIONMEM+sizeof VERSIONITEM*32
pop eax
.endif
mov ebx,eax
push ebx
mov esi,[ebx].PROJECT.hmem
invoke GetProjectItemName,ebx,addr buffer
invoke SetProjectItemName,ebx,addr buffer
invoke GetDlgItemText,hWin,IDC_EDTVERFILE,addr buffer,16
push esi
lea esi,[esi].VERSIONMEM.fv
call GetVerNum
pop esi
invoke GetDlgItemText,hWin,IDC_EDTVERPROD,addr buffer,16
push esi
lea esi,[esi].VERSIONMEM.pv
call GetVerNum
pop esi
invoke SendDlgItemMessage,hWin,IDC_CBOVEROS,CB_GETCURSEL,0,0
invoke SendDlgItemMessage,hWin,IDC_CBOVEROS,CB_GETITEMDATA,eax,0
mov [esi].VERSIONMEM.os,eax
invoke SendDlgItemMessage,hWin,IDC_CBOVERTYPE,CB_GETCURSEL,0,0
invoke SendDlgItemMessage,hWin,IDC_CBOVERTYPE,CB_GETITEMDATA,eax,0
mov [esi].VERSIONMEM.ft,eax
invoke SendDlgItemMessage,hWin,IDC_CBOVERLANG,CB_GETCURSEL,0,0
invoke SendDlgItemMessage,hWin,IDC_CBOVERLANG,CB_GETITEMDATA,eax,0
mov [esi].VERSIONMEM.lng,eax
invoke SendDlgItemMessage,hWin,IDC_CBOVERCHAR,CB_GETCURSEL,0,0
invoke SendDlgItemMessage,hWin,IDC_CBOVERCHAR,CB_GETITEMDATA,eax,0
mov [esi].VERSIONMEM.chs,eax
lea esi,[esi+sizeof VERSIONMEM]
mov nInx,0
.while TRUE
mov [esi].VERSIONITEM.szname,0
mov [esi].VERSIONITEM.szvalue,0
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETTEXT,nInx,addr [esi].VERSIONITEM.szname
.break .if eax==LB_ERR
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETITEMDATA,nInx,0
invoke strcpy,addr [esi].VERSIONITEM.szvalue,eax
lea esi,[esi+sizeof VERSIONITEM]
inc nInx
.endw
pop eax
ret
GetVerNum:
lea edi,buffer
call GetVerNumItem
mov [esi],eax
call GetVerNumItem
mov [esi+4],eax
call GetVerNumItem
mov [esi+8],eax
call GetVerNumItem
mov [esi+12],eax
retn
GetVerNumItem:
invoke ResEdDecToBin,edi
.while byte ptr [edi]!='.' && byte ptr [edi]
inc edi
.endw
.if byte ptr [edi]=='.'
inc edi
.endif
retn
SaveVersionEdit endp
VersionSetCbo proc uses esi,hWin:HWND,nID:DWORD,lpKey:DWORD,nVal:DWORD
LOCAL nInx:DWORD
mov esi,lpKey
.while byte ptr [esi+4]
push [esi]
add esi,4
invoke SendDlgItemMessage,hWin,nID,CB_ADDSTRING,0,esi
pop edx
invoke SendDlgItemMessage,hWin,nID,CB_SETITEMDATA,eax,edx
invoke strlen,esi
lea esi,[esi+eax+1]
.endw
mov nInx,0
.while TRUE
invoke SendDlgItemMessage,hWin,nID,CB_GETITEMDATA,nInx,0
.break .if eax==CB_ERR
.if eax==nVal
invoke SendDlgItemMessage,hWin,nID,CB_SETCURSEL,nInx,0
.break
.endif
inc nInx
.endw
ret
VersionSetCbo endp
EditProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.if uMsg==WM_CHAR
.if wParam==VK_RETURN
invoke GetParent,hWin
invoke PostMessage,eax,WM_COMMAND,IDC_BTNVERADD,hWin
xor eax,eax
ret
.endif
.endif
invoke CallWindowProc,lpOldEditProc,hWin,uMsg,wParam,lParam
ret
EditProc endp
VersionEditProc proc uses esi edi,hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL nInx:DWORD
LOCAL buffer[512]:BYTE
LOCAL rect:RECT
LOCAL fChanged:DWORD
mov eax,uMsg
.if eax==WM_INITDIALOG
mov eax,hWin
mov hVerDlg,eax
mov fChanged,FALSE
mov esi,lParam
invoke SetWindowLong,hWin,GWL_USERDATA,esi
.if esi
mov esi,[esi].PROJECT.hmem
.else
invoke GetFreeProjectitemID,TPE_VERSION
mov esi,offset defver
mov [esi].VERSIONMEM.value,eax
invoke strcpy,addr [esi].VERSIONMEM.szname,addr szVersionName
invoke GetUnikeName,addr [esi].VERSIONMEM.szname
mov fChanged,TRUE
.endif
invoke RtlZeroMemory,offset szVersionTxt,sizeof szVersionTxt
mov lpResType,offset szVERSIONINFO
lea eax,[esi].VERSIONMEM.szname
mov lpResName,eax
lea eax,[esi].VERSIONMEM.value
mov lpResID,eax
invoke SendDlgItemMessage,hWin,IDC_EDTVERFILE,EM_LIMITTEXT,16,0
push esi
lea esi,[esi].VERSIONMEM.fv
call ConvVer
pop esi
invoke SetDlgItemText,hWin,IDC_EDTVERFILE,addr buffer
invoke SendDlgItemMessage,hWin,IDC_EDTVERPROD,EM_LIMITTEXT,16,0
push esi
lea esi,[esi].VERSIONMEM.pv
call ConvVer
pop esi
invoke SetDlgItemText,hWin,IDC_EDTVERPROD,addr buffer
invoke VersionSetCbo,hWin,IDC_CBOVEROS,offset szVerOS,[esi].VERSIONMEM.os
invoke VersionSetCbo,hWin,IDC_CBOVERTYPE,offset szVerFT,[esi].VERSIONMEM.ft
invoke VersionSetCbo,hWin,IDC_CBOVERLANG,addr szVerLNG,[esi].VERSIONMEM.lng
invoke VersionSetCbo,hWin,IDC_CBOVERCHAR,addr szVerCHS,[esi].VERSIONMEM.chs
lea esi,[esi+sizeof VERSIONMEM]
mov edi,offset szVerTpe
.while byte ptr [edi]
call AddTpe
invoke strlen,edi
lea edi,[edi+eax+1]
.endw
mov edi,offset szVersionTxt
.while [esi].VERSIONITEM.szname
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_ADDSTRING,0,addr [esi].VERSIONITEM.szname
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_SETITEMDATA,eax,edi
invoke strcpy,edi,addr [esi].VERSIONITEM.szvalue
add edi,256
lea esi,[esi+sizeof VERSIONITEM]
.endw
invoke SendDlgItemMessage,hWin,IDC_EDTVER,EM_LIMITTEXT,255,0
invoke SendDlgItemMessage,hWin,IDC_EDTVERTPE,EM_LIMITTEXT,63,0
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_SETCURSEL,0,0
invoke SendMessage,hWin,WM_COMMAND,(LBN_SELCHANGE shl 16) or IDC_LSTVER,0
invoke GetDlgItem,hWin,IDC_EDTVERTPE
mov edx,eax
invoke SetWindowLong,edx,GWL_WNDPROC,addr EditProc
mov lpOldEditProc,eax
invoke GetWindowLong,hWin,GWL_USERDATA
.if !eax
invoke SaveVersionEdit,hWin
invoke SetWindowLong,hWin,GWL_USERDATA,eax
.endif
invoke PropertyList,-2
mov fNoScroll,TRUE
invoke ShowScrollBar,hDEd,SB_BOTH,FALSE
invoke SendMessage,hWin,WM_SIZE,0,0
mov eax,fChanged
mov fDialogChanged,eax
.elseif eax==WM_COMMAND
mov eax,wParam
mov edx,eax
shr edx,16
and eax,0FFFFh
.if edx==BN_CLICKED
.if eax==IDOK
invoke SaveVersionEdit,hWin
.if fDialogChanged
invoke SendMessage,hRes,PRO_SETMODIFY,TRUE,0
mov fDialogChanged,FALSE
.endif
.elseif eax==IDCANCEL
invoke SendMessage,hWin,WM_CLOSE,NULL,NULL
invoke PropertyList,0
.elseif eax==IDC_BTNVERADD
invoke SendDlgItemMessage,hWin,IDC_EDTVERTPE,WM_GETTEXT,sizeof buffer,addr buffer
.if eax
lea edi,buffer
invoke GetWindowLong,hWin,GWL_USERDATA
.if eax
mov esi,[eax].PROJECT.hmem
.else
mov esi,offset defver
.endif
lea esi,[esi+sizeof VERSIONMEM]
call AddTpe
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_RESETCONTENT,0,0
mov edi,offset szVersionTxt
mov nInx,-1
.while [esi].VERSIONITEM.szname
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_ADDSTRING,0,addr [esi].VERSIONITEM.szname
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_SETITEMDATA,eax,edi
invoke strcpy,edi,addr [esi].VERSIONITEM.szvalue
inc nInx
add edi,256
lea esi,[esi+sizeof VERSIONITEM]
.endw
mov buffer,0
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_SETCURSEL,nInx,0
invoke SendDlgItemMessage,hWin,IDC_EDTVERTPE,WM_SETTEXT,0,addr buffer
invoke SendMessage,hWin,WM_COMMAND,(LBN_SELCHANGE shl 16) or IDC_LSTVER,0
invoke GetDlgItem,hWin,IDC_BTNVERADD
invoke EnableWindow,eax,FALSE
.endif
.endif
.elseif edx==EN_CHANGE
.if eax==IDC_EDTVER
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETCURSEL,0,0
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETITEMDATA,eax,0
invoke SendDlgItemMessage,hWin,IDC_EDTVER,WM_GETTEXT,256,eax
.elseif eax==IDC_EDTVERTPE
invoke GetDlgItem,hWin,IDC_BTNVERADD
push eax
invoke SendDlgItemMessage,hWin,IDC_EDTVERTPE,WM_GETTEXTLENGTH,0,0
pop edx
invoke EnableWindow,edx,eax
.endif
mov fDialogChanged,TRUE
invoke NotifyParent
.elseif edx==LBN_SELCHANGE
.if eax==IDC_LSTVER
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETCURSEL,0,0
.if eax!=LB_ERR
invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETITEMDATA,eax,0
invoke SendDlgItemMessage,hWin,IDC_EDTVER,WM_SETTEXT,0,eax
.endif
.endif
mov fDialogChanged,TRUE
invoke NotifyParent
.endif
.elseif eax==WM_CLOSE
mov fNoScroll,FALSE
invoke ShowScrollBar,hDEd,SB_BOTH,TRUE
invoke DestroyWindow,hWin
mov hVerDlg,0
.elseif eax==WM_SIZE
invoke SendMessage,hDEd,WM_VSCROLL,SB_THUMBTRACK,0
invoke SendMessage,hDEd,WM_HSCROLL,SB_THUMBTRACK,0
invoke GetClientRect,hDEd,addr rect
mov rect.left,3
mov rect.top,3
sub rect.right,6
sub rect.bottom,6
invoke MoveWindow,hWin,rect.left,rect.top,rect.right,rect.bottom,TRUE
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
ConvVer:
lea edi,buffer
invoke ResEdBinToDec,[esi],edi
invoke strlen,edi
lea edi,[edi+eax]
mov al,'.'
stosb
invoke ResEdBinToDec,[esi+4],edi
invoke strlen,edi
lea edi,[edi+eax]
mov al,'.'
stosb
invoke ResEdBinToDec,[esi+8],edi
invoke strlen,edi
lea edi,[edi+eax]
mov al,'.'
stosb
invoke ResEdBinToDec,[esi+12],edi
retn
AddTpe:
push esi
.while [esi].VERSIONITEM.szname
invoke strcmpi,addr [esi].VERSIONITEM.szname,edi
.break .if !eax
lea esi,[esi+sizeof VERSIONITEM]
.endw
invoke strcpy,addr [esi].VERSIONITEM.szname,edi
pop esi
retn
VersionEditProc endp
|
; A216973: Exponential Riordan array [x*exp(x),x].
; 0,1,0,2,2,0,3,6,3,0,4,12,12,4,0,5,20,30,20,5,0,6,30,60,60,30,6,0,7,42,105,140,105,42,7,0,8,56,168,280,280,168,56,8,0,9,72,252,504,630,504,252,72,9,0,10,90,360,840,1260,1260,840,360,90,10,0
lpb $0
add $1,$2
add $2,1
sub $0,$2
bin $1,$0
mul $1,$2
lpe
mov $0,$1
|
[bits 32]
dd Window.$FILE_END - Window.$FILE_START
db "OrcaHLL Class", 0
db "Window", 0
Window.$FILE_START :
Window.winNum equ 38
Window.yPos equ 16
Window.windowBuffer equ 22
Window.xPos equ 12
Window.title equ 0
Window.type equ 20
Window.depth equ 21
Window.lastYpos equ 18
Window.lastXpos equ 14
Window.width equ 4
Window.lastWidth equ 6
Window.buffer equ 26
Window.lastHeight equ 10
Window.oldBuffer equ 34
Window.height equ 8
Window.bufferSize equ 30
Window.$global.TYPE_IMAGE :
db 0x0
Window.$global.TYPE_TEXT :
db 0x0
Window.Create:
pop dword [Window.Create.returnVal]
pop ecx
mov [Window.Create.$local.type], cl
pop ecx
mov [Window.Create.$local.title], ecx
push eax
push ebx
push edx
mov ecx, 39
push ecx
mov ax, 0x0502
int 0x30
mov [Window.Create.$local.ret], ecx
mov ecx, [Window.Create.$local.title]
push edx ; Begin getting subvar
mov edx, [Window.Create.$local.ret]
add dl, Window.title
mov eax, edx
mov edx, [edx]
pop edx ; End getting subvar
mov [eax], ecx
xor ecx, ecx
mov cl, [Window.Create.$local.type]
push edx ; Begin getting subvar
mov edx, [Window.Create.$local.ret]
add dl, Window.type
mov eax, edx
mov edx, [edx]
pop edx ; End getting subvar
mov [eax], ecx
mov ecx, 40
mov [Window.Create.$local.wk], cx
xor ecx, ecx
mov cx, [Window.Create.$local.wk]
push edx ; Begin getting subvar
mov edx, [Window.Create.$local.ret]
add dl, Window.width
mov eax, edx
mov edx, [edx]
pop edx ; End getting subvar
mov [eax], ecx
xor ecx, ecx
mov cx, [Window.Create.$local.wk]
push edx ; Begin getting subvar
mov edx, [Window.Create.$local.ret]
add dl, Window.height
mov eax, edx
mov edx, [edx]
pop edx ; End getting subvar
mov [eax], ecx
mov ecx, 0x1 ; System Constant
push ecx
mov ax, 0x0001
int 0x30
mov [Window.Create.$local.size], ecx
push edx ; Math start
mov ecx, 0x2 ; System Constant
push ecx
mov ax, 0x0001
int 0x30
mov edx, ecx
mov ecx, [Window.Create.$local.size]
imul ecx, edx
pop edx ; Math end
mov [Window.Create.$local.size], ecx
mov ecx, [Window.Create.$local.size]
push ecx
mov ax, 0x0501
int 0x30
push edx ; Begin getting subvar
mov edx, [Window.Create.$local.ret]
add dl, Window.windowBuffer
mov eax, edx
mov edx, [edx]
pop edx ; End getting subvar
mov [eax], ecx
mov ecx, [Window.Create.$local.size]
push ecx
mov ax, 0x0502
int 0x30
push edx ; Begin getting subvar
mov edx, [Window.Create.$local.ret]
add dl, Window.buffer
mov eax, edx
mov edx, [edx]
pop edx ; End getting subvar
mov [eax], ecx
mov ecx, [Window.Create.$local.size]
push ecx
mov ax, 0x0502
int 0x30
push edx ; Begin getting subvar
mov edx, [Window.Create.$local.ret]
add dl, Window.oldBuffer
mov eax, edx
mov edx, [edx]
pop edx ; End getting subvar
mov [eax], ecx
mov ecx, [Window.Create.$local.ret]
pop edx
pop ebx
pop eax
push dword [Window.Create.returnVal]
ret
;Vars:
Window.Create.$local.ret :
dd 0x0
Window.Create.$local.wk :
dw 0x0
Window.Create.$local.size :
dd 0x0
Window.Create.$local.title :
dd 0x0
Window.Create.$local.type :
db 0x0
Window.Create.returnVal:
dd 0x0
Window.$FILE_END :
|
; A190949: Odd Fibonacci numbers with odd index.
; 1,5,13,89,233,1597,4181,28657,75025,514229,1346269,9227465,24157817,165580141,433494437,2971215073,7778742049,53316291173,139583862445,956722026041,2504730781961,17167680177565,44945570212853,308061521170129,806515533049393,5527939700884757,14472334024676221,99194853094755497,259695496911122585,1779979416004714189,4660046610375530309,31940434634990099905,83621143489848422977,573147844013817084101,1500520536206896083277,10284720757613717413913,26925748508234281076009,184551825793033096366333,483162952612010163284885,3311648143516982017180081,8670007398507948658051921,59425114757512643212875125,155576970220531065681649693,1066340417491710595814572169,2791715456571051233611642553,19134702400093278081449423917,50095301248058391139327916261,343358302784187294870275058337,898923707008479989274290850145,6161314747715278029583501626149,16130531424904581415797907386349,110560307156090817237632754212345,289450641941273985495088042104137,1983924214061919432247806074196061,5193981023518027157495786850488117,35600075545958458963222876581316753,93202207781383214849429075266681969,638817435613190341905763972389505493
mul $0,3
add $0,1
mov $1,261241
lpb $0
sub $0,2
add $2,$1
add $1,$2
lpe
div $1,261241
mov $0,$1
|
; BEGIN_LEGAL
; Intel Open Source License
;
; Copyright (c) 2002-2016 Intel Corporation. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are
; met:
;
; Redistributions of source code must retain the above copyright notice,
; this list of conditions and the following disclaimer. Redistributions
; in binary form must reproduce the above copyright notice, this list of
; conditions and the following disclaimer in the documentation and/or
; other materials provided with the distribution. Neither the name of
; the Intel Corporation nor the names of its contributors may be used to
; endorse or promote products derived from this software without
; specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
; ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
; END_LEGAL
.686
.XMM
.model flat, c
PUBLIC SetXmmScratchesFun
extern xmmInitVals:dword
.code
SetXmmScratchesFun PROC
push ebp
mov ebp, esp
lea eax,xmmInitVals
movdqu xmm0, xmmword ptr [eax]
movdqu xmm1, xmmword ptr [eax]+16
movdqu xmm2, xmmword ptr [eax]+32
movdqu xmm3, xmmword ptr [eax]+48
movdqu xmm4, xmmword ptr [eax]+64
movdqu xmm5, xmmword ptr [eax]+80
movdqu xmm6, xmmword ptr [eax]+96
movdqu xmm7, xmmword ptr [eax]+112
pop ebp
ret
SetXmmScratchesFun ENDP
end |
COMMENT }%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: PostScript printer driver
FILE: psbManager.asm
AUTHOR: Jim DeFrisco
REVISION HISTORY:
Name Date Description
---- ---- -----------
Jim 6/91 initial version
DESCRIPTION:
This file contains the source for the PostScript printer driver
$Id: psbManager.asm,v 1.1 97/04/18 11:52:12 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
;--------------------------------------
; Include files
;--------------------------------------
include printcomInclude.def
include timer.def
include psbInclude.def
UseLib ui.def
UseLib spool.def
;------------------------------------------------------------------------------
; Constants and Macros
;------------------------------------------------------------------------------
include printcomConstant.def
include psbConstant.def
include printcomMacro.def
include psbMacro.def
;------------------------------------------------------------------------------
; Driver Info Table
;------------------------------------------------------------------------------
idata segment ; MODULE_FIXED
DriverTable DriverExtendedInfoStruct \
< <Entry:DriverStrategy, ; DIS_strategy
mask DA_HAS_EXTENDED_INFO, ; DIS_driverAttributes
DRIVER_TYPE_PRINTER >, ; DIS_driverType
handle DriverInfo ; DEIS_resource
>
idata ends
;------------------------------------------------------------------------------
; Data Area
;------------------------------------------------------------------------------
udata segment ; MODULE_FIXED
include printcomVariable.def ; local buffer space
include psbVariable.def ; local buffer space
udata ends
;------------------------------------------------------------------------------
; Entry Code
;------------------------------------------------------------------------------
Entry segment resource ; MODULE_FIXED
include printcomEntry.asm ; entry point, misc bookeeping routines
include printcomTables.asm ; jump table for some driver calls
include printcomCursor.asm ; a few cursor (current position) setting routs
include printcomInfo.asm ; various info getting/setting routines
include psbAdmin.asm ; misc admin routines
include psbTables.asm ; module jump table for other driver calls
include psbTextRes.asm ; misc useless routines
Entry ends
;------------------------------------------------------------------------------
; Driver code
;------------------------------------------------------------------------------
CommonCode segment resource ; MODULE_STANDARD
include printcomGraphics.asm ; common code to implement graphics routines
include printcomStream.asm ; code to talk with the stream driver
include psbSetup.asm ; misc setup/cleanup routines
include psbText.asm ; code to implement text routines
include psbStyles.asm ; code to implement Style routines
include psbGraphics.asm ; code to implement graphics routines
include psbBitmap.asm ; code to write out bitmap header
include psbStream.asm ; code to talk with the stream driver
include psbCursor.asm ; code to implement Cursor routines
include psbPage.asm ; code to implement Page routines
include psbHeader.asm ; code to implement Page routines
include psbUtils.asm ; code to implement Page routines
CommonCode ends
;------------------------------------------------------------------------------
; Device Info Resources (each in their own resource)
;------------------------------------------------------------------------------
include psbDriverInfo.asm ; overall driver info
include psbInfo.asm
include psbProlog.asm
include psbPSCode.asm
include psbComments.asm
end
|
; CALLER linkage for function pointers
PUBLIC strrchr
EXTERN strrchr_callee
EXTERN ASMDISP_STRRCHR_CALLEE
.strrchr
pop hl
pop bc
pop de
push de
push bc
push hl
jp strrchr_callee + ASMDISP_STRRCHR_CALLEE
|
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r8
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x1432f, %rbx
nop
nop
nop
cmp $59523, %rbp
movb $0x61, (%rbx)
nop
add $58310, %rdi
lea addresses_UC_ht+0xa9b, %r14
nop
nop
nop
nop
nop
sub $23350, %r8
mov $0x6162636465666768, %rax
movq %rax, %xmm2
movups %xmm2, (%r14)
nop
nop
nop
nop
sub $9882, %r14
lea addresses_D_ht+0xf11b, %rax
sub $7160, %r14
mov $0x6162636465666768, %rsi
movq %rsi, %xmm7
vmovups %ymm7, (%rax)
dec %rbx
lea addresses_A_ht+0x1239b, %r14
nop
xor %rbx, %rbx
movb $0x61, (%r14)
nop
nop
nop
nop
and %rbx, %rbx
lea addresses_UC_ht+0x1319b, %rax
nop
nop
cmp %rdi, %rdi
mov (%rax), %r8d
nop
nop
nop
nop
nop
xor %r14, %r14
lea addresses_WC_ht+0xad5b, %rax
xor %rbp, %rbp
mov (%rax), %r8w
nop
nop
nop
inc %rax
lea addresses_UC_ht+0x6ff1, %rsi
lea addresses_normal_ht+0x1619b, %rdi
nop
nop
nop
sub $23860, %rbp
mov $49, %rcx
rep movsw
nop
nop
nop
nop
add $32155, %rbx
lea addresses_UC_ht+0xad1b, %r8
add %rax, %rax
mov $0x6162636465666768, %rbx
movq %rbx, %xmm2
movups %xmm2, (%r8)
inc %rcx
lea addresses_A_ht+0xc0db, %rbp
nop
nop
nop
nop
nop
add %rax, %rax
mov $0x6162636465666768, %r8
movq %r8, %xmm1
movups %xmm1, (%rbp)
nop
xor %rdi, %rdi
lea addresses_D_ht+0x419b, %rsi
lea addresses_normal_ht+0x1d99b, %rdi
nop
nop
nop
add %rax, %rax
mov $124, %rcx
rep movsb
nop
nop
cmp $37110, %rax
lea addresses_WC_ht+0x13c9b, %rdi
nop
nop
nop
add $45480, %r14
movb (%rdi), %cl
and %rbx, %rbx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r8
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %rbp
push %rbx
push %rcx
push %rsi
// Store
lea addresses_PSE+0x19b, %r13
nop
nop
nop
nop
inc %r12
mov $0x5152535455565758, %r10
movq %r10, %xmm3
vmovups %ymm3, (%r13)
nop
and %rbp, %rbp
// Store
lea addresses_D+0x1a47, %r13
nop
nop
nop
inc %rsi
mov $0x5152535455565758, %r12
movq %r12, %xmm3
vmovups %ymm3, (%r13)
nop
cmp $4910, %rsi
// Store
lea addresses_UC+0x999b, %r10
nop
nop
sub $34251, %r12
movw $0x5152, (%r10)
nop
nop
nop
nop
nop
dec %rbp
// Store
lea addresses_WC+0x133e3, %r12
and $15970, %r10
movw $0x5152, (%r12)
nop
sub $30198, %rsi
// Store
lea addresses_UC+0x9933, %rbx
nop
nop
nop
nop
and $43213, %r12
mov $0x5152535455565758, %rsi
movq %rsi, %xmm4
movups %xmm4, (%rbx)
nop
nop
nop
xor %r13, %r13
// Store
lea addresses_D+0x1a5a3, %rbx
xor %rsi, %rsi
movw $0x5152, (%rbx)
nop
nop
nop
nop
xor $41546, %r13
// Store
lea addresses_PSE+0x811b, %rbx
nop
sub %r12, %r12
mov $0x5152535455565758, %r10
movq %r10, (%rbx)
// Exception!!!
mov (0), %r12
nop
nop
nop
cmp $53211, %rbp
// Store
lea addresses_PSE+0x1bf49, %rsi
nop
nop
and $37246, %rbp
mov $0x5152535455565758, %r12
movq %r12, (%rsi)
nop
nop
cmp $12567, %r12
// Faulty Load
lea addresses_UC+0x999b, %r10
nop
nop
nop
nop
nop
cmp %r12, %r12
mov (%r10), %rbp
lea oracles, %r12
and $0xff, %rbp
shlq $12, %rbp
mov (%r12,%rbp,1), %rbp
pop %rsi
pop %rcx
pop %rbx
pop %rbp
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 11, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 1, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 3, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 6, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': True}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 2, 'size': 1, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 8, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 11, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 6, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 7, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 6, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'congruent': 7, 'size': 1, 'same': False, 'NT': False}}
{'52': 15260}
52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52
*/
|
; testing an early exit
main:
mov w0, 'B'
bl putchar
mov w0, '4'
bl putchar
mov pc, -1
mov w0, 'E'
bl putchar
mov w0, 'C'
bl putchar
done:
mov w0, 'P'
bl putchar
mov w0, '\n'
bl putchar
prgi
mov w0, 0
ret
|
; A100315: Number of 3 X n 0-1 matrices avoiding simultaneously the right angled numbered polyomino patterns (ranpp) (00;1), (01;0), (10;0) and (01;1).
; 1,8,14,22,34,54,90,158,290,550,1066,2094,4146,8246,16442,32830,65602,131142,262218,524366,1048658,2097238,4194394,8388702,16777314,33554534,67108970,134217838,268435570,536871030,1073741946,2147483774,4294967426,8589934726
mov $1,1
lpb $0
sub $0,1
mul $1,2
trn $2,2
add $2,6
lpe
add $1,$2
mov $0,$1
|
; A098080: Nontrivial slowest increasing sequence whose succession of digits is that of the nonnegative integers.
; 0,12,34,56,78,910,1112,1314,1516,1718,1920,2122,2324,2526,2728,2930,3132,3334,3536,3738,3940,4142,4344,4546,4748,4950,5152,5354,5556,5758,5960,6162,6364,6566,6768,6970,7172,7374,7576,7778,7980,8182,8384,8586,8788,8990,9192,9394,9596,9798,99100,101102
mov $5,$0
mul $0,2
mov $3,$0
trn $3,1
mov $4,$0
mov $6,$3
lpb $4
div $4,10
mul $6,10
lpe
mov $1,$6
mov $2,$5
mul $2,2
add $1,$2
mov $0,$1
|
Sound39_Smash_Header:
smpsHeaderStartSong 2
smpsHeaderVoice Sound2C_39_4B_Voices
smpsHeaderTempoSFX $01
smpsHeaderChanSFX $04
smpsHeaderSFXChannel cFM3, Sound39_Smash_FM3, $10, $00
smpsHeaderSFXChannel cFM4, Sound39_Smash_FM4, $00, $00
smpsHeaderSFXChannel cFM5, Sound39_Smash_FM5, $10, $00
smpsHeaderSFXChannel cPSG3, Sound39_Smash_PSG3, $00, $00
; FM3 Data
Sound39_Smash_FM3:
smpsPan panRight, $00
dc.b nRst, $02
smpsJump Sound39_Smash_FM4
; FM5 Data
Sound39_Smash_FM5:
smpsPan panLeft, $00
dc.b nRst, $01
; FM4 Data
Sound39_Smash_FM4:
smpsSetvoice $00
smpsModSet $03, $01, $20, $04
Sound39_Smash_Loop00:
dc.b nC0, $18
smpsAlterVol $0A
smpsLoop $00, $06, Sound39_Smash_Loop00
smpsStop
; PSG3 Data
Sound39_Smash_PSG3:
smpsModSet $01, $01, $0F, $05
smpsPSGform $E7
Sound39_Smash_Loop01:
dc.b nB3, $18, smpsNoAttack
smpsPSGAlterVol $03
smpsLoop $00, $05, Sound39_Smash_Loop01
smpsStop
|
;
; System Call for REX6000
;
; $Id: syscall0.asm,v 1.3 2002/04/17 21:30:25 dom Exp $
XLIB syscall0
.syscall0
pop bc
pop hl ;parameter
push hl
push bc
ld ($c000),hl
rst $10
ld hl,($c00e)
ret
|
; int p_forward_list_empty_fastcall(p_forward_list_t *list)
SECTION code_adt_p_forward_list
PUBLIC _p_forward_list_empty_fastcall
defc _p_forward_list_empty_fastcall = asm_p_forward_list_empty
INCLUDE "adt/p_forward_list/z80/asm_p_forward_list_empty.asm"
|
/*++
Copyright (c) 2000 Microsoft Corporation
Module Name:
KingsQuestMask.cpp
Abstract:
The app calls UnmapViewOfFile with a bogus address - an address that wasn't obtained
from MapViewOfFile. We validate the address before calling UnmapViewOfFile.
History:
11/20/2000 maonis Created
--*/
#include "precomp.h"
typedef BOOL (WINAPI *_pfn_UnmapViewOfFile)(LPCVOID lpBaseAddress);
IMPLEMENT_SHIM_BEGIN(KingsQuestMask)
#include "ShimHookMacro.h"
APIHOOK_ENUM_BEGIN
APIHOOK_ENUM_ENTRY(MapViewOfFile)
APIHOOK_ENUM_ENTRY(UnmapViewOfFile)
APIHOOK_ENUM_END
// Link list of base addresses
struct MAPADDRESS
{
MAPADDRESS *next;
LPCVOID pBaseAddress;
};
MAPADDRESS *g_pBaseAddressList;
/*++
Function Description:
Add a base address to the linked list of addresses. Does not add if the
address is NULL or a duplicate.
Arguments:
IN pBaseAddress - base address returned by MapViewOfFile.
Return Value:
None
History:
11/20/2000 maonis Created
--*/
VOID
AddBaseAddress(
IN LPCVOID pBaseAddress
)
{
if (pBaseAddress)
{
MAPADDRESS *pMapAddress = g_pBaseAddressList;
while (pMapAddress)
{
if (pMapAddress->pBaseAddress == pBaseAddress)
{
return;
}
pMapAddress = pMapAddress->next;
}
pMapAddress = (MAPADDRESS *) malloc(sizeof MAPADDRESS);
pMapAddress->pBaseAddress = pBaseAddress;
pMapAddress->next = g_pBaseAddressList;
g_pBaseAddressList = pMapAddress;
}
}
/*++
Function Description:
Remove a base address if it can be found in the linked list of addresses.
Arguments:
IN pBaseAddress - the base address to remove.
Return Value:
TRUE if the address is found.
FALSE if the address is not found.
History:
11/20/2000 maonis Created
--*/
BOOL
RemoveBaseAddress(
IN LPCVOID pBaseAddress
)
{
MAPADDRESS *pMapAddress = g_pBaseAddressList;
MAPADDRESS *last = NULL;
while (pMapAddress)
{
if (pMapAddress->pBaseAddress == pBaseAddress)
{
if (last)
{
last->next = pMapAddress->next;
}
else
{
g_pBaseAddressList = pMapAddress->next;
}
free(pMapAddress);
return TRUE;
}
last = pMapAddress;
pMapAddress = pMapAddress->next;
}
return FALSE;
}
/*++
Add the base address to our list.
--*/
LPVOID
APIHOOK(MapViewOfFile)(
HANDLE hFileMappingObject,
DWORD dwDesiredAccess,
DWORD dwFileOffsetHigh,
DWORD dwFileOffsetLow,
SIZE_T dwNumberOfBytesToMap
)
{
LPVOID pRet = ORIGINAL_API(MapViewOfFile)(
hFileMappingObject,
dwDesiredAccess,
dwFileOffsetHigh,
dwFileOffsetLow,
dwNumberOfBytesToMap);
AddBaseAddress(pRet);
DPFN( eDbgLevelInfo, "MapViewOfFile: added base address = 0x%x\n", pRet);
return pRet;
}
/*++
Remove the address from our list if it can be found; otherwise do nothing.
--*/
BOOL
APIHOOK(UnmapViewOfFile)(
LPCVOID lpBaseAddress
)
{
BOOL bRet;
if (RemoveBaseAddress(lpBaseAddress))
{
bRet = ORIGINAL_API(UnmapViewOfFile)(lpBaseAddress);
if (bRet)
{
DPFN( eDbgLevelInfo, "UnmapViewOfFile unmapped address 0x%x\n", lpBaseAddress);
}
return bRet;
}
else
{
DPFN( eDbgLevelError,"UnmapViewOfFile was passed an invalid address 0x%x\n", lpBaseAddress);
return FALSE;
}
}
/*++
Free the list.
--*/
BOOL
NOTIFY_FUNCTION(
DWORD fdwReason)
{
if (fdwReason == DLL_PROCESS_DETACH) {
DWORD dwCount = 0;
MAPADDRESS *pMapAddress = g_pBaseAddressList;
while (pMapAddress)
{
g_pBaseAddressList = pMapAddress->next;
ORIGINAL_API(UnmapViewOfFile)(pMapAddress->pBaseAddress);
free(pMapAddress);
pMapAddress = g_pBaseAddressList;
dwCount++;
}
if (dwCount > 0)
{
DPFN( eDbgLevelInfo,"%d addresses not unmapped.", dwCount);
}
}
return TRUE;
}
/*++
Register hooked functions
--*/
HOOK_BEGIN
APIHOOK_ENTRY(KERNEL32.DLL, MapViewOfFile)
APIHOOK_ENTRY(KERNEL32.DLL, UnmapViewOfFile)
CALL_NOTIFY_FUNCTION
HOOK_END
IMPLEMENT_SHIM_END
|
; A193422: Smallest number m such that A193358(m) = n.
; 0,1,4,2,10,6,18,12,28,20,40,30,54,42,70,56,88,72,108,90,130,110,154,132,180,156,208,182,238,210,270,240,304,272,340,306,378,342,418,380,460,420,504,462,550,506,598,552,648,600,700,650,754,702,810,756,868,812,928,870,990,930,1054,992,1120,1056,1188,1122,1258,1190,1330,1260,1404,1332,1480,1406,1558,1482,1638,1560,1720,1640,1804,1722,1890,1806,1978,1892,2068,1980,2160,2070,2254,2162,2350,2256,2448,2352,2548,2450,2650,2550,2754,2652,2860,2756,2968,2862,3078,2970,3190,3080,3304,3192,3420,3306,3538,3422,3658,3540,3780,3660,3904,3782,4030,3906,4158,4032,4288,4160,4420,4290,4554,4422,4690,4556,4828,4692,4968,4830,5110,4970,5254,5112,5400,5256,5548,5402,5698,5550,5850,5700,6004,5852,6160,6006,6318,6162,6478,6320,6640,6480,6804,6642,6970,6806,7138,6972,7308,7140,7480,7310,7654,7482,7830,7656,8008,7832,8188,8010,8370,8190,8554,8372,8740,8556,8928,8742,9118,8930,9310,9120,9504,9312,9700,9506,9898,9702,10098,9900,10300,10100,10504,10302,10710,10506,10918,10712,11128,10920,11340,11130,11554,11342,11770,11556,11988,11772,12208,11990,12430,12210,12654,12432,12880,12656,13108,12882,13338,13110,13570,13340,13804,13572,14040,13806,14278,14042,14518,14280,14760,14520,15004,14762,15250,15006,15498,15252,15748,15500
mov $1,$0
lpb $0,1
add $2,$0
sub $0,1
mov $3,$1
mov $1,2
add $4,$2
add $2,1
trn $4,2
add $1,$4
mov $4,$3
lpe
sub $1,$4
|
assume cs:code, ds:data
data segment
maxFileName db 100
lFileName db ?
fileName db 100 dup (?), '$'
maxFileExt db 100
lFileExt db ?
fileExt db 100 dup (?), '$'
fileNameMsg db 'Please input the file name: $'
extMsg db 'Please input the extenstion: $'
finalFile db 200 dup(?)
data ends
code segment
start:
mov ax, data
mov ds, ax
mov ah, 09h
mov dx, offset fileNameMsg
int 21h
;read filename
mov ah, 0ah
mov dx, offset maxFileName
int 21h
mov cl, lFileName
mov ch, 0
mov si, 0
mov di, 0
; move the file name
putFileName:
mov ah, fileName[si]
mov finalFile[di], ah
inc di
inc si
loop putFileName
; put a '.'
mov finalFile[di], '.'
inc di
mov ah, 02h
mov dl, 0ah
int 21h
mov dl, 0dh
int 21h
mov ah, 09h
mov dx, offset extMsg
int 21h
;read extension
mov ah, 0ah
mov dx, offset maxFIleExt
int 21h
mov cl, lFIleExt
mov ch, 0
mov si, 0
putFileExt:
mov ah, fileExt[si]
mov finalFile[di], ah
inc di
inc si
loop putFileExt
mov finalFile[di], 0
mov ah, 3ch
mov al, 0 ;normal mode
mov dx, offset finalFile
int 21h
mov ax, 4c00h
int 21h
code ends
end start
|
/*
Copyright 2016 Massachusetts Institute of Technology
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 "catalog.h"
#include "global.h"
#include "helper.h"
void
Catalog::init(const char * table_name, uint32_t table_id, int field_cnt) {
this->table_name = table_name;
this->table_id = table_id;
this->field_cnt = 0;
this->_columns = new Column [field_cnt];
this->tuple_size = 0;
}
void Catalog::add_col(char * col_name, uint64_t size, char * type) {
_columns[field_cnt].size = size;
strcpy(_columns[field_cnt].type, type);
strcpy(_columns[field_cnt].name, col_name);
_columns[field_cnt].id = field_cnt;
_columns[field_cnt].index = tuple_size;
tuple_size += size;
field_cnt ++;
}
uint64_t Catalog::get_field_id(const char * name) {
UInt32 i;
for (i = 0; i < field_cnt; i++) {
if (strcmp(name, _columns[i].name) == 0)
break;
}
assert (i < field_cnt);
return i;
}
char * Catalog::get_field_type(uint64_t id) {
return _columns[id].type;
}
char * Catalog::get_field_name(uint64_t id) {
return _columns[id].name;
}
char * Catalog::get_field_type(char * name) {
return get_field_type( get_field_id(name) );
}
uint64_t Catalog::get_field_index(char * name) {
return get_field_index( get_field_id(name) );
}
void Catalog::print_schema() {
printf("\n[Catalog] %s\n", table_name);
for (UInt32 i = 0; i < field_cnt; i++) {
printf("\t%s\t%s\t%ld\n", get_field_name(i),
get_field_type(i), get_field_size(i));
}
}
|
// ----------------------------------------------------------------------------
// - Open3D: www.open3d.org -
// ----------------------------------------------------------------------------
// The MIT License (MIT)
//
// Copyright (c) 2018 www.open3d.org
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------
#include <cmath>
#include <cstdio>
#include <thread>
#ifdef _OPENMP
#include <omp.h>
#endif
#include <Eigen/Dense>
#include <Eigen/SVD>
#include "open3d/Open3D.h"
#define NUM_THREADS 4
#define NUM_START 1
#define NUM_END 10
using namespace open3d;
void simple_task() {
int n_a_rows = 2000;
int n_a_cols = 2000;
int n_b_rows = 2000;
int n_b_cols = 2000;
Eigen::MatrixXd a(n_a_rows, n_a_cols);
for (int i = 0; i < n_a_rows; ++i)
for (int j = 0; j < n_a_cols; ++j) a(i, j) = n_a_cols * i + j;
Eigen::MatrixXd b(n_b_rows, n_b_cols);
for (int i = 0; i < n_b_rows; ++i)
for (int j = 0; j < n_b_cols; ++j) b(i, j) = n_b_cols * i + j;
Eigen::MatrixXd d(n_a_rows, n_b_cols);
d = a * b;
}
void svd_task() {
int n_a_rows = 10000;
int n_a_cols = 200;
Eigen::MatrixXd a(n_a_rows, n_a_cols);
for (int i = 0; i < n_a_rows; ++i)
for (int j = 0; j < n_a_cols; ++j) a(i, j) = n_a_cols * i + j;
Eigen::JacobiSVD<Eigen::MatrixXd> svd(
a, Eigen::ComputeThinU | Eigen::ComputeThinV);
Eigen::MatrixXd pca = svd.matrixU().block<10000, 10>(0, 0).transpose() * a;
}
void TestMatrixMultiplication(int argc, char **argv) {
int i = 0, nSum = 0, nStart = NUM_START, nEnd = NUM_END;
int nThreads = 1, nTmp = nStart + nEnd;
unsigned uTmp = (unsigned(nEnd - nStart + 1) * unsigned(nTmp)) / 2;
int nSumCalc = uTmp;
if (nTmp < 0) {
nSumCalc = -nSumCalc;
}
#ifdef _OPENMP
utility::LogInfo("OpenMP is supported.");
#else
utility::LogInfo("OpenMP is not supported.");
#endif
#ifdef _OPENMP
omp_set_num_threads(NUM_THREADS);
#endif
#pragma omp parallel default(none) private(i) \
shared(nSum, nThreads, nStart, nEnd)
{
#ifdef _OPENMP
#pragma omp master
nThreads = omp_get_num_threads();
#endif
#pragma omp for
for (i = nStart; i <= nEnd; ++i) {
#pragma omp atomic
nSum += i;
}
}
if (nThreads == NUM_THREADS) {
utility::LogInfo("{:d} OpenMP threads were used.", NUM_THREADS);
} else {
utility::LogInfo("Expected {:d} OpenMP threads, but {:d} were used.",
NUM_THREADS, nThreads);
}
if (nSum != nSumCalc) {
utility::LogInfo(
"The sum of {:d} through {:d} should be {:d}, "
"but {:d} was reported!",
NUM_START, NUM_END, nSumCalc, nSum);
} else {
utility::LogInfo("The sum of {:d} through {:d} is {:d}", NUM_START,
NUM_END, nSum);
}
int test_thread = 256;
if (argc > 1) {
test_thread = std::stoi(argv[1]);
}
open3d::utility::LogInfo("Benchmark multithreading up to {:d} threads.",
test_thread);
for (int i = 1; i <= test_thread; i *= 2) {
std::string buff =
fmt::format("simple task, {:d} tasks, {:d} threads", i, i);
open3d::utility::ScopeTimer t(buff.c_str());
#ifdef _OPENMP
omp_set_num_threads(i);
#endif
#pragma omp parallel default(none) shared(nThreads)
{ simple_task(); }
}
for (int i = 1; i <= test_thread; i *= 2) {
std::string buff =
fmt::format("simple task, {:d} tasks, {:d} threads", i, i);
open3d::utility::ScopeTimer t(buff.c_str());
std::vector<std::thread> threads(i);
for (int k = 0; k < i; k++) {
threads[k] = std::thread(simple_task);
}
for (int k = 0; k < i; k++) {
threads[k].join();
}
}
for (int i = 1; i <= test_thread; i *= 2) {
std::string buff = fmt::format("svd, {:d} tasks, {:d} threads", i, i);
open3d::utility::ScopeTimer t(buff.c_str());
#ifdef _OPENMP
omp_set_num_threads(i);
#endif
#pragma omp parallel default(none) shared(nThreads)
{ svd_task(); }
}
for (int i = 1; i <= test_thread; i *= 2) {
std::string buff =
fmt::format("svd task, {:d} tasks, {:d} threads", i, i);
open3d::utility::ScopeTimer t(buff.c_str());
std::vector<std::thread> threads(i);
for (int k = 0; k < i; k++) {
threads[k] = std::thread(svd_task);
}
for (int k = 0; k < i; k++) {
threads[k].join();
}
}
}
inline void ComputeSomething(int i,
Eigen::Vector6d &A_r,
double &r,
std::vector<Eigen::Vector3d> &data) {
const Eigen::Vector3d &vs = data[i];
const Eigen::Vector3d &vt = data[i];
const Eigen::Vector3d &nt = data[i];
r = (vs - vt).dot(nt);
// A_r.setZero();
A_r.block<3, 1>(0, 0).noalias() = vs.cross(nt);
A_r.block<3, 1>(3, 0).noalias() = nt;
}
/// Function to simulate building Jacobian matrix
/// uses simple way of using OpenMP and std::bind
void TestBindedFunction() {
// data generation
const int NCORR = 200000000;
std::vector<Eigen::Vector3d> data;
{
open3d::utility::ScopeTimer timer1("Data generation");
data.resize(NCORR);
#pragma omp for nowait
for (int i = 0; i < NCORR; i++) {
data[i] = Eigen::Vector3d::Random();
}
}
// data we want to build
Eigen::Matrix6d ATA;
Eigen::Vector6d ATb;
// to do using private ATA
// https://stackoverflow.com/questions/24948395/openmp-calling-global-variables-through-functions
auto f = std::bind(ComputeSomething, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3, data);
auto f_lambda = [&](int i, Eigen::Vector6d &A_r, double &r) {
ComputeSomething(i, A_r, r, data);
};
ATA.setZero();
ATb.setZero();
{
open3d::utility::ScopeTimer timer("Calling binding function");
#pragma omp parallel
{
Eigen::Matrix6d ATA_private;
Eigen::Vector6d ATb_private;
ATA_private.setZero();
ATb_private.setZero();
#pragma omp for nowait
for (int i = 0; i < NCORR; i++) {
Eigen::Vector6d A_r;
double r;
f(i, A_r, r);
ATA_private.noalias() += A_r * A_r.transpose();
ATb_private.noalias() += A_r * r;
}
#pragma omp critical
{
ATA += ATA_private;
ATb += ATb_private;
} // omp critical
} // omp parallel
}
std::cout << ATA << std::endl;
std::cout << ATb << std::endl;
ATA.setZero();
ATb.setZero();
{
open3d::utility::ScopeTimer timer("Calling lambda function");
#pragma omp parallel
{
Eigen::Matrix6d ATA_private;
Eigen::Vector6d ATb_private;
ATA_private.setZero();
ATb_private.setZero();
#pragma omp for nowait
for (int i = 0; i < NCORR; i++) {
Eigen::Vector6d A_r;
double r;
f_lambda(i, A_r, r);
ATA_private.noalias() += A_r * A_r.transpose();
ATb_private.noalias() += A_r * r;
}
#pragma omp critical
{
ATA += ATA_private;
ATb += ATb_private;
} // omp critical
} // omp parallel
}
std::cout << ATA << std::endl;
std::cout << ATb << std::endl;
ATA.setZero();
ATb.setZero();
{
open3d::utility::ScopeTimer timer("Calling function directly");
#pragma omp parallel
{
Eigen::Matrix6d ATA_private;
Eigen::Vector6d ATb_private;
ATA_private.setZero();
ATb_private.setZero();
#pragma omp for nowait
for (int i = 0; i < NCORR; i++) {
Eigen::Vector6d A_r;
double r;
ComputeSomething(i, A_r, r, data);
ATA_private.noalias() += A_r * A_r.transpose();
ATb_private.noalias() += A_r * r;
}
#pragma omp critical
{
ATA += ATA_private;
ATb += ATb_private;
} // omp critical
} // omp parallel
}
std::cout << ATA << std::endl;
std::cout << ATb << std::endl;
ATA.setZero();
ATb.setZero();
{
open3d::utility::ScopeTimer timer("Direct optration");
#pragma omp parallel
{
Eigen::Matrix6d ATA_private;
Eigen::Vector6d ATb_private;
ATA_private.setZero();
ATb_private.setZero();
#pragma omp for nowait
for (int i = 0; i < NCORR; i++) {
const Eigen::Vector3d &vs = data[i];
const Eigen::Vector3d &vt = data[i];
const Eigen::Vector3d &nt = data[i];
double r = (vs - vt).dot(nt);
Eigen::Vector6d A_r;
A_r.block<3, 1>(0, 0).noalias() = vs.cross(nt);
A_r.block<3, 1>(3, 0).noalias() = nt;
ATA_private.noalias() += A_r * A_r.transpose();
ATb_private.noalias() += A_r * r;
}
#pragma omp critical
{
ATA += ATA_private;
ATb += ATb_private;
} // omp critical
} // omp parallel
}
std::cout << ATA << std::endl;
std::cout << ATb << std::endl;
}
int main(int argc, char **argv) {
using namespace open3d;
if (utility::ProgramOptionExists(argc, argv, "--test_bind")) {
TestBindedFunction();
} else {
TestMatrixMultiplication(argc, argv);
}
return 0;
}
|
copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
004AEC move.w D1, -(A0)
004AEE dbra D0, $4aec
004B02 move.w A6, -(A4) [base+6A5C]
004B04 move.w A4, ($6a5c,A5) [base+6A88, base+6A8A, base+6A8C]
006622 movea.w (A0)+, A1
006624 tst.b ($7f,A1) [base+6A8A, base+6A8C]
0AAACA move.l (A0), D2
0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAACE move.w D0, ($2,A0)
0AAAD2 cmp.l (A0), D0
0AAAD4 bne $aaafc
0AAAD8 move.l D2, (A0)+
0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAE6 move.l (A0), D2
0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAF4 move.l D2, (A0)+
0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
copyright zengfr site:http://github.com/zengfr/romhack
|
; A092803: Expansion of (1-5x)/((1-2x)(1-6x)).
; 1,3,12,60,336,1968,11712,70080,420096,2519808,15117312,90700800,544198656,3265179648,19591053312,117546270720,705277526016,4231664959488,25389989363712,152339935395840,914039610802176
mov $1,6
pow $1,$0
mov $2,2
pow $2,$0
add $1,$2
div $1,2
add $1,$2
sub $1,1
div $1,2
add $1,1
mov $0,$1
|
; A196265: Number of standard puzzles of shape 2 X n with support CK (see reference for precise definition).
; 1,2,4,8,26,66,276,816,4050,13410,75780,274680,1723050,6735330,46104660,192296160,1418802210,6264006210,49355252100,229233450600,1914861598650,9309854203650,81969299111700,415483465597200,3837397323409650,20209910950879650,195025075426080900,1064132673817613400,10692951933111698250,60298939472074553250,629112521641484380500,3658621046342430168000,39533105245923484445250,236653126586465023685250,2642558050809981534730500,16256159524641131588493000,187221221564160713964284250,1181814929240530617892109250,14013964014321043272212212500,90652934711383546424872950000,1105086342113018668421800031250,7316876598611768923953249281250,91566871638968080722621116362500,619879632954186789955570875075000,7953738957320813053600585938806250,54998732464914098113868016833681250,722721040718294140489919969729212500
mov $3,$0
add $3,1
mov $5,$0
lpb $3
mov $0,$5
sub $3,1
sub $0,$3
mov $2,1
mov $4,1
lpb $0
sub $0,1
add $2,$0
sub $0,1
add $2,1
add $2,$0
sub $2,1
mul $4,$2
mov $2,2
lpe
add $1,$4
lpe
mov $0,$1
|
; A057354: a(n) = floor(2*n/5).
; 0,0,0,1,1,2,2,2,3,3,4,4,4,5,5,6,6,6,7,7,8,8,8,9,9,10,10,10,11,11,12,12,12,13,13,14,14,14,15,15,16,16,16,17,17,18,18,18,19,19,20,20,20,21,21,22,22,22,23,23,24,24,24,25,25,26,26,26,27,27,28,28,28,29,29,30,30,30,31,31,32,32,32,33,33,34,34,34,35,35,36,36,36,37,37,38,38,38,39,39
mul $0,2
div $0,5
|
// Original test: ./nfischer/hw4/problem6/ld_2.asm
// Author: nfischer
// Test source code follows
//load at negative offset
lbi r1, 50 //mem location
lbi r2, 8 //value to store
lbi r3, 0 //clear r3
st r2, r1, -10 //store at mem location -10
ld r3, r1, -10 //load from mem location -10
halt
|
AnthonyAteBerriesText:
text "The other day, I"
line "was watching my"
para "@"
text_ram wStringBuffer4
text " eat"
line "some BERRIES."
para "It looked like it"
line "was enjoying its"
para "meal, so I decided"
line "to try some."
para "I'm not sure if"
line "people should eat"
para "that stuff, but it"
line "was delicious!"
done
UnknownText_0x176aef:
text "Lately, I've been"
line "running across"
para "wild @"
text_ram wStringBuffer4
text_start
line "quite often."
para "They're easily"
line "taken care of."
done
UnknownText_0x176b45:
text "Oh yeah, I was"
line "battling this"
para "@"
text_ram wStringBuffer4
text " the"
line "other day…"
para "It took off when I"
line "got distracted by"
cont "a passing BEAUTY."
para "Learn from my"
line "mistake--always"
para "stay focused on"
line "the job at hand!"
done
UnknownText_0x176bee:
text "Come on--let's"
line "battle right now!"
para "@"
text_ram wStringBuffer5
text " is"
line "where I am."
para "Come on down if"
line "you feel up to it!"
done
UnknownText_0x176c47:
text "All right then!"
line "Be good!"
done
UnknownText_0x176c61:
text "<PLAYER>! It's"
line "mind-blowing!"
para "I took a hike in"
line "@"
text_ram wStringBuffer5
text_start
cont "yesterday, see?"
para "Well, there were"
line "tons of @"
text_ram wStringBuffer4
text_start
para "around! You have"
line "to see it!"
para "I get this feeling"
line "that @"
text_ram wStringBuffer4
text_start
para "may be timid."
line "I didn't see any"
para "where there are"
line "strong #MON."
done
UnknownText_0x176d32:
text "Rare #MON?"
para "Hey, sorry! I was"
line "too focused on my"
para "hike, so I wasn't"
line "paying attention."
done
UnknownText_0x176d85:
text "Hello! You haven't"
line "forgotten about"
para "our battle, have"
line "you?"
para "@"
text_ram wStringBuffer5
text "!"
line "I'm waiting!"
done
UnknownText_0x176dd1:
text "Hello? What? Where"
line "is DUNSPARCE?"
para "DARK CAVE! Hurry!"
para "I know I've said"
line "it before, but"
para "DUNSPARCE don't"
line "appear when there"
para "are strong #MON"
line "around."
done
|
L3gxImage_data equ 0x0
L3gxImage_w equ 0x4
L3gxImage_h equ 0x8
L3gxImage_$CLASSSIZE equ 0xC
L3gxImage.Create : ; int width, int height
methodTraceEnter
pop dword [L3gxImage.Create.retval]
pop dword [L3gxImage.Create.width]
pop dword [L3gxImage.Create.height]
push eax
push ebx
mov al, 7
mov ebx, [L3gxImage.Create.width]
imul ebx, [L3gxImage.Create.height]
call ProgramManager.reserveMemory
mov eax, ebx
mov ebx, [L3gxImage.Create.width]
mov ecx, [L3gxImage.Create.height]
call L3gxImage.FromBuffer
pop ebx
pop eax
push dword [L3gxImage.Create.retval]
methodTraceLeave
ret
L3gxImage.Create.retval :
dd 0x0
L3gxImage.Create.width :
dd 0x0
L3gxImage.Create.height :
dd 0x0
L3gxImage.FromBuffer : ; eax = data, ebx = width, ecx = height
methodTraceEnter
push edx
push eax
mov edx, eax
push ebx
mov al, 7
mov ebx, L3gxImage_$CLASSSIZE
call ProgramManager.reserveMemory
mov eax, ebx
pop ebx
mov [eax+L3gxImage_data], edx
mov [eax+L3gxImage_w], ebx
mov [eax+L3gxImage_h], ecx
mov ecx, eax
pop eax
pop edx
methodTraceLeave
ret
L3gxImage.FakeFromComponent : ; ebx = component
methodTraceEnter
mov ecx, [ebx+Component_image]
mov [L3gxImage.fakedImageData+L3gxImage_data], ecx
mov ecx, [ebx+Component_w]
shr ecx, 2 ; div by 4 so its in pixels and not bytes
mov [L3gxImage.fakedImageData+L3gxImage_w], ecx
mov ecx, [ebx+Component_h]
mov [L3gxImage.fakedImageData+L3gxImage_h], ecx
mov ecx, L3gxImage.fakedImageData
methodTraceLeave
ret
L3gxImage.fakedImageData :
times 3 dd 0x0
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x148de, %rdi
nop
nop
nop
inc %r12
mov (%rdi), %ax
cmp %rdx, %rdx
lea addresses_WC_ht+0x97be, %rcx
nop
nop
cmp $40756, %rbx
movups (%rcx), %xmm0
vpextrq $1, %xmm0, %r13
nop
nop
nop
nop
sub %rax, %rax
lea addresses_WT_ht+0x603e, %rsi
lea addresses_WT_ht+0xdabe, %rdi
nop
nop
nop
nop
nop
inc %r12
mov $102, %rcx
rep movsb
nop
nop
nop
nop
cmp $5292, %rbx
lea addresses_normal_ht+0x1dbe, %rsi
lea addresses_WT_ht+0x48, %rdi
nop
nop
and $29051, %r12
mov $43, %rcx
rep movsb
nop
nop
nop
nop
nop
and %r12, %r12
lea addresses_D_ht+0xaabe, %rsi
lea addresses_WT_ht+0x1a5b3, %rdi
cmp $21977, %r13
mov $32, %rcx
rep movsl
nop
nop
nop
nop
and %rax, %rax
lea addresses_normal_ht+0x3, %rsi
lea addresses_UC_ht+0x1c1de, %rdi
nop
nop
nop
nop
nop
xor $34262, %r13
mov $81, %rcx
rep movsl
nop
nop
nop
nop
xor $52034, %rax
lea addresses_UC_ht+0x1b6e3, %r13
nop
nop
nop
nop
add %rsi, %rsi
movl $0x61626364, (%r13)
nop
xor %rbx, %rbx
lea addresses_D_ht+0x111fe, %r13
nop
nop
nop
nop
dec %r12
mov (%r13), %rsi
nop
nop
nop
and $58790, %r13
lea addresses_WC_ht+0x5a3e, %rdx
nop
nop
cmp $5838, %rbx
mov (%rdx), %r13
nop
nop
nop
nop
xor $2627, %r13
lea addresses_WT_ht+0xcc3e, %rsi
lea addresses_D_ht+0xafae, %rdi
nop
nop
cmp %r13, %r13
mov $58, %rcx
rep movsl
xor $3467, %r13
lea addresses_WC_ht+0x80fe, %r12
nop
nop
nop
sub $12010, %rdi
and $0xffffffffffffffc0, %r12
vmovaps (%r12), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $0, %xmm7, %r13
nop
add $61808, %r12
lea addresses_UC_ht+0x1997e, %r12
nop
nop
nop
xor $60552, %rdx
mov $0x6162636465666768, %rdi
movq %rdi, %xmm1
vmovups %ymm1, (%r12)
nop
nop
nop
nop
nop
add %rdx, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r8
push %rax
push %rsi
// Faulty Load
lea addresses_WC+0xb43e, %r13
nop
nop
nop
nop
cmp %r12, %r12
movups (%r13), %xmm1
vpextrq $0, %xmm1, %r8
lea oracles, %r13
and $0xff, %r8
shlq $12, %r8
mov (%r13,%r8,1), %r8
pop %rsi
pop %rax
pop %r8
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 4, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 4, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 6, 'size': 8, 'same': False, 'NT': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 9, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'congruent': 2, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 5, 'size': 32, 'same': False, 'NT': False}}
{'53': 522, 'fc': 1, '47': 1, '48': 29, 'f0': 6507, '01': 463, '00': 333, '46': 600, 'b0': 5, 'ff': 10142, 'd0': 2, '49': 1273, 'b1': 11, '44': 1939, 'd8': 1}
49 ff f0 ff f0 ff f0 ff f0 ff ff 01 ff f0 44 ff 49 ff f0 ff f0 ff f0 ff f0 ff 49 ff ff 01 46 ff f0 00 ff ff f0 ff f0 ff f0 53 ff ff f0 00 00 ff 49 ff f0 ff f0 ff f0 ff f0 ff f0 ff f0 ff ff f0 ff f0 ff f0 ff ff f0 46 ff f0 ff 49 49 ff f0 ff f0 ff f0 ff f0 ff f0 ff f0 ff f0 ff ff f0 44 ff ff f0 ff f0 ff f0 00 ff 49 ff f0 44 ff 49 ff f0 ff f0 44 ff f0 ff f0 ff f0 44 ff 49 ff f0 ff f0 ff f0 ff ff f0 ff f0 ff f0 ff 44 ff f0 ff f0 ff 53 ff f0 53 ff f0 ff 53 ff f0 ff 49 ff f0 ff f0 44 fc 46 ff ff f0 ff f0 44 ff ff f0 44 ff f0 00 49 ff f0 ff f0 ff f0 ff ff f0 ff f0 ff f0 53 ff f0 ff f0 44 ff f0 ff f0 ff f0 ff ff ff f0 ff f0 ff f0 ff ff f0 44 ff f0 49 00 ff ff f0 44 44 ff f0 49 ff f0 ff f0 ff f0 47 ff f0 ff f0 44 44 49 00 ff 44 ff f0 ff 49 ff f0 ff ff 49 ff f0 ff f0 ff 49 ff f0 ff f0 ff f0 ff 49 ff f0 ff f0 ff ff f0 ff f0 ff f0 ff 53 ff f0 ff f0 49 53 ff f0 ff f0 ff f0 00 ff 53 ff f0 ff f0 ff ff f0 ff f0 44 ff ff f0 ff f0 ff f0 49 ff ff f0 ff f0 46 49 ff ff f0 ff f0 ff ff f0 46 ff f0 ff ff f0 ff f0 ff f0 ff 49 ff f0 44 44 44 49 ff f0 44 ff f0 ff ff ff f0 ff f0 ff ff f0 ff f0 ff f0 ff f0 44 ff f0 ff 53 ff f0 ff f0 ff f0 49 49 44 ff f0 ff f0 ff ff 46 44 ff 49 ff f0 44 ff f0 ff ff f0 46 ff f0 ff 49 ff 49 46 ff f0 ff ff ff f0 44 ff ff f0 44 ff ff ff ff 01 ff 01 ff 01 ff 01 46 ff f0 ff 44 ff 01 ff 44 ff 49 ff 01 ff 01 ff 01 ff 01 ff 01 ff 01 49 ff f0 44 ff f0 ff ff f0 ff f0 ff f0 ff ff 01 ff 01 44 ff 44 ff f0 ff ff 01 ff 46 ff 01 ff 01 ff 01 ff 01 44 ff f0 ff ff 01 44 ff ff 01 ff 01 ff 01 ff 01 ff f0 ff ff 01 44 ff 49 ff f0 44 46 ff 44 ff 53 ff f0 ff 49 ff f0 ff f0 44 ff ff f0 ff f0 ff f0 ff ff f0 ff f0 ff f0 ff 49 ff 44 ff 49 ff f0 44 ff f0 00 ff 53 ff f0 44 53 ff ff f0 44 ff 53 ff f0 ff f0 ff f0 ff 44 44 00 ff f0 ff f0 46 44 ff 49 ff ff f0 ff ff 00 ff ff f0 00 49 00 ff f0 44 ff f0 44 ff f0 ff f0 53 ff f0 ff ff ff f0 ff f0 44 ff 49 ff f0 44 ff f0 ff ff f0 ff f0 ff f0 ff ff 44 ff f0 ff 49 49 ff f0 ff f0 ff ff ff f0 ff f0 ff f0 ff ff f0 46 ff f0 ff 49 ff f0 ff f0 53 ff ff f0 46 53 ff f0 ff f0 ff ff ff ff f0 ff f0 44 ff 49 ff f0 ff f0 44 ff ff f0 ff f0 ff f0 ff 49 ff f0 44 46 ff ff f0 ff f0 ff f0 ff f0 44 ff ff f0 44 44 ff ff f0 44 ff 53 49 ff f0 46 ff ff ff f0 46 ff f0 ff f0 53 44 44 ff f0 ff ff f0 46 ff f0 ff f0 ff 53 ff f0 ff f0 ff ff 53 44 ff f0 44 ff 49 00 ff f0 53 ff f0 ff f0 44 44 ff f0 ff ff ff f0 ff ff f0 ff 53 ff f0 ff f0 ff f0 44 ff ff ff 01 44 ff f0 ff f0 ff f0 ff f0 ff ff f0 ff f0 ff f0 ff ff f0 44 ff f0 ff ff ff 01 ff 01 49 49 ff f0 ff f0 ff f0 53 ff f0 ff 49 49 ff f0 ff f0 ff f0 44 ff f0 ff f0 44 ff ff f0 53 ff f0 ff 49 ff f0 ff f0 ff f0 ff f0 44 ff f0 ff f0 49 ff f0 ff f0 44 00 ff ff f0 44 ff f0 00 ff 49 ff b1 44 ff f0 49 ff f0 ff f0 44 49 ff f0 ff 44 ff f0 ff 53 ff f0 44 53 44 49 00 ff f0 ff f0 ff f0 44 ff ff f0 ff f0 44 00 49 49 ff f0 ff f0 ff f0 ff f0 ff f0 ff f0 ff 49 ff f0 ff f0 ff ff ff f0 53 ff f0 ff f0 ff f0 ff f0 ff 49 ff f0 46 44 44 ff 49 ff f0 ff 01 ff f0 ff ff f0 ff f0 ff f0 ff 53 ff f0 ff f0 ff f0 ff ff f0 ff f0 ff f0 ff f0 ff f0 ff
*/
|
dnl AMD64 SSSE3/XOP mpn_popcount -- population count.
dnl Copyright 2010-2017 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb good for cpu?
C AMD K8,K9 n/a
C AMD K10 n/a
C AMD bd1 1.27 y
C AMD bd2 1.24 y
C AMD bd3 ?
C AMD bd4 1.22
C AMD zen n/a
C AMD bobcat n/a
C AMD jaguar n/a
C Intel P4 n/a
C Intel CNR n/a
C Intel PNR n/a
C Intel NHM n/a
C Intel SBR n/a
C Intel IBR n/a
C Intel HWL n/a
C Intel BWL n/a
C Intel SKL n/a
C Intel atom n/a
C Intel SLM n/a
C VIA nano n/a
C TODO
C * We need to use .byte for vpshlb, vpperm, vphaddubq, and all popcnt if we
C intend to support old systems.
C We use vpshlb and vpperm below, which are XOP extensions to AVX. Some
C systems, e.g., NetBSD, set OSXSAVE but nevertheless trigger SIGILL for AVX.
C We fall back to the core2 code.
ifdef(`GMP_AVX_NOT_REALLY_AVAILABLE',`
MULFUNC_PROLOGUE(mpn_popcount)
include_mpn(`x86_64/core2/popcount.asm')
',`
define(`up', `%rdi')
define(`n', `%rsi')
ABI_SUPPORT(DOS64)
ABI_SUPPORT(STD64)
ASM_START()
TEXT
ALIGN(32)
PROLOGUE(mpn_popcount)
FUNC_ENTRY(3)
lea L(cnsts)(%rip), %r9
ifdef(`PIC', `define(`OFF1',32) define(`OFF2',48) define(`OFF3',64)',
`define(`OFF1',64) define(`OFF2',80) define(`OFF3',96)')
movdqa OFF1`'(%r9), %xmm7 C nibble counts table
movdqa OFF2`'(%r9), %xmm6 C splat shift counts
movdqa OFF3`'(%r9), %xmm9 C masks
pxor %xmm4, %xmm4
pxor %xmm5, %xmm5 C 0-reg
pxor %xmm8, %xmm8 C grand total count
xor R32(%rdx), R32(%rdx)
mov R32(n), R32(%rax)
and $7, R32(%rax)
ifdef(`PIC',`
movslq (%r9,%rax,4), %rax
add %r9, %rax
jmp *%rax
',`
jmp *(%r9,%rax,8)
')
L(1): .byte 0xf3,0x48,0x0f,0xb8,0x17 C popcnt (up),%rdx
add $8, up
dec n
jnz L(top)
mov %rdx, %rax
FUNC_EXIT()
ret
L(2): add $-48, up
jmp L(e2)
L(3): .byte 0xf3,0x48,0x0f,0xb8,0x17 C popcnt (up), %rdx
add $-40, up
jmp L(e2)
L(4): add $-32, up
jmp L(e4)
L(5): .byte 0xf3,0x48,0x0f,0xb8,0x17 C popcnt (up), %rdx
add $-24, up
jmp L(e4)
L(6): add $-16, up
jmp L(e6)
L(7): .byte 0xf3,0x48,0x0f,0xb8,0x17 C popcnt (up), %rdx
add $-8, up
jmp L(e6)
ALIGN(32)
L(top): lddqu (up), %xmm0
.byte 0x8f,0xe9,0x48,0x94,0xc8 C vpshlb %xmm6, %xmm0, %xmm1
pand %xmm9, %xmm0
pand %xmm9, %xmm1
.byte 0x8f,0xe8,0x40,0xa3,0xd7,0x00 C vpperm %xmm0,%xmm7,%xmm7,%xmm2
.byte 0x8f,0xe8,0x40,0xa3,0xdf,0x10 C vpperm %xmm1, %xmm7, %xmm7, %xmm3
paddb %xmm2, %xmm3
paddb %xmm3, %xmm4
L(e6): lddqu 16(up), %xmm0
.byte 0x8f,0xe9,0x48,0x94,0xc8 C vpshlb %xmm6, %xmm0, %xmm1
pand %xmm9, %xmm0
pand %xmm9, %xmm1
.byte 0x8f,0xe8,0x40,0xa3,0xd7,0x00 C vpperm %xmm0,%xmm7,%xmm7,%xmm2
.byte 0x8f,0xe8,0x40,0xa3,0xdf,0x10 C vpperm %xmm1,%xmm7,%xmm7,%xmm3
paddb %xmm2, %xmm3
paddb %xmm3, %xmm4
L(e4): lddqu 32(up), %xmm0
.byte 0x8f,0xe9,0x48,0x94,0xc8 C vpshlb %xmm6, %xmm0, %xmm1
pand %xmm9, %xmm0
pand %xmm9, %xmm1
.byte 0x8f,0xe8,0x40,0xa3,0xd7,0x00 C vpperm %xmm0, %xmm7, %xmm7, %xmm2
.byte 0x8f,0xe9,0x78,0xd3,0xec C vphaddubq %xmm4, %xmm5
.byte 0x8f,0xe8,0x40,0xa3,0xe7,0x10 C vpperm %xmm1,%xmm7,%xmm7,%xmm4
paddb %xmm2, %xmm4
L(e2): popcnt 48(up), %r8
popcnt 56(up), %r9
add $64, up
paddq %xmm5, %xmm8 C sum to 2 x 64-bit counts
add %r8, %rdx
add %r9, %rdx
sub $8, n
jg L(top)
.byte 0x8f,0xe9,0x78,0xd3,0xec C vphaddubq %xmm4, %xmm5
paddq %xmm5, %xmm8
pshufd $14, %xmm8, %xmm0
paddq %xmm8, %xmm0
movq %xmm0, %rax
add %rdx, %rax
FUNC_EXIT()
ret
EPILOGUE()
DEF_OBJECT(L(cnsts),16,`JUMPTABSECT')
JMPENT( L(top), L(cnsts))
JMPENT( L(1), L(cnsts))
JMPENT( L(2), L(cnsts))
JMPENT( L(3), L(cnsts))
JMPENT( L(4), L(cnsts))
JMPENT( L(5), L(cnsts))
JMPENT( L(6), L(cnsts))
JMPENT( L(7), L(cnsts))
.byte 0x00,0x01,0x01,0x02,0x01,0x02,0x02,0x03
.byte 0x01,0x02,0x02,0x03,0x02,0x03,0x03,0x04
.byte -4,-4,-4,-4,-4,-4,-4,-4
.byte -4,-4,-4,-4,-4,-4,-4,-4
.byte 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f
.byte 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f
END_OBJECT(L(cnsts))
')
|
#include <QtGlobal>
// Automatically generated by extract_strings.py
#ifdef __GNUC__
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif
static const char UNUSED *bitcoin_strings[] = {QT_TRANSLATE_NOOP("bitcoin-core", "To use the %s option"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"%s, you must set a rpcpassword in the configuration file:\n"
" %s\n"
"It is recommended you use the following random password:\n"
"rpcuser=ucoinrpc\n"
"rpcpassword=%s\n"
"(you do not need to remember this password)\n"
"The username and password MUST NOT be the same.\n"
"If the file does not exist, create it with owner-readable-only file "
"permissions.\n"
"It is also recommended to set alertnotify so you are notified of problems;\n"
"for example: alertnotify=echo %%s | mail -s \"UCoin Alert\" admin@foo."
"com\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Error"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"An error occurred while setting up the RPC port %u for listening on IPv6, "
"falling back to IPv4: %s"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"An error occurred while setting up the RPC port %u for listening on IPv4: %s"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"You must set rpcpassword=<password> in the configuration file:\n"
"%s\n"
"If the file does not exist, create it with owner-readable-only file "
"permissions."),
QT_TRANSLATE_NOOP("bitcoin-core", "UCoin version"),
QT_TRANSLATE_NOOP("bitcoin-core", "Usage:"),
QT_TRANSLATE_NOOP("bitcoin-core", "Send command to -server or ucoind"),
QT_TRANSLATE_NOOP("bitcoin-core", "List commands"),
QT_TRANSLATE_NOOP("bitcoin-core", "Get help for a command"),
QT_TRANSLATE_NOOP("bitcoin-core", "UCoin"),
QT_TRANSLATE_NOOP("bitcoin-core", "Options:"),
QT_TRANSLATE_NOOP("bitcoin-core", "This help message"),
QT_TRANSLATE_NOOP("bitcoin-core", "Specify configuration file (default: ucoin.conf)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Specify pid file (default: ucoind.pid)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Specify data directory"),
QT_TRANSLATE_NOOP("bitcoin-core", "Specify wallet file (within data directory)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Set database cache size in megabytes (default: 25)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Set database disk log size in megabytes (default: 100)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Specify connection timeout in milliseconds (default: 5000)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Connect through socks proxy"),
QT_TRANSLATE_NOOP("bitcoin-core", "Select the version of socks proxy to use (4-5, default: 5)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Use proxy to reach tor hidden services (default: same as -proxy)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Allow DNS lookups for -addnode, -seednode and -connect"),
QT_TRANSLATE_NOOP("bitcoin-core", "Listen for connections on <port> (default: 15714 or testnet: 25714)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Maintain at most <n> connections to peers (default: 125)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Add a node to connect to and attempt to keep the connection open"),
QT_TRANSLATE_NOOP("bitcoin-core", "Connect only to the specified node(s)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Connect to a node to retrieve peer addresses, and disconnect"),
QT_TRANSLATE_NOOP("bitcoin-core", "Specify your own public address"),
QT_TRANSLATE_NOOP("bitcoin-core", "Only connect to nodes in network <net> (IPv4, IPv6 or Tor)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Discover own IP address (default: 1 when listening and no -externalip)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Find peers using internet relay chat (default: 0)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Accept connections from outside (default: 1 if no -proxy or -connect)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Bind to given address. Use [host]:port notation for IPv6"),
QT_TRANSLATE_NOOP("bitcoin-core", "Find peers using DNS lookup (default: 1)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Stake your coins to support network and gain reward (default: 1)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Sync time with other nodes. Disable if time on your system is precise e.g. "
"syncing with NTP (default: 1)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Sync checkpoints policy (default: strict)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Threshold for disconnecting misbehaving peers (default: 100)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Number of seconds to keep misbehaving peers from reconnecting (default: "
"86400)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Use UPnP to map the listening port (default: 1 when listening)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Use UPnP to map the listening port (default: 0)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Detach block and address databases. Increases shutdown time (default: 0)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Fee per KB to add to transactions you send"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"When creating transactions, ignore inputs with value less than this "
"(default: 0.01)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Accept command line and JSON-RPC commands"),
QT_TRANSLATE_NOOP("bitcoin-core", "Run in the background as a daemon and accept commands"),
QT_TRANSLATE_NOOP("bitcoin-core", "Use the test network"),
QT_TRANSLATE_NOOP("bitcoin-core", "Output extra debugging information. Implies all other -debug* options"),
QT_TRANSLATE_NOOP("bitcoin-core", "Output extra network debugging information"),
QT_TRANSLATE_NOOP("bitcoin-core", "Prepend debug output with timestamp"),
QT_TRANSLATE_NOOP("bitcoin-core", "Shrink debug.log file on client startup (default: 1 when no -debug)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Send trace/debug info to console instead of debug.log file"),
QT_TRANSLATE_NOOP("bitcoin-core", "Send trace/debug info to debugger"),
QT_TRANSLATE_NOOP("bitcoin-core", "Username for JSON-RPC connections"),
QT_TRANSLATE_NOOP("bitcoin-core", "Password for JSON-RPC connections"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Listen for JSON-RPC connections on <port> (default: 15715 or testnet: 25715)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Allow JSON-RPC connections from specified IP address"),
QT_TRANSLATE_NOOP("bitcoin-core", "Send commands to node running on <ip> (default: 127.0.0.1)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Execute command when the best block changes (%s in cmd is replaced by block "
"hash)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Execute command when a wallet transaction changes (%s in cmd is replaced by "
"TxID)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Require a confirmations for change (default: 0)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Enforce transaction scripts to use canonical PUSH operators (default: 1)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Execute command when a relevant alert is received (%s in cmd is replaced by "
"message)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Upgrade wallet to latest format"),
QT_TRANSLATE_NOOP("bitcoin-core", "Set key pool size to <n> (default: 100)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Rescan the block chain for missing wallet transactions"),
QT_TRANSLATE_NOOP("bitcoin-core", "Attempt to recover private keys from a corrupt wallet.dat"),
QT_TRANSLATE_NOOP("bitcoin-core", "How many blocks to check at startup (default: 2500, 0 = all)"),
QT_TRANSLATE_NOOP("bitcoin-core", "How thorough the block verification is (0-6, default: 1)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Imports blocks from external blk000?.dat file"),
QT_TRANSLATE_NOOP("bitcoin-core", "Block creation options:"),
QT_TRANSLATE_NOOP("bitcoin-core", "Set minimum block size in bytes (default: 0)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Set maximum block size in bytes (default: 250000)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Set maximum size of high-priority/low-fee transactions in bytes (default: "
"27000)"),
QT_TRANSLATE_NOOP("bitcoin-core", "SSL options: (see the Bitcoin Wiki for SSL setup instructions)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Use OpenSSL (https) for JSON-RPC connections"),
QT_TRANSLATE_NOOP("bitcoin-core", "Server certificate file (default: server.cert)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Server private key (default: server.pem)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:"
"@STRENGTH)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -paytxfee=<amount>: '%s'"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Warning: -paytxfee is set very high! This is the transaction fee you will "
"pay if you send a transaction."),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -mininput=<amount>: '%s'"),
QT_TRANSLATE_NOOP("bitcoin-core", "Wallet %s resides outside data directory %s."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Cannot obtain a lock on data directory %s. UCoin is probably already "
"running."),
QT_TRANSLATE_NOOP("bitcoin-core", "Verifying database integrity..."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Error initializing database environment %s! To recover, BACKUP THAT "
"DIRECTORY, then remove everything from it except for wallet.dat."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as "
"wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect "
"you should restore from a backup."),
QT_TRANSLATE_NOOP("bitcoin-core", "wallet.dat corrupt, salvage failed"),
QT_TRANSLATE_NOOP("bitcoin-core", "Unknown -socks proxy version requested: %i"),
QT_TRANSLATE_NOOP("bitcoin-core", "Unknown network specified in -onlynet: '%s'"),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -proxy address: '%s'"),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -tor address: '%s'"),
QT_TRANSLATE_NOOP("bitcoin-core", "Cannot resolve -bind address: '%s'"),
QT_TRANSLATE_NOOP("bitcoin-core", "Failed to listen on any port. Use -listen=0 if you want this."),
QT_TRANSLATE_NOOP("bitcoin-core", "Cannot resolve -externalip address: '%s'"),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -reservebalance=<amount>"),
QT_TRANSLATE_NOOP("bitcoin-core", "Unable to sign checkpoint, wrong checkpointkey?\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Loading block index..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading blkindex.dat"),
QT_TRANSLATE_NOOP("bitcoin-core", "Loading wallet..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet corrupted"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Warning: error reading wallet.dat! All keys read correctly, but transaction "
"data or address book entries might be missing or incorrect."),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet requires newer version of UCoin"),
QT_TRANSLATE_NOOP("bitcoin-core", "Wallet needed to be rewritten: restart UCoin to complete"),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat"),
QT_TRANSLATE_NOOP("bitcoin-core", "Cannot downgrade wallet"),
QT_TRANSLATE_NOOP("bitcoin-core", "Cannot initialize keypool"),
QT_TRANSLATE_NOOP("bitcoin-core", "Cannot write default address"),
QT_TRANSLATE_NOOP("bitcoin-core", "Rescanning..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Importing blockchain data file."),
QT_TRANSLATE_NOOP("bitcoin-core", "Importing bootstrap blockchain data file."),
QT_TRANSLATE_NOOP("bitcoin-core", "Loading addresses..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Error: could not start node"),
QT_TRANSLATE_NOOP("bitcoin-core", "Done loading"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Unable to bind to %s on this computer. UCoin is probably already running."),
QT_TRANSLATE_NOOP("bitcoin-core", "Unable to bind to %s on this computer (bind returned error %d, %s)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Error: Wallet locked, unable to create transaction "),
QT_TRANSLATE_NOOP("bitcoin-core", "Error: Wallet unlocked for staking only, unable to create transaction."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Error: This transaction requires a transaction fee of at least %s because of "
"its amount, complexity, or use of recently received funds "),
QT_TRANSLATE_NOOP("bitcoin-core", "Error: Transaction creation failed "),
QT_TRANSLATE_NOOP("bitcoin-core", "Sending..."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Error: The transaction was rejected. This might happen if some of the coins "
"in your wallet were already spent, such as if you used a copy of wallet.dat "
"and coins were spent in the copy but not marked as spent here."),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount"),
QT_TRANSLATE_NOOP("bitcoin-core", "Insufficient funds"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Warning: Please check that your computer's date and time are correct! If "
"your clock is wrong UCoin will not work properly."),
QT_TRANSLATE_NOOP("bitcoin-core", "Warning: This version is obsolete, upgrade required!"),
QT_TRANSLATE_NOOP("bitcoin-core", "WARNING: syncronized checkpoint violation detected, but skipped!"),
QT_TRANSLATE_NOOP("bitcoin-core", "Warning: Disk space is low!"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"WARNING: Invalid checkpoint found! Displayed transactions may not be "
"correct! You may need to upgrade, or notify developers."),
}; |
#include <stdexcept>
#include <string>
#include "OnlineDB/Oracle/interface/Oracle.h"
#include "OnlineDB/EcalCondDB/interface/MonOccupancyDat.h"
using namespace std;
using namespace oracle::occi;
MonOccupancyDat::MonOccupancyDat()
{
m_env = nullptr;
m_conn = nullptr;
m_writeStmt = nullptr;
m_readStmt = nullptr;
m_eventsOverLowThreshold = 0;
m_eventsOverHighThreshold = 0;
m_avgEnergy = 0;
}
MonOccupancyDat::~MonOccupancyDat()
{
}
void MonOccupancyDat::prepareWrite()
noexcept(false)
{
this->checkConnection();
try {
m_writeStmt = m_conn->createStatement();
m_writeStmt->setSQL("INSERT INTO mon_occupancy_dat (iov_id, logic_id, "
"events_over_low_threshold, events_over_high_threshold, avg_energy) "
"VALUES (:iov_id, :logic_id, "
":3, :4, :5)");
} catch (SQLException &e) {
throw(std::runtime_error(std::string("MonOccupancyDat::prepareWrite(): ")+getOraMessage(&e)));
}
}
void MonOccupancyDat::writeDB(const EcalLogicID* ecid, const MonOccupancyDat* item, MonRunIOV* iov)
noexcept(false)
{
this->checkConnection();
this->checkPrepare();
int iovID = iov->fetchID();
if (!iovID) { throw(std::runtime_error("MonOccupancyDat::writeDB: IOV not in DB")); }
int logicID = ecid->getLogicID();
if (!logicID) { throw(std::runtime_error("MonOccupancyDat::writeDB: Bad EcalLogicID")); }
try {
m_writeStmt->setInt(1, iovID);
m_writeStmt->setInt(2, logicID);
m_writeStmt->setInt(3, item->getEventsOverLowThreshold() );
m_writeStmt->setInt(4, item->getEventsOverHighThreshold() );
m_writeStmt->setFloat(5, item->getAvgEnergy() );
m_writeStmt->executeUpdate();
} catch (SQLException &e) {
throw(std::runtime_error(std::string("MonOccupancyDat::writeDB(): ")+getOraMessage(&e)));
}
}
void MonOccupancyDat::fetchData(std::map< EcalLogicID, MonOccupancyDat >* fillMap, MonRunIOV* iov)
noexcept(false)
{
this->checkConnection();
fillMap->clear();
iov->setConnection(m_env, m_conn);
int iovID = iov->fetchID();
if (!iovID) {
// throw(std::runtime_error("MonOccupancyDat::writeDB: IOV not in DB"));
return;
}
try {
m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
"d.events_over_low_threshold, d.events_over_high_threshold, d.avg_energy "
"FROM channelview cv JOIN mon_occupancy_dat d "
"ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
"WHERE d.iov_id = :iov_id");
m_readStmt->setInt(1, iovID);
ResultSet* rset = m_readStmt->executeQuery();
std::pair< EcalLogicID, MonOccupancyDat > p;
MonOccupancyDat dat;
while(rset->next()) {
p.first = EcalLogicID( getOraString(rset,1), // name
rset->getInt(2), // logic_id
rset->getInt(3), // id1
rset->getInt(4), // id2
rset->getInt(5), // id3
getOraString(rset,6)); // maps_to
dat.setEventsOverLowThreshold( rset->getInt(7) );
dat.setEventsOverHighThreshold( rset->getInt(8) );
dat.setAvgEnergy( rset->getFloat(9) );
p.second = dat;
fillMap->insert(p);
}
} catch (SQLException &e) {
throw(std::runtime_error(std::string("MonOccupancyDat::fetchData(): ")+getOraMessage(&e)));
}
}
void MonOccupancyDat::writeArrayDB(const std::map< EcalLogicID, MonOccupancyDat >* data, MonRunIOV* iov)
noexcept(false)
{
this->checkConnection();
this->checkPrepare();
int iovID = iov->fetchID();
if (!iovID) { throw(std::runtime_error("MonOccupancyDat::writeArrayDB: IOV not in DB")); }
int nrows=data->size();
int* ids= new int[nrows];
int* iovid_vec= new int[nrows];
int* xx= new int[nrows];
int* yy= new int[nrows];
float* zz= new float[nrows];
ub2* ids_len= new ub2[nrows];
ub2* iov_len= new ub2[nrows];
ub2* x_len= new ub2[nrows];
ub2* y_len= new ub2[nrows];
ub2* z_len= new ub2[nrows];
const EcalLogicID* channel;
const MonOccupancyDat* dataitem;
int count=0;
typedef map< EcalLogicID, MonOccupancyDat >::const_iterator CI;
for (CI p = data->begin(); p != data->end(); ++p) {
channel = &(p->first);
int logicID = channel->getLogicID();
if (!logicID) { throw(std::runtime_error("MonOccupancyDat::writeArrayDB: Bad EcalLogicID")); }
ids[count]=logicID;
iovid_vec[count]=iovID;
dataitem = &(p->second);
// dataIface.writeDB( channel, dataitem, iov);
int x=dataitem->getEventsOverLowThreshold();
int y=dataitem->getEventsOverHighThreshold();
float z=dataitem->getAvgEnergy();
xx[count]=x;
yy[count]=y;
zz[count]=z;
ids_len[count]=sizeof(ids[count]);
iov_len[count]=sizeof(iovid_vec[count]);
x_len[count]=sizeof(xx[count]);
y_len[count]=sizeof(yy[count]);
z_len[count]=sizeof(zz[count]);
count++;
}
try {
m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT , sizeof(xx[0]), x_len );
m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT , sizeof(zz[0]), z_len );
m_writeStmt->executeArrayUpdate(nrows);
delete [] ids;
delete [] iovid_vec;
delete [] xx;
delete [] yy;
delete [] zz;
delete [] ids_len;
delete [] iov_len;
delete [] x_len;
delete [] y_len;
delete [] z_len;
} catch (SQLException &e) {
throw(std::runtime_error(std::string("MonOccupancyDat::writeArrayDB(): ")+getOraMessage(&e)));
}
}
|
; A087131: a(n) = 2^n*Lucas(n), where Lucas = A000032.
; 2,2,12,32,112,352,1152,3712,12032,38912,125952,407552,1318912,4268032,13811712,44695552,144637952,468058112,1514668032,4901568512,15861809152,51329892352,166107021312,537533612032,1739495309312
seq $0,14335 ; Exponential convolution of Fibonacci numbers with themselves (divided by 2).
mul $0,10
add $0,2
|
#include "emit.h"
#include <cstdio>
void emit_error(std::string text){
std::fputs(text.c_str(), stderr);
std::fputc('\n', stderr);
}
void emit_warning(std::string text){
std::fputs(text.c_str(), stdout);
std::fputc('\n', stdout);
}
|
; nasm -f elf32 ex2.asm -o ex2.o
; gcc -m32 ex2.o -o ex2.out
; ./ex2.out
; echo $?
global main
section .data
msg db "Hello, word!", 0x0a; "Hello, word!\n"
len equ $ - msg ; 13
section .text
main:
mov ebp, esp; for correct debugging
mov eax, 4 ; write call
mov ebx, 1 ; stdout
mov ecx, msg; ['H']
mov edx, len; 13 bytes
int 0x80 ; system call
mov eax, 1 ; exit call
mov ebx, 0 ; exit status
int 0x80 ; system call
|
; A229232: Number of undirected circular permutations pi(1), ..., pi(n) of 1, ..., n with the n numbers pi(1)*pi(2)-1, pi(2)*pi(3)-1, ..., pi(n-1)*pi(n)-1, pi(n)*pi(1)-1 all prime.
; Submitted by Jamie Morken(s4)
; 0,0,0,1,0,2,1,2,2,8
pow $0,2
dif $0,4
add $0,4
div $0,10
sub $0,1
dif $0,4
add $0,1
mod $0,10
|
// Computes sum=1+...+100.
@i // i=1
M=1
@sum // sum=0
M=0
(LOOP)
@i // if (i-100)=0 goto END
D=M
@100
D=D-A
@END
D;JGT
@i // sum+=i
D=M
@sum
M=D+M
@i // i++
M=M+1
@LOOP // goto LOOP
0;JMP
(END) // infinite loop
@END
0;JMP
|
; Arquivo: multiploDeDois.nasm
; Curso: Elementos de Sistemas
; Criado por: Rafael Corsi
; Data: 28/3/2019
;
; Verifica se o valor salvo no endereço RAM[5] é
; multiplo de dois, se for verdadeiro, salva 1
; em RAM[0] e 0 caso contrário.
|
Route14_Script:
call EnableAutoTextBoxDrawing
ld hl, Route14TrainerHeader0
ld de, Route14_ScriptPointers
ld a, [wRoute14CurScript]
call ExecuteCurMapScriptInTable
ld [wRoute14CurScript], a
ret
Route14_ScriptPointers:
dw CheckFightingMapTrainers
dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route14_TextPointers:
dw Route14Text1
dw Route14Text2
dw Route14Text3
dw Route14Text4
dw Route14Text5
dw Route14Text6
dw Route14Text7
dw Route14Text8
dw Route14Text9
dw Route14Text10
dw Route14Text11
Route14TrainerHeader0:
dbEventFlagBit EVENT_BEAT_ROUTE_14_TRAINER_0
db ($2 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_14_TRAINER_0
dw Route14BattleText1 ; TextBeforeBattle
dw Route14AfterBattleText1 ; TextAfterBattle
dw Route14EndBattleText1 ; TextEndBattle
dw Route14EndBattleText1 ; TextEndBattle
Route14TrainerHeader1:
dbEventFlagBit EVENT_BEAT_ROUTE_14_TRAINER_1
db ($2 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_14_TRAINER_1
dw Route14BattleText2 ; TextBeforeBattle
dw Route14AfterBattleText2 ; TextAfterBattle
dw Route14EndBattleText2 ; TextEndBattle
dw Route14EndBattleText2 ; TextEndBattle
Route14TrainerHeader2:
dbEventFlagBit EVENT_BEAT_ROUTE_14_TRAINER_2
db ($4 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_14_TRAINER_2
dw Route14BattleText3 ; TextBeforeBattle
dw Route14AfterBattleText3 ; TextAfterBattle
dw Route14EndBattleText3 ; TextEndBattle
dw Route14EndBattleText3 ; TextEndBattle
Route14TrainerHeader3:
dbEventFlagBit EVENT_BEAT_ROUTE_14_TRAINER_3
db ($3 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_14_TRAINER_3
dw Route14BattleText4 ; TextBeforeBattle
dw Route14AfterBattleText4 ; TextAfterBattle
dw Route14EndBattleText4 ; TextEndBattle
dw Route14EndBattleText4 ; TextEndBattle
Route14TrainerHeader4:
dbEventFlagBit EVENT_BEAT_ROUTE_14_TRAINER_4
db ($3 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_14_TRAINER_4
dw Route14BattleText5 ; TextBeforeBattle
dw Route14AfterBattleText5 ; TextAfterBattle
dw Route14EndBattleText5 ; TextEndBattle
dw Route14EndBattleText5 ; TextEndBattle
Route14TrainerHeader5:
dbEventFlagBit EVENT_BEAT_ROUTE_14_TRAINER_5
db ($4 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_14_TRAINER_5
dw Route14BattleText6 ; TextBeforeBattle
dw Route14AfterBattleText6 ; TextAfterBattle
dw Route14EndBattleText6 ; TextEndBattle
dw Route14EndBattleText6 ; TextEndBattle
Route14TrainerHeader6:
dbEventFlagBit EVENT_BEAT_ROUTE_14_TRAINER_6
db ($4 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_14_TRAINER_6
dw Route14BattleText7 ; TextBeforeBattle
dw Route14AfterBattleText7 ; TextAfterBattle
dw Route14EndBattleText7 ; TextEndBattle
dw Route14EndBattleText7 ; TextEndBattle
Route14TrainerHeader7:
dbEventFlagBit EVENT_BEAT_ROUTE_14_TRAINER_7, 1
db ($4 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_14_TRAINER_7, 1
dw Route14BattleText8 ; TextBeforeBattle
dw Route14AfterBattleText8 ; TextAfterBattle
dw Route14EndBattleText8 ; TextEndBattle
dw Route14EndBattleText8 ; TextEndBattle
Route14TrainerHeader8:
dbEventFlagBit EVENT_BEAT_ROUTE_14_TRAINER_8, 1
db ($3 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_14_TRAINER_8, 1
dw Route14BattleText9 ; TextBeforeBattle
dw Route14AfterBattleText9 ; TextAfterBattle
dw Route14EndBattleText9 ; TextEndBattle
dw Route14EndBattleText9 ; TextEndBattle
Route14TrainerHeader9:
dbEventFlagBit EVENT_BEAT_ROUTE_14_TRAINER_9, 1
db ($4 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_14_TRAINER_9, 1
dw Route14BattleText10 ; TextBeforeBattle
dw Route14AfterBattleText10 ; TextAfterBattle
dw Route14EndBattleText10 ; TextEndBattle
dw Route14EndBattleText10 ; TextEndBattle
db $ff
Route14Text1:
TX_ASM
ld hl, Route14TrainerHeader0
call TalkToTrainer
jp TextScriptEnd
Route14BattleText1:
TX_FAR _Route14BattleText1
db "@"
Route14EndBattleText1:
TX_FAR _Route14EndBattleText1
db "@"
Route14AfterBattleText1:
TX_FAR _Route14AfterBattleText1
db "@"
Route14Text2:
TX_ASM
ld hl, Route14TrainerHeader1
call TalkToTrainer
jp TextScriptEnd
Route14BattleText2:
TX_FAR _Route14BattleText2
db "@"
Route14EndBattleText2:
TX_FAR _Route14EndBattleText2
db "@"
Route14AfterBattleText2:
TX_FAR _Route14AfterBattleText2
db "@"
Route14Text3:
TX_ASM
ld hl, Route14TrainerHeader2
call TalkToTrainer
jp TextScriptEnd
Route14BattleText3:
TX_FAR _Route14BattleText3
db "@"
Route14EndBattleText3:
TX_FAR _Route14EndBattleText3
db "@"
Route14AfterBattleText3:
TX_FAR _Route14AfterBattleText3
db "@"
Route14Text4:
TX_ASM
ld hl, Route14TrainerHeader3
call TalkToTrainer
jp TextScriptEnd
Route14BattleText4:
TX_FAR _Route14BattleText4
db "@"
Route14EndBattleText4:
TX_FAR _Route14EndBattleText4
db "@"
Route14AfterBattleText4:
TX_FAR _Route14AfterBattleText4
db "@"
Route14Text5:
TX_ASM
ld hl, Route14TrainerHeader4
call TalkToTrainer
jp TextScriptEnd
Route14BattleText5:
TX_FAR _Route14BattleText5
db "@"
Route14EndBattleText5:
TX_FAR _Route14EndBattleText5
db "@"
Route14AfterBattleText5:
TX_FAR _Route14AfterBattleText5
db "@"
Route14Text6:
TX_ASM
ld hl, Route14TrainerHeader5
call TalkToTrainer
jp TextScriptEnd
Route14BattleText6:
TX_FAR _Route14BattleText6
db "@"
Route14EndBattleText6:
TX_FAR _Route14EndBattleText6
db "@"
Route14AfterBattleText6:
TX_FAR _Route14AfterBattleText6
db "@"
Route14Text7:
TX_ASM
ld hl, Route14TrainerHeader6
call TalkToTrainer
jp TextScriptEnd
Route14BattleText7:
TX_FAR _Route14BattleText7
db "@"
Route14EndBattleText7:
TX_FAR _Route14EndBattleText7
db "@"
Route14AfterBattleText7:
TX_FAR _Route14AfterBattleText7
db "@"
Route14Text8:
TX_ASM
ld hl, Route14TrainerHeader7
call TalkToTrainer
jp TextScriptEnd
Route14BattleText8:
TX_FAR _Route14BattleText8
db "@"
Route14EndBattleText8:
TX_FAR _Route14EndBattleText8
db "@"
Route14AfterBattleText8:
TX_FAR _Route14AfterBattleText8
db "@"
Route14Text9:
TX_ASM
ld hl, Route14TrainerHeader8
call TalkToTrainer
jp TextScriptEnd
Route14BattleText9:
TX_FAR _Route14BattleText9
db "@"
Route14EndBattleText9:
TX_FAR _Route14EndBattleText9
db "@"
Route14AfterBattleText9:
TX_FAR _Route14AfterBattleText9
db "@"
Route14Text10:
TX_ASM
ld hl, Route14TrainerHeader9
call TalkToTrainer
jp TextScriptEnd
Route14BattleText10:
TX_FAR _Route14BattleText10
db "@"
Route14EndBattleText10:
TX_FAR _Route14EndBattleText10
db "@"
Route14AfterBattleText10:
TX_FAR _Route14AfterBattleText10
db "@"
Route14Text11:
TX_FAR _Route14Text11
db "@"
|
/* <editor-fold desc="MIT License">
Copyright(c) 2018 Robert Osfield
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</editor-fold> */
#include <vsg/traversals/CompileTraversal.h>
#include <vsg/commands/Commands.h>
#include <vsg/commands/PipelineBarrier.h>
#include <vsg/io/Options.h>
#include <vsg/nodes/Geometry.h>
#include <vsg/nodes/Group.h>
#include <vsg/nodes/LOD.h>
#include <vsg/nodes/QuadGroup.h>
#include <vsg/state/StateGroup.h>
#include <vsg/vk/CommandBuffer.h>
#include <vsg/vk/Extensions.h>
#include <vsg/vk/RenderPass.h>
#include <vsg/vk/State.h>
#include <iostream>
using namespace vsg;
/////////////////////////////////////////////////////////////////////////////////////////
//
// BuildAccelerationStructureCommand
//
BuildAccelerationStructureCommand::BuildAccelerationStructureCommand(Device* device, VkAccelerationStructureInfoNV* info, const VkAccelerationStructureNV& structure, Buffer* instanceBuffer, Allocator* allocator) :
Inherit(allocator),
_device(device),
_accelerationStructureInfo(info),
_accelerationStructure(structure),
_instanceBuffer(instanceBuffer)
{
}
void BuildAccelerationStructureCommand::record(CommandBuffer& commandBuffer) const
{
Extensions* extensions = Extensions::Get(_device, true);
extensions->vkCmdBuildAccelerationStructureNV(commandBuffer,
_accelerationStructureInfo,
_instanceBuffer.valid() ? _instanceBuffer->vk(commandBuffer.deviceID) : (VkBuffer)VK_NULL_HANDLE,
0,
VK_FALSE,
_accelerationStructure,
VK_NULL_HANDLE,
_scratchBuffer->vk(commandBuffer.deviceID),
0);
VkMemoryBarrier memoryBarrier;
memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
memoryBarrier.pNext = nullptr;
memoryBarrier.srcAccessMask = VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_NV | VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_NV;
memoryBarrier.dstAccessMask = VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_NV | VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_NV;
vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_NV, VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_NV, 0, 1, &memoryBarrier, 0, 0, 0, 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// vsg::Context
//
Context::Context(Device* in_device, BufferPreferences bufferPreferences) :
deviceID(in_device->deviceID),
device(in_device),
deviceMemoryBufferPools(MemoryBufferPools::create("Device_MemoryBufferPool", device, bufferPreferences)),
stagingMemoryBufferPools(MemoryBufferPools::create("Staging_MemoryBufferPool", device, bufferPreferences)),
scratchBufferSize(0)
{
//semaphore = vsg::Semaphore::create(device);
scratchMemory = ScratchMemory::create(4096);
}
Context::Context(const Context& context) :
Inherit(context),
deviceID(context.deviceID),
device(context.device),
renderPass(context.renderPass),
defaultPipelineStates(context.defaultPipelineStates),
overridePipelineStates(context.overridePipelineStates),
descriptorPool(context.descriptorPool),
graphicsQueue(context.graphicsQueue),
commandPool(context.commandPool),
deviceMemoryBufferPools(context.deviceMemoryBufferPools),
stagingMemoryBufferPools(context.stagingMemoryBufferPools),
scratchBufferSize(context.scratchBufferSize)
{
scratchMemory = ScratchMemory::create(4096);
}
Context::~Context()
{
waitForCompletion();
}
ref_ptr<CommandBuffer> Context::getOrCreateCommandBuffer()
{
if (!commandBuffer)
{
commandBuffer = vsg::CommandBuffer::create(device, commandPool);
}
return commandBuffer;
}
ShaderCompiler* Context::getOrCreateShaderCompiler()
{
if (shaderCompiler) return shaderCompiler;
#ifdef HAS_GLSLANG
shaderCompiler = new ShaderCompiler;
#endif
return shaderCompiler;
}
bool Context::record()
{
if (commands.empty() && buildAccelerationStructureCommands.empty()) return false;
//auto before_compile = std::chrono::steady_clock::now();
if (!fence)
{
fence = vsg::Fence::create(device);
}
else
{
fence->reset();
}
getOrCreateCommandBuffer();
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
vkBeginCommandBuffer(*commandBuffer, &beginInfo);
// issue commands of interest
{
for (auto& command : commands) command->record(*commandBuffer);
}
// create scratch buffer and issue build acceleration structure commands
ref_ptr<Buffer> scratchBuffer;
ref_ptr<DeviceMemory> scratchBufferMemory;
if (scratchBufferSize > 0)
{
scratchBuffer = vsg::createBufferAndMemory(device, scratchBufferSize, VK_BUFFER_USAGE_RAY_TRACING_BIT_NV, VK_SHARING_MODE_EXCLUSIVE, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
for (auto& command : buildAccelerationStructureCommands)
{
command->_scratchBuffer = scratchBuffer;
command->record(*commandBuffer);
}
}
vkEndCommandBuffer(*commandBuffer);
VkPipelineStageFlags waitDstStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
VkSubmitInfo submitInfo = {};
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = commandBuffer->data();
if (semaphore)
{
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = semaphore->data();
submitInfo.pWaitDstStageMask = &waitDstStageMask;
}
else
{
submitInfo.signalSemaphoreCount = 0;
submitInfo.pSignalSemaphores = nullptr;
}
graphicsQueue->submit(submitInfo, fence);
return true;
}
void Context::waitForCompletion()
{
if (!commandBuffer || !fence)
{
return;
}
if (commands.empty() && buildAccelerationStructureCommands.empty())
{
return;
}
// we must wait for the queue to empty before we can safely clean up the commandBuffer
uint64_t timeout = 1000000000;
if (timeout > 0)
{
VkResult result;
while ((result = fence->wait(timeout)) == VK_TIMEOUT)
{
std::cout << "Context::waitForCompletion() " << this << " fence->wait() timed out, trying again." << std::endl;
}
if (result != VK_SUCCESS)
{
std::cout << "Context::waitForCompletion() " << this << " fence->wait() failed with error. VkResult = " << result << std::endl;
}
}
commands.clear();
}
|
#include <matplot/matplot.h>
int main() {
using namespace matplot;
auto z = rand(5,5,0,10);
stem3(z);
ztickformat("usd");
wait();
return 0;
}
|
db 0 ; species ID placeholder
db 55, 50, 45, 120, 135, 85
; hp atk def spd sat sdf
db PSYCHIC, PSYCHIC ; type
db 50 ; catch rate
db 186 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F25 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/alakazam/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_SLOW ; growth rate
dn EGG_HUMANSHAPE, EGG_HUMANSHAPE ; egg groups
; tm/hm learnset
tmhm DYNAMICPUNCH, HEADBUTT, CURSE, TOXIC, ZAP_CANNON, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, RETURN, DIG, PSYCHIC_M, SHADOW_BALL, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, THUNDERPUNCH, DREAM_EATER, REST, ATTRACT, THIEF, FIRE_PUNCH, NIGHTMARE
; end
|
SECTION code_clib
SECTION code_l_sccz80
PUBLIC __atof2
EXTERN atof
__atof2:
push hl
call atof
pop bc
ret
|
#include "idl.h"
#include "idl_extern.h"
#include "be.h"
#include "be_visitor_interface.h"
ACE_RCSID (be_visitor_interface, base_proxy_broker_sh, "strategized_proxy_broker_sh.cpp,v 1.7 2001/05/31 04:48:55 othman Exp")
be_visitor_interface_strategized_proxy_broker_sh::be_visitor_interface_strategized_proxy_broker_sh (be_visitor_context *ctx)
: be_visitor_interface (ctx)
{
// No-Op.
}
be_visitor_interface_strategized_proxy_broker_sh::~be_visitor_interface_strategized_proxy_broker_sh (void)
{
// No-Op.
}
int
be_visitor_interface_strategized_proxy_broker_sh::visit_interface (be_interface *node)
{
TAO_OutStream *os = this->ctx_->stream ();
// os->gen_ifdef_macro (node->local_name (), "STRATEGIZED_PROXY_BROKER_");
// Generate the class declaration.
os->indent ();
*os << be_nl
<< "///////////////////////////////////////////////////////////////////////" << be_nl
<< "// Strategized Proxy Broker Declaration " << be_nl
<< "//" << be_nl << be_nl;
*os << "class " << be_global->skel_export_macro () << " "
<< node->strategized_proxy_broker_name () << " : public virtual "
<< "::" << node->full_base_proxy_broker_name () << be_nl << "{" << be_nl
<< "public: " << be_idt_nl;
// Constructor
*os << node->strategized_proxy_broker_name () << " (void);" << be_nl << be_nl;
// Destructor
*os << "virtual ~" << node->strategized_proxy_broker_name () << " (void);" << be_nl << be_nl;
// Accessor Method
*os << "virtual " << "::" << node->full_base_proxy_impl_name () << " &" << "select_proxy (" << be_idt_nl;
*os << "::" << node->full_name () << " *object," << be_nl
<< "CORBA_Environment &ACE_TRY_ENV" << be_uidt_nl
<< ");" << be_uidt_nl << be_nl;
*os << "private:" << be_idt_nl
<< "// Helper methods that takes care to create the proxy" << be_nl
<< "// as soon as their use is necessary." << be_nl
<< "void create_proxy (" << be_idt_nl << "int collocation_strategy,"
<< be_nl << "CORBA::Environment &ACE_TRY_ENV"
<< be_uidt_nl << ");"
<< be_nl << be_nl
<< "// Caches the proxy implementations. The proxy implementation" << be_nl
<< "// are totally stateless, and those can be shared by all the" << be_nl
<< "// instances of a given IDL interface type." << be_nl
<< "::" << node->full_base_proxy_impl_name () << be_nl
<< "*proxy_cache_[TAO_Collocation_Strategies::CS_LAST];"
<< be_nl << be_nl
<< "TAO_SYNCH_MUTEX mutex_;" << be_nl;
// Factory Function declaration.
*os << "// This funxtion is used to get an handle to the unique instance" << be_nl
<< "// of the Strategized Proxy Broker that is available for a given" << be_nl
<< "// interface."
<< be_uidt_nl << be_nl;
*os << "public:" << be_idt_nl
<< "static " << node->strategized_proxy_broker_name ()
<< " *the" << node->strategized_proxy_broker_name ()
<< " (void);" << be_uidt_nl;
*os << "};" << be_nl << be_nl;
*os << be_nl
<< "//" << be_nl
<< "// End Strategized Proxy Broker Declaration " << be_nl
<< "///////////////////////////////////////////////////////////////////////"
<< be_nl << be_nl;
return 0;
}
|
<%
from pwnlib.shellcraft.powerpc.linux import syscall
%>
<%page args="sig, handler"/>
<%docstring>
Invokes the syscall signal. See 'man 2 signal' for more information.
Arguments:
sig(int): sig
handler(sighandler_t): handler
</%docstring>
${syscall('SYS_signal', sig, handler)}
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Copyright (c) 2013 The NovaCoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "txdb.h"
#include "miner.h"
#include "kernel.h"
using namespace std;
//////////////////////////////////////////////////////////////////////////////
//
// BitcoinMiner
//
extern unsigned int nMinerSleep;
int static FormatHashBlocks(void* pbuffer, unsigned int len)
{
unsigned char* pdata = (unsigned char*)pbuffer;
unsigned int blocks = 1 + ((len + 8) / 64);
unsigned char* pend = pdata + 64 * blocks;
memset(pdata + len, 0, 64 * blocks - len);
pdata[len] = 0x80;
unsigned int bits = len * 8;
pend[-1] = (bits >> 0) & 0xff;
pend[-2] = (bits >> 8) & 0xff;
pend[-3] = (bits >> 16) & 0xff;
pend[-4] = (bits >> 24) & 0xff;
return blocks;
}
static const unsigned int pSHA256InitState[8] =
{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
void SHA256Transform(void* pstate, void* pinput, const void* pinit)
{
SHA256_CTX ctx;
unsigned char data[64];
SHA256_Init(&ctx);
for (int i = 0; i < 16; i++)
((uint32_t*)data)[i] = ByteReverse(((uint32_t*)pinput)[i]);
for (int i = 0; i < 8; i++)
ctx.h[i] = ((uint32_t*)pinit)[i];
SHA256_Update(&ctx, data, sizeof(data));
for (int i = 0; i < 8; i++)
((uint32_t*)pstate)[i] = ctx.h[i];
}
// Some explaining would be appreciated
class COrphan
{
public:
CTransaction* ptx;
set<uint256> setDependsOn;
double dPriority;
double dFeePerKb;
COrphan(CTransaction* ptxIn)
{
ptx = ptxIn;
dPriority = dFeePerKb = 0;
}
void print() const
{
printf("COrphan(hash=%s, dPriority=%.1f, dFeePerKb=%.1f)\n",
ptx->GetHash().ToString().substr(0,10).c_str(), dPriority, dFeePerKb);
BOOST_FOREACH(uint256 hash, setDependsOn)
printf(" setDependsOn %s\n", hash.ToString().substr(0,10).c_str());
}
};
uint64_t nLastBlockTx = 0;
uint64_t nLastBlockSize = 0;
int64_t nLastCoinStakeSearchInterval = 0;
// We want to sort transactions by priority and fee, so:
typedef boost::tuple<double, double, CTransaction*> TxPriority;
class TxPriorityCompare
{
bool byFee;
public:
TxPriorityCompare(bool _byFee) : byFee(_byFee) { }
bool operator()(const TxPriority& a, const TxPriority& b)
{
if (byFee)
{
if (a.get<1>() == b.get<1>())
return a.get<0>() < b.get<0>();
return a.get<1>() < b.get<1>();
}
else
{
if (a.get<0>() == b.get<0>())
return a.get<1>() < b.get<1>();
return a.get<0>() < b.get<0>();
}
}
};
// CreateNewBlock: create new block (without proof-of-work/proof-of-stake)
CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake, int64_t* pFees)
{
// Create new block
auto_ptr<CBlock> pblock(new CBlock());
if (!pblock.get())
return NULL;
CBlockIndex* pindexPrev = pindexBest;
// Create coinbase tx
CTransaction txNew;
txNew.vin.resize(1);
txNew.vin[0].prevout.SetNull();
txNew.vout.resize(1);
if (!fProofOfStake)
{
CReserveKey reservekey(pwallet);
CPubKey pubkey;
if (!reservekey.GetReservedKey(pubkey))
return NULL;
txNew.vout[0].scriptPubKey.SetDestination(pubkey.GetID());
}
else
{
// Height first in coinbase required for block.version=2
txNew.vin[0].scriptSig = (CScript() << pindexPrev->nHeight+1) + COINBASE_FLAGS;
assert(txNew.vin[0].scriptSig.size() <= 100);
txNew.vout[0].SetEmpty();
}
// Add our coinbase tx as first transaction
pblock->vtx.push_back(txNew);
// Largest block you're willing to create:
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2);
// Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity:
nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize));
// How much of the block should be dedicated to high-priority transactions,
// included regardless of the fees they pay
unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", 27000);
nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize);
// Minimum block size you want to create; block will be filled with free transactions
// until there are no more or the block reaches this size:
unsigned int nBlockMinSize = GetArg("-blockminsize", 0);
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
// Fee-per-kilobyte amount considered the same as "free"
// Be careful setting this: if you set it to zero then
// a transaction spammer can cheaply fill blocks using
// 1-satoshi-fee transactions. It should be set above the real
// cost to you of processing a transaction.
int64_t nMinTxFee = MIN_TX_FEE;
if (mapArgs.count("-mintxfee"))
ParseMoney(mapArgs["-mintxfee"], nMinTxFee);
pblock->nBits = GetNextTargetRequired(pindexPrev, fProofOfStake);
// Collect memory pool transactions into the block
int64_t nFees = 0;
{
LOCK2(cs_main, mempool.cs);
CTxDB txdb("r");
// Priority order to process transactions
list<COrphan> vOrphan; // list memory doesn't move
map<uint256, vector<COrphan*> > mapDependers;
// This vector will be sorted into a priority queue:
vector<TxPriority> vecPriority;
vecPriority.reserve(mempool.mapTx.size());
for (map<uint256, CTransaction>::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi)
{
CTransaction& tx = (*mi).second;
if (tx.IsCoinBase() || tx.IsCoinStake() || !IsFinalTx(tx, pindexPrev->nHeight + 1))
continue;
COrphan* porphan = NULL;
double dPriority = 0;
int64_t nTotalIn = 0;
bool fMissingInputs = false;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
// Read prev transaction
CTransaction txPrev;
CTxIndex txindex;
if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex))
{
// This should never happen; all transactions in the memory
// pool should connect to either transactions in the chain
// or other transactions in the memory pool.
if (!mempool.mapTx.count(txin.prevout.hash))
{
printf("ERROR: mempool transaction missing input\n");
if (fDebug) assert("mempool transaction missing input" == 0);
fMissingInputs = true;
if (porphan)
vOrphan.pop_back();
break;
}
// Has to wait for dependencies
if (!porphan)
{
// Use list for automatic deletion
vOrphan.push_back(COrphan(&tx));
porphan = &vOrphan.back();
}
mapDependers[txin.prevout.hash].push_back(porphan);
porphan->setDependsOn.insert(txin.prevout.hash);
nTotalIn += mempool.mapTx[txin.prevout.hash].vout[txin.prevout.n].nValue;
continue;
}
int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue;
nTotalIn += nValueIn;
int nConf = txindex.GetDepthInMainChain();
dPriority += (double)nValueIn * nConf;
}
if (fMissingInputs) continue;
// Priority is sum(valuein * age) / txsize
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
dPriority /= nTxSize;
// This is a more accurate fee-per-kilobyte than is used by the client code, because the
// client code rounds up the size to the nearest 1K. That's good, because it gives an
// incentive to create smaller transactions.
double dFeePerKb = double(nTotalIn-tx.GetValueOut()) / (double(nTxSize)/1000.0);
if (porphan)
{
porphan->dPriority = dPriority;
porphan->dFeePerKb = dFeePerKb;
}
else
vecPriority.push_back(TxPriority(dPriority, dFeePerKb, &(*mi).second));
}
// Collect transactions into block
map<uint256, CTxIndex> mapTestPool;
uint64_t nBlockSize = 1000;
uint64_t nBlockTx = 0;
int nBlockSigOps = 100;
bool fSortedByFee = (nBlockPrioritySize <= 0);
TxPriorityCompare comparer(fSortedByFee);
std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);
while (!vecPriority.empty())
{
// Take highest priority transaction off the priority queue:
double dPriority = vecPriority.front().get<0>();
double dFeePerKb = vecPriority.front().get<1>();
CTransaction& tx = *(vecPriority.front().get<2>());
std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer);
vecPriority.pop_back();
// Size limits
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
if (nBlockSize + nTxSize >= nBlockMaxSize)
continue;
// Legacy limits on sigOps:
unsigned int nTxSigOps = tx.GetLegacySigOpCount();
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
continue;
// Timestamp limit
if (tx.nTime > GetAdjustedTime() || (fProofOfStake && tx.nTime > pblock->vtx[0].nTime))
continue;
// Transaction fee
int64_t nMinFee = tx.GetMinFee(nBlockSize, GMF_BLOCK);
// Skip free transactions if we're past the minimum block size:
if (fSortedByFee && (dFeePerKb < nMinTxFee) && (nBlockSize + nTxSize >= nBlockMinSize))
continue;
// Prioritize by fee once past the priority size or we run out of high-priority
// transactions:
if (!fSortedByFee &&
((nBlockSize + nTxSize >= nBlockPrioritySize) || (dPriority < COIN * 144 / 250)))
{
fSortedByFee = true;
comparer = TxPriorityCompare(fSortedByFee);
std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);
}
// Connecting shouldn't fail due to dependency on other memory pool transactions
// because we're already processing them in order of dependency
map<uint256, CTxIndex> mapTestPoolTmp(mapTestPool);
MapPrevTx mapInputs;
bool fInvalid;
if (!tx.FetchInputs(txdb, mapTestPoolTmp, false, true, mapInputs, fInvalid))
continue;
int64_t nTxFees = tx.GetValueIn(mapInputs)-tx.GetValueOut();
if (nTxFees < nMinFee)
continue;
nTxSigOps += tx.GetP2SHSigOpCount(mapInputs);
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
continue;
if (!tx.ConnectInputs(txdb, mapInputs, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, false, true))
continue;
mapTestPoolTmp[tx.GetHash()] = CTxIndex(CDiskTxPos(1,1,1), tx.vout.size());
swap(mapTestPool, mapTestPoolTmp);
// Added
pblock->vtx.push_back(tx);
nBlockSize += nTxSize;
++nBlockTx;
nBlockSigOps += nTxSigOps;
nFees += nTxFees;
if (fDebug && GetBoolArg("-printpriority"))
{
printf("priority %.1f feeperkb %.1f txid %s\n",
dPriority, dFeePerKb, tx.GetHash().ToString().c_str());
}
// Add transactions that depend on this one to the priority queue
uint256 hash = tx.GetHash();
if (mapDependers.count(hash))
{
BOOST_FOREACH(COrphan* porphan, mapDependers[hash])
{
if (!porphan->setDependsOn.empty())
{
porphan->setDependsOn.erase(hash);
if (porphan->setDependsOn.empty())
{
vecPriority.push_back(TxPriority(porphan->dPriority, porphan->dFeePerKb, porphan->ptx));
std::push_heap(vecPriority.begin(), vecPriority.end(), comparer);
}
}
}
}
}
nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize;
if (fDebug && GetBoolArg("-printpriority"))
printf("CreateNewBlock(): total size %"PRIu64"\n", nBlockSize);
if (!fProofOfStake)
pblock->vtx[0].vout[0].nValue = GetProofOfWorkReward(nFees);
if (pFees)
*pFees = nFees;
// Fill in header
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
pblock->nTime = max(pindexPrev->GetPastTimeLimit()+1, pblock->GetMaxTransactionTime());
pblock->nTime = max(pblock->GetBlockTime(), PastDrift(pindexPrev->GetBlockTime()));
if (!fProofOfStake)
pblock->UpdateTime(pindexPrev);
pblock->nNonce = 0;
}
return pblock.release();
}
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
{
// Update nExtraNonce
static uint256 hashPrevBlock;
if (hashPrevBlock != pblock->hashPrevBlock)
{
nExtraNonce = 0;
hashPrevBlock = pblock->hashPrevBlock;
}
++nExtraNonce;
unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2
pblock->vtx[0].vin[0].scriptSig = (CScript() << nHeight << CBigNum(nExtraNonce)) + COINBASE_FLAGS;
assert(pblock->vtx[0].vin[0].scriptSig.size() <= 100);
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
}
void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1)
{
//
// Pre-build hash buffers
//
struct
{
struct unnamed2
{
int nVersion;
uint256 hashPrevBlock;
uint256 hashMerkleRoot;
unsigned int nTime;
unsigned int nBits;
unsigned int nNonce;
}
block;
unsigned char pchPadding0[64];
uint256 hash1;
unsigned char pchPadding1[64];
}
tmp;
memset(&tmp, 0, sizeof(tmp));
tmp.block.nVersion = pblock->nVersion;
tmp.block.hashPrevBlock = pblock->hashPrevBlock;
tmp.block.hashMerkleRoot = pblock->hashMerkleRoot;
tmp.block.nTime = pblock->nTime;
tmp.block.nBits = pblock->nBits;
tmp.block.nNonce = pblock->nNonce;
FormatHashBlocks(&tmp.block, sizeof(tmp.block));
FormatHashBlocks(&tmp.hash1, sizeof(tmp.hash1));
// Byte swap all the input buffer
for (unsigned int i = 0; i < sizeof(tmp)/4; i++)
((unsigned int*)&tmp)[i] = ByteReverse(((unsigned int*)&tmp)[i]);
// Precalc the first half of the first hash, which stays constant
SHA256Transform(pmidstate, &tmp.block, pSHA256InitState);
memcpy(pdata, &tmp.block, 128);
memcpy(phash1, &tmp.hash1, 64);
}
bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
{
uint256 hashBlock = pblock->GetHash();
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
if(!pblock->IsProofOfWork())
return error("CheckWork() : %s is not a proof-of-work block", hashBlock.GetHex().c_str());
if (hashBlock > hashTarget)
return error("CheckWork() : proof-of-work not meeting target");
//// debug print
printf("CheckWork() : new proof-of-work block found \n hash: %s \ntarget: %s\n", hashBlock.GetHex().c_str(), hashTarget.GetHex().c_str());
pblock->print();
printf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str());
// Found a solution
{
LOCK(cs_main);
if (pblock->hashPrevBlock != hashBestChain)
return error("CheckWork() : generated block is stale");
// Remove key from key pool
reservekey.KeepKey();
// Track how many getdata requests this block gets
{
LOCK(wallet.cs_wallet);
wallet.mapRequestCount[hashBlock] = 0;
}
// Process this block the same as if we had received it from another node
if (!ProcessBlock(NULL, pblock))
return error("CheckWork() : ProcessBlock, block not accepted");
}
return true;
}
bool CheckStake(CBlock* pblock, CWallet& wallet)
{
uint256 proofHash = 0, hashTarget = 0;
uint256 hashBlock = pblock->GetHash();
if(!pblock->IsProofOfStake())
return error("CheckStake() : %s is not a proof-of-stake block", hashBlock.GetHex().c_str());
// verify hash target and signature of coinstake tx
if (!CheckProofOfStake(pblock->vtx[1], pblock->nBits, proofHash, hashTarget))
return error("CheckStake() : proof-of-stake checking failed");
//// debug print
printf("CheckStake() : new proof-of-stake block found \n hash: %s \nproofhash: %s \ntarget: %s\n", hashBlock.GetHex().c_str(), proofHash.GetHex().c_str(), hashTarget.GetHex().c_str());
pblock->print();
printf("out %s\n", FormatMoney(pblock->vtx[1].GetValueOut()).c_str());
// Found a solution
{
LOCK(cs_main);
if (pblock->hashPrevBlock != hashBestChain)
return error("CheckStake() : generated block is stale");
// Track how many getdata requests this block gets
{
LOCK(wallet.cs_wallet);
wallet.mapRequestCount[hashBlock] = 0;
}
// Process this block the same as if we had received it from another node
if (!ProcessBlock(NULL, pblock))
return error("CheckStake() : ProcessBlock, block not accepted");
}
return true;
}
void StakeMiner(CWallet *pwallet)
{
SetThreadPriority(THREAD_PRIORITY_LOWEST);
// Make this thread recognisable as the mining thread
RenameThread("gpu-miner");
bool fTryToSync = true;
while (true)
{
if (fShutdown)
return;
while (pwallet->IsLocked())
{
nLastCoinStakeSearchInterval = 0;
MilliSleep(1000);
if (fShutdown)
return;
}
while (vNodes.empty() || IsInitialBlockDownload())
{
nLastCoinStakeSearchInterval = 0;
fTryToSync = true;
MilliSleep(1000);
if (fShutdown)
return;
}
if (fTryToSync)
{
fTryToSync = false;
if (vNodes.size() < 3 || nBestHeight < GetNumBlocksOfPeers())
{
MilliSleep(60000);
continue;
}
}
//
// Create new block
//
int64_t nFees;
auto_ptr<CBlock> pblock(CreateNewBlock(pwallet, true, &nFees));
if (!pblock.get())
return;
// Trying to sign a block
if (pblock->SignBlock(*pwallet, nFees))
{
SetThreadPriority(THREAD_PRIORITY_NORMAL);
CheckStake(pblock.get(), *pwallet);
SetThreadPriority(THREAD_PRIORITY_LOWEST);
MilliSleep(500);
}
else
MilliSleep(nMinerSleep);
}
}
|
; A160812: a(n) = A161205(n)-A000005(n).
; Submitted by Jamie Morken(w4)
; 0,0,0,0,2,0,2,0,2,2,4,0,4,2,2,2,6,2,6,2,4,4,6,0,6,6,6,4,8,2,8,4,6,6,6,2,10,8,8,4,10,4,10,6,6,8,10,2,10,8,10,8,12,6,10,6,10,10,12,2,12,10,8,8,12,8,14,10,12,8,14,4,14,12,10,10,12,8,14,6,12,14,16,6,14,14,14,10,16,6
sub $0,1
mov $2,$0
mov $4,1
lpb $0
add $4,1
min $0,$4
mov $3,$2
dif $3,$0
cmp $3,$2
sub $2,$4
mov $0,$2
add $1,$3
sub $2,$4
lpe
mov $0,$1
mul $0,2
|
#pragma once
// This file is generated from the Game's Reflection data
#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/Scripting/Natives/Generated/anim/AnimFeature.hpp>
namespace RED4ext
{
namespace anim {
struct AnimFeature_CrowdLocomotion : anim::AnimFeature
{
static constexpr const char* NAME = "animAnimFeature_CrowdLocomotion";
static constexpr const char* ALIAS = NAME;
float speed; // 40
float slopeAngle; // 44
bool isCrowd; // 48
uint8_t unk49[0x50 - 0x49]; // 49
};
RED4EXT_ASSERT_SIZE(AnimFeature_CrowdLocomotion, 0x50);
} // namespace anim
} // namespace RED4ext
|
org 0x00;
JMP init;
org 0x23;
JMP irq;
org 0x30;
init:
MOV PCON, #0x80; ustawienie SMOD (najstarszego bitu PCON) na wartość 1
MOV SCON, #0x50; ustawienie REN = 1 - uaktywnienie odbiornika
MOV TMOD, #0x20; ustawienie drugiego trybu timera - zegara z przeładowaniem
MOV TH1, #0xF5; prędkość transmisji 4800 [bit/sek]
MOV TL1, #0xF5; prędkość transmisji 4800 [bit/sek]
SETB TR1; uruchomienie licznika
SETB EA; zezwolenie na globalne przerwania
SETB ES; zezwolenie na przerwania z portu szeregowego
SETB REN; uaktywnienie odbiornika
CLR RI; wyczyszczenie znacznika przerwania odbiornika
SETB TI; ustawienie znacznika przerwania nadajnika - programowe wywołanie pierwszego przerwania
main:
JMP main; ponowne wykonanie głównego programu
irq:
JNB RI, zero; skocz do etykiety "zero" jeśli bit zerowy - sprawdzenie rodzaju przerwania
CLR RI; wyczyszczenie znacznika przerwania odbiornika
MOV SBUF, A; wysłanie kodu ASCII wpisanego znaku
MOV A, SBUF; odbiór zapamiętanego kodu ASCII przez mikrokontroler
zero:
JNB TI, irq; skocz do etykiety "irq" jeśli bit zerowy
CLR TI; wyczyszczenie znacznika przerwania nadajnika
RETI; powrót z procedury obsługi przerwania
end;
|
; A111002: a(n) = gcd(f(n), f(n+1)) where f(n) = n^4 + n^2 + 1.
; Submitted by Christian Krause
; 1,3,7,91,21,31,43,57,73,91,777,133,157,183,211,241,273,2149,343,381,421,463,507,553,4207,651,703,757,813,871,931,6951,1057,1123,1191,1261,1333,1407,10381,1561,1641,1723,1807,1893,1981,14497,2163,2257,2353,2451,2551,2653,19299,2863,2971,3081,3193,3307,3423,24787,3661,3783,3907,4033,4161,4291,30961,4557,4693,4831,4971,5113,5257,37821,5551,5701,5853,6007,6163,6321,45367,6643,6807,6973,7141,7311,7483,53599,7833,8011,8191,8373,8557,8743,62517,9121,9313,9507,9703,9901
mov $1,$0
add $0,1
pow $1,2
add $1,$0
mul $0,2
sub $0,1
gcd $0,7
mul $1,$0
mov $0,$1
|
TESTSTATUS equ $ffffff00
; Populate Exception Vectors
;
org $00000
dc.l $000003F0 ; Vector = 0 Reset Supervisor Stack Pointer
dc.l $00000400 ; Vector = 1 Reset Initial PC
dc.l $22222222 ; Vector = 2 Bus Error
dc.l $30303033 ; Vector = 3 Address Error
dc.l $44444444 ; Vector = 4 Illegal Instruction
dc.l $55555555 ; Vector = 5 Zero Divide
dc.l $0000F010 ; Vector = 6 CHK Instruction
dc.l $0000F020 ; Vector = 7 TRAPV Instruction
dc.l $88888888 ; Vector = 8 Privilege Violation
dc.l $99999999 ; Vector = 9 Trace
dc.l $aaaaaaaa ; Vector = 10 Line A Emulator
dc.l $bbbbbbbb ; Vector = 11 Line F Emulator
org $00060
dc.l $12121212 ; Vector = 24 Spurrious Interrupt
dc.l $11111111 ; Vector = 25 Level 1 Interrupt Autovector
dc.l $22222222 ; Vector = 26 Level 2 Interrupt Autovector
dc.l $33333333 ; Vector = 27 Level 3 Interrupt Autovector
dc.l $44444444 ; Vector = 28 Level 4 Interrupt Autovector
dc.l $55555555 ; Vector = 29 Level 5 Interrupt Autovector
dc.l $66666666 ; Vector = 30 Level 6 Interrupt Autovector
dc.l $77777777 ; Vector = 31 Level 7 Interrupt Autovector
; Loop here when all tests pass
;
org $00F000
ALL_DONE:
move #$2700,sr
stop #$2700
; Exception Vector = 6 CHK Instruction
;
org $00F010
EXCEPTION_6:
move.l #$EEEE0006,d6 ; Set d6 to the exception vector
rte
; Exception Vector = 7 TRAPV Instruction
;
org $00F020
EXCEPTION_7:
move.l #$12345678,d0 ; Set d6 to the exception vector
rte
; Beginning of opcode tests
;
org $000400
move.l #$000003F0,a7 ; populate stack pointer
jsr op_ORI_TO_CCR
jsr op_ORI_TO_SR
jsr op_EORI_TO_CCR
jsr op_EORI_TO_SR
jsr op_ANDI_TO_CCR
jsr op_ANDI_TO_SR
jsr op_BTST
jsr op_BCHG
jsr op_BCLR
jsr op_BSET
jsr op_MOVEP
jsr op_BOOL_I
jsr op_BSR
jsr op_CMP_I
jsr op_ADD_I
jsr op_SUB_I
jsr op_MOVE
jsr op_MOVE_xxx_FLAGS
jsr op_EXT
jsr op_SWAP
jsr op_LEAPEA
jsr op_TAS
jsr op_TST
jsr op_LINKS
jsr op_MOVE_USP
jsr op_CHK
jsr op_NEGS
jsr op_CLR
jsr op_MOVEM
jsr op_TRAPV
jsr op_RTR
jsr op_BCC
jsr op_DBCC
jsr op_SCC
jsr op_ADDQ
jsr op_SUBQ
jsr op_MOVEQ
jsr op_DIVU
jsr op_DIVS
jsr op_OR
jsr op_AND
jsr op_EOR
jsr op_CMP
jsr op_CMPA
jsr op_CMPM
jsr op_ADD
jsr op_SUB
jsr op_ADDA
jsr op_SUBA
jsr op_ADDX
jsr op_SUBX
jsr op_MULU
jsr op_MULS
jsr op_EXG
jsr op_ROx
jsr op_ROXx
jsr op_SHIFTS2
jsr op_SHIFTS
jsr op_ABCD
jsr op_SBCD
jsr op_NBCD
jmp ALL_DONE
BSR_FAR1: move.l #$33333333,d3
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ORI_TO_CCR
;-----------------------------------------------------------
;-----------------------------------------------------------
op_ORI_TO_CCR:
ori.b #$FF,CCR
bpl ORI_TO_CCR_FAIL ; branch if Z clear
bne ORI_TO_CCR_FAIL ; branch if N clear
bvc ORI_TO_CCR_FAIL ; branch if V clear
bcc ORI_TO_CCR_FAIL ; branch if C clear
move #$00,CCR
ori.b #$00,CCR
beq ORI_TO_CCR_FAIL ; branch if Z set
bmi ORI_TO_CCR_FAIL ; branch if N set
bvs ORI_TO_CCR_FAIL ; branch if V set
bcs ORI_TO_CCR_FAIL ; branch if C set
move #$2700,SR ; Put flags back to initial value
movea #TESTSTATUS,a0
move.b #$1,$00(a0)
rts
ORI_TO_CCR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$00(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ORI_TO_SR
;-----------------------------------------------------------
;-----------------------------------------------------------
op_ORI_TO_SR:
ori.w #$2FFF,SR
bpl ORI_TO_SR_FAIL ; branch if Z clear
bne ORI_TO_SR_FAIL ; branch if N clear
bvc ORI_TO_SR_FAIL ; branch if V clear
bcc ORI_TO_SR_FAIL ; branch if C clear
move #$2000,SR
ori.w #$0000,SR
beq ORI_TO_SR_FAIL ; branch if Z set
bmi ORI_TO_SR_FAIL ; branch if N set
bvs ORI_TO_SR_FAIL ; branch if V set
bcs ORI_TO_SR_FAIL ; branch if C set
move #$2700,SR ; Put flags back to initial value
movea #TESTSTATUS,a0
move.b #$1,$01(a0)
rts
ORI_TO_SR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$01(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : EORI_TO_CCR
;-----------------------------------------------------------
;-----------------------------------------------------------
op_EORI_TO_CCR:
move #$00,CCR
eori.b #$FF,CCR
bpl EORI_TO_CCR_FAIL ; branch if Z clear
bne EORI_TO_CCR_FAIL ; branch if N clear
bvc EORI_TO_CCR_FAIL ; branch if V clear
bcc EORI_TO_CCR_FAIL ; branch if C clear
move #$00,CCR
eori.b #$00,CCR
beq EORI_TO_CCR_FAIL ; branch if Z set
bmi EORI_TO_CCR_FAIL ; branch if N set
bvs EORI_TO_CCR_FAIL ; branch if V set
bcs EORI_TO_CCR_FAIL ; branch if C set
move #$2700,SR ; Put flags back to initial value
movea #TESTSTATUS,a0
move.b #$1,$02(a0)
rts
EORI_TO_CCR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$02(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : EORI_TO_SR
;-----------------------------------------------------------
;-----------------------------------------------------------
op_EORI_TO_SR:
move #$2000,SR
eori.w #$0FFF,SR
bpl EORI_TO_SR_FAIL ; branch if Z clear
bne EORI_TO_SR_FAIL ; branch if N clear
bvc EORI_TO_SR_FAIL ; branch if V clear
bcc EORI_TO_SR_FAIL ; branch if C clear
move #$2000,SR
eori.w #$0000,SR
beq EORI_TO_SR_FAIL ; branch if Z set
bmi EORI_TO_SR_FAIL ; branch if N set
bvs EORI_TO_SR_FAIL ; branch if V set
bcs EORI_TO_SR_FAIL ; branch if C set
move #$2700,SR ; Put flags back to initial value
movea #TESTSTATUS,a0
move.b #$1,$03(a0)
rts
EORI_TO_SR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$03(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ANDI_TO_CCR
;-----------------------------------------------------------
;-----------------------------------------------------------
op_ANDI_TO_CCR:
move #$FF,CCR
andi.b #$FF,CCR
bpl ANDI_TO_CCR_FAIL ; branch if Z clear
bne ANDI_TO_CCR_FAIL ; branch if N clear
bvc ANDI_TO_CCR_FAIL ; branch if V clear
bcc ANDI_TO_CCR_FAIL ; branch if C clear
move #$FF,CCR
andi.b #$00,CCR
beq ANDI_TO_CCR_FAIL ; branch if Z set
bmi ANDI_TO_CCR_FAIL ; branch if N set
bvs ANDI_TO_CCR_FAIL ; branch if V set
bcs ANDI_TO_CCR_FAIL ; branch if C set
move #$2700,SR ; Put flags back to initial value
movea #TESTSTATUS,a0
move.b #$1,$04(a0)
rts
ANDI_TO_CCR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$04(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ANDI_TO_SR
;-----------------------------------------------------------
;-----------------------------------------------------------
op_ANDI_TO_SR:
move #$20FF,SR
andi.w #$FFFF,SR
bpl ANDI_TO_SR_FAIL ; branch if Z clear
bne ANDI_TO_SR_FAIL ; branch if N clear
bvc ANDI_TO_SR_FAIL ; branch if V clear
bcc ANDI_TO_SR_FAIL ; branch if C clear
move #$20FF,SR
andi.w #$FF00,SR
beq ANDI_TO_SR_FAIL ; branch if Z set
bmi ANDI_TO_SR_FAIL ; branch if N set
bvs ANDI_TO_SR_FAIL ; branch if V set
bcs ANDI_TO_SR_FAIL ; branch if C set
move #$2700,SR ; Put flags back to initial value
movea #TESTSTATUS,a0
move.b #$1,$05(a0)
rts
ANDI_TO_SR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$05(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : BTST
;-----------------------------------------------------------
;-----------------------------------------------------------
op_BTST:
; Bit Number Static
; EA = Dn - LONG only
move.l #$80000001,d0 ; populate test data
btst.l #0,d0
beq BTST_FAIL ; branch if Z set
btst.l #1,d0 ;
bne BTST_FAIL ; branch if Z clear
btst.l #31,d0 ;
beq BTST_FAIL ; branch if Z set
; EA = (An) - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$81,(a0) ; populate test data
move.b (a0),d1 ; Check to see if data in memory is 0x81
btst.b #0,(a0)
beq BTST_FAIL ; branch if Z set
btst.b #1,(a0) ;
bne BTST_FAIL ; branch if Z clear
btst.b #7,(a0) ;
beq BTST_FAIL ; branch if Z set
; EA = (An)+ - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address 0x100
btst.b #0,(a0)+
beq BTST_FAIL ; branch if Z set
btst.b #1,(a0)+ ;
bne BTST_FAIL ; branch if Z clear
btst.b #7,(a0)+ ;
beq BTST_FAIL ; branch if Z set
; EA = -(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$80,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$01,(a0)+ ; populate test data
move.l #$00000103,a0 ; point to memory to address
btst.b #0,-(a0)
beq BTST_FAIL ; branch if Z set
btst.b #1,-(a0) ;
bne BTST_FAIL ; branch if Z clear
btst.b #7,-(a0) ;
beq BTST_FAIL ; branch if Z set
; EA = n(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
btst.b #0,0(a0)
beq BTST_FAIL ; branch if Z set
btst.b #1,1(a0) ;
bne BTST_FAIL ; branch if Z clear
btst.b #7,2(a0) ;
beq BTST_FAIL ; branch if Z set
; EA = n(An,R.W) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.l #$00000000,a1 ; point to memory to address
move.l #$00000001,a2 ; point to memory to address
move.l #$00000000,d0 ; point to memory to address
move.l #$00000001,d1 ; point to memory to address
btst.b #0,0(a0,d0.w)
beq BTST_FAIL ; branch if Z set
btst.b #1,0(a0,d1.w) ;
bne BTST_FAIL ; branch if Z clear
btst.b #7,1(a0,d1.w) ;
beq BTST_FAIL ; branch if Z set
; EA = n(An,R.L) - BYTE only
btst.b #0,0(a0,d0.l)
beq BTST_FAIL ; branch if Z set
btst.b #1,0(a0,d1.l) ;
bne BTST_FAIL ; branch if Z clear
btst.b #7,1(a0,d1.l) ;
beq BTST_FAIL ; branch if Z set
; EA = n(An,A.W) - BYTE only
btst.b #0,0(a0,a1.w)
beq BTST_FAIL ; branch if Z set
btst.b #1,0(a0,a2.w) ;
bne BTST_FAIL ; branch if Z clear
btst.b #7,1(a0,a2.w) ;
beq BTST_FAIL ; branch if Z set
; EA = n(An,A.L) - BYTE only
btst.b #0,0(a0,a1.l)
beq BTST_FAIL ; branch if Z set
btst.b #1,0(a0,a2.l) ;
bne BTST_FAIL ; branch if Z clear
btst.b #7,1(a0,a2.l) ;
beq BTST_FAIL ; branch if Z set
; EA = x.W - BYTE only
btst.b #0,$0100
beq BTST_FAIL ; branch if Z set
btst.b #1,$0101 ;
bne BTST_FAIL ; branch if Z clear
btst.b #7,$0102 ;
beq BTST_FAIL ; branch if Z set
; EA = x.L - BYTE only
move.l #$000F0100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
btst.b #0,$000F0100
beq BTST_FAIL ; branch if Z set
btst.b #1,$000F0101 ;
bne BTST_FAIL ; branch if Z clear
btst.b #7,$000F0102 ;
beq BTST_FAIL ; branch if Z set
; EA = x(PC) - BYTE only
lea op_BTST(pc),a5
btst.b #0,op_BTST(pc)
bne BTST_FAIL ; branch if Z clear
btst.b #3,op_BTST0(pc) ;
beq BTST_FAIL ; branch if Z set
btst.b #6,op_BTST12(pc) ;
beq BTST_FAIL ; branch if Z set
; EA = n(PC,R.W) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.l #$00000000,a1 ; point to memory to address
move.l #$00000001,a2 ; point to memory to address
move.l #$00000000,d0 ; point to memory to address
move.l #$00000001,d1 ; point to memory to address
op_BTST0: btst.b #0,op_BTST0(pc,d0.w)
bne BTST_FAIL ; branch if Z clear
lea op_BTST1(pc,d1.w),a5
op_BTST1: btst.b #1,op_BTST1(pc,d1.w) ;
beq BTST_FAIL ; branch if Z set
op_BTST2: btst.b #7,op_BTST2(pc,d1.w) ;
bne BTST_FAIL ; branch if Z clear
; EA = n(PC,R.L) - BYTE only
op_BTST3: btst.b #0,op_BTST3(pc,d0.l)
bne BTST_FAIL ; branch if Z clear
op_BTST4: btst.b #1,op_BTST4(pc,d1.l) ;
beq BTST_FAIL ; branch if Z set
op_BTST5: btst.b #7,op_BTST5(pc,d1.l) ;
bne BTST_FAIL ; branch if Z clear
; EA = n(PC,A.W) - BYTE only
op_BTST6 btst.b #0,op_BTST6(pc,a1.w)
bne BTST_FAIL ; branch if Z clear
op_BTST7: btst.b #1,op_BTST7(pc,a2.w) ;
beq BTST_FAIL ; branch if Z set
op_BTST8: btst.b #7,op_BTST8(pc,a2.w) ;
bne BTST_FAIL ; branch if Z clear
; EA = n(PC,A.L) - BYTE only
op_BTST9: btst.b #0,op_BTST9(pc,a1.l)
bne BTST_FAIL ; branch if Z clear
op_BTST10: btst.b #1,op_BTST10(pc,a2.l) ;
beq BTST_FAIL ; branch if Z set
op_BTST11: btst.b #7,op_BTST11(pc,a2.l) ;
op_BTST12: bne BTST_FAIL ; branch if Z clear
; Bit Number Dynamic
; EA = Dn - LONG only
move.l #$80000001,d0 ; populate test data
move.l #0,d5 ; populate bit number to test
move.l #1,d6 ; populate bit number to test
move.l #31,d7 ; populate bit number to test
btst.l d5,d0
beq BTST_FAIL ; branch if Z set
btst.l d6,d0 ;
bne BTST_FAIL ; branch if Z clear
btst.l d7,d0 ;
beq BTST_FAIL ; branch if Z set
; EA = (An) - BYTE only
move.l #0,d5 ; populate bit number to test
move.l #1,d6 ; populate bit number to test
move.l #7,d7 ; populate bit number to test
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$81,(a0) ; populate test data
move.b (a0),d1 ; Check to see if data in memory is 0x81
btst.b d5,(a0)
beq BTST_FAIL ; branch if Z set
btst.b d6,(a0) ;
bne BTST_FAIL ; branch if Z clear
btst.b d7,(a0) ;
beq BTST_FAIL ; branch if Z set
; ---
; EA = (An)+ - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address 0x100
btst.b d5,(a0)+
beq BTST_FAIL ; branch if Z set
btst.b d6,(a0)+ ;
bne BTST_FAIL ; branch if Z clear
btst.b d7,(a0)+ ;
beq BTST_FAIL ; branch if Z set
; EA = -(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$80,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$01,(a0)+ ; populate test data
move.l #$00000103,a0 ; point to memory to address
btst.b d5,-(a0)
beq BTST_FAIL ; branch if Z set
btst.b d6,-(a0) ;
bne BTST_FAIL ; branch if Z clear
btst.b d7,-(a0) ;
beq BTST_FAIL ; branch if Z set
; EA = n(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
btst.b d5,0(a0)
beq BTST_FAIL ; branch if Z set
btst.b d6,1(a0) ;
bne BTST_FAIL ; branch if Z clear
btst.b d7,2(a0) ;
beq BTST_FAIL ; branch if Z set
; EA = n(An,R.W) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.l #$00000000,a1 ; point to memory to address
move.l #$00000001,a2 ; point to memory to address
move.l #$00000000,d0 ; point to memory to address
move.l #$00000001,d1 ; point to memory to address
btst.b d5,0(a0,d0.w)
beq BTST_FAIL ; branch if Z set
btst.b d6,0(a0,d1.w) ;
bne BTST_FAIL ; branch if Z clear
btst.b d7,1(a0,d1.w) ;
beq BTST_FAIL ; branch if Z set
; EA = n(An,R.L) - BYTE only
btst.b d5,0(a0,d0.l)
beq BTST_FAIL ; branch if Z set
btst.b d6,0(a0,d1.l) ;
bne BTST_FAIL ; branch if Z clear
btst.b d7,1(a0,d1.l) ;
beq BTST_FAIL ; branch if Z set
; EA = n(An,A.W) - BYTE only
btst.b d5,0(a0,a1.w)
beq BTST_FAIL ; branch if Z set
btst.b d6,0(a0,a2.w) ;
bne BTST_FAIL ; branch if Z clear
btst.b d7,1(a0,a2.w) ;
beq BTST_FAIL ; branch if Z set
; EA = n(An,A.L) - BYTE only
btst.b d5,0(a0,a1.l)
beq BTST_FAIL ; branch if Z set
btst.b d6,0(a0,a2.l) ;
bne BTST_FAIL ; branch if Z clear
btst.b d7,1(a0,a2.l) ;
beq BTST_FAIL ; branch if Z set
; EA = x.W - BYTE only
btst.b d5,$0100
beq BTST_FAIL ; branch if Z set
btst.b d6,$0101 ;
bne BTST_FAIL ; branch if Z clear
btst.b d7,$0102 ;
beq BTST_FAIL ; branch if Z set
; EA = x.L - BYTE only
move.l #$000F0100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
btst.b d5,$000F0100
beq BTST_FAIL ; branch if Z set
btst.b d6,$000F0101 ;
bne BTST_FAIL ; branch if Z clear
btst.b d7,$000F0102 ;
beq BTST_FAIL ; branch if Z set
; EA = x(PC) - BYTE only
move.l #3,d6 ; populate bit number to test
move.l #6,d7 ; populate bit number to test
lea op_BTST(pc),a5
btst.b d5,op_BTST(pc)
bne BTST_FAIL ; branch if Z clear
btst.b d6,op_BTST0(pc) ;
beq BTST_FAIL ; branch if Z set
btst.b d7,op_BTST12(pc) ;
beq BTST_FAIL ; branch if Z set
; EA = n(PC,R.W) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.l #$00000000,a1 ; point to memory to address
move.l #$00000001,a2 ; point to memory to address
move.l #$00000000,d0 ; point to memory to address
move.l #$00000001,d1 ; point to memory to address
move.l #1,d6 ; populate bit number to test
move.l #7,d7 ; populate bit number to test
op_BTST20: btst.b d5,op_BTST20(pc,d0.w)
beq BTST_FAIL ; branch if Z set
lea op_BTST21(pc,d1.w),a5
op_BTST21: btst.b d6,op_BTST21(pc,d1.w) ;
beq BTST_FAIL ; branch if Z set
op_BTST22: btst.b d7,op_BTST22(pc,d1.w) ;
bne BTST_FAIL ; branch if Z clear
; EA = n(PC,R.L) - BYTE only
op_BTST23: btst.b d5,op_BTST23(pc,d0.l)
beq BTST_FAIL ; branch if Z set
op_BTST24: btst.b d6,op_BTST24(pc,d1.l) ;
beq BTST_FAIL ; branch if Z set
op_BTST25 btst.b d7,op_BTST25(pc,d1.l) ;
bne BTST_FAIL ; branch if Z clear
; EA = n(PC,A.W) - BYTE only
op_BTST26 btst.b d5,op_BTST26(pc,a1.w)
beq BTST_FAIL ; branch if Z set
op_BTST27: btst.b d6,op_BTST27(pc,a2.w) ;
beq BTST_FAIL ; branch if Z set
op_BTST28: btst.b d7,op_BTST28(pc,a2.w) ;
bne BTST_FAIL ; branch if Z clear
; EA = n(PC,A.L) - BYTE only
op_BTST29: btst.b d5,op_BTST29(pc,a1.l)
beq BTST_FAIL ; branch if Z set
op_BTST30: btst.b d6,op_BTST30(pc,a2.l) ;
beq BTST_FAIL ; branch if Z set
op_BTST31: btst.b d7,op_BTST31(pc,a2.l) ;
op_BTST32: bne BTST_FAIL ; branch if Z clear
; EA = #x - BYTE only
move.l #0,d5 ; populate bit number to test
move.l #3,d6 ; populate bit number to test
move.l #7,d7 ; populate bit number to test
btst.b d5,#$88
bne BTST_FAIL ; branch if Z clear
btst.b d6,#$88
beq BTST_FAIL ; branch if Z set
btst.b d7,#$88
beq BTST_FAIL ; branch if Z set
movea #TESTSTATUS,a0
move.b #$1,$06(a0)
rts
BTST_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$06(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : BCHG
;-----------------------------------------------------------
;-----------------------------------------------------------
op_BCHG:
; Bit Number Static
; EA = Dn - LONG only
move.l #$80000001,d0 ; populate test data
bchg.l #0,d0
beq BCHG_FAIL ; branch if Z set
bchg.l #1,d0 ;
bne BCHG_FAIL ; branch if Z clear
bchg.l #31,d0 ;
beq BCHG_FAIL ; branch if Z set
cmpi.l #$00000002,d0
bne BCHG_FAIL ; branch if Z clear
; EA = (An) - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$81,(a0) ; populate test data
move.b (a0),d1 ; Check to see if data in memory is 0x81
bchg.b #0,(a0)
beq BCHG_FAIL ; branch if Z set
bchg.b #1,(a0) ;
bne BCHG_FAIL ; branch if Z clear
bchg.b #7,(a0) ;
beq BCHG_FAIL ; branch if Z set
cmpi.b #$02,(a0)
bne BCHG_FAIL ; branch if Z clear
; EA = (An)+ - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address 0x100
bchg.b #0,(a0)+
beq BCHG_FAIL ; branch if Z set
bchg.b #1,(a0)+ ;
bne BCHG_FAIL ; branch if Z clear
bchg.b #7,(a0)+ ;
beq BCHG_FAIL ; branch if Z set
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$FE,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
; EA = -(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$80,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$01,(a0)+ ; populate test data
move.l #$00000103,a0 ; point to memory to address
bchg.b #0,-(a0)
beq BCHG_FAIL ; branch if Z set
bchg.b #1,-(a0) ;
bne BCHG_FAIL ; branch if Z clear
bchg.b #7,-(a0) ;
beq BCHG_FAIL ; branch if Z set
move.l #$00000103,a0 ; point to memory to address 0x100
cmpi.b #$00,-(a0)
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$FE,-(a0)
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$00,-(a0)
bne BCHG_FAIL ; branch if Z clear
; EA = n(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
bchg.b #0,0(a0)
beq BCHG_FAIL ; branch if Z set
bchg.b #1,1(a0) ;
bne BCHG_FAIL ; branch if Z clear
bchg.b #7,2(a0) ;
beq BCHG_FAIL ; branch if Z set
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$FE,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
; EA = n(An,D.W) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.l #$00000000,a1 ; point to memory to address
move.l #$00000001,a2 ; point to memory to address
move.l #$00000000,d0 ; point to memory to address
move.l #$00000001,d1 ; point to memory to address
bchg.b #0,0(a0,d0.w)
bne BCHG_FAIL ; branch if Z clear
bchg.b #1,0(a0,d1.w) ;
beq BCHG_FAIL ; branch if Z set
bchg.b #7,1(a0,d1.w) ;
bne BCHG_FAIL ; branch if Z clear
; EA = n(An,D.L) - BYTE only
bchg.b #0,0(a0,d0.l)
beq BCHG_FAIL ; branch if Z set
bchg.b #1,0(a0,d1.l) ;
bne BCHG_FAIL ; branch if Z clear
bchg.b #7,1(a0,d1.l) ;
beq BCHG_FAIL ; branch if Z set
; EA = n(An,A.W) - BYTE only
bchg.b #0,0(a0,a1.w)
bne BCHG_FAIL ; branch if Z clear
bchg.b #1,0(a0,a2.w) ;
beq BCHG_FAIL ; branch if Z set
bchg.b #7,1(a0,a2.w) ;
bne BCHG_FAIL ; branch if Z clear
; EA = n(An,A.L) - BYTE only
bchg.b #0,0(a0,a1.l)
beq BCHG_FAIL ; branch if Z set
bchg.b #1,0(a0,a2.l) ;
bne BCHG_FAIL ; branch if Z clear
bchg.b #7,1(a0,a2.l) ;
beq BCHG_FAIL ; branch if Z set
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$FE,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
; EA = x.W - BYTE only
bchg.b #0,$0100
bne BCHG_FAIL ; branch if Z clear
bchg.b #1,$0101 ;
beq BCHG_FAIL ; branch if Z set
bchg.b #7,$0102 ;
bne BCHG_FAIL ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$01,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$FC,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$80,(a0)+
bne BCHG_FAIL ; branch if Z clear
; EA = x.L - BYTE only
move.l #$000F0100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
bchg.b #0,$000F0100
beq BCHG_FAIL ; branch if Z set
bchg.b #1,$000F0101 ;
bne BCHG_FAIL ; branch if Z clear
bchg.b #7,$000F0102 ;
beq BCHG_FAIL ; branch if Z set
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$01,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$FC,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$80,(a0)+
bne BCHG_FAIL ; branch if Z clear
; Bit Number Dynamic
; EA = Dn - LONG only
move.l #$80000001,d0 ; populate test data
move.l #0,d5 ; populate bit number to test
move.l #1,d6 ; populate bit number to test
move.l #31,d7 ; populate bit number to test
bchg.l d5,d0
beq BCHG_FAIL ; branch if Z set
bchg.l d6,d0 ;
bne BCHG_FAIL ; branch if Z clear
bchg.l d7,d0 ;
beq BCHG_FAIL ; branch if Z set
cmpi.l #$00000002,d0
bne BCHG_FAIL ; branch if Z clear
; EA = (An) - BYTE only
move.l #0,d5 ; populate bit number to test
move.l #1,d6 ; populate bit number to test
move.l #7,d7 ; populate bit number to test
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$81,(a0) ; populate test data
move.b (a0),d1 ; Check to see if data in memory is 0x81
bchg.b d5,(a0)
beq BCHG_FAIL ; branch if Z set
bchg.b d6,(a0) ;
bne BCHG_FAIL ; branch if Z clear
bchg.b d7,(a0) ;
beq BCHG_FAIL ; branch if Z set
cmpi.b #$02,(a0)
bne BCHG_FAIL ; branch if Z clear
; EA = (An)+ - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address 0x100
bchg.b d5,(a0)+
beq BCHG_FAIL ; branch if Z set
bchg.b d6,(a0)+ ;
bne BCHG_FAIL ; branch if Z clear
bchg.b d7,(a0)+ ;
beq BCHG_FAIL ; branch if Z set
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$FE,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
; EA = -(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$80,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$01,(a0)+ ; populate test data
move.l #$00000103,a0 ; point to memory to address
bchg.b d5,-(a0)
beq BCHG_FAIL ; branch if Z set
bchg.b d6,-(a0) ;
bne BCHG_FAIL ; branch if Z clear
bchg.b d7,-(a0) ;
beq BCHG_FAIL ; branch if Z set
move.l #$00000103,a0 ; point to memory to address 0x100
cmpi.b #$00,-(a0)
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$FE,-(a0)
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$00,-(a0)
bne BCHG_FAIL ; branch if Z clear
; EA = n(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
bchg.b d5,0(a0)
beq BCHG_FAIL ; branch if Z set
bchg.b d6,1(a0) ;
bne BCHG_FAIL ; branch if Z clear
bchg.b d7,2(a0) ;
beq BCHG_FAIL ; branch if Z set
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$FE,(a0)+
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
; EA = n(An,R.W) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.l #$00000000,a1 ; point to memory to address
move.l #$00000001,a2 ; point to memory to address
move.l #$00000000,d0 ; point to memory to address
move.l #$00000001,d1 ; point to memory to address
bchg.b d5,0(a0,d0.w)
bne BCHG_FAIL ; branch if Z clear
bchg.b d6,0(a0,d1.w) ;
beq BCHG_FAIL ; branch if Z set
bchg.b d7,1(a0,d1.w) ;
bne BCHG_FAIL ; branch if Z clear
; EA = n(An,R.L) - BYTE only
bchg.b d5,0(a0,d0.l)
beq BCHG_FAIL ; branch if Z set
bchg.b d6,0(a0,d1.l) ;
bne BCHG_FAIL ; branch if Z clear
bchg.b d7,1(a0,d1.l) ;
beq BCHG_FAIL ; branch if Z set
; EA = n(An,A.W) - BYTE only
bchg.b d5,0(a0,a1.w)
bne BCHG_FAIL ; branch if Z clear
bchg.b d6,0(a0,a2.w) ;
beq BCHG_FAIL ; branch if Z set
bchg.b d7,1(a0,a2.w) ;
bne BCHG_FAIL ; branch if Z clear
; EA = n(An,A.L) - BYTE only
bchg.b d5,0(a0,a1.l)
beq BCHG_FAIL ; branch if Z set
bchg.b d6,0(a0,a2.l) ;
bne BCHG_FAIL ; branch if Z clear
bchg.b d7,1(a0,a2.l) ;
beq BCHG_FAIL ; branch if Z set
cmpi.b #$00,(a0)+
bne BCHG_FAIL ; branch if Z clear
; EA = x.W - BYTE only
bchg.b d5,$0100
bne BCHG_FAIL ; branch if Z clear
bchg.b d6,$0101 ;
beq BCHG_FAIL ; branch if Z set
bchg.b d7,$0102 ;
bne BCHG_FAIL ; branch if Z clear
cmpi.b #$FC,(a0)+
bne BCHG_FAIL ; branch if Z clear
; EA = x.L - BYTE only
move.l #$000F0100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
bchg.b d5,$000F0100
beq BCHG_FAIL ; branch if Z set
bchg.b d6,$000F0101 ;
bne BCHG_FAIL ; branch if Z clear
bchg.b d7,$000F0102 ;
beq BCHG_FAIL ; branch if Z set
move.l #$000F0101,a0 ; point to memory to address 0x100
cmpi.b #$FE,(a0)
bne BCHG_FAIL ; branch if Z clear
movea #TESTSTATUS,a0
move.b #$1,$07(a0)
rts
BCHG_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$07(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : BCLR
;-----------------------------------------------------------
;-----------------------------------------------------------
op_BCLR:
; Bit Number Static
; EA = Dn - LONG only
move.l #$FF0000FF,d0 ; populate test data
bclr.l #0,d0
beq BCLR_FAIL; ; branch if Z set
bclr.l #1,d0 ;
beq BCLR_FAIL; ; branch if Z set
bclr.l #15,d0 ;
bne BCLR_FAIL; ; branch if Z clear
bclr.l #31,d0 ;
beq BCLR_FAIL; ; branch if Z set
cmpi.l #$7F0000FC,d0
bne BCLR_FAIL; ; branch if Z clear
; EA = (An) - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$0F,(a0) ; populate test data
bclr.b #0,(a0)
beq BCLR_FAIL; ; branch if Z set
bclr.b #7,(a0) ;
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$0E,(a0)
bne BCLR_FAIL; ; branch if Z clear
; EA = (An)+ - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address 0x100
bclr.b #0,(a0)+
beq BCLR_FAIL; ; branch if Z set
bclr.b #1,(a0)+ ;
bne BCLR_FAIL; ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$00,(a0)+
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$00,(a0)+
bne BCLR_FAIL; ; branch if Z clear
; EA = -(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$01,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
bclr.b #7,-(a0)
beq BCLR_FAIL; ; branch if Z set
bclr.b #0,-(a0) ;
beq BCLR_FAIL; ; branch if Z set
move.l #$00000102,a0 ; point to memory to address 0x100
cmpi.b #$00,-(a0)
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$00,-(a0)
bne BCLR_FAIL; ; branch if Z clear
; EA = n(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$FF,(a0)+ ; populate test data
move.b #$FF,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
bclr.b #0,0(a0)
beq BCLR_FAIL; ; branch if Z set
bclr.b #4,1(a0) ;
beq BCLR_FAIL; ; branch if Z set
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$FE,(a0)+
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$EF,(a0)+
bne BCLR_FAIL; ; branch if Z clear
; EA = n(An,D.W) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.l #$00000000,a1 ; point to memory to address
move.l #$00000001,a2 ; point to memory to address
move.l #$00000000,d0 ; point to memory to address
move.l #$00000001,d1 ; point to memory to address
move.b #$FF,(a0)+ ; populate test data
move.b #$FF,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
bclr.b #0,0(a0,d0.w)
beq BCLR_FAIL; ; branch if Z set
bclr.b #1,0(a0,d1.w) ;
beq BCLR_FAIL; ; branch if Z set
bclr.b #2,1(a0,d1.w) ;
bne BCLR_FAIL; ; branch if Z clear
; EA = n(An,D.L) - BYTE only
bclr.b #3,0(a0,d0.l)
beq BCLR_FAIL; ; branch if Z set
bclr.b #4,0(a0,d1.l) ;
beq BCLR_FAIL; ; branch if Z set
bclr.b #5,1(a0,d1.l) ;
bne BCLR_FAIL; ; branch if Z clear
; EA = n(An,A.W) - BYTE only
bclr.b #6,0(a0,a1.w)
beq BCLR_FAIL; ; branch if Z set
bclr.b #1,0(a0,a2.w) ;
bne BCLR_FAIL; ; branch if Z clear
bclr.b #7,1(a0,a2.w) ;
beq BCLR_FAIL; ; branch if Z set
; EA = n(An,A.L) - BYTE only
bclr.b #0,0(a0,a1.l)
bne BCLR_FAIL; ; branch if Z clear
bclr.b #0,0(a0,a2.l) ;
beq BCLR_FAIL; ; branch if Z set
bclr.b #1,1(a0,a2.l) ;
bne BCLR_FAIL; ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$B6,(a0)+
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$EC,(a0)+
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$59,(a0)+
beq BCLR_FAIL; ; branch if Z set
; EA = x.W - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$FF,(a0)+ ; populate test data
bclr.b #0,$0100
beq BCLR_FAIL; ; branch if Z set
bclr.b #1,$0100 ;
beq BCLR_FAIL; ; branch if Z set
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$FC,(a0)+
bne BCLR_FAIL; ; branch if Z clear
; EA = x.L - BYTE only
move.l #$000F0100,a0 ; point to memory to address 0x100
move.b #$FF,(a0) ; populate test data
bclr.b #0,$000F0100
beq BCLR_FAIL; ; branch if Z set
bclr.b #1,$000F0100 ;
beq BCLR_FAIL; ; branch if Z set
bclr.b #2,$000F0100 ;
beq BCLR_FAIL; ; branch if Z set
move.l #$000F0100,a0 ; point to memory to address 0x100
cmpi.b #$F8,(a0)+
bne BCLR_FAIL; ; branch if Z clear
; Bit Number Dynamic
; EA = Dn - LONG only
move.l #$FF00FF00,d0 ; populate test data
move.l #0,d5 ; populate bit number to test
move.l #1,d6 ; populate bit number to test
move.l #31,d7 ; populate bit number to test
bclr.l d5,d0
bne BCLR_FAIL; ; branch if Z clear
bclr.l d6,d0 ;
bne BCLR_FAIL; ; branch if Z clear
bclr.l d7,d0 ;
beq BCLR_FAIL; ; branch if Z set
cmpi.l #$7F00FF00,d0
bne BCLR_FAIL; ; branch if Z clear
; EA = (An) - BYTE only
move.l #0,d5 ; populate bit number to test
move.l #1,d6 ; populate bit number to test
move.l #7,d7 ; populate bit number to test
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$81,(a0) ; populate test data
bclr.b d5,(a0)
beq BCLR_FAIL; ; branch if Z set
bclr.b d6,(a0) ;
bne BCLR_FAIL; ; branch if Z clear
bclr.b d7,(a0) ;
beq BCLR_FAIL; ; branch if Z set
cmpi.b #$00,(a0)
bne BCLR_FAIL; ; branch if Z clear
; EA = (An)+ - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address 0x100
bclr.b d5,(a0)+
beq BCLR_FAIL; ; branch if Z set
bclr.b d6,(a0)+ ;
bne BCLR_FAIL; ; branch if Z clear
bclr.b d7,(a0)+ ;
beq BCLR_FAIL; ; branch if Z set
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$00,(a0)+
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$FC,(a0)+
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$00,(a0)+
bne BCLR_FAIL; ; branch if Z clear
; EA = -(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$80,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$01,(a0)+ ; populate test data
move.l #$00000103,a0 ; point to memory to address
bclr.b d5,-(a0)
beq BCLR_FAIL; ; branch if Z set
bclr.b d6,-(a0) ;
bne BCLR_FAIL; ; branch if Z clear
bclr.b d7,-(a0) ;
beq BCLR_FAIL; ; branch if Z set
move.l #$00000103,a0 ; point to memory to address 0x100
cmpi.b #$00,-(a0)
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$FC,-(a0)
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$00,-(a0)
bne BCLR_FAIL; ; branch if Z clear
; EA = n(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
bclr.b d5,0(a0)
beq BCLR_FAIL; ; branch if Z set
bclr.b d6,1(a0) ;
bne BCLR_FAIL; ; branch if Z clear
bclr.b d7,2(a0) ;
beq BCLR_FAIL; ; branch if Z set
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$00,(a0)+
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$FC,(a0)+
bne BCLR_FAIL; ; branch if Z clear
cmpi.b #$00,(a0)+
bne BCLR_FAIL; ; branch if Z clear
; EA = n(An,R.W) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$FF,(a0)+ ; populate test data
move.b #$FF,(a0)+ ; populate test data
move.b #$FF,(a0)+ ; populate test data
move.l #$00000103,a0 ; point to memory to address
move.l #$00000100,a0 ; point to memory to address
move.l #$00000000,a1 ; point to memory to address
move.l #$00000001,a2 ; point to memory to address
move.l #$00000000,d0 ; point to memory to address
move.l #$00000001,d1 ; point to memory to address
bclr.b d5,0(a0,d0.w)
beq BCLR_FAIL; ; branch if Z set
bclr.b d6,0(a0,d1.w) ;
beq BCLR_FAIL; ; branch if Z set
bclr.b d7,1(a0,d1.w) ;
beq BCLR_FAIL; ; branch if Z set
; EA = n(An,R.L) - BYTE only
bclr.b d5,0(a0,d0.l)
bne BCLR_FAIL; ; branch if Z clear
bclr.b d6,0(a0,d1.l) ;
bne BCLR_FAIL; ; branch if Z clear
bclr.b d7,1(a0,d1.l) ;
bne BCLR_FAIL; ; branch if Z clear
; EA = n(An,A.W) - BYTE only
bclr.b d5,0(a0,a1.w)
bne BCLR_FAIL; ; branch if Z clear
bclr.b d6,0(a0,a2.w) ;
bne BCLR_FAIL; ; branch if Z clear
bclr.b d7,1(a0,a2.w) ;
bne BCLR_FAIL; ; branch if Z clear
; EA = n(An,A.L) - BYTE only
bclr.b d5,0(a0,a1.l)
bne BCLR_FAIL; ; branch if Z clear
bclr.b d6,0(a0,a2.l) ;
bne BCLR_FAIL; ; branch if Z clear
bclr.b d7,1(a0,a2.l) ;
bne BCLR_FAIL; ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address
cmpi.b #$FE,(a0)
bne BCLR_FAIL; ; branch if Z clear
; EA = x.W - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$FF,(a0)+ ; populate test data
move.b #$FF,(a0)+ ; populate test data
move.b #$FF,(a0)+ ; populate test data
bclr.b d5,$0100
beq BCLR_FAIL; ; branch if Z set
bclr.b d6,$0101 ;
beq BCLR_FAIL; ; branch if Z set
bclr.b d7,$0102 ;
beq BCLR_FAIL; ; branch if Z set
move.l #$00000100,a0 ; point to memory to address
cmpi.b #$FE,(a0)+
bne BCLR_FAIL; ; branch if Z clear
; EA = x.L - BYTE only
move.l #$000F0100,a0 ; point to memory to address 0x100
move.b #$01,(a0)+ ; populate test data
move.b #$FC,(a0)+ ; populate test data
move.b #$80,(a0)+ ; populate test data
bclr.b d5,$000F0100
beq BCLR_FAIL; ; branch if Z set
bclr.b d6,$000F0101 ;
bne BCLR_FAIL; ; branch if Z clear
bclr.b d7,$000F0102 ;
beq BCLR_FAIL; ; branch if Z set
move.l #$000F0101,a0 ; point to memory to address 0x100
cmpi.b #$FC,(a0)
bne BCLR_FAIL; ; branch if Z clear
movea #TESTSTATUS,a0
move.b #$1,$08(a0)
rts
BCLR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$08(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : BSET
;-----------------------------------------------------------
;-----------------------------------------------------------
op_BSET:
; Bit Number Static
; EA = Dn - LONG only
move.l #$00000000,d0 ; populate test data
bset.l #0,d0
bne BSET_FAIL ; branch if Z clear
bset.l #1,d0 ;
bne BSET_FAIL ; branch if Z clear
bset.l #15,d0 ;
bne BSET_FAIL ; branch if Z clear
bset.l #31,d0 ;
bne BSET_FAIL ; branch if Z clear
cmpi.l #$80008003,d0
bne BSET_FAIL ; branch if Z clear
; EA = (An) - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$00,(a0) ; populate test data
bset.b #0,(a0)
bne BSET_FAIL ; branch if Z clear
bset.b #7,(a0) ;
bne BSET_FAIL ; branch if Z clear
cmpi.b #$81,(a0)
bne BSET_FAIL ; branch if Z clear
; EA = (An)+ - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address 0x100
bset.b #0,(a0)+
bne BSET_FAIL ; branch if Z clear
bset.b #1,(a0)+ ;
bne BSET_FAIL ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$01,(a0)+
bne BSET_FAIL ; branch if Z clear
cmpi.b #$02,(a0)+
bne BSET_FAIL ; branch if Z clear
; EA = -(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
bset.b #7,-(a0)
bne BSET_FAIL ; branch if Z clear
bset.b #0,-(a0) ;
bne BSET_FAIL ; branch if Z clear
move.l #$00000102,a0 ; point to memory to address 0x100
cmpi.b #$80,-(a0)
bne BSET_FAIL ; branch if Z clear
cmpi.b #$01,-(a0)
bne BSET_FAIL ; branch if Z clear
; EA = n(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
bset.b #0,0(a0)
bne BSET_FAIL ; branch if Z clear
bset.b #4,1(a0) ;
bne BSET_FAIL ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$01,(a0)+
bne BSET_FAIL ; branch if Z clear
cmpi.b #$10,(a0)+
bne BSET_FAIL ; branch if Z clear
; EA = n(An,D.W) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.l #$00000000,a1 ; point to memory to address
move.l #$00000004,a2 ; point to memory to address
move.l #$00000000,d0 ; point to memory to address
move.l #$00000001,d1 ; point to memory to address
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
bset.b #0,0(a0,d0.w)
bne BSET_FAIL ; branch if Z clear
bset.b #1,0(a0,d1.w) ;
bne BSET_FAIL ; branch if Z clear
bset.b #2,1(a0,d1.w) ;
bne BSET_FAIL ; branch if Z clear
; EA = n(An,D.L) - BYTE only
bset.b #3,2(a0,d0.l)
bne BSET_FAIL ; branch if Z clear
bset.b #4,0(a0,d1.l) ;
bne BSET_FAIL ; branch if Z clear
bset.b #5,1(a0,d1.l) ;
bne BSET_FAIL ; branch if Z clear
; EA = n(An,A.W) - BYTE only
bset.b #6,0(a0,a1.w)
bne BSET_FAIL ; branch if Z clear
bset.b #1,0(a0,a2.w) ;
bne BSET_FAIL ; branch if Z clear
bset.b #7,1(a0,a2.w) ;
bne BSET_FAIL ; branch if Z clear
; EA = n(An,A.L) - BYTE only
bset.b #0,2(a0,a2.l)
bne BSET_FAIL ; branch if Z clear
bset.b #0,3(a0,a2.l) ;
bne BSET_FAIL ; branch if Z clear
bset.b #1,4(a0,a2.l) ;
bne BSET_FAIL ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.l #$41122C00,(a0)+
bne BSET_FAIL ; branch if Z clear
cmpi.l #$02800101,(a0)+
bne BSET_FAIL;
; EA = x.W - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$00,(a0)+ ; populate test data
bset.b #0,$0100
bne BSET_FAIL ; branch if Z clear
bset.b #1,$0100 ;
bne BSET_FAIL ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$03,(a0)+
bne BSET_FAIL;
; EA = x.L - BYTE only
move.l #$000F0100,a0 ; point to memory to address 0x100
move.b #$00,(a0) ; populate test data
bset.b #0,$000F0100
bne BSET_FAIL ; branch if Z clear
bset.b #1,$000F0100 ;
bne BSET_FAIL ; branch if Z clear
bset.b #2,$000F0100 ;
bne BSET_FAIL ; branch if Z clear
move.l #$000F0100,a0 ; point to memory to address 0x100
cmpi.b #$07,(a0)+
bne BSET_FAIL;
; Bit Number Dynamic
; EA = Dn - LONG only
move.l #$00000000,d0 ; populate test data
move.l #0,d5 ; populate bit number to test
move.l #1,d6 ; populate bit number to test
move.l #31,d7 ; populate bit number to test
bset.l d5,d0
bne BSET_FAIL ; branch if Z clear
bset.l d6,d0 ;
bne BSET_FAIL ; branch if Z clear
bset.l d7,d0 ;
bne BSET_FAIL ; branch if Z clear
cmpi.l #$80000003,d0
bne BSET_FAIL ; branch if Z clear
; EA = (An) - BYTE only
move.l #0,d5 ; populate bit number to test
move.l #1,d6 ; populate bit number to test
move.l #7,d7 ; populate bit number to test
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$00,(a0) ; populate test data
bset.b d5,(a0)
bne BSET_FAIL ; branch if Z clear
bset.b d6,(a0) ;
bne BSET_FAIL ; branch if Z clear
bset.b d7,(a0) ;
bne BSET_FAIL ; branch if Z clear
cmpi.b #$83,(a0)
bne BSET_FAIL ; branch if Z clear
; EA = (An)+ - BYTE only
move.l #$00000100,a0 ; point to memory to address 0x100
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address 0x100
bset.b d5,(a0)+
bne BSET_FAIL ; branch if Z clear
bset.b d6,(a0)+ ;
bne BSET_FAIL ; branch if Z clear
bset.b d7,(a0)+ ;
bne BSET_FAIL ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$01,(a0)+
bne BSET_FAIL ; branch if Z clear
cmpi.b #$02,(a0)+
bne BSET_FAIL ; branch if Z clear
cmpi.b #$80,(a0)+
bne BSET_FAIL ; branch if Z clear
; EA = -(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.l #$00000103,a0 ; point to memory to address
bset.b d5,-(a0)
bne BSET_FAIL ; branch if Z clear
bset.b d6,-(a0) ;
bne BSET_FAIL ; branch if Z clear
bset.b d7,-(a0) ;
bne BSET_FAIL ; branch if Z clear
move.l #$00000103,a0 ; point to memory to address 0x100
cmpi.b #$01,-(a0)
bne BSET_FAIL ; branch if Z clear
cmpi.b #$02,-(a0)
bne BSET_FAIL ; branch if Z clear
cmpi.b #$80,-(a0)
bne BSET_FAIL ; branch if Z clear
; EA = n(An) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
bset.b d5,0(a0)
bne BSET_FAIL ; branch if Z clear
bset.b d6,1(a0) ;
bne BSET_FAIL ; branch if Z clear
bset.b d7,2(a0) ;
bne BSET_FAIL ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.b #$01,(a0)+
bne BSET_FAIL ; branch if Z clear
cmpi.b #$02,(a0)+
bne BSET_FAIL ; branch if Z clear
cmpi.b #$80,(a0)+
bne BSET_FAIL ; branch if Z clear
; EA = n(An,R.W) - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.l #$00000100,a0 ; point to memory to address
move.l #$00000000,a1 ; point to memory to address
move.l #$00000001,a2 ; point to memory to address
move.l #$00000000,d0 ; point to memory to address
move.l #$00000001,d1 ; point to memory to address
bset.b d5,0(a0,d0.w)
bne BSET_FAIL ; branch if Z clear
bset.b d6,0(a0,d1.w) ;
bne BSET_FAIL ; branch if Z clear
bset.b d7,1(a0,d1.w) ;
bne BSET_FAIL ; branch if Z clear
; EA = n(An,R.L) - BYTE only
bset.b d5,2(a0,d0.l)
bne BSET_FAIL ; branch if Z clear
bset.b d6,3(a0,d1.l) ;
bne BSET_FAIL ; branch if Z clear
bset.b d7,4(a0,d1.l) ;
bne BSET_FAIL ; branch if Z clear
; EA = n(An,A.W) - BYTE only
bset.b d5,5(a0,a1.w)
bne BSET_FAIL ; branch if Z clear
bset.b d6,6(a0,a2.w) ;
bne BSET_FAIL ; branch if Z clear
bset.b d7,7(a0,a2.w) ;
bne BSET_FAIL ; branch if Z clear
; EA = n(An,A.L) - BYTE only
bset.b d5,8(a0,a1.l)
bne BSET_FAIL ; branch if Z clear
bset.b d6,9(a0,a2.l) ;
bne BSET_FAIL ; branch if Z clear
bset.b d7,10(a0,a2.l) ;
bne BSET_FAIL ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address 0x100
cmpi.l #$01028100,(a0)+
bne BSET_FAIL ; branch if Z clear
cmpi.l #$02810002,(a0)+
bne BSET_FAIL;
; EA = x.W - BYTE only
move.l #$00000100,a0 ; point to memory to address
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
bset.b d5,$0100
bne BSET_FAIL ; branch if Z clear
bset.b d6,$0100 ;
bne BSET_FAIL ; branch if Z clear
bset.b d7,$0100 ;
bne BSET_FAIL ; branch if Z clear
move.l #$00000100,a0 ; point to memory to address
cmpi.b #$83,(a0)+
bne BSET_FAIL ; branch if Z clear
; EA = x.L - BYTE only
move.l #$000F0100,a0 ; point to memory to address 0x100
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
move.b #$00,(a0)+ ; populate test data
bset.b d5,$000F0100
bne BSET_FAIL ; branch if Z clear
bset.b d6,$000F0100 ;
bne BSET_FAIL ; branch if Z clear
bset.b d7,$000F0100 ;
bne BSET_FAIL ; branch if Z clear
move.l #$000F0100,a0 ; point to memory to address 0x100
cmpi.b #$83,(a0)
bne BSET_FAIL ; branch if Z clear
movea #TESTSTATUS,a0
move.b #$1,$09(a0)
rts
BSET_FAIL:
movea #TESTSTATUS,a0
move.b #$1,$09(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : MOVEP
;-----------------------------------------------------------
;-----------------------------------------------------------
op_MOVEP:
; Dn --> x(An)
move.l #$00000100,a0
move.l #$12345678,d0
move.l #$AABBCCDD,d1
move.l #0,(a0)
move.l #0,4(a0)
movep.w d0,0(a0) ; even offset
movep.w d1,1(a0) ; odd offset
movep.l d0,4(a0) ; even offset
movep.l d1,5(a0) ; odd offset
cmpi.l #$56CC78DD,(a0)
bne MOVEP_FAIL;
cmpi.l #$12AA34BB,4(a0)
bne MOVEP_FAIL;
cmpi.l #$56CC78DD,8(a0)
bne MOVEP_FAIL;
; x(An)--> Dn
move.l #$5a5a5a5a,d0
move.l #$5a5a5a5a,d1
move.l #$5a5a5a5a,d2
move.l #$5a5a5a5a,d3
movep.w 0(a0),d0 ; even offset
movep.w 1(a0),d1 ; odd offset
movep.l 4(a0),d2 ; even offset
movep.l 5(a0),d3 ; odd offset
cmpi.l #$5a5a5678,d0
bne MOVEP_FAIL;
cmpi.l #$5a5aCCDD,d1
bne MOVEP_FAIL;
cmpi.l #$12345678,d2
bne MOVEP_FAIL;
cmpi.l #$AABBCCDD,d3
bne MOVEP_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$0a(a0)
rts
MOVEP_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$0a(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : BOOL_I
;-----------------------------------------------------------
;-----------------------------------------------------------
op_BOOL_I:
; Dn -- BYTE
move.l #$12345678,d0
move.w #$000F,CCR ; pre-set Flags
ori.b #$FF,d0
eori.b #$5A,d0
and.b #$F0,d0
bvs BOOL_I_FAIL; ; Check V,C are cleared
bcs BOOL_I_FAIL;
bpl BOOL_I_FAIL; ; Verify if N flag is set
and.b #$00,d0
bmi BOOL_I_FAIL; ; Verify if N flag is cleared
bne BOOL_I_FAIL; ; Verify if Z flag is set
; Dn -- WORD
move.l #$12345678,d1
move.w #$000F,CCR ; pre-set Flags
ori.w #$FFFF,d1
eori.w #$5A5A,d1
and.w #$F0F0,d1
bvs BOOL_I_FAIL; ; Check V,C are cleared
bcs BOOL_I_FAIL;
bpl BOOL_I_FAIL; ; Verify if N flag is set
and.w #$0000,d1
bmi BOOL_I_FAIL; ; Verify if N flag is cleared
bne BOOL_I_FAIL; ; Verify if Z flag is set
; Dn -- LONG
move.l #$12345678,d2
move.w #$000F,CCR ; pre-set Flags
ori.l #$FFFFFFFF,d2
eori.l #$5A5A5A5A,d2
and.l #$F0F0F0F0,d2
bvs BOOL_I_FAIL; ; Check V,C are cleared
bcs BOOL_I_FAIL;
bpl BOOL_I_FAIL; ; Verify if N flag is set
and.l #$00000000,d2
bmi BOOL_I_FAIL; ; Verify if N flag is cleared
bne BOOL_I_FAIL; ; Verify if Z flag is set
; (An) -- BYTE
move.l #$00000100,a0
move.l #$12345678,(a0)
move.w #$000F,CCR ; pre-set Flags
ori.b #$FF,(a0)
eori.b #$5A,(a0)
and.b #$F0,(a0)
bvs BOOL_I_FAIL; ; Check V,C are cleared
bcs BOOL_I_FAIL;
bpl BOOL_I_FAIL; ; Verify if N flag is set
and.b #$00,(a0)
bmi BOOL_I_FAIL; ; Verify if N flag is cleared
bne BOOL_I_FAIL; ; Verify if Z flag is set
cmpi.b #$00,(a0)
bne BOOL_I_FAIL; ; Verify if Z flag is set
; (An) -- WORD
move.l #$12345678,(a0)
move.w #$000F,CCR ; pre-set Flags
ori.w #$FFFF,(a0)
eori.w #$5A5A,(a0)
and.w #$F0F0,(a0)
bvs BOOL_I_FAIL; ; Check V,C are cleared
bcs BOOL_I_FAIL;
bpl BOOL_I_FAIL; ; Verify if N flag is set
and.w #$0000,(a0)
bmi BOOL_I_FAIL; ; Verify if N flag is cleared
bne BOOL_I_FAIL; ; Verify if Z flag is set
cmpi.w #$00,(a0)
bne BOOL_I_FAIL; ; Verify if Z flag is set
; (An) -- LONG
move.l #$12345678,(a0)
move.w #$000F,CCR ; pre-set Flags
ori.l #$FFFFFFFF,(a0)
eori.l #$5A5A5A5A,(a0)
and.l #$F0F0F0F0,(a0)
bvs BOOL_I_FAIL; ; Check V,C are cleared
bcs BOOL_I_FAIL;
bpl BOOL_I_FAIL; ; Verify if N flag is set
and.l #$00000000,(a0)
bmi BOOL_I_FAIL; ; Verify if N flag is cleared
bne BOOL_I_FAIL; ; Verify if Z flag is set
cmpi.l #$00,(a0)
bne BOOL_I_FAIL; ; Verify if Z flag is set
; (An)+ -- BYTE
move.l #$00000100,a0
move.l #$00A5FF88,(a0)
move.w #$000F,CCR ; pre-set Flags
ori.b #$F5,(a0)+
bpl BOOL_I_FAIL; ; Verify if N flag is set
beq BOOL_I_FAIL; ; Verify if Z flag is cleared
eori.b #$FF,(a0)+
bmi BOOL_I_FAIL; ; Verify if N flag is cleared
beq BOOL_I_FAIL; ; Verify if Z flag is cleared
and.b #$AA,(a0)+
bpl BOOL_I_FAIL; ; Verify if N flag is set
beq BOOL_I_FAIL; ; Verify if Z flag is cleared
move.l #$00000100,a0
cmpi.l #$F55AAA88,(a0)
bne BOOL_I_FAIL; ; Verify if Z flag is set
; (An)+ -- WORD
move.l #$00000100,a0
move.l #$00000104,a1
move.l #$00005a5a,(a0)
move.l #$12345678,(a1)
move.w #$000F,CCR ; pre-set Flags
ori.w #$5678,(a0)+
bmi BOOL_I_FAIL; ; Verify if N flag is cleared
beq BOOL_I_FAIL; ; Verify if Z flag is cleared
eori.w #$FFFF,(a0)+
bpl BOOL_I_FAIL; ; Verify if N flag is set
beq BOOL_I_FAIL; ; Verify if Z flag is cleared
and.w #$A55A,(a0)+
bmi BOOL_I_FAIL; ; Verify if N flag is cleared
beq BOOL_I_FAIL; ; Verify if Z flag is cleared
move.l #$00000100,a0
cmpi.l #$5678a5a5,(a0)
move.l #$00000104,a0
cmpi.l #$00105678,(a0)
bne BOOL_I_FAIL; ; Verify if Z flag is set
; (An)+ -- LONG
move.l #$00000100,a0
move.l #$00000000,(a0)+
move.l #$5a5a5a5a,(a0)+
move.l #$FFFFFFFF,(a0)+
move.l #$00000100,a0
move.w #$000F,CCR ; pre-set Flags
ori.l #$12345678,(a0)+
bmi BOOL_I_FAIL; ; Verify if N flag is cleared
beq BOOL_I_FAIL; ; Verify if Z flag is cleared
eori.l #$FFFFFFFF,(a0)+
bpl BOOL_I_FAIL; ; Verify if N flag is set
beq BOOL_I_FAIL; ; Verify if Z flag is cleared
and.l #$A5A5A55A,(a0)+
bpl BOOL_I_FAIL; ; Verify if N flag is set
beq BOOL_I_FAIL; ; Verify if Z flag is cleared
move.l #$00000100,a0
cmpi.l #$12345678,(a0)+
cmpi.l #$a5a5a5a5,(a0)+
cmpi.l #$a5a5a55a,(a0)+
bne BOOL_I_FAIL; ; Verify if Z flag is set
movea #TESTSTATUS,a0
move.b #$1,$0b(a0)
rts
BOOL_I_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$0b(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : BSR
;-----------------------------------------------------------
;-----------------------------------------------------------
BSR_CLOSE1: move.l #$11111111,d1
rts
op_BSR: bsr.s BSR_CLOSE1 ; Negative 8-bit displacement
bsr.s BSR_CLOSE2 ; Positive 8-bit displacement
bsr.w BSR_FAR1 ; Negative 16-bit displacement
bsr.w BSR_FAR2 ; Positive 16-bit displacement
cmpi.l #$11111111,d1
bne BSR_FAIL;
cmpi.l #$22222222,d2
bne BSR_FAIL;
cmpi.l #$33333333,d3
bne BSR_FAIL;
cmpi.l #$44444444,d4
bne BSR_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$0c(a0)
rts
BSR_CLOSE2: move.l #$22222222,d2
rts
BSR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$0c(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : op_CMP_I
;-----------------------------------------------------------
;-----------------------------------------------------------
op_CMP_I:
move.l #$00000100,a0
move.l #$00000100,(a0)
; REGISTER - BYTE
move.l #$FFFFFF80,d0
cmpi.b #$80,d0
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFFFF000,d1
cmpi.b #$00,d1
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFFFFF02,d2
cmpi.b #$FF,d2
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFFFFF7F,d3
cmpi.b #$FF,d3
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bpl CMP_I_FAIL; ; Check N Flag bmi/bpl #FIXME
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvc CMP_I_FAIL; ; Check V Flag bvc/bvs
; REGISTER - WORD
move.l #$FFFF8000,d0
cmpi.w #$8000,d0
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFF00000,d1
cmpi.w #$0000,d1
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFFF0002,d2
cmpi.w #$FFFF,d2
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFFF7FFF,d3
cmpi.w #$FFFF,d3
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bpl CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvc CMP_I_FAIL; ; Check V Flag bvc/bvs
; REGISTER - LONG
move.l #$80000000,d0
cmpi.l #$80000000,d0
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$00000000,d1
cmpi.l #$00000000,d1
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$00000002,d2
cmpi.l #$FFFFFFFF,d2
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$7FFFFFFF,d3
cmpi.l #$FFFFFFFF,d3
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bpl CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvc CMP_I_FAIL; ; Check V Flag bvc/bvs
; EA=x(An,Dn) - BYTE
move.l #$00000100,a0
move.l #$00000004,d7
move.l #$FFFFFF80,12(a0,d7)
move.l #$FFFFFF80,12(a0,d7)
cmpi.b #$80,15(a0,d7)
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFFFF000,12(a0,d7)
cmpi.b #$00,15(a0,d7)
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFFFFF02,12(a0,d7)
cmpi.b #$FF,15(a0,d7)
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFFFFF7F,12(a0,d7)
cmpi.b #$FF,15(a0,d7)
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bpl CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvc CMP_I_FAIL; ; Check V Flag bvc/bvs
; EA=x(An,Dn) - WORD
move.l #$FFFF8000,12(a0,d7)
cmpi.w #$8000,14(a0,d7)
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFF00000,12(a0,d7)
cmpi.w #$0000,14(a0,d7)
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFFF0002,12(a0,d7)
cmpi.w #$FFFF,14(a0,d7)
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$FFFF7FFF,12(a0,d7)
cmpi.w #$FFFF,14(a0,d7)
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bpl CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvc CMP_I_FAIL; ; Check V Flag bvc/bvs
; EA=x(An,Dn) - LONG
move.l #$80000000,12(a0,d7)
cmpi.l #$80000000,12(a0,d7)
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$00000000,12(a0,d7)
cmpi.l #$00000000,12(a0,d7)
bne CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcs CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$00000002,12(a0,d7)
cmpi.l #$FFFFFFFF,12(a0,d7)
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bmi CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvs CMP_I_FAIL; ; Check V Flag bvc/bvs
move.l #$7FFFFFFF,12(a0,d7)
cmpi.l #$FFFFFFFF,12(a0,d7)
beq CMP_I_FAIL; ; Check Z Flag beq/bne
bpl CMP_I_FAIL; ; Check N Flag bmi/bpl
bcc CMP_I_FAIL; ; Check C Flag bcc/bcs
bvc CMP_I_FAIL; ; Check V Flag bvc/bvs
movea #TESTSTATUS,a0
move.b #$1,$0d(a0)
rts
CMP_I_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$0d(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ADD_I
;-----------------------------------------------------------
;-----------------------------------------------------------
op_ADD_I:
; EA = Dn - Byte
move.l #$12345678,d0 ; populate test data
addi.b #0,d0
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvs ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.b #$10,d0
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bpl ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvc ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.b #$A5,d0
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcc ADD_I_FAIL; ; Check C Flag bcc/bcs
bvc ADD_I_FAIL; ; Check V Flag bvc/bvs
cmpi.b #$2D,d0
bne ADD_I_FAIL; ; Check Z Flag beq/bne
; EA = Dn - WORD
move.l #$12345678,d0 ; populate test data
addi.w #0,d0
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvs ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.w #$7000,d0
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bpl ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvc ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.w #$A55A,d0
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcc ADD_I_FAIL; ; Check C Flag bcc/bcs
bvc ADD_I_FAIL; ; Check V Flag bvc/bvs
cmpi.w #$6BD2,d0
bne ADD_I_FAIL; ; Check Z Flag beq/bne
; EA = Dn - LONG
move.l #$12345678,d0 ; populate test data
addi.l #0,d0
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvs ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.l #$F0000000,d0
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcc ADD_I_FAIL; ; Check C Flag bcc/bcs
bvs ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.l #$855AA55A,d0
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bpl ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvs ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.l #$A0000000,d0
bvc ADD_I_FAIL; ; Check V Flag bvc/bvs
cmpi.l #$278EFBD2,d0
bne ADD_I_FAIL; ; Check Z Flag beq/bne
; EA = x.L - Byte
move.l #$000F0100,a0 ; populate test data
move.l #$12345678,(a0) ; populate test data
addi.b #0,$000F0103
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvs ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.b #$10,$000F0103
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bpl ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvc ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.b #$A5,$000F0103
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcc ADD_I_FAIL; ; Check C Flag bcc/bcs
bvc ADD_I_FAIL; ; Check V Flag bvc/bvs
cmpi.b #$2D,$000F0103
bne ADD_I_FAIL; ; Check Z Flag beq/bne
; EA = x.L- WORD
move.l #$000F0100,a0 ; populate test data
move.l #$12345678,(a0) ; populate test data
addi.w #0,$000F0100
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvs ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.w #$7000,$000F0100
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bpl ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvc ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.w #$A55A,$000F0100
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcc ADD_I_FAIL; ; Check C Flag bcc/bcs
bvc ADD_I_FAIL; ; Check V Flag bvc/bvs
cmpi.w #$278E,$000F0100
bne ADD_I_FAIL; ; Check Z Flag beq/bne
; EA = x.L- LONG
move.l #$12345678,$000F0100 ; populate test data
addi.l #0,$000F0100
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvs ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.l #$F0000000,$000F0100
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bmi ADD_I_FAIL; ; Check N Flag bmi/bpl
bcc ADD_I_FAIL; ; Check C Flag bcc/bcs
bvs ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.l #$855AA55A,$000F0100
beq ADD_I_FAIL; ; Check Z Flag beq/bne
bpl ADD_I_FAIL; ; Check N Flag bmi/bpl
bcs ADD_I_FAIL; ; Check C Flag bcc/bcs
bvs ADD_I_FAIL; ; Check V Flag bvc/bvs
addi.l #$A0000000,$000F0100
bvc ADD_I_FAIL; ; Check V Flag bvc/bvs
cmpi.l #$278EFBD2,$000F0100
bne ADD_I_FAIL; ; Check Z Flag beq/bne
movea #TESTSTATUS,a0
move.b #$1,$0e(a0)
rts
ADD_I_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$0e(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : SUB_I
;-----------------------------------------------------------
;-----------------------------------------------------------
op_SUB_I:
; EA = Dn - Byte
move.l #$12345678,d0 ; populate test data
subi.b #0,d0
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcs SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.b #$10,d0
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcs SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.b #$A5,d0
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bpl SUB_I_FAIL; ; Check N Flag bmi/bpl
bcc SUB_I_FAIL; ; Check C Flag bcc/bcs
bvc SUB_I_FAIL; ; Check V Flag bvc/bvs
cmpi.b #$C3,d0
bne SUB_I_FAIL; ; Check Z Flag beq/bne
; EA = Dn - WORD
move.l #$12345678,d0 ; populate test data
subi.w #0,d0
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcs SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.w #$7000,d0
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bpl SUB_I_FAIL; ; Check N Flag bmi/bpl
bcc SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.w #$A55A,d0
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcs SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
cmpi.w #$411E,d0
bne SUB_I_FAIL; ; Check Z Flag beq/bne
; EA = Dn - LONG
move.l #$12345678,d0 ; populate test data
subi.l #0,d0
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcs SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.l #$F0000000,d0
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcc SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.l #$855AA55A,d0
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bpl SUB_I_FAIL; ; Check N Flag bmi/bpl
bcc SUB_I_FAIL; ; Check C Flag bcc/bcs
bvc SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.l #$A0000000,d0
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
cmpi.l #$FCD9B11E,d0
bne SUB_I_FAIL; ; Check Z Flag beq/bne
; EA = x.L - Byte
move.l #$000F0100,a0 ; populate test data
move.l #$12345678,(a0) ; populate test data
subi.b #0,$000F0103
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcs SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.b #$10,$000F0103
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcs SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.b #$A5,$000F0103
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bpl SUB_I_FAIL; ; Check N Flag bmi/bpl
bcc SUB_I_FAIL; ; Check C Flag bcc/bcs
bvc SUB_I_FAIL; ; Check V Flag bvc/bvs
cmpi.b #$C3,$000F0103
bne SUB_I_FAIL; ; Check Z Flag beq/bne
; EA = x.L- WORD
move.l #$000F0100,a0 ; populate test data
move.l #$12345678,(a0) ; populate test data
subi.w #0,$000F0100
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcs SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.w #$7000,$000F0100
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bpl SUB_I_FAIL; ; Check N Flag bmi/bpl
bcc SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.w #$A55A,$000F0100
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bpl SUB_I_FAIL; ; Check N Flag bmi/bpl
bcc SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
cmpi.w #$FCDA,$000F0100
bne SUB_I_FAIL; ; Check Z Flag beq/bne
; EA = x.L- LONG
move.l #$12345678,$000F0100 ; populate test data
subi.l #0,$000F0100
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcs SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.l #$F0000000,$000F0100
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bmi SUB_I_FAIL; ; Check N Flag bmi/bpl
bcc SUB_I_FAIL; ; Check C Flag bcc/bcs
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.l #$855AA55A,$000F0100
beq SUB_I_FAIL; ; Check Z Flag beq/bne
bpl SUB_I_FAIL; ; Check N Flag bmi/bpl
bcc SUB_I_FAIL; ; Check C Flag bcc/bcs
bvc SUB_I_FAIL; ; Check V Flag bvc/bvs
subi.l #$A0000000,$000F0100
bvs SUB_I_FAIL; ; Check V Flag bvc/bvs
cmpi.l #$FCD9B11E,$000F0100
bne SUB_I_FAIL; ; Check Z Flag beq/bne
movea #TESTSTATUS,a0
move.b #$1,$0f(a0)
rts
SUB_I_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$0f(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : MOVE
;-----------------------------------------------------------
;-----------------------------------------------------------
op_MOVE:
move.l #$11223344,d0
move.l #$55667788,d1
move.l #$8899aabb,d2
move.l #$ccddeeff,d3
move.l #$00000000,d4
move.l #$00000000,d5
move.l #$00000000,d6
move.l #$00000000,d7
move.l #$44332211,a0
move.l #$88776655,a1
move.l #$bbaa9988,a2
move.l #$ffeeddcc,a3
move.b d0,d4 ; BYTE - DATA REGISTER
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.l #$00000044,d4
bne MOVE_FAIL; ; Check Z Flag beq/bne
move.w d1,d5 ; WORD - DATA REGISTER
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.l #$00007788,d5
bne MOVE_FAIL; ; Check Z Flag beq/bne
move.l d2,d6 ; LONG - DATA REGISTER
beq MOVE_FAIL; ; Check Z Flag beq/bne
bpl MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.l #$8899aabb,d6
bne MOVE_FAIL; ; Check Z Flag beq/bne
move.w a1,d5 ; WORD - ADDRESS REGISTER
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.l #$00006655,d5
bne MOVE_FAIL; ; Check Z Flag beq/bne
move.l a2,d6 ; LONG - ADDRESS REGISTER
beq MOVE_FAIL; ; Check Z Flag beq/bne
bpl MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.l #$bbaa9988,d6
bne MOVE_FAIL; ; Check Z Flag beq/bne
movea.w d2,a4 ; WORD - ADDRESS REGISTER as SOURCE ## MOVEA
cmpa.l d2,a4
beq MOVE_FAIL; ; Check Z Flag beq/bne ## comopare fails because A4 was sign extended
movea.l d1,a5 ; LONG - ADDRESS REGISTER as SOURCE ## MOVEA
cmpa.l d1,a5
bne MOVE_FAIL; ; Check Z Flag beq/bne
; Too mamy EA combinations to test,so we focus on a few of the more complicted EA's
move.l #$11223344,d0
move.l #$00010100,d1
move.l #$8899aabb,d2
move.l #$00000001,d3
move.l #$00000000,d4
move.l #$00000000,d5
move.l #$00000000,d6
move.l #$00000000,d7
move.l #$00000000,a0
move.l #$00010100,a1
; x(An,AL) --> x.L
move.b #$5A,4(a0,a1.l) ; BYTE
lea 4(a0,a1.l),a3
move.b 4(a0,a1.l),$00010105
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.b #$5A,5(a0,a1.l)
bne MOVE_FAIL; ; Check Z Flag beq/bne
; x.L --> n(An,Dw)
MOVE2: move.b $00010105,7(a0,d1.w) ; BYTE
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.b #$5A,7(a0,d1.w)
bne MOVE_FAIL; ; Check Z Flag beq/bne
; x(PC,Ds) --> x.w
move.b MOVE1(pc,d3),$0100 ; BYTE
beq MOVE_FAIL; ; Check Z Flag beq/bne
bpl MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.b #$B9,1+MOVE2
bne MOVE_FAIL; ; Check Z Flag beq/bne
; #x --> n(An,AL)
move.b #$78,7(a0,d1.w) ; BYTE
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.b #$78,7(a0,d1.w)
bne MOVE_FAIL; ; Check Z Flag beq/bne
move.l #$11223344,d0
move.l #$00010100,d1
move.l #$8899aabb,d2
move.l #$00000002,d3
moveq #$00,d4
moveq #$00,d5
moveq #$00,d6
moveq #$00,d7
suba.l a0,a0
move.l #$00010100,a1
; x(An,AL) --> x.L
move.w #$5A5A,4(a0,a1.l) ; WORD
lea 4(a0,a1.l),a4
move.w 4(a0,a1.l),$00010104
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.w #$5A5A,4(a0,a1.l)
bne MOVE_FAIL; ; Check Z Flag beq/bne
; x.L --> n(An,Dw)
MOVE1: move.w $00010104,6(a0,d1.w) ; WORD
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.w #$5A5A,6(a0,d1.w)
bne MOVE_FAIL; ; Check Z Flag beq/bne
; x(PC,Ds) --> x.w
move.w MOVE1(pc,d3),$0100 ; WORD
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.w #$6700,8+MOVE1
bne MOVE_FAIL; ; Check Z Flag beq/bne
; #x --> n(An,AL)
move.w #$7878,6(a0,d1.w) ; WORD
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.w #$7878,6(a0,d1.w)
bne MOVE_FAIL; ; Check Z Flag beq/bne
; ---
move.l #$11223344,d0
move.l #$00010100,d1
move.l #$8899aabb,d2
move.l #$00000002,d3
move.l #$00000000,d4
move.l #$00000000,d5
move.l #$00000000,d6
move.l #$00000000,d7
move.l #$00000000,a0
move.l #$00010100,a1
; x(An,AL) --> x.L
move.l #$5A5A1234,4(a0,a1.l) ; LONG
lea 4(a0,a1.l),a4
move.l 4(a0,a1.l),$00010104
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.l #$5A5A1234,4(a0,a1.l)
bne MOVE_FAIL; ; Check Z Flag beq/bne
; x.L --> n(An,Dw)
MOVE3: move.l $00010104,6(a0,d1.w) ; LONG
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.l #$5A5A1234,6(a0,d1.w)
bne MOVE_FAIL; ; Check Z Flag beq/bne
; x(PC,Ds) --> x.w
move.l MOVE3(pc,d3),$0100 ; LONG
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.l #$67000058,8+MOVE3
bne MOVE_FAIL; ; Check Z Flag beq/bne
; #x --> n(An,AL)
move.l #$78782323,6(a0,d1.w) ; LONG
beq MOVE_FAIL; ; Check Z Flag beq/bne
bmi MOVE_FAIL; ; Check N Flag bmi/bpl
cmpi.l #$78782323,6(a0,d1.w)
bne MOVE_FAIL; ; Check Z Flag beq/bne
movea #TESTSTATUS,a0
move.b #$1,$10(a0)
rts
MOVE_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$10(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : MOVE_xxx_FLAGS
;-----------------------------------------------------------
;-----------------------------------------------------------
op_MOVE_xxx_FLAGS:
; Move_To_SR
; Dn
move.w #$2FFF,d0
move d0,SR
bpl MOVE_FLAGS_FAIL; ; branch if Z clear
bne MOVE_FLAGS_FAIL; ; branch if N clear
bvc MOVE_FLAGS_FAIL; ; branch if V clear
bcc MOVE_FLAGS_FAIL; ; branch if C clear
move.w #$2F00,d0
move d0,CCR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
move.w #$2000,d0
move d0,SR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
; (An)
move.l #$00000100,a0
move.w #$2FFF,(a0)
move (a0),SR
bpl MOVE_FLAGS_FAIL; ; branch if Z clear
bne MOVE_FLAGS_FAIL; ; branch if N clear
bvc MOVE_FLAGS_FAIL; ; branch if V clear
bcc MOVE_FLAGS_FAIL; ; branch if C clear
move.w #$2000,(a0)
move (a0),SR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
; (An)+
move.l #$00000100,a0
move.w #$2FFF,(a0)
move (a0)+,SR
bpl MOVE_FLAGS_FAIL; ; branch if Z clear
bne MOVE_FLAGS_FAIL; ; branch if N clear
bvc MOVE_FLAGS_FAIL; ; branch if V clear
bcc MOVE_FLAGS_FAIL; ; branch if C clear
move.w #$2000,(a0)
move (a0)+,SR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
; -(An)
move.l #$00000102,a0
move.w #$2FFF,(a0)
move (a0)+,SR
bpl MOVE_FLAGS_FAIL; ; branch if Z clear
bne MOVE_FLAGS_FAIL; ; branch if N clear
bvc MOVE_FLAGS_FAIL; ; branch if V clear
bcc MOVE_FLAGS_FAIL; ; branch if C clear
move.w #$2000,(a0)
move (a0)+,SR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
; n(An)
move.l #$00000102,a0
move.w #$2FFF,2(a0)
move 2(a0),SR
bpl MOVE_FLAGS_FAIL; ; branch if Z clear
bne MOVE_FLAGS_FAIL; ; branch if N clear
bvc MOVE_FLAGS_FAIL; ; branch if V clear
bcc MOVE_FLAGS_FAIL; ; branch if C clear
move.w #$2000,2(a0)
move 2(a0),SR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
; n(An,Rn.l)
move.l #$00000100,a0
move.l #$00000002,d0
move.w #$2FFF,2(a0,d0.l)
move 2(a0,d0.l),SR
bpl MOVE_FLAGS_FAIL; ; branch if Z clear
bne MOVE_FLAGS_FAIL; ; branch if N clear
bvc MOVE_FLAGS_FAIL; ; branch if V clear
bcc MOVE_FLAGS_FAIL; ; branch if C clear
move.w #$2000,2(a0,d0.l)
move 2(a0,d0.l),SR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
; x.W
move.w #$2FFF,$0100
move $0100,SR
bpl MOVE_FLAGS_FAIL; ; branch if Z clear
bne MOVE_FLAGS_FAIL; ; branch if N clear
bvc MOVE_FLAGS_FAIL; ; branch if V clear
bcc MOVE_FLAGS_FAIL; ; branch if C clear
move.w #$2000,$0100
move $0100,SR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
; x.L
move.w #$2FFF,$00010100
move $00010100,SR
bpl MOVE_FLAGS_FAIL; ; branch if Z clear
bne MOVE_FLAGS_FAIL; ; branch if N clear
bvc MOVE_FLAGS_FAIL; ; branch if V clear
bcc MOVE_FLAGS_FAIL; ; branch if C clear
MOVE4: move.w #$2000,$00010100
move $00010100,SR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
; x(PC)
move MOVE4+2(pc),SR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
; x(PC,d0.l)
move.l #$00000000,d0
move MOVE4+2(pc,d0.l),SR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
move MOVE4+2(pc,d0.l),CCR
beq MOVE_FLAGS_FAIL; ; branch if Z set
bmi MOVE_FLAGS_FAIL; ; branch if N set
bvs MOVE_FLAGS_FAIL; ; branch if V set
bcs MOVE_FLAGS_FAIL; ; branch if C set
; #x
move #$2FFF,SR
bne MOVE_FLAGS_FAIL; ; branch if Z clear
bpl MOVE_FLAGS_FAIL; ; branch if N clear
bvc MOVE_FLAGS_FAIL; ; branch if V clear
bcc MOVE_FLAGS_FAIL; ; branch if C clear
; MOVE_From_SR
; Dn
move #$275A,SR ; Initial value
move SR,d0
cmpi.w #$271A,d0
bne MOVE_FLAGS_FAIL; ; branch if Z set
; (An)
move.l #$00000100,a0
move #$275A,SR ; Initial value
move SR,(a0)
cmpi.w #$271A,(a0)
bne MOVE_FLAGS_FAIL; ; branch if Z set
; (An)+
move.l #$00000100,a0
move #$257A,SR ; Initial value
move SR,(a0)+
move.l #$00000100,a0
cmpi.w #$251A,(a0)+
bne MOVE_FLAGS_FAIL; ; branch if Z set
; -(An)
move.l #$00000102,a0
move #$2766,SR ; Initial value
move SR,-(a0)
move.l #$00000100,a0
cmpi.w #$2706,(a0)
bne MOVE_FLAGS_FAIL; ; branch if Z set
; x(An)
move.l #$00000102,a0
move #$2733,SR ; Initial value
move SR,4(a0)
cmpi.w #$2713,4(a0)
bne MOVE_FLAGS_FAIL; ; branch if Z set
; x(An,rn)
move.l #$00000102,a0
move.l #$00000004,d0
move #$275a,SR ; Initial value
move SR,4(a0,d0.l)
cmpi.w #$271a,4(a0,d0.l)
bne MOVE_FLAGS_FAIL; ; branch if Z set
; x.W
move #$2777,SR ; Initial value
move SR,$0102
cmpi.w #$2717,$0102
bne MOVE_FLAGS_FAIL; ; branch if Z set
; x.L
move #$2777,SR ; Initial value
move SR,$10102
cmpi.w #$2717,$10102
bne MOVE_FLAGS_FAIL; ; branch if Z set
move #$2700,SR ; Put flags back to initial value
movea #TESTSTATUS,a0
move.b #$1,$11(a0)
rts
MOVE_FLAGS_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$11(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : EXT
;-----------------------------------------------------------
;-----------------------------------------------------------
op_EXT:
move.l #$0000007F,d0
move.l #$00008FFF,d1
move.l #$00000000,d2
ext.w d0
bmi EXT_FAIL; ; Check N Flag bmi/bpl
beq EXT_FAIL; ; Check Z Flag beq/bne
cmpi.l #$0000007F,d0
bne EXT_FAIL; ; branch if Z set
ext.l d1
bpl EXT_FAIL; ; Check N Flag bmi/bpl
beq EXT_FAIL; ; Check Z Flag beq/bne
cmpi.l #$FFFF8FFF,d1
bne EXT_FAIL; ; branch if Z set
ext.l d2
bne EXT_FAIL; ; Check Z Flag beq/bne
movea #TESTSTATUS,a0
move.b #$1,$12(a0)
rts
EXT_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$12(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : SWAP
;-----------------------------------------------------------
;-----------------------------------------------------------
op_SWAP:
move.l #$12345678,d0
swap d0
bmi SWAP_FAIL; ; Check N Flag bmi/bpl
beq SWAP_FAIL; ; Check Z Flag beq/bne
cmpi.l #$56781234,d0
bne SWAP_FAIL; ; branch if Z set
movea #TESTSTATUS,a0
move.b #$1,$13(a0)
rts
SWAP_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$13(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : LEA_PEA
;-----------------------------------------------------------
;-----------------------------------------------------------
op_LEAPEA:
move.l #$00345678,a0
move.l #$00000000,d4
; (An)
lea (a0),a6
move.l a6,d0
cmpi.l #$00345678,d0
bne LEAPEA_FAIL; ; branch if Z set
pea (a0)
cmpi.l #$00345678,(a7)
bne LEAPEA_FAIL; ; branch if Z set
addq #4,a7 ; Restore Stack Pointer
; x(An)
lea 4(a0),a6
move.l a6,d0
cmpi.l #$0034567C,d0
bne LEAPEA_FAIL; ; branch if Z set
pea 4(a0)
cmpi.l #$0034567C,(a7)
bne LEAPEA_FAIL; ; branch if Z set
addq #4,a7 ; Restore Stack Pointer
; x(An,Dn.l)
lea 4(a0,d4),a6
move.l a6,d0
cmpi.l #$0034567C,d0
bne LEAPEA_FAIL; ; branch if Z set
pea 4(a0,d4.l)
cmpi.l #$0034567C,(a7)
bne LEAPEA_FAIL; ; branch if Z set
addq #4,a7 ; Restore Stack Pointer
; x.W
lea $1234,a6
move.l a6,d0
cmpi.w #$1234,d0
bne LEAPEA_FAIL; ; branch if Z set
pea $1234
cmpi.l #$00001234,(a7)
bne LEAPEA_FAIL; ; branch if Z set
addq #4,a7 ; Restore Stack Pointer
; x.L
lea $00345678,a6
move.l a6,d0
cmp.l a6,d0
bne LEAPEA_FAIL; ; branch if Z set
pea $00345678
cmpi.l #$00345678,(a7)
bne LEAPEA_FAIL; ; branch if Z set
addq #4,a7 ; Restore Stack Pointer
; x(PC)
lea LEA1(pc),a6
move.l a6,d0
cmp.l a6,d0
bne LEAPEA_FAIL; ; branch if Z set
LEA1: pea LEA1(pc)
cmpi.l #$0000241E,(a7)
beq LEAPEA_FAIL; ; branch if Z clear
addq #4,a7 ; Restore Stack Pointer
move #$2700,SR ; Put flags back to initial value
movea #TESTSTATUS,a0
move.b #$1,$14(a0)
rts
LEAPEA_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$14(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : LEA_TAS
;-----------------------------------------------------------
;-----------------------------------------------------------
op_TAS:
; Test just one addressing mode
move.l #$00000100,a0
; (An)
move.b #$00,(a0)
bmi TAS_FAIL; ; Check N Flag bmi/bpl
bne TAS_FAIL; ; Check Z Flag beq/bne
tas (a0)
cmpi.b #$80,(a0)
bne TAS_FAIL; ; branch if Z set
move.b #$F5,(a0)
tas (a0)
bpl TAS_FAIL; ; Check N Flag bmi/bpl
beq TAS_FAIL; ; Check Z Flag beq/bne
tas (a0)
cmpi.b #$F5,(a0)
bne TAS_FAIL ; branch if Z set
movea #TESTSTATUS,a0
move.b #$1,$15(a0)
rts
TAS_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$15(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : LEA_TST
;-----------------------------------------------------------
;-----------------------------------------------------------
op_TST:
; Test just one addressing mode
move.l #$00000100,a0
; (An) - BYTE
move.b #$00,(a0)
tst.b (a0)
bmi TST_FAIL; ; Check N Flag bmi/bpl
bne TST_FAIL; ; Check Z Flag beq/bne
move.b #$F5,(a0)
tst.b (a0)
bpl TST_FAIL; ; Check N Flag bmi/bpl
beq TST_FAIL; ; Check Z Flag beq/bne
; (An) - WORD
move.w #$0000,(a0)
tst.w (a0)
bmi TST_FAIL; ; Check N Flag bmi/bpl
bne TST_FAIL; ; Check Z Flag beq/bne
move.w #$F567,(a0)
tst.w (a0)
bpl TST_FAIL; ; Check N Flag bmi/bpl
beq TST_FAIL; ; Check Z Flag beq/bne
; (An) - LONG
move.l #$00000000,(a0)
tst.l (a0)
bmi TST_FAIL; ; Check N Flag bmi/bpl
bne TST_FAIL; ; Check Z Flag beq/bne
move.l #$F56789ab,(a0)
tst.l (a0)
bpl TST_FAIL; ; Check N Flag bmi/bpl
beq TST_FAIL; ; Check Z Flag beq/bne
movea #TESTSTATUS,a0
move.b #$1,$16(a0)
rts
TST_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$16(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : LINKS
;-----------------------------------------------------------
;-----------------------------------------------------------
op_LINKS:
move.l #$11223344,a0
move.l #$11223344,d0
link a0,#$0
cmpi.l #$11223344,(a7)
unlk a0
cmp.l d0,a0
bne LINK_FAIL; ; branch if Z set
movea #TESTSTATUS,a0
move.b #$1,$17(a0)
rts
LINK_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$17(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : MOVE_USP
;-----------------------------------------------------------
;-----------------------------------------------------------
op_MOVE_USP:
move.l #$11223344,a0
move USP,a3
move a0,USP
move USP,a1
cmp.l a0,a1
bne MOVE_USP_FAIL; ; branch if Z set
move a3,USP
movea #TESTSTATUS,a0
move.b #$1,$18(a0)
rts
MOVE_USP_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$18(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : CHK
;-----------------------------------------------------------
;-----------------------------------------------------------
op_CHK:
move.w #$1122,d0
move.w #$1122,d1
chk d0,d1
nop
nop
move.w #$1122,d1
chk #$1122,d1
; Comment out when using Easy68K
move.w #$1122,d1
chk #00122,d1
cmp.l #$EEEE0006,d6
bne CHK_FAIL; ; branch if Z set
move.w #$1122,d0
move.w #$8000,d1
chk d0,d1
cmp.l #$EEEE0006,d6
bne CHK_FAIL; ; branch if Z set
movea #TESTSTATUS,a0
move.b #$1,$19(a0)
rts
CHK_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$19(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : NEGS
;-----------------------------------------------------------
;-----------------------------------------------------------
op_NEGS:
; NOT - BYTE
move.l #$00000100,a0
move.l #$00000000,d0
not.b d0
bpl NEGS_FAIL; ; Check N Flag bmi/bpl
beq NEGS_FAIL; ; Check Z Flag beq/bne
not.b d0
bmi NEGS_FAIL; ; Check N Flag bmi/bpl
bne NEGS_FAIL; ; Check Z Flag beq/bne
cmpi.b #$00,d0
bne NEGS_FAIL; ; Check Z Flag beq/bne
move.b #$80,(a0)
not.b (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl
beq NEGS_FAIL; ; Check Z Flag beq/bne
not.b (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl
beq NEGS_FAIL; ; Check Z Flag beq/bne
cmpi.b #$80,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
; NOT - WORD
move.l #$00000100,a0
move.l #$00000000,d0
not.w d0
bpl NEGS_FAIL; ; Check N Flag bmi/bpl
beq NEGS_FAIL; ; Check Z Flag beq/bne
not.w d0
bmi NEGS_FAIL; ; Check N Flag bmi/bpl
bne NEGS_FAIL; ; Check Z Flag beq/bne
cmpi.w #$0000,d0
bne NEGS_FAIL; ; Check Z Flag beq/bne
move.w #$5a5a,(a0)
not.w (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl
beq NEGS_FAIL; ; Check Z Flag beq/bne
not.w (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl
beq NEGS_FAIL; ; Check Z Flag beq/bne
cmpi.w #$5a5a,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
; NOT - LONG
move.l #$00000100,a0
move.l #$00000000,d0
not.l d0
bpl NEGS_FAIL; ; Check N Flag bmi/bpl
beq NEGS_FAIL; ; Check Z Flag beq/bne
not.l d0
bmi NEGS_FAIL; ; Check N Flag bmi/bpl
bne NEGS_FAIL; ; Check Z Flag beq/bne
cmpi.l #$00000000,d0
bne NEGS_FAIL; ; Check Z Flag beq/bne
move.l #$5a5a1234,(a0)
not.l (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl
beq NEGS_FAIL; ; Check Z Flag beq/bne
not.l (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl
beq NEGS_FAIL; ; Check Z Flag beq/bne
cmpi.l #$5a5a1234,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
; -----
; NEG - BYTE
move.l #$00000100,a0
move.l #$00000000,d0
move.l #$00000080,d1
neg.b d0
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
bne NEGS_FAIL; ; Check Z Flag beq/bne 1
bcs NEGS_FAIL; ; Check C Flag bcc/bcs 1
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
neg.b d1
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvc NEGS_FAIL; ; Check V Flag bvc/bvs 0
cmpi.b #$80,d1
bne NEGS_FAIL; ; Check Z Flag beq/bne
move.b #$7F,(a0)
neg.b (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
move.b #$F5,(a0)
neg.b (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
cmpi.b #$0B,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
; -----
; NEG - WORD
move.l #$00000100,a0
move.l #$00000000,d0
move.l #$00008000,d1
neg.w d0
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
bne NEGS_FAIL; ; Check Z Flag beq/bne 1
bcs NEGS_FAIL; ; Check C Flag bcc/bcs 1
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
neg.w d1
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvc NEGS_FAIL; ; Check V Flag bvc/bvs 0
cmpi.w #$8000,d1
bne NEGS_FAIL; ; Check Z Flag beq/bne
move.w #$7FFF,(a0)
neg.w (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
move.w #$F578,(a0)
neg.w (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
cmpi.w #$0A88,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
; -----
; NEG - LONG
move.l #$00000100,a0
move.l #$00000000,d0
move.l #$80000000,d1
neg.l d0
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
bne NEGS_FAIL; ; Check Z Flag beq/bne 1
bcs NEGS_FAIL; ; Check C Flag bcc/bcs 1
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
neg.l d1
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvc NEGS_FAIL; ; Check V Flag bvc/bvs 0
cmpi.l #$80000000,d1
bne NEGS_FAIL; ; Check Z Flag beq/bne
move.l #$7FFFFFFF,(a0)
neg.l (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
move.l #$F5781234,(a0)
neg.l (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
cmpi.l #$0A87EDCC,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
; -----
; NEGX - BYTE
move.l #$00000100,a0
move.l #$00000000,d0
move.l #$00000080,d1
ori.b #$10,CCR ; Set X Flag
negx.b d0
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 1
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 1
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
andi.b #$EF,CCR ; Clear X Flag
negx.b d0
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 1
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 1
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
ori.b #$10,CCR ; Set X Flag
negx.b d1
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 0
cmpi.b #$7F,d1
bne NEGS_FAIL; ; Check Z Flag beq/bne
andi.b #$EF,CCR ; Clear X Flag
negx.b d1
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 0
cmpi.b #$81,d1
bne NEGS_FAIL; ; Check Z Flag beq/bne
move.b #$7F,(a0)
ori.b #$10,CCR ; Set X Flag
negx.b (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
move.b #$7F,(a0)
andi.b #$EF,CCR ; Clear X Flag
negx.b (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
move.b #$F5,(a0)
ori.b #$10,CCR ; Set X Flag
negx.b (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
cmpi.b #$0A,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
andi.b #$EF,CCR ; Clear X Flag
negx.b (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
cmpi.b #$F6,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
; -----
; NEGX - WORD
move.l #$00000100,a0
move.l #$00000000,d0
move.l #$00008000,d1
ori.b #$10,CCR ; Set X Flag
negx.w d0
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 1
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 1
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
andi.b #$EF,CCR ; Clear X Flag
negx.w d0
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 1
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 1
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
ori.b #$10,CCR ; Set X Flag
negx.w d1
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 0
cmpi.w #$7FFF,d1
bne NEGS_FAIL; ; Check Z Flag beq/bne
andi.b #$EF,CCR ; Clear X Flag
negx.w d1
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 0
cmpi.w #$8001,d1
bne NEGS_FAIL; ; Check Z Flag beq/bne
move.w #$7FFF,(a0)
ori.b #$10,CCR ; Set X Flag
negx.w (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
move.w #$F567,(a0)
andi.b #$EF,CCR ; Clear X Flag
negx.w (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
move.w #$F567,(a0)
ori.b #$10,CCR ; Set X Flag
negx.w (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
cmpi.w #$0A98,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
andi.b #$EF,CCR ; Clear X Flag
negx.w (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
cmpi.w #$F568,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
; -----
; NEGX - LONG
move.l #$00000100,a0
move.l #$00000000,d0
move.l #$80000000,d1
ori.b #$10,CCR ; Set X Flag
negx.l d0
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 1
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 1
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
andi.b #$EF,CCR ; Clear X Flag
negx.l d0
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 1
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 1
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
ori.b #$10,CCR ; Set X Flag
negx.l d1
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 0
cmpi.l #$7FFFFFFF,d1
bne NEGS_FAIL; ; Check Z Flag beq/bne
andi.b #$EF,CCR ; Clear X Flag
negx.l d1
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 0
cmpi.l #$80000001,d1
bne NEGS_FAIL; ; Check Z Flag beq/bne
move.l #$7FFF,(a0)
ori.b #$10,CCR ; Set X Flag
negx.l (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
move.l #$F5671234,(a0)
andi.b #$EF,CCR ; Clear X Flag
negx.l (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 1
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
move.l #$F5675678,(a0)
ori.b #$10,CCR ; Set X Flag
negx.l (a0)
bmi NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
cmpi.l #$0A98A987,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
andi.b #$EF,CCR ; Clear X Flag
negx.l (a0)
bpl NEGS_FAIL; ; Check N Flag bmi/bpl 0
beq NEGS_FAIL; ; Check Z Flag beq/bne 0
bcc NEGS_FAIL; ; Check C Flag bcc/bcs 0
bvs NEGS_FAIL; ; Check V Flag bvc/bvs 1
cmpi.l #$F5675679,(a0)
bne NEGS_FAIL; ; Check Z Flag beq/bne
movea #TESTSTATUS,a0
move.b #$1,$1a(a0)
rts
NEGS_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$1a(a0)
rts
; -----
op_CLR:
; CLR - BYTE
move.l #$00000100,a0
move.l #$12345678,d0
move.l #$12345678,d1
move.l #$12345678,d2
move.l #$12345600,d4
move.l #$12340000,d5
move.l #$00000000,d6
clr.b d0
bne CLR_FAIL; ; Check Z Flag beq/bne 0
bmi CLR_FAIL; ; Check N Flag bmi/bpl 0
cmp.l d0,d4
bne CLR_FAIL; ; Check Z Flag beq/bne 0
clr.w d1
bne CLR_FAIL; ; Check Z Flag beq/bne 0
bmi CLR_FAIL; ; Check N Flag bmi/bpl 0
cmp.l d1,d5
bne CLR_FAIL; ; Check Z Flag beq/bne 0
clr.l d2
bne CLR_FAIL; ; Check Z Flag beq/bne 0
bmi CLR_FAIL; ; Check N Flag bmi/bpl 0
cmp.l d2,d6
bne CLR_FAIL; ; Check Z Flag beq/bne 0
movea #TESTSTATUS,a0
move.b #$1,$1b(a0)
rts
CLR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$1b(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : MOVEM
;-----------------------------------------------------------
;-----------------------------------------------------------
op_MOVEM:
; WORD Registers --> Memory
move.l #$0000d0d0,d0
move.l #$0000d1d1,d1
move.l #$0000d2d2,d2
move.l #$0000d3d3,d3
move.l #$0000d4d4,d4
move.l #$0000d5d5,d5
move.l #$0000d6d6,d6
move.l #$0000d7d7,d7
move.l #$00000a0a,a0
move.l #$00001a1a,a1
move.l #$00002a2a,a2
move.l #$00003a3a,a3
move.l #$00004a4a,a4
move.l #$00005a5a,a5
move.l #$00006a6a,a6
;move.l #$00007a7a,a7 ; Dont change the Stack Pointer
movem.w D0-D7/A0-A7,$00000100
move.l #$00000100,a0
cmp.w (a0)+,d0
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,d1
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,d2
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,d3
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,d4
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,d5
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,d6
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,d7
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w #$0A0A,(a0)+ ; Because we are using a0 as a pointer
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,a1
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,a2
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,a3
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,a4
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,a5
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w (a0)+,a6
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
; LONG Registers --> Memory
move.l #$d0d0d0d0,d0
move.l #$d1d1d1d1,d1
move.l #$d2d2d2d2,d2
move.l #$d3d3d3d3,d3
move.l #$d4d4d4d4,d4
move.l #$d5d5d5d5,d5
move.l #$d6d6d6d6,d6
move.l #$d7d7d7d7,d7
move.l #$0a0a0a0a,a0
move.l #$1a1a1a1a,a1
move.l #$2a2a2a2a,a2
move.l #$3a3a3a3a,a3
move.l #$4a4a4a4a,a4
move.l #$5a5a5a5a,a5
move.l #$6a6a6a6a,a6
;move.l #$7a7a7a7a,a7 ; Dont change the Stack Pointer
movem.l D0-D7/A0-A7,$00000120
move.l #$00000120,a0
cmp.l (a0)+,d0
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,d1
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,d2
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,d3
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,d4
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,d5
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,d6
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,d7
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$0A0A0A0A,(a0)+ ; Because we are using a0 as a pointer
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,a1
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,a2
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,a3
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,a4
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,a5
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l (a0)+,a6
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
; ----
; WORD Registers --> Memory -(An) EA Mode
move.l #$0000d0d0,d0
move.l #$0000d1d1,d1
move.l #$0000d2d2,d2
move.l #$0000d3d3,d3
move.l #$0000d4d4,d4
move.l #$0000d5d5,d5
move.l #$0000d6d6,d6
move.l #$0000d7d7,d7
move.l #$00000a0a,a0
move.l #$00001a1a,a1
move.l #$00002a2a,a2
move.l #$00003a3a,a3
move.l #$00004a4a,a4
move.l #$00005a5a,a5
move.l #$00006a6a,a6
;move.l #$00007a7a,a7 ; Dont change the Stack Pointer
move.l #$000001A0,a0
movem.w D0-D7/A0-A7,-(a0)
move.l #$0000019E,a0
cmp.w -(a0),a6
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),a5
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),a4
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),a3
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),a2
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),a1
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),a0
; bne ; ; Check Z Flag beq/bne 0
cmp.w -(a0),d7
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),d6
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),d5
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),d4
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),d3
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),d2
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),d1
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.w -(a0),d0
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
; LONG Registers --> Memory -(An) EA Mode
move.l #$d0d0d0d0,d0
move.l #$d1d1d1d1,d1
move.l #$d2d2d2d2,d2
move.l #$d3d3d3d3,d3
move.l #$d4d4d4d4,d4
move.l #$d5d5d5d5,d5
move.l #$d6d6d6d6,d6
move.l #$d7d7d7d7,d7
move.l #$0a0a0a0a,a0
move.l #$1a1a1a1a,a1
move.l #$2a2a2a2a,a2
move.l #$3a3a3a3a,a3
move.l #$4a4a4a4a,a4
move.l #$5a5a5a5a,a5
move.l #$6a6a6a6a,a6
;move.l #$7a7a7a7a,a7 ; Dont change the Stack Pointer
move.l #$000001A0,a0
movem.l D0-D7/A0-A7,-(a0)
move.l #$0000019C,a0
cmp.l -(a0),a6
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),a5
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),a4
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),a3
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),a2
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),a1
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),a0
; bne ; ; Check Z Flag beq/bne 0
cmp.l -(a0),d7
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),d6
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),d5
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),d4
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),d3
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),d2
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),d1
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l -(a0),d0
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
;----
; WORD - Memory --> Registers
move.l #$00000000,d0
move.l #$00000000,d1
move.l #$00000000,d2
move.l #$00000000,d3
move.l #$00000000,d4
move.l #$00000000,d5
move.l #$00000000,d6
move.l #$00000000,d7
move.l #$00000000,a0
move.l #$00000000,a1
move.l #$00000000,a2
move.l #$00000000,a3
move.l #$00000000,a4
move.l #$00000000,a5
move.l #$00000000,a6
;move.l #$00000000,a7 ; Dont change the Stack Pointer
movem.w $00000100,D0/D2/D4/D6/A1/A3/A5
cmp.l #$FFFFD0D0,d0
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$FFFFD1D1,d2
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$FFFFD2D2,d4
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$FFFFD3D3,d6
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$FFFFD4D4,a1
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$FFFFD5D5,a3
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$FFFFD6D6,a5
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
; LONG - Memory --> Registers
move.l #$00000000,d0
move.l #$00000000,d1
move.l #$00000000,d2
move.l #$00000000,d3
move.l #$00000000,d4
move.l #$00000000,d5
move.l #$00000000,d6
move.l #$00000000,d7
move.l #$00000000,a0
move.l #$00000000,a1
move.l #$00000000,a2
move.l #$00000000,a3
move.l #$00000000,a4
move.l #$00000000,a5
move.l #$00000000,a6
;move.l #$00000000,a7 ; Dont change the Stack Pointer
movem.l $00000120,D0/D2/D4/D6/A1/A3/A5
cmp.l #$D0D0D0D0,d0
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$D1D1D1D1,d2
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$D2D2D2D2,d4
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$D3D3D3D3,d6
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$D4D4D4D4,a1
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$D5D5D5D5,a3
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
cmp.l #$D6D6D6D6,a5
bne MOVEM_FAIL; ; Check Z Flag beq/bne 0
movea #TESTSTATUS,a0
move.b #$1,$1c(a0)
rts
MOVEM_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$1c(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : TRAPV
;-----------------------------------------------------------
;-----------------------------------------------------------
op_TRAPV:
; TRAPV will set d0 to 12345678 if V flag is set
move.l #$00000000,d0 ; Clear d0
move #$00,CCR ; Clear V flag
trapv
cmpi.l #$00000000,d0 ; Check of d0 was updated (should not be_)
bne TRAPV_FAIL;
move #$02,CCR ; Set V flag
trapv
cmpi.l #$12345678,d0 ; Check of d0 was updated (should not be_)
bne TRAPV_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$1d(a0)
rts
TRAPV_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$1d(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : RTR
;-----------------------------------------------------------
;-----------------------------------------------------------
op_RTR:
lea RTR_DONE,a0
move.l a0,-(a7) ; push destination PC to the stack
move.w #$FF15,-(a7) ; push flags=0xFFFF to the stack
rtr
RTR_DONE: move SR,d0
andi #$1F,d0
cmpi #$15,d0
bne RTR_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$1e(a0)
rts
BSR_FAR2: move.l #$44444444,d4
rts
RTR_FAIL:
movea #TESTSTATUS,a0
move.b #$1,$1e(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : BCC
;-----------------------------------------------------------
;-----------------------------------------------------------
op_BCC: move #$00,CCR
bhi.s BCC1 ; Higher Than C=0 AND Z=0
bra BCC_FAIL;
BCC1: move #$01,CCR
bls.w BCC2 ; Lower or Same C=1 OR Z=1
bra BCC_FAIL;
BCC2: move #$00,CCR
bcc.s BCC3 ; Carry Clear C=0
bra BCC_FAIL;
BCC3: move #$01,CCR
bcs.w BCC4 ; Carry Set C=1
bra BCC_FAIL;
BCC4: move #$00,CCR
bne.s BCC5 ; Not Equal Z=0
bra BCC_FAIL;
BCC5: move #$04,CCR
beq.w BCC6 ; Equal Z=1
bra BCC_FAIL;
BCC6: move #$00,CCR
bvc.s BCC7 ; V Clear V=0
bra BCC_FAIL;
BCC7: move #$02,CCR
bvs.w BCC8 ; V Set V=1
bra BCC_FAIL;
BCC8: move #$00,CCR
bpl.s BCC9 ; Plus N=0
bra BCC_FAIL;
BCC9: move #$08,CCR
bmi.w BCC10 ; Minus N=1
bra BCC_FAIL;
BCC10: move #$00,CCR
bge.s BCC11 ; Greater or Equal N=V
bra BCC_FAIL;
BCC11: move #$02,CCR
blt.w BCC12 ; Less Than N!=V
bra BCC_FAIL;
BCC12: move #$0A,CCR
bgt.s BCC13 ; Greater Than N=V AND Z=0
bra BCC_FAIL;
BCC13: move #$06,CCR
ble.w BCC14 ; Less Than or Equal N!=V AND Z=1
bra BCC_FAIL;
BCC14: movea #TESTSTATUS,a0
move.b #$1,$1f(a0)
rts
BCC_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$1f(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : DBCC
;-----------------------------------------------------------
;-----------------------------------------------------------
op_DBCC: move.l #$00000003,d0 ; Loop counter
move.l #$00000000,d1 ; Accumulator
move #$00,CCR
DBCC_LOOP1: addi.b #$1,d1
dbf d0,DBCC_LOOP1
cmpi.l #$00000004,d1 ; Check Accumulator results
bne DBCC_FAIL;
DBCC_LOOP2: addi.b #$1,d1
dbcc d0,DBCC_LOOP2 ; Dont loop
cmpi.l #$00000005,d1 ; Check Accumulator results
bne DBCC_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$20(a0)
rts
DBCC_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$20(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : SCC
;-----------------------------------------------------------
;-----------------------------------------------------------
op_SCC: move #$01,CCR
scc $00010000 ; Clear the EA byte
cmpi.b #$00,$00010000
bne SCC_FAIL;
move #$00,CCR
scc $00010000 ; Set the EA byte to 0xFF
cmpi.b #$FF,$00010000
bne SCC_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$21(a0)
rts
SCC_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$21(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ADDQ
;-----------------------------------------------------------
;-----------------------------------------------------------
op_ADDQ:
; BYTE
move.l #$000000FF,d0 ; Loop counter
move.l #$00000000,d1 ; Flag results accumulator
move.l #$00000000,d2 ; Data results accumulator
move.l #$00000000,d3
move.l #$00000000,d4
move.l #$00000000,d5
move.l #$00000000,d6
move.l #$00000000,d7
ADDQ_LOOP1: addq.b #3,d5
move SR,d6
andi.l #$1F,d6 ; Isolate flags
add.l d6,d1 ; Copy flag results into accumulator
add.l d5,d2 ; Copy data results into data accumulator
dbf d0,ADDQ_LOOP1
cmpi.l #$0000043D,d1
bne ADDQ_FAIL;
cmpi.l #$00007F80,d2
bne ADDQ_FAIL;
; WORD
move.l #$000000FF,d0 ; Loop counter
move.l #$00000000,d1 ; Flag results accumulator
move.l #$00000000,d2 ; Data results accumulator
move.l #$00000000,d3
move.l #$00000000,d4
move.l #$0000FFF0,d5
move.l #$00000000,d6
move.l #$00000000,d7
move.l #$00000100,a0
ADDQ_LOOP2: addq.w #5,d5
move SR,d6
andi.l #$1F,d6 ; Isolate flags
add.l d6,d1 ; Copy flag results into accumulator
add.l d5,d2 ; Copy data results into data accumulator
dbf d0,ADDQ_LOOP2
cmpi.l #$00000029,d1
bne ADDQ_FAIL;
cmpi.l #$00057280,d2
bne ADDQ_FAIL;
; LONG
move.l #$000000FF,d0 ; Loop counter
move.l #$00000000,d1 ; Flag results accumulator
move.l #$00000000,d2 ; Data results accumulator
move.l #$00000000,d3
move.l #$00000000,d4
move.l #$FFFFFFF0,d5
move.l #$00000000,d6
move.l #$00000000,d7
ADDQ_LOOP3: addq.l #1,d5
move SR,d6
andi.l #$1F,d6 ; Isolate flags
add.l d6,d1 ; Copy flag results into accumulator
add.l d5,d2 ; Copy data results into data accumulator
dbf d0,ADDQ_LOOP3
cmpi.l #$0000008D,d1
bne ADDQ_FAIL;
cmpi.l #$00007080,d2
bne ADDQ_FAIL;
; Check that Flags are not updated for Address registers
move.l #$0000FFFF,a0
move #$00,CCR ; Clear flags
addq.w #$7,a0
bcs ADDQ_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$22(a0)
rts
ADDQ_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$22(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : SUBQ
;-----------------------------------------------------------
;-----------------------------------------------------------
op_SUBQ:
; BYTE
move.l #$000000FF,d0 ; Loop counter
move.l #$00000000,d1 ; Flag results accumulator
move.l #$00001234,d2 ; Data results accumulator
move.l #$00000000,d3
move.l #$00000000,d4
move.l #$00000012,d5
move.l #$00000000,d6
move.l #$00000000,d7
SUBQ_LOOP1: subq.b #1,d5
move SR,d6
andi.l #$1F,d6 ; Isolate flags
add.l d6,d1 ; Copy flag results into accumulator
add.l d5,d2 ; Copy data results into data accumulator
dbf d0,SUBQ_LOOP1
cmpi.l #$00000417,d1
bne SUBQ_FAIL;
cmpi.l #$000091B4,d2
bne SUBQ_FAIL;
; WORD
move.l #$000000FF,d0 ; Loop counter
move.l #$00000000,d1 ; Flag results accumulator
move.l #$00000000,d2 ; Data results accumulator
move.l #$00000000,d3
move.l #$00000000,d4
move.l #$00000002,d5
move.l #$00000000,d6
move.l #$00000000,d7
move.l #$00000100,a0
SUBQ_LOOP2: subq.w #5,d5
move SR,d6
andi.l #$1F,d6 ; Isolate flags
add.l d6,d1 ; Copy flag results into accumulator
add.l d5,d2 ; Copy data results into data accumulator
dbf d0,SUBQ_LOOP2
cmpi.l #$00000811,d1
bne SUBQ_FAIL;
cmpi.l #$00FD7F80,d2
bne SUBQ_FAIL;
; LONG
move.l #$000000FF,d0 ; Loop counter
move.l #$00000000,d1 ; Flag results accumulator
move.l #$00000000,d2 ; Data results accumulator
move.l #$00000000,d3
move.l #$00000000,d4
move.l #$00000007,d5
move.l #$00000000,d6
move.l #$00000000,d7
SUBQ_LOOP3: subq.l #1,d5
move SR,d6
andi.l #$1F,d6 ; Isolate flags
add.l d6,d1 ; Copy flag results into accumulator
add.l d5,d2 ; Copy data results into data accumulator
dbf d0,SUBQ_LOOP3
cmpi.l #$000007DD,d1
bne SUBQ_FAIL;
cmpi.l #$FFFF8680,d2
bne SUBQ_FAIL;
; Check that Flags are not updated for Address registers
move.l #$0001FFFF,a0
move #$00,CCR ; Clear flags
subq.w #$7,a0
bcs SUBQ_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$23(a0)
rts
SUBQ_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$23(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : MOVEQ
;-----------------------------------------------------------
;-----------------------------------------------------------
op_MOVEQ:
move.l #$00000000,d0
moveq #$0,d0
bne MOVEQ_FAIL;
cmpi.l #$00000000,d0
bne MOVEQ_FAIL;
move.l #$00000000,d0
moveq #$80,d0
beq MOVEQ_FAIL;
bpl MOVEQ_FAIL;
cmpi.l #$FFFFFF80,d0
bne MOVEQ_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$24(a0)
rts
MOVEQ_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$24(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : DIVU
;-----------------------------------------------------------
;-----------------------------------------------------------
op_DIVU:
move.l #$a5a5a5a5,d0 ; Initial Numerator
move.l #$00005a5a,d1 ; Initial Divisor
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000000E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
DIVU_OUTER1: divu d1,d0
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
lsr.l #$1,d1
dbf d6,DIVU_OUTER1
lsr.l #$1,d2
move.l d2,d0
move.l #$00005a5a,d1 ; Initial Divisor
move.l #$0000000E,d6 ; Inner loop counter
dbf d7,DIVU_OUTER1
cmpi.l #$92FEDB89,d4 ; Check the data results
bne DIVU_FAIL;
cmpi.l #$00000110,d5 ; Check the Flag results
bne DIVU_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$25(a0)
rts
DIVU_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$25(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : DIVS
;-----------------------------------------------------------
;-----------------------------------------------------------
op_DIVS:
move.l #$a5a5a5a5,d0 ; Initial Numerator
move.l #$00005a5a,d1 ; Initial Divisor
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000000E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
DIVS_OUTER1: divs d1,d0
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
lsr.l #$1,d1
dbf d6,DIVS_OUTER1
lsr.l #$1,d2
move.l d2,d0
move.l #$00005a5a,d1 ; Initial Divisor
move.l #$0000000E,d6 ; Inner loop counter
dbf d7,DIVS_OUTER1
cmpi.l #$4EC5D057,d4 ; Check the data results
bne DIVS_FAIL;
cmpi.l #$00000038,d5 ; Check the Flag results
bne DIVS_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$26(a0)
rts
DIVS_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$26(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : OR
;-----------------------------------------------------------
;-----------------------------------------------------------
op_OR:
;; <EA> to Register
move.l #$a5a5a5a5,d0 ; Initial Data-X Inner loop
move.l #$8167E123,d1 ; Initial Data-Y Outer loop
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
OR_OUTER1:
; BYTE
move.l d1,(a0)
or.b (a0),d0
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; WORD
move.l d1,(a0)
or.w (a0),d0
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; LONG
move.l d1,(a0)
or.l (a0),d0
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
lsr.l #$1,d1
dbf d6,OR_OUTER1
lsr.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,OR_OUTER1
cmpi.l #$76EAC803,d4 ; Check the data results
bne OR_FAIL;
cmpi.l #$00005A18,d5 ; Check the Flag results
bne OR_FAIL;
;; Register to <EA>
move.l #$86738374,d0 ; Initial Data-X Inner loop
move.l #$FC55F2FE,d1 ; Initial Data-Y Outer loop
move.l #$86738374,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001D,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
OR_OUTER2:
; BYTE
move.l d0,(a0)
or.b d1,(a0)
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
; WORD
move.l d0,(a0)
or.w d1,(a0)
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
; LONG
move.l d0,(a0)
or.l d1,(a0)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
lsr.l #$1,d1
dbf d6,OR_OUTER2
lsr.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,OR_OUTER2
cmpi.l #$FA82B9E4,d4 ; Check the data results
bne OR_FAIL;
cmpi.l #$00005730,d5 ; Check the Flag results
bne OR_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$27(a0)
rts
OR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$27(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : AND
;-----------------------------------------------------------
;-----------------------------------------------------------
op_AND:
;; <EA> to Register
move.l #$a5a5a5a5,d0 ; Initial Data-X Inner loop
move.l #$8167E123,d1 ; Initial Data-Y Outer loop
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
AND_OUTER1:
; BYTE
move.l d1,(a0)
and.b (a0),d0
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; WORD
move.l d1,(a0)
and.w (a0),d0
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; LONG
move.l d1,(a0)
and.l (a0),d0
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
lsr.l #$1,d1
dbf d6,AND_OUTER1
lsr.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,AND_OUTER1
cmpi.l #$CF212883,d4 ; Check the data results
bne AND_FAIL;
cmpi.l #$00002D10,d5 ; Check the Flag results
bne AND_FAIL;
;; Register to <EA>
move.l #$86738374,d0 ; Initial Data-X Inner loop
move.l #$FC55F2FE,d1 ; Initial Data-Y Outer loop
move.l #$86738374,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001D,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
AND_OUTER2:
; BYTE
move.l d0,(a0)
and.b d1,(a0)
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
; WORD
move.l d0,(a0)
and.w d1,(a0)
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
; LONG
move.l d0,(a0)
and.l d1,(a0)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
lsr.l #$1,d1
dbf d6,AND_OUTER2
lsr.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,AND_OUTER2
cmpi.l #$4A3DE544,d4 ; Check the data results
bne AND_FAIL;
cmpi.l #$000018E8,d5 ; Check the Flag results
bne AND_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$28(a0)
rts
AND_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$28(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : EOR
;-----------------------------------------------------------
;-----------------------------------------------------------
op_EOR:
;; Register to <EA>
move.l #$86738374,d0 ; Initial Data-X Inner loop
move.l #$FC55F2FE,d1 ; Initial Data-Y Outer loop
move.l #$86738374,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001D,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
EOR_OUTER2:
; BYTE
move.l d0,(a0)
eor.b d1,(a0)
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
; WORD
move.l d0,(a0)
eor.w d1,(a0)
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
; LONG
move.l d0,(a0)
eor.l d1,(a0)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
lsr.l #$1,d1
dbf d6,EOR_OUTER2
lsr.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,EOR_OUTER2
cmpi.l #$55C5EB70,d4 ; Check the data results
bne EOR_FAIL;
cmpi.l #$00004430,d5 ; Check the Flag results
bne EOR_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$29(a0)
rts
EOR_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$29(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : CMP
;-----------------------------------------------------------
;-----------------------------------------------------------
op_CMP:
;; <EA> to Register
move.l #$a5a5a5a5,d0 ; Initial Data-X Inner loop
move.l #$8167E123,d1 ; Initial Data-Y Outer loop
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
CMP_OUTER1:
; BYTE
move.l d1,(a0)
cmp.b (a0),d0
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; WORD
move.l d1,(a0)
cmp.w (a0),d0
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; LONG
move.l d1,(a0)
cmp.l (a0),d0
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
lsr.l #$1,d1
dbf d6,CMP_OUTER1
lsr.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,CMP_OUTER1
cmpi.l #$7878712F,d4 ; Check the data results
bne CMP_FAIL;
cmpi.l #$00005502,d5 ; Check the Flag results
bne CMP_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$2a(a0)
rts
CMP_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$2a(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : CMPA
;-----------------------------------------------------------
;-----------------------------------------------------------
op_CMPA:
;; <EA> to Register
move.l #$a5a5a5a5,a0 ; Initial Data-X Inner loop
move.l #$8167E123,d1 ; Initial Data-Y Outer loop
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
move.l #$00000100,a1 ; Address for memory EA operations
CMPA_OUTER1:
; WORD
move.l d1,(a1)
cmpa.w (a1),a0
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l a0,d4 ; Copy data results into data accumulator
; LONG
move.l d1,(a1)
cmpa.l (a1),a0
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l a0,d4 ; Copy data results into data accumulator
lsr.l #$1,d1
dbf d6,CMPA_OUTER1
lsr.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,CMPA_OUTER1
cmpi.l #$a5a5a0ca,d4 ; Check the data results
bne CMPA_FAIL;
cmpi.l #$00003A7D,d5 ; Check the Flag results
bne CMPA_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$2b(a0)
rts
CMPA_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$2b(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : CMPM
;-----------------------------------------------------------
;-----------------------------------------------------------
op_CMPM:
move.l #$00000100,a0 ; Address for Data-X
move.l #$00000200,a1 ; Address for Data-Y
move.l #$00000000,d0
move.l #$00000000,d1
move.l #$00000000,d2
move.l #$11FF5580,(a0)+ ; Populate test data
move.l #$1111FFFF,(a0)+ ; Populate test data
move.l #$33333333,(a0)+ ; Populate test data
move.l #$44444444,(a0)+ ; Populate test data
move.l #$80FF337F,(a1)+ ; Populate test data
move.l #$FFFF1111,(a1)+ ; Populate test data
move.l #$33333333,(a1)+ ; Populate test data
move.l #$44444444,(a1)+ ; Populate test data
move.l #$00000100,a0 ; Address for Data-X
move.l #$00000200,a1 ; Address for Data-Y
move.l #$0000000F,d6 ; Loop counter
CMPM_LOOP1: cmpm.b (a0)+,(a1)+
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d0 ; Copy flag results into accumulator
dbf d6,CMPM_LOOP1
move.l #$00000100,a0 ; Address for Data-X
move.l #$00000200,a1 ; Address for Data-Y
move.l #$00000007,d6 ; Loop counter
CMPM_LOOP2: cmpm.w (a0)+,(a1)+
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d1 ; Copy flag results into accumulator
dbf d6,CMPM_LOOP2
move.l #$00000100,a0 ; Address for Data-X
move.l #$00000200,a1 ; Address for Data-Y
move.l #$00000003,d6 ; Loop counter
CMPM_LOOP3: cmpm.l (a0)+,(a1)+
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d2 ; Copy flag results into accumulator
dbf d6,CMPM_LOOP3
cmpi.l #$0000004C,d0 ; Check the data results
bne CMPM_FAIL;
cmpi.l #$00000024,d1
bne CMPM_FAIL;
cmpi.l #$00000012,d2
bne CMPM_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$2c(a0)
rts
CMPM_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$2c(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ADD
;-----------------------------------------------------------
;-----------------------------------------------------------
op_ADD:
;; <EA> to Register
move.l #$a5a5a5a5,d0 ; Initial Data-X Inner loop
move.l #$8167E123,d1 ; Initial Data-Y Outer loop
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
ADD_OUTER1:
; BYTE
move.l d1,(a0)
add.b (a0),d0
move SR,d3
andi.l #$1F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; WORD
move.l d1,(a0)
add.w (a0),d0
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; LONG
move.l d1,(a0)
add.l (a0),d0
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
ror.l #$1,d1
dbf d6,ADD_OUTER1
ror.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,ADD_OUTER1
cmpi.l #$23ED428F,d4 ; Check the data results
bne ADD_FAIL;
cmpi.l #$00004C96,d5 ; Check the Flag results
bne ADD_FAIL;
;; Register to <EA>
move.l #$86738374,d0 ; Initial Data-X Inner loop
move.l #$FC55F2FE,d1 ; Initial Data-Y Outer loop
move.l #$86738374,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001D,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
ADD_OUTER2:
; BYTE
move.l d0,(a0)
add.b d1,(a0)
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
; WORD
move.l d0,(a0)
add.w d1,(a0)
move SR,d3
andi.l #$1F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
; LONG
move.l d0,(a0)
add.l d1,(a0)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
ror.l #$1,d1
dbf d6,ADD_OUTER2
ror.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,ADD_OUTER2
cmpi.l #$6701B884,d4 ; Check the data results
bne ADD_FAIL;
cmpi.l #$00005467,d5 ; Check the Flag results
bne ADD_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$2d(a0)
rts
ADD_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$2d(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : SUB
;-----------------------------------------------------------
;-----------------------------------------------------------
op_SUB:
;; <EA> to Register
move.l #$a5a5a5a5,d0 ; Initial Data-X Inner loop
move.l #$8167E123,d1 ; Initial Data-Y Outer loop
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
SUB_OUTER1:
; BYTE
move.l d1,(a0)
sub.b (a0),d0
move SR,d3
andi.l #$1F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; WORD
move.l d1,(a0)
sub.w (a0),d0
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; LONG
move.l d1,(a0)
sub.l (a0),d0
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
ror.l #$1,d1
dbf d6,SUB_OUTER1
ror.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,SUB_OUTER1
cmpi.l #$1A8D14CF,d4 ; Check the data results
bne SUB_FAIL;
cmpi.l #$00004FC4,d5 ; Check the Flag results
bne SUB_FAIL;
;; Register to <EA>
move.l #$86738374,d0 ; Initial Data-X Inner loop
move.l #$FC55F2FE,d1 ; Initial Data-Y Outer loop
move.l #$86738374,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001D,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
SUB_OUTER2:
; BYTE
move.l d0,(a0)
sub.b d1,(a0)
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
; WORD
move.l d0,(a0)
sub.w d1,(a0)
move SR,d3
andi.l #$1F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
; LONG
move.l d0,(a0)
sub.l d1,(a0)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l (a0),d4 ; Copy data results into data accumulator
ror.l #$1,d1
dbf d6,SUB_OUTER2
ror.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,SUB_OUTER2
cmpi.l #$36D38BEC,d4 ; Check the data results
bne SUB_FAIL;
cmpi.l #$000045A5,d5 ; Check the Flag results
bne SUB_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$2e(a0)
rts
SUB_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$2e(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ADDA
;-----------------------------------------------------------
;-----------------------------------------------------------
op_ADDA:
;; <EA> to Register
move.l #$a5a5a5a5,d0 ; Initial Data-X Inner loop
move.l #$8167E123,d1
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
move.l #$8167E123,a1 ; Initial Data-Y Outer loop
ADDA_OUTER1:
; WORD
move.l d1,(a0)
adda.w (a0),a1
add.l a1,d4 ; Copy data results into data accumulator
; LONG
move.l d1,(a0)
adda.l (a0),a1
add.l a1,d4 ; Copy data results into data accumulator
ror.l #$1,d1
dbf d6,ADDA_OUTER1
ror.l #$1,d1
move.l d1,a1
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,ADDA_OUTER1
cmpi.l #$abe3cab5,d4 ; Check the data results
bne ADDA_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$2f(a0)
rts
ADDA_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$2f(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : SUBA
;-----------------------------------------------------------
;-----------------------------------------------------------
op_SUBA:
;; <EA> to Register
move.l #$a5a5a5a5,d0 ; Initial Data-X Inner loop
move.l #$8167E123,d1
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
move.l #$8167E123,a1 ; Initial Data-Y Outer loop
SUBA_OUTER1:
; WORD
move.l d1,(a0)
suba.w (a0),a1
add.l a1,d4 ; Copy data results into data accumulator
; LONG
move.l d1,(a0)
suba.l (a0),a1
add.l a1,d4 ; Copy data results into data accumulator
ror.l #$1,d1
dbf d6,SUBA_OUTER1
ror.l #$1,d1
move.l d1,a1
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,SUBA_OUTER1
cmpi.l #$6fecc6d7,d4 ; Check the data results
bne SUBA_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$30(a0)
rts
SUBA_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$30(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ADDX
;-----------------------------------------------------------
;-----------------------------------------------------------
op_ADDX:
;; Register to Register
move.l #$a5a5a5a5,d0 ; Initial Data-X Inner loop
move.l #$8167E123,d1 ; Initial Data-Y Outer loop
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
move #$2700,sr ; Reset flags
ADDX_OUTER1:
; BYTE
move.l d2,d0
addx.b d1,d0
move SR,d3
andi.l #$1F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; WORD
move.l d2,d0
addx.w d1,d0
move SR,d3
andi.l #$1F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; LONG
move.l d2,d0
addx.l d1,d0
move SR,d3
andi.l #$1F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
ror.l #$1,d1
dbf d6,ADDX_OUTER1
ror.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,ADDX_OUTER1
cmpi.l #$4E96A4D9,d4 ; Check the data results
bne ADDX_FAIL;
cmpi.l #$000085CD,d5 ; Check the Flag results
bne ADDX_FAIL;
; -(An),-(An)
move.l #$00000000,d0 ; BYTE Flag Results Accumulator
move.l #$00000000,d1
move.l #$00000000,d2
move.l #$00000100,a0 ; Address for Data-X
move.l #$00000200,a1 ; Address for Data-Y
move.l #$11FF5580,(a0)+ ; Populate test data
move.l #$1111FFFF,(a0)+ ; Populate test data
move.l #$33333333,(a0)+ ; Populate test data
move.l #$44444444,(a0)+ ; Populate test data
move.l #$80FF337F,(a1)+ ; Populate test data
move.l #$FFFF1111,(a1)+ ; Populate test data
move.l #$33333333,(a1)+ ; Populate test data
move.l #$44444444,(a1)+ ; Populate test data
move.l #$0000000F,d6 ; Loop counter
ADDX_LOOP3: addx.b -(a0),-(a1)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d0 ; Copy flag results into accumulator
add.b (a1),d1
dbf d6,ADDX_LOOP3
move.l #$00000110,a0 ; Address for Data-X
move.l #$00000210,a1 ; Address for Data-Y
move.l #$00000007,d6 ; Loop counter
ADDX_LOOP4: addx.w -(a0),-(a1)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d0 ; Copy flag results into accumulator
add.w (a1),d1
dbf d6,ADDX_LOOP4
move.l #$00000110,a0 ; Address for Data-X
move.l #$00000210,a1 ; Address for Data-Y
move.l #$00000003,d6 ; Loop counter
ADDX_LOOP5: addx.l -(a0),-(a1)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d0 ; Copy flag results into accumulator
add.l (a1),d1
dbf d6,ADDX_LOOP5
cmpi.l #$00000095,d0 ; Check the flag results
bne ADDX_FAIL;
cmpi.l #$C812A682,d1 ; Check the data results
bne ADDX_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$31(a0)
rts
ADDX_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$31(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : SUBX
;-----------------------------------------------------------
;-----------------------------------------------------------
op_SUBX:
;; Register to Register
move.l #$a5a5a5a5,d0 ; Initial Data-X Inner loop
move.l #$8167E123,d1 ; Initial Data-Y Outer loop
move.l #$a5a5a5a5,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000001E,d6 ; Inner loop counter
move.l #$0000001E,d7 ; Outer loop counter
move.l #$00000100,a0 ; Address for memory EA operations
move #$2700,sr ; Reset flags
SUBX_OUTER1:
; BYTE
move.l d2,d0
subx.b d1,d0
move SR,d3
andi.l #$1F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; WORD
move.l d2,d0
subx.w d1,d0
move SR,d3
andi.l #$1F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
; LONG
move.l d2,d0
subx.l d1,d0
move SR,d3
andi.l #$1F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
ror.l #$1,d1
dbf d6,SUBX_OUTER1
ror.l #$1,d2
move.l #$8167E123,d1 ; Initial Data-Y
move.l #$0000001E,d6 ; Inner loop counter
dbf d7,SUBX_OUTER1
cmpi.l #$FCAA913E,d4 ; Check the data results
bne SUBX_FAIL;
cmpi.l #$00007E89,d5 ; Check the Flag results
bne SUBX_FAIL;
; -(An),-(An)
move.l #$00000000,d0 ; BYTE Flag Results Accumulator
move.l #$00000000,d1
move.l #$00000000,d2
move.l #$00000100,a0 ; Address for Data-X
move.l #$00000200,a1 ; Address for Data-Y
move.l #$11FF5580,(a0)+ ; Populate test data
move.l #$1111FFFF,(a0)+ ; Populate test data
move.l #$80FF337F,(a0)+ ; Populate test data
move.l #$44444444,(a0)+ ; Populate test data
move.l #$80FF337F,(a1)+ ; Populate test data
move.l #$1111FFFF,(a1)+ ; Populate test data
move.l #$33333333,(a1)+ ; Populate test data
move.l #$5580EECC,(a1)+ ; Populate test data
move.l #$0000000F,d6 ; Loop counter
SUBX_LOOP3: subx.b -(a0),-(a1)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d0 ; Copy flag results into accumulator
add.b (a1),d1
dbf d6,SUBX_LOOP3
move.l #$00000110,a0 ; Address for Data-X
move.l #$00000210,a1 ; Address for Data-Y
move.l #$00000007,d6 ; Loop counter
SUBX_LOOP4: subx.w -(a0),-(a1)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d0 ; Copy flag results into accumulator
add.w (a1),d1
dbf d6,SUBX_LOOP4
move.l #$00000110,a0 ; Address for Data-X
move.l #$00000210,a1 ; Address for Data-Y
move.l #$00000003,d6 ; Loop counter
SUBX_LOOP5: subx.l -(a0),-(a1)
move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d0 ; Copy flag results into accumulator
add.l (a1),d1
dbf d6,SUBX_LOOP5
cmpi.l #$000000B1,d0 ; Check the flag results
bne SUBX_FAIL;
cmpi.l #$62C6F417,d1 ; Check the data results
bne SUBX_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$32(a0)
rts
SUBX_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$32(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : MULU
;-----------------------------------------------------------
;-----------------------------------------------------------
op_MULU:
move.l #$FE805501,d0 ; Initial
move.l #$5697EDB6,d1 ; Initial Y
move.l #$FE805501,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000000E,d6 ; Inner loop counter
move.l #$0000000E,d7 ; Outer loop counter
MULU_OUTER1: mulu d1,d0
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
ror.l #$1,d1
dbf d6,MULU_OUTER1
ror.l #$1,d2
move.l d2,d0
move.l #$0000000E,d6 ; Inner loop counter
dbf d7,MULU_OUTER1
cmpi.l #$76FB988C,d4 ; Check the data results
bne MULU_FAIL;
cmpi.l #$00000170,d5 ; Check the Flag results
bne MULU_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$33(a0)
rts
MULU_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$33(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : MULS
;-----------------------------------------------------------
;-----------------------------------------------------------
op_MULS:
move.l #$FE805501,d0 ; Initial
move.l #$5697EDB6,d1 ; Initial Y
move.l #$FE805501,d2
move.l #$00000000,d3
move.l #$00000000,d4 ; Cumulative data results
move.l #$00000000,d5 ; Cumulative flag results
move.l #$0000000E,d6 ; Inner loop counter
move.l #$0000000E,d7 ; Outer loop counter
MULS_OUTER1: muls d1,d0
move SR,d3
andi.l #$0C,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
add.l d0,d4 ; Copy data results into data accumulator
ror.l #$1,d1
dbf d6,MULS_OUTER1
ror.l #$1,d2
move.l d2,d0
move.l #$0000000E,d6 ; Inner loop counter
dbf d7,MULS_OUTER1
cmpi.l #$D4E2988C,d4 ; Check the data results
bne MULS_FAIL;
cmpi.l #$000003E0,d5 ; Check the Flag results
bne MULS_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$34(a0)
rts
MULS_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$34(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : EXG
;-----------------------------------------------------------
;-----------------------------------------------------------
op_EXG:
move.l #$d1d1d1d1,d1
move.l #$d2d2d2d2,d2
move.l #$d3d3d3d3,d3
move.l #$a1a1a1a1,a1
move.l #$a2a2a2a2,a2
move.l #$a3a3a3a3,a3
exg d1,d2
exg a1,a2
exg d3,a3
cmpi.l #$d2d2d2d2,d1 ; Check the results
bne EXG_FAIL;
cmpi.l #$d1d1d1d1,d2
bne EXG_FAIL;
cmpi.l #$a3a3a3a3,d3
bne EXG_FAIL;
move.l a1,d1
move.l a2,d2
move.l a3,d3
cmpi.l #$a2a2a2a2,d1
bne EXG_FAIL;
cmpi.l #$a1a1a1a1,d2
bne EXG_FAIL;
cmpi.l #$d3d3d3d3,d3
bne EXG_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$35(a0)
rts
EXG_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$35(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ROx
;-----------------------------------------------------------
;-----------------------------------------------------------
; Subroutine to check and accumulate the flags
ROx_FLAGS: move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
rts
op_ROx:
; Shift a Register LEFT and RIGHT with shift_count ## IN A REGISTER ##
; BYTE LEFT
move.l #$80018FF1,d0
move.l #$00000000,d5
move.l #$00000011,d6
ROx_LOOP1:
rol.b d6,d0
jsr ROx_FLAGS
dbf d6,ROx_LOOP1
cmpi.l #$80018FE3,d0
bne ROX_FAIL;
cmpi.l #$0000006B,d5
bne ROX_FAIL;
; BYTE RIGHT
move.l #$80018FF1,d0
move.l #$00000012,d6
ROx_LOOP2:
ror.b d6,d0
jsr ROx_FLAGS
dbf d6,ROx_LOOP2
cmpi.l #$80018F3E,d0
bne ROX_FAIL;
cmpi.l #$000000C5,d5
bne ROX_FAIL;
; WORD LEFT
move.l #$80018FF1,d0
move.l #$00000013,d6
ROx_LOOP3:
rol.w d6,d0
jsr ROx_FLAGS
dbf d6,ROx_LOOP3
cmpi.l #$800163FC,d0
bne ROX_FAIL;
cmpi.l #$00000131,d5
bne ROX_FAIL;
; WORD RIGHT
move.l #$80018FF1,d0
move.l #$0000001E,d6
ROx_LOOP4:
ror.w d6,d0
jsr ROx_FLAGS
dbf d6,ROx_LOOP4
cmpi.l #$8001C7F8,d0
bne ROX_FAIL;
cmpi.l #$000001DB,d5
bne ROX_FAIL;
; LONG LEFT
move.l #$80018FF1,d0
move.l #$00000015,d6
ROx_LOOP5:
rol.l d6,d0
jsr ROx_FLAGS
dbf d6,ROx_LOOP5
cmpi.l #$00C7F8C0,d0
bne ROX_FAIL;
cmpi.l #$0000021A,d5
bne ROX_FAIL;
; LONG RIGHT
move.l #$80018FF1,d0
move.l #$00000016,d6
ROx_LOOP6:
ror.l d6,d0
jsr ROx_FLAGS
dbf d6,ROx_LOOP6
cmpi.l #$000C7F8C,d0
bne ROX_FAIL;
cmpi.l #$00000250,d5
bne ROX_FAIL;
; Shift a Register LEFT and RIGHT with shift_count ## IN THE OPCODE ##
move.l #$80018FF1,d0
move.l #$00000000,d5
; BYTE LEFT
rol.b #1,d0
jsr ROx_FLAGS
rol.b #5,d0
jsr ROx_FLAGS
rol.b #7,d0
jsr ROx_FLAGS
rol.b #8,d0
jsr ROx_FLAGS
cmpi.l #$80018F3E,d0
bne ROX_FAIL;
cmpi.l #$00000009,d5
bne ROX_FAIL;
; BYTE RIGHT
ror.b #1,d0
jsr ROx_FLAGS
ror.b #5,d0
jsr ROx_FLAGS
ror.b #7,d0
jsr ROx_FLAGS
ror.b #8,d0
jsr ROx_FLAGS
cmpi.l #$80018FF1,d0
bne ROX_FAIL;
cmpi.l #$00000024,d5
bne ROX_FAIL;
; WORD LEFT
rol.w #1,d0
jsr ROx_FLAGS
rol.w #5,d0
jsr ROx_FLAGS
rol.w #7,d0
jsr ROx_FLAGS
rol.w #8,d0
jsr ROx_FLAGS
cmpi.l #$8001FE31,d0
bne ROX_FAIL;
cmpi.l #$00000037,d5
bne ROX_FAIL;
; WORD RIGHT
ror.w #1,d0
jsr ROx_FLAGS
ror.w #5,d0
jsr ROx_FLAGS
ror.w #7,d0
jsr ROx_FLAGS
ror.w #8,d0
jsr ROx_FLAGS
cmpi.l #$80018FF1,d0
bne ROX_FAIL;
cmpi.l #$0000005B,d5
bne ROX_FAIL;
; LONG LEFT
rol.l #1,d0
jsr ROx_FLAGS
rol.l #5,d0
jsr ROx_FLAGS
rol.l #7,d0
jsr ROx_FLAGS
rol.l #8,d0
jsr ROx_FLAGS
cmpi.l #$FE300031,d0
bne ROX_FAIL;
cmpi.l #$00000065,d5
bne ROX_FAIL;
; LONG RIGHT
ror.l #1,d0
jsr ROx_FLAGS
ror.l #5,d0
jsr ROx_FLAGS
ror.l #7,d0
jsr ROx_FLAGS
ror.l #8,d0
jsr ROx_FLAGS
cmpi.l #$80018FF1,d0
bne ROX_FAIL;
cmpi.l #$00000080,d5
bne ROX_FAIL;
; Shift a Memory location LEFT and RIGHT with shift_count of 1 - WORD only
move.l #$00000000,d5
move.l #$00000100,a0
move.w #$8FF1,(a0)
; WORD LEFT
rol (a0)
jsr ROx_FLAGS
rol (a0)
jsr ROx_FLAGS
rol (a0)
jsr ROx_FLAGS
rol (a0)
jsr ROx_FLAGS
move.w (a0),d0
cmpi.l #$8001FF18,d0
bne ROX_FAIL;
cmpi.l #$00000009,d5
bne ROX_FAIL;
; WORD RIGHT
ror (a0)
jsr ROx_FLAGS
ror (a0)
jsr ROx_FLAGS
ror (a0)
jsr ROx_FLAGS
ror (a0)
jsr ROx_FLAGS
ror (a0)
jsr ROx_FLAGS
ror (a0)
jsr ROx_FLAGS
move.w (a0),d0
cmpi.l #$800163FC,d0
bne ROX_FAIL;
cmpi.l #$0000001B,d5
bne ROX_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$36(a0)
rts
ROX_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$36(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ROXx
;-----------------------------------------------------------
;-----------------------------------------------------------
; Subroutine to check and accumulate the flags
ROXx_FLAGS: move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
rts
op_ROXx:
; Shift a Register LEFT and RIGHT with shift_count ## IN A REGISTER ##
; BYTE LEFT
move.l #$80018FF1,d0
move.l #$00000000,d5
move.l #$00000011,d6
ROXx_LOOP1:
roxl.b d6,d0
jsr ROXx_FLAGS
dbf d6,ROXx_LOOP1
cmpi.l #$80018FD0,d0
bne ROXX_FAIL;
cmpi.l #$00000042,d5
bne ROXX_FAIL;
; BYTE RIGHT
move.l #$80018FF1,d0
move.l #$00000012,d6
ROXx_LOOP2:
roxr.b d6,d0
jsr ROXx_FLAGS
dbf d6,ROXx_LOOP2
cmpi.l #$80018F51,d0
bne ROXX_FAIL;
cmpi.l #$0000009C,d5
bne ROXX_FAIL;
; WORD LEFT
move.l #$80018FF1,d0
move.l #$00000013,d6
ROXx_LOOP3:
roxl.w d6,d0
jsr ROXx_FLAGS
dbf d6,ROXx_LOOP3
cmpi.l #$80013980,d0
bne ROXX_FAIL;
cmpi.l #$000000C9,d5
bne ROXX_FAIL;
; WORD RIGHT
move.l #$80018FF1,d0
move.l #$0000001E,d6
ROXx_LOOP4:
roxr.w d6,d0
jsr ROXx_FLAGS
dbf d6,ROXx_LOOP4
cmpi.l #$80010A1D,d0
bne ROXX_FAIL;
cmpi.l #$0000014D,d5
bne ROXX_FAIL;
; LONG LEFT
move.l #$80018FF1,d0
move.l #$00000015,d6
ROXx_LOOP5:
roxl.l d6,d0
jsr ROXx_FLAGS
dbf d6,ROXx_LOOP5
cmpi.l #$800185D0,d0
bne ROXX_FAIL;
cmpi.l #$000001A1,d5
bne ROXX_FAIL;
; LONG RIGHT
move.l #$80018FF1,d0
move.l #$00000016,d6
ROXx_LOOP6:
roxr.l d6,d0
jsr ROXx_FLAGS
dbf d6,ROXx_LOOP6
cmpi.l #$082D8200,d0
bne ROXX_FAIL;
cmpi.l #$000001DE,d5
bne ROXX_FAIL;
; Shift a Register LEFT and RIGHT with shift_count ## IN THE OPCODE ##
move.l #$80018FF1,d0
move.l #$00000000,d5
; BYTE LEFT
roxl.b #1,d0
jsr ROXx_FLAGS
roxl.b #5,d0
jsr ROXx_FLAGS
roxl.b #7,d0
jsr ROXx_FLAGS
roxl.b #8,d0
jsr ROXx_FLAGS
cmpi.l #$80018F09,d0
bne ROXX_FAIL;
cmpi.l #$0000000B,d5
bne ROXX_FAIL;
; BYTE RIGHT
roxr.b #1,d0
jsr ROXx_FLAGS
roxr.b #5,d0
jsr ROXx_FLAGS
roxr.b #7,d0
jsr ROXx_FLAGS
roxr.b #8,d0
jsr ROXx_FLAGS
cmpi.l #$80018F00,d0
bne ROXX_FAIL;
cmpi.l #$00000015,d5
bne ROXX_FAIL;
; WORD LEFT
roxl.w #1,d0
jsr ROXx_FLAGS
roxl.w #5,d0
jsr ROXx_FLAGS
roxl.w #7,d0
jsr ROXx_FLAGS
roxl.w #8,d0
jsr ROXx_FLAGS
cmpi.l #$8001B000,d0
bne ROXX_FAIL;
cmpi.l #$00000027,d5
bne ROXX_FAIL;
; WORD RIGHT
roxr.w #1,d0
jsr ROXx_FLAGS
roxr.w #5,d0
jsr ROXx_FLAGS
roxr.w #7,d0
jsr ROXx_FLAGS
roxr.w #8,d0
jsr ROXx_FLAGS
cmpi.l #$80010A00,d0
bne ROXX_FAIL;
cmpi.l #$00000028,d5
bne ROXX_FAIL;
; LONG LEFT
roxl.l #1,d0
jsr ROXx_FLAGS
roxl.l #5,d0
jsr ROXx_FLAGS
roxl.l #7,d0
jsr ROXx_FLAGS
roxl.l #8,d0
jsr ROXx_FLAGS
cmpi.l #$40000010,d0
bne ROXX_FAIL;
cmpi.l #$0000002A,d5
bne ROXX_FAIL;
; LONG RIGHT
roxr.l #1,d0
jsr ROXx_FLAGS
roxr.l #5,d0
jsr ROXx_FLAGS
roxr.l #7,d0
jsr ROXx_FLAGS
roxr.l #8,d0
jsr ROXx_FLAGS
cmpi.l #$00010200,d0
bne ROXX_FAIL;
cmpi.l #$00000032,d5
bne ROXX_FAIL;
; Shift a Memory location LEFT and RIGHT with shift_count of 1 - WORD only
move.l #$00000000,d5
move.l #$00000100,a0
move.w #$8FF1,(a0)
; WORD LEFT
roxl (a0)
jsr ROXx_FLAGS
roxl (a0)
jsr ROXx_FLAGS
roxl (a0)
jsr ROXx_FLAGS
roxl (a0)
jsr ROXx_FLAGS
move.w (a0),d0
cmpi.l #$0001FF10,d0
bne ROXX_FAIL;
cmpi.l #$00000009,d5
bne ROXX_FAIL;
; WORD RIGHT
roxr (a0)
jsr ROXx_FLAGS
roxr (a0)
jsr ROXx_FLAGS
roxr (a0)
jsr ROXx_FLAGS
roxr (a0)
jsr ROXx_FLAGS
roxr (a0)
jsr ROXx_FLAGS
roxr (a0)
jsr ROXx_FLAGS
move.w (a0),d0
cmpi.l #$000103FC,d0
bne ROXX_FAIL;
cmpi.l #$0000000A,d5
bne ROXX_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$37(a0)
rts
ROXX_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$37(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : SHIFTS
;-----------------------------------------------------------
;-----------------------------------------------------------
; Subroutine to check and accumulate the flags
SHIFTS_FLAGS: move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
rts
op_SHIFTS:
; Shift a Register LEFT and RIGHT with shift_count ## IN A REGISTER ##
; BYTE LEFT
move.l #$80018F81,d0
move.l #$00000000,d5
move.l #$00000002,d6
SHIFTS_LOOP1:
asl.b d6,d0
jsr SHIFTS_FLAGS
dbf d6,SHIFTS_LOOP1
cmpi.l #$80018F08,d0
bne SHIFT_FAIL;
cmpi.l #$00000002,d5
bne SHIFT_FAIL;
; BYTE RIGHT
move.l #$80018F81,d0
move.l #$00000002,d6
SHIFTS_LOOP2:
asr.b d6,d0
jsr SHIFTS_FLAGS
dbf d6,SHIFTS_LOOP2
cmpi.l #$80018FF0,d0
bne SHIFT_FAIL;
cmpi.l #$0000001A,d5
bne SHIFT_FAIL;
; WORD LEFT
move.l #$80018FF1,d0
move.l #$00000002,d6
SHIFTS_LOOP3:
asl.w d6,d0
jsr SHIFTS_FLAGS
dbf d6,SHIFTS_LOOP3
cmpi.l #$80017F88,d0
bne SHIFT_FAIL;
cmpi.l #$0000001C,d5
bne SHIFT_FAIL;
; WORD RIGHT
move.l #$80018FF1,d0
move.l #$00000002,d6
SHIFTS_LOOP4:
asr.w d6,d0
jsr SHIFTS_FLAGS
dbf d6,SHIFTS_LOOP4
cmpi.l #$8001F1FE,d0
bne SHIFT_FAIL;
cmpi.l #$00000034,d5
bne SHIFT_FAIL;
; LONG LEFT
move.l #$80018FF1,d0
move.l #$00000002,d6
SHIFTS_LOOP5:
asl.l d6,d0
jsr SHIFTS_FLAGS
dbf d6,SHIFTS_LOOP5
cmpi.l #$000C7F88,d0
bne SHIFT_FAIL;
cmpi.l #$00000036,d5
bne SHIFT_FAIL;
; LONG RIGHT
move.l #$80018FF1,d0
move.l #$00000002,d6
SHIFTS_LOOP6:
asr.l d6,d0
jsr SHIFTS_FLAGS
dbf d6,SHIFTS_LOOP6
cmpi.l #$F00031FE,d0
bne SHIFT_FAIL;
cmpi.l #$0000004E,d5
bne SHIFT_FAIL;
; Shift a Register LEFT and RIGHT with shift_count ## IN THE OPCODE ##
move.l #$80018FF1,d0
move.l #$00000000,d5
; BYTE LEFT
asl.b #1,d0
jsr SHIFTS_FLAGS
asl.b #2,d0
jsr SHIFTS_FLAGS
asl.b #1,d0
jsr SHIFTS_FLAGS
asl.b #3,d0
jsr SHIFTS_FLAGS
cmpi.l #$80018F80,d0
bne SHIFT_FAIL;
cmpi.l #$0000001F,d5
bne SHIFT_FAIL;
; BYTE RIGHT
asr.b #1,d0
jsr SHIFTS_FLAGS
asr.b #2,d0
jsr SHIFTS_FLAGS
asr.b #3,d0
jsr SHIFTS_FLAGS
asr.b #1,d0
jsr SHIFTS_FLAGS
cmpi.l #$80018FFF,d0
bne SHIFT_FAIL;
cmpi.l #$0000003F,d5
bne SHIFT_FAIL;
; WORD LEFT
asl.w #1,d0
jsr SHIFTS_FLAGS
asl.w #2,d0
jsr SHIFTS_FLAGS
asl.w #3,d0
jsr SHIFTS_FLAGS
asl.w #5,d0
jsr SHIFTS_FLAGS
cmpi.l #$8001F800,d0
bne SHIFT_FAIL;
cmpi.l #$00000056,d5
bne SHIFT_FAIL;
; WORD RIGHT
asr.w #5,d0
jsr SHIFTS_FLAGS
asr.w #1,d0
jsr SHIFTS_FLAGS
asr.w #2,d0
jsr SHIFTS_FLAGS
asr.w #4,d0
jsr SHIFTS_FLAGS
cmpi.l #$8001FFFF,d0
bne SHIFT_FAIL;
cmpi.l #$00000077,d5
bne SHIFT_FAIL;
; LONG LEFT
move.l #$80018FF1,d0
asl.l #1,d0
jsr SHIFTS_FLAGS
asl.l #2,d0
jsr SHIFTS_FLAGS
asl.l #7,d0
jsr SHIFTS_FLAGS
asl.l #4,d0
jsr SHIFTS_FLAGS
cmpi.l #$63FC4000,d0
bne SHIFT_FAIL;
cmpi.l #$0000007A,d5
bne SHIFT_FAIL;
; LONG RIGHT
move.l #$80018FF1,d0
asr.l #1,d0
jsr SHIFTS_FLAGS
asr.l #5,d0
jsr SHIFTS_FLAGS
asr.l #7,d0
jsr SHIFTS_FLAGS
asr.l #8,d0
jsr SHIFTS_FLAGS
cmpi.l #$FFFFFC00,d0
bne SHIFT_FAIL;
cmpi.l #$0000009C,d5
bne SHIFT_FAIL;
; Shift a Memory location LEFT and RIGHT with shift_count of 1 - WORD only
move.l #$00000000,d5
move.l #$00000100,a0
move.w #$8FF1,(a0)
; WORD LEFT
asl (a0)
jsr SHIFTS_FLAGS
asl (a0)
jsr SHIFTS_FLAGS
asl (a0)
jsr SHIFTS_FLAGS
asl (a0)
jsr SHIFTS_FLAGS
move.w (a0),d0
cmpi.l #$FFFFFF10,d0
bne SHIFT_FAIL;
cmpi.l #$0000000D,d5
bne SHIFT_FAIL;
; WORD RIGHT
asr (a0)
jsr SHIFTS_FLAGS
asr (a0)
jsr SHIFTS_FLAGS
asr (a0)
jsr SHIFTS_FLAGS
asr (a0)
jsr SHIFTS_FLAGS
asr (a0)
jsr SHIFTS_FLAGS
asr (a0)
jsr SHIFTS_FLAGS
move.w (a0),d0
cmpi.l #$FFFFFFFC,d0
bne SHIFT_FAIL;
cmpi.l #$0000003E,d5
bne SHIFT_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$38(a0)
rts
SHIFT_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$38(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : SHIFTS2
;-----------------------------------------------------------
;-----------------------------------------------------------
; Subroutine to check and accumulate the flags
SHIFTS2_FLAGS: move SR,d3
andi.l #$0F,d3 ; Isolate flags
add.l d3,d5 ; Copy flag results into accumulator
rts
op_SHIFTS2:
; Shift a Register LEFT and RIGHT with shift_count ## IN A REGISTER ##
; BYTE LEFT
move.l #$80018F81,d0
move.l #$00000000,d5
move.l #$00000002,d6
SHIFTS2_LOOP1:
lsl.b d6,d0
jsr SHIFTS2_FLAGS
dbf d6,SHIFTS2_LOOP1
cmpi.l #$80018F08,d0
bne LSHIFT_FAIL;
cmpi.l #$00000000,d5
bne LSHIFT_FAIL;
; BYTE RIGHT
move.l #$80018F81,d0
move.l #$00000002,d6
SHIFTS2_LOOP2:
lsr.b d6,d0
jsr SHIFTS2_FLAGS
dbf d6,SHIFTS2_LOOP2
cmpi.l #$80018F10,d0
bne LSHIFT_FAIL;
cmpi.l #$00000000,d5
bne LSHIFT_FAIL;
; WORD LEFT
move.l #$80018FF1,d0
move.l #$00000002,d6
SHIFTS2_LOOP3:
lsl.w d6,d0
jsr SHIFTS2_FLAGS
dbf d6,SHIFTS2_LOOP3
cmpi.l #$80017F88,d0
bne LSHIFT_FAIL;
cmpi.l #$00000000,d5
bne LSHIFT_FAIL;
; WORD RIGHT
move.l #$80018FF1,d0
move.l #$00000002,d6
SHIFTS2_LOOP4:
lsr.w d6,d0
jsr SHIFTS2_FLAGS
dbf d6,SHIFTS2_LOOP4
cmpi.l #$800111FE,d0
bne LSHIFT_FAIL;
cmpi.l #$00000000,d5
bne LSHIFT_FAIL;
; LONG LEFT
move.l #$80018FF1,d0
move.l #$00000002,d6
SHIFTS2_LOOP5:
lsl.l d6,d0
jsr SHIFTS2_FLAGS
dbf d6,SHIFTS2_LOOP5
cmpi.l #$000C7F88,d0
bne LSHIFT_FAIL;
cmpi.l #$00000000,d5
bne LSHIFT_FAIL;
; LONG RIGHT
move.l #$80018FF1,d0
move.l #$00000002,d6
SHIFTS2_LOOP6:
lsr.l d6,d0
jsr SHIFTS2_FLAGS
dbf d6,SHIFTS2_LOOP6
cmpi.l #$100031FE,d0
bne LSHIFT_FAIL;
cmpi.l #$00000000,d5
bne LSHIFT_FAIL;
; Shift a Register LEFT and RIGHT with shift_count ## IN THE OPCODE ##
move.l #$80018FF1,d0
move.l #$00000000,d5
; BYTE LEFT
lsl.b #1,d0
jsr SHIFTS2_FLAGS
lsl.b #2,d0
jsr SHIFTS2_FLAGS
lsl.b #1,d0
jsr SHIFTS2_FLAGS
lsl.b #3,d0
jsr SHIFTS2_FLAGS
cmpi.l #$80018F80,d0
bne LSHIFT_FAIL;
cmpi.l #$0000001B,d5
bne LSHIFT_FAIL;
; BYTE RIGHT
lsr.b #1,d0
jsr SHIFTS2_FLAGS
lsr.b #2,d0
jsr SHIFTS2_FLAGS
lsr.b #3,d0
jsr SHIFTS2_FLAGS
lsr.b #1,d0
jsr SHIFTS2_FLAGS
cmpi.l #$80018F01,d0
bne LSHIFT_FAIL;
cmpi.l #$0000001B,d5
bne LSHIFT_FAIL;
; WORD LEFT
lsl.w #1,d0
jsr SHIFTS2_FLAGS
lsl.w #2,d0
jsr SHIFTS2_FLAGS
lsl.w #3,d0
jsr SHIFTS2_FLAGS
lsl.w #5,d0
jsr SHIFTS2_FLAGS
cmpi.l #$80010800,d0
bne LSHIFT_FAIL;
cmpi.l #$00000025,d5
bne LSHIFT_FAIL;
; WORD RIGHT
lsr.w #5,d0
jsr SHIFTS2_FLAGS
lsr.w #1,d0
jsr SHIFTS2_FLAGS
lsr.w #2,d0
jsr SHIFTS2_FLAGS
lsr.w #4,d0
jsr SHIFTS2_FLAGS
cmpi.l #$80010000,d0
bne LSHIFT_FAIL;
cmpi.l #$0000002A,d5
bne LSHIFT_FAIL;
; LONG LEFT
move.l #$80018FF1,d0
lsl.l #1,d0
jsr SHIFTS2_FLAGS
lsl.l #2,d0
jsr SHIFTS2_FLAGS
lsl.l #7,d0
jsr SHIFTS2_FLAGS
lsl.l #4,d0
jsr SHIFTS2_FLAGS
cmpi.l #$63FC4000,d0
bne LSHIFT_FAIL;
cmpi.l #$0000002B,d5
bne LSHIFT_FAIL;
; LONG RIGHT
move.l #$80018FF1,d0
lsr.l #1,d0
jsr SHIFTS2_FLAGS
lsr.l #5,d0
jsr SHIFTS2_FLAGS
lsr.l #7,d0
jsr SHIFTS2_FLAGS
lsr.l #8,d0
jsr SHIFTS2_FLAGS
cmpi.l #$00000400,d0
bne LSHIFT_FAIL;
cmpi.l #$0000002D,d5
bne LSHIFT_FAIL;
; Shift a Memory location LEFT and RIGHT with shift_count of 1 - WORD only
move.l #$00000000,d5
move.l #$00000100,a0
move.w #$8FF1,(a0)
; WORD LEFT
lsl (a0)
jsr SHIFTS2_FLAGS
lsl (a0)
jsr SHIFTS2_FLAGS
lsl (a0)
jsr SHIFTS2_FLAGS
lsl (a0)
jsr SHIFTS2_FLAGS
move.w (a0),d0
cmpi.l #$0000FF10,d0
bne LSHIFT_FAIL;
cmpi.l #$00000009,d5
bne LSHIFT_FAIL;
; WORD RIGHT
lsr (a0)
jsr SHIFTS2_FLAGS
lsr (a0)
jsr SHIFTS2_FLAGS
lsr (a0)
jsr SHIFTS2_FLAGS
lsr (a0)
jsr SHIFTS2_FLAGS
lsr (a0)
jsr SHIFTS2_FLAGS
lsr (a0)
jsr SHIFTS2_FLAGS
move.w (a0),d0
cmpi.l #$000003FC,d0
bne LSHIFT_FAIL;
cmpi.l #$0000000A,d5
bne LSHIFT_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$39(a0)
rts
LSHIFT_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$39(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : ABCD
;-----------------------------------------------------------
;-----------------------------------------------------------
op_ABCD:
; Test with X Flag CLEARED
move.l #$00000110,a0 ; Address pointer-X
move.l #$00000120,a1 ; Address pointer-Y
move.l #$00000000,d0 ; BCD byte-X
move.l #$00000000,d1 ; BCD byte-Y
move.l #$00000000,d2
move.l #$00000000,d3 ; Cumulative -(An) BCD results
move.l #$00000000,d4 ; Cumulative number of times C was set
move.l #$00000000,d5 ; Cumulative Register BCD results
move.l #$00000099,d6 ; Inner loop counter
move.l #$00000099,d7 ; Outer loop counter
ABCD_OUTER1: move.l d7,d0
ABCD_INNER1: move.l d6,d1
andi.b #$EF,CCR ; Clear X Flag
move.l #$00000110,a0 ; Address pointer-X
move.l #$00000120,a1 ; Address pointer-Y
move.b d0,-1(a0)
move.b d1,-1(a1)
abcd d0,d1
bcc ABCD_NO_C1 ; Check C Flag bcc/bcs 0
add.l #1,d4
ABCD_NO_C1: add.l d1,d5
abcd -(a0),-(a1)
bcc ABCD_NO_C2 ; Check C Flag bcc/bcs 0
add.l #1,d4
ABCD_NO_C2: add.b (a1),d3
dbf d6,ABCD_INNER1
move.l #$00000099,d6
dbf d7,ABCD_OUTER1
cmpi.l #$00005AFC,d4 ; Check the cumulative results
bne ABCD_FAIL;
cmpi.l #$001C9A34,d5
bne ABCD_FAIL;
cmpi.l #$00000034,d3
bne ABCD_FAIL;
; Test with X Flag SET
move.l #$00000110,a0 ; Address pointer-X
move.l #$00000120,a1 ; Address pointer-Y
move.l #$00000000,d0 ; BCD byte-X
move.l #$00000000,d1 ; BCD byte-Y
move.l #$00000000,d2
move.l #$00000000,d3 ; Cumulative -(An) BCD results
move.l #$00000000,d4 ; Cumulative number of times C was set
move.l #$00000000,d5 ; Cumulative Register BCD results
move.l #$00000099,d6 ; Inner loop counter
move.l #$00000099,d7 ; Outer loop counter
ABCD_OUTER2: move.l d7,d0
ABCD_INNER2: move.l d6,d1
ori.b #$10,CCR ; Set X Flag
move.l #$00000110,a0 ; Address pointer-X
move.l #$00000120,a1 ; Address pointer-Y
move.b d0,-1(a0)
move.b d1,-1(a1)
abcd d0,d1
bcc ABCD_NO_C3 ; Check C Flag bcc/bcs 0
add.l #1,d4
ABCD_NO_C3: add.l d1,d5
abcd -(a0),-(a1)
bcc ABCD_NO_C4 ; Check C Flag bcc/bcs 0
add.l #1,d4
ABCD_NO_C4: add.b (a1),d3
dbf d6,ABCD_INNER2
move.l #$00000099,d6
dbf d7,ABCD_OUTER2
cmpi.l #$00005B60,d4 ; Check the cumulative results
bne ABCD_FAIL;
cmpi.l #$001CCFC8,d5
bne ABCD_FAIL;
cmpi.l #$00000034,d3
bne ABCD_FAIL;
; Quick check of Z Flag
move.b #$00,d0
move.b #$00,d1
move #$00,CCR ; Set Z flag to 0
abcd d1,d0 ; Should NOT set Z Flag to 1
beq ABCD_FAIL; ; Check Z Flag beq/bne
move.b #$01,d0
move.b #$00,d1
move #$04,CCR ; Set Z flag to 0
abcd d1,d0 ; Should NOT set Z Flag to 1
beq ABCD_FAIL; ; Check Z Flag beq/bne
movea #TESTSTATUS,a0
move.b #$1,$3a(a0)
rts
ABCD_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$3a(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : SBCD
;-----------------------------------------------------------
;-----------------------------------------------------------
op_SBCD:
; Test with X Flag CLEARED
move.l #$00000110,a0 ; Address pointer-X
move.l #$00000120,a1 ; Address pointer-Y
move.l #$00000000,d0 ; BCD byte-X
move.l #$00000000,d1 ; BCD byte-Y
move.l #$00000000,d2
move.l #$00000000,d3 ; Cumulative -(An) BCD results
move.l #$00000000,d4 ; Cumulative number of times C was set
move.l #$00000000,d5 ; Cumulative Register BCD results
move.l #$00000099,d6 ; Inner loop counter
move.l #$00000099,d7 ; Outer loop counter
SBCD_OUTER1: move.l d7,d0
SBCD_INNER1: move.l d6,d1
andi.b #$EF,CCR ; Clear X Flag
move.l #$00000110,a0 ; Address pointer-X
move.l #$00000120,a1 ; Address pointer-Y
move.b d0,-1(a0)
move.b d1,-1(a1)
sbcd d0,d1
bcc SBCD_NO_C1 ; Check C Flag bcc/bcs 0
add.l #1,d4
SBCD_NO_C1: add.l d1,d5
sbcd -(a0),-(a1)
bcc SBCD_NO_C2 ; Check C Flag bcc/bcs 0
add.l #1,d4
SBCD_NO_C2: add.b (a1),d3
dbf d6,SBCD_INNER1
move.l #$00000099,d6
dbf d7,SBCD_OUTER1
cmpi.l #$00005C0A,d4 ; Check the cumulative results
bne SBCD_FAIL;
cmpi.l #$001C459E,d5
bne SBCD_FAIL;
cmpi.l #$0000009E,d3
bne SBCD_FAIL;
; Test with X Flag SET
move.l #$00000110,a0 ; Address pointer-X
move.l #$00000120,a1 ; Address pointer-Y
move.l #$00000000,d0 ; BCD byte-X
move.l #$00000000,d1 ; BCD byte-Y
move.l #$00000000,d2
move.l #$00000000,d3 ; Cumulative -(An) BCD results
move.l #$00000000,d4 ; Cumulative number of times C was set
move.l #$00000000,d5 ; Cumulative Register BCD results
move.l #$00000099,d6 ; Inner loop counter
move.l #$00000099,d7 ; Outer loop counter
SBCD_OUTER2: move.l d7,d0
SBCD_INNER2: move.l d6,d1
ori.b #$10,CCR ; Set X Flag
move.l #$00000110,a0 ; Address pointer-X
move.l #$00000120,a1 ; Address pointer-Y
move.b d0,-1(a0)
move.b d1,-1(a1)
sbcd d0,d1
bcc SBCD_NO_C3 ; Check C Flag bcc/bcs 0
add.l #1,d4
SBCD_NO_C3: add.l d1,d5
sbcd -(a0),-(a1)
bcc SBCD_NO_C4 ; Check C Flag bcc/bcs 0
add.l #1,d4
SBCD_NO_C4: add.b (a1),d3
dbf d6,SBCD_INNER2
move.l #$00000099,d6
dbf d7,SBCD_OUTER2
cmpi.l #$00005CA4,d4 ; Check the cumulative results
bne SBCD_FAIL;
cmpi.l #$001C5C66,d5
bne SBCD_FAIL;
cmpi.l #$0000009E,d3
bne SBCD_FAIL;
; Quick check of Z Flag
move.b #$00,d0
move.b #$00,d1
move #$00,CCR ; Set Z flag to 0
sbcd d1,d0 ; Should NOT set Z Flag to 1
beq SBCD_FAIL; ; Check Z Flag beq/bne
move.b #$01,d0
move.b #$00,d1
move #$04,CCR ; Set Z flag to 0
sbcd d1,d0 ; Should NOT set Z Flag to 1
beq SBCD_FAIL; ; Check Z Flag beq/bne
movea #TESTSTATUS,a0
move.b #$1,$3b(a0)
rts
SBCD_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$3b(a0)
rts
;-----------------------------------------------------------
;-----------------------------------------------------------
; OPCODE : NBCD
;-----------------------------------------------------------
;-----------------------------------------------------------
op_NBCD:
; NBCD to a Register
move.l #$00000000,d0 ; BCD byte
move.l #$00000000,d1
move.l #$00000000,d2
move.l #$00000000,d3 ; Cumulative number of times Z was set
move.l #$00000000,d4 ; Cumulative number of times C was set
move.l #$00000000,d5 ; Cumulative BCD results
move.l #$00000099,d6
move.l #$00000099,d7 ; Loop counter
NBCD_LOOP: move.l d7,d0
move #$04,CCR ; Set Z flag to 0
nbcd d0
bcc NBCD_NO_C ; Check C Flag
add.l #1,d4
NBCD_NO_C: bne NBCD_NO_Z ; Check Z Flag
add.l #1,d3
NBCD_NO_Z: add.l d0,d5 ; Add results into d5
dbf d7,NBCD_LOOP
cmpi.l #$00000001,d3 ; Check the cumulative results
bne NBCD_FAIL;
cmpi.l #$00000099,d4
bne NBCD_FAIL;
cmpi.l #$00002E3B,d5
bne NBCD_FAIL;
; NBCD to a memory location
move.l #$00000000,d0 ; BCD byte
move.l #$00000000,d1
move.l #$00000000,d2
move.l #$00000000,d3 ; Cumulative number of times Z was set
move.l #$00000000,d4 ; Cumulative number of times C was set
move.l #$00000000,d5 ; Cumulative BCD results
move.l #$00000099,d6
move.l #$00000099,d7 ; Loop counter
NBCD_LOOP1: move.b d7,$00000100
move #$04,CCR ; Set Z flag to 0
nbcd $00000100
move.b $00000100,d0
bcc NBCD_NO_C1 ; Check C Flag
add.l #1,d4
NBCD_NO_C1: bne NBCD_NO_Z1 ; Check Z Flag
add.l #1,d3
NBCD_NO_Z1: add.l d0,d5 ; Add results into d5
dbf d7,NBCD_LOOP1
cmpi.l #$00000001,d3 ; Check the cumulative results
bne NBCD_FAIL;
cmpi.l #$00000000,d4
bne NBCD_FAIL;
cmpi.l #$00002E3B,d5
bne NBCD_FAIL;
movea #TESTSTATUS,a0
move.b #$1,$3c(a0)
rts
NBCD_FAIL:
movea #TESTSTATUS,a0
move.b #$2,$3c(a0)
rts
|
;note: DIV16Amul256dCUNDOC as per
; BC = A0
; DE = 0C
; so BC = a * 256 / C
; We can cheat here, Speed is always 0 or positive
; z postion will always be positive if we can see it
InitStarAtHL: ex de,hl ; preserving hl
call doRND ; a = random OR bit 5
ex de,hl ; .
or 8 ; .
ld (hl),a ; save to x pos
and $7F ; a = abs a
inc hl ;
ld (hl),a ;
ex de,hl ; preserving hl
call doRND ; a = -ve (random / 2)
ex de,hl ; .
rrca ; .
and $80 ; .
or (hl) ; or with
ld (hl),a
inc hl
ex de,hl
call doRND
ex de,hl
or 4
ld (hl),a
inc hl
and $7F
ld (hl),a
ex de,hl
call doRND
ex de,hl
rrca
and $80
or (hl)
ld (hl),a
inc hl
ex de,hl
call doRND
ex de,hl
or 144
ld (hl),a
inc hl
or %01110000
and $7f ; bodge
ld (hl),a
inc hl
ret
InitHyperStarAtHL: ex de,hl
call doRND
sla a
sla a ; so its * 4 as we have a blank spot
ex de,hl
and %11111000
ld (hl),a
and $7F
inc hl
ld (hl),a
ex de,hl
call doRND
ex de,hl
rrca
and $80
or (hl)
ld (hl),a
inc hl
ex de,hl
call doRND
sla a
sla a ; so its * 4 as we have a blank spot
ex de,hl
and %11111000
ld (hl),a
inc hl
and $7F
ld (hl),a
ex de,hl
call doRND
ex de,hl
rrca
and $80
or (hl)
ld (hl),a
inc hl
ex de,hl
call doRND
ex de,hl
or 95
ld (hl),a
inc hl
or %01110000
and $7f ; bodge
ld (hl),a
inc hl
ret
; we could cheat, flip the sign of DE and just add but its not very optimised
StarsSUBHLDESigned: ld a,h
and SignOnly8Bit
ld b,a ;save sign bit in b
xor d ;if h sign and d sign were different then bit 7 of a will be 1 which means
JumpIfNegative .SUBHLDEOppSGN ;Signs are opposite therefore we can add
.SUBHLDESameSigns: ld a,b
or d
JumpIfNegative .SUBHLDESameNeg ; optimisation so we can just do simple add if both positive
or a
sbc hl,de
JumpIfNegative .SUBHLDESameOvrFlw
ret
.SUBHLDESameNeg: ld a,h ; so if we enter here then signs are the same so we clear the 16th bit
and SignMask8Bit ; we could check the value of b for optimisation
ld h,a
ld a,d
and SignMask8Bit
ld d,a
or a
sbc hl,de
JumpIfNegative .SUBHLDESameOvrFlw
ld a,h ; now set bit for negative value, we won't bother with overflow for now TODO
or SignOnly8Bit
ld h,a
ret
.SUBHLDESameOvrFlw: NegHL
ld a,b
xor SignOnly8Bit ; flip sign bit
or h
ld h,a ; recover sign
ret
.SUBHLDEOppSGN: or a
ld a,h ; so if we enter here then signs are the same so we clear the 16th bit
and SignMask8Bit ; we could check the value of b for optimisation
ld h,a
ld a,d
and SignMask8Bit
ld d,a
add hl,de
ld a,b ; we got here so hl > de therefore we can just take hl's previous sign bit
or h
ld h,a ; set the previou sign value
ret
StarsADDHLDESigned: ld a,h
and SignOnly8Bit
ld b,a ;save sign bit in b
xor d ;if h sign and d sign were different then bit 7 of a will be 1 which means
JumpIfNegative .ADDHLDEOppSGN ;Signs are opposite there fore we can subtract to get difference
.ADDHLDESameSigns: ld a,b
or d
JumpIfNegative .ADDHLDESameNeg ; optimisation so we can just do simple add if both positive
add hl,de
ret
.ADDHLDESameNeg: ld a,h ; so if we enter here then signs are the same so we clear the 16th bit
and SignMask8Bit ; we could check the value of b for optimisation
ld h,a
ld a,d
and SignMask8Bit
ld d,a
add hl,de
ld a,SignOnly8Bit
or h ; now set bit for negative value, we won't bother with overflow for now TODO
ld h,a
ret
.ADDHLDEOppSGN: ld a,h ; here HL and DE are opposite so if we enter here then signs are the same so we clear the 16th bit
and SignMask8Bit ; we could check the value of b for optimisation
ld h,a
ld a,d
and SignMask8Bit
ld d,a
or a
sbc hl,de
jr c,.ADDHLDEOppInvert
.ADDHLDEOppSGNNoCarry: ld a,b ; we got here so hl > de therefore we can just take hl's previous sign bit
or h
ld h,a ; set the previou sign value
ret
.ADDHLDEOppInvert: NegHL
ld a,b
xor SignOnly8Bit ; flip sign bit
or h
ld h,a ; recover sign
ret
;----------------------------------------------------------------------------------------------------------------------------------
InitialiseStars: ld b,MaxNumberOfStars
ld hl,varDust
.InitStarsLoop: call InitStarAtHL
djnz .InitStarsLoop
ret
;----------------------------------------------------------------------------------------------------------------------------------
InitialiseHyperStars: ld b,MaxNumberOfStars
ld hl,varDust
.InitStarsLoop: call InitHyperStarAtHL
djnz .InitStarsLoop
ret
;----------------------------------------------------------------------------------------------------------------------------------
DustForward: ld b,MaxNumberOfStars ; get the number of stars to process
ld iy,varDust ; hl is now a pointer to the dust array
StarProcessLoop: push bc ; save counter +1
.Qequ64XSpeedDivZHi: ld a,(iy+5) ; e = z high
ld e,a ; d = 0
ld d,0 ; de = zhi/256
ld a,(DELTA) ; a = speed
JumpIfAIsNotZero .NormalSpeed ; if we are stationary set speed
inc a ; so it is at least some dust movement
.NormalSpeed: ld b,a ;
ld c,0 ; bc = delta * 256
call BC_Div_DE ; BC = Speed/Z , HL = remainder
ShiftHLRight1
ShiftHLRight1 ; hl = remainder/2 so now 64 * speed / zhi
ld a,l ;
or 1 ; so ensure A is at least 1 for ambient movement
ld ixl,a ; preserve A which is also VarQ = 64 * speed / zhi
.ZequZMinusSpeedX64: ld hl,(iy+4) ; hl = z
ld de, (DELTA4) ; de = delta4 i.e. speed * 64 pre computed
call StarsSUBHLDESigned
JumpOnBitSet h,7,ResetStar ; if z ended up negative then reset the star
ld (iy+4),hl ; save new z pos
.XEquXPlusXhiMulQ ld hl,(iy+0) ; hl = x
ld a,h ;
and $7F ;
ld d,a ; d = abs(x hi)
ld e,ixl ; e = Q = 64 * speed / zhi
mul ; de = abs(x hi) * Q
ld a,h ;
and $80 ;
or d ; set sign bit in d
ld d,a ;
call StarsADDHLDESigned ; x = x + (x hi/256 * Q)
ld a,h
and $7F
JumpIfAGTENusng $70, ResetStar
ld (iy+0),hl ;
.YEquYPlusYhiMulQ ld hl,(iy+2) ; hl = y
ld a,h ;
and $7F ;
ld d,a ; d = abs(y hi)
ld e,ixl ; e = Q = 64 * speed / zhi
mul ; de = abs(y hi) * Q
ld a,h ;
and $80 ;
or d ; set sign bit in d
ld d,a ;
call StarsADDHLDESigned ; y = y + (x hi/256 * Q)
ld a,h
and $7F
JumpIfAGTENusng $60, ResetStar
ld a,h
and $80
jr nz,.NoSecondCheck
ld a,h
JumpIfAGTENusng $20, ResetStar
.NoSecondCheck: ld (iy+2),hl ;
; Now roll
; 6. x = x - alpha * y / 256
.XRoll: ld hl,(ALP1) ; h = sign, l = magnitude
ld a,l
cp 0
jr z,.NoRoll ; don;t roll if magnitude is 0
;break
;ld a,$80
;xor l ; l = flipped sign as we are rotating stars not us
push hl
ld a,h
and $80
.rxSaveAlphaSign: ld c,a ; save alpha sign in c
.rxDEquABSAlpha: ld d,l ; d= abs (alpha)
ld a,(iy+3) ; get high byte from x coord
ld e,a
and $80
.rxBEquSignXHi: ld b,a ; save sign of x in b
.rxEEquABSignX: ld a,e
and $7F
ld e,a ; save abs x hi in e
mul ; abs(alpha) * abs(y high) (so /256)
ld a,c
xor b ; handle muliple sign bits
or d
ld d,a ; de = signed alpha & y high / 256
ld hl,(iy+0) ; h = iy+1, l = iy+0
call StarsSUBHLDESigned ; we are usign add, so may need to fip sign?
ld (iy+0),hl
; 5. y = y + alpha * x / 256
.YRoll: ;break
pop hl ; h = sign, l = magnitude
ld a,h
and $80
.rySaveAlphaSign: ld c,a ; save alpha sign in c
.ryDEquABSAlpha: ld d,l ; d= abs (alpha)
ld a,(iy+1) ; get high byte from x coord
ld e,a
and $80
.ryBEquSignXHi: ld b,a ; save sign of x in b
.ryEEquABSignX: ld a,e
and $7F
ld e,a ; save abs x hi in e
mul ; abs(alpha) * abs(y high) (so /256)
ld a,c
xor b ; handle muliple sign bits
or d
ld d,a ; de = signed alpha & y high / 256
ld hl,(iy+2) ; h = iy+1, l = iy+0
call StarsADDHLDESigned ; we are usign add, so may need to fip sign?
ld (iy+2),hl
.NoRoll: ld a,(BET1)
cp 0
jr z,.NoPitch
; 8. y = y - beta * 256
.YPitch: ld d,a ; d = BET1
ld a,(iy+2)
ld e,a ; e = Y HI
mul ; de = BET1 * YHi so now D = BETA & YHI / 256
ld e,a
mul ; so now de = (BETA & Yhi) ^ 2
ShiftDELeft1 ; de = 2 * ((BETA & Yhi) ^ 2)
ld a,(BET2FLIP) ; get inverted Sign
or d
ld d,a ; de = - (2 * ((BETA & Yhi) ^ 2))
ld hl,(iy+2)
call StarsADDHLDESigned
ld (iy+2),hl
; now work out screen pos
; Note two optimistations, write to layer 2 - we get a free removal via double buffer cls
; read z dept than determine hw many pixesl to plot, e.g. 1,2,3,4
; pop de
; call ProjectStarXToScreen
;pop de
.NoPitch:
.ProjectStar: ld a,(iy+1)
ld l,a
and $7F
JumpOnBitSet l,7,StarNegXPt
add a,$80
ld c,a
jp StarDoneX
StarNegXPt: ld b,a
ld a,$80
sub b
ld c,a
StarDoneX: ld a,(iy+3)
ld l,a
and $7F
JumpOnBitSet l,7,StarNegYPt
add a,$60
ld b,a
jp StarDoneY
StarNegYPt: ld b,a
ld a,$60
sub b
ld b,a
StarDoneY: ld a,L2DustColour
push bc
.DrawStar: MMUSelectLayer2 : call l2_plot_pixel
ld a,(iy+5)
pop bc
JumpIfAGTENusng $60,EndofStarsLoop
ld a,L2DustColour
inc c
push bc
MMUSelectLayer2
call l2_plot_pixel
ld a,(iy+5)
pop bc
JumpIfAGTENusng $37,EndofStarsLoop
ld a,L2DustColour
inc b
push bc
MMUSelectLayer2 : call l2_plot_pixel
ld a,(iy+5)
pop bc
ld a,L2DustColour
dec c
MMUSelectLayer2 : call l2_plot_pixel
EndofStarsLoop: pop bc ; 0
NextStarLoop3: push iy ; +1
pop hl ; 0
add hl,6
NextStarLoop2: push hl ; +1
pop iy ; 0
dec b
jp nz,StarProcessLoop
ret
ResetStar: pop bc ; 0
push iy ; +1 (current star)
pop hl ; 0
call InitStarAtHL
jp NextStarLoop3
;----------------------------------------------------------------------------------------------------------------------------------
ProjectStarXToScreen: ld c,(iy+0)
ld a,(iy+1)
ld l,a
and $7F
ld b,a
call DIV16BCDivDEUNDOC
ld a,l
JumpOnBitSet a,7,StarXNegativePoint ; LL62 up, -ve Xdist, RU screen onto XX3 heap
;StarXPositivePoint: ; x was positive result
ld l,ScreenCenterX ;
ld h,0
add hl,bc ; hl = Screen Centre + X
jp StarStoreXPoint
StarXNegativePoint: ; x < 0 so need to subtract from the screen centre position
ld l,ScreenCenterX
ld h,0
ClearCarryFlag
sbc hl,bc ; hl = Screen Centre - X
StarStoreXPoint: ; also from LL62, XX3 node heap has xscreen node so far.
ld a,l
ld (varStarX),a
ret
ProjectStarYToScreen: ld b,(iy+2)
ld a,(iy+3)
ld l,a
and $7F
ld b,a
call DIV16BCDivDEUNDOC
ld a,l ; XX15+2 \ sign of X dist
JumpOnBitSet a,7,StarNegativeYPoint ; LL62 up, -ve Xdist, RU screen onto XX3 heap top of screen is Y = 0
;StarPositiveYPoint: ; Y is positive so above the centre line
ld l,ScreenCenterY
ClearCarryFlag
sbc hl,bc ; hl = ScreenCentreY - Y coord (as screen is 0 at top)
jp StarStoreYPoint
StarNegativeYPoint: ; this bit is only 8 bit aware TODO FIX
ld l,ScreenCenterY
ld h,0
add hl,bc ; hl = ScreenCenterY + Y as negative is below the center of screen
StarStoreYPoint: ; also from LL62, XX3 node heap has xscreen node so far.
ld a,l
ld (varStarY),a
ret
|
%include "include/u7si-all-includes.asm"
defineAddress 326, 0x01D8, startDialogMode_enableKeyMouse
defineAddress 326, 0x01F4, startDialogMode_enableKeyMouse_end
%include "../u7-common/patch-noKeyMouseWhenStartingDialogMode.asm"
|
SECTION rodata_font_fzx
PUBLIC _ff_dkud1_Transcript
_ff_dkud1_Transcript:
BINARY "font/fzx/fonts/dkud1/Transcript/transcript.fzx"
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x13839, %rax
nop
nop
nop
nop
nop
sub $51675, %rdi
movb (%rax), %r8b
and $57046, %rax
lea addresses_normal_ht+0x3215, %rsi
lea addresses_WT_ht+0xb3c9, %rdi
nop
nop
nop
nop
nop
xor $5524, %rbx
mov $56, %rcx
rep movsq
nop
add $19115, %rsi
lea addresses_D_ht+0x16139, %rdi
nop
sub $26896, %r12
movb $0x61, (%rdi)
add %rcx, %rcx
lea addresses_A_ht+0x19439, %r8
nop
add %rbx, %rbx
vmovups (%r8), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $0, %xmm7, %rax
nop
nop
nop
nop
nop
dec %rbx
lea addresses_WC_ht+0xc8e9, %rcx
nop
nop
nop
add %rdi, %rdi
movb (%rcx), %r12b
nop
nop
nop
nop
nop
inc %rax
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r15
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
// REPMOV
lea addresses_RW+0x7039, %rsi
lea addresses_A+0x17c39, %rdi
nop
inc %r10
mov $1, %rcx
rep movsl
cmp $51579, %r15
// Store
lea addresses_D+0x1d1d0, %rax
clflush (%rax)
sub $40592, %rbx
movw $0x5152, (%rax)
nop
nop
inc %rsi
// Load
lea addresses_A+0x17c39, %r10
nop
and $25963, %rsi
mov (%r10), %eax
nop
nop
sub %rdi, %rdi
// Load
lea addresses_PSE+0x16039, %r15
cmp $19626, %rcx
vmovups (%r15), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $1, %xmm4, %rsi
nop
nop
nop
sub $61715, %r10
// REPMOV
lea addresses_RW+0x1c939, %rsi
lea addresses_WC+0x8139, %rdi
nop
dec %r15
mov $6, %rcx
rep movsb
nop
nop
nop
nop
nop
add $17012, %r15
// REPMOV
lea addresses_WT+0x6339, %rsi
lea addresses_A+0x1e607, %rdi
nop
nop
nop
nop
cmp $35477, %r8
mov $104, %rcx
rep movsl
nop
nop
dec %rax
// Store
lea addresses_D+0x1b30b, %rdi
nop
sub %r8, %r8
mov $0x5152535455565758, %r15
movq %r15, %xmm4
movups %xmm4, (%rdi)
nop
nop
nop
nop
inc %r15
// Faulty Load
lea addresses_A+0x17c39, %rbx
nop
nop
sub $21802, %rax
mov (%rbx), %r15w
lea oracles, %r8
and $0xff, %r15
shlq $12, %r15
mov (%r8,%r15,1), %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r15
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_RW', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A', 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 2, 'AVXalign': False}}
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_PSE', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_RW', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC', 'congruent': 7, 'same': False}}
{'src': {'type': 'addresses_WT', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A', 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_D', 'size': 16, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': True, 'congruent': 9, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False}}
{'src': {'same': True, 'congruent': 10, 'NT': False, 'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
; TODO: UTILITIES
; Make sure ruledef has been included
#include "../CESC16.cpu"
; Include OS routines
#include "OS.inc"
MAIN_PROGRAM:
|
section.data ;data segment
msg: db 'Hello, world!',10 ;String
len: equ $ - msg ;Length of the String
section.text ;code segment
global _start ;must be declared for linker (ld)
_start: ;tells linker entry point
mov eax,4 ;system call number (sys_write)
mov ebx,1 ;file descriptor (stdout)
mov edx,len ;message length
mov ecx,msg ;message to write
int 0x80 ;call kernel
mov eax,1 ;system call number (sys_exit)
mov ebx,0 ;error code
int 0x80 ;call kernel
|
// Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2018 The Atheneum developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "overviewpage.h"
#include "ui_overviewpage.h"
#include "bitcoinunits.h"
#include "clientmodel.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "init.h"
#include "obfuscation.h"
#include "obfuscationconfig.h"
#include "optionsmodel.h"
#include "transactionfilterproxy.h"
#include "transactiontablemodel.h"
#include "walletmodel.h"
#include <QAbstractItemDelegate>
#include <QPainter>
#include <QSettings>
#include <QTimer>
#define DECORATION_SIZE 48
#define ICON_OFFSET 16
#define NUM_ITEMS 5
class TxViewDelegate : public QAbstractItemDelegate
{
Q_OBJECT
public:
TxViewDelegate() : QAbstractItemDelegate(), unit(BitcoinUnits::AEM)
{
}
inline void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
painter->save();
QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
QRect mainRect = option.rect;
mainRect.moveLeft(ICON_OFFSET);
QRect decorationRect(mainRect.topLeft(), QSize(DECORATION_SIZE, DECORATION_SIZE));
int xspace = DECORATION_SIZE + 8;
int ypad = 6;
int halfheight = (mainRect.height() - 2 * ypad) / 2;
QRect amountRect(mainRect.left() + xspace, mainRect.top() + ypad, mainRect.width() - xspace - ICON_OFFSET, halfheight);
QRect addressRect(mainRect.left() + xspace, mainRect.top() + ypad + halfheight, mainRect.width() - xspace, halfheight);
icon.paint(painter, decorationRect);
QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime();
QString address = index.data(Qt::DisplayRole).toString();
qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong();
bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool();
QVariant value = index.data(Qt::ForegroundRole);
QColor foreground = COLOR_BLACK;
if (value.canConvert<QBrush>()) {
QBrush brush = qvariant_cast<QBrush>(value);
foreground = brush.color();
}
painter->setPen(foreground);
QRect boundingRect;
painter->drawText(addressRect, Qt::AlignLeft | Qt::AlignVCenter, address, &boundingRect);
if (index.data(TransactionTableModel::WatchonlyRole).toBool()) {
QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole));
QRect watchonlyRect(boundingRect.right() + 5, mainRect.top() + ypad + halfheight, 16, halfheight);
iconWatchonly.paint(painter, watchonlyRect);
}
if (amount < 0) {
foreground = COLOR_NEGATIVE;
} else if (!confirmed) {
foreground = COLOR_UNCONFIRMED;
} else {
foreground = COLOR_BLACK;
}
painter->setPen(foreground);
QString amountText = BitcoinUnits::formatWithUnit(unit, amount, true, BitcoinUnits::separatorAlways);
if (!confirmed) {
amountText = QString("[") + amountText + QString("]");
}
painter->drawText(amountRect, Qt::AlignRight | Qt::AlignVCenter, amountText);
painter->setPen(COLOR_BLACK);
painter->drawText(amountRect, Qt::AlignLeft | Qt::AlignVCenter, GUIUtil::dateTimeStr(date));
painter->restore();
}
inline QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
{
return QSize(DECORATION_SIZE, DECORATION_SIZE);
}
int unit;
};
#include "overviewpage.moc"
OverviewPage::OverviewPage(QWidget* parent) : QWidget(parent),
ui(new Ui::OverviewPage),
clientModel(0),
walletModel(0),
currentBalance(-1),
currentUnconfirmedBalance(-1),
currentImmatureBalance(-1),
currentWatchOnlyBalance(-1),
currentWatchUnconfBalance(-1),
currentWatchImmatureBalance(-1),
txdelegate(new TxViewDelegate()),
filter(0)
{
nDisplayUnit = 0; // just make sure it's not unitialized
ui->setupUi(this);
// Recent transactions
ui->listTransactions->setItemDelegate(txdelegate);
ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE));
ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false);
connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex)));
// init "out of sync" warning labels
//ui->labelWalletStatus->setText("(" + tr("out of sync") + ")");
ui->labelTransactionsStatus->setText("(" + tr("out of sync") + ")");
// start with displaying the "out of sync" warnings
showOutOfSyncWarning(true);
}
void OverviewPage::handleTransactionClicked(const QModelIndex& index)
{
if (filter)
emit transactionClicked(filter->mapToSource(index));
}
OverviewPage::~OverviewPage()
{
if (!fLiteMode && !fMasterNode) disconnect(timer, SIGNAL(timeout()), this, SLOT(obfuScationStatus()));
delete ui;
}
void OverviewPage::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& anonymizedBalance, const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance)
{
currentBalance = balance;
currentUnconfirmedBalance = unconfirmedBalance;
currentImmatureBalance = immatureBalance;
currentAnonymizedBalance = anonymizedBalance;
currentWatchOnlyBalance = watchOnlyBalance;
currentWatchUnconfBalance = watchUnconfBalance;
currentWatchImmatureBalance = watchImmatureBalance;
ui->labelBalance->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, balance - immatureBalance, false, BitcoinUnits::separatorAlways));
ui->labelUnconfirmed->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, unconfirmedBalance, false, BitcoinUnits::separatorAlways));
ui->labelImmature->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, immatureBalance, false, BitcoinUnits::separatorAlways));
ui->labelTotal->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, balance + unconfirmedBalance, false, BitcoinUnits::separatorAlways));
ui->labelWatchAvailable->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, watchOnlyBalance, false, BitcoinUnits::separatorAlways));
ui->labelWatchPending->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, watchUnconfBalance, false, BitcoinUnits::separatorAlways));
ui->labelWatchImmature->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, watchImmatureBalance, false, BitcoinUnits::separatorAlways));
ui->labelWatchTotal->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, watchOnlyBalance + watchUnconfBalance + watchImmatureBalance, false, BitcoinUnits::separatorAlways));
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
// for the non-mining users
bool showImmature = immatureBalance != 0;
bool showWatchOnlyImmature = watchImmatureBalance != 0;
// for symmetry reasons also show immature label when the watch-only one is shown
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance
updateObfuscationProgress();
static int cachedTxLocks = 0;
if (cachedTxLocks != nCompleteTXLocks) {
cachedTxLocks = nCompleteTXLocks;
ui->listTransactions->update();
}
}
// show/hide watch-only labels
void OverviewPage::updateWatchOnlyLabels(bool showWatchOnly)
{
ui->labelSpendable->setVisible(showWatchOnly); // show spendable label (only when watch-only is active)
ui->labelWatchonly->setVisible(showWatchOnly); // show watch-only label
ui->labelWatchAvailable->setVisible(showWatchOnly); // show watch-only available balance
ui->labelWatchPending->setVisible(showWatchOnly); // show watch-only pending balance
ui->labelWatchTotal->setVisible(showWatchOnly); // show watch-only total balance
if (!showWatchOnly) {
ui->labelWatchImmature->hide();
} else {
ui->labelBalance->setIndent(20);
ui->labelUnconfirmed->setIndent(20);
ui->labelImmature->setIndent(20);
ui->labelTotal->setIndent(20);
}
}
void OverviewPage::setClientModel(ClientModel* model)
{
this->clientModel = model;
if (model) {
// Show warning if this is a prerelease version
connect(model, SIGNAL(alertsChanged(QString)), this, SLOT(updateAlerts(QString)));
updateAlerts(model->getStatusBarWarnings());
}
}
void OverviewPage::setWalletModel(WalletModel* model)
{
this->walletModel = model;
if (model && model->getOptionsModel()) {
// Set up transaction list
filter = new TransactionFilterProxy();
filter->setSourceModel(model->getTransactionTableModel());
filter->setLimit(NUM_ITEMS);
filter->setDynamicSortFilter(true);
filter->setSortRole(Qt::EditRole);
filter->setShowInactive(false);
filter->sort(TransactionTableModel::Date, Qt::DescendingOrder);
ui->listTransactions->setModel(filter);
ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress);
// Keep up to date with wallet
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance(),
model->getWatchBalance(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance());
connect(model, SIGNAL(balanceChanged(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount)), this, SLOT(setBalance(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
updateWatchOnlyLabels(model->haveWatchOnly());
connect(model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyLabels(bool)));
}
// update the display unit, to not use the default ("AEM")
updateDisplayUnit();
}
void OverviewPage::updateDisplayUnit()
{
if (walletModel && walletModel->getOptionsModel()) {
nDisplayUnit = walletModel->getOptionsModel()->getDisplayUnit();
if (currentBalance != -1)
setBalance(currentBalance, currentUnconfirmedBalance, currentImmatureBalance, currentAnonymizedBalance,
currentWatchOnlyBalance, currentWatchUnconfBalance, currentWatchImmatureBalance);
// Update txdelegate->unit with the current unit
txdelegate->unit = nDisplayUnit;
ui->listTransactions->update();
}
}
void OverviewPage::updateAlerts(const QString& warnings)
{
this->ui->labelAlerts->setVisible(!warnings.isEmpty());
this->ui->labelAlerts->setText(warnings);
}
void OverviewPage::showOutOfSyncWarning(bool fShow)
{
//ui->labelWalletStatus->setVisible(fShow);
ui->labelTransactionsStatus->setVisible(fShow);
}
void OverviewPage::updateObfuscationProgress()
{
if (!masternodeSync.IsBlockchainSynced() || ShutdownRequested()) return;
if (!pwalletMain) return;
}
void OverviewPage::obfuScationStatus()
{
}
void OverviewPage::obfuscationAuto()
{
}
void OverviewPage::obfuscationReset()
{
}
void OverviewPage::toggleObfuscation()
{
}
|
;
; TinyBASIC interpreter in 512 bytes (boot sector)
;
; by Oscar Toledo G. and DiamondCoder1000
; http://nanochess.org/
;
; (c) Copyright 2019-2020 Oscar Toledo G.
;
; Creation date: Jul/19/2019. 10pm to 12am.
; Revision date: Jul/20/2019. 10am to 2pm.
; Added assignment statement. list now
; works. run/goto now works. Added
; system and new.
; Revision date: Jul/22/2019. Boot image now includes 'system'
; statement.
;
;
; USER'S MANUAL:
;
; Line entry is done with keyboard, finish the line with Enter.
; Only 19 characters per line as maximum.
;
; Backspace can be used, don't be fooled by the fact
; that screen isn't deleted (it's all right in the buffer).
;
; All statements must be in lowercase.
;
; Line numbers can be 1 to 999.
;
; 26 variables are available (a-z)
;
; Numbers (0-65535) can be entered and display as unsigned.
;
; To enter new program lines:
; 10 print "Hello all!"
;
; To erase program lines:
; 10
;
; To test statements directly (interactive syntax):
; print "Hello all!"
;
; To erase the current program:
; new
;
; To run the current program:
; run
;
; To list the current program:
; list
;
; To exit to command-line:
; system
;
; Statements:
; var=expr Assign expr value to var (a-z)
;
; print expr Print expression value, new line
; print expr; Print expression value, continue
; print "hello" Print string, new line
; print "hello"; Print string, continue
;
; input var Input value into variable (a-z)
;
; goto expr Goto to indicated line in program
;
; if expr1 goto expr2
; If expr1 is non-zero then go to line,
; else go to following line.
;
; Examples of if:
;
; if c-5 goto 20 If c isn't 5, go to line 20
;
; Expressions:
;
; The operators +, -, / and * are available with
; common precedence rules and signed operation.
; Integer-only arithmetic.
;
; You can also use parentheses:
;
; 5+6*(10/2)
;
; Variables and numbers can be used in expressions.
;
; The rnd function (without arguments) returns a
; value between 0 and 255.
;
; Sample program (counting 1 to 10):
;
; 10 a=1
; 20 print a
; 30 a=a+1
; 40 if a-11 goto 20
;
; Sample program (Pascal's triangle, each number is the sum
; of the two over it):
;
; 10 input n
; 20 i=1
; 30 c=1
; 40 j=0
; 50 t=n-i
; 60 if j-t goto 80
; 70 goto 110
; 80 print " ";
; 90 j=j+1
; 100 goto 50
; 110 k=1
; 120 if k-i-1 goto 140
; 130 goto 190
; 140 print c;
; 150 c=c*(i-k)/k
; 160 print " ";
; 170 k=k+1
; 180 goto 120
; 190 print
; 200 i=i+1
; 210 if i-n-1 goto 30
;
; Sample program of guessing the dice:
;
; 10 print "choose ";
; 20 print "a number ";
; 30 print "(1-6)"
; 40 input a
; 50 b=rnd
; 60 b=b-b/6*6
; 70 b=b+1
; 80 if a-b goto 110
; 90 print "good"
; 100 goto 120
; 110 print "miss"
; 120 print b
;
cpu 8086
%ifndef com_file ; If not defined create a boot sector
com_file: equ 0
%endif
%if com_file
org 0x0100
%else
org 0x7c00
%endif
vars: equ 0x7e00 ; Variables (multiple of 256)
line: equ 0x7e80 ; Line input
program: equ 0x8000 ; Program address
; (notice optimizations dependent on this address)
stack: equ 0xff00 ; Stack address
max_line: equ 1000 ; First unavailable line number
max_length: equ 20 ; Maximum length of line
max_size: equ max_line*max_length ; Max. program size
start:
%if com_file
%else
push cs ; For boot sector
push cs ; it needs to setup
push cs ; DS, ES and SS.
pop ds
pop es
pop ss
%endif
cld ; Clear Direction flag
mov di,program ; Point to program
f14: mov byte [di],0x0d ; Fill with Carriage Return (CR) character
inc di ; Until reaching maximum 64K (DI becomes zero)
jne f14
;
; Main loop
;
main_loop:
mov sp,stack ; Reinitialize stack pointer
mov ax,main_loop
push ax
mov al,'>' ; Show prompt
call input_line ; Accept line
call input_number ; Get number
or ax,ax ; No number or zero?
je statement ; Yes, jump
call find_line ; Find the line
xchg ax,di
; mov cx,max_length ; CX loaded with this value in 'find_line'
rep movsb ; Copy entered line into program
ret
;
; Handle 'if' statement
;
if_statement:
call expr ; Process expression
or ax,ax ; Is it zero?
je f6 ; Yes, return (ignore if)
statement:
call spaces ; Avoid spaces
cmp byte [si],0x0d ; Empty line?
je f6 ; Yes, return
mov di,statements ; Point to statements list
f5: mov al,[di] ; Read length of the string
inc di ; Avoid length byte
cbw ; Make AH zero
dec ax ; Is it zero?
je f4 ; Yes, jump
xchg ax,cx
push si ; Save current position
f16: rep cmpsb ; Compare statement
jne f3 ; Equal? No, jump
pop ax
call spaces ; Avoid spaces
jmp word [di] ; Jump to process statement
f3: add di,cx ; Advance the list pointer
inc di ; Avoid the address
inc di
pop si
jmp f5 ; Compare another statement
f4: call get_variable ; Try variable
push ax ; Save address
lodsb ; Read a line letter
cmp al,'=' ; Is it assignment '=' ?
je assignment ; Yes, jump to assignment.
;
; An error happened
;
error:
mov si,error_message
call print_2 ; Show error message
jmp main_loop ; Exit to main loop
error_message:
db "@#!",0x0d ; Guess the words :P
;
; Handle 'list' statement
;
list_statement:
xor ax,ax ; Start from line zero
f29: push ax
call find_line ; Find program line
xchg ax,si
cmp byte [si],0x0d ; Empty line?
je f30 ; Yes, jump
pop ax
push ax
call output_number ; Show line number
f32: lodsb ; Show line contents
call output
jne f32 ; Jump if it wasn't 0x0d (CR)
f30: pop ax
inc ax ; Go to next line
cmp ax,max_line ; Finished?
jne f29 ; No, continue
f6:
ret
;
; Handle 'input' statement
;
input_statement:
call get_variable ; Get variable address
push ax ; Save it
mov al,'?' ; Prompt
call input_line ; Wait for line
;
; Second part of the assignment statement
;
assignment:
call expr ; Process expression
pop di
stosw ; Save onto variable
ret
;
; Handle an expression.
; First tier: addition & subtraction.
;
expr:
call expr1 ; Call second tier
f20: cmp byte [si],'-' ; Subtraction operator?
je f19 ; Yes, jump
cmp byte [si],'+' ; Addition operator?
jne f6 ; No, return
push ax
call expr1_2 ; Call second tier
f15: pop cx
add ax,cx ; Addition
jmp f20 ; Find more operators
f19:
push ax
call expr1_2 ; Call second tier
neg ax ; Negate it (a - b converted to a + -b)
jmp f15
;
; Handle an expression.
; Second tier: division & multiplication.
;
expr1_2:
inc si ; Avoid operator
expr1:
call expr2 ; Call third tier
f21: cmp byte [si],'/' ; Division operator?
je f23 ; Yes, jump
cmp byte [si],'*' ; Multiplication operator?
jne f6 ; No, return
push ax
call expr2_2 ; Call third tier
pop cx
imul cx ; Multiplication
jmp f21 ; Find more operators
f23:
push ax
call expr2_2 ; Call third tier
pop cx
xchg ax,cx
cwd ; Expand AX to DX:AX
idiv cx ; Signed division
jmp f21 ; Find more operators
;
; Handle an expression.
; Third tier: parentheses, numbers and vars.
;
expr2_2:
inc si ; Avoid operator
expr2:
call spaces ; Jump spaces
lodsb ; Read character
cmp al,'(' ; Open parenthesis?
jne f24
call expr ; Process inner expr.
cmp byte [si],')' ; Closing parenthesis?
je spaces_2 ; Yes, avoid spaces
jmp error ; No, jump to error
f24: cmp al,0x40 ; Variable?
jnc f25 ; Yes, jump
dec si ; Back one letter...
call input_number ; ...to read number
jmp short spaces
f25: cmp al,0x72
jne f22
cmp byte [si],0x6e
jne f22
lodsw ; Advance SI by 2
in al,0x40 ; Read timer counter 0
mov ah,0
ret
f22: call get_variable_2 ; Get variable address
xchg ax,bx
mov ax,[bx] ; Read
ret ; Return
;
; Get variable address.
; Also avoid spaces.
;
get_variable:
lodsb ; Read source
get_variable_2:
and al,0x1f ; 0x61-0x7a -> 0x01-0x1a
add al,al ; x 2 (each variable = word)
mov ah,vars>>8 ; Setup high-byte of address
dec si
;
; Avoid spaces after current character
;
spaces_2:
inc si
;
; Avoid spaces
; The interpreter depends on this routine not modifying AX
;
spaces:
cmp byte [si],' ' ; Space found?
je spaces_2 ; Yes, move one character ahead.
ret ; No, return.
;
; Output unsigned number
; AX = value
;
output_number:
f26:
xor dx,dx ; DX:AX
mov cx,10 ; Divisor = 10
div cx ; Divide
or ax,ax ; Nothing at left?
push dx
je f8 ; No, jump
call f26 ; Yes, output left side
f8: pop ax
add al,'0' ; Output remainder as...
jmp short output ; ...ASCII digit
;
; Read number in input.
; AX = result
;
input_number:
xor bx,bx ; BX = 0
f11: lodsb ; Read source
sub al,'0'
cmp al,10 ; Digit valid?
cbw
xchg ax,bx
jnc f12 ; No, jump
mov cx,10 ; Multiply by 10
mul cx
add bx,ax ; Add new digit
jmp f11 ; Continue
f12: dec si ; SI points to first non-digit
ret
;
; Handle 'system' statement
;
system_statement:
int 0x20
;
; Handle 'goto' statement
;
goto_statement:
call expr ; Handle expression
db 0xb9 ; MOV CX to jump over XOR AX,AX
;
; Handle 'run' statement
; (equivalent to 'goto 0')
;
run_statement:
xor ax,ax
f10:
call find_line ; Find line in program
f27: cmp sp,stack-2 ; In interactive mode?
je f31 ; Yes, jump.
mov [stack-4],ax ; No, replace the saved address of next line
ret
f31:
push ax
pop si
add ax,max_length ; Point to next line
push ax ; Save for next time (this goes into address stack-4)
call statement ; Process current statement
pop ax ; Restore address of next line (could have changed)
cmp ax,program+max_size ; Reached the end?
jne f31 ; No, continue
ret ; Yes, return
;
; Input line from keyboard
; Entry:
; al = prompt character
; Result:
; buffer 'line' contains line, finished with CR
; SI points to 'line'.
;
input_line:
call output
mov si,line
push si
pop di ; Target for writing line
f1: call input_key ; Read keyboard
stosb ; Save key in buffer
cmp al,0x08 ; Backspace?
jne f2 ; No, jump
dec di ; Get back one character
dec di
f2: cmp al,0x0d ; CR pressed?
jne f1 ; No, wait another key
ret ; Yes, return
;
; Handle "print" statement
;
print_statement:
lodsb ; Read source
cmp al,0x0d ; End of line?
je new_line ; Yes, generate new line and return
cmp al,'"' ; Double quotes?
jne f7 ; No, jump
print_2:
f9:
lodsb ; Read string contents
cmp al,'"' ; Double quotes?
je f18 ; Yes, jump
call output ; Output character
cmp al,0x0d ;
jne f9 ; Jump if not finished with 0x0d (CR)
ret ; Return
f7: dec si
call expr ; Handle expression
call output_number ; Output result
f18: lodsb ; Read next character
cmp al,';' ; Is it semicolon?
jne new_line ; No, jump to generate new line
ret ; Yes, return
;
; Read a key into al
; Also outputs it to screen
;
input_key:
mov ah,0x00
int 0x16
;
; Screen output of character contained in al
; Expands 0x0d (CR) into 0x0a 0x0d (LF CR)
;
output:
cmp al,0x0d
jne f17
;
; Go to next line (generates LF+CR)
;
new_line:
mov al,0x0a
call f17
mov al,0x0d
f17:
mov ah,0x0e
mov bx,0x0007
int 0x10
ret
;
; Find line in program
; Entry:
; ax = line number
; Result:
; ax = pointer to program.
; cx = max. length allowed for line.
find_line:
mov cx,max_length
mul cx
add ax,program
ret
;
; List of statements of bootBASIC
; First one byte with length of string
; Then string with statement
; Then a word with the address of the code
;
statements:
db 4,"new"
dw start
db 5,"list"
dw list_statement
db 4,"run"
dw run_statement
db 6,"print"
dw print_statement
db 6,"input"
dw input_statement
db 3,"if"
dw if_statement
db 5,"goto"
dw goto_statement
db 7,"system"
dw system_statement
db 1
;
; Boot sector filler
;
%if com_file
%else
times 510-($-$$) db 0x4f
db 0x55,0xaa ; Make it a bootable sector
%endif
|
/******************************************************************************
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: Implementation of OGRGeoJSONDriver class (OGR GeoJSON Driver).
* Author: Mateusz Loskot, mateusz@loskot.net
*
******************************************************************************
* Copyright (c) 2007, Mateusz Loskot
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#include "cpl_port.h"
#include "ogr_geojson.h"
#include <stdlib.h>
#include <string.h>
#include "cpl_conv.h"
#include "cpl_error.h"
#include "cpl_http.h"
#include "cpl_multiproc.h"
#include "cpl_string.h"
#include "cpl_vsi.h"
// #include "json_object.h"
#include "gdal.h"
#include "gdal_priv.h"
#include "ogr_core.h"
#include "ogr_feature.h"
#include "ogrgeojsonutils.h"
#include "ogrsf_frmts.h"
CPL_CVSID("$Id: ogrgeojsondriver.cpp a965bda62acdb21b5ac3e5291f84cdadcbeb4b05 2018-11-22 12:39:10 +0100 Even Rouault $")
static CPLMutex* ghMutex = nullptr;
static char* gpszSource = nullptr;
static char* gpszText = nullptr;
class OGRESRIFeatureServiceDataset;
/************************************************************************/
/* OGRESRIFeatureServiceLayer */
/************************************************************************/
class OGRESRIFeatureServiceLayer: public OGRLayer
{
OGRESRIFeatureServiceDataset* poDS;
OGRFeatureDefn* poFeatureDefn;
GIntBig nFeaturesRead;
GIntBig nFirstFID;
GIntBig nLastFID;
bool bOtherPage;
bool bUseSequentialFID;
public:
explicit OGRESRIFeatureServiceLayer( OGRESRIFeatureServiceDataset* poDS );
virtual ~OGRESRIFeatureServiceLayer();
void ResetReading() override;
OGRFeature* GetNextFeature() override;
GIntBig GetFeatureCount( int bForce = TRUE ) override;
OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE) override;
virtual OGRErr GetExtent( int iGeomField, OGREnvelope *psExtent,
int bForce) override
{ return OGRLayer::GetExtent(iGeomField, psExtent, bForce); }
int TestCapability( const char* pszCap ) override;
OGRFeatureDefn* GetLayerDefn() override { return poFeatureDefn; }
};
/************************************************************************/
/* OGRESRIFeatureServiceDataset */
/************************************************************************/
class OGRESRIFeatureServiceDataset: public GDALDataset
{
CPLString osURL;
GIntBig nFirstOffset;
GIntBig nLastOffset;
OGRGeoJSONDataSource *poCurrent;
OGRESRIFeatureServiceLayer *poLayer;
int LoadPage();
public:
OGRESRIFeatureServiceDataset( const CPLString &osURL,
OGRGeoJSONDataSource* poFirst );
~OGRESRIFeatureServiceDataset();
int GetLayerCount() override { return 1; }
OGRLayer* GetLayer( int nLayer ) override
{ return (nLayer == 0) ? poLayer : nullptr; }
OGRLayer* GetUnderlyingLayer() { return poCurrent->GetLayer(0); }
int MyResetReading();
int LoadNextPage();
const CPLString& GetURL() { return osURL; }
};
/************************************************************************/
/* OGRESRIFeatureServiceLayer() */
/************************************************************************/
OGRESRIFeatureServiceLayer::OGRESRIFeatureServiceLayer(
OGRESRIFeatureServiceDataset* poDSIn) :
poDS(poDSIn),
nFeaturesRead(0),
nFirstFID(0),
nLastFID(0),
bOtherPage(false),
bUseSequentialFID(false)
{
OGRFeatureDefn* poSrcFeatDefn = poDS->GetUnderlyingLayer()->GetLayerDefn();
poFeatureDefn = new OGRFeatureDefn(poSrcFeatDefn->GetName());
SetDescription(poFeatureDefn->GetName());
poFeatureDefn->Reference();
poFeatureDefn->SetGeomType(wkbNone);
for( int i = 0; i < poSrcFeatDefn->GetFieldCount(); i++ )
poFeatureDefn->AddFieldDefn(poSrcFeatDefn->GetFieldDefn(i));
for( int i = 0; i <poSrcFeatDefn->GetGeomFieldCount(); i++ )
poFeatureDefn->AddGeomFieldDefn(poSrcFeatDefn->GetGeomFieldDefn(i));
}
/************************************************************************/
/* ~OGRESRIFeatureServiceLayer() */
/************************************************************************/
OGRESRIFeatureServiceLayer::~OGRESRIFeatureServiceLayer()
{
poFeatureDefn->Release();
}
/************************************************************************/
/* ResetReading() */
/************************************************************************/
void OGRESRIFeatureServiceLayer::ResetReading()
{
poDS->MyResetReading();
nFeaturesRead = 0;
nLastFID = 0;
bOtherPage = false;
bUseSequentialFID = false;
}
/************************************************************************/
/* GetNextFeature() */
/************************************************************************/
OGRFeature* OGRESRIFeatureServiceLayer::GetNextFeature()
{
while( true )
{
const bool bWasInFirstPage = !bOtherPage;
OGRFeature* poSrcFeat = poDS->GetUnderlyingLayer()->GetNextFeature();
if( poSrcFeat == nullptr )
{
if( !poDS->LoadNextPage() )
return nullptr;
poSrcFeat = poDS->GetUnderlyingLayer()->GetNextFeature();
if( poSrcFeat == nullptr )
return nullptr;
bOtherPage = true;
if( bWasInFirstPage && poSrcFeat->GetFID() != 0 &&
poSrcFeat->GetFID() == nFirstFID )
{
// End-less looping
CPLDebug("ESRIJSON", "Scrolling not working. Stopping");
delete poSrcFeat;
return nullptr;
}
if( bWasInFirstPage && poSrcFeat->GetFID() == 0 &&
nLastFID == nFeaturesRead - 1 )
{
bUseSequentialFID = true;
}
}
if( nFeaturesRead == 0 )
nFirstFID = poSrcFeat->GetFID();
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetFrom(poSrcFeat);
if( bUseSequentialFID )
poFeature->SetFID(nFeaturesRead);
else
poFeature->SetFID(poSrcFeat->GetFID());
nLastFID = poFeature->GetFID();
nFeaturesRead ++;
delete poSrcFeat;
if( (m_poFilterGeom == nullptr
|| FilterGeometry( poFeature->GetGeometryRef() ) )
&& (m_poAttrQuery == nullptr
|| m_poAttrQuery->Evaluate( poFeature )) )
{
return poFeature;
}
delete poFeature;
}
}
/************************************************************************/
/* TestCapability() */
/************************************************************************/
int OGRESRIFeatureServiceLayer::TestCapability( const char* pszCap )
{
if( EQUAL(pszCap, OLCFastFeatureCount) )
return m_poAttrQuery == nullptr && m_poFilterGeom == nullptr;
if( EQUAL(pszCap, OLCFastGetExtent) )
return FALSE;
return poDS->GetUnderlyingLayer()->TestCapability(pszCap);
}
/************************************************************************/
/* GetFeatureCount() */
/************************************************************************/
GIntBig OGRESRIFeatureServiceLayer::GetFeatureCount( int bForce )
{
GIntBig nFeatureCount = -1;
if( m_poAttrQuery == nullptr && m_poFilterGeom == nullptr )
{
const CPLString osNewURL =
CPLURLAddKVP(poDS->GetURL(), "returnCountOnly", "true");
CPLErrorReset();
CPLHTTPResult* pResult = CPLHTTPFetch( osNewURL, nullptr );
if( pResult != nullptr &&
pResult->nDataLen != 0 &&
CPLGetLastErrorNo() == 0 &&
pResult->nStatus == 0 )
{
const char* pszCount =
strstr((const char*)pResult->pabyData, "\"count\"");
if( pszCount )
{
pszCount = strchr(pszCount, ':');
if( pszCount )
{
pszCount++;
nFeatureCount = CPLAtoGIntBig(pszCount);
}
}
}
CPLHTTPDestroyResult( pResult );
}
if( nFeatureCount < 0 )
nFeatureCount = OGRLayer::GetFeatureCount(bForce);
return nFeatureCount;
}
/************************************************************************/
/* GetExtent() */
/************************************************************************/
OGRErr OGRESRIFeatureServiceLayer::GetExtent( OGREnvelope *psExtent,
int bForce )
{
OGRErr eErr = OGRERR_FAILURE;
CPLString osNewURL =
CPLURLAddKVP(poDS->GetURL(), "returnExtentOnly", "true");
osNewURL = CPLURLAddKVP(osNewURL, "f", "geojson");
CPLErrorReset();
CPLHTTPResult* pResult = CPLHTTPFetch( osNewURL, nullptr );
if( pResult != nullptr && pResult->nDataLen != 0 && CPLGetLastErrorNo() == 0 &&
pResult->nStatus == 0 )
{
const char* pszBBox =
strstr((const char*)pResult->pabyData, "\"bbox\"");
if( pszBBox )
{
pszBBox = strstr(pszBBox, ":[");
if( pszBBox )
{
pszBBox += 2;
char** papszTokens = CSLTokenizeString2(pszBBox, ",", 0);
if( CSLCount(papszTokens) >= 4 )
{
psExtent->MinX = CPLAtof(papszTokens[0]);
psExtent->MinY = CPLAtof(papszTokens[1]);
psExtent->MaxX = CPLAtof(papszTokens[2]);
psExtent->MaxY = CPLAtof(papszTokens[3]);
eErr = OGRERR_NONE;
}
CSLDestroy(papszTokens);
}
}
}
CPLHTTPDestroyResult( pResult );
if( eErr == OGRERR_FAILURE )
eErr = OGRLayer::GetExtent(psExtent, bForce);
return eErr;
}
/************************************************************************/
/* OGRESRIFeatureServiceDataset() */
/************************************************************************/
OGRESRIFeatureServiceDataset::OGRESRIFeatureServiceDataset(
const CPLString &osURLIn,
OGRGeoJSONDataSource* poFirst) :
poCurrent(poFirst)
{
poLayer = new OGRESRIFeatureServiceLayer(this);
osURL = osURLIn;
if( CPLURLGetValue(osURL, "resultRecordCount").empty() )
{
// We assume that if the server sets the exceededTransferLimit, the
// and resultRecordCount is not set, the number of features returned
// in our first request is the maximum allowed by the server
// So set it for following requests.
osURL =
CPLURLAddKVP(
this->osURL, "resultRecordCount",
CPLSPrintf(
"%d",
static_cast<int>(poFirst->GetLayer(0)->GetFeatureCount())));
}
else
{
const int nUserSetRecordCount =
atoi(CPLURLGetValue(osURL, "resultRecordCount"));
if( nUserSetRecordCount > poFirst->GetLayer(0)->GetFeatureCount() )
{
CPLError(CE_Warning, CPLE_AppDefined,
"Specificied resultRecordCount=%d is greater than "
"the maximum %d supported by the server",
nUserSetRecordCount,
static_cast<int>(poFirst->GetLayer(0)->GetFeatureCount()));
}
}
nFirstOffset = CPLAtoGIntBig(CPLURLGetValue(osURL, "resultOffset"));
nLastOffset = nFirstOffset;
}
/************************************************************************/
/* ~OGRESRIFeatureServiceDataset() */
/************************************************************************/
OGRESRIFeatureServiceDataset::~OGRESRIFeatureServiceDataset()
{
delete poCurrent;
delete poLayer;
}
/************************************************************************/
/* MyResetReading() */
/************************************************************************/
int OGRESRIFeatureServiceDataset::MyResetReading()
{
if( nLastOffset > nFirstOffset )
{
nLastOffset = nFirstOffset;
return LoadPage();
}
poCurrent->GetLayer(0)->ResetReading();
return TRUE;
}
/************************************************************************/
/* LoadNextPage() */
/************************************************************************/
int OGRESRIFeatureServiceDataset::LoadNextPage()
{
if( !poCurrent->HasOtherPages() )
return FALSE;
nLastOffset += poCurrent->GetLayer(0)->GetFeatureCount();
return LoadPage();
}
/************************************************************************/
/* LoadPage() */
/************************************************************************/
int OGRESRIFeatureServiceDataset::LoadPage()
{
CPLString osNewURL = CPLURLAddKVP(osURL, "resultOffset",
CPLSPrintf(CPL_FRMT_GIB, nLastOffset));
OGRGeoJSONDataSource* poDS = new OGRGeoJSONDataSource();
GDALOpenInfo oOpenInfo(osNewURL, GA_ReadOnly);
GeoJSONSourceType nSrcType;
if( EQUAL(poCurrent->GetJSonFlavor(), "GeoJSON") )
nSrcType = GeoJSONGetSourceType( &oOpenInfo );
else
nSrcType = ESRIJSONDriverGetSourceType( &oOpenInfo );
if( !poDS->Open( &oOpenInfo, nSrcType,
poCurrent->GetJSonFlavor() ) ||
poDS->GetLayerCount() == 0 )
{
delete poDS;
poDS = nullptr;
return FALSE;
}
delete poCurrent;
poCurrent = poDS;
return TRUE;
}
/************************************************************************/
/* OGRGeoJSONDriverIdentify() */
/************************************************************************/
static int OGRGeoJSONDriverIdentifyInternal( GDALOpenInfo* poOpenInfo,
GeoJSONSourceType& nSrcType )
{
/* -------------------------------------------------------------------- */
/* Determine type of data source: text file (.geojson, .json), */
/* Web Service or text passed directly and load data. */
/* -------------------------------------------------------------------- */
nSrcType = GeoJSONGetSourceType( poOpenInfo );
if( nSrcType == eGeoJSONSourceUnknown )
return FALSE;
if( nSrcType == eGeoJSONSourceService &&
!STARTS_WITH_CI(poOpenInfo->pszFilename, "GeoJSON:") )
{
return -1;
}
return TRUE;
}
/************************************************************************/
/* OGRGeoJSONDriverIdentify() */
/************************************************************************/
static int OGRGeoJSONDriverIdentify( GDALOpenInfo* poOpenInfo )
{
GeoJSONSourceType nSrcType;
return OGRGeoJSONDriverIdentifyInternal(poOpenInfo, nSrcType);
}
/************************************************************************/
/* Open() */
/************************************************************************/
static GDALDataset* OGRGeoJSONDriverOpen( GDALOpenInfo* poOpenInfo )
{
GeoJSONSourceType nSrcType;
if( OGRGeoJSONDriverIdentifyInternal(poOpenInfo, nSrcType) == FALSE )
{
return nullptr;
}
return OGRGeoJSONDriverOpenInternal(poOpenInfo, nSrcType, "GeoJSON");
}
/************************************************************************/
/* OGRGeoJSONDriverOpenInternal() */
/************************************************************************/
GDALDataset* OGRGeoJSONDriverOpenInternal( GDALOpenInfo* poOpenInfo,
GeoJSONSourceType nSrcType,
const char* pszJSonFlavor )
{
OGRGeoJSONDataSource* poDS = new OGRGeoJSONDataSource();
/* -------------------------------------------------------------------- */
/* Processing configuration options. */
/* -------------------------------------------------------------------- */
// TODO: Currently, options are based on environment variables.
// This is workaround for not yet implemented Andrey's concept
// described in document 'RFC 10: OGR Open Parameters'.
poDS->SetGeometryTranslation( OGRGeoJSONDataSource::eGeometryPreserve );
const char* pszOpt = CPLGetConfigOption("GEOMETRY_AS_COLLECTION", nullptr);
if( nullptr != pszOpt && STARTS_WITH_CI(pszOpt, "YES") )
{
poDS->SetGeometryTranslation(
OGRGeoJSONDataSource::eGeometryAsCollection );
}
poDS->SetAttributesTranslation( OGRGeoJSONDataSource::eAttributesPreserve );
pszOpt = CPLGetConfigOption("ATTRIBUTES_SKIP", nullptr);
if( nullptr != pszOpt && STARTS_WITH_CI(pszOpt, "YES") )
{
poDS->SetAttributesTranslation(
OGRGeoJSONDataSource::eAttributesSkip );
}
/* -------------------------------------------------------------------- */
/* Open and start processing GeoJSON datasource to OGR objects. */
/* -------------------------------------------------------------------- */
if( !poDS->Open( poOpenInfo, nSrcType, pszJSonFlavor ) )
{
delete poDS;
poDS = nullptr;
}
if( poDS != nullptr && poDS->HasOtherPages() &&
(STARTS_WITH(poOpenInfo->pszFilename, "http") ||
STARTS_WITH(poOpenInfo->pszFilename, "/vsimem/")) )
{
const char* pszFSP = CSLFetchNameValue(poOpenInfo->papszOpenOptions,
"FEATURE_SERVER_PAGING");
const bool bHasResultOffset =
!CPLURLGetValue(poOpenInfo->pszFilename, "resultOffset").empty();
if( (!bHasResultOffset && (pszFSP == nullptr || CPLTestBool(pszFSP))) ||
(bHasResultOffset && pszFSP != nullptr && CPLTestBool(pszFSP)) )
{
return new OGRESRIFeatureServiceDataset(poOpenInfo->pszFilename,
poDS);
}
}
return poDS;
}
/************************************************************************/
/* Create() */
/************************************************************************/
static GDALDataset *OGRGeoJSONDriverCreate( const char * pszName,
int /* nBands */,
int /* nXSize */,
int /* nYSize */,
GDALDataType /* eDT */,
char **papszOptions )
{
OGRGeoJSONDataSource* poDS = new OGRGeoJSONDataSource();
if( !poDS->Create( pszName, papszOptions ) )
{
delete poDS;
poDS = nullptr;
}
return poDS;
}
/************************************************************************/
/* Delete() */
/************************************************************************/
static CPLErr OGRGeoJSONDriverDelete( const char *pszFilename )
{
if( VSIUnlink( pszFilename ) == 0 )
{
return CE_None;
}
CPLDebug( "GeoJSON", "Failed to delete \'%s\'", pszFilename);
return CE_Failure;
}
/************************************************************************/
/* OGRGeoJSONDriverStoreContent() */
/************************************************************************/
void OGRGeoJSONDriverStoreContent( const char* pszSource, char* pszText )
{
CPLMutexHolderD(&ghMutex);
CPLAssert( pszSource );
CPLAssert( pszText );
CPLFree(gpszSource);
CPLFree(gpszText);
gpszSource = CPLStrdup(pszSource);
gpszText = pszText;
}
/************************************************************************/
/* OGRGeoJSONDriverStealStoredContent() */
/************************************************************************/
char* OGRGeoJSONDriverStealStoredContent( const char* pszSource )
{
CPLMutexHolderD(&ghMutex);
if( gpszSource && EQUAL(pszSource, gpszSource) )
{
char* pszRet = gpszText;
CPLFree(gpszSource);
gpszSource = nullptr;
gpszText = nullptr;
return pszRet;
}
return nullptr;
}
/************************************************************************/
/* OGRGeoJSONDriverUnload() */
/************************************************************************/
static void OGRGeoJSONDriverUnload( GDALDriver* )
{
if( ghMutex )
CPLDestroyMutex(ghMutex);
ghMutex = nullptr;
CPLFree(gpszSource);
CPLFree(gpszText);
gpszSource = nullptr;
gpszText = nullptr;
}
/************************************************************************/
/* RegisterOGRGeoJSON() */
/************************************************************************/
void RegisterOGRGeoJSON()
{
if( !GDAL_CHECK_VERSION("OGR/GeoJSON driver") )
return;
if( GDALGetDriverByName( "GeoJSON" ) != nullptr )
return;
GDALDriver *poDriver = new GDALDriver();
poDriver->SetDescription( "GeoJSON" );
poDriver->SetMetadataItem( GDAL_DCAP_VECTOR, "YES" );
poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, "GeoJSON" );
poDriver->SetMetadataItem( GDAL_DMD_EXTENSIONS, "json geojson" );
poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, "drv_geojson.html" );
poDriver->SetMetadataItem( GDAL_DMD_OPENOPTIONLIST,
"<OpenOptionList>"
" <Option name='FLATTEN_NESTED_ATTRIBUTES' type='boolean' description='Whether to recursively explore nested objects and produce flatten OGR attributes' default='NO'/>"
" <Option name='NESTED_ATTRIBUTE_SEPARATOR' type='string' description='Separator between components of nested attributes' default='_'/>"
" <Option name='FEATURE_SERVER_PAGING' type='boolean' description='Whether to automatically scroll through results with a ArcGIS Feature Service endpoint'/>"
" <Option name='NATIVE_DATA' type='boolean' description='Whether to store the native JSon representation at FeatureCollection and Feature level' default='NO'/>"
" <Option name='ARRAY_AS_STRING' type='boolean' description='Whether to expose JSon arrays of strings, integers or reals as a OGR String' default='NO'/>"
"</OpenOptionList>");
poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST,
"<CreationOptionList/>");
poDriver->SetMetadataItem( GDAL_DS_LAYER_CREATIONOPTIONLIST,
"<LayerCreationOptionList>"
" <Option name='WRITE_BBOX' type='boolean' description='whether to write a bbox property with the bounding box of the geometries at the feature and feature collection level' default='NO'/>"
" <Option name='COORDINATE_PRECISION' type='int' description='Number of decimal for coordinates. Default is 15 for GJ2008 and 7 for RFC7946'/>"
" <Option name='SIGNIFICANT_FIGURES' type='int' description='Number of significant figures for floating-point values' default='17'/>"
" <Option name='NATIVE_DATA' type='string' description='FeatureCollection level elements.'/>"
" <Option name='NATIVE_MEDIA_TYPE' type='string' description='Format of NATIVE_DATA. Must be \"application/vnd.geo+json\", otherwise NATIVE_DATA will be ignored.'/>"
" <Option name='RFC7946' type='boolean' description='Whether to use RFC 7946 standard. Otherwise GeoJSON 2008 initial version will be used' default='NO'/>"
" <Option name='WRITE_NAME' type='boolean' description='Whether to write a "name" property at feature collection level with layer name' default='YES'/>"
" <Option name='DESCRIPTION' type='string' description='(Long) description to write in a "description" property at feature collection level'/>"
" <Option name='ID_FIELD' type='string' description='Name of the source field that must be used as the id member of Feature features'/>"
" <Option name='ID_TYPE' type='string-select' description='Type of the id member of Feature features'>"
" <Value>AUTO</Value>"
" <Value>String</Value>"
" <Value>Integer</Value>"
" </Option>"
" <Option name='WRITE_NON_FINITE_VALUES' type='boolean' description='Whether to write NaN / Infinity values' default='NO'/>"
"</LayerCreationOptionList>");
poDriver->SetMetadataItem( GDAL_DCAP_VIRTUALIO, "YES" );
poDriver->SetMetadataItem( GDAL_DMD_CREATIONFIELDDATATYPES,
"Integer Integer64 Real String IntegerList "
"Integer64List RealList StringList" );
poDriver->SetMetadataItem( GDAL_DMD_CREATIONFIELDDATASUBTYPES, "Boolean" );
poDriver->pfnOpen = OGRGeoJSONDriverOpen;
poDriver->pfnIdentify = OGRGeoJSONDriverIdentify;
poDriver->pfnCreate = OGRGeoJSONDriverCreate;
poDriver->pfnDelete = OGRGeoJSONDriverDelete;
poDriver->pfnUnloadDriver = OGRGeoJSONDriverUnload;
GetGDALDriverManager()->RegisterDriver( poDriver );
}
|
/* file: parameter.cpp */
/*******************************************************************************
* Copyright 2014-2017 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>/* Header for class com_intel_daal_algorithms_logitboost_Batch */
#include "daal.h"
#include "logitboost/JParameter.h"
using namespace daal;
using namespace daal::algorithms;
JNIEXPORT void JNICALL Java_com_intel_daal_algorithms_logitboost_Parameter_cSetAccuracyThreshold
(JNIEnv *env, jobject thisObj, jlong parAddr, jdouble acc)
{
(*(logitboost::Parameter *)parAddr).accuracyThreshold = acc;
}
JNIEXPORT jdouble JNICALL Java_com_intel_daal_algorithms_logitboost_Parameter_cGetAccuracyThreshold
(JNIEnv *env, jobject thisObj, jlong parAddr)
{
return(jdouble)(*(logitboost::Parameter *)parAddr).accuracyThreshold;
}
JNIEXPORT void JNICALL Java_com_intel_daal_algorithms_logitboost_Parameter_cSetWeightsThreshold
(JNIEnv *env, jobject thisObj, jlong parAddr, jdouble acc)
{
(*(logitboost::Parameter *)parAddr).weightsDegenerateCasesThreshold = acc;
}
JNIEXPORT jdouble JNICALL Java_com_intel_daal_algorithms_logitboost_Parameter_cGetWeightsThreshold
(JNIEnv *env, jobject thisObj, jlong parAddr)
{
return(jdouble)(*(logitboost::Parameter *)parAddr).weightsDegenerateCasesThreshold;
}
JNIEXPORT void JNICALL Java_com_intel_daal_algorithms_logitboost_Parameter_cSetResponsesThreshold
(JNIEnv *env, jobject thisObj, jlong parAddr, jdouble acc)
{
(*(logitboost::Parameter *)parAddr).responsesDegenerateCasesThreshold = acc;
}
JNIEXPORT jdouble JNICALL Java_com_intel_daal_algorithms_logitboost_Parameter_cGetResponsesThreshold
(JNIEnv *env, jobject thisObj, jlong parAddr)
{
return(jdouble)(*(logitboost::Parameter *)parAddr).responsesDegenerateCasesThreshold;
}
JNIEXPORT void JNICALL Java_com_intel_daal_algorithms_logitboost_Parameter_cSetMaxIterations
(JNIEnv *env, jobject thisObj, jlong parAddr, jlong nIter)
{
(*(logitboost::Parameter *)parAddr).maxIterations = nIter;
}
JNIEXPORT jlong JNICALL Java_com_intel_daal_algorithms_logitboost_Parameter_cGetMaxIterations
(JNIEnv *env, jobject thisObj, jlong parAddr)
{
return(jlong)(*(logitboost::Parameter *)parAddr).maxIterations;
}
JNIEXPORT void JNICALL Java_com_intel_daal_algorithms_logitboost_Parameter_cSetNClasses
(JNIEnv *env, jobject thisObj, jlong parAddr, jlong nIter)
{
(*(logitboost::Parameter *)parAddr).nClasses = nIter;
}
JNIEXPORT jlong JNICALL Java_com_intel_daal_algorithms_logitboost_Parameter_cGetNClasses
(JNIEnv *env, jobject thisObj, jlong parAddr)
{
return(jlong)(*(logitboost::Parameter *)parAddr).nClasses;
}
|
; A073424: Triangle read by rows: T(m,n) = parity of 0^n + 0^m, n = 0,1,2,3 ..., m = 0,1,2,3, ... n.
; 0,1,0,1,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0
mov $1,1
lpb $0
add $1,1
sub $0,$1
lpe
cmp $0,1
|
// Copyright (c) 2012-2017, The CryptoNote developers, The Bytecoin developers
// Copyright (c) 2018, The BBSCoin Developers
// Copyright (c) 2018, The Karbo Developers
// Copyright (c) 2018, The TURTLECOIN Developers
// Copyright (c) 2018, The BitcoinRich Developers
// Please see the included LICENSE file for more information.
#include "TransfersConsumer.h"
#include <numeric>
#include <future>
#include "CommonTypes.h"
#include "Common/BlockingQueue.h"
#include "CryptoNoteCore/CryptoNoteBasicImpl.h"
#include "CryptoNoteCore/CryptoNoteFormatUtils.h"
#include "CryptoNoteCore/TransactionApi.h"
#include "IWallet.h"
#include "INode.h"
#include <future>
using namespace Crypto;
using namespace Logging;
using namespace Common;
std::unordered_set<Crypto::Hash> transactions_hash_seen;
std::unordered_set<Crypto::PublicKey> public_keys_seen;
std::mutex seen_mutex;
namespace {
using namespace CryptoNote;
class MarkTransactionConfirmedException : public std::exception {
public:
MarkTransactionConfirmedException(const Crypto::Hash& txHash) {
}
const Hash& getTxHash() const {
return m_txHash;
}
private:
Crypto::Hash m_txHash;
};
void checkOutputKey(
const KeyDerivation& derivation,
const PublicKey& key,
size_t keyIndex,
size_t outputIndex,
const std::unordered_set<PublicKey>& spendKeys,
std::unordered_map<PublicKey, std::vector<uint32_t>>& outputs) {
PublicKey spendKey;
underive_public_key(derivation, keyIndex, key, spendKey);
if (spendKeys.find(spendKey) != spendKeys.end()) {
outputs[spendKey].push_back(static_cast<uint32_t>(outputIndex));
}
}
void findMyOutputs(
const ITransactionReader& tx,
const SecretKey& viewSecretKey,
const std::unordered_set<PublicKey>& spendKeys,
std::unordered_map<PublicKey, std::vector<uint32_t>>& outputs) {
auto txPublicKey = tx.getTransactionPublicKey();
KeyDerivation derivation;
if (!generate_key_derivation( txPublicKey, viewSecretKey, derivation)) {
return;
}
size_t keyIndex = 0;
size_t outputCount = tx.getOutputCount();
for (size_t idx = 0; idx < outputCount; ++idx) {
auto outType = tx.getOutputType(size_t(idx));
if (outType == TransactionTypes::OutputType::Key) {
uint64_t amount;
KeyOutput out;
tx.getOutput(idx, out, amount);
checkOutputKey(derivation, out.key, keyIndex, idx, spendKeys, outputs);
++keyIndex;
}
}
}
std::vector<Crypto::Hash> getBlockHashes(const CryptoNote::CompleteBlock* blocks, size_t count) {
std::vector<Crypto::Hash> result;
result.reserve(count);
for (size_t i = 0; i < count; ++i) {
result.push_back(blocks[i].blockHash);
}
return result;
}
}
namespace CryptoNote {
TransfersConsumer::TransfersConsumer(const CryptoNote::Currency& currency, INode& node, Logging::ILogger& logger, const SecretKey& viewSecret) :
m_node(node), m_viewSecret(viewSecret), m_currency(currency), m_logger(logger, "TransfersConsumer") {
updateSyncStart();
}
ITransfersSubscription& TransfersConsumer::addSubscription(const AccountSubscription& subscription) {
if (subscription.keys.viewSecretKey != m_viewSecret) {
throw std::runtime_error("TransfersConsumer: view secret key mismatch");
}
auto& res = m_subscriptions[subscription.keys.address.spendPublicKey];
if (res.get() == nullptr) {
res.reset(new TransfersSubscription(m_currency, m_logger.getLogger(), subscription));
m_spendKeys.insert(subscription.keys.address.spendPublicKey);
if (m_subscriptions.size() == 1) {
m_syncStart = res->getSyncStart();
} else {
auto subStart = res->getSyncStart();
m_syncStart.height = std::min(m_syncStart.height, subStart.height);
m_syncStart.timestamp = std::min(m_syncStart.timestamp, subStart.timestamp);
}
}
return *res;
}
bool TransfersConsumer::removeSubscription(const AccountPublicAddress& address) {
m_subscriptions.erase(address.spendPublicKey);
m_spendKeys.erase(address.spendPublicKey);
updateSyncStart();
return m_subscriptions.empty();
}
ITransfersSubscription* TransfersConsumer::getSubscription(const AccountPublicAddress& acc) {
auto it = m_subscriptions.find(acc.spendPublicKey);
return it == m_subscriptions.end() ? nullptr : it->second.get();
}
void TransfersConsumer::getSubscriptions(std::vector<AccountPublicAddress>& subscriptions) {
for (const auto& kv : m_subscriptions) {
subscriptions.push_back(kv.second->getAddress());
}
}
void TransfersConsumer::initTransactionPool(const std::unordered_set<Crypto::Hash>& uncommitedTransactions) {
for (auto itSubscriptions = m_subscriptions.begin(); itSubscriptions != m_subscriptions.end(); ++itSubscriptions) {
std::vector<Crypto::Hash> unconfirmedTransactions;
itSubscriptions->second->getContainer().getUnconfirmedTransactions(unconfirmedTransactions);
for (auto itTransactions = unconfirmedTransactions.begin(); itTransactions != unconfirmedTransactions.end(); ++itTransactions) {
if (uncommitedTransactions.count(*itTransactions) == 0) {
m_poolTxs.emplace(*itTransactions);
}
}
}
}
void TransfersConsumer::updateSyncStart() {
SynchronizationStart start;
start.height = std::numeric_limits<uint64_t>::max();
start.timestamp = std::numeric_limits<uint64_t>::max();
for (const auto& kv : m_subscriptions) {
auto subStart = kv.second->getSyncStart();
start.height = std::min(start.height, subStart.height);
start.timestamp = std::min(start.timestamp, subStart.timestamp);
}
m_syncStart = start;
}
SynchronizationStart TransfersConsumer::getSyncStart() {
return m_syncStart;
}
void TransfersConsumer::onBlockchainDetach(uint32_t height) {
m_observerManager.notify(&IBlockchainConsumerObserver::onBlockchainDetach, this, height);
for (const auto& kv : m_subscriptions) {
kv.second->onBlockchainDetach(height);
}
}
uint32_t TransfersConsumer::onNewBlocks(const CompleteBlock* blocks, uint32_t startHeight, uint32_t count) {
assert(blocks);
assert(count > 0);
struct Tx {
TransactionBlockInfo blockInfo;
const ITransactionReader* tx;
bool isLastTransactionInBlock;
};
struct PreprocessedTx : Tx, PreprocessInfo {};
std::vector<PreprocessedTx> preprocessedTransactions;
std::mutex preprocessedTransactionsMutex;
size_t workers = std::thread::hardware_concurrency();
if (workers == 0) {
workers = 2;
}
BlockingQueue<Tx> inputQueue(workers * 2);
std::atomic<bool> stopProcessing(false);
std::atomic<size_t> emptyBlockCount(0);
auto pushingThread = std::async(std::launch::async, [&] {
for( uint32_t i = 0; i < count && !stopProcessing; ++i) {
const auto& block = blocks[i].block;
if (!block.is_initialized()) {
++emptyBlockCount;
continue;
}
// filter by syncStartTimestamp
if (m_syncStart.timestamp && block->timestamp < m_syncStart.timestamp) {
++emptyBlockCount;
continue;
}
TransactionBlockInfo blockInfo;
blockInfo.height = startHeight + i;
blockInfo.timestamp = block->timestamp;
blockInfo.transactionIndex = 0; // position in block
for (const auto& tx : blocks[i].transactions) {
auto pubKey = tx->getTransactionPublicKey();
if (pubKey == NULL_PUBLIC_KEY) {
++blockInfo.transactionIndex;
continue;
}
bool isLastTransactionInBlock = blockInfo.transactionIndex + 1 == blocks[i].transactions.size();
Tx item = { blockInfo, tx.get(), isLastTransactionInBlock };
inputQueue.push(item);
++blockInfo.transactionIndex;
}
}
inputQueue.close();
});
auto processingFunction = [&] {
Tx item;
std::error_code ec;
while (!stopProcessing && inputQueue.pop(item)) {
PreprocessedTx output;
static_cast<Tx&>(output) = item;
ec = preprocessOutputs(item.blockInfo, *item.tx, output);
if (ec) {
stopProcessing = true;
break;
}
std::lock_guard<std::mutex> lk(preprocessedTransactionsMutex);
preprocessedTransactions.push_back(std::move(output));
}
return ec;
};
std::vector<std::future<std::error_code>> processingThreads;
for (size_t i = 0; i < workers; ++i) {
processingThreads.push_back(std::async(std::launch::async, processingFunction));
}
std::error_code processingError;
for (auto& f : processingThreads) {
try {
std::error_code ec = f.get();
if (!processingError && ec) {
processingError = ec;
}
} catch (const std::system_error& e) {
processingError = e.code();
} catch (const std::exception&) {
processingError = std::make_error_code(std::errc::operation_canceled);
}
}
if (processingError) {
forEachSubscription([&](TransfersSubscription& sub) {
sub.onError(processingError, startHeight);
});
return 0;
}
std::vector<Crypto::Hash> blockHashes = getBlockHashes(blocks, count);
m_observerManager.notify(&IBlockchainConsumerObserver::onBlocksAdded, this, blockHashes);
// sort by block height and transaction index in block
std::sort(preprocessedTransactions.begin(), preprocessedTransactions.end(), [](const PreprocessedTx& a, const PreprocessedTx& b) {
return std::tie(a.blockInfo.height, a.blockInfo.transactionIndex) < std::tie(b.blockInfo.height, b.blockInfo.transactionIndex);
});
uint32_t processedBlockCount = static_cast<uint32_t>(emptyBlockCount);
try {
for (const auto& tx : preprocessedTransactions) {
processTransaction(tx.blockInfo, *tx.tx, tx);
if (tx.isLastTransactionInBlock) {
++processedBlockCount;
m_logger(TRACE) << "Processed block " << processedBlockCount << " of " << count << ", last processed block index " << tx.blockInfo.height <<
", hash " << blocks[processedBlockCount - 1].blockHash;
auto newHeight = startHeight + processedBlockCount - 1;
forEachSubscription([newHeight](TransfersSubscription& sub) {
sub.advanceHeight(newHeight);
});
}
}
} catch (const MarkTransactionConfirmedException& e) {
m_logger(ERROR, BRIGHT_RED) << "Failed to process block transactions: failed to confirm transaction " << e.getTxHash() <<
", remove this transaction from all containers and transaction pool";
forEachSubscription([&e](TransfersSubscription& sub) {
sub.deleteUnconfirmedTransaction(e.getTxHash());
});
m_poolTxs.erase(e.getTxHash());
} catch (std::exception& e) {
m_logger(ERROR, BRIGHT_RED) << "Failed to process block transactions, exception: " << e.what();
} catch (...) {
m_logger(ERROR, BRIGHT_RED) << "Failed to process block transactions, unknown exception";
}
if (processedBlockCount < count) {
uint32_t detachIndex = startHeight + processedBlockCount;
m_logger(ERROR, BRIGHT_RED) << "Not all block transactions are processed, fully processed block count: " << processedBlockCount << " of " << count <<
", last processed block hash " << (processedBlockCount > 0 ? blocks[processedBlockCount - 1].blockHash : NULL_HASH) <<
", detach block index " << detachIndex << " to remove partially processed block";
forEachSubscription([detachIndex](TransfersSubscription& sub) {
sub.onBlockchainDetach(detachIndex);
});
}
return processedBlockCount;
}
std::error_code TransfersConsumer::onPoolUpdated(const std::vector<std::unique_ptr<ITransactionReader>>& addedTransactions, const std::vector<Hash>& deletedTransactions) {
TransactionBlockInfo unconfirmedBlockInfo;
unconfirmedBlockInfo.timestamp = 0;
unconfirmedBlockInfo.height = WALLET_UNCONFIRMED_TRANSACTION_HEIGHT;
std::error_code processingError;
for (auto& cryptonoteTransaction : addedTransactions) {
m_poolTxs.emplace(cryptonoteTransaction->getTransactionHash());
processingError = processTransaction(unconfirmedBlockInfo, *cryptonoteTransaction.get());
if (processingError) {
for (auto& sub : m_subscriptions) {
sub.second->onError(processingError, WALLET_UNCONFIRMED_TRANSACTION_HEIGHT);
}
return processingError;
}
}
for (auto& deletedTxHash : deletedTransactions) {
m_poolTxs.erase(deletedTxHash);
m_observerManager.notify(&IBlockchainConsumerObserver::onTransactionDeleteBegin, this, deletedTxHash);
for (auto& sub : m_subscriptions) {
sub.second->deleteUnconfirmedTransaction(*reinterpret_cast<const Hash*>(&deletedTxHash));
}
m_observerManager.notify(&IBlockchainConsumerObserver::onTransactionDeleteEnd, this, deletedTxHash);
}
return std::error_code();
}
const std::unordered_set<Crypto::Hash>& TransfersConsumer::getKnownPoolTxIds() const {
return m_poolTxs;
}
std::error_code TransfersConsumer::addUnconfirmedTransaction(const ITransactionReader& transaction) {
TransactionBlockInfo unconfirmedBlockInfo;
unconfirmedBlockInfo.height = WALLET_UNCONFIRMED_TRANSACTION_HEIGHT;
unconfirmedBlockInfo.timestamp = 0;
unconfirmedBlockInfo.transactionIndex = 0;
return processTransaction(unconfirmedBlockInfo, transaction);
}
void TransfersConsumer::removeUnconfirmedTransaction(const Crypto::Hash& transactionHash) {
m_observerManager.notify(&IBlockchainConsumerObserver::onTransactionDeleteBegin, this, transactionHash);
for (auto& subscription : m_subscriptions) {
subscription.second->deleteUnconfirmedTransaction(transactionHash);
}
m_observerManager.notify(&IBlockchainConsumerObserver::onTransactionDeleteEnd, this, transactionHash);
}
void TransfersConsumer::addPublicKeysSeen(const Crypto::Hash& transactionHash, const Crypto::PublicKey& outputKey) {
std::lock_guard<std::mutex> lk(seen_mutex);
transactions_hash_seen.insert(transactionHash);
public_keys_seen.insert(outputKey);
}
std::error_code createTransfers(
const AccountKeys& account,
const TransactionBlockInfo& blockInfo,
const ITransactionReader& tx,
const std::vector<uint32_t>& outputs,
const std::vector<uint32_t>& globalIdxs,
std::vector<TransactionOutputInformationIn>& transfers,
Logging::LoggerRef& m_logger)
{
auto txPubKey = tx.getTransactionPublicKey();
std::vector<PublicKey> temp_keys;
std::lock_guard<std::mutex> lk(seen_mutex);
for (auto idx : outputs)
{
bool isDuplicate = false;
if (idx >= tx.getOutputCount())
{
return std::make_error_code(std::errc::argument_out_of_domain);
}
auto outType = tx.getOutputType(size_t(idx));
if (outType != TransactionTypes::OutputType::Key)
{
continue;
}
TransactionOutputInformationIn info;
info.type = outType;
info.transactionPublicKey = txPubKey;
info.outputInTransaction = idx;
info.globalOutputIndex = (blockInfo.height == WALLET_UNCONFIRMED_TRANSACTION_HEIGHT) ?
UNCONFIRMED_TRANSACTION_GLOBAL_OUTPUT_INDEX : globalIdxs[idx];
if (outType == TransactionTypes::OutputType::Key)
{
uint64_t amount;
KeyOutput out;
tx.getOutput(idx, out, amount);
CryptoNote::KeyPair in_ephemeral;
CryptoNote::generate_key_image_helper(
account,
txPubKey,
idx,
in_ephemeral,
info.keyImage);
assert(out.key == reinterpret_cast<const PublicKey&>(in_ephemeral.publicKey));
if (transactions_hash_seen.find(tx.getTransactionHash()) == transactions_hash_seen.end())
{
if (public_keys_seen.find(out.key) != public_keys_seen.end())
{
m_logger(WARNING, BRIGHT_RED) << "A duplicate public key was found in " << Common::podToHex(tx.getTransactionHash());
isDuplicate = true;
}
else
{
temp_keys.push_back(out.key);
}
}
info.amount = amount;
info.outputKey = out.key;
}
if (!isDuplicate)
{
transfers.push_back(info);
}
}
transactions_hash_seen.insert(tx.getTransactionHash());
std::copy(temp_keys.begin(), temp_keys.end(), std::inserter(public_keys_seen, public_keys_seen.end()));
return std::error_code();
}
std::error_code TransfersConsumer::preprocessOutputs(const TransactionBlockInfo& blockInfo, const ITransactionReader& tx, PreprocessInfo& info) {
std::unordered_map<PublicKey, std::vector<uint32_t>> outputs;
try
{
findMyOutputs(tx, m_viewSecret, m_spendKeys, outputs);
}
catch (const std::exception& e)
{
m_logger(WARNING, BRIGHT_RED) << "Failed to process transaction: " << e.what() << ", transaction hash " << Common::podToHex(tx.getTransactionHash());
return std::error_code();
}
if (outputs.empty())
{
return std::error_code();
}
std::error_code errorCode;
auto txHash = tx.getTransactionHash();
if (blockInfo.height != WALLET_UNCONFIRMED_TRANSACTION_HEIGHT)
{
errorCode = getGlobalIndices(reinterpret_cast<const Hash&>(txHash), info.globalIdxs);
if (errorCode)
{
return errorCode;
}
}
for (const auto& kv : outputs) {
auto it = m_subscriptions.find(kv.first);
if (it != m_subscriptions.end()) {
auto& transfers = info.outputs[kv.first];
errorCode = createTransfers(it->second->getKeys(), blockInfo, tx, kv.second, info.globalIdxs, transfers, m_logger);
if (errorCode)
{
return errorCode;
}
}
}
return std::error_code();
}
std::error_code TransfersConsumer::processTransaction(const TransactionBlockInfo& blockInfo, const ITransactionReader& tx) {
PreprocessInfo info;
auto ec = preprocessOutputs(blockInfo, tx, info);
if (ec) {
return ec;
}
processTransaction(blockInfo, tx, info);
return std::error_code();
}
void TransfersConsumer::processTransaction(const TransactionBlockInfo& blockInfo, const ITransactionReader& tx, const PreprocessInfo& info) {
std::vector<TransactionOutputInformationIn> emptyOutputs;
std::vector<ITransfersContainer*> transactionContainers;
m_logger(TRACE) << "Process transaction, block " << blockInfo.height << ", transaction index " << blockInfo.transactionIndex << ", hash " << tx.getTransactionHash();
bool someContainerUpdated = false;
for (auto& kv : m_subscriptions) {
auto it = info.outputs.find(kv.first);
auto& subscriptionOutputs = (it == info.outputs.end()) ? emptyOutputs : it->second;
bool containerContainsTx;
bool containerUpdated;
processOutputs(blockInfo, *kv.second, tx, subscriptionOutputs, info.globalIdxs, containerContainsTx, containerUpdated);
someContainerUpdated = someContainerUpdated || containerUpdated;
if (containerContainsTx) {
transactionContainers.emplace_back(&kv.second->getContainer());
}
}
if (someContainerUpdated) {
m_logger(TRACE) << "Transaction updated some containers, hash " << tx.getTransactionHash();
m_observerManager.notify(&IBlockchainConsumerObserver::onTransactionUpdated, this, tx.getTransactionHash(), transactionContainers);
} else {
m_logger(TRACE) << "Transaction doesn't updated any container, hash " << tx.getTransactionHash();
}
}
void TransfersConsumer::processOutputs(const TransactionBlockInfo& blockInfo, TransfersSubscription& sub, const ITransactionReader& tx,
const std::vector<TransactionOutputInformationIn>& transfers, const std::vector<uint32_t>& globalIdxs, bool& contains, bool& updated) {
TransactionInformation subscribtionTxInfo;
contains = sub.getContainer().getTransactionInformation(tx.getTransactionHash(), subscribtionTxInfo);
updated = false;
if (contains) {
if (subscribtionTxInfo.blockHeight == WALLET_UNCONFIRMED_TRANSACTION_HEIGHT && blockInfo.height != WALLET_UNCONFIRMED_TRANSACTION_HEIGHT) {
try {
// pool->blockchain
sub.markTransactionConfirmed(blockInfo, tx.getTransactionHash(), globalIdxs);
updated = true;
} catch (...) {
m_logger(ERROR, BRIGHT_RED) << "markTransactionConfirmed failed, throw MarkTransactionConfirmedException";
throw MarkTransactionConfirmedException(tx.getTransactionHash());
}
} else {
assert(subscribtionTxInfo.blockHeight == blockInfo.height);
}
} else {
updated = sub.addTransaction(blockInfo, tx, transfers);
contains = updated;
}
}
std::error_code TransfersConsumer::getGlobalIndices(const Hash& transactionHash, std::vector<uint32_t>& outsGlobalIndices) {
std::promise<std::error_code> prom;
std::future<std::error_code> f = prom.get_future();
INode::Callback cb = [&prom](std::error_code ec) {
std::promise<std::error_code> p(std::move(prom));
p.set_value(ec);
};
outsGlobalIndices.clear();
m_node.getTransactionOutsGlobalIndices(transactionHash, outsGlobalIndices, cb);
return f.get();
}
}
|
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.486 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include \masm32\include\windows.inc
include \masm32\macros\macros.asm
; -----------------------------------------------------------------
; include files that have MASM format prototypes for function calls
; -----------------------------------------------------------------
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
; ------------------------------------------------
; Library files that have definitions for function
; exports and tested reliable prebuilt code.
; ------------------------------------------------
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.data
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.code
start:
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
mov eax, hval(input("Please enter an hexadecimal number: "))
mov cl, 16
mov si, 8
print_input:
push eax
print chr$("You have entered: 0x")
pop eax
push eax
print uhex$(eax),13,10
pop eax
step:
push eax
mov eax, ebx
mul ecx
mov ebx, eax
pop eax
div ecx
add ebx, edx
condition:
inc si
jnz step
mov eax, ebx
print_result:
push eax
print chr$("Result: 0x")
pop eax
push eax
print uhex$(eax),13,10
pop eax
exit_prog:
exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start |
BITS 32
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
;TEST_BEGIN_RECORDING
lea edi, [esp-0x10]
mov dword [edi], 0x12345678
mov dword [edi+04], 0x12345678
mov dword [edi+08], 0x00001234
FBLD tword [edi]
mov edi, 0
;TEST_END_RECORDING
|
; A077235: Bisection (odd part) of Chebyshev sequence with Diophantine property.
; 5,16,59,220,821,3064,11435,42676,159269,594400,2218331,8278924,30897365,115310536,430344779,1606068580,5993929541,22369649584,83484668795,311569025596,1162791433589,4339596708760,16195595401451,60442784897044,225575544186725,841859391849856,3141862023212699
mov $1,5
lpb $0,1
sub $0,1
add $2,$1
add $1,$2
add $1,6
add $2,$1
lpe
|
; A186620: Fibonacci sequence beginning 12, 25.
; 12,25,37,62,99,161,260,421,681,1102,1783,2885,4668,7553,12221,19774,31995,51769,83764,135533,219297,354830,574127,928957,1503084,2432041,3935125,6367166,10302291,16669457,26971748,43641205,70612953,114254158
add $0,3
mov $1,6
mov $2,8
lpb $0
sub $0,1
add $2,$1
mov $1,$3
mov $3,$2
sub $2,1
lpe
sub $1,1
mov $0,$1
|
; A181402: Total number of positive integers below 10^n requiring 7 positive cubes in their representation as sum of cubes.
; 1,10,73,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121
lpb $0,1
gcd $1,2
mov $0,$1
lpe
add $1,7
pow $1,$0
div $1,2
mul $1,3
add $1,1
|
; A099166: G.f.: (1+x^2)/((1-2x)(1-x-x^2); a(n)=3a(n-1)-a(n-2)-2a(n-3); a(n)=5*2^n-L(n+3); a(n)=sum{k=0..n, (L(k)-0^k)2^(n-k)}.
; Submitted by Jamie Morken(s2)
; 1,3,9,22,51,113,244,517,1081,2238,4599,9397,19116,38753,78349,158062,318331,640233,1286244,2581837,5178801,10382078,20803759,41671597,83446876,167061513,334394469,669228142,1339166931,2679483713
mov $1,3
mov $2,5
mov $4,1
lpb $0
sub $0,1
mov $3,$2
mul $2,2
add $3,$4
mov $4,$1
add $1,$3
lpe
mov $0,$4
|
%define BPM 100
%include "../src/sointu.inc"
; warning: crashes ahead. Now that the bpm could be changed and even modulated by other
; signals, there is no easy way to figure out how many ticks your song is. Either
; allocate some extra memory of the output just in case or simulate exactly how many
; samples are outputted. Here the triplets are slightly faster than the original so
; they fit the default MAX_TICKS that is calculated using the simple bpm assumption.
BEGIN_PATTERNS
PATTERN 64, 0, 64, 64, 64, 0, 64, 64, 64, 0, 64, 64, 65, 0, 65, 65,
PATTERN 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ; 4-rows
PATTERN 78, 0, 54, 0, 78, 0, 54, 0, 78, 0, 54, 0, 78, 0, 54, 0, ; triplets
END_PATTERNS
BEGIN_TRACKS
TRACK VOICES(1),0,0
TRACK VOICES(1),1,2
END_TRACKS
BEGIN_PATCH
BEGIN_INSTRUMENT VOICES(1) ; Instrument0
SU_ENVELOPE MONO,ATTAC(64),DECAY(64),SUSTAIN(0),RELEASE(64),GAIN(128)
SU_ENVELOPE MONO,ATTAC(64),DECAY(64),SUSTAIN(0),RELEASE(64),GAIN(128)
SU_OSCILLAT MONO,TRANSPOSE(64),DETUNE(32),PHASE(0),COLOR(96),SHAPE(64),GAIN(128), FLAGS(TRISAW)
SU_OSCILLAT MONO,TRANSPOSE(72),DETUNE(64),PHASE(64),COLOR(64),SHAPE(96),GAIN(128), FLAGS(TRISAW)
SU_MULP STEREO
SU_OUT STEREO,GAIN(128)
END_INSTRUMENT
BEGIN_INSTRUMENT VOICES(1) ; Speed changer
SU_LOADNOTE MONO
SU_SPEED
END_INSTRUMENT
END_PATCH
%include "../src/sointu.asm"
|
/*------------------------------------------------------------------------
* Vulkan Conformance Tests
* ------------------------
*
* Copyright (c) 2019 The Khronos Group Inc.
* Copyright (c) 2019 Google Inc.
* Copyright (c) 2017 Codeplay Software Ltd.
*
* 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.
*
*/ /*!
* \file
* \brief Subgroups Tests
*/ /*--------------------------------------------------------------------*/
#include "vktSubgroupsShapeTests.hpp"
#include "vktSubgroupsTestsUtils.hpp"
#include <string>
#include <vector>
using namespace tcu;
using namespace std;
using namespace vk;
using namespace vkt;
namespace
{
static bool checkVertexPipelineStages(std::vector<const void*> datas,
deUint32 width, deUint32)
{
return vkt::subgroups::check(datas, width, 1);
}
static bool checkCompute(std::vector<const void*> datas,
const deUint32 numWorkgroups[3], const deUint32 localSize[3],
deUint32)
{
return vkt::subgroups::checkCompute(datas, numWorkgroups, localSize, 1);
}
enum OpType
{
OPTYPE_CLUSTERED = 0,
OPTYPE_QUAD,
OPTYPE_LAST
};
std::string getOpTypeName(int opType)
{
switch (opType)
{
default:
DE_FATAL("Unsupported op type");
return "";
case OPTYPE_CLUSTERED:
return "clustered";
case OPTYPE_QUAD:
return "quad";
}
}
struct CaseDefinition
{
int opType;
VkShaderStageFlags shaderStage;
de::SharedPtr<bool> geometryPointSizeSupported;
};
void initFrameBufferPrograms (SourceCollections& programCollection, CaseDefinition caseDef)
{
const vk::ShaderBuildOptions buildOptions (programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_3, 0u);
std::ostringstream bdy;
std::string extension = (OPTYPE_CLUSTERED == caseDef.opType) ?
"#extension GL_KHR_shader_subgroup_clustered: enable\n" :
"#extension GL_KHR_shader_subgroup_quad: enable\n";
subgroups::setFragmentShaderFrameBuffer(programCollection);
if (VK_SHADER_STAGE_VERTEX_BIT != caseDef.shaderStage)
subgroups::setVertexShaderFrameBuffer(programCollection);
extension += "#extension GL_KHR_shader_subgroup_ballot: enable\n";
bdy << " uint tempResult = 0x1;\n"
<< " uvec4 mask = subgroupBallot(true);\n";
if (OPTYPE_CLUSTERED == caseDef.opType)
{
for (deUint32 i = 1; i <= subgroups::maxSupportedSubgroupSize(); i *= 2)
{
bdy << " if (gl_SubgroupSize >= " << i << ")\n"
<< " {\n"
<< " uvec4 contribution = uvec4(0);\n"
<< " const uint modID = gl_SubgroupInvocationID % 32;\n"
<< " switch (gl_SubgroupInvocationID / 32)\n"
<< " {\n"
<< " case 0: contribution.x = 1 << modID; break;\n"
<< " case 1: contribution.y = 1 << modID; break;\n"
<< " case 2: contribution.z = 1 << modID; break;\n"
<< " case 3: contribution.w = 1 << modID; break;\n"
<< " }\n"
<< " uvec4 result = subgroupClusteredOr(contribution, " << i << ");\n"
<< " uint rootID = gl_SubgroupInvocationID & ~(" << i - 1 << ");\n"
<< " for (uint i = 0; i < " << i << "; i++)\n"
<< " {\n"
<< " uint nextID = rootID + i;\n"
<< " if (subgroupBallotBitExtract(mask, nextID) ^^ subgroupBallotBitExtract(result, nextID))\n"
<< " {\n"
<< " tempResult = 0;\n"
<< " }\n"
<< " }\n"
<< " }\n";
}
}
else
{
bdy << " uint cluster[4] =\n"
<< " {\n"
<< " subgroupQuadBroadcast(gl_SubgroupInvocationID, 0),\n"
<< " subgroupQuadBroadcast(gl_SubgroupInvocationID, 1),\n"
<< " subgroupQuadBroadcast(gl_SubgroupInvocationID, 2),\n"
<< " subgroupQuadBroadcast(gl_SubgroupInvocationID, 3)\n"
<< " };\n"
<< " uint rootID = gl_SubgroupInvocationID & ~0x3;\n"
<< " for (uint i = 0; i < 4; i++)\n"
<< " {\n"
<< " uint nextID = rootID + i;\n"
<< " if (subgroupBallotBitExtract(mask, nextID) && (cluster[i] != nextID))\n"
<< " {\n"
<< " tempResult = mask.x;\n"
<< " }\n"
<< " }\n";
}
if (VK_SHADER_STAGE_VERTEX_BIT == caseDef.shaderStage)
{
std::ostringstream vertexSrc;
vertexSrc << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
<< extension
<< "layout(location = 0) in highp vec4 in_position;\n"
<< "layout(location = 0) out float result;\n"
<< "\n"
<< "void main (void)\n"
<< "{\n"
<< bdy.str()
<< " result = float(tempResult);\n"
<< " gl_Position = in_position;\n"
<< " gl_PointSize = 1.0f;\n"
<< "}\n";
programCollection.glslSources.add("vert")
<< glu::VertexSource(vertexSrc.str()) << buildOptions;
}
else if (VK_SHADER_STAGE_GEOMETRY_BIT == caseDef.shaderStage)
{
std::ostringstream geometry;
geometry << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
<< extension
<< "layout(points) in;\n"
<< "layout(points, max_vertices = 1) out;\n"
<< "layout(location = 0) out float out_color;\n"
<< "\n"
<< "void main (void)\n"
<< "{\n"
<< bdy.str()
<< " out_color = float(tempResult);\n"
<< " gl_Position = gl_in[0].gl_Position;\n"
<< (*caseDef.geometryPointSizeSupported ? " gl_PointSize = gl_in[0].gl_PointSize;\n" : "")
<< " EmitVertex();\n"
<< " EndPrimitive();\n"
<< "}\n";
programCollection.glslSources.add("geometry")
<< glu::GeometrySource(geometry.str()) << buildOptions;
}
else if (VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT == caseDef.shaderStage)
{
std::ostringstream controlSource;
controlSource << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
<< extension
<< "layout(vertices = 2) out;\n"
<< "layout(location = 0) out float out_color[];\n"
<< "\n"
<< "void main (void)\n"
<< "{\n"
<< " if (gl_InvocationID == 0)\n"
<<" {\n"
<< " gl_TessLevelOuter[0] = 1.0f;\n"
<< " gl_TessLevelOuter[1] = 1.0f;\n"
<< " }\n"
<< bdy.str()
<< " out_color[gl_InvocationID] = float(tempResult);\n"
<< " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
<< "}\n";
programCollection.glslSources.add("tesc")
<< glu::TessellationControlSource(controlSource.str()) << buildOptions;
subgroups::setTesEvalShaderFrameBuffer(programCollection);
}
else if (VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT == caseDef.shaderStage)
{
std::ostringstream evaluationSource;
evaluationSource << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
<< extension
<< "layout(isolines, equal_spacing, ccw ) in;\n"
<< "layout(location = 0) out float out_color;\n"
<< "void main (void)\n"
<< "{\n"
<< bdy.str()
<< " out_color = float(tempResult);\n"
<< " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n"
<< "}\n";
subgroups::setTesCtrlShaderFrameBuffer(programCollection);
programCollection.glslSources.add("tese")
<< glu::TessellationEvaluationSource(evaluationSource.str()) << buildOptions;
}
else
{
DE_FATAL("Unsupported shader stage");
}
}
void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
{
std::string extension = (OPTYPE_CLUSTERED == caseDef.opType) ?
"#extension GL_KHR_shader_subgroup_clustered: enable\n" :
"#extension GL_KHR_shader_subgroup_quad: enable\n";
extension += "#extension GL_KHR_shader_subgroup_ballot: enable\n";
std::ostringstream bdy;
bdy << " uint tempResult = 0x1;\n"
<< " uvec4 mask = subgroupBallot(true);\n";
if (OPTYPE_CLUSTERED == caseDef.opType)
{
for (deUint32 i = 1; i <= subgroups::maxSupportedSubgroupSize(); i *= 2)
{
bdy << " if (gl_SubgroupSize >= " << i << ")\n"
<< " {\n"
<< " uvec4 contribution = uvec4(0);\n"
<< " const uint modID = gl_SubgroupInvocationID % 32;\n"
<< " switch (gl_SubgroupInvocationID / 32)\n"
<< " {\n"
<< " case 0: contribution.x = 1 << modID; break;\n"
<< " case 1: contribution.y = 1 << modID; break;\n"
<< " case 2: contribution.z = 1 << modID; break;\n"
<< " case 3: contribution.w = 1 << modID; break;\n"
<< " }\n"
<< " uvec4 result = subgroupClusteredOr(contribution, " << i << ");\n"
<< " uint rootID = gl_SubgroupInvocationID & ~(" << i - 1 << ");\n"
<< " for (uint i = 0; i < " << i << "; i++)\n"
<< " {\n"
<< " uint nextID = rootID + i;\n"
<< " if (subgroupBallotBitExtract(mask, nextID) ^^ subgroupBallotBitExtract(result, nextID))\n"
<< " {\n"
<< " tempResult = 0;\n"
<< " }\n"
<< " }\n"
<< " }\n";
}
}
else
{
bdy << " uint cluster[4] =\n"
<< " {\n"
<< " subgroupQuadBroadcast(gl_SubgroupInvocationID, 0),\n"
<< " subgroupQuadBroadcast(gl_SubgroupInvocationID, 1),\n"
<< " subgroupQuadBroadcast(gl_SubgroupInvocationID, 2),\n"
<< " subgroupQuadBroadcast(gl_SubgroupInvocationID, 3)\n"
<< " };\n"
<< " uint rootID = gl_SubgroupInvocationID & ~0x3;\n"
<< " for (uint i = 0; i < 4; i++)\n"
<< " {\n"
<< " uint nextID = rootID + i;\n"
<< " if (subgroupBallotBitExtract(mask, nextID) && (cluster[i] != nextID))\n"
<< " {\n"
<< " tempResult = mask.x;\n"
<< " }\n"
<< " }\n";
}
if (VK_SHADER_STAGE_COMPUTE_BIT == caseDef.shaderStage)
{
std::ostringstream src;
src << "#version 450\n"
<< extension
<< "layout (local_size_x_id = 0, local_size_y_id = 1, "
"local_size_z_id = 2) in;\n"
<< "layout(set = 0, binding = 0, std430) buffer Buffer1\n"
<< "{\n"
<< " uint result[];\n"
<< "};\n"
<< "\n"
<< "void main (void)\n"
<< "{\n"
<< " uvec3 globalSize = gl_NumWorkGroups * gl_WorkGroupSize;\n"
<< " highp uint offset = globalSize.x * ((globalSize.y * "
"gl_GlobalInvocationID.z) + gl_GlobalInvocationID.y) + "
"gl_GlobalInvocationID.x;\n"
<< bdy.str()
<< " result[offset] = tempResult;\n"
<< "}\n";
programCollection.glslSources.add("comp")
<< glu::ComputeSource(src.str()) << vk::ShaderBuildOptions(programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_3, 0u);
}
else
{
{
const string vertex =
"#version 450\n"
+ extension +
"layout(set = 0, binding = 0, std430) buffer Buffer1\n"
"{\n"
" uint result[];\n"
"};\n"
"\n"
"void main (void)\n"
"{\n"
+ bdy.str() +
" result[gl_VertexIndex] = tempResult;\n"
" float pixelSize = 2.0f/1024.0f;\n"
" float pixelPosition = pixelSize/2.0f - 1.0f;\n"
" gl_Position = vec4(float(gl_VertexIndex) * pixelSize + pixelPosition, 0.0f, 0.0f, 1.0f);\n"
" gl_PointSize = 1.0f;\n"
"}\n";
programCollection.glslSources.add("vert")
<< glu::VertexSource(vertex) << vk::ShaderBuildOptions(programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_3, 0u);
}
{
const string tesc =
"#version 450\n"
+ extension +
"layout(vertices=1) out;\n"
"layout(set = 0, binding = 1, std430) buffer Buffer1\n"
"{\n"
" uint result[];\n"
"};\n"
"\n"
"void main (void)\n"
"{\n"
+ bdy.str() +
" result[gl_PrimitiveID] = 1;\n"
" if (gl_InvocationID == 0)\n"
" {\n"
" gl_TessLevelOuter[0] = 1.0f;\n"
" gl_TessLevelOuter[1] = 1.0f;\n"
" }\n"
" gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
"}\n";
programCollection.glslSources.add("tesc")
<< glu::TessellationControlSource(tesc) << vk::ShaderBuildOptions(programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_3, 0u);
}
{
const string tese =
"#version 450\n"
+ extension +
"layout(isolines) in;\n"
"layout(set = 0, binding = 2, std430) buffer Buffer1\n"
"{\n"
" uint result[];\n"
"};\n"
"\n"
"void main (void)\n"
"{\n"
+ bdy.str() +
" result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = 1;\n"
" float pixelSize = 2.0f/1024.0f;\n"
" gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n"
"}\n";
programCollection.glslSources.add("tese")
<< glu::TessellationEvaluationSource(tese) << vk::ShaderBuildOptions(programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_3, 0u);
}
{
const string geometry =
"#version 450\n"
+ extension +
"layout(${TOPOLOGY}) in;\n"
"layout(points, max_vertices = 1) out;\n"
"layout(set = 0, binding = 3, std430) buffer Buffer1\n"
"{\n"
" uint result[];\n"
"};\n"
"\n"
"void main (void)\n"
"{\n"
+ bdy.str() +
" result[gl_PrimitiveIDIn] = tempResult;\n"
" gl_Position = gl_in[0].gl_Position;\n"
" EmitVertex();\n"
" EndPrimitive();\n"
"}\n";
subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_3, 0u),
programCollection.glslSources);
}
{
const string fragment =
"#version 450\n"
+ extension +
"layout(location = 0) out uint result;\n"
"void main (void)\n"
"{\n"
+ bdy.str() +
" result = tempResult;\n"
"}\n";
programCollection.glslSources.add("fragment")
<< glu::FragmentSource(fragment)<< vk::ShaderBuildOptions(programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_3, 0u);
}
subgroups::addNoSubgroupShader(programCollection);
}
}
void supportedCheck (Context& context, CaseDefinition caseDef)
{
if (!subgroups::isSubgroupSupported(context))
TCU_THROW(NotSupportedError, "Subgroup operations are not supported");
if (!subgroups::isSubgroupFeatureSupportedForDevice(context, VK_SUBGROUP_FEATURE_BALLOT_BIT))
{
TCU_THROW(NotSupportedError, "Device does not support subgroup ballot operations");
}
if (OPTYPE_CLUSTERED == caseDef.opType)
{
if (!subgroups::isSubgroupFeatureSupportedForDevice(context, VK_SUBGROUP_FEATURE_CLUSTERED_BIT))
{
TCU_THROW(NotSupportedError, "Subgroup shape tests require that clustered operations are supported!");
}
}
if (OPTYPE_QUAD == caseDef.opType)
{
if (!subgroups::isSubgroupFeatureSupportedForDevice(context, VK_SUBGROUP_FEATURE_QUAD_BIT))
{
TCU_THROW(NotSupportedError, "Subgroup shape tests require that quad operations are supported!");
}
}
*caseDef.geometryPointSizeSupported = subgroups::isTessellationAndGeometryPointSizeSupported(context);
}
tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef)
{
if (!subgroups::areSubgroupOperationsSupportedForStage(
context, caseDef.shaderStage))
{
if (subgroups::areSubgroupOperationsRequiredForStage(
caseDef.shaderStage))
{
return tcu::TestStatus::fail(
"Shader stage " +
subgroups::getShaderStageName(caseDef.shaderStage) +
" is required to support subgroup operations!");
}
else
{
TCU_THROW(NotSupportedError, "Device does not support subgroup operations for this stage");
}
}
if (VK_SHADER_STAGE_VERTEX_BIT == caseDef.shaderStage)
return subgroups::makeVertexFrameBufferTest(context, VK_FORMAT_R32_UINT, DE_NULL, 0, checkVertexPipelineStages);
else if (VK_SHADER_STAGE_GEOMETRY_BIT == caseDef.shaderStage)
return subgroups::makeGeometryFrameBufferTest(context, VK_FORMAT_R32_UINT, DE_NULL, 0, checkVertexPipelineStages);
else if (VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT == caseDef.shaderStage)
return subgroups::makeTessellationEvaluationFrameBufferTest(context, VK_FORMAT_R32_UINT, DE_NULL, 0, checkVertexPipelineStages, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
else if (VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT == caseDef.shaderStage)
return subgroups::makeTessellationEvaluationFrameBufferTest(context, VK_FORMAT_R32_UINT, DE_NULL, 0, checkVertexPipelineStages, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
else
TCU_THROW(InternalError, "Unhandled shader stage");
}
tcu::TestStatus test(Context& context, const CaseDefinition caseDef)
{
if (!subgroups::isSubgroupFeatureSupportedForDevice(context, VK_SUBGROUP_FEATURE_BASIC_BIT))
{
return tcu::TestStatus::fail(
"Subgroup feature " +
subgroups::getShaderStageName(VK_SUBGROUP_FEATURE_BASIC_BIT) +
" is a required capability!");
}
if (VK_SHADER_STAGE_COMPUTE_BIT == caseDef.shaderStage)
{
if (!subgroups::areSubgroupOperationsSupportedForStage(context, caseDef.shaderStage))
{
return tcu::TestStatus::fail(
"Shader stage " +
subgroups::getShaderStageName(caseDef.shaderStage) +
" is required to support subgroup operations!");
}
return subgroups::makeComputeTest(context, VK_FORMAT_R32_UINT, DE_NULL, 0, checkCompute);
}
else
{
VkPhysicalDeviceSubgroupProperties subgroupProperties;
subgroupProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES;
subgroupProperties.pNext = DE_NULL;
VkPhysicalDeviceProperties2 properties;
properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
properties.pNext = &subgroupProperties;
context.getInstanceInterface().getPhysicalDeviceProperties2(context.getPhysicalDevice(), &properties);
VkShaderStageFlagBits stages = (VkShaderStageFlagBits)(caseDef.shaderStage & subgroupProperties.supportedStages);
if (VK_SHADER_STAGE_FRAGMENT_BIT != stages && !subgroups::isVertexSSBOSupportedForDevice(context))
{
if ( (stages & VK_SHADER_STAGE_FRAGMENT_BIT) == 0)
TCU_THROW(NotSupportedError, "Device does not support vertex stage SSBO writes");
else
stages = VK_SHADER_STAGE_FRAGMENT_BIT;
}
if ((VkShaderStageFlagBits)0u == stages)
TCU_THROW(NotSupportedError, "Subgroup operations are not supported for any graphic shader");
return subgroups::allStages(context, VK_FORMAT_R32_UINT, DE_NULL, 0, checkVertexPipelineStages, stages);
}
}
}
namespace vkt
{
namespace subgroups
{
tcu::TestCaseGroup* createSubgroupsShapeTests(tcu::TestContext& testCtx)
{
de::MovePtr<tcu::TestCaseGroup> graphicGroup(new tcu::TestCaseGroup(
testCtx, "graphics", "Subgroup shape category tests: graphics"));
de::MovePtr<tcu::TestCaseGroup> computeGroup(new tcu::TestCaseGroup(
testCtx, "compute", "Subgroup shape category tests: compute"));
de::MovePtr<tcu::TestCaseGroup> framebufferGroup(new tcu::TestCaseGroup(
testCtx, "framebuffer", "Subgroup shape category tests: framebuffer"));
const VkShaderStageFlags stages[] =
{
VK_SHADER_STAGE_VERTEX_BIT,
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
VK_SHADER_STAGE_GEOMETRY_BIT,
};
for (int opTypeIndex = 0; opTypeIndex < OPTYPE_LAST; ++opTypeIndex)
{
const std::string op = de::toLower(getOpTypeName(opTypeIndex));
{
const CaseDefinition caseDef = {opTypeIndex, VK_SHADER_STAGE_COMPUTE_BIT, de::SharedPtr<bool>(new bool)};
addFunctionCaseWithPrograms(computeGroup.get(), op, "", supportedCheck, initPrograms, test, caseDef);
}
{
const CaseDefinition caseDef =
{
opTypeIndex,
VK_SHADER_STAGE_ALL_GRAPHICS,
de::SharedPtr<bool>(new bool)
};
addFunctionCaseWithPrograms(graphicGroup.get(),
op, "",
supportedCheck, initPrograms, test, caseDef);
}
for (int stageIndex = 0; stageIndex < DE_LENGTH_OF_ARRAY(stages); ++stageIndex)
{
const CaseDefinition caseDef = {opTypeIndex, stages[stageIndex], de::SharedPtr<bool>(new bool)};
addFunctionCaseWithPrograms(framebufferGroup.get(),op + "_" + getShaderStageName(caseDef.shaderStage), "",
supportedCheck, initFrameBufferPrograms, noSSBOtest, caseDef);
}
}
de::MovePtr<tcu::TestCaseGroup> group(new tcu::TestCaseGroup(
testCtx, "shape", "Subgroup shape category tests"));
group->addChild(graphicGroup.release());
group->addChild(computeGroup.release());
group->addChild(framebufferGroup.release());
return group.release();
}
} // subgroups
} // vkt
|
;program to swap the contents of R7 and R6 residing in bank 0
org 0000h
xch a,r6 ;data in r6 excahnged with accumulator
xch a,r7 ;data in r7 excahnged with accumulator
xch a,r6 ;data in r6 excahnged with accumulator
end |
leaw $1, %A
movw $1, (%A) ; guarda f em R1
FAT:
COMECO: ; salva os dois valores a serem multiplicados, um em um registrador e outro em uma RAM
leaw $1, %A
movw (%A), %S
leaw $0, %A
movw (%A), %D
leaw $7, %A
movw %D, (%A)
leaw $ZERO, %A
decw %S
je %S ;checa se um dos numeros é 0, se for ja salva 0 na ram 3
nop
je %D
nop
MEIO: ; soma um dos valores o número de vezes do segundo valor
nop
leaw $7, %A
movw (%A), %A
addw %D, %A, %D
leaw %3, %A
movw %D, (%A)
decw %S
leaw %MEIO, %A
jg %S
nop
leaw %FIM, %A
je %S
nop
ZERO: ; salva 0 na ram
leaw $3, %A
leaw $0, (%A)
nop
FIM:
nop
leaw $3, %A
movw (%A), %S
leaw $1, %A
movw %S, (%A) ;Atualiza f
leaw $0, %A
decw (%A) ; n-1
movw (%A), %D
leaw %FAT, %A
jne %D
nop
|
; A137508: Successive structures of alkaline earth metals (periodic table elements from 2nd column).
; 2,2,2,8,2,2,8,8,2,2,8,18,8,2,2,8,18,18,8,2,2,8,18,32,18,8,2
add $0,1
seq $0,157454 ; Triangle read by rows: T(n, m) = min(2*m - 1, 2*(n - m) + 1).
div $0,2
add $0,1
pow $0,2
mul $0,2
|
RestoreScreenTilesAndReloadTilePatterns::
call ClearSprites
ld a, $1
ld [wUpdateSpritesEnabled], a
call ReloadMapSpriteTilePatterns
call LoadScreenTilesFromBuffer2
call LoadTextBoxTilePatterns
call RunDefaultPaletteCommand
jr Delay3
GBPalWhiteOutWithDelay3::
call GBPalWhiteOut
Delay3::
; The bg map is updated each frame in thirds.
; Wait three frames to let the bg map fully update.
ld c, 3
jp DelayFrames
GBPalNormal::
; Reset BGP and OBP0.
ld a, %11100100 ; 3210
ldh [rBGP], a
ld a, %11010000 ; 3100
ldh [rOBP0], a
ret
GBPalWhiteOut::
; White out all palettes.
xor a
ldh [rBGP], a
ldh [rOBP0], a
ldh [rOBP1], a
ret
RunDefaultPaletteCommand::
ld b, SET_PAL_DEFAULT
RunPaletteCommand::
ld a, [wOnSGB]
and a
ret z
predef_jump _RunPaletteCommand
GetHealthBarColor::
; Return at hl the palette of
; an HP bar e pixels long.
ld a, e
cp 27
ld d, 0 ; green
jr nc, .gotColor
cp 10
inc d ; yellow
jr nc, .gotColor
inc d ; red
.gotColor
ld [hl], d
ret
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.