text stringlengths 1 1.05M |
|---|
; float __fsadd_callee (float left, float right)
SECTION code_clib
SECTION code_fp_math32
PUBLIC cm32_sccz80_fsadd_callee
EXTERN m32_fsadd_callee
; add two sccz80 floats
;
; enter : stack = sccz80_float left, ret
; DEHL = sccz80_float right
;
; exit : DEHL = sccz80_float(left+right)
;
; uses : af, bc, de, hl, af', bc', de', hl'
defc cm32_sccz80_fsadd_callee = m32_fsadd_callee
; enter stack = sccz80_float left, ret
; DEHL = sccz80_float right
; return DEHL = sccz80_float
|
; namespace DebugStub
; var DebugWaitMsg = 'Waiting for debugger connection...'
DebugStub_DebugWaitMsg:
db 87, 97, 105, 116, 105, 110, 103, 32, 102, 111, 114, 32, 100, 101, 98, 117, 103, 103, 101, 114, 32, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 46, 46, 46
; //! %ifndef Exclude_Memory_Based_Console
%ifndef Exclude_Memory_Based_Console
; const VidBase = $B8000
DebugStub_Const_VidBase equ 753664
; function Cls {
DebugStub_Cls:
; ESI = #VidBase
Mov ESI, DebugStub_Const_VidBase
; End of Video Area
; VidBase + 25 * 80 * 2 = B8FA0
; while ESI < $B8FA0 {
; Text
; [ESI] = $00
Mov DWORD [ESI], 0x0
; ESI++
Inc ESI
; Colour
; [ESI] = $0A
Mov DWORD [ESI], 0xA
; ESI++
Inc ESI
; }
DebugStub_Cls_Block1_End:
; }
DebugStub_Cls_Exit:
Mov DWORD [INTS_LastKnownAddress], DebugStub_Cls_Exit
Ret
; function DisplayWaitMsg {
DebugStub_DisplayWaitMsg:
; ESI = @.DebugWaitMsg
Mov ESI, DebugStub_DebugWaitMsg
; EDI = #VidBase
Mov EDI, DebugStub_Const_VidBase
; 10 lines down, 20 cols in (10 * 80 + 20) * 2)
; EDI += 1640
Add EDI, 0x668
; Read and copy string till 0 terminator
; while byte [ESI] != 0 {
; AL = [ESI]
Mov AL, BYTE [ESI]
; [EDI] = AL
Mov BYTE [EDI], AL
; ESI++
Inc ESI
; EDI += 2
Add EDI, 0x2
; }
DebugStub_DisplayWaitMsg_Block1_End:
; }
DebugStub_DisplayWaitMsg_Exit:
Mov DWORD [INTS_LastKnownAddress], DebugStub_DisplayWaitMsg_Exit
Ret
; //! %endif
%endif
|
#ifndef STAN_MATH_PRIM_FUN_FFT_HPP
#define STAN_MATH_PRIM_FUN_FFT_HPP
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <unsupported/Eigen/FFT>
#include <Eigen/Dense>
#include <complex>
#include <type_traits>
#include <vector>
namespace stan {
namespace math {
/**
* Return the discrete Fourier transform of the specified complex
* vector.
*
* Given an input complex vector `x[0:N-1]` of size `N`, the discrete
* Fourier transform computes entries of the resulting complex
* vector `y[0:N-1]` by
*
* ```
* y[n] = SUM_{i < N} x[i] * exp(-n * i * 2 * pi * sqrt(-1) / N)
* ```
*
* If the input is of size zero, the result is a size zero vector.
*
* @tparam V type of complex vector argument
* @param[in] x vector to transform
* @return discrete Fourier transform of `x`
*/
template <typename V, require_eigen_vector_vt<is_complex, V>* = nullptr>
inline Eigen::Matrix<scalar_type_t<V>, -1, 1> fft(const V& x) {
// copy because fft() requires Eigen::Matrix type
Eigen::Matrix<scalar_type_t<V>, -1, 1> xv = x;
if (xv.size() <= 1)
return xv;
Eigen::FFT<base_type_t<V>> fft;
return fft.fwd(xv);
}
/**
* Return the inverse discrete Fourier transform of the specified
* complex vector.
*
* Given an input complex vector `y[0:N-1]` of size `N`, the inverse
* discrete Fourier transform computes entries of the resulting
* complex vector `x[0:N-1]` by
*
* ```
* x[n] = SUM_{i < N} y[i] * exp(n * i * 2 * pi * sqrt(-1) / N)
* ```
*
* If the input is of size zero, the result is a size zero vector.
* The only difference between the discrete DFT and its inverse is
* the sign of the exponent.
*
* @tparam V type of complex vector argument
* @param[in] y vector to inverse transform
* @return inverse discrete Fourier transform of `y`
*/
template <typename V, require_eigen_vector_vt<is_complex, V>* = nullptr>
inline Eigen::Matrix<scalar_type_t<V>, -1, 1> inv_fft(const V& y) {
// copy because fft() requires Eigen::Matrix type
Eigen::Matrix<scalar_type_t<V>, -1, 1> yv = y;
if (y.size() <= 1)
return yv;
Eigen::FFT<base_type_t<V>> fft;
return fft.inv(yv);
}
/**
* Return the two-dimensional discrete Fourier transform of the
* specified complex matrix. The 2D discrete Fourier transform first
* runs the discrete Fourier transform on the each row, then on each
* column of the result.
*
* @tparam M type of complex matrix argument
* @param[in] x matrix to transform
* @return discrete 2D Fourier transform of `x`
*/
template <typename M, require_eigen_dense_dynamic_vt<is_complex, M>* = nullptr>
inline Eigen::Matrix<scalar_type_t<M>, -1, -1> fft2(const M& x) {
Eigen::Matrix<scalar_type_t<M>, -1, -1> y(x.rows(), x.cols());
for (int i = 0; i < y.rows(); ++i)
y.row(i) = fft(x.row(i));
for (int j = 0; j < y.cols(); ++j)
y.col(j) = fft(y.col(j));
return y;
}
/**
* Return the two-dimensional inverse discrete Fourier transform of
* the specified complex matrix. The 2D inverse discrete Fourier
* transform first runs the 1D inverse Fourier transform on the
* columns, and then on the resulting rows. The composition of the
* FFT and inverse FFT (or vice-versa) is the identity.
*
* @tparam M type of complex matrix argument
* @param[in] y matrix to inverse trnasform
* @return inverse discrete 2D Fourier transform of `y`
*/
template <typename M, require_eigen_dense_dynamic_vt<is_complex, M>* = nullptr>
inline Eigen::Matrix<scalar_type_t<M>, -1, -1> inv_fft2(const M& y) {
Eigen::Matrix<scalar_type_t<M>, -1, -1> x(y.rows(), y.cols());
for (int j = 0; j < x.cols(); ++j)
x.col(j) = inv_fft(y.col(j));
for (int i = 0; i < x.rows(); ++i)
x.row(i) = inv_fft(x.row(i));
return x;
}
} // namespace math
} // namespace stan
#endif
|
; A278814: a(n) = ceiling(sqrt(3n+1)).
; 1,2,3,4,4,4,5,5,5,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,11,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18
mul $0,3
lpb $0,1
add $1,2
sub $0,$1
trn $0,1
lpe
div $1,2
add $1,1
|
#include <iostream>
#include <vector>
#include <thread>
#include <list>
#include <mutex>
#include <condition_variable>
#include <future>
//demo to show how object-oriented new async thread
int mythread(int temp)
{
std::cout<<"mythread started: "<<std::this_thread::get_id()<<std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cout<<"mythread end "<<std::this_thread::get_id()<<std::endl;
return temp;
}
int main(){
std::cout<<"main thread is: "<<std::this_thread::get_id()<<std::endl;
std::packaged_task<int(int)> myobj(mythread);
std::thread p1(std::ref(myobj), 2); //pass 2 as user::mythread input argument
p1.join();
std::future<int> res0 = myobj.get_future(); //std::future contains return result for packaged thread
std::cout<<res0.get() <<std::endl;
//lambda function as args for packaged_task
std::packaged_task<int(int)> newPkg([](int args){
std::cout<<"mythread started: "<<std::this_thread::get_id()<<std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cout<<"mythread end "<<std::this_thread::get_id()<<std::endl;
return args;
});
std::thread p2(std::ref(newPkg), 5); //pass 2 as user::mythread input argument
p2.join();
std::future<int> res1 = newPkg.get_future(); //std::future contains return result for packaged thread
std::cout<<res1.get() <<std::endl;
std::packaged_task<int(int)> newPkg1([](int args){
std::cout<<"mythread started: "<<std::this_thread::get_id()<<std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cout<<"mythread end "<<std::this_thread::get_id()<<std::endl;
return args;
});
std::cout<<"before lambda function is called\n";
newPkg1(100); //call this lambda function directly in the main thread
std::cout<<"package task is called"<<std::endl;
std::future<int> res2 = newPkg1.get_future();
std::cout<<res2.get()<<std::endl;
std::packaged_task<int(int)> newPkg2([](int args){
std::cout<<"mythread started: "<<std::this_thread::get_id()<<std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cout<<"mythread end "<<std::this_thread::get_id()<<std::endl;
return args;
});
std::vector<std::packaged_task<int(int)>> tasks; //vector container for packaged_task
//demo to show how to call element/packaged_task in vector container
tasks.push_back(std::move(newPkg2)); //move a new container
//pass to another packaged_task
std::packaged_task<int(int)> newPkg3;
auto iter = tasks.begin();
newPkg3 = std::move(*iter); //delete first iter
tasks.erase(iter); //no longer available to use iter
newPkg3(200);
std::future<int> res3 = newPkg3.get_future();
std::cout<<res3.get()<<std::endl;
return 0;
}
|
; double fmax(double x, double y)
SECTION code_fp_math48
PUBLIC cm48_sccz80_fmax
EXTERN am48_fmax, cm48_sccz80p_dparam2
cm48_sccz80_fmax:
call cm48_sccz80p_dparam2
; AC'= y
; AC = x
jp am48_fmax
|
; A158773: a(n) = 1600*n^2 - 40.
; 1560,6360,14360,25560,39960,57560,78360,102360,129560,159960,193560,230360,270360,313560,359960,409560,462360,518360,577560,639960,705560,774360,846360,921560,999960,1081560,1166360,1254360,1345560,1439960,1537560,1638360,1742360,1849560,1959960,2073560,2190360,2310360,2433560,2559960,2689560,2822360,2958360,3097560,3239960,3385560,3534360,3686360,3841560,3999960,4161560,4326360,4494360,4665560,4839960,5017560,5198360,5382360,5569560,5759960,5953560,6150360,6350360,6553560,6759960,6969560,7182360,7398360,7617560,7839960,8065560,8294360,8526360,8761560,8999960,9241560,9486360,9734360,9985560,10239960,10497560,10758360,11022360,11289560,11559960,11833560,12110360,12390360,12673560,12959960,13249560,13542360,13838360,14137560,14439960,14745560,15054360,15366360,15681560,15999960
mov $1,2
add $1,$0
mul $1,$0
mul $1,1600
add $1,1560
mov $0,$1
|
;Add two memory location-8 bit each and store the two byte result
MVI C, 00H
LDA 2000H
MOV B, A
LDA 2001H
ADD B
JNC down
INR C
down: STA 2002H
MOV A,C
STA 2003H
HLT
|
icl '../os/symbols.asm'
org BOOTADDR
lda #0
sta ROS8
lda #$0B
ldx #OS_SET_VIDEO_MODE
jsr OS_CALL
mwa VRAM_FREE VTILESET_BIG
mwa VRAM_FREE VRAM_TO_RAM
jsr lib_vram_to_ram
adw RAM_TO_VRAM #128
ldy #0
copy_tile:
lda tile, y
sta (RAM_TO_VRAM), y
iny
cpy #128
bne copy_tile
mwa DISPLAY_START VRAM_TO_RAM
jsr lib_vram_to_ram
ldy #0
copy:
lda message, y
cmp #255
beq stop
sta (RAM_TO_VRAM), y
iny
bne copy
stop:
jmp stop
message:
.byte 0, 1, 1, 0, 1, 255
tile:
.byte $13, $00, $00, $07, $70, $00, $00, $21
.byte $21, $30, $00, $07, $70, $00, $02, $13
.byte $02, $13, $00, $07, $70, $00, $21, $30
.byte $00, $21, $30, $07, $70, $02, $13, $00
.byte $00, $02, $13, $07, $70, $21, $30, $00
.byte $00, $00, $21, $37, $72, $13, $00, $00
.byte $44, $40, $02, $13, $21, $30, $04, $44
.byte $55, $50, $00, $21, $13, $00, $05, $55
.byte $44, $40, $00, $31, $12, $00, $04, $44
.byte $00, $00, $03, $12, $31, $20, $00, $00
.byte $00, $00, $31, $26, $63, $12, $00, $00
.byte $00, $03, $12, $06, $60, $31, $20, $00
.byte $00, $31, $20, $06, $60, $03, $12, $00
.byte $03, $12, $00, $06, $60, $00, $31, $20
.byte $31, $20, $00, $06, $60, $00, $03, $12
.byte $12, $00, $00, $06, $60, $00, $00, $31
icl '../os/stdlib.asm'
|
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_CI_CIFIELD_HPP
#define SHARE_VM_CI_CIFIELD_HPP
#include "ci/ciClassList.hpp"
#include "ci/ciConstant.hpp"
#include "ci/ciFlags.hpp"
#include "ci/ciInstance.hpp"
// ciField
//
// This class represents the result of a field lookup in the VM.
// The lookup may not succeed, in which case the information in
// the ciField will be incomplete.
class ciField : public ResourceObj {
CI_PACKAGE_ACCESS
friend class ciEnv;
friend class ciInstanceKlass;
friend class NonStaticFieldFiller;
private:
ciFlags _flags;
ciInstanceKlass* _holder;
ciSymbol* _name;
ciSymbol* _signature;
ciType* _type;
int _offset;
bool _is_constant;
ciInstanceKlass* _known_to_link_with_put;
ciInstanceKlass* _known_to_link_with_get;
ciConstant _constant_value;
// Used for will_link
int _cp_index;
ciType* compute_type();
ciType* compute_type_impl();
ciField(ciInstanceKlass* klass, int index);
ciField(fieldDescriptor* fd);
// shared constructor code
void initialize_from(fieldDescriptor* fd);
public:
ciFlags flags() { return _flags; }
// Of which klass is this field a member?
//
// Usage note: the declared holder of a field is the class
// referenced by name in the bytecodes. The canonical holder
// is the most general class which holds the field. This
// method returns the canonical holder. The declared holder
// can be accessed via a method in ciBytecodeStream.
//
// Ex.
// class A {
// public int f = 7;
// }
// class B extends A {
// public void test() {
// System.out.println(f);
// }
// }
//
// A java compiler is permitted to compile the access to
// field f as:
//
// getfield B.f
//
// In that case the declared holder of f would be B and
// the canonical holder of f would be A.
ciInstanceKlass* holder() { return _holder; }
// Name of this field?
ciSymbol* name() { return _name; }
// Signature of this field?
ciSymbol* signature() { return _signature; }
// Of what type is this field?
ciType* type() { return (_type == NULL) ? compute_type() : _type; }
// How is this field actually stored in memory?
BasicType layout_type() { return type2field[(_type == NULL) ? T_OBJECT : _type->basic_type()]; }
// How big is this field in memory?
int size_in_bytes() { return type2aelembytes(layout_type()); }
// What is the offset of this field?
int offset() {
assert(_offset >= 1, "illegal call to offset()");
return _offset;
}
// Same question, explicit units. (Fields are aligned to the byte level.)
int offset_in_bytes() {
return offset();
}
// Is this field shared?
bool is_shared() {
// non-static fields of shared holders are cached
return _holder->is_shared() && !is_static();
}
// Is this field a constant?
//
// Clarification: A field is considered constant if:
// 1. The field is both static and final
// 2. The canonical holder of the field has undergone
// static initialization.
// 3. If the field is an object or array, then the oop
// in question is allocated in perm space.
// 4. The field is not one of the special static/final
// non-constant fields. These are java.lang.System.in
// and java.lang.System.out. Abomination.
//
// Note: the check for case 4 is not yet implemented.
bool is_constant() { return _is_constant; }
// Get the constant value of this field.
ciConstant constant_value() {
assert(is_static() && is_constant(), "illegal call to constant_value()");
return _constant_value;
}
// Get the constant value of non-static final field in the given
// object.
ciConstant constant_value_of(ciObject* object) {
assert(!is_static() && is_constant(), "only if field is non-static constant");
assert(object->is_instance(), "must be instance");
return object->as_instance()->field_value(this);
}
// Check for link time errors. Accessing a field from a
// certain class via a certain bytecode may or may not be legal.
// This call checks to see if an exception may be raised by
// an access of this field.
//
// Usage note: if the same field is accessed multiple times
// in the same compilation, will_link will need to be checked
// at each point of access.
bool will_link(ciInstanceKlass* accessing_klass,
Bytecodes::Code bc);
// Java access flags
bool is_public () { return flags().is_public(); }
bool is_private () { return flags().is_private(); }
bool is_protected () { return flags().is_protected(); }
bool is_static () { return flags().is_static(); }
bool is_final () { return flags().is_final(); }
bool is_volatile () { return flags().is_volatile(); }
bool is_transient () { return flags().is_transient(); }
bool is_call_site_target() {
ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass();
if (callsite_klass == NULL)
return false;
return (holder()->is_subclass_of(callsite_klass) && (name() == ciSymbol::target_name()));
}
// Debugging output
void print();
void print_name_on(outputStream* st);
};
#endif // SHARE_VM_CI_CIFIELD_HPP
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0xc15a, %rsi
lea addresses_UC_ht+0x915a, %rdi
nop
inc %rax
mov $33, %rcx
rep movsw
nop
nop
nop
nop
nop
xor %r15, %r15
lea addresses_D_ht+0x17aba, %rcx
nop
add %r12, %r12
mov (%rcx), %edi
nop
nop
nop
nop
xor %rax, %rax
lea addresses_A_ht+0xafda, %rsi
lea addresses_UC_ht+0x1285a, %rdi
nop
nop
nop
nop
nop
sub $7964, %r9
mov $46, %rcx
rep movsb
nop
nop
nop
nop
sub $51529, %rcx
lea addresses_A_ht+0x1dda, %rax
nop
dec %rcx
mov (%rax), %si
and $4408, %r15
lea addresses_WT_ht+0x1277a, %rdi
nop
sub $4622, %r9
mov (%rdi), %r12
nop
nop
sub $49527, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r15
push %r9
push %rax
push %rbp
push %rdx
// Faulty Load
lea addresses_RW+0xa7da, %r10
nop
nop
nop
add %rbp, %rbp
mov (%r10), %rdx
lea oracles, %r15
and $0xff, %rdx
shlq $12, %rdx
mov (%r15,%rdx,1), %rdx
pop %rdx
pop %rbp
pop %rax
pop %r9
pop %r15
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'32': 3490}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r14
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x19ac0, %rsi
lea addresses_A_ht+0x9900, %rdi
nop
nop
nop
nop
nop
xor $33124, %r13
mov $91, %rcx
rep movsw
nop
sub $51904, %rcx
lea addresses_A_ht+0x9080, %rsi
lea addresses_D_ht+0x6c80, %rdi
nop
cmp %rdx, %rdx
mov $43, %rcx
rep movsw
nop
nop
nop
inc %rdx
lea addresses_WT_ht+0x17ea0, %rsi
lea addresses_UC_ht+0xf680, %rdi
nop
nop
add $8676, %r10
mov $76, %rcx
rep movsl
nop
nop
add %r10, %r10
lea addresses_WC_ht+0x102ac, %rsi
lea addresses_A_ht+0xce00, %rdi
nop
nop
nop
nop
xor $28441, %rbp
mov $70, %rcx
rep movsw
xor %rdx, %rdx
lea addresses_UC_ht+0xefc0, %rsi
lea addresses_D_ht+0xb300, %rdi
nop
nop
nop
xor %r13, %r13
mov $108, %rcx
rep movsl
nop
nop
nop
nop
and $11477, %r10
lea addresses_WT_ht+0x1be80, %rdx
nop
nop
nop
and %r10, %r10
vmovups (%rdx), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $1, %xmm2, %rsi
dec %rsi
lea addresses_WT_ht+0x7e80, %rdi
clflush (%rdi)
nop
nop
xor $57271, %r13
mov $0x6162636465666768, %rbp
movq %rbp, %xmm3
movups %xmm3, (%rdi)
nop
nop
nop
nop
nop
inc %rdi
lea addresses_UC_ht+0x18480, %rsi
lea addresses_WC_ht+0x4e2c, %rdi
nop
nop
nop
nop
add %r10, %r10
mov $40, %rcx
rep movsl
cmp %r10, %r10
lea addresses_UC_ht+0xbe20, %rsi
lea addresses_normal_ht+0x8a80, %rdi
clflush (%rsi)
nop
nop
nop
xor $17775, %r14
mov $117, %rcx
rep movsb
add %rbp, %rbp
lea addresses_A_ht+0xac30, %rcx
nop
sub %rdi, %rdi
mov $0x6162636465666768, %rbp
movq %rbp, (%rcx)
nop
nop
nop
nop
xor $44503, %rdi
lea addresses_WC_ht+0x173c0, %rbp
nop
and $6640, %rsi
vmovups (%rbp), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %r13
and %rdx, %rdx
lea addresses_WT_ht+0x15a8c, %rdx
clflush (%rdx)
nop
nop
nop
inc %r14
mov $0x6162636465666768, %rbp
movq %rbp, %xmm2
vmovups %ymm2, (%rdx)
nop
nop
nop
nop
sub %rbp, %rbp
lea addresses_A_ht+0x5880, %rsi
lea addresses_A_ht+0x6fba, %rdi
nop
sub %rdx, %rdx
mov $113, %rcx
rep movsb
nop
and %r13, %r13
lea addresses_WC_ht+0x5a80, %rdx
inc %r13
movw $0x6162, (%rdx)
nop
nop
nop
nop
dec %rdi
lea addresses_A_ht+0x1ce80, %rsi
lea addresses_normal_ht+0xc680, %rdi
xor $43522, %rbp
mov $29, %rcx
rep movsb
and $10585, %r13
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r14
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r8
push %r9
push %rbp
push %rbx
push %rdi
// Faulty Load
lea addresses_A+0xce80, %rdi
cmp %rbx, %rbx
movb (%rdi), %r8b
lea oracles, %r9
and $0xff, %r8
shlq $12, %r8
mov (%r9,%r8,1), %r8
pop %rdi
pop %rbx
pop %rbp
pop %r9
pop %r8
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'same': True, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': True}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': True}, 'OP': 'REPM'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': True}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 16, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_WC_ht', 'same': True, 'size': 2, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'}
{'35': 21829}
35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35
*/
|
; DV3 Medium Change Utility V3.00 1992 Tony Tebby
section dv3
xdef dv3_change
xref dv3_sbclr
include 'dev8_dv3_keys'
include 'dev8_keys_err'
include 'dev8_mac_assert'
;+++
; DV3 Medium Change
;
; a4 c p drive definition
;
; status return standard
;---
dv3_change
tst.b ddf_lock(a4) ; locked?
beq.s dch_change ; ... no, changed medium
move.b #ddf.mchg,ddf_mstat(a4) ; ... bad status
moveq #err.mchk,d0
rts
dch_change
assert ddf.mnew,0
sf ddf_mstat(a4) ; new medium
jmp dv3_sbclr ; and clear slave blocks
end
|
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2019 Baldur Karlsson
*
* 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 "d3d12_device.h"
#include "d3d12_resources.h"
HRESULT WrappedID3D12Device::CreatePipelineLibrary(_In_reads_(BlobLength) const void *pLibraryBlob,
SIZE_T BlobLength, REFIID riid,
_COM_Outptr_ void **ppPipelineLibrary)
{
// we don't want to ever use pipeline libraries since then we can't get the
// bytecode and pipeline config. So instead we always return that a blob is
// non-matching and return a dummy interface that does nothing when stored.
// This might cause the application to clear its previous cache but that's
// not the end of the world.
#ifndef D3D12_ERROR_DRIVER_VERSION_MISMATCH
#define D3D12_ERROR_DRIVER_VERSION_MISMATCH _HRESULT_TYPEDEF_(0x887E0002L)
#endif
if(BlobLength > 0)
return D3D12_ERROR_DRIVER_VERSION_MISMATCH;
WrappedID3D12PipelineLibrary1 *pipeLibrary = new WrappedID3D12PipelineLibrary1(this);
if(riid == __uuidof(ID3D12PipelineLibrary))
{
*ppPipelineLibrary = (ID3D12PipelineLibrary *)pipeLibrary;
}
else if(riid == __uuidof(ID3D12PipelineLibrary1))
{
*ppPipelineLibrary = (ID3D12PipelineLibrary1 *)pipeLibrary;
}
else
{
RDCERR("Unexpected interface type %s", ToStr(riid).c_str());
pipeLibrary->Release();
*ppPipelineLibrary = NULL;
return E_NOINTERFACE;
}
return S_OK;
}
HRESULT WrappedID3D12Device::SetEventOnMultipleFenceCompletion(
_In_reads_(NumFences) ID3D12Fence *const *ppFences,
_In_reads_(NumFences) const UINT64 *pFenceValues, UINT NumFences,
D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, HANDLE hEvent)
{
ID3D12Fence **unwrapped = GetTempArray<ID3D12Fence *>(NumFences);
for(UINT i = 0; i < NumFences; i++)
unwrapped[i] = Unwrap(ppFences[i]);
return m_pDevice1->SetEventOnMultipleFenceCompletion(unwrapped, pFenceValues, NumFences, Flags,
hEvent);
}
HRESULT WrappedID3D12Device::SetResidencyPriority(UINT NumObjects,
_In_reads_(NumObjects)
ID3D12Pageable *const *ppObjects,
_In_reads_(NumObjects)
const D3D12_RESIDENCY_PRIORITY *pPriorities)
{
ID3D12Pageable **unwrapped = GetTempArray<ID3D12Pageable *>(NumObjects);
for(UINT i = 0; i < NumObjects; i++)
unwrapped[i] = (ID3D12Pageable *)Unwrap((ID3D12DeviceChild *)ppObjects[i]);
return m_pDevice1->SetResidencyPriority(NumObjects, unwrapped, pPriorities);
}
|
; A001311: Final 2 digits of 6^n.
; 1,6,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96,76,56,36,16,96
mov $1,1
lpb $0,1
sub $0,1
mul $1,6
mod $1,100
lpe
|
MODULE get_sprite_prop
PUBLIC get_sprite_prop
PUBLIC _get_sprite_prop
SECTION code_driver
INCLUDE "target/gb/def/gb_globals.def"
; uint8_t __LIB__ get_sprite_prop(uint8_t nb) NONBANKED;
get_sprite_prop:
_get_sprite_prop:
PUSH BC
LD HL,sp+4 ; Skip return address and registers
LD C,(HL) ; C = nb
CALL get_prop
POP BC
RET
;; Get prop of sprite number C
get_prop:
LD HL,OAM+3 ; Calculate origin of sprite info
SLA C ; Multiply C by 4
SLA C
LD B,0x00
ADD HL,BC
LD A,(HL) ; Get sprite number
LD E,A
LD L,A
LD H,0
RET
|
// SPDX-License-Identifier: BSD-2-Clause
//
// This code has been produced by the European Spallation Source
// and its partner institutes under the BSD 2 Clause License.
//
// See LICENSE.md at the top level for license information.
//
// Screaming Udder! https://esss.se
#include "Master.h"
#include "Status/StatusReporter.h"
#include "StreamController.h"
#include <flatbuffers/flatbuffers.h>
#include <gtest/gtest.h>
#include <memory>
#include <trompeloeil.hpp>
class CommandHandlerStandIn : public Command::HandlerBase {
public:
MAKE_MOCK1(registerStartFunction, void(Command::StartFuncType), override);
MAKE_MOCK1(registerSetStopTimeFunction, void(Command::StopTimeFuncType),
override);
MAKE_MOCK1(registerStopNowFunction, void(Command::StopNowFuncType), override);
MAKE_MOCK1(registerIsWritingFunction, void(Command::IsWritingFuncType),
override);
MAKE_MOCK2(sendHasStoppedMessage, void(std::string, std::string), override);
MAKE_MOCK3(sendErrorEncounteredMessage,
void(std::string, std::string, std::string), override);
MAKE_MOCK0(loopFunction, void(), override);
};
class StatusReporterStandIn : public Status::StatusReporterBase {
public:
StatusReporterStandIn()
: Status::StatusReporterBase(std::shared_ptr<Kafka::Producer>{}, {}, {}) {
}
MAKE_MOCK1(updateStatusInfo, void(Status::JobStatusInfo const &), override);
MAKE_MOCK1(useAlternativeStatusTopic, void(std::string const &), override);
MAKE_MOCK0(revertToDefaultStatusTopic, void(), override);
MAKE_MOCK1(updateStopTime, void(time_point), override);
MAKE_MOCK0(getStopTime, time_point(), override);
MAKE_MOCK0(resetStatusInfo, void(), override);
MAKE_CONST_MOCK1(createReport,
flatbuffers::DetachedBuffer(std::string const &), override);
MAKE_CONST_MOCK0(createJSONReport, std::string(), override);
MAKE_MOCK1(setJSONMetaDataGenerator, void(Status::JsonGeneratorFuncType),
override);
};
using trompeloeil::_;
class MasterTest : public ::testing::Test {
public:
void SetUp() override {
std::unique_ptr<Command::HandlerBase> TmpCmdHandler =
std::make_unique<CommandHandlerStandIn>();
CmdHandler = dynamic_cast<CommandHandlerStandIn *>(TmpCmdHandler.get());
REQUIRE_CALL(*CmdHandler, registerStartFunction(_)).TIMES(1);
REQUIRE_CALL(*CmdHandler, registerSetStopTimeFunction(_)).TIMES(1);
REQUIRE_CALL(*CmdHandler, registerStopNowFunction(_)).TIMES(1);
REQUIRE_CALL(*CmdHandler, registerIsWritingFunction(_)).TIMES(1);
std::unique_ptr<Status::StatusReporterBase> TmpStatusReporter =
std::make_unique<StatusReporterStandIn>();
StatusReporter =
dynamic_cast<StatusReporterStandIn *>(TmpStatusReporter.get());
REQUIRE_CALL(*StatusReporter, setJSONMetaDataGenerator(_)).TIMES(1);
UnderTest = std::make_unique<FileWriter::Master>(
Config, std::move(TmpCmdHandler), std::move(TmpStatusReporter),
Registrar);
if (std::filesystem::exists(StartCmd.Filename)) {
std::filesystem::remove(StartCmd.Filename);
}
}
MainOpt Config;
Metrics::Registrar Registrar{"no_prefix", {}};
void TearDown() override { UnderTest.reset(); }
CommandHandlerStandIn *CmdHandler;
StatusReporterStandIn *StatusReporter;
std::unique_ptr<FileWriter::Master> UnderTest;
time_point StartTime{system_clock::now()};
Command::StartInfo StartCmd{"job_id",
"file_name",
"{\"nexus_structure\":5}",
"{\"meta_data\":54}",
uri::URI{"localhost:9092"},
StartTime,
StartTime + 50s,
"control_topic"};
};
TEST_F(MasterTest, Init) {
// Do nothing extra here, its all done in the SetUp()-function
}
TEST_F(MasterTest, StartWritingSuccess) {
REQUIRE_CALL(*StatusReporter,
useAlternativeStatusTopic(StartCmd.ControlTopic))
.TIMES(1);
REQUIRE_CALL(*StatusReporter, updateStatusInfo(_)).TIMES(1);
UnderTest->startWriting(StartCmd);
}
TEST_F(MasterTest, StartWritingFailureWhenWriting) {
REQUIRE_CALL(*StatusReporter,
useAlternativeStatusTopic(StartCmd.ControlTopic))
.TIMES(1);
REQUIRE_CALL(*StatusReporter, updateStatusInfo(_)).TIMES(1);
UnderTest->startWriting(StartCmd);
EXPECT_THROW(UnderTest->startWriting(StartCmd), std::runtime_error);
}
TEST_F(MasterTest, SetStopTimeFailsWhenIdle) {
EXPECT_THROW(UnderTest->setStopTime(system_clock::now()), std::runtime_error);
}
TEST_F(MasterTest, SetStopTimeSuccess) {
REQUIRE_CALL(*StatusReporter,
useAlternativeStatusTopic(StartCmd.ControlTopic))
.TIMES(1);
REQUIRE_CALL(*StatusReporter, updateStatusInfo(_)).TIMES(1);
UnderTest->startWriting(StartCmd);
auto NewStopTime = StartTime + 5s;
REQUIRE_CALL(*StatusReporter, updateStopTime(NewStopTime)).TIMES(1);
ALLOW_CALL(*StatusReporter, getStopTime()).RETURN(StartCmd.StopTime);
UnderTest->setStopTime(NewStopTime);
}
TEST_F(MasterTest, SetStopTimeInThePastSuccess) {
REQUIRE_CALL(*StatusReporter,
useAlternativeStatusTopic(StartCmd.ControlTopic))
.TIMES(1);
REQUIRE_CALL(*StatusReporter, updateStatusInfo(_)).TIMES(1);
UnderTest->startWriting(StartCmd);
auto NewStopTime = StartTime - 5s;
REQUIRE_CALL(*StatusReporter, updateStopTime(NewStopTime)).TIMES(1);
ALLOW_CALL(*StatusReporter, getStopTime()).RETURN(StartCmd.StopTime);
UnderTest->setStopTime(NewStopTime);
}
TEST_F(MasterTest, SetStopTimeFailureDueToStopTimePassed) {
REQUIRE_CALL(*StatusReporter,
useAlternativeStatusTopic(StartCmd.ControlTopic))
.TIMES(1);
REQUIRE_CALL(*StatusReporter, updateStatusInfo(_)).TIMES(1);
UnderTest->startWriting(StartCmd);
auto NewStopTime1 = StartTime - 5s;
REQUIRE_CALL(*StatusReporter, updateStopTime(NewStopTime1)).TIMES(1);
ALLOW_CALL(*StatusReporter, getStopTime()).RETURN(StartCmd.StopTime);
UnderTest->setStopTime(NewStopTime1);
auto NewStopTime2 = StartTime + 20s;
ALLOW_CALL(*StatusReporter, getStopTime()).RETURN(NewStopTime1);
FORBID_CALL(*StatusReporter, updateStopTime(_));
EXPECT_THROW(UnderTest->setStopTime(NewStopTime2), std::runtime_error);
}
TEST_F(MasterTest, StopNowFailureDueToIdle) {
EXPECT_THROW(UnderTest->stopNow(), std::runtime_error);
}
TEST_F(MasterTest, StopNowSuccess) {
REQUIRE_CALL(*StatusReporter,
useAlternativeStatusTopic(StartCmd.ControlTopic))
.TIMES(1);
REQUIRE_CALL(*StatusReporter, updateStatusInfo(_)).TIMES(1);
UnderTest->startWriting(StartCmd);
REQUIRE_CALL(*StatusReporter, updateStopTime(_)).TIMES(1);
UnderTest->stopNow();
}
TEST_F(MasterTest, StopNowSuccessWhenStopTimePassed) {
REQUIRE_CALL(*StatusReporter,
useAlternativeStatusTopic(StartCmd.ControlTopic))
.TIMES(1);
REQUIRE_CALL(*StatusReporter, updateStatusInfo(_)).TIMES(1);
UnderTest->startWriting(StartCmd);
auto NewStopTime1 = StartTime - 5s;
REQUIRE_CALL(*StatusReporter, updateStopTime(NewStopTime1)).TIMES(1);
ALLOW_CALL(*StatusReporter, getStopTime()).RETURN(StartCmd.StopTime);
UnderTest->setStopTime(NewStopTime1);
REQUIRE_CALL(*StatusReporter, updateStopTime(_)).TIMES(1);
UnderTest->stopNow();
} |
<%
from pwnlib.shellcraft.i386.linux import syscall
%>
<%page args="name"/>
<%docstring>
Invokes the syscall unlink. See 'man 2 unlink' for more information.
Arguments:
name(char): name
</%docstring>
${syscall('SYS_unlink', name)}
|
proc DoMan
fastcall ConsolePrint, _gr_message_mandata
ret
endp |
Ani_2647E: dc.w byte_26480-Ani_2647E
byte_26480: dc.b 3, 1, 2, 3, 4, 5, 3, 4, 6, 7, 8, $FC
|
[org 0x1000]
dw 0x55aa; 魔数,用于判断错误
; 打印字符串
mov si, loading
call print
; xchg bx, bx; 断点
detect_memory:
; 将 ebx 置为 0
xor ebx, ebx
; es:di 结构体的缓存位置
mov ax, 0
mov es, ax
mov edi, ards_buffer
mov edx, 0x534d4150; 固定签名
.next:
; 子功能号
mov eax, 0xe820
; ards 结构的大小 (字节)
mov ecx, 20
; 调用 0x15 系统调用
int 0x15
; 如果 CF 置位,表示出错
jc error
; 将缓存指针指向下一个结构体
add di, cx
; 将结构体数量加一
inc dword [ards_count]
cmp ebx, 0
jnz .next
mov si, detecting
call print
; xchg bx, bx
; mov byte [0xb8000], 'P'
jmp prepare_protected_mode
prepare_protected_mode:
; xchg bx, bx; 断点
cli; 关闭中断
; 打开 A20 线
in al, 0x92
or al, 0b10
out 0x92, al
lgdt [gdt_ptr]; 加载 gdt
; 启动保护模式
mov eax, cr0
or eax, 1
mov cr0, eax
; 用跳转来刷新缓存,启用保护模式
jmp dword code_selector:protect_mode
print:
mov ah, 0x0e
.next:
mov al, [si]
cmp al, 0
jz .done
int 0x10
inc si
jmp .next
.done:
ret
loading:
db "Loading Onix...", 10, 13, 0; \n\r
detecting:
db "Detecting Memory Success...", 10, 13, 0; \n\r
error:
mov si, .msg
call print
hlt; 让 CPU 停止
jmp $
.msg db "Loading Error!!!", 10, 13, 0
[bits 32]
protect_mode:
; xchg bx, bx; 断点
mov ax, data_selector
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax; 初始化段寄存器
mov esp, 0x10000; 修改栈顶
mov edi, 0x10000; 读取的目标内存
mov ecx, 10; 起始扇区
mov bl, 200; 扇区数量
call read_disk ; 读取内核
mov eax, 0x20220205; 内核魔数
mov ebx, ards_count; ards 数量指针
jmp dword code_selector:0x10000
ud2; 表示出错
read_disk:
; 设置读写扇区的数量
mov dx, 0x1f2
mov al, bl
out dx, al
inc dx; 0x1f3
mov al, cl; 起始扇区的前八位
out dx, al
inc dx; 0x1f4
shr ecx, 8
mov al, cl; 起始扇区的中八位
out dx, al
inc dx; 0x1f5
shr ecx, 8
mov al, cl; 起始扇区的高八位
out dx, al
inc dx; 0x1f6
shr ecx, 8
and cl, 0b1111; 将高四位置为 0
mov al, 0b1110_0000;
or al, cl
out dx, al; 主盘 - LBA 模式
inc dx; 0x1f7
mov al, 0x20; 读硬盘
out dx, al
xor ecx, ecx; 将 ecx 清空
mov cl, bl; 得到读写扇区的数量
.read:
push cx; 保存 cx
call .waits; 等待数据准备完毕
call .reads; 读取一个扇区
pop cx; 恢复 cx
loop .read
ret
.waits:
mov dx, 0x1f7
.check:
in al, dx
jmp $+2; nop 直接跳转到下一行
jmp $+2; 一点点延迟
jmp $+2
and al, 0b1000_1000
cmp al, 0b0000_1000
jnz .check
ret
.reads:
mov dx, 0x1f0
mov cx, 256; 一个扇区 256 字
.readw:
in ax, dx
jmp $+2; 一点点延迟
jmp $+2
jmp $+2
mov [edi], ax
add edi, 2
loop .readw
ret
code_selector equ (1 << 3)
data_selector equ (2 << 3)
memory_base equ 0; 内存开始的位置:基地址
; 内存界限 4G / 4K - 1
memory_limit equ ((1024 * 1024 * 1024 * 4) / (1024 * 4)) - 1
gdt_ptr:
dw (gdt_end - gdt_base) - 1
dd gdt_base
gdt_base:
dd 0, 0; NULL 描述符
gdt_code:
dw memory_limit & 0xffff; 段界限 0 ~ 15 位
dw memory_base & 0xffff; 基地址 0 ~ 15 位
db (memory_base >> 16) & 0xff; 基地址 16 ~ 23 位
; 存在 - dlp 0 - S _ 代码 - 非依从 - 可读 - 没有被访问过
db 0b_1_00_1_1_0_1_0;
; 4k - 32 位 - 不是 64 位 - 段界限 16 ~ 19
db 0b1_1_0_0_0000 | (memory_limit >> 16) & 0xf;
db (memory_base >> 24) & 0xff; 基地址 24 ~ 31 位
gdt_data:
dw memory_limit & 0xffff; 段界限 0 ~ 15 位
dw memory_base & 0xffff; 基地址 0 ~ 15 位
db (memory_base >> 16) & 0xff; 基地址 16 ~ 23 位
; 存在 - dlp 0 - S _ 数据 - 向上 - 可写 - 没有被访问过
db 0b_1_00_1_0_0_1_0;
; 4k - 32 位 - 不是 64 位 - 段界限 16 ~ 19
db 0b1_1_0_0_0000 | (memory_limit >> 16) & 0xf;
db (memory_base >> 24) & 0xff; 基地址 24 ~ 31 位
gdt_end:
ards_count:
dd 0
ards_buffer:
|
; A008732: Molien series for 3-dimensional group [2,n] = *22n.
; 1,2,3,4,5,7,9,11,13,15,18,21,24,27,30,34,38,42,46,50,55,60,65,70,75,81,87,93,99,105,112,119,126,133,140,148,156,164,172,180,189,198,207,216,225,235,245,255,265,275,286,297,308,319,330,342,354,366,378,390,403,416,429,442,455,469,483,497,511,525,540,555,570,585,600,616,632,648,664,680,697,714,731,748,765,783,801,819,837,855,874,893,912,931,950,970,990,1010,1030,1050,1071,1092,1113,1134,1155,1177,1199,1221,1243,1265,1288,1311,1334,1357,1380,1404,1428,1452,1476,1500,1525,1550,1575,1600,1625,1651,1677,1703,1729,1755,1782,1809,1836,1863,1890,1918,1946,1974,2002,2030,2059,2088,2117,2146,2175,2205,2235,2265,2295,2325,2356,2387,2418,2449,2480,2512,2544,2576,2608,2640,2673,2706,2739,2772,2805,2839,2873,2907,2941,2975,3010,3045,3080,3115,3150,3186,3222,3258,3294,3330,3367,3404,3441,3478,3515,3553,3591,3629,3667,3705,3744,3783,3822,3861,3900,3940,3980,4020,4060,4100,4141,4182,4223,4264,4305,4347,4389,4431,4473,4515,4558,4601,4644,4687,4730,4774,4818,4862,4906,4950,4995,5040,5085,5130,5175,5221,5267,5313,5359,5405,5452,5499,5546,5593,5640,5688,5736,5784,5832,5880,5929,5978,6027,6076,6125,6175,6225,6275,6325,6375
add $0,4
bin $0,2
div $0,5
mov $1,$0
|
SECTION code_clib
SECTION code_l_sdcc
PUBLIC ____sdcc_4_copy_src_mhl_dst_bcix
EXTERN ____sdcc_4_copy_src_mhl_dst_deix
____sdcc_4_copy_src_mhl_dst_bcix:
push de
ld e,c
ld d,b
call ____sdcc_4_copy_src_mhl_dst_deix
pop de
ret
|
/**
* @file src/bin2llvmir/optimizations/x86_addr_spaces/x86_addr_spaces.cpp
* @brief Optimize a single x86 address spaces instruction.
* @copyright (c) 2018 Avast Software, licensed under the MIT license
*/
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Constants.h>
#include "retdec/bin2llvmir/optimizations/x86_addr_spaces/x86_addr_spaces.h"
#include "retdec/bin2llvmir/providers/abi/abi.h"
#include "retdec/bin2llvmir/utils/ir_modifier.h"
#include "retdec/bin2llvmir/utils/llvm.h"
#include "retdec/capstone2llvmir/x86/x86_defs.h"
using namespace llvm;
namespace retdec {
namespace bin2llvmir {
namespace x86_addr_spaces {
namespace {
/**
* MSDN: unsigned char __readfsbyte(unsigned long Offset);
* LLVM: i8 __readfsbyte(<default_type> offset)
*/
llvm::Function* getReadFsByte(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getInt8Ty(m->getContext()),
{Abi::getDefaultType(m)},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__readfsbyte",
m);
}
/**
* MSDN: unsigned short __readfsword(unsigned long Offset);
* LLVM: i16 __readfsword(<default_type> offset)
*/
llvm::Function* getReadFsWord(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getInt16Ty(m->getContext()),
{Abi::getDefaultType(m)},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__readfsword",
m);
}
/**
* MSDN: unsigned long __readfsdword(unsigned long Offset);
* LLVM: i32 __readfsdword(<default_type> offset)
*/
llvm::Function* getReadFsDword(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getInt32Ty(m->getContext()),
{Abi::getDefaultType(m)},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__readfsdword",
m);
}
/**
* MSDN: unsigned __int64 __readfsqword(unsigned long Offset);
* LLVM: i64 __readfsdword(<default_type> offset)
*/
llvm::Function* getReadFsQword(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getInt64Ty(m->getContext()),
{Abi::getDefaultType(m)},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__readfsqword",
m);
}
/**
* MSDN: void __writefsbyte(unsigned long Offset, unsigned char Data);
* LLVM: void __writefsbyte(<default_type> offset, i8 data)
*/
llvm::Function* getWriteFsByte(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getVoidTy(m->getContext()),
{Abi::getDefaultType(m), Type::getInt8Ty(m->getContext())},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__writefsbyte",
m);
}
/**
* MSDN: void __writefsword(unsigned long Offset, unsigned short Data);
* LLVM: void __writefsword(<default_type> offset, i16 data)
*/
llvm::Function* getWriteFsWord(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getVoidTy(m->getContext()),
{Abi::getDefaultType(m), Type::getInt16Ty(m->getContext())},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__writefsword",
m);
}
/**
* MSDN: void __writefsdword(unsigned long Offset, unsigned long Data);
* LLVM: void __writefsdword(<default_type> offset, i32 data)
*/
llvm::Function* getWriteFsDword(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getVoidTy(m->getContext()),
{Abi::getDefaultType(m), Type::getInt32Ty(m->getContext())},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__writefsdword",
m);
}
/**
* MSDN: void __writefsqword(unsigned long Offset, unsigned __int64 Data);
* LLVM: void __writefsqword(<default_type> offset, i64 data)
*/
llvm::Function* getWriteFsQword(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getVoidTy(m->getContext()),
{Abi::getDefaultType(m), Type::getInt64Ty(m->getContext())},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__writefsqword",
m);
}
/**
* MSDN: unsigned char __readgsbyte(unsigned long Offset);
* LLVM: i8 __readgsbyte(<default_type> offset)
*/
llvm::Function* getReadGsByte(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getInt8Ty(m->getContext()),
{Abi::getDefaultType(m)},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__readgsbyte",
m);
}
/**
* MSDN: unsigned short __readgsword(unsigned long Offset);
* LLVM: i16 __readgsword(<default_type> offset)
*/
llvm::Function* getReadGsWord(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getInt16Ty(m->getContext()),
{Abi::getDefaultType(m)},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__readgsword",
m);
}
/**
* MSDN: unsigned long __readgsdword(unsigned long Offset);
* LLVM: i32 __readgsdword(<default_type> offset)
*/
llvm::Function* getReadGsDword(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getInt32Ty(m->getContext()),
{Abi::getDefaultType(m)},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__readgsdword",
m);
}
/**
* MSDN: unsigned __int64 __readgsqword(unsigned long Offset);
* LLVM: i64 __readgsqword(<default_type> offset)
*/
llvm::Function* getReadGsQword(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getInt64Ty(m->getContext()),
{Abi::getDefaultType(m)},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__readgsqword",
m);
}
/**
* MSDN: void __writegsbyte(unsigned long Offset, unsigned char Data);
* LLVM: void __writegsbyte(<default_type> offset, i8 data)
*/
llvm::Function* getWriteGsByte(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getVoidTy(m->getContext()),
{Abi::getDefaultType(m), Type::getInt8Ty(m->getContext())},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__writegsbyte",
m);
}
/**
* MSDN: void __writegsword(unsigned long Offset, unsigned short Data);
* LLVM: void __writegsword(<default_type> offset, i16 data)
*/
llvm::Function* getWriteGsWord(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getVoidTy(m->getContext()),
{Abi::getDefaultType(m), Type::getInt16Ty(m->getContext())},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__writegsword",
m);
}
/**
* MSDN: void __writegsdword(unsigned long Offset, unsigned long Data);
* LLVM: void __writegsdword(<default_type> offset, i32 data)
*/
llvm::Function* getWriteGsDword(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getVoidTy(m->getContext()),
{Abi::getDefaultType(m), Type::getInt32Ty(m->getContext())},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__writegsdword",
m);
}
/**
* MSDN: void __writegsqword(unsigned long Offset, unsigned __int64 Data);
* LLVM: void __writegsqword(<default_type> offset, i64 data)
*/
llvm::Function* getWriteGsQword(llvm::Module* m)
{
return Function::Create(
FunctionType::get(
Type::getVoidTy(m->getContext()),
{Abi::getDefaultType(m), Type::getInt64Ty(m->getContext())},
false),
GlobalValue::LinkageTypes::ExternalLinkage,
"__writegsqword",
m);
}
llvm::Instruction* optimizeLoad(llvm::LoadInst* load, Config* c)
{
unsigned addrSpace = load->getPointerAddressSpace();
Function* replacement = nullptr;
if (addrSpace == static_cast<unsigned>(x86_addr_space::FS))
{
if (load->getType()->isIntegerTy(8))
{
replacement = c->getIntrinsicFunction(getReadFsByte);
}
else if (load->getType()->isIntegerTy(16))
{
replacement = c->getIntrinsicFunction(getReadFsWord);
}
else if (load->getType()->isIntegerTy(32))
{
replacement = c->getIntrinsicFunction(getReadFsDword);
}
else if (load->getType()->isIntegerTy(64))
{
replacement = c->getIntrinsicFunction(getReadFsQword);
}
}
else if (addrSpace == static_cast<unsigned>(x86_addr_space::GS))
{
if (load->getType()->isIntegerTy(8))
{
replacement = c->getIntrinsicFunction(getReadGsByte);
}
else if (load->getType()->isIntegerTy(16))
{
replacement = c->getIntrinsicFunction(getReadGsWord);
}
else if (load->getType()->isIntegerTy(32))
{
replacement = c->getIntrinsicFunction(getReadGsDword);
}
else if (load->getType()->isIntegerTy(64))
{
replacement = c->getIntrinsicFunction(getReadGsQword);
}
}
if (replacement == nullptr)
{
return nullptr;
}
if (replacement->arg_size() != 1) // expecting one arg
{
return nullptr;
}
Argument& arg = *replacement->arg_begin();
auto* ptr = llvm_utils::skipCasts(load->getPointerOperand());
ptr = IrModifier::convertValueToType(ptr, arg.getType(), load);
auto* call = CallInst::Create(replacement, {ptr}, "", load);
auto* conv = IrModifier::convertValueToType(call, load->getType(), load);
conv->takeName(load);
load->replaceAllUsesWith(conv);
load->eraseFromParent();
return call;
}
llvm::Instruction* optimizeStore(llvm::StoreInst* store, Config* c)
{
unsigned addrSpace = store->getPointerAddressSpace();
Function* replacement = nullptr;
if (addrSpace == static_cast<unsigned>(x86_addr_space::FS))
{
if (store->getValueOperand()->getType()->isIntegerTy(8))
{
replacement = c->getIntrinsicFunction(getWriteFsByte);
}
else if (store->getValueOperand()->getType()->isIntegerTy(16))
{
replacement = c->getIntrinsicFunction(getWriteFsWord);
}
else if (store->getValueOperand()->getType()->isIntegerTy(32))
{
replacement = c->getIntrinsicFunction(getWriteFsDword);
}
else if (store->getValueOperand()->getType()->isIntegerTy(64))
{
replacement = c->getIntrinsicFunction(getWriteFsQword);
}
}
else if (addrSpace == static_cast<unsigned>(x86_addr_space::GS))
{
if (store->getValueOperand()->getType()->isIntegerTy(8))
{
replacement = c->getIntrinsicFunction(getWriteGsByte);
}
else if (store->getValueOperand()->getType()->isIntegerTy(16))
{
replacement = c->getIntrinsicFunction(getWriteGsWord);
}
else if (store->getValueOperand()->getType()->isIntegerTy(32))
{
replacement = c->getIntrinsicFunction(getWriteGsDword);
}
else if (store->getValueOperand()->getType()->isIntegerTy(64))
{
replacement = c->getIntrinsicFunction(getWriteGsQword);
}
}
if (replacement == nullptr)
{
return nullptr;
}
if (replacement->arg_size() != 2) // expecting 2 args
{
return nullptr;
}
auto ait = replacement->arg_begin();
Argument& arg1 = *ait++;
auto* ptr = llvm_utils::skipCasts(store->getPointerOperand());
ptr = IrModifier::convertValueToType(ptr, arg1.getType(), store);
Argument& arg2 = *ait;
auto* val = store->getValueOperand();
val = IrModifier::convertValueToType(val, arg2.getType(), store);
auto* call = CallInst::Create(replacement, {ptr, val}, "", store);
store->eraseFromParent();
return call;
}
} // anonymous namespace
llvm::Instruction* optimize(llvm::Instruction* insn, Config* config)
{
if (LoadInst* l = dyn_cast<LoadInst>(insn))
{
return optimizeLoad(l, config);
}
else if (StoreInst* s = dyn_cast<StoreInst>(insn))
{
return optimizeStore(s, config);
}
else
{
return nullptr;
}
}
llvm::Instruction* optimize(llvm::Instruction* insn, bool isX86, Config* config)
{
return isX86 ? optimize(insn, config) : nullptr;
}
} // namespace x86_addr_spaces
} // namespace bin2llvmir
} // namespace retdec
|
ldy {m1}
sty $fe
ldy {m1}+1
sty $ff
ldy #0
ora ($fe),y
sta ($fe),y |
; A282848: a(n) = 2*n + 1 + n mod 4.
; 4,7,10,9,12,15,18,17,20,23,26,25,28,31,34,33,36,39,42,41,44,47,50,49,52,55,58,57,60,63,66,65,68,71,74,73,76,79,82,81,84,87,90,89,92,95,98,97,100,103,106,105,108,111,114,113,116,119,122,121,124,127,130,129,132,135,138,137,140,143,146,145,148,151,154,153,156,159,162,161,164,167,170,169,172,175,178,177,180,183,186,185,188,191,194,193,196,199,202,201
mov $1,$0
mul $0,2
add $1,1
mod $1,4
add $0,$1
add $0,3
|
object_const_def ; object_event constants
const CELADONMANSIONROOF_FISHER
CeladonMansionRoof_MapScripts:
db 0 ; scene scripts
db 0 ; callbacks
CeladonMansionRoofFisherScript:
jumptextfaceplayer CeladonMansionRoofFisherText
CeladonMansionRoofGraffiti:
jumptext CeladonMansionRoofGraffitiText
CeladonMansionRoofFisherText:
text "High places--I do"
line "love them so!"
para "I'd say the only"
line "thing that loves"
para "heights as much as"
line "me is smoke!"
done
CeladonMansionRoofGraffitiText:
text "There's graffiti"
line "on the wall…"
para "<PLAYER> added a"
line "moustache!"
done
CeladonMansionRoof_MapEvents:
db 0, 0 ; filler
db 3 ; warp events
warp_event 1, 1, CELADON_MANSION_3F, 1
warp_event 6, 1, CELADON_MANSION_3F, 4
warp_event 2, 5, CELADON_MANSION_ROOF_HOUSE, 1
db 0 ; coord events
db 1 ; bg events
bg_event 6, 1, BGEVENT_LEFT, CeladonMansionRoofGraffiti
db 1 ; object events
object_event 7, 5, SPRITE_FISHER, SPRITEMOVEDATA_WALK_UP_DOWN, 0, 1, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, CeladonMansionRoofFisherScript, -1
|
; A290564: Number of primes between n^2 and 2*n^2.
; Submitted by Christian Krause
; 1,2,3,5,6,9,10,13,15,21,23,27,29,33,39,43,45,52,56,61,67,71,78,85,90,95,102,110,117,124,131,137,145,153,163,167,180,190,196,201,211,218,233,241,252,261,271,281,290,302,314,320,329,344,355,371,385,393,407,416,423,443
mov $2,2
add $2,$0
mul $0,$2
mov $3,$0
seq $0,108954 ; a(n) = pi(2*n) - pi(n). Number of primes in the interval (n,2n].
sub $2,1
gcd $3,$2
add $0,$3
sub $0,1
|
/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#pragma once
#include "src/gen-cpp2/module_types.h"
#include <thrift/lib/cpp2/GeneratedSerializationCodeHelper.h>
#include <thrift/lib/cpp2/protocol/BinaryProtocol.h>
#include <thrift/lib/cpp2/protocol/CompactProtocol.h>
#include <thrift/lib/cpp2/protocol/ProtocolReaderStructReadState.h>
namespace cpp2 {
template <class Protocol_>
void House::readNoXfer(Protocol_* iprot) {
apache::thrift::detail::ProtocolReaderStructReadState<Protocol_> _readState;
_readState.readStructBegin(iprot);
using apache::thrift::TProtocolException;
if (UNLIKELY(!_readState.advanceToNextField(
iprot,
0,
1,
apache::thrift::protocol::T_I64))) {
goto _loop;
}
_readField_id:
{
::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, ::cpp2::ColorID>::read(*iprot, this->id);
}
if (UNLIKELY(!_readState.advanceToNextField(
iprot,
1,
2,
apache::thrift::protocol::T_STRING))) {
goto _loop;
}
_readField_houseName:
{
iprot->readString(this->houseName);
}
if (UNLIKELY(!_readState.advanceToNextField(
iprot,
2,
3,
apache::thrift::protocol::T_SET))) {
goto _loop;
}
_readField_houseColors:
{
this->houseColors = std::set< ::cpp2::ColorID>();
::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::set<::apache::thrift::type_class::integral>, std::set< ::cpp2::ColorID>>::read(*iprot, this->houseColors.value());
}
if (UNLIKELY(!_readState.advanceToNextField(
iprot,
3,
0,
apache::thrift::protocol::T_STOP))) {
goto _loop;
}
_end:
_readState.readStructEnd(iprot);
return;
_loop:
if (_readState.fieldType == apache::thrift::protocol::T_STOP) {
goto _end;
}
if (iprot->kUsesFieldNames()) {
this->translateFieldName(_readState.fieldName(), _readState.fieldId, _readState.fieldType);
}
switch (_readState.fieldId) {
case 1:
{
if (LIKELY(_readState.fieldType == apache::thrift::protocol::T_I64)) {
goto _readField_id;
} else {
goto _skip;
}
}
case 2:
{
if (LIKELY(_readState.fieldType == apache::thrift::protocol::T_STRING)) {
goto _readField_houseName;
} else {
goto _skip;
}
}
case 3:
{
if (LIKELY(_readState.fieldType == apache::thrift::protocol::T_SET)) {
goto _readField_houseColors;
} else {
goto _skip;
}
}
default:
{
_skip:
iprot->skip(_readState.fieldType);
_readState.readFieldEnd(iprot);
_readState.readFieldBeginNoInline(iprot);
goto _loop;
}
}
}
template <class Protocol_>
uint32_t House::serializedSize(Protocol_ const* prot_) const {
uint32_t xfer = 0;
xfer += prot_->serializedStructSize("House");
xfer += prot_->serializedFieldSize("id", apache::thrift::protocol::T_I64, 1);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, ::cpp2::ColorID>::serializedSize<false>(*prot_, this->id);
xfer += prot_->serializedFieldSize("houseName", apache::thrift::protocol::T_STRING, 2);
xfer += prot_->serializedSizeString(this->houseName);
if (this->houseColors.hasValue()) {
xfer += prot_->serializedFieldSize("houseColors", apache::thrift::protocol::T_SET, 3);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::set<::apache::thrift::type_class::integral>, std::set< ::cpp2::ColorID>>::serializedSize<false>(*prot_, this->houseColors.value());
}
xfer += prot_->serializedSizeStop();
return xfer;
}
template <class Protocol_>
uint32_t House::serializedSizeZC(Protocol_ const* prot_) const {
uint32_t xfer = 0;
xfer += prot_->serializedStructSize("House");
xfer += prot_->serializedFieldSize("id", apache::thrift::protocol::T_I64, 1);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, ::cpp2::ColorID>::serializedSize<false>(*prot_, this->id);
xfer += prot_->serializedFieldSize("houseName", apache::thrift::protocol::T_STRING, 2);
xfer += prot_->serializedSizeString(this->houseName);
if (this->houseColors.hasValue()) {
xfer += prot_->serializedFieldSize("houseColors", apache::thrift::protocol::T_SET, 3);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::set<::apache::thrift::type_class::integral>, std::set< ::cpp2::ColorID>>::serializedSize<false>(*prot_, this->houseColors.value());
}
xfer += prot_->serializedSizeStop();
return xfer;
}
template <class Protocol_>
uint32_t House::write(Protocol_* prot_) const {
uint32_t xfer = 0;
xfer += prot_->writeStructBegin("House");
xfer += prot_->writeFieldBegin("id", apache::thrift::protocol::T_I64, 1);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, ::cpp2::ColorID>::write(*prot_, this->id);
xfer += prot_->writeFieldEnd();
xfer += prot_->writeFieldBegin("houseName", apache::thrift::protocol::T_STRING, 2);
xfer += prot_->writeString(this->houseName);
xfer += prot_->writeFieldEnd();
if (this->houseColors.hasValue()) {
xfer += prot_->writeFieldBegin("houseColors", apache::thrift::protocol::T_SET, 3);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::set<::apache::thrift::type_class::integral>, std::set< ::cpp2::ColorID>>::write(*prot_, this->houseColors.value());
xfer += prot_->writeFieldEnd();
}
xfer += prot_->writeFieldStop();
xfer += prot_->writeStructEnd();
return xfer;
}
} // cpp2
namespace cpp2 {
template <class Protocol_>
void Field::readNoXfer(Protocol_* iprot) {
apache::thrift::detail::ProtocolReaderStructReadState<Protocol_> _readState;
_readState.readStructBegin(iprot);
using apache::thrift::TProtocolException;
if (UNLIKELY(!_readState.advanceToNextField(
iprot,
0,
1,
apache::thrift::protocol::T_I64))) {
goto _loop;
}
_readField_id:
{
::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, ::cpp2::ColorID>::read(*iprot, this->id);
}
if (UNLIKELY(!_readState.advanceToNextField(
iprot,
1,
2,
apache::thrift::protocol::T_I32))) {
goto _loop;
}
_readField_fieldType:
{
::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, int32_t>::read(*iprot, this->fieldType);
}
if (UNLIKELY(!_readState.advanceToNextField(
iprot,
2,
0,
apache::thrift::protocol::T_STOP))) {
goto _loop;
}
_end:
_readState.readStructEnd(iprot);
return;
_loop:
if (_readState.fieldType == apache::thrift::protocol::T_STOP) {
goto _end;
}
if (iprot->kUsesFieldNames()) {
this->translateFieldName(_readState.fieldName(), _readState.fieldId, _readState.fieldType);
}
switch (_readState.fieldId) {
case 1:
{
if (LIKELY(_readState.fieldType == apache::thrift::protocol::T_I64)) {
goto _readField_id;
} else {
goto _skip;
}
}
case 2:
{
if (LIKELY(_readState.fieldType == apache::thrift::protocol::T_I32)) {
goto _readField_fieldType;
} else {
goto _skip;
}
}
default:
{
_skip:
iprot->skip(_readState.fieldType);
_readState.readFieldEnd(iprot);
_readState.readFieldBeginNoInline(iprot);
goto _loop;
}
}
}
template <class Protocol_>
uint32_t Field::serializedSize(Protocol_ const* prot_) const {
uint32_t xfer = 0;
xfer += prot_->serializedStructSize("Field");
xfer += prot_->serializedFieldSize("id", apache::thrift::protocol::T_I64, 1);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, ::cpp2::ColorID>::serializedSize<false>(*prot_, this->id);
xfer += prot_->serializedFieldSize("fieldType", apache::thrift::protocol::T_I32, 2);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, int32_t>::serializedSize<false>(*prot_, this->fieldType);
xfer += prot_->serializedSizeStop();
return xfer;
}
template <class Protocol_>
uint32_t Field::serializedSizeZC(Protocol_ const* prot_) const {
uint32_t xfer = 0;
xfer += prot_->serializedStructSize("Field");
xfer += prot_->serializedFieldSize("id", apache::thrift::protocol::T_I64, 1);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, ::cpp2::ColorID>::serializedSize<false>(*prot_, this->id);
xfer += prot_->serializedFieldSize("fieldType", apache::thrift::protocol::T_I32, 2);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, int32_t>::serializedSize<false>(*prot_, this->fieldType);
xfer += prot_->serializedSizeStop();
return xfer;
}
template <class Protocol_>
uint32_t Field::write(Protocol_* prot_) const {
uint32_t xfer = 0;
xfer += prot_->writeStructBegin("Field");
xfer += prot_->writeFieldBegin("id", apache::thrift::protocol::T_I64, 1);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, ::cpp2::ColorID>::write(*prot_, this->id);
xfer += prot_->writeFieldEnd();
xfer += prot_->writeFieldBegin("fieldType", apache::thrift::protocol::T_I32, 2);
xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, int32_t>::write(*prot_, this->fieldType);
xfer += prot_->writeFieldEnd();
xfer += prot_->writeFieldStop();
xfer += prot_->writeStructEnd();
return xfer;
}
} // cpp2
|
; A160011: Numerator of Hermite(n, 7/25).
; Submitted by Christian Krause
; 1,14,-1054,-49756,3255916,294362824,-16228395464,-2434918716496,107909598279056,25859921540866784,-851944079067245024,-335176236367776230336,7021763778025751855296,5125948238409003981014144,-42340386055192411914361984,-90296859576930263434548587776,-470273795542165964689393028864,1799353358401014945185320253115904,35184265172885235982244085406982656,-39992870851602442962918288499410082816,-1395526489778458556059153067407579239424,980284400433162654288129069541545961048064
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
mul $2,14
mul $3,-50
mul $3,$0
add $2,$3
mul $3,24
lpe
mov $0,$1
|
cpu 8008new
|
; Modify King of Red Lions's code so he doesn't stop you when you veer off the path he wants you to go on.
.open "files/rels/d_a_ship.rel"
; We need to change some of the conditions in his checkOutRange function so he still prevents you from leaving the bounds of the map, but doesn't railroad you based on your story progress.
; First is the check for before you've reached Dragon Roost Island. Make this branch unconditional so it considers you to have seen Dragon Roost's intro whether you have or not.
.org 0x29EC
b 0x2A50
; Second is the check for whether you've gotten Farore's Pearl. Make this branch unconditional too.
.org 0x2A08
b 0x2A50
; Third is the check for whether you have the Master Sword. Again make the branch unconditional.
.org 0x2A24
b 0x2A34
; Skip the check for if you've seen the Dragon Roost Island intro which prevents you from getting in the King of Red Lions.
; Make this branch unconditional as well.
.org 0xB2D8
b 0xB2F0
.close
|
%ifdef CONFIG
{
"Env": { "FEX_X87REDUCEDPRECISION" : "1" }
}
%endif
mov rdx, 0xe0000000
; Just to ensure execution
fldcw [rdx]
hlt
|
initFilesystem:
; Set all file handles to unused
ld hl, fileHandleTable
ld (hl), 0xFF
ld de, fileHandleTable + 1
ld bc, 8 * maxFileStreams
ldir
ret
; If findNode turned up a symlink, this will follow it and
; give the findNode return value for the final destination.
followSymLink:
#define newName kernelGarbage + 2 ; findNode uses kernelGarbage
push de
dec hl ; ID
dec hl \ dec hl ; Entry len
dec hl \ dec hl ; Parent ID
ld b, 0
ld c, (hl) \ dec hl ; Name length
scf \ ccf
sbc hl, bc
.recurse:
ld de, newName
.load_target_loop:
ld a, (hl)
ld (de), a
inc de \ dec hl
; NOTE: KFS spec doesn't mention the trailing zero, this should be standardized
or a
jr nz, .load_target_loop
ld de, newName
call findNode
jr nz, .not_found
setBankA
ld a, (hl)
cp fsSymLink
jr z, .recurse
cp a
.not_found:
pop de
ret
#undefine newName
;; openFileRead [Filestreams]
;; Opens a file stream in read-only mode.
;; Inputs:
;; DE: Path to file (string pointer)
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
;; D: File stream ID (on success)
;; E: Garbage (on success)
openFileRead:
push hl
push bc
push af
ld a, i
push af
di
push iy
push bc
push de
.linkLoop:
call findNode
jp nz, .fileNotFound
; Check if node is file or symlink or other
setBankA
ld a, (hl)
cp fsFile
jr z, .validNode
cp fsSymLink
jp nz, .fileNotFound ; TODO: use something like errNotAFile?
call followSymLink
jp nz, .fileNotFound
.validNode:
pop de
ld iy, fileHandleTable
ld bc, FILE_HANDLE_SIZE
ld d, 0
.findEntryLoop:
ld a, (iy)
cp 0xFF
jr z, .entryFound
add iy, bc
inc d
ld a, maxFileStreams - 1
cp d
jr nc, .findEntryLoop
; Too many active streams
; We could check (activeFileStreams) instead, but since we have to iterate through the table
; anyway, we may as well do it here and save some space.
pop bc
pop iy
pop af
jp po, _
ei
_: pop af
pop bc
pop hl
or a
ld a, errTooManyStreams
ret
.entryFound:
; We can put the stream entry at (iy) and use d as the ID
pop bc
push de
push ix
push hl
push af
call getCurrentThreadId
and 0b111111
ld (iy + FILE_FLAGS), a ; Flags & owner
; Create a buffer
ld bc, KFS_BLOCK_SIZE
call malloc
jp nz, .outOfMemory
push ix \ pop bc
ld (iy + FILE_BUFFER), c ; Buffer
ld (iy + FILE_BUFFER + 1), b
dec hl \ dec hl \ dec hl \ dec hl \ dec hl \ dec hl \ dec hl ; Move HL to middle file size byte
; Check for final block
xor a
ld (iy + FILE_FINAL_LENGTH), a
ld a, (hl)
or a ; cp 0
jr z, .final
cp 1
jr nz, .notFinal
; Check next byte to see if it's zero - if so, it's the final block
inc hl
ld a, (hl)
or a ; cp 0
jr nz, .notFinal - 1 ; (-1 adds the dec hl)
dec hl
.final:
set 7, (iy)
ld a, (hl)
ld (iy + FILE_FINAL_LENGTH), a
jr .notFinal
dec hl
.notFinal:
inc hl
ld a, (hl)
ld (iy + FILE_FINAL_LENGTH), a ; Length of final block
dec hl \ dec hl \ dec hl ; Move to section ID
ld c, (hl)
ld (iy + FILE_SECTION_ID), c
dec hl \ ld b, (hl)
ld (iy + FILE_SECTION_ID + 1), b
; Section ID in BC
call populateStreamBuffer
; Populate the previous section, which is 0xFFFF for new streams
ld a, 0xFF
ld (iy + FILE_PREV_SECTION), a
ld (iy + FILE_PREV_SECTION + 1), a
xor a
ld (iy + FILE_STREAM), a ; Stream pointer
pop af
pop hl
pop ix
pop de
; Load file entry info
ld (iy + FILE_ENTRY_PAGE), a
ld (iy + FILE_ENTRY_PTR), l
ld (iy + FILE_ENTRY_PTR + 1), h
; And the working file size
; This doesn't matter for ro streams
xor a
ld (iy + FILE_WORKING_SIZE), a
ld (iy + FILE_WORKING_SIZE + 1), a
ld (iy + FILE_WORKING_SIZE + 2), a
pop iy
pop af
jp po, _
ei
_: pop af
pop bc
pop hl
cp a
ret
.fileNotFound:
pop de
pop bc
pop iy
pop af
jp po, _
ei
_: pop af
pop bc
pop hl
ld a, errFileNotFound
cp 0
ret
.outOfMemory:
pop ix
pop de
pop iy
pop af
jp po, _
ei
_: pop af
pop bc
pop hl
ld a, errOutOfMem
or a
ret
; TODO: Error out if the parent directory does not exist
; Right now, closeStream is the first time that's ever checked
;; openFileWrite [Filestreams]
;; Opens a file stream in write mode. If the file does not exist,
;; it is created.
;; Inputs:
;; DE: Path to file (string pointer)
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
;; D: File stream ID (on success)
;; E: Garbage (on success)
openFileWrite:
push hl
push bc
push af
ld a, i
push af
di
push iy
push bc
ld iy, fileHandleTable
ld bc, FILE_HANDLE_SIZE
ld l, 0
.findEntryLoop:
ld a, (iy + FILE_FLAGS)
cp 0xFF
jr z, .entryFound
add iy, bc
inc l
ld a, maxFileStreams - 1
cp l
jr nc, .findEntryLoop
; Too many active streams
; We could check (activeFileStreams) instead, but since we have to iterate through the table
; anyway, we may as well do it here and save some space.
pop bc
pop iy
pop af
jp po, _
ei
_: pop af
pop bc
pop hl
or a
ld a, errTooManyStreams
ret
.entryFound:
push hl
call findNode ; TODO: Check if this is a file, follow symlinks, etc
jp nz, .fileNotFound
pop de
ld d, e
; The rest of this code path *only* covers existing files that are being overwritten
; The case of brand-new files is handled in .fileNotFound
; We can put the stream entry at (iy) and use d as the ID
push de
push ix
push hl
push af
call getCurrentThreadId
and 0b111111
or 0b01000000 ; Set writable
ld (iy), a ; Flags & owner
; Create a buffer
ld bc, KFS_BLOCK_SIZE
ld a, 1
call calloc
jp nz, .outOfMemory
push ix \ pop bc
ld (iy + FILE_BUFFER), c ; Buffer
ld (iy + FILE_BUFFER + 1), b
dec hl \ dec hl \ dec hl \ dec hl \ dec hl \ dec hl \ dec hl ; Move HL to middle file size byte
; Check for final block
; Note to self: how on earth does this properly check if this is the last block
; Will this fail on files >64K in length?
; Someone should examine this more closely later, I'm in the middle of something.
; openFileRead is likely affected by the same.
xor a
ld (iy + FILE_FINAL_LENGTH), a
ld a, (hl)
or a ; cp 0
jr z, .final
cp 1
jr nz, .notFinal
; Check next byte to see if it's zero - if so, it's the final block
inc hl
ld a, (hl)
or a ; cp 0
jr nz, .notFinal - 1 ; -1 adds dec hl
dec hl
.final:
set 7, (iy + FILE_FLAGS)
ld a, (hl)
ld (iy + FILE_FINAL_LENGTH), a
jr .notFinal
dec hl
.notFinal:
inc hl
ld a, (hl)
ld (iy + FILE_FINAL_LENGTH), a ; Length of final block
dec hl \ dec hl \ dec hl ; Move to section ID
ld c, (hl)
ld (iy + FILE_SECTION_ID), c
dec hl \ ld b, (hl)
ld (iy + FILE_SECTION_ID + 1), b
; Section ID in BC
call populateStreamBuffer
; Populate the previous section, which is 0xFFFF for new streams
ld a, 0xFF
ld (iy + FILE_PREV_SECTION), a
ld (iy + FILE_PREV_SECTION + 1), a
; Stream pointer
xor a
ld (iy + FILE_STREAM), a
pop af
pop hl
pop ix
pop de
push af
; Load file entry info
ld (iy + FILE_ENTRY_PAGE), a
ld (iy + FILE_ENTRY_PTR), l
ld (iy + FILE_ENTRY_PTR + 1), h
ld a, 1 ; Stream is flushed
ld (iy + FILE_WRITE_FLAGS), a ; Set stream write flags (TODO: Move flags around)
pop af
setBankA
ld bc, 6
or a
sbc hl, bc
ld a, (hl)
ld (iy + FILE_WORKING_SIZE), a
dec hl \ ld a, (hl)
ld (iy + FILE_WORKING_SIZE + 1), a
dec hl \ ld a, (hl)
ld (iy + FILE_WORKING_SIZE + 2), a
.done:
_: pop bc
pop iy
pop af
jp po, _
ei
_: pop af
pop bc
pop hl
ret
.fileNotFound:
;push hl
push af
; Set up some important parts of the file entry first
ex de, hl
call strlen
inc bc
push ix
call malloc
; TODO: Handle out of memory
push ix \ pop de
pop ix
push de
ldir
pop de
; FILE_ENTRY_PAGE and FILE_ENTRY_PTR are not important when working with brand-new files
; We use them instead to save the file name to memory so we can use it later.
; FILE_ENTRY_PAGE set to zero indicates this special case.
xor a
ld (iy + FILE_ENTRY_PAGE), a
ld (iy + FILE_ENTRY_PTR), e
ld (iy + FILE_ENTRY_PTR + 1), d
pop af
; Now we just have to populate the rest of this file handle
push ix
call getCurrentThreadId
and 0b111111
or 0b01000000 ; Set writable
ld (iy + FILE_FLAGS), a ; Flags & owner
; Create a buffer
ld bc, KFS_BLOCK_SIZE
ld a, 1
call calloc
jp nz, .outOfMemory
push ix \ pop bc
ld (iy + FILE_BUFFER), c ; Buffer
ld (iy + FILE_BUFFER + 1), b
xor a
ld (iy + FILE_FINAL_LENGTH), a
set 7, (iy + FILE_FLAGS) ; Set "final block"
ld a, 0xFF
ld (iy + FILE_SECTION_ID), a
ld (iy + FILE_SECTION_ID + 1), a
ld (iy + FILE_PREV_SECTION), a
ld (iy + FILE_PREV_SECTION + 1), a
xor a
ld (iy + FILE_STREAM), a
ld (iy + FILE_WORKING_SIZE), a
ld (iy + FILE_WORKING_SIZE + 1), a
ld (iy + FILE_WORKING_SIZE + 2), a
inc a ; Stream is flushed
ld (iy + FILE_WRITE_FLAGS), a ; TODO: Move flags around
; End of stream
set 5, (iy + FILE_FLAGS)
pop ix
pop hl
ld d, l
jp .done
.outOfMemory:
pop ix
pop de
pop iy
pop af
jp po, _
ei
_: pop af
pop bc
pop hl
ld a, errOutOfMem
or a
ret
; Section ID in BC, block in IX
populateStreamBuffer:
push af
getBankA
push af
push de
push hl
push bc
ld hl, 0xFFFF
call cpHLBC
jr z, _
ld a, b
setBankA
ld a, c
add a, 0x40
ld h, a
ld l, 0
ld bc, KFS_BLOCK_SIZE
push ix \ pop de
ldir
pop bc
pop hl
pop de
pop af
setBankA
pop af
ret
_: push ix \ pop de ; New blocks get to be 0xFF
ld h, d \ ld l, e
inc de
ld a, 0xFF
ld (hl), a
ld bc, KFS_BLOCK_SIZE
ldir
pop bc
pop hl
pop de
pop af
setBankA
pop af
ret
;; getStreamBuffer [Filestreams]
;; Gets the address of a stream's memory buffer.
;; Inputs:
;; D: Stream ID
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
;; HL: Stream buffer (on success)
;; Notes:
;; For read-only streams, modifying this buffer could have unforseen consequences and it will not be copied back to the file.
;; For writable streams, make sure you call [[flush]] if you modify this buffer and want to make the changes persist to the file.
getStreamBuffer:
push ix
call getStreamEntry
jr nz, .fail
ld l, (ix + FILE_BUFFER)
ld h, (ix + FILE_BUFFER + 1)
pop ix
ret
.fail:
pop ix
ret
; getStreamEntry [Filestreams]
; Gets the address of a stream entry in the kernel file stream table.
; Note that it is almost always better to use the kernel functions for
; getting data out of this, because the internal struct layout may
; change between kernel releases.
; Inputs:
; D: Stream ID
; Outputs:
; Z: Set on success, reset on failure
; A: Error code (on failure)
; IX: File stream entry pointer (on success)
getStreamEntry:
push af
push hl
push bc
ld a, d
cp maxFileStreams
jr nc, .notFound
or a \ rla \ rla \ rla \ rla ; A *= 16 (length of file handle)
ld ix, fileHandleTable
add ixl \ ld ixl, a
ld a, (ix)
cp 0xFF
jr z, .notFound
pop bc
inc sp \ inc sp
pop af
cp a
ret
.notFound:
pop bc
pop hl
pop af
or 1
ld a, errStreamNotFound
ret
;; closeStream [Filestreams]
;; Closes an open stream.
;; Inputs:
;; D: Stream ID
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
closeStream:
push ix
push af
ld a, i
push af
di
call getStreamEntry
jr nz, .fail
bit 6, (ix)
jr nz, .closeWritableStream
push hl
ld (ix + FILE_FLAGS), 0xFF
ld l, (ix + FILE_BUFFER)
ld h, (ix + FILE_BUFFER + 1)
push hl \ pop ix
call free
ld hl, activeFileStreams
dec (hl)
pop hl
pop af
jp po, _
ei
_: pop af
pop ix
cp a
ret
.fail:
pop ix
ret
.closeWritableStream:
push bc
push de
push hl
push iy
call flush_withStream
xor a
ld l, (ix + FILE_ENTRY_PTR)
ld h, (ix + FILE_ENTRY_PTR + 1)
cp (ix + FILE_ENTRY_PAGE)
jp nz, .overwriteFile
; Find the parent directory and extract the file name alone
call strlen
inc bc
ld de, kernelGarbage + 0x100
push bc
ldir
pop bc
ld hl, kernelGarbage + 0x100
add hl, bc
ld a, '/'
cpdr
inc hl
xor a
ld (hl), a
push hl
ld de, kernelGarbage + 0x100
call findNode ; TODO: Check that this is a directory node
jp nz, .wtf
setBankA
pop de
ex de, hl
ld a, '/'
ld (hl), a
inc hl
push hl
ex de, hl
dec hl \ dec hl \ dec hl
dec hl \ dec hl
ld e, (hl) \ dec hl \ ld d, (hl) ; Parent dir
ld a, (ix + FILE_WORKING_SIZE + 2)
ld c, (ix + FILE_WORKING_SIZE)
ld b, (ix + FILE_WORKING_SIZE + 1)
ld l, (ix + FILE_SECTION_ID)
ld h, (ix + FILE_SECTION_ID + 1)
; Traverse the sections to find the first
; TODO: We can skip one iteration by pulling the PREV_SECTION_ID
; from the file handle
push af
push de
push hl
_: ld a, h
setBankA
ld a, l
rlca \ rlca
ld l, a
ld h, 0x40
ld e, (hl)
inc hl
ld d, (hl)
ex de, hl
ld de, 0x7FFF
call cpHLDE
jr z, _
inc sp \ inc sp \ push hl
jr -_
_: pop hl
pop de
pop af
push hl \ pop iy
pop hl
.resumeWrite:
call createFileEntry
jp nz, .wtf + 2
; Clear away file handle
push hl
ld (ix), 0xFF
ld l, (ix + FILE_BUFFER)
ld h, (ix + FILE_BUFFER + 1)
push hl \ pop ix
call free
ld hl, activeFileStreams
dec (hl)
pop hl
pop iy
pop hl
pop de
pop bc
pop af
jp po, _
ei
_: pop af
pop ix
cp a
ret
.overwriteFile:
ld a, (ix + FILE_ENTRY_PAGE)
ld l, (ix + FILE_ENTRY_PTR)
ld h, (ix + FILE_ENTRY_PTR + 1)
setBankA
ld a, fsModifiedFile
call unlockFlash
call writeFlashByte ; Mark old entry as modified
call lockFlash
; Load appropriate values for createFileEntry
dec hl \ dec hl \ dec hl
ld e, (hl)
dec hl
ld d, (hl) ; Parent ID
push de
; Grab file name, too
ld bc, -7
add hl, bc
ld bc, 0
ld de, kernelGarbage + 0x100
_: ld a, (hl)
ld (de), a
dec hl
inc de
inc bc
or a
jr nz, -_
ld l, (ix + FILE_SECTION_ID)
ld h, (ix + FILE_SECTION_ID + 1)
; Traverse to find first section
push af
push hl
_: ld a, h
setBankA
ld a, l
rlca \ rlca
and 0b11111100
ld l, a
ld h, 0x40
ld e, (hl)
inc hl
ld d, (hl)
ex de, hl
ld de, 0x7FFF
call cpHLDE
jr z, _
inc sp \ inc sp \ push hl
jr -_
_: pop hl
pop af
push hl \ pop iy
ex de, hl
ld hl, kernelGarbage + 0x100 ; File name
ld a, (ix + FILE_WORKING_SIZE + 2)
ld c, (ix + FILE_WORKING_SIZE)
ld b, (ix + FILE_WORKING_SIZE + 1)
pop de
jp .resumeWrite
.wtf:
pop hl
pop iy
pop hl
pop de
pop bc
pop af
jp po, _
ei
_: pop af
pop ix
ld a, 'W'|'T'|'F'
or 1
ret
; Flushes writes and loads the next block
advanceBlock:
call flush
ret nz
push ix
push hl
push bc
push af
ld a, i
push af
di
call getStreamEntry
ld l, (ix + FILE_SECTION_ID)
ld h, (ix + FILE_SECTION_ID + 1)
ld (ix + FILE_PREV_SECTION), l
ld (ix + FILE_PREV_SECTION + 1), h
; Grab the next block
ld a, h
setBankA
ld a, l
rlca \ rlca \ inc a \ inc a
ld l, a
ld h, 0x40
ld c, (hl)
inc hl
ld b, (hl)
ld (ix + FILE_SECTION_ID), c
ld (ix + FILE_SECTION_ID + 1), b
ld l, (ix + FILE_BUFFER)
ld h, (ix + FILE_BUFFER + 1)
push hl \ pop ix
call populateStreamBuffer
pop af
jp po, _
ei
_: pop af
pop bc
pop hl
pop ix
ret
;; flush [Filestreams]
;; Flushes pending writes to disk.
;; Inputs:
;; D: Stream ID
;; Outputs:
;; A: Preserved on success; error code on error
;; Z: Set on success, reset on error
;; Notes:
;; This happens periodically as you write to the stream, and happens
;; automatically on closeStream. Try not to use it unless you have to.
flush:
push ix
push af
ld a, i
push af
di
call getStreamEntry
jp nz, _flush_fail
bit 6, (ix + FILE_FLAGS)
jp z, _flush_exitEarly ; Do nothing if not writable
_flush_withStream:
bit 0, (ix + FILE_WRITE_FLAGS) ; Check if flushed
jp nz, _flush_exitEarly
push ix
push hl
push bc
push de
; Find a free block
ld a, 4
.pageLoop:
setBankA
ld hl, 0x4000 + 5
.searchLoop:
ld a, (hl)
bit 7, a
jr nz, .freeBlockFound
inc hl \ inc hl \ inc hl \ inc hl
ld bc, 0x4101 ; End of section
call cpHLBC
jr nz, .searchLoop
; Next page
getBankA
inc a
; TODO: Stop at end of filesystem
jr .pageLoop
.freeBlockFound:
dec hl
push hl
; Convert HL into section ID
sra l \ sra l ; L /= 4 to get index
ld a, l
and 0b00111111
ld l, a
getBankA
ld h, a
push hl
; Write buffer to disk
ld a, l
add a, 0x40
call getStreamBuffer ; At this point, D is still the stream ID
ld d, a
ld e, 0
ld bc, KFS_BLOCK_SIZE
call unlockFlash
call writeFlashBuffer
pop hl
pop de
; HL is new section ID, DE is header pointer
.firstSection:
push hl
; We have to check to see if the section we're editing is already allocated, and if
; so, we have to reallocate it elsewhere.
; Best case - current section ID is set to 0xFFFF
ld c, (ix + FILE_PREV_SECTION)
ld b, (ix + FILE_PREV_SECTION + 1)
res 7, b
ld (kernelGarbage), bc
ld bc, 0xFFFF
ld l, (ix + FILE_SECTION_ID)
ld h, (ix + FILE_SECTION_ID + 1)
call cpHLBC ; BC == 0xFFFF
jr z, _ ; Current section ID is 0xFFFF, so skip this
; Grab the next section ID from the obsolete section
getBankA
push af
ld a, h
setBankA
ld a, l
rlca \ rlca \ and 0b11111100 \ inc a \ inc a
ld l, a
ld h, 0x40
ld c, (hl)
inc hl
ld b, (hl)
pop af
setBankA
_: ld (kernelGarbage + 2), bc
ld bc, 4
ld hl, kernelGarbage
call writeFlashBuffer
ld bc, (kernelGarbage + 2) ; Grab next section ID again
ld hl, 0xFFFF
call cpHLBC
pop hl \ push hl
call nz, flush_updateNextSection
; Update previous section's header if needed
ld l, (ix + FILE_PREV_SECTION)
ld h, (ix + FILE_PREV_SECTION + 1)
ld bc, 0xFFFF
call cpHLBC
jr z, _ ; "if needed"
; HL is previous section ID (needs updating)
ld c, l \ ld b, h
pop hl \ push hl
call flush_updatePreviousSection
_: pop hl
; End wrong
; Load current section ID into file handle
ld (ix + FILE_SECTION_ID), l
ld (ix + FILE_SECTION_ID + 1), h
.done:
call lockFlash
pop de
pop bc
pop hl
pop ix
set 0, (ix + FILE_WRITE_FLAGS) ; Mark as flushed
_flush_exitEarly:
pop af
jp po, _
ei
_: pop af
pop ix
cp a
ret
_flush_fail:
call lockFlash
pop af
jp po, _
ei
_: pop af
pop ix
or 1
ld a, errStreamNotFound
ret
flush_withStream:
push ix
push af
ld a, i
push af
jp _flush_withStream
flush_updatePreviousSection:
push de ; Can destroy all others
ld a, b
setBankA
ld a, c
rlca \ rlca \ inc a \ inc a
ld e, a
ld d, 0x40
; We'll do a quick check to make sure we really really have to erase flash
; Perform A & B ^ B for both octets and if Z is set, we don't need to erase
ex de, hl
ld a, (hl)
and e
xor e
jr nz, .mustErase + 1
inc hl
ld a, (hl)
and d
xor d
jr nz, .mustErase
; Woo we can do it without an erasure
ex de, hl
ld (kernelGarbage), hl
dec de
ld bc, 2
ld hl, kernelGarbage
call writeFlashBuffer
pop de
ret
.mustErase:
dec hl
ex de, hl
jr flush_update_mustErase
; We have to do a flash erasure for this procedure
; HL is the new section ID
; BC is the section to update
; This is the worst case for performance, to be avoided
; The performance of this can probably be made better by way of some custom RAM shellcode
; instead of using the flash driver directly
; To be investigated later, this is an edge case after all
flush_updateNextSection:
push de ; Can destroy all others
ld a, b
setBankA
ld a, c
rlca \ rlca
ld e, a
ld d, 0x40
; We'll do a quick check to make sure we really really have to erase flash
; Perform A & B ^ B for both octets and if Z is set, we don't need to erase
ex de, hl
ld a, (hl)
and e
xor e
jr nz, .mustErase + 1
inc hl
ld a, (hl)
and d
xor d
jr nz, .mustErase
; Woo we can do it without an erasure
ex de, hl
ld (kernelGarbage), hl
dec de
ld bc, 2
ld hl, kernelGarbage
call writeFlashBuffer
pop de
ret
.mustErase:
dec hl
ex de, hl
flush_update_mustErase:
; DE points to the address that needs fixing up
; HL is the value to fix it up to
getBankA
push de
push hl
; Clear the sector and restore all but the affected page
call copySectorToSwap
call eraseFlashSector
ld b, swapSector
ld d, a ; Flash page being dealt with
and 0b11111100 ; Start of sector
ld e, a
_: or e
cp d
call nz, copyFlashPage
inc a
inc b
and 0b00000011
jr nz, -_
.modifiedPage:
; Re-write the old page, minus the first 0x200 bytes
ld a, d
and 0b00000011
add a, swapSector
ld b, a
ld a, d
; A is source page
; B is destination page
ld hl, 0x4042 ; Skip the first 0x200 bytes
call copyFlashExcept
ld a, b
setBankA
ld a, d
ld hl, 0x4000
ld de, kernelGarbage
ld bc, 0x200
ldir ; Move the header into kernelGarbage to edit
setBankA
pop hl
pop de
ex de, hl
ld h, kernelGarbage >> 8 ; TODO: What if kernelGarbage isn't aligned?
ld (hl), e
inc hl
ld (hl), d
ld hl, kernelGarbage
ld de, 0x4000
ld bc, 0x200
call writeFlashBuffer
pop de
ret
;; streamWriteByte [Filestreams]
;; Writes a single byte to a file stream and advances the stream.
;; Inputs:
;; D: Stream ID
;; A: Value
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
streamWriteByte:
push ix
push af
call getStreamEntry
jr z, .writeByte
.errStreamNotFound:
pop af
pop ix
or 1
ld a, errStreamNotFound
ret
.errNotWritable:
pop af
pop ix
or 1
ld a, errReadOnly
ret
.writeByte:
bit 6, (ix + FILE_FLAGS)
jr z, .errNotWritable
push hl
push bc
ld l, (ix + FILE_BUFFER)
ld h, (ix + FILE_BUFFER + 1)
ld b, 0
ld c, (ix + FILE_STREAM)
add hl, bc
ld (hl), a ; Write actual value
; Mark stream as not flushed
res 0, (ix + FILE_WRITE_FLAGS)
; Advance stream
inc c
ld (ix + FILE_STREAM), c
xor a
cp c
call z, advanceBlock
; Bump file size if at end of stream
bit 5, (ix + FILE_FLAGS)
jr z, _
ld c, (ix + FILE_WORKING_SIZE)
ld b, (ix + FILE_WORKING_SIZE + 1)
inc bc
ld a, c
or b
jr nz, $+5 \ inc (ix + FILE_WORKING_SIZE + 2)
ld (ix + FILE_WORKING_SIZE), c
ld (ix + FILE_WORKING_SIZE + 1), b
_: pop bc
pop hl
pop af
pop ix
cp a
ret
;; streamWriteWord [Filestreams]
;; Writes a 16-bit word to a file stream and advances the stream.
;; Inputs:
;; D: Stream ID
;; HL: Value
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
streamWriteWord:
push af
ld a, l
call streamWriteByte
jr nz, .error
ld a, h
call streamWriteByte
jr nz, .error
pop af
ret
.error:
inc sp \ inc sp
ret
;; streamReadByte [Filestreams]
;; Reads a single byte from a file stream and advances the stream.
;; Inputs:
;; D: Stream ID
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Data read (on success); Error code (on failure)
streamReadByte:
push ix
push hl
call getStreamEntry
jr nz, .fail
ld l, (ix + FILE_BUFFER)
ld h, (ix + FILE_BUFFER + 1)
ld a, (ix + FILE_STREAM)
bit 7, (ix + FILE_FLAGS)
jr z, ++_
; check for end of stream
bit 5, (ix + FILE_FLAGS) ; Set on EOF
jr z, _
pop hl
pop ix
or 1
ld a, errEndOfStream
ret
_: cp (ix + FILE_FINAL_LENGTH)
jr c, _
jr nz, _
; End of stream!
pop hl
pop ix
or 1
ld a, errEndOfStream
ret
_: add l
ld l, a
jr nc, _
inc h
_: ld a, (ix + FILE_STREAM)
add a, 1 ; inc doesn't affect flags
ld (ix + FILE_STREAM), a
ld a, (hl)
jr nc, _
; We need to get the next block (or end of stream)
call getNextBuffer
_: pop hl
pop ix
cp a
ret
.fail:
pop hl
pop ix
ret
getNextBuffer:
push af
bit 7, (ix + FILE_FLAGS)
jr z, _
; Set EOF
set 5, (ix + FILE_FLAGS)
pop af
ret
_: push bc
push hl
ld a, i
push af
di
call selectSection
or a \ rlca \ rlca \ inc a \ inc a
ld l, a
ld h, 0x40
ld c, (hl)
inc hl
ld b, (hl)
push ix
ld l, (ix + FILE_BUFFER)
ld h, (ix + FILE_BUFFER + 1)
push hl \ pop ix
call populateStreamBuffer
pop ix
; Update the entry in the stream table
ld (ix + FILE_SECTION_ID), c
ld (ix + FILE_SECTION_ID + 1), b
; Check if this is the last block
call selectSection
or a \ rlca \ rlca \ inc a \ inc a
ld l, a
ld h, 0x40
ld a, 0xFF
cp (hl)
jr nz, _
inc hl \ cp (hl)
jr nz, _
; Set last section stuff
set 7, (ix + FILE_FLAGS)
_: pop af
jp po, _
ei
_: pop hl
pop bc
pop af
ret
; Given stream entry at IX, grabs the section ID, swaps in the page, and sets A to the block index.
selectSection:
ld a, (ix + FILE_SECTION_ID + 1)
setBankA
ld a, (ix + FILE_SECTION_ID)
ret
;; streamReadWord [Filestreams]
;; Reads a 16-bit word from a file stream and advances the stream.
;; Inputs:
;; D: Stream ID
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
;; HL: Data read (on success)
streamReadWord:
; TODO: Perhaps optimize this into something like streamReadByte
; The problem here is that reading two bytes requires you to do some
; additional bounds checks that would make us basically put the same
; code in twice (i.e. what happens when the word straddles a block
; boundary? Although the only time this would happen is when the pointer
; is on the last byte of the block.)
push af
call streamReadByte
jr nz, .error
ld l, a
call streamReadByte
jr nz, .error
ld h, a
pop af
ret
.error:
inc sp \ inc sp
ret
;; streamWriteBuffer [Filestreams]
;; Writes a buffer of bytes to a file stream and advances the stream.
;; Inputs:
;; D: Stream ID
;; IX: Buffer address
;; BC: Length
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
streamWriteBuffer:
push ix
push de
push hl
push af
push ix \ pop hl
call getStreamEntry
jr z, .continue
.errStreamNotFound:
pop af
pop hl
pop de
pop ix
or 1
ld a, errStreamNotFound
ret
.errNotWritable:
pop af
pop hl
pop de
pop ix
or 1
ld a, errReadOnly
ret
.continue:
bit 6, (ix + FILE_FLAGS)
jr z, .errNotWritable
.loop:
xor a
cp b \ jr nz, .write
cp c \ jr z, .done
.write:
; Note: 256 is represented with 0 in 8-bit registers here
ld a, (ix + FILE_STREAM)
neg ; Amount left in the buffer
or a
jr z, _
cp c
jr c, ++_
_: ld a, c
or a ; Handle A == 0 (i.e. 256)
jr nz, _
ld a, (ix + FILE_STREAM)
neg
_: ; A is the number of bytes to write this time around the loop
push bc
push af
push de
ld e, (ix + FILE_BUFFER)
ld d, (ix + FILE_BUFFER + 1)
ld b, 0
ld c, (ix + FILE_STREAM)
ex de, hl
add hl, bc
ex de, hl
ld c, a
or a \ jr nz, $+3 \ inc b ; 0 == 256
push bc
ldir
pop bc
res 0, (ix + FILE_WRITE_FLAGS) ; Mark as not flushed
ld a, (ix + FILE_STREAM)
add a, c
ld (ix + FILE_STREAM), a
pop de
bit 7, (ix + FILE_FLAGS)
call z, .check_end
or a ; cp 0
call z, advanceBlock
bit 5, (ix + FILE_FLAGS) ; eof
jr z, .done_2
ld a, (ix + FILE_WORKING_SIZE)
add c
ld (ix + FILE_WORKING_SIZE), a
jr nc, _ \ inc (ix + FILE_WORKING_SIZE + 1)
_: jr nc, _ \ inc (ix + FILE_WORKING_SIZE + 2)
_: ld a, (ix + FILE_WORKING_SIZE + 1)
add b
ld (ix + FILE_WORKING_SIZE + 1), a
jr nc, _ \ inc (ix + FILE_WORKING_SIZE + 2)
_: pop af
pop bc
neg
add a, c
ld c, a
jr c, .loop
dec b
jr .loop
.done:
pop af
pop hl
pop de
pop ix
cp a
ret
.done_2:
pop af
pop bc
jr .done
.check_end:
; Checks if the amount written increases the file size
push af
push bc
ld a, (ix + FILE_STREAM)
ld c, a
ld a, (ix + FILE_FINAL_LENGTH)
cp c
jr nc, .nope
set 5, (ix + FILE_STREAM) ; set eof
.nope:
pop bc
pop af
ret
;; streamReadBuffer [Filestreams]
;; Reads a number of bytes from a file stream and advances the stream.
;; Inputs:
;; D: Stream ID
;; IX: Destination address
;; BC: Length
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
;; Notes:
;; If BC is greater than the remaining space in the stream, the stream will be advanced to the end
;; before returning an error.
streamReadBuffer:
push hl \ push bc \ push de \ push af \ push ix ; Chance for optimization - skip all these if not found
call getStreamEntry
jr z, .streamFound
pop ix \ pop de \ pop de \ pop bc \ pop hl
ret
.streamFound:
pop de \ push de ; the value of IX before getStreamEntry was called
ld l, (ix + FILE_BUFFER)
ld h, (ix + FILE_BUFFER + 1)
ld a, (ix + FILE_STREAM)
add l, a \ ld l, a \ jr nc, $+3 \ inc h
.readLoop:
; Registers:
; DE: Destination in RAM
; HL: Buffer pointer (including current position offset)
; IX: File stream entry
; BC: Total length left to read
; Try to return if BC == 0
xor a
cp c
jr nz, _
cp b
jp z, .done
_: bit 5, (ix + FILE_FLAGS) ; Check for EOF
jr nz, .endOfStream
push bc
; Check if we have enough space left in file stream
bit 7, (ix + FILE_FLAGS) ; Final block?
jr z, _
; Final block.
cp (ix + FILE_FINAL_LENGTH) ; A is still zero
jr z, .readOkay
ld a, (ix + FILE_FINAL_LENGTH)
cp c
jr nc, .readOkay
jr .endOfStream - 1
_: xor a
cp c
jr nz, .readOkay ; 0 < n < 0x100
; We need to read 0x100 bytes this round
bit 7, (ix + FILE_FLAGS)
jr z, .readOkay ; Not the final block, go for it
cp (ix + FILE_FINAL_LENGTH)
jr z, .readOkay
; Not enough space
pop bc
.endOfStream:
pop ix \ pop de \ pop de \ pop bc \ pop hl
or 1 \ ld a, errEndOfStream \ ret
.readOkay:
ld b, 0
ld a, c
or a ; cp 0
jr nz, _
ld bc, KFS_BLOCK_SIZE
; BC is the amount they want us to read, assuming we're at the start of the block
; But we may not be at the start of the block - handle that here
; If (amount left in block) is less than BC, set BC to (amount left in block)
; See if we can manage a full block
cp (ix + FILE_STREAM)
jr z, .doRead
; We can't, so truncate
sub (ix + FILE_STREAM)
ld c, a
ld b, 0
jr .doRead
_: ; Check for partial blocks (BC != 0x100)
push de
push af
; Load the amount we *can* read into B
xor a
bit 7, (ix + FILE_FLAGS)
jr z, _
ld a, (ix + FILE_FINAL_LENGTH)
_: ; Space left in block in A
sub (ix + FILE_STREAM)
ld d, a
pop af
cp d
jr c, _
jr z, _
xor a \ cp d
jr z, _ ; Handle 0x100 bytes
; Too long, truncate a little
ld c, d
ld b, 0
_: pop de
.doRead:
; Update HL with stream pointer
ld l, (ix + FILE_BUFFER)
ld h, (ix + FILE_BUFFER + 1)
ld a, (ix + FILE_STREAM)
add l, a \ ld l, a
jr nc, _ \ inc h
_: ; Do read
push bc \ ldir \ pop bc
; Subtract BC from itself
pop hl ; Was BC
or a \ sbc hl, bc
_: push hl ; Push *new* length to stack so we can remember it while we cycle to the next buffer
; Update stream pointer
ld a, (ix + FILE_STREAM)
add c
ld (ix + FILE_STREAM), a
bit 7, (ix + FILE_FLAGS)
jr z, _
; Handle "last buffer"
cp (ix + FILE_FINAL_LENGTH)
jr nz, .loopAround
set 5, (ix + FILE_FLAGS)
jr .loopAround
_: ; Handle any other buffer
xor a
cp (ix + FILE_STREAM)
jr nz, .loopAround
ld (ix + FILE_STREAM), a
call getNextBuffer
ld l, (ix + FILE_BUFFER)
ld h, (ix + FILE_BUFFER + 1)
.loopAround:
; Back to the main loop
pop bc
jp .readLoop
;.done - 2:
pop bc
.done:
pop ix \ pop af \ pop de \ pop bc \ pop hl
cp a
ret
;; getStreamInfo [Filestreams]
;; Gets the amount of space remaining in a file stream.
;; Inputs:
;; D: Stream ID
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
;; EBC: Remaining space in stream (on success)
getStreamInfo:
push ix
call getStreamEntry
jr z, .streamFound
pop ix
ret
.streamFound:
bit 5, (ix + FILE_FLAGS)
jr z, _
pop ix
ld e, 0
ld bc, 0
ret
; Start with what remains in the current block
_: push af \ push af \ push de
ld e, 0
ld b, 0
; Get size of current block
bit 7, (ix + FILE_FLAGS)
jr nz, _
ld a, 0 ; 0x100 bytes
jr ++_
_: ld a, (ix + FILE_FINAL_LENGTH)
_: ; Subtract amount already read from this block
sub (ix + FILE_STREAM)
; And A is now the length left in this block
ld c, a
or a ; cp 0
jr nz, _ \ inc b
_: bit 7, (ix + FILE_FLAGS)
jr nz, .done ; Leave eary for final block
; Loop through remaining blocks
ld a, i
push af \ di
ld l, (ix + FILE_SECTION_ID)
ld h, (ix + FILE_SECTION_ID + 1)
; HL is section ID
dec b ; Reset B to zero
.loop:
ld a, h
setBankA
ld a, l
rlca \ rlca \ inc a \ inc a
ld h, 0x40
ld l, a
; (HL) is the section header
push de
ld e, (hl)
inc hl
ld d, (hl)
ex de, hl
pop de
; HL is the next section ID
; Check if it's 0xFFFE - if it is, we're done.
ld a, 0xFF
cp h
jr nz, .continue
cp l
jr nz, .continue
; All done, add the final block length and exit
ld a, (ix + FILE_FINAL_LENGTH)
add c
ld c, a
jr nc, .done_ei
ld a, b
add a, 1
ld b, a
jr nc, .done_ei
inc d
jr .done_ei
.continue:
ld a, b ; Update length and continue
add a, 1
ld b, a
jr nc, .loop
inc d
jr .loop
.done_ei:
pop af
jp po, .done
ei
.done:
; We have to preserve DE through this
ld a, e
pop de
ld e, a
pop hl \ pop af
pop ix
cp a
ret
;; streamReadToEnd [Filestreams]
;; Reads the remainder of a file stream into memory.
;; Inputs:
;; D: Stream ID
;; IX: Destination address
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
streamReadToEnd:
push bc
push de
call getStreamInfo
jr z, _
pop de
pop bc
ret
_: pop de \ push de
call streamReadBuffer
pop de
pop bc
ret
; Seeks the stream (after getStreamEntry) to zero
; Destroys AF HL BC DE
seek_zero:
.loop:
call selectSection
ld h, 0x40
add a, a \ add a, a
ld l, a
ld c, (hl)
inc hl
ld b, (hl)
ld de, 0x7FFF
call cpBCDE
jr z, .resetPointer ; This is the first section
res 7, (ix + FILE_FLAGS)
; Move on to next section
ld (ix + FILE_SECTION_ID + 1), b
ld (ix + FILE_SECTION_ID), c
jr .loop
.resetPointer:
ld (ix + FILE_STREAM), 0
push ix
ld b, (ix + FILE_SECTION_ID + 1)
ld c, (ix + FILE_SECTION_ID)
ld d, (ix + FILE_BUFFER + 1)
ld e, (ix + FILE_BUFFER)
push de \ pop ix
call populateStreamBuffer
pop ix
ret
;; seek [Filestreams]
;; Moves the current position in a file stream.
;; Inputs:
;; D: Stream ID
;; EBC: Offset to start of file in bytes
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
seek:
call flush
ret nz ; This nicely covers "stream not found"
push ix
push hl
push de
push af
ld a, i
push af
di
call getStreamEntry
push bc \ push de
call seek_zero
pop de \ pop bc
.loop:
; Are we done?
ld a, e
or b
jr z, .done
; Nope, not done. Reduce EB and swap in the next section
ld a, b
sub 1
ld b, a
jr nc, _
ld a, e
or a
jr z, _
dec e
_: call selectSection
add a, a \ add a, a
ld h, 0x40
ld l, 2
add l
ld l, a ; HL points to next block
push bc \ push de
ld c, (hl)
inc hl
ld b, (hl)
ld de, 0x7FFF
call cpBCDE
jr z, .endOfStream
ld (ix + FILE_SECTION_ID + 1), b
ld (ix + FILE_SECTION_ID), c
pop de \ pop bc
jr .loop
.done:
ld (ix + FILE_STREAM), c
ld b, (ix + FILE_SECTION_ID + 1)
ld c, (ix + FILE_SECTION_ID)
ld d, (ix + FILE_BUFFER + 1)
ld e, (ix + FILE_BUFFER)
push de \ pop ix
call populateStreamBuffer
pop af
jp po, _
ei
_: pop af
pop de
pop hl
pop ix
ret
.endOfStream:
pop de \ pop bc
; Set us to the end of the stream
ld c, (ix + FILE_FINAL_LENGTH)
ld (ix + FILE_STREAM), c
ld b, (ix + FILE_SECTION_ID + 1)
ld c, (ix + FILE_SECTION_ID)
ld d, (ix + FILE_BUFFER + 1)
ld e, (ix + FILE_BUFFER)
push de \ pop ix
call populateStreamBuffer
pop af
jp po, _
ei
_: pop af
pop de
pop hl
pop ix
or 1
ld a, errEndOfStream
ret
;; getStreamPos [Filestreams]
;; Returns the current position in a file stream.
;; Inputs:
;; D: Stream ID
;; Outputs:
;; Z: Set on success, reset on failure
;; A: Error code (on failure)
;; EBC: Offset to start of file in bytes
; * Get section ID from File Stream Table
; * Using DAT linked list, count the number of sections until the beginning of the file
; * Add 256 bytes for each section and stream pointer from File Stream Table
getStreamPos:
push ix
call getStreamEntry
jr z, .streamFound
pop ix
ret
.streamFound:
push af
push hl
push de
; Initialize counter (EBC)
; ld de, 0 ; E must be zero but we need to use it first
ld b, 0
ld c, (ix + FILE_STREAM)
; Set pointer to first section ID
ld de, FILE_SECTION_ID
add ix, de
ld de, 0
.loop:
; Set flash page
ld a, (ix + 1)
setBankA
; Get pointer to entry in linked list
; 0x4000 + 4*index
ld hl, 0x4000
ld l, (ix)
rlc l
rlc l
push hl \ pop ix
; If entry is 0x7FFF, this is the beginning of the file
ld a, (ix + 1)
cp 0x7F
jr nz, _
ld a, (ix)
cp 0xFF
jr nz, _
jr .exit
; Add section length to counter and loop
_: ld hl, KFS_BLOCK_SIZE
add hl, bc
jr nc, _
inc e
_: push hl \ pop bc
jr .loop
.exit:
ex de, hl
pop de
ld e, l
pop hl
pop af
pop ix
ret
|
/*
* Copyright (c) 2021, Krisna Pranav
*
* SPDX-License-Identifier: BSD-2-Clause
*/
// includes
#include <base/Format.h>
#include <base/StringView.h>
#include <kernel/acpi/Parser.h>
#include <kernel/arch/PC/BIOS.h>
#include <kernel/arch/x86/InterruptDisabler.h>
#include <kernel/bus/PCI/Access.h>
#include <kernel/Debug.h>
#include <kernel/IO.h>
#include <kernel/memory/TypedMapping.h>
#include <kernel/Sections.h>
#include <kernel/StdLib.h>
namespace Kernel::ACPI {
static Parser* s_acpi_parser;
Parser* Parser::the()
{
return s_acpi_parser;
}
UNMAP_AFTER_INIT NonnullRefPtr<ACPISysFSComponent> ACPISysFSComponent::create(String name, PhysicalAddress paddr, size_t table_size)
{
return adopt_ref(*new (nothrow) ACPISysFSComponent(name, paddr, table_size));
}
KResultOr<size_t> ACPISysFSComponent::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, FileDescription*) const
{
auto blob = try_to_generate_buffer();
if (!blob)
return KResult(EFAULT);
if ((size_t)offset >= blob->size())
return KSuccess;
ssize_t nread = min(static_cast<off_t>(blob->size() - offset), static_cast<off_t>(count));
if (!buffer.write(blob->data() + offset, nread))
return KResult(EFAULT);
return nread;
}
OwnPtr<KBuffer> ACPISysFSComponent::try_to_generate_buffer() const
{
auto acpi_blob = Memory::map_typed<u8>((m_paddr), m_length);
return KBuffer::try_create_with_bytes(Span<u8> { acpi_blob.ptr(), m_length });
}
UNMAP_AFTER_INIT ACPISysFSComponent::ACPISysFSComponent(String name, PhysicalAddress paddr, size_t table_size)
: SysFSComponent(name)
, m_paddr(paddr)
, m_length(table_size)
{
}
UNMAP_AFTER_INIT void ACPISysFSDirectory::initialize()
{
auto acpi_directory = adopt_ref(*new (nothrow) ACPISysFSDirectory());
SysFSComponentRegistry::the().register_new_component(acpi_directory);
}
UNMAP_AFTER_INIT ACPISysFSDirectory::ACPISysFSDirectory()
: SysFSDirectory("acpi", SysFSComponentRegistry::the().root_directory())
{
NonnullRefPtrVector<SysFSComponent> components;
size_t ssdt_count = 0;
ACPI::Parser::the()->enumerate_static_tables([&](const StringView& signature, PhysicalAddress p_table, size_t length) {
if (signature == "SSDT") {
components.append(ACPISysFSComponent::create(String::formatted("{:4s}{}", signature.characters_without_null_termination(), ssdt_count), p_table, length));
ssdt_count++;
return;
}
components.append(ACPISysFSComponent::create(signature, p_table, length));
});
m_components = components;
auto rsdp = Memory::map_typed<Structures::RSDPDescriptor20>(ACPI::Parser::the()->rsdp());
m_components.append(ACPISysFSComponent::create("RSDP", ACPI::Parser::the()->rsdp(), rsdp->base.revision == 0 ? sizeof(Structures::RSDPDescriptor) : rsdp->length));
auto main_system_description_table = Memory::map_typed<Structures::SDTHeader>(ACPI::Parser::the()->main_system_description_table());
if (ACPI::Parser::the()->is_xsdt_supported()) {
m_components.append(ACPISysFSComponent::create("XSDT", ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length));
} else {
m_components.append(ACPISysFSComponent::create("RSDT", ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length));
}
}
void Parser::enumerate_static_tables(Function<void(const StringView&, PhysicalAddress, size_t)> callback)
{
for (auto& p_table : m_sdt_pointers) {
auto table = Memory::map_typed<Structures::SDTHeader>(p_table);
callback({ table->sig, 4 }, p_table, table->length);
}
}
void Parser::set_the(Parser& parser)
{
VERIFY(!s_acpi_parser);
s_acpi_parser = &parser;
}
static bool match_table_signature(PhysicalAddress table_header, const StringView& signature);
static PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt, const StringView& signature);
static PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt, const StringView& signature);
static bool validate_table(const Structures::SDTHeader&, size_t length);
UNMAP_AFTER_INIT void Parser::locate_static_data()
{
locate_main_system_description_table();
initialize_main_system_description_table();
init_fadt();
init_facs();
}
UNMAP_AFTER_INIT PhysicalAddress Parser::find_table(const StringView& signature)
{
dbgln_if(ACPI_DEBUG, "ACPI: Calling Find Table method!");
for (auto p_sdt : m_sdt_pointers) {
auto sdt = Memory::map_typed<Structures::SDTHeader>(p_sdt);
dbgln_if(ACPI_DEBUG, "ACPI: Examining Table @ {}", p_sdt);
if (!strncmp(sdt->sig, signature.characters_without_null_termination(), 4)) {
dbgln_if(ACPI_DEBUG, "ACPI: Found Table @ {}", p_sdt);
return p_sdt;
}
}
return {};
}
UNMAP_AFTER_INIT void Parser::init_facs()
{
m_facs = find_table("FACS");
}
UNMAP_AFTER_INIT void Parser::init_fadt()
{
dmesgln("ACPI: Initializing Fixed ACPI data");
dmesgln("ACPI: Searching for the Fixed ACPI Data Table");
m_fadt = find_table("FACP");
VERIFY(!m_fadt.is_null());
auto sdt = Memory::map_typed<const volatile Structures::FADT>(m_fadt);
dbgln_if(ACPI_DEBUG, "ACPI: FADT @ V{}, {}", &sdt, m_fadt);
auto* header = &sdt.ptr()->h;
dmesgln("ACPI: Fixed ACPI data, Revision {}, length: {} bytes", (size_t)header->revision, (size_t)header->length);
dmesgln("ACPI: DSDT {}", PhysicalAddress(sdt->dsdt_ptr));
m_x86_specific_flags.cmos_rtc_not_present = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::CMOS_RTC_Not_Present);
// FIXME: QEMU doesn't report that we have an i8042 controller in these flags, even if it should (when FADT revision is 3),
// Later on, we need to make sure that we enumerate the ACPI namespace (AML encoded), instead of just using this value.
m_x86_specific_flags.keyboard_8042 = (sdt->h.revision <= 3) || (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::PS2_8042);
m_x86_specific_flags.legacy_devices = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::Legacy_Devices);
m_x86_specific_flags.msi_not_supported = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::MSI_Not_Supported);
m_x86_specific_flags.vga_not_present = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::VGA_Not_Present);
m_hardware_flags.cpu_software_sleep = (sdt->flags & (u32)FADTFlags::FeatureFlags::CPU_SW_SLP);
m_hardware_flags.docking_capability = (sdt->flags & (u32)FADTFlags::FeatureFlags::DCK_CAP);
m_hardware_flags.fix_rtc = (sdt->flags & (u32)FADTFlags::FeatureFlags::FIX_RTC);
m_hardware_flags.force_apic_cluster_model = (sdt->flags & (u32)FADTFlags::FeatureFlags::FORCE_APIC_CLUSTER_MODEL);
m_hardware_flags.force_apic_physical_destination_mode = (sdt->flags & (u32)FADTFlags::FeatureFlags::FORCE_APIC_PHYSICAL_DESTINATION_MODE);
m_hardware_flags.hardware_reduced_acpi = (sdt->flags & (u32)FADTFlags::FeatureFlags::HW_REDUCED_ACPI);
m_hardware_flags.headless = (sdt->flags & (u32)FADTFlags::FeatureFlags::HEADLESS);
m_hardware_flags.low_power_s0_idle_capable = (sdt->flags & (u32)FADTFlags::FeatureFlags::LOW_POWER_S0_IDLE_CAPABLE);
m_hardware_flags.multiprocessor_c2 = (sdt->flags & (u32)FADTFlags::FeatureFlags::P_LVL2_UP);
m_hardware_flags.pci_express_wake = (sdt->flags & (u32)FADTFlags::FeatureFlags::PCI_EXP_WAK);
m_hardware_flags.power_button = (sdt->flags & (u32)FADTFlags::FeatureFlags::PWR_BUTTON);
m_hardware_flags.processor_c1 = (sdt->flags & (u32)FADTFlags::FeatureFlags::PROC_C1);
m_hardware_flags.remote_power_on_capable = (sdt->flags & (u32)FADTFlags::FeatureFlags::REMOTE_POWER_ON_CAPABLE);
m_hardware_flags.reset_register_supported = (sdt->flags & (u32)FADTFlags::FeatureFlags::RESET_REG_SUPPORTED);
m_hardware_flags.rtc_s4 = (sdt->flags & (u32)FADTFlags::FeatureFlags::RTC_s4);
m_hardware_flags.s4_rtc_status_valid = (sdt->flags & (u32)FADTFlags::FeatureFlags::S4_RTC_STS_VALID);
m_hardware_flags.sealed_case = (sdt->flags & (u32)FADTFlags::FeatureFlags::SEALED_CASE);
m_hardware_flags.sleep_button = (sdt->flags & (u32)FADTFlags::FeatureFlags::SLP_BUTTON);
m_hardware_flags.timer_value_extension = (sdt->flags & (u32)FADTFlags::FeatureFlags::TMR_VAL_EXT);
m_hardware_flags.use_platform_clock = (sdt->flags & (u32)FADTFlags::FeatureFlags::USE_PLATFORM_CLOCK);
m_hardware_flags.wbinvd = (sdt->flags & (u32)FADTFlags::FeatureFlags::WBINVD);
m_hardware_flags.wbinvd_flush = (sdt->flags & (u32)FADTFlags::FeatureFlags::WBINVD_FLUSH);
}
bool Parser::can_reboot()
{
auto fadt = Memory::map_typed<Structures::FADT>(m_fadt);
if (fadt->h.revision < 2)
return false;
return m_hardware_flags.reset_register_supported;
}
void Parser::access_generic_address(const Structures::GenericAddressStructure& structure, u32 value)
{
switch ((GenericAddressStructure::AddressSpace)structure.address_space) {
case GenericAddressStructure::AddressSpace::SystemIO: {
IOAddress address(structure.address);
dbgln("ACPI: Sending value {:x} to {}", value, address);
switch (structure.access_size) {
case (u8)GenericAddressStructure::AccessSize::QWord: {
dbgln("Trying to send QWord to IO port");
VERIFY_NOT_REACHED();
break;
}
case (u8)GenericAddressStructure::AccessSize::Undefined: {
dbgln("ACPI Warning: Unknown access size {}", structure.access_size);
VERIFY(structure.bit_width != (u8)GenericAddressStructure::BitWidth::QWord);
VERIFY(structure.bit_width != (u8)GenericAddressStructure::BitWidth::Undefined);
dbgln("ACPI: Bit Width - {} bits", structure.bit_width);
address.out(value, structure.bit_width);
break;
}
default:
address.out(value, (8 << (structure.access_size - 1)));
break;
}
return;
}
case GenericAddressStructure::AddressSpace::SystemMemory: {
dbgln("ACPI: Sending value {:x} to {}", value, PhysicalAddress(structure.address));
switch ((GenericAddressStructure::AccessSize)structure.access_size) {
case GenericAddressStructure::AccessSize::Byte:
*Memory::map_typed<u8>(PhysicalAddress(structure.address)) = value;
break;
case GenericAddressStructure::AccessSize::Word:
*Memory::map_typed<u16>(PhysicalAddress(structure.address)) = value;
break;
case GenericAddressStructure::AccessSize::DWord:
*Memory::map_typed<u32>(PhysicalAddress(structure.address)) = value;
break;
case GenericAddressStructure::AccessSize::QWord: {
*Memory::map_typed<u64>(PhysicalAddress(structure.address)) = value;
break;
}
default:
VERIFY_NOT_REACHED();
}
return;
}
case GenericAddressStructure::AddressSpace::PCIConfigurationSpace: {
// According to https://uefi.org/specs/ACPI/6.4/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#address-space-format,
// PCI addresses must be confined to devices on Segment group 0, bus 0.
auto pci_address = PCI::Address(0, 0, ((structure.address >> 24) & 0xFF), ((structure.address >> 16) & 0xFF));
dbgln("ACPI: Sending value {:x} to {}", value, pci_address);
u32 offset_in_pci_address = structure.address & 0xFFFF;
if (structure.access_size == (u8)GenericAddressStructure::AccessSize::QWord) {
dbgln("Trying to send QWord to PCI configuration space");
VERIFY_NOT_REACHED();
}
VERIFY(structure.access_size != (u8)GenericAddressStructure::AccessSize::Undefined);
PCI::raw_access(pci_address, offset_in_pci_address, (1 << (structure.access_size - 1)), value);
return;
}
default:
VERIFY_NOT_REACHED();
}
VERIFY_NOT_REACHED();
}
bool Parser::validate_reset_register()
{
// According to https://uefi.org/specs/ACPI/6.4/04_ACPI_Hardware_Specification/ACPI_Hardware_Specification.html#reset-register,
// the reset register can only be located in I/O bus, PCI bus or memory-mapped.
auto fadt = Memory::map_typed<Structures::FADT>(m_fadt);
return (fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::PCIConfigurationSpace || fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::SystemMemory || fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::SystemIO);
}
void Parser::try_acpi_reboot()
{
InterruptDisabler disabler;
if (!can_reboot()) {
dmesgln("ACPI: Reboot not supported!");
return;
}
dbgln_if(ACPI_DEBUG, "ACPI: Rebooting, probing FADT ({})", m_fadt);
auto fadt = Memory::map_typed<Structures::FADT>(m_fadt);
VERIFY(validate_reset_register());
access_generic_address(fadt->reset_reg, fadt->reset_value);
Processor::halt();
}
void Parser::try_acpi_shutdown()
{
dmesgln("ACPI: Shutdown is not supported with the current configuration, aborting!");
}
size_t Parser::get_table_size(PhysicalAddress table_header)
{
InterruptDisabler disabler;
dbgln_if(ACPI_DEBUG, "ACPI: Checking SDT Length");
return Memory::map_typed<Structures::SDTHeader>(table_header)->length;
}
u8 Parser::get_table_revision(PhysicalAddress table_header)
{
InterruptDisabler disabler;
dbgln_if(ACPI_DEBUG, "ACPI: Checking SDT Revision");
return Memory::map_typed<Structures::SDTHeader>(table_header)->revision;
}
UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table()
{
dbgln_if(ACPI_DEBUG, "ACPI: Checking Main SDT Length to choose the correct mapping size");
VERIFY(!m_main_system_description_table.is_null());
auto length = get_table_size(m_main_system_description_table);
auto revision = get_table_revision(m_main_system_description_table);
auto sdt = Memory::map_typed<Structures::SDTHeader>(m_main_system_description_table, length);
dmesgln("ACPI: Main Description Table valid? {}", validate_table(*sdt, length));
if (m_xsdt_supported) {
auto& xsdt = (const Structures::XSDT&)*sdt;
dmesgln("ACPI: Using XSDT, enumerating tables @ {}", m_main_system_description_table);
dmesgln("ACPI: XSDT revision {}, total length: {}", revision, length);
dbgln_if(ACPI_DEBUG, "ACPI: XSDT pointer @ {}", VirtualAddress { &xsdt });
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) {
dbgln_if(ACPI_DEBUG, "ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &xsdt.table_ptrs[i]);
m_sdt_pointers.append(PhysicalAddress(xsdt.table_ptrs[i]));
}
} else {
auto& rsdt = (const Structures::RSDT&)*sdt;
dmesgln("ACPI: Using RSDT, enumerating tables @ {}", m_main_system_description_table);
dmesgln("ACPI: RSDT revision {}, total length: {}", revision, length);
dbgln_if(ACPI_DEBUG, "ACPI: RSDT pointer @ V{}", &rsdt);
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) {
dbgln_if(ACPI_DEBUG, "ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &rsdt.table_ptrs[i]);
m_sdt_pointers.append(PhysicalAddress(rsdt.table_ptrs[i]));
}
}
}
UNMAP_AFTER_INIT void Parser::locate_main_system_description_table()
{
auto rsdp = Memory::map_typed<Structures::RSDPDescriptor20>(m_rsdp);
if (rsdp->base.revision == 0) {
m_xsdt_supported = false;
} else if (rsdp->base.revision >= 2) {
if (rsdp->xsdt_ptr != (u64) nullptr) {
m_xsdt_supported = true;
} else {
m_xsdt_supported = false;
}
}
if (!m_xsdt_supported) {
m_main_system_description_table = PhysicalAddress(rsdp->base.rsdt_ptr);
} else {
m_main_system_description_table = PhysicalAddress(rsdp->xsdt_ptr);
}
}
UNMAP_AFTER_INIT Parser::Parser(PhysicalAddress rsdp)
: m_rsdp(rsdp)
{
dmesgln("ACPI: Using RSDP @ {}", rsdp);
locate_static_data();
}
static bool validate_table(const Structures::SDTHeader& v_header, size_t length)
{
u8 checksum = 0;
auto* sdt = (const u8*)&v_header;
for (size_t i = 0; i < length; i++)
checksum += sdt[i];
if (checksum == 0)
return true;
return false;
}
// https://uefi.org/specs/ACPI/6.4/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#finding-the-rsdp-on-ia-pc-systems
UNMAP_AFTER_INIT Optional<PhysicalAddress> StaticParsing::find_rsdp()
{
StringView signature("RSD PTR ");
auto rsdp = map_ebda().find_chunk_starting_with(signature, 16);
if (rsdp.has_value())
return rsdp;
return map_bios().find_chunk_starting_with(signature, 16);
}
UNMAP_AFTER_INIT PhysicalAddress StaticParsing::find_table(PhysicalAddress rsdp_address, const StringView& signature)
{
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
VERIFY(signature.length() == 4);
auto rsdp = Memory::map_typed<Structures::RSDPDescriptor20>(rsdp_address);
if (rsdp->base.revision == 0)
return search_table_in_rsdt(PhysicalAddress(rsdp->base.rsdt_ptr), signature);
if (rsdp->base.revision >= 2) {
if (rsdp->xsdt_ptr)
return search_table_in_xsdt(PhysicalAddress(rsdp->xsdt_ptr), signature);
return search_table_in_rsdt(PhysicalAddress(rsdp->base.rsdt_ptr), signature);
}
VERIFY_NOT_REACHED();
}
UNMAP_AFTER_INIT static PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt_address, const StringView& signature)
{
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
VERIFY(signature.length() == 4);
auto xsdt = Memory::map_typed<Structures::XSDT>(xsdt_address);
for (size_t i = 0; i < ((xsdt->h.length - sizeof(Structures::SDTHeader)) / sizeof(u64)); ++i) {
if (match_table_signature(PhysicalAddress((PhysicalPtr)xsdt->table_ptrs[i]), signature))
return PhysicalAddress((PhysicalPtr)xsdt->table_ptrs[i]);
}
return {};
}
static bool match_table_signature(PhysicalAddress table_header, const StringView& signature)
{
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
VERIFY(signature.length() == 4);
auto table = Memory::map_typed<Structures::RSDT>(table_header);
return !strncmp(table->h.sig, signature.characters_without_null_termination(), 4);
}
UNMAP_AFTER_INIT static PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt_address, const StringView& signature)
{
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
VERIFY(signature.length() == 4);
auto rsdt = Memory::map_typed<Structures::RSDT>(rsdt_address);
for (u32 i = 0; i < ((rsdt->h.length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) {
if (match_table_signature(PhysicalAddress((PhysicalPtr)rsdt->table_ptrs[i]), signature))
return PhysicalAddress((PhysicalPtr)rsdt->table_ptrs[i]);
}
return {};
}
void Parser::enable_aml_interpretation()
{
VERIFY_NOT_REACHED();
}
void Parser::enable_aml_interpretation(File&)
{
VERIFY_NOT_REACHED();
}
void Parser::enable_aml_interpretation(u8*, u32)
{
VERIFY_NOT_REACHED();
}
void Parser::disable_aml_interpretation()
{
VERIFY_NOT_REACHED();
}
}
|
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2017 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_NETWORK_OPERATION_HPP
#define CAF_IO_NETWORK_OPERATION_HPP
namespace caf {
namespace io {
namespace network {
/// Identifies network IO operations, i.e., read or write.
enum class operation {
read,
write,
propagate_error
};
inline std::string to_string(operation op) {
return op == operation::read ? "read"
: (op == operation::write ? "write"
: "propagate_error");
}
} // namespace network
} // namespace io
} // namespace caf
#endif // CAF_IO_NETWORK_OPERATION_HPP
|
.file "deflate.c"
.section .text.unlikely,"ax",@progbits
.LCOLDB1:
.section .rodata
.align 64
.local configuration_table
.type configuration_table, @object
configuration_table:
.value 0
.value 0
.value 0
.value 0
.quad deflate_stored
.long 262148
.long 262152
.quad deflate_fast
.long 327684
.long 524304
.quad deflate_fast
.long 393220
.long 2097184
.quad deflate_fast
.long 262148
.long 1048592
.quad deflate_slow
.long 1048584
.long 2097184
.quad deflate_slow
.long 1048584
.long 8388736
.quad deflate_slow
.long 2097160
.long 16777344
.quad deflate_slow
.long 8388640
.long 67109122
.quad deflate_slow
.long 16908320
.long 268435714
.quad deflate_slow
.zero 32
.size configuration_table, 192
# ----------------------
.globl deflate_copyright
.type deflate_copyright, @object
deflate_copyright:
.string " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler "
.size deflate_copyright, 68
# ----------------------
.text
.local longest_match
.type longest_match, @function
longest_match:
pushq %r15
pushq %r14
xorl %r11d, %r11d
pushq %r13
pushq %r12
pushq %rbp
pushq %rbx
movl 192(%rdi), %ebx
movl 156(%rdi), %r9d
movq 80(%rdi), %r10
movl 168(%rdi), %r8d
movl 172(%rdi), %ecx
movl %ebx, -20(%rsp)
movl 68(%rdi), %ebx
leaq (%r10,%r9), %r13
movl %r8d, %eax
leal -262(%rbx), %ebp
cmpl %ebp, %r9d
jbe .L0000004E
.L00000044:
leal 262(%r9), %r11d
subl %ebx, %r11d
.L0000004E:
leaq 258(%r10,%r9), %rbx
movslq %r8d, %rdx
movl 164(%rdi), %r15d
movzbl -1(%r13,%rdx), %r14d
movq 96(%rdi), %r12
movq %rbx, -8(%rsp)
movzbl (%r13,%rdx), %ebx
movl %ecx, %edx
shrl $2, %edx
cmpl 188(%rdi), %r8d
movl 76(%rdi), %ebp
movq %rdi, -16(%rsp)
cmovae %edx, %ecx
movl -20(%rsp), %edx
cmpl %r15d, %edx
cmova %r15d, %edx
movl %edx, -20(%rsp)
jmp .L000000B9
.L0000009D:
.p2align 4,,10
.p2align 3
.L000000A0:
andl %ebp, %esi
movzwl (%r12,%rsi,2), %esi
cmpl %esi, %r11d
jae .L000001E0
.L000000B0:
subl $1, %ecx
je .L000001E0
.L000000B9:
movl %esi, %edx
movslq %eax, %r9
addq %r10, %rdx
movzbl (%rdx,%r9), %r8d
cmpb %bl, %r8b
jne .L000000A0
.L000000CB:
movzbl -1(%rdx,%r9), %r9d
cmpb %r14b, %r9b
jne .L000000A0
.L000000D6:
movzbl (%r13), %edi
cmpb %dil, (%rdx)
jne .L000000A0
.L000000E0:
movzbl 1(%r13), %edi
cmpb %dil, 1(%rdx)
jne .L000000A0
.L000000EB:
addq $2, %r13
addq $2, %rdx
movq -8(%rsp), %rbx
movq -16(%rsp), %rdi
jmp .L00000179
.L000000FF:
.p2align 4,,10
.p2align 3
.L00000100:
movzbl 2(%rdx), %r14d
cmpb %r14b, 2(%r13)
jne .L00000224
.L0000010F:
movzbl 3(%rdx), %r14d
cmpb %r14b, 3(%r13)
jne .L00000216
.L0000011E:
movzbl 4(%rdx), %r14d
cmpb %r14b, 4(%r13)
jne .L00000208
.L0000012D:
movzbl 5(%rdx), %r14d
cmpb %r14b, 5(%r13)
jne .L000001FD
.L0000013C:
movzbl 6(%rdx), %r14d
cmpb %r14b, 6(%r13)
jne .L00000240
.L0000014B:
movzbl 7(%rdx), %r14d
cmpb %r14b, 7(%r13)
jne .L00000232
.L0000015A:
addq $8, %rdx
addq $8, %r13
movzbl (%rdx), %r14d
cmpb %r14b, (%r13)
jne .L0000024E
.L00000170:
cmpq %r13, %rbx
jbe .L0000024E
.L00000179:
movzbl 1(%rdx), %r14d
cmpb %r14b, 1(%r13)
je .L00000100
.L00000188:
movq %rdi, -16(%rsp)
addq $1, %r13
.L00000191:
movq -8(%rsp), %rdi
movl $258, %ebx
movq %rdi, %rdx
subq %r13, %rdx
leaq -258(%rdi), %r13
subl %edx, %ebx
cmpl %ebx, %eax
movl %ebx, %edx
jge .L000001F2
.L000001B0:
cmpl %ebx, -20(%rsp)
movq -16(%rsp), %rax
movl %esi, 160(%rax)
jle .L000001D9
.L000001C1:
movslq %ebx, %rax
movzbl -1(%r13,%rax), %r14d
movzbl -258(%rdi,%rax), %ebx
movl %edx, %eax
jmp .L000000A0
.L000001D9:
movl %ebx, %eax
.p2align 4,,10
.p2align 3
.L000001E0:
cmpl %r15d, %eax
popq %rbx
cmova %r15d, %eax
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L000001F2:
movl %r8d, %ebx
movl %r9d, %r14d
jmp .L000000A0
.L000001FD:
movq %rdi, -16(%rsp)
addq $5, %r13
jmp .L00000191
.L00000208:
movq %rdi, -16(%rsp)
addq $4, %r13
jmp .L00000191
.L00000216:
movq %rdi, -16(%rsp)
addq $3, %r13
jmp .L00000191
.L00000224:
movq %rdi, -16(%rsp)
addq $2, %r13
jmp .L00000191
.L00000232:
movq %rdi, -16(%rsp)
addq $7, %r13
jmp .L00000191
.L00000240:
movq %rdi, -16(%rsp)
addq $6, %r13
jmp .L00000191
.L0000024E:
movq %rdi, -16(%rsp)
jmp .L00000191
.size longest_match, .-longest_match
# ----------------------
.L00000258:
.p2align 4
# ----------------------
.local fill_window
.type fill_window, @function
fill_window:
pushq %r15
pushq %r14
movq $-2, %rcx
pushq %r13
pushq %r12
xorl %r14d, %r14d
pushq %rbp
pushq %rbx
movq %rdi, %rbx
subq $56, %rsp
movl 68(%rdi), %r12d
movl 164(%rdi), %edx
movq %rcx, %rdi
movq %rcx, 32(%rsp)
leaq (%r12,%r12), %rax
movq %r12, %r13
movq %r12, 40(%rsp)
movq %rax, 16(%rsp)
leal -1(%r12), %eax
addq %rax, %rax
subq %rax, %rdi
movl %r12d, %eax
movq %rdi, 24(%rsp)
leal -262(%r12), %edi
movl %edi, 12(%rsp)
.p2align 4,,10
.p2align 3
.L000002C0:
movl 156(%rbx), %ecx
movl 88(%rbx), %r15d
addl 12(%rsp), %eax
subl %edx, %r15d
subl %ecx, %r15d
cmpl %eax, %ecx
jae .L00000430
.L000002DC:
movq (%rbx), %r12
movl 8(%r12), %ebp
testl %ebp, %ebp
je .L000004F0
.L000002EC:
cmpl %ebp, %r15d
movq 80(%rbx), %rsi
movl 164(%rbx), %edx
jae .L000003D8
.L000002FF:
testl %r15d, %r15d
jne .L00000634
.L00000308:
xorl %r8d, %r8d
.L0000030B:
movl 5916(%rbx), %esi
addl %r8d, %edx
movl %edx, 164(%rbx)
leal (%rdx,%rsi), %eax
cmpl $2, %eax
jbe .L000003B1
.L00000326:
movl 156(%rbx), %edi
movq 80(%rbx), %r11
movl 128(%rbx), %ecx
movl 124(%rbx), %r15d
subl %esi, %edi
movl %edi, %eax
movzbl (%r11,%rax), %r8d
leal 1(%rdi), %eax
movl %r8d, 112(%rbx)
movzbl (%r11,%rax), %r9d
movl %r8d, %eax
sall %cl, %eax
xorl %r9d, %eax
andl %r15d, %eax
movl %eax, 112(%rbx)
jmp .L000003AD
.L0000035F:
.p2align 4,,10
.p2align 3
.L00000360:
leal 2(%rdi), %r8d
sall %cl, %eax
movl %edi, %r10d
andl 76(%rbx), %r10d
subl $1, %esi
movzbl (%r11,%r8), %r8d
xorl %r8d, %eax
movq 104(%rbx), %r8
andl %r15d, %eax
movl %eax, %r9d
movl %eax, 112(%rbx)
leaq (%r8,%r9,2), %r8
movq 96(%rbx), %r9
movzwl (%r8), %ebp
movw %bp, (%r9,%r10,2)
movw %di, (%r8)
leal (%rsi,%rdx), %r8d
addl $1, %edi
movl %esi, 5916(%rbx)
cmpl $2, %r8d
jbe .L000003B1
.L000003AD:
testl %esi, %esi
jne .L00000360
.L000003B1:
cmpl $261, %edx
ja .L000004F0
.L000003BD:
movq (%rbx), %rax
movl 8(%rax), %r8d
testl %r8d, %r8d
je .L000004F0
.L000003CD:
movl 68(%rbx), %eax
jmp .L000002C0
.L000003D5:
.p2align 4,,10
.p2align 3
.L000003D8:
xorl %eax, %eax
.L000003DA:
addq %rdx, %rcx
movl %ebp, %r15d
movl %eax, 8(%r12)
addq %rsi, %rcx
movq (%r12), %rsi
movq %r15, %rdx
movq %rcx, %rdi
call memcpy
.L000003F7:
movq %rax, %rcx
movq 56(%r12), %rax
movl 44(%rax), %eax
cmpl $1, %eax
je .L0000056C
.L0000040B:
cmpl $2, %eax
je .L00000585
.L00000414:
addq %r15, (%r12)
addq %r15, 16(%r12)
movl %ebp, %r8d
movl 164(%rbx), %edx
jmp .L0000030B
.L0000042B:
.p2align 4,,10
.p2align 3
.L00000430:
movq 40(%rsp), %rbp
movq 80(%rbx), %rdi
leaq (%rdi,%rbp), %rsi
movq %rbp, %rdx
call memcpy
.L00000445:
movl 116(%rbx), %esi
movq 104(%rbx), %rax
movl 156(%rbx), %ecx
movq 32(%rsp), %rdi
subl %r13d, 160(%rbx)
subq %rbp, 136(%rbx)
movq %rsi, %rdx
leaq (%rax,%rsi,2), %rax
subl %r13d, %ecx
subl $1, %edx
addq %rdx, %rdx
subq %rdx, %rdi
movl %ecx, 156(%rbx)
addq %rax, %rdi
.p2align 4,,10
.p2align 3
.L00000488:
subq $2, %rax
movzwl (%rax), %esi
movl %esi, %edx
subl %r13d, %edx
cmpl %esi, %r13d
cmova %r14d, %edx
cmpq %rdi, %rax
movw %dx, (%rax)
jne .L00000488
.L000004A3:
movq 16(%rsp), %rax
addq 96(%rbx), %rax
movq 24(%rsp), %rdi
addq %rax, %rdi
.p2align 4,,10
.p2align 3
.L000004B8:
subq $2, %rax
movzwl (%rax), %esi
movl %esi, %edx
subl %r13d, %edx
cmpl %esi, %r13d
cmova %r14d, %edx
cmpq %rdi, %rax
movw %dx, (%rax)
jne .L000004B8
.L000004D3:
movq (%rbx), %r12
addl %r13d, %r15d
movl 8(%r12), %ebp
testl %ebp, %ebp
jne .L000002EC
.L000004E6:
.p2align 4
.L000004F0:
movq 5928(%rbx), %rcx
movq 88(%rbx), %rax
cmpq %rax, %rcx
jae .L0000055D
.L00000500:
movl 164(%rbx), %esi
movl 156(%rbx), %edx
addq %rdx, %rsi
cmpq %rsi, %rcx
jae .L0000059E
.L00000518:
subq %rsi, %rax
movl $258, %edx
cmpq $258, %rax
cmovbe %rax, %rdx
movq %rsi, %rax
addq 80(%rbx), %rax
cmpl $8, %edx
jae .L000005E4
.L0000053A:
testb $4, %dl
jne .L00000611
.L00000543:
testl %edx, %edx
je .L00000553
.L00000547:
testb $2, %dl
movb $0, (%rax)
jne .L00000626
.L00000553:
addq %rsi, %rdx
movq %rdx, 5928(%rbx)
.L0000055D:
addq $56, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L0000056C:
movq 96(%r12), %rdi
movl %ebp, %edx
movq %rcx, %rsi
call adler32
.L0000057B:
movq %rax, 96(%r12)
jmp .L00000414
.L00000585:
movq 96(%r12), %rdi
movl %ebp, %edx
movq %rcx, %rsi
call crc32
.L00000594:
movq %rax, 96(%r12)
jmp .L00000414
.L0000059E:
leaq 258(%rsi), %rdx
cmpq %rdx, %rcx
jae .L0000055D
.L000005AA:
subq %rcx, %rsi
subq %rcx, %rax
leaq 258(%rsi), %rbp
cmpq %rax, %rbp
cmova %rax, %rbp
addq 80(%rbx), %rcx
xorl %esi, %esi
movl %ebp, %edx
movq %rcx, %rdi
call memset
.L000005CE:
addq %rbp, 5928(%rbx)
addq $56, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L000005E4:
leaq 8(%rax), %rdi
movl %edx, %ecx
movq $0, (%rax)
movq $0, -8(%rax,%rcx)
andq $-8, %rdi
subq %rdi, %rax
leal (%rdx,%rax), %ecx
xorl %eax, %eax
shrl $3, %ecx
rep stosq
jmp .L00000553
.L00000611:
movl %edx, %ecx
movl $0, (%rax)
movl $0, -4(%rax,%rcx)
jmp .L00000553
.L00000626:
movl %edx, %ecx
xorl %edi, %edi
movw %di, -2(%rax,%rcx)
jmp .L00000553
.L00000634:
movl %ebp, %eax
movl %r15d, %ebp
subl %r15d, %eax
jmp .L000003DA
.size fill_window, .-fill_window
# ----------------------
.L00000641:
.p2align 4
# ----------------------
.local deflate_fast
.type deflate_fast, @function
deflate_fast:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbp
pushq %rbx
movq %rdi, %rbx
subq $24, %rsp
movl %esi, 12(%rsp)
.L00000665:
movl 164(%rbx), %r8d
.p2align 4,,10
.p2align 3
.L00000670:
cmpl $261, %r8d
jbe .L00000978
.L0000067D:
movl 156(%rbx), %edx
movq 80(%rbx), %rcx
leal 2(%rdx), %eax
movl %edx, %edi
andl 76(%rbx), %edi
movzbl (%rcx,%rax), %esi
movl 128(%rbx), %ecx
movl 112(%rbx), %eax
sall %cl, %eax
movq 104(%rbx), %rcx
xorl %esi, %eax
andl 124(%rbx), %eax
movl %eax, 112(%rbx)
leaq (%rcx,%rax,2), %rax
movq 96(%rbx), %rcx
movzwl (%rax), %esi
testl %esi, %esi
movw %si, (%rcx,%rdi,2)
movw %dx, (%rax)
je .L000006D4
.L000006C0:
movl 68(%rbx), %eax
movl %edx, %ecx
subl %esi, %ecx
subl $262, %eax
cmpl %eax, %ecx
jbe .L000009E8
.L000006D4:
movl 144(%rbx), %eax
.L000006DA:
cmpl $2, %eax
jbe .L000008B0
.L000006E3:
subw 160(%rbx), %dx
movl 5884(%rbx), %esi
subl $3, %eax
movq 5888(%rbx), %rdi
movw %dx, (%rdi,%rsi,2)
movq 5872(%rbx), %rdi
movq %rsi, %rcx
addl $1, %ecx
subl $1, %edx
movl %ecx, 5884(%rbx)
movb %al, (%rdi,%rsi)
movzbl %al, %eax
movzbl _length_code(%rax), %eax
addw $1, 1224(%rbx,%rax,4)
cmpw $255, %dx
ja .L000009C8
.L00000735:
movzwl %dx, %edx
movzbl _dist_code(%rdx), %eax
.L0000073F:
addw $1, 2488(%rbx,%rax,4)
xorl %r10d, %r10d
movl 5880(%rbx), %eax
movl 164(%rbx), %r8d
movl 144(%rbx), %r9d
subl $1, %eax
cmpl %eax, 5884(%rbx)
sete %r10b
subl %r9d, %r8d
cmpl $2, %r8d
movl %r8d, 164(%rbx)
jbe .L00000930
.L00000780:
cmpl 176(%rbx), %r9d
ja .L00000930
.L0000078D:
movl 156(%rbx), %eax
leal -1(%r9), %edi
movq 96(%rbx), %r14
movl 76(%rbx), %r13d
movq 104(%rbx), %r12
movq 80(%rbx), %rbp
movl 128(%rbx), %ecx
movl %eax, %esi
movl %eax, 4(%rsp)
movl 124(%rbx), %r11d
movl 112(%rbx), %eax
leal 1(%rsi), %edx
movl %edi, 144(%rbx)
movl %r8d, 8(%rsp)
.p2align 4
.L000007D0:
leal 2(%rdx), %esi
movl %edx, 156(%rbx)
sall %cl, %eax
movl %edx, %r15d
subl $1, %edi
movzbl (%rbp,%rsi), %esi
andl %r13d, %r15d
xorl %esi, %eax
andl %r11d, %eax
movl %eax, %esi
movl %eax, 112(%rbx)
leaq (%r12,%rsi,2), %rsi
movzwl (%rsi), %r8d
movw %r8w, (%r14,%r15,2)
movw %dx, (%rsi)
addl $1, %edx
testl %edi, %edi
movl %edi, 144(%rbx)
jne .L000007D0
.L00000810:
addl 4(%rsp), %r9d
movl 8(%rsp), %r8d
movl %r9d, 156(%rbx)
.p2align 4,,10
.p2align 3
.L00000828:
testl %r10d, %r10d
je .L00000670
.L00000831:
movq 136(%rbx), %rax
movl %r9d, %edx
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L0000084E
.L00000845:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L0000084E:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00000858:
movq (%rbx), %r12
movl 156(%rbx), %eax
movq 56(%r12), %r13
movq %rax, 136(%rbx)
movq %r13, %rdi
call _tr_flush_bits
.L00000875:
movl 40(%r13), %ebp
movl 32(%r12), %eax
cmpl %ebp, %eax
cmovbe %eax, %ebp
testl %ebp, %ebp
jne .L00000A01
.L0000088B:
movq (%rbx), %rax
movl 32(%rax), %esi
testl %esi, %esi
jne .L00000665
.L00000899:
addq $24, %rsp
xorl %eax, %eax
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L000008AA:
.p2align 4,,10
.p2align 3
.L000008B0:
movl 5884(%rbx), %ecx
movq 80(%rbx), %rax
xorl %edi, %edi
movq 5888(%rbx), %rsi
xorl %r10d, %r10d
movzbl (%rax,%rdx), %eax
movw %di, (%rsi,%rcx,2)
movq 5872(%rbx), %rsi
movq %rcx, %rdx
addl $1, %edx
movl %edx, 5884(%rbx)
movb %al, (%rsi,%rcx)
addw $1, 196(%rbx,%rax,4)
movl 5880(%rbx), %eax
subl $1, %eax
cmpl %eax, 5884(%rbx)
movl 164(%rbx), %eax
leal -1(%rax), %r8d
movl 156(%rbx), %eax
sete %r10b
movl %r8d, 164(%rbx)
leal 1(%rax), %r9d
movl %r9d, 156(%rbx)
jmp .L00000828
.L00000927:
.p2align 4
.L00000930:
addl 156(%rbx), %r9d
movq 80(%rbx), %rdx
movl $0, 144(%rbx)
movl %r9d, %eax
movl %r9d, 156(%rbx)
leal 1(%r9), %ecx
movzbl (%rdx,%rax), %eax
movl %eax, 112(%rbx)
movzbl (%rdx,%rcx), %edx
movl 128(%rbx), %ecx
sall %cl, %eax
xorl %edx, %eax
andl 124(%rbx), %eax
movl %eax, 112(%rbx)
jmp .L00000828
.L00000973:
.p2align 4,,10
.p2align 3
.L00000978:
movq %rbx, %rdi
call fill_window
.L00000980:
movl 164(%rbx), %eax
cmpl $261, %eax
ja .L0000067D
.L00000991:
movl 12(%rsp), %r8d
testl %r8d, %r8d
je .L00000899
.L0000099F:
testl %eax, %eax
je .L00000A3F
.L000009A7:
cmpl $2, %eax
ja .L0000067D
.L000009B0:
movl 144(%rbx), %eax
movl 156(%rbx), %edx
jmp .L000006DA
.L000009C1:
.p2align 4,,10
.p2align 3
.L000009C8:
shrw $7, %dx
leaq 256(%rdx), %rax
andl $1023, %eax
movzbl _dist_code(%rax), %eax
jmp .L0000073F
.L000009E4:
.p2align 4,,10
.p2align 3
.L000009E8:
movq %rbx, %rdi
call longest_match
.L000009F0:
movl 156(%rbx), %edx
movl %eax, 144(%rbx)
jmp .L000006DA
.L00000A01:
movq 24(%r12), %rdi
movq 32(%r13), %rsi
movl %ebp, %r14d
movq %r14, %rdx
call memcpy
.L00000A15:
addq %r14, 24(%r12)
addq %r14, 32(%r13)
addq %r14, 40(%r12)
subl %ebp, 32(%r12)
subl %ebp, 40(%r13)
jne .L0000088B
.L00000A32:
movq 16(%r13), %rax
movq %rax, 32(%r13)
jmp .L0000088B
.L00000A3F:
movl 156(%rbx), %edx
movl $2, %eax
cmpl $2, %edx
cmovbe %edx, %eax
cmpl $4, 12(%rsp)
movl %eax, 5916(%rbx)
je .L00000AE5
.L00000A61:
movl 5884(%rbx), %ecx
movl $1, %eax
testl %ecx, %ecx
je .L00000AD6
.L00000A70:
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L00000A8A
.L00000A81:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L00000A8A:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00000A94:
movq (%rbx), %r13
movl 156(%rbx), %eax
movq 56(%r13), %rbp
movq %rax, 136(%rbx)
movq %rbp, %rdi
call _tr_flush_bits
.L00000AB0:
movl 40(%rbp), %r12d
movl 32(%r13), %eax
cmpl %r12d, %eax
cmovbe %eax, %r12d
testl %r12d, %r12d
jne .L00000B59
.L00000AC8:
movq (%rbx), %rax
movl 32(%rax), %eax
testl %eax, %eax
setne %al
movzbl %al, %eax
.L00000AD6:
addq $24, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L00000AE5:
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L00000AFF
.L00000AF6:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L00000AFF:
movl $1, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00000B0C:
movq (%rbx), %r12
movl 156(%rbx), %eax
movq 56(%r12), %rbp
movq %rax, 136(%rbx)
movq %rbp, %rdi
call _tr_flush_bits
.L00000B29:
movl 40(%rbp), %r13d
movl 32(%r12), %eax
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
jne .L00000B93
.L00000B3E:
movq (%rbx), %rax
cmpl $1, 32(%rax)
sbbl %eax, %eax
addq $24, %rsp
popq %rbx
addl $3, %eax
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L00000B59:
movq 24(%r13), %rdi
movq 32(%rbp), %rsi
movl %r12d, %r14d
movq %r14, %rdx
call memcpy
.L00000B6C:
addq %r14, 24(%r13)
addq %r14, 32(%rbp)
addq %r14, 40(%r13)
subl %r12d, 32(%r13)
subl %r12d, 40(%rbp)
jne .L00000AC8
.L00000B86:
movq 16(%rbp), %rax
movq %rax, 32(%rbp)
jmp .L00000AC8
.L00000B93:
movq 24(%r12), %rdi
movq 32(%rbp), %rsi
movl %r13d, %r14d
movq %r14, %rdx
call memcpy
.L00000BA7:
addq %r14, 24(%r12)
addq %r14, 32(%rbp)
addq %r14, 40(%r12)
subl %r13d, 32(%r12)
subl %r13d, 40(%rbp)
jne .L00000B3E
.L00000BC4:
movq 16(%rbp), %rax
movq %rax, 32(%rbp)
jmp .L00000B3E
.size deflate_fast, .-deflate_fast
# ----------------------
.L00000BD1:
.p2align 4
# ----------------------
.local deflate_slow
.type deflate_slow, @function
deflate_slow:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbp
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
subq $8, %rsp
.L00000BF3:
movl 164(%rbx), %edi
.p2align 4
.L00000C00:
cmpl $261, %edi
jbe .L00000EFE
.L00000C0C:
movl 156(%rbx), %edx
movq 80(%rbx), %rcx
leal 2(%rdx), %eax
movl %edx, %edi
andl 76(%rbx), %edi
movzbl (%rcx,%rax), %esi
movl 128(%rbx), %ecx
movl 112(%rbx), %eax
sall %cl, %eax
movq 104(%rbx), %rcx
xorl %esi, %eax
andl 124(%rbx), %eax
movl %eax, 112(%rbx)
leaq (%rcx,%rax,2), %rax
movq 96(%rbx), %rcx
movzwl (%rax), %esi
movw %si, (%rcx,%rdi,2)
movw %dx, (%rax)
testl %esi, %esi
movl 144(%rbx), %ecx
movl 160(%rbx), %eax
movl $2, 144(%rbx)
movl %eax, 148(%rbx)
movl %ecx, 168(%rbx)
movl $2, %eax
je .L00000CA0
.L00000C76:
cmpl 176(%rbx), %ecx
jae .L00000CA0
.L00000C7E:
movl 68(%rbx), %edi
movl %edx, %r8d
subl %esi, %r8d
subl $262, %edi
cmpl %edi, %r8d
jbe .L00001050
.L00000C96:
.p2align 4
.L00000CA0:
cmpl $2, %ecx
jbe .L00000E68
.L00000CA9:
cmpl %eax, %ecx
jb .L00000E68
.L00000CB1:
movl 164(%rbx), %eax
movl 5884(%rbx), %esi
subl $3, %ecx
movq 5888(%rbx), %rdi
leal -3(%rdx,%rax), %r8d
subw 148(%rbx), %dx
movq %rsi, %rax
addl $1, %eax
leal -1(%rdx), %r9d
subl $2, %edx
movw %r9w, (%rdi,%rsi,2)
movq 5872(%rbx), %rdi
movl %eax, 5884(%rbx)
movb %cl, (%rdi,%rsi)
movzbl %cl, %ecx
movzbl _length_code(%rcx), %eax
addw $1, 1224(%rbx,%rax,4)
cmpw $255, %dx
ja .L00000F90
.L00000D13:
movzwl %dx, %edx
movzbl _dist_code(%rdx), %eax
.L00000D1D:
addw $1, 2488(%rbx,%rax,4)
movl 5880(%rbx), %eax
movl 168(%rbx), %r10d
movl 156(%rbx), %r11d
movl 5884(%rbx), %r12d
leal -1(%rax), %r9d
movl 164(%rbx), %eax
leal -2(%r10), %esi
movl %esi, 168(%rbx)
leal 1(%rax), %edi
leal 1(%r11), %eax
subl %r10d, %edi
movl %edi, 164(%rbx)
.p2align 4,,10
.p2align 3
.L00000D68:
cmpl %r8d, %eax
movl %eax, 156(%rbx)
ja .L00000DB2
.L00000D73:
movq 80(%rbx), %rcx
leal 2(%rax), %edx
movzbl (%rcx,%rdx), %r13d
movl 128(%rbx), %ecx
movl 112(%rbx), %edx
sall %cl, %edx
movq 104(%rbx), %rcx
xorl %r13d, %edx
andl 124(%rbx), %edx
movl %eax, %r13d
andl 76(%rbx), %r13d
movl %edx, 112(%rbx)
leaq (%rcx,%rdx,2), %rdx
movq 96(%rbx), %rcx
movzwl (%rdx), %r15d
movw %r15w, (%rcx,%r13,2)
movw %ax, (%rdx)
.L00000DB2:
subl $1, %esi
addl $1, %eax
testl %esi, %esi
movl %esi, 168(%rbx)
jne .L00000D68
.L00000DC2:
leal -1(%r10,%r11), %eax
cmpl %r9d, %r12d
movl $0, 152(%rbx)
movl $2, 144(%rbx)
movl %eax, 156(%rbx)
jne .L00000C00
.L00000DEA:
movq 136(%rbx), %rcx
movl %eax, %edx
xorl %esi, %esi
subq %rcx, %rdx
testq %rcx, %rcx
js .L00000E06
.L00000DFD:
movl %ecx, %ecx
movq %rcx, %rsi
addq 80(%rbx), %rsi
.L00000E06:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00000E10:
movq (%rbx), %r13
movl 156(%rbx), %eax
movq 56(%r13), %r14
movq %rax, 136(%rbx)
movq %r14, %rdi
call _tr_flush_bits
.L00000E2C:
movl 40(%r14), %r12d
movl 32(%r13), %eax
cmpl %r12d, %eax
cmovbe %eax, %r12d
testl %r12d, %r12d
jne .L00001082
.L00000E44:
movq (%rbx), %rax
movl 32(%rax), %r12d
testl %r12d, %r12d
jne .L00000BF3
.L00000E54:
xorl %eax, %eax
.L00000E56:
addq $8, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L00000E65:
.p2align 4,,10
.p2align 3
.L00000E68:
movl 152(%rbx), %r11d
testl %r11d, %r11d
je .L00000F68
.L00000E78:
movl 5884(%rbx), %ecx
movq 80(%rbx), %rax
subl $1, %edx
movq 5888(%rbx), %rsi
xorl %r10d, %r10d
movzbl (%rax,%rdx), %eax
movw %r10w, (%rsi,%rcx,2)
movq 5872(%rbx), %rsi
movq %rcx, %rdx
addl $1, %edx
movl %edx, 5884(%rbx)
movb %al, (%rsi,%rcx)
addw $1, 196(%rbx,%rax,4)
movl 5880(%rbx), %eax
subl $1, %eax
cmpl %eax, 5884(%rbx)
je .L00000FB0
.L00000ECC:
movl 164(%rbx), %eax
addl $1, 156(%rbx)
leal -1(%rax), %edi
movq (%rbx), %rax
movl %edi, 164(%rbx)
movl 32(%rax), %r9d
testl %r9d, %r9d
je .L00000E54
.L00000EF2:
cmpl $261, %edi
ja .L00000C0C
.L00000EFE:
movq %rbx, %rdi
call fill_window
.L00000F06:
movl 164(%rbx), %eax
cmpl $261, %eax
ja .L00000C0C
.L00000F17:
testl %ebp, %ebp
je .L00000E54
.L00000F1F:
testl %eax, %eax
je .L000010FD
.L00000F27:
cmpl $2, %eax
ja .L00000C0C
.L00000F30:
movl 144(%rbx), %ecx
movl 160(%rbx), %eax
movl $2, 144(%rbx)
movl 156(%rbx), %edx
movl %eax, 148(%rbx)
movl %ecx, 168(%rbx)
movl $2, %eax
jmp .L00000CA0
.L00000F62:
.p2align 4,,10
.p2align 3
.L00000F68:
movl 164(%rbx), %eax
addl $1, %edx
movl $1, 152(%rbx)
movl %edx, 156(%rbx)
leal -1(%rax), %edi
movl %edi, 164(%rbx)
jmp .L00000C00
.L00000F8F:
.p2align 4,,10
.p2align 3
.L00000F90:
shrw $7, %dx
leaq 256(%rdx), %rax
andl $1023, %eax
movzbl _dist_code(%rax), %eax
jmp .L00000D1D
.L00000FAC:
.p2align 4,,10
.p2align 3
.L00000FB0:
movl 156(%rbx), %edx
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L00000FD0
.L00000FC7:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L00000FD0:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00000FDA:
movq (%rbx), %r13
movl 156(%rbx), %eax
movq 56(%r13), %r14
movq %rax, 136(%rbx)
movq %r14, %rdi
call _tr_flush_bits
.L00000FF6:
movl 40(%r14), %r12d
movl 32(%r13), %eax
cmpl %r12d, %eax
cmovbe %eax, %r12d
testl %r12d, %r12d
je .L00000ECC
.L0000100E:
movq 24(%r13), %rdi
movq 32(%r14), %rsi
movl %r12d, %r15d
movq %r15, %rdx
call memcpy
.L00001021:
addq %r15, 24(%r13)
addq %r15, 32(%r14)
addq %r15, 40(%r13)
subl %r12d, 32(%r13)
subl %r12d, 40(%r14)
jne .L00000ECC
.L0000103B:
movq 16(%r14), %rax
movq %rax, 32(%r14)
jmp .L00000ECC
.L00001048:
.p2align 4
.L00001050:
movq %rbx, %rdi
call longest_match
.L00001058:
cmpl $5, %eax
movl %eax, 144(%rbx)
ja .L00001071
.L00001063:
cmpl $1, 184(%rbx)
je .L000010BC
.L0000106C:
cmpl $3, %eax
je .L000010DC
.L00001071:
movl 168(%rbx), %ecx
movl 156(%rbx), %edx
jmp .L00000CA0
.L00001082:
movq 24(%r13), %rdi
movq 32(%r14), %rsi
movl %r12d, %r15d
movq %r15, %rdx
call memcpy
.L00001095:
addq %r15, 24(%r13)
addq %r15, 32(%r14)
addq %r15, 40(%r13)
subl %r12d, 32(%r13)
subl %r12d, 40(%r14)
jne .L00000E44
.L000010AF:
movq 16(%r14), %rax
movq %rax, 32(%r14)
jmp .L00000E44
.L000010BC:
movl 156(%rbx), %edx
.L000010C2:
movl $2, 144(%rbx)
movl 168(%rbx), %ecx
movl $2, %eax
jmp .L00000CA0
.L000010DC:
movl 156(%rbx), %edx
movl %edx, %ecx
subl 160(%rbx), %ecx
cmpl $4096, %ecx
ja .L000010C2
.L000010F2:
movl 168(%rbx), %ecx
jmp .L00000CA0
.L000010FD:
movl 152(%rbx), %r8d
testl %r8d, %r8d
jne .L000011B7
.L0000110D:
movl 156(%rbx), %edx
movl $2, %eax
cmpl $2, %edx
cmovbe %edx, %eax
cmpl $4, %ebp
movl %eax, 5916(%rbx)
je .L00001209
.L0000112D:
movl 5884(%rbx), %ecx
movl $1, %eax
testl %ecx, %ecx
je .L00000E56
.L00001140:
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L0000115A
.L00001151:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L0000115A:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00001164:
movq (%rbx), %r12
movl 156(%rbx), %eax
movq 56(%r12), %rbp
movq %rax, 136(%rbx)
movq %rbp, %rdi
call _tr_flush_bits
.L00001181:
movl 40(%rbp), %r13d
movl 32(%r12), %eax
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
jne .L0000127D
.L0000119A:
movq (%rbx), %rax
movl 32(%rax), %eax
testl %eax, %eax
setne %al
addq $8, %rsp
popq %rbx
movzbl %al, %eax
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L000011B7:
movl 156(%rbx), %eax
movq 80(%rbx), %rdx
xorl %edi, %edi
movl 5884(%rbx), %ecx
movq 5888(%rbx), %rsi
subl $1, %eax
movzbl (%rdx,%rax), %eax
movw %di, (%rsi,%rcx,2)
movq 5872(%rbx), %rsi
movq %rcx, %rdx
addl $1, %edx
movl %edx, 5884(%rbx)
movb %al, (%rsi,%rcx)
addw $1, 196(%rbx,%rax,4)
movl $0, 152(%rbx)
jmp .L0000110D
.L00001209:
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L00001223
.L0000121A:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L00001223:
movl $1, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00001230:
movq (%rbx), %r12
movl 156(%rbx), %eax
movq 56(%r12), %rbp
movq %rax, 136(%rbx)
movq %rbp, %rdi
call _tr_flush_bits
.L0000124D:
movl 40(%rbp), %r13d
movl 32(%r12), %eax
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
jne .L000012BB
.L00001262:
movq (%rbx), %rax
cmpl $1, 32(%rax)
sbbl %eax, %eax
addq $8, %rsp
popq %rbx
addl $3, %eax
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L0000127D:
movq 24(%r12), %rdi
movq 32(%rbp), %rsi
movl %r13d, %r14d
movq %r14, %rdx
call memcpy
.L00001291:
addq %r14, 24(%r12)
addq %r14, 32(%rbp)
addq %r14, 40(%r12)
subl %r13d, 32(%r12)
subl %r13d, 40(%rbp)
jne .L0000119A
.L000012AE:
movq 16(%rbp), %rax
movq %rax, 32(%rbp)
jmp .L0000119A
.L000012BB:
movq 24(%r12), %rdi
movq 32(%rbp), %rsi
movl %r13d, %r14d
movq %r14, %rdx
call memcpy
.L000012CF:
addq %r14, 24(%r12)
addq %r14, 32(%rbp)
addq %r14, 40(%r12)
subl %r13d, 32(%r12)
subl %r13d, 40(%rbp)
jne .L00001262
.L000012EC:
movq 16(%rbp), %rax
movq %rax, 32(%rbp)
jmp .L00001262
.size deflate_slow, .-deflate_slow
# ----------------------
.L000012F9:
.p2align 4
# ----------------------
.local deflate_stored
.type deflate_stored, @function
deflate_stored:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbp
pushq %rbx
movq %rdi, %rbx
subq $24, %rsp
movq 24(%rdi), %rax
movl %esi, 4(%rsp)
leaq -5(%rax), %rbp
movl $65535, %eax
cmpq $65535, %rbp
cmovae %rax, %rbp
jmp .L00001360
.L0000132F:
.p2align 4,,10
.p2align 3
.L00001330:
movq (%rbx), %rax
movl 32(%rax), %ecx
testl %ecx, %ecx
je .L0000143D
.L0000133E:
movl 156(%rbx), %eax
movq 136(%rbx), %rcx
.L0000134B:
movl 68(%rbx), %edi
movl %eax, %esi
subl %ecx, %esi
leal -262(%rdi), %edx
cmpl %edx, %esi
jae .L00001500
.L00001360:
movl 164(%rbx), %eax
cmpl $1, %eax
jbe .L00001450
.L0000136F:
addl 156(%rbx), %eax
movq 136(%rbx), %rcx
movl $0, 164(%rbx)
leaq (%rbp,%rcx), %rdx
testl %eax, %eax
movl %eax, 156(%rbx)
je .L0000139C
.L00001395:
movl %eax, %esi
cmpq %rsi, %rdx
ja .L0000134B
.L0000139C:
subl %edx, %eax
movl %edx, 156(%rbx)
movl %edx, %edx
subq %rcx, %rdx
xorl %esi, %esi
testq %rcx, %rcx
movl %eax, 164(%rbx)
js .L000013BC
.L000013B6:
movl %ecx, %esi
addq 80(%rbx), %rsi
.L000013BC:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L000013C6:
movq (%rbx), %r14
movl 156(%rbx), %eax
movq 56(%r14), %r15
movq %rax, 136(%rbx)
movq %r15, %rdi
call _tr_flush_bits
.L000013E2:
movl 40(%r15), %r13d
movl 32(%r14), %eax
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
je .L00001330
.L000013FA:
movq 24(%r14), %rdi
movq 32(%r15), %rsi
movl %r13d, %r12d
movq %r12, %rdx
call memcpy
.L0000140D:
addq %r12, 24(%r14)
addq %r12, 32(%r15)
addq %r12, 40(%r14)
subl %r13d, 32(%r14)
subl %r13d, 40(%r15)
jne .L00001330
.L00001427:
movq 16(%r15), %rax
movq %rax, 32(%r15)
movq (%rbx), %rax
movl 32(%rax), %ecx
testl %ecx, %ecx
jne .L0000133E
.L0000143D:
xorl %eax, %eax
.L0000143F:
addq $24, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L0000144E:
.p2align 4,,10
.p2align 3
.L00001450:
movq %rbx, %rdi
call fill_window
.L00001458:
movl 164(%rbx), %eax
testl %eax, %eax
jne .L0000136F
.L00001466:
movl 4(%rsp), %esi
testl %esi, %esi
je .L0000143D
.L0000146E:
cmpl $4, 4(%rsp)
movl $0, 5916(%rbx)
je .L000015A5
.L00001483:
movl 156(%rbx), %edx
movq 136(%rbx), %rcx
movl $1, %eax
cmpq %rcx, %rdx
jle .L0000143F
.L0000149A:
subq %rcx, %rdx
xorl %esi, %esi
testq %rcx, %rcx
js .L000014AD
.L000014A4:
movl %ecx, %ecx
addq 80(%rbx), %rcx
movq %rcx, %rsi
.L000014AD:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L000014B7:
movq (%rbx), %r12
movl 156(%rbx), %eax
movq 56(%r12), %rbp
movq %rax, 136(%rbx)
movq %rbp, %rdi
call _tr_flush_bits
.L000014D4:
movl 40(%rbp), %r13d
movl 32(%r12), %eax
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
jne .L00001615
.L000014ED:
movq (%rbx), %rax
movl 32(%rax), %eax
testl %eax, %eax
setne %al
movzbl %al, %eax
jmp .L0000143F
.L00001500:
movl %eax, %edx
xorl %esi, %esi
subq %rcx, %rdx
testq %rcx, %rcx
js .L00001515
.L0000150C:
movl %ecx, %ecx
addq 80(%rbx), %rcx
movq %rcx, %rsi
.L00001515:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L0000151F:
movq (%rbx), %r14
movl 156(%rbx), %eax
movq 56(%r14), %r15
movq %rax, 136(%rbx)
movq %r15, %rdi
call _tr_flush_bits
.L0000153B:
movl 40(%r15), %r13d
movl 32(%r14), %eax
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
jne .L00001568
.L0000154F:
movq (%rbx), %rax
movl 32(%rax), %edx
testl %edx, %edx
jne .L00001360
.L0000155D:
jmp .L0000143D
.L00001562:
.p2align 4,,10
.p2align 3
.L00001568:
movq 24(%r14), %rdi
movq 32(%r15), %rsi
movl %r13d, %ecx
movq %rcx, %rdx
movq %rcx, 8(%rsp)
call memcpy
.L00001580:
movq 8(%rsp), %rcx
addq %rcx, 24(%r14)
addq %rcx, 32(%r15)
addq %rcx, 40(%r14)
subl %r13d, 32(%r14)
subl %r13d, 40(%r15)
jne .L0000154F
.L0000159B:
movq 16(%r15), %rax
movq %rax, 32(%r15)
jmp .L0000154F
.L000015A5:
movl 156(%rbx), %edx
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L000015C5
.L000015BC:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L000015C5:
movl $1, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L000015D2:
movq (%rbx), %r12
movl 156(%rbx), %eax
movq 56(%r12), %rbp
movq %rax, 136(%rbx)
movq %rbp, %rdi
call _tr_flush_bits
.L000015EF:
movl 40(%rbp), %r13d
movl 32(%r12), %eax
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
jne .L00001653
.L00001604:
movq (%rbx), %rax
cmpl $1, 32(%rax)
sbbl %eax, %eax
addl $3, %eax
jmp .L0000143F
.L00001615:
movq 24(%r12), %rdi
movq 32(%rbp), %rsi
movl %r13d, %r14d
movq %r14, %rdx
call memcpy
.L00001629:
addq %r14, 24(%r12)
addq %r14, 32(%rbp)
addq %r14, 40(%r12)
subl %r13d, 32(%r12)
subl %r13d, 40(%rbp)
jne .L000014ED
.L00001646:
movq 16(%rbp), %rax
movq %rax, 32(%rbp)
jmp .L000014ED
.L00001653:
movq 24(%r12), %rdi
movq 32(%rbp), %rsi
movl %r13d, %r14d
movq %r14, %rdx
call memcpy
.L00001667:
addq %r14, 24(%r12)
addq %r14, 32(%rbp)
addq %r14, 40(%r12)
subl %r13d, 32(%r12)
subl %r13d, 40(%rbp)
jne .L00001604
.L00001680:
movq 16(%rbp), %rax
movq %rax, 32(%rbp)
jmp .L00001604
.size deflate_stored, .-deflate_stored
# ----------------------
.L0000168D:
.p2align 4,,10
.p2align 3
# ----------------------
.globl deflateSetDictionary
.type deflateSetDictionary, @function
deflateSetDictionary:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbp
pushq %rbx
movq %rdi, %rbx
subq $24, %rsp
testq %rdi, %rdi
je .L000018AD
.L000016AA:
testq %rsi, %rsi
movq %rsi, %r15
movq 56(%rdi), %r13
je .L000018AD
.L000016BA:
testq %r13, %r13
je .L000018AD
.L000016C3:
movl 44(%r13), %ebp
cmpl $2, %ebp
je .L000018AD
.L000016D0:
cmpl $1, %ebp
movl %edx, %r14d
je .L00001827
.L000016DC:
movl 164(%r13), %eax
testl %eax, %eax
jne .L000018AD
.L000016EB:
movl 68(%r13), %eax
movl $0, 44(%r13)
cmpl %eax, %r14d
jae .L00001815
.L00001700:
movl 8(%rbx), %eax
movq (%rbx), %r12
movl %r14d, 8(%rbx)
movq %r15, (%rbx)
movl %eax, 12(%rsp)
.p2align 4,,10
.p2align 3
.L00001718:
movq %r13, %rdi
call fill_window
.L00001720:
movl 164(%r13), %esi
cmpl $2, %esi
jbe .L000017AC
.L00001730:
movl 156(%r13), %edx
movl 112(%r13), %eax
movl 128(%r13), %ecx
movq 80(%r13), %r15
movl 124(%r13), %r14d
movq 96(%r13), %r11
movl 76(%r13), %r10d
movq 104(%r13), %r9
leal -2(%rdx,%rsi), %r8d
movq %rbx, (%rsp)
.p2align 4,,10
.p2align 3
.L00001760:
leal 2(%rdx), %esi
sall %cl, %eax
movl %edx, %edi
andl %r10d, %edi
movzbl (%r15,%rsi), %esi
xorl %esi, %eax
andl %r14d, %eax
movl %eax, %esi
movl %eax, 112(%r13)
leaq (%r9,%rsi,2), %rsi
movzwl (%rsi), %ebx
movw %bx, (%r11,%rdi,2)
movw %dx, (%rsi)
addl $1, %edx
cmpl %r8d, %edx
jne .L00001760
.L00001791:
movq (%rsp), %rbx
movl %edx, 156(%r13)
movl $2, 164(%r13)
jmp .L00001718
.L000017AC:
movl %esi, %eax
addl 156(%r13), %eax
movl %esi, 5916(%r13)
movl $0, 164(%r13)
movl $2, 168(%r13)
movl $2, 144(%r13)
movl $0, 152(%r13)
movl %eax, 156(%r13)
movq %rax, 136(%r13)
movl 12(%rsp), %eax
movq %r12, (%rbx)
movl %eax, 8(%rbx)
movl %ebp, 44(%r13)
xorl %eax, %eax
.L00001806:
addq $24, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L00001815:
testl %ebp, %ebp
je .L00001867
.L00001819:
subl %eax, %r14d
addq %r14, %r15
movl %eax, %r14d
jmp .L00001700
.L00001827:
cmpl $42, 8(%r13)
movl $-2, %eax
jne .L00001806
.L00001833:
movl 164(%r13), %edx
testl %edx, %edx
jne .L00001806
.L0000183E:
movq 96(%rbx), %rdi
movl %r14d, %edx
movq %r15, %rsi
call adler32
.L0000184D:
movq %rax, 96(%rbx)
movl 68(%r13), %eax
movl $0, 44(%r13)
cmpl %eax, %r14d
jae .L00001819
.L00001862:
jmp .L00001700
.L00001867:
movl 116(%r13), %eax
movq 104(%r13), %rdi
xorl %ecx, %ecx
xorl %esi, %esi
subl $1, %eax
leaq (%rax,%rax), %rdx
movw %cx, (%rdi,%rax,2)
call memset
.L00001883:
movl $0, 156(%r13)
movq $0, 136(%r13)
movl $0, 5916(%r13)
movl 68(%r13), %eax
jmp .L00001819
.L000018AD:
movl $-2, %eax
jmp .L00001806
.size deflateSetDictionary, .-deflateSetDictionary
# ----------------------
.L000018B7:
.p2align 4
# ----------------------
.globl deflateResetKeep
.type deflateResetKeep, @function
deflateResetKeep:
testq %rdi, %rdi
je .L00001987
.L000018C9:
pushq %rbp
pushq %rbx
subq $8, %rsp
movq 56(%rdi), %rbp
testq %rbp, %rbp
je .L00001980
.L000018DC:
cmpq $0, 64(%rdi)
je .L00001980
.L000018E7:
cmpq $0, 72(%rdi)
je .L00001980
.L000018F2:
movq 16(%rbp), %rax
movq $0, 40(%rdi)
movq %rdi, %rbx
movq $0, 16(%rdi)
movq $0, 48(%rdi)
movl $2, 88(%rdi)
movl $0, 40(%rbp)
movq %rax, 32(%rbp)
movl 44(%rbp), %eax
testl %eax, %eax
js .L00001960
.L0000192A:
jne .L00001965
.L0000192C:
movl $113, 8(%rbp)
.L00001933:
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
call adler32
.L0000193E:
movq %rax, 96(%rbx)
movq %rbp, %rdi
movl $0, 64(%rbp)
call _tr_init
.L00001951:
xorl %eax, %eax
.L00001953:
addq $8, %rsp
popq %rbx
popq %rbp
ret
.L0000195A:
.p2align 4,,10
.p2align 3
.L00001960:
negl %eax
movl %eax, 44(%rbp)
.L00001965:
cmpl $2, %eax
movl $42, 8(%rbp)
jne .L00001933
.L00001971:
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
call crc32
.L0000197C:
jmp .L0000193E
.L0000197E:
.p2align 4,,10
.p2align 3
.L00001980:
movl $-2, %eax
jmp .L00001953
.L00001987:
movl $-2, %eax
ret
.size deflateResetKeep, .-deflateResetKeep
# ----------------------
.L0000198D:
.p2align 4,,10
.p2align 3
# ----------------------
.globl deflateReset
.type deflateReset, @function
deflateReset:
testq %rdi, %rdi
je .L00001B1F
.L00001999:
pushq %rbp
pushq %rbx
subq $8, %rsp
movq 56(%rdi), %rbp
testq %rbp, %rbp
je .L00001B18
.L000019AC:
cmpq $0, 64(%rdi)
je .L00001B18
.L000019B7:
cmpq $0, 72(%rdi)
je .L00001B18
.L000019C2:
movq 16(%rbp), %rax
movq $0, 40(%rdi)
movq %rdi, %rbx
movq $0, 16(%rdi)
movq $0, 48(%rdi)
movl $2, 88(%rdi)
movl $0, 40(%rbp)
movq %rax, 32(%rbp)
movl 44(%rbp), %eax
testl %eax, %eax
js .L00001AF0
.L000019FE:
jne .L00001AF5
.L00001A04:
movl $113, 8(%rbp)
.L00001A0B:
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
call adler32
.L00001A16:
movq %rax, 96(%rbx)
movq %rbp, %rdi
movl $0, 64(%rbp)
call _tr_init
.L00001A29:
movq 56(%rbx), %rbx
xorl %ecx, %ecx
xorl %esi, %esi
movl 68(%rbx), %eax
movq 104(%rbx), %rdi
addq %rax, %rax
movq %rax, 88(%rbx)
movl 116(%rbx), %eax
subl $1, %eax
leaq (%rax,%rax), %rdx
movw %cx, (%rdi,%rax,2)
call memset
.L00001A52:
movslq 180(%rbx), %rax
movl $0, 156(%rbx)
movq $0, 136(%rbx)
movl $0, 164(%rbx)
movl $0, 5916(%rbx)
movl $2, 168(%rbx)
movl $2, 144(%rbx)
movl $0, 152(%rbx)
salq $4, %rax
movl $0, 112(%rbx)
leaq configuration_table(%rax), %rdx
movzwl configuration_table+2(%rax), %ecx
movzwl configuration_table(%rax), %eax
movl %eax, 188(%rbx)
movzwl 4(%rdx), %eax
movl %ecx, 176(%rbx)
movl %eax, 192(%rbx)
movzwl 6(%rdx), %eax
movl %eax, 172(%rbx)
xorl %eax, %eax
.L00001AE2:
addq $8, %rsp
popq %rbx
popq %rbp
ret
.L00001AE9:
.p2align 4
.L00001AF0:
negl %eax
movl %eax, 44(%rbp)
.L00001AF5:
cmpl $2, %eax
movl $42, 8(%rbp)
jne .L00001A0B
.L00001B05:
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
call crc32
.L00001B10:
jmp .L00001A16
.L00001B15:
.p2align 4,,10
.p2align 3
.L00001B18:
movl $-2, %eax
jmp .L00001AE2
.L00001B1F:
movl $-2, %eax
ret
.size deflateReset, .-deflateReset
# ----------------------
.L00001B25:
.p2align 4
# ----------------------
.globl deflateSetHeader
.type deflateSetHeader, @function
deflateSetHeader:
testq %rdi, %rdi
je .L00001B52
.L00001B35:
movq 56(%rdi), %rdx
movl $-2, %eax
testq %rdx, %rdx
je .L00001B50
.L00001B43:
cmpl $2, 44(%rdx)
jne .L00001B50
.L00001B49:
movq %rsi, 48(%rdx)
xorl %eax, %eax
ret
.L00001B50:
rep; ret
.L00001B52:
movl $-2, %eax
ret
.size deflateSetHeader, .-deflateSetHeader
# ----------------------
.L00001B58:
.p2align 4
# ----------------------
.globl deflatePending
.type deflatePending, @function
deflatePending:
testq %rdi, %rdi
je .L00001B98
.L00001B65:
movq 56(%rdi), %rax
testq %rax, %rax
je .L00001B98
.L00001B6E:
testq %rsi, %rsi
je .L00001B78
.L00001B73:
movl 40(%rax), %ecx
movl %ecx, (%rsi)
.L00001B78:
testq %rdx, %rdx
je .L00001B90
.L00001B7D:
movl 5924(%rax), %eax
movl %eax, (%rdx)
xorl %eax, %eax
ret
.L00001B88:
.p2align 4
.L00001B90:
xorl %eax, %eax
ret
.L00001B93:
.p2align 4,,10
.p2align 3
.L00001B98:
movl $-2, %eax
ret
.size deflatePending, .-deflatePending
# ----------------------
.L00001B9E:
.p2align 4,,10
.p2align 3
# ----------------------
.globl deflatePrime
.type deflatePrime, @function
deflatePrime:
testq %rdi, %rdi
je .L00001C47
.L00001BA9:
pushq %r14
pushq %r13
pushq %r12
pushq %rbp
pushq %rbx
movq 56(%rdi), %r12
testq %r12, %r12
je .L00001C40
.L00001BBE:
movq 32(%r12), %rax
addq $2, %rax
cmpq %rax, 5888(%r12)
jb .L00001C39
.L00001BD1:
movl %esi, %r13d
movl %edx, %r14d
movl $16, %ebx
.p2align 4,,10
.p2align 3
.L00001BE0:
movl 5924(%r12), %r8d
movl %ebx, %ebp
movl $1, %eax
movq %r12, %rdi
subl %r8d, %ebp
cmpl %ebp, %r13d
cmovle %r13d, %ebp
movl %ebp, %ecx
sall %cl, %eax
movl %r8d, %ecx
addl %ebp, %r8d
subl $1, %eax
movl %r8d, 5924(%r12)
andl %r14d, %eax
sall %cl, %eax
orw %ax, 5920(%r12)
call _tr_flush_bits
.L00001C24:
movl %ebp, %ecx
sarl %cl, %r14d
subl %ebp, %r13d
jne .L00001BE0
.L00001C2E:
xorl %eax, %eax
.L00001C30:
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
ret
.L00001C39:
movl $-5, %eax
jmp .L00001C30
.L00001C40:
movl $-2, %eax
jmp .L00001C30
.L00001C47:
movl $-2, %eax
ret
.size deflatePrime, .-deflatePrime
# ----------------------
.L00001C4D:
.p2align 4,,10
.p2align 3
# ----------------------
.globl deflateTune
.type deflateTune, @function
deflateTune:
testq %rdi, %rdi
je .L00001C80
.L00001C55:
movq 56(%rdi), %rax
testq %rax, %rax
je .L00001C80
.L00001C5E:
movl %esi, 188(%rax)
movl %edx, 176(%rax)
movl %ecx, 192(%rax)
movl %r8d, 172(%rax)
xorl %eax, %eax
ret
.L00001C7A:
.p2align 4,,10
.p2align 3
.L00001C80:
movl $-2, %eax
ret
.size deflateTune, .-deflateTune
# ----------------------
.L00001C86:
.p2align 4
# ----------------------
.globl deflateBound
.type deflateBound, @function
deflateBound:
leaq 7(%rsi), %r8
leaq 63(%rsi), %rax
movq %r8, %rdx
shrq $6, %rax
shrq $3, %rdx
addq %rdx, %rax
addq %rsi, %rax
testq %rdi, %rdi
je .L00001DB0
.L00001CB2:
movq 56(%rdi), %rcx
testq %rcx, %rcx
je .L00001DB0
.L00001CBF:
movl 44(%rcx), %edx
cmpl $1, %edx
je .L00001D90
.L00001CCB:
cmpl $2, %edx
je .L00001CF0
.L00001CD0:
cmpl $1, %edx
sbbq %rdx, %rdx
notq %rdx
andl $6, %edx
.L00001CDC:
cmpl $15, 72(%rcx)
je .L00001D60
.L00001CE2:
leaq 5(%rdx,%rax), %rax
ret
.L00001CE8:
.p2align 4
.L00001CF0:
movq 48(%rcx), %r9
testq %r9, %r9
je .L00001DB8
.L00001CFD:
cmpq $0, 24(%r9)
je .L00001DC8
.L00001D08:
movl 32(%r9), %edx
addl $2, %edx
addq $18, %rdx
.L00001D13:
movq 40(%r9), %rdi
testq %rdi, %rdi
je .L00001D2B
.L00001D1C:
subq %rdx, %rdi
.p2align 4,,10
.p2align 3
.L00001D20:
addq $1, %rdx
cmpb $0, -1(%rdi,%rdx)
jne .L00001D20
.L00001D2B:
movq 56(%r9), %rdi
testq %rdi, %rdi
je .L00001D4B
.L00001D34:
subq %rdx, %rdi
.p2align 4
.L00001D40:
addq $1, %rdx
cmpb $0, -1(%rdi,%rdx)
jne .L00001D40
.L00001D4B:
movl 68(%r9), %r9d
leaq 2(%rdx), %rdi
testl %r9d, %r9d
cmovne %rdi, %rdx
cmpl $15, 72(%rcx)
jne .L00001CE2
.L00001D60:
cmpl $15, 120(%rcx)
jne .L00001CE2
.L00001D6A:
movq %rsi, %rax
shrq $12, %rax
addq %rax, %r8
movq %rsi, %rax
shrq $25, %rsi
shrq $14, %rax
addq %rax, %r8
leaq (%r8,%rsi), %rax
addq %rdx, %rax
ret
.L00001D8A:
.p2align 4,,10
.p2align 3
.L00001D90:
cmpl $1, 156(%rcx)
sbbq %rdx, %rdx
andq $-4, %rdx
addq $10, %rdx
jmp .L00001CDC
.L00001DA7:
.p2align 4
.L00001DB0:
addq $11, %rax
ret
.L00001DB5:
.p2align 4,,10
.p2align 3
.L00001DB8:
movl $18, %edx
jmp .L00001CDC
.L00001DC2:
.p2align 4,,10
.p2align 3
.L00001DC8:
movl $18, %edx
jmp .L00001D13
.size deflateBound, .-deflateBound
# ----------------------
.L00001DD2:
.p2align 4
# ----------------------
.globl deflate
.type deflate, @function
deflate:
testq %rdi, %rdi
je .L000033A6
.L00001DE9:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbp
pushq %rbx
subq $40, %rsp
movq 56(%rdi), %rbx
testq %rbx, %rbx
je .L00002E30
.L00001E04:
cmpl $5, %esi
ja .L00002E30
.L00001E0D:
cmpq $0, 24(%rdi)
je .L00002C8D
.L00001E18:
cmpq $0, (%rdi)
je .L00002C80
.L00001E22:
cmpl $4, %esi
movl 8(%rbx), %eax
setne 27(%rsp)
je .L00001E3A
.L00001E2F:
cmpl $666, %eax
je .L00002C8D
.L00001E3A:
movl 32(%rdi), %r9d
testl %r9d, %r9d
je .L00002EB5
.L00001E47:
cmpl $42, %eax
movl 64(%rbx), %r13d
movl %esi, %ebp
movq %rdi, %r14
movq %rdi, (%rbx)
movl %esi, 64(%rbx)
je .L00002290
.L00001E5F:
cmpl $69, %eax
je .L00002391
.L00001E68:
cmpl $73, %eax
movl 40(%rbx), %edi
je .L000024A8
.L00001E74:
movl %edi, %edx
.L00001E76:
cmpl $91, %eax
je .L00002D5D
.L00001E7F:
cmpl $103, %eax
je .L00002D54
.L00001E88:
testl %edx, %edx
jne .L00002240
.L00001E90:
movl 8(%r14), %esi
testl %esi, %esi
je .L00001F10
.L00001E98:
cmpl $666, 8(%rbx)
je .L00002560
.L00001EA5:
movl 184(%rbx), %eax
cmpl $2, %eax
je .L00002023
.L00001EB4:
cmpl $3, %eax
je .L00002950
.L00001EBD:
movslq 180(%rbx), %rax
movl %ebp, %esi
movq %rbx, %rdi
salq $4, %rax
call *configuration_table+8(%rax)
.L00001ED3:
leal -2(%rax), %edx
cmpl $1, %edx
jbe .L00002CC8
.L00001EDF:
movl %eax, %edx
andl $-3, %edx
.L00001EE4:
testl %edx, %edx
jne .L00002170
.L00001EEC:
movl 32(%r14), %r10d
testl %r10d, %r10d
je .L00002580
.L00001EF9:
xorl %eax, %eax
.L00001EFB:
addq $40, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L00001F0A:
.p2align 4,,10
.p2align 3
.L00001F10:
xorl %eax, %eax
cmpl $5, %ebp
leal (%rbp,%rbp), %ecx
sete %al
leal (%r13,%r13), %edx
leal (%rax,%rax,8), %eax
subl %eax, %ecx
xorl %eax, %eax
cmpl $4, %r13d
setg %al
leal (%rax,%rax,8), %eax
subl %eax, %edx
cmpl %edx, %ecx
jg .L00001F43
.L00001F38:
cmpb $0, 27(%rsp)
jne .L00002560
.L00001F43:
movl 8(%rbx), %eax
.L00001F46:
movl 164(%rbx), %r15d
testl %r15d, %r15d
jne .L00001EA5
.L00001F56:
testl %ebp, %ebp
je .L00001EF9
.L00001F5A:
cmpl $666, %eax
jne .L00001EA5
.L00001F65:
jmp .L00002179
.L00001F6A:
.p2align 4,,10
.p2align 3
.L00001F70:
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L00001F8A
.L00001F81:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L00001F8A:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00001F94:
movq (%rbx), %r15
movl 156(%rbx), %eax
movq 56(%r15), %rcx
movq %rax, 136(%rbx)
movq %rcx, %rdi
movq %rcx, 8(%rsp)
call _tr_flush_bits
.L00001FB5:
movq 8(%rsp), %rcx
movl 32(%r15), %eax
movl 40(%rcx), %r13d
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
je .L00002013
.L00001FCE:
movq 32(%rcx), %rsi
movq 24(%r15), %rdi
movl %r13d, %r8d
movq %r8, %rdx
movq %rcx, 16(%rsp)
movq %r8, 8(%rsp)
call memcpy
.L00001FEB:
movq 16(%rsp), %rcx
movq 8(%rsp), %r8
addq %r8, 24(%r15)
addq %r8, 32(%rcx)
addq %r8, 40(%r15)
subl %r13d, 32(%r15)
subl %r13d, 40(%rcx)
jne .L00002013
.L0000200B:
movq 16(%rcx), %rax
movq %rax, 32(%rcx)
.L00002013:
movq (%rbx), %rax
movl 32(%rax), %r11d
testl %r11d, %r11d
je .L00001EEC
.L00002023:
movl 164(%rbx), %eax
jmp .L000020AF
.L0000202E:
.p2align 4,,10
.p2align 3
.L00002030:
movl 156(%rbx), %eax
movl 5884(%rbx), %ecx
xorl %r12d, %r12d
movq 80(%rbx), %rdx
movq 5888(%rbx), %rsi
movl $0, 144(%rbx)
movzbl (%rdx,%rax), %eax
movw %r12w, (%rsi,%rcx,2)
movq %rcx, %rdx
movq 5872(%rbx), %rsi
addl $1, %edx
movl %edx, 5884(%rbx)
movb %al, (%rsi,%rcx)
addw $1, 196(%rbx,%rax,4)
movl 5880(%rbx), %eax
movl 156(%rbx), %edi
leal -1(%rax), %ecx
movl 164(%rbx), %eax
leal 1(%rdi), %edx
movl %edx, 156(%rbx)
subl $1, %eax
cmpl %ecx, 5884(%rbx)
movl %eax, 164(%rbx)
je .L00001F70
.L000020AF:
testl %eax, %eax
jne .L00002030
.L000020B7:
movq %rbx, %rdi
call fill_window
.L000020BF:
movl 164(%rbx), %r13d
testl %r13d, %r13d
jne .L00002030
.L000020CF:
testl %ebp, %ebp
je .L00001EEC
.L000020D7:
cmpl $4, %ebp
movl $0, 5916(%rbx)
je .L0000329F
.L000020EA:
movl 5884(%rbx), %r9d
testl %r9d, %r9d
je .L000025AF
.L000020FA:
movl 156(%rbx), %edx
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L0000211A
.L00002111:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L0000211A:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00002124:
movq (%rbx), %r15
movl 156(%rbx), %eax
movq 56(%r15), %r13
movq %rax, 136(%rbx)
movq %r13, %rdi
call _tr_flush_bits
.L00002140:
movl 40(%r13), %ecx
movl 32(%r15), %eax
cmpl %ecx, %eax
cmovbe %eax, %ecx
testl %ecx, %ecx
jne .L000033AC
.L00002155:
movq (%rbx), %rax
movl 32(%rax), %r11d
xorl %eax, %eax
testl %r11d, %r11d
setne %al
movl %eax, %edx
jmp .L00001EE4
.L0000216B:
.p2align 4,,10
.p2align 3
.L00002170:
cmpl $1, %eax
je .L000025AF
.L00002179:
cmpb $0, 27(%rsp)
jne .L00001EF9
.L00002184:
movl 44(%rbx), %eax
testl %eax, %eax
jle .L000031CA
.L0000218F:
cmpl $2, %eax
je .L00002F20
.L00002198:
movl 40(%rbx), %eax
movq 96(%r14), %rdx
movq 16(%rbx), %rcx
shrq $16, %rdx
leal 1(%rax), %esi
movl %esi, 40(%rbx)
movl %edx, %esi
shrl $8, %esi
movb %sil, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %esi
movl %esi, 40(%rbx)
movb %dl, (%rcx,%rax)
movl 40(%rbx), %eax
movzwl 96(%r14), %edx
movq 16(%rbx), %rcx
leal 1(%rax), %esi
movl %esi, 40(%rbx)
movl %edx, %esi
shrl $8, %esi
movb %sil, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %esi
movl %esi, 40(%rbx)
movb %dl, (%rcx,%rax)
.L000021F1:
movq 56(%r14), %r12
movq %r12, %rdi
call _tr_flush_bits
.L000021FD:
movl 40(%r12), %ebp
movl 32(%r14), %eax
cmpl %ebp, %eax
cmovbe %eax, %ebp
testl %ebp, %ebp
jne .L00002E3A
.L00002213:
movl 44(%rbx), %eax
testl %eax, %eax
jle .L0000221F
.L0000221A:
negl %eax
movl %eax, 44(%rbx)
.L0000221F:
movl 40(%rbx), %esi
xorl %eax, %eax
testl %esi, %esi
sete %al
addq $40, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L00002238:
.p2align 4
.L00002240:
movq 56(%r14), %r15
movq %r15, %rdi
call _tr_flush_bits
.L0000224C:
movl 40(%r15), %r13d
movl 32(%r14), %eax
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
jne .L00002657
.L00002264:
testl %eax, %eax
je .L00002641
.L0000226C:
movl 8(%rbx), %eax
cmpl $666, %eax
je .L00002550
.L0000227A:
movl 8(%r14), %edx
testl %edx, %edx
je .L00001F46
.L00002286:
jmp .L00001EA5
.L0000228B:
.p2align 4,,10
.p2align 3
.L00002290:
cmpl $2, 44(%rbx)
je .L00003017
.L0000229A:
movl 72(%rbx), %eax
xorl %ecx, %ecx
sall $12, %eax
subl $30720, %eax
cmpl $1, 184(%rbx)
jle .L000026B3
.L000022B4:
movl 156(%rbx), %r12d
orl %eax, %ecx
movl $138547333, %edx
movl %ecx, %eax
movl $113, 8(%rbx)
orl $32, %eax
testl %r12d, %r12d
cmovne %eax, %ecx
movl %ecx, %eax
mull %edx
subl %edx, %ecx
shrl $1, %ecx
addl %ecx, %edx
movq 16(%rbx), %rcx
shrl $4, %edx
movl %edx, %eax
sall $5, %eax
subl %edx, %eax
movl 40(%rbx), %edx
addl $31, %eax
leal 1(%rdx), %esi
movl %esi, 40(%rbx)
movl %eax, %esi
shrl $8, %esi
movb %sil, (%rcx,%rdx)
movl 40(%rbx), %edx
movq 16(%rbx), %rcx
leal 1(%rdx), %esi
movl %esi, 40(%rbx)
movb %al, (%rcx,%rdx)
movl 156(%rbx), %r15d
testl %r15d, %r15d
je .L00002376
.L0000231D:
movl 40(%rbx), %eax
movq 96(%r14), %rdx
movq 16(%rbx), %rcx
shrq $16, %rdx
leal 1(%rax), %esi
movl %esi, 40(%rbx)
movl %edx, %esi
shrl $8, %esi
movb %sil, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %esi
movl %esi, 40(%rbx)
movb %dl, (%rcx,%rax)
movl 40(%rbx), %eax
movzwl 96(%r14), %edx
movq 16(%rbx), %rcx
leal 1(%rax), %esi
movl %esi, 40(%rbx)
movl %edx, %esi
shrl $8, %esi
movb %sil, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %esi
movl %esi, 40(%rbx)
movb %dl, (%rcx,%rax)
.L00002376:
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
call adler32
.L00002381:
movq %rax, 96(%r14)
movl 8(%rbx), %eax
cmpl $69, %eax
jne .L00001E68
.L00002391:
movq 48(%rbx), %rax
.L00002395:
cmpq $0, 24(%rax)
je .L00002ECA
.L000023A0:
movl 56(%rbx), %ecx
movl 32(%rax), %esi
movl 40(%rbx), %edi
movzwl %si, %edx
cmpl %ecx, %edx
jbe .L00002490
.L000023B4:
movl %edi, %r8d
movl %edi, %edx
jmp .L000023F0
.L000023BB:
.p2align 4,,10
.p2align 3
.L000023C0:
movq 24(%rax), %rax
addl $1, %edx
movq 16(%rbx), %r9
movl %edx, 40(%rbx)
movzbl (%rax,%rcx), %eax
movb %al, (%r9,%rsi)
movl 56(%rbx), %eax
leal 1(%rax), %ecx
movq 48(%rbx), %rax
movl %ecx, 56(%rbx)
movl 32(%rax), %esi
movzwl %si, %edx
cmpl %ecx, %edx
jbe .L00002450
.L000023ED:
movl 40(%rbx), %edx
.L000023F0:
movl %edx, %esi
cmpq 24(%rbx), %rsi
jne .L000023C0
.L000023F8:
cmpl %edx, %edi
jae .L00002409
.L000023FC:
movl 68(%rax), %r11d
testl %r11d, %r11d
jne .L00002CA8
.L00002409:
movq 56(%r14), %r12
movq %r12, %rdi
call _tr_flush_bits
.L00002415:
movl 40(%r12), %r15d
movl 32(%r14), %eax
cmpl %r15d, %eax
cmovbe %eax, %r15d
testl %r15d, %r15d
jne .L00002730
.L0000242E:
movl 40(%rbx), %esi
cmpq 24(%rbx), %rsi
movq %rsi, %rdi
movl %esi, %r8d
je .L00002E98
.L00002441:
movq 48(%rbx), %rax
movl 56(%rbx), %ecx
movl %esi, %edx
jmp .L000023C0
.L0000244F:
.p2align 4,,10
.p2align 3
.L00002450:
movl 68(%rax), %r10d
movl 40(%rbx), %edi
testl %r10d, %r10d
je .L00002490
.L0000245C:
cmpl %r8d, %edi
jbe .L00002490
.L00002461:
subl %r8d, %edi
movq %r8, %rsi
addq 16(%rbx), %rsi
movl %edi, %edx
movq 96(%r14), %rdi
call crc32
.L00002476:
movq %rax, 96(%r14)
movq 48(%rbx), %rax
movl 56(%rbx), %ecx
movl 40(%rbx), %edi
movl 32(%rax), %esi
.p2align 4
.L00002490:
cmpl %esi, %ecx
je .L000026A0
.L00002498:
movl 8(%rbx), %eax
cmpl $73, %eax
jne .L00001E74
.L000024A4:
.p2align 4,,10
.p2align 3
.L000024A8:
movq 48(%rbx), %rax
.L000024AC:
cmpq $0, 40(%rax)
je .L00002EA7
.L000024B7:
movl %edi, %esi
movl %esi, %edx
jmp .L000024EF
.L000024BD:
.p2align 4,,10
.p2align 3
.L000024C0:
movq 40(%rax), %rdi
movl 56(%rbx), %eax
addl $1, %edx
leal 1(%rax), %r8d
movl %r8d, 56(%rbx)
movzbl (%rdi,%rax), %eax
movq 16(%rbx), %rdi
movl %edx, 40(%rbx)
testb %al, %al
movb %al, (%rdi,%rcx)
je .L00002780
.L000024E8:
movl 40(%rbx), %edx
movq 48(%rbx), %rax
.L000024EF:
movl %edx, %ecx
cmpq 24(%rbx), %rcx
jne .L000024C0
.L000024F7:
cmpl %edx, %esi
jae .L00002508
.L000024FB:
movl 68(%rax), %r9d
testl %r9d, %r9d
jne .L00002C40
.L00002508:
movq 56(%r14), %r12
movq %r12, %rdi
call _tr_flush_bits
.L00002514:
movl 40(%r12), %r15d
movl 32(%r14), %eax
cmpl %r15d, %eax
cmovbe %eax, %r15d
testl %r15d, %r15d
jne .L000026E0
.L0000252D:
movl 40(%rbx), %esi
movq 48(%rbx), %rax
movl %esi, %ecx
cmpq 24(%rbx), %rcx
je .L00002E79
.L00002540:
movl %esi, %edx
jmp .L000024C0
.L00002547:
.p2align 4
.L00002550:
movl 8(%r14), %ecx
testl %ecx, %ecx
je .L00001F46
.L0000255C:
.p2align 4,,10
.p2align 3
.L00002560:
movq z_errmsg+56(%rip), %rax
movq %rax, 48(%r14)
addq $40, %rsp
movl $-5, %eax
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L0000257F:
.p2align 4,,10
.p2align 3
.L00002580:
movl $-1, 64(%rbx)
jmp .L00001EF9
.L0000258C:
cmpl $4, %ebp
movl $0, 5916(%rbx)
je .L000031D4
.L0000259F:
movl 5884(%rbx), %r12d
testl %r12d, %r12d
jne .L00002D66
.L000025AF:
cmpl $1, %ebp
je .L00003344
.L000025B8:
cmpl $5, %ebp
je .L00002618
.L000025BD:
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
movq %rbx, %rdi
call _tr_stored_block
.L000025CB:
cmpl $3, %ebp
jne .L00002618
.L000025D0:
movl 116(%rbx), %eax
movq 104(%rbx), %rdi
xorl %r8d, %r8d
xorl %esi, %esi
subl $1, %eax
leaq (%rax,%rax), %rdx
movw %r8w, (%rdi,%rax,2)
call memset
.L000025ED:
movl 164(%rbx), %r9d
testl %r9d, %r9d
jne .L00002618
.L000025F9:
movl $0, 156(%rbx)
movq $0, 136(%rbx)
movl $0, 5916(%rbx)
.L00002618:
movq 56(%r14), %r13
movq %r13, %rdi
call _tr_flush_bits
.L00002624:
movl 40(%r13), %ebp
movl 32(%r14), %eax
cmpl %ebp, %eax
cmovbe %eax, %ebp
testl %ebp, %ebp
jne .L00002FDD
.L00002639:
testl %eax, %eax
jne .L00002179
.L00002641:
movl $-1, 64(%rbx)
addq $40, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L00002657:
movq 24(%r14), %rdi
movq 32(%r15), %rsi
movl %r13d, %ecx
movq %rcx, %rdx
movq %rcx, 8(%rsp)
call memcpy
.L0000266F:
movq 8(%rsp), %rcx
addq %rcx, 24(%r14)
addq %rcx, 32(%r15)
addq %rcx, 40(%r14)
subl %r13d, 32(%r14)
subl %r13d, 40(%r15)
jne .L00002692
.L0000268A:
movq 16(%r15), %rax
movq %rax, 32(%r15)
.L00002692:
movl 32(%r14), %eax
testl %eax, %eax
jne .L0000226C
.L0000269E:
jmp .L00002641
.L000026A0:
movl $0, 56(%rbx)
movl $73, 8(%rbx)
jmp .L000024AC
.L000026B3:
movl 180(%rbx), %edx
cmpl $1, %edx
jle .L000022B4
.L000026C2:
cmpl $5, %edx
movb $64, %cl
jle .L000022B4
.L000026CD:
cmpl $6, %edx
movb $-64, %cl
movl $128, %edx
cmove %edx, %ecx
jmp .L000022B4
.L000026DF:
.p2align 4,,10
.p2align 3
.L000026E0:
movq 24(%r14), %rdi
movq 32(%r12), %rsi
movl %r15d, %r8d
movq %r8, %rdx
movq %r8, 8(%rsp)
call memcpy
.L000026F9:
movq 8(%rsp), %r8
addq %r8, 24(%r14)
addq %r8, 32(%r12)
addq %r8, 40(%r14)
subl %r15d, 32(%r14)
subl %r15d, 40(%r12)
jne .L0000252D
.L0000271A:
movq 16(%r12), %rax
movq %rax, 32(%r12)
jmp .L0000252D
.L00002729:
.p2align 4
.L00002730:
movq 24(%r14), %rdi
movq 32(%r12), %rsi
movl %r15d, %r8d
movq %r8, %rdx
movq %r8, 8(%rsp)
call memcpy
.L00002749:
movq 8(%rsp), %r8
addq %r8, 24(%r14)
addq %r8, 32(%r12)
addq %r8, 40(%r14)
subl %r15d, 32(%r14)
subl %r15d, 40(%r12)
jne .L0000242E
.L0000276A:
movq 16(%r12), %rax
movq %rax, 32(%r12)
jmp .L0000242E
.L00002779:
.p2align 4
.L00002780:
movq 48(%rbx), %rax
movl 40(%rbx), %edx
movl 68(%rax), %ecx
testl %ecx, %ecx
je .L000027B8
.L0000278E:
cmpl %esi, %edx
jbe .L000027B8
.L00002792:
movl %edx, %eax
movl %esi, %edx
movq 96(%r14), %rdi
subl %esi, %eax
movq %rdx, %rsi
addq 16(%rbx), %rsi
movl %eax, %edx
call crc32
.L000027AA:
movl 40(%rbx), %edx
movq %rax, 96(%r14)
movq 48(%rbx), %rax
.p2align 4,,10
.p2align 3
.L000027B8:
movl $0, 56(%rbx)
movl $91, 8(%rbx)
.L000027C6:
cmpq $0, 56(%rax)
je .L000028E8
.L000027D1:
movl %edx, %edi
movl %edi, %esi
jmp .L00002810
.L000027D7:
.p2align 4
.L000027E0:
movq 56(%rax), %rdx
movl 56(%rbx), %eax
addl $1, %esi
leal 1(%rax), %r8d
movl %r8d, 56(%rbx)
movzbl (%rdx,%rax), %eax
movq 16(%rbx), %r8
movl %esi, 40(%rbx)
testb %al, %al
movb %al, (%r8,%rcx)
je .L000028B0
.L00002809:
movl 40(%rbx), %esi
movq 48(%rbx), %rax
.L00002810:
movl %esi, %ecx
cmpq 24(%rbx), %rcx
jne .L000027E0
.L00002818:
cmpl %esi, %edi
jae .L00002829
.L0000281C:
movl 68(%rax), %r8d
testl %r8d, %r8d
jne .L00002C60
.L00002829:
movq 56(%r14), %r12
movq %r12, %rdi
call _tr_flush_bits
.L00002835:
movl 40(%r12), %r15d
movl 32(%r14), %eax
cmpl %r15d, %eax
cmovbe %eax, %r15d
testl %r15d, %r15d
jne .L00002868
.L0000284A:
movl 40(%rbx), %edi
movq 48(%rbx), %rax
movl %edi, %ecx
cmpq 24(%rbx), %rcx
je .L00002E83
.L0000285D:
movl %edi, %esi
jmp .L000027E0
.L00002864:
.p2align 4,,10
.p2align 3
.L00002868:
movq 24(%r14), %rdi
movq 32(%r12), %rsi
movl %r15d, %r8d
movq %r8, %rdx
movq %r8, 8(%rsp)
call memcpy
.L00002881:
movq 8(%rsp), %r8
addq %r8, 24(%r14)
addq %r8, 32(%r12)
addq %r8, 40(%r14)
subl %r15d, 32(%r14)
subl %r15d, 40(%r12)
jne .L0000284A
.L0000289E:
movq 16(%r12), %rax
movq %rax, 32(%r12)
jmp .L0000284A
.L000028AA:
.p2align 4,,10
.p2align 3
.L000028B0:
movq 48(%rbx), %rax
movl 68(%rax), %edx
testl %edx, %edx
movl 40(%rbx), %edx
je .L000028E8
.L000028BE:
cmpl %edi, %edx
jbe .L000028E8
.L000028C2:
movl %edx, %eax
movl %edi, %edx
movq %rdx, %rsi
addq 16(%rbx), %rsi
subl %edi, %eax
movq 96(%r14), %rdi
movl %eax, %edx
call crc32
.L000028DA:
movl 40(%rbx), %edx
movq %rax, 96(%r14)
movq 48(%rbx), %rax
.p2align 4,,10
.p2align 3
.L000028E8:
movl $103, 8(%rbx)
.L000028EF:
movl 68(%rax), %edi
testl %edi, %edi
je .L00002D48
.L000028FA:
leal 2(%rdx), %eax
cmpq 24(%rbx), %rax
ja .L00002ED9
.L00002907:
leal 1(%rdx), %ecx
movq 16(%rbx), %rax
xorl %esi, %esi
xorl %edi, %edi
movl %ecx, 40(%rbx)
movq 96(%r14), %rcx
movb %cl, (%rax,%rdx)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 96(%r14), %rdx
shrq $8, %rdx
movb %dl, (%rcx,%rax)
xorl %edx, %edx
call crc32
.L0000293B:
movl 40(%rbx), %edx
movq %rax, 96(%r14)
movl $113, 8(%rbx)
jmp .L00001E88
.L0000294E:
.p2align 4,,10
.p2align 3
.L00002950:
movzbl _dist_code(%rip), %eax
movl $258, %r12d
leaq (%rbx,%rax,4), %r15
.L00002961:
movl 164(%rbx), %eax
jmp .L000029FE
.L0000296C:
.p2align 4,,10
.p2align 3
.L00002970:
movl $0, 144(%rbx)
.L0000297A:
movl 156(%rbx), %ecx
movq 80(%rbx), %rsi
testl %ecx, %ecx
jne .L00002A58
.L0000298C:
xorl %ecx, %ecx
.L0000298E:
movzbl (%rsi,%rcx), %eax
movl 5884(%rbx), %ecx
xorl %edi, %edi
movq 5888(%rbx), %rsi
movw %di, (%rsi,%rcx,2)
movq 5872(%rbx), %rsi
movq %rcx, %rdx
addl $1, %edx
movl %edx, 5884(%rbx)
movb %al, (%rsi,%rcx)
addw $1, 196(%rbx,%rax,4)
xorl %ecx, %ecx
movl 5880(%rbx), %eax
movl 156(%rbx), %edi
subl $1, %eax
cmpl %eax, 5884(%rbx)
leal 1(%rdi), %edx
movl 164(%rbx), %eax
movl %edx, 156(%rbx)
sete %cl
subl $1, %eax
testl %ecx, %ecx
movl %eax, 164(%rbx)
jne .L00002BC6
.L000029FE:
cmpl $258, %eax
ja .L00002970
.L00002A09:
movq %rbx, %rdi
call fill_window
.L00002A11:
movl 164(%rbx), %eax
cmpl $258, %eax
ja .L00002970
.L00002A22:
testl %ebp, %ebp
je .L00001EEC
.L00002A2A:
testl %eax, %eax
je .L0000258C
.L00002A32:
cmpl $2, %eax
movl $0, 144(%rbx)
ja .L0000297A
.L00002A45:
movq 80(%rbx), %rsi
movl 156(%rbx), %ecx
jmp .L0000298E
.L00002A54:
.p2align 4,,10
.p2align 3
.L00002A58:
leaq -1(%rsi,%rcx), %rdx
movzbl (%rdx), %r11d
movzbl (%rdx), %edi
cmpb %r11b, 1(%rdx)
jne .L0000298E
.L00002A6E:
movzbl 2(%rdx), %r8d
cmpl %r8d, %edi
jne .L0000298E
.L00002A7C:
movzbl 3(%rdx), %r8d
cmpl %r8d, %edi
jne .L0000298E
.L00002A8A:
addq $3, %rdx
leaq 258(%rsi,%rcx), %r9
jmp .L00002B06
.L00002A98:
.p2align 4
.L00002AA0:
movzbl 2(%rdx), %r8d
cmpl %r8d, %edi
jne .L00003401
.L00002AAE:
movzbl 3(%rdx), %r8d
cmpl %r8d, %edi
jne .L00003425
.L00002ABC:
movzbl 4(%rdx), %r8d
cmpl %r8d, %edi
jne .L0000341C
.L00002ACA:
movzbl 5(%rdx), %r8d
cmpl %r8d, %edi
jne .L00003413
.L00002AD8:
movzbl 6(%rdx), %r8d
cmpl %r8d, %edi
jne .L0000340A
.L00002AE6:
movzbl 7(%rdx), %r8d
cmpl %r8d, %edi
jne .L000033F8
.L00002AF4:
addq $8, %rdx
movzbl (%rdx), %r8d
cmpl %r8d, %edi
jne .L00002B14
.L00002B01:
cmpq %r9, %rdx
jae .L00002B14
.L00002B06:
movzbl 1(%rdx), %r8d
cmpl %r8d, %edi
je .L00002AA0
.L00002B10:
addq $1, %rdx
.L00002B14:
subq %rdx, %r9
movl %r12d, %edx
subl %r9d, %edx
cmpl %eax, %edx
movl %edx, 144(%rbx)
jbe .L00002E1B
.L00002B2B:
movl %eax, 144(%rbx)
movl %eax, %edx
.L00002B33:
movl 5884(%rbx), %ecx
movq 5888(%rbx), %rsi
movl $1, %r8d
leal -3(%rdx), %eax
movw %r8w, (%rsi,%rcx,2)
movq 5872(%rbx), %rsi
movq %rcx, %rdx
addl $1, %edx
movl %edx, 5884(%rbx)
movb %al, (%rsi,%rcx)
movzbl %al, %eax
xorl %ecx, %ecx
movzbl _length_code(%rax), %eax
addw $1, 1224(%rbx,%rax,4)
addw $1, 2488(%r15)
movl 5880(%rbx), %eax
movl 144(%rbx), %edx
movl $0, 144(%rbx)
subl $1, %eax
cmpl %eax, 5884(%rbx)
movl 164(%rbx), %eax
sete %cl
subl %edx, %eax
addl 156(%rbx), %edx
testl %ecx, %ecx
movl %eax, 164(%rbx)
movl %edx, 156(%rbx)
je .L000029FE
.L00002BC6:
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L00002BE0
.L00002BD7:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L00002BE0:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00002BEA:
movq (%rbx), %r8
movl 156(%rbx), %eax
movq 56(%r8), %r13
movq %r8, 8(%rsp)
movq %rax, 136(%rbx)
movq %r13, %rdi
call _tr_flush_bits
.L00002C0B:
movq 8(%rsp), %r8
movl 40(%r13), %ecx
movl 32(%r8), %eax
cmpl %ecx, %eax
cmovbe %eax, %ecx
testl %ecx, %ecx
jne .L00002CE0
.L00002C25:
movq (%rbx), %rax
movl 32(%rax), %r13d
testl %r13d, %r13d
jne .L00002961
.L00002C35:
jmp .L00001EEC
.L00002C3A:
.p2align 4,,10
.p2align 3
.L00002C40:
subl %esi, %edx
addq 16(%rbx), %rsi
movq 96(%r14), %rdi
call crc32
.L00002C4F:
movq %rax, 96(%r14)
jmp .L00002508
.L00002C58:
.p2align 4
.L00002C60:
subl %edi, %esi
addq 16(%rbx), %rdi
movl %esi, %edx
movq %rdi, %rsi
movq 96(%r14), %rdi
call crc32
.L00002C74:
movq %rax, 96(%r14)
jmp .L00002829
.L00002C7D:
.p2align 4,,10
.p2align 3
.L00002C80:
movl 8(%rdi), %r10d
testl %r10d, %r10d
je .L00001E22
.L00002C8D:
movq z_errmsg+32(%rip), %rax
movq %rax, 48(%rdi)
movl $-2, %eax
jmp .L00001EFB
.L00002CA2:
.p2align 4,,10
.p2align 3
.L00002CA8:
movl %edi, %esi
addq 16(%rbx), %rsi
subl %edi, %edx
movq 96(%r14), %rdi
call crc32
.L00002CB9:
movq %rax, 96(%r14)
jmp .L00002409
.L00002CC2:
.p2align 4,,10
.p2align 3
.L00002CC8:
andl $-3, %eax
.L00002CCB:
testl %eax, %eax
movl $666, 8(%rbx)
je .L00001EEC
.L00002CDA:
jmp .L00002179
.L00002CDF:
.p2align 4,,10
.p2align 3
.L00002CE0:
movq 24(%r8), %rdi
movq 32(%r13), %rsi
movl %ecx, %r10d
movq %r10, %rdx
movl %ecx, 28(%rsp)
movq %r8, 16(%rsp)
movq %r10, 8(%rsp)
call memcpy
.L00002D01:
movq 16(%rsp), %r8
movq 8(%rsp), %r10
movl 28(%rsp), %ecx
addq %r10, 24(%r8)
addq %r10, 32(%r13)
addq %r10, 40(%r8)
subl %ecx, 32(%r8)
subl %ecx, 40(%r13)
jne .L00002C25
.L00002D29:
movq 16(%r13), %rax
movq %rax, 32(%r13)
jmp .L00002C25
.L00002D36:
cmpl $103, 8(%rbx)
movl %edi, %edx
jne .L00001E88
.L00002D42:
.p2align 4,,10
.p2align 3
.L00002D48:
movl $113, 8(%rbx)
jmp .L00001E88
.L00002D54:
movq 48(%rbx), %rax
jmp .L000028EF
.L00002D5D:
movq 48(%rbx), %rax
jmp .L000027C6
.L00002D66:
movl 156(%rbx), %edx
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L00002D86
.L00002D7D:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L00002D86:
xorl %ecx, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00002D90:
movq (%rbx), %rcx
movl 156(%rbx), %eax
movq 56(%rcx), %r15
movq %rcx, 8(%rsp)
movq %rax, 136(%rbx)
movq %r15, %rdi
call _tr_flush_bits
.L00002DB1:
movq 8(%rsp), %rcx
movl 40(%r15), %r13d
movl 32(%rcx), %eax
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
je .L00002155
.L00002DCD:
movq 24(%rcx), %rdi
movq 32(%r15), %rsi
movl %r13d, %r8d
movq %r8, %rdx
movq %rcx, 16(%rsp)
movq %r8, 8(%rsp)
call memcpy
.L00002DEA:
movq 16(%rsp), %rcx
movq 8(%rsp), %r8
addq %r8, 24(%rcx)
addq %r8, 32(%r15)
addq %r8, 40(%rcx)
subl %r13d, 32(%rcx)
subl %r13d, 40(%r15)
jne .L00002155
.L00002E0E:
movq 16(%r15), %rax
movq %rax, 32(%r15)
jmp .L00002155
.L00002E1B:
cmpl $2, %edx
ja .L00002B33
.L00002E24:
jmp .L0000298E
.L00002E29:
.p2align 4
.L00002E30:
movl $-2, %eax
jmp .L00001EFB
.L00002E3A:
movq 24(%r14), %rdi
movq 32(%r12), %rsi
movl %ebp, %r13d
movq %r13, %rdx
call memcpy
.L00002E4E:
addq %r13, 24(%r14)
addq %r13, 32(%r12)
addq %r13, 40(%r14)
subl %ebp, 32(%r14)
subl %ebp, 40(%r12)
jne .L00002213
.L00002E6A:
movq 16(%r12), %rax
movq %rax, 32(%r12)
jmp .L00002213
.L00002E79:
movl 8(%rbx), %eax
movl %esi, %edx
jmp .L00001E76
.L00002E83:
movl 68(%rax), %eax
testl %eax, %eax
je .L00002D36
.L00002E8E:
movl 8(%rbx), %eax
movl %edi, %edx
jmp .L00001E7F
.L00002E98:
movq 48(%rbx), %rax
movl 56(%rbx), %ecx
movl 32(%rax), %esi
jmp .L00002490
.L00002EA7:
movl $91, 8(%rbx)
movl %edi, %edx
jmp .L000027C6
.L00002EB5:
movq z_errmsg+56(%rip), %rax
movq %rax, 48(%rdi)
movl $-5, %eax
jmp .L00001EFB
.L00002ECA:
movl $73, 8(%rbx)
movl 40(%rbx), %edi
jmp .L000024AC
.L00002ED9:
movq 56(%r14), %rcx
movq %rcx, %rdi
movq %rcx, 8(%rsp)
call _tr_flush_bits
.L00002EEA:
movq 8(%rsp), %rcx
movl 32(%r14), %eax
movl 40(%rcx), %r15d
cmpl %r15d, %eax
cmovbe %eax, %r15d
testl %r15d, %r15d
jne .L00003251
.L00002F07:
movl 40(%rbx), %edx
leal 2(%rdx), %eax
cmpq 24(%rbx), %rax
ja .L00001E88
.L00002F17:
jmp .L00002907
.L00002F1C:
.p2align 4,,10
.p2align 3
.L00002F20:
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movq 96(%r14), %rcx
movb %cl, (%rdx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 96(%r14), %rdx
shrq $8, %rdx
movb %dl, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 96(%r14), %rdx
shrq $16, %rdx
movb %dl, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 96(%r14), %rdx
shrq $24, %rdx
movb %dl, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movq 16(%r14), %rcx
movb %cl, (%rdx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 16(%r14), %rdx
shrq $8, %rdx
movb %dl, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 16(%r14), %rdx
shrq $16, %rdx
movb %dl, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 16(%r14), %rdx
shrq $24, %rdx
movb %dl, (%rcx,%rax)
jmp .L000021F1
.L00002FDD:
movq 24(%r14), %rdi
movq 32(%r13), %rsi
movl %ebp, %r15d
movq %r15, %rdx
call memcpy
.L00002FF0:
addq %r15, 24(%r14)
addq %r15, 32(%r13)
addq %r15, 40(%r14)
subl %ebp, 32(%r14)
subl %ebp, 40(%r13)
jne .L0000300E
.L00003006:
movq 16(%r13), %rax
movq %rax, 32(%r13)
.L0000300E:
movl 32(%r14), %eax
jmp .L00002639
.L00003017:
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
call crc32
.L00003022:
movq %rax, 96(%r14)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movb $31, (%rdx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movb $-117, (%rdx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movb $8, (%rdx,%rax)
movq 48(%rbx), %rcx
testq %rcx, %rcx
je .L0000342E
.L00003066:
movl (%rcx), %r8d
movl 40(%rbx), %esi
movq 16(%rbx), %rdi
testl %r8d, %r8d
setne %dl
cmpl $1, 68(%rcx)
leal 1(%rsi), %eax
movl %eax, 40(%rbx)
sbbl %eax, %eax
notl %eax
andl $2, %eax
addl %eax, %edx
cmpq $1, 24(%rcx)
sbbl %eax, %eax
notl %eax
andl $4, %eax
addl %eax, %edx
cmpq $1, 40(%rcx)
sbbl %eax, %eax
notl %eax
andl $8, %eax
addl %eax, %edx
cmpq $1, 56(%rcx)
sbbl %eax, %eax
notl %eax
andl $16, %eax
addl %edx, %eax
movb %al, (%rdi,%rsi)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movq 48(%rbx), %rcx
movq 8(%rcx), %rcx
movb %cl, (%rdx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 48(%rbx), %rdx
movq 8(%rdx), %rdx
shrq $8, %rdx
movb %dl, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 48(%rbx), %rdx
movq 8(%rdx), %rdx
shrq $16, %rdx
movb %dl, (%rcx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 48(%rbx), %rdx
movq 8(%rdx), %rdx
shrq $24, %rdx
movb %dl, (%rcx,%rax)
movl 40(%rbx), %eax
movl 180(%rbx), %ecx
leal 1(%rax), %edx
addq 16(%rbx), %rax
cmpl $9, %ecx
movl %edx, 40(%rbx)
movl $2, %edx
je .L00003157
.L0000313F:
cmpl $1, 184(%rbx)
jg .L000034D7
.L0000314C:
cmpl $1, %ecx
jle .L000034D7
.L00003155:
xorl %edx, %edx
.L00003157:
movb %dl, (%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movq 48(%rbx), %rcx
movl 20(%rcx), %ecx
movb %cl, (%rdx,%rax)
movq 48(%rbx), %rax
cmpq $0, 24(%rax)
je .L000031AC
.L0000317B:
movl 40(%rbx), %edx
movl 32(%rax), %eax
movq 16(%rbx), %rcx
leal 1(%rdx), %esi
movl %esi, 40(%rbx)
movb %al, (%rcx,%rdx)
movl 40(%rbx), %eax
movq 16(%rbx), %rcx
leal 1(%rax), %edx
movl %edx, 40(%rbx)
movq 48(%rbx), %rdx
movl 32(%rdx), %edx
shrl $8, %edx
movb %dl, (%rcx,%rax)
movq 48(%rbx), %rax
.L000031AC:
movl 68(%rax), %edx
testl %edx, %edx
jne .L00003389
.L000031B7:
movl $0, 56(%rbx)
movl $69, 8(%rbx)
jmp .L00002395
.L000031CA:
movl $1, %eax
jmp .L00001EFB
.L000031D4:
movl 156(%rbx), %edx
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L000031F4
.L000031EB:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L000031F4:
movl $1, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L00003201:
movq (%rbx), %r15
movl 156(%rbx), %eax
movq 56(%r15), %rbp
movq %rax, 136(%rbx)
movq %rbp, %rdi
call _tr_flush_bits
.L0000321D:
movl 40(%rbp), %r13d
movl 32(%r15), %eax
cmpl %r13d, %eax
cmovbe %eax, %r13d
testl %r13d, %r13d
jne .L00003351
.L00003235:
movq (%rbx), %rax
movl 32(%rax), %r10d
movl $1, %eax
testl %r10d, %r10d
jne .L00002CCB
.L0000324A:
xorl %eax, %eax
jmp .L00002CCB
.L00003251:
movq 32(%rcx), %rsi
movq 24(%r14), %rdi
movl %r15d, %r8d
movq %r8, %rdx
movq %rcx, 16(%rsp)
movq %r8, 8(%rsp)
call memcpy
.L0000326E:
movq 16(%rsp), %rcx
movq 8(%rsp), %r8
addq %r8, 24(%r14)
addq %r8, 32(%rcx)
addq %r8, 40(%r14)
subl %r15d, 32(%r14)
subl %r15d, 40(%rcx)
jne .L00002F07
.L00003292:
movq 16(%rcx), %rax
movq %rax, 32(%rcx)
jmp .L00002F07
.L0000329F:
movl 156(%rbx), %edx
movq 136(%rbx), %rax
xorl %esi, %esi
subq %rax, %rdx
testq %rax, %rax
js .L000032BF
.L000032B6:
movl %eax, %eax
addq 80(%rbx), %rax
movq %rax, %rsi
.L000032BF:
movl $1, %ecx
movq %rbx, %rdi
call _tr_flush_block
.L000032CC:
movq (%rbx), %r13
movl 156(%rbx), %eax
movq 56(%r13), %rbp
movq %rax, 136(%rbx)
movq %rbp, %rdi
call _tr_flush_bits
.L000032E8:
movl 40(%rbp), %r15d
movl 32(%r13), %eax
cmpl %r15d, %eax
cmovbe %eax, %r15d
testl %r15d, %r15d
je .L00003235
.L00003300:
movq 24(%r13), %rdi
movq 32(%rbp), %rsi
movl %r15d, %ecx
movq %rcx, %rdx
movq %rcx, 8(%rsp)
call memcpy
.L00003318:
movq 8(%rsp), %rcx
addq %rcx, 24(%r13)
addq %rcx, 32(%rbp)
addq %rcx, 40(%r13)
subl %r15d, 32(%r13)
subl %r15d, 40(%rbp)
jne .L00003235
.L00003337:
movq 16(%rbp), %rax
movq %rax, 32(%rbp)
jmp .L00003235
.L00003344:
movq %rbx, %rdi
call _tr_align
.L0000334C:
jmp .L00002618
.L00003351:
movq 24(%r15), %rdi
movq 32(%rbp), %rsi
movl %r13d, %ecx
movq %rcx, %rdx
movq %rcx, 8(%rsp)
call memcpy
.L00003369:
movq 8(%rsp), %rcx
addq %rcx, 24(%r15)
addq %rcx, 32(%rbp)
addq %rcx, 40(%r15)
subl %r13d, 32(%r15)
subl %r13d, 40(%rbp)
je .L00003337
.L00003384:
jmp .L00003235
.L00003389:
movl 40(%rbx), %edx
movq 16(%rbx), %rsi
movq 96(%r14), %rdi
call crc32
.L00003399:
movq %rax, 96(%r14)
movq 48(%rbx), %rax
jmp .L000031B7
.L000033A6:
movl $-2, %eax
ret
.L000033AC:
movq 24(%r15), %rdi
movq 32(%r13), %rsi
movl %ecx, %r8d
movq %r8, %rdx
movl %ecx, 16(%rsp)
movq %r8, 8(%rsp)
call memcpy
.L000033C8:
movq 8(%rsp), %r8
movl 16(%rsp), %ecx
addq %r8, 24(%r15)
addq %r8, 32(%r13)
addq %r8, 40(%r15)
subl %ecx, 32(%r15)
subl %ecx, 40(%r13)
jne .L00002155
.L000033EB:
movq 16(%r13), %rax
movq %rax, 32(%r13)
jmp .L00002155
.L000033F8:
addq $7, %rdx
jmp .L00002B14
.L00003401:
addq $2, %rdx
jmp .L00002B14
.L0000340A:
addq $6, %rdx
jmp .L00002B14
.L00003413:
addq $5, %rdx
jmp .L00002B14
.L0000341C:
addq $4, %rdx
jmp .L00002B14
.L00003425:
addq $3, %rdx
jmp .L00002B14
.L0000342E:
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movb $0, (%rdx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movb $0, (%rdx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movb $0, (%rdx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movb $0, (%rdx,%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movb $0, (%rdx,%rax)
movl 40(%rbx), %eax
movl 180(%rbx), %ecx
leal 1(%rax), %edx
addq 16(%rbx), %rax
cmpl $9, %ecx
movl %edx, 40(%rbx)
movl $2, %edx
je .L000034B0
.L000034A0:
cmpl $1, 184(%rbx)
jg .L000034E1
.L000034A9:
cmpl $1, %ecx
jle .L000034E1
.L000034AE:
xorl %edx, %edx
.L000034B0:
movb %dl, (%rax)
movl 40(%rbx), %eax
movq 16(%rbx), %rdx
leal 1(%rax), %ecx
movl %ecx, 40(%rbx)
movb $3, (%rdx,%rax)
movl $113, %eax
movl $113, 8(%rbx)
movl 40(%rbx), %edi
jmp .L00001E74
.L000034D7:
movl $4, %edx
jmp .L00003157
.L000034E1:
movl $4, %edx
jmp .L000034B0
.size deflate, .-deflate
# ----------------------
.L000034E8:
.p2align 4
# ----------------------
.globl deflateParams
.type deflateParams, @function
deflateParams:
pushq %rbp
pushq %rbx
movslq %esi, %rbx
subq $24, %rsp
testq %rdi, %rdi
je .L00003610
.L00003502:
movq 56(%rdi), %rbp
testq %rbp, %rbp
je .L00003610
.L0000350F:
cmpl $-1, %ebx
je .L000035A0
.L00003518:
cmpl $9, %ebx
ja .L00003610
.L00003521:
cmpl $4, %edx
ja .L00003610
.L0000352A:
movslq 180(%rbp), %rax
movq %rax, %rcx
salq $4, %rax
cmpl %edx, 184(%rbp)
movq configuration_table+8(%rax), %rax
je .L000035B0
.L00003547:
xorl %eax, %eax
cmpq $0, 16(%rdi)
jne .L000035C8
.L00003550:
cmpl %ecx, %ebx
je .L00003592
.L00003554:
movl %ebx, 180(%rbp)
salq $4, %rbx
movzwl configuration_table+2(%rbx), %esi
movzwl configuration_table+6(%rbx), %ecx
movl %esi, 176(%rbp)
movzwl configuration_table(%rbx), %esi
movl %ecx, 172(%rbp)
movl %esi, 188(%rbp)
movzwl configuration_table+4(%rbx), %esi
movl %esi, 192(%rbp)
.L00003592:
movl %edx, 184(%rbp)
.L00003598:
addq $24, %rsp
popq %rbx
popq %rbp
ret
.L0000359F:
.p2align 4,,10
.p2align 3
.L000035A0:
movl $6, %ebx
jmp .L00003521
.L000035AA:
.p2align 4,,10
.p2align 3
.L000035B0:
movslq %ebx, %rsi
salq $4, %rsi
cmpq %rax, configuration_table+8(%rsi)
jne .L00003547
.L000035C0:
xorl %eax, %eax
jmp .L00003550
.L000035C4:
.p2align 4,,10
.p2align 3
.L000035C8:
movl $5, %esi
movl %edx, 12(%rsp)
call deflate
.L000035D6:
cmpl $-5, %eax
movl 12(%rsp), %edx
je .L000035F0
.L000035DF:
movl 180(%rbp), %ecx
jmp .L00003550
.L000035EA:
.p2align 4,,10
.p2align 3
.L000035F0:
movl 40(%rbp), %ecx
testl %ecx, %ecx
movl 180(%rbp), %ecx
jne .L00003550
.L00003601:
xorl %eax, %eax
jmp .L00003550
.L00003608:
.p2align 4
.L00003610:
movl $-2, %eax
jmp .L00003598
.size deflateParams, .-deflateParams
# ----------------------
.L0000361A:
.p2align 4,,10
.p2align 3
# ----------------------
.globl deflateEnd
.type deflateEnd, @function
deflateEnd:
testq %rdi, %rdi
je .L000036F0
.L00003629:
movq 56(%rdi), %rdx
testq %rdx, %rdx
je .L000036F0
.L00003636:
pushq %rbp
pushq %rbx
subq $8, %rsp
movl 8(%rdx), %ebp
cmpl $42, %ebp
je .L00003670
.L00003644:
leal -69(%rbp), %eax
andl $-5, %eax
je .L00003670
.L0000364C:
cmpl $91, %ebp
je .L00003670
.L00003651:
cmpl $103, %ebp
setne %cl
cmpl $113, %ebp
setne %al
testb %al, %cl
je .L00003670
.L00003661:
cmpl $666, %ebp
movl $-2, %eax
jne .L000036E1
.L0000366E:
.p2align 4,,10
.p2align 3
.L00003670:
movq 16(%rdx), %rsi
movq %rdi, %rbx
testq %rsi, %rsi
je .L00003687
.L0000367C:
movq 80(%rdi), %rdi
call *72(%rbx)
.L00003683:
movq 56(%rbx), %rdx
.L00003687:
movq 104(%rdx), %rsi
testq %rsi, %rsi
je .L0000369B
.L00003690:
movq 80(%rbx), %rdi
call *72(%rbx)
.L00003697:
movq 56(%rbx), %rdx
.L0000369B:
movq 96(%rdx), %rsi
testq %rsi, %rsi
je .L000036AF
.L000036A4:
movq 80(%rbx), %rdi
call *72(%rbx)
.L000036AB:
movq 56(%rbx), %rdx
.L000036AF:
movq 80(%rdx), %rsi
testq %rsi, %rsi
je .L000036C3
.L000036B8:
movq 80(%rbx), %rdi
call *72(%rbx)
.L000036BF:
movq 56(%rbx), %rdx
.L000036C3:
movq 80(%rbx), %rdi
movq %rdx, %rsi
call *72(%rbx)
.L000036CD:
xorl %eax, %eax
cmpl $113, %ebp
movq $0, 56(%rbx)
setne %al
leal -3(%rax,%rax,2), %eax
.L000036E1:
addq $8, %rsp
popq %rbx
popq %rbp
ret
.L000036E8:
.p2align 4
.L000036F0:
movl $-2, %eax
ret
.size deflateEnd, .-deflateEnd
# ----------------------
.L000036F6:
.p2align 4
# ----------------------
.globl deflateInit2_
.type deflateInit2_, @function
deflateInit2_:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbp
pushq %rbx
subq $24, %rsp
movq 80(%rsp), %rax
testq %rax, %rax
je .L00003B28
.L0000371C:
cmpb $49, (%rax)
jne .L00003B28
.L00003725:
cmpl $112, 88(%rsp)
jne .L00003B28
.L00003730:
testq %rdi, %rdi
movq %rdi, %rbp
je .L00003B10
.L0000373C:
movq 64(%rdi), %rax
movl %esi, %r14d
movl %ecx, %r12d
movl %r8d, %r13d
movl %r9d, %r15d
movq $0, 48(%rdi)
testq %rax, %rax
je .L00003AE0
.L0000375D:
cmpq $0, 72(%rbp)
je .L00003B00
.L00003768:
cmpl $-1, %r14d
movl $6, %ecx
cmove %ecx, %r14d
testl %r12d, %r12d
js .L00003AB8
.L0000377E:
cmpl $15, %r12d
movl $1, %ecx
jg .L00003A80
.L0000378D:
leal -1(%r13), %esi
cmpl $8, %esi
ja .L00003B10
.L0000379A:
cmpl $8, %edx
jne .L00003B10
.L000037A3:
leal -8(%r12), %edx
cmpl $7, %edx
ja .L00003B10
.L000037B1:
cmpl $4, %r15d
ja .L00003B10
.L000037BB:
cmpl $9, %r14d
ja .L00003B10
.L000037C5:
cmpl $8, %r12d
movl %r12d, %r8d
je .L00003AC8
.L000037D2:
movl %r8d, 12(%rsp)
movl %ecx, 8(%rsp)
movl $5936, %edx
movq 80(%rbp), %rdi
movl $1, %esi
call *%rax
.L000037EB:
testq %rax, %rax
movq %rax, %rbx
je .L00003B68
.L000037F7:
movl 12(%rsp), %r8d
movl 8(%rsp), %ecx
movl $-1431655765, %edx
movq %rax, 56(%rbp)
movq %rbp, (%rax)
movq $0, 48(%rax)
movq 80(%rbp), %rdi
movl %r8d, 72(%rax)
movl $1, %r8d
movl %ecx, 44(%rax)
movl %r8d, %esi
movl %r12d, %ecx
movl %r8d, 8(%rsp)
sall %cl, %esi
leal 7(%r13), %ecx
movl %esi, 68(%rax)
leal -1(%rsi), %eax
movl %ecx, 120(%rbx)
movl %eax, 76(%rbx)
movl %r8d, %eax
sall %cl, %eax
movl %eax, 116(%rbx)
subl $1, %eax
movl %eax, 124(%rbx)
leal 9(%r13), %eax
mull %edx
shrl $1, %edx
movl %edx, 128(%rbx)
movl $2, %edx
call *64(%rbp)
.L00003866:
movl 68(%rbx), %esi
movq 80(%rbp), %rdi
movl $2, %edx
movq %rax, 80(%rbx)
call *64(%rbp)
.L00003879:
movl 116(%rbx), %esi
movq 80(%rbp), %rdi
movl $2, %edx
movq %rax, 96(%rbx)
call *64(%rbp)
.L0000388C:
movl 8(%rsp), %r8d
leal 6(%r13), %ecx
movl $4, %edx
movq %rax, 104(%rbx)
movq $0, 5928(%rbx)
movq 80(%rbp), %rdi
movl %r8d, %esi
sall %cl, %esi
movl %esi, 5880(%rbx)
call *64(%rbp)
.L000038BB:
movl 5880(%rbx), %ecx
cmpq $0, 80(%rbx)
movq %rax, 16(%rbx)
leaq 0(,%rcx,4), %rsi
movq %rcx, %rdx
movq %rsi, 24(%rbx)
je .L00003B40
.L000038DF:
cmpq $0, 96(%rbx)
je .L00003B40
.L000038EA:
testq %rax, %rax
je .L00003B40
.L000038F3:
cmpq $0, 104(%rbx)
je .L00003B40
.L000038FE:
shrl $1, %edx
movl %r14d, 180(%rbx)
movl %r15d, 184(%rbx)
leaq (%rax,%rdx,2), %rdx
movb $8, 60(%rbx)
movq %rdx, 5888(%rbx)
leaq (%rcx,%rcx,2), %rdx
addq %rdx, %rax
movq %rax, 5872(%rbx)
movq 56(%rbp), %rbx
testq %rbx, %rbx
je .L00003B10
.L00003938:
cmpq $0, 64(%rbp)
je .L00003B10
.L00003943:
cmpq $0, 72(%rbp)
je .L00003B10
.L0000394E:
movq 16(%rbx), %rax
movq $0, 40(%rbp)
movq $0, 16(%rbp)
movq $0, 48(%rbp)
movl $2, 88(%rbp)
movl $0, 40(%rbx)
movq %rax, 32(%rbx)
movl 44(%rbx), %eax
testl %eax, %eax
js .L00003A90
.L00003987:
jne .L00003A95
.L0000398D:
movl $113, 8(%rbx)
.L00003994:
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
call adler32
.L0000399F:
movq %rax, 96(%rbp)
movq %rbx, %rdi
movl $0, 64(%rbx)
call _tr_init
.L000039B2:
movq 56(%rbp), %rbx
xorl %ecx, %ecx
xorl %esi, %esi
movl 68(%rbx), %eax
movq 104(%rbx), %rdi
addq %rax, %rax
movq %rax, 88(%rbx)
movl 116(%rbx), %eax
subl $1, %eax
leaq (%rax,%rax), %rdx
movw %cx, (%rdi,%rax,2)
call memset
.L000039DB:
movslq 180(%rbx), %rax
movl $0, 156(%rbx)
movq $0, 136(%rbx)
movl $0, 164(%rbx)
movl $0, 5916(%rbx)
movl $2, 168(%rbx)
movl $2, 144(%rbx)
movl $0, 152(%rbx)
salq $4, %rax
movl $0, 112(%rbx)
leaq configuration_table(%rax), %rdx
movzwl configuration_table+2(%rax), %ecx
movzwl configuration_table(%rax), %eax
movl %eax, 188(%rbx)
movzwl 4(%rdx), %eax
movl %ecx, 176(%rbx)
movl %eax, 192(%rbx)
movzwl 6(%rdx), %eax
movl %eax, 172(%rbx)
xorl %eax, %eax
.L00003A6B:
addq $24, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L00003A7A:
.p2align 4,,10
.p2align 3
.L00003A80:
subl $16, %r12d
movb $2, %cl
jmp .L0000378D
.L00003A8B:
.p2align 4,,10
.p2align 3
.L00003A90:
negl %eax
movl %eax, 44(%rbx)
.L00003A95:
cmpl $2, %eax
movl $42, 8(%rbx)
jne .L00003994
.L00003AA5:
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
call crc32
.L00003AB0:
jmp .L0000399F
.L00003AB5:
.p2align 4,,10
.p2align 3
.L00003AB8:
negl %r12d
xorb %cl, %cl
jmp .L0000378D
.L00003AC2:
.p2align 4,,10
.p2align 3
.L00003AC8:
movl $9, %r8d
movb $9, %r12b
jmp .L000037D2
.L00003AD6:
.p2align 4
.L00003AE0:
cmpq $0, 72(%rbp)
movq $zcalloc, 64(%rdi)
movl $zcalloc, %eax
movq $0, 80(%rdi)
jne .L00003768
.L00003B00:
movq $zcfree, 72(%rbp)
jmp .L00003768
.L00003B0D:
.p2align 4,,10
.p2align 3
.L00003B10:
addq $24, %rsp
movl $-2, %eax
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L00003B24:
.p2align 4,,10
.p2align 3
.L00003B28:
addq $24, %rsp
movl $-6, %eax
popq %rbx
popq %rbp
popq %r12
popq %r13
popq %r14
popq %r15
ret
.L00003B3C:
.p2align 4,,10
.p2align 3
.L00003B40:
movq z_errmsg+48(%rip), %rax
movl $666, 8(%rbx)
movq %rbp, %rdi
movq %rax, 48(%rbp)
call deflateEnd
.L00003B5A:
movl $-4, %eax
jmp .L00003A6B
.L00003B64:
.p2align 4,,10
.p2align 3
.L00003B68:
movl $-4, %eax
jmp .L00003A6B
.size deflateInit2_, .-deflateInit2_
# ----------------------
.L00003B72:
.p2align 4
# ----------------------
.globl deflateInit_
.type deflateInit_, @function
deflateInit_:
testq %rdx, %rdx
je .L00003ED0
.L00003B89:
cmpb $49, (%rdx)
jne .L00003ED0
.L00003B92:
cmpl $112, %ecx
jne .L00003ED0
.L00003B9B:
testq %rdi, %rdi
pushq %r12
pushq %rbp
movq %rdi, %rbp
pushq %rbx
je .L00003EE0
.L00003BAB:
movq 64(%rdi), %rax
movl %esi, %r12d
movq $0, 48(%rdi)
testq %rax, %rax
je .L00003EA0
.L00003BC3:
cmpq $0, 72(%rbp)
je .L00003EC0
.L00003BCE:
cmpl $-1, %r12d
je .L00003E90
.L00003BD8:
cmpl $9, %r12d
ja .L00003EE0
.L00003BE2:
movq 80(%rbp), %rdi
movl $5936, %edx
movl $1, %esi
call *%rax
.L00003BF2:
testq %rax, %rax
movq %rax, %rbx
je .L00003F18
.L00003BFE:
movq %rax, 56(%rbp)
movq 80(%rbp), %rdi
movl $2, %edx
movl $32768, %esi
movq %rbp, (%rax)
movl $1, 44(%rax)
movq $0, 48(%rax)
movl $15, 72(%rax)
movl $32768, 68(%rax)
movl $32767, 76(%rax)
movl $15, 120(%rax)
movl $32768, 116(%rax)
movl $32767, 124(%rax)
movl $5, 128(%rax)
call *64(%rbp)
.L00003C59:
movl 68(%rbx), %esi
movq 80(%rbp), %rdi
movl $2, %edx
movq %rax, 80(%rbx)
call *64(%rbp)
.L00003C6C:
movl 116(%rbx), %esi
movq 80(%rbp), %rdi
movl $2, %edx
movq %rax, 96(%rbx)
call *64(%rbp)
.L00003C7F:
movl $4, %edx
movl $16384, %esi
movq %rax, 104(%rbx)
movq $0, 5928(%rbx)
movl $16384, 5880(%rbx)
movq 80(%rbp), %rdi
call *64(%rbp)
.L00003CA9:
movl 5880(%rbx), %ecx
cmpq $0, 80(%rbx)
movq %rax, 16(%rbx)
leaq 0(,%rcx,4), %rsi
movq %rcx, %rdx
movq %rsi, 24(%rbx)
je .L00003EF0
.L00003CCD:
cmpq $0, 96(%rbx)
je .L00003EF0
.L00003CD8:
testq %rax, %rax
je .L00003EF0
.L00003CE1:
cmpq $0, 104(%rbx)
je .L00003EF0
.L00003CEC:
shrl $1, %edx
movl %r12d, 180(%rbx)
movl $0, 184(%rbx)
leaq (%rax,%rdx,2), %rdx
movb $8, 60(%rbx)
movq %rdx, 5888(%rbx)
leaq (%rcx,%rcx,2), %rdx
addq %rdx, %rax
movq %rax, 5872(%rbx)
movq 56(%rbp), %rbx
testq %rbx, %rbx
je .L00003EE0
.L00003D29:
cmpq $0, 64(%rbp)
je .L00003EE0
.L00003D34:
cmpq $0, 72(%rbp)
je .L00003EE0
.L00003D3F:
movq 16(%rbx), %rax
movq $0, 40(%rbp)
movq $0, 16(%rbp)
movq $0, 48(%rbp)
movl $2, 88(%rbp)
movl $0, 40(%rbx)
movq %rax, 32(%rbx)
movl 44(%rbx), %eax
testl %eax, %eax
js .L00003E68
.L00003D78:
jne .L00003E6D
.L00003D7E:
movl $113, 8(%rbx)
.L00003D85:
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
call adler32
.L00003D90:
movq %rax, 96(%rbp)
movq %rbx, %rdi
movl $0, 64(%rbx)
call _tr_init
.L00003DA3:
movq 56(%rbp), %rbx
xorl %ecx, %ecx
xorl %esi, %esi
movl 68(%rbx), %eax
movq 104(%rbx), %rdi
addq %rax, %rax
movq %rax, 88(%rbx)
movl 116(%rbx), %eax
subl $1, %eax
leaq (%rax,%rax), %rdx
movw %cx, (%rdi,%rax,2)
call memset
.L00003DCC:
movslq 180(%rbx), %rax
movl $0, 156(%rbx)
movq $0, 136(%rbx)
movl $0, 164(%rbx)
movl $0, 5916(%rbx)
movl $2, 168(%rbx)
movl $2, 144(%rbx)
movl $0, 152(%rbx)
salq $4, %rax
movl $0, 112(%rbx)
leaq configuration_table(%rax), %rdx
movzwl configuration_table+2(%rax), %ecx
movzwl configuration_table(%rax), %eax
movl %eax, 188(%rbx)
movzwl 4(%rdx), %eax
movl %ecx, 176(%rbx)
movl %eax, 192(%rbx)
movzwl 6(%rdx), %eax
movl %eax, 172(%rbx)
xorl %eax, %eax
.L00003E5C:
popq %rbx
popq %rbp
popq %r12
ret
.L00003E61:
.p2align 4,,10
.p2align 3
.L00003E68:
negl %eax
movl %eax, 44(%rbx)
.L00003E6D:
cmpl $2, %eax
movl $42, 8(%rbx)
jne .L00003D85
.L00003E7D:
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
call crc32
.L00003E88:
jmp .L00003D90
.L00003E8D:
.p2align 4,,10
.p2align 3
.L00003E90:
movl $6, %r12d
jmp .L00003BE2
.L00003E9B:
.p2align 4,,10
.p2align 3
.L00003EA0:
cmpq $0, 72(%rbp)
movq $zcalloc, 64(%rdi)
movl $zcalloc, %eax
movq $0, 80(%rdi)
jne .L00003BCE
.L00003EC0:
movq $zcfree, 72(%rbp)
jmp .L00003BCE
.L00003ECD:
.p2align 4,,10
.p2align 3
.L00003ED0:
movl $-6, %eax
ret
.L00003ED6:
.p2align 4
.L00003EE0:
movl $-2, %eax
jmp .L00003E5C
.L00003EEA:
.p2align 4,,10
.p2align 3
.L00003EF0:
movq z_errmsg+48(%rip), %rax
movl $666, 8(%rbx)
movq %rbp, %rdi
movq %rax, 48(%rbp)
call deflateEnd
.L00003F0A:
movl $-4, %eax
jmp .L00003E5C
.L00003F14:
.p2align 4,,10
.p2align 3
.L00003F18:
movl $-4, %eax
jmp .L00003E5C
.size deflateInit_, .-deflateInit_
# ----------------------
.L00003F22:
.p2align 4
# ----------------------
.globl deflateCopy
.type deflateCopy, @function
deflateCopy:
testq %rsi, %rsi
je .L00004160
.L00003F39:
testq %rdi, %rdi
je .L00004160
.L00003F42:
pushq %r13
pushq %r12
pushq %rbp
pushq %rbx
subq $8, %rsp
movq 56(%rsi), %r12
testq %r12, %r12
je .L00004180
.L00003F59:
movq (%rsi), %rax
movq %rdi, %rbp
movq %rax, (%rdi)
movq 8(%rsi), %rax
movq %rax, 8(%rdi)
movq 16(%rsi), %rax
movq %rax, 16(%rdi)
movq 24(%rsi), %rax
movq %rax, 24(%rdi)
movq 32(%rsi), %rax
movq %rax, 32(%rdi)
movq 40(%rsi), %rax
movq %rax, 40(%rdi)
movq 48(%rsi), %rax
movq %rax, 48(%rdi)
movq 56(%rsi), %rax
movq %rax, 56(%rdi)
movq 64(%rsi), %rax
movq %rax, 64(%rdi)
movq 72(%rsi), %rdx
movq %rdx, 72(%rdi)
movq 80(%rsi), %rdi
movq %rdi, 80(%rbp)
movq 88(%rsi), %rdx
movq %rdx, 88(%rbp)
movq 96(%rsi), %rdx
movq %rdx, 96(%rbp)
movq 104(%rsi), %rdx
movl $1, %esi
movq %rdx, 104(%rbp)
movl $5936, %edx
call *%rax
.L00003FD6:
testq %rax, %rax
movq %rax, %rbx
je .L00004190
.L00003FE2:
movq %rax, 56(%rbp)
movq (%r12), %rax
leaq 8(%rbx), %rdi
movq %rbx, %rcx
movq %r12, %rsi
movl $2, %edx
andq $-8, %rdi
movq %rax, (%rbx)
movq 5928(%r12), %rax
subq %rdi, %rcx
subq %rcx, %rsi
addl $5936, %ecx
shrl $3, %ecx
movq %rax, 5928(%rbx)
rep movsq
movq %rbp, (%rbx)
movl 68(%rbx), %esi
movq 80(%rbp), %rdi
call *64(%rbp)
.L0000402E:
movl 68(%rbx), %esi
movq 80(%rbp), %rdi
movl $2, %edx
movq %rax, 80(%rbx)
call *64(%rbp)
.L00004041:
movl 116(%rbx), %esi
movq 80(%rbp), %rdi
movl $2, %edx
movq %rax, 96(%rbx)
call *64(%rbp)
.L00004054:
movq 80(%rbp), %rdi
movq %rax, 104(%rbx)
movl $4, %edx
movl 5880(%rbx), %esi
call *64(%rbp)
.L0000406A:
movq 80(%rbx), %rdi
movq %rax, %r13
movq %rax, 16(%rbx)
testq %rdi, %rdi
je .L00004170
.L0000407E:
cmpq $0, 96(%rbx)
je .L00004170
.L00004089:
testq %rax, %rax
je .L00004170
.L00004092:
cmpq $0, 104(%rbx)
je .L00004170
.L0000409D:
movl 68(%rbx), %eax
movq 80(%r12), %rsi
leal (%rax,%rax), %edx
call memcpy
.L000040AD:
movl 68(%rbx), %edx
movq 96(%rbx), %rdi
movq 96(%r12), %rsi
addq %rdx, %rdx
call memcpy
.L000040C1:
movl 116(%rbx), %edx
movq 104(%rbx), %rdi
movq 104(%r12), %rsi
addq %rdx, %rdx
call memcpy
.L000040D5:
movl 24(%rbx), %edx
movq 16(%r12), %rsi
movq 16(%rbx), %rdi
call memcpy
.L000040E6:
movq 16(%rbx), %rsi
movq %rsi, %rdx
addq 32(%r12), %rdx
subq 16(%r12), %rdx
movq %rdx, 32(%rbx)
movl 5880(%rbx), %edx
movl %edx, %ecx
shrl $1, %ecx
leaq (%r13,%rcx,2), %rax
movq %rax, 5888(%rbx)
movl %edx, %eax
leaq (%rax,%rax,2), %rax
addq %rsi, %rax
movq %rax, 5872(%rbx)
leaq 196(%rbx), %rax
movq %rax, 2888(%rbx)
leaq 2488(%rbx), %rax
movq %rax, 2912(%rbx)
leaq 2732(%rbx), %rax
movq %rax, 2936(%rbx)
xorl %eax, %eax
.L0000414D:
addq $8, %rsp
popq %rbx
popq %rbp
popq %r12
popq %r13
ret
.L00004158:
.p2align 4
.L00004160:
movl $-2, %eax
ret
.L00004166:
.p2align 4
.L00004170:
movq %rbp, %rdi
call deflateEnd
.L00004178:
movl $-4, %eax
jmp .L0000414D
.L0000417F:
.p2align 4,,10
.p2align 3
.L00004180:
movl $-2, %eax
jmp .L0000414D
.L00004187:
.p2align 4
.L00004190:
movl $-4, %eax
jmp .L0000414D
.size deflateCopy, .-deflateCopy
# ----------------------
.hidden _length_code
.hidden _dist_code
.hidden _tr_flush_block
.hidden _tr_flush_bits
.hidden _tr_init
.hidden _tr_stored_block
.hidden _tr_align
.hidden zcalloc
.hidden zcfree
.ident "GCC: (Debian 4.9.2-10) 4.9.2"
.section .note.GNU-stack,"",@progbits
|
#include <Arduino.h>
#include "LSAnalogTrigger.h"
#define N_TRIGGERS 5
#define ID_0 0
#define ID_1 1
#define ID_2 2
#define ID_3 3
#define ID_4 4
#define ANALOG_PIN_0 0
#define ANALOG_PIN_1 1
#define ANALOG_PIN_2 2
#define ANALOG_PIN_3 3
#define ANALOG_PIN_4 4
const int thresholdValues[N_TRIGGERS] {1000,1000,1000,1000,1000};
LSAnalogTrigger analogTriggers[N_TRIGGERS] = {
LSAnalogTrigger(ID_0, ANALOG_PIN_0),
LSAnalogTrigger(ID_1, ANALOG_PIN_1),
LSAnalogTrigger(ID_2, ANALOG_PIN_2),
LSAnalogTrigger(ID_3, ANALOG_PIN_3),
LSAnalogTrigger(ID_4, ANALOG_PIN_4)
};
void actOnTrigger(int ID, String callbackString){
Serial.printf("ID: %d, %s\n", ID, callbackString.c_str());
/*
Whatever you want to do when the trigger is fired
*/
}
void setup() {
Serial.begin(115200);
for(int i=0; i<N_TRIGGERS; i++)
analogTriggers[i].setThreshold(thresholdValues[i]);
}
void loop() {
for(LSAnalogTrigger trigger:analogTriggers)
trigger.readnShoot(actOnTrigger);
} |
\ MATHS & Numbers -- funcs_math.asm --------------------------------------------
\ NOT CURRENTLY USING THIS
.subtract16u
; subtracts a 16-bit number stored in INT16uB from another 16-bit value
; in INT16uA.
pha
sec
lda INT16uA
sbc INT16uB
sta FUNC_RES_L
lda INT16uA + 1
sbc INT16uB + 1
sta FUNC_RES_H
pla
rts
.compare16u ; Compare two 16-bit unsigned values
pha
lda INT16uA+1
cmp INT16uB+1
bcc compare16u_less_than
bne compare16u_more_than
lda INT16uA
cmp INT16uB
bcc compare16u_less_than
bne compare16u_more_than
lda #EQUAL ; A = B
jmp compare16u_end
.compare16u_less_than
lda #LESS_THAN ; A < B
jmp compare16u_end
.compare16u_more_than
lda #MORE_THAN ; A > B
.compare16u_end
sta FUNC_RESULT
pla
rts
.compare32u ; Compare two 32-bit unsigned values
pha
lda INT32uA+3
cmp INT32uB+3
bcc compare32u_less_than ; NUMA < NUMB
bne compare32u_more_than ; if NUMA+3 <> NUMB+3 then NUMA > NUMB
lda INT32uA+2
cmp INT32uB+2
bcc compare32u_less_than
bne compare32u_more_than
lda INT32uA+1
cmp INT32uB+1
bcc compare32u_less_than
bne compare32u_more_than
lda INT32uA
cmp INT32uB
bcc compare32u_less_than
bne compare32u_more_than
lda #EQUAL ; A = B
jmp compare32u_end
.compare32u_less_than
lda #LESS_THAN ; A < B
jmp compare32u_end
.compare32u_more_than
lda #MORE_THAN ; A > B
.compare32u_end
sta FUNC_RESULT
pla
rts
|
; A127988: Sequence determining the parity of A025748.
; 0,8,32,40,128,136,160,168,512,520,544,552,640,648,672,680,2048,2056,2080,2088,2176,2184,2208,2216,2560,2568,2592,2600,2688,2696,2720,2728,8192,8200,8224,8232,8320,8328,8352,8360,8704,8712,8736
mov $7,$0
mov $9,$0
lpb $7
mov $0,$9
sub $7,1
sub $0,$7
mov $4,$0
gcd $4,32
lpb $0
sub $0,$0
mov $2,$4
add $3,2
pow $2,$3
add $2,1
lpe
mov $3,0
mov $6,$5
add $6,$2
mul $6,2
mov $8,$6
div $8,3
mul $8,8
add $1,$8
lpe
|
; A101496: Expansion of (1-x^2)/(1-x-x^2+x^3+x^4).
; Submitted by Christian Krause
; 1,1,1,1,0,-1,-3,-5,-7,-8,-7,-3,5,17,32,47,57,55,33,-16,-95,-199,-311,-399,-416,-305,-11,499,1209,2024,2745,3061,2573,865,-2368,-7137,-12943,-18577,-22015,-20512,-11007,9073,40593,81185,123712,155231,157165,107499,-14279,-219176,-498119,-810515,-1075179,-1168399,-934944,-217649,1090985,2976679,5220257,7323600,8476193,7602857,3535193,-4661743,-17205600,-33005393,-49084443,-60222493,-59095943,-37228600,12982393,95072229,204379165,323697601,420022144,444268351,336213729,36762335,-491314431
mov $1,1
lpb $0
sub $0,1
add $1,$3
sub $3,$4
mov $4,$2
mov $2,$3
mov $3,$5
add $4,$1
add $4,$2
add $5,$2
lpe
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r8
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x68c7, %rax
clflush (%rax)
cmp $61635, %rbp
mov $0x6162636465666768, %rdi
movq %rdi, %xmm3
and $0xffffffffffffffc0, %rax
vmovntdq %ymm3, (%rax)
nop
nop
and $59049, %rsi
lea addresses_A_ht+0x15ec7, %rdi
nop
nop
nop
nop
nop
add $32268, %rsi
mov $0x6162636465666768, %rax
movq %rax, %xmm5
movups %xmm5, (%rdi)
nop
nop
nop
cmp $54888, %r12
lea addresses_A_ht+0x16917, %r9
add %r8, %r8
vmovups (%r9), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $0, %xmm3, %rsi
and $39282, %r12
lea addresses_WT_ht+0x525b, %r8
nop
nop
nop
nop
nop
and $10773, %rsi
mov $0x6162636465666768, %rax
movq %rax, %xmm4
and $0xffffffffffffffc0, %r8
movaps %xmm4, (%r8)
nop
nop
nop
nop
and $40416, %r12
lea addresses_UC_ht+0x1bf37, %r12
nop
nop
nop
xor %rsi, %rsi
movb (%r12), %r8b
and %r9, %r9
lea addresses_WT_ht+0x2ac7, %rbp
nop
nop
dec %rdi
mov (%rbp), %r12w
inc %rdi
lea addresses_WC_ht+0xa0c7, %rdi
clflush (%rdi)
nop
add $55990, %r12
mov (%rdi), %rsi
and $52946, %rsi
lea addresses_normal_ht+0x10707, %rsi
lea addresses_WT_ht+0x19527, %rdi
nop
nop
nop
nop
xor %rax, %rax
mov $66, %rcx
rep movsl
nop
nop
nop
nop
nop
cmp $8931, %rdi
lea addresses_normal_ht+0x3ac7, %rsi
lea addresses_D_ht+0x13397, %rdi
clflush (%rdi)
nop
nop
inc %r8
mov $67, %rcx
rep movsw
nop
nop
nop
xor %rbp, %rbp
lea addresses_WC_ht+0x86c7, %rcx
nop
nop
nop
inc %r8
movl $0x61626364, (%rcx)
nop
and $48184, %r8
lea addresses_WC_ht+0x1b6c7, %rsi
lea addresses_WT_ht+0xb6cf, %rdi
xor $39908, %rax
mov $40, %rcx
rep movsb
nop
nop
nop
nop
nop
cmp $28648, %rax
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r8
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r15
push %r8
push %rbp
push %rbx
push %rcx
// Store
lea addresses_RW+0x8df, %r11
nop
nop
nop
sub %rbp, %rbp
mov $0x5152535455565758, %r15
movq %r15, %xmm7
vmovaps %ymm7, (%r11)
nop
dec %r8
// Faulty Load
lea addresses_WT+0x1cec7, %rbx
clflush (%rbx)
nop
nop
nop
nop
nop
and $32253, %r10
movb (%rbx), %r11b
lea oracles, %rbp
and $0xff, %r11
shlq $12, %r11
mov (%rbp,%r11,1), %r11
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r15
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_WT', 'AVXalign': True, 'size': 2, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': True, 'size': 32, 'NT': False, 'same': False, 'congruent': 3}}
[Faulty Load]
{'src': {'type': 'addresses_WT', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 32, 'NT': True, 'same': False, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 8}}
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': True, 'size': 16, 'NT': False, 'same': True, 'congruent': 2}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': True, 'size': 1, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 8, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 11}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}}
{'39': 752}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
; A337821: For n >= 0, a(4n+1) = 0, a(4n+3) = a(2n+1) + 1, a(2n+2) = a(n+1).
; Submitted by Jamie Morken(s2)
; 0,0,1,0,0,1,2,0,0,0,1,1,0,2,3,0,0,0,1,0,0,1,2,1,0,0,1,2,0,3,4,0,0,0,1,0,0,1,2,0,0,0,1,1,0,2,3,1,0,0,1,0,0,1,2,2,0,0,1,3,0,4,5,0,0,0,1,0,0,1,2,0,0,0,1,1,0,2,3,0,0,0,1,0,0,1,2,1,0,0,1,2,0,3,4,1
add $0,1
lpb $0
dif $0,2
lpe
seq $0,7814 ; Exponent of highest power of 2 dividing n, a.k.a. the binary carry sequence, the ruler sequence, or the 2-adic valuation of n.
sub $0,1
|
db 0 ; species ID placeholder
db 35, 55, 35, 35, 30, 30
; hp atk def spd sat sdf
db DARK, DARK ; type
db 255 ; catch rate
db 55 ; base exp
db NO_ITEM, PSNCUREBERRY ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 15 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/poochyena/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_GROUND, EGG_GROUND ; egg groups
; tm/hm learnset
tmhm HEADBUTT, CURSE, ROAR, TOXIC, ROCK_SMASH, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, IRON_TAIL, RETURN, DIG, SHADOW_BALL, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, DETECT, REST, ATTRACT, THIEF, NIGHTMARE
; end
|
// Distributed under the MIT License.
// See LICENSE.txt for details.
#pragma once
#include <complex>
#include <cstddef>
#include "DataStructures/ComplexModalVector.hpp"
#include "DataStructures/DataVector.hpp"
#include "DataStructures/ModalVector.hpp"
#include "NumericalAlgorithms/Interpolation/SpanInterpolator.hpp"
#include "Options/Options.hpp"
#include "Parallel/CharmPupable.hpp"
#include "Utilities/Gsl.hpp"
namespace intrp {
/// \brief Performs a linear interpolation; this class can be chosen via the
/// options factory mechanism as a possible `SpanInterpolator`
class LinearSpanInterpolator : public SpanInterpolator {
public:
using options = tmpl::list<>;
static constexpr OptionString help = {"Linear interpolator."};
LinearSpanInterpolator() = default;
LinearSpanInterpolator(const LinearSpanInterpolator&) noexcept = default;
LinearSpanInterpolator& operator=(const LinearSpanInterpolator&) noexcept =
default;
LinearSpanInterpolator(LinearSpanInterpolator&&) noexcept = default;
LinearSpanInterpolator& operator=(LinearSpanInterpolator&&) noexcept =
default;
~LinearSpanInterpolator() noexcept override = default;
WRAPPED_PUPable_decl_template(LinearSpanInterpolator); // NOLINT
explicit LinearSpanInterpolator(CkMigrateMessage* /*unused*/) noexcept {}
// clang-tidy: do not pass by non-const reference
void pup(PUP::er& /*p*/) noexcept override {}
std::unique_ptr<SpanInterpolator> get_clone() const noexcept override {
return std::make_unique<LinearSpanInterpolator>(*this);
}
double interpolate(const gsl::span<const double>& source_points,
const gsl::span<const double>& values,
double target_point) const noexcept override;
std::complex<double> interpolate(
const gsl::span<const double>& source_points,
const gsl::span<const std::complex<double>>& values,
double target_point) const noexcept;
size_t required_number_of_points_before_and_after() const noexcept override {
return 1;
}
};
} // namespace intrp
|
#include "Platform.inc"
#include "FarCalls.inc"
#include "Flash.inc"
#include "Lcd.inc"
#include "States.inc"
#include "WaitButtonPressState.inc"
radix decimal
defineUiState UI_STATE_SETTINGS_OPENCLOSEOFFSETS
fcall isLcdIdle
xorlw 0
btfsc STATUS, Z
returnFromUiState
loadFlashAddressOf screen
fcall putScreenFromFlash
waitForButtonPress UI_STATE_SETTINGS_OPENCLOSEOFFSETS_LEFT, UI_STATE_SETTINGS_OPENCLOSEOFFSETS_RIGHT, UI_STATE_SETTINGS_OPENCLOSEOFFSETS_ENTER
returnFromUiState
defineUiStateInSameSection UI_STATE_SETTINGS_OPENCLOSEOFFSETS_LEFT
setUiState UI_STATE_WAIT_BUTTONPRESS
returnFromUiState
defineUiStateInSameSection UI_STATE_SETTINGS_OPENCLOSEOFFSETS_RIGHT
setUiState UI_STATE_WAIT_BUTTONPRESS
returnFromUiState
defineUiStateInSameSection UI_STATE_SETTINGS_OPENCLOSEOFFSETS_ENTER
setUiState UI_STATE_SETTINGS_LOCATION
returnFromUiState
screen:
da "Open -00 mins "
da "Close +00 mins "
end
|
#include <stan/math/rev/mat.hpp>
#include <gtest/gtest.h>
#include <test/unit/math/rev/mat/fun/jacobian.hpp>
#include <test/unit/math/rev/mat/util.hpp>
TEST(prob_transform,ordered_jacobian_ad) {
using stan::math::var;
using stan::math::ordered_constrain;
using stan::math::determinant;
using Eigen::Matrix;
using Eigen::Dynamic;
Matrix<double,Dynamic,1> x(3);
x << -12.0, 3.0, -1.9;
double lp = 0.0;
Matrix<double,Dynamic,1> y = ordered_constrain(x,lp);
Matrix<var,Dynamic,1> xv(3);
xv << -12.0, 3.0, -1.9;
std::vector<var> xvec(3);
for (int i = 0; i < 3; ++i)
xvec[i] = xv[i];
Matrix<var,Dynamic,1> yv = ordered_constrain(xv);
EXPECT_EQ(y.size(), yv.size());
for (int i = 0; i < y.size(); ++i)
EXPECT_FLOAT_EQ(y(i),yv(i).val());
std::vector<var> yvec(3);
for (unsigned int i = 0; i < 3; ++i)
yvec[i] = yv[i];
std::vector<std::vector<double> > j;
stan::math::jacobian(yvec,xvec,j);
Matrix<double,Dynamic,Dynamic> J(3,3);
for (int m = 0; m < 3; ++m)
for (int n = 0; n < 3; ++n)
J(m,n) = j[m][n];
double log_abs_jacobian_det = log(fabs(determinant(J)));
EXPECT_FLOAT_EQ(log_abs_jacobian_det, lp);
}
TEST(AgradRevMatrix, check_varis_on_stack) {
Eigen::Matrix<stan::math::var,Eigen::Dynamic,1> x(3);
x << -12.0, 3.0, -1.9;
stan::math::var lp = 0.0;
test::check_varis_on_stack(stan::math::ordered_constrain(x, lp));
test::check_varis_on_stack(stan::math::ordered_constrain(x));
}
|
Music_LookHiker:
musicheader 4, 1, Music_LookHiker_Ch1
musicheader 1, 2, Music_LookHiker_Ch2
musicheader 1, 3, Music_LookHiker_Ch3
musicheader 1, 4, Music_LookHiker_Ch4
Music_LookHiker_Ch1:
tempo 132
volume $77
tone $0001
vibrato $12, $24
dutycycle $2
stereopanning $f
notetype $c, $68
octave 3
note F#, 2
note F_, 2
note F#, 8
Music_LookHiker_branch_f7433:
note D_, 2
note D#, 2
note E_, 2
note F_, 2
note F#, 2
note __, 4
note F#, 2
note __, 4
note F#, 2
note __, 2
note F#, 2
note __, 6
loopchannel 0, Music_LookHiker_branch_f7433
Music_LookHiker_Ch2:
dutycycle $0
notetype $c, $a1
note __, 4
octave 1
note B_, 1
note B_, 5
octave 2
note F#, 1
note F#, 5
octave 1
note B_, 1
octave 2
note D_, 1
note F#, 1
note D_, 1
intensity $a1
Music_LookHiker_branch_f7457:
octave 1
note B_, 1
note B_, 2
octave 2
note D_, 1
note D_, 2
note F#, 1
note F#, 2
note A#, 1
note A#, 2
octave 1
note B_, 1
octave 2
note D_, 1
note F#, 1
note D_, 1
loopchannel 0, Music_LookHiker_branch_f7457
Music_LookHiker_Ch3:
vibrato $12, $24
stereopanning $f0
notetype $c, $14
octave 4
note B_, 2
note A#, 2
note B_, 8
Music_LookHiker_branch_f7477:
octave 5
note D#, 2
note D_, 2
note C#, 2
note C_, 2
callchannel Music_LookHiker_branch_f748a
note G_, 2
note G#, 2
note A_, 2
note A#, 2
callchannel Music_LookHiker_branch_f748a
loopchannel 0, Music_LookHiker_branch_f7477
Music_LookHiker_branch_f748a:
octave 4
note B_, 2
note __, 4
note B_, 2
note __, 4
note B_, 2
note __, 2
note B_, 2
note __, 6
endchannel
Music_LookHiker_Ch4:
togglenoise $3
notetype $c
note F_, 4
note __, 16
Music_LookHiker_branch_f749a:
note D#, 2
note G_, 2
note D_, 2
note G_, 2
loopchannel 0, Music_LookHiker_branch_f749a
|
BITS 64
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
; Lea32R1
mov eax, 0x21
mov edi, 0x8
;TEST_BEGIN_RECORDING
lea eax, [eax+edi+0x1]
;TEST_END_RECORDING
|
#include <iostream>
#include <cctype>
using namespace std;
int main() {
struct cadastro {
char pal[21];
} palavra[2];
int x, y;
for (x = 0; x < 2; x++) {
cout << "\nPalavra: ";
cin.getline(palavra[x].pal, 21);
}
palavra[0].pal[0] = toupper(palavra[0].pal[0]);
system("clear");
for (x = 0; x < 2; x++) {
for (y = 0; palavra[x].pal[y] != '\0'; y++) {
cout << "\n" << palavra[x].pal[y];
}
cout << "\n\n";
}
cout << "\n\n";
return 0;
} |
; A231677: a(n) = Sum_{i=0..n} digsum_7(i)^2, where digsum_7(i) = A053828(i).
; 0,1,5,14,30,55,91,92,96,105,121,146,182,231,235,244,260,285,321,370,434,443,459,484,520,569,633,714,730,755,791,840,904,985,1085,1110,1146,1195,1259,1340,1440,1561,1597,1646,1710,1791,1891,2012,2156,2157,2161,2170,2186,2211,2247,2296,2300,2309,2325,2350,2386,2435,2499,2508,2524,2549,2585,2634,2698,2779
mov $4,$0
mov $6,$0
lpb $4,1
mov $0,$6
sub $4,1
sub $0,$4
add $3,1
lpb $3,1
add $2,1
sub $3,1
lpb $2,1
sub $2,1
cal $0,53828 ; Sum of digits of (n written in base 7).
mul $0,2
mov $5,$0
pow $5,2
mul $5,2
lpe
lpe
div $5,8
add $1,$5
lpe
|
; A245180: A160239(n)/8.
; Submitted by Christian Krause
; 1,1,3,1,8,3,14,1,8,8,24,3,24,14,52,1,8,8,24,8,64,24,112,3,24,24,72,14,112,52,216,1,8,8,24,8,64,24,112,8,64,64,192,24,192,112,416,3,24,24,72,24,192,72,336,14,112,112,336,52,416,216,848,1,8,8,24,8,64,24,112,8,64,64,192,24,192,112,416,8,64,64,192,64,512,192,896,24,192,192,576,112,896,416,1728,3,24,24,72,24
add $0,1
seq $0,160239 ; Number of "ON" cells in a 2-dimensional cellular automaton ("Fredkin's Replicator") evolving according to the rule that a cell is ON in a given generation if and only if there was an odd number of ON cells among the eight nearest neighbors in the preceding generation, starting with one ON cell.
div $0,8
|
; asm_isdigit
PUBLIC asm_isdigit
; determine whether ascii char is a decimal digit
; enter : a = char
; exit : carry = not a digit
; uses : f
.asm_isdigit
cp '0'
ret c
cp '9'+1
ccf
ret
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Geoworks 1994 -- All Rights Reserved
PROJECT:
MODULE:
FILE: irlapPrefControl.asm
AUTHOR: Steve Jang, Dec 8, 1994
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
SJ 12/ 8/94 Initial revision
DESCRIPTION:
Custom ui for IrLAP preference.
$Id: irlapPrefControl.asm,v 1.1 97/04/18 11:57:02 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ife NO_PREFERENCES_APPLICATION
IrlapClassStructures segment resource
IrlapPrefCtrlChildList GenControlChildInfo \
< offset IrlapPrefCtrlBox,
0,
mask GCCF_IS_DIRECTLY_A_FEATURE or mask GCCF_ALWAYS_ADD>
IrlapPrefCtrlFeaturesList GenControlFeaturesInfo \
< offset IrlapPrefCtrlBox,
0,
1>
IrlapClassStructures ends
IrlapCommonCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefGenControlGetInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns GenCtrl information for IrlapPreferenceControlClass
CALLED BY: MSG_GEN_CONTROL_GET_INFO
PASS: *ds:si = IrlapPreferenceControlClass object
ds:di = IrlapPreferenceControlClass instance data
ds:bx = IrlapPreferenceControlClass object
es = segment of IrlapPreferenceControlClass
ax = message #
cx:dx = Buffer for GenControlInfo
RETURN: GenControlDupInfo field filled in
DESTROYED: nothing
REVISION HISTORY:
Name Date Description
---- ---- -----------
SJ 12/ 5/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefGenControlGetInfo method dynamic IrlapPreferenceControlClass,
MSG_GEN_CONTROL_GET_INFO
uses cx
.enter
;
; copy the data into the buffer
;
segmov ds, cs ; ds:si = source
mov si, offset IrlapPrefCtrlInfo
mov es, cx
mov di, dx ; es:di = dest
mov cx, size GenControlBuildInfo
rep movsb
.leave
ret
PrefGenControlGetInfo endm
IrlapPrefCtrlInfo GenControlBuildInfo <
mask GCBF_NOT_REQUIRED_TO_BE_ON_SELF_LOAD_OPTIONS_LIST, ;GCBI_flags
0, ; GCBI_initFileKey
0, ; GCBI_gcnList
0, ; GCBI_gcnCount
0, ; GCBI_notificationList
0, ; GCBI_notificationCount
0, ; GCBI_controllerName
handle IrlapPrefCtrlBox, ; GCBI_dupBlock
IrlapPrefCtrlChildList, ; GCBI_childList
length IrlapPrefCtrlChildList, ; GCBI_childCount
IrlapPrefCtrlFeaturesList, ; GCBI_featuresList
length IrlapPrefCtrlFeaturesList, ; GCBI_featuresCount
1, ; GCBI_features
0, ; GCBI_toolBlock
0, ; GCBI_toolList
0, ; GCBI_toolCount
0, ; GCBI_toolFeaturesList
0, ; GCBI_toolFeaturesCount
0, ; GCBI_toolFeatures
0, ; GCBI_helpContext
0 ; GCBI_reserve
>
IrlapCommonCode ends
endif ; !NO_PREFERENCES_APPLICATION
|
db 0 ; species ID placeholder
db 50, 25, 28, 15, 45, 55
; hp atk def spd sat sdf
db NORMAL, NORMAL ; type
db 150 ; catch rate
db 37 ; base exp
db MYSTERYBERRY, MOON_STONE ; items
db GENDER_F75 ; gender ratio
db 100 ; unknown 1
db 10 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/cleffa/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_FAST ; growth rate
dn EGG_NONE, EGG_NONE ; egg groups
; tm/hm learnset
tmhm HEADBUTT, CURSE, ROLLOUT, TOXIC, ZAP_CANNON, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, ICY_WIND, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, SOLARBEAM, IRON_TAIL, RETURN, PSYCHIC_M, SHADOW_BALL, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, FIRE_BLAST, DEFENSE_CURL, DREAM_EATER, DETECT, REST, ATTRACT, NIGHTMARE, FLASH, FLAMETHROWER
; end
|
#include <cstdio>
#include <string>
#include <vector>
#include "caffe/solver.hpp"
#include "caffe/util/format.hpp"
#include "caffe/util/hdf5.hpp"
#include "caffe/util/io.hpp"
#include "caffe/util/upgrade_proto.hpp"
namespace caffe {
template<typename Dtype>
void Solver<Dtype>::SetActionFunction(ActionCallback func) {
action_request_function_ = func;
}
template<typename Dtype>
SolverAction::Enum Solver<Dtype>::GetRequestedAction() {
if (action_request_function_) {
// If the external request function has been set, call it.
return action_request_function_();
}
return SolverAction::NONE;
}
// 构造函数,初始化两个Net类,net和test_net,并调用init()
// 输入为SolverParameter类型的param
template <typename Dtype>
Solver<Dtype>::Solver(const SolverParameter& param, const Solver* root_solver)
: net_(), callbacks_(), root_solver_(root_solver),
requested_early_exit_(false) {
if(MY_DEBUG)
LOG(INFO) << "调用Solver构造函数成功";
Init(param);
}
// 构造函数,初始化两个Net类,net和test_net,并调用init()
// 输入为string类型的param_file
template <typename Dtype>
Solver<Dtype>::Solver(const string& param_file, const Solver* root_solver)
: net_(), callbacks_(), root_solver_(root_solver),
requested_early_exit_(false) {
SolverParameter param;
ReadSolverParamsFromTextFileOrDie(param_file, ¶m);
Init(param);
}
// 功能:初始化网络
template <typename Dtype>
void Solver<Dtype>::Init(const SolverParameter& param) {
LOG(INFO) << "调用Init()";
CHECK(Caffe::root_solver() || root_solver_)
<< "root_solver_ needs to be set for all non-root solvers";
LOG_IF(INFO, Caffe::root_solver()) << "Initializing solver from parameters: "
<< std::endl << param.DebugString();
if(MY_DEBUG)
LOG(INFO) << "param.DebugString()输出结束";
param_ = param; // 为数据成员赋值
CHECK_GE(param_.average_loss(), 1) << "average_loss should be non-negative.";
CheckSnapshotWritePermissions();
// 步骤1:设置随机数种子
if (Caffe::root_solver() && param_.random_seed() >= 0) {
// 调用Caffe命名空间里的set_random_seed函数,而不是caffe类的该
// 函数,param_.random_seed()实际上调用的是::google::protobuf::int64 random_seed()
Caffe::set_random_seed(param_.random_seed());
}
// Scaffolding code
InitTrainNet(); // 步骤2:初始化训练网络
if (Caffe::root_solver()) {
InitTestNets();
LOG(INFO) << "Solver scaffolding done.";
}
iter_ = 0;
current_step_ = 0;
}
template <typename Dtype>
void Solver<Dtype>::InitTrainNet() {
if(MY_DEBUG)
LOG(INFO) << "InitTrainNet()开始...";
const int num_train_nets = param_.has_net() + param_.has_net_param() +
param_.has_train_net() + param_.has_train_net_param();
if(MY_DEBUG)
LOG(INFO) << "num_train_nets的值" << num_train_nets;
const string& field_names = "net, net_param, train_net, train_net_param";
// 只能有一个train net
CHECK_GE(num_train_nets, 1) << "SolverParameter must specify a train net "
<< "using one of these fields: " << field_names;
CHECK_LE(num_train_nets, 1) << "SolverParameter must not contain more than "
<< "one of these fields specifying a train_net: " << field_names;
NetParameter net_param;
if (param_.has_train_net_param()) {
LOG_IF(INFO, Caffe::root_solver())
<< "Creating training net specified in train_net_param.";
net_param.CopyFrom(param_.train_net_param());
} else if (param_.has_train_net()) {
LOG_IF(INFO, Caffe::root_solver())
<< "Creating training net from train_net file: " << param_.train_net();
ReadNetParamsFromTextFileOrDie(param_.train_net(), &net_param);
}
if (param_.has_net_param()) {
LOG_IF(INFO, Caffe::root_solver())
<< "Creating training net specified in net_param.";
net_param.CopyFrom(param_.net_param());
}
// 当前实验只构造了net网
if (param_.has_net()) {
// 输出net protocol buffer定义所在的文件
LOG_IF(INFO, Caffe::root_solver())
<< "Creating training net from net file: " << param_.net();
// 读取net_param
if(MY_DEBUG)
LOG(INFO) << "读取net_param";
ReadNetParamsFromTextFileOrDie(param_.net(), &net_param);
}
// Set the correct NetState. We start with the solver defaults (lowest
// precedence); then, merge in any NetState specified by the net_param itself;
// finally, merge in any NetState specified by the train_state (highest
// precedence).
// 声明一个Google buffer的NetState对象,并设置
NetState net_state;
net_state.set_phase(TRAIN); // 设置当前阶段是TRAIN
// 从低到高获取state,最终从最高优先级SolverParameter类型种的train_state,显然这会覆盖掉之前获取的state
net_state.MergeFrom(net_param.state());
//if(MY_DEBUG)
// LOG(INFO) << "param_.train_state() phase:" << param_.train_state().phase << "level: " << param_.train_state().level << "stage: " << param.train_state().stage;
// 这里获取的state可以为NetParameter的state赋值,然后可以根据LayerParameter中的include和exclude来确定该层是否应该包含在网络中
net_state.MergeFrom(param_.train_state());
// 返回一个NetState对象,这是Initialize train net的一部分工作,InitTestNets也是如此
net_param.mutable_state()->CopyFrom(net_state); //将当前已经“收集”到的net_state赋给可变的state
// 申请一块Net空间
if (Caffe::root_solver()) {
if(MY_DEBUG)
LOG(INFO) << "调用Net构造函数开始";
//调用模板类的构造函数,进行Net的初始化
net_.reset(new Net<Dtype>(net_param));
} else {
net_.reset(new Net<Dtype>(net_param, root_solver_->net_.get()));
}
}
template <typename Dtype>
void Solver<Dtype>::InitTestNets() {
if(MY_DEBUG)
LOG(INFO) << "调用InitTestNets()";
CHECK(Caffe::root_solver());
// 通过proto文件获取相关参数
const bool has_net_param = param_.has_net_param();
const bool has_net_file = param_.has_net();
const int num_generic_nets = has_net_param + has_net_file;
CHECK_LE(num_generic_nets, 1)
<< "Both net_param and net_file may not be specified.";
const int num_test_net_params = param_.test_net_param_size();
const int num_test_net_files = param_.test_net_size();
const int num_test_nets = num_test_net_params + num_test_net_files;
if(MY_DEBUG)
LOG(INFO) << "has_net_param: " << has_net_param << " has_net_file: "
<< has_net_file << " num_test_net_params: " << num_test_net_params << " num_test_net_files: " << num_test_net_files;
if (num_generic_nets) {
CHECK_GE(param_.test_iter_size(), num_test_nets)
<< "test_iter must be specified for each test network.";
} else {
CHECK_EQ(param_.test_iter_size(), num_test_nets)
<< "test_iter must be specified for each test network.";
}
// If we have a generic net (specified by net or net_param, rather than
// test_net or test_net_param), we may have an unlimited number of actual
// test networks -- the actual number is given by the number of remaining
// test_iters after any test nets specified by test_net_param and/or test_net
// are evaluated.
const int num_generic_net_instances = param_.test_iter_size() - num_test_nets;
const int num_test_net_instances = num_test_nets + num_generic_net_instances;
if (param_.test_state_size()) {
CHECK_EQ(param_.test_state_size(), num_test_net_instances)
<< "test_state must be unspecified or specified once per test net.";
}
if (num_test_net_instances) {
CHECK_GT(param_.test_interval(), 0);
}
int test_net_id = 0;
vector<string> sources(num_test_net_instances);
vector<NetParameter> net_params(num_test_net_instances);
for (int i = 0; i < num_test_net_params; ++i, ++test_net_id) {
sources[test_net_id] = "test_net_param";
net_params[test_net_id].CopyFrom(param_.test_net_param(i));
}
for (int i = 0; i < num_test_net_files; ++i, ++test_net_id) {
sources[test_net_id] = "test_net file: " + param_.test_net(i);
ReadNetParamsFromTextFileOrDie(param_.test_net(i),
&net_params[test_net_id]);
}
const int remaining_test_nets = param_.test_iter_size() - test_net_id;
if (has_net_param) {
for (int i = 0; i < remaining_test_nets; ++i, ++test_net_id) {
sources[test_net_id] = "net_param";
net_params[test_net_id].CopyFrom(param_.net_param());
}
}
if (has_net_file) {
for (int i = 0; i < remaining_test_nets; ++i, ++test_net_id) {
sources[test_net_id] = "net file: " + param_.net();
ReadNetParamsFromTextFileOrDie(param_.net(), &net_params[test_net_id]);
}
}
test_nets_.resize(num_test_net_instances);
for (int i = 0; i < num_test_net_instances; ++i) {
// Set the correct NetState. We start with the solver defaults (lowest
// precedence); then, merge in any NetState specified by the net_param
// itself; finally, merge in any NetState specified by the test_state
// (highest precedence).
NetState net_state;
net_state.set_phase(TEST);
net_state.MergeFrom(net_params[i].state());
if (param_.test_state_size()) {
net_state.MergeFrom(param_.test_state(i));
}
net_params[i].mutable_state()->CopyFrom(net_state);
LOG(INFO)
<< "Creating test net (#" << i << ") specified by " << sources[i];
if (Caffe::root_solver()) {
test_nets_[i].reset(new Net<Dtype>(net_params[i]));
} else {
test_nets_[i].reset(new Net<Dtype>(net_params[i],
root_solver_->test_nets_[i].get()));
}
test_nets_[i]->set_debug_info(param_.debug_info());
}
}
template <typename Dtype>
void Solver<Dtype>::Step(int iters) {
vector<Blob<Dtype>*> bottom_vec;
// 设置开始的迭代次数(如果是从之前的snapshot恢复的,那iter_等于其迭代次数)和结束的迭代次数
const int start_iter = iter_;
const int stop_iter = iter_ + iters;
// 输出的loss为前average_loss次loss的平均值,在solver.proto中设置,默认1
int average_loss = this->param_.average_loss();
// losses存储之前的average_loss个loss,smoothed_loss为最后要输出的均值
vector<Dtype> losses;
Dtype smoothed_loss = 0;
while (iter_ < stop_iter) {
// zero-init the params
// 清空上一次所有参数的梯度
net_->ClearParamDiffs();
// 判断是否需要测试
if (param_.test_interval() && iter_ % param_.test_interval() == 0
&& (iter_ > 0 || param_.test_initialization())
&& Caffe::root_solver()) {
// 此时用到的网络时测试网络,即test_net_
TestAll();
// 判断是否需要提前结束迭代
if (requested_early_exit_) {
// Break out of the while loop because stop was requested while testing.
break;
}
}
for (int i = 0; i < callbacks_.size(); ++i) {
callbacks_[i]->on_start();
}
// 判断当前迭代次数是否需要显示loss等信息
const bool display = param_.display() && iter_ % param_.display() == 0;
net_->set_debug_info(display && param_.debug_info());
// accumulate the loss and gradient
Dtype loss = 0;
// iter_size也是在solver.prototxt里设置,实际上的batch_size=iter_size*网络定义里的batch_size
// 因此每一次迭代的loss是iter_size次迭代的和,再除以iter_size,这个loss是通过调用Net::ForwardBackward计算的
// 在GPU显存不够时使用,例如如果把batch_size设置为128,但是会out_of_memory,借助这个方法,可以设置batch_size=32,iter_size=4,那实际上每次迭代还是处理了128个数据
for (int i = 0; i < param_.iter_size(); ++i) {
// 此时用到的网络是训练网络,即net_
loss += net_->ForwardBackward(bottom_vec);
}
loss /= param_.iter_size();
// 计算要输出的smoothed_loss,如果losses里还没有存够average个loss则将当前的loss插入,如果已经已经存够了,则将之前的替换掉
// average the loss across iterations for smoothed reporting
if (losses.size() < average_loss) {
losses.push_back(loss);
int size = losses.size();
smoothed_loss = (smoothed_loss * (size - 1) + loss) / size;
} else {
int idx = (iter_ - start_iter) % average_loss;
smoothed_loss += (loss - losses[idx]) / average_loss;
losses[idx] = loss;
}
// 输出当前迭代的信息
if (display) {
LOG_IF(INFO, Caffe::root_solver()) << "Iteration " << iter_
<< ", loss = " << smoothed_loss;
const vector<Blob<Dtype>*>& result = net_->output_blobs();
int score_index = 0;
for (int j = 0; j < result.size(); ++j) {
const Dtype* result_vec = result[j]->cpu_data();
const string& output_name =
net_->blob_names()[net_->output_blob_indices()[j]];
const Dtype loss_weight =
net_->blob_loss_weights()[net_->output_blob_indices()[j]];
for (int k = 0; k < result[j]->count(); ++k) {
ostringstream loss_msg_stream;
if (loss_weight) {
loss_msg_stream << " (* " << loss_weight
<< " = " << loss_weight * result_vec[k] << " loss)";
}
LOG_IF(INFO, Caffe::root_solver()) << " Train net output #"
<< score_index++ << ": " << output_name << " = "
<< result_vec[k] << loss_msg_stream.str();
}
}
}
for (int i = 0; i < callbacks_.size(); ++i) {
callbacks_[i]->on_gradients_ready();
}
// 执行梯度的更新,这个函数在基类Solver中没有实现,会调用每个子类自己的实现
ApplyUpdate();
// Increment the internal iter_ counter -- its value should always indicate
// the number of times the weights have been updated.
++iter_;
// 调用GetRequestedAction,实际是通过action_request_function_函数指针调用之前设置好
// signal_hanlder的CheckForSignals函数,这个函数的作用是
// 会根据之前是否遇到系统信号以及信号的类型和我们设置或默认的方式返回处理的方式
SolverAction::Enum request = GetRequestedAction();
// 判断当前迭代是否需要snapshot,如果request等于SNAPSHOT,则也需要
// Save a snapshot if needed.
if ((param_.snapshot()
&& iter_ % param_.snapshot() == 0
&& Caffe::root_solver()) ||
(request == SolverAction::SNAPSHOT)) {
Snapshot();
}
// 如果request是STOP,则修改,之后就会提前结束迭代
if (SolverAction::STOP == request) {
requested_early_exit_ = true;
// Break out of training loop.
break;
}
} // end of while
} // end of Step
// 对整个网络进行训练(也就是运行caffe训练某个模型)的时候,实际上是在运行caffe.cpp中的train()函数,而这个函数实际上是实例化一个Solver对象,初始化后调用了Solver中的Solve()方法。调用此方法训练网络,其中调用Step()来迭代,迭代param_.max_iter()-iter_次.
template <typename Dtype>
void Solver<Dtype>::Solve(const char* resume_file) {
if(MY_TEST_DEBUG)
LOG(INFO) << "进入Solver::Slove()";
// 检查当前是否是root_slover(多GPU模式下,只有root_slover才运行这一部分的代码)
CHECK(Caffe::root_solver());
LOG(INFO) << "Solving " << net_->name();
LOG(INFO) << "Learning Rate Policy: " << param_.lr_policy();
// Initialize to false every time we start solving.一开始被赋值为false,也就是现在没有要求在优化结束前推出
requested_early_exit_ = false;
// 判断这个指针是否NULL,如果不是则需要从resume_file存储的路径里读取之前训练的solver status
if (resume_file) {
LOG(INFO) << "Restoring previous solver status from " << resume_file;
Restore(resume_file);
}
// 然后调用了Step函数,执行了实际的逐步的迭代过程
// For a network that is trained by the solver, no bottom or top vecs
// should be given, and we will just provide dummy vecs.
Step(param_.max_iter() - iter_);
// 迭代结束或遇到系统信号提前结束后,判断是否需要在训练结束之后snapshot
// If we haven't already, save a snapshot after optimization, unless
// overridden by setting snapshot_after_train := false
if (param_.snapshot_after_train()
&& (!param_.snapshot() || iter_ % param_.snapshot() != 0)) {
Snapshot();
}
// 如果在Step函数的迭代过程中遇到了系统信号,且我们的处理方式设置为"STOP"
// 那么其会被修改为true,迭代提前结束,输出相关信息
if (requested_early_exit_) {
LOG(INFO) << "Optimization stopped early.";
return;
}
// After the optimization is done, run an additional train and test pass to
// display the train and test loss/outputs if appropriate (based on the
// display and test_interval settings, respectively). Unlike in the rest of
// training, for the train net we only run a forward pass as we've already
// updated the parameters "max_iter" times -- this final pass is only done to
// display the loss, which is computed in the forward pass.
// 判断是否需要输出最后的loss
if (param_.display() && iter_ % param_.display() == 0) {
Dtype loss;
// 最后在已经训练好的网络中计算loss
net_->ForwardPrefilled(&loss);
if(MY_TEST_DEBUG)
LOG(INFO) << "输出最后的loss";
LOG(INFO) << "Iteration " << iter_ << ", loss = " << loss;
}
if(MY_TEST_DEBUG){
LOG(INFO) << "net_input_blobs_.size(): " << net_->num_inputs() << " " << test_nets_[0]->num_inputs();
LOG(INFO) << "训练网络的层数: " << net_->layers().size();
LOG(INFO) << "测试网络的层数: " << test_nets_[0]->layers().size();
LOG(INFO) << "训练网络的可学习参数的个数: " << net_->learnable_params().size();
LOG(INFO) << "测试网络的可学习参数的个数: " << test_nets_[0]->learnable_params().size();
}
// 判断是否需要最后Test
if (param_.test_interval() && iter_ % param_.test_interval() == 0) {
if(MY_TEST_DEBUG)
LOG(INFO) << "进入最后的Test";
TestAll();
}
LOG(INFO) << "Optimization Done.";
}
template <typename Dtype>
void Solver<Dtype>::TestAll() {
for (int test_net_id = 0;
test_net_id < test_nets_.size() && !requested_early_exit_;
++test_net_id) {
Test(test_net_id);
}
}
// 测试整个test_net_,并输出相应的测试信息,如loss等
template <typename Dtype>
void Solver<Dtype>::Test(const int test_net_id) {
CHECK(Caffe::root_solver());
// 打印测试网络信息
LOG(INFO) << "Iteration " << iter_
<< ", Testing net (#" << test_net_id << ")";
CHECK_NOTNULL(test_nets_[test_net_id].get())->
ShareTrainedLayersWith(net_.get());
vector<Dtype> test_score; // 装载测试网络输出的loss和accuracy的累加的数值
vector<int> test_score_output_id; // 相应的id
vector<Blob<Dtype>*> bottom_vec;
// test_nets_是已经初始化后的得到的训练网络
const shared_ptr<Net<Dtype> >& test_net = test_nets_[test_net_id];
Dtype loss = 0;
// test_iter specifies how many forward passed the test should carry out
for (int i = 0; i < param_.test_iter(test_net_id); ++i) {
SolverAction::Enum request = GetRequestedAction();
// Check to see if stoppage of testing/training has been requested.
while (request != SolverAction::NONE) {
if (SolverAction::SNAPSHOT == request) {
Snapshot();
} else if (SolverAction::STOP == request) {
requested_early_exit_ = true;
}
request = GetRequestedAction();
}
if (requested_early_exit_) {
// break out of test loop.
break;
}
Dtype iter_loss;
// call the Forward() to cumpute the loss and accuracy
// and result the Net::net_output_blobs_
const vector<Blob<Dtype>*>& result =
test_net->Forward(bottom_vec, &iter_loss);
// default faslse
if (param_.test_compute_loss()) {
loss += iter_loss;
}
if (i == 0) {
// result.size()=2, result[j]=1,即只有Accuracy层的top[0]->count()
for (int j = 0; j < result.size(); ++j) {
const Dtype* result_vec = result[j]->cpu_data();
for (int k = 0; k < result[j]->count(); ++k) {
test_score.push_back(result_vec[k]);
test_score_output_id.push_back(j);
}
}
} else {
int idx = 0;
for (int j = 0; j < result.size(); ++j) {
const Dtype* result_vec = result[j]->cpu_data();
for (int k = 0; k < result[j]->count(); ++k) {
test_score[idx++] += result_vec[k];
}
}
}
}
if (requested_early_exit_) {
LOG(INFO) << "Test interrupted.";
return;
}
// default fasle
if (param_.test_compute_loss()) {
loss /= param_.test_iter(test_net_id);
LOG(INFO) << "Test loss: " << loss;
}
if(false && MY_TEST_DEBUG){
// 两个都输出2
LOG(INFO) << "test_score.size(): " << test_score.size();
LOG(INFO) << "test_score_output_id.size(): " << test_score_output_id.size();
}
for (int i = 0; i < test_score.size(); ++i) {
const int output_blob_index =
test_net->output_blob_indices()[test_score_output_id[i]];
const string& output_name = test_net->blob_names()[output_blob_index];
const Dtype loss_weight = test_net->blob_loss_weights()[output_blob_index];
ostringstream loss_msg_stream;
const Dtype mean_score = test_score[i] / param_.test_iter(test_net_id);
if (loss_weight) {
loss_msg_stream << " (* " << loss_weight
<< " = " << loss_weight * mean_score << " loss)";
}
LOG(INFO) << " Test net output #" << i << ": " << output_name << " = "
<< mean_score << loss_msg_stream.str();
}
}
template <typename Dtype>
void Solver<Dtype>::Snapshot() {
CHECK(Caffe::root_solver());
string model_filename;
switch (param_.snapshot_format()) {
case caffe::SolverParameter_SnapshotFormat_BINARYPROTO:
model_filename = SnapshotToBinaryProto();
break;
case caffe::SolverParameter_SnapshotFormat_HDF5:
model_filename = SnapshotToHDF5();
break;
default:
LOG(FATAL) << "Unsupported snapshot format.";
}
SnapshotSolverState(model_filename);
}
template <typename Dtype>
void Solver<Dtype>::CheckSnapshotWritePermissions() {
if (Caffe::root_solver() && param_.snapshot()) {
CHECK(param_.has_snapshot_prefix())
<< "In solver params, snapshot is specified but snapshot_prefix is not";
string probe_filename = SnapshotFilename(".tempfile");
std::ofstream probe_ofs(probe_filename.c_str());
if (probe_ofs.good()) {
probe_ofs.close();
std::remove(probe_filename.c_str());
} else {
LOG(FATAL) << "Cannot write to snapshot prefix '"
<< param_.snapshot_prefix() << "'. Make sure "
<< "that the directory exists and is writeable.";
}
}
}
template <typename Dtype>
string Solver<Dtype>::SnapshotFilename(const string extension) {
return param_.snapshot_prefix() + "_iter_" + caffe::format_int(iter_)
+ extension;
}
template <typename Dtype>
string Solver<Dtype>::SnapshotToBinaryProto() {
string model_filename = SnapshotFilename(".caffemodel");
LOG(INFO) << "Snapshotting to binary proto file " << model_filename;
NetParameter net_param;
net_->ToProto(&net_param, param_.snapshot_diff());
WriteProtoToBinaryFile(net_param, model_filename);
return model_filename;
}
template <typename Dtype>
string Solver<Dtype>::SnapshotToHDF5() {
string model_filename = SnapshotFilename(".caffemodel.h5");
LOG(INFO) << "Snapshotting to HDF5 file " << model_filename;
net_->ToHDF5(model_filename, param_.snapshot_diff());
return model_filename;
}
template <typename Dtype>
void Solver<Dtype>::Restore(const char* state_file) {
CHECK(Caffe::root_solver());
string state_filename(state_file);
if (state_filename.size() >= 3 &&
state_filename.compare(state_filename.size() - 3, 3, ".h5") == 0) {
RestoreSolverStateFromHDF5(state_filename);
} else {
RestoreSolverStateFromBinaryProto(state_filename);
}
}
INSTANTIATE_CLASS(Solver);
} // namespace caffe
|
; void *tshc_aaddr2saddr(void *aaddr)
SECTION code_clib
SECTION code_arch
PUBLIC _tshc_aaddr2saddr_fastcall
EXTERN asm_tshc_aaddr2saddr
defc _tshc_aaddr2saddr_fastcall = asm_tshc_aaddr2saddr
|
Name: test.asm
Type: file
Size: 29
Last-Modified: '1992-02-13T07:48:36Z'
SHA-1: 66D543C1459ACB0BBA55EBC46F1751923E3D48A8
Description: null
|
Name: ys_demo_1.asm
Type: file
Size: 30120
Last-Modified: '2016-05-13T04:51:15Z'
SHA-1: 30FF1DA425E5B980C3D354118A98E5CDA91A7883
Description: null
|
BITS 32
start:
mov eax, 41
jmp short start
|
; GLOBALS ===========================================================
SIZE .INT 7
cnt .INT 7
tenth .INT 0
c .BYT 0
.BYT 0
.BYT 0
.BYT 0
.BYT 0
.BYT 0
.BYT 0
data .INT 0
flag .INT 0
opdv .INT 0
; Program vars
PLUS .BYT '+'
spc .BYT 32
ret .BYT 13
EOT .BYT 3 ; End of text
LTUE .INT -42
; Strings
opderr .BYT 32
.BYT 'i'
.BYT 's'
.BYT 32
.BYT 'n'
.BYT 'o'
.BYT 't'
.BYT 32
.BYT 'a'
.BYT 32
.BYT 'n'
.BYT 'u'
.BYT 'm'
.BYT 'b'
.BYT 'e'
.BYT 'r'
.BYT 13
.BYT 3 ; EOT
getdataerr .BYT 'N'
.BYT 'u'
.BYT 'm'
.BYT 'b'
.BYT 'e'
.BYT 'r'
.BYT 32
.BYT 't'
.BYT 'o'
.BYT 'o'
.BYT 32
.BYT 'B'
.BYT 'i'
.BYT 'g'
.BYT 10
.BYT 3 ; END OF TEXT
; Other useful values
ZERO .INT 0
I .INT 1
II .INT 2
III .INT 3
IV .INT 4
V .INT 5
VI .INT 6
VII .INT 7
VIII .INT 8
IX .INT 9
cZERO .BYT 48
cI .BYT 49
cII .BYT 50
cIII .BYT 51
cIV .BYT 52
cV .BYT 53
cVI .BYT 54
cVII .BYT 55
cVIII .BYT 56
cIX .BYT 57
_s .BYT '+'
_k .INT 1
_j .BYT '7'
JMP START
; === print =========================================================
print MOV R1 FP ; Copy over the FP
ADI R1 -36 ; Bypass the ret addr, PFP, and Registers
LDR R2 (R1) ; Load in the value at the 3rd slot up in AR
LDB R3 (R2) ; R2 = addr of argument
ps_ LDB R0 EOT
CMP R0 R3
BRZ R0 eps_
TRP 3
ADI R2 1
LDB R3 (R2)
JMP ps_
; === Begin return call
eps_ MOV SP FP ; Test for underflow
MOV R5 SP
CMP R6 SB
BGT R6 UNDERFLOW
; === Store Ret value
LDR R7 ZERO ; Return value
; === Return to last location
MOV R6 FP ; Return address pointed to by FP
ADI R6 -4
LDR R6 (R6)
JMR R6
; === END print =====================================================
; === reset =========================================================
; Reset c to all 0's
; Assign values to data, opdv, cnt, and flag
reset MOV R6 FP
ADI R6 -36 ; Access w
LDR R0 (R6)
ADI R6 -4 ; x
LDR R1 (R6)
ADI R6 -4 ; y
LDR R2 (R6)
ADI R6 -4 ; z
LDR R4 (R6)
; === End variable initiation
LDR R6 ZERO
LDA R5 c
for0 LDR R7 SIZE
CMP R7 R6
BRZ R7 ef0
LDR R7 ZERO
STB R7 (R5)
ADI R6 1
ADI R5 1
JMP for0
ef0 LDR R5 ZERO
STR R5 data
STR R5 opdv
STR R5 cnt
STR R5 flag
; === Begin return call
MOV SP FP ; Test for underflow
MOV R5 SP
CMP R6 SB
BGT R6 UNDERFLOW
; === Store Ret value
LDR R7 ZERO ; Return value
; === Return to last location
MOV R6 FP ; Return address pointed to by FP
ADI R6 -4
LDR R6 (R6)
JMR R6
; === END reset =====================================================
; === getdata =======================================================
; Read one char at a time from the keyboard after a
; newline ‘\n’ has been entered. If there is room
; place the char in the array c
; otherwise indicate the number is too big and
; flush the keyboard input.
getdata LDR R0 cnt
LDR R1 SIZE
CMP R0 R1
BLT R0 isroom ; Get data if there is room
; === Begin Function call
MOV R7 SP ; Test for overflow
ADI R7 -8 ; Adjust for Rtn address & PFP
ADI R7 -24 ; Registers
ADI R7 -4 ; Vars
CMP R7 SL
BLT R7 OVERFLOW
; === Store Ret and PFP
MOV R7 FP ; Save FP in R1, this will be PFP
MOV FP SP ; Point at current activation record
ADI SP -4 ; Adjust SP for ret address
MOV R6 PC ; PC incremented by 1 instruction
ADI R6 252 ; Compute return address
STR R6 (SP) ; Push return address
ADI SP -4 ; Adjust for PFP
STR R7 (SP) ; Push PFP to top of stack
; === Store registers
ADI SP -4 ; R0
STR R0 (SP)
ADI SP -4 ; R1
STR R1 (SP)
ADI SP -4 ; R2
STR R2 (SP)
ADI SP -4 ; R3
STR R3 (SP)
ADI SP -4 ; R4
STR R4 (SP)
ADI SP -4 ; R5
STR R5 (SP)
; === Store variables
ADI SP -4
LDA R6 getdataerr
STR R6 (SP)
; === Function call
JMP print
; === Restore the registers
MOV R6 FP
ADI R6 -12
LDR R0 (R6)
ADI R6 -4
LDR R1 (R6)
; === Roll back SP and FP
MOV SP FP
ADI FP -8
LDR FP (FP)
; === End function call
eps2 ADI R0 0 ; flush()
JMP gdendif
isroom LDA R5 c
LDR R4 cnt
ADD R5 R4
TRP 4
STB R3 (R5)
ADI R4 1
STR R4 cnt
gdendif MOV SP FP ; Test for underflow
MOV R5 SP
CMP R6 SB
BGT R6 UNDERFLOW
; === Store Ret value
LDR R7 ZERO ; Return value
; === Return to last location
MOV R6 FP ; Return address pointed to by FP
ADI R6 -4
LDR R6 (R6)
JMR R6
; === END getdata ===================================================
;==== Main ==========================================================
; === Begin Function call
START MOV R7 SP ; Test for overflow
ADI R7 -8 ; Adjust for Rtn address & PFP
ADI R7 -24 ; Registers
ADI R7 -20 ; Vars
CMP R7 SL
BLT R7 OVERFLOW
; === Store Ret and PFP
MOV R7 FP ; Save FP in R1, this will be PFP
MOV FP SP ; Point at current activation record
ADI SP -4 ; Adjust SP for ret address
MOV R6 PC ; PC incremented by 1 instruction
ADI R6 360 ; Compute return address
STR R6 (SP) ; Push return address
ADI SP -4 ; Adjust for PFP
STR R7 (SP) ; Push PFP to top of stack
; === Store registers
ADI SP -4 ; R0
STR R0 (SP)
ADI SP -4 ; R1
STR R1 (SP)
ADI SP -4 ; R2
STR R2 (SP)
ADI SP -4 ; R3
STR R3 (SP)
ADI SP -4 ; R4
STR R4 (SP)
ADI SP -4 ; R5
STR R5 (SP)
; === Store variables
ADI SP -4
LDR R6 I
STR R6 (SP) ; w
ADI SP -4
LDR R6 ZERO
STR R6 (SP) ; x
ADI SP -4
LDR R6 ZERO
STR R6 (SP) ; y
ADI SP -4
LDR R6 ZERO
STR R6 (SP) ; z
; === Function call
JMP reset
; === Restore the registers
; === Roll back SP and FP
MOV SP FP
ADI FP -8
LDR FP (FP)
; === End function call
; === Begin Function call
MOV R7 SP ; Test for overflow
ADI R7 -8 ; Adjust for Rtn address & PFP
ADI R7 -24 ; Registers
ADI R7 -20 ; Vars
CMP R7 SL
BLT R7 OVERFLOW
; === Store Ret and PFP
MOV R7 FP ; Save FP in R1, this will be PFP
MOV FP SP ; Point at current activation record
ADI SP -4 ; Adjust SP for ret address
MOV R6 PC ; PC incremented by 1 instruction
ADI R6 216 ; Compute return address
STR R6 (SP) ; Push return address
ADI SP -4 ; Adjust for PFP
STR R7 (SP) ; Push PFP to top of stack
; === Store registers
ADI SP -4 ; R0
STR R0 (SP)
ADI SP -4 ; R1
STR R1 (SP)
ADI SP -4 ; R2
STR R2 (SP)
ADI SP -4 ; R3
STR R3 (SP)
ADI SP -4 ; R4
STR R4 (SP)
ADI SP -4 ; R5
STR R5 (SP)
; === Store variables
; === Function call
JMP getdata
; === Restore the registers
; === Roll back SP and FP
MOV SP FP
ADI FP -8
LDR FP (FP)
; === End function call
LDR R3 LTUE
TRP 1
TRP 0
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r8
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x39a9, %rax
nop
inc %rbp
vmovups (%rax), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $1, %xmm5, %r13
nop
cmp $10423, %rbx
lea addresses_A_ht+0x57a9, %r8
nop
nop
and %rsi, %rsi
movw $0x6162, (%r8)
cmp $38265, %rbx
lea addresses_WT_ht+0x155a9, %rsi
lea addresses_normal_ht+0x1369, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
sub %rbx, %rbx
mov $45, %rcx
rep movsb
nop
dec %rax
lea addresses_WC_ht+0xf709, %rsi
lea addresses_WC_ht+0x7da9, %rdi
cmp $17925, %rax
mov $37, %rcx
rep movsl
nop
nop
nop
inc %rbp
lea addresses_WC_ht+0x188a9, %r8
nop
nop
nop
nop
xor %rsi, %rsi
movb $0x61, (%r8)
nop
nop
nop
cmp $43370, %r8
lea addresses_UC_ht+0xf314, %rbp
nop
cmp $25020, %rcx
mov $0x6162636465666768, %rbx
movq %rbx, (%rbp)
nop
nop
lfence
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r8
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r8
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
// Faulty Load
lea addresses_normal+0x169a9, %rdx
nop
nop
inc %rdi
mov (%rdx), %esi
lea oracles, %r8
and $0xff, %rsi
shlq $12, %rsi
mov (%r8,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r8
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'34': 20799}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
;
; Copyright (c) 2020 Phillip Stevens
;
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;
; feilipu, August 2020
;
;-------------------------------------------------------------------------
; asm_am9511_pow - am9511 floating point power x^y
;-------------------------------------------------------------------------
SECTION code_clib
SECTION code_fp_am9511
EXTERN __IO_APU_CONTROL
EXTERN __IO_APU_OP_PWR
EXTERN asm_am9511_pushf_hl
EXTERN asm_am9511_pushf_fastcall
EXTERN asm_am9511_popf
PUBLIC asm_am9511_pow, asm_am9511_pow_callee
; enter here for floating power, x^y x on stack, y in dehl
.asm_am9511_pow
exx
ld hl,2
add hl,sp
call asm_am9511_pushf_hl ; x
exx
call asm_am9511_pushf_fastcall ; y
ld a,__IO_APU_OP_PWR
out (__IO_APU_CONTROL),a ; x ^ y
jp asm_am9511_popf
; enter here for floating power callee, x^y x on stack, y in dehl
.asm_am9511_pow_callee
exx
ld hl,2
add hl,sp
call asm_am9511_pushf_hl ; x
exx
call asm_am9511_pushf_fastcall ; y
ld a,__IO_APU_OP_PWR
out (__IO_APU_CONTROL),a ; x ^ y
pop hl ; ret
pop de
ex (sp),hl ; ret back on stack
jp asm_am9511_popf
|
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
#include <boost/timer.hpp>
// for sophus
#include <sophus/se3.h>
using Sophus::SE3;
// for eigen
#include <Eigen/Core>
#include <Eigen/Geometry>
using namespace Eigen;
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
/**********************************************
* 本程序演示了单目相机在已知轨迹下的稠密深度估计
* 使用极线搜索 + NCC 匹配的方式,与书本的 13.2 节对应
* 请注意本程序并不完美,你完全可以改进它——我其实在故意暴露一些问题。
***********************************************/
// ------------------------------------------------------------------
// parameters
const int boarder = 20; // 边缘宽度
const int width = 640; // 宽度
const int height = 480; // 高度
const double fx = 481.2f; // 相机内参
const double fy = -480.0f;
const double cx = 319.5f;
const double cy = 239.5f;
const int ncc_window_size = 2; // NCC 取的窗口半宽度
const int ncc_area = (2*ncc_window_size+1)*(2*ncc_window_size+1); // NCC窗口面积
const double min_cov = 0.1; // 收敛判定:最小方差
const double max_cov = 10; // 发散判定:最大方差
// ------------------------------------------------------------------
// 重要的函数
// 从 REMODE 数据集读取数据
bool readDatasetFiles(
const string& path,
vector<string>& color_image_files,
vector<SE3>& poses
);
// 根据新的图像更新深度估计
bool update(
const Mat& ref,
const Mat& curr,
const SE3& T_C_R,
Mat& depth,
Mat& depth_cov
);
// 极线搜索
bool epipolarSearch(
const Mat& ref,
const Mat& curr,
const SE3& T_C_R,
const Vector2d& pt_ref,
const double& depth_mu,
const double& depth_cov,
Vector2d& pt_curr
);
// 更新深度滤波器
bool updateDepthFilter(
const Vector2d& pt_ref,
const Vector2d& pt_curr,
const SE3& T_C_R,
Mat& depth,
Mat& depth_cov
);
// 计算 NCC 评分
double NCC( const Mat& ref, const Mat& curr, const Vector2d& pt_ref, const Vector2d& pt_curr );
// 双线性灰度插值
inline double getBilinearInterpolatedValue( const Mat& img, const Vector2d& pt ) {
uchar* d = & img.data[ int(pt(1,0))*img.step+int(pt(0,0)) ];
double xx = pt(0,0) - floor(pt(0,0));
double yy = pt(1,0) - floor(pt(1,0));
return (( 1-xx ) * ( 1-yy ) * double(d[0]) +
xx* ( 1-yy ) * double(d[1]) +
( 1-xx ) *yy* double(d[img.step]) +
xx*yy*double(d[img.step+1]))/255.0;
}
// ------------------------------------------------------------------
// 一些小工具
// 显示估计的深度图
void plotDepth( const Mat& depth );
// 像素到相机坐标系
inline Vector3d px2cam ( const Vector2d px ) {
return Vector3d (
(px(0,0) - cx)/fx,
(px(1,0) - cy)/fy,
1
);
}
// 相机坐标系到像素
inline Vector2d cam2px ( const Vector3d p_cam ) {
return Vector2d (
p_cam(0,0)*fx/p_cam(2,0) + cx,
p_cam(1,0)*fy/p_cam(2,0) + cy
);
}
// 检测一个点是否在图像边框内
inline bool inside( const Vector2d& pt ) {
return pt(0,0) >= boarder && pt(1,0)>=boarder
&& pt(0,0)+boarder<width && pt(1,0)+boarder<=height;
}
// 显示极线匹配
void showEpipolarMatch( const Mat& ref, const Mat& curr, const Vector2d& px_ref, const Vector2d& px_curr );
// 显示极线
void showEpipolarLine( const Mat& ref, const Mat& curr, const Vector2d& px_ref, const Vector2d& px_min_curr, const Vector2d& px_max_curr );
// ------------------------------------------------------------------
int main( int argc, char** argv )
{
if ( argc != 2 )
{
cout<<"Usage: dense_mapping path_to_test_dataset"<<endl;
return -1;
}
// 从数据集读取数据
vector<string> color_image_files;
vector<SE3> poses_TWC;
bool ret = readDatasetFiles( argv[1], color_image_files, poses_TWC );
if ( ret==false )
{
cout<<"Reading image files failed!"<<endl;
return -1;
}
cout<<"read total "<<color_image_files.size()<<" files."<<endl;
// 第一张图
Mat ref = imread( color_image_files[0], 0 ); // gray-scale image
SE3 pose_ref_TWC = poses_TWC[0];
double init_depth = 3.0; // 深度初始值
double init_cov2 = 3.0; // 方差初始值
Mat depth( height, width, CV_64F, init_depth ); // 深度图
Mat depth_cov( height, width, CV_64F, init_cov2 ); // 深度图方差
for ( int index=1; index<color_image_files.size(); index++ )
{
cout<<"*** loop "<<index<<" ***"<<endl;
Mat curr = imread( color_image_files[index], 0 );
if (curr.data == nullptr) continue;
SE3 pose_curr_TWC = poses_TWC[index];
SE3 pose_T_C_R = pose_curr_TWC.inverse() * pose_ref_TWC; // 坐标转换关系: T_C_W * T_W_R = T_C_R
update( ref, curr, pose_T_C_R, depth, depth_cov );
plotDepth( depth );
imshow("image", curr);
waitKey(1);
}
cout<<"estimation returns, saving depth map ..."<<endl;
imwrite( "depth.png", depth );
cout<<"done."<<endl;
return 0;
}
bool readDatasetFiles(
const string& path,
vector< string >& color_image_files,
std::vector<SE3>& poses
)
{
ifstream fin( path+"/first_200_frames_traj_over_table_input_sequence.txt");
if ( !fin ) return false;
while ( !fin.eof() )
{
// 数据格式:图像文件名 tx, ty, tz, qx, qy, qz, qw ,注意是 TWC 而非 TCW
string image;
fin>>image;
double data[7];
for ( double& d:data ) fin>>d;
color_image_files.push_back( path+string("/images/")+image );
poses.push_back(
SE3( Quaterniond(data[6], data[3], data[4], data[5]),
Vector3d(data[0], data[1], data[2]))
);
if ( !fin.good() ) break;
}
return true;
}
// 对整个深度图进行更新
bool update(const Mat& ref, const Mat& curr, const SE3& T_C_R, Mat& depth, Mat& depth_cov )
{
#pragma omp parallel for
for ( int x=boarder; x<width-boarder; x++ )
#pragma omp parallel for
for ( int y=boarder; y<height-boarder; y++ )
{
// 遍历每个像素
if ( depth_cov.ptr<double>(y)[x] < min_cov || depth_cov.ptr<double>(y)[x] > max_cov ) // 深度已收敛或发散
continue;
// 在极线上搜索 (x,y) 的匹配
Vector2d pt_curr;
bool ret = epipolarSearch (
ref,
curr,
T_C_R,
Vector2d(x,y),
depth.ptr<double>(y)[x],
sqrt(depth_cov.ptr<double>(y)[x]),
pt_curr
);
if ( ret == false ) // 匹配失败
continue;
// 取消该注释以显示匹配
// showEpipolarMatch( ref, curr, Vector2d(x,y), pt_curr );
// 匹配成功,更新深度图
updateDepthFilter( Vector2d(x,y), pt_curr, T_C_R, depth, depth_cov );
}
}
// 极线搜索
// 方法见书 13.2 13.3 两节
bool epipolarSearch(
const Mat& ref, const Mat& curr,
const SE3& T_C_R, const Vector2d& pt_ref,
const double& depth_mu, const double& depth_cov,
Vector2d& pt_curr )
{
Vector3d f_ref = px2cam( pt_ref );
f_ref.normalize();
Vector3d P_ref = f_ref*depth_mu; // 参考帧的 P 向量
Vector2d px_mean_curr = cam2px( T_C_R*P_ref ); // 按深度均值投影的像素
double d_min = depth_mu-3*depth_cov, d_max = depth_mu+3*depth_cov;
if ( d_min<0.1 ) d_min = 0.1;
Vector2d px_min_curr = cam2px( T_C_R*(f_ref*d_min) ); // 按最小深度投影的像素
Vector2d px_max_curr = cam2px( T_C_R*(f_ref*d_max) ); // 按最大深度投影的像素
Vector2d epipolar_line = px_max_curr - px_min_curr; // 极线(线段形式)
Vector2d epipolar_direction = epipolar_line; // 极线方向
epipolar_direction.normalize();
double half_length = 0.5*epipolar_line.norm(); // 极线线段的半长度
if ( half_length>100 ) half_length = 100; // 我们不希望搜索太多东西
// 取消此句注释以显示极线(线段)
// showEpipolarLine( ref, curr, pt_ref, px_min_curr, px_max_curr );
// 在极线上搜索,以深度均值点为中心,左右各取半长度
double best_ncc = -1.0;
Vector2d best_px_curr;
for ( double l=-half_length; l<=half_length; l+=0.7 ) // l+=sqrt(2)
{
Vector2d px_curr = px_mean_curr + l*epipolar_direction; // 待匹配点
if ( !inside(px_curr) )
continue;
// 计算待匹配点与参考帧的 NCC
double ncc = NCC( ref, curr, pt_ref, px_curr );
if ( ncc>best_ncc )
{
best_ncc = ncc;
best_px_curr = px_curr;
}
}
if ( best_ncc < 0.85f ) // 只相信 NCC 很高的匹配
return false;
pt_curr = best_px_curr;
return true;
}
double NCC (
const Mat& ref, const Mat& curr,
const Vector2d& pt_ref, const Vector2d& pt_curr
)
{
// 零均值-归一化互相关
// 先算均值
double mean_ref = 0, mean_curr = 0;
vector<double> values_ref, values_curr; // 参考帧和当前帧的均值
for ( int x=-ncc_window_size; x<=ncc_window_size; x++ )
for ( int y=-ncc_window_size; y<=ncc_window_size; y++ )
{
double value_ref = double(ref.ptr<uchar>( int(y+pt_ref(1,0)) )[ int(x+pt_ref(0,0)) ])/255.0;
mean_ref += value_ref;
double value_curr = getBilinearInterpolatedValue( curr, pt_curr+Vector2d(x,y) );
mean_curr += value_curr;
values_ref.push_back(value_ref);
values_curr.push_back(value_curr);
}
mean_ref /= ncc_area;
mean_curr /= ncc_area;
// 计算 Zero mean NCC
double numerator = 0, demoniator1 = 0, demoniator2 = 0;
for ( int i=0; i<values_ref.size(); i++ )
{
double n = (values_ref[i]-mean_ref) * (values_curr[i]-mean_curr);
numerator += n;
demoniator1 += (values_ref[i]-mean_ref)*(values_ref[i]-mean_ref);
demoniator2 += (values_curr[i]-mean_curr)*(values_curr[i]-mean_curr);
}
return numerator / sqrt( demoniator1*demoniator2+1e-10 ); // 防止分母出现零
}
bool updateDepthFilter(
const Vector2d& pt_ref,
const Vector2d& pt_curr,
const SE3& T_C_R,
Mat& depth,
Mat& depth_cov
)
{
// 我是一只喵
// 不知道这段还有没有人看
// 用三角化计算深度
SE3 T_R_C = T_C_R.inverse();
Vector3d f_ref = px2cam( pt_ref );
f_ref.normalize();
Vector3d f_curr = px2cam( pt_curr );
f_curr.normalize();
// 方程
// d_ref * f_ref = d_cur * ( R_RC * f_cur ) + t_RC
// => [ f_ref^T f_ref, -f_ref^T f_cur ] [d_ref] = [f_ref^T t]
// [ f_cur^T f_ref, -f_cur^T f_cur ] [d_cur] = [f_cur^T t]
// 二阶方程用克莱默法则求解并解之
Vector3d t = T_R_C.translation();
Vector3d f2 = T_R_C.rotation_matrix() * f_curr;
Vector2d b = Vector2d ( t.dot ( f_ref ), t.dot ( f2 ) );
double A[4];
A[0] = f_ref.dot ( f_ref );
A[2] = f_ref.dot ( f2 );
A[1] = -A[2];
A[3] = - f2.dot ( f2 );
double d = A[0]*A[3]-A[1]*A[2];
Vector2d lambdavec =
Vector2d ( A[3] * b ( 0,0 ) - A[1] * b ( 1,0 ),
-A[2] * b ( 0,0 ) + A[0] * b ( 1,0 )) /d;
Vector3d xm = lambdavec ( 0,0 ) * f_ref;
Vector3d xn = t + lambdavec ( 1,0 ) * f2;
Vector3d d_esti = ( xm+xn ) / 2.0; // 三角化算得的深度向量
double depth_estimation = d_esti.norm(); // 深度值
// 计算不确定性(以一个像素为误差)
Vector3d p = f_ref*depth_estimation;
Vector3d a = p - t;
double t_norm = t.norm();
double a_norm = a.norm();
double alpha = acos( f_ref.dot(t)/t_norm );
double beta = acos( -a.dot(t)/(a_norm*t_norm));
double beta_prime = beta + atan(1/fx);
double gamma = M_PI - alpha - beta_prime;
double p_prime = t_norm * sin(beta_prime) / sin(gamma);
double d_cov = p_prime - depth_estimation;
double d_cov2 = d_cov*d_cov;
// 高斯融合
double mu = depth.ptr<double>( int(pt_ref(1,0)) )[ int(pt_ref(0,0)) ];
double sigma2 = depth_cov.ptr<double>( int(pt_ref(1,0)) )[ int(pt_ref(0,0)) ];
double mu_fuse = (d_cov2*mu+sigma2*depth_estimation) / ( sigma2+d_cov2);
double sigma_fuse2 = ( sigma2 * d_cov2 ) / ( sigma2 + d_cov2 );
depth.ptr<double>( int(pt_ref(1,0)) )[ int(pt_ref(0,0)) ] = mu_fuse;
depth_cov.ptr<double>( int(pt_ref(1,0)) )[ int(pt_ref(0,0)) ] = sigma_fuse2;
return true;
}
// 后面这些太简单我就不注释了(其实是因为懒)
void plotDepth(const Mat& depth)
{
imshow( "depth", depth*0.4 );
waitKey(1);
}
void showEpipolarMatch(const Mat& ref, const Mat& curr, const Vector2d& px_ref, const Vector2d& px_curr)
{
Mat ref_show, curr_show;
cv::cvtColor( ref, ref_show, CV_GRAY2BGR );
cv::cvtColor( curr, curr_show, CV_GRAY2BGR );
cv::circle( ref_show, cv::Point2f(px_ref(0,0), px_ref(1,0)), 5, cv::Scalar(0,0,250), 2);
cv::circle( curr_show, cv::Point2f(px_curr(0,0), px_curr(1,0)), 5, cv::Scalar(0,0,250), 2);
imshow("ref", ref_show );
imshow("curr", curr_show );
waitKey(1);
}
void showEpipolarLine(const Mat& ref, const Mat& curr, const Vector2d& px_ref, const Vector2d& px_min_curr, const Vector2d& px_max_curr)
{
Mat ref_show, curr_show;
cv::cvtColor( ref, ref_show, CV_GRAY2BGR );
cv::cvtColor( curr, curr_show, CV_GRAY2BGR );
cv::circle( ref_show, cv::Point2f(px_ref(0,0), px_ref(1,0)), 5, cv::Scalar(0,255,0), 2);
cv::circle( curr_show, cv::Point2f(px_min_curr(0,0), px_min_curr(1,0)), 5, cv::Scalar(0,255,0), 2);
cv::circle( curr_show, cv::Point2f(px_max_curr(0,0), px_max_curr(1,0)), 5, cv::Scalar(0,255,0), 2);
cv::line( curr_show, Point2f(px_min_curr(0,0), px_min_curr(1,0)), Point2f(px_max_curr(0,0), px_max_curr(1,0)), Scalar(0,255,0), 1);
imshow("ref", ref_show );
imshow("curr", curr_show );
waitKey(1);
}
|
dnl PowerPC-64 mpn_rsh1add_n -- rp[] = (up[] + vp[]) >> 1
dnl Copyright 2003, 2005 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published
dnl by the Free Software Foundation; either version 3 of the License, or (at
dnl your option) any later version.
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C POWER3/PPC630: 2 (1.5 c/l should be possible)
C POWER4/PPC970: 4 (2.0 c/l should be possible)
C INPUT PARAMETERS
C rp r3
C up r4
C vp r5
C n r6
define(`rp',`r3')
define(`up',`r4')
define(`vp',`r5')
define(`s0',`r6')
define(`s1',`r7')
define(`x',`r0')
define(`u0',`r8')
define(`u1',`r9')
define(`v0',`r10')
define(`v1',`r11')
ASM_START()
PROLOGUE(mpn_rsh1add_n)
mtctr r6 C copy size to count register
addi rp, rp, -8
ld u1, 0(up)
ld v1, 0(vp)
addc x, v1, u1
rldicl r12, x, 0, 63 C return value
srdi s1, x, 1
bdz L(1)
ld u0, 8(up)
ld v0, 8(vp)
bdz L(end)
L(oop): ldu u1, 16(up)
ldu v1, 16(vp)
adde x, v0, u0
srdi s0, x, 1
rldimi s1, x, 63, 0
std s1, 8(rp)
bdz L(exit)
ld u0, 8(up)
ld v0, 8(vp)
adde x, v1, u1
srdi s1, x, 1
rldimi s0, x, 63, 0
stdu s0, 16(rp)
bdnz L(oop)
L(end): adde x, v0, u0
srdi s0, x, 1
rldimi s1, x, 63, 0
std s1, 8(rp)
li x, 0
addze x, x
rldimi s0, x, 63, 0
std s0, 16(rp)
mr r3, r12
blr
L(exit): adde x, v1, u1
srdi s1, x, 1
rldimi s0, x, 63, 0
stdu s0, 16(rp)
L(1): li x, 0
addze x, x
rldimi s1, x, 63, 0
std s1, 8(rp)
mr r3, r12
blr
EPILOGUE()
|
; A120503: Generalized meta-Fibonacci sequence a(n) with parameters s=0 and k=3.
; 1,2,3,3,4,5,6,6,7,8,9,9,9,10,11,12,12,13,14,15,15,16,17,18,18,18,19,20,21,21,22,23,24,24,25,26,27,27,27,27,28,29,30,30,31,32,33,33,34,35,36,36,36,37,38,39,39,40,41,42,42,43,44,45,45,45,46,47,48,48,49,50,51,51
mov $3,$0
add $3,1
mov $6,$0
lpb $3
mov $0,$6
sub $3,1
sub $0,$3
mov $2,$0
mov $8,2
lpb $8
mov $0,$2
sub $8,1
add $0,$8
sub $0,1
cal $0,96346 ; Complement of A004128.
mov $5,$0
mov $7,$8
lpb $7
mov $4,$5
sub $7,1
lpe
lpe
lpb $2
mov $2,0
sub $4,$5
lpe
mov $5,$4
div $5,3
add $1,$5
lpe
|
;
; file: max.asm
; This example demostrates how to avoid conditional branches
%include "asm_io.inc"
segment _DATA public align=4 class=DATA use32
message1 db "Enter a number: ",0
message2 db "Enter another number: ", 0
message3 db "The larger number is: ", 0
segment _BSS public align=4 class=BSS use32
input1 resd 1 ; first number entered
group DGROUP _BSS _DATA
segment _TEXT public align=1 class=CODE use32
global _asm_main
_asm_main:
enter 0,0 ; setup routine
pusha
mov eax, message1 ; print out first message
call print_string
call read_int ; input first number
mov [input1], eax
mov eax, message2 ; print out second message
call print_string
call read_int ; input second number (in eax)
xor ebx, ebx ; ebx = 0
cmp eax, [input1] ; compare second and first number
setg bl ; ebx = (input2 > input1) ? 1 : 0
neg ebx ; ebx = (input2 > input1) ? 0xFFFFFFFF : 0
mov ecx, ebx ; ecx = (input2 > input1) ? 0xFFFFFFFF : 0
and ecx, eax ; ecx = (input2 > input1) ? input2 : 0
not ebx ; ebx = (input2 > input1) ? 0 : 0xFFFFFFFF
and ebx, [input1] ; ebx = (input2 > input1) ? 0 : input1
or ecx, ebx ; ecx = (input2 > input1) ? input2 : input1
mov eax, message3 ; print out result
call print_string
mov eax, ecx
call print_int
call print_nl
popa
mov eax, 0 ; return back to C
leave
ret
|
; A138691: Numbers of the form 68+p^2 (where p is a prime).
; Submitted by Jamie Morken(s3)
; 72,77,93,117,189,237,357,429,597,909,1029,1437,1749,1917,2277,2877,3549,3789,4557,5109,5397,6309,6957,7989,9477,10269,10677,11517,11949,12837,16197,17229,18837,19389,22269,22869,24717,26637,27957,29997,32109,32829,36549,37317,38877,39669,44589,49797,51597,52509,54357,57189,58149,63069,66117,69237,72429,73509,76797,79029,80157,85917,94317,96789,98037,100557,109629,113637,120477,121869,124677,128949,134757,139197,143709,146757,151389,157677,160869,167349,175629,177309,185829,187557,192789,196317
mul $0,2
max $0,1
seq $0,173919 ; Numbers that are prime or one less than a prime.
pow $0,2
add $0,68
|
SECTION code_fcntl
PUBLIC zx_01_output_char_32_tty_z88dk_27_escape
EXTERN error_zc
zx_01_output_char_32_tty_z88dk_27_escape:
; output escaped char uninterpretted
; de = parameters *
ld a,(de)
ld c,a ; c = escaped char
; pop one return address from stack
; so that carry is not cleared
jp error_zc - 1 ; carry set to deliver char to terminal
|
// Copyright (c) 2020-2021 The UFO Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bloom.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <uint256.h>
#include <cassert>
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
FUZZ_TARGET(rolling_bloom_filter)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
CRollingBloomFilter rolling_bloom_filter{
fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(1, 1000),
0.999 / fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(1, std::numeric_limits<unsigned int>::max())};
while (fuzzed_data_provider.remaining_bytes() > 0) {
CallOneOf(
fuzzed_data_provider,
[&] {
const std::vector<unsigned char> b = ConsumeRandomLengthByteVector(fuzzed_data_provider);
(void)rolling_bloom_filter.contains(b);
rolling_bloom_filter.insert(b);
const bool present = rolling_bloom_filter.contains(b);
assert(present);
},
[&] {
const std::optional<uint256> u256 = ConsumeDeserializable<uint256>(fuzzed_data_provider);
if (!u256) {
return;
}
(void)rolling_bloom_filter.contains(*u256);
rolling_bloom_filter.insert(*u256);
const bool present = rolling_bloom_filter.contains(*u256);
assert(present);
},
[&] {
rolling_bloom_filter.reset();
});
}
}
|
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/core/grappler/optimizers/loop_optimizer.h"
#include <algorithm>
#include <deque>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "tensorflow/core/framework/attr_value.pb.h"
#include "tensorflow/core/framework/node_def.pb.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/tensor_shape.pb.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/grappler/grappler_item.h"
#include "tensorflow/core/grappler/op_types.h"
#include "tensorflow/core/grappler/optimizers/constant_folding.h"
#include "tensorflow/core/grappler/utils.h"
#include "tensorflow/core/grappler/utils/frame.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/tensor_coding.h"
#include "tensorflow/core/util/device_name_utils.h"
#include "tensorflow/core/util/saved_tensor_slice_util.h"
using tensorflow::strings::StrCat;
namespace tensorflow {
namespace grappler {
namespace {
class LoopInvariantNodeMotionOptimizer {
public:
explicit LoopInvariantNodeMotionOptimizer(GraphDef* optimized_graph)
: optimized_graph_(optimized_graph) {}
virtual ~LoopInvariantNodeMotionOptimizer() = default;
Status Optimize();
private:
Status FindInvariantNodes(NodeDef* node);
Status RevertInvariantNodes();
Status MoveInvariantNodes(const int frame_id);
Status HandleInvariantNode(NodeDef* node, const int num_outputs,
const int frame_id);
Status HandleConst(NodeDef* node, const int num_outputs, const int frame_id);
Status HandleInvariantEnter(NodeDef* node, const int num_outputs);
GraphDef* optimized_graph_; // Not owned.
std::unique_ptr<NodeMap> node_map_;
std::map<NodeDef*, int> invariant_nodes_;
std::set<int> empty_set_;
// TODO(rmlarsen): Use vector instead of map, since frames ids are dense.
std::map<int, std::set<int>> frame_children_;
std::map<int, int> frame_parent_;
std::map<int, const NodeDef*> loop_cond_;
std::map<int, std::vector<NodeDef*>> invariant_enters_;
int new_enter_id_;
};
Status LoopInvariantNodeMotionOptimizer::HandleInvariantEnter(
NodeDef* node, const int num_outputs) {
auto consumers = node_map_->GetOutputs(node->name());
std::vector<string> enter_control_inputs;
string enter_input;
for (auto& input : node->input()) {
if (IsControlInput(input)) {
enter_control_inputs.push_back(input);
} else {
enter_input = input;
}
}
for (auto* consumer : consumers) {
if (invariant_nodes_.count(consumer)) {
for (int i = 0; i < consumer->input_size(); ++i) {
if (NodeName(consumer->input(i)) == node->name()) {
consumer->set_input(i, enter_input);
node_map_->AddOutput(NodeName(enter_input), consumer->name());
node_map_->RemoveOutput(node->name(), consumer->name());
}
}
for (auto& control_input : enter_control_inputs) {
consumer->add_input(control_input);
node_map_->AddOutput(NodeName(control_input), consumer->name());
}
}
}
return Status::OK();
}
Status LoopInvariantNodeMotionOptimizer::HandleConst(NodeDef* node,
const int num_outputs,
const int frame_id) {
NodeDef* const_node = nullptr;
if (num_outputs == 0) {
// all successor nodes are invariant
// Remove the control inputs from this frame to the const node,
// when moving it out of the frame (in parent frame)
const_node = node;
node_map_->RemoveInputs(node->name());
node->clear_input();
} else {
// some successor nodes are variant
// Have to keep the const node in the frame,
// so create a new one outside the frame (in parent frame)
const string const_node_name =
AddPrefixToNodeName(node->name(), kLoopOptimizer);
const_node = node_map_->GetNode(const_node_name);
if (const_node == nullptr) {
const_node = optimized_graph_->add_node();
const_node->set_name(const_node_name);
const_node->set_op("Const");
const_node->set_device(node->device());
*const_node->mutable_attr() = node->attr();
node_map_->AddNode(const_node->name(), const_node);
}
auto consumers = node_map_->GetOutputs(node->name());
for (auto* consumer : consumers) {
if (invariant_nodes_.count(consumer)) {
for (int i = 0; i < consumer->input_size(); ++i) {
if (NodeName(consumer->input(i)) == node->name()) {
if (IsControlInput(consumer->input(i))) {
*consumer->mutable_input(i) = AsControlDependency(*const_node);
} else {
*consumer->mutable_input(i) = const_node->name();
}
node_map_->AddOutput(const_node->name(), consumer->name());
node_map_->RemoveOutput(node->name(), consumer->name());
}
}
}
}
}
// add a control input from the parent frame
auto parent_it = frame_parent_.find(frame_id);
if (parent_it != frame_parent_.end()) {
int parent_id = parent_it->second;
auto loop_cond_it = loop_cond_.find(parent_id);
if (loop_cond_it == loop_cond_.end()) {
return errors::InvalidArgument("Frame ", frame_id,
" doesn't have a LoopCond node");
}
auto& loop_cond_name = loop_cond_it->second->name();
NodeDef* switch_node = nullptr;
for (auto* node : node_map_->GetOutputs(loop_cond_name)) {
if (node->op() == "Switch") {
switch_node = node;
break;
}
}
if (!switch_node) {
return errors::InvalidArgument("LoopCond node of Frame ", frame_id,
" doesn't connect to any Switch node");
}
string switch_output = StrCat(switch_node->name(), ":1");
const string ctrl_dep = ConstantFolding::AddControlDependency(
switch_output, optimized_graph_, node_map_.get());
const_node->add_input(ctrl_dep);
node_map_->AddOutput(NodeName(ctrl_dep), const_node->name());
}
return Status::OK();
}
Status LoopInvariantNodeMotionOptimizer::HandleInvariantNode(
NodeDef* node, const int num_outputs, const int frame_id) {
// have to remove control inputs to the invariant node from the same frame
// when moving this node out of this frame
for (int i = 0; i < node->input_size(); ++i) {
if (IsControlInput(node->input(i))) {
node->mutable_input()->SwapElements(i, node->input_size() - 1);
node->mutable_input()->RemoveLast();
}
}
if (num_outputs == 0) {
return Status::OK();
}
DataTypeVector input_types;
DataTypeVector output_types;
OpRegistryInterface* op_registry = OpRegistry::Global();
const OpRegistrationData* op_reg_data = nullptr;
TF_RETURN_IF_ERROR(op_registry->LookUp(node->op(), &op_reg_data));
TF_RETURN_IF_ERROR(InOutTypesForNode(*node, op_reg_data->op_def, &input_types,
&output_types));
auto consumers = node_map_->GetOutputs(node->name());
string fname = invariant_enters_[frame_id][0]->attr().at("frame_name").s();
int piterations =
invariant_enters_[frame_id][0]->attr().at("parallel_iterations").i();
for (auto* consumer : consumers) {
if (!invariant_nodes_.count(consumer)) {
for (int i = 0; i < consumer->input_size(); ++i) {
int port;
string node_name = ParseNodeName(consumer->input(i), &port);
if (node_name != node->name()) {
continue;
}
if (port < 0) {
return errors::InvalidArgument(
"Invariant node should not have control outputs "
"to variant node");
}
DataType output_type = output_types[port];
NodeDef* new_enter = optimized_graph_->add_node();
new_enter->set_op("Enter");
new_enter->set_device(node->device());
new_enter->set_name(AddPrefixToNodeName(
StrCat(fname, "_enter_", new_enter_id_++), kLoopOptimizer));
AttrValue data_type;
data_type.set_type(output_type);
new_enter->mutable_attr()->insert({"T", data_type});
AttrValue frame_name;
frame_name.set_s(fname);
new_enter->mutable_attr()->insert({"frame_name", frame_name});
AttrValue is_const;
is_const.set_b(true);
new_enter->mutable_attr()->insert({"is_constant", is_const});
AttrValue parallel_iterations;
parallel_iterations.set_i(piterations);
new_enter->mutable_attr()->insert(
{"parallel_iterations", parallel_iterations});
new_enter->add_input(consumer->input(i));
*consumer->mutable_input(i) = new_enter->name();
node_map_->AddNode(new_enter->name(), new_enter);
node_map_->AddOutput(node->name(), new_enter->name());
node_map_->AddOutput(new_enter->name(), consumer->name());
}
}
}
return Status::OK();
}
Status LoopInvariantNodeMotionOptimizer::MoveInvariantNodes(
const int frame_id) {
for (auto iter = invariant_nodes_.begin(); iter != invariant_nodes_.end();
++iter) {
auto* invariant_node = iter->first;
const int num_outputs = iter->second;
if (IsEnter(*invariant_node)) {
TF_RETURN_IF_ERROR(HandleInvariantEnter(invariant_node, num_outputs));
} else if (IsConstant(*invariant_node)) {
TF_RETURN_IF_ERROR(HandleConst(invariant_node, num_outputs, frame_id));
} else {
TF_RETURN_IF_ERROR(
HandleInvariantNode(invariant_node, num_outputs, frame_id));
}
}
return Status::OK();
}
Status LoopInvariantNodeMotionOptimizer::RevertInvariantNodes() {
std::deque<const NodeDef*> reverted_nodes;
for (auto iter = invariant_nodes_.begin(); iter != invariant_nodes_.end();) {
bool erased = false;
const auto* node = iter->first;
if (!IsConstant(*node) && !IsEnter(*node) && iter->second > 0) {
auto& consumers = node_map_->GetOutputs(node->name());
for (auto* consumer : consumers) {
if (!invariant_nodes_.count(consumer)) {
for (const auto& input : consumer->input()) {
if (IsControlInput(input) && NodeName(input) == node->name()) {
reverted_nodes.push_back(node);
invariant_nodes_.erase(iter++);
erased = true;
break;
}
}
if (erased) break;
}
}
}
if (!erased) ++iter;
}
while (!reverted_nodes.empty()) {
const auto* node = reverted_nodes.front();
reverted_nodes.pop_front();
std::set<NodeDef*> producers;
for (const auto& input : node->input()) {
auto* producer = node_map_->GetNode(input);
auto iter = invariant_nodes_.find(producer);
if (iter != invariant_nodes_.end()) {
if (IsControlInput(input) && !IsConstant(*producer) &&
!IsEnter(*producer)) {
reverted_nodes.push_back(producer);
invariant_nodes_.erase(iter);
} else {
producers.insert(producer);
}
}
}
for (auto* producer : producers) {
auto iter = invariant_nodes_.find(producer);
if (iter != invariant_nodes_.end()) {
++iter->second;
}
}
for (auto* consumer : node_map_->GetOutputs(node->name())) {
auto iter = invariant_nodes_.find(consumer);
if (iter != invariant_nodes_.end()) {
reverted_nodes.push_back(consumer);
invariant_nodes_.erase(iter);
}
}
}
return Status::OK();
}
Status LoopInvariantNodeMotionOptimizer::FindInvariantNodes(NodeDef* node) {
auto consumers = node_map_->GetOutputs(node->name());
invariant_nodes_.insert(std::make_pair(node, consumers.size()));
for (auto* consumer : consumers) {
if (invariant_nodes_.count(consumer) || ModifiesFrameInfo(*consumer)) {
continue;
}
bool is_invariant = true;
for (const auto& input : consumer->input()) {
if (!IsControlInput(input)) {
const string name = NodeName(input);
auto* producer = node_map_->GetNode(name);
if (!invariant_nodes_.count(producer)) {
if (IsConstant(*producer)) {
invariant_nodes_.insert(
std::make_pair(producer, node_map_->GetOutputs(name).size()));
} else {
is_invariant = false;
break;
}
}
}
}
if (is_invariant) {
std::set<NodeDef*> producers;
for (const auto& input : consumer->input()) {
auto* producer = node_map_->GetNode(input);
producers.insert(producer);
}
for (auto* producer : producers) {
auto iter = invariant_nodes_.find(producer);
if (iter != invariant_nodes_.end()) {
--iter->second;
}
}
TF_RETURN_IF_ERROR(FindInvariantNodes(consumer));
}
}
return Status::OK();
}
Status LoopInvariantNodeMotionOptimizer::Optimize() {
node_map_.reset(new NodeMap(optimized_graph_));
FrameMap frame_map;
int num_frames;
TF_RETURN_IF_ERROR(IdentifyFramesWithNodeMap(*optimized_graph_, *node_map_,
&frame_map, &num_frames));
std::deque<int> worklist;
for (auto iter = frame_map.begin(); iter != frame_map.end(); ++iter) {
auto* node = iter->first;
auto& frame_ids = iter->second;
if (frame_ids.size() >= 3) {
for (unsigned int i = 1; i < frame_ids.size() - 1; ++i) {
frame_parent_[frame_ids[i]] = frame_ids[i - 1];
frame_children_[frame_ids[i]].insert(frame_ids[i + 1]);
}
}
if (frame_ids.size() >= 2) {
frame_children_[frame_ids[0]].insert(frame_ids[1]);
frame_parent_[frame_ids.back()] = frame_ids[frame_ids.size() - 2];
}
if (frame_ids.size() >= 1) {
frame_children_.insert(std::make_pair(frame_ids.back(), empty_set_));
if (node->op() == "LoopCond") {
if (loop_cond_.count(frame_ids.back())) {
return errors::InvalidArgument(
"Loop ", frame_ids.back(),
" has more than one LoopCond node: ", node->name(), " and ",
loop_cond_[frame_ids.back()]->name());
}
loop_cond_[frame_ids.back()] = node;
}
if (IsEnter(*node) && node->attr().at("is_constant").b()) {
invariant_enters_[frame_ids.back()].push_back(
const_cast<NodeDef*>(node));
}
}
}
for (auto it = frame_children_.begin(); it != frame_children_.end(); ++it) {
if (it->second.size() == 0) {
worklist.push_back(it->first);
}
}
while (!worklist.empty()) {
int frame_id = worklist.front();
new_enter_id_ = 0;
worklist.pop_front();
auto parent_it = frame_parent_.find(frame_id);
if (parent_it != frame_parent_.end()) {
int parent_id = parent_it->second;
frame_children_[parent_id].erase(frame_id);
if (frame_children_[parent_id].size() == 0) {
worklist.push_back(parent_id);
}
}
if (invariant_enters_[frame_id].empty()) {
continue;
}
invariant_nodes_.clear();
for (auto* enter : invariant_enters_[frame_id]) {
TF_RETURN_IF_ERROR(FindInvariantNodes(enter));
}
// revert invariant nodes that have control outputs to variant nodes
TF_RETURN_IF_ERROR(RevertInvariantNodes());
TF_RETURN_IF_ERROR(MoveInvariantNodes(frame_id));
}
return Status::OK();
}
std::vector<int> GetStackPushNodesToConvert(
const SimpleGraphView& graph_view,
const std::unordered_set<string>& nodes_to_preserve, int stack_node_idx) {
VLOG(1) << "Stack node: " << graph_view.graph()->node(stack_node_idx).name();
const std::unordered_set<string> op_types_to_traverse(
{"Stack", "StackV2", "Enter", "RefEnter", "Switch", "RefSwitch",
"Identity", "RefIdentity"});
std::vector<int> nodes_to_convert;
std::set<int> fanout;
graph_view.DepthFirstSearch(op_types_to_traverse, stack_node_idx, &fanout);
for (int fanout_idx : fanout) {
const NodeDef& fanout_node = graph_view.graph()->node(fanout_idx);
VLOG(1) << "Fanout " << fanout_idx << " : " << fanout_node.name();
if (IsStackPushOp(fanout_node)) {
nodes_to_convert.push_back(fanout_idx);
} else if (IsStackOp(fanout_node) || IsStackCloseOp(fanout_node) ||
op_types_to_traverse.find(fanout_node.op()) !=
op_types_to_traverse.end()) {
continue;
} else if (!IsStackPopOp(fanout_node) ||
(!graph_view.outputs(fanout_idx).empty() ||
nodes_to_preserve.find(fanout_node.name()) !=
nodes_to_preserve.end())) {
// The node is either a stack pop with consumers or something unexpected
// so we leave the graph alone.
nodes_to_convert.clear();
break;
}
}
return nodes_to_convert;
}
Status RemoveStackOps(const GrapplerItem& item, GraphDef* optimized_graph) {
const std::unordered_set<string> nodes_to_preserve = item.NodesToPreserve();
const GraphDef& graph = item.graph;
*optimized_graph = graph;
NodeMap node_map(optimized_graph);
SimpleGraphView graph_view;
TF_RETURN_IF_ERROR(graph_view.Initialize(graph));
for (int node_idx = 0; node_idx < graph.node_size(); ++node_idx) {
if (IsStackOp(graph.node(node_idx))) {
for (int push_node_idx : GetStackPushNodesToConvert(
graph_view, nodes_to_preserve, node_idx)) {
// We found push nodes without corresponding pops. Convert them to
// Identity passing the data through and add a control dependency from
// the op supplying the stack handle.
NodeDef* push_node = optimized_graph->mutable_node(push_node_idx);
VLOG(1) << "Converting " << push_node_idx << " : "
<< push_node->DebugString();
if (push_node->attr().count("swap_memory") != 0) {
push_node->mutable_attr()->erase("swap_memory");
}
push_node->set_op("Identity");
push_node->mutable_input()->SwapElements(0, 1);
const string ctrl_dep = ConstantFolding::AddControlDependency(
push_node->input(1), optimized_graph, &node_map);
push_node->set_input(1, ctrl_dep);
VLOG(1) << "After converting: " << push_node->DebugString();
}
}
}
return Status::OK();
}
} // namespace
Status LoopOptimizer::Optimize(Cluster* cluster, const GrapplerItem& item,
GraphDef* optimized_graph) {
*optimized_graph = item.graph;
// Set up helper data structures.
if (options_.enable_loop_invariant_node_motion) {
LoopInvariantNodeMotionOptimizer linm_optimizer(optimized_graph);
TF_RETURN_IF_ERROR(linm_optimizer.Optimize());
}
if (options_.enable_stack_push_removal) {
TF_RETURN_IF_ERROR(RemoveStackOps(item, optimized_graph));
}
return Status::OK();
}
void LoopOptimizer::Feedback(Cluster* /*cluster*/, const GrapplerItem& /*item*/,
const GraphDef& /*optimized_graph*/,
double /*result*/) {
// Nothing to do for LoopOptimizer.
}
} // end namespace grappler
} // end namespace tensorflow
|
; A097017: a(n) = sigma(5*n) modulo 6.
; 0,0,0,0,1,0,0,0,0,3,0,0,0,0,4,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,3,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,3,0,0,0,0,2,0,0,0,0,0
seq $0,283118 ; a(n) = sigma(5*n).
mod $0,6
|
copyright zengfr site:http://github.com/zengfr/romhack
0039F6 movem.l D0-D3, -(A6)
0039FA movem.l D0-D3, -(A6)
006222 move.b ($b,A3), ($62,A4) [boss+36, container+36, enemy+36]
006228 move.b ($c,A3), ($60,A4)
009ACA dbra D5, $9ac8
copyright zengfr site:http://github.com/zengfr/romhack
|
_start:
sub sp, sp, #0x20
stp x29, x30, [sp, #0x10]
add x29, sp, #0x10
mov x0, #16
loop:
subs x0, x0, #1
b.ne loop
ldp x29, x30, [sp, #0x10]
add sp, sp, #0x20
ret
|
; A320431: The number of tiles inside a regular n-gon created by lines that run from each of the vertices of the n edges orthogonal to these edges.
; 1,1,31,13,71,25,127,41,199,61,287,85,391,113,511,145,647,181,799,221,967,265,1151,313,1351,365,1567,421,1799,481,2047,545,2311,613,2591,685,2887,761,3199,841,3527,925,3871,1013,4231,1105,4607,1201,4999,1301,5407,1405,5831,1513,6271,1625,6727,1741
lpb $0
mov $1,$0
cal $1,70260 ; Third diagonal of triangle defined in A051537.
mod $0,2
lpe
mul $1,2
add $1,1
|
; Master thesis
; by Alf-Andre Walla 2016-2017
ORG 0x8000
%define code32_segment 0x08
%define data32_segment 0x10
%define SOFT_RESET_MAGIC 0xFEE1DEAD
[BITS 64]
ALIGN 16
;; first six pointer arguments are passed in
;; RDI, RSI, RDX, RCX, R8, and R9
;; hotswap64(
;; RDI: char* dest,
;; RSI: const char* base,
;; RDX: size_t len,
;; RCX: void* entry_function,
;; R8: void* reset_data,
;; R9: void* zero_until)
hotswap_amd64:
;; save soft reset data location and entry function
mov rax, r8
mov [startaddr], ecx ; rcx
mov [bootaddr], eax ; r8
;; hotswap 64-bit kernel
;; source: RSI
;; dest: RDI
mov rcx, rdx ;; count
cld
rep movsb
;; memzero area between kernel and end of heap
cmp r9, 0 ;; ... but only if r9 != 0
jz begin_enter_protected
mov rcx, r9 ;; rdi = kernel_end, r9 = zero_until
sub rcx, rdi ;; set rcx = zero_until - kernel_end
mov rax, 0 ;; memzero
rep stosb
begin_enter_protected:
; load 64-bit GDTR with 32-bit entries
lgdt [gdtr64]
; enter compatibility mode
push data32_segment
push rsp
pushf
push code32_segment
mov ecx, compatibility_mode
push rcx
iretq
startaddr: dd 0
bootaddr: dd 0
[BITS 32]
ALIGN 16
compatibility_mode:
; disable paging
mov ecx, cr0
and ecx, 0x7fffffff ;; clear PG (bit 31)
mov cr0, ecx
; disable LM
mov ecx, 0xC0000080 ; EFER MSR
rdmsr
and eax, ~(1 << 8) ; remove LM-bit
wrmsr
;; enter 32-bit protected mode
jmp code32_segment:protected_mode
protected_mode:
mov cx, data32_segment
mov ss, cx
mov ds, cx
mov es, cx
mov fs, cx
mov gs, cx
;;rdtsc
;;mov DWORD [0x10000], eax
;;mov DWORD [0x10004], edx
;; enter the new service from its entry point
;; in 32-bit protected mode, while passing
;; multiboot parameters in eax and ebx
mov eax, SOFT_RESET_MAGIC
mov ebx, [bootaddr]
jmp DWORD [startaddr]
gdtr:
dw gdt32_end - gdt32 - 1
dd gdt32
gdt32:
;; Entry 0x0: Null descriptor
dq 0x0
;; Entry 0x18: 32-bit Code segment
dw 0xffff ;Limit
dw 0x0000 ;Base 15:00
db 0x00 ;Base 23:16
dw 0xcf9a ;Flags / Limit / Type [F,L,F,Type]
db 0x00 ;Base 32:24
;; Entry 0x20: 32-bit Data segment
dw 0xffff ;Limit
dw 0x0000 ;Base 15:00
db 0x00 ;Base 23:16
dw 0xcf92 ;Flags / Limit / Type [F,L,F,Type]
db 0x00 ;Base 32:24
gdt32_end:
gdtr64:
dw $ - gdt32 - 1 ; Limit
dq gdt32 ; Base
|
//===--- Selection.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Selection.h"
#include "Logger.h"
#include "SourceCode.h"
#include "clang/AST/ASTTypeTraits.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/TypeLoc.h"
#include "clang/Basic/OperatorKinds.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Lex/Lexer.h"
#include "clang/Tooling/Syntax/Tokens.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <string>
namespace clang {
namespace clangd {
namespace {
using Node = SelectionTree::Node;
using ast_type_traits::DynTypedNode;
// An IntervalSet maintains a set of disjoint subranges of an array.
//
// Initially, it contains the entire array.
// [-----------------------------------------------------------]
//
// When a range is erased(), it will typically split the array in two.
// Claim: [--------------------]
// after: [----------------] [-------------------]
//
// erase() returns the segments actually erased. Given the state above:
// Claim: [---------------------------------------]
// Out: [---------] [------]
// After: [-----] [-----------]
//
// It is used to track (expanded) tokens not yet associated with an AST node.
// On traversing an AST node, its token range is erased from the unclaimed set.
// The tokens actually removed are associated with that node, and hit-tested
// against the selection to determine whether the node is selected.
template <typename T>
class IntervalSet {
public:
IntervalSet(llvm::ArrayRef<T> Range) { UnclaimedRanges.insert(Range); }
// Removes the elements of Claim from the set, modifying or removing ranges
// that overlap it.
// Returns the continuous subranges of Claim that were actually removed.
llvm::SmallVector<llvm::ArrayRef<T>, 4> erase(llvm::ArrayRef<T> Claim) {
llvm::SmallVector<llvm::ArrayRef<T>, 4> Out;
if (Claim.empty())
return Out;
// General case:
// Claim: [-----------------]
// UnclaimedRanges: [-A-] [-B-] [-C-] [-D-] [-E-] [-F-] [-G-]
// Overlap: ^first ^second
// Ranges C and D are fully included. Ranges B and E must be trimmed.
auto Overlap = std::make_pair(
UnclaimedRanges.lower_bound({Claim.begin(), Claim.begin()}), // C
UnclaimedRanges.lower_bound({Claim.end(), Claim.end()})); // F
// Rewind to cover B.
if (Overlap.first != UnclaimedRanges.begin()) {
--Overlap.first;
// ...unless B isn't selected at all.
if (Overlap.first->end() <= Claim.begin())
++Overlap.first;
}
if (Overlap.first == Overlap.second)
return Out;
// First, copy all overlapping ranges into the output.
auto OutFirst = Out.insert(Out.end(), Overlap.first, Overlap.second);
// If any of the overlapping ranges were sliced by the claim, split them:
// - restrict the returned range to the claimed part
// - save the unclaimed part so it can be reinserted
llvm::ArrayRef<T> RemainingHead, RemainingTail;
if (Claim.begin() > OutFirst->begin()) {
RemainingHead = {OutFirst->begin(), Claim.begin()};
*OutFirst = {Claim.begin(), OutFirst->end()};
}
if (Claim.end() < Out.back().end()) {
RemainingTail = {Claim.end(), Out.back().end()};
Out.back() = {Out.back().begin(), Claim.end()};
}
// Erase all the overlapping ranges (invalidating all iterators).
UnclaimedRanges.erase(Overlap.first, Overlap.second);
// Reinsert ranges that were merely trimmed.
if (!RemainingHead.empty())
UnclaimedRanges.insert(RemainingHead);
if (!RemainingTail.empty())
UnclaimedRanges.insert(RemainingTail);
return Out;
}
private:
using TokenRange = llvm::ArrayRef<T>;
struct RangeLess {
bool operator()(llvm::ArrayRef<T> L, llvm::ArrayRef<T> R) const {
return L.begin() < R.begin();
}
};
// Disjoint sorted unclaimed ranges of expanded tokens.
std::set<llvm::ArrayRef<T>, RangeLess>
UnclaimedRanges;
};
// Sentinel value for the selectedness of a node where we've seen no tokens yet.
// This resolves to Unselected if no tokens are ever seen.
// But Unselected + Complete -> Partial, while NoTokens + Complete --> Complete.
// This value is never exposed publicly.
constexpr SelectionTree::Selection NoTokens =
static_cast<SelectionTree::Selection>(
static_cast<unsigned char>(SelectionTree::Complete + 1));
// Nodes start with NoTokens, and then use this function to aggregate the
// selectedness as more tokens are found.
void update(SelectionTree::Selection &Result, SelectionTree::Selection New) {
if (New == NoTokens)
return;
if (Result == NoTokens)
Result = New;
else if (Result != New)
// Can only be completely selected (or unselected) if all tokens are.
Result = SelectionTree::Partial;
}
// SelectionTester can determine whether a range of tokens from the PP-expanded
// stream (corresponding to an AST node) is considered selected.
//
// When the tokens result from macro expansions, the appropriate tokens in the
// main file are examined (macro invocation or args). Similarly for #includes.
//
// It tests each token in the range (not just the endpoints) as contiguous
// expanded tokens may not have contiguous spellings (with macros).
//
// Non-token text, and tokens not modeled in the AST (comments, semicolons)
// are ignored when determining selectedness.
class SelectionTester {
public:
// The selection is offsets [SelBegin, SelEnd) in SelFile.
SelectionTester(const syntax::TokenBuffer &Buf, FileID SelFile,
unsigned SelBegin, unsigned SelEnd, const SourceManager &SM)
: SelFile(SelFile), SM(SM) {
// Find all tokens (partially) selected in the file.
auto AllSpelledTokens = Buf.spelledTokens(SelFile);
const syntax::Token *SelFirst =
llvm::partition_point(AllSpelledTokens, [&](const syntax::Token &Tok) {
return SM.getFileOffset(Tok.endLocation()) <= SelBegin;
});
const syntax::Token *SelLimit = std::partition_point(
SelFirst, AllSpelledTokens.end(), [&](const syntax::Token &Tok) {
return SM.getFileOffset(Tok.location()) < SelEnd;
});
// Precompute selectedness and offset for selected spelled tokens.
for (const syntax::Token *T = SelFirst; T < SelLimit; ++T) {
// As well as comments, don't count semicolons as real tokens.
// They're not properly claimed as expr-statement is missing from the AST.
if (T->kind() == tok::comment || T->kind() == tok::semi)
continue;
SpelledTokens.emplace_back();
Tok &S = SpelledTokens.back();
S.Offset = SM.getFileOffset(T->location());
if (S.Offset >= SelBegin && S.Offset + T->length() <= SelEnd)
S.Selected = SelectionTree::Complete;
else
S.Selected = SelectionTree::Partial;
}
}
// Test whether a consecutive range of tokens is selected.
// The tokens are taken from the expanded token stream.
SelectionTree::Selection
test(llvm::ArrayRef<syntax::Token> ExpandedTokens) const {
if (SpelledTokens.empty())
return NoTokens;
SelectionTree::Selection Result = NoTokens;
while (!ExpandedTokens.empty()) {
// Take consecutive tokens from the same context together for efficiency.
FileID FID = SM.getFileID(ExpandedTokens.front().location());
auto Batch = ExpandedTokens.take_while([&](const syntax::Token &T) {
return SM.getFileID(T.location()) == FID;
});
assert(!Batch.empty());
ExpandedTokens = ExpandedTokens.drop_front(Batch.size());
update(Result, testChunk(FID, Batch));
}
return Result;
}
// Cheap check whether any of the tokens in R might be selected.
// If it returns false, test() will return NoTokens or Unselected.
// If it returns true, test() may return any value.
bool mayHit(SourceRange R) const {
if (SpelledTokens.empty())
return false;
auto B = SM.getDecomposedLoc(R.getBegin());
auto E = SM.getDecomposedLoc(R.getEnd());
if (B.first == SelFile && E.first == SelFile)
if (E.second < SpelledTokens.front().Offset ||
B.second > SpelledTokens.back().Offset)
return false;
return true;
}
private:
// Hit-test a consecutive range of tokens from a single file ID.
SelectionTree::Selection
testChunk(FileID FID, llvm::ArrayRef<syntax::Token> Batch) const {
assert(!Batch.empty());
SourceLocation StartLoc = Batch.front().location();
// There are several possible categories of FileID depending on how the
// preprocessor was used to generate these tokens:
// main file, #included file, macro args, macro bodies.
// We need to identify the main-file tokens that represent Batch, and
// determine whether we want to exclusively claim them. Regular tokens
// represent one AST construct, but a macro invocation can represent many.
// Handle tokens written directly in the main file.
if (FID == SelFile) {
return testTokenRange(SM.getFileOffset(Batch.front().location()),
SM.getFileOffset(Batch.back().location()));
}
// Handle tokens in another file #included into the main file.
// Check if the #include is selected, but don't claim it exclusively.
if (StartLoc.isFileID()) {
for (SourceLocation Loc = Batch.front().location(); Loc.isValid();
Loc = SM.getIncludeLoc(SM.getFileID(Loc))) {
if (SM.getFileID(Loc) == SelFile)
// FIXME: use whole #include directive, not just the filename string.
return testToken(SM.getFileOffset(Loc));
}
return NoTokens;
}
assert(StartLoc.isMacroID());
// Handle tokens that were passed as a macro argument.
SourceLocation ArgStart = SM.getTopMacroCallerLoc(StartLoc);
if (SM.getFileID(ArgStart) == SelFile) {
SourceLocation ArgEnd = SM.getTopMacroCallerLoc(Batch.back().location());
return testTokenRange(SM.getFileOffset(ArgStart),
SM.getFileOffset(ArgEnd));
}
// Handle tokens produced by non-argument macro expansion.
// Check if the macro name is selected, don't claim it exclusively.
auto Expansion = SM.getDecomposedExpansionLoc(StartLoc);
if (Expansion.first == SelFile)
// FIXME: also check ( and ) for function-like macros?
return testToken(Expansion.second);
else
return NoTokens;
}
// Is the closed token range [Begin, End] selected?
SelectionTree::Selection testTokenRange(unsigned Begin, unsigned End) const {
assert(Begin <= End);
// Outside the selection entirely?
if (End < SpelledTokens.front().Offset ||
Begin > SpelledTokens.back().Offset)
return SelectionTree::Unselected;
// Compute range of tokens.
auto B = llvm::partition_point(
SpelledTokens, [&](const Tok &T) { return T.Offset < Begin; });
auto E = std::partition_point(
B, SpelledTokens.end(), [&](const Tok &T) { return T.Offset <= End; });
// Aggregate selectedness of tokens in range.
bool ExtendsOutsideSelection = Begin < SpelledTokens.front().Offset ||
End > SpelledTokens.back().Offset;
SelectionTree::Selection Result =
ExtendsOutsideSelection ? SelectionTree::Unselected : NoTokens;
for (auto It = B; It != E; ++It)
update(Result, It->Selected);
return Result;
}
// Is the token at `Offset` selected?
SelectionTree::Selection testToken(unsigned Offset) const {
// Outside the selection entirely?
if (Offset < SpelledTokens.front().Offset ||
Offset > SpelledTokens.back().Offset)
return SelectionTree::Unselected;
// Find the token, if it exists.
auto It = llvm::partition_point(
SpelledTokens, [&](const Tok &T) { return T.Offset < Offset; });
if (It != SpelledTokens.end() && It->Offset == Offset)
return It->Selected;
return NoTokens;
}
struct Tok {
unsigned Offset;
SelectionTree::Selection Selected;
};
std::vector<Tok> SpelledTokens;
FileID SelFile;
const SourceManager &SM;
};
// Show the type of a node for debugging.
void printNodeKind(llvm::raw_ostream &OS, const DynTypedNode &N) {
if (const TypeLoc *TL = N.get<TypeLoc>()) {
// TypeLoc is a hierarchy, but has only a single ASTNodeKind.
// Synthesize the name from the Type subclass (except for QualifiedTypeLoc).
if (TL->getTypeLocClass() == TypeLoc::Qualified)
OS << "QualifiedTypeLoc";
else
OS << TL->getType()->getTypeClassName() << "TypeLoc";
} else {
OS << N.getNodeKind().asStringRef();
}
}
#ifndef NDEBUG
std::string printNodeToString(const DynTypedNode &N, const PrintingPolicy &PP) {
std::string S;
llvm::raw_string_ostream OS(S);
printNodeKind(OS, N);
OS << " ";
return std::move(OS.str());
}
#endif
bool isImplicit(const Stmt* S) {
// Some Stmts are implicit and shouldn't be traversed, but there's no
// "implicit" attribute on Stmt/Expr.
// Unwrap implicit casts first if present (other nodes too?).
if (auto *ICE = llvm::dyn_cast<ImplicitCastExpr>(S))
S = ICE->getSubExprAsWritten();
// Implicit this in a MemberExpr is not filtered out by RecursiveASTVisitor.
// It would be nice if RAV handled this (!shouldTraverseImplicitCode()).
if (auto *CTI = llvm::dyn_cast<CXXThisExpr>(S))
if (CTI->isImplicit())
return true;
// Refs to operator() and [] are (almost?) always implicit as part of calls.
if (auto *DRE = llvm::dyn_cast<DeclRefExpr>(S)) {
if (auto *FD = llvm::dyn_cast<FunctionDecl>(DRE->getDecl())) {
switch (FD->getOverloadedOperator()) {
case OO_Call:
case OO_Subscript:
return true;
default:
break;
}
}
}
return false;
}
// We find the selection by visiting written nodes in the AST, looking for nodes
// that intersect with the selected character range.
//
// While traversing, we maintain a parent stack. As nodes pop off the stack,
// we decide whether to keep them or not. To be kept, they must either be
// selected or contain some nodes that are.
//
// For simple cases (not inside macros) we prune subtrees that don't intersect.
class SelectionVisitor : public RecursiveASTVisitor<SelectionVisitor> {
public:
// Runs the visitor to gather selected nodes and their ancestors.
// If there is any selection, the root (TUDecl) is the first node.
static std::deque<Node> collect(ASTContext &AST,
const syntax::TokenBuffer &Tokens,
const PrintingPolicy &PP, unsigned Begin,
unsigned End, FileID File) {
SelectionVisitor V(AST, Tokens, PP, Begin, End, File);
V.TraverseAST(AST);
assert(V.Stack.size() == 1 && "Unpaired push/pop?");
assert(V.Stack.top() == &V.Nodes.front());
return std::move(V.Nodes);
}
// We traverse all "well-behaved" nodes the same way:
// - push the node onto the stack
// - traverse its children recursively
// - pop it from the stack
// - hit testing: is intersection(node, selection) - union(children) empty?
// - attach it to the tree if it or any children hit the selection
//
// Two categories of nodes are not "well-behaved":
// - those without source range information, we don't record those
// - those that can't be stored in DynTypedNode.
// We're missing some interesting things like Attr due to the latter.
bool TraverseDecl(Decl *X) {
if (X && isa<TranslationUnitDecl>(X))
return Base::TraverseDecl(X); // Already pushed by constructor.
// Base::TraverseDecl will suppress children, but not this node itself.
if (X && X->isImplicit())
return true;
return traverseNode(X, [&] { return Base::TraverseDecl(X); });
}
bool TraverseTypeLoc(TypeLoc X) {
return traverseNode(&X, [&] { return Base::TraverseTypeLoc(X); });
}
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc X) {
return traverseNode(
&X, [&] { return Base::TraverseNestedNameSpecifierLoc(X); });
}
bool TraverseConstructorInitializer(CXXCtorInitializer *X) {
return traverseNode(
X, [&] { return Base::TraverseConstructorInitializer(X); });
}
// Stmt is the same, but this form allows the data recursion optimization.
bool dataTraverseStmtPre(Stmt *X) {
if (!X || isImplicit(X))
return false;
auto N = DynTypedNode::create(*X);
if (canSafelySkipNode(N))
return false;
push(std::move(N));
if (shouldSkipChildren(X)) {
pop();
return false;
}
return true;
}
bool dataTraverseStmtPost(Stmt *X) {
pop();
return true;
}
// QualifiedTypeLoc is handled strangely in RecursiveASTVisitor: the derived
// TraverseTypeLoc is not called for the inner UnqualTypeLoc.
// This means we'd never see 'int' in 'const int'! Work around that here.
// (The reason for the behavior is to avoid traversing the nested Type twice,
// but we ignore TraverseType anyway).
bool TraverseQualifiedTypeLoc(QualifiedTypeLoc QX) {
return traverseNode<TypeLoc>(
&QX, [&] { return TraverseTypeLoc(QX.getUnqualifiedLoc()); });
}
// Uninteresting parts of the AST that don't have locations within them.
bool TraverseNestedNameSpecifier(NestedNameSpecifier *) { return true; }
bool TraverseType(QualType) { return true; }
// The DeclStmt for the loop variable claims to cover the whole range
// inside the parens, this causes the range-init expression to not be hit.
// Traverse the loop VarDecl instead, which has the right source range.
bool TraverseCXXForRangeStmt(CXXForRangeStmt *S) {
return traverseNode(S, [&] {
return TraverseStmt(S->getInit()) && TraverseDecl(S->getLoopVariable()) &&
TraverseStmt(S->getRangeInit()) && TraverseStmt(S->getBody());
});
}
private:
using Base = RecursiveASTVisitor<SelectionVisitor>;
SelectionVisitor(ASTContext &AST, const syntax::TokenBuffer &Tokens,
const PrintingPolicy &PP, unsigned SelBegin, unsigned SelEnd,
FileID SelFile)
: SM(AST.getSourceManager()), LangOpts(AST.getLangOpts()),
#ifndef NDEBUG
PrintPolicy(PP),
#endif
TokenBuf(Tokens), SelChecker(Tokens, SelFile, SelBegin, SelEnd, SM),
UnclaimedExpandedTokens(Tokens.expandedTokens()) {
// Ensure we have a node for the TU decl, regardless of traversal scope.
Nodes.emplace_back();
Nodes.back().ASTNode = DynTypedNode::create(*AST.getTranslationUnitDecl());
Nodes.back().Parent = nullptr;
Nodes.back().Selected = SelectionTree::Unselected;
Stack.push(&Nodes.back());
}
// Generic case of TraverseFoo. Func should be the call to Base::TraverseFoo.
// Node is always a pointer so the generic code can handle any null checks.
template <typename T, typename Func>
bool traverseNode(T *Node, const Func &Body) {
if (Node == nullptr)
return true;
auto N = DynTypedNode::create(*Node);
if (canSafelySkipNode(N))
return true;
push(DynTypedNode::create(*Node));
bool Ret = Body();
pop();
return Ret;
}
// HIT TESTING
//
// We do rough hit testing on the way down the tree to avoid traversing
// subtrees that don't touch the selection (canSafelySkipNode), but
// fine-grained hit-testing is mostly done on the way back up (in pop()).
// This means children get to claim parts of the selection first, and parents
// are only selected if they own tokens that no child owned.
//
// Nodes *usually* nest nicely: a child's getSourceRange() lies within the
// parent's, and a node (transitively) owns all tokens in its range.
//
// Exception 1: child range claims tokens that should be owned by the parent.
// e.g. in `void foo(int);`, the FunctionTypeLoc should own
// `void (int)` but the parent FunctionDecl should own `foo`.
// To handle this case, certain nodes claim small token ranges *before*
// their children are traversed. (see earlySourceRange).
//
// Exception 2: siblings both claim the same node.
// e.g. `int x, y;` produces two sibling VarDecls.
// ~~~~~ x
// ~~~~~~~~ y
// Here the first ("leftmost") sibling claims the tokens it wants, and the
// other sibling gets what's left. So selecting "int" only includes the left
// VarDecl in the selection tree.
// An optimization for a common case: nodes outside macro expansions that
// don't intersect the selection may be recursively skipped.
bool canSafelySkipNode(const DynTypedNode &N) {
SourceRange S = N.getSourceRange();
if (!SelChecker.mayHit(S)) {
dlog("{1}skip: {0}", printNodeToString(N, PrintPolicy), indent());
dlog("{1}skipped range = {0}", S.printToString(SM), indent(1));
return true;
}
return false;
}
// There are certain nodes we want to treat as leaves in the SelectionTree,
// although they do have children.
bool shouldSkipChildren(const Stmt *X) const {
// UserDefinedLiteral (e.g. 12_i) has two children (12 and _i).
// Unfortunately TokenBuffer sees 12_i as one token and can't split it.
// So we treat UserDefinedLiteral as a leaf node, owning the token.
return llvm::isa<UserDefinedLiteral>(X);
}
// Pushes a node onto the ancestor stack. Pairs with pop().
// Performs early hit detection for some nodes (on the earlySourceRange).
void push(DynTypedNode Node) {
SourceRange Early = earlySourceRange(Node);
dlog("{1}push: {0}", printNodeToString(Node, PrintPolicy), indent());
Nodes.emplace_back();
Nodes.back().ASTNode = std::move(Node);
Nodes.back().Parent = Stack.top();
Nodes.back().Selected = NoTokens;
Stack.push(&Nodes.back());
claimRange(Early, Nodes.back().Selected);
}
// Pops a node off the ancestor stack, and finalizes it. Pairs with push().
// Performs primary hit detection.
void pop() {
Node &N = *Stack.top();
dlog("{1}pop: {0}", printNodeToString(N.ASTNode, PrintPolicy), indent(-1));
claimRange(N.ASTNode.getSourceRange(), N.Selected);
if (N.Selected == NoTokens)
N.Selected = SelectionTree::Unselected;
if (N.Selected || !N.Children.empty()) {
// Attach to the tree.
N.Parent->Children.push_back(&N);
} else {
// Neither N any children are selected, it doesn't belong in the tree.
assert(&N == &Nodes.back());
Nodes.pop_back();
}
Stack.pop();
}
// Returns the range of tokens that this node will claim directly, and
// is not available to the node's children.
// Usually empty, but sometimes children cover tokens but shouldn't own them.
SourceRange earlySourceRange(const DynTypedNode &N) {
if (const Decl *D = N.get<Decl>()) {
// void [[foo]]();
if (auto *FD = llvm::dyn_cast<FunctionDecl>(D))
return FD->getNameInfo().getSourceRange();
// int (*[[s]])();
else if (auto *VD = llvm::dyn_cast<VarDecl>(D))
return VD->getLocation();
} else if (const auto* CCI = N.get<CXXCtorInitializer>()) {
// : [[b_]](42)
return CCI->getMemberLocation();
}
return SourceRange();
}
// Perform hit-testing of a complete Node against the selection.
// This runs for every node in the AST, and must be fast in common cases.
// This is usually called from pop(), so we can take children into account.
// The existing state of Result is relevant (early/late claims can interact).
void claimRange(SourceRange S, SelectionTree::Selection &Result) {
for (const auto &ClaimedRange :
UnclaimedExpandedTokens.erase(TokenBuf.expandedTokens(S)))
update(Result, SelChecker.test(ClaimedRange));
if (Result && Result != NoTokens)
dlog("{1}hit selection: {0}", S.printToString(SM), indent());
}
std::string indent(int Offset = 0) {
// Cast for signed arithmetic.
int Amount = int(Stack.size()) + Offset;
assert(Amount >= 0);
return std::string(Amount, ' ');
}
SourceManager &SM;
const LangOptions &LangOpts;
#ifndef NDEBUG
const PrintingPolicy &PrintPolicy;
#endif
const syntax::TokenBuffer &TokenBuf;
std::stack<Node *> Stack;
SelectionTester SelChecker;
IntervalSet<syntax::Token> UnclaimedExpandedTokens;
std::deque<Node> Nodes; // Stable pointers as we add more nodes.
};
} // namespace
void SelectionTree::print(llvm::raw_ostream &OS, const SelectionTree::Node &N,
int Indent) const {
if (N.Selected)
OS.indent(Indent - 1) << (N.Selected == SelectionTree::Complete ? '*'
: '.');
else
OS.indent(Indent);
printNodeKind(OS, N.ASTNode);
OS << ' ';
N.ASTNode.print(OS, PrintPolicy);
OS << "\n";
for (const Node *Child : N.Children)
print(OS, *Child, Indent + 2);
}
std::string SelectionTree::Node::kind() const {
std::string S;
llvm::raw_string_ostream OS(S);
printNodeKind(OS, ASTNode);
return std::move(OS.str());
}
// Decide which selection emulates a "point" query in between characters.
static std::pair<unsigned, unsigned> pointBounds(unsigned Offset, FileID FID,
ASTContext &AST) {
StringRef Buf = AST.getSourceManager().getBufferData(FID);
// Edge-cases where the choice is forced.
if (Buf.size() == 0)
return {0, 0};
if (Offset == 0)
return {0, 1};
if (Offset == Buf.size())
return {Offset - 1, Offset};
// We could choose either this byte or the previous. Usually we prefer the
// character on the right of the cursor (or under a block cursor).
// But if that's whitespace/semicolon, we likely want the token on the left.
auto IsIgnoredChar = [](char C) { return isWhitespace(C) || C == ';'; };
if (IsIgnoredChar(Buf[Offset]) && !IsIgnoredChar(Buf[Offset - 1]))
return {Offset - 1, Offset};
return {Offset, Offset + 1};
}
SelectionTree::SelectionTree(ASTContext &AST, const syntax::TokenBuffer &Tokens,
unsigned Begin, unsigned End)
: PrintPolicy(AST.getLangOpts()) {
// No fundamental reason the selection needs to be in the main file,
// but that's all clangd has needed so far.
const SourceManager &SM = AST.getSourceManager();
FileID FID = SM.getMainFileID();
if (Begin == End)
std::tie(Begin, End) = pointBounds(Begin, FID, AST);
PrintPolicy.TerseOutput = true;
PrintPolicy.IncludeNewlines = false;
dlog("Computing selection for {0}",
SourceRange(SM.getComposedLoc(FID, Begin), SM.getComposedLoc(FID, End))
.printToString(SM));
Nodes = SelectionVisitor::collect(AST, Tokens, PrintPolicy, Begin, End, FID);
Root = Nodes.empty() ? nullptr : &Nodes.front();
dlog("Built selection tree\n{0}", *this);
}
SelectionTree::SelectionTree(ASTContext &AST, const syntax::TokenBuffer &Tokens,
unsigned Offset)
: SelectionTree(AST, Tokens, Offset, Offset) {}
const Node *SelectionTree::commonAncestor() const {
const Node *Ancestor = Root;
while (Ancestor->Children.size() == 1 && !Ancestor->Selected)
Ancestor = Ancestor->Children.front();
// Returning nullptr here is a bit unprincipled, but it makes the API safer:
// the TranslationUnitDecl contains all of the preamble, so traversing it is a
// performance cliff. Callers can check for null and use root() if they want.
return Ancestor != Root ? Ancestor : nullptr;
}
const DeclContext& SelectionTree::Node::getDeclContext() const {
for (const Node* CurrentNode = this; CurrentNode != nullptr;
CurrentNode = CurrentNode->Parent) {
if (const Decl* Current = CurrentNode->ASTNode.get<Decl>()) {
if (CurrentNode != this)
if (auto *DC = dyn_cast<DeclContext>(Current))
return *DC;
return *Current->getDeclContext();
}
}
llvm_unreachable("A tree must always be rooted at TranslationUnitDecl.");
}
const SelectionTree::Node &SelectionTree::Node::ignoreImplicit() const {
if (Children.size() == 1 &&
Children.front()->ASTNode.getSourceRange() == ASTNode.getSourceRange())
return Children.front()->ignoreImplicit();
return *this;
}
const SelectionTree::Node &SelectionTree::Node::outerImplicit() const {
if (Parent && Parent->ASTNode.getSourceRange() == ASTNode.getSourceRange())
return Parent->outerImplicit();
return *this;
}
} // namespace clangd
} // namespace clang
|
; A142124: Primes congruent to 15 mod 37.
; Submitted by Jon Maiga
; 89,163,311,607,829,977,1051,2087,2161,2309,2383,2531,2753,3049,3271,3863,4159,4603,4751,4973,5417,5639,5861,6379,6823,6971,7193,7489,7933,8081,8377,8599,8747,8821,8969,9043,9413,9857,9931,10079,10301,10597,11411,11633,12373,12743,13187,14149,14519,14593,14741,15259,15629,16073,16369,17183,17257,17627,17923,18367,18959,19181,19403,19477,19699,20143,20809,21031,21179,21401,22067,22511,22807,23029,23251,23399,23473,23917,24509,24953,25471,25693,25841,26729,26951,27617,27691,28283,28579,28949,29023
mov $1,14
mov $2,$0
add $2,2
pow $2,2
lpb $2
sub $2,1
mov $3,$1
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,37
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
mov $0,$1
sub $0,36
|
; A103391: 'Even' fractal sequence for the natural numbers: Deleting every even-index term results in the same sequence.
; 1,2,2,3,2,4,3,5,2,6,4,7,3,8,5,9,2,10,6,11,4,12,7,13,3,14,8,15,5,16,9,17,2,18,10,19,6,20,11,21,4,22,12,23,7,24,13,25,3,26,14,27,8,28,15,29,5,30,16,31,9,32,17,33,2,34,18,35,10,36,19,37,6,38,20,39,11,40,21,41,4,42,22,43,12,44,23,45,7,46,24,47,13,48,25,49,3,50,26,51
lpb $0
dif $0,2
lpe
add $0,3
div $0,2
|
;;
;; Copyright (c) 2012-2018, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%define AES_CBC_ENC_X8 aes_cbc_enc_256_x8
%define FLUSH_JOB_AES_ENC flush_job_aes256_enc_avx
%include "avx/mb_mgr_aes_flush_avx.asm"
|
#include "indexmanager.h"
|
; A048488: a(n) = 6*2^n - 5.
; 1,7,19,43,91,187,379,763,1531,3067,6139,12283,24571,49147,98299,196603,393211,786427,1572859,3145723,6291451,12582907,25165819,50331643,100663291,201326587,402653179,805306363,1610612731,3221225467,6442450939,12884901883,25769803771,51539607547,103079215099,206158430203,412316860411,824633720827,1649267441659,3298534883323,6597069766651,13194139533307,26388279066619,52776558133243,105553116266491,211106232532987,422212465065979,844424930131963,1688849860263931,3377699720527867,6755399441055739
mov $1,2
pow $1,$0
mul $1,6
sub $1,5
mov $0,$1
|
#include "color.h"
#include <assert.h>
#include <ncurses.h>
namespace color {
void initialize() {
assert(has_colors());
start_color();
init_pair(INACTIVE, COLOR_WHITE, COLOR_BLACK);
init_pair(ACTIVE, COLOR_RED, COLOR_BLACK);
}
} // end namespace color
|
; A033374: a(n) = floor(54/n).
; 54,27,18,13,10,9,7,6,6,5,4,4,4,3,3,3,3,3,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
add $0,1
mov $1,54
div $1,$0
mov $0,$1
|
/*
* Copyright (c) 2017-2020, [Ribose Inc](https://www.ribose.com).
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is originally derived from software contributed to
* The NetBSD Foundation by Alistair Crooks (agc@netbsd.org), and
* carried further by Ribose Inc (https://www.ribose.com).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
* All rights reserved.
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
* their moral rights under the UK Copyright Design and Patents Act 1988 to
* be recorded as the authors of this copyright work.
*
* 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 "config.h"
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
__RCSID("$NetBSD: crypto.c,v 1.36 2014/02/17 07:39:19 agc Exp $");
#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include <time.h>
#include <rnp/rnp_sdk.h>
#include <rnp/rnp_def.h>
#include <librepgp/stream-packet.h>
#include <librepgp/stream-key.h>
#include "types.h"
#include "crypto/common.h"
#include "crypto.h"
#include "fingerprint.h"
#include "pgp-key.h"
#include "utils.h"
bool
pgp_generate_seckey(const rnp_keygen_crypto_params_t *crypto,
pgp_key_pkt_t * seckey,
bool primary)
{
if (!crypto || !seckey) {
RNP_LOG("NULL args");
return false;
}
/* populate pgp key structure */
*seckey = {};
seckey->version = PGP_V4;
seckey->creation_time = time(NULL);
seckey->alg = crypto->key_alg;
seckey->material.alg = crypto->key_alg;
seckey->tag = primary ? PGP_PKT_SECRET_KEY : PGP_PKT_SECRET_SUBKEY;
switch (seckey->alg) {
case PGP_PKA_RSA:
if (rsa_generate(crypto->rng, &seckey->material.rsa, crypto->rsa.modulus_bit_len)) {
RNP_LOG("failed to generate RSA key");
return false;
}
break;
case PGP_PKA_DSA:
if (dsa_generate(crypto->rng,
&seckey->material.dsa,
crypto->dsa.p_bitlen,
crypto->dsa.q_bitlen)) {
RNP_LOG("failed to generate DSA key");
return false;
}
break;
case PGP_PKA_EDDSA:
if (eddsa_generate(
crypto->rng, &seckey->material.ec, get_curve_desc(PGP_CURVE_ED25519)->bitlen)) {
RNP_LOG("failed to generate EDDSA key");
return false;
}
break;
case PGP_PKA_ECDH:
if (!ecdh_set_params(&seckey->material.ec, crypto->ecc.curve)) {
RNP_LOG("Unsupported curve [ID=%d]", crypto->ecc.curve);
return false;
}
if (crypto->ecc.curve == PGP_CURVE_25519) {
if (x25519_generate(crypto->rng, &seckey->material.ec)) {
RNP_LOG("failed to generate x25519 key");
return false;
}
seckey->material.ec.curve = crypto->ecc.curve;
break;
}
/* FALLTHROUGH for non-x25519 curves */
case PGP_PKA_ECDSA:
case PGP_PKA_SM2:
if (ec_generate(crypto->rng, &seckey->material.ec, seckey->alg, crypto->ecc.curve)) {
RNP_LOG("failed to generate EC key");
return false;
}
seckey->material.ec.curve = crypto->ecc.curve;
break;
case PGP_PKA_ELGAMAL:
if (elgamal_generate(crypto->rng, &seckey->material.eg, crypto->elgamal.key_bitlen)) {
RNP_LOG("failed to generate ElGamal key");
return false;
}
break;
default:
RNP_LOG("key generation not implemented for PK alg: %d", seckey->alg);
return false;
}
seckey->sec_protection.s2k.usage = PGP_S2KU_NONE;
seckey->material.secret = true;
/* fill the sec_data/sec_len */
if (encrypt_secret_key(seckey, NULL, NULL)) {
RNP_LOG("failed to fill sec_data");
return false;
}
return true;
}
bool
key_material_equal(const pgp_key_material_t *key1, const pgp_key_material_t *key2)
{
if (key1->alg != key2->alg) {
return false;
}
switch (key1->alg) {
case PGP_PKA_RSA:
case PGP_PKA_RSA_ENCRYPT_ONLY:
case PGP_PKA_RSA_SIGN_ONLY:
return mpi_equal(&key1->rsa.n, &key2->rsa.n) && mpi_equal(&key1->rsa.e, &key2->rsa.e);
case PGP_PKA_DSA:
return mpi_equal(&key1->dsa.p, &key2->dsa.p) &&
mpi_equal(&key1->dsa.q, &key2->dsa.q) &&
mpi_equal(&key1->dsa.g, &key2->dsa.g) && mpi_equal(&key1->dsa.y, &key2->dsa.y);
case PGP_PKA_ELGAMAL:
case PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN:
return mpi_equal(&key1->eg.p, &key2->eg.p) && mpi_equal(&key1->eg.g, &key2->eg.g) &&
mpi_equal(&key1->eg.y, &key2->eg.y);
case PGP_PKA_EDDSA:
case PGP_PKA_ECDH:
case PGP_PKA_ECDSA:
case PGP_PKA_SM2:
return (key1->ec.curve == key2->ec.curve) && mpi_equal(&key1->ec.p, &key2->ec.p);
default:
RNP_LOG("unknown public key algorithm: %d", (int) key1->alg);
return false;
}
}
rnp_result_t
validate_pgp_key_material(const pgp_key_material_t *material, rng_t *rng)
{
#ifdef FUZZERS_ENABLED
/* do not timeout on large keys during fuzzing */
return RNP_SUCCESS;
#else
switch (material->alg) {
case PGP_PKA_RSA:
case PGP_PKA_RSA_ENCRYPT_ONLY:
case PGP_PKA_RSA_SIGN_ONLY:
return rsa_validate_key(rng, &material->rsa, material->secret);
case PGP_PKA_DSA:
return dsa_validate_key(rng, &material->dsa, material->secret);
case PGP_PKA_EDDSA:
return eddsa_validate_key(rng, &material->ec, material->secret);
case PGP_PKA_ECDH:
return ecdh_validate_key(rng, &material->ec, material->secret);
case PGP_PKA_ECDSA:
return ecdsa_validate_key(rng, &material->ec, material->secret);
case PGP_PKA_SM2:
return sm2_validate_key(rng, &material->ec, material->secret);
case PGP_PKA_ELGAMAL:
case PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN:
return elgamal_validate_key(rng, &material->eg, material->secret);
default:
RNP_LOG("unknown public key algorithm: %d", (int) material->alg);
}
return RNP_ERROR_BAD_PARAMETERS;
#endif
}
size_t
key_bitlength(const pgp_key_material_t *key)
{
switch (key->alg) {
case PGP_PKA_RSA:
case PGP_PKA_RSA_ENCRYPT_ONLY:
case PGP_PKA_RSA_SIGN_ONLY:
return 8 * mpi_bytes(&key->rsa.n);
case PGP_PKA_DSA:
return 8 * mpi_bytes(&key->dsa.p);
case PGP_PKA_ELGAMAL:
case PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN:
return 8 * mpi_bytes(&key->eg.y);
case PGP_PKA_ECDH:
case PGP_PKA_ECDSA:
case PGP_PKA_EDDSA:
case PGP_PKA_SM2: {
// bn_num_bytes returns value <= curve order
const ec_curve_desc_t *curve = get_curve_desc(key->ec.curve);
return curve ? curve->bitlen : 0;
}
default:
RNP_LOG("Unknown public key alg in key_bitlength");
return 0;
}
}
|
; A135098: First differences of A135094.
; 1,2,5,10,22,44,92,184,376,752,1520,3040,6112,12224,24512,49024,98176,196352,392960,785920,1572352,3144704,6290432,12580864,25163776,50327552,100659200,201318400,402644992,805289984,1610596352,3221192704,6442418176,12884836352,25769738240,51539476480,103079084032,206158168064,412316598272,824633196544,1649266917376,3298533834752,6597068718080,13194137436160,26388276969472,52776553938944,105553112072192,211106224144384,422212456677376,844424913354752,1688849843486720,3377699686973440,6755399407501312
mov $4,2
mov $6,$0
lpb $4,1
mov $0,$6
sub $4,1
add $0,$4
sub $0,1
mov $2,$0
mov $5,1
lpb $2,1
mul $5,2
add $5,$0
trn $0,2
sub $2,1
sub $5,$0
lpe
mov $3,$4
lpb $3,1
mov $1,$5
sub $3,1
lpe
lpe
lpb $6,1
sub $1,$5
mov $6,0
lpe
|
copyright zengfr site:http://github.com/zengfr/romhack
001AD8 abcd -(A3), -(A1) [1p+86]
001ADA abcd -(A3), -(A1) [1p+85]
copyright zengfr site:http://github.com/zengfr/romhack
|
0 PUSH 3
1 PUSH 8
2 PUSH 0
3 POP 2
4 PUSH 4
5 GT
6 MUL
7 PUSH 86
8 WRITE |
; A001994: Expansion of 1/((1-x^2)*(1-x^4)^2*(1-x^6)*(1-x^8)*(1-x^10)) (even powers only).
; 1,1,3,4,8,11,18,24,36,47,66,84,113,141,183,225,284,344,425,508,617,729,872,1020,1205,1397,1632,1877,2172,2480,2846,3228,3677,4146,4691,5261,5917,6603,7386,8205,9133,10103,11195,12336,13613,14947,16431,17981,19697,21488,23462,25521,27781,30137,32713,35397,38321,41366,44672,48113,51838,55712,59894,64241,68921,73783,79004,84425,90233,96260,102703,109385,116514,123903,131771,139922,148585,157555,167072,176921,187354,198145,209558,221357,233818,246694,260273,274298,289069,304318,320358,336909,354298,372233,391054,410458,430798,451759,473708,496318
lpb $0
mov $2,$0
sub $0,2
seq $2,1401 ; Number of partitions of n into at most 5 parts.
add $1,$2
lpe
add $1,1
mov $0,$1
|
;
; Project: Real Time Tone Generation - Chapter 3
;
; File name: cos.asm
;
; Description: 16-bit cos(x) approximation function
;
; For the book "Real Time Digital Signal Processing:
; Fundamentals, Implementation and Application, 3rd Ed"
; By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
; Publisher: John Wiley and Sons, Ltd
;
; Entry: T0 = x, in the range of [-pi=0x8000 pi=0x7fff]
; Return: T0 = cos(x)
;
; 25 cycles
;
.def _cosine
;
; Approximation coefficients in Q12 (4096) format
;
.data
coeff ; Cosine appoximation coefficients
.word 0x1000 ; d0 = 1.0000
.word 0xfff8 ; d1 = -0.001922133
.word 0xb199 ; d2 = -4.90014738
.word 0xfbc3 ; d3 = -0.2648921
.word 0x50ba ; d4 = 5.0454103
.word 0xe332 ; d5 = -1.800293
;
; Function starts
;
.text
_cosine
amov #14,AR0
|| bset SATD ; Set Saturate bit
btstp AR0,T0 ; Test bit 15 and 14
bset SMUL
;
; Start cos(x)
;
amov #coeff+5,XAR0 ; Pointer to the end of coefficients
bset FRCT ; Set up fractional bit
|| xcc neg_x,TC1
neg T0 ; Negate if bit 14 is set
neg_x
and #0x7fff,T0 ; Mask out sign bit
mov *AR0-<<#16,AC0 ; AC0 = d5
mov *AR0-<<#16,AC1 ; AC1 = d4
mac AC0,T0,AC1 ; AC1 = (d5*x+d4)
|| mov *AR0-<<#16,AC0 ; AC0 = d3
mac AC1,T0,AC0 ; AC0 = (d5*x^2+d4*x+d3)
|| mov *AR0-<<#16,AC1 ; AC1 = d2
mac AC0,T0,AC1 ; AC1 = (d5*x^3+d4*x^2+d3*x+d2)
|| mov *AR0-<<#16,AC0 ; AC0 = d1
mac AC1,T0,AC0 ; AC0 = (d5*x^4+d4*x^3+d3*x^2+d2*x+d1)
|| mov *AR0-<<#16,AC1 ; AC1 = d0
macr AC0,T0,AC1 ; AC1 = (d5*x^4+d4*x^3+d3*x^2+d2*x+d1)*x+d0
|| xcc neg_result1,TC2
neg AC1
neg_result1
bclr FRCT ; Reset fractional bit
|| xcc neg_result2,TC1
neg AC1
neg_result2
sfts AC1,#3
|| bclr SMUL
mov HI(saturate(AC1)),mmap(T0) ; Return cos(x) in Q15
bclr SATD ; Reset saturate bit
ret
.end
|
#include<iostream>
using namespace std;
template <typename T>
T sum(T a,T b)
{
return a+b;
}
int main()
{
int x,y; float c,d;
cout<<"Enter two no. for sum ";
cin>>x>>y;
cin>>c>>d;
cout<<sum<int>(x,y);
cout<<sum<float>(c,d);
}
|
; A110185: Coefficients of x in the partial quotients of the continued fraction expansion exp(1/x) = [1, x - 1/2, 12*x, 5*x, 28*x, 9*x, 44*x, 13*x, ...]. The partial quotients all have the form a(n)*x except the constant term of 1 and the initial partial quotient which equals (x - 1/2).
; 0,1,12,5,28,9,44,13,60,17,76,21,92,25,108,29,124,33,140,37,156,41,172,45,188,49,204,53,220,57,236,61,252,65,268,69,284,73,300,77,316,81,332,85,348,89,364,93,380,97,396,101,412,105,428,109,444,113,460,117,476,121,492,125,508,129,524,133,540,137,556,141,572,145,588,149,604,153,620,157,636,161,652,165,668,169,684,173,700,177,716,181,732,185,748,189,764,193,780,197
mov $1,$0
pow $0,2
gcd $0,4
mov $2,$1
trn $2,1
add $1,$2
mul $0,$1
|
PUBLIC _fgetattr
; Fastcall
._fgetattr call 0xB8C9
jr c, _fgetok
ld hl, 0xffff
ret
_fgetok: ld l, a
ld h, 0
ret
|
; A171577: 0, 1 and primes > 3.
; 0,1,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277
seq $0,40 ; The prime numbers.
lpb $0
sub $0,2
pow $0,2
lpe
|
Monitor: DB $04
DW $3600
DW MonitorEdges
DB MonitorEdgesSize
DB $00, $2A
DB MonitorVertSize /6
DB MonitorVertSize
DB MonitorEdgesCnt
DB $01, $90
DB MonitorNormalsSize
DB $28, $84, $10
DW MonitorNormals
DB $00, $37
DW MonitorVertices
DB 0,0 ; Type and Tactics
DB ShipCanAnger
MonitorVertices: DB $00, $0A, $8C, $1F, $FF, $FF
DB $14, $28, $14, $3F, $23, $01
DB $14, $28, $14, $BF, $50, $34
DB $32, $00, $0A, $1F, $78, $12
DB $32, $00, $0A, $9F, $96, $45
DB $1E, $04, $3C, $3F, $AA, $28
DB $1E, $04, $3C, $BF, $AA, $49
DB $12, $14, $3C, $3F, $AA, $23
DB $12, $14, $3C, $BF, $AA, $34
DB $00, $14, $3C, $7F, $AA, $89
DB $00, $28, $0A, $5F, $89, $67
DB $00, $22, $0A, $0A, $00, $00
DB $00, $1A, $32, $0A, $00, $00
DB $14, $0A, $3C, $4A, $77, $77
DB $0A, $00, $64, $0A, $77, $77
DB $14, $0A, $3C, $CA, $66, $66
DB $0A, $00, $64, $8A, $66, $66
MonitorVertSize: equ $ - MonitorVertices
MonitorEdges: DB $1F, $01, $00, $04
DB $1F, $12, $04, $0C
DB $1F, $23, $04, $1C
DB $1F, $34, $08, $20
DB $1F, $45, $08, $10
DB $1F, $50, $00, $08
DB $1F, $03, $04, $08
DB $1F, $67, $00, $28
DB $1F, $78, $0C, $28
DB $1F, $89, $24, $28
DB $1F, $96, $10, $28
DB $1F, $17, $00, $0C
DB $1F, $28, $0C, $14
DB $1F, $49, $18, $10
DB $1F, $56, $10, $00
DB $1F, $2A, $1C, $14
DB $1F, $3A, $20, $1C
DB $1F, $4A, $20, $18
DB $1F, $8A, $14, $24
DB $1F, $9A, $18, $24
DB $0A, $00, $2C, $30
DB $0A, $77, $34, $38
DB $0A, $66, $3C, $40
MonitorEdgesSize: equ $ - MonitorEdges
MonitorEdgesCnt: equ MonitorEdgesSize/4
MonitorNormals: DB $1F, $00, $3E, $0B
DB $1F, $2C, $2B, $0D
DB $3F, $36, $1C, $10
DB $3F, $00, $39, $1C
DB $BF, $36, $1C, $10
DB $9F, $2C, $2B, $0D
DB $DF, $26, $2F, $12
DB $5F, $26, $2F, $12
DB $7F, $27, $30, $0D
DB $FF, $27, $30, $0D
DB $3F, $00, $00, $40
MonitorNormalsSize: equ $ - MonitorNormals
MonitorLen: equ $ - Monitor
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r13
push %r14
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x16b28, %rbx
nop
nop
nop
nop
nop
cmp $22305, %r14
mov (%rbx), %r10
nop
inc %rax
lea addresses_WC_ht+0x1e6a8, %r12
dec %rbx
movb $0x61, (%r12)
nop
nop
nop
nop
nop
cmp %rbx, %rbx
lea addresses_WC_ht+0x47a8, %r12
nop
nop
add $7592, %r8
movl $0x61626364, (%r12)
nop
nop
nop
and $24864, %r8
lea addresses_A_ht+0x1eec, %rbx
nop
nop
nop
nop
and $885, %r8
movb $0x61, (%rbx)
nop
nop
cmp %rbx, %rbx
lea addresses_WT_ht+0x1d0a8, %rsi
lea addresses_D_ht+0x15ca8, %rdi
add $52473, %r12
mov $34, %rcx
rep movsq
nop
nop
nop
nop
dec %r10
lea addresses_UC_ht+0x847c, %r12
nop
nop
nop
and %r8, %r8
mov (%r12), %r14d
xor $47291, %rdi
lea addresses_D_ht+0x9828, %rax
clflush (%rax)
nop
nop
nop
and $43093, %rdi
and $0xffffffffffffffc0, %rax
movaps (%rax), %xmm6
vpextrq $1, %xmm6, %rsi
nop
nop
nop
nop
cmp %rsi, %rsi
lea addresses_D_ht+0x174a8, %rsi
clflush (%rsi)
nop
nop
inc %rdi
vmovups (%rsi), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $1, %xmm5, %r12
nop
nop
nop
nop
nop
cmp %r13, %r13
lea addresses_A_ht+0x7fde, %rsi
lea addresses_WC_ht+0x2ba8, %rdi
nop
nop
nop
nop
inc %rax
mov $69, %rcx
rep movsl
dec %r12
lea addresses_WT_ht+0x108a8, %rsi
lea addresses_UC_ht+0x18228, %rdi
clflush (%rdi)
nop
nop
nop
nop
sub $31387, %r12
mov $92, %rcx
rep movsw
nop
nop
nop
inc %r8
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r14
pop %r13
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %r9
push %rbx
push %rdi
// Store
lea addresses_UC+0xcfa8, %r14
nop
nop
and %rbx, %rbx
mov $0x5152535455565758, %r10
movq %r10, (%r14)
nop
nop
and %r10, %r10
// Store
lea addresses_A+0x197a8, %r14
and $18543, %rdi
mov $0x5152535455565758, %r13
movq %r13, (%r14)
inc %r13
// Faulty Load
lea addresses_WT+0xd0a8, %r14
nop
nop
nop
sub %rbx, %rbx
vmovups (%r14), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $1, %xmm4, %rdi
lea oracles, %r10
and $0xff, %rdi
shlq $12, %rdi
mov (%r10,%rdi,1), %rdi
pop %rdi
pop %rbx
pop %r9
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_UC'}}
{'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_A'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 4, 'NT': True, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_A_ht'}}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 6, 'AVXalign': True, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 1, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_UC_ht'}}
{'46': 388, '00': 3501, '49': 10905, '45': 7035}
49 49 49 45 49 45 49 45 49 49 49 45 49 49 45 00 45 45 49 45 49 49 00 49 49 49 45 49 49 45 45 00 49 49 49 45 49 45 49 45 49 49 45 49 49 46 49 45 49 45 00 49 49 00 00 45 00 45 49 49 49 49 45 45 49 45 49 49 49 45 46 49 00 49 00 00 49 49 49 46 49 49 49 49 45 49 49 49 45 49 49 00 49 49 49 49 49 45 49 49 49 49 49 00 49 49 00 45 49 45 45 49 49 45 49 45 00 45 45 45 49 49 49 49 00 45 49 49 00 45 49 49 00 49 45 00 45 49 00 49 46 45 00 49 49 49 45 00 49 49 49 49 49 00 45 00 49 49 49 49 49 00 49 49 49 00 49 49 45 45 49 45 49 45 45 00 49 00 45 49 49 45 49 00 49 49 45 49 00 45 45 45 49 49 00 49 00 49 45 00 45 49 45 49 49 49 49 00 00 45 00 49 46 49 49 49 49 49 46 45 00 45 45 45 49 45 49 00 45 49 45 45 00 45 45 45 49 49 49 00 45 00 49 00 49 49 00 45 49 45 45 49 45 00 49 49 45 00 49 49 45 00 45 49 45 45 49 49 49 45 49 00 45 49 00 45 49 49 45 00 45 49 49 00 49 45 00 45 45 45 49 49 49 49 45 49 00 49 45 45 49 49 45 00 45 49 00 49 46 45 49 49 00 49 49 45 00 45 49 49 45 46 49 49 49 49 00 45 00 00 49 49 45 49 49 49 00 45 49 49 49 49 45 45 49 00 45 49 00 49 45 45 49 00 49 49 49 49 49 00 49 45 45 49 45 45 49 49 49 49 46 49 49 49 49 45 00 45 49 49 49 49 49 00 49 49 45 45 49 00 49 49 49 00 49 45 00 49 49 00 45 49 45 49 45 45 49 45 49 49 49 00 49 46 45 49 49 49 00 00 49 49 49 49 45 49 49 45 49 00 45 45 00 45 49 45 00 49 49 00 45 49 45 49 49 49 45 49 45 49 49 46 45 00 49 49 45 49 00 45 00 45 45 49 00 49 49 49 49 45 49 45 49 49 00 45 49 49 45 45 45 45 49 45 45 45 49 49 49 49 49 45 49 49 49 49 49 49 49 00 00 00 45 49 49 49 49 00 49 49 45 49 45 49 45 49 46 45 00 49 45 45 49 45 49 49 49 49 49 49 45 49 46 45 45 49 49 49 49 45 46 49 49 45 45 00 49 45 45 00 45 49 49 45 49 49 49 45 49 49 49 49 49 00 45 46 49 00 00 49 45 49 45 49 00 49 49 45 49 49 49 49 45 49 49 49 49 49 49 45 00 00 49 49 46 45 49 49 45 49 00 00 45 45 45 45 49 49 00 49 00 49 49 45 49 45 49 49 45 49 49 45 45 45 45 49 00 00 45 49 49 46 49 49 45 45 00 45 49 49 45 45 49 49 49 00 45 45 45 49 49 49 49 49 45 49 00 45 49 45 49 00 00 45 49 49 49 45 46 45 00 45 49 00 45 00 49 45 49 49 45 45 45 45 49 49 49 49 49 49 00 49 49 49 45 45 45 49 00 49 45 45 00 45 49 49 49 49 45 45 49 46 49 49 49 45 49 00 49 49 49 45 45 45 45 49 45 49 00 45 49 49 45 45 46 45 49 49 49 49 45 45 45 49 00 45 45 49 45 49 00 45 49 49 45 45 00 45 46 00 45 49 49 49 49 45 49 49 00 45 45 00 45 49 00 49 45 49 45 49 45 45 49 00 00 49 49 49 45 45 45 45 49 45 49 49 00 45 45 49 45 49 49 49 45 46 45 00 45 49 49 45 00 49 45 49 00 45 49 45 45 49 49 49 45 46 49 45 49 49 00 45 49 49 49 00 45 49 00 45 49 49 49 45 45 45 49 49 00 49 49 00 45 00 45 00 00 49 45 49 45 49 00 45 49 45 45 45 49 49 49 49 49 45 45 00 45 49 00 00 00 00 45 45 49 00 45 49 00 45 49 45 49 49 49 49 45 45 45 49 00 45 49 49 49 49 49 45 00 49 00 45 00 49 45 49 49 45 49 45 45 49 45 49 49 49 45 00 45 45 45 49 00 45 49 45 49 45 49 45 49 00 49 45 45 00 49 49 49 00 00 49 00 45 46 49 00 49 45 45 45 45 45 45 00 45 45 49 49 49 00 00 45 49 49 45 00 49 45 49 45 49 46 45 49 49 00 00 00 45 49 49 49 49 49 49 45 49 49 49
*/
|
//
// Created by root on 11/13/16.
//
#ifndef AUGMENTEDSTUFF_AUGMENTER_HPP
#define AUGMENTEDSTUFF_AUGMENTER_HPP
#include <jni.h>
#include <errno.h>
#include <string>
#include <android/sensor.h>
#include <android/log.h>
#include <boost/lexical_cast.hpp>
#include <boost/thread.hpp>
#include <boost/chrono.hpp>
#include <boost/date_time.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
#include <opencv2/photo/photo.hpp>
#include <opencv2/video/video.hpp>
#include <opencv2/videoio/videoio.hpp>
#include <opencv2/videostab/stabilizer.hpp>
#define APPNAME "Augmented"
#define LOGPRINT(...) ((void)__android_log_print(ANDROID_LOG_INFO, APPNAME, __VA_ARGS__))
#define TIMESSEC(TIMES) ((1000L/TIMES) * 1000)
#endif //AUGMENTEDSTUFF_AUGMENTER_HPP
|
;******************************************************************************************************
; MAIN TRACK MUSIC DRIVER : this still has a LOT of debug stuff in it.
;------------------------------------------------------------------------------------------------------
psgMainDrive
;...........................................................................
; make sure song is ready.
jsr initCheck ; initialize song, if it needs it.
;...........................................................................
; does main track need updated ?
lda psgTrackCtrl ; get track control bits
bmi .mainStatusUpdate ; if main track paused, skip to status update
;...........................................................................
; main not paused, it needs updated. count interrupt, see if time to update.
inc psgTrackCtrl ; count interrupt
and #$0F ; keep it in range
cmp psgTrackDelay ; did we reach delay count ?
bcc .mainStatusUpdate ; nope, it's not time to update
;...........................................................................
; time to update main track. reset delay count
lda #$0F ; only change low 4 bits
trb psgTrackCtrl ; zero delay count
;...........................................................................
; main track voice loop
lda #5 ; count down voices
sta psgCurrentVoice ; save working voice
.voiceLoop
;...........................................................................
; check voice status, skip it if off
ldx psgCurrentVoice ; retrieve working voice
lda psgMainVoiceStatus,x ; get status
beq .voiceNext ; if off, skip it
;...........................................................................
; voice needs updated. Call subroutines to do it
jsr mainParseMMLCodes
jsr processVolume
jsr processDrums
jsr processEnvelope
jsr processFrequency
;...........................................................................
; process next voice
.voiceNext
dec psgCurrentVoice ; count down voice
bpl .voiceLoop ; loop if not done
;...........................................................................
; all the main track voices have been handled.
; fade out if needed, and output sounds
jsr processFade
jsr outputSounds
;...........................................................................
; and finally, update the main tracks status.
; Note that the return at end of psgMStat, sends us back to whomever called us.
.mainStatusUpdate
jmp psgMStat ; update track status. I'm not sure why; we don't do anything
; with it and it doesn't change anything...
;-----------------------------------------------------------------------------
; initCheck - initialize track information, if needed.
initCheck
lda psgSongNo ; check song number
bpl psgSetupSong ; if not already started (or changed), go start it
driveExit
rts
;-----------------------------------------------------------------------------
; psgSetupSong - initialize song information
;.............................................................................
; IN : A = song number
psgSetupSong
;...........................................................................
; convert song number to 2-byte offset, put in Y for indexing
asl a ; 2 bytes per pointer
tay ; into index Y
;...........................................................................
; locate pointer for this song's header
lda psgTrackIndexTable ; location of track pointers
sta <psgPtr2 ; set up zp pointer
lda psgTrackIndexTable+1
sta <psgPtr2+1
;...........................................................................
; psgPtr2 now points to track index table. using Y, we now
; copy the actual track header data pointer to psgPtr1
lda [psgPtr2],Y ; y'th entry
sta <psgPtr1
iny
lda [psgPtr2],Y
sta <psgPtr1+1
;...........................................................................
; now that we know where track header information is, start processing it.
lda [psgPtr1] ; get voice mask for track
; bit 7: 0= main track; 1= subtrack
; bit 6: 0= normal; 1= debug mode
; bit 5-0: voice in use
bmi driveExit ; if it's a sub track, we're done
;...........................................................................
; save voice mask in temp area. we shift one byte, and need the other to hold
; the original flags, so we can check for the debug flag.
sta <psgTemp1 ; save in temp area -> shiftable value
sta <psgTemp2 ; for debug flags
;...........................................................................
; set up voices
cly ; index of active tracks
clx ; start with voice 0
.voiceLoop
lsr <psgTemp1 ; get voice bit
bcc .nextVoice ; skip it if voice not in use
;...........................................................................
; set main voice status, note duration.
lda #1
sta psgMainVoiceStatus,x ; mark voice as enabled
sta psgMainNoteDuration,x ; set duration to 1 ?
;...........................................................................
; clear main voice information
stz psgMainTieState,x ; clear tie state (ie, note not tied)
stz psgMainKeyOffPeriods,x ; clear # periods Key is off
stz psgMainVoiceVolume,x ; clear per-channel voice volume (100%?)
stz psgMainModDelay,x ; clear modulation delay
stz psgMainPEDelay,x ; clear pitch envelope delay
stz psgMainModCorrection,x ; clear modulation correction
stz psgMainDetuneAmount,x ; clear detune amount
stz psgMainSweepDelta,x ; clear sweep change amount
stz psgMainSweepTime,x ; clear sweep time
stz psgMainStackOffset,x ; clear offset from stack base
stz psgMainTransposeAmount,x ; clear transpose amount
stz psgMainVolumeChangeAmount,x ; clear volume change amount
stz psgMainPanRightDelta,x ; clear right pan pot change amount
stz psgMainPanLeftDelta,x ; clear left pan pot change amount
stz psgMainDurationMultiplier,x ; clear duration multiplier
lda psgSysEnv ; point to envelope 0
sta psgMainEnvelopePtrLo,x
lda psgSysEnv+1
sta psgMainEnvelopePtrHi,x
;...........................................................................
; set defaults for non-zero items
lda #$84
sta psgMainEnvReleaseHi,x ; set release rate to $8400
lda #4
sta psgMainOctave,x ; default octave number
;...........................................................................
; next header entry : voice data location
iny ; next byte in track header
lda [psgPtr1],y ; get voice data addresss
sta psgMainTrackPtrLo,x ; save track pointer
sta psgMainSegnoLo,x ; and repeat location (ie, segno)
iny ; next byte in track header
lda [psgPtr1],y ; get voice data addresss
sta psgMainTrackPtrHi,x ; save track pointer
sta psgMainSegnoHi,x ; and repeat location (ie, segno)
;...........................................................................
; skip channel if not 5 or 6 (noise-capable channels)
lda #$80 ; moise off flag
cpx #4 ; last non-noise channel
bcc .notNoiseChannel ; if not a noise-capable channel, skip flagging
;...........................................................................
; pay attention: noise flags are right after wave flags. X must be at
; least 4 to get here. 2476+4 = 247a, which is address we have defined.
; ergo, to use straight X as index, we need 247a-4, which is 2476
;...........................................................................
; c3bc: 9d 76 24 STA $2476, X ; disable noise (if voice is noise-capable)
sta psgMainNoiseFlag-4, X ; mark noise as diabled.
.notNoiseChannel
sta psgMainWaveNo,x ; disable waveform download. last loaded is 0
bbr6 <psgTemp2, .nextVoice ; check debug flag. That's why we saved flags twice!
;...........................................................................
; track marked for debug mode. copy debug waveform number to voice waveform
lda psg_WaveNo ; get debug wave number
sta psgMainWaveNo,x ; save as voice waveform. Note bit 7 should be off,
; so it will get loaded when we reach that point
;...........................................................................
; that voice should be initialized. do the next voice
.nextVoice
inx
cpx #6
bcc .voiceLoop
;...........................................................................
; initialize remaining track variables
stz psgMainFadeOutSpeed ; clear fade speed
stz psgMainFadeOutCount+1 ; clear fade count (only 1 byte?)
;...........................................................................
; enable track
lda #$80
tsb psgSongNo ; set bit 7 in song on (ie, song ready)
lda psgTrackCtrl ; get track control bits
and #$70 ; turn off bit 7 (main -not- paused)
; -and- clear delay count
ora psgTrackDelay ; set delay to max
sta psgTrackCtrl ; and update control
rts
|
; char *strcpy(char * restrict s1, const char * restrict s2)
SECTION code_clib
SECTION code_string
PUBLIC strcpy
EXTERN asm_strcpy
strcpy:
pop af
pop hl
pop de
push de
push hl
push af
jp asm_strcpy
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _strcpy
defc _strcpy = strcpy
ENDIF
|
/**
* @file vfs_file_handle.cc
*
* @section LICENSE
*
* The MIT License
*
* @copyright Copyright (c) 2017-2019 TileDB, Inc.
*
* 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.
*
* @section DESCRIPTION
*
* This file implements the VFSFileHandle class.
*/
#include "tiledb/sm/filesystem/vfs_file_handle.h"
#include "tiledb/sm/misc/logger.h"
#include <sstream>
namespace tiledb {
namespace sm {
/* ********************************* */
/* CONSTRUCTORS & DESTRUCTORS */
/* ********************************* */
VFSFileHandle::VFSFileHandle(const URI& uri, VFS* vfs, VFSMode mode)
: uri_(uri)
, vfs_(vfs)
, mode_(mode) {
is_open_ = true;
}
/* ********************************* */
/* API */
/* ********************************* */
Status VFSFileHandle::close() {
if (!is_open_) {
std::stringstream msg;
msg << "Cannot close file '" << uri_.to_string() << "'; File is not open";
auto st = tiledb::sm::Status::VFSFileHandleError(msg.str());
return LOG_STATUS(st);
}
// Close file in write or append mode
if (mode_ != tiledb::sm::VFSMode::VFS_READ) {
RETURN_NOT_OK(vfs_->close_file(uri_));
// Create an empty file if the file does not exist
bool exists;
RETURN_NOT_OK(vfs_->is_file(uri_, &exists));
if (!exists)
RETURN_NOT_OK(vfs_->touch(uri_));
}
is_open_ = false;
return Status::Ok();
}
bool VFSFileHandle::is_open() const {
return is_open_;
}
Status VFSFileHandle::open() {
return vfs_->open_file(uri_, mode_);
}
Status VFSFileHandle::read(uint64_t offset, void* buffer, uint64_t nbytes) {
if (!is_open_) {
std::stringstream msg;
msg << "Cannot read from file '" << uri_.to_string()
<< "'; File is not open";
auto st = tiledb::sm::Status::VFSFileHandleError(msg.str());
return LOG_STATUS(st);
}
return vfs_->read(uri_, offset, buffer, nbytes);
}
Status VFSFileHandle::sync() {
if (!is_open_) {
std::stringstream msg;
msg << "Cannot sync file '" << uri_.to_string() << "'; File is not open";
auto st = tiledb::sm::Status::VFSFileHandleError(msg.str());
return LOG_STATUS(st);
}
return vfs_->sync(uri_);
}
URI VFSFileHandle::uri() const {
return uri_;
}
Status VFSFileHandle::write(const void* buffer, uint64_t nbytes) {
if (!is_open_) {
std::stringstream msg;
msg << "Cannot write to file '" << uri_.to_string()
<< "'; File is not open";
auto st = tiledb::sm::Status::VFSFileHandleError(msg.str());
return LOG_STATUS(st);
}
return vfs_->write(uri_, buffer, nbytes);
}
} // namespace sm
} // namespace tiledb
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.