text stringlengths 1 1.05M |
|---|
.data
buforTekst: .space 17
buforKlucz: .space 9
pytanieTekst: .asciiz "\nPodaj tekst (max 16 znakow): "
pytanieKlucz: .asciiz "\nPodaj klucz (min 1 znak, max 8 znakow): "
pytanieOperacja:.asciiz "Podaj kod operacji (0 - szyfrowanie, 1 - odszyfrowanie): "
.text
Main:
#Pytanie o kod operacji
la $a0, pytanieOperacja
li $v0, 4
syscall
li $v0,5
syscall
move $s0,$v0
#Pytanie o klucz
Klucz:
la $a0, pytanieKlucz
li $v0, 4
syscall
la $a0, buforKlucz
li $a1, 9
li $v0, 8
syscall
lb $t0, ($a0)
blt $t0, 97, Klucz
#sprawdz czy zawiera poprawne znaki (97-122) i jesli nie to idz do szyfr
move $s1, $a0
#Pytanie o tekst
Tekst:
la $a0, pytanieTekst
li $v0, 4
syscall
la $a0, buforTekst
li $a1, 17
li $v0, 8
syscall
#sprawdz czy zawiera poprawne znaki (97-122) i jesli nie to idz to szyfr
la $a0, buforTekst
li $v0, 4
syscall
move $s2, $a0
add $t1, $zero, $zero # tekst licznik
ZerujLicznikKlucza:
add $t0, $zero, $zero # klucz licznik
Petla:
add $t2, $s1, $t0
lb $t2, ($t2)
blt $t2, 'a', ZerujLicznikKlucza
bgt $t2, 122, ZerujLicznikKlucza
add $t3, $s2, $t1
lb $t3, ($t3)
blt $t3, 97, Koniec # jeśli biezacy znak tekstu to null to zakoncz
bgt $t3, 122, Koniec
beq $s0, 1, Odszyfruj
Zaszyfruj:
add $t3, $t3, $t2
sub $t3, $t3, 97
ble $t3, 122, Wyswietl
sub $t3, $t3, 26
j Wyswietl
Odszyfruj:
sub $t3, $t3, $t2
add $t3, $t3, 97
bge $t3, 97, Wyswietl
add $t3, $t3, 26
Wyswietl:
move $a0, $t3
li $v0, 11
syscall
add $t0, $t0, 1 # zwieksz licznik klucza
add $t1, $t1, 1 # zwieksz licznik tekstu
j Petla
Koniec:
li $v0, 10
syscall
|
cpu 78070
page 0
relaxed on
include reg78k0.inc
saddr equ 0fe80h
sfr equ 0ff90h
brk
ret
retb
reti
nop
ei
di
halt
stop
adjba
adjbs
mov d,#20
mov saddr,#30
mov sfr,#40
mov a,c
mov e,a
mov a,saddr
mov saddr,a
mov a,sfr
mov sfr,a
mov a,!saddr
mov !saddr,r1
mov psw,#40h
mov a,psw
mov psw,a
mov a,[de]
mov [de],a
mov a,[hl]
mov [hl],a
mov a,[hl+10]
mov [hl+10],a
mov a,[hl+b]
mov [hl+b],a
mov a,[hl+c]
mov [hl+c],a
xch a,d
xch l,a
xch a,saddr
xch a,sfr
xch a,!saddr
xch a,[de]
xch a,[hl]
xch a,[hl+10]
xch a,[hl+b]
xch a,[hl+c]
movw de,#1000
movw saddr,#2000
movw sfr,#3000
movw ax,saddr
movw saddr,ax
movw ax,sfr
movw sfr,ax
movw ax,de
movw hl,ax
movw ax,!saddr
movw !saddr,ax
xchw ax,de
xchw hl,ax
add a,#10
add saddr,#20
add a,c
add h,a
add a,saddr
add a,!saddr
add a,[hl]
add a,[hl+10]
add a,[hl+b]
add a,[hl+c]
addc a,#10
addc saddr,#20
addc a,c
addc h,a
addc a,saddr
addc a,!saddr
addc a,[hl]
addc a,[hl+10]
addc a,[hl+b]
addc a,[hl+c]
sub a,#10
sub saddr,#20
sub a,c
sub h,a
sub a,saddr
sub a,!saddr
sub a,[hl]
sub a,[hl+10]
sub a,[hl+b]
sub a,[hl+c]
subc a,#10
subc saddr,#20
subc a,c
subc h,a
subc a,saddr
subc a,!saddr
subc a,[hl]
subc a,[hl+10]
subc a,[hl+b]
subc a,[hl+c]
and a,#10
and saddr,#20
and a,c
and h,a
and a,saddr
and a,!saddr
and a,[hl]
and a,[hl+10]
and a,[hl+b]
and a,[hl+c]
or a,#10
or saddr,#20
or a,c
or h,a
or a,saddr
or a,!saddr
or a,[hl]
or a,[hl+10]
or a,[hl+b]
or a,[hl+c]
xor a,#10
xor saddr,#20
xor a,c
xor h,a
xor a,saddr
xor a,!saddr
xor a,[hl]
xor a,[hl+10]
xor a,[hl+b]
xor a,[hl+c]
cmp a,#10
cmp saddr,#20
cmp a,c
cmp h,a
cmp a,saddr
cmp a,!saddr
cmp a,[hl]
cmp a,[hl+10]
cmp a,[hl+b]
cmp a,[hl+c]
addw ax,#1234h
subw rp0,#2345h
cmpw ax,#3456h
mulu x
divuw c
inc d
inc saddr
dec e
dec saddr
incw hl
decw de
ror a,1
rol a,1
rorc a,1
rolc a,1
ror4 [hl]
rol4 [hl]
mov1 cy,saddr.3
mov1 cy,sfr.4
mov1 cy,a.5
mov1 cy,psw.6
mov1 cy,[hl].7
mov1 saddr.3,cy
mov1 sfr.4,cy
mov1 a.5,cy
mov1 psw.6,cy
mov1 [hl].7,cy
and1 cy,saddr.3
and1 cy,sfr.4
and1 cy,a.5
and1 cy,psw.6
and1 cy,[hl].7
or1 cy,saddr.3
or1 cy,sfr.4
or1 cy,a.5
or1 cy,psw.6
or1 cy,[hl].7
xor1 cy,saddr.3
xor1 cy,sfr.4
xor1 cy,a.5
xor1 cy,psw.6
xor1 cy,[hl].7
set1 saddr.3
set1 sfr.4
set1 a.5
set1 psw.6
set1 [hl].7
clr1 saddr.3
clr1 sfr.4
clr1 a.5
clr1 psw.6
clr1 [hl].7
set1 cy
clr1 cy
not1 cy
call 1234h
callf 234h
callt [12h]
push psw
push de
pop psw
pop hl
movw sp,#1234h
movw sp,ax
movw ax,sp
br ax
br rp0
br 1234h
br pc
br $pc
br !pc
bc pc
bnc pc
bz pc
bnz pc
bt saddr.3,pc
bt sfr.4,pc
bt a.5,pc
bt psw.6,pc
bt [hl].7,pc
bf saddr.3,pc
bf sfr.4,pc
bf a.5,pc
bf psw.6,pc
bf [hl].7,pc
btclr saddr.3,pc
btclr sfr.4,pc
btclr a.5,pc
btclr psw.6,pc
btclr [hl].7,pc
dbnz b,pc
dbnz c,pc
dbnz saddr,pc
sel rb0
sel rb1
sel rb2
sel rb3
db 1,2,3
dw 1,2,3
dd 1,2,3
dd 1.0,2.0,3.0
dq 1.0,2.0,3.0
dt 1.0,2.0,3.0
db 10 dup (?)
db 0
end
|
#include <rwlibs/task/Task.hpp>
#include <rwlibs/task/loader/TaskSaver.hpp>
#include <rw/math/Vector3D.hpp>
using namespace rw::core;
using namespace rw::math;
using namespace rwlibs::task;
int main(int argc, char** argv)
{
Vector3D<> pos(-0.075, 0, 0.10139);
Rotation3D<> rot(-0.960294, 0.0857174, -0.265497,
-0.000391172, 0.951217, 0.308521,
0.278991, 0.296375, -0.913414);
rwlibs::task::CartesianTask tasks;
// first set up the configuration
Vector3D<> d(0,0,-0.10);
Transform3D<> wTe_n(pos, rot);
Transform3D<> wTe_home(pos+inverse(rot)*d, rot);
Q openQ(1,0.0);
Q closeQ(1,1.0);
//wTe_n = Transform3D<>::identity();
//wTe_home = Transform3D<>::identity();
tasks.getPropertyMap().set<Transform3D<> >("Nominal", wTe_n);
tasks.getPropertyMap().set<Transform3D<> >("Home", wTe_home);
tasks.getPropertyMap().set<Vector3D<> >("Approach", Vector3D<>(0,0,0.02));
tasks.getPropertyMap().set<Q>("OpenQ", openQ);
tasks.getPropertyMap().set<Q>("CloseQ", closeQ);
// next generate the targets
/*
while(true){
double x = Math::ran(-0.2,0.2);
double y = Math::ran(-0.2,0.2);
double z = Math::ran(-0.2,0.2);
Rotation3D<> rot = Math::ranRotation3D();
Transform3D<> rt3d( Vector3D<>(x,y,z), rot);
// TODO check collision between cylinder and object
}
*/
for(int i=0; i<10; i++){
for(int j=0; j<10; j++){
Transform3D<> target = Transform3D<>::identity();
target.P()[0] -= i*0.01;
target.P()[1] -= j*0.01;
CartesianTarget::Ptr ctarget = ownedPtr( new CartesianTarget(target) );
tasks.addTarget( ctarget );
}
}
try {
const TaskSaver::Ptr saver = TaskSaver::Factory::getTaskSaver("xml");
saver->save(&tasks, "SuctionCupTaskFile.xml");
} catch (const Exception&) {
// QMessageBox::information(this, "Task Execution Widget", "Unable to save tasks");
}
return (0);
}
|
/*******************************************************************************
* Copyright 2021 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#pragma once
#include "oneapi/dal/detail/common.hpp"
#include "oneapi/dal/table/common.hpp"
#include "oneapi/dal/util/result_option_id.hpp"
namespace oneapi::dal::basic_statistics {
namespace task {
namespace v1 {
/// Tag-type that parameterizes entities that are used to compute statistics.
struct compute {};
/// Alias tag-type for the compute task.
using by_default = compute;
} // namespace v1
using v1::compute;
using v1::by_default;
} // namespace task
namespace method {
namespace v1 {
/// Tag-type that denotes dense computational method.
struct dense {};
/// Alias tag-type for dense computational method.
using by_default = dense;
} // namespace v1
using v1::dense;
using v1::by_default;
} // namespace method
/// Represents result option flag
/// Behaves like a regular :expr`enum`.
class result_option_id : public result_option_id_base {
public:
constexpr result_option_id() = default;
constexpr explicit result_option_id(const result_option_id_base& base)
: result_option_id_base{ base } {}
};
namespace detail {
ONEDAL_EXPORT result_option_id get_max_id();
ONEDAL_EXPORT result_option_id get_min_id();
ONEDAL_EXPORT result_option_id get_sum_id();
ONEDAL_EXPORT result_option_id get_sum_squares_id();
ONEDAL_EXPORT result_option_id get_sum_squares_centered_id();
ONEDAL_EXPORT result_option_id get_mean_id();
ONEDAL_EXPORT result_option_id get_second_order_raw_moment_id();
ONEDAL_EXPORT result_option_id get_variance_id();
ONEDAL_EXPORT result_option_id get_standard_deviation_id();
ONEDAL_EXPORT result_option_id get_variation_id();
} // namespace detail
/// Result options are used to define
/// what should algorithm return
namespace result_options {
const inline result_option_id min = detail::get_max_id();
const inline result_option_id max = detail::get_min_id();
const inline result_option_id sum = detail::get_sum_id();
const inline result_option_id sum_squares = detail::get_sum_squares_id();
const inline result_option_id sum_squares_centered = detail::get_sum_squares_centered_id();
const inline result_option_id mean = detail::get_mean_id();
const inline result_option_id second_order_raw_moment = detail::get_second_order_raw_moment_id();
const inline result_option_id variance = detail::get_variance_id();
const inline result_option_id standard_deviation = detail::get_standard_deviation_id();
const inline result_option_id variation = detail::get_variation_id();
} // namespace result_options
namespace detail {
namespace v1 {
struct descriptor_tag {};
template <typename Task>
class descriptor_impl;
template <typename Float>
constexpr bool is_valid_float_v = dal::detail::is_one_of_v<Float, float, double>;
template <typename Method>
constexpr bool is_valid_method_v = dal::detail::is_one_of_v<Method, method::dense>;
template <typename Task>
constexpr bool is_valid_task_v = dal::detail::is_one_of_v<Task, task::compute>;
template <typename Task = task::by_default>
class descriptor_base : public base {
static_assert(is_valid_task_v<Task>);
public:
using tag_t = descriptor_tag;
using float_t = float;
using method_t = method::by_default;
using task_t = Task;
descriptor_base();
result_option_id get_result_options() const;
protected:
void set_result_options_impl(const result_option_id& value);
private:
dal::detail::pimpl<descriptor_impl<Task>> impl_;
};
} // namespace v1
using v1::descriptor_tag;
using v1::descriptor_impl;
using v1::descriptor_base;
using v1::is_valid_float_v;
using v1::is_valid_method_v;
using v1::is_valid_task_v;
} // namespace detail
namespace v1 {
/// @tparam Float The floating-point type that the algorithm uses for
/// intermediate computations. Can be :expr:`float` or
/// :expr:`double`.
/// @tparam Method Tag-type that specifies an implementation of algorithm. Can
/// be :expr:`method::v1::dense`.
/// @tparam Task Tag-type that specifies the type of the problem to solve. Can
/// be :expr:`task::v1::compute`.
template <typename Float = detail::descriptor_base<>::float_t,
typename Method = detail::descriptor_base<>::method_t,
typename Task = detail::descriptor_base<>::task_t>
class descriptor : public detail::descriptor_base<Task> {
static_assert(detail::is_valid_float_v<Float>);
static_assert(detail::is_valid_method_v<Method>);
static_assert(detail::is_valid_task_v<Task>);
using base_t = detail::descriptor_base<Task>;
public:
using float_t = Float;
using method_t = Method;
using task_t = Task;
/// Choose which results should be computed and returned.
result_option_id get_result_options() const {
return base_t::get_result_options();
}
auto& set_result_options(const result_option_id& value) {
base_t::set_result_options_impl(value);
return *this;
}
};
} // namespace v1
using v1::descriptor;
} // namespace oneapi::dal::basic_statistics
|
; A188087: Positions of 0 in A188086; complement of A188088.
; 1,2,3,5,6,7,9,10,11,12,13,14,16,17,18,20,21,22,24,25,26,27,28,29,31,32,33,35,36,37,39,40,41,42,43,44,46,47,48,50,51,52,53,54,55,57,58,59,61,62,63,65,66,67,68,69,70,72,73,74,76,77,78,80,81,82,83,84,85,87,88,89,91,92,93,95,96,97,98,99,100,102,103,104,106,107,108,109,110,111,113
mov $2,$0
div $0,3
seq $0,76538 ; Numerators a(n) of fractions slowly converging to e: let a(1) = 0, b(n) = n - a(n); if (a(n) + 1) / b(n) < e then a(n+1) = a(n) + 1, else a(n+1)= a(n).
add $0,1
add $0,$2
|
; A278129: a(n) = 348*2^n - 188.
; 160,508,1204,2596,5380,10948,22084,44356,88900,177988,356164,712516,1425220,2850628,5701444,11403076,22806340,45612868,91225924,182452036,364904260,729808708,1459617604,2919235396,5838470980,11676942148,23353884484
mov $1,2
pow $1,$0
sub $1,1
mul $1,348
add $1,160
|
; Original address was $A5CD
; 7-5 underground
.word W705L ; Alternate level layout
.word W705O ; Alternate object layout
.byte LEVEL1_SIZE_08 | LEVEL1_YSTART_180
.byte LEVEL2_BGPAL_07 | LEVEL2_OBJPAL_09 | LEVEL2_XSTART_18
.byte LEVEL3_TILESET_01 | LEVEL3_VSCROLL_LOCKED | LEVEL3_PIPENOTEXIT
.byte LEVEL4_BGBANK_INDEX(1) | LEVEL4_INITACT_NOTHING
.byte LEVEL5_BGM_UNDERGROUND | LEVEL5_TIME_300
.byte $4B, $00, $B4, $7F, $40, $00, $B0, $7F, $5A, $00, $B0, $7F, $41, $00, $BE, $0F
.byte $50, $00, $B9, $01, $30, $02, $D5, $4B, $14, $BE, $08, $41, $1F, $BE, $02, $24
.byte $19, $13, $27, $16, $13, $49, $12, $FD, $47, $1D, $FB, $53, $20, $B3, $00, $56
.byte $20, $B0, $1A, $44, $23, $B0, $06, $45, $24, $BA, $04, $50, $27, $B5, $01, $44
.byte $2B, $BB, $02, $45, $2F, $B0, $11, $48, $22, $FB, $48, $29, $FB, $48, $2E, $FB
.byte $32, $25, $00, $24, $22, $0E, $24, $2A, $0E, $36, $2B, $0E, $36, $2C, $0E, $37
.byte $25, $10, $38, $25, $10, $45, $30, $BA, $00, $45, $33, $B3, $00, $49, $33, $B1
.byte $05, $45, $3F, $BF, $02, $54, $3F, $B5, $02, $25, $35, $0E, $36, $34, $0E, $36
.byte $35, $0E, $25, $32, $0F, $28, $3B, $01, $32, $36, $24, $48, $31, $FB, $48, $3D
.byte $FF, $57, $30, $E0, $58, $30, $E0, $59, $30, $E0, $41, $44, $B2, $00, $45, $43
.byte $B0, $00, $45, $44, $BA, $01, $47, $48, $B0, $04, $43, $4E, $B0, $07, $24, $44
.byte $10, $32, $4D, $10, $33, $4D, $10, $34, $4D, $10, $35, $4D, $13, $35, $45, $82
.byte $35, $4E, $21, $49, $42, $F8, $49, $4E, $F9, $50, $56, $B9, $08, $44, $5A, $B0
.byte $06, $48, $53, $B0, $08, $23, $56, $0E, $23, $57, $0E, $23, $58, $0E, $23, $59
.byte $0E, $49, $5F, $FD, $28, $50, $0E, $28, $51, $0E, $28, $52, $0E, $50, $64, $B7
.byte $00, $58, $62, $B1, $00, $58, $66, $B1, $00, $44, $61, $B0, $08, $44, $6A, $B6
.byte $02, $54, $6C, $B2, $00, $56, $6C, $B0, $02, $36, $6F, $0E, $36, $70, $0E, $36
.byte $71, $0E, $36, $72, $0E, $36, $73, $0E, $36, $74, $0E, $26, $6F, $0F, $48, $68
.byte $FE, $49, $6D, $FA, $45, $61, $E4, $46, $61, $E0, $47, $61, $E0, $46, $65, $E0
.byte $47, $65, $E0, $48, $61, $E4, $49, $61, $E4, $4A, $61, $E4, $41, $70, $B9, $0F
.byte $50, $73, $B2, $00, $56, $75, $B3, $00, $30, $78, $C6, $50, $7B, $B9, $04, $E7
.byte $61, $42, $FF
|
; A335691: A000166(n)^2.
; 1,0,1,4,81,1936,70225,3437316,220017889,17821182016,1782120871521,215636596084900,31051670188655281,5247732257301156624,1028555522495168900401,231424992560450869558756,59244798095490816735545025,17121746649596584336387952896
seq $0,166 ; Subfactorial or rencontres numbers, or derangements: number of permutations of n elements with no fixed points.
pow $0,2
|
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_PrimitiveID 0 x 0 PRIMID uint x
// SV_SampleIndex 0 x 1 SAMPLE uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
// Pixel Shader runs at sample frequency
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_input_ps_sgv constant v0.x, primitive_id
dcl_input_ps_sgv constant v1.x, sampleIndex
dcl_input vCoverage
dcl_output o0.xyzw
dcl_temps 1
//
// Initial variable locations:
// v0.x <- b;
// vCoverage.x <- c;
// v1.x <- d;
// o0.x <- <main return value>.x; o0.y <- <main return value>.y; o0.z <- <main return value>.z; o0.w <- <main return value>.w
//
#line 4 "L:\C++ GitHub\DirectX 11 Engine 2019\Shaders\Shaders\PS\shTest.hlsl"
iadd r0.x, v0.x, vCoverage.x
imul null, r0.x, r0.x, v1.x
utof o0.x, r0.x
#line 5
imad r0.x, v0.x, v1.x, vCoverage.x
utof o0.y, r0.x
#line 6
imad r0.x, vCoverage.x, v0.x, v1.x
utof o0.zw, r0.xxxx
#line 9
ret
// Approximately 8 instruction slots used
// 0000: 43425844 24e245a6 e50701f0 8e9f579d DXBC.E.$.....W..
// 0010: a82be3d1 00000001 000030e4 00000006 ..+..___.0__.___
// 0020: 00000038 000000a4 00000104 00000138 8___.___..__8.__
// 0030: 00000240 000002dc 46454452 00000064 @.__..__RDEFd___
// 0040: 00000000 00000000 00000000 0000003c ____________<___
// 0050: ffff0500 00000501 0000003c 31314452 _.....__<___RD11
// 0060: 0000003c 00000018 00000020 00000028 <___.___ ___(___
// 0070: 00000024 0000000c 00000000 7263694d $___._______Micr
// 0080: 666f736f 52282074 4c482029 53204c53 osoft (R) HLSL S
// 0090: 65646168 6f432072 6c69706d 31207265 hader Compiler 1
// 00a0: 00312e30 4e475349 00000058 00000002 0.1_ISGNX___.___
// 00b0: 00000008 00000038 00000000 00000007 .___8_______.___
// 00c0: 00000001 00000000 00000101 00000047 ._______..__G___
// 00d0: 00000000 0000000a 00000001 00000001 ____.___.___.___
// 00e0: 00000101 505f5653 696d6972 65766974 ..__SV_Primitive
// 00f0: 53004449 61535f56 656c706d 65646e49 ID_SV_SampleInde
// 0100: abab0078 4e47534f 0000002c 00000001 x_..OSGN,___.___
// 0110: 00000008 00000020 00000000 00000000 .___ ___________
// 0120: 00000003 00000000 0000000f 545f5653 ._______.___SV_T
// 0130: 65677261 abab0074 58454853 00000100 arget_..SHEX_.__
// 0140: 00000050 00000040 0100086a 04000863 P___@___j._.c._.
// 0150: 00101012 00000000 00000007 04000863 ..._____.___c._.
// 0160: 00101012 00000001 0000000a 0200005f ..._.___.______.
// 0170: 00023001 03000065 001020f2 00000000 .0._e__.. ._____
// 0180: 02000068 00000001 0600001e 00100012 h__..___.__.._._
// 0190: 00000000 0010100a 00000000 0002300a ____..._____.0._
// 01a0: 08000026 0000d000 00100012 00000000 &__._.__._._____
// 01b0: 0010000a 00000000 0010100a 00000001 ._._____..._.___
// 01c0: 05000056 00102012 00000000 0010000a V__.. ._____._._
// 01d0: 00000000 08000023 00100012 00000000 ____#__.._._____
// 01e0: 0010100a 00000000 0010100a 00000001 ..._____..._.___
// 01f0: 0002300a 05000056 00102022 00000000 .0._V__." ._____
// 0200: 0010000a 00000000 08000023 00100012 ._._____#__.._._
// 0210: 00000000 0002300a 0010100a 00000000 ____.0._..._____
// 0220: 0010100a 00000001 05000056 001020c2 ..._.___V__.. ._
// 0230: 00000000 00100006 00000000 0100003e ____._._____>__.
// 0240: 54415453 00000094 00000008 00000001 STAT.___.___.___
// 0250: 00000000 00000004 00000000 00000004 ____._______.___
// 0260: 00000000 00000001 00000000 00000000 ____.___________
// 0270: 00000000 00000000 00000000 00000000 ________________
// 0280: 00000000 00000000 00000000 00000000 ________________
// 0290: 00000000 00000000 00000000 00000003 ____________.___
// 02a0: 00000000 00000000 00000000 00000000 ________________
// 02b0: 00000000 00000000 00000001 00000000 ________._______
// 02c0: 00000000 00000000 00000000 00000000 ________________
// 02d0: 00000000 00000000 00000000 42445053 ____________SPDB
// 02e0: 00002e00 7263694d 666f736f 2f432074 _.__Microsoft C/
// 02f0: 202b2b43 2046534d 30302e37 441a0a0d C++ MSF 7.00...D
// 0300: 00000053 00000200 00000002 00000017 S____.__.___.___
// 0310: 00000084 00000000 00000016 00000000 ._______._______
// 0320: 00000000 00000000 00000000 00000000 ________________
// 0330: 00000000 00000000 00000000 00000000 ________________
// 0340: 00000000 00000000 00000000 00000000 ________________
// 0350: 00000000 00000000 00000000 00000000 ________________
// 0360: 00000000 00000000 00000000 00000000 ________________
// 0370: 00000000 00000000 00000000 00000000 ________________
// 0380: 00000000 00000000 00000000 00000000 ________________
// 0390: 00000000 00000000 00000000 00000000 ________________
// 03a0: 00000000 00000000 00000000 00000000 ________________
// 03b0: 00000000 00000000 00000000 00000000 ________________
// 03c0: 00000000 00000000 00000000 00000000 ________________
// 03d0: 00000000 00000000 00000000 00000000 ________________
// 03e0: 00000000 00000000 00000000 00000000 ________________
// 03f0: 00000000 00000000 00000000 00000000 ________________
// 0400: 00000000 00000000 00000000 00000000 ________________
// 0410: 00000000 00000000 00000000 00000000 ________________
// 0420: 00000000 00000000 00000000 00000000 ________________
// 0430: 00000000 00000000 00000000 00000000 ________________
// 0440: 00000000 00000000 00000000 00000000 ________________
// 0450: 00000000 00000000 00000000 00000000 ________________
// 0460: 00000000 00000000 00000000 00000000 ________________
// 0470: 00000000 00000000 00000000 00000000 ________________
// 0480: 00000000 00000000 00000000 00000000 ________________
// 0490: 00000000 00000000 00000000 00000000 ________________
// 04a0: 00000000 00000000 00000000 00000000 ________________
// 04b0: 00000000 00000000 00000000 00000000 ________________
// 04c0: 00000000 00000000 00000000 00000000 ________________
// 04d0: 00000000 00000000 00000000 00000000 ________________
// 04e0: 00000000 ffffffc0 ffffffff ffffffff ____............
// 04f0: ffffffff ffffffff ffffffff ffffffff ................
// 0500: ffffffff ffffffff ffffffff ffffffff ................
// 0510: ffffffff ffffffff ffffffff ffffffff ................
// 0520: ffffffff ffffffff ffffffff ffffffff ................
// 0530: ffffffff ffffffff ffffffff ffffffff ................
// 0540: ffffffff ffffffff ffffffff ffffffff ................
// 0550: ffffffff ffffffff ffffffff ffffffff ................
// 0560: ffffffff ffffffff ffffffff ffffffff ................
// 0570: ffffffff ffffffff ffffffff ffffffff ................
// 0580: ffffffff ffffffff ffffffff ffffffff ................
// 0590: ffffffff ffffffff ffffffff ffffffff ................
// 05a0: ffffffff ffffffff ffffffff ffffffff ................
// 05b0: ffffffff ffffffff ffffffff ffffffff ................
// 05c0: ffffffff ffffffff ffffffff ffffffff ................
// 05d0: ffffffff ffffffff ffffffff ffffffff ................
// 05e0: ffffffff ffffffff ffffffff ffffffff ................
// 05f0: ffffffff ffffffff ffffffff ffffffff ................
// 0600: ffffffff ffffffff ffffffff ffffffff ................
// 0610: ffffffff ffffffff ffffffff ffffffff ................
// 0620: ffffffff ffffffff ffffffff ffffffff ................
// 0630: ffffffff ffffffff ffffffff ffffffff ................
// 0640: ffffffff ffffffff ffffffff ffffffff ................
// 0650: ffffffff ffffffff ffffffff ffffffff ................
// 0660: ffffffff ffffffff ffffffff ffffffff ................
// 0670: ffffffff ffffffff ffffffff ffffffff ................
// 0680: ffffffff ffffffff ffffffff ffffffff ................
// 0690: ffffffff ffffffff ffffffff ffffffff ................
// 06a0: ffffffff ffffffff ffffffff ffffffff ................
// 06b0: ffffffff ffffffff ffffffff ffffffff ................
// 06c0: ffffffff ffffffff ffffffff ffffffff ................
// 06d0: ffffffff ffffffff ffffffff ffffffff ................
// 06e0: ffffffff ff800038 ffffffff ffffffff ....8_..........
// 06f0: ffffffff ffffffff ffffffff ffffffff ................
// 0700: ffffffff ffffffff ffffffff ffffffff ................
// 0710: ffffffff ffffffff ffffffff ffffffff ................
// 0720: ffffffff ffffffff ffffffff ffffffff ................
// 0730: ffffffff ffffffff ffffffff ffffffff ................
// 0740: ffffffff ffffffff ffffffff ffffffff ................
// 0750: ffffffff ffffffff ffffffff ffffffff ................
// 0760: ffffffff ffffffff ffffffff ffffffff ................
// 0770: ffffffff ffffffff ffffffff ffffffff ................
// 0780: ffffffff ffffffff ffffffff ffffffff ................
// 0790: ffffffff ffffffff ffffffff ffffffff ................
// 07a0: ffffffff ffffffff ffffffff ffffffff ................
// 07b0: ffffffff ffffffff ffffffff ffffffff ................
// 07c0: ffffffff ffffffff ffffffff ffffffff ................
// 07d0: ffffffff ffffffff ffffffff ffffffff ................
// 07e0: ffffffff ffffffff ffffffff ffffffff ................
// 07f0: ffffffff ffffffff ffffffff ffffffff ................
// 0800: ffffffff ffffffff ffffffff ffffffff ................
// 0810: ffffffff ffffffff ffffffff ffffffff ................
// 0820: ffffffff ffffffff ffffffff ffffffff ................
// 0830: ffffffff ffffffff ffffffff ffffffff ................
// 0840: ffffffff ffffffff ffffffff ffffffff ................
// 0850: ffffffff ffffffff ffffffff ffffffff ................
// 0860: ffffffff ffffffff ffffffff ffffffff ................
// 0870: ffffffff ffffffff ffffffff ffffffff ................
// 0880: ffffffff ffffffff ffffffff ffffffff ................
// 0890: ffffffff ffffffff ffffffff ffffffff ................
// 08a0: ffffffff ffffffff ffffffff ffffffff ................
// 08b0: ffffffff ffffffff ffffffff ffffffff ................
// 08c0: ffffffff ffffffff ffffffff ffffffff ................
// 08d0: ffffffff ffffffff ffffffff ffffffff ................
// 08e0: ffffffff 00000005 00000020 0000003c .....___ ___<___
// 08f0: 00000000 ffffffff 00000000 00000006 ____....____.___
// 0900: 00000005 00000000 00000000 00000000 ._______________
// 0910: 00000000 00000000 00000000 00000000 ________________
// 0920: 00000000 00000000 00000000 00000000 ________________
// 0930: 00000000 00000000 00000000 00000000 ________________
// 0940: 00000000 00000000 00000000 00000000 ________________
// 0950: 00000000 00000000 00000000 00000000 ________________
// 0960: 00000000 00000000 00000000 00000000 ________________
// 0970: 00000000 00000000 00000000 00000000 ________________
// 0980: 00000000 00000000 00000000 00000000 ________________
// 0990: 00000000 00000000 00000000 00000000 ________________
// 09a0: 00000000 00000000 00000000 00000000 ________________
// 09b0: 00000000 00000000 00000000 00000000 ________________
// 09c0: 00000000 00000000 00000000 00000000 ________________
// 09d0: 00000000 00000000 00000000 00000000 ________________
// 09e0: 00000000 00000000 00000000 00000000 ________________
// 09f0: 00000000 00000000 00000000 00000000 ________________
// 0a00: 00000000 00000000 00000000 00000000 ________________
// 0a10: 00000000 00000000 00000000 00000000 ________________
// 0a20: 00000000 00000000 00000000 00000000 ________________
// 0a30: 00000000 00000000 00000000 00000000 ________________
// 0a40: 00000000 00000000 00000000 00000000 ________________
// 0a50: 00000000 00000000 00000000 00000000 ________________
// 0a60: 00000000 00000000 00000000 00000000 ________________
// 0a70: 00000000 00000000 00000000 00000000 ________________
// 0a80: 00000000 00000000 00000000 00000000 ________________
// 0a90: 00000000 00000000 00000000 00000000 ________________
// 0aa0: 00000000 00000000 00000000 00000000 ________________
// 0ab0: 00000000 00000000 00000000 00000000 ________________
// 0ac0: 00000000 00000000 00000000 00000000 ________________
// 0ad0: 00000000 00000000 00000000 00000000 ________________
// 0ae0: 00000000 00000003 00000000 00000000 ____.___________
// 0af0: 00000000 00000000 00000000 00000000 ________________
// 0b00: 00000000 00000000 00000000 00000000 ________________
// 0b10: 00000000 00000000 00000000 00000000 ________________
// 0b20: 00000000 00000000 00000000 00000000 ________________
// 0b30: 00000000 00000000 00000000 00000000 ________________
// 0b40: 00000000 00000000 00000000 00000000 ________________
// 0b50: 00000000 00000000 00000000 00000000 ________________
// 0b60: 00000000 00000000 00000000 00000000 ________________
// 0b70: 00000000 00000000 00000000 00000000 ________________
// 0b80: 00000000 00000000 00000000 00000000 ________________
// 0b90: 00000000 00000000 00000000 00000000 ________________
// 0ba0: 00000000 00000000 00000000 00000000 ________________
// 0bb0: 00000000 00000000 00000000 00000000 ________________
// 0bc0: 00000000 00000000 00000000 00000000 ________________
// 0bd0: 00000000 00000000 00000000 00000000 ________________
// 0be0: 00000000 00000000 00000000 00000000 ________________
// 0bf0: 00000000 00000000 00000000 00000000 ________________
// 0c00: 00000000 00000000 00000000 00000000 ________________
// 0c10: 00000000 00000000 00000000 00000000 ________________
// 0c20: 00000000 00000000 00000000 00000000 ________________
// 0c30: 00000000 00000000 00000000 00000000 ________________
// 0c40: 00000000 00000000 00000000 00000000 ________________
// 0c50: 00000000 00000000 00000000 00000000 ________________
// 0c60: 00000000 00000000 00000000 00000000 ________________
// 0c70: 00000000 00000000 00000000 00000000 ________________
// 0c80: 00000000 00000000 00000000 00000000 ________________
// 0c90: 00000000 00000000 00000000 00000000 ________________
// 0ca0: 00000000 00000000 00000000 00000000 ________________
// 0cb0: 00000000 00000000 00000000 00000000 ________________
// 0cc0: 00000000 00000000 00000000 00000000 ________________
// 0cd0: 00000000 00000000 00000000 00000000 ________________
// 0ce0: 00000000 01312e94 5da5a92d 00000001 ____..1.-..].___
// 0cf0: 5a046c39 4f7d0cdf 850b96a4 6685aa75 9l.Z..}O....u..f
// 0d00: 00000000 00000000 00000001 00000001 ________.___.___
// 0d10: 00000000 00000000 00000000 013351dc ____________.Q3.
// 0d20: 00000000 00000000 00000000 00000000 ________________
// 0d30: 00000000 00000000 00000000 00000000 ________________
// 0d40: 00000000 00000000 00000000 00000000 ________________
// 0d50: 00000000 00000000 00000000 00000000 ________________
// 0d60: 00000000 00000000 00000000 00000000 ________________
// 0d70: 00000000 00000000 00000000 00000000 ________________
// 0d80: 00000000 00000000 00000000 00000000 ________________
// 0d90: 00000000 00000000 00000000 00000000 ________________
// 0da0: 00000000 00000000 00000000 00000000 ________________
// 0db0: 00000000 00000000 00000000 00000000 ________________
// 0dc0: 00000000 00000000 00000000 00000000 ________________
// 0dd0: 00000000 00000000 00000000 00000000 ________________
// 0de0: 00000000 00000000 00000000 00000000 ________________
// 0df0: 00000000 00000000 00000000 00000000 ________________
// 0e00: 00000000 00000000 00000000 00000000 ________________
// 0e10: 00000000 00000000 00000000 00000000 ________________
// 0e20: 00000000 00000000 00000000 00000000 ________________
// 0e30: 00000000 00000000 00000000 00000000 ________________
// 0e40: 00000000 00000000 00000000 00000000 ________________
// 0e50: 00000000 00000000 00000000 00000000 ________________
// 0e60: 00000000 00000000 00000000 00000000 ________________
// 0e70: 00000000 00000000 00000000 00000000 ________________
// 0e80: 00000000 00000000 00000000 00000000 ________________
// 0e90: 00000000 00000000 00000000 00000000 ________________
// 0ea0: 00000000 00000000 00000000 00000000 ________________
// 0eb0: 00000000 00000000 00000000 00000000 ________________
// 0ec0: 00000000 00000000 00000000 00000000 ________________
// 0ed0: 00000000 00000000 00000000 00000000 ________________
// 0ee0: 00000000 53443344 00524448 00000100 ____D3DSHDR__.__
// 0ef0: 00000000 00000000 00000000 00000000 ________________
// 0f00: 00000000 00000000 60000020 00000000 ________ __`____
// 0f10: 00000000 00000000 00000000 00000000 ________________
// 0f20: 00000000 00000000 00000000 00000000 ________________
// 0f30: 00000000 00000000 00000000 00000000 ________________
// 0f40: 00000000 00000000 00000000 00000000 ________________
// 0f50: 00000000 00000000 00000000 00000000 ________________
// 0f60: 00000000 00000000 00000000 00000000 ________________
// 0f70: 00000000 00000000 00000000 00000000 ________________
// 0f80: 00000000 00000000 00000000 00000000 ________________
// 0f90: 00000000 00000000 00000000 00000000 ________________
// 0fa0: 00000000 00000000 00000000 00000000 ________________
// 0fb0: 00000000 00000000 00000000 00000000 ________________
// 0fc0: 00000000 00000000 00000000 00000000 ________________
// 0fd0: 00000000 00000000 00000000 00000000 ________________
// 0fe0: 00000000 00000000 00000000 00000000 ________________
// 0ff0: 00000000 00000000 00000000 00000000 ________________
// 1000: 00000000 00000000 00000000 00000000 ________________
// 1010: 00000000 00000000 00000000 00000000 ________________
// 1020: 00000000 00000000 00000000 00000000 ________________
// 1030: 00000000 00000000 00000000 00000000 ________________
// 1040: 00000000 00000000 00000000 00000000 ________________
// 1050: 00000000 00000000 00000000 00000000 ________________
// 1060: 00000000 00000000 00000000 00000000 ________________
// 1070: 00000000 00000000 00000000 00000000 ________________
// 1080: 00000000 00000000 00000000 00000000 ________________
// 1090: 00000000 00000000 00000000 00000000 ________________
// 10a0: 00000000 00000000 00000000 00000000 ________________
// 10b0: 00000000 00000000 00000000 00000000 ________________
// 10c0: 00000000 00000000 00000000 00000000 ________________
// 10d0: 00000000 00000000 00000000 00000000 ________________
// 10e0: 00000000 0003fa8f 00005ac6 0002f0e9 ____..._.Z__..._
// 10f0: 00020076 00001000 00000000 00000000 v_.__.__________
// 1100: 00000000 00000000 00000000 00000000 ________________
// 1110: 00000000 00000000 00000000 00000000 ________________
// 1120: 00000000 00000000 00000000 00000000 ________________
// 1130: 00000000 00000000 00000000 00000000 ________________
// 1140: 00000000 00000000 00000000 00000000 ________________
// 1150: 00000000 00000000 00000000 00000000 ________________
// 1160: 00000000 00000000 00000000 00000000 ________________
// 1170: 00000000 00000000 00000000 00000000 ________________
// 1180: 00000000 00000000 00000000 00000000 ________________
// 1190: 00000000 00000000 00000000 00000000 ________________
// 11a0: 00000000 00000000 00000000 00000000 ________________
// 11b0: 00000000 00000000 00000000 00000000 ________________
// 11c0: 00000000 00000000 00000000 00000000 ________________
// 11d0: 00000000 00000000 00000000 00000000 ________________
// 11e0: 00000000 00000000 00000000 00000000 ________________
// 11f0: 00000000 00000000 00000000 00000000 ________________
// 1200: 00000000 00000000 00000000 00000000 ________________
// 1210: 00000000 00000000 00000000 00000000 ________________
// 1220: 00000000 00000000 00000000 00000000 ________________
// 1230: 00000000 00000000 00000000 00000000 ________________
// 1240: 00000000 00000000 00000000 00000000 ________________
// 1250: 00000000 00000000 00000000 00000000 ________________
// 1260: 00000000 00000000 00000000 00000000 ________________
// 1270: 00000000 00000000 00000000 00000000 ________________
// 1280: 00000000 00000000 00000000 00000000 ________________
// 1290: 00000000 00000000 00000000 00000000 ________________
// 12a0: 00000000 00000000 00000000 00000000 ________________
// 12b0: 00000000 00000000 00000000 00000000 ________________
// 12c0: 00000000 00000000 00000000 00000000 ________________
// 12d0: 00000000 00000000 00000000 00000000 ________________
// 12e0: 00000000 616f6c66 6d203474 286e6961 ____float4 main(
// 12f0: 746e6975 3a206220 5f565320 6d697250 uint b : SV_Prim
// 1300: 76697469 2c444965 200a0d20 20202020 itiveID, ..
// 1310: 20202020 75202020 20746e69 203a2063 uint c :
// 1320: 435f5653 7265766f 2c656761 200a0d20 SV_Coverage, ..
// 1330: 20202020 20202020 75202020 20746e69 uint
// 1340: 203a2064 535f5653 6c706d61 646e4965 d : SV_SampleInd
// 1350: 20297865 5653203a 7261545f 30746567 ex) : SV_Target0
// 1360: 0a0d7b20 20202020 616f6c66 20612074 {.. float a
// 1370: 6328203d 62202b20 202a2029 0a0d3b64 = (c + b) * d;..
// 1380: 20202020 616f6c66 20652074 2063203d float e = c
// 1390: 2062202b 3b64202a 20200a0d 6c662020 + b * d;.. fl
// 13a0: 2074616f 203d2066 202a2063 202b2062 oat f = c * b +
// 13b0: 0a0d3b64 20202020 616f6c66 20672074 d;.. float g
// 13c0: 616d203d 2c632864 202c6220 0d3b2964 = mad(c, b, d);.
// 13d0: 200a0d0a 72202020 72757465 6c66206e ... return fl
// 13e0: 3474616f 202c6128 66202c65 2967202c oat4(a, e, f, g)
// 13f0: 7d0a0d3b 00000a0d 00000000 00000000 ;..}..__________
// 1400: 00000000 00000000 00000000 00000000 ________________
// 1410: 00000000 00000000 00000000 00000000 ________________
// 1420: 00000000 00000000 00000000 00000000 ________________
// 1430: 00000000 00000000 00000000 00000000 ________________
// 1440: 00000000 00000000 00000000 00000000 ________________
// 1450: 00000000 00000000 00000000 00000000 ________________
// 1460: 00000000 00000000 00000000 00000000 ________________
// 1470: 00000000 00000000 00000000 00000000 ________________
// 1480: 00000000 00000000 00000000 00000000 ________________
// 1490: 00000000 00000000 00000000 00000000 ________________
// 14a0: 00000000 00000000 00000000 00000000 ________________
// 14b0: 00000000 00000000 00000000 00000000 ________________
// 14c0: 00000000 00000000 00000000 00000000 ________________
// 14d0: 00000000 00000000 00000000 00000000 ________________
// 14e0: 00000000 effeeffe 00000001 0000019d ____.....___..__
// 14f0: 5c3a4c00 202b2b43 48746947 445c6275 _L:\C++ GitHub\D
// 1500: 63657269 31205874 6e452031 656e6967 irectX 11 Engine
// 1510: 31303220 68535c39 72656461 68535c73 2019\Shaders\Sh
// 1520: 72656461 53505c73 5468735c 2e747365 aders\PS\shTest.
// 1530: 6c736c68 3a6c0000 2b2b635c 74696720 hlsl__l:\c++ git
// 1540: 5c627568 65726964 20787463 65203131 hub\directx 11 e
// 1550: 6e69676e 30322065 735c3931 65646168 ngine 2019\shade
// 1560: 735c7372 65646168 705c7372 68735c73 rs\shaders\ps\sh
// 1570: 74736574 736c682e 6c66006c 3474616f test.hlsl_float4
// 1580: 69616d20 6975286e 6220746e 53203a20 main(uint b : S
// 1590: 72505f56 74696d69 49657669 0d202c44 V_PrimitiveID, .
// 15a0: 2020200a 20202020 20202020 6e697520 . uin
// 15b0: 20632074 5653203a 766f435f 67617265 t c : SV_Coverag
// 15c0: 0d202c65 2020200a 20202020 20202020 e, ..
// 15d0: 6e697520 20642074 5653203a 6d61535f uint d : SV_Sam
// 15e0: 49656c70 7865646e 203a2029 545f5653 pleIndex) : SV_T
// 15f0: 65677261 7b203074 20200a0d 6c662020 arget0 {.. fl
// 1600: 2074616f 203d2061 2b206328 20296220 oat a = (c + b)
// 1610: 3b64202a 20200a0d 6c662020 2074616f * d;.. float
// 1620: 203d2065 202b2063 202a2062 0a0d3b64 e = c + b * d;..
// 1630: 20202020 616f6c66 20662074 2063203d float f = c
// 1640: 2062202a 3b64202b 20200a0d 6c662020 * b + d;.. fl
// 1650: 2074616f 203d2067 2864616d 62202c63 oat g = mad(c, b
// 1660: 2964202c 0d0a0d3b 2020200a 74657220 , d);.... ret
// 1670: 206e7275 616f6c66 61283474 2c65202c urn float4(a, e,
// 1680: 202c6620 0d3b2967 0a0d7d0a 00000700 f, g);..}.._.__
// 1690: 00004600 00004500 00008a00 00000000 _F___E___.______
// 16a0: 00000000 00000000 00000100 00000400 _________.___.__
// 16b0: 00000000 00000000 00000000 00000000 ________________
// 16c0: 00000000 00000000 00000000 00000000 ________________
// 16d0: 00000000 00000000 00000000 00000000 ________________
// 16e0: 00000000 0130e21b 00000080 2c33fe26 ____..0..___&.3,
// 16f0: 01d58349 00000001 00000000 00000000 I....___________
// 1700: 00000000 00000000 00000000 00000000 ________________
// 1710: 00000000 00000000 00000000 00000000 ________________
// 1720: 00000000 00000001 00000002 00000001 ____.___.___.___
// 1730: 00000001 00000000 00000046 00000028 ._______F___(___
// 1740: 0130e21b e942418c 00000112 00000001 ..0..AB...__.___
// 1750: 00000045 00000046 00000000 00000000 E___F___________
// 1760: 00000000 00000000 00000000 00000000 ________________
// 1770: 00000000 00000000 00000000 00000000 ________________
// 1780: 00000000 00000000 00000000 00000000 ________________
// 1790: 00000000 00000000 00000000 00000000 ________________
// 17a0: 00000000 00000000 00000000 00000000 ________________
// 17b0: 00000000 00000000 00000000 00000000 ________________
// 17c0: 00000000 00000000 00000000 00000000 ________________
// 17d0: 00000000 00000000 00000000 00000000 ________________
// 17e0: 00000000 00000000 00000000 00000000 ________________
// 17f0: 00000000 00000000 00000000 00000000 ________________
// 1800: 00000000 00000000 00000000 00000000 ________________
// 1810: 00000000 00000000 00000000 00000000 ________________
// 1820: 00000000 00000000 00000000 00000000 ________________
// 1830: 00000000 00000000 00000000 00000000 ________________
// 1840: 00000000 00000000 00000000 00000000 ________________
// 1850: 00000000 00000000 00000000 00000000 ________________
// 1860: 00000000 00000000 00000000 00000000 ________________
// 1870: 00000000 00000000 00000000 00000000 ________________
// 1880: 00000000 00000000 00000000 00000000 ________________
// 1890: 00000000 00000000 00000000 00000000 ________________
// 18a0: 00000000 00000000 00000000 00000000 ________________
// 18b0: 00000000 00000000 00000000 00000000 ________________
// 18c0: 00000000 00000000 00000000 00000000 ________________
// 18d0: 00000000 00000000 00000000 00000000 ________________
// 18e0: 00000000 00000004 113c0042 00000110 ____.___B_<...__
// 18f0: 000a0100 00840001 000a4563 00840001 _.._._._cE._._._
// 1900: 694d4563 736f7263 2074666f 20295228 cEMicrosoft (R)
// 1910: 4c534c48 61685320 20726564 706d6f43 HLSL Shader Comp
// 1920: 72656c69 2e303120 00000031 113d0036 iler 10.1___6_=.
// 1930: 736c6801 616c466c 30007367 31303478 .hlslFlags_0x401
// 1940: 736c6800 7261546c 00746567 355f7370 _hlslTarget_ps_5
// 1950: 6800305f 456c736c 7972746e 69616d00 _0_hlslEntry_mai
// 1960: 0000006e 1110002a 00000000 00000214 n___*_..____..__
// 1970: 00000000 000000b8 00000000 000000b8 ____._______.___
// 1980: 00001003 00000048 6da00001 006e6961 ..__H___._.main_
// 1990: 113e002a 00000075 00620001 00000000 *_>.u___._b_____
// 19a0: 00000000 00000000 00000000 00000000 ________________
// 19b0: 00000000 00000000 00000000 11500016 ____________._P.
// 19c0: 00010001 00040000 00000048 00b80001 ._.___._H___._._
// 19d0: 00000000 113e002a 00000075 00630001 ____*_>.u___._c_
// 19e0: 00000000 00000000 00000000 00000000 ________________
// 19f0: 00000000 00000000 00000000 00000000 ________________
// 1a00: 11500016 00010023 00040000 00000048 ._P.#_.___._H___
// 1a10: 00b80001 ffffff70 113e002a 00000075 ._._p...*_>.u___
// 1a20: 00640001 00000000 00000000 00000000 ._d_____________
// 1a30: 00000000 00000000 00000000 00000000 ________________
// 1a40: 00000000 11500016 00010001 00040000 ____._P.._.___._
// 1a50: 00000048 00b80001 00000010 113e003a H___._._.___:_>.
// 1a60: 00001002 6d3c0088 206e6961 75746572 ..__._<main retu
// 1a70: 76206e72 65756c61 0000003e 00000000 rn value>_______
// 1a80: 00000000 00000000 00000000 00000000 ________________
// 1a90: 00000000 00000000 11500016 00050002 ________._P.._._
// 1aa0: 00040000 00000048 00b80001 00000000 __._H___._._____
// 1ab0: 11500016 00050002 00040004 00000048 ._P.._._._._H___
// 1ac0: 00b80001 00000004 11500016 00050002 ._._.___._P.._._
// 1ad0: 00040008 00000048 00b80001 00000008 ._._H___._._.___
// 1ae0: 11500016 00050002 0004000c 00000048 ._P.._._._._H___
// 1af0: 00b80001 0000000c 00060002 000000f4 ._._.___._._.___
// 1b00: 00000018 00000001 56a80110 7b4a21b6 .___.___...V.!J{
// 1b10: c167a37d 81bcd8d9 00009957 000000f2 }.g.....W.__.___
// 1b20: 000000d8 00000000 00010001 00000100 ._______._.__.__
// 1b30: 00000000 00000010 000000cc 00000048 ____.___.___H___
// 1b40: 80000004 00000048 00000004 00000060 .__.H___.___`___
// 1b50: 80000004 00000060 00000004 00000080 .__.`___.___.___
// 1b60: 80000004 00000080 00000004 00000094 .__..___.___.___
// 1b70: 80000005 00000094 00000005 000000b4 .__..___.___.___
// 1b80: 80000005 000000b4 00000005 000000c8 .__..___.___.___
// 1b90: 80000006 000000c8 00000006 000000e8 .__..___.___.___
// 1ba0: 80000006 000000e8 00000006 000000fc .__..___.___.___
// 1bb0: 80000009 000000fc 00000009 001a0005 .__..___.___._._
// 1bc0: 00140010 001a0005 0019000f 001a0005 ._._._._._._._._
// 1bd0: 0019000b 00180005 0017000f 00180005 ._._._._._._._._
// 1be0: 0017000b 00180005 0017000f 00180005 ._._._._._._._._
// 1bf0: 0017000b 001e0005 001e0005 000000f6 ._._._._._._.___
// 1c00: 00000004 00000000 00000004 00000000 ._______._______
// 1c10: 00000000 00000000 00000000 00000000 ________________
// 1c20: 00000000 00000000 00000000 00000000 ________________
// 1c30: 00000000 00000000 00000000 00000000 ________________
// 1c40: 00000000 00000000 00000000 00000000 ________________
// 1c50: 00000000 00000000 00000000 00000000 ________________
// 1c60: 00000000 00000000 00000000 00000000 ________________
// 1c70: 00000000 00000000 00000000 00000000 ________________
// 1c80: 00000000 00000000 00000000 00000000 ________________
// 1c90: 00000000 00000000 00000000 00000000 ________________
// 1ca0: 00000000 00000000 00000000 00000000 ________________
// 1cb0: 00000000 00000000 00000000 00000000 ________________
// 1cc0: 00000000 00000000 00000000 00000000 ________________
// 1cd0: 00000000 00000000 00000000 00000000 ________________
// 1ce0: 00000000 0131ca0b 00000038 00001000 ____..1.8____.__
// 1cf0: 00001004 00000048 ffff000a 00000004 ..__H___._...___
// 1d00: 0003ffff 00000000 00000010 00000010 ..._____.___.___
// 1d10: 00000008 00000018 00000000 12010012 .___._______._..
// 1d20: 00000003 00000075 00000075 00000075 .___u___u___u___
// 1d30: 151b0016 00000040 00000004 6c660010 ._..@___.___._fl
// 1d40: 3474616f f1f2f300 1518000a 00001001 oat4_...._....__
// 1d50: 00010001 1008000e 00001002 00030017 ._._._....__._._
// 1d60: 00001000 00000000 00000000 00000000 _.______________
// 1d70: 00000000 00000000 00000000 00000000 ________________
// 1d80: 00000000 00000000 00000000 00000000 ________________
// 1d90: 00000000 00000000 00000000 00000000 ________________
// 1da0: 00000000 00000000 00000000 00000000 ________________
// 1db0: 00000000 00000000 00000000 00000000 ________________
// 1dc0: 00000000 00000000 00000000 00000000 ________________
// 1dd0: 00000000 00000000 00000000 00000000 ________________
// 1de0: 00000000 00000000 00000000 00000000 ________________
// 1df0: 00000000 00000000 00000000 00000000 ________________
// 1e00: 00000000 00000000 00000000 00000000 ________________
// 1e10: 00000000 00000000 00000000 00000000 ________________
// 1e20: 00000000 00000000 00000000 00000000 ________________
// 1e30: 00000000 00000000 00000000 00000000 ________________
// 1e40: 00000000 00000000 00000000 00000000 ________________
// 1e50: 00000000 00000000 00000000 00000000 ________________
// 1e60: 00000000 00000000 00000000 00000000 ________________
// 1e70: 00000000 00000000 00000000 00000000 ________________
// 1e80: 00000000 00000000 00000000 00000000 ________________
// 1e90: 00000000 00000000 00000000 00000000 ________________
// 1ea0: 00000000 00000000 00000000 00000000 ________________
// 1eb0: 00000000 00000000 00000000 00000000 ________________
// 1ec0: 00000000 00000000 00000000 00000000 ________________
// 1ed0: 00000000 00000000 00000000 00000000 ________________
// 1ee0: 00000000 0131ca0b 00000038 00001000 ____..1.8____.__
// 1ef0: 00001000 00000000 ffff000b 00000004 _.______._...___
// 1f00: 0003ffff 00000000 00000000 00000000 ..._____________
// 1f10: 00000000 00000000 00000000 00000000 ________________
// 1f20: 00000000 00000000 00000000 00000000 ________________
// 1f30: 00000000 00000000 00000000 00000000 ________________
// 1f40: 00000000 00000000 00000000 00000000 ________________
// 1f50: 00000000 00000000 00000000 00000000 ________________
// 1f60: 00000000 00000000 00000000 00000000 ________________
// 1f70: 00000000 00000000 00000000 00000000 ________________
// 1f80: 00000000 00000000 00000000 00000000 ________________
// 1f90: 00000000 00000000 00000000 00000000 ________________
// 1fa0: 00000000 00000000 00000000 00000000 ________________
// 1fb0: 00000000 00000000 00000000 00000000 ________________
// 1fc0: 00000000 00000000 00000000 00000000 ________________
// 1fd0: 00000000 00000000 00000000 00000000 ________________
// 1fe0: 00000000 00000000 00000000 00000000 ________________
// 1ff0: 00000000 00000000 00000000 00000000 ________________
// 2000: 00000000 00000000 00000000 00000000 ________________
// 2010: 00000000 00000000 00000000 00000000 ________________
// 2020: 00000000 00000000 00000000 00000000 ________________
// 2030: 00000000 00000000 00000000 00000000 ________________
// 2040: 00000000 00000000 00000000 00000000 ________________
// 2050: 00000000 00000000 00000000 00000000 ________________
// 2060: 00000000 00000000 00000000 00000000 ________________
// 2070: 00000000 00000000 00000000 00000000 ________________
// 2080: 00000000 00000000 00000000 00000000 ________________
// 2090: 00000000 00000000 00000000 00000000 ________________
// 20a0: 00000000 00000000 00000000 00000000 ________________
// 20b0: 00000000 00000000 00000000 00000000 ________________
// 20c0: 00000000 00000000 00000000 00000000 ________________
// 20d0: 00000000 00000000 00000000 00000000 ________________
// 20e0: 00000000 ffffffff f12f091a 00000008 ____....../..___
// 20f0: 00000208 00000001 00000001 00000000 ..__.___._______
// 2100: 00000000 00000000 00000000 00000000 ________________
// 2110: 00000000 00000000 00000000 00000000 ________________
// 2120: 00000000 00000000 00000000 00000000 ________________
// 2130: 00000000 00000000 00000000 00000000 ________________
// 2140: 00000020 00000000 00000000 00000000 _______________
// 2150: 00000000 00000000 00000000 00000000 ________________
// 2160: 00000000 00000000 00000000 00000000 ________________
// 2170: 00000000 00000000 00000000 00000000 ________________
// 2180: 00000000 00000000 00000000 00000000 ________________
// 2190: 00000000 00000000 00000000 00000000 ________________
// 21a0: 00000000 00000000 00000000 00000000 ________________
// 21b0: 00000000 00000000 00000000 00000000 ________________
// 21c0: 00000000 00000000 00000000 00000000 ________________
// 21d0: 00000000 00000000 00000000 00000000 ________________
// 21e0: 00000000 00000000 00000000 00000000 ________________
// 21f0: 00000000 00000000 00000000 00000000 ________________
// 2200: 00000000 00000000 00000000 00000000 ________________
// 2210: 00000000 00000000 00000000 00000000 ________________
// 2220: 00000000 00000000 00000000 00000000 ________________
// 2230: 00000000 00000000 00000000 00000000 ________________
// 2240: 00000000 00000000 00000000 00000000 ________________
// 2250: 00000000 00000000 00000000 00000000 ________________
// 2260: 00000000 00000000 00000000 00000000 ________________
// 2270: 00000000 00000000 00000000 00000000 ________________
// 2280: 00000000 00000000 00000000 00000000 ________________
// 2290: 00000000 00000000 00000000 00000000 ________________
// 22a0: 00000000 00000000 00000000 00000000 ________________
// 22b0: 00000000 00000000 00000000 00000000 ________________
// 22c0: 00000000 00000000 00000000 00000000 ________________
// 22d0: 00000000 00000000 00000000 00000000 ________________
// 22e0: 00000000 00000000 00000000 00000000 ________________
// 22f0: 00000000 00000000 00000000 00000000 ________________
// 2300: 00000000 00000000 00000000 00000000 ________________
// 2310: 00000000 00000000 00000000 00000000 ________________
// 2320: 00000000 00000000 00000000 00000000 ________________
// 2330: 00000000 00000000 00000000 00000000 ________________
// 2340: 00000000 00000000 00000000 00000000 ________________
// 2350: 00000000 00000000 00000000 00000000 ________________
// 2360: 00000000 00000000 00000000 00000000 ________________
// 2370: 00000000 00000000 00000000 00000000 ________________
// 2380: 00000000 00000000 00000000 00000000 ________________
// 2390: 00000000 00000000 00000000 00000000 ________________
// 23a0: 00000000 00000000 00000000 00000000 ________________
// 23b0: 00000000 00000000 00000000 00000000 ________________
// 23c0: 00000000 00000000 00000000 00000000 ________________
// 23d0: 00000000 00000000 00000000 00000000 ________________
// 23e0: 00000000 00000000 00000000 00000000 ________________
// 23f0: 00000000 00000000 00000000 00000000 ________________
// 2400: 00000000 00000000 00000000 00000000 ________________
// 2410: 00000000 00000000 00000000 00000000 ________________
// 2420: 00000000 00000000 00000000 00000000 ________________
// 2430: 00000000 00000000 00000000 00000000 ________________
// 2440: 00000000 00000000 00000000 00000000 ________________
// 2450: 00000000 00000000 00000000 00000000 ________________
// 2460: 00000000 00000000 00000000 00000000 ________________
// 2470: 00000000 00000000 00000000 00000000 ________________
// 2480: 00000000 00000000 00000000 00000000 ________________
// 2490: 00000000 00000000 00000000 00000000 ________________
// 24a0: 00000000 00000000 00000000 00000000 ________________
// 24b0: 00000000 00000000 00000000 00000000 ________________
// 24c0: 00000000 00000000 00000000 00000000 ________________
// 24d0: 00000000 00000000 00000000 00000000 ________________
// 24e0: 00000000 11250012 00000000 00000080 ____._%.____.___
// 24f0: 616d0001 00006e69 00000000 00000000 ._main__________
// 2500: ffffffff f12f091a 00000000 00000000 ....../.________
// 2510: 00000000 00000000 00000000 00000000 ________________
// 2520: 00000000 00000000 00000000 00000000 ________________
// 2530: 00000000 00000000 00000000 00000000 ________________
// 2540: 00000000 00000000 00000000 00000000 ________________
// 2550: 00000000 00000000 00000000 00000000 ________________
// 2560: 00000000 00000000 00000000 00000000 ________________
// 2570: 00000000 00000000 00000000 00000000 ________________
// 2580: 00000000 00000000 00000000 00000000 ________________
// 2590: 00000000 00000000 00000000 00000000 ________________
// 25a0: 00000000 00000000 00000000 00000000 ________________
// 25b0: 00000000 00000000 00000000 00000000 ________________
// 25c0: 00000000 00000000 00000000 00000000 ________________
// 25d0: 00000000 00000000 00000000 00000000 ________________
// 25e0: 00000000 00000000 00000000 00000000 ________________
// 25f0: 00000000 00000000 00000000 00000000 ________________
// 2600: 00000000 00000000 00000000 00000000 ________________
// 2610: 00000000 00000000 00000000 00000000 ________________
// 2620: 00000000 00000000 00000000 00000000 ________________
// 2630: 00000000 00000000 00000000 00000000 ________________
// 2640: 00000000 00000000 00000000 00000000 ________________
// 2650: 00000000 00000000 00000000 00000000 ________________
// 2660: 00000000 00000000 00000000 00000000 ________________
// 2670: 00000000 00000000 00000000 00000000 ________________
// 2680: 00000000 00000000 00000000 00000000 ________________
// 2690: 00000000 00000000 00000000 00000000 ________________
// 26a0: 00000000 00000000 00000000 00000000 ________________
// 26b0: 00000000 00000000 00000000 00000000 ________________
// 26c0: 00000000 00000000 00000000 00000000 ________________
// 26d0: 00000000 00000000 00000000 00000000 ________________
// 26e0: 00000000 00000010 00000000 00000000 ____.___________
// 26f0: 00000000 00000000 00000000 00000000 ________________
// 2700: ffffffff f12f091a 00000000 00000000 ....../.________
// 2710: 00000000 00000000 00000000 00000000 ________________
// 2720: 00000000 00000000 00000000 00000000 ________________
// 2730: 00000000 00000000 00000000 00000000 ________________
// 2740: 00000000 00000000 00000000 00000000 ________________
// 2750: 00000000 00000000 00000000 00000000 ________________
// 2760: 00000000 00000000 00000000 00000000 ________________
// 2770: 00000000 00000000 00000000 00000000 ________________
// 2780: 00000000 00000000 00000000 00000000 ________________
// 2790: 00000000 00000000 00000000 00000000 ________________
// 27a0: 00000000 00000000 00000000 00000000 ________________
// 27b0: 00000000 00000000 00000000 00000000 ________________
// 27c0: 00000000 00000000 00000000 00000000 ________________
// 27d0: 00000000 00000000 00000000 00000000 ________________
// 27e0: 00000000 00000000 00000000 00000000 ________________
// 27f0: 00000000 00000000 00000000 00000000 ________________
// 2800: 00000000 00000000 00000000 00000000 ________________
// 2810: 00000000 00000000 00000000 00000000 ________________
// 2820: 00000000 00000000 00000000 00000000 ________________
// 2830: 00000000 00000000 00000000 00000000 ________________
// 2840: 00000000 00000000 00000000 00000000 ________________
// 2850: 00000000 00000000 00000000 00000000 ________________
// 2860: 00000000 00000000 00000000 00000000 ________________
// 2870: 00000000 00000000 00000000 00000000 ________________
// 2880: 00000000 00000000 00000000 00000000 ________________
// 2890: 00000000 00000000 00000000 00000000 ________________
// 28a0: 00000000 00000000 00000000 00000000 ________________
// 28b0: 00000000 00000000 00000000 00000000 ________________
// 28c0: 00000000 00000000 00000000 00000000 ________________
// 28d0: 00000000 00000000 00000000 00000000 ________________
// 28e0: 00000000 ffffffff 01310977 00000001 ____....w.1..___
// 28f0: 8e00000d 5c3f000e 0000000f 0000004c .__.._?\.___L___
// 2900: 00000020 0000002c 00000050 00000000 ___,___P_______
// 2910: 00000000 00000016 00000019 00000000 ____.___._______
// 2920: 00000000 00000000 00000001 00000000 ________._______
// 2930: 00000100 60000020 66850000 00000000 _.__ __`__.f____
// 2940: 00000000 00090002 00000218 00000000 ____._._..______
// 2950: 0000010c 00000001 02be8a78 00000000 ..__.___x...____
// 2960: 00000000 6e69616d 6e6f6e00 00000065 ____main_none___
// 2970: f12eba2d 00000001 00000000 00000100 -....________.__
// 2980: 60000020 66850000 00000000 00000000 __`__.f________
// 2990: 00020002 00000007 00010000 ffffffff ._._._____._....
// 29a0: 00000000 00000100 00000208 00000000 _____.__..______
// 29b0: ffffffff 00000000 ffffffff 00010001 ....____....._._
// 29c0: 00010000 00000000 435c3a4c 47202b2b __._____L:\C++ G
// 29d0: 75487469 69445c62 74636572 31312058 itHub\DirectX 11
// 29e0: 676e4520 20656e69 39313032 6168535c Engine 2019\Sha
// 29f0: 73726564 6168535c 73726564 5c53505c ders\Shaders\PS\
// 2a00: 65546873 682e7473 006c736c effeeffe shTest.hlsl_....
// 2a10: 00000001 00000001 00000100 00000000 .___.____.______
// 2a20: 00000000 ffffff00 ffffffff 0cffffff _____...........
// 2a30: ffffff00 ffffffff 00ffffff 00000000 _.........._____
// 2a40: 00000000 00000000 00000000 00000000 ________________
// 2a50: 00000000 00000000 00000000 00000000 ________________
// 2a60: 00000000 00000000 00000000 00000000 ________________
// 2a70: 00000000 00000000 00000000 00000000 ________________
// 2a80: 00000000 00000000 00000000 00000000 ________________
// 2a90: 00000000 00000000 00000000 00000000 ________________
// 2aa0: 00000000 00000000 00000000 00000000 ________________
// 2ab0: 00000000 00000000 00000000 00000000 ________________
// 2ac0: 00000000 00000000 00000000 00000000 ________________
// 2ad0: 00000000 00000000 00000000 00000000 ________________
// 2ae0: 00000000 01312e94 5da5a92d 00000001 ____..1.-..].___
// 2af0: 5a046c39 4f7d0cdf 850b96a4 6685aa75 9l.Z..}O....u..f
// 2b00: 00000071 6e694c2f 666e496b 6e2f006f q___/LinkInfo_/n
// 2b10: 73656d61 72732f00 65682f63 72656461 ames_/src/header
// 2b20: 636f6c62 732f006b 662f6372 73656c69 block_/src/files
// 2b30: 5c3a6c2f 202b2b63 68746967 645c6275 /l:\c++ github\d
// 2b40: 63657269 31207874 6e652031 656e6967 irectx 11 engine
// 2b50: 31303220 68735c39 72656461 68735c73 2019\shaders\sh
// 2b60: 72656461 73705c73 7468735c 2e747365 aders\ps\shtest.
// 2b70: 6c736c68 00000400 00000600 00000100 hlsl_.___.___.__
// 2b80: 00001b00 00000000 00002200 00000800 _._______"___.__
// 2b90: 00001100 00000700 00000a00 00000600 _.___.___.___.__
// 2ba0: 00000000 00000500 00000000 3351dc00 _____._______.Q3
// 2bb0: 00000001 00000000 00000000 00000000 ._______________
// 2bc0: 00000000 00000000 00000000 00000000 ________________
// 2bd0: 00000000 00000000 00000000 00000000 ________________
// 2be0: 00000000 00000000 00000000 00000000 ________________
// 2bf0: 00000000 00000000 00000000 00000000 ________________
// 2c00: 00000000 00000000 00000000 00000000 ________________
// 2c10: 00000000 00000000 00000000 00000000 ________________
// 2c20: 00000000 00000000 00000000 00000000 ________________
// 2c30: 00000000 00000000 00000000 00000000 ________________
// 2c40: 00000000 00000000 00000000 00000000 ________________
// 2c50: 00000000 00000000 00000000 00000000 ________________
// 2c60: 00000000 00000000 00000000 00000000 ________________
// 2c70: 00000000 00000000 00000000 00000000 ________________
// 2c80: 00000000 00000000 00000000 00000000 ________________
// 2c90: 00000000 00000000 00000000 00000000 ________________
// 2ca0: 00000000 00000000 00000000 00000000 ________________
// 2cb0: 00000000 00000000 00000000 00000000 ________________
// 2cc0: 00000000 00000000 00000000 00000000 ________________
// 2cd0: 00000000 00000000 00000000 00000000 ________________
// 2ce0: 00000000 00000010 00000020 000000cd ____.___ ___.___
// 2cf0: 00000080 00000157 00000038 00000000 .___W.__8_______
// 2d00: 000001cd 00000080 00000112 0000032c ..__.___..__,.__
// 2d10: 00000018 00000000 00000028 00000220 ._______(___ .__
// 2d20: 0000002c 00000014 00000003 00000014 ,___.___.___.___
// 2d30: 0000000d 00000013 0000000e 00000009 .___.___.___.___
// 2d40: 0000000a 00000008 0000000b 0000000c .___.___.___.___
// 2d50: 00000007 00000006 0000000f 00000010 .___.___.___.___
// 2d60: 00000012 00000011 00000000 00000000 .___.___________
// 2d70: 00000000 00000000 00000000 00000000 ________________
// 2d80: 00000000 00000000 00000000 00000000 ________________
// 2d90: 00000000 00000000 00000000 00000000 ________________
// 2da0: 00000000 00000000 00000000 00000000 ________________
// 2db0: 00000000 00000000 00000000 00000000 ________________
// 2dc0: 00000000 00000000 00000000 00000000 ________________
// 2dd0: 00000000 00000000 00000000 00000000 ________________
// 2de0: 00000000 00000000 00000000 00000000 ________________
// 2df0: 00000000 00000000 00000000 00000000 ________________
// 2e00: 00000000 00000000 00000000 00000000 ________________
// 2e10: 00000000 00000000 00000000 00000000 ________________
// 2e20: 00000000 00000000 00000000 00000000 ________________
// 2e30: 00000000 00000000 00000000 00000000 ________________
// 2e40: 00000000 00000000 00000000 00000000 ________________
// 2e50: 00000000 00000000 00000000 00000000 ________________
// 2e60: 00000000 00000000 00000000 00000000 ________________
// 2e70: 00000000 00000000 00000000 00000000 ________________
// 2e80: 00000000 00000000 00000000 00000000 ________________
// 2e90: 00000000 00000000 00000000 00000000 ________________
// 2ea0: 00000000 00000000 00000000 00000000 ________________
// 2eb0: 00000000 00000000 00000000 00000000 ________________
// 2ec0: 00000000 00000000 00000000 00000000 ________________
// 2ed0: 00000000 00000000 00000000 00000000 ________________
// 2ee0: 00000000 00000015 00000000 00000000 ____.___________
// 2ef0: 00000000 00000000 00000000 00000000 ________________
// 2f00: 00000000 00000000 00000000 00000000 ________________
// 2f10: 00000000 00000000 00000000 00000000 ________________
// 2f20: 00000000 00000000 00000000 00000000 ________________
// 2f30: 00000000 00000000 00000000 00000000 ________________
// 2f40: 00000000 00000000 00000000 00000000 ________________
// 2f50: 00000000 00000000 00000000 00000000 ________________
// 2f60: 00000000 00000000 00000000 00000000 ________________
// 2f70: 00000000 00000000 00000000 00000000 ________________
// 2f80: 00000000 00000000 00000000 00000000 ________________
// 2f90: 00000000 00000000 00000000 00000000 ________________
// 2fa0: 00000000 00000000 00000000 00000000 ________________
// 2fb0: 00000000 00000000 00000000 00000000 ________________
// 2fc0: 00000000 00000000 00000000 00000000 ________________
// 2fd0: 00000000 00000000 00000000 00000000 ________________
// 2fe0: 00000000 00000000 00000000 00000000 ________________
// 2ff0: 00000000 00000000 00000000 00000000 ________________
// 3000: 00000000 00000000 00000000 00000000 ________________
// 3010: 00000000 00000000 00000000 00000000 ________________
// 3020: 00000000 00000000 00000000 00000000 ________________
// 3030: 00000000 00000000 00000000 00000000 ________________
// 3040: 00000000 00000000 00000000 00000000 ________________
// 3050: 00000000 00000000 00000000 00000000 ________________
// 3060: 00000000 00000000 00000000 00000000 ________________
// 3070: 00000000 00000000 00000000 00000000 ________________
// 3080: 00000000 00000000 00000000 00000000 ________________
// 3090: 00000000 00000000 00000000 00000000 ________________
// 30a0: 00000000 00000000 00000000 00000000 ________________
// 30b0: 00000000 00000000 00000000 00000000 ________________
// 30c0: 00000000 00000000 00000000 00000000 ________________
// 30d0: 00000000 00000000 00000000 00000000 ________________
// 30e0: 00000000 ____
|
; $Id: bs3-mode-SwitchToPAE32_16.asm $
;; @file
; BS3Kit - Bs3SwitchToPAE32_16
;
;
; Copyright (C) 2007-2017 Oracle Corporation
;
; This file is part of VirtualBox Open Source Edition (OSE), as
; available from http://www.virtualbox.org. This file is free software;
; you can redistribute it and/or modify it under the terms of the GNU
; General Public License (GPL) as published by the Free Software
; Foundation, in version 2 as it comes in the "COPYING" file of the
; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
;
; The contents of this file may alternatively be used under the terms
; of the Common Development and Distribution License Version 1.0
; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
; VirtualBox OSE distribution, in which case the provisions of the
; CDDL are applicable instead of those of the GPL.
;
; You may elect to license modified versions of this file under the
; terms and conditions of either the GPL or the CDDL or both.
;
%include "bs3kit-template-header.mac"
;;
; Switch to 16-bit code under 32-bit PAE paged protected mode sys/tss from any other mode.
;
; @cproto BS3_DECL(void) Bs3SwitchToPAE32_16(void);
;
; @uses Nothing (except high 32-bit register parts).
;
; @remarks Obviously returns to 16-bit mode, even if the caller was
; in 32-bit or 64-bit mode.
;
; @remarks Does not require 20h of parameter scratch space in 64-bit mode.
;
%if TMPL_BITS == 16
BS3_GLOBAL_NAME_EX TMPL_NM(Bs3SwitchToPAE32_16_Safe), function , 0
%endif
BS3_PROC_BEGIN_MODE Bs3SwitchToPAE32_16, BS3_PBC_NEAR
%if TMPL_MODE == BS3_MODE_PAE32_16
ret
%elif TMPL_MODE == BS3_MODE_PAE32
extern BS3_CMN_NM(Bs3SwitchTo16Bit)
jmp BS3_CMN_NM(Bs3SwitchTo16Bit)
%else
;
; Switch to PAE32.
;
extern TMPL_NM(Bs3SwitchToPAE32)
call TMPL_NM(Bs3SwitchToPAE32)
BS3_SET_BITS 32
;
; Make sure we're in the 16-bit segment and then do the switch to 16-bit.
;
%if TMPL_BITS != 16
jmp .sixteen_bit_segment
BS3_BEGIN_TEXT16
BS3_SET_BITS TMPL_BITS
BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
%endif
extern _Bs3SwitchTo16Bit_c32
%if TMPL_BITS == 32
jmp _Bs3SwitchTo16Bit_c32
%else
call _Bs3SwitchTo16Bit_c32
BS3_SET_BITS 16
%if TMPL_BITS == 16
ret
%else
ret 6 ; Return and pop 6 bytes of "parameters" (unused return address).
%endif
%endif
%endif
BS3_PROC_END_MODE Bs3SwitchToPAE32_16
%if TMPL_BITS == 16
;;
; Custom far stub.
BS3_BEGIN_TEXT16_FARSTUBS
BS3_PROC_BEGIN_MODE Bs3SwitchToPAE32_16, BS3_PBC_FAR
inc bp
push bp
mov bp, sp
; Call the real thing.
call TMPL_NM(Bs3SwitchToPAE32_16)
%if BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
; Jmp to common code for the tedious conversion.
BS3_EXTERN_CMN Bs3SwitchHlpConvRealModeRetfPopBpDecBpAndReturn
jmp Bs3SwitchHlpConvRealModeRetfPopBpDecBpAndReturn
%else
pop bp
dec bp
retf
%endif
BS3_PROC_END_MODE Bs3SwitchToPAE32_16
%else
;;
; Safe far return to non-BS3TEXT16 code.
BS3_EXTERN_CMN Bs3SwitchHlpConvFlatRetToRetfProtMode
BS3_BEGIN_TEXT16
BS3_SET_BITS TMPL_BITS
BS3_PROC_BEGIN_MODE Bs3SwitchToPAE32_16_Safe, BS3_PBC_NEAR
call Bs3SwitchHlpConvFlatRetToRetfProtMode ; Special internal function. Uses nothing, but modifies the stack.
call TMPL_NM(Bs3SwitchToPAE32_16)
BS3_SET_BITS 16
retf
BS3_PROC_END_MODE Bs3SwitchToPAE32_16_Safe
%endif
|
/*
Copyright 2018 <Pierre Constantineau>
3-Clause BSD License
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "keymap.h"
#if KEYBOARD_SIDE == MASTER
std::array<std::array<Key, MATRIX_COLS>, MATRIX_ROWS> matrix =
{KEYMAP(
KC_1, KC_2, KC_3, KC_4, KC_5, KC_6,
KC_A, KC_B, KC_C, KC_D, KC_E, KC_F,
KC_G, KC_H, KC_I, KC_J, KC_K, KC_L,
KC_M, KC_N, KC_O, KC_P, KC_Q, KC_R,
KC_S, KC_T, KC_U, KC_V, KC_W, KC_X
)};
void setupKeymap() {
// no layers for master keymap
// this is a keymap that's used for testing that each key is responding properly to key presses
// flash this keymap to both left and right to test whether each half works properly.
// once tested, you can flash the left and right to their respective halves.
}
#endif
#if KEYBOARD_SIDE == LEFT
std::array<std::array<Key, MATRIX_COLS>, MATRIX_ROWS> matrix =
{KEYMAP(
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, \
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, \
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, \
ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC \
)};
/*
[_QWERTY] = LAYOUT( \
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
),
layer1 = lower
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
layer 2 = raise
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
layer3 = adjust
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
_______, RESET , RGB_TOG, RGB_MOD, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, _______, KC_DEL, \
_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
*/
void setupKeymap() {
uint32_t layer1[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, \
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, \
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, \
KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, _______ \
);
uint32_t layer2[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, \
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, \
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, \
KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, _______ \
);
uint32_t layer3[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, \
_______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______,\
KC_TRNS, _______, _______, _______, _______, _______, \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, _______ \
);
/*
* add the other layers on the regular presses.
*/
for (int row = 0; row < MATRIX_ROWS; ++row)
{
for (int col = 0; col < MATRIX_COLS; ++col)
{
matrix[row][col].addActivation(_L1, Method::PRESS, layer1[row][col]);
matrix[row][col].addActivation(_L2, Method::PRESS, layer2[row][col]);
matrix[row][col].addActivation(_L3, Method::PRESS, layer3[row][col]);
}
}
// if you want to add Tap/Hold or Tap/Doubletap activations, then you add them below.
}
#endif
#if KEYBOARD_SIDE == RIGHT
std::array<std::array<Key, MATRIX_COLS>, MATRIX_ROWS> matrix =
{KEYMAP(
KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \
KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
)};
void setupKeymap() {
uint32_t layer1[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \
_______, KC_TRNS, _______,_______, _______, _______ \
);
uint32_t layer2[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
_______, KC_TRNS, _______, _______, _______, _______ \
);
uint32_t layer3[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
_______, _______, _______, _______, _______, KC_DEL, \
_______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, \
_______, KC_TRNS, _______, _______, _______, _______ \
);
/*
* add the other layers on the regular presses.
*/
for (int row = 0; row < MATRIX_ROWS; ++row)
{
for (int col = 0; col < MATRIX_COLS; ++col)
{
matrix[row][col].addActivation(_L1, Method::PRESS, layer1[row][col]);
matrix[row][col].addActivation(_L2, Method::PRESS, layer2[row][col]);
matrix[row][col].addActivation(_L3, Method::PRESS, layer3[row][col]);
}
}
// if you want to add Tap/Hold or Tap/Doubletap activations, then you add them below.
}
#endif
|
// ======================================================================
//
// test registry_via_id's requirement that the value type have
// a member function that is:
// 1) named id, and
// 2) returns a value of the key type
//
// ======================================================================
#include "cetlib/registry_via_id.h"
using success_t = int;
using fail_t = char*; // anything other than success_t
struct val {
success_t
// fail_t
id() const
{
return 0;
}
};
using reg = cet::registry_via_id<success_t, val>;
int
main()
{
reg::put(val());
return 0;
} // main()
|
* ED - set window colours 1985 Tony Tebby QJUMP
*
section ed
*
xdef ed_shigh
xdef ed_snorm
*
include dev8_sbsext_ed_keys
include dev8_sbsext_ed_data
include dev8_keys_con
*
ed_snorm
sf ed_chang(a5) clear change flag
tst.b ed_high(a5) ... already normal?
beq.s edc_ok
sf ed_high(a5)
bra.s edc_sclr
ed_shigh
tst.b ed_high(a5) ... already high?
bne.s edc_ok
st ed_high(a5)
edc_sclr
lea edc_extop,a2
moveq #sd.extop,d0 swap colours
moveq #-1,d3
trap #3
bra.s edc_ok
edc_extop
move.l sd_imask(a0),d0
move.l sd_pmask(a0),sd_imask(a0)
move.l d0,sd_pmask(a0)
move.l d0,sd_smask(a0)
move.b sd_icolr(a0),d0
move.b sd_pcolr(a0),sd_icolr(a0)
move.b d0,sd_pcolr(a0)
move.b d0,sd_scolr(a0)
edc_ok
moveq #0,d0
rts
end
|
; void p_stack_push(p_stack_t *s, void *item)
SECTION code_adt_p_stack
PUBLIC p_stack_push_callee
EXTERN p_forward_list_insert_after_callee
defc p_stack_push_callee = p_forward_list_insert_after_callee
INCLUDE "adt/p_stack/z80/asm_p_stack_push.asm"
|
// This file extracted from the https://github.com/ucsc-vama/firrtl-sig repo with LICENSE.firrtl-sig license
#pragma once
#include <algorithm>
#include <array>
#include <bitset>
#include <cinttypes>
#include <iomanip>
#include <iostream>
#include <random>
#include <string>
#include <type_traits>
// Internal RNG
namespace {
std::mt19937_64 rng64(14);
uint64_t rng_leftover;
uint64_t rng_bits_left = 0;
} // namespace
// Forward dec
template <int w_>
class SInt;
template <int w_, typename word_t = typename std::conditional<(w_ <= 8), uint8_t, uint64_t>::type,
int n_ = (w_ <= 8) ? 1 : (w_ + 64 - 1) / 64>
class UInt {
private:
constexpr static int cmin(int wa, int wb) { return wa < wb ? wa : wb; }
constexpr static int cmax(int wa, int wb) { return wa > wb ? wa : wb; }
constexpr static int cap(int s) { return s % kWordSize; }
public:
constexpr UInt() : words_{} {
for (int i = 0; i < n_; ++i) words_[i] = 0;
}
template <word_t... Limbs>
constexpr UInt(const std::integer_sequence<word_t, Limbs...>) : words_{Limbs...} {}
constexpr UInt(word_t initial) : UInt() {
constexpr int bits_word = std::is_same<word_t, uint64_t>::value ? 64 : 8;
if constexpr (w_ < 64) {
uint64_t top_word_mask = (1l << w_) - 1;
words_[0] = initial & top_word_mask;
} else {
words_[0] = initial;
}
}
UInt(std::string initial) {
if (initial.substr(0, 2) != "0x") {
std::cout << "ERROR: UInt string literal must start with 0x!" << std::endl;
std::exit(-17);
}
initial.erase(0, 2);
// FUTURE: check that literal isn't too big
int input_bits = 4 * initial.length();
int last_start = initial.length();
for (int word = 0; word < n_; word++) {
if (word * kWordSize >= input_bits)
words_[word] = 0;
else {
int word_start = std::max(static_cast<int>(initial.length()) - 16 * (word + 1), 0);
int word_len = std::min(16, last_start - word_start);
last_start = word_start;
const std::string substr = initial.substr(word_start, word_len);
words_[word] = static_cast<uint64_t>(std::stoul(substr, nullptr, 16));
}
}
}
// NOTE: reads words right to left so literal appears to be concatted
constexpr UInt(std::array<word_t, n_> raw_input_reversed) {
for (int i = 0; i < n_; i++) words_[i] = raw_input_reversed[n_ - i - 1];
mask_top_unused();
}
template <int other_w>
constexpr explicit UInt(const UInt<other_w> &other) {
static_assert(other_w <= w_, "Can't copy construct from wider UInt");
for (int word = 0; word < n_; word++) {
if (word < UInt<other_w>::NW)
words_[word] = other.words_[word];
else
words_[word] = 0;
}
}
template <int other_w>
constexpr UInt<w_> operator=(const UInt<other_w> &other) {
if constexpr (other_w < w_) {
for (int word = 0; word < other_w; word++) {
if (word < UInt<other_w>::NW)
words_[word] = other.words_[word];
else
words_[word] = 0;
}
} else {
for (int word = 0; word < n_; word++) {
if (word < UInt<other_w>::NW)
words_[word] = other.words_[word];
else
words_[word] = 0;
}
}
return *this;
}
void rand_init() {
core_rand_init();
mask_top_unused();
}
template <int out_w>
UInt<cmax(w_, out_w)> pad() const {
return UInt<cmax(w_, out_w)>(*this);
}
#if 0
template<int other_w>
constexpr auto cat(const UInt<other_w> &other) {
UInt<w_ + other_w> to_return(other);
const int offset = other_w % kWordSize;
for (int i = 0; i < n_; i++) {
to_return.words_[word_index(other_w) + i] |= static_cast<uint64_t>(words_[i]) <<
cap(offset);
if ((offset != 0) && (i + 1 < to_return.NW - word_index(other_w)))
to_return.words_[word_index(other_w) + i + 1] |= static_cast<uint64_t>(words_[i]) >>
cap(kWordSize - offset);
}
return to_return;
}
#endif
template <int other_w>
UInt<w_ + other_w> cat(const UInt<other_w> &other) const {
UInt<w_ + other_w> to_return(other);
const int offset = other_w % kWordSize;
for (int i = 0; i < n_; i++) {
to_return.words_[word_index(other_w) + i] |= static_cast<uint64_t>(words_[i]) << cap(offset);
if ((offset != 0) && (i + 1 < to_return.NW - word_index(other_w)))
to_return.words_[word_index(other_w) + i + 1] |= static_cast<uint64_t>(words_[i]) >> cap(kWordSize - offset);
}
return to_return;
}
template <int other_w, typename other_word_t = typename std::conditional<(other_w <= 8), uint8_t, uint64_t>::type,
int other_n = (other_w <= 8) ? 1 : (other_w + 64 - 1) / 64>
constexpr auto operator+(const UInt<other_w> &other) const {
constexpr auto max_bits = cmax(w_, other_w);
constexpr auto max_n = cmax(n_, other_n);
UInt<max_bits + 1> result;
if constexpr (w_ > other_w) {
result = core_add_sub<max_bits + 1, false>(other.template pad<max_bits>());
} else if constexpr (w_ < other_w) {
result = other.core_add_sub<max_bits + 1, false>(pad<max_bits>());
} else {
result = core_add_sub<w_ + 1, false>(other);
}
if constexpr (kWordSize * max_n == max_bits) {
// propagate to next word in needed
if (result.words_[max_n - 1] < words_[max_n - 1])
result.words_[word_index(w_ + 1)] = 1;
}
return result;
}
SInt<w_ + 1> operator+(const SInt<w_> &other) const { return SInt<w_ + 1>(pad<w_ + 1>()).addw(other.template pad<w_ + 1>()); }
UInt<w_> addw(const UInt<w_> &other) const {
UInt<w_> result = core_add_sub<w_, false>(other);
result.mask_top_unused();
return result;
}
SInt<w_> subw(const UInt<w_> &other) const {
SInt<w_> result(core_add_sub<w_, true>(other.ui));
result.sign_extend();
return result;
}
SInt<w_ + 1> operator-() const { return SInt<w_>(0) - *this; }
SInt<w_ + 1> operator-(const UInt<w_> &other) const {
return SInt<w_ + 1>(pad<w_ + 1>()).subw(SInt<w_ + 1>(other.template pad<w_ + 1>()));
}
SInt<w_ + 1> operator-(const SInt<w_> &other) const { return SInt<w_ + 1>(pad<w_ + 1>()).subw(other.template pad<w_ + 1>()); }
#if 1
template <int other_w, int result_n = ((w_ + other_w) + 64 - 1) / 64>
constexpr UInt<w_ + other_w> operator*(UInt<other_w> other) const {
if constexpr ((w_ + other_w) <= 8) {
uint64_t val = words_[0] * other.words_[0];
return UInt<w_ + other_w>(val);
} else {
UInt<w_ + other_w> result(0);
using u128 = unsigned __int128; // Sometimes 16 is enough but just for small consts
for (auto j = 0; j < other.NW; ++j) {
uint64_t k = 0;
for (auto i = 0; i < n_; ++i) {
u128 t = static_cast<u128>(words_[i]) * static_cast<u128>(other.words_[j]) + result.words_[i + j] + k;
result.words_[i + j] = static_cast<uint64_t>(t);
k = t >> std::numeric_limits<uint64_t>::digits;
}
if ((j + n_) < result_n)
result.words_[j + n_] = k;
}
return result;
}
}
#else
constexpr UInt<w_ + w_> operator*(const UInt<w_> &other) const {
UInt<w_ + w_> result(0);
uint64_t carry = 0;
for (int i = 0; i < n_; i++) {
carry = 0;
for (int j = 0; j < n_; j++) {
uint64_t prod_ll = lower(words_[i]) * lower(other.words_[j]);
uint64_t prod_lu = lower(words_[i]) * upper(other.words_[j]);
uint64_t prod_ul = upper(words_[i]) * lower(other.words_[j]);
uint64_t prod_uu = upper(words_[i]) * upper(other.words_[j]);
uint64_t lower_sum = lower(result.words_[i + j]) + lower(carry) + lower(prod_ll);
uint64_t upper_sum
= upper(result.words_[i + j]) + upper(carry) + upper(prod_ll) + upper(lower_sum) + lower(prod_lu) + lower(prod_ul);
result.words_[i + j] = (upper_sum << 32) | lower(lower_sum);
carry = upper(upper_sum) + upper(prod_lu) + upper(prod_ul) + prod_uu;
}
if ((i + n_) < result.NW)
result.words_[i + n_] += carry;
}
return result;
}
#endif
SInt<w_ + w_> operator*(const SInt<w_> &other) const {
SInt<w_ + w_ + 2> product(SInt<w_ + 1>(pad<w_ + 1>()) * other.template pad<w_ + 1>());
SInt<w_ + w_> result = (product.template tail<2>()).asSInt();
result.sign_extend();
return result;
}
// this / other
template <int other_w>
UInt<w_> operator/(const UInt<other_w> &other) const {
static_assert(w_ <= kWordSize, "Div not supported beyond 64b");
static_assert(other_w <= kWordSize, "Div not supported beyond 64b");
return UInt<w_>(as_single_word() / other.as_single_word());
}
template <int other_w>
UInt<w_ + 1> operator/(const SInt<other_w> &other) const {
return SInt<w_ + 1>(pad<w_ + 1>()) / other;
}
// this % other
template <int other_w>
UInt<cmin(w_, other_w)> operator%(const UInt<other_w> &other) const {
static_assert(w_ <= kWordSize, "Mod not supported beyond 64b");
static_assert(other_w <= kWordSize, "Mod not supported beyond 64b");
return UInt<cmin(w_, other_w)>(as_single_word() % other.as_single_word());
}
template <int other_w>
UInt<cmin(w_, other_w)> operator%(const SInt<other_w> &other) const {
return *this % other.asUInt();
}
UInt<w_> operator~() const {
UInt<w_> result;
for (int i = 0; i < n_; i++) {
result.words_[i] = ~words_[i];
}
result.mask_top_unused();
return result;
}
UInt<w_> operator&(const UInt<w_> &other) const {
UInt<w_> result;
for (int i = 0; i < n_; i++) {
result.words_[i] = words_[i] & other.words_[i];
}
return result;
}
UInt<w_> operator|(const UInt<w_> &other) const {
UInt<w_> result;
for (int i = 0; i < n_; i++) {
result.words_[i] = words_[i] | other.words_[i];
}
return result;
}
UInt<w_> operator^(const UInt<w_> &other) const {
UInt<w_> result;
for (int i = 0; i < n_; i++) {
result.words_[i] = words_[i] ^ other.words_[i];
}
return result;
}
UInt<1> andr() const { return *this == ~UInt<w_>(0); }
UInt<w_> operator!() const {
UInt<w_> result;
for (int i = 0; i < n_; i++) {
result.words_[i] = ~words_[i];
}
return result;
}
UInt<1> orr() const { return *this != UInt<w_>(0); }
UInt<1> xorr() const {
word_t result = 0;
for (int i = 0; i < n_; i++) {
word_t word_parity_scratch = words_[i] ^ (words_[i] >> 1);
word_parity_scratch ^= (word_parity_scratch >> 2);
word_parity_scratch ^= (word_parity_scratch >> 4);
if (WW > 8) {
word_parity_scratch ^= (word_parity_scratch >> 8);
word_parity_scratch ^= (word_parity_scratch >> 16);
word_parity_scratch ^= (word_parity_scratch >> 32);
}
result ^= word_parity_scratch;
}
return UInt<1>(result & 1);
}
template <int hi, int lo>
UInt<hi - lo + 1> bits() const {
UInt<hi - lo + 1> result = core_bits<hi, lo>();
result.mask_top_unused();
return result;
}
template <int hi, int lo>
constexpr auto mbits() const {
constexpr UInt<hi - lo + 1> result = mcore_bits<hi, lo>();
return result;
}
template <int hi>
UInt<1> bit() const {
constexpr int word_down = word_index(hi);
constexpr int bits_down = hi % kWordSize;
UInt<1> result;
result.words_[0] = words_[0 + word_down] >> bits_down;
result.mask_top_unused();
return result;
}
template <int n>
UInt<n> head() const {
static_assert(n <= w_, "Head n must be <= width");
return bits<w_ - 1, w_ - n>();
}
template <int n>
UInt<w_ - n> tail() const {
static_assert(n < w_, "Tail n must be < width");
return bits<w_ - n - 1, 0>();
}
template <int shamt>
UInt<w_ + shamt> shl() const {
return cat(UInt<shamt>(0));
}
template <int shamt>
UInt<w_> shlw() const {
return shl<shamt>().template tail<shamt>();
}
template <int shamt>
UInt<w_ - shamt> shr() const {
return bits<w_ - 1, shamt>();
}
template <int other_w>
UInt<w_> operator>>(const UInt<other_w> &other) const {
UInt<w_> result(0);
uint64_t dshamt = other.as_single_word();
uint64_t word_down = word_index(dshamt);
uint64_t bits_down = dshamt % kWordSize;
for (uint64_t i = word_down; i < n_; i++) {
result.words_[i - word_down] = words_[i] >> bits_down;
if ((bits_down != 0) && (i < n_ - 1))
result.words_[i - word_down] |= words_[i + 1] << cap(kWordSize - bits_down);
}
return result;
}
template <int other_w>
UInt<w_ + (1 << other_w) - 1> operator<<(const UInt<other_w> &other) const {
UInt<w_ + (1 << other_w) - 1> result(0);
uint64_t dshamt = other.as_single_word();
uint64_t word_up = word_index(dshamt);
uint64_t bits_up = dshamt % kWordSize;
for (uint64_t i = 0; i < n_; i++) {
result.words_[i + word_up] |= words_[i] << bits_up;
if ((bits_up != 0) && (dshamt + w_ > kWordSize) && (i + word_up + 1 < result.NW))
result.words_[i + word_up + 1] = words_[i] >> cap(kWordSize - bits_up);
}
return result;
}
template <int other_w>
UInt<w_> dshlw(const UInt<other_w> &other) const {
// return operator<<(other).template bits<w_-1,0>();
UInt<w_> result(0);
uint64_t dshamt = other.as_single_word();
uint64_t word_up = word_index(dshamt);
uint64_t bits_up = dshamt % kWordSize;
for (uint64_t i = 0; i + word_up < n_; i++) {
result.words_[i + word_up] |= words_[i] << bits_up;
if ((bits_up != 0) && (w_ > kWordSize) && (i + word_up + 1 < n_))
result.words_[i + word_up + 1] = words_[i] >> cap(kWordSize - bits_up);
}
result.mask_top_unused();
return result;
}
constexpr UInt<1> operator<=(const UInt<w_> &other) const {
for (int i = n_ - 1; i >= 0; i--) {
if (words_[i] < other.words_[i])
return UInt<1>(1);
if (words_[i] > other.words_[i])
return UInt<1>(0);
}
return UInt<1>(1);
}
UInt<1> operator>=(const UInt<w_> &other) const {
for (int i = n_ - 1; i >= 0; i--) {
if (words_[i] > other.words_[i])
return UInt<1>(1);
if (words_[i] < other.words_[i])
return UInt<1>(0);
}
return UInt<1>(1);
}
UInt<1> operator<(const UInt<w_> &other) const { return ~(*this >= other); }
UInt<1> operator>(const UInt<w_> &other) const { return ~(*this <= other); }
template <int other_w, typename other_word_t = typename std::conditional<(other_w <= 8), uint8_t, uint64_t>::type,
int other_n = (other_w <= 8) ? 1 : (other_w + 64 - 1) / 64>
constexpr UInt<1> operator==(const UInt<other_w> &other) const {
constexpr auto min_words = cmin(n_, other_n);
for (int i = 0; i < min_words; ++i) {
if (words_[i] != other.words_[i])
return UInt<1>(0);
}
if constexpr (n_ < other_n) {
for (int i = min_words; i < other_n; ++i) {
if (other.words_[i])
return UInt<1>(0);
}
} else if constexpr (n_ > other_n) {
for (int i = min_words; i < other_n; ++i) {
if (words_[i])
return UInt<1>(0);
}
}
return UInt<1>(1);
}
constexpr UInt<1> operator!=(const UInt<w_> &other) const { return ~(*this == other); }
constexpr operator bool() const {
static_assert(w_ == 1, "conversion to bool only allowed for width 1");
return static_cast<bool>(words_[0]);
}
UInt<w_> asUInt() const { return UInt<w_>(*this); }
SInt<w_> asSInt() const {
SInt<w_> result(*this);
result.sign_extend();
return result;
}
SInt<w_ + 1> cvt() const { return pad<w_ + 1>().asSInt(); }
// Direct access for ops that only need small signals
uint64_t as_single_word() const {
static_assert(w_ <= kWordSize, "UInt too big for single uint64_t");
return words_[0];
}
std::string to_string_binary() const {
constexpr std::string_view nibble_to_str[] = {"0000",
"0001",
"0010",
"0011",
"0100",
"0101",
"0110",
"0111",
"1000",
"1001",
"1010",
"1011",
"1100",
"1101",
"1110",
"1111"};
bool multibit = (bits_in_top_word_ / sizeof(uint8_t)) > 1 ? 1 : 0;
if constexpr (n_ <= 64 && n_ > 8) {
std::string result;
auto v = words_[0];
bool non_zero_found = false;
for (int i = 64; i > 0; i = i - 4) {
auto x = v >> i;
if (!non_zero_found && x == 0)
continue;
non_zero_found = true;
result.append(nibble_to_str[x & 0xF]);
}
return result;
} else if constexpr (n_ <= 8) {
bool top_zeroes = true;
auto v = words_[0];
auto v_casted = static_cast<uint64_t>(words_[0]);
std::string result = (multibit ? "b" : "");
if (!multibit) {
result.append(nibble_to_str[v & 0xF]);
result = result.back();
} else {
for (int i = bits_in_top_word_; i > 0; i = i - 4) {
auto x = (v >> (i - 4));
if ((top_zeroes && (x & 0xF)) || (i == 4)) {
top_zeroes = false;
}
if (!top_zeroes) {
result.append(nibble_to_str[x & 0xF]);
}
}
}
return result;
} else {
std::stringstream ss;
if (multibit) {
ss << "b";
} // we want "b" only in multi-bit variables
// ss << "b";
uint64_t top_word_mask = bits_in_top_word_ == kWordSize ? -1 : (1ULL << cap(bits_in_top_word_)) - 1;
auto v = (static_cast<uint64_t>(words_[n_ - 1]) & top_word_mask);
uint64_t mask = 1ULL << (bits_in_top_word_ - 1);
while (mask) {
ss << ((mask & v) ? "1" : "0");
mask >>= 1;
}
for (int word = n_ - 2; word >= 0; word--) {
auto v2 = words_[word];
uint64_t mask = 1ULL << 63;
while (mask) {
ss << ((mask & v2) ? "1" : "0");
mask >>= 1;
}
}
return ss.str();
}
}
std::string to_string_hex() const {
std::stringstream ss;
ss << "0x" << std::hex << std::setfill('0');
int top_nibble_width = (bits_in_top_word_ + 3) / 4;
ss << std::setw(top_nibble_width);
uint64_t top_word_mask = bits_in_top_word_ == kWordSize ? -1 : (1ULL << cap(bits_in_top_word_)) - 1;
ss << (static_cast<uint64_t>(words_[n_ - 1]) & top_word_mask);
for (int word = n_ - 2; word >= 0; word--) {
ss << std::hex << std::setfill('0') << std::setw(16) << words_[word];
}
return ss.str();
}
std::string to_string() const {
if constexpr ((w_ % 4) == 0) {
return to_string_hex();
} else {
return to_string_binary();
}
}
std::string to_verilog() const {
std::stringstream ss;
ss << w_ << "'h" << std::hex << std::setfill('0');
int top_nibble_width = (bits_in_top_word_ + 3) / 4;
ss << std::setw(top_nibble_width);
uint64_t top_word_mask = bits_in_top_word_ == kWordSize ? -1 : (1l << cap(bits_in_top_word_)) - 1;
ss << (static_cast<uint64_t>(words_[n_ - 1]) & top_word_mask);
for (int word = n_ - 2; word >= 0; word--) {
ss << std::hex << std::setfill('0') << std::setw(16) << words_[word];
}
return ss.str();
}
constexpr size_t bit_length() const {
size_t L = n_;
while (L > 0 && words_[L - 1] == 0) --L;
if (L == 0)
return 0;
size_t bitlen = L * std::numeric_limits<word_t>::digits;
auto msb = words_[L - 1];
while (bitlen > 0 && (msb & (static_cast<word_t>(1) << (std::numeric_limits<word_t>::digits - 1))) == 0) {
msb <<= 1;
--bitlen;
}
return bitlen;
}
protected:
template <int other_w>
friend class uint_wrapper_t;
void raw_copy_in(const uint64_t *src) {
for (int word = 0; word < n_; word++) words_[word] = *src++;
}
void raw_copy_out(uint64_t *dst) const {
for (int word = 0; word < n_; word++) *dst++ = words_[word];
}
private:
// Internal state
std::array<word_t, n_> words_;
// Access array word type
typedef word_t WT;
// Access array length
constexpr static int NW = n_;
// Access array word type bit width
constexpr static int WW = std::is_same<word_t, uint64_t>::value ? 64 : 8;
constexpr static int bits_in_top_word_ = w_ % WW == 0 ? WW : w_ % WW;
// Friend Access
template <int other_w, typename other_word_t, int other_n>
friend class UInt;
template <int other_w>
friend class SInt;
template <int w>
friend std::ostream &operator<<(std::ostream &os, const UInt<w> &ui);
// Bit Addressing
constexpr static int kWordSize = 64;
constexpr int static word_index(int bit_index) { return bit_index / kWordSize; }
static constexpr uint64_t upper(uint64_t i) { return i >> 32; }
static constexpr uint64_t lower(uint64_t i) { return i & 0x00000000ffffffffUL; }
// Clean up high bits
constexpr void mask_top_unused() {
if (bits_in_top_word_ != WW) {
words_[n_ - 1] = words_[n_ - 1] & ((1ULL << cap(bits_in_top_word_)) - 1ULL);
}
}
// Reused math operators
template <int out_w, bool subtract>
constexpr UInt<out_w> core_add_sub(const UInt<w_> &other) const {
UInt<out_w> result;
uint64_t carry = subtract;
for (int i = 0; i < n_; i++) {
uint64_t operand = subtract ? ~other.words_[i] : other.words_[i];
result.words_[i] = words_[i] + operand + carry;
carry = result.words_[i] < operand ? 1 : 0;
}
return result;
}
__attribute__((noinline)) void core_rand_init() {
// trusting mask_top_unused() will be called afterwards
if (w_ < 64) {
if (w_ > rng_bits_left) {
rng_leftover = rng64();
rng_bits_left = 64;
}
words_[0] = rng_leftover;
rng_leftover = rng_leftover >> cap(w_);
rng_bits_left -= w_;
} else {
for (int word = 0; word < n_; word++) {
words_[word] = rng64();
}
}
}
template <int hi, int lo>
UInt<hi - lo + 1> core_bits() const {
static_assert(hi < w_, "Bit extract hi bigger than width");
static_assert(hi >= lo, "Bit extract lo > hi");
static_assert(lo >= 0, "Bit extract lo is negative");
UInt<hi - lo + 1> result;
constexpr int word_down = word_index(lo);
constexpr int bits_down = lo % kWordSize;
for (int i = 0; i < result.NW; i++) {
result.words_[i] = words_[i + word_down] >> bits_down;
if ((bits_down != 0) && (i + word_down + 1 < n_))
result.words_[i] |= words_[i + word_down + 1] << cap(kWordSize - bits_down);
}
return result;
}
template <int hi, int lo>
constexpr auto mcore_bits() const {
static_assert(hi < w_, "Bit extract hi bigger than width");
static_assert(hi >= lo, "Bit extract lo > hi");
static_assert(lo >= 0, "Bit extract lo is negative");
UInt<hi - lo + 1> result;
constexpr int word_down = word_index(lo);
constexpr int bits_down = lo % kWordSize;
for (int i = 0; i < result.NW; i++) {
result.words_[i] = words_[i + word_down] >> bits_down;
if ((bits_down != 0) && (i + word_down + 1 < n_))
result.words_[i] |= words_[i + word_down + 1] << cap(kWordSize - bits_down);
}
return result;
}
void print_to_stream(std::ostream &os) const {
os << "0x" << std::hex << std::setfill('0');
int top_nibble_width = (bits_in_top_word_ + 3) / 4;
os << std::setw(top_nibble_width);
uint64_t top_word_mask = bits_in_top_word_ == kWordSize ? -1 : (1l << cap(bits_in_top_word_)) - 1;
os << (static_cast<uint64_t>(words_[n_ - 1]) & top_word_mask);
for (int word = n_ - 2; word >= 0; word--) {
os << std::hex << std::setfill('0') << std::setw(16) << words_[word];
}
os << std::dec;
}
};
template <int w>
std::ostream &operator<<(std::ostream &os, const UInt<w> &ui) {
ui.print_to_stream(os);
os << "<U" << w << ">";
return os;
}
constexpr size_t ctlog2(uint8_t n) { return ((n < 2) ? 1 : 1 + ctlog2(n / 2)); }
template <char... Chars>
constexpr auto operator"" _uint() {
constexpr int N = sizeof...(Chars);
constexpr std::array<char, N> seq{Chars...};
uint8_t scale_val = 0;
std::size_t start_pos = 0;
if constexpr (seq.size() < 3) {
scale_val = 10;
} else if constexpr (seq[0] == '0' && (seq[1] == 'd' || seq[1] == 'D')) {
start_pos = 2;
scale_val = 10;
} else if constexpr (seq[0] == '0' && (seq[1] == 'x' || seq[1] == 'X')) {
start_pos = 2;
scale_val = 16;
} else if constexpr (seq[0] == '0' && (seq[1] == 'b' || seq[1] == 'B')) {
start_pos = 2;
scale_val = 2;
} else if constexpr (seq[0] == '0') {
start_pos = 1;
scale_val = 8;
} else {
scale_val = 10;
}
constexpr std::size_t max_bits
= (seq.size() > 1 && seq[0] == '0' && (seq[1] == 'b' || seq[1] == 'b'))
? (seq.size() - 2)
: ((seq.size() > 1 && seq[0] == '0' && (seq[1] == 'x' || seq[1] == 'X'))
? (seq.size() - 2) * 4
: ((seq.size() > 0 && seq[0] == '0') ? (seq.size() - 1) * 3 : (1 + ctlog2(2 * seq.size()))));
UInt<max_bits> value;
UInt<max_bits> scale(scale_val);
for (std::size_t i = start_pos; i < seq.size(); ++i) {
uint64_t v = 0;
if (seq[i] >= 'A' && seq[i] <= 'Z')
v = 10 + seq[i] - 'A';
else if (seq[i] >= 'a' && seq[i] <= 'z')
v = 10 + seq[i] - 'a';
else if (seq[i] >= '0' && seq[i] <= '9')
v = seq[i] - '0';
else
continue;
value = value * scale;
value = value + UInt<max_bits>(v);
}
return value;
}
|
# mp_limb_t mulredc12(mp_limb_t * z, const mp_limb_t * x, const mp_limb_t * y,
# const mp_limb_t *m, mp_limb_t inv_m);
#
# Stack:
# inv_m ## parameters
# m
# y
# x
# z (4*(2k+7))%esp
# ??? (1 limb???)
# ebp ## pushed registers (4*(2k+5))%esp
# edi
# esi
# ebx
# ... ## counter (1 mp_limb_t) (4*(2k+1))%esp
# ... ## tmp space (2*k+1 mp_limb_t)
include(`config.m4')
TEXT
GLOBL GSYM_PREFIX`'mulredc12
TYPE(GSYM_PREFIX`'mulredc12,`function')
GSYM_PREFIX`'mulredc12:
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
subl $104, %esp
movl %esp, %edi
### set tmp[0..2k+1[ to 0
movl $0, (%edi)
movl $0, 4(%edi)
movl $0, 8(%edi)
movl $0, 12(%edi)
movl $0, 16(%edi)
movl $0, 20(%edi)
movl $0, 24(%edi)
movl $0, 28(%edi)
movl $0, 32(%edi)
movl $0, 36(%edi)
movl $0, 40(%edi)
movl $0, 44(%edi)
movl $0, 48(%edi)
movl $0, 52(%edi)
movl $0, 56(%edi)
movl $0, 60(%edi)
movl $0, 64(%edi)
movl $0, 68(%edi)
movl $0, 72(%edi)
movl $0, 76(%edi)
movl $0, 80(%edi)
movl $0, 84(%edi)
movl $0, 88(%edi)
movl $0, 92(%edi)
movl $0, 96(%edi)
###########################################
movl $12, 100(%esp)
.align 32
Loop:
## compute u and store in %ebp
movl 128(%esp), %eax
movl 132(%esp), %esi
movl (%eax), %eax
mull (%esi)
addl (%edi), %eax
mull 140(%esp)
movl %eax, %ebp
movl 136(%esp), %esi
### addmul1: src[0] is (%esi)
### dst[0] is (%edi)
### mult is %ebp
### k is 12
### kills %eax, %ebx, %ecx, %edx
### dst[0,k[ += mult*src[0,k[ plus carry put in ecx or ebx
movl (%esi), %eax
mull %ebp
movl %eax, %ebx
movl %edx, %ecx
movl 4(%esi), %eax
mull %ebp
addl %ebx, (%edi)
movl $0, %ebx
adcl %eax, %ecx
movl 8(%esi), %eax
adcl %edx, %ebx
mull %ebp
addl %ecx, 4(%edi)
movl $0, %ecx
adcl %eax, %ebx
movl 12(%esi), %eax
adcl %edx, %ecx
mull %ebp
addl %ebx, 8(%edi)
movl $0, %ebx
adcl %eax, %ecx
movl 16(%esi), %eax
adcl %edx, %ebx
mull %ebp
addl %ecx, 12(%edi)
movl $0, %ecx
adcl %eax, %ebx
movl 20(%esi), %eax
adcl %edx, %ecx
mull %ebp
addl %ebx, 16(%edi)
movl $0, %ebx
adcl %eax, %ecx
movl 24(%esi), %eax
adcl %edx, %ebx
mull %ebp
addl %ecx, 20(%edi)
movl $0, %ecx
adcl %eax, %ebx
movl 28(%esi), %eax
adcl %edx, %ecx
mull %ebp
addl %ebx, 24(%edi)
movl $0, %ebx
adcl %eax, %ecx
movl 32(%esi), %eax
adcl %edx, %ebx
mull %ebp
addl %ecx, 28(%edi)
movl $0, %ecx
adcl %eax, %ebx
movl 36(%esi), %eax
adcl %edx, %ecx
mull %ebp
addl %ebx, 32(%edi)
movl $0, %ebx
adcl %eax, %ecx
movl 40(%esi), %eax
adcl %edx, %ebx
mull %ebp
addl %ecx, 36(%edi)
movl $0, %ecx
adcl %eax, %ebx
movl 44(%esi), %eax
adcl %edx, %ecx
mull %ebp
addl %ebx, 40(%edi)
adcl %ecx, %eax
adcl $0, %edx
addl %eax, 44(%edi)
adcl $0, %edx
### carry limb is in %edx
addl %edx, 48(%edi)
adcl $0, 52(%edi)
movl 128(%esp), %eax
movl (%eax), %ebp
movl 132(%esp), %esi
### addmul1: src[0] is (%esi)
### dst[0] is (%edi)
### mult is %ebp
### k is 12
### kills %eax, %ebx, %ecx, %edx
### dst[0,k[ += mult*src[0,k[ plus carry put in ecx or ebx
movl (%esi), %eax
mull %ebp
movl %eax, %ebx
movl %edx, %ecx
movl 4(%esi), %eax
mull %ebp
addl %ebx, (%edi)
movl $0, %ebx
adcl %eax, %ecx
movl 8(%esi), %eax
adcl %edx, %ebx
mull %ebp
addl %ecx, 4(%edi)
movl $0, %ecx
adcl %eax, %ebx
movl 12(%esi), %eax
adcl %edx, %ecx
mull %ebp
addl %ebx, 8(%edi)
movl $0, %ebx
adcl %eax, %ecx
movl 16(%esi), %eax
adcl %edx, %ebx
mull %ebp
addl %ecx, 12(%edi)
movl $0, %ecx
adcl %eax, %ebx
movl 20(%esi), %eax
adcl %edx, %ecx
mull %ebp
addl %ebx, 16(%edi)
movl $0, %ebx
adcl %eax, %ecx
movl 24(%esi), %eax
adcl %edx, %ebx
mull %ebp
addl %ecx, 20(%edi)
movl $0, %ecx
adcl %eax, %ebx
movl 28(%esi), %eax
adcl %edx, %ecx
mull %ebp
addl %ebx, 24(%edi)
movl $0, %ebx
adcl %eax, %ecx
movl 32(%esi), %eax
adcl %edx, %ebx
mull %ebp
addl %ecx, 28(%edi)
movl $0, %ecx
adcl %eax, %ebx
movl 36(%esi), %eax
adcl %edx, %ecx
mull %ebp
addl %ebx, 32(%edi)
movl $0, %ebx
adcl %eax, %ecx
movl 40(%esi), %eax
adcl %edx, %ebx
mull %ebp
addl %ecx, 36(%edi)
movl $0, %ecx
adcl %eax, %ebx
movl 44(%esi), %eax
adcl %edx, %ecx
mull %ebp
addl %ebx, 40(%edi)
adcl %ecx, %eax
adcl $0, %edx
addl %eax, 44(%edi)
adcl $0, %edx
### carry limb is in %edx
addl %edx, 48(%edi)
adcl $0, 52(%edi)
addl $4, 128(%esp)
addl $4, %edi
decl 100(%esp)
jnz Loop
###########################################
### Copy result in z
movl 124(%esp), %ebx
movl (%edi), %eax
movl %eax, (%ebx)
movl 4(%edi), %eax
movl %eax, 4(%ebx)
movl 8(%edi), %eax
movl %eax, 8(%ebx)
movl 12(%edi), %eax
movl %eax, 12(%ebx)
movl 16(%edi), %eax
movl %eax, 16(%ebx)
movl 20(%edi), %eax
movl %eax, 20(%ebx)
movl 24(%edi), %eax
movl %eax, 24(%ebx)
movl 28(%edi), %eax
movl %eax, 28(%ebx)
movl 32(%edi), %eax
movl %eax, 32(%ebx)
movl 36(%edi), %eax
movl %eax, 36(%ebx)
movl 40(%edi), %eax
movl %eax, 40(%ebx)
movl 44(%edi), %eax
movl %eax, 44(%ebx)
movl 48(%edi), %eax # carry
addl $104, %esp
popl %ebx
popl %esi
popl %edi
popl %ebp
ret
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r15
push %r8
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x9112, %rsi
lea addresses_normal_ht+0x15a3d, %rdi
nop
nop
nop
nop
mfence
mov $38, %rcx
rep movsq
nop
nop
nop
nop
nop
inc %rdx
lea addresses_UC_ht+0x1eab5, %rcx
nop
dec %r9
movups (%rcx), %xmm5
vpextrq $0, %xmm5, %rsi
nop
nop
nop
xor %r9, %r9
lea addresses_D_ht+0x17fb5, %rsi
lea addresses_WT_ht+0x18bb5, %rdi
nop
nop
nop
and $8639, %r8
mov $44, %rcx
rep movsq
nop
inc %rdi
lea addresses_normal_ht+0x5b55, %rcx
nop
nop
nop
sub %rsi, %rsi
mov $0x6162636465666768, %rdx
movq %rdx, %xmm0
movups %xmm0, (%rcx)
nop
mfence
lea addresses_D_ht+0x1a1b5, %r15
xor $62972, %r8
vmovups (%r15), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $0, %xmm7, %rdx
dec %rdx
lea addresses_UC_ht+0x187b5, %rsi
lea addresses_WC_ht+0x4295, %rdi
nop
nop
nop
nop
add $59193, %r10
mov $41, %rcx
rep movsq
nop
nop
nop
xor %rdx, %rdx
lea addresses_D_ht+0xa1b5, %rdi
nop
cmp %rdx, %rdx
mov $0x6162636465666768, %r9
movq %r9, %xmm2
movups %xmm2, (%rdi)
nop
nop
nop
nop
sub %r9, %r9
lea addresses_normal_ht+0xda8b, %rsi
lea addresses_WT_ht+0x1d4b5, %rdi
nop
nop
xor %r15, %r15
mov $27, %rcx
rep movsq
nop
nop
nop
nop
xor %r15, %r15
lea addresses_normal_ht+0x1e541, %r10
and %rcx, %rcx
mov $0x6162636465666768, %rdi
movq %rdi, %xmm0
movups %xmm0, (%r10)
nop
nop
nop
sub $41148, %rdi
lea addresses_WT_ht+0x184b5, %rdx
nop
cmp %r9, %r9
movw $0x6162, (%rdx)
nop
nop
nop
nop
nop
and $36067, %rcx
lea addresses_normal_ht+0x1af15, %r8
nop
nop
nop
nop
xor $11477, %rdi
mov $0x6162636465666768, %rdx
movq %rdx, %xmm0
movups %xmm0, (%r8)
xor %rdx, %rdx
lea addresses_UC_ht+0x5e75, %r15
and $26648, %r9
mov $0x6162636465666768, %rdi
movq %rdi, (%r15)
nop
nop
nop
xor $30377, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r15
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %r8
push %rax
push %rcx
// Store
lea addresses_WT+0x1a5b5, %r14
nop
nop
nop
nop
nop
inc %rax
movb $0x51, (%r14)
cmp %r14, %r14
// Faulty Load
lea addresses_normal+0x49b5, %r12
nop
cmp $14963, %r14
mov (%r12), %eax
lea oracles, %rcx
and $0xff, %rax
shlq $12, %rax
mov (%rcx,%rax,1), %rax
pop %rcx
pop %rax
pop %r8
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': True}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r14
push %r8
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x763c, %r13
nop
nop
nop
add %r12, %r12
mov (%r13), %r8d
nop
nop
nop
xor %rsi, %rsi
lea addresses_D_ht+0x1d1bc, %r12
nop
nop
nop
nop
nop
cmp %rdi, %rdi
movl $0x61626364, (%r12)
nop
nop
nop
nop
add $9570, %rdi
lea addresses_normal_ht+0xfe3c, %r8
nop
nop
nop
nop
dec %r14
mov $0x6162636465666768, %rsi
movq %rsi, %xmm4
movups %xmm4, (%r8)
nop
nop
cmp %r13, %r13
lea addresses_WT_ht+0x583c, %r12
nop
nop
nop
nop
dec %r8
mov $0x6162636465666768, %rbx
movq %rbx, %xmm1
vmovups %ymm1, (%r12)
nop
add $56041, %rbx
lea addresses_WT_ht+0x1d83c, %r14
nop
nop
nop
nop
nop
xor $40670, %rdi
mov $0x6162636465666768, %r12
movq %r12, %xmm0
vmovups %ymm0, (%r14)
nop
nop
nop
xor %r14, %r14
lea addresses_WC_ht+0x1bffc, %rsi
lea addresses_normal_ht+0x1903c, %rdi
nop
nop
sub $13389, %r14
mov $53, %rcx
rep movsl
nop
nop
nop
nop
and $33078, %rdi
lea addresses_UC_ht+0x8ca4, %rsi
lea addresses_A_ht+0xd43c, %rdi
nop
nop
nop
nop
nop
add $41506, %r14
mov $5, %rcx
rep movsw
nop
nop
and %rbx, %rbx
lea addresses_WT_ht+0x5ee0, %r8
nop
add %rsi, %rsi
mov (%r8), %bx
nop
nop
dec %r12
lea addresses_WC_ht+0x1063c, %r14
nop
nop
nop
nop
cmp $8992, %r8
mov (%r14), %r13
nop
nop
nop
nop
nop
inc %rdi
lea addresses_normal_ht+0xc3c, %rcx
nop
dec %rsi
mov $0x6162636465666768, %rbx
movq %rbx, (%rcx)
nop
add %rdi, %rdi
lea addresses_WT_ht+0x11b5e, %rbx
nop
nop
nop
nop
nop
sub %r12, %r12
movl $0x61626364, (%rbx)
nop
nop
nop
nop
nop
add %r13, %r13
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r14
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %r9
push %rax
push %rdi
// Store
lea addresses_normal+0x47bc, %r11
nop
nop
nop
nop
nop
cmp $42299, %r13
mov $0x5152535455565758, %r10
movq %r10, (%r11)
nop
nop
nop
nop
nop
dec %r10
// Load
lea addresses_PSE+0x11c3c, %r9
nop
nop
add %rax, %rax
movb (%r9), %r11b
nop
nop
nop
cmp $60249, %rax
// Store
lea addresses_WT+0xd73c, %r11
nop
nop
nop
dec %rdi
movw $0x5152, (%r11)
nop
nop
nop
nop
xor $34432, %rax
// Faulty Load
lea addresses_D+0x1543c, %rdi
nop
nop
cmp %rax, %rax
mov (%rdi), %r13
lea oracles, %r11
and $0xff, %r13
shlq $12, %r13
mov (%r11,%r13,1), %r13
pop %rdi
pop %rax
pop %r9
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': True, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': True, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 8}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 8, 'NT': True, 'type': 'addresses_D', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': True, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': True, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 10}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 11}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 2}}
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': True, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
SFX_Battle_27_Ch5:
duty_cycle 2
square_note 15, 3, -7, 1984
SFX_Battle_27_branch_2062a:
square_note 15, 13, -7, 1984
sound_loop 4, SFX_Battle_27_branch_2062a
square_note 15, 13, 1, 1984
sound_ret
SFX_Battle_27_Ch6:
duty_cycle_pattern 2, 3, 0, 3
square_note 15, 2, -7, 1992
SFX_Battle_27_branch_2063d:
square_note 15, 12, -7, 1991
sound_loop 4, SFX_Battle_27_branch_2063d
square_note 15, 12, 1, 1992
sound_ret
SFX_Battle_27_Ch8:
noise_note 3, 9, 7, 18
noise_note 3, 10, 1, 17
sound_loop 10, SFX_Battle_27_Ch8
sound_ret
|
; A197603: Floor((n+1/n)^4).
; Submitted by Jamie Morken(s1)
; 16,39,123,326,731,1446,2603,4358,6891,10406,15131,21318,29243,39206,51531,66566,84683,106278,131771,161606,196251,236198,281963,334086,393131,459686,534363,617798,710651,813606,927371,1052678,1190283,1340966,1505531,1684806,1879643,2090918,2319531,2566406,2832491,3118758,3426203,3755846,4108731,4485926,4888523,5317638,5774411,6260006,6775611,7322438,7901723,8514726,9162731,9847046,10569003,11329958,12131291,12974406,13860731,14791718,15768843,16793606,17867531,18992166,20169083,21399878
add $0,1
pow $0,2
mov $1,$0
pow $0,2
add $1,1
pow $1,4
div $1,$0
mov $0,$1
|
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2008-2015. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
// Stable vector.
//
// Copyright 2008 Joaquin M Lopez Munoz.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_CONTAINER_STABLE_VECTOR_HPP
#define BOOST_CONTAINER_STABLE_VECTOR_HPP
#ifndef BOOST_CONFIG_HPP
# include <boost/config.hpp>
#endif
#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/detail/workaround.hpp>
// container
#include <boost/container/allocator_traits.hpp>
#include <boost/container/container_fwd.hpp>
#include <boost/container/new_allocator.hpp> //new_allocator
#include <boost/container/throw_exception.hpp>
// container/detail
#include <boost/container/detail/addressof.hpp>
#include <boost/container/detail/algorithm.hpp> //algo_equal(), algo_lexicographical_compare
#include <boost/container/detail/alloc_helpers.hpp>
#include <boost/container/detail/allocator_version_traits.hpp>
#include <boost/container/detail/construct_in_place.hpp>
#include <boost/container/detail/iterator.hpp>
#include <boost/container/detail/iterators.hpp>
#include <boost/container/detail/placement_new.hpp>
#include <boost/move/detail/to_raw_pointer.hpp>
#include <boost/container/detail/type_traits.hpp>
// intrusive
#include <boost/intrusive/pointer_traits.hpp>
// intrusive/detail
#include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
// move
#include <boost/move/utility_core.hpp>
#include <boost/move/iterator.hpp>
#include <boost/move/adl_move_swap.hpp>
// move/detail
#include <boost/move/detail/move_helpers.hpp>
// other
#include <boost/assert.hpp>
#include <boost/core/no_exceptions_support.hpp>
// std
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
#include <boost/container/vector.hpp>
//#define STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
namespace boost {
namespace container {
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
namespace stable_vector_detail{
template <class C>
class clear_on_destroy
{
public:
clear_on_destroy(C &c)
: c_(c), do_clear_(true)
{}
void release()
{ do_clear_ = false; }
~clear_on_destroy()
{
if(do_clear_){
c_.clear();
c_.priv_clear_pool();
}
}
private:
clear_on_destroy(const clear_on_destroy &);
clear_on_destroy &operator=(const clear_on_destroy &);
C &c_;
bool do_clear_;
};
template<typename Pointer>
struct node;
template<class VoidPtr>
struct node_base
{
private:
typedef typename boost::intrusive::
pointer_traits<VoidPtr> void_ptr_traits;
typedef typename void_ptr_traits::
template rebind_pointer
<node_base>::type node_base_ptr;
typedef typename void_ptr_traits::
template rebind_pointer
<node_base_ptr>::type node_base_ptr_ptr;
public:
node_base(const node_base_ptr_ptr &n)
: up(n)
{}
node_base()
: up()
{}
node_base_ptr_ptr up;
};
template<typename Pointer>
struct node
: public node_base
<typename ::boost::intrusive::pointer_traits<Pointer>::template
rebind_pointer<void>::type
>
{
private:
node();
public:
typename ::boost::intrusive::pointer_traits<Pointer>::element_type value;
};
template<class VoidPtr, class VoidAllocator>
struct index_traits
{
typedef boost::intrusive::
pointer_traits
<VoidPtr> void_ptr_traits;
typedef stable_vector_detail::
node_base<VoidPtr> node_base_type;
typedef typename void_ptr_traits::template
rebind_pointer<node_base_type>::type node_base_ptr;
typedef typename void_ptr_traits::template
rebind_pointer<node_base_ptr>::type node_base_ptr_ptr;
typedef boost::intrusive::
pointer_traits<node_base_ptr> node_base_ptr_traits;
typedef boost::intrusive::
pointer_traits<node_base_ptr_ptr> node_base_ptr_ptr_traits;
typedef typename allocator_traits<VoidAllocator>::
template portable_rebind_alloc
<node_base_ptr>::type node_base_ptr_allocator;
typedef ::boost::container::vector
<node_base_ptr, node_base_ptr_allocator> index_type;
typedef typename index_type::iterator index_iterator;
typedef typename index_type::const_iterator const_index_iterator;
typedef typename index_type::size_type size_type;
static const size_type ExtraPointers = 3;
//Stable vector stores metadata at the end of the index (node_base_ptr vector) with additional 3 pointers:
// back() is this->index.back() - ExtraPointers;
// end node index is *(this->index.end() - 3)
// Node cache first is *(this->index.end() - 2);
// Node cache last is this->index.back();
static node_base_ptr_ptr ptr_to_node_base_ptr(node_base_ptr &n)
{ return node_base_ptr_ptr_traits::pointer_to(n); }
static void fix_up_pointers(index_iterator first, index_iterator last)
{
while(first != last){
typedef typename index_type::reference node_base_ptr_ref;
node_base_ptr_ref nbp = *first;
nbp->up = index_traits::ptr_to_node_base_ptr(nbp);
++first;
}
}
static index_iterator get_fix_up_end(index_type &index)
{ return index.end() - (ExtraPointers - 1); }
static void fix_up_pointers_from(index_type & index, index_iterator first)
{ index_traits::fix_up_pointers(first, index_traits::get_fix_up_end(index)); }
static void readjust_end_node(index_type &index, node_base_type &end_node)
{
if(!index.empty()){
index_iterator end_node_it(index_traits::get_fix_up_end(index));
node_base_ptr &end_node_idx_ref = *(--end_node_it);
end_node_idx_ref = node_base_ptr_traits::pointer_to(end_node);
end_node.up = node_base_ptr_ptr_traits::pointer_to(end_node_idx_ref);
}
else{
end_node.up = node_base_ptr_ptr();
}
}
static void initialize_end_node(index_type &index, node_base_type &end_node, const size_type index_capacity_if_empty)
{
if(index.empty()){
index.reserve(index_capacity_if_empty + ExtraPointers);
index.resize(ExtraPointers);
node_base_ptr &end_node_ref = *index.data();
end_node_ref = node_base_ptr_traits::pointer_to(end_node);
end_node.up = index_traits::ptr_to_node_base_ptr(end_node_ref);
}
}
#ifdef STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
static bool invariants(index_type &index)
{
for( index_iterator it = index.begin()
, it_end = index_traits::get_fix_up_end(index)
; it != it_end
; ++it){
if((*it)->up != index_traits::ptr_to_node_base_ptr(*it)){
return false;
}
}
return true;
}
#endif //STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
};
} //namespace stable_vector_detail
template<typename Pointer, bool IsConst>
class stable_vector_iterator
{
typedef boost::intrusive::pointer_traits<Pointer> non_const_ptr_traits;
public:
typedef std::random_access_iterator_tag iterator_category;
typedef typename non_const_ptr_traits::element_type value_type;
typedef typename non_const_ptr_traits::difference_type difference_type;
typedef typename ::boost::container::dtl::if_c
< IsConst
, typename non_const_ptr_traits::template
rebind_pointer<const value_type>::type
, Pointer
>::type pointer;
typedef boost::intrusive::pointer_traits<pointer> ptr_traits;
typedef typename ptr_traits::reference reference;
private:
typedef typename non_const_ptr_traits::template
rebind_pointer<void>::type void_ptr;
typedef stable_vector_detail::node<Pointer> node_type;
typedef stable_vector_detail::node_base<void_ptr> node_base_type;
typedef typename non_const_ptr_traits::template
rebind_pointer<node_type>::type node_ptr;
typedef boost::intrusive::
pointer_traits<node_ptr> node_ptr_traits;
typedef typename non_const_ptr_traits::template
rebind_pointer<node_base_type>::type node_base_ptr;
typedef typename non_const_ptr_traits::template
rebind_pointer<node_base_ptr>::type node_base_ptr_ptr;
node_base_ptr m_pn;
public:
explicit stable_vector_iterator(node_base_ptr p) BOOST_NOEXCEPT_OR_NOTHROW
: m_pn(p)
{}
stable_vector_iterator() BOOST_NOEXCEPT_OR_NOTHROW
: m_pn() //Value initialization to achieve "null iterators" (N3644)
{}
stable_vector_iterator(stable_vector_iterator<Pointer, false> const& other) BOOST_NOEXCEPT_OR_NOTHROW
: m_pn(other.node_pointer())
{}
node_ptr node_pointer() const BOOST_NOEXCEPT_OR_NOTHROW
{ return node_ptr_traits::static_cast_from(m_pn); }
public:
//Pointer like operators
reference operator*() const BOOST_NOEXCEPT_OR_NOTHROW
{ return node_pointer()->value; }
pointer operator->() const BOOST_NOEXCEPT_OR_NOTHROW
{ return ptr_traits::pointer_to(this->operator*()); }
//Increment / Decrement
stable_vector_iterator& operator++() BOOST_NOEXCEPT_OR_NOTHROW
{
node_base_ptr_ptr p(this->m_pn->up);
this->m_pn = *(++p);
return *this;
}
stable_vector_iterator operator++(int) BOOST_NOEXCEPT_OR_NOTHROW
{ stable_vector_iterator tmp(*this); ++*this; return stable_vector_iterator(tmp); }
stable_vector_iterator& operator--() BOOST_NOEXCEPT_OR_NOTHROW
{
node_base_ptr_ptr p(this->m_pn->up);
this->m_pn = *(--p);
return *this;
}
stable_vector_iterator operator--(int) BOOST_NOEXCEPT_OR_NOTHROW
{ stable_vector_iterator tmp(*this); --*this; return stable_vector_iterator(tmp); }
reference operator[](difference_type off) const BOOST_NOEXCEPT_OR_NOTHROW
{ return node_ptr_traits::static_cast_from(this->m_pn->up[off])->value; }
stable_vector_iterator& operator+=(difference_type off) BOOST_NOEXCEPT_OR_NOTHROW
{
if(off) this->m_pn = this->m_pn->up[off];
return *this;
}
friend stable_vector_iterator operator+(const stable_vector_iterator &left, difference_type off) BOOST_NOEXCEPT_OR_NOTHROW
{
stable_vector_iterator tmp(left);
tmp += off;
return tmp;
}
friend stable_vector_iterator operator+(difference_type off, const stable_vector_iterator& right) BOOST_NOEXCEPT_OR_NOTHROW
{
stable_vector_iterator tmp(right);
tmp += off;
return tmp;
}
stable_vector_iterator& operator-=(difference_type off) BOOST_NOEXCEPT_OR_NOTHROW
{ *this += -off; return *this; }
friend stable_vector_iterator operator-(const stable_vector_iterator &left, difference_type off) BOOST_NOEXCEPT_OR_NOTHROW
{
stable_vector_iterator tmp(left);
tmp -= off;
return tmp;
}
friend difference_type operator-(const stable_vector_iterator &left, const stable_vector_iterator &right) BOOST_NOEXCEPT_OR_NOTHROW
{ return left.m_pn->up - right.m_pn->up; }
//Comparison operators
friend bool operator== (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return l.m_pn == r.m_pn; }
friend bool operator!= (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return l.m_pn != r.m_pn; }
friend bool operator< (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return l.m_pn->up < r.m_pn->up; }
friend bool operator<= (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return l.m_pn->up <= r.m_pn->up; }
friend bool operator> (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return l.m_pn->up > r.m_pn->up; }
friend bool operator>= (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return l.m_pn->up >= r.m_pn->up; }
};
#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
#define STABLE_VECTOR_CHECK_INVARIANT \
invariant_checker BOOST_JOIN(check_invariant_,__LINE__)(*this); \
BOOST_JOIN(check_invariant_,__LINE__).touch();
#else //STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
#define STABLE_VECTOR_CHECK_INVARIANT
#endif //#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
//! Originally developed by Joaquin M. Lopez Munoz, stable_vector is a std::vector
//! drop-in replacement implemented as a node container, offering iterator and reference
//! stability.
//!
//! Here are the details taken from the author's blog
//! (<a href="http://bannalia.blogspot.com/2008/09/introducing-stablevector.html" >
//! Introducing stable_vector</a>):
//!
//! We present stable_vector, a fully STL-compliant stable container that provides
//! most of the features of std::vector except element contiguity.
//!
//! General properties: stable_vector satisfies all the requirements of a container,
//! a reversible container and a sequence and provides all the optional operations
//! present in std::vector. Like std::vector, iterators are random access.
//! stable_vector does not provide element contiguity; in exchange for this absence,
//! the container is stable, i.e. references and iterators to an element of a stable_vector
//! remain valid as long as the element is not erased, and an iterator that has been
//! assigned the return value of end() always remain valid until the destruction of
//! the associated stable_vector.
//!
//! Operation complexity: The big-O complexities of stable_vector operations match
//! exactly those of std::vector. In general, insertion/deletion is constant time at
//! the end of the sequence and linear elsewhere. Unlike std::vector, stable_vector
//! does not internally perform any value_type destruction, copy or assignment
//! operations other than those exactly corresponding to the insertion of new
//! elements or deletion of stored elements, which can sometimes compensate in terms
//! of performance for the extra burden of doing more pointer manipulation and an
//! additional allocation per element.
//!
//! Exception safety: As stable_vector does not internally copy elements around, some
//! operations provide stronger exception safety guarantees than in std::vector.
//!
//! \tparam T The type of object that is stored in the stable_vector
//! \tparam Allocator The allocator used for all internal memory management
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
template <class T, class Allocator = new_allocator<T> >
#else
template <class T, class Allocator>
#endif
class stable_vector
{
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
typedef allocator_traits<Allocator> allocator_traits_type;
typedef boost::intrusive::
pointer_traits
<typename allocator_traits_type::pointer> ptr_traits;
typedef typename ptr_traits::
template rebind_pointer<void>::type void_ptr;
typedef typename allocator_traits_type::
template portable_rebind_alloc
<void>::type void_allocator_type;
typedef stable_vector_detail::index_traits
<void_ptr, void_allocator_type> index_traits_type;
typedef typename index_traits_type::node_base_type node_base_type;
typedef typename index_traits_type::node_base_ptr node_base_ptr;
typedef typename index_traits_type::
node_base_ptr_ptr node_base_ptr_ptr;
typedef typename index_traits_type::
node_base_ptr_traits node_base_ptr_traits;
typedef typename index_traits_type::
node_base_ptr_ptr_traits node_base_ptr_ptr_traits;
typedef typename index_traits_type::index_type index_type;
typedef typename index_traits_type::index_iterator index_iterator;
typedef typename index_traits_type::
const_index_iterator const_index_iterator;
typedef stable_vector_detail::node
<typename ptr_traits::pointer> node_type;
typedef typename ptr_traits::template
rebind_pointer<node_type>::type node_ptr;
typedef boost::intrusive::
pointer_traits<node_ptr> node_ptr_traits;
typedef typename ptr_traits::template
rebind_pointer<const node_type>::type const_node_ptr;
typedef boost::intrusive::
pointer_traits<const_node_ptr> const_node_ptr_traits;
typedef typename node_ptr_traits::reference node_reference;
typedef typename const_node_ptr_traits::reference const_node_reference;
typedef ::boost::container::dtl::integral_constant
<unsigned, boost::container::dtl::
version<Allocator>::value> alloc_version;
typedef typename allocator_traits_type::
template portable_rebind_alloc
<node_type>::type node_allocator_type;
typedef ::boost::container::dtl::
allocator_version_traits<node_allocator_type> allocator_version_traits_t;
typedef typename allocator_version_traits_t::multiallocation_chain multiallocation_chain;
node_ptr allocate_one()
{ return allocator_version_traits_t::allocate_one(this->priv_node_alloc()); }
void deallocate_one(const node_ptr &p)
{ allocator_version_traits_t::deallocate_one(this->priv_node_alloc(), p); }
void allocate_individual(typename allocator_traits_type::size_type n, multiallocation_chain &m)
{ allocator_version_traits_t::allocate_individual(this->priv_node_alloc(), n, m); }
void deallocate_individual(multiallocation_chain &holder)
{ allocator_version_traits_t::deallocate_individual(this->priv_node_alloc(), holder); }
friend class stable_vector_detail::clear_on_destroy<stable_vector>;
typedef stable_vector_iterator
< typename allocator_traits<Allocator>::pointer
, false> iterator_impl;
typedef stable_vector_iterator
< typename allocator_traits<Allocator>::pointer
, true> const_iterator_impl;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
public:
//////////////////////////////////////////////
//
// types
//
//////////////////////////////////////////////
typedef T value_type;
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
typedef Allocator allocator_type;
typedef node_allocator_type stored_allocator_type;
typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<iterator>) reverse_iterator;
typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<const_iterator>) const_reverse_iterator;
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private:
BOOST_COPYABLE_AND_MOVABLE(stable_vector)
static const size_type ExtraPointers = index_traits_type::ExtraPointers;
class insert_rollback;
friend class insert_rollback;
class push_back_rollback;
friend class push_back_rollback;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
public:
//////////////////////////////////////////////
//
// construct/copy/destroy
//
//////////////////////////////////////////////
//! <b>Effects</b>: Default constructs a stable_vector.
//!
//! <b>Throws</b>: If allocator_type's default constructor throws.
//!
//! <b>Complexity</b>: Constant.
stable_vector() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<Allocator>::value)
: internal_data(), index()
{
STABLE_VECTOR_CHECK_INVARIANT;
}
//! <b>Effects</b>: Constructs a stable_vector taking the allocator as parameter.
//!
//! <b>Throws</b>: Nothing
//!
//! <b>Complexity</b>: Constant.
explicit stable_vector(const allocator_type& al) BOOST_NOEXCEPT_OR_NOTHROW
: internal_data(al), index(al)
{
STABLE_VECTOR_CHECK_INVARIANT;
}
//! <b>Effects</b>: Constructs a stable_vector
//! and inserts n value initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
explicit stable_vector(size_type n)
: internal_data(), index()
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->resize(n);
STABLE_VECTOR_CHECK_INVARIANT;
cod.release();
}
//! <b>Effects</b>: Constructs a stable_vector
//! and inserts n default initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
//!
//! <b>Note</b>: Non-standard extension
stable_vector(size_type n, default_init_t)
: internal_data(), index()
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->resize(n, default_init);
STABLE_VECTOR_CHECK_INVARIANT;
cod.release();
}
//! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a
//! and inserts n value initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
explicit stable_vector(size_type n, const allocator_type &a)
: internal_data(), index(a)
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->resize(n);
STABLE_VECTOR_CHECK_INVARIANT;
cod.release();
}
//! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a
//! and inserts n default initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
//!
//! <b>Note</b>: Non-standard extension
stable_vector(size_type n, default_init_t, const allocator_type &a)
: internal_data(), index(a)
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->resize(n, default_init);
STABLE_VECTOR_CHECK_INVARIANT;
cod.release();
}
//! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a
//! and inserts n copies of value.
//!
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
stable_vector(size_type n, const T& t, const allocator_type& al = allocator_type())
: internal_data(al), index(al)
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->insert(this->cend(), n, t);
STABLE_VECTOR_CHECK_INVARIANT;
cod.release();
}
//! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a
//! and inserts a copy of the range [first, last) in the stable_vector.
//!
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's constructor taking a dereferenced InIt throws.
//!
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InputIterator>
stable_vector(InputIterator first,InputIterator last, const allocator_type& al = allocator_type())
: internal_data(al), index(al)
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->insert(this->cend(), first, last);
STABLE_VECTOR_CHECK_INVARIANT;
cod.release();
}
//! <b>Effects</b>: Copy constructs a stable_vector.
//!
//! <b>Postcondition</b>: x == *this.
//!
//! <b>Complexity</b>: Linear to the elements x contains.
stable_vector(const stable_vector& x)
: internal_data(allocator_traits<node_allocator_type>::
select_on_container_copy_construction(x.priv_node_alloc()))
, index(allocator_traits<allocator_type>::
select_on_container_copy_construction(x.index.get_stored_allocator()))
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->insert(this->cend(), x.begin(), x.end());
STABLE_VECTOR_CHECK_INVARIANT;
cod.release();
}
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
//! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a
//! and inserts a copy of the range [il.begin(), il.last()) in the stable_vector
//!
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's constructor taking a dereferenced initializer_list iterator throws.
//!
//! <b>Complexity</b>: Linear to the range [il.begin(), il.end()).
stable_vector(std::initializer_list<value_type> il, const allocator_type& l = allocator_type())
: internal_data(l), index(l)
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
insert(cend(), il.begin(), il.end());
STABLE_VECTOR_CHECK_INVARIANT;
cod.release();
}
#endif
//! <b>Effects</b>: Move constructor. Moves x's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
stable_vector(BOOST_RV_REF(stable_vector) x) BOOST_NOEXCEPT_OR_NOTHROW
: internal_data(boost::move(x.priv_node_alloc())), index(boost::move(x.index))
{
this->priv_swap_members(x);
}
//! <b>Effects</b>: Copy constructs a stable_vector using the specified allocator.
//!
//! <b>Postcondition</b>: x == *this.
//!
//! <b>Complexity</b>: Linear to the elements x contains.
stable_vector(const stable_vector& x, const allocator_type &a)
: internal_data(a), index(a)
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->insert(this->cend(), x.begin(), x.end());
STABLE_VECTOR_CHECK_INVARIANT;
cod.release();
}
//! <b>Effects</b>: Move constructor using the specified allocator.
//! Moves x's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
//!
//! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise
stable_vector(BOOST_RV_REF(stable_vector) x, const allocator_type &a)
: internal_data(a), index(a)
{
if(this->priv_node_alloc() == x.priv_node_alloc()){
this->index.swap(x.index);
this->priv_swap_members(x);
}
else{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->insert(this->cend(), boost::make_move_iterator(x.begin()), boost::make_move_iterator(x.end()));
STABLE_VECTOR_CHECK_INVARIANT;
cod.release();
}
}
//! <b>Effects</b>: Destroys the stable_vector. All stored values are destroyed
//! and used memory is deallocated.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the number of elements.
~stable_vector()
{
this->clear();
this->priv_clear_pool();
}
//! <b>Effects</b>: Makes *this contain the same elements as x.
//!
//! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
//! of each of x's elements.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to the number of elements in x.
stable_vector& operator=(BOOST_COPY_ASSIGN_REF(stable_vector) x)
{
STABLE_VECTOR_CHECK_INVARIANT;
if (&x != this){
node_allocator_type &this_alloc = this->priv_node_alloc();
const node_allocator_type &x_alloc = x.priv_node_alloc();
dtl::bool_<allocator_traits_type::
propagate_on_container_copy_assignment::value> flag;
if(flag && this_alloc != x_alloc){
this->clear();
this->shrink_to_fit();
}
dtl::assign_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag);
dtl::assign_alloc(this->index.get_stored_allocator(), x.index.get_stored_allocator(), flag);
this->assign(x.begin(), x.end());
}
return *this;
}
//! <b>Effects</b>: Move assignment. All x's values are transferred to *this.
//!
//! <b>Postcondition</b>: x.empty(). *this contains a the elements x had
//! before the function.
//!
//! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment
//! is false and (allocation throws or T's move constructor throws)
//!
//! <b>Complexity</b>: Constant if allocator_traits_type::
//! propagate_on_container_move_assignment is true or
//! this->get>allocator() == x.get_allocator(). Linear otherwise.
stable_vector& operator=(BOOST_RV_REF(stable_vector) x)
BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
|| allocator_traits_type::is_always_equal::value)
{
//for move constructor, no aliasing (&x != this) is assummed.
BOOST_ASSERT(this != &x);
node_allocator_type &this_alloc = this->priv_node_alloc();
node_allocator_type &x_alloc = x.priv_node_alloc();
const bool propagate_alloc = allocator_traits_type::
propagate_on_container_move_assignment::value;
dtl::bool_<propagate_alloc> flag;
const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal;
//Resources can be transferred if both allocators are
//going to be equal after this function (either propagated or already equal)
if(propagate_alloc || allocators_equal){
STABLE_VECTOR_CHECK_INVARIANT
//Destroy objects but retain memory in case x reuses it in the future
this->clear();
//Move allocator if needed
dtl::move_alloc(this_alloc, x_alloc, flag);
//Take resources
this->index.swap(x.index);
this->priv_swap_members(x);
}
//Else do a one by one move
else{
this->assign( boost::make_move_iterator(x.begin())
, boost::make_move_iterator(x.end()));
}
return *this;
}
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
//! <b>Effects</b>: Make *this container contains elements from il.
//!
//! <b>Complexity</b>: Linear to the range [il.begin(), il.end()).
stable_vector& operator=(std::initializer_list<value_type> il)
{
STABLE_VECTOR_CHECK_INVARIANT;
assign(il.begin(), il.end());
return *this;
}
#endif
//! <b>Effects</b>: Assigns the n copies of val to *this.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
void assign(size_type n, const T& t)
{
typedef constant_iterator<value_type, difference_type> cvalue_iterator;
this->assign(cvalue_iterator(t, n), cvalue_iterator());
}
//! <b>Effects</b>: Assigns the the range [first, last) to *this.
//!
//! <b>Throws</b>: If memory allocation throws or
//! T's constructor from dereferencing InpIt throws.
//!
//! <b>Complexity</b>: Linear to n.
template<typename InputIterator>
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
typename dtl::disable_if_convertible<InputIterator, size_type>::type
#else
void
#endif
assign(InputIterator first,InputIterator last)
{
STABLE_VECTOR_CHECK_INVARIANT;
iterator first1 = this->begin();
iterator last1 = this->end();
for ( ; first1 != last1 && first != last; ++first1, ++first)
*first1 = *first;
if (first == last){
this->erase(first1, last1);
}
else{
this->insert(last1, first, last);
}
}
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
//! <b>Effects</b>: Assigns the the range [il.begin(), il.end()) to *this.
//!
//! <b>Throws</b>: If memory allocation throws or
//! T's constructor from dereferencing initializer_list iterator throws.
//!
void assign(std::initializer_list<value_type> il)
{
STABLE_VECTOR_CHECK_INVARIANT;
assign(il.begin(), il.end());
}
#endif
//! <b>Effects</b>: Returns a copy of the internal allocator.
//!
//! <b>Throws</b>: If allocator's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
allocator_type get_allocator() const
{ return this->priv_node_alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
//!
//! <b>Throws</b>: Nothing
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Note</b>: Non-standard extension.
const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->priv_node_alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
//!
//! <b>Throws</b>: Nothing
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Note</b>: Non-standard extension.
stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW
{ return this->priv_node_alloc(); }
//////////////////////////////////////////////
//
// iterators
//
//////////////////////////////////////////////
//! <b>Effects</b>: Returns an iterator to the first element contained in the stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
iterator begin() BOOST_NOEXCEPT_OR_NOTHROW
{ return (this->index.empty()) ? this->end(): iterator(node_ptr_traits::static_cast_from(this->index.front())); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return (this->index.empty()) ? this->cend() : const_iterator(node_ptr_traits::static_cast_from(this->index.front())) ; }
//! <b>Effects</b>: Returns an iterator to the end of the stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
iterator end() BOOST_NOEXCEPT_OR_NOTHROW
{ return iterator(this->priv_get_end_node()); }
//! <b>Effects</b>: Returns a const_iterator to the end of the stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW
{ return const_iterator(this->priv_get_end_node()); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
//! of the reversed stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW
{ return reverse_iterator(this->end()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
//! of the reversed stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return const_reverse_iterator(this->end()); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
//! of the reversed stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW
{ return reverse_iterator(this->begin()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
//! of the reversed stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW
{ return const_reverse_iterator(this->begin()); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->begin(); }
//! <b>Effects</b>: Returns a const_iterator to the end of the stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->end(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
//! of the reversed stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->rbegin(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
//! of the reversed stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crend()const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->rend(); }
//////////////////////////////////////////////
//
// capacity
//
//////////////////////////////////////////////
//! <b>Effects</b>: Returns true if the stable_vector contains no elements.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
bool empty() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->index.size() <= ExtraPointers; }
//! <b>Effects</b>: Returns the number of the elements contained in the stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
size_type size() const BOOST_NOEXCEPT_OR_NOTHROW
{
const size_type index_size = this->index.size();
return (index_size - ExtraPointers) & (size_type(0u) -size_type(index_size != 0));
}
//! <b>Effects</b>: Returns the largest possible size of the stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->index.max_size() - ExtraPointers; }
//! <b>Effects</b>: Inserts or erases elements at the end such that
//! the size becomes n. New elements are value initialized.
//!
//! <b>Throws</b>: If memory allocation throws, or T's value initialization throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
void resize(size_type n)
{
typedef value_init_construct_iterator<value_type, difference_type> value_init_iterator;
STABLE_VECTOR_CHECK_INVARIANT;
if(n > this->size())
this->insert(this->cend(), value_init_iterator(n - this->size()), value_init_iterator());
else if(n < this->size())
this->erase(this->cbegin() + n, this->cend());
}
//! <b>Effects</b>: Inserts or erases elements at the end such that
//! the size becomes n. New elements are default initialized.
//!
//! <b>Throws</b>: If memory allocation throws, or T's default initialization throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
//!
//! <b>Note</b>: Non-standard extension
void resize(size_type n, default_init_t)
{
typedef default_init_construct_iterator<value_type, difference_type> default_init_iterator;
STABLE_VECTOR_CHECK_INVARIANT;
if(n > this->size())
this->insert(this->cend(), default_init_iterator(n - this->size()), default_init_iterator());
else if(n < this->size())
this->erase(this->cbegin() + n, this->cend());
}
//! <b>Effects</b>: Inserts or erases elements at the end such that
//! the size becomes n. New elements are copy constructed from x.
//!
//! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
void resize(size_type n, const T& t)
{
STABLE_VECTOR_CHECK_INVARIANT;
if(n > this->size())
this->insert(this->cend(), n - this->size(), t);
else if(n < this->size())
this->erase(this->cbegin() + n, this->cend());
}
//! <b>Effects</b>: Number of elements for which memory has been allocated.
//! capacity() is always greater than or equal to size().
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW
{
const size_type index_size = this->index.size();
BOOST_ASSERT(!index_size || index_size >= ExtraPointers);
const size_type node_extra_capacity = this->internal_data.pool_size;
//Pool count must be less than index capacity, as index is a vector
BOOST_ASSERT(node_extra_capacity <= (this->index.capacity()- index_size));
const size_type index_offset =
(node_extra_capacity - ExtraPointers) & (size_type(0u) - size_type(index_size != 0));
return index_size + index_offset;
}
//! <b>Effects</b>: If n is less than or equal to capacity(), this call has no
//! effect. Otherwise, it is a request for allocation of additional memory.
//! If the request is successful, then capacity() is greater than or equal to
//! n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
//!
//! <b>Throws</b>: If memory allocation allocation throws.
void reserve(size_type n)
{
STABLE_VECTOR_CHECK_INVARIANT;
if(n > this->max_size()){
throw_length_error("stable_vector::reserve max_size() exceeded");
}
size_type sz = this->size();
size_type old_capacity = this->capacity();
if(n > old_capacity){
index_traits_type::initialize_end_node(this->index, this->internal_data.end_node, n);
const void * old_ptr = &index[0];
this->index.reserve(n + ExtraPointers);
bool realloced = &index[0] != old_ptr;
//Fix the pointers for the newly allocated buffer
if(realloced){
index_traits_type::fix_up_pointers_from(this->index, this->index.begin());
}
//Now fill pool if data is not enough
if((n - sz) > this->internal_data.pool_size){
this->priv_increase_pool((n - sz) - this->internal_data.pool_size);
}
}
}
//! <b>Effects</b>: Tries to deallocate the excess of memory created
//! with previous allocations. The size of the stable_vector is unchanged
//!
//! <b>Throws</b>: If memory allocation throws.
//!
//! <b>Complexity</b>: Linear to size().
void shrink_to_fit()
{
if(this->capacity()){
//First empty allocated node pool
this->priv_clear_pool();
//If empty completely destroy the index, let's recover default-constructed state
if(this->empty()){
this->index.clear();
this->index.shrink_to_fit();
this->internal_data.end_node.up = node_base_ptr_ptr();
}
//Otherwise, try to shrink-to-fit the index and readjust pointers if necessary
else{
const void* old_ptr = &index[0];
this->index.shrink_to_fit();
bool realloced = &index[0] != old_ptr;
//Fix the pointers for the newly allocated buffer
if(realloced){
index_traits_type::fix_up_pointers_from(this->index, this->index.begin());
}
}
}
}
//////////////////////////////////////////////
//
// element access
//
//////////////////////////////////////////////
//! <b>Requires</b>: !empty()
//!
//! <b>Effects</b>: Returns a reference to the first
//! element of the container.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
reference front() BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(!this->empty());
return static_cast<node_reference>(*this->index.front()).value;
}
//! <b>Requires</b>: !empty()
//!
//! <b>Effects</b>: Returns a const reference to the first
//! element of the container.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(!this->empty());
return static_cast<const_node_reference>(*this->index.front()).value;
}
//! <b>Requires</b>: !empty()
//!
//! <b>Effects</b>: Returns a reference to the last
//! element of the container.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
reference back() BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(!this->empty());
return static_cast<node_reference>(*this->index[this->size()-1u]).value;
}
//! <b>Requires</b>: !empty()
//!
//! <b>Effects</b>: Returns a const reference to the last
//! element of the container.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(!this->empty());
return static_cast<const_node_reference>(*this->index[this->size()-1u]).value;
}
//! <b>Requires</b>: size() > n.
//!
//! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->size() > n);
return static_cast<node_reference>(*this->index[n]).value;
}
//! <b>Requires</b>: size() > n.
//!
//! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
const_reference operator[](size_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->size() > n);
return static_cast<const_node_reference>(*this->index[n]).value;
}
//! <b>Requires</b>: size() >= n.
//!
//! <b>Effects</b>: Returns an iterator to the nth element
//! from the beginning of the container. Returns end()
//! if n == size().
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Note</b>: Non-standard extension
iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->size() >= n);
return (this->index.empty()) ? this->end() : iterator(node_ptr_traits::static_cast_from(this->index[n]));
}
//! <b>Requires</b>: size() >= n.
//!
//! <b>Effects</b>: Returns a const_iterator to the nth element
//! from the beginning of the container. Returns end()
//! if n == size().
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Note</b>: Non-standard extension
const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->size() >= n);
return (this->index.empty()) ? this->cend() : iterator(node_ptr_traits::static_cast_from(this->index[n]));
}
//! <b>Requires</b>: begin() <= p <= end().
//!
//! <b>Effects</b>: Returns the index of the element pointed by p
//! and size() if p == end().
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Note</b>: Non-standard extension
size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW
{ return this->priv_index_of(p.node_pointer()); }
//! <b>Requires</b>: begin() <= p <= end().
//!
//! <b>Effects</b>: Returns the index of the element pointed by p
//! and size() if p == end().
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Note</b>: Non-standard extension
size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->priv_index_of(p.node_pointer()); }
//! <b>Requires</b>: size() > n.
//!
//! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
//!
//! <b>Throws</b>: std::range_error if n >= size()
//!
//! <b>Complexity</b>: Constant.
reference at(size_type n)
{
if(n >= this->size()){
throw_out_of_range("vector::at invalid subscript");
}
return operator[](n);
}
//! <b>Requires</b>: size() > n.
//!
//! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
//!
//! <b>Throws</b>: std::range_error if n >= size()
//!
//! <b>Complexity</b>: Constant.
const_reference at(size_type n)const
{
if(n >= this->size()){
throw_out_of_range("vector::at invalid subscript");
}
return operator[](n);
}
//////////////////////////////////////////////
//
// modifiers
//
//////////////////////////////////////////////
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts an object of type T constructed with
//! std::forward<Args>(args)... in the end of the stable_vector.
//!
//! <b>Returns</b>: A reference to the created object.
//!
//! <b>Throws</b>: If memory allocation throws or the in-place constructor throws.
//!
//! <b>Complexity</b>: Amortized constant time.
template<class ...Args>
reference emplace_back(Args &&...args)
{
typedef emplace_functor<Args...> EmplaceFunctor;
typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;
EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...);
return *this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator());
}
//! <b>Requires</b>: p must be a valid iterator of *this.
//!
//! <b>Effects</b>: Inserts an object of type T constructed with
//! std::forward<Args>(args)... before p
//!
//! <b>Throws</b>: If memory allocation throws or the in-place constructor throws.
//!
//! <b>Complexity</b>: If p is end(), amortized constant time
//! Linear time otherwise.
template<class ...Args>
iterator emplace(const_iterator p, Args && ...args)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
size_type pos_n = p - cbegin();
typedef emplace_functor<Args...> EmplaceFunctor;
typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;
EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...);
this->insert(p, EmplaceIterator(ef), EmplaceIterator());
return iterator(this->begin() + pos_n);
}
#else
#define BOOST_CONTAINER_STABLE_VECTOR_EMPLACE_CODE(N) \
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
reference emplace_back(BOOST_MOVE_UREF##N)\
{\
typedef emplace_functor##N\
BOOST_MOVE_LT##N BOOST_MOVE_TARG##N BOOST_MOVE_GT##N EmplaceFunctor;\
typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;\
EmplaceFunctor ef BOOST_MOVE_LP##N BOOST_MOVE_FWD##N BOOST_MOVE_RP##N;\
return *this->insert(this->cend() , EmplaceIterator(ef), EmplaceIterator());\
}\
\
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
iterator emplace(const_iterator p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
{\
BOOST_ASSERT(this->priv_in_range_or_end(p));\
typedef emplace_functor##N\
BOOST_MOVE_LT##N BOOST_MOVE_TARG##N BOOST_MOVE_GT##N EmplaceFunctor;\
typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;\
EmplaceFunctor ef BOOST_MOVE_LP##N BOOST_MOVE_FWD##N BOOST_MOVE_RP##N;\
const size_type pos_n = p - this->cbegin();\
this->insert(p, EmplaceIterator(ef), EmplaceIterator());\
return this->begin() += pos_n;\
}\
//
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_STABLE_VECTOR_EMPLACE_CODE)
#undef BOOST_CONTAINER_STABLE_VECTOR_EMPLACE_CODE
#endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts a copy of x at the end of the stable_vector.
//!
//! <b>Throws</b>: If memory allocation throws or
//! T's copy constructor throws.
//!
//! <b>Complexity</b>: Amortized constant time.
void push_back(const T &x);
//! <b>Effects</b>: Constructs a new element in the end of the stable_vector
//! and moves the resources of x to this new element.
//!
//! <b>Throws</b>: If memory allocation throws.
//!
//! <b>Complexity</b>: Amortized constant time.
void push_back(T &&x);
#else
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
#endif
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Requires</b>: p must be a valid iterator of *this.
//!
//! <b>Effects</b>: Insert a copy of x before p.
//!
//! <b>Returns</b>: An iterator to the inserted element.
//!
//! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
//!
//! <b>Complexity</b>: If p is end(), amortized constant time
//! Linear time otherwise.
iterator insert(const_iterator p, const T &x);
//! <b>Requires</b>: p must be a valid iterator of *this.
//!
//! <b>Effects</b>: Insert a new element before p with x's resources.
//!
//! <b>Returns</b>: an iterator to the inserted element.
//!
//! <b>Throws</b>: If memory allocation throws.
//!
//! <b>Complexity</b>: If p is end(), amortized constant time
//! Linear time otherwise.
iterator insert(const_iterator p, T &&x);
#else
BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator)
#endif
//! <b>Requires</b>: p must be a valid iterator of *this.
//!
//! <b>Effects</b>: Insert n copies of x before p.
//!
//! <b>Returns</b>: an iterator to the first inserted element or p if n is 0.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
iterator insert(const_iterator p, size_type n, const T& t)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
STABLE_VECTOR_CHECK_INVARIANT;
typedef constant_iterator<value_type, difference_type> cvalue_iterator;
return this->insert(p, cvalue_iterator(t, n), cvalue_iterator());
}
//! <b>Requires</b>: p must be a valid iterator of *this.
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
//! <b>Requires</b>: p must be a valid iterator of *this.
//!
//! <b>Effects</b>: Insert a copy of the [il.begin(), il.end()) range before p.
//!
//! <b>Returns</b>: an iterator to the first inserted element or p if first == last.
//!
//! <b>Complexity</b>: Linear to distance [il.begin(), il.end()).
iterator insert(const_iterator p, std::initializer_list<value_type> il)
{
//Position checks done by insert()
STABLE_VECTOR_CHECK_INVARIANT;
return insert(p, il.begin(), il.end());
}
#endif
//! <b>Requires</b>: pos must be a valid iterator of *this.
//!
//! <b>Effects</b>: Insert a copy of the [first, last) range before p.
//!
//! <b>Returns</b>: an iterator to the first inserted element or p if first == last.
//!
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced InpIt throws or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to distance [first, last).
template <class InputIterator>
iterator insert(const_iterator p, InputIterator first, InputIterator last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//Put this as argument instead of the return type as old GCC's like 3.4
//detect this and the next disable_if_or as overloads
, typename dtl::disable_if_or
< void
, dtl::is_convertible<InputIterator, size_type>
, dtl::is_not_input_iterator<InputIterator>
>::type* = 0
#endif
)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
STABLE_VECTOR_CHECK_INVARIANT;
const size_type pos_n = p - this->cbegin();
for(; first != last; ++first){
this->emplace(p, *first);
}
return this->begin() + pos_n;
}
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
template <class FwdIt>
typename dtl::disable_if_or
< iterator
, dtl::is_convertible<FwdIt, size_type>
, dtl::is_input_iterator<FwdIt>
>::type
insert(const_iterator p, FwdIt first, FwdIt last)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
const size_type num_new = static_cast<size_type>(boost::container::iterator_distance(first, last));
const size_type idx = static_cast<size_type>(p - this->cbegin());
if(num_new){
//Fills the node pool and inserts num_new null pointers in idx.
//If a new buffer was needed fixes up pointers up to idx so
//past-new nodes are not aligned until the end of this function
//or in a rollback in case of exception
index_iterator it_past_newly_constructed(this->priv_insert_forward_non_templated(idx, num_new));
const index_iterator it_past_new(it_past_newly_constructed + num_new);
{
//Prepare rollback
insert_rollback rollback(*this, it_past_newly_constructed, it_past_new);
while(first != last){
const node_ptr n = this->priv_get_from_pool();
BOOST_ASSERT(!!n);
//Put it in the index so rollback can return it in pool if construct_in_place throws
*it_past_newly_constructed = n;
//Constructs and fixes up pointers This can throw
this->priv_build_node_from_it(n, it_past_newly_constructed, first);
++first;
++it_past_newly_constructed;
}
//rollback.~insert_rollback() called in case of exception
}
//Fix up pointers for past-new nodes (new nodes were fixed during construction) and
//nodes before insertion p in priv_insert_forward_non_templated(...)
index_traits_type::fix_up_pointers_from(this->index, it_past_newly_constructed);
}
return this->begin() + idx;
}
#endif
//! <b>Effects</b>: Removes the last element from the stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant time.
void pop_back() BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(!this->empty());
this->erase(--this->cend());
}
//! <b>Effects</b>: Erases the element at p.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the elements between p and the
//! last element. Constant if p is the last element.
iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->priv_in_range(p));
STABLE_VECTOR_CHECK_INVARIANT;
const size_type d = p - this->cbegin();
index_iterator it = this->index.begin() + d;
this->priv_delete_node(p.node_pointer());
it = this->index.erase(it);
index_traits_type::fix_up_pointers_from(this->index, it);
return iterator(node_ptr_traits::static_cast_from(*it));
}
//! <b>Effects</b>: Erases the elements pointed by [first, last).
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the distance between first and last
//! plus linear to the elements between p and the last element.
iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(first == last ||
(first < last && this->priv_in_range(first) && this->priv_in_range_or_end(last)));
STABLE_VECTOR_CHECK_INVARIANT;
const const_iterator cbeg(this->cbegin());
const size_type d1 = static_cast<size_type>(first - cbeg),
d2 = static_cast<size_type>(last - cbeg);
size_type d_dif = d2 - d1;
if(d_dif){
multiallocation_chain holder;
const index_iterator it1(this->index.begin() + d1);
const index_iterator it2(it1 + d_dif);
index_iterator it(it1);
while(d_dif--){
node_base_ptr &nb = *it;
++it;
node_type &n = *node_ptr_traits::static_cast_from(nb);
this->priv_destroy_node(n);
holder.push_back(node_ptr_traits::pointer_to(n));
}
this->priv_put_in_pool(holder);
const index_iterator e = this->index.erase(it1, it2);
index_traits_type::fix_up_pointers_from(this->index, e);
}
return iterator(last.node_pointer());
}
//! <b>Effects</b>: Swaps the contents of *this and x.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
void swap(stable_vector & x)
BOOST_NOEXCEPT_IF( allocator_traits_type::propagate_on_container_swap::value
|| allocator_traits_type::is_always_equal::value)
{
BOOST_ASSERT(allocator_traits_type::propagate_on_container_swap::value ||
allocator_traits_type::is_always_equal::value ||
this->get_stored_allocator() == x.get_stored_allocator());
STABLE_VECTOR_CHECK_INVARIANT;
dtl::bool_<allocator_traits_type::propagate_on_container_swap::value> flag;
dtl::swap_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag);
//vector's allocator is swapped here
this->index.swap(x.index);
this->priv_swap_members(x);
}
//! <b>Effects</b>: Erases all the elements of the stable_vector.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the number of elements in the stable_vector.
void clear() BOOST_NOEXCEPT_OR_NOTHROW
{ this->erase(this->cbegin(),this->cend()); }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const stable_vector& x, const stable_vector& y)
{ return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); }
//! <b>Effects</b>: Returns true if x and y are unequal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator!=(const stable_vector& x, const stable_vector& y)
{ return !(x == y); }
//! <b>Effects</b>: Returns true if x is less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const stable_vector& x, const stable_vector& y)
{ return ::boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
//! <b>Effects</b>: Returns true if x is greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>(const stable_vector& x, const stable_vector& y)
{ return y < x; }
//! <b>Effects</b>: Returns true if x is equal or less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<=(const stable_vector& x, const stable_vector& y)
{ return !(y < x); }
//! <b>Effects</b>: Returns true if x is equal or greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>=(const stable_vector& x, const stable_vector& y)
{ return !(x < y); }
//! <b>Effects</b>: x.swap(y)
//!
//! <b>Complexity</b>: Constant.
friend void swap(stable_vector& x, stable_vector& y)
{ x.swap(y); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private:
bool priv_in_range(const_iterator pos) const
{
return (this->begin() <= pos) && (pos < this->end());
}
bool priv_in_range_or_end(const_iterator pos) const
{
return (this->begin() <= pos) && (pos <= this->end());
}
size_type priv_index_of(node_ptr p) const
{
//Check range
BOOST_ASSERT(this->index.empty() || (this->index.data() <= p->up));
BOOST_ASSERT(this->index.empty() || p->up <= (this->index.data() + this->index.size()));
return this->index.empty() ? 0 : p->up - this->index.data();
}
class insert_rollback
{
public:
insert_rollback(stable_vector &sv, index_iterator &it_past_constructed, const index_iterator &it_past_new)
: m_sv(sv), m_it_past_constructed(it_past_constructed), m_it_past_new(it_past_new)
{}
~insert_rollback()
{
if(m_it_past_constructed != m_it_past_new){
m_sv.priv_put_in_pool(node_ptr_traits::static_cast_from(*m_it_past_constructed));
index_iterator e = m_sv.index.erase(m_it_past_constructed, m_it_past_new);
index_traits_type::fix_up_pointers_from(m_sv.index, e);
}
}
private:
stable_vector &m_sv;
index_iterator &m_it_past_constructed;
const index_iterator &m_it_past_new;
};
class push_back_rollback
{
public:
push_back_rollback(stable_vector &sv, const node_ptr &p)
: m_sv(sv), m_p(p)
{}
~push_back_rollback()
{
if(m_p){
m_sv.priv_put_in_pool(m_p);
}
}
void release()
{ m_p = node_ptr(); }
private:
stable_vector &m_sv;
node_ptr m_p;
};
index_iterator priv_insert_forward_non_templated(size_type idx, size_type num_new)
{
index_traits_type::initialize_end_node(this->index, this->internal_data.end_node, num_new);
//Now try to fill the pool with new data
if(this->internal_data.pool_size < num_new){
this->priv_increase_pool(num_new - this->internal_data.pool_size);
}
//Now try to make room in the vector
const node_base_ptr_ptr old_buffer = this->index.data();
this->index.insert(this->index.begin() + idx, num_new, node_ptr());
bool new_buffer = this->index.data() != old_buffer;
//Fix the pointers for the newly allocated buffer
const index_iterator index_beg = this->index.begin();
if(new_buffer){
index_traits_type::fix_up_pointers(index_beg, index_beg + idx);
}
return index_beg + idx;
}
bool priv_capacity_bigger_than_size() const
{
return this->index.capacity() > this->index.size() &&
this->internal_data.pool_size > 0;
}
template <class U>
void priv_push_back(BOOST_MOVE_CATCH_FWD(U) x)
{
if(BOOST_LIKELY(this->priv_capacity_bigger_than_size())){
//Enough memory in the pool and in the index
const node_ptr p = this->priv_get_from_pool();
BOOST_ASSERT(!!p);
{
push_back_rollback rollback(*this, p);
//This might throw
this->priv_build_node_from_convertible(p, ::boost::forward<U>(x));
rollback.release();
}
//This can't throw as there is room for a new elements in the index
index_iterator new_index = this->index.insert(this->index.end() - ExtraPointers, p);
index_traits_type::fix_up_pointers_from(this->index, new_index);
}
else{
this->insert(this->cend(), ::boost::forward<U>(x));
}
}
iterator priv_insert(const_iterator p, const value_type &t)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
typedef constant_iterator<value_type, difference_type> cvalue_iterator;
return this->insert(p, cvalue_iterator(t, 1), cvalue_iterator());
}
iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
typedef repeat_iterator<T, difference_type> repeat_it;
typedef boost::move_iterator<repeat_it> repeat_move_it;
//Just call more general insert(p, size, value) and return iterator
return this->insert(p, repeat_move_it(repeat_it(x, 1)), repeat_move_it(repeat_it()));
}
void priv_clear_pool()
{
if(!this->index.empty() && this->index.back()){
node_base_ptr &pool_first_ref = *(this->index.end() - 2);
node_base_ptr &pool_last_ref = this->index.back();
multiallocation_chain holder;
holder.incorporate_after( holder.before_begin()
, node_ptr_traits::static_cast_from(pool_first_ref)
, node_ptr_traits::static_cast_from(pool_last_ref)
, internal_data.pool_size);
this->deallocate_individual(holder);
pool_first_ref = pool_last_ref = 0;
this->internal_data.pool_size = 0;
}
}
void priv_increase_pool(size_type n)
{
node_base_ptr &pool_first_ref = *(this->index.end() - 2);
node_base_ptr &pool_last_ref = this->index.back();
multiallocation_chain holder;
holder.incorporate_after( holder.before_begin()
, node_ptr_traits::static_cast_from(pool_first_ref)
, node_ptr_traits::static_cast_from(pool_last_ref)
, internal_data.pool_size);
multiallocation_chain m;
this->allocate_individual(n, m);
holder.splice_after(holder.before_begin(), m, m.before_begin(), m.last(), n);
this->internal_data.pool_size += n;
std::pair<node_ptr, node_ptr> data(holder.extract_data());
pool_first_ref = data.first;
pool_last_ref = data.second;
}
void priv_put_in_pool(const node_ptr &p)
{
node_base_ptr &pool_first_ref = *(this->index.end()-2);
node_base_ptr &pool_last_ref = this->index.back();
multiallocation_chain holder;
holder.incorporate_after( holder.before_begin()
, node_ptr_traits::static_cast_from(pool_first_ref)
, node_ptr_traits::static_cast_from(pool_last_ref)
, internal_data.pool_size);
holder.push_front(p);
++this->internal_data.pool_size;
std::pair<node_ptr, node_ptr> ret(holder.extract_data());
pool_first_ref = ret.first;
pool_last_ref = ret.second;
}
void priv_put_in_pool(multiallocation_chain &ch)
{
node_base_ptr &pool_first_ref = *(this->index.end()-(ExtraPointers-1));
node_base_ptr &pool_last_ref = this->index.back();
ch.incorporate_after( ch.before_begin()
, node_ptr_traits::static_cast_from(pool_first_ref)
, node_ptr_traits::static_cast_from(pool_last_ref)
, internal_data.pool_size);
this->internal_data.pool_size = ch.size();
const std::pair<node_ptr, node_ptr> ret(ch.extract_data());
pool_first_ref = ret.first;
pool_last_ref = ret.second;
}
node_ptr priv_get_from_pool()
{
//Precondition: index is not empty
BOOST_ASSERT(!this->index.empty());
node_base_ptr &pool_first_ref = *(this->index.end() - (ExtraPointers-1));
node_base_ptr &pool_last_ref = this->index.back();
multiallocation_chain holder;
holder.incorporate_after( holder.before_begin()
, node_ptr_traits::static_cast_from(pool_first_ref)
, node_ptr_traits::static_cast_from(pool_last_ref)
, internal_data.pool_size);
node_ptr ret = holder.pop_front();
--this->internal_data.pool_size;
if(!internal_data.pool_size){
pool_first_ref = pool_last_ref = node_ptr();
}
else{
const std::pair<node_ptr, node_ptr> data(holder.extract_data());
pool_first_ref = data.first;
pool_last_ref = data.second;
}
return ret;
}
node_base_ptr priv_get_end_node() const
{ return node_base_ptr_traits::pointer_to(const_cast<node_base_type&>(this->internal_data.end_node)); }
void priv_destroy_node(const node_type &n)
{
allocator_traits<node_allocator_type>::
destroy(this->priv_node_alloc(), dtl::addressof(n.value));
static_cast<const node_base_type*>(&n)->~node_base_type();
}
void priv_delete_node(const node_ptr &n)
{
this->priv_destroy_node(*n);
this->priv_put_in_pool(n);
}
template<class Iterator>
void priv_build_node_from_it(const node_ptr &p, const index_iterator &up_index, const Iterator &it)
{
//This can throw
boost::container::construct_in_place
( this->priv_node_alloc()
, dtl::addressof(p->value)
, it);
//This does not throw
::new(static_cast<node_base_type*>(boost::movelib::to_raw_pointer(p)), boost_container_new_t())
node_base_type(index_traits_type::ptr_to_node_base_ptr(*up_index));
}
template<class ValueConvertible>
void priv_build_node_from_convertible(const node_ptr &p, BOOST_FWD_REF(ValueConvertible) value_convertible)
{
//This can throw
boost::container::allocator_traits<node_allocator_type>::construct
( this->priv_node_alloc()
, dtl::addressof(p->value)
, ::boost::forward<ValueConvertible>(value_convertible));
//This does not throw
::new(static_cast<node_base_type*>(boost::movelib::to_raw_pointer(p)), boost_container_new_t()) node_base_type;
}
void priv_swap_members(stable_vector &x)
{
boost::adl_move_swap(this->internal_data.pool_size, x.internal_data.pool_size);
index_traits_type::readjust_end_node(this->index, this->internal_data.end_node);
index_traits_type::readjust_end_node(x.index, x.internal_data.end_node);
}
#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
bool priv_invariant()const
{
index_type & index_ref = const_cast<index_type&>(this->index);
const size_type index_size = this->index.size();
if(!index_size)
return !this->capacity() && !this->size();
if(index_size < ExtraPointers)
return false;
const size_type bucket_extra_capacity = this->index.capacity()- index_size;
const size_type node_extra_capacity = this->internal_data.pool_size;
if(bucket_extra_capacity < node_extra_capacity){
return false;
}
if(this->priv_get_end_node() != *(index.end() - ExtraPointers)){
return false;
}
if(!index_traits_type::invariants(index_ref)){
return false;
}
size_type n = this->capacity() - this->size();
node_base_ptr &pool_first_ref = *(index_ref.end() - (ExtraPointers-1));
node_base_ptr &pool_last_ref = index_ref.back();
multiallocation_chain holder;
holder.incorporate_after( holder.before_begin()
, node_ptr_traits::static_cast_from(pool_first_ref)
, node_ptr_traits::static_cast_from(pool_last_ref)
, internal_data.pool_size);
typename multiallocation_chain::iterator beg(holder.begin()), end(holder.end());
size_type num_pool = 0;
while(beg != end){
++num_pool;
++beg;
}
return n >= num_pool && num_pool == internal_data.pool_size;
}
class invariant_checker
{
invariant_checker(const invariant_checker &);
invariant_checker & operator=(const invariant_checker &);
const stable_vector* p;
public:
invariant_checker(const stable_vector& v):p(&v){}
~invariant_checker(){BOOST_ASSERT(p->priv_invariant());}
void touch(){}
};
#endif
class ebo_holder
: public node_allocator_type
{
private:
BOOST_MOVABLE_BUT_NOT_COPYABLE(ebo_holder)
public:
template<class AllocatorRLValue>
explicit ebo_holder(BOOST_FWD_REF(AllocatorRLValue) a)
: node_allocator_type(boost::forward<AllocatorRLValue>(a))
, pool_size(0)
, end_node()
{}
ebo_holder()
: node_allocator_type()
, pool_size(0)
, end_node()
{}
size_type pool_size;
node_base_type end_node;
} internal_data;
node_allocator_type &priv_node_alloc() { return internal_data; }
const node_allocator_type &priv_node_alloc() const { return internal_data; }
index_type index;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
};
#if __cplusplus >= 201703L
template <typename InputIterator>
stable_vector(InputIterator, InputIterator) ->
stable_vector<typename iterator_traits<InputIterator>::value_type>;
template <typename InputIterator, typename Allocator>
stable_vector(InputIterator, InputIterator, Allocator const&) ->
stable_vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
#endif
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
#undef STABLE_VECTOR_CHECK_INVARIANT
} //namespace container {
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
template <class T, class Allocator>
struct has_trivial_destructor_after_move<boost::container::stable_vector<T, Allocator> >
{
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
::boost::has_trivial_destructor_after_move<pointer>::value;
};
namespace container {
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
}} //namespace boost{ namespace container {
#include <boost/container/detail/config_end.hpp>
#endif //BOOST_CONTAINER_STABLE_VECTOR_HPP
|
;-----------------------------------------------------------------------------;
; Author: Stephen Fewer (stephen_fewer@harmonysecurity.com)
; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT4
; Version: 1.0 (24 July 2009)
;-----------------------------------------------------------------------------;
[BITS 32]
; Input: EBP must be the address of 'api_call'.
; Output: EDI will be the newly connected clients socket
; Clobbers: EAX, ESI, EDI, ESP will also be modified (-0x1A0)
bind_tcp:
push 0x00003233 ; Push the bytes 'ws2_32',0,0 onto the stack.
push 0x5F327377 ; ...
push esp ; Push a pointer to the "ws2_32" string on the stack.
push 0x0726774C ; hash( "kernel32.dll", "LoadLibraryA" )
call ebp ; LoadLibraryA( "ws2_32" )
mov eax, 0x0190 ; EAX = sizeof( struct WSAData )
sub esp, eax ; alloc some space for the WSAData structure
push esp ; push a pointer to this stuct
push eax ; push the wVersionRequested parameter
push 0x006B8029 ; hash( "ws2_32.dll", "WSAStartup" )
call ebp ; WSAStartup( 0x0190, &WSAData );
push byte 8
pop ecx
push_8_loop:
push eax ; if we succeed, eax will be zero, push it 8 times for later ([1]-[8])
loop push_8_loop
; push zero for the flags param [8]
; push null for reserved parameter [7]
; we do not specify a WSAPROTOCOL_INFO structure [6]
; we do not specify a protocol [5]
inc eax ;
push eax ; push SOCK_STREAM
inc eax ;
push eax ; push AF_INET
push 0xE0DF0FEA ; hash( "ws2_32.dll", "WSASocketA" )
call ebp ; WSASocketA( AF_INET, SOCK_STREAM, 0, 0, 0, 0 );
xchg edi, eax ; save the socket for later, don't care about the value of eax after this
; bind to 0.0.0.0, pushed earlier [4]
push 0x5C110002 ; family AF_INET and port 4444
mov esi, esp ; save a pointer to sockaddr_in struct
push byte 16 ; length of the sockaddr_in struct (we only set the first 8 bytes as the last 8 are unused)
push esi ; pointer to the sockaddr_in struct
push edi ; socket
push 0x6737DBC2 ; hash( "ws2_32.dll", "bind" )
call ebp ; bind( s, &sockaddr_in, 16 );
; backlog, pushed earlier [3]
push edi ; socket
push 0xFF38E9B7 ; hash( "ws2_32.dll", "listen" )
call ebp ; listen( s, 0 );
; we set length for the sockaddr struct to zero, pushed earlier [2]
; we dont set the optional sockaddr param, pushed earlier [1]
push edi ; listening socket
push 0xE13BEC74 ; hash( "ws2_32.dll", "accept" )
call ebp ; accept( s, 0, 0 );
push edi ; push the listening socket to close
xchg edi, eax ; replace the listening socket with the new connected socket for further comms
push 0x614D6E75 ; hash( "ws2_32.dll", "closesocket" )
call ebp ; closesocket( s );
|
; Z80 Mandelbrot with output to TMS9918 video chip
;
; Fixed point Mandelbrot routine from https://rosettacode.org/wiki/Mandelbrot_set#Z80_Assembly
;
; Adapted to TMS9918 by J.B. Langston
ramtop: equ $ffff
bdos: equ $0005
org 100h
ld (oldstack),sp ; save old stack pointer
ld sp, ramtop ; initailize stack
jp mandelbrot
include "tms.asm" ; TMS subroutines
; mandelbrot constants
scale: equ 256 ; Do NOT change this - the
; arithmetic routines rely on
; this scaling factor! :-)
divergent: equ scale * 4
iteration_max: equ 14 ; How many iterations
x_start: equ -2 * scale ; Minimum x-coordinate
x_end: equ scale - 1 ; Maximum x-coordinate
x_step: equ 3 ; x-coordinate step-width
y_start: equ -9 * (scale / 8) ; Minimum y-coordinate
y_end: equ 9 * (scale / 8) - 1 ; Maximum y-coordinate
y_step: equ 3 ; y-coordinate step-width
; mandelbrot variables
oldstack: defw 0
x: defw 0 ; x-coordinate
y: defw 0 ; y-coordinate
z_0: defw 0
z_1: defw 0
scratch_0: defw 0
z_0_square_high: defw 0
z_0_square_low: defw 0
z_1_square_high: defw 0
z_1_square_low: defw 0
; mandelbrot entry point
mandelbrot:
call tmsbitmap
xor a ; clear pixel counters
ld (xypos), a
ld (xypos+1), a
ld (bitindex), a
ld hl, y_start ; y = y_start
ld (y), hl
; for (y = <initial_value> ; y <= y_end; y += y_step)
; {
outer_loop: ld hl, y_end ; Is y <= y_end?
ld de, (y)
and a ; Clear carry
sbc hl, de ; Perform the comparison
jp m, mandel_end ; End of outer loop reached
; for (x = x_start; x <= x_end; x += x_step)
; {
ld hl, x_start ; x = x_start
ld (x), hl
inner_loop: ld hl, x_end ; Is x <= x_end?
ld de, (x)
and a
sbc hl, de
jp m, inner_loop_end ; End of inner loop reached
; z_0 = z_1 = 0;
ld hl, 0
ld (z_0), hl
ld (z_1), hl
; for (iteration = iteration_max; iteration; iteration--)
; {
ld a, iteration_max
ld b, a
iteration_loop: push bc ; iteration -> stack
; z2 = (z_0 * z_0 - z_1 * z_1) / SCALE;
ld de, (z_1) ; Compute DE HL = z_1 * z_1
ld b, d
ld c, e
call mul_16
ld (z_0_square_low), hl ; z_0 ** 2 is needed later again
ld (z_0_square_high), de
ld de, (z_0) ; Compute DE HL = z_0 * z_0
ld b, d
ld c, e
call mul_16
ld (z_1_square_low), hl ; z_1 ** 2 will be also needed
ld (z_1_square_high), de
and a ; Compute subtraction
ld bc, (z_0_square_low)
sbc hl, bc
ld (scratch_0), hl ; Save lower 16 bit of result
ld h, d
ld l, e
ld bc, (z_0_square_high)
sbc hl, bc
ld bc, (scratch_0) ; HL BC = z_0 ** 2 - z_1 ** 2
ld c, b ; Divide by scale = 256
ld b, l ; Discard the rest
push bc ; We need BC later
; z3 = 2 * z0 * z1 / SCALE;
ld hl, (z_0) ; Compute DE HL = 2 * z_0 * z_1
add hl, hl
ld d, h
ld e, l
ld bc, (z_1)
call mul_16
ld b, e ; Divide by scale (= 256)
ld c, h ; BC contains now z_3
; z1 = z3 + y;
ld hl, (y)
add hl, bc
ld (z_1), hl
; z_0 = z_2 + x;
pop bc ; Here BC is needed again :-)
ld hl, (x)
add hl, bc
ld (z_0), hl
; if (z0 * z0 / SCALE + z1 * z1 / SCALE > 4 * SCALE)
ld hl, (z_0_square_low) ; Use the squares computed
ld de, (z_1_square_low) ; above
add hl, de
ld b, h ; BC contains lower word of sum
ld c, l
ld hl, (z_0_square_high)
ld de, (z_1_square_high)
adc hl, de
ld h, l ; HL now contains (z_0 ** 2 +
ld l, b ; z_1 ** 2) / scale
ld bc, divergent
and a
sbc hl, bc
; break;
jp c, iteration_dec ; No break
pop bc ; Get latest iteration counter
jr iteration_end ; Exit loop
; iteration++;
iteration_dec: pop bc ; Get iteration counter
djnz iteration_loop ; We might fall through!
; }
iteration_end:
; printf("%c", display[iteration % 7]);
inc b ; increment iteration count to get color
call drawpixel ; plot it
ld de, x_step ; x += x_step
ld hl, (x)
add hl, de
ld (x), hl
jp inner_loop
; }
; printf("\n");
inner_loop_end:
ld de, y_step ; y += y_step
ld hl, (y)
add hl, de
ld (y), hl ; Store new y-value
jp outer_loop
; }
mandel_end:
ld sp,(oldstack) ; put stack back to how we found it
;ld c,$0 ; this is the CP/M proper exit call
;jp bdos
halt
;
; Compute DEHL = BC * DE (signed): This routine is not too clever but it
; works. It is based on a standard 16-by-16 multiplication routine for unsigned
; integers. At the beginning the sign of the result is determined based on the
; signs of the operands which are negated if necessary. Then the unsigned
; multiplication takes place, followed by negating the result if necessary.
;
mul_16: xor a ; Clear carry and A (-> +)
bit 7, b ; Is BC negative?
jr z, bc_positive ; No
sub c ; A is still zero, complement
ld c, a
ld a, 0
sbc a, b
ld b, a
scf ; Set carry (-> -)
bc_positive: bit 7, D ; Is DE negative?
jr z, de_positive ; No
push af ; Remember carry for later!
xor a
sub e
ld e, a
ld a, 0
sbc a, d
ld d, a
pop af ; Restore carry for complement
ccf ; Complement Carry (-> +/-?)
de_positive: push af ; Remember state of carry
and a ; Start multiplication
sbc hl, hl
ld a, 16 ; 16 rounds
mul_16_loop: add hl, hl
rl e
rl d
jr nc, mul_16_exit
add hl, bc
jr nc, mul_16_exit
inc de
mul_16_exit: dec a
jr nz, mul_16_loop
pop af ; Restore carry from beginning
ret nc ; No sign inversion necessary
xor a ; Complement DE HL
sub l
ld l, a
ld a, 0
sbc a, h
ld h, a
ld a, 0
sbc a, e
ld e, a
ld a, 0
sbc a, d
ld d, a
ret
; working area for 8 pixels at a time
primary: defb 0 ; primary color
secondary: defb 0 ; secondary color
pattern: defb 0 ; color bit pattern
bitindex: defb 0 ; current bit within byte
xypos: defw 0 ; current x, y position on the screen
; plot a pixel to TMS9918 screen
; B = color of pixel
drawpixel:
ld a, (bitindex) ; check whether this is the first bit of a byte
or a
ld a, b ; load the current color in a
jr nz, comparecolor ; for subsequent bits, proceed to comparison
ld (primary), a ; for first bit, set both colors to current color
ld (secondary), a
comparecolor:
ld hl, primary ; compare the current color to primary color
cp (hl)
scf
jr z, setbit ; if it's the same, set the pattern bit
cp 1 ; if it's different, is the current color black?
jr z, swapblack ; if so, make it the primary color
ld (secondary), a ; otherwise, set secondary color to current color
or a ; and clear the pattern bit
jr setbit
swapblack:
ld (primary), a ; set the primary color to black
xor a ; clear all previous pattern bits
ld (pattern), a
scf ; and set the current pattern bit
setbit:
ld hl, pattern ; pull the current pattern bit into the byte
rl (hl)
ld a, (bitindex)
inc a ; increment the bit index
and 7 ; mask it to a maximum of 7
ld (bitindex), a ; save it back in memory
ret nz ; if this wasn't the last bit, we're done
ld bc, (xypos) ; calculate address for current x, y position
ld a, b ; d = (y / 8)
rrca
rrca
rrca
and 1fh
ld d, a
ld a, c ; e = (x & f8) + (y & 7)
and 0f8h
ld e, a
ld a, b
and 7
or e
ld e, a
call tmswriteaddr ; set write address within pattern table
ld a, (pattern) ; send the pattern to the TMS
out (tmsram), a
ld bc, 2000h ; add the color table base address
ex de, hl
add hl, bc
ex de, hl
call tmswriteaddr ; set write address within color table
ld a, (primary) ; load primary color into upper 4 bits
add a, a
add a, a
add a, a
add a, a
ld hl, secondary ; load secondary color into lower 4 bits
or (hl)
out (tmsram), a ; send to TMS
ld hl, (xypos) ; increase next x/y position by 8 pixels
ld de, 8
add hl, de
ld (xypos), hl
ret |
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r9
push %rax
push %rbp
lea addresses_normal_ht+0x5fd4, %rbp
dec %r9
movw $0x6162, (%rbp)
nop
nop
nop
nop
xor %r14, %r14
pop %rbp
pop %rax
pop %r9
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r8
push %r9
push %rbp
push %rbx
push %rdx
// Store
lea addresses_WT+0x70b4, %rdx
sub %rbx, %rbx
movb $0x51, (%rdx)
nop
nop
nop
nop
cmp %rbp, %rbp
// Store
lea addresses_RW+0xe1b4, %r12
nop
nop
nop
nop
sub %rdx, %rdx
mov $0x5152535455565758, %rbx
movq %rbx, (%r12)
nop
nop
nop
nop
nop
and %r8, %r8
// Store
lea addresses_UC+0x1c6f4, %rbp
nop
nop
nop
sub $41598, %r9
movl $0x51525354, (%rbp)
nop
nop
xor $51744, %r9
// Load
lea addresses_WC+0x69c, %rbp
nop
nop
nop
inc %rbx
movb (%rbp), %dl
and %rbx, %rbx
// Store
lea addresses_WC+0xaa06, %rdx
nop
nop
add %r8, %r8
mov $0x5152535455565758, %r9
movq %r9, %xmm7
movups %xmm7, (%rdx)
nop
xor $21433, %r12
// Load
lea addresses_WC+0x130b4, %rbx
nop
nop
nop
nop
inc %rdx
mov (%rbx), %r12w
nop
sub $33986, %r12
// Load
lea addresses_WT+0x1dc34, %rbp
nop
nop
xor %r12, %r12
vmovups (%rbp), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $1, %xmm6, %r8
nop
nop
nop
nop
nop
xor %rdx, %rdx
// Load
lea addresses_A+0x19b48, %rdx
nop
nop
nop
nop
xor $39726, %rbx
mov (%rdx), %bp
// Exception!!!
mov (0), %r8
nop
nop
nop
xor $28385, %r9
// Faulty Load
lea addresses_WT+0x70b4, %rdx
clflush (%rdx)
nop
nop
nop
nop
nop
sub %rbp, %rbp
mov (%rdx), %rbx
lea oracles, %r12
and $0xff, %rbx
shlq $12, %rbx
mov (%r12,%rbx,1), %rbx
pop %rdx
pop %rbx
pop %rbp
pop %r9
pop %r8
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': True, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 11}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': True, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 2}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'51': 1}
51
*/
|
; The MIT License (MIT)
;
; Copyright (c) 2014 Microsoft
;
; 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.
;
; Author: Mark Gottscho <mgottscho@ucla.edu>
.code
win_x86_64_asm_dummy_revStride2Loop_Word256 proc
; Arguments:
; rcx is address of the last 256-bit word in the array
; rdx is address of the first 256-bit word in the array
; rax holds number of words accessed
; rcx holds the last 256-bit word address
; rdx holds the target total number of words to access
; xmm0 holds result from reading the memory 256-bit wide
mov rax,rcx ; Temporarily save last word address
sub rcx,rdx ; Get total number of 256-bit words between starting and ending addresses
shr rcx,5
mov rdx,rcx ; Set target number of words
mov rcx,rax ; Restore last word address
xor rax,rax ; initialize number of words accessed to 0
cmp rax,rdx ; have we completed the target total number of words to access?
jae done ; if the number of words accessed >= the target number, then we are done
myloop:
add rax,64 ; Just did 64 accesses
cmp rax,rdx ; have we completed the target number of accesses in total yet?
jb myloop ; make another unrolled pass on the memory
done:
xor eax,eax ; return 0
ret
win_x86_64_asm_dummy_revStride2Loop_Word256 endp
end
|
;********************************************************************************************************
; uC/OS-II
; The Real-Time Kernel
;
; Copyright 1992-2020 Silicon Laboratories Inc. www.silabs.com
;
; SPDX-License-Identifier: APACHE-2.0
;
; This software is subject to an open source license and is distributed by
; Silicon Laboratories Inc. pursuant to the terms of the Apache License,
; Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
;
;********************************************************************************************************
;********************************************************************************************************
;
; H8S
; (Advanced Mode)
;
; Filename : os_cpu_a.asm
; Version : V2.93.00
;********************************************************************************************************
; Compiler : IAR H8 Compiler
;********************************************************************************************************
;********************************************************************************************************
; Cross references
;********************************************************************************************************
;
PUBLIC OSStartHighRdy ; Public functions
PUBLIC OSCtxSw
PUBLIC OSIntCtxSw
PUBLIC OSTickISR
EXTERN OSIntEnter ; External functions
EXTERN OSIntExit
EXTERN OSTimeTick
EXTERN OSTaskSwHook
EXTERN OSTCBCur ; External variables (uC/OS-II)
EXTERN OSTCBHighRdy
EXTERN OSPrioCur
EXTERN OSPrioHighRdy
EXTERN OSIntNesting
EXTERN OSRunning
;********************************************************************************************************
; Define vector table
;********************************************************************************************************
COMMON INTVEC(2)
ORG 0020H ; Task switching TRAPA0 vector
DC.L OSCtxSw ; (32-bit pointer in ADVANCED mode)
ORG 0080H ; Timer 0 GRA (Vector 0x0080 on H8S/2623)
DC.L OSTickISR ; (32-bit pointer in ADVANCED mode)
;*********************************************************************************************************
; START MULTITASKING
;
; Description : This function is called by OSStart() to start the highest priority task that was created
; by your application before calling OSStart().
;
; Arguments : none
;
; Note(s) : 1) The stack frame is assumed to look as follows:
;
; LOW MEMORY
; OSTCBHighRdy->OSTCBStkPtr + 0 ----> ER6 (H)
; + 2 ER6 (L) (Contains 'p_arg')
; + 4 ER5 (H)
; + 6 ER5 (L)
; + 8 ER4 (H)
; + 10 ER4 (L)
; + 12 ER3 (H)
; + 14 ER3 (L)
; + 16 ER2 (H)
; + 18 ER2 (L)
; + 20 ER1 (H)
; + 22 ER1 (L)
; + 24 ER0 (H)
; + 26 ER0 (L)
; + 28 CCR (Initial value of 0x0000)
; + 30 task (16-bit address of 'task')
; + 32 task (16-bit address of 'task')
; + 34 p_arg (16-bit contents of 'p_arg')
; HIGH MEMORY
;
; 2) OSStartHighRdy() MUST:
; a) Call OSTaskSwHook() then,
; b) Set OSRunning to TRUE,
; c) Switch to the highest priority task.
;*********************************************************************************************************
RSEG CODE(1)
OSStartHighRdy:
JSR @OSTaskSwHook ; Execute task switch hook
;
MOV.B #1, R6L ; Set OSRunning to TRUE
MOV.B R6L, @OSRunning
;
MOV.L @OSTCBHighRdy, ER0 ; SP = OSTCBHighRdy->OSTCBStkPtr
MOV.L ER0, @OSTCBCur
MOV.L @ER0, ER7
;
POP.L ER6
POP.L ER5
POP.L ER4
POP.L ER3
POP.L ER2
POP.L ER1
POP.L ER0
;
RTE
;*********************************************************************************************************
; TASK LEVEL CONTEXT SWITCH
;
; Description : This function is called when a task makes a higher priority task ready-to-run.
;
; Arguments : none
;
; Note(s) : 1) Upon entry,
; OSTCBCur points to the OS_TCB of the task to suspend
; OSTCBHighRdy points to the OS_TCB of the task to resume
;
; 2) The stack frame of the task to suspend looks as follows. This was caused by the
; execution of a TRAPA #0 instruction (the registers for the task to suspend need to be
; saved):
;
; LOW MEMORY
; SP + 0 ----> 8-bit CCR
; + 1 24-bit PC of task
; + 4
; HIGH MEMORY
;
; 3) The stack frame of the task to resume looks as follows:
;
; LOW MEMORY
; OSTCBHighRdy->OSTCBStkPtr + 0 ----> ER6
; + 4 ER5
; + 8 ER4
; + 12 ER3
; + 16 ER2
; + 20 ER1
; + 24 ER0
; + 28 8-bit CCR & 24-bit PC of task
; + 32 HIGH MEMORY
;*********************************************************************************************************
OSCtxSw:
PUSH.L ER0
PUSH.L ER1
PUSH.L ER2
PUSH.L ER3
PUSH.L ER4
PUSH.L ER5
PUSH.L ER6
;
MOV.L @OSTCBCur, ER6 ; Save current task's SP into its TCB
MOV.L ER7, @ER6
;
JSR @OSTaskSwHook ; Execute task switch hook
;
MOV.B @OSPrioHighRdy, R1L ; OSPrioCur = OSPrioHighRdy
MOV.B R1L, @OSPrioCur
;
MOV.L @OSTCBHighRdy, ER6 ; Get new task's SP from its TCB
MOV.L ER6, @OSTCBCur ; OSTCBCur = OSTCBHighRdy
MOV.L @ER6, ER7
;
POP.L ER6
POP.L ER5
POP.L ER4
POP.L ER3
POP.L ER2
POP.L ER1
POP.L ER0
;
RTE ; Return to task
;*********************************************************************************************************
; PERFORM A CONTEXT SWITCH (From an ISR)
;
; Description : This function is called when an ISR makes a higher priority task ready-to-run.
;
; Arguments : none
;
; Note(s) : 1) Upon entry,
; OSTCBCur points to the OS_TCB of the task to suspend
; OSTCBHighRdy points to the OS_TCB of the task to resume
;
; 2) The stack frame of the task to suspend looks as follows.
;
; LOW MEMORY
; + 0 Return address of OSIntCtxSw()
; + 4 ER3 saved upon entry by OSIntExit
; + 8 ER2 saved upon entry by OSIntExit
; + 12 Return address of OSIntExit()
; OSTCBCur->OSTCBStkPtr -----> + 16 ER6
; + 20 ER5
; + 24 ER4
; + 28 ER3
; + 32 ER2
; + 36 ER1
; + 40 ER0
; + 44 8-bit CCR & 24-bit PC of task
; + 48 HIGH MEMORY
;
; 3) The stack frame of the task to resume looks as follows:
;
; LOW MEMORY
; OSTCBHighRdy->OSTCBStkPtr -> + 0 ----> ER6
; + 4 ER5
; + 8 ER4
; + 12 ER3
; + 16 ER2
; + 20 ER1
; + 24 ER0
; + 28 8-bit CCR & 24-bit PC of task
; + 32 HIGH MEMORY
;*********************************************************************************************************
OSIntCtxSw:
JSR @OSTaskSwHook ; Execute task switch hook
;
MOV.B @OSPrioHighRdy, R1L ; OSPrioCur = OSPrioHighRdy
MOV.B R1L, @OSPrioCur
;
MOV.L @OSTCBHighRdy, ER6 ; Get new task's SP from its TCB
MOV.L ER6, @OSTCBCur ; OSTCBCur = OSTCBHighRdy
MOV.L @ER6, ER7
;
POP.L ER6
POP.L ER5
POP.L ER4
POP.L ER3
POP.L ER2
POP.L ER1
POP.L ER0
;
RTE
;*********************************************************************************************************
;* TICK ISR
;*
;* OSTickISR:
;* Push ALL registers onto current task's stack
;* OSIntNesting++;
;* if (OSIntNesting == 1) {
;* OSTCBCur->OSTCBStkPtr = SP;
;* }
;* /* Code to clear interrupt source */
;* OSTimeTick();
;* OSIntExit();
;* Pop ALL registers from current stack;
;* Return from interrupt;
;*********************************************************************************************************
OSTickISR:
PUSH.L ER0
PUSH.L ER1
PUSH.L ER2
PUSH.L ER3
PUSH.L ER4
PUSH.L ER5
PUSH.L ER6
MOV.B @OSIntNesting, R6L ; tell uC/OS-II we're in an ISR
INC.B R6L
MOV.B R6L, @OSIntNesting
CMP.B #1,R6L ; if (OSNesting == 1)
BNE OSTickISR1
MOV.L @OSTCBCur, ER6 ; Save current task's SP into its TCB
MOV.L ER7, @ER6
OSTickISR1:
; ADD YOUR code HERE to clear the interrupt source!
JSR @OSTimeTick ; Notify uC/OS-II about Tick
JSR @OSIntExit ; Notify uC/OS-II about end of ISR
POP.L ER6
POP.L ER5
POP.L ER4
POP.L ER3
POP.L ER2
POP.L ER1
POP.L ER0
RTE
END
|
// Copyright (c) 2014-2017 The Hah Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "activemasternode.h"
#include "base58.h"
#include "init.h"
#include "netbase.h"
#include "validation.h"
#include "masternode-payments.h"
#include "masternode-sync.h"
#include "masternodeconfig.h"
#include "masternodeman.h"
#ifdef ENABLE_WALLET
#include "privatesend-client.h"
#endif // ENABLE_WALLET
#include "privatesend-server.h"
#include "rpc/server.h"
#include "util.h"
#include "utilmoneystr.h"
#include <fstream>
#include <iomanip>
#include <univalue.h>
#ifdef ENABLE_WALLET
void EnsureWalletIsUnlocked();
UniValue privatesend(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw std::runtime_error(
"privatesend \"command\"\n"
"\nArguments:\n"
"1. \"command\" (string or set of strings, required) The command to execute\n"
"\nAvailable commands:\n"
" start - Start mixing\n"
" stop - Stop mixing\n"
" reset - Reset mixing\n"
);
if(params[0].get_str() == "start") {
{
LOCK(pwalletMain->cs_wallet);
EnsureWalletIsUnlocked();
}
if(fMasterNode)
return "Mixing is not supported from masternodes";
privateSendClient.fEnablePrivateSend = true;
bool result = privateSendClient.DoAutomaticDenominating(*g_connman);
return "Mixing " + (result ? "started successfully" : ("start failed: " + privateSendClient.GetStatus() + ", will retry"));
}
if(params[0].get_str() == "stop") {
privateSendClient.fEnablePrivateSend = false;
return "Mixing was stopped";
}
if(params[0].get_str() == "reset") {
privateSendClient.ResetPool();
return "Mixing was reset";
}
return "Unknown command, please see \"help privatesend\"";
}
#endif // ENABLE_WALLET
UniValue getpoolinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw std::runtime_error(
"getpoolinfo\n"
"Returns an object containing mixing pool related information.\n");
#ifdef ENABLE_WALLET
CPrivateSendBase* pprivateSendBase = fMasterNode ? (CPrivateSendBase*)&privateSendServer : (CPrivateSendBase*)&privateSendClient;
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("state", pprivateSendBase->GetStateString()));
obj.push_back(Pair("mixing_mode", (!fMasterNode && privateSendClient.fPrivateSendMultiSession) ? "multi-session" : "normal"));
obj.push_back(Pair("queue", pprivateSendBase->GetQueueSize()));
obj.push_back(Pair("entries", pprivateSendBase->GetEntriesCount()));
obj.push_back(Pair("status", privateSendClient.GetStatus()));
masternode_info_t mnInfo;
if (privateSendClient.GetMixingMasternodeInfo(mnInfo)) {
obj.push_back(Pair("outpoint", mnInfo.vin.prevout.ToStringShort()));
obj.push_back(Pair("addr", mnInfo.addr.ToString()));
}
if (pwalletMain) {
obj.push_back(Pair("keys_left", pwalletMain->nKeysLeftSinceAutoBackup));
obj.push_back(Pair("warnings", pwalletMain->nKeysLeftSinceAutoBackup < PRIVATESEND_KEYS_THRESHOLD_WARNING
? "WARNING: keypool is almost depleted!" : ""));
}
#else // ENABLE_WALLET
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("state", privateSendServer.GetStateString()));
obj.push_back(Pair("queue", privateSendServer.GetQueueSize()));
obj.push_back(Pair("entries", privateSendServer.GetEntriesCount()));
#endif // ENABLE_WALLET
return obj;
}
UniValue masternode(const UniValue& params, bool fHelp)
{
std::string strCommand;
if (params.size() >= 1) {
strCommand = params[0].get_str();
}
#ifdef ENABLE_WALLET
if (strCommand == "start-many")
throw JSONRPCError(RPC_INVALID_PARAMETER, "DEPRECATED, please use start-all instead");
#endif // ENABLE_WALLET
if (fHelp ||
(
#ifdef ENABLE_WALLET
strCommand != "start-alias" && strCommand != "start-all" && strCommand != "start-missing" &&
strCommand != "start-disabled" && strCommand != "outputs" &&
#endif // ENABLE_WALLET
strCommand != "list" && strCommand != "list-conf" && strCommand != "count" &&
strCommand != "debug" && strCommand != "current" && strCommand != "winner" && strCommand != "winners" && strCommand != "genkey" &&
strCommand != "connect" && strCommand != "status"))
throw std::runtime_error(
"masternode \"command\"...\n"
"Set of commands to execute masternode related actions\n"
"\nArguments:\n"
"1. \"command\" (string or set of strings, required) The command to execute\n"
"\nAvailable commands:\n"
" count - Print number of all known masternodes (optional: 'ps', 'enabled', 'all', 'qualify')\n"
" current - Print info on current masternode winner to be paid the next block (calculated locally)\n"
" genkey - Generate new masternodeprivkey\n"
#ifdef ENABLE_WALLET
" outputs - Print masternode compatible outputs\n"
" start-alias - Start single remote masternode by assigned alias configured in masternode.conf\n"
" start-<mode> - Start remote masternodes configured in masternode.conf (<mode>: 'all', 'missing', 'disabled')\n"
#endif // ENABLE_WALLET
" status - Print masternode status information\n"
" list - Print list of all known masternodes (see masternodelist for more info)\n"
" list-conf - Print masternode.conf in JSON format\n"
" winner - Print info on next masternode winner to vote for\n"
" winners - Print list of masternode winners\n"
);
if (strCommand == "list")
{
UniValue newParams(UniValue::VARR);
// forward params but skip "list"
for (unsigned int i = 1; i < params.size(); i++) {
newParams.push_back(params[i]);
}
return masternodelist(newParams, fHelp);
}
if(strCommand == "connect")
{
if (params.size() < 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Masternode address required");
std::string strAddress = params[1].get_str();
CService addr;
if (!Lookup(strAddress.c_str(), addr, 0, false))
throw JSONRPCError(RPC_INTERNAL_ERROR, strprintf("Incorrect masternode address %s", strAddress));
// TODO: Pass CConnman instance somehow and don't use global variable.
CNode *pnode = g_connman->ConnectNode(CAddress(addr, NODE_NETWORK), NULL);
if(!pnode)
throw JSONRPCError(RPC_INTERNAL_ERROR, strprintf("Couldn't connect to masternode %s", strAddress));
return "successfully connected";
}
if (strCommand == "count")
{
if (params.size() > 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Too many parameters");
if (params.size() == 1)
return mnodeman.size();
std::string strMode = params[1].get_str();
if (strMode == "ps")
return mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION);
if (strMode == "enabled")
return mnodeman.CountEnabled();
int nCount;
masternode_info_t mnInfo;
mnodeman.GetNextMasternodeInQueueForPayment(true, nCount, mnInfo);
if (strMode == "qualify")
return nCount;
if (strMode == "all")
return strprintf("Total: %d (PS Compatible: %d / Enabled: %d / Qualify: %d)",
mnodeman.size(), mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION),
mnodeman.CountEnabled(), nCount);
}
if (strCommand == "current" || strCommand == "winner")
{
int nCount;
int nHeight;
masternode_info_t mnInfo;
CBlockIndex* pindex = NULL;
{
LOCK(cs_main);
pindex = chainActive.Tip();
}
nHeight = pindex->nHeight + (strCommand == "current" ? 1 : 10);
mnodeman.UpdateLastPaid(pindex);
if(!mnodeman.GetNextMasternodeInQueueForPayment(nHeight, true, nCount, mnInfo))
return "unknown";
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("height", nHeight));
obj.push_back(Pair("IP:port", mnInfo.addr.ToString()));
obj.push_back(Pair("protocol", (int64_t)mnInfo.nProtocolVersion));
obj.push_back(Pair("outpoint", mnInfo.vin.prevout.ToStringShort()));
obj.push_back(Pair("payee", CBitcoinAddress(mnInfo.pubKeyCollateralAddress.GetID()).ToString()));
obj.push_back(Pair("lastseen", mnInfo.nTimeLastPing));
obj.push_back(Pair("activeseconds", mnInfo.nTimeLastPing - mnInfo.sigTime));
return obj;
}
#ifdef ENABLE_WALLET
if (strCommand == "start-alias")
{
if (params.size() < 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Please specify an alias");
{
LOCK(pwalletMain->cs_wallet);
EnsureWalletIsUnlocked();
}
std::string strAlias = params[1].get_str();
bool fFound = false;
UniValue statusObj(UniValue::VOBJ);
statusObj.push_back(Pair("alias", strAlias));
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
if(mne.getAlias() == strAlias) {
fFound = true;
std::string strError;
CMasternodeBroadcast mnb;
bool fResult = CMasternodeBroadcast::Create(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), strError, mnb);
statusObj.push_back(Pair("result", fResult ? "successful" : "failed"));
if(fResult) {
mnodeman.UpdateMasternodeList(mnb, *g_connman);
mnb.Relay(*g_connman);
} else {
statusObj.push_back(Pair("errorMessage", strError));
}
mnodeman.NotifyMasternodeUpdates(*g_connman);
break;
}
}
if(!fFound) {
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Could not find alias in config. Verify with list-conf."));
}
return statusObj;
}
if (strCommand == "start-all" || strCommand == "start-missing" || strCommand == "start-disabled")
{
{
LOCK(pwalletMain->cs_wallet);
EnsureWalletIsUnlocked();
}
if((strCommand == "start-missing" || strCommand == "start-disabled") && !masternodeSync.IsMasternodeListSynced()) {
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "You can't use this command until masternode list is synced");
}
int nSuccessful = 0;
int nFailed = 0;
UniValue resultsObj(UniValue::VOBJ);
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
std::string strError;
COutPoint outpoint = COutPoint(uint256S(mne.getTxHash()), uint32_t(atoi(mne.getOutputIndex().c_str())));
CMasternode mn;
bool fFound = mnodeman.Get(outpoint, mn);
CMasternodeBroadcast mnb;
if(strCommand == "start-missing" && fFound) continue;
if(strCommand == "start-disabled" && fFound && mn.IsEnabled()) continue;
bool fResult = CMasternodeBroadcast::Create(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), strError, mnb);
UniValue statusObj(UniValue::VOBJ);
statusObj.push_back(Pair("alias", mne.getAlias()));
statusObj.push_back(Pair("result", fResult ? "successful" : "failed"));
if (fResult) {
nSuccessful++;
mnodeman.UpdateMasternodeList(mnb, *g_connman);
mnb.Relay(*g_connman);
} else {
nFailed++;
statusObj.push_back(Pair("errorMessage", strError));
}
resultsObj.push_back(Pair("status", statusObj));
}
mnodeman.NotifyMasternodeUpdates(*g_connman);
UniValue returnObj(UniValue::VOBJ);
returnObj.push_back(Pair("overall", strprintf("Successfully started %d masternodes, failed to start %d, total %d", nSuccessful, nFailed, nSuccessful + nFailed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
#endif // ENABLE_WALLET
if (strCommand == "genkey")
{
CKey secret;
secret.MakeNewKey(false);
return CBitcoinSecret(secret).ToString();
}
if (strCommand == "list-conf")
{
UniValue resultObj(UniValue::VOBJ);
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
COutPoint outpoint = COutPoint(uint256S(mne.getTxHash()), uint32_t(atoi(mne.getOutputIndex().c_str())));
CMasternode mn;
bool fFound = mnodeman.Get(outpoint, mn);
std::string strStatus = fFound ? mn.GetStatus() : "MISSING";
UniValue mnObj(UniValue::VOBJ);
mnObj.push_back(Pair("alias", mne.getAlias()));
mnObj.push_back(Pair("address", mne.getIp()));
mnObj.push_back(Pair("privateKey", mne.getPrivKey()));
mnObj.push_back(Pair("txHash", mne.getTxHash()));
mnObj.push_back(Pair("outputIndex", mne.getOutputIndex()));
mnObj.push_back(Pair("status", strStatus));
resultObj.push_back(Pair("masternode", mnObj));
}
return resultObj;
}
#ifdef ENABLE_WALLET
if (strCommand == "outputs") {
// Find possible candidates
std::vector<COutput> vPossibleCoins;
pwalletMain->AvailableCoins(vPossibleCoins, true, NULL, false, ONLY_1000);
UniValue obj(UniValue::VOBJ);
BOOST_FOREACH(COutput& out, vPossibleCoins) {
obj.push_back(Pair(out.tx->GetHash().ToString(), strprintf("%d", out.i)));
}
return obj;
}
#endif // ENABLE_WALLET
if (strCommand == "status")
{
if (!fMasterNode)
throw JSONRPCError(RPC_INTERNAL_ERROR, "This is not a masternode");
UniValue mnObj(UniValue::VOBJ);
mnObj.push_back(Pair("outpoint", activeMasternode.outpoint.ToStringShort()));
mnObj.push_back(Pair("service", activeMasternode.service.ToString()));
CMasternode mn;
if(mnodeman.Get(activeMasternode.outpoint, mn)) {
mnObj.push_back(Pair("payee", CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString()));
}
mnObj.push_back(Pair("status", activeMasternode.GetStatus()));
return mnObj;
}
if (strCommand == "winners")
{
int nHeight;
{
LOCK(cs_main);
CBlockIndex* pindex = chainActive.Tip();
if(!pindex) return NullUniValue;
nHeight = pindex->nHeight;
}
int nLast = 10;
std::string strFilter = "";
if (params.size() >= 2) {
nLast = atoi(params[1].get_str());
}
if (params.size() == 3) {
strFilter = params[2].get_str();
}
if (params.size() > 3)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'masternode winners ( \"count\" \"filter\" )'");
UniValue obj(UniValue::VOBJ);
for(int i = nHeight - nLast; i < nHeight + 20; i++) {
std::string strPayment = GetRequiredPaymentsString(i);
if (strFilter !="" && strPayment.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strprintf("%d", i), strPayment));
}
return obj;
}
return NullUniValue;
}
UniValue masternodelist(const UniValue& params, bool fHelp)
{
std::string strMode = "status";
std::string strFilter = "";
if (params.size() >= 1) strMode = params[0].get_str();
if (params.size() == 2) strFilter = params[1].get_str();
if (fHelp || (
strMode != "activeseconds" && strMode != "addr" && strMode != "full" && strMode != "info" &&
strMode != "lastseen" && strMode != "lastpaidtime" && strMode != "lastpaidblock" &&
strMode != "protocol" && strMode != "payee" && strMode != "pubkey" &&
strMode != "rank" && strMode != "status"))
{
throw std::runtime_error(
"masternodelist ( \"mode\" \"filter\" )\n"
"Get a list of masternodes in different modes\n"
"\nArguments:\n"
"1. \"mode\" (string, optional/required to use filter, defaults = status) The mode to run list in\n"
"2. \"filter\" (string, optional) Filter results. Partial match by outpoint by default in all modes,\n"
" additional matches in some modes are also available\n"
"\nAvailable modes:\n"
" activeseconds - Print number of seconds masternode recognized by the network as enabled\n"
" (since latest issued \"masternode start/start-many/start-alias\")\n"
" addr - Print ip address associated with a masternode (can be additionally filtered, partial match)\n"
" full - Print info in format 'status protocol payee lastseen activeseconds lastpaidtime lastpaidblock IP'\n"
" (can be additionally filtered, partial match)\n"
" info - Print info in format 'status protocol payee lastseen activeseconds sentinelversion sentinelstate IP'\n"
" (can be additionally filtered, partial match)\n"
" lastpaidblock - Print the last block height a node was paid on the network\n"
" lastpaidtime - Print the last time a node was paid on the network\n"
" lastseen - Print timestamp of when a masternode was last seen on the network\n"
" payee - Print Hah address associated with a masternode (can be additionally filtered,\n"
" partial match)\n"
" protocol - Print protocol of a masternode (can be additionally filtered, exact match)\n"
" pubkey - Print the masternode (not collateral) public key\n"
" rank - Print rank of a masternode based on current block\n"
" status - Print masternode status: PRE_ENABLED / ENABLED / EXPIRED / WATCHDOG_EXPIRED / NEW_START_REQUIRED /\n"
" UPDATE_REQUIRED / POSE_BAN / OUTPOINT_SPENT (can be additionally filtered, partial match)\n"
);
}
if (strMode == "full" || strMode == "lastpaidtime" || strMode == "lastpaidblock") {
CBlockIndex* pindex = NULL;
{
LOCK(cs_main);
pindex = chainActive.Tip();
}
mnodeman.UpdateLastPaid(pindex);
}
UniValue obj(UniValue::VOBJ);
if (strMode == "rank") {
CMasternodeMan::rank_pair_vec_t vMasternodeRanks;
mnodeman.GetMasternodeRanks(vMasternodeRanks);
BOOST_FOREACH(PAIRTYPE(int, CMasternode)& s, vMasternodeRanks) {
std::string strOutpoint = s.second.vin.prevout.ToStringShort();
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, s.first));
}
} else {
std::map<COutPoint, CMasternode> mapMasternodes = mnodeman.GetFullMasternodeMap();
for (auto& mnpair : mapMasternodes) {
CMasternode mn = mnpair.second;
std::string strOutpoint = mnpair.first.ToStringShort();
if (strMode == "activeseconds") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, (int64_t)(mn.lastPing.sigTime - mn.sigTime)));
} else if (strMode == "addr") {
std::string strAddress = mn.addr.ToString();
if (strFilter !="" && strAddress.find(strFilter) == std::string::npos &&
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, strAddress));
} else if (strMode == "full") {
std::ostringstream streamFull;
streamFull << std::setw(18) <<
mn.GetStatus() << " " <<
mn.nProtocolVersion << " " <<
CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString() << " " <<
(int64_t)mn.lastPing.sigTime << " " << std::setw(8) <<
(int64_t)(mn.lastPing.sigTime - mn.sigTime) << " " << std::setw(10) <<
mn.GetLastPaidTime() << " " << std::setw(6) <<
mn.GetLastPaidBlock() << " " <<
mn.addr.ToString();
std::string strFull = streamFull.str();
if (strFilter !="" && strFull.find(strFilter) == std::string::npos &&
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, strFull));
} else if (strMode == "info") {
std::ostringstream streamInfo;
streamInfo << std::setw(18) <<
mn.GetStatus() << " " <<
mn.nProtocolVersion << " " <<
CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString() << " " <<
(int64_t)mn.lastPing.sigTime << " " << std::setw(8) <<
(int64_t)(mn.lastPing.sigTime - mn.sigTime) << " " <<
SafeIntVersionToString(mn.lastPing.nSentinelVersion) << " " <<
(mn.lastPing.fSentinelIsCurrent ? "current" : "expired") << " " <<
mn.addr.ToString();
std::string strInfo = streamInfo.str();
if (strFilter !="" && strInfo.find(strFilter) == std::string::npos &&
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, strInfo));
} else if (strMode == "lastpaidblock") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, mn.GetLastPaidBlock()));
} else if (strMode == "lastpaidtime") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, mn.GetLastPaidTime()));
} else if (strMode == "lastseen") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, (int64_t)mn.lastPing.sigTime));
} else if (strMode == "payee") {
CBitcoinAddress address(mn.pubKeyCollateralAddress.GetID());
std::string strPayee = address.ToString();
if (strFilter !="" && strPayee.find(strFilter) == std::string::npos &&
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, strPayee));
} else if (strMode == "protocol") {
if (strFilter !="" && strFilter != strprintf("%d", mn.nProtocolVersion) &&
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, (int64_t)mn.nProtocolVersion));
} else if (strMode == "pubkey") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, HexStr(mn.pubKeyMasternode)));
} else if (strMode == "status") {
std::string strStatus = mn.GetStatus();
if (strFilter !="" && strStatus.find(strFilter) == std::string::npos &&
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, strStatus));
}
}
}
return obj;
}
bool DecodeHexVecMnb(std::vector<CMasternodeBroadcast>& vecMnb, std::string strHexMnb) {
if (!IsHex(strHexMnb))
return false;
std::vector<unsigned char> mnbData(ParseHex(strHexMnb));
CDataStream ssData(mnbData, SER_NETWORK, PROTOCOL_VERSION);
try {
ssData >> vecMnb;
}
catch (const std::exception&) {
return false;
}
return true;
}
UniValue masternodebroadcast(const UniValue& params, bool fHelp)
{
std::string strCommand;
if (params.size() >= 1)
strCommand = params[0].get_str();
if (fHelp ||
(
#ifdef ENABLE_WALLET
strCommand != "create-alias" && strCommand != "create-all" &&
#endif // ENABLE_WALLET
strCommand != "decode" && strCommand != "relay"))
throw std::runtime_error(
"masternodebroadcast \"command\"...\n"
"Set of commands to create and relay masternode broadcast messages\n"
"\nArguments:\n"
"1. \"command\" (string or set of strings, required) The command to execute\n"
"\nAvailable commands:\n"
#ifdef ENABLE_WALLET
" create-alias - Create single remote masternode broadcast message by assigned alias configured in masternode.conf\n"
" create-all - Create remote masternode broadcast messages for all masternodes configured in masternode.conf\n"
#endif // ENABLE_WALLET
" decode - Decode masternode broadcast message\n"
" relay - Relay masternode broadcast message to the network\n"
);
#ifdef ENABLE_WALLET
if (strCommand == "create-alias")
{
// wait for reindex and/or import to finish
if (fImporting || fReindex)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Wait for reindex and/or import to finish");
if (params.size() < 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Please specify an alias");
{
LOCK(pwalletMain->cs_wallet);
EnsureWalletIsUnlocked();
}
bool fFound = false;
std::string strAlias = params[1].get_str();
UniValue statusObj(UniValue::VOBJ);
std::vector<CMasternodeBroadcast> vecMnb;
statusObj.push_back(Pair("alias", strAlias));
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
if(mne.getAlias() == strAlias) {
fFound = true;
std::string strError;
CMasternodeBroadcast mnb;
bool fResult = CMasternodeBroadcast::Create(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), strError, mnb, true);
statusObj.push_back(Pair("result", fResult ? "successful" : "failed"));
if(fResult) {
vecMnb.push_back(mnb);
CDataStream ssVecMnb(SER_NETWORK, PROTOCOL_VERSION);
ssVecMnb << vecMnb;
statusObj.push_back(Pair("hex", HexStr(ssVecMnb.begin(), ssVecMnb.end())));
} else {
statusObj.push_back(Pair("errorMessage", strError));
}
break;
}
}
if(!fFound) {
statusObj.push_back(Pair("result", "not found"));
statusObj.push_back(Pair("errorMessage", "Could not find alias in config. Verify with list-conf."));
}
return statusObj;
}
if (strCommand == "create-all")
{
// wait for reindex and/or import to finish
if (fImporting || fReindex)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Wait for reindex and/or import to finish");
{
LOCK(pwalletMain->cs_wallet);
EnsureWalletIsUnlocked();
}
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
int nSuccessful = 0;
int nFailed = 0;
UniValue resultsObj(UniValue::VOBJ);
std::vector<CMasternodeBroadcast> vecMnb;
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
std::string strError;
CMasternodeBroadcast mnb;
bool fResult = CMasternodeBroadcast::Create(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), strError, mnb, true);
UniValue statusObj(UniValue::VOBJ);
statusObj.push_back(Pair("alias", mne.getAlias()));
statusObj.push_back(Pair("result", fResult ? "successful" : "failed"));
if(fResult) {
nSuccessful++;
vecMnb.push_back(mnb);
} else {
nFailed++;
statusObj.push_back(Pair("errorMessage", strError));
}
resultsObj.push_back(Pair("status", statusObj));
}
CDataStream ssVecMnb(SER_NETWORK, PROTOCOL_VERSION);
ssVecMnb << vecMnb;
UniValue returnObj(UniValue::VOBJ);
returnObj.push_back(Pair("overall", strprintf("Successfully created broadcast messages for %d masternodes, failed to create %d, total %d", nSuccessful, nFailed, nSuccessful + nFailed)));
returnObj.push_back(Pair("detail", resultsObj));
returnObj.push_back(Pair("hex", HexStr(ssVecMnb.begin(), ssVecMnb.end())));
return returnObj;
}
#endif // ENABLE_WALLET
if (strCommand == "decode")
{
if (params.size() != 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'masternodebroadcast decode \"hexstring\"'");
std::vector<CMasternodeBroadcast> vecMnb;
if (!DecodeHexVecMnb(vecMnb, params[1].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Masternode broadcast message decode failed");
int nSuccessful = 0;
int nFailed = 0;
int nDos = 0;
UniValue returnObj(UniValue::VOBJ);
BOOST_FOREACH(CMasternodeBroadcast& mnb, vecMnb) {
UniValue resultObj(UniValue::VOBJ);
if(mnb.CheckSignature(nDos)) {
nSuccessful++;
resultObj.push_back(Pair("outpoint", mnb.vin.prevout.ToStringShort()));
resultObj.push_back(Pair("addr", mnb.addr.ToString()));
resultObj.push_back(Pair("pubKeyCollateralAddress", CBitcoinAddress(mnb.pubKeyCollateralAddress.GetID()).ToString()));
resultObj.push_back(Pair("pubKeyMasternode", CBitcoinAddress(mnb.pubKeyMasternode.GetID()).ToString()));
resultObj.push_back(Pair("vchSig", EncodeBase64(&mnb.vchSig[0], mnb.vchSig.size())));
resultObj.push_back(Pair("sigTime", mnb.sigTime));
resultObj.push_back(Pair("protocolVersion", mnb.nProtocolVersion));
resultObj.push_back(Pair("nLastDsq", mnb.nLastDsq));
UniValue lastPingObj(UniValue::VOBJ);
lastPingObj.push_back(Pair("outpoint", mnb.lastPing.vin.prevout.ToStringShort()));
lastPingObj.push_back(Pair("blockHash", mnb.lastPing.blockHash.ToString()));
lastPingObj.push_back(Pair("sigTime", mnb.lastPing.sigTime));
lastPingObj.push_back(Pair("vchSig", EncodeBase64(&mnb.lastPing.vchSig[0], mnb.lastPing.vchSig.size())));
resultObj.push_back(Pair("lastPing", lastPingObj));
} else {
nFailed++;
resultObj.push_back(Pair("errorMessage", "Masternode broadcast signature verification failed"));
}
returnObj.push_back(Pair(mnb.GetHash().ToString(), resultObj));
}
returnObj.push_back(Pair("overall", strprintf("Successfully decoded broadcast messages for %d masternodes, failed to decode %d, total %d", nSuccessful, nFailed, nSuccessful + nFailed)));
return returnObj;
}
if (strCommand == "relay")
{
if (params.size() < 2 || params.size() > 3)
throw JSONRPCError(RPC_INVALID_PARAMETER, "masternodebroadcast relay \"hexstring\" ( fast )\n"
"\nArguments:\n"
"1. \"hex\" (string, required) Broadcast messages hex string\n"
"2. fast (string, optional) If none, using safe method\n");
std::vector<CMasternodeBroadcast> vecMnb;
if (!DecodeHexVecMnb(vecMnb, params[1].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Masternode broadcast message decode failed");
int nSuccessful = 0;
int nFailed = 0;
bool fSafe = params.size() == 2;
UniValue returnObj(UniValue::VOBJ);
// verify all signatures first, bailout if any of them broken
BOOST_FOREACH(CMasternodeBroadcast& mnb, vecMnb) {
UniValue resultObj(UniValue::VOBJ);
resultObj.push_back(Pair("outpoint", mnb.vin.prevout.ToStringShort()));
resultObj.push_back(Pair("addr", mnb.addr.ToString()));
int nDos = 0;
bool fResult;
if (mnb.CheckSignature(nDos)) {
if (fSafe) {
fResult = mnodeman.CheckMnbAndUpdateMasternodeList(NULL, mnb, nDos, *g_connman);
} else {
mnodeman.UpdateMasternodeList(mnb, *g_connman);
mnb.Relay(*g_connman);
fResult = true;
}
mnodeman.NotifyMasternodeUpdates(*g_connman);
} else fResult = false;
if(fResult) {
nSuccessful++;
resultObj.push_back(Pair(mnb.GetHash().ToString(), "successful"));
} else {
nFailed++;
resultObj.push_back(Pair("errorMessage", "Masternode broadcast signature verification failed"));
}
returnObj.push_back(Pair(mnb.GetHash().ToString(), resultObj));
}
returnObj.push_back(Pair("overall", strprintf("Successfully relayed broadcast messages for %d masternodes, failed to relay %d, total %d", nSuccessful, nFailed, nSuccessful + nFailed)));
return returnObj;
}
return NullUniValue;
}
UniValue sentinelping(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1) {
throw std::runtime_error(
"sentinelping version\n"
"\nSentinel ping.\n"
"\nArguments:\n"
"1. version (string, required) Sentinel version in the form \"x.x.x\"\n"
"\nResult:\n"
"state (boolean) Ping result\n"
"\nExamples:\n"
+ HelpExampleCli("sentinelping", "1.0.2")
+ HelpExampleRpc("sentinelping", "1.0.2")
);
}
activeMasternode.UpdateSentinelPing(StringVersionToInt(params[0].get_str()));
return true;
}
|
; A244635: 29*n^2.
; 0,29,116,261,464,725,1044,1421,1856,2349,2900,3509,4176,4901,5684,6525,7424,8381,9396,10469,11600,12789,14036,15341,16704,18125,19604,21141,22736,24389,26100,27869,29696,31581,33524,35525,37584,39701,41876,44109,46400,48749,51156,53621,56144,58725,61364,64061,66816,69629,72500,75429,78416,81461,84564,87725,90944,94221,97556,100949,104400,107909,111476,115101,118784,122525,126324,130181,134096,138069,142100,146189,150336,154541,158804,163125,167504,171941,176436,180989,185600,190269,194996,199781,204624,209525,214484,219501,224576,229709,234900,240149,245456,250821,256244,261725,267264,272861,278516,284229,290000,295829,301716,307661,313664,319725,325844,332021,338256,344549,350900,357309,363776,370301,376884,383525,390224,396981,403796,410669,417600,424589,431636,438741,445904,453125,460404,467741,475136,482589,490100,497669,505296,512981,520724,528525,536384,544301,552276,560309,568400,576549,584756,593021,601344,609725,618164,626661,635216,643829,652500,661229,670016,678861,687764,696725,705744,714821,723956,733149,742400,751709,761076,770501,779984,789525,799124,808781,818496,828269,838100,847989,857936,867941,878004,888125,898304,908541,918836,929189,939600,950069,960596,971181,981824,992525,1003284,1014101,1024976,1035909,1046900,1057949,1069056,1080221,1091444,1102725,1114064,1125461,1136916,1148429,1160000,1171629,1183316,1195061,1206864,1218725,1230644,1242621,1254656,1266749,1278900,1291109,1303376,1315701,1328084,1340525,1353024,1365581,1378196,1390869,1403600,1416389,1429236,1442141,1455104,1468125,1481204,1494341,1507536,1520789,1534100,1547469,1560896,1574381,1587924,1601525,1615184,1628901,1642676,1656509,1670400,1684349,1698356,1712421,1726544,1740725,1754964,1769261,1783616,1798029
mov $1,$0
pow $1,2
mul $1,29
|
;================================================================================
; Master / Tempered / Golden Sword Swap
;================================================================================
;$03348E: smith sword check (to see if uprade-able)
;================================================================================
;GetFairySword:
; CMP.b #$49 : BNE + : LDA.b #$00 : + ; convert single fighter sword to low id one
; CMP.b #$50 : BNE + : LDA.b #$01 : + ; convert safe master sword to normal one
; CMP #$04 : !BLT + : JML.l PyramidFairy_BRANCH_IOTA : + ; for any sword, incl newer
; JSL ItemCheck_FairySword : BEQ + : JML.l PyramidFairy_BRANCH_IOTA : + ; skip if we already flagged getting this
; JSL ItemSet_FairySword ; mark as got
; LDA FairySword : STA $0DC0, X ; whichever sword
; LDA.b #$05 : STA $0EB0, X ; something we overwrote, documentation unclear on purpose
;
;JML.l PyramidFairy_BRANCH_GAMMA
;================================================================================
;GetSmithSword:
; JSL ItemCheck_SmithSword : BEQ + : JML.l Smithy_AlreadyGotSword : + ; check if we're not already done
; ;JSL ItemSet_SmithSword - too early
;JML.l Smithy_DoesntHaveSword
;================================================================================
;LoadSwordForDamage:
; LDA $7EF359 : CMP #$04 : BNE .done ; skip if not gold sword
; LDA $1B : BEQ + ; skip if outdoors
; LDA $A0 : CMP #41 : BNE + ; decimal 41 ; skip if not in the mothula room
; LDA #$03 ; pretend we're using tempered
; BRA .done
; +
; LDA #$04 ; nvm gold sword is fine
; .done
;RTL
;================================================================================
LoadSwordForDamage:
LDA $0E20, X : CMP.b #$88 : BNE .notMoth
JSR.w LoadModifiedSwordLevel ; load normal sword value
CMP.b #$04 : !BLT + : DEC : + ; if it's gold sword, change it to tempered
RTL
.notMoth
JSR.w LoadModifiedSwordLevel ; load normal sword value
RTL
;================================================================================
; $7F50C0 - Sword Modifier
LoadModifiedSwordLevel: ; returns short
LDA $7F50C0 : BEQ +
!ADD $7EF359 ; add normal sword value to modifier
BNE ++ : LDA.b #$01 : RTS : ++
CMP.b #$05 : !BLT ++ : LDA.b #$04 : RTS : ++
RTS
+
LDA $7EF359 ; load normal sword value
RTS
;================================================================================
; $7EF35B - Armor Inventory
; $7F50C2 - Armor Modifier
; $7F5020 - Scratch Space (Caller Preserved)
LoadModifiedArmorLevel:
PHA
LDA $7EF35B : !ADD $7F50C2
CMP.b #$FF : BNE + : LDA.b #$00 : +
CMP.b #$03 : !BLT + : LDA.b #$02 : +
STA $7F5020
PLA
!ADD $7F5020
RTL
;================================================================================
; $7EF37B - Magic Inventory
; $7F50C3 - Magic Modifier
LoadModifiedMagicLevel:
LDA $7F50C3 : BEQ +
!ADD $7EF37B ; add normal magic value to modifier
CMP.b #$FF : BNE ++ : LDA.b #$00 : RTL : ++
CMP.b #$03 : !BLT ++ : LDA.b #$02 : ++
RTL
+
LDA $7EF37B ; load normal magic value
RTL
;================================================================================
; $7E0348 - Ice Value
; $7F50C7 - Ice Modifier
LoadModifiedIceFloorValue_a11:
LDA $A0 : CMP #$91 : BEQ + : CMP #$92 : BEQ + : CMP #$93 : BEQ + ; mire basement currently broken - not sure why
LDA $5D : CMP #$01 : BEQ + : CMP #$17 : BEQ + : CMP #$1C : BEQ +
LDA $5E : CMP #$02 : BEQ +
LDA $5B : BNE +
LDA.w $0348 : ORA $7F50C7 : AND.b #$11 : RTL
+ : LDA.w $0348 : AND.b #$11
RTL
LoadModifiedIceFloorValue_a01:
LDA $A0 : CMP #$91 : BEQ + : CMP #$92 : BEQ + : CMP #$93 : BEQ + ; mire basement currently broken - not sure why
LDA $5D : CMP #$01 : BEQ + : CMP #$17 : BEQ + : CMP #$1C : BEQ +
LDA $5E : CMP #$02 : BEQ +
LDA $5B : BNE +
LDA.w $0348 : ORA $7F50C7 : AND.b #$01 : RTL
+ : LDA.w $0348 : AND.b #$01
RTL
;================================================================================
CheckTabletSword:
LDA.l AllowHammerTablets : BEQ +
LDA $7EF34B : BEQ + ; check for hammer
LDA.b #$02 : RTL
+
LDA $7EF359 ; get actual sword value
RTL
;================================================================================
CheckGanonHammerDamage:
LDA.l HammerableGanon : BEQ +
LDA $0E20, X : CMP.b #$D8 ; original behavior except ganon
RTL
+
LDA $0E20, X : CMP.b #$D6 ; original behavior
RTL
;================================================================================
GetSmithSword:
JSL ItemCheck_SmithSword : BEQ + : JML.l Smithy_AlreadyGotSword : +
LDA.l SmithItemMode : BNE +
JML.l Smithy_DoesntHaveSword ; Classic Smithy
+
LDA.l SmithItem : TAY
STZ $02E9 ; Item from NPC
PHX : JSL Link_ReceiveItem : PLX
REP #$20 : LDA $7EF360 : !SUB.w #$000A : STA $7EF360 : SEP #$20 ; Take 10 rupees
JSL ItemSet_SmithSword
JML.l Smithy_AlreadyGotSword
;================================================================================
CheckMedallionSword:
PHB : PHX : PHY
LDA.l AllowSwordlessMedallionUse : BNE +++ : BRL + : +++
LDA $1B : BEQ .outdoors
.indoors
REP #$20 ; set 16-bit accumulator
LDA $A0 ; load room ID
CMP.w #$000E : BNE ++ : .freezor1
LDA $22 : AND.w #$01FF : CMP.w #368-8 : !BLT .normal : CMP.w #368+32-8 : !BGE .normal ; check x-coord
LDA $20 : AND.w #$01FF : CMP.w #400-22 : !BLT .normal : CMP.w #400+32-22 : !BGE .normal ; check y-coord
BRL .permit
++ : CMP.w #$007E : BNE ++ : .freezor2
LDA $22 : AND.w #$01FF : CMP.w #112-8 : !BLT .normal : CMP.w #112+32-8 : !BGE .normal ; check x-coord
LDA $20 : AND.w #$01FF : CMP.w #400-22 : !BLT .normal : CMP.w #400+32-22 : !BGE .normal ; check y-coord
BRL .permit
++ : CMP.w #$00DE : BNE ++ : .kholdstare
LDA $22 : AND.w #$01FF : CMP.w #368-8 : !BLT .normal : CMP.w #368+32-8 : !BGE .normal ; check x-coord
LDA $20 : AND.w #$01FF : CMP.w #144-22 : !BLT .normal : CMP.w #144+32-22 : !BGE .normal ; check y-coord
BRA .permit
++ : .normal
SEP #$20 ; set 8-bit accumulator
BRA .done
.outdoors
LDA $8A : CMP.b #$70 : BNE ++
LDA.l MireRequiredMedallion : TAX : LDA.l .medallion_type, X : CMP $0303 : BNE +
LDA $7EF2F0 : AND.b #$20 : BNE +
LDA.b #$08 : PHA : PLB ; set data bank to $08
LDY.b #$02 : JSL.l Ancilla_CheckIfEntranceTriggered : BCS .permit ; misery mire
BRA +
++ : CMP.b #$47 : BNE ++
LDA.l TRockRequiredMedallion : TAX : LDA.l .medallion_type, X : CMP $0303 : BNE +
LDA $7EF2C7 : AND.b #$20 : BNE +
LDA.b #$08 : PHA : PLB ; set data bank to $08
LDY.b #$03 : JSL.l Ancilla_CheckIfEntranceTriggered : BCS .permit ; turtle rock
++
.done
+
PLY : PLX : PLB
LDA $7EF359
RTL
.permit
SEP #$20 ; set 8-bit accumulator
PLY : PLX : PLB
LDA.b #$02 ; Pretend we have master sword
RTL
.medallion_type
db #$0F, #$10, #$11
;================================================================================
|
; A278131: a(n) = 591*2^n - 273.
; 318,909,2091,4455,9183,18639,37551,75375,151023,302319,604911,1210095,2420463,4841199,9682671,19365615,38731503,77463279,154926831,309853935,619708143,1239416559,2478833391,4957667055,9915334383,19830669039,39661338351
mov $1,2
pow $1,$0
sub $1,1
mul $1,591
add $1,318
|
// Copyright 2011, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * 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 Google Inc. 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.
// ICU integration functions.
#include <stdlib.h>
#include <string.h>
#include <unicode/ucnv.h>
#include <unicode/ucnv_cb.h>
#include <unicode/uidna.h>
#include "src/url_canon_icu.h"
#include "src/url_canon_internal.h" // for _itoa_s
#include "base/logging.h"
namespace url_canon {
namespace {
// Called when converting a character that can not be represented, this will
// append an escaped version of the numerical character reference for that code
// point. It is of the form "Ӓ" and we will escape the non-digits to
// "%26%231234%3B". Why? This is what Netscape did back in the olden days.
void appendURLEscapedChar(const void* context,
UConverterFromUnicodeArgs* from_args,
const UChar* code_units,
int32_t length,
UChar32 code_point,
UConverterCallbackReason reason,
UErrorCode* err) {
if (reason == UCNV_UNASSIGNED) {
*err = U_ZERO_ERROR;
const static int prefix_len = 6;
const static char prefix[prefix_len + 1] = "%26%23"; // "&#" percent-escaped
ucnv_cbFromUWriteBytes(from_args, prefix, prefix_len, 0, err);
DCHECK(code_point < 0x110000);
char number[8]; // Max Unicode code point is 7 digits.
_itoa_s(code_point, number, 10);
int number_len = static_cast<int>(strlen(number));
ucnv_cbFromUWriteBytes(from_args, number, number_len, 0, err);
const static int postfix_len = 3;
const static char postfix[postfix_len + 1] = "%3B"; // ";" percent-escaped
ucnv_cbFromUWriteBytes(from_args, postfix, postfix_len, 0, err);
}
}
// A class for scoping the installation of the invalid character callback.
class AppendHandlerInstaller {
public:
// The owner of this object must ensure that the converter is alive for the
// duration of this object's lifetime.
AppendHandlerInstaller(UConverter* converter) : converter_(converter) {
UErrorCode err = U_ZERO_ERROR;
ucnv_setFromUCallBack(converter_, appendURLEscapedChar, 0,
&old_callback_, &old_context_, &err);
}
~AppendHandlerInstaller() {
UErrorCode err = U_ZERO_ERROR;
ucnv_setFromUCallBack(converter_, old_callback_, old_context_, 0, 0, &err);
}
private:
UConverter* converter_;
UConverterFromUCallback old_callback_;
const void* old_context_;
};
} // namespace
ICUCharsetConverter::ICUCharsetConverter(UConverter* converter)
: converter_(converter) {
}
ICUCharsetConverter::~ICUCharsetConverter() {
}
void ICUCharsetConverter::ConvertFromUTF16(const char16* input,
int input_len,
CanonOutput* output) {
// Install our error handler. It will be called for character that can not
// be represented in the destination character set.
AppendHandlerInstaller handler(converter_);
int begin_offset = output->length();
int dest_capacity = output->capacity() - begin_offset;
output->set_length(output->length());
do {
UErrorCode err = U_ZERO_ERROR;
char* dest = &output->data()[begin_offset];
int required_capacity = ucnv_fromUChars(converter_, dest, dest_capacity,
input, input_len, &err);
if (err != U_BUFFER_OVERFLOW_ERROR) {
output->set_length(begin_offset + required_capacity);
return;
}
// Output didn't fit, expand
dest_capacity = required_capacity;
output->Resize(begin_offset + dest_capacity);
} while (true);
}
// Converts the Unicode input representing a hostname to ASCII using IDN rules.
// The output must be ASCII, but is represented as wide characters.
//
// On success, the output will be filled with the ASCII host name and it will
// return true. Unlike most other canonicalization functions, this assumes that
// the output is empty. The beginning of the host will be at offset 0, and
// the length of the output will be set to the length of the new host name.
//
// On error, this will return false. The output in this case is undefined.
bool IDNToASCII(const char16* src, int src_len, CanonOutputW* output) {
DCHECK(output->length() == 0); // Output buffer is assumed empty.
while (true) {
// Use ALLOW_UNASSIGNED to be more tolerant of hostnames that violate
// the spec (which do exist). This does not present any risk and is a
// little more future proof.
UErrorCode err = U_ZERO_ERROR;
int num_converted = uidna_IDNToASCII(src, src_len, output->data(),
output->capacity(),
UIDNA_ALLOW_UNASSIGNED, NULL, &err);
if (err == U_ZERO_ERROR) {
output->set_length(num_converted);
return true;
}
if (err != U_BUFFER_OVERFLOW_ERROR)
return false; // Unknown error, give up.
// Not enough room in our buffer, expand.
output->Resize(output->capacity() * 2);
}
}
bool ReadUTFChar(const char* str, int* begin, int length,
unsigned* code_point_out) {
int code_point; // Avoids warning when U8_NEXT writes -1 to it.
U8_NEXT(str, *begin, length, code_point);
*code_point_out = static_cast<unsigned>(code_point);
// The ICU macro above moves to the next char, we want to point to the last
// char consumed.
(*begin)--;
// Validate the decoded value.
if (U_IS_UNICODE_CHAR(code_point))
return true;
*code_point_out = kUnicodeReplacementCharacter;
return false;
}
bool ReadUTFChar(const char16* str, int* begin, int length,
unsigned* code_point) {
if (U16_IS_SURROGATE(str[*begin])) {
if (!U16_IS_SURROGATE_LEAD(str[*begin]) || *begin + 1 >= length ||
!U16_IS_TRAIL(str[*begin + 1])) {
// Invalid surrogate pair.
*code_point = kUnicodeReplacementCharacter;
return false;
} else {
// Valid surrogate pair.
*code_point = U16_GET_SUPPLEMENTARY(str[*begin], str[*begin + 1]);
(*begin)++;
}
} else {
// Not a surrogate, just one 16-bit word.
*code_point = str[*begin];
}
if (U_IS_UNICODE_CHAR(*code_point))
return true;
// Invalid code point.
*code_point = kUnicodeReplacementCharacter;
return false;
}
} // namespace url_canon
|
; A170390: Number of reduced words of length n in Coxeter group on 45 generators S_i with relations (S_i)^2 = (S_i S_j)^43 = I.
; 1,45,1980,87120,3833280,168664320,7421230080,326534123520,14367501434880,632170063134720,27815482777927680,1223881242228817920,53850774658067988480,2369434084954991493120,104255099738019625697280
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
div $3,$2
mul $2,44
lpe
mov $0,$2
div $0,44
|
;worksheet 1
;exercise 3
segment code
assume cs: code
main:
mov bx , 00h ; space counter
mov cx , 03h ; line counter
next_line:
push cx ; remeber how many lines left
mov cx , bx ; is it first line ?
cmp cx , 0
je first_space
next_space:
mov dl , 20h ; ascii space
int 21h
dec cx
jnz next_space
first_space:
mov cx , 0ah ; char counter
mov dl , 41h ; ascii value to display
next_char: ; displays next char
mov ah , 02h
int 21h
inc dl ; next ascii value
dec cx ; one less char to display
jnz next_char
; endline
mov dl , 0ah ; CR
int 21h
mov dl , 0dh ; LF
int 21h
add bx , 02h ; add two spaces
pop cx
dec cx ; how many lines left ?
cmp cx , 0
jnz next_line
exit:
mov ah, 4ch
int 21h
ends code ;end of code segment
end main ;end of program and starting point
|
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/System.h>
#include <LibKeyboard/CharacterMap.h>
#include <LibMain/Main.h>
#include <stdio.h>
int set_keymap(String const& keymap);
int set_keymap(String const& keymap)
{
auto character_map = Keyboard::CharacterMap::load_from_file(keymap);
if (character_map.is_error()) {
warnln("Cannot read keymap {}", keymap);
warnln("Hint: Must be a keymap name (e.g. 'en-us')");
return 1;
}
int rc = character_map.value().set_system_map();
if (rc != 0) {
perror("setkeymap");
}
return rc;
}
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio setkeymap getkeymap rpath wpath cpath"));
TRY(Core::System::unveil("/res/keymaps", "r"));
TRY(Core::System::unveil("/etc/Keyboard.ini", "rwc"));
String mapping;
String mappings;
Core::ArgsParser args_parser;
args_parser.add_option(mapping, "The mapping to be used", "set-keymap", 'm', "keymap");
args_parser.add_option(mappings, "Comma separated list of enabled mappings", "set-keymaps", 's', "keymaps");
args_parser.parse(arguments);
TRY(Core::System::unveil(nullptr, nullptr));
if (mapping.is_empty() && mappings.is_empty()) {
auto keymap = TRY(Keyboard::CharacterMap::fetch_system_map());
outln("{}", keymap.character_map_name());
return 0;
}
auto mapper_config(Core::ConfigFile::open("/etc/Keyboard.ini", Core::ConfigFile::AllowWriting::Yes));
int rc = 0;
if (!mappings.is_empty()) {
auto mappings_vector = mappings.split(',');
if (mappings_vector.is_empty()) {
warnln("Keymaps list should not be empty");
return 1;
}
// Verify that all specified keymaps are loadable
for (auto& keymap_name : mappings_vector) {
auto keymap = Keyboard::CharacterMap::load_from_file(keymap_name);
if (keymap.is_error()) {
warnln("Cannot load keymap {}: {}({})", keymap_name, keymap.error().string_literal(), keymap.error().code());
return keymap.error();
}
}
auto keymaps = String::join(',', mappings_vector);
mapper_config->write_entry("Mapping", "Keymaps", keymaps);
mapper_config->sync();
rc = set_keymap(mappings_vector.first());
if (rc != 0) {
return rc;
}
}
auto keymaps = mapper_config->read_entry("Mapping", "Keymaps");
auto keymaps_vector = keymaps.split(',');
if (!mapping.is_empty()) {
if (keymaps_vector.is_empty()) {
warnln("No keymaps configured - writing default configurations (en-us)");
mapper_config->write_entry("Mapping", "Keymaps", "en-us");
mapper_config->sync();
keymaps_vector.append("en-us");
}
if (!keymaps_vector.find(mapping).is_end()) {
rc = set_keymap(mapping);
if (rc != 0) {
return rc;
}
} else {
warnln("Keymap '{}' is not in list of configured keymaps ({})", mapping, keymaps);
}
}
return 0;
}
|
<%
from pwnlib.shellcraft.i386.linux import syscall
%>
<%page args="fd, iovec, count, offset"/>
<%docstring>
Invokes the syscall preadv. See 'man 2 preadv' for more information.
Arguments:
fd(int): fd
iovec(iovec): iovec
count(int): count
offset(off_t): offset
</%docstring>
${syscall('SYS_preadv', fd, iovec, count, offset)}
|
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "admin-server.h"
#include <lib/fidl-async/cpp/bind.h>
#include <lib/syslog/cpp/macros.h>
#include <fs/service.h>
namespace devmgr {
fbl::RefPtr<fs::Service> AdminServer::Create(devmgr::FsManager* fs_manager,
async_dispatcher* dispatcher) {
return fbl::MakeRefCounted<fs::Service>([dispatcher, fs_manager](zx::channel chan) mutable {
zx_status_t status = fidl::BindSingleInFlightOnly(dispatcher, std::move(chan),
std::make_unique<AdminServer>(fs_manager));
if (status != ZX_OK) {
FX_LOGS(ERROR) << "failed to bind admin service: " << zx_status_get_string(status);
return status;
}
return ZX_OK;
});
}
void AdminServer::Shutdown(ShutdownCompleter::Sync& completer) {
FX_LOGS(INFO) << "received shutdown command over admin interface";
fs_manager_->Shutdown([completer = completer.ToAsync()](zx_status_t status) mutable {
if (status != ZX_OK) {
FX_LOGS(ERROR) << "error waiting for FSHOST_SIGNAL_EXIT_DONE: "
<< zx_status_get_string(status);
} else {
completer.Reply();
FX_LOGS(INFO) << "shutdown complete";
}
});
}
} // namespace devmgr
|
; A286728: Positions of 1 in A286063; complement of A286727.
; 3,4,7,12,13,18,21,22,25,30,33,34,39,40,43,48,49,54,57,58,63,64,67,72,75,76,79,84,85,90,93,94,97,102,105,106,111,112,115,120,123,124,127,132,133,138,141,142,147,148,151,156,157,162,165,166,169,174,177,178,183,184,187,192,193,198,201,202,207,208,211,216,219,220,223,228,229,234,237,238,243,244,247,252,253,258,261,262,265,270,273,274,279,280,283,288,291,292,295,300,301,306,309,310,313,318,321,322,327,328,331,336,337,342,345,346,351,352,355,360,363,364,367,372,373,378,381,382,385,390,393,394,399,400,403,408,411,412,415,420,421,426,429,430,435,436,439,444,445,450,453,454,457,462,465,466,471,472,475,480,483,484,487,492,493,498,501,502,505,510,513,514,519,520,523,528,529,534,537,538,543,544,547,552,555,556,559,564,565,570,573,574,579,580,583,588,589,594,597,598,601,606,609,610,615,616,619,624,625,630,633,634,639,640,643,648,651,652,655,660,661,666,669,670,673,678,681,682,687,688,691,696,699,700,703,708,709,714,717,718,723,724,727,732,733,738,741,742,745,750
mov $2,1
mov $3,$0
lpb $0,1
mov $5,$0
div $0,2
add $2,$5
lpe
mov $1,$2
mul $1,2
mod $1,4
add $1,1
mov $4,$3
mul $4,3
add $1,$4
|
; A108577: Number of symmetry classes of 3 X 3 magic squares (with distinct positive entries) having all entries < n.
; 0,0,0,0,0,0,0,0,0,1,2,5,8,12,16,23,30,40,50,63,76,93,110,132,154,180,206,238,270,308,346,390,434,485,536,595,654,720,786,861,936,1020,1104,1197,1290,1393,1496,1610,1724,1848,1972,2108,2244,2392,2540,2700,2860,3033,3206,3393,3580,3780,3980,4195,4410,4640,4870,5115,5360,5621,5882,6160,6438,6732,7026,7338,7650,7980,8310,8658,9006,9373,9740,10127,10514,10920,11326,11753,12180,12628,13076,13545,14014,14505,14996,15510,16024,16560,17096,17656,18216,18800,19384,19992,20600,21233,21866,22525,23184,23868,24552,25263,25974,26712,27450,28215,28980,29773,30566,31388,32210,33060,33910,34790,35670,36580,37490,38430,39370,40341,41312,42315,43318,44352,45386,46453,47520,48620,49720,50853,51986,53153,54320,55522,56724,57960,59196,60468,61740,63048,64356,65700,67044,68425,69806,71225,72644,74100,75556,77051,78546,80080,81614,83187,84760,86373,87986,89640,91294,92988,94682,96418,98154,99932,101710,103530,105350,107213,109076,110983,112890,114840,116790,118785,120780,122820,124860,126945,129030,131161,133292,135470,137648,139872,142096,144368,146640,148960,151280,153648,156016,158433,160850,163317,165784,168300,170816,173383,175950,178568,181186,183855,186524,189245,191966,194740,197514,200340,203166,206046,208926,211860,214794,217782,220770,223813,226856,229955,233054,236208,239362,242573,245784,249052,252320,255645,258970,262353,265736,269178,272620,276120,279620,283180,286740,290360,293980,297660,301340,305081
cal $0,108576 ; Number of 3 X 3 magic squares (with distinct positive entries) having all entries < n.
mov $1,$0
div $1,8
|
; A081336: a(n) = (7^n + 3^n)/2.
; 1,5,29,185,1241,8525,59189,412865,2885681,20186645,141267149,988751945,6920909321,48445302365,339113927909,2373787929425,16616486808161,116315321563685,814206992665469,5699448173817305,39896134892198201,279272937271818605,1954910539982023829,13684373717112047585,95790615831497975441,670534310255626755125,4693740170094810066989,32856181185579938812265,229993268283808376715881,1609952877940905052101245,11269670145449074609978949,78887691017731740005663345,552213837122886833247075521
mov $1,3
pow $1,$0
mov $2,7
pow $2,$0
add $1,$2
div $1,8
mul $1,4
add $1,1
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x16611, %rsi
lea addresses_A_ht+0x199f9, %rdi
nop
nop
nop
and %r9, %r9
mov $111, %rcx
rep movsl
nop
nop
nop
nop
nop
dec %r11
lea addresses_WC_ht+0x11bd1, %rsi
lea addresses_UC_ht+0xaf51, %rdi
xor %r12, %r12
mov $72, %rcx
rep movsl
xor $248, %rsi
lea addresses_normal_ht+0xd51, %rdi
nop
nop
sub $55099, %rsi
movups (%rdi), %xmm1
vpextrq $0, %xmm1, %r12
nop
nop
nop
sub %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r15
push %r9
push %rdx
push %rsi
// Store
lea addresses_A+0x151c4, %r12
nop
nop
nop
nop
and $20656, %rdx
movb $0x51, (%r12)
// Exception!!!
nop
mov (0), %r15
nop
nop
sub $51340, %r12
// Faulty Load
lea addresses_RW+0x10551, %r12
nop
nop
nop
nop
xor $56324, %r9
mov (%r12), %r14d
lea oracles, %rdx
and $0xff, %r14
shlq $12, %r14
mov (%rdx,%r14,1), %r14
pop %rsi
pop %rdx
pop %r9
pop %r15
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_RW', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 3}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 9}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 11}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
;
; Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
;
; Use of this source code is governed by a BSD-style license
; that can be found in the LICENSE file in the root of the source
; tree. An additional intellectual property rights grant can be found
; in the file PATENTS. All contributing project authors may
; be found in the AUTHORS file in the root of the source tree.
;
EXPORT |vp8_short_inv_walsh4x4_neon|
EXPORT |vp8_short_inv_walsh4x4_1_neon|
ARM
REQUIRE8
PRESERVE8
AREA |.text|, CODE, READONLY ; name this block of code
;short vp8_short_inv_walsh4x4_neon(short *input, short *output)
|vp8_short_inv_walsh4x4_neon| PROC
; read in all four lines of values: d0->d3
vldm.64 r0, {q0, q1}
; first for loop
vadd.s16 d4, d0, d3 ;a = [0] + [12]
vadd.s16 d5, d1, d2 ;b = [4] + [8]
vsub.s16 d6, d1, d2 ;c = [4] - [8]
vsub.s16 d7, d0, d3 ;d = [0] - [12]
vadd.s16 d0, d4, d5 ;a + b
vadd.s16 d1, d6, d7 ;c + d
vsub.s16 d2, d4, d5 ;a - b
vsub.s16 d3, d7, d6 ;d - c
vtrn.32 d0, d2 ;d0: 0 1 8 9
;d2: 2 3 10 11
vtrn.32 d1, d3 ;d1: 4 5 12 13
;d3: 6 7 14 15
vtrn.16 d0, d1 ;d0: 0 4 8 12
;d1: 1 5 9 13
vtrn.16 d2, d3 ;d2: 2 6 10 14
;d3: 3 7 11 15
; second for loop
vadd.s16 d4, d0, d3 ;a = [0] + [3]
vadd.s16 d5, d1, d2 ;b = [1] + [2]
vsub.s16 d6, d1, d2 ;c = [1] - [2]
vsub.s16 d7, d0, d3 ;d = [0] - [3]
vadd.s16 d0, d4, d5 ;e = a + b
vadd.s16 d1, d6, d7 ;f = c + d
vsub.s16 d2, d4, d5 ;g = a - b
vsub.s16 d3, d7, d6 ;h = d - c
vmov.i16 q2, #3
vadd.i16 q0, q0, q2 ;e/f += 3
vadd.i16 q1, q1, q2 ;g/h += 3
vshr.s16 q0, q0, #3 ;e/f >> 3
vshr.s16 q1, q1, #3 ;g/h >> 3
vtrn.32 d0, d2
vtrn.32 d1, d3
vtrn.16 d0, d1
vtrn.16 d2, d3
vstmia.16 r1!, {q0}
vstmia.16 r1!, {q1}
bx lr
ENDP ; |vp8_short_inv_walsh4x4_neon|
;short vp8_short_inv_walsh4x4_1_neon(short *input, short *output)
|vp8_short_inv_walsh4x4_1_neon| PROC
; load a full line into a neon register
vld1.16 {q0}, [r0]
; extract first element and replicate
vdup.16 q1, d0[0]
; add 3 to all values
vmov.i16 q2, #3
vadd.i16 q3, q1, q2
; right shift
vshr.s16 q3, q3, #3
; write it back
vstmia.16 r1!, {q3}
vstmia.16 r1!, {q3}
bx lr
ENDP ; |vp8_short_inv_walsh4x4_1_neon|
END
|
lda {m1}
sta $fe
lda {m1}+1
sta $ff
lda ($fe),y |
// Copyright (c) 2020 Can Boluk and contributors of the VTIL Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of VTIL Project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#include "amd64.hpp"
#include "flags.hpp"
namespace vtil::lifter::amd64
{
// Converts from x86_reg to register_cast, handling RIP.
//
static operand reg2op( x86_reg reg )
{
if ( reg == X86_REG_RIP ) return register_desc{ register_internal, 0, 64, 0, architecture_amd64 };
if ( reg == X86_REG_EIP ) return register_desc{ register_internal, 0, 32, 0, architecture_amd64 };
if ( reg == X86_REG_IP ) return register_desc{ register_internal, 0, 8, 0, architecture_amd64 };
return register_cast<x86_reg>{}( reg );
}
// Create a series of instructions representing memory displacement given the current operand and basic block.
//
register_desc get_disp_from_operand(basic_block* block, const operand_info& operand)
{
// Avoid temporary register if only base is used without displacement.
if (operand.mem.base != X86_REG_INVALID &&
operand.mem.index == X86_REG_INVALID &&
operand.mem.disp == 0)
{
return register_cast<x86_reg>{}(operand.mem.base);
}
// Create a temporary register to store the current displacement.
auto current_offs = block->tmp(64);
if ( operand.mem.index != X86_REG_INVALID )
{
block
// Move the index register into the offset
->mov(current_offs, reg2op(operand.mem.index));
if (operand.mem.scale > 1)
{
block
// Multiply it by the scale (unsigned).
->mul(current_offs, operand.mem.scale);
}
}
if ( operand.mem.base != X86_REG_INVALID )
{
if ( operand.mem.index == X86_REG_INVALID )
{
block
// Add the base offset.
->mov(current_offs, reg2op(operand.mem.base));
}
else
{
block
// Add the base offset.
->add(current_offs, reg2op(operand.mem.base));
}
}
if ( operand.mem.disp != 0 )
{
if ( operand.mem.index != X86_REG_INVALID || operand.mem.base != X86_REG_INVALID )
{
block
// Add the displacement offset.
->add(current_offs, operand.mem.disp);
}
else
{
block
// Move the displacement offset.
->mov(current_offs, operand.mem.disp);
}
}
// Return resulting temporary.
return current_offs;
}
// Load a register, immediate, or memory operand from the given instruction and operand index.
//
operand load_operand( basic_block* block, const instruction_info& insn, size_t idx )
{
// Grab the operand at the current index.
const auto& opr = insn.operands[ idx ];
// Check the type and return relevant value accordingly.
switch ( opr.type )
{
case X86_OP_IMM:
return { opr.imm, opr.size * 8 };
case X86_OP_REG:
return reg2op( opr.reg );
case X86_OP_MEM:
{
auto tmp = block->tmp( opr.size * 8 );
block
->ldd( tmp, get_disp_from_operand( block, opr ), 0 );
return { tmp };
}
default:
unreachable();
}
}
// Store to a register or memory operand given the instruction, block, operand index, and source operand.
//
void store_operand( basic_block* block, const instruction_info& insn, size_t idx, const operand& source )
{
// Grab the operand at the current index.
const auto& opr = insn.operands[ idx ];
// Check the type and return relevant value accordingly.
switch ( opr.type )
{
case X86_OP_REG:
{
operand op = reg2op( opr.reg );
if ( op.bit_count() == 32 )
{
operand op_hi = op;
op_hi.reg().bit_offset += 32;
block->mov( op_hi, 0ull );
}
block->mov( op, source );
break;
}
case X86_OP_MEM:
{
block->str( get_disp_from_operand( block, opr ), 0, source );
break;
}
case X86_OP_IMM:
default:
unreachable();
}
}
size_t lifter_t::process( basic_block* block, uint64_t vip, uint8_t* code )
{
const auto& insns = vtil::amd64::disasm( code, vip, 0 );
if ( insns.empty() )
{
handle_instruction( block, { .id = X86_INS_INVALID } );
return 0;
}
const auto& insn = insns[ 0 ];
code += insn.bytes.size();
batch_translator translator = { block };
lifter::operative::translator = &translator;
block->mov( reg2op( X86_REG_RIP ), vip + insn.bytes.size() );
// Validate operands:
//
constexpr auto is_valid = [ ] ( const auto& op )
{
return vtil::amd64::registers.is_generic( op ) ||
op == X86_REG_RIP || op == X86_REG_EIP || op == X86_REG_IP;
};
bool is_invalid = false;
for ( auto& operand : insn.operands )
{
if ( operand.type == X86_OP_REG && !is_valid( operand.reg ) )
{
is_invalid = true;
break;
}
else if ( operand.type == X86_OP_MEM )
{
if ( operand.mem.base != X86_REG_INVALID && !is_valid( operand.mem.base ) )
{
is_invalid = true;
break;
}
else if ( operand.mem.index != X86_REG_INVALID && !is_valid( operand.mem.index ) )
{
is_invalid = true;
break;
}
}
}
// If is invalid or could not handle:
//
if ( is_invalid || !handle_instruction( block, insn ) )
{
// Hint all side effects.
//
for ( auto& operand : insn.operands )
{
if ( operand.type == X86_OP_REG && ( operand.access & CS_AC_READ ) )
block->vpinr( operand.reg );
if ( operand.type == X86_OP_MEM )
{
if ( operand.mem.base != X86_REG_INVALID )
block->vpinr( operand.mem.base );
if ( operand.mem.index != X86_REG_INVALID )
block->vpinr( operand.mem.index );
}
}
for ( auto& reg : insn.regs_read )
block->vpinr( ( x86_reg ) reg );
for ( auto byte : insn.bytes )
block->vemit( byte );
for ( auto& reg : insn.regs_write )
block->vpinw( ( x86_reg ) reg );
for ( auto& operand : insn.operands )
if ( operand.type == X86_OP_REG && ( operand.access & CS_AC_WRITE ) )
block->vpinw( operand.reg );
if ( insn.eflags & X86_EFLAGS_MODIFY_CF ) block->vpinw( flags::CF );
if ( insn.eflags & X86_EFLAGS_MODIFY_DF ) block->vpinw( flags::DF );
if ( insn.eflags & X86_EFLAGS_MODIFY_OF ) block->vpinw( flags::OF );
if ( insn.eflags & X86_EFLAGS_MODIFY_ZF ) block->vpinw( flags::ZF );
if ( insn.eflags & X86_EFLAGS_MODIFY_PF ) block->vpinw( flags::PF );
if ( insn.eflags & X86_EFLAGS_MODIFY_AF ) block->vpinw( flags::AF );
if ( insn.eflags & X86_EFLAGS_MODIFY_SF ) block->vpinw( flags::SF );
if ( insn.eflags & X86_EFLAGS_MODIFY_IF ) block->vpinw( flags::IF );
}
// Enforce undefined bits.
//
if ( insn.eflags & X86_EFLAGS_UNDEFINED_OF ) block->mov( flags::OF, UNDEFINED );
if ( insn.eflags & X86_EFLAGS_UNDEFINED_SF ) block->mov( flags::SF, UNDEFINED );
if ( insn.eflags & X86_EFLAGS_UNDEFINED_ZF ) block->mov( flags::ZF, UNDEFINED );
if ( insn.eflags & X86_EFLAGS_UNDEFINED_PF ) block->mov( flags::PF, UNDEFINED );
if ( insn.eflags & X86_EFLAGS_UNDEFINED_AF ) block->mov( flags::AF, UNDEFINED );
if ( insn.eflags & X86_EFLAGS_UNDEFINED_CF ) block->mov( flags::CF, UNDEFINED );
return insn.bytes.size();
}
};
|
dnl AMD64 mpn_mod_1_1p
dnl Contributed to the GNU project by Torbjörn Granlund and Niels Möller.
dnl Copyright 2009-2012 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C AMD K8,K9 6
C AMD K10 6
C Intel P4 26
C Intel core2 12.5
C Intel NHM 11.3
C Intel SBR 8.4 (slowdown, old code took 8.0)
C Intel atom 26
C VIA nano 13
define(`B2mb', `%r10')
define(`B2modb', `%r11')
define(`ap', `%rdi')
define(`n', `%rsi')
define(`pre', `%r8')
define(`b', `%rbx')
define(`r0', `%rbp') C r1 kept in %rax
define(`r2', `%rcx') C kept negated. Also used as shift count
define(`t0', `%r9')
C mp_limb_t
C mpn_mod_1_1p (mp_srcptr ap, mp_size_t n, mp_limb_t b, mp_limb_t bmodb[4])
C %rdi %rsi %rdx %rcx
C The pre array contains bi, cnt, B1modb, B2modb
C Note: This implementation needs B1modb only when cnt > 0
C The iteration is almost as follows,
C
C r_2 B^3 + r_1 B^2 + r_0 B + u = r_1 B2modb + (r_0 + r_2 B2mod) B + u
C
C where r2 is a single bit represented as a mask. But to make sure that the
C result fits in two limbs and a bit, carry from the addition
C
C r_0 + r_2 B2mod
C
C is handled specially. On carry, we subtract b to cancel the carry,
C and we use instead the value
C
C r_0 + B2mb (mod B)
C
C This addition can be issued early since it doesn't depend on r2, and it is
C the source of the cmov in the loop.
C
C We have the invariant that r_2 B^2 + r_1 B + r_0 < B^2 + B b
ABI_SUPPORT(DOS64)
ABI_SUPPORT(STD64)
ASM_START()
TEXT
ALIGN(16)
PROLOGUE(mpn_mod_1_1p)
FUNC_ENTRY(4)
push %rbp
push %rbx
mov %rdx, b
mov %rcx, pre
mov -8(ap, n, 8), %rax
cmp $3, n
jnc L(first)
mov -16(ap, n, 8), r0
jmp L(reduce_two)
L(first):
C First iteration, no r2
mov 24(pre), B2modb
mul B2modb
mov -24(ap, n, 8), r0
add %rax, r0
mov -16(ap, n, 8), %rax
adc %rdx, %rax
sbb r2, r2
sub $4, n
jc L(reduce_three)
mov B2modb, B2mb
sub b, B2mb
ALIGN(16)
L(top): and B2modb, r2
lea (B2mb, r0), t0
mul B2modb
add r0, r2
mov (ap, n, 8), r0
cmovc t0, r2
add %rax, r0
mov r2, %rax
adc %rdx, %rax
sbb r2, r2
sub $1, n
jnc L(top)
L(reduce_three):
C Eliminate r2
and b, r2
sub r2, %rax
L(reduce_two):
mov 8(pre), R32(%rcx)
test R32(%rcx), R32(%rcx)
jz L(normalized)
C Unnormalized, use B1modb to reduce to size < B (b+1)
mulq 16(pre)
xor t0, t0
add %rax, r0
adc %rdx, t0
mov t0, %rax
C Left-shift to normalize
ifdef(`SHLD_SLOW',`
shl R8(%rcx), %rax
mov r0, t0
neg R32(%rcx)
shr R8(%rcx), t0
or t0, %rax
neg R32(%rcx)
',`
shld R8(%rcx), r0, %rax
')
shl R8(%rcx), r0
jmp L(udiv)
L(normalized):
mov %rax, t0
sub b, t0
cmovnc t0, %rax
L(udiv):
lea 1(%rax), t0
mulq (pre)
add r0, %rax
adc t0, %rdx
imul b, %rdx
sub %rdx, r0
cmp r0, %rax
lea (b, r0), %rax
cmovnc r0, %rax
cmp b, %rax
jnc L(fix)
L(ok): shr R8(%rcx), %rax
pop %rbx
pop %rbp
FUNC_EXIT()
ret
L(fix): sub b, %rax
jmp L(ok)
EPILOGUE()
ALIGN(16)
PROLOGUE(mpn_mod_1_1p_cps)
FUNC_ENTRY(2)
push %rbp
bsr %rsi, %rcx
push %rbx
mov %rdi, %rbx
push %r12
xor $63, R32(%rcx)
mov %rsi, %r12
mov R32(%rcx), R32(%rbp)
sal R8(%rcx), %r12
IFSTD(` mov %r12, %rdi ') C pass parameter
IFDOS(` mov %r12, %rcx ') C pass parameter
CALL( mpn_invert_limb)
neg %r12
mov %r12, %r8
mov %rax, (%rbx) C store bi
mov %rbp, 8(%rbx) C store cnt
imul %rax, %r12
mov %r12, 24(%rbx) C store B2modb
mov R32(%rbp), R32(%rcx)
test R32(%rcx), R32(%rcx)
jz L(z)
mov $1, R32(%rdx)
ifdef(`SHLD_SLOW',`
C Destroys %rax, unlike shld. Otherwise, we could do B1modb
C before B2modb, and get rid of the move %r12, %r8 above.
shl R8(%rcx), %rdx
neg R32(%rcx)
shr R8(%rcx), %rax
or %rax, %rdx
neg R32(%rcx)
',`
shld R8(%rcx), %rax, %rdx
')
imul %rdx, %r8
shr R8(%rcx), %r8
mov %r8, 16(%rbx) C store B1modb
L(z):
pop %r12
pop %rbx
pop %rbp
FUNC_EXIT()
ret
EPILOGUE()
ASM_END()
|
; A315632: Coordination sequence Gal.5.112.5 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; 1,6,12,16,20,24,28,34,40,46,52,56,60,64,68,74,80,86,92,96,100,104,108,114,120,126,132,136,140,144,148,154,160,166,172,176,180,184,188,194,200,206,212,216,220,224,228,234,240,246
mov $4,$0
mov $5,$0
add $5,1
lpb $5
mov $0,$4
sub $5,1
sub $0,$5
add $0,4
bin $0,2
mov $2,2
lpb $0
div $0,$2
mod $0,2
mul $0,2
add $0,7
mov $3,$2
add $3,2
mov $6,2
sub $6,$3
sub $0,$6
lpe
mul $0,2
mov $6,$0
sub $6,12
div $6,2
add $6,1
add $1,$6
lpe
|
; A056220: a(n) = 2*n^2 - 1.
; -1,1,7,17,31,49,71,97,127,161,199,241,287,337,391,449,511,577,647,721,799,881,967,1057,1151,1249,1351,1457,1567,1681,1799,1921,2047,2177,2311,2449,2591,2737,2887,3041,3199,3361,3527,3697,3871,4049,4231,4417,4607,4801,4999,5201,5407,5617,5831,6049,6271,6497,6727,6961,7199,7441,7687,7937,8191,8449,8711,8977,9247,9521,9799,10081,10367,10657,10951,11249,11551,11857,12167,12481,12799,13121,13447,13777,14111,14449,14791,15137,15487,15841,16199,16561,16927,17297,17671,18049,18431,18817,19207,19601,19999,20401,20807,21217,21631,22049,22471,22897,23327,23761,24199,24641,25087,25537,25991,26449,26911,27377,27847,28321,28799,29281,29767,30257,30751,31249,31751,32257,32767,33281,33799,34321,34847,35377,35911,36449,36991,37537,38087,38641,39199,39761,40327,40897,41471,42049,42631,43217,43807,44401,44999,45601,46207,46817,47431,48049,48671,49297,49927,50561,51199,51841,52487,53137,53791,54449,55111,55777,56447,57121,57799,58481,59167,59857,60551,61249,61951,62657,63367,64081,64799,65521,66247,66977,67711,68449,69191,69937,70687,71441,72199,72961,73727,74497,75271,76049,76831,77617,78407,79201,79999,80801,81607,82417,83231,84049,84871,85697,86527,87361,88199,89041,89887,90737,91591,92449,93311,94177,95047,95921,96799,97681,98567,99457,100351,101249,102151,103057,103967,104881,105799,106721,107647,108577,109511,110449,111391,112337,113287,114241,115199,116161,117127,118097,119071,120049,121031,122017,123007,124001
pow $0,2
mul $0,2
sub $0,1
mov $1,$0
|
; A038572: a(n) = n rotated one binary place to the right.
; 0,1,1,3,2,6,3,7,4,12,5,13,6,14,7,15,8,24,9,25,10,26,11,27,12,28,13,29,14,30,15,31,16,48,17,49,18,50,19,51,20,52,21,53,22,54,23,55,24,56,25,57,26,58,27,59,28,60,29,61,30,62,31,63,32,96,33,97,34,98,35,99,36,100,37,101,38,102,39,103,40,104,41,105,42,106,43,107,44,108,45,109,46,110,47,111,48,112,49,113,50,114,51,115,52,116,53,117,54,118,55,119,56,120,57,121,58,122,59,123,60,124,61,125,62,126,63,127,64,192,65,193,66,194,67,195,68,196,69,197,70,198,71,199,72,200,73,201,74,202,75,203,76,204,77,205,78,206,79,207,80,208,81,209,82,210,83,211,84,212,85,213,86,214,87,215,88,216,89,217,90,218,91,219,92,220,93,221,94,222,95,223,96,224,97,225,98,226,99,227,100,228,101,229,102,230,103,231,104,232,105,233,106,234,107,235,108,236,109,237,110,238,111,239,112,240,113,241,114,242,115,243,116,244,117,245,118,246,119,247,120,248,121,249,122,250,123,251,124,252
mov $3,$0
div $0,2
mod $3,2
mov $2,$3
mov $4,$0
lpb $4,1
mul $2,2
div $4,2
lpe
sub $0,1
add $0,$2
mov $1,$0
add $1,1
|
;******************************************************************************
;* Copyright (c) 2010 David Conrad
;*
;* This file is part of FFmpeg.
;*
;* FFmpeg is free software; you can redistribute it and/or
;* modify it under the terms of the GNU Lesser General Public
;* License as published by the Free Software Foundation; either
;* version 2.1 of the License, or (at your option) any later version.
;*
;* FFmpeg is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;* Lesser General Public License for more details.
;*
;* You should have received a copy of the GNU Lesser General Public
;* License along with FFmpeg; if not, write to the Free Software
;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;******************************************************************************
%include "libavutil/x86/x86util.asm"
SECTION_RODATA
pw_7: times 8 dw 7
cextern pw_3
cextern pw_16
cextern pw_32
cextern pb_80
section .text
%macro UNPACK_ADD 6
mov%5 %1, %3
mov%6 m5, %4
mova m4, %1
mova %2, m5
punpcklbw %1, m7
punpcklbw m5, m7
punpckhbw m4, m7
punpckhbw %2, m7
paddw %1, m5
paddw %2, m4
%endmacro
%macro HPEL_FILTER 1
; dirac_hpel_filter_v_sse2(uint8_t *dst, uint8_t *src, int stride, int width);
cglobal dirac_hpel_filter_v_%1, 4,6,8, dst, src, stride, width, src0, stridex3
mov src0q, srcq
lea stridex3q, [3*strideq]
sub src0q, stridex3q
pxor m7, m7
.loop:
; 7*(src[0] + src[1])
UNPACK_ADD m0, m1, [srcq], [srcq + strideq], a,a
pmullw m0, [pw_7]
pmullw m1, [pw_7]
; 3*( ... + src[-2] + src[3])
UNPACK_ADD m2, m3, [src0q + strideq], [srcq + stridex3q], a,a
paddw m0, m2
paddw m1, m3
pmullw m0, [pw_3]
pmullw m1, [pw_3]
; ... - 7*(src[-1] + src[2])
UNPACK_ADD m2, m3, [src0q + strideq*2], [srcq + strideq*2], a,a
pmullw m2, [pw_7]
pmullw m3, [pw_7]
psubw m0, m2
psubw m1, m3
; ... - (src[-3] + src[4])
UNPACK_ADD m2, m3, [src0q], [srcq + strideq*4], a,a
psubw m0, m2
psubw m1, m3
paddw m0, [pw_16]
paddw m1, [pw_16]
psraw m0, 5
psraw m1, 5
packuswb m0, m1
mova [dstq], m0
add dstq, mmsize
add srcq, mmsize
add src0q, mmsize
sub widthd, mmsize
jg .loop
RET
; dirac_hpel_filter_h_sse2(uint8_t *dst, uint8_t *src, int width);
cglobal dirac_hpel_filter_h_%1, 3,3,8, dst, src, width
dec widthd
pxor m7, m7
and widthd, ~(mmsize-1)
.loop:
; 7*(src[0] + src[1])
UNPACK_ADD m0, m1, [srcq + widthq], [srcq + widthq + 1], u,u
pmullw m0, [pw_7]
pmullw m1, [pw_7]
; 3*( ... + src[-2] + src[3])
UNPACK_ADD m2, m3, [srcq + widthq - 2], [srcq + widthq + 3], u,u
paddw m0, m2
paddw m1, m3
pmullw m0, [pw_3]
pmullw m1, [pw_3]
; ... - 7*(src[-1] + src[2])
UNPACK_ADD m2, m3, [srcq + widthq - 1], [srcq + widthq + 2], u,u
pmullw m2, [pw_7]
pmullw m3, [pw_7]
psubw m0, m2
psubw m1, m3
; ... - (src[-3] + src[4])
UNPACK_ADD m2, m3, [srcq + widthq - 3], [srcq + widthq + 4], u,u
psubw m0, m2
psubw m1, m3
paddw m0, [pw_16]
paddw m1, [pw_16]
psraw m0, 5
psraw m1, 5
packuswb m0, m1
mova [dstq + widthq], m0
sub widthd, mmsize
jge .loop
RET
%endmacro
%macro PUT_RECT 1
; void put_rect_clamped(uint8_t *dst, int dst_stride, int16_t *src, int src_stride, int width, int height)
cglobal put_signed_rect_clamped_%1, 5,9,3, dst, dst_stride, src, src_stride, w, dst2, src2
mova m0, [pb_80]
add wd, (mmsize-1)
and wd, ~(mmsize-1)
%if ARCH_X86_64
movsxd dst_strideq, dst_strided
movsxd src_strideq, src_strided
mov r7d, r5m
mov r8d, wd
%define wspill r8d
%define hd r7d
%else
mov r4m, wd
%define wspill r4m
%define hd r5mp
%endif
.loopy
lea src2q, [srcq+src_strideq*2]
lea dst2q, [dstq+dst_strideq]
.loopx:
sub wd, mmsize
mova m1, [srcq +2*wq]
mova m2, [src2q+2*wq]
packsswb m1, [srcq +2*wq+mmsize]
packsswb m2, [src2q+2*wq+mmsize]
paddb m1, m0
paddb m2, m0
mova [dstq +wq], m1
mova [dst2q+wq], m2
jg .loopx
lea srcq, [srcq+src_strideq*4]
lea dstq, [dstq+dst_strideq*2]
sub hd, 2
mov wd, wspill
jg .loopy
RET
%endm
%macro ADD_RECT 1
; void add_rect_clamped(uint8_t *dst, uint16_t *src, int stride, int16_t *idwt, int idwt_stride, int width, int height)
cglobal add_rect_clamped_%1, 7,9,3, dst, src, stride, idwt, idwt_stride, w, h
mova m0, [pw_32]
add wd, (mmsize-1)
and wd, ~(mmsize-1)
%if ARCH_X86_64
movsxd strideq, strided
movsxd idwt_strideq, idwt_strided
mov r8d, wd
%define wspill r8d
%else
mov r5m, wd
%define wspill r5m
%endif
.loop:
sub wd, mmsize
movu m1, [srcq +2*wq] ; FIXME: ensure alignment
paddw m1, m0
psraw m1, 6
movu m2, [srcq +2*wq+mmsize] ; FIXME: ensure alignment
paddw m2, m0
psraw m2, 6
paddw m1, [idwtq+2*wq]
paddw m2, [idwtq+2*wq+mmsize]
packuswb m1, m2
mova [dstq +wq], m1
jg .loop
lea srcq, [srcq + 2*strideq]
add dstq, strideq
lea idwtq, [idwtq+ 2*idwt_strideq]
sub hd, 1
mov wd, wspill
jg .loop
RET
%endm
%macro ADD_OBMC 2
; void add_obmc(uint16_t *dst, uint8_t *src, int stride, uint8_t *obmc_weight, int yblen)
cglobal add_dirac_obmc%1_%2, 6,6,5, dst, src, stride, obmc, yblen
pxor m4, m4
.loop:
%assign i 0
%rep %1 / mmsize
mova m0, [srcq+i]
mova m1, m0
punpcklbw m0, m4
punpckhbw m1, m4
mova m2, [obmcq+i]
mova m3, m2
punpcklbw m2, m4
punpckhbw m3, m4
pmullw m0, m2
pmullw m1, m3
movu m2, [dstq+2*i]
movu m3, [dstq+2*i+mmsize]
paddw m0, m2
paddw m1, m3
movu [dstq+2*i], m0
movu [dstq+2*i+mmsize], m1
%assign i i+mmsize
%endrep
lea srcq, [srcq+strideq]
lea dstq, [dstq+2*strideq]
add obmcq, 32
sub yblend, 1
jg .loop
RET
%endm
INIT_MMX
%if ARCH_X86_64 == 0
PUT_RECT mmx
ADD_RECT mmx
HPEL_FILTER mmx
ADD_OBMC 32, mmx
ADD_OBMC 16, mmx
%endif
ADD_OBMC 8, mmx
INIT_XMM
PUT_RECT sse2
ADD_RECT sse2
HPEL_FILTER sse2
ADD_OBMC 32, sse2
ADD_OBMC 16, sse2
|
.MODEL SMALL
.STACK
.DATA
MSG1 DB 10,13, 'Enter First Number: $'
MSG2 DB 10,13, 'Enter Second Number: $'
MSG3 DB 10,13, 'SUM: $'
MSG4 DB 10,13, 'DIFFERENCE: $'
MSG5 DB 10,13, 'PRODUCT: $'
MSG6 DB 10,13, 'QUOTIENT: $'
NEGA DB '-$'
NUM1 DB 0
NUM2 DB 0
DIG1 DB 0
DIG2 DB 0
ANS DB 0
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
ENT1:
MOV DX,OFFSET MSG1 ;display prompt for first number
MOV AH,09H
int 21h
MOV AH,01H ;input first number
INT 21H
CMP AL,'0' ;check if it is in range from 0 - 9
JB ENT1
CMP AL,'9'
JA ENT1
SUB AL,30H ;convert to real number entered
MOV DIG1,AL
MOV AH,01H ;input first number
INT 21H
CMP AL,'0' ;check if it is in range from 0 - 9
JB ENT1
CMP AL,'9'
JA ENT1
SUB AL,30H ;convert to real number entered
MOV DIG2,AL
MOV AL,DIG1 ;convert 1st digit to tens place
MOV BL,10
MUL BL
MOV NUM1,AL ;add 1st digit to 2nd digit
MOV AL,DIG2
ADD NUM1,AL
ENT2:
MOV DX,OFFSET MSG2 ;display prompt for second number
MOV AH,09H
int 21h
MOV AH,01H ;input second number
INT 21H
CMP AL,'0' ;check if it is in range from 0 - 9
JB ENT2
CMP AL,'9'
JA ENT2
SUB AL,30H ; convert to real number entered
MOV DIG1,AL
MOV AH,01H ;input second number
INT 21H
CMP AL,'0' ;check if it is in range from 0 - 9
JB ENT2
CMP AL,'9'
JA ENT2
SUB AL,30H ;convert to real number entered
MOV DIG2,AL
MOV AL,DIG1
MOV BL,10
MUL BL
MOV NUM2,AL
MOV AL,DIG2
ADD NUM2,AL
ADDITION:
MOV BL,NUM1
ADD BL,NUM2
CALL CHANGE
MOV DX,OFFSET MSG3
CALL RESULT
SUBTRACTION:
MOV BL, NUM1
CMP BL, NUM2
JL LESS
SUB BL, NUM2
CALL CHANGE
MOV DX,OFFSET MSG4
CALL RESULT
LESS:
MOV BL, NUM2
SUB BL, NUM1
CALL CHANGE
MOV DX, OFFSET MSG4
MOV AH,09H
int 21h
MOV DX, OFFSET NEGA
CALL RESULT
MOV AH,4CH ; exit to DOS
INT 21H
MAIN ENDP
CHANGE PROC
MOV AH,0
MOV AL,BL
MOV BL,10
DIV BL
MOV BL,AL
MOV BH,AH
ADD BH,30H ; convert to ascii code
MOV ANS,BH
MOV AH,0
MOV AL,BL
MOV BL,10
DIV BL
MOV BL,AL
MOV BH,AH
ADD BH,30h ; convert to ascii code
ADD BL, 30h ; covert to ascii code
RET
CHANGE ENDP
RESULT PROC
MOV AH,09H
INT 21H
MOV DL,BL
MOV AH,02H
INT 21H
MOV DL,BH
MOV AH,02H
INT 21H
MOV DL,ANS
MOV AH,02H
INT 21H
RET
RESULT ENDP
END
|
#ifndef __SEGMENT2DFROMPDG_CXX__
#define __SEGMENT2DFROMPDG_CXX__
#include "larcv/core/DataFormat/EventVoxel2D.h"
#include "larcv/core/DataFormat/EventImage2D.h"
#include "larcv/core/DataFormat/EventParticle.h"
#include "Segment2DFromPDG.h"
#include "ImageMod.h"
namespace larcv {
static Segment2DFromPDGProcessFactory __global_Segment2DFromPDGProcessFactory__;
Segment2DFromPDG::Segment2DFromPDG(const std::string name)
: ProcessBase(name)
{}
void Segment2DFromPDG::configure(const PSet& cfg)
{
_output_producer = cfg.get<std::string>( "OutputImage" );
_label_producer = cfg.get<std::string>( "OutputSegment" );
_weight_producer = cfg.get<std::string>( "OutputWeight", "");
_input_producer = cfg.get<std::string>( "InputImage" );
_cluster_producer = cfg.get<std::string>( "InputCluster" );
_particle_producer = cfg.get<std::string>( "InputParticle" );
_dist_surrounding = cfg.get<size_t>( "DistSurrounding");
_projection_v = cfg.get<std::vector<size_t> >("Projection" );
_label_type = (LabelType_t)(cfg.get<unsigned short>("LabelType"));
std::vector<int> empty_list;
std::vector<std::set<int> > pdg_list;
while (true) {
std::string param_name = "ParticleSet" + std::to_string(pdg_list.size());
auto another_set = cfg.get<std::vector<int> >(param_name, empty_list);
if (another_set.empty() && pdg_list.size()) break;
for (size_t i = 0; i < pdg_list.size(); ++i) {
for (auto const& pdg : another_set) {
if (pdg_list[i].find(pdg) == pdg_list[i].end()) continue;
LARCV_CRITICAL() << param_name << " includes PDG " << pdg
<< " which was already used in ParticleSet" << i << std::endl;
throw larbys();
}
}
std::set<int> temp_pdg_list;
for (auto const& pdg : another_set) temp_pdg_list.insert(pdg);
pdg_list.emplace_back(std::move(temp_pdg_list));
}
_pdg_list.clear();
_pdg_list.resize(pdg_list.size());
for (size_t class_index = 0; class_index < pdg_list.size(); ++class_index) {
LARCV_INFO() << "Assining to class " << class_index << " ... " << std::flush;
for (auto pdg : pdg_list[class_index]) {
_pdg_list[class_index].push_back(pdg);
LARCV_INFO() << pdg << " ";
}
LARCV_INFO() << std::endl;
}
}
void Segment2DFromPDG::initialize()
{}
larcv::Image2D
Segment2DFromPDG::CreateSegment2D(const larcv::ClusterPixel2D& cluster_v,
const larcv::ParticleSet& particle_v) {
// Ignore pdgcode==0 (last boolean)
auto label_v = Image2DByParticlePDG( cluster_v, particle_v, _pdg_list, true, true );
std::vector<float> data;
data.resize(label_v.front().meta().size(), 0.);
switch (_label_type) {
case kOverwrite:
for (size_t i = 0; i < data.size(); ++i) {
size_t label_class = 0;
for (size_t j = 0; j < label_v.size(); ++j)
if (label_v[j].as_vector()[i] > 0.) label_class = (j + 1);
data[i] = label_class;
}
break;
case kPixelValue:
for (size_t i = 0; i < data.size(); ++i) {
size_t label_class = 0;
float max_q = 0;
for (size_t j = 0; j < label_v.size(); ++j) {
if (label_v[j].as_vector()[i] <= max_q) continue;
max_q = label_v[j].as_vector()[i];
label_class = (j + 1);
}
data[i] = label_class;
}
break;
default:
LARCV_CRITICAL() << "LabelType_t " << (int)(_label_type) << " not supported..." << std::endl;
throw larbys();
}
larcv::ImageMeta meta(label_v.front().meta());
larcv::Image2D res(std::move(meta), std::move(data));
return res;
}
larcv::Image2D
Segment2DFromPDG::CreateWeight2D(const larcv::ClusterPixel2D& cluster_v,
const larcv::Image2D& input_image) {
// Ignore last cluster
auto weight_image = Weight2DFromPixelCount(cluster_v, false, 0, 1, 10);
// Mask irrlevant pixels
Mask(weight_image, input_image, 0.0, 0., false);
auto const& meta = weight_image.meta();
if (_boundary_data.size() != meta.size())
_boundary_data.resize(meta.size(), 0.);
for (auto& v : _boundary_data) v = 0.;
// Next, compute "surrounding pixels"
float surrounding_weight = 0;
int target_row, target_col;
int nrows = meta.rows();
int ncols = meta.cols();
size_t n_surrounding_pixel = 0;
bool flag = false;
for (int row = 0; row < nrows; ++row) {
for (int col = 0; col < ncols; ++col) {
float weight = (size_t)(weight_image.pixel(row, col));
if (weight > 0.)
continue;
flag = false;
for (target_row = (int)(row + _dist_surrounding); (int)(target_row + _dist_surrounding) >= row; --target_row) {
if (target_row >= nrows) continue;
if (target_row < 0) break;
for (target_col = (int)(col + _dist_surrounding); (int)(target_col + _dist_surrounding) >= col; --target_col) {
if (target_col >= ncols) continue;
if (target_col < 0) break;
weight = weight_image.pixel(target_row, target_col);
if (weight > 0.) {
flag = true;
break;
}
}
if (flag) break;
}
_boundary_data[meta.index(row, col)] = (flag ? 1. : 0.);
if (flag) ++n_surrounding_pixel;
}
}
if (n_surrounding_pixel)
surrounding_weight = 1. / (float)(n_surrounding_pixel);
LARCV_INFO() << "Found " << n_surrounding_pixel << " pixels surrounding non-zero pixels ..." << std::endl;
LARCV_INFO() << "Weight: " << surrounding_weight << std::endl;
int ahoaho=0;
for(auto const& v : _boundary_data) {
if(v<1) continue;
ahoaho += 1;
}
/*
auto weight_data = weight_image.move();
for (size_t idx = 0; idx < weight_data.size(); ++idx) {
if(_boundary_data[idx]<1) continue;
weight_data[idx] = surrounding_weight;
}
*/
auto weight_data = weight_image.move();
// Next, compute "background pixels"
size_t n_background_pixel = 0;
for (auto const& v : weight_data) {
if (v == 0.) n_background_pixel += 1;
}
float background_weight = 1. / (float)(n_background_pixel);
LARCV_INFO() <<"Background pixel count " << n_background_pixel << " weight = " << background_weight<<std::endl;
for (auto& v : weight_data) {
if (v == 0.) v = background_weight;
}
// Normalize
float sum = 0.;
for (auto const& v : weight_data) sum += v;
for (auto& v : weight_data) v /= sum;
weight_image.move(std::move(weight_data));
return weight_image;
}
bool Segment2DFromPDG::process(IOManager & mgr)
{
// Retrieve input
auto const& event_image = mgr.get_data<larcv::EventImage2D> ( _input_producer );
auto const& event_cluster = mgr.get_data<larcv::EventClusterPixel2D> ( _cluster_producer );
auto const& event_particle = mgr.get_data<larcv::EventParticle> ( _particle_producer );
for (size_t input_index = 0; input_index < event_image.as_vector().size(); ++input_index) {
auto const& input_image = event_image.as_vector()[input_index];
auto const& input_meta = input_image.meta();
auto const& cluster_v = event_cluster.cluster_pixel_2d(input_meta.id());
// Check if this projection should be skipped or not
if (!_projection_v.empty()) {
bool skip = true;
for (auto const& p : _projection_v) {
if (p != input_meta.id()) continue;
skip = false;
break;
}
if (skip) {
LARCV_INFO() << "Skipping projection " << input_meta.id() << std::endl;
continue;
}
}
// Create output name suffix
std::string suffix = "_projection" + std::to_string((int)(input_meta.id()));
// Save output
auto& output_image = mgr.get_data<larcv::EventImage2D> (_output_producer + suffix);
output_image.append(input_image);
// Create label image
auto segment_image = CreateSegment2D(cluster_v, event_particle);
// Mask label by data
Mask(segment_image, input_image, 0.0, 0., false);
// Save output
auto& output_segment = mgr.get_data<larcv::EventImage2D> (_label_producer + suffix);
output_segment.emplace(std::move(segment_image));
// Create weight image (if requested)
if (!_weight_producer.empty()) {
// Ignore last cluster
auto weight_image = CreateWeight2D(cluster_v, input_image);
// Save output
auto& output_weight = mgr.get_data<larcv::EventImage2D> (_weight_producer + suffix);
output_weight.emplace(std::move(weight_image));
}
}
return true;
}
void Segment2DFromPDG::finalize()
{}
}
#endif
|
/*
============================================================================================
This file contains an implementation of a derived C++ Class from the abstract base class
in 'FEM_Interpolation.cc'.
NOTE: portions of this code are automatically generated!
Copyright (c) 01-31-2013, Shawn W. Walker
============================================================================================
*/
/*------------ BEGIN: Auto Generate ------------*/
// FEM interpolation is:
//
// geomOmega_X1*p_v1_t1_grad1 + geomOmega_X2*p_v1_t1_grad2, on Omega.
//
/*------------ END: Auto Generate ------------*/
/*------------ BEGIN: Auto Generate ------------*/
// define the name of the FEM interpolation (should be the same as the filename of this file)
#define SpecificFEM I_p
#define SpecificFEM_str "I_p"
// set the number of rows of the expression
#define ROW_NC 1
// set the number of columns of the expression
#define COL_NC 1
/*------------ END: Auto Generate ------------*/
/***************************************************************************************/
/* C++ (Specific) FEM interpolation class */
class SpecificFEM: public FEM_Interpolation_Class // derive from base class
{
public:
// pointers to arrays of interpolation data
// (lengths of those arrays correspond to number of interpolation points)
double* Interp_Data[ROW_NC][COL_NC];
/*------------ BEGIN: Auto Generate ------------*/
// access local mesh geometry info
const CLASS_geom_Omega_embedded_in_Omega_restricted_to_Omega* geom_Omega_embedded_in_Omega_restricted_to_Omega;
/*------------ END: Auto Generate ------------*/
/*------------ BEGIN: Auto Generate ------------*/
// pointers for accessing coefficient functions
const Data_Type_p_restricted_to_Omega* p_restricted_to_Omega;
const Data_Type_v_restricted_to_Omega* v_restricted_to_Omega;
/*------------ END: Auto Generate ------------*/
/*------------ BEGIN: Auto Generate ------------*/
// constructor
SpecificFEM (const unsigned int);
~SpecificFEM (); // destructor
void Init_Interpolation_Data_Arrays(const unsigned int);
void Eval_All_Interpolations (const unsigned int&);
/*------------ END: Auto Generate ------------*/
private:
/*------------ BEGIN: Auto Generate ------------*/
void Eval_Interp_00(double&);
/*------------ END: Auto Generate ------------*/
};
/***************************************************************************************/
/* constructor */
/*------------ BEGIN: Auto Generate ------------*/
SpecificFEM::SpecificFEM (const unsigned int Num_Interp_Points) :
/*------------ END: Auto Generate ------------*/
FEM_Interpolation_Class () // call the base class constructor
{
// set the 'Name' of the FEM interpolation
Name = (char*) SpecificFEM_str; // this should be the same as the Class identifier
// get the "matrix-valued"-ness of the interpolation
num_row = ROW_NC;
num_col = COL_NC;
// init the output data (MATLAB cell array)
Init_Interpolation_Data_Arrays(Num_Interp_Points);
}
/***************************************************************************************/
/***************************************************************************************/
/* destructor: should not usually need to be modified */
SpecificFEM::~SpecificFEM ()
{
}
/***************************************************************************************/
/***************************************************************************************/
/* this initializes the output data arrays that will contain the interpolation data */
void SpecificFEM::Init_Interpolation_Data_Arrays(const unsigned int Num_Interp_Points)
{
// create a cell array to contain the interpolation data (to be output to MATLAB eventually)
mwSize ndim = 2;
mwSize dims[2];
dims[0] = (mwSize) num_row;
dims[1] = (mwSize) num_col;
mxInterp_Data = mxCreateCellArray(ndim, dims);
// initialize the entries of the cell array with vector arrays (to be filled with interpolation data)
mwIndex SetIndex = 0; // init
mwIndex subs[2];
for (unsigned int ri = 0; (ri < num_row); ri++)
for (unsigned int ci = 0; (ci < num_col); ci++)
{
mxArray* Interp_Data_Vec = mxCreateDoubleMatrix((mwSize) Num_Interp_Points, 1, mxREAL);
// get the correct index
subs[0] = (mwIndex) ri;
subs[1] = (mwIndex) ci;
SetIndex = mxCalcSingleSubscript(mxInterp_Data, (mwSize) 2, subs);
mxSetCell(mxInterp_Data, SetIndex, Interp_Data_Vec);
// get pointer to interpolation data in the cell array
mxArray* TEMP = mxGetCell(mxInterp_Data, SetIndex);
Interp_Data[ri][ci] = mxGetPr(TEMP);
}
}
/***************************************************************************************/
/*------------ BEGIN: Auto Generate ------------*/
/***************************************************************************************/
/* evaluate all FEM interpolations */
void SpecificFEM::Eval_All_Interpolations (const unsigned int& Interp_Pt_Index)
{
// loop through the different sub-interpolations
Eval_Interp_00(Interp_Data[0][0][Interp_Pt_Index]);
}
/***************************************************************************************/
/*------------ END: Auto Generate ------------*/
/*------------ BEGIN: Auto Generate ------------*/
/***************************************************************************************/
/* evaluate component-wise interpolation expression */
void SpecificFEM::Eval_Interp_00(double& INTERP)
{
// Compute interpolation
// only one point for interpolation
for (unsigned int qp = 0; qp < 1; qp++)
INTERP = geom_Omega_embedded_in_Omega_restricted_to_Omega->Map_PHI[qp].v[0]*p_restricted_to_Omega->Func_f_Grad[0][qp].v[0]+geom_Omega_embedded_in_Omega_restricted_to_Omega->Map_PHI[qp].v[1]*p_restricted_to_Omega->Func_f_Grad[0][qp].v[1];
}
/***************************************************************************************/
/*------------ END: Auto Generate ------------*/
// remove those macros!
#undef SpecificFEM
#undef SpecificFEM_str
#undef ROW_NC
#undef COL_NC
/***/
|
; A139700: Binomial transform of [1, 30, 30, 30, ...].
; 1,31,91,211,451,931,1891,3811,7651,15331,30691,61411,122851,245731,491491,983011,1966051,3932131,7864291,15728611,31457251,62914531,125829091,251658211,503316451,1006632931,2013265891,4026531811,8053063651,16106127331
mov $1,2
pow $1,$0
sub $1,1
mul $1,30
add $1,1
|
#include <Interpreters/addMissingDefaults.h>
#include <Common/typeid_cast.h>
#include <DataTypes/NestedUtils.h>
#include <DataTypes/DataTypeArray.h>
#include <Columns/ColumnArray.h>
#include <Interpreters/inplaceBlockConversions.h>
#include <Core/Block.h>
#include <Storages/ColumnsDescription.h>
#include <Interpreters/ExpressionActions.h>
#include <Functions/IFunctionAdaptors.h>
#include <Functions/materialize.h>
namespace DB
{
ActionsDAGPtr addMissingDefaults(
const Block & header,
const NamesAndTypesList & required_columns,
const ColumnsDescription & columns,
ContextPtr context,
bool null_as_default)
{
auto actions = std::make_shared<ActionsDAG>(header.getColumnsWithTypeAndName());
auto & index = actions->getIndex();
/// For missing columns of nested structure, you need to create not a column of empty arrays, but a column of arrays of correct lengths.
/// First, remember the offset columns for all arrays in the block.
std::map<String, ActionsDAG::NodeRawConstPtrs> nested_groups;
for (size_t i = 0, size = header.columns(); i < size; ++i)
{
const auto & elem = header.getByPosition(i);
if (typeid_cast<const ColumnArray *>(&*elem.column))
{
String offsets_name = Nested::extractTableName(elem.name);
auto & group = nested_groups[offsets_name];
if (group.empty())
group.push_back(nullptr);
group.push_back(actions->getInputs()[i]);
}
}
FunctionOverloadResolverPtr func_builder_replicate = FunctionFactory::instance().get("replicate", context);
/// We take given columns from input block and missed columns without default value
/// (default and materialized will be computed later).
for (const auto & column : required_columns)
{
if (header.has(column.name))
continue;
if (columns.hasDefault(column.name))
continue;
String offsets_name = Nested::extractTableName(column.name);
if (nested_groups.count(offsets_name))
{
DataTypePtr nested_type = typeid_cast<const DataTypeArray &>(*column.type).getNestedType();
ColumnPtr nested_column = nested_type->createColumnConstWithDefaultValue(0);
const auto & constant = actions->addColumn({std::move(nested_column), nested_type, column.name});
auto & group = nested_groups[offsets_name];
group[0] = &constant;
index.push_back(&actions->addFunction(func_builder_replicate, group, constant.result_name));
continue;
}
/** It is necessary to turn a constant column into a full column, since in part of blocks (from other parts),
* it can be full (or the interpreter may decide that it is constant everywhere).
*/
auto new_column = column.type->createColumnConstWithDefaultValue(0);
const auto * col = &actions->addColumn({std::move(new_column), column.type, column.name});
index.push_back(&actions->materializeNode(*col));
}
/// Computes explicitly specified values by default and materialized columns.
if (auto dag = evaluateMissingDefaults(actions->getResultColumns(), required_columns, columns, context, true, null_as_default))
actions = ActionsDAG::merge(std::move(*actions), std::move(*dag));
else
/// Removes unused columns and reorders result.
/// The same is done in evaluateMissingDefaults if not empty dag is returned.
actions->removeUnusedActions(required_columns.getNames());
return actions;
}
}
|
; A097839: Chebyshev polynomials S(n,83).
; Submitted by Christian Krause
; 1,83,6888,571621,47437655,3936753744,326703123097,27112422463307,2250004361331384,186723249568041565,15495779709786118511,1285962992662679794848,106719432611292636853873,8856426943744626179076611,734976716898192680226504840,60994211075606247832620825109,5061784542558420377427301979207,420067122821273285078633443449072,34860509409623124241149148504293769,2893002213875898038730300692412933755,240084323242289914090373808321769207896,19924105826896186971462295790014431321613
lpb $0
sub $0,1
add $2,1
mov $1,$2
mul $1,81
add $3,$1
add $2,$3
lpe
mov $0,$2
add $0,1
|
SECTION code_fp_math48
PUBLIC _islessequal_callee
EXTERN cm48_sdccix_islessequal_callee
defc _islessequal_callee = cm48_sdccix_islessequal_callee
|
; A115286: a(n) = (1/6)*(n^6+3*n^4+12*n^3+8*n^2).
; 0,4,40,228,960,3200,8904,21560,46848,93420,173800,305404,511680,823368,1279880,1930800,2837504,4074900,5733288,7920340,10763200,14410704,19035720,24837608,32044800,40917500,51750504,64876140,80667328,99540760,121960200,148439904,179548160,215910948,258215720,307215300,363731904,428661280,502976968,587734680,684076800,793237004,916545000,1055431388,1211432640,1386196200,1581485704,1799186320,2041310208,2310002100,2607545000,2936366004,3299042240,3698306928,4137055560,4618352200,5145435904
mov $2,$0
pow $2,2
add $0,$2
pow $0,2
mov $3,$2
bin $3,3
add $0,$3
|
!!ARBfp1.0
# This is the fragment program for two
# component dependent data with no shading
# We need some temporary variables
TEMP temp1, temp2, temp3;
TEMP finalColor, finalOpacity;
# We are going to use the first
# texture coordinate
ATTRIB tex0 = fragment.texcoord[0];
# This is our output color
OUTPUT out = result.color;
# Look up the scalar values / gradient
# magnitude in the first volume
TEX temp1, tex0, texture[0], 3D;
# Swizzle this to use (a,r) as texture
# coordinates for color, and (g,b) for
# opacity
SWZ temp2, temp1, a, r, 1, 1;
SWZ temp3, temp1, g, b, 1, 1;
# Use the (a,r) coordinate to look up a
# final color in the second texture
# (this is a 2D texture)
TEX finalColor, temp2, texture[1], 2D;
# Use the (g,b) coordinate to look up a
# final opacity in the fourth texture
# (this is a 2D texture)
TEX finalOpacity, temp3, texture[3], 2D;
# Combine these into the result
MOV out, finalColor;
MOV out.w, finalOpacity.w;
END
|
db "JET@" ; species name
db "Its instinct is to"
next "bury itself in"
next "holes. It often"
page "steals the nesting"
next "holes of others to"
next "sleep in them.@"
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/platform_window/text_input_state.h"
namespace ui {
TextInputState::TextInputState()
: type(TEXT_INPUT_TYPE_NONE),
flags(TEXT_INPUT_FLAG_NONE),
selection_start(0),
selection_end(0),
composition_start(0),
composition_end(0),
can_compose_inline(false) {}
TextInputState::TextInputState(TextInputType type,
int flags,
const std::string& text,
int selection_start,
int selection_end,
int composition_start,
int composition_end,
bool can_compose_inline)
: type(type),
flags(flags),
text(text),
selection_start(selection_start),
selection_end(selection_end),
composition_start(composition_start),
composition_end(composition_end),
can_compose_inline(can_compose_inline) {}
TextInputState::TextInputState(const TextInputState& other) = default;
bool TextInputState::operator==(const TextInputState& other) const {
return type == other.type &&
flags == other.flags &&
text == other.text &&
selection_start == other.selection_start &&
selection_end == other.selection_end &&
composition_start == other.composition_start &&
composition_end == other.composition_end &&
can_compose_inline == other.can_compose_inline;
}
} // namespace ui
|
; A168670: Numbers that are congruent to {1, 8} mod 11.
; 1,8,12,19,23,30,34,41,45,52,56,63,67,74,78,85,89,96,100,107,111,118,122,129,133,140,144,151,155,162,166,173,177,184,188,195,199,206,210,217,221,228,232,239,243,250,254,261,265,272,276,283,287,294,298,305,309,316,320,327,331,338,342,349,353,360,364,371,375,382,386,393,397,404,408,415,419,426,430,437,441,448,452,459,463,470,474,481,485,492,496,503,507,514,518,525,529,536,540,547,551,558,562,569,573,580,584,591,595,602,606,613,617,624,628,635,639,646,650,657,661,668,672,679,683,690,694,701,705,712,716,723,727,734,738,745,749,756,760,767,771,778,782,789,793,800,804,811,815,822,826,833,837,844,848,855,859,866,870,877,881,888,892,899,903,910,914,921,925,932,936,943,947,954,958,965,969,976,980,987,991,998,1002,1009,1013,1020,1024,1031,1035,1042,1046,1053,1057,1064,1068,1075,1079,1086,1090,1097,1101,1108,1112,1119,1123,1130,1134,1141,1145,1152,1156,1163,1167,1174,1178,1185,1189,1196,1200,1207,1211,1218,1222,1229,1233,1240,1244,1251,1255,1262,1266,1273,1277,1284,1288,1295,1299,1306,1310,1317,1321,1328,1332,1339,1343,1350,1354,1361,1365,1372
mov $1,7
mul $1,$0
div $0,2
mul $0,3
add $1,1
sub $1,$0
|
; A120893: a(n) = 3*a(n-1) + 3*a(n-2) - a(n-3); a(0)=1, a(1)=1, a(2)=5.
; 1,1,5,17,65,241,901,3361,12545,46817,174725,652081,2433601,9082321,33895685,126500417,472105985,1761923521,6575588101,24540428881,91586127425,341804080817,1275630195845,4760716702561,17767236614401,66308229755041,247465682405765,923554499868017,3446752317066305,12863454768397201,48007066756522501,179164812257692801,668652182274248705,2495443916839302017,9313123485082959365,34757050023492535441,129715076608887182401,484103256412056194161,1806697949039337594245,6742688539745294182817
mov $1,2
lpb $0
sub $0,1
add $1,$2
add $2,$1
add $1,$2
lpe
add $1,1
div $1,3
mov $0,$1
|
[bits 64]
[org 0x14000B4D4]
jmp 0x140059080
|
/*!********************************************************************
Audacity: A Digital Audio Editor
@file CurlHandleManager.cpp
@brief Define a class responsible for reuse of CURL hanldes.
Dmitry Vedenko
**********************************************************************/
#include "CurlHandleManager.h"
#include <algorithm>
#include <sstream>
#include <wx/platinfo.h>
namespace audacity
{
namespace network_manager
{
namespace
{
void GetOSString (std::ostringstream& output, const wxPlatformInfo& platformInfo)
{
const wxOperatingSystemId osID = platformInfo.GetOperatingSystemId ();
if (osID & wxOS_WINDOWS)
output << "Windows ";
else if (osID & wxOS_MAC)
output << "MacOS ";
else if (osID & wxOS_UNIX_LINUX)
output << "Linux ";
else if (osID & wxOS_UNIX_FREEBSD)
output << "FreeBSD ";
else if (osID & wxOS_UNIX_OPENBSD)
output << "OpenBSD ";
else
output << "Other ";
output <<
platformInfo.GetOSMajorVersion () <<
"_" <<
platformInfo.GetOSMinorVersion () <<
"_" <<
platformInfo.GetOSMicroVersion() <<
"; ";
#if defined(__amd64__) || defined(__x86_64__) || defined(_M_X64)
output << "x64";
#elif defined(__i386__) || defined(i386) || defined(_M_IX86) || defined(_X86_) || defined(__THW_INTEL)
output << "x86";
#elif
output << "arm64";
#elif defined(arm) || defined(__arm__) || defined(ARM) || defined(_ARM_)
output << "arm";
#else
output << "unknown";
#endif
}
}
constexpr std::chrono::milliseconds CurlHandleManager::KEEP_ALIVE_IDLE;
constexpr std::chrono::milliseconds CurlHandleManager::KEEP_ALIVE_PROBE;
CurlHandleManager::Handle::Handle(CurlHandleManager* owner, CURL* handle, RequestVerb verb, std::string url) noexcept
: mHandle (handle),
mOwner (owner),
mVerb (verb),
mUrl (std::move (url)),
mHandleFromCache (handle != nullptr)
{
if (mHandle == nullptr)
mHandle = curl_easy_init ();
setOption (CURLOPT_URL, mUrl);
switch (verb)
{
case RequestVerb::Head:
setOption (CURLOPT_NOBODY, 1);
break;
case RequestVerb::Get:
// This is a default, no additional setup is needed
// We cache handles by the verb, so there is no need to
// reset the handle state
break;
case RequestVerb::Post:
setOption (CURLOPT_POST, 1);
break;
case RequestVerb::Put:
setOption (CURLOPT_UPLOAD, 1);
break;
case RequestVerb::Delete:
setOption (CURLOPT_CUSTOMREQUEST, "DELETE");
break;
}
setOption (CURLOPT_NOSIGNAL, 1L);
setOption (CURLOPT_SSL_VERIFYPEER, 1L);
setOption (CURLOPT_SSL_VERIFYHOST, 2L);
setOption (CURLOPT_ACCEPT_ENCODING, "");
}
CurlHandleManager::Handle::Handle (Handle&& rhs) noexcept
{
*this = std::move (rhs);
}
CurlHandleManager::Handle::~Handle () noexcept
{
if (mReuse)
mOwner->cacheHandle (*this);
else
curl_easy_cleanup (mHandle);
}
CurlHandleManager::Handle& CurlHandleManager::Handle::operator=(Handle&& rhs) noexcept
{
std::swap (mHandle, rhs.mHandle);
std::swap (mOwner, rhs.mOwner);
std::swap (mVerb, rhs.mVerb);
mUrl = std::move (rhs.mUrl);
mHeaders = std::move (rhs.mHeaders);
mReuse = rhs.mReuse;
rhs.mReuse = false;
return *this;
}
CURLcode CurlHandleManager::Handle::setOption (CURLoption option, const std::string& value) noexcept
{
return setOption (option, value.c_str ());
}
CURLcode CurlHandleManager::Handle::appendCookie (const Cookie& cookie) noexcept
{
return setOption(CURLOPT_COOKIE, "Set-Cookie: " + cookie.Name + "=" + cookie.Value);
}
CURLcode CurlHandleManager::Handle::appendCookies (const CookiesList& cookies)noexcept
{
for (const Cookie& cookie : cookies)
{
const CURLcode result = appendCookie (cookie);
if (result != CURLE_OK)
return result;
}
return CURLE_OK;
}
void CurlHandleManager::Handle::appendHeader (const Header& header)
{
if (header.hasSameName ("User-Agent"))
mUserAgentSet = true;
mHeaders.append(header.Name + ": " + header.Value);
}
void CurlHandleManager::Handle::appendHeaders (const HeadersList& headers)
{
for (const Header& header : headers)
appendHeader (header);
}
CurlHandleManager::Handle::Result CurlHandleManager::Handle::perform ()
{
if (!mUserAgentSet)
mHeaders.append ("User-Agent: " + mOwner->getUserAgent ());
CURLcode result = setOption (CURLOPT_HTTPHEADER, mHeaders.getCurlList ());
if (result != CURLE_OK)
return { result, std::string () };
char currentError[CURL_ERROR_SIZE] = {};
setOption(CURLOPT_ERRORBUFFER, currentError);
result = curl_easy_perform (mHandle);
mReuse = mReuse && result == CURLE_OK;
return { result, std::string (currentError) };
}
void CurlHandleManager::Handle::markKeepAlive ()
{
mReuse = true;
}
bool CurlHandleManager::Handle::isHandleFromCache () const noexcept
{
return mHandleFromCache;
}
unsigned CurlHandleManager::Handle::getHTTPCode () const noexcept
{
long code = 0;
if (CURLE_OK != curl_easy_getinfo(mHandle, CURLINFO_RESPONSE_CODE, &code))
return 0;
return code;
}
void CurlHandleManager::Handle::reset () noexcept
{
setOption (CURLOPT_COOKIELIST, nullptr);
setOption (CURLOPT_PROXY, nullptr);
setOption (CURLOPT_SSL_OPTIONS, 0);
mUserAgentSet = false;
}
CurlHandleManager::CurlHandleManager ()
{
std::ostringstream ss;
ss << "Audacity/" <<
AUDACITY_VERSION << "." <<
AUDACITY_RELEASE << "." <<
AUDACITY_REVISION <<
" (";
GetOSString (ss, wxPlatformInfo::Get ());
ss << ")";
mUserAgent = ss.str ();
}
CurlHandleManager::~CurlHandleManager ()
{
std::lock_guard<std::mutex> lock (mHandleCacheLock);
for (auto& cachedHandle : mHandleCache)
curl_easy_cleanup (cachedHandle.Handle);
}
void CurlHandleManager::setProxy (std::string proxy)
{
mProxy = std::move (proxy);
}
CurlHandleManager::Handle CurlHandleManager::getHandle (RequestVerb verb, const std::string& url)
{
Handle handle (this, getCurlHandleFromCache (verb, url), verb, url);
if (!mProxy.empty ())
{
handle.setOption (CURLOPT_PROXY, mProxy);
// If we use proxy, checking the CRL will likely break the SSL proxying
handle.setOption (CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
}
handle.setOption (CURLOPT_TCP_KEEPALIVE, 1L);
handle.setOption (CURLOPT_TCP_KEEPIDLE,
std::chrono::duration_cast<std::chrono::seconds> (KEEP_ALIVE_IDLE).count ()
);
handle.setOption (CURLOPT_TCP_KEEPINTVL,
std::chrono::duration_cast<std::chrono::seconds> (KEEP_ALIVE_PROBE).count ()
);
return handle;
}
std::string CurlHandleManager::getUserAgent () const
{
return mUserAgent;
}
CURL* CurlHandleManager::getCurlHandleFromCache (RequestVerb verb, const std::string& url)
{
std::lock_guard<std::mutex> lock (mHandleCacheLock);
cleanupHandlesCache ();
const std::string schemeAndDomain = GetSchemeAndDomain (url);
auto it = std::find_if (mHandleCache.begin (), mHandleCache.end (), [verb, schemeAndDomain](const CachedHandle& handle) {
return handle.Verb == verb && handle.SchemeAndDomain == schemeAndDomain;
});
if (it == mHandleCache.end ())
return nullptr;
CURL* handle = it->Handle;
mHandleCache.erase (it);
return handle;
}
void CurlHandleManager::cacheHandle (Handle& handle)
{
// Reset the state to the safe defaults
handle.reset ();
std::lock_guard<std::mutex> lock (mHandleCacheLock);
cleanupHandlesCache ();
mHandleCache.push_back ({
handle.mVerb,
GetSchemeAndDomain (handle.mUrl),
handle.mHandle,
RequestClock::now ()
});
}
void CurlHandleManager::cleanupHandlesCache ()
{
const RequestTimePoint timePoint = RequestClock::now ();
mHandleCache.erase (std::remove_if (mHandleCache.begin (), mHandleCache.end (), [timePoint](const CachedHandle& cachedHandle) {
return (timePoint - cachedHandle.RequestTime) >= KEEP_ALIVE_IDLE;
}), mHandleCache.end ());
}
std::string CurlHandleManager::GetSchemeAndDomain (const std::string& url)
{
const size_t schemeEndPosition = url.find ("://");
if (schemeEndPosition == std::string::npos) // Is url even valid?
return url;
const size_t domainStartPosition = schemeEndPosition + 3;
const size_t slashLocation = url.find ('/', domainStartPosition);
if (slashLocation == std::string::npos)
return url;
return url.substr (domainStartPosition, slashLocation - domainStartPosition);
}
}
}
|
#include "ntshell.h"
#include "ntopt.h"
#include "ntlibc.h"
#include "Arduino.h"
#include "ntshell_arduino.h"
USER_CALLBACK user_cb = NULL;
HardwareSerial* serialPtr = NULL;
// NOTE:
// int usrcmd_execute(const char *text)
// needs to be defined somewhere else, conventionally usrcmd_arduino.cpp
// look for this in the project sources.
#define INITCODE (0x4367)
#define SERIAL_READ(HANDLE, BUF, CNT) ((HANDLE)->func_read(BUF, CNT, (HANDLE)->extobj))
static ntshell_t ntshell;
static int func_read(char *buf, int cnt, void *extobj)
{
if (serialPtr->available())
{
return serialPtr->readBytes(buf, cnt);
}
else
{
return 0;
}
}
static int func_write(const char *buf, int cnt, void *extobj)
{
return serialPtr->write((const uint8_t*)buf, cnt);
}
static int func_callback(const char *text, void *extobj)
{
#if 0 // local testing.
ntshell_t *ntshell = (ntshell_t *)extobj;
//UNUSED_VARIABLE(ntshell);
//UNUSED_VARIABLE(extobj);
if (ntlibc_strlen(text) > 0) {
Serial.print("User input text:");
Serial.print(text);
Serial.print("\r\n");
}
return 0;
#else
return user_cb(text);
#endif
}
void initialize_shell(USER_CALLBACK cb, const char* prompt, HardwareSerial* serial)
{
// set the user callback function
user_cb = cb;
// set the serial port instance (HWSerial only) TODO: make this stream oriented !
serialPtr = serial;
// init shell with read/write/cb functions
ntshell_init(
&ntshell,
func_read,
func_write,
func_callback,
(void *)(&ntshell));
// set prompt if passed in
if(prompt != NULL)
{
ntshell_set_prompt(&ntshell, prompt);
}
}
void set_prompt(const char* prompt)
{
ntshell_set_prompt(&ntshell, prompt);
}
void poll_shell()
{
while(serialPtr->available())
{
if (ntshell.initcode != INITCODE) {
return;
}
unsigned char ch;
SERIAL_READ(&ntshell, (char *)&ch, sizeof(ch));
vtrecv_execute(&(ntshell.vtrecv), &ch, sizeof(ch));
}
}
|
; A284293: Numbers using only digits 1 and 6.
; Submitted by Jon Maiga
; 1,6,11,16,61,66,111,116,161,166,611,616,661,666,1111,1116,1161,1166,1611,1616,1661,1666,6111,6116,6161,6166,6611,6616,6661,6666,11111,11116,11161,11166,11611,11616,11661,11666,16111,16116,16161,16166,16611,16616
add $0,1
mov $2,1
lpb $0
mov $3,$0
mul $0,2
sub $0,1
div $0,4
mod $3,2
mul $3,$2
add $1,$3
mul $2,10
lpe
mul $1,15
mul $2,2
sub $2,$1
mov $0,$2
div $0,3
|
/*
* Copyright 2017 The Polycube Authors
*
* 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 "polycubed_core.h"
#include "config.h"
#include "rest_server.h"
#include "utils/netlink.h"
#include "server/Resources/Body/ListResource.h"
#include "server/Resources/Body/ParentResource.h"
#include "server/Resources/Body/LeafResource.h"
#include "server/Resources/Endpoint/ParentResource.h"
#include <pistache/client.h>
#include <regex>
using namespace Pistache::Http;
using namespace configuration;
namespace polycube {
namespace polycubed {
PolycubedCore::PolycubedCore(BaseModel *base_model)
: base_model_(base_model), logger(spdlog::get("polycubed")),
cubes_dump_(nullptr) {}
PolycubedCore::~PolycubedCore() {
servicectrls_map_.clear();
ServiceController::ports_to_ifaces.clear();
}
void PolycubedCore::set_polycubeendpoint(std::string &polycube) {
polycubeendpoint_ = polycube;
}
std::string PolycubedCore::get_polycubeendpoint() {
return polycubeendpoint_;
}
void PolycubedCore::add_servicectrl(const std::string &name,
const ServiceControllerType type,
const std::string &base_url,
const std::string &path) {
// logger->debug("PolycubedCore: post servicectrl {0}", name);
if (servicectrls_map_.count(name) != 0) {
throw std::runtime_error("Service Controller already exists");
}
std::unordered_map<std::string, ServiceController>::iterator iter;
bool inserted;
std::tie(iter, inserted) = servicectrls_map_.emplace(
std::piecewise_construct, std::forward_as_tuple(name),
std::forward_as_tuple(name, path, base_url, type));
if (!inserted) {
throw std::runtime_error("error creating service controller");
}
ServiceController &s = iter->second;
try {
s.connect(this);
logger->info("service {0} loaded using {1}", s.get_name(),
s.get_servicecontroller());
} catch (const std::exception &e) {
// logger->error("cannot load service: {0}", e.what());
servicectrls_map_.erase(name);
throw;
}
}
std::string PolycubedCore::get_servicectrl(const std::string &name) {
logger->debug("PolycubedCore: get service {0}", name);
auto iter = servicectrls_map_.find(name);
if (iter == servicectrls_map_.end()) {
// logger->warn("no service present with name {0}", name);
throw std::runtime_error("Service Controller does not exist");
}
ServiceController &s = iter->second;
json j = json::array();
j += s.to_json_datamodel();
return j.dump(4);
}
const ServiceController &PolycubedCore::get_service_controller(
const std::string &name) const {
if (servicectrls_map_.count(name) == 0) {
throw std::runtime_error("Service Controller does not exist");
}
return servicectrls_map_.at(name);
}
std::list<std::string> PolycubedCore::get_servicectrls_names() {
std::list<std::string> list;
for (auto &it : servicectrls_map_) {
list.push_back(it.first);
}
return list;
}
std::list<ServiceController const *> PolycubedCore::get_servicectrls_list()
const {
std::list<ServiceController const *> list;
for (auto &it : servicectrls_map_) {
list.push_back(&it.second);
}
return list;
}
std::string PolycubedCore::get_servicectrls() {
logger->debug("PolycubedCore: get services");
json j = json::array();
for (auto &it : servicectrls_map_) {
j += it.second.to_json();
}
return j.dump(4);
}
void PolycubedCore::delete_servicectrl(const std::string &name) {
logger->debug("PolycubedCore: delete service {0}", name);
if (servicectrls_map_.count(name) == 0) {
logger->warn("no service present with name {0}", name);
throw std::runtime_error("Service Controller does not exist");
}
// automatically destroy management grpc client instance and disconnect
// TODO Check consistency of currently deployed cubes,
// is necessary to undeploy them?
servicectrls_map_.erase(name);
logger->info("delete service {0}", name);
}
void PolycubedCore::clear_servicectrl_list() {
servicectrls_map_.clear();
}
std::string PolycubedCore::get_cube(const std::string &name) {
logger->debug("PolycubedCore: get cube {0}", name);
auto cube = ServiceController::get_cube(name);
if (cube == nullptr) {
logger->warn("no cube present with name {0}", name);
throw std::runtime_error("Cube does not exist");
}
return cube->to_json().dump(4);
}
std::string PolycubedCore::get_cubes() {
logger->debug("PolycubedCore: get cubes");
json j = json::object();
for (auto &it : servicectrls_map_) {
json j2 = json::array();
for (auto &it2 : it.second.get_cubes()) {
j2 += it2->to_json();
}
if (j2.size()) {
j[it.first] = j2;
}
}
return j.dump(4);
}
std::string PolycubedCore::get_netdev(const std::string &name) {
logger->debug("PolycubedCore: get netdev {0}", name);
json j = json::array();
auto ifaces = Netlink::getInstance().get_available_ifaces();
if (ifaces.count(name) != 0) {
j += ifaces.at(name).toJson();
return j.dump(4);
}
throw std::runtime_error("netdev " + name + "does not exist");
}
std::string PolycubedCore::get_netdevs() {
logger->debug("PolycubedCore: get netdevs");
json j = json::array();
auto ifaces = Netlink::getInstance().get_available_ifaces();
for (auto &it : ifaces) {
j += it.second.toJson();
}
return j.dump(4);
}
std::string PolycubedCore::topology() {
json j = json::array();
auto cubes = ServiceController::get_all_cubes();
for (auto &it : cubes) {
j += it->to_json();
}
return j.dump(4);
}
std::string PolycubedCore::get_if_topology(const std::string &if_name) {
json j = {{"name", if_name}};
auto extIface = polycube::polycubed::ExtIface::get_extiface(if_name);
if (extIface != NULL) {
auto names = extIface->get_cubes_names();
auto ingress_indices = extIface->get_cubes_ingress_index();
auto egress_indices = extIface->get_cubes_egress_index();
std::vector<std::string> cubes_info;
std::ostringstream stream;
for (int i=0; i<names.size(); i++) {
stream.str("");
stream << names[i] << ",\t" << ingress_indices[i] << ",\t" << egress_indices[i];
cubes_info.push_back(std::string(stream.str()));
}
j["cubes, ingress_index, egress_index"] = cubes_info;
stream.str("");
auto i_serv_chain = extIface->get_service_chain(ProgramType::INGRESS);
for (auto service : i_serv_chain) {
stream << service;
if (service != std::string("stack"))
stream << " ---> ";
}
j["ingress service chain"] = stream.str();
stream.str("");
auto e_serv_chain = extIface->get_service_chain(ProgramType::EGRESS);
for (auto service : e_serv_chain) {
stream << service;
if (service != std::string("stack"))
stream << " ---> ";
}
j["egress service chain"] = stream.str();
}
return j.dump(4);
}
std::string get_port_peer(const std::string &port) {
std::smatch match;
std::regex rule("(\\S+):(\\S+)");
if (std::regex_match(port, match, rule)) {
auto cube_ = ServiceController::get_cube(match[1]);
if (cube_ == nullptr) {
throw std::runtime_error("Cube does not exist");
}
auto cube = std::dynamic_pointer_cast<CubeIface>(cube_);
if (!cube) {
throw std::runtime_error("Bad cube type");
}
auto port = cube->get_port(match[2]);
return port->peer();
}
return std::string();
}
bool PolycubedCore::try_to_set_peer(const std::string &peer1,
const std::string &peer2) {
std::smatch match;
std::regex rule("(\\S+):(\\S+)");
if (std::regex_match(peer1, match, rule)) {
auto cube_ = ServiceController::get_cube(match[1]);
if (cube_ == nullptr) {
throw std::runtime_error("Cube does not exist");
}
auto cube = std::dynamic_pointer_cast<CubeIface>(cube_);
if (!cube) {
throw std::runtime_error("Bad cube type");
}
auto port = cube->get_port(match[2]);
port->set_peer(peer2);
// Update the peer of a port in the cubes configuration in memory
if (cubes_dump_) {
cubes_dump_->UpdatePortPeer(cube->get_name(), port->name(), peer2);
}
return true;
}
return false;
}
void PolycubedCore::connect(const std::string &peer1,
const std::string &peer2) {
int count = 0;
std::string ret;
ret = get_port_peer(peer1);
if (!ret.empty()) {
throw std::runtime_error(peer1 + " already has a peer " + ret);
}
ret = get_port_peer(peer2);
if (!ret.empty()) {
throw std::runtime_error(peer2 + " already has a peer " + ret);
}
if (try_to_set_peer(peer1, peer2)) {
count++;
}
if (try_to_set_peer(peer2, peer1)) {
count++;
}
if (count == 0) {
throw std::runtime_error("Error setting peer");
}
}
void PolycubedCore::disconnect(const std::string &peer1,
const std::string &peer2) {
std::string ret1, ret2;
ret1 = get_port_peer(peer1);
ret2 = get_port_peer(peer2);
if (ret1.empty() && ret2.empty()) {
throw std::runtime_error(peer1 + " is not connected to " + peer2);
}
if (!ret1.empty() && ret1 != peer2) {
throw std::runtime_error(peer1 + " is not connected to " + peer2);
}
if (!ret2.empty() && ret2 != peer1) {
throw std::runtime_error(peer1 + " is not connected to " + peer2);
}
try_to_set_peer(peer1, "");
try_to_set_peer(peer2, "");
}
void PolycubedCore::attach(const std::string &cube_name,
const std::string &port_name,
const std::string &position,
const std::string &other) {
std::shared_ptr<TransparentCube> cube;
std::shared_ptr<PeerIface> peer;
auto cube_ = ServiceController::get_cube(cube_name);
if (cube_ == nullptr) {
throw std::runtime_error("Cube " + cube_name + " does not exist");
}
cube = std::dynamic_pointer_cast<TransparentCube>(cube_);
if (!cube) {
throw std::runtime_error("Cube " + cube_name + " is not transparent");
}
if (cube->get_parent()) {
throw std::runtime_error("Cube " + cube_name + " is already attached");
}
std::smatch match;
std::regex rule("(\\S+):(\\S+)");
std::shared_ptr<CubeIface> cube2;
std::shared_ptr<PortIface> port;
if (std::regex_match(port_name, match, rule)) {
auto cube2_ = ServiceController::get_cube(match[1]);
if (cube2_ == nullptr) {
throw std::runtime_error("Port " + port_name + " does not exist");
}
cube2 = std::dynamic_pointer_cast<CubeIface>(cube2_);
if (!cube2) {
throw std::runtime_error("Cube " + std::string(match[1]) +
" is transparent");
}
port = cube2->get_port(match[2]);
switch (port->get_type()) {
case PortType::TC:
if (cube->get_type() != CubeType::TC) {
throw std::runtime_error(cube_name + " and " + port_name +
" have incompatible types");
}
break;
case PortType::XDP:
if (cube->get_type() != CubeType::XDP_SKB &&
cube->get_type() != CubeType::XDP_DRV) {
throw std::runtime_error(cube_name + " and " + port_name +
" have incompatible types");
}
break;
}
peer = std::dynamic_pointer_cast<PeerIface>(port);
} else {
std::unique_ptr<ExtIface> iface;
if (ServiceController::ports_to_ifaces.count(port_name) == 0) {
switch (cube->get_type()) {
case CubeType::TC:
iface.reset(new ExtIfaceTC(port_name));
break;
case CubeType::XDP_DRV:
iface.reset(new ExtIfaceXDP(port_name, 1U << 2));
break;
case CubeType::XDP_SKB:
iface.reset(new ExtIfaceXDP(port_name, 1U << 1));
break;
}
ServiceController::ports_to_ifaces.emplace(
std::piecewise_construct, std::forward_as_tuple(port_name),
std::forward_as_tuple(std::move(iface)));
}
// peer = dynamic_cast<PeerIface
// *>(ServiceController::ports_to_ifaces.at(port_name).get());
peer = std::dynamic_pointer_cast<PeerIface>(
ServiceController::ports_to_ifaces.at(port_name));
}
int insertPosition = peer->add_cube(cube.get(), position, other);
cube->set_parent(peer.get());
// if it is a cube's transparent cube,
// add it to the cubes configuration in memory
if (!match.empty() && cubes_dump_) {
cubes_dump_->UpdatePortTCubes(cube2->get_name(), port->name(), cube_name,
insertPosition);
}
}
void PolycubedCore::detach(const std::string &cube_name,
const std::string &port_name) {
std::shared_ptr<TransparentCube> cube;
std::shared_ptr<PeerIface> peer;
auto cube_ = ServiceController::get_cube(cube_name);
if (cube_ == nullptr) {
throw std::runtime_error("Cube " + cube_name + " does not exist");
}
cube = std::dynamic_pointer_cast<TransparentCube>(cube_);
if (!cube) {
throw std::runtime_error("Cube " + cube_name + " is not transparent");
}
std::smatch match;
std::regex rule("(\\S+):(\\S+)");
std::shared_ptr<CubeIface> cube2;
std::shared_ptr<PortIface> port;
if (std::regex_match(port_name, match, rule)) {
auto cube2_ = ServiceController::get_cube(match[1]);
if (cube2_ == nullptr) {
throw std::runtime_error("Port " + port_name + " does not exist");
}
cube2 = std::dynamic_pointer_cast<CubeIface>(cube2_);
if (!cube2) {
throw std::runtime_error("Cube " + std::string(match[1]) +
" is transparent");
}
port = cube2->get_port(match[2]);
peer = std::dynamic_pointer_cast<PeerIface>(port);
peer->remove_cube(cube->get_name());
} else {
if (ServiceController::ports_to_ifaces.count(port_name) == 0) {
throw std::runtime_error("netdev " + port_name + " not found");
}
auto iface = ServiceController::ports_to_ifaces.at(port_name);
peer = std::dynamic_pointer_cast<PeerIface>(iface);
peer->remove_cube(cube->get_name());
if (!iface->is_used()) {
ServiceController::ports_to_ifaces.erase(port_name);
}
}
cube->set_parent(nullptr);
// if it is a cube's transparent cube,
// remove it from the cubes configuration in memory
if (!match.empty() && cubes_dump_) {
cubes_dump_->UpdatePortTCubes(cube2->get_name(), port->name(), cube_name,
-1);
}
}
void PolycubedCore::cube_port_parameter_subscribe(
const std::string &cube, const std::string &port_name,
const std::string &caller, const std::string ¶meter,
ParameterEventCallback &cb) {
std::string outer_key(cube + ":" + port_name + ":" + parameter);
std::lock_guard<std::mutex> lock(cubes_port_event_mutex_);
cubes_port_event_callbacks_[outer_key][caller] = cb;
// send a first notification with the initial value
auto value = get_cube_port_parameter(cube, port_name, parameter);
cb(parameter, value);
}
void PolycubedCore::cube_port_parameter_unsubscribe(
const std::string &cube, const std::string &port_name,
const std::string &caller, const std::string ¶meter) {
std::string outer_key(cube + ":" + port_name + ":" + parameter);
std::lock_guard<std::mutex> lock(cubes_port_event_mutex_);
if (cubes_port_event_callbacks_.count(outer_key) > 0 &&
cubes_port_event_callbacks_[outer_key].count(caller) > 0) {
cubes_port_event_callbacks_[outer_key].erase(caller);
} else {
throw std::runtime_error("there is not subscription for " + parameter);
}
}
void PolycubedCore::notify_port_subscribers(
const std::string &cube, const std::string &port_name,
const std::string ¶meter, const std::string &value) {
std::string outer_key(cube + ":" + port_name + ":" + parameter);
std::lock_guard<std::mutex> lock(cubes_port_event_mutex_);
// if there are not subscribers just return
if (cubes_port_event_callbacks_.count(outer_key) == 0) {
return;
}
// TODO: what are the implications of calling the callbacks while
// having the lock?, could it be a good idea to create a temporal copy
// of the callbacks to be invoked and call then with the lock released?
for (const auto &it: cubes_port_event_callbacks_[outer_key]) {
it.second(parameter, value);
}
}
std::string PolycubedCore::get_cube_port_parameter(
const std::string &cube, const std::string &port_name,
const std::string ¶meter) {
using namespace Rest::Resources::Body;
auto service_name = ServiceController::get_cube_service(cube);
auto &ctrl = get_service_controller(service_name);
auto res = ctrl.get_management_interface()->get_service()->Child("ports");
ListKeyValues k{{"ports", "name", "ports_name", ListType::kString,
port_name}};
std::istringstream iss(port_name + "/" + parameter);
for (std::string segment; std::getline(iss, segment, '/');) {
auto current = std::dynamic_pointer_cast<ParentResource>(res);
if (current != nullptr) {
auto list = std::dynamic_pointer_cast<ListResource>(res);
if (list != nullptr) {
for (const auto &key : list->keys_) {
ListKeyValue v{"ports", key.OriginalName(), key.Name(), key.Type(),
segment};
k.emplace_back(v);
std::getline(iss, segment, '/'); // if null raise error
}
}
res = current->Child(segment);
if (res == nullptr) {
throw std::runtime_error("parameter not found");
}
} else {
throw std::runtime_error("parameter not found");
}
}
// support only leaf elements, maybe in the future we want to extend it
// to support complex elements
if (!std::dynamic_pointer_cast<LeafResource>(res)) {
throw std::runtime_error("Error getting port parameters: " + parameter);
}
auto result = res->ReadValue(cube, k);
std::string val(result.message);
val = val.substr(1, val.length() - 2); // remove qoutes
::free(result.message);
if (result.error_tag != ErrorTag::kOk) {
throw std::runtime_error("Error getting port parameters: " + parameter);
}
return val;
}
std::string PolycubedCore::set_cube_parameter(const std::string &cube,
const std::string ¶meter,
const std::string &value) {
throw std::logic_error(
"PolycubedCore::set_cube_parameter is not implemented");
}
std::vector<std::string> PolycubedCore::get_all_ports() {
std::vector<std::string> ports;
auto cubes = ServiceController::get_all_cubes();
for (auto &cube_ : cubes) {
auto cube = std::dynamic_pointer_cast<Cube>(cube_);
if (!cube) {
continue;
}
for (auto &it : cube->get_ports()) {
ports.push_back(cube->get_name() + ":" + it.first);
}
}
return std::move(ports);
}
void PolycubedCore::set_rest_server(RestServer *rest_server) {
rest_server_ = rest_server;
}
RestServer *PolycubedCore::get_rest_server() {
return rest_server_;
}
BaseModel *PolycubedCore::base_model() {
return base_model_;
}
void PolycubedCore::set_cubes_dump(CubesDump *cubes_dump) {
cubes_dump_= cubes_dump;
}
CubesDump *PolycubedCore::get_cubes_dump() {
return cubes_dump_;
}
} // namespace polycubed
} // namespace polycube
|
# mark_description "Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.0.166 Build 20191121";
# mark_description "-o asm/matvec_auto.asm -O2 -xCORE_AVX2 -S -masm=intel";
.intel_syntax noprefix
.file "matvec.c"
.text
..TXTST0:
.L_2__routine_start_main_0:
# -- Begin main
.text
# mark_begin;
.align 16,0x90
.globl main
# --- main(int, char **)
main:
# parameter 1: edi
# parameter 2: rsi
..B1.1: # Preds ..B1.0
# Execution count [1.00e+00]
.cfi_startproc
..___tag_value_main.1:
..L2:
#57.33
push rbp #57.33
.cfi_def_cfa_offset 16
mov rbp, rsp #57.33
.cfi_def_cfa 6, 16
.cfi_offset 6, -16
and rsp, -128 #57.33
push r12 #57.33
push r13 #57.33
push r14 #57.33
push r15 #57.33
push rbx #57.33
sub rsp, 88 #57.33
mov edi, 3 #57.33
mov esi, 10330110 #57.33
call __intel_new_feature_proc_init #57.33
.cfi_escape 0x10, 0x03, 0x0e, 0x38, 0x1c, 0x0d, 0x80, 0xff, 0xff, 0xff, 0x1a, 0x0d, 0xd8, 0xff, 0xff, 0xff, 0x22
.cfi_escape 0x10, 0x0c, 0x0e, 0x38, 0x1c, 0x0d, 0x80, 0xff, 0xff, 0xff, 0x1a, 0x0d, 0xf8, 0xff, 0xff, 0xff, 0x22
.cfi_escape 0x10, 0x0d, 0x0e, 0x38, 0x1c, 0x0d, 0x80, 0xff, 0xff, 0xff, 0x1a, 0x0d, 0xf0, 0xff, 0xff, 0xff, 0x22
.cfi_escape 0x10, 0x0e, 0x0e, 0x38, 0x1c, 0x0d, 0x80, 0xff, 0xff, 0xff, 0x1a, 0x0d, 0xe8, 0xff, 0xff, 0xff, 0x22
.cfi_escape 0x10, 0x0f, 0x0e, 0x38, 0x1c, 0x0d, 0x80, 0xff, 0xff, 0xff, 0x1a, 0x0d, 0xe0, 0xff, 0xff, 0xff, 0x22
# LOE r14 r15
..B1.64: # Preds ..B1.1
# Execution count [1.00e+00]
vstmxcsr DWORD PTR [rsp] #57.33
mov edi, 5760000 #59.18
or DWORD PTR [rsp], 32832 #57.33
vldmxcsr DWORD PTR [rsp] #57.33
# malloc(size_t)
call malloc #59.18
# LOE rax r14 r15
..B1.63: # Preds ..B1.64
# Execution count [1.00e+00]
mov rbx, rax #59.18
# LOE rbx r14 r15
..B1.2: # Preds ..B1.63
# Execution count [1.00e+00]
mov edi, 4800 #60.18
# malloc(size_t)
call malloc #60.18
# LOE rax rbx r14 r15
..B1.65: # Preds ..B1.2
# Execution count [1.00e+00]
mov r12, rax #60.18
# LOE rbx r12 r14 r15
..B1.3: # Preds ..B1.65
# Execution count [1.00e+00]
mov edi, 4800 #61.18
# malloc(size_t)
call malloc #61.18
# LOE rax rbx r12 r14 r15
..B1.66: # Preds ..B1.3
# Execution count [1.00e+00]
mov r13, rax #61.18
# LOE rbx r12 r13 r14 r15
..B1.4: # Preds ..B1.66
# Execution count [1.00e+00]
xor edi, edi #63.8
# time(time_t *)
call time #63.8
# LOE rax rbx r12 r13 r14 r15
..B1.5: # Preds ..B1.4
# Execution count [1.00e+00]
mov edi, eax #63.2
# srand(unsigned int)
call srand #63.2
# LOE rbx r12 r13 r14 r15
..B1.6: # Preds ..B1.5
# Execution count [1.00e+00]
xor edx, edx #64.2
xor ecx, ecx #64.2
mov r14, rdx #64.2
mov r15d, ecx #64.2
mov QWORD PTR [rsp], r13 #64.2[spill]
mov r13, rdx #64.2
# LOE rbx r12 r13 r14 r15d
..B1.7: # Preds ..B1.11 ..B1.6
# Execution count [1.20e+03]
xor edx, edx #64.2
lea rax, QWORD PTR [rbx+r13*4] #64.2
mov DWORD PTR [16+rsp], r15d #64.2[spill]
mov r15, rdx #64.2
mov QWORD PTR [8+rsp], r12 #64.2[spill]
mov r12, rax #64.2
# LOE rbx r12 r13 r14 r15
..B1.8: # Preds ..B1.9 ..B1.7
# Execution count [1.44e+06]
# rand(void)
call rand #64.2
# LOE rbx r12 r13 r14 r15 eax
..B1.9: # Preds ..B1.8
# Execution count [1.44e+06]
vxorps xmm0, xmm0, xmm0 #64.2
vcvtsi2ss xmm0, xmm0, eax #64.2
vdivss xmm1, xmm0, DWORD PTR .L_2il0floatpacket.0[rip] #64.2
vmovss DWORD PTR [r12+r15*4], xmm1 #64.2
inc r15 #64.2
cmp r15, 1200 #64.2
jl ..B1.8 # Prob 99% #64.2
# LOE rbx r12 r13 r14 r15
..B1.10: # Preds ..B1.9
# Execution count [1.20e+03]
mov r15d, DWORD PTR [16+rsp] #[spill]
mov r12, QWORD PTR [8+rsp] #[spill]
# rand(void)
call rand #64.2
# LOE rbx r12 r13 r14 eax r15d
..B1.11: # Preds ..B1.10
# Execution count [1.20e+03]
vxorps xmm0, xmm0, xmm0 #64.2
inc r15d #64.2
vcvtsi2ss xmm0, xmm0, eax #64.2
vdivss xmm1, xmm0, DWORD PTR .L_2il0floatpacket.0[rip] #64.2
vmovss DWORD PTR [r12+r14*4], xmm1 #64.2
add r13, 1200 #64.2
inc r14 #64.2
cmp r15d, 1200 #64.2
jl ..B1.7 # Prob 99% #64.2
# LOE rbx r12 r13 r14 r15d
..B1.12: # Preds ..B1.11
# Execution count [1.00e+00]
lea rdi, QWORD PTR [24+rsp] #66.17
mov r13, QWORD PTR [rsp] #[spill]
..___tag_value_main.16:
# ftime(struct timeb *)
call ftime #66.17
..___tag_value_main.17:
# LOE rbx r12 r13 r14 r15
..B1.13: # Preds ..B1.12
# Execution count [1.92e+01]
vxorpd xmm0, xmm0, xmm0 #66.17
vxorpd xmm1, xmm1, xmm1 #66.17
movzx eax, WORD PTR [32+rsp] #66.17
mov r10, r12 #68.3
vcvtsi2sd xmm0, xmm0, eax #66.17
vcvtsi2sd xmm1, xmm1, QWORD PTR [24+rsp] #66.17
vdivsd xmm2, xmm0, QWORD PTR .L_2il0floatpacket.1[rip] #66.17
and r10, 31 #68.3
xor r8d, r8d #67.13
mov edi, r10d #68.3
xor r9d, r9d #68.3
mov r11d, edi #68.3
mov esi, edi #68.3
neg r11d #68.3
and esi, 3 #68.3
add r11d, 32 #68.3
vaddsd xmm3, xmm1, xmm2 #66.17
vmovsd QWORD PTR [40+rsp], xmm3 #66.17[spill]
shr r11d, 2 #68.3
# LOE rbx r10 r12 r13 esi edi r8d r9d r11d
..B1.14: # Preds ..B1.29 ..B1.13
# Execution count [1.02e+03]
mov DWORD PTR [48+rsp], r9d #68.3
xor ecx, ecx #68.3
mov rdx, rbx #68.3
# LOE rdx rcx rbx r10 r12 r13 esi edi r8d r9d r11d
..B1.15: # Preds ..B1.28 ..B1.14
# Execution count [1.20e+06]
mov r15d, edi #68.3
test edi, edi #68.3
vxorps xmm0, xmm0, xmm0 #68.3
je ..B1.20 # Prob 50% #68.3
# LOE rdx rcx rbx r10 r12 r13 esi edi r8d r9d r11d r15d xmm0
..B1.16: # Preds ..B1.15
# Execution count [1.20e+06]
test esi, esi #68.3
jne ..B1.58 # Prob 10% #68.3
# LOE rdx rcx rbx r10 r12 r13 esi edi r8d r9d r11d xmm0
..B1.17: # Preds ..B1.16
# Execution count [1.20e+06]
mov eax, r11d #68.3
mov r15d, r11d #68.3
xor r14d, r14d #68.3
# LOE rax rdx rcx rbx r10 r12 r13 r14 esi edi r8d r9d r11d r15d xmm0
..B1.18: # Preds ..B1.18 ..B1.17
# Execution count [1.44e+09]
vmovss xmm1, DWORD PTR [r12+r14*4] #68.3
vmulss xmm2, xmm1, DWORD PTR [rdx+r14*4] #68.3
inc r14 #68.3
vaddss xmm0, xmm2, xmm0 #68.3
cmp r14, rax #68.3
jb ..B1.18 # Prob 99% #68.3
jmp ..B1.21 # Prob 100% #68.3
# LOE rax rdx rcx rbx r10 r12 r13 r14 esi edi r8d r9d r11d r15d xmm0
..B1.20: # Preds ..B1.15
# Execution count [6.00e+05]
mov rax, r10 #68.3
# LOE rax rdx rcx rbx r10 r12 r13 esi edi r8d r9d r11d r15d xmm0
..B1.21: # Preds ..B1.18 ..B1.20
# Execution count [1.20e+06]
neg r15d #68.3
and r15d, 15 #68.3
vxorps xmm1, xmm1, xmm1 #68.3
vmovss xmm1, xmm1, xmm0 #68.3
neg r15 #68.3
vxorps ymm0, ymm0, ymm0 #68.3
add r15, 1200 #68.3
vmovaps xmm1, xmm1 #68.3
# LOE rax rdx rcx rbx r10 r12 r13 r15 esi edi r8d r9d r11d ymm0 ymm1
..B1.22: # Preds ..B1.22 ..B1.21
# Execution count [1.44e+09]
vmovups ymm2, YMMWORD PTR [r12+rax*4] #68.3
vmovups ymm3, YMMWORD PTR [32+r12+rax*4] #68.3
vfmadd231ps ymm1, ymm2, YMMWORD PTR [rdx+rax*4] #68.3
vfmadd231ps ymm0, ymm3, YMMWORD PTR [32+rdx+rax*4] #68.3
add rax, 16 #68.3
cmp rax, r15 #68.3
jb ..B1.22 # Prob 99% #68.3
# LOE rax rdx rcx rbx r10 r12 r13 r15 esi edi r8d r9d r11d ymm0 ymm1
..B1.23: # Preds ..B1.22
# Execution count [1.20e+06]
vaddps ymm0, ymm1, ymm0 #68.3
vextractf128 xmm1, ymm0, 1 #68.3
vaddps xmm2, xmm0, xmm1 #68.3
vmovhlps xmm3, xmm2, xmm2 #68.3
vaddps xmm4, xmm2, xmm3 #68.3
vshufps xmm5, xmm4, xmm4, 245 #68.3
vaddss xmm0, xmm4, xmm5 #68.3
# LOE rdx rcx rbx r10 r12 r13 r15 esi edi r8d r9d r11d xmm0
..B1.24: # Preds ..B1.23 ..B1.58
# Execution count [1.20e+06]
cmp r15, 1200 #68.3
jae ..B1.28 # Prob 0% #68.3
# LOE rdx rcx rbx r10 r12 r13 r15 esi edi r8d r9d r11d xmm0
..B1.26: # Preds ..B1.24 ..B1.26
# Execution count [1.44e+09]
vmovss xmm1, DWORD PTR [r12+r15*4] #68.3
vmulss xmm2, xmm1, DWORD PTR [rdx+r15*4] #68.3
inc r15 #68.3
vaddss xmm0, xmm2, xmm0 #68.3
cmp r15, 1200 #68.3
jb ..B1.26 # Prob 99% #68.3
# LOE rdx rcx rbx r10 r12 r13 r15 esi edi r8d r9d r11d xmm0
..B1.28: # Preds ..B1.26 ..B1.24
# Execution count [1.20e+06]
vmovss DWORD PTR [r13+rcx*4], xmm0 #68.3
inc rcx #68.3
add rdx, 4800 #68.3
cmp rcx, 1200 #68.3
jb ..B1.15 # Prob 99% #68.3
# LOE rdx rcx rbx r10 r12 r13 esi edi r8d r9d r11d
..B1.29: # Preds ..B1.28
# Execution count [1.00e+03]
.byte 15 #67.28
.byte 31 #67.28
.byte 64 #67.28
.byte 0 #67.28
inc r8d #67.28
cmp r8d, 1000 #67.20
jl ..B1.14 # Prob 99% #67.20
# LOE rbx r10 r12 r13 esi edi r8d r9d r11d
..B1.30: # Preds ..B1.29
# Execution count [1.00e+00]
vzeroupper #69.14
lea rdi, QWORD PTR [rsp] #69.14
..___tag_value_main.20:
# ftime(struct timeb *)
call ftime #69.14
..___tag_value_main.21:
# LOE rbx r12 r13 r14 r15
..B1.31: # Preds ..B1.30
# Execution count [1.00e+00]
vxorpd xmm0, xmm0, xmm0 #69.14
vxorpd xmm1, xmm1, xmm1 #69.14
movzx eax, WORD PTR [8+rsp] #69.14
mov edi, offset flat: il0_peep_printf_format_0 #73.2
vcvtsi2sd xmm0, xmm0, eax #69.14
vcvtsi2sd xmm1, xmm1, QWORD PTR [rsp] #69.14
vdivsd xmm2, xmm0, QWORD PTR .L_2il0floatpacket.1[rip] #69.14
vaddsd xmm3, xmm1, xmm2 #69.14
vsubsd xmm4, xmm3, QWORD PTR [40+rsp] #69.29[spill]
vmovsd QWORD PTR [16+rsp], xmm4 #69.29[spill]
call puts #73.2
# LOE rbx r12 r13 r14 r15
..B1.32: # Preds ..B1.31
# Execution count [1.00e+00]
mov edi, offset flat: il0_peep_printf_format_1 #74.5
call puts #74.5
# LOE rbx r12 r13 r14 r15
..B1.33: # Preds ..B1.32
# Execution count [1.00e+00]
mov edi, offset flat: il0_peep_printf_format_2 #75.5
call puts #75.5
# LOE rbx r12 r13 r14 r15
..B1.34: # Preds ..B1.33
# Execution count [1.00e+00]
vmovsd xmm0, QWORD PTR [16+rsp] #76.5[spill]
mov edi, offset flat: .L_2__STRING.3 #76.5
vmulsd xmm2, xmm0, QWORD PTR .L_2il0floatpacket.3[rip] #76.5
mov eax, 2 #76.5
vmovsd xmm1, QWORD PTR .L_2il0floatpacket.2[rip] #76.5
vdivsd xmm1, xmm1, xmm2 #76.5
..___tag_value_main.25:
# printf(const char *__restrict__, ...)
call printf #76.5
..___tag_value_main.26:
# LOE rbx r12 r13 r14 r15
..B1.35: # Preds ..B1.34
# Execution count [1.00e+00]
mov rax, r13 #78.13
xor edx, edx #78.13
and rax, 31 #78.13
vpxor ymm8, ymm8, ymm8 #78.13
test eax, eax #78.13
je ..B1.40 # Prob 50% #78.13
# LOE rbx r12 r13 r14 r15 eax edx ymm8
..B1.36: # Preds ..B1.35
# Execution count [1.00e+00]
test al, 3 #78.13
jne ..B1.59 # Prob 10% #78.13
# LOE rbx r12 r13 r14 r15 eax edx ymm8
..B1.37: # Preds ..B1.36
# Execution count [1.00e+00]
neg eax #78.13
xor ecx, ecx #78.13
add eax, 32 #78.13
shr eax, 2 #78.13
mov esi, eax #78.13
vmovss xmm0, DWORD PTR .L_2il0floatpacket.4[rip] #78.13
# LOE rcx rbx rsi r12 r13 r14 r15 eax edx xmm0 ymm8
..B1.38: # Preds ..B1.38 ..B1.37
# Execution count [1.20e+03]
vmovss xmm1, DWORD PTR [r13+rcx*4] #78.13
inc rcx #78.13
vcomiss xmm1, xmm0 #78.13
lea r8d, DWORD PTR [1+rdx] #78.13
jbe ..L27 # Prob 50% #78.13
mov edx, r8d #78.13
..L27: #
cmp rcx, rsi #78.13
jb ..B1.38 # Prob 99% #78.13
jmp ..B1.41 # Prob 100% #78.13
# LOE rcx rbx rsi r12 r13 r14 r15 eax edx xmm0 ymm8
..B1.40: # Preds ..B1.35
# Execution count [5.00e-01]
xor esi, esi #78.13
# LOE rbx rsi r12 r13 r14 r15 eax edx ymm8
..B1.41: # Preds ..B1.38 ..B1.40
# Execution count [1.00e+00]
neg eax #78.13
vpxor ymm5, ymm5, ymm5 #78.13
add eax, 48 #78.13
vmovups ymm6, YMMWORD PTR .L_2il0floatpacket.5[rip] #78.13
vmovdqa ymm4, ymm5 #78.13
neg eax #78.13
vmovdqa ymm3, ymm4 #78.13
add eax, 1200 #78.13
vmovdqa ymm2, ymm3 #78.13
mov ecx, eax #78.13
vmovdqa ymm1, ymm2 #78.13
vmovdqa ymm7, ymm1 #78.13
vmovdqa ymm0, ymm7 #78.13
.align 16,0x90
# LOE rcx rbx rsi r12 r13 r14 r15 eax edx ymm0 ymm1 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 ymm8
..B1.42: # Preds ..B1.42 ..B1.41
# Execution count [1.20e+03]
vcmpltps ymm9, ymm6, YMMWORD PTR [r13+rsi*4] #78.13
vcmpltps ymm10, ymm6, YMMWORD PTR [32+r13+rsi*4] #78.13
vcmpltps ymm11, ymm6, YMMWORD PTR [64+r13+rsi*4] #78.13
vcmpltps ymm12, ymm6, YMMWORD PTR [96+r13+rsi*4] #78.13
vcmpltps ymm13, ymm6, YMMWORD PTR [128+r13+rsi*4] #78.13
vcmpltps ymm14, ymm6, YMMWORD PTR [160+r13+rsi*4] #78.13
vcmpltps ymm15, ymm6, YMMWORD PTR [192+r13+rsi*4] #78.13
vpsubd ymm8, ymm8, ymm9 #78.13
vpsubd ymm5, ymm5, ymm10 #78.13
vpsubd ymm4, ymm4, ymm11 #78.13
vpsubd ymm3, ymm3, ymm12 #78.13
vpsubd ymm2, ymm2, ymm13 #78.13
vpsubd ymm1, ymm1, ymm14 #78.13
vpsubd ymm7, ymm7, ymm15 #78.13
vcmpltps ymm9, ymm6, YMMWORD PTR [224+r13+rsi*4] #78.13
add rsi, 64 #78.13
vpsubd ymm0, ymm0, ymm9 #78.13
cmp rsi, rcx #78.13
jb ..B1.42 # Prob 99% #78.13
# LOE rcx rbx rsi r12 r13 r14 r15 eax edx ymm0 ymm1 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 ymm8
..B1.43: # Preds ..B1.42
# Execution count [1.00e+00]
vpaddd ymm5, ymm8, ymm5 #78.13
vpaddd ymm3, ymm4, ymm3 #78.13
vpaddd ymm1, ymm2, ymm1 #78.13
vpaddd ymm0, ymm7, ymm0 #78.13
vpaddd ymm4, ymm5, ymm3 #78.13
vpaddd ymm2, ymm1, ymm0 #78.13
vpaddd ymm8, ymm4, ymm2 #78.13
# LOE rbx r12 r13 r14 r15 eax edx ymm8
..B1.44: # Preds ..B1.43 ..B1.59
# Execution count [1.00e+00]
lea ecx, DWORD PTR [1+rax] #78.13
cmp ecx, 1200 #78.13
ja ..B1.53 # Prob 50% #78.13
# LOE rbx r12 r13 r14 r15 eax edx ymm8
..B1.45: # Preds ..B1.44
# Execution count [1.00e+00]
mov r9d, eax #78.13
neg r9d #78.13
add r9d, 1200 #78.13
cmp r9d, 8 #78.13
jb ..B1.60 # Prob 10% #78.13
# LOE rbx r12 r13 r14 r15 eax edx r9d ymm8
..B1.46: # Preds ..B1.45
# Execution count [1.00e+00]
mov r8d, r9d #78.13
xor esi, esi #78.13
vmovups ymm0, YMMWORD PTR .L_2il0floatpacket.5[rip] #78.13
and r8d, -8 #78.13
mov ecx, eax #78.13
# LOE rcx rbx r12 r13 r14 r15 eax edx esi r8d r9d ymm0 ymm8
..B1.47: # Preds ..B1.47 ..B1.46
# Execution count [1.20e+03]
vcmpltps ymm1, ymm0, YMMWORD PTR [r13+rcx*4] #78.13
add esi, 8 #78.13
add rcx, 8 #78.13
vpsubd ymm8, ymm8, ymm1 #78.13
cmp esi, r8d #78.13
jb ..B1.47 # Prob 99% #78.13
# LOE rcx rbx r12 r13 r14 r15 eax edx esi r8d r9d ymm0 ymm8
..B1.49: # Preds ..B1.47 ..B1.60
# Execution count [1.00e+00]
add eax, r8d #78.13
cmp r8d, r9d #78.13
jae ..B1.53 # Prob 0% #78.13
# LOE rax rbx r12 r13 r14 r15 edx r8d r9d ymm8
..B1.50: # Preds ..B1.49
# Execution count [1.00e+00]
vmovss xmm0, DWORD PTR .L_2il0floatpacket.4[rip] #78.13
# LOE rax rbx r12 r13 r14 r15 edx r8d r9d xmm0 ymm8
..B1.51: # Preds ..B1.51 ..B1.50
# Execution count [1.20e+03]
vmovss xmm1, DWORD PTR [r13+rax*4] #78.13
inc r8d #78.13
vcomiss xmm1, xmm0 #78.13
lea ecx, DWORD PTR [1+rdx] #78.13
jbe ..L28 # Prob 50% #78.13
mov edx, ecx #78.13
..L28: #
inc rax #78.13
cmp r8d, r9d #78.13
jb ..B1.51 # Prob 99% #78.13
# LOE rax rbx r12 r13 r14 r15 edx r8d r9d xmm0 ymm8
..B1.53: # Preds ..B1.51 ..B1.49 ..B1.44
# Execution count [1.00e+00]
mov edi, offset flat: .L_2__STRING.4 #79.5
vextractf128 xmm0, ymm8, 1 #78.13
xor eax, eax #79.5
vpaddd xmm1, xmm8, xmm0 #78.13
vpsrldq xmm2, xmm1, 8 #78.13
vpaddd xmm3, xmm1, xmm2 #78.13
vpsrlq xmm4, xmm3, 32 #78.13
vpaddd xmm5, xmm3, xmm4 #78.13
vmovd esi, xmm5 #78.13
add esi, edx #79.5
vzeroupper #79.5
..___tag_value_main.29:
# printf(const char *__restrict__, ...)
call printf #79.5
..___tag_value_main.30:
# LOE rbx r12 r13 r14 r15
..B1.54: # Preds ..B1.53
# Execution count [1.00e+00]
mov rdi, rbx #81.5
# free(void *)
call free #81.5
# LOE r12 r13 r14 r15
..B1.55: # Preds ..B1.54
# Execution count [1.00e+00]
mov rdi, r12 #82.5
# free(void *)
call free #82.5
# LOE r13 r14 r15
..B1.56: # Preds ..B1.55
# Execution count [1.00e+00]
mov rdi, r13 #83.5
# free(void *)
call free #83.5
# LOE r14 r15
..B1.57: # Preds ..B1.56
# Execution count [1.00e+00]
xor eax, eax #85.9
add rsp, 88 #85.9
.cfi_restore 3
pop rbx #85.9
.cfi_restore 15
pop r15 #85.9
.cfi_restore 14
pop r14 #85.9
.cfi_restore 13
pop r13 #85.9
.cfi_restore 12
pop r12 #85.9
mov rsp, rbp #85.9
pop rbp #85.9
.cfi_def_cfa 7, 8
.cfi_restore 6
ret #85.9
.cfi_def_cfa 6, 16
.cfi_escape 0x10, 0x03, 0x0e, 0x38, 0x1c, 0x0d, 0x80, 0xff, 0xff, 0xff, 0x1a, 0x0d, 0xd8, 0xff, 0xff, 0xff, 0x22
.cfi_offset 6, -16
.cfi_escape 0x10, 0x0c, 0x0e, 0x38, 0x1c, 0x0d, 0x80, 0xff, 0xff, 0xff, 0x1a, 0x0d, 0xf8, 0xff, 0xff, 0xff, 0x22
.cfi_escape 0x10, 0x0d, 0x0e, 0x38, 0x1c, 0x0d, 0x80, 0xff, 0xff, 0xff, 0x1a, 0x0d, 0xf0, 0xff, 0xff, 0xff, 0x22
.cfi_escape 0x10, 0x0e, 0x0e, 0x38, 0x1c, 0x0d, 0x80, 0xff, 0xff, 0xff, 0x1a, 0x0d, 0xe8, 0xff, 0xff, 0xff, 0x22
.cfi_escape 0x10, 0x0f, 0x0e, 0x38, 0x1c, 0x0d, 0x80, 0xff, 0xff, 0xff, 0x1a, 0x0d, 0xe0, 0xff, 0xff, 0xff, 0x22
# LOE
..B1.58: # Preds ..B1.16
# Execution count [1.20e+05]: Infreq
xor r15d, r15d #68.3
jmp ..B1.24 # Prob 100% #68.3
# LOE rdx rcx rbx r10 r12 r13 r15 esi edi r8d r9d r11d xmm0
..B1.59: # Preds ..B1.36
# Execution count [1.00e-01]: Infreq
xor eax, eax #78.13
jmp ..B1.44 # Prob 100% #78.13
# LOE rbx r12 r13 r14 r15 eax edx ymm8
..B1.60: # Preds ..B1.45
# Execution count [1.00e-01]: Infreq
xor r8d, r8d #78.13
jmp ..B1.49 # Prob 100% #78.13
.align 16,0x90
# LOE rbx r12 r13 r14 r15 eax edx r8d r9d ymm8
.cfi_endproc
# mark_end;
.type main,@function
.size main,.-main
..LNmain.0:
.section .rodata.str1.4, "aMS",@progbits,1
.align 4
.align 4
il0_peep_printf_format_1:
.long 1718773072
.long 1634562671
.long 979723118
.long 1376323849
.long 1769238133
.long 673211757
.long 537471347
.long 1330398791
.word 21328
.byte 0
.section .rodata.str1.32, "aMS",@progbits,1
.align 32
.align 32
il0_peep_printf_format_0:
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.long 1027423549
.word 15677
.byte 0
.space 29, 0x00 # pad
.align 32
il0_peep_printf_format_2:
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.long 757935405
.word 11565
.byte 0
.data
# -- End main
.text
.L_2__routine_start_read_timer_1:
# -- Begin read_timer
.text
# mark_begin;
.align 16,0x90
.globl read_timer
# --- read_timer()
read_timer:
..B2.1: # Preds ..B2.0
# Execution count [1.00e+00]
.cfi_startproc
..___tag_value_read_timer.46:
..L47:
#14.21
sub rsp, 24 #14.21
.cfi_def_cfa_offset 32
lea rdi, QWORD PTR [rsp] #16.5
..___tag_value_read_timer.49:
# ftime(struct timeb *)
call ftime #16.5
..___tag_value_read_timer.50:
# LOE rbx rbp r12 r13 r14 r15
..B2.2: # Preds ..B2.1
# Execution count [1.00e+00]
vxorpd xmm0, xmm0, xmm0 #17.40
vxorpd xmm1, xmm1, xmm1 #17.21
movzx eax, WORD PTR [8+rsp] #17.40
vcvtsi2sd xmm0, xmm0, eax #17.40
vcvtsi2sd xmm1, xmm1, QWORD PTR [rsp] #17.21
vdivsd xmm2, xmm0, QWORD PTR .L_2il0floatpacket.1[rip] #17.53
vaddsd xmm0, xmm1, xmm2 #17.53
add rsp, 24 #17.53
.cfi_def_cfa_offset 8
ret #17.53
.align 16,0x90
# LOE
.cfi_endproc
# mark_end;
.type read_timer,@function
.size read_timer,.-read_timer
..LNread_timer.1:
.data
# -- End read_timer
.text
.L_2__routine_start_sum_2:
# -- Begin sum
.text
# mark_begin;
.align 16,0x90
.globl sum
# --- sum(float *, float *, float *)
sum:
# parameter 1: rdi
# parameter 2: rsi
# parameter 3: rdx
..B3.1: # Preds ..B3.0
# Execution count [1.04e+00]
.cfi_startproc
..___tag_value_sum.53:
..L54:
#32.55
push r12 #32.55
.cfi_def_cfa_offset 16
.cfi_offset 12, -16
push r13 #32.55
.cfi_def_cfa_offset 24
.cfi_offset 13, -24
mov r10, rsi #38.3
and r10, 31 #38.3
xor r9d, r9d #35.2
mov ecx, r10d #38.3
mov r11d, ecx #38.3
mov r8d, ecx #38.3
neg r11d #38.3
and r8d, 3 #38.3
add r11d, 32 #38.3
mov DWORD PTR [-8+rsp], 0 #33.19
shr r11d, 2 #38.3
# LOE rdx rbx rbp rsi rdi r9 r10 r14 r15 ecx r8d r11d
..B3.2: # Preds ..B3.15 ..B3.1
# Execution count [1.20e+03]
mov r13d, ecx #38.3
test ecx, ecx #38.3
vxorps xmm0, xmm0, xmm0 #36.11
je ..B3.7 # Prob 50% #38.3
# LOE rdx rbx rbp rsi rdi r9 r10 r14 r15 ecx r8d r11d r13d xmm0
..B3.3: # Preds ..B3.2
# Execution count [1.20e+03]
test r8d, r8d #38.3
jne ..B3.17 # Prob 10% #38.3
# LOE rdx rbx rbp rsi rdi r9 r10 r14 r15 ecx r8d r11d xmm0
..B3.4: # Preds ..B3.3
# Execution count [1.20e+03]
mov eax, r11d #38.3
mov r13d, r11d #38.3
xor r12d, r12d #38.3
# LOE rax rdx rbx rbp rsi rdi r9 r10 r12 r14 r15 ecx r8d r11d r13d xmm0
..B3.5: # Preds ..B3.5 ..B3.4
# Execution count [1.44e+06]
vmovss xmm1, DWORD PTR [rsi+r12*4] #39.26
vmulss xmm2, xmm1, DWORD PTR [rdi+r12*4] #39.4
inc r12 #38.3
vaddss xmm0, xmm2, xmm0 #39.4
cmp r12, rax #38.3
jb ..B3.5 # Prob 99% #38.3
jmp ..B3.8 # Prob 100% #38.3
# LOE rax rdx rbx rbp rsi rdi r9 r10 r12 r14 r15 ecx r8d r11d r13d xmm0
..B3.7: # Preds ..B3.2
# Execution count [6.00e+02]
mov rax, r10 #38.3
# LOE rax rdx rbx rbp rsi rdi r9 r10 r14 r15 ecx r8d r11d r13d xmm0
..B3.8: # Preds ..B3.5 ..B3.7
# Execution count [1.20e+03]
neg r13d #38.3
and r13d, 15 #38.3
vxorps xmm1, xmm1, xmm1 #36.11
vmovss xmm1, xmm1, xmm0 #36.11
neg r13 #38.3
vxorps ymm0, ymm0, ymm0 #36.11
add r13, 1200 #38.3
vmovaps xmm1, xmm1 #36.11
# LOE rax rdx rbx rbp rsi rdi r9 r10 r13 r14 r15 ecx r8d r11d ymm0 ymm1
..B3.9: # Preds ..B3.9 ..B3.8
# Execution count [1.44e+06]
vmovups ymm2, YMMWORD PTR [rsi+rax*4] #39.26
vmovups ymm3, YMMWORD PTR [32+rsi+rax*4] #39.26
vfmadd231ps ymm1, ymm2, YMMWORD PTR [rdi+rax*4] #39.4
vfmadd231ps ymm0, ymm3, YMMWORD PTR [32+rdi+rax*4] #39.4
add rax, 16 #38.3
cmp rax, r13 #38.3
jb ..B3.9 # Prob 99% #38.3
# LOE rax rdx rbx rbp rsi rdi r9 r10 r13 r14 r15 ecx r8d r11d ymm0 ymm1
..B3.10: # Preds ..B3.9
# Execution count [1.20e+03]
vaddps ymm0, ymm1, ymm0 #36.11
vextractf128 xmm1, ymm0, 1 #36.11
vaddps xmm2, xmm0, xmm1 #36.11
vmovhlps xmm3, xmm2, xmm2 #36.11
vaddps xmm4, xmm2, xmm3 #36.11
vshufps xmm5, xmm4, xmm4, 245 #36.11
vaddss xmm0, xmm4, xmm5 #36.11
# LOE rdx rbx rbp rsi rdi r9 r10 r13 r14 r15 ecx r8d r11d xmm0
..B3.11: # Preds ..B3.10 ..B3.17
# Execution count [1.20e+03]
cmp r13, 1200 #38.3
jae ..B3.15 # Prob 0% #38.3
# LOE rdx rbx rbp rsi rdi r9 r10 r13 r14 r15 ecx r8d r11d xmm0
..B3.13: # Preds ..B3.11 ..B3.13
# Execution count [1.44e+06]
vmovss xmm1, DWORD PTR [rsi+r13*4] #39.26
vmulss xmm2, xmm1, DWORD PTR [rdi+r13*4] #39.4
inc r13 #38.3
vaddss xmm0, xmm2, xmm0 #39.4
cmp r13, 1200 #38.3
jb ..B3.13 # Prob 99% #38.3
# LOE rdx rbx rbp rsi rdi r9 r10 r13 r14 r15 ecx r8d r11d xmm0
..B3.15: # Preds ..B3.13 ..B3.11
# Execution count [1.20e+03]
vmovss DWORD PTR [rdx+r9*4], xmm0 #42.3
inc r9 #35.2
add rdi, 4800 #35.2
cmp r9, 1200 #35.2
jb ..B3.2 # Prob 99% #35.2
# LOE rdx rbx rbp rsi rdi r9 r10 r14 r15 ecx r8d r11d
..B3.16: # Preds ..B3.15
# Execution count [1.00e+00]
vzeroupper #44.1
.cfi_restore 13
pop r13 #44.1
.cfi_def_cfa_offset 16
.cfi_restore 12
pop r12 #44.1
.cfi_def_cfa_offset 8
ret #44.1
.cfi_def_cfa_offset 24
.cfi_offset 12, -16
.cfi_offset 13, -24
# LOE
..B3.17: # Preds ..B3.3
# Execution count [1.20e+02]: Infreq
xor r13d, r13d #38.3
jmp ..B3.11 # Prob 100% #38.3
.align 16,0x90
# LOE rdx rbx rbp rsi rdi r9 r10 r13 r14 r15 ecx r8d r11d xmm0
.cfi_endproc
# mark_end;
.type sum,@function
.size sum,.-sum
..LNsum.2:
.data
# -- End sum
.text
.L_2__routine_start_dummy_3:
# -- Begin dummy
.text
# mark_begin;
.align 16,0x90
.globl dummy
# --- dummy(float *)
dummy:
# parameter 1: rdi
..B4.1: # Preds ..B4.0
# Execution count [1.00e+00]
.cfi_startproc
..___tag_value_dummy.67:
..L68:
#48.21
mov rax, rdi #50.2
and rax, 31 #50.2
xor edx, edx #49.13
vpxor ymm8, ymm8, ymm8 #49.13
test eax, eax #50.2
je ..B4.6 # Prob 50% #50.2
# LOE rbx rbp rdi r12 r13 r14 r15 eax edx ymm8
..B4.2: # Preds ..B4.1
# Execution count [1.00e+00]
test al, 3 #50.2
jne ..B4.20 # Prob 10% #50.2
# LOE rbx rbp rdi r12 r13 r14 r15 eax edx ymm8
..B4.3: # Preds ..B4.2
# Execution count [1.00e+00]
neg eax #50.2
xor ecx, ecx #50.2
add eax, 32 #50.2
shr eax, 2 #50.2
mov esi, eax #50.2
vmovss xmm0, DWORD PTR .L_2il0floatpacket.4[rip] #51.14
# LOE rcx rbx rbp rsi rdi r12 r13 r14 r15 eax edx xmm0 ymm8
..B4.4: # Preds ..B4.4 ..B4.3
# Execution count [1.20e+03]
vmovss xmm1, DWORD PTR [rdi+rcx*4] #51.7
inc rcx #50.2
vcomiss xmm1, xmm0 #52.6
lea r8d, DWORD PTR [1+rdx] #52.6
jbe ..L69 # Prob 50% #52.6
mov edx, r8d #52.6
..L69: #
cmp rcx, rsi #50.2
jb ..B4.4 # Prob 99% #50.2
jmp ..B4.7 # Prob 100% #50.2
# LOE rcx rbx rbp rsi rdi r12 r13 r14 r15 eax edx xmm0 ymm8
..B4.6: # Preds ..B4.1
# Execution count [5.00e-01]
xor esi, esi #50.2
# LOE rbx rbp rsi rdi r12 r13 r14 r15 eax edx ymm8
..B4.7: # Preds ..B4.4 ..B4.6
# Execution count [1.00e+00]
neg eax #50.2
vpxor ymm5, ymm5, ymm5 #49.13
add eax, 48 #50.2
vmovups ymm6, YMMWORD PTR .L_2il0floatpacket.5[rip] #51.14
vmovdqa ymm4, ymm5 #49.13
neg eax #50.2
vmovdqa ymm3, ymm4 #49.13
add eax, 1200 #50.2
vmovdqa ymm2, ymm3 #49.13
mov ecx, eax #50.2
vmovdqa ymm1, ymm2 #49.13
vmovdqa ymm7, ymm1 #49.13
vmovdqa ymm0, ymm7 #49.13
.align 16,0x90
# LOE rcx rbx rbp rsi rdi r12 r13 r14 r15 eax edx ymm0 ymm1 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 ymm8
..B4.8: # Preds ..B4.8 ..B4.7
# Execution count [1.20e+03]
vcmpltps ymm9, ymm6, YMMWORD PTR [rdi+rsi*4] #51.14
vcmpltps ymm10, ymm6, YMMWORD PTR [32+rdi+rsi*4] #51.14
vcmpltps ymm11, ymm6, YMMWORD PTR [64+rdi+rsi*4] #51.14
vcmpltps ymm12, ymm6, YMMWORD PTR [96+rdi+rsi*4] #51.14
vcmpltps ymm13, ymm6, YMMWORD PTR [128+rdi+rsi*4] #51.14
vcmpltps ymm14, ymm6, YMMWORD PTR [160+rdi+rsi*4] #51.14
vcmpltps ymm15, ymm6, YMMWORD PTR [192+rdi+rsi*4] #51.14
vpsubd ymm8, ymm8, ymm9 #52.6
vpsubd ymm5, ymm5, ymm10 #52.6
vpsubd ymm4, ymm4, ymm11 #52.6
vpsubd ymm3, ymm3, ymm12 #52.6
vpsubd ymm2, ymm2, ymm13 #52.6
vpsubd ymm1, ymm1, ymm14 #52.6
vpsubd ymm7, ymm7, ymm15 #52.6
vcmpltps ymm9, ymm6, YMMWORD PTR [224+rdi+rsi*4] #51.14
add rsi, 64 #50.2
vpsubd ymm0, ymm0, ymm9 #52.6
cmp rsi, rcx #50.2
jb ..B4.8 # Prob 99% #50.2
# LOE rcx rbx rbp rsi rdi r12 r13 r14 r15 eax edx ymm0 ymm1 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 ymm8
..B4.9: # Preds ..B4.8
# Execution count [1.00e+00]
vpaddd ymm5, ymm8, ymm5 #49.13
vpaddd ymm3, ymm4, ymm3 #49.13
vpaddd ymm1, ymm2, ymm1 #49.13
vpaddd ymm0, ymm7, ymm0 #49.13
vpaddd ymm4, ymm5, ymm3 #49.13
vpaddd ymm2, ymm1, ymm0 #49.13
vpaddd ymm8, ymm4, ymm2 #49.13
# LOE rbx rbp rdi r12 r13 r14 r15 eax edx ymm8
..B4.10: # Preds ..B4.9 ..B4.20
# Execution count [1.00e+00]
lea ecx, DWORD PTR [1+rax] #50.2
cmp ecx, 1200 #50.2
ja ..B4.19 # Prob 50% #50.2
# LOE rbx rbp rdi r12 r13 r14 r15 eax edx ymm8
..B4.11: # Preds ..B4.10
# Execution count [1.00e+00]
mov r9d, eax #50.2
neg r9d #50.2
add r9d, 1200 #50.2
cmp r9d, 8 #50.2
jb ..B4.21 # Prob 10% #50.2
# LOE rbx rbp rdi r12 r13 r14 r15 eax edx r9d ymm8
..B4.12: # Preds ..B4.11
# Execution count [1.00e+00]
mov r8d, r9d #50.2
xor esi, esi #50.2
vmovups ymm0, YMMWORD PTR .L_2il0floatpacket.5[rip] #51.14
and r8d, -8 #50.2
mov ecx, eax #50.2
# LOE rcx rbx rbp rdi r12 r13 r14 r15 eax edx esi r8d r9d ymm0 ymm8
..B4.13: # Preds ..B4.13 ..B4.12
# Execution count [1.20e+03]
vcmpltps ymm1, ymm0, YMMWORD PTR [rdi+rcx*4] #51.14
add esi, 8 #50.2
add rcx, 8 #50.2
vpsubd ymm8, ymm8, ymm1 #52.6
cmp esi, r8d #50.2
jb ..B4.13 # Prob 99% #50.2
# LOE rcx rbx rbp rdi r12 r13 r14 r15 eax edx esi r8d r9d ymm0 ymm8
..B4.15: # Preds ..B4.13 ..B4.21
# Execution count [1.00e+00]
add eax, r8d #50.2
cmp r8d, r9d #50.2
jae ..B4.19 # Prob 0% #50.2
# LOE rax rbx rbp rdi r12 r13 r14 r15 edx r8d r9d ymm8
..B4.16: # Preds ..B4.15
# Execution count [1.00e+00]
vmovss xmm0, DWORD PTR .L_2il0floatpacket.4[rip] #51.14
# LOE rax rbx rbp rdi r12 r13 r14 r15 edx r8d r9d xmm0 ymm8
..B4.17: # Preds ..B4.17 ..B4.16
# Execution count [1.20e+03]
vmovss xmm1, DWORD PTR [rdi+rax*4] #51.7
inc r8d #50.2
vcomiss xmm1, xmm0 #52.6
lea ecx, DWORD PTR [1+rdx] #52.6
jbe ..L70 # Prob 50% #52.6
mov edx, ecx #52.6
..L70: #
inc rax #50.2
cmp r8d, r9d #50.2
jb ..B4.17 # Prob 99% #50.2
# LOE rax rbx rbp rdi r12 r13 r14 r15 edx r8d r9d xmm0 ymm8
..B4.19: # Preds ..B4.17 ..B4.15 ..B4.10
# Execution count [1.00e+00]
vextractf128 xmm0, ymm8, 1 #49.13
vpaddd xmm1, xmm8, xmm0 #49.13
vpsrldq xmm2, xmm1, 8 #49.13
vpaddd xmm3, xmm1, xmm2 #49.13
vpsrlq xmm4, xmm3, 32 #49.13
vpaddd xmm5, xmm3, xmm4 #49.13
vmovd eax, xmm5 #49.13
add eax, edx #49.13
vzeroupper #54.9
ret #54.9
# LOE
..B4.20: # Preds ..B4.2
# Execution count [1.00e-01]: Infreq
xor eax, eax #50.2
jmp ..B4.10 # Prob 100% #50.2
# LOE rbx rbp rdi r12 r13 r14 r15 eax edx ymm8
..B4.21: # Preds ..B4.11
# Execution count [1.00e-01]: Infreq
xor r8d, r8d #50.2
jmp ..B4.15 # Prob 100% #50.2
.align 16,0x90
# LOE rbx rbp rdi r12 r13 r14 r15 eax edx r8d r9d ymm8
.cfi_endproc
# mark_end;
.type dummy,@function
.size dummy,.-dummy
..LNdummy.3:
.data
# -- End dummy
.text
.L_2__routine_start_init_4:
# -- Begin init
.text
# mark_begin;
.align 16,0x90
.globl init
# --- init(float *, float *)
init:
# parameter 1: rdi
# parameter 2: rsi
..B5.1: # Preds ..B5.0
# Execution count [1.00e+00]
.cfi_startproc
..___tag_value_init.72:
..L73:
#21.41
push r12 #21.41
.cfi_def_cfa_offset 16
.cfi_offset 12, -16
push r13 #21.41
.cfi_def_cfa_offset 24
.cfi_offset 13, -24
push r14 #21.41
.cfi_def_cfa_offset 32
.cfi_offset 14, -32
push r15 #21.41
.cfi_def_cfa_offset 40
.cfi_offset 15, -40
push rbx #21.41
.cfi_def_cfa_offset 48
.cfi_offset 3, -48
push rbp #21.41
.cfi_def_cfa_offset 56
.cfi_offset 6, -56
push rsi #21.41
.cfi_def_cfa_offset 64
xor edx, edx #22.13
xor ecx, ecx #22.13
mov rbx, rdx #22.13
mov r13, rdx #22.13
mov ebp, ecx #22.13
mov r15, rsi #22.13
mov r12, rdi #22.13
# LOE rbx r12 r13 r15 ebp
..B5.2: # Preds ..B5.6 ..B5.1
# Execution count [1.20e+03]
xor eax, eax #23.14
lea r14, QWORD PTR [r12+rbx*4] #24.4
mov QWORD PTR [rsp], r15 #24.4[spill]
mov r15, rax #24.4
# LOE rbx r12 r13 r14 r15 ebp
..B5.3: # Preds ..B5.4 ..B5.2
# Execution count [1.44e+06]
# rand(void)
call rand #24.27
# LOE rbx r12 r13 r14 r15 eax ebp
..B5.4: # Preds ..B5.3
# Execution count [1.44e+06]
vxorps xmm0, xmm0, xmm0 #24.27
vcvtsi2ss xmm0, xmm0, eax #24.27
vdivss xmm1, xmm0, DWORD PTR .L_2il0floatpacket.0[rip] #24.34
vmovss DWORD PTR [r14+r15*4], xmm1 #24.4
inc r15 #23.24
cmp r15, 1200 #23.21
jl ..B5.3 # Prob 99% #23.21
# LOE rbx r12 r13 r14 r15 ebp
..B5.5: # Preds ..B5.4
# Execution count [1.20e+03]
mov r15, QWORD PTR [rsp] #[spill]
# rand(void)
call rand #27.22
# LOE rbx r12 r13 r15 eax ebp
..B5.6: # Preds ..B5.5
# Execution count [1.20e+03]
vxorps xmm0, xmm0, xmm0 #27.22
inc ebp #22.23
vcvtsi2ss xmm0, xmm0, eax #27.22
vdivss xmm1, xmm0, DWORD PTR .L_2il0floatpacket.0[rip] #27.29
vmovss DWORD PTR [r15+r13*4], xmm1 #27.3
add rbx, 1200 #22.23
inc r13 #22.23
cmp ebp, 1200 #22.20
jl ..B5.2 # Prob 99% #22.20
# LOE rbx r12 r13 r15 ebp
..B5.7: # Preds ..B5.6
# Execution count [1.00e+00]
pop rcx #29.1
.cfi_def_cfa_offset 56
.cfi_restore 6
pop rbp #29.1
.cfi_def_cfa_offset 48
.cfi_restore 3
pop rbx #29.1
.cfi_def_cfa_offset 40
.cfi_restore 15
pop r15 #29.1
.cfi_def_cfa_offset 32
.cfi_restore 14
pop r14 #29.1
.cfi_def_cfa_offset 24
.cfi_restore 13
pop r13 #29.1
.cfi_def_cfa_offset 16
.cfi_restore 12
pop r12 #29.1
.cfi_def_cfa_offset 8
ret #29.1
.align 16,0x90
# LOE
.cfi_endproc
# mark_end;
.type init,@function
.size init,.-init
..LNinit.4:
.data
# -- End init
.section .rodata, "a"
.align 32
.align 32
.L_2il0floatpacket.5:
.long 0x42c80000,0x42c80000,0x42c80000,0x42c80000,0x42c80000,0x42c80000,0x42c80000,0x42c80000
.type .L_2il0floatpacket.5,@object
.size .L_2il0floatpacket.5,32
.align 8
.L_2il0floatpacket.1:
.long 0x00000000,0x408f4000
.type .L_2il0floatpacket.1,@object
.size .L_2il0floatpacket.1,8
.align 8
.L_2il0floatpacket.2:
.long 0x00000000,0x41e5752a
.type .L_2il0floatpacket.2,@object
.size .L_2il0floatpacket.2,8
.align 8
.L_2il0floatpacket.3:
.long 0x00000000,0x41cdcd65
.type .L_2il0floatpacket.3,@object
.size .L_2il0floatpacket.3,8
.align 4
.L_2il0floatpacket.0:
.long 0x4d4ccccd
.type .L_2il0floatpacket.0,@object
.size .L_2il0floatpacket.0,4
.align 4
.L_2il0floatpacket.4:
.long 0x42c80000
.type .L_2il0floatpacket.4,@object
.size .L_2il0floatpacket.4,4
.section .rodata.str1.4, "aMS",@progbits,1
.space 1, 0x00 # pad
.align 4
.L_2__STRING.3:
.long 1920229709
.long 1982691433
.long 1869898597
.long 1814569074
.long 1634037353
.long 154806642
.long 1714693385
.long 1714693385
.word 10
.type .L_2__STRING.3,@object
.size .L_2__STRING.3,34
.space 2, 0x00 # pad
.align 4
.L_2__STRING.4:
.long 1835889988
.long 622869113
.word 2660
.byte 0
.type .L_2__STRING.4,@object
.size .L_2__STRING.4,11
.data
.section .note.GNU-stack, ""
# End
|
/* Name : Dumitru
** Class : CS 330 - 001
** Date : Jan/Feb 2007
**
** Description: ProcessCmd.cpp
******************************************************************************/
#ifndef PROCESS_CMD_CPP
#define PROCESS_CMD_CPP
#include "ProcessCmd.h"
// constructors
ProcessCmd::ProcessCmd()
{ Clear(); }
ProcessCmd::ProcessCmd(string str)
{ Clear(); NewCommand(str); }
// new command based on str
void ProcessCmd::NewCommand(string str)
{
Clear();
this->mainStr = str;
this->original = str;
BreakApart();
}
// clear the old string
void ProcessCmd::Clear()
{
lineIsComment = false;
mainStr = original = command = "";
theTime = user = numParams = -1;
for(int i = 0; i < MAX_NUM_PARAMS;i++)
param[i] = "";
}
void ProcessCmd::BreakApart()
/******************************************************************************
Breaks apart the mainStr into it's corresponding parts, the user and time, the
command and the command parameters
******************************************************************************/
{
vector<string> temp; // holds individual parts of the string
vector<string>::iterator itr; // used to transverse temp
string tempStr; // part to be pushed into temp
int tempInt = -1;
// strip off leading spaces from the string
while(mainStr.at(0) == ' ')
mainStr = mainStr.substr(1);
while(mainStr.at(mainStr.length()-1) == ' ')
mainStr = mainStr.substr(0,mainStr.size()-1);
// search the strings for any comments ( ie. "#")
for(int i = 0; i < (int)mainStr.length();i++)
{
if(mainStr.at(i) == '#')
{
if(i == 0)
lineIsComment = true;
tempInt = i; break;
}
}
// trim the string of comments if it has any
if(tempInt > 0)
{
if(mainStr.at(tempInt - 1) == ' ')
mainStr = mainStr.substr(0,tempInt-1);
else
mainStr = mainStr.substr(0,tempInt);
}
tempInt = -1;
do
{
// break off each part of the string
tempInt =(int)mainStr.find_first_of(' ',0);
tempStr = mainStr.substr(0,tempInt);
// push each part onto temp
temp.push_back(tempStr);
mainStr = mainStr.substr(tempInt+1);
// next while loop trims leading spaces
// of the remaining string so we can then
// search for the next space behind the
// first term in the string
// .: the amount of spaces between the
// arguments doesn't matter
while(mainStr.at(0) == ' ')
mainStr = mainStr.substr(1);
}while(tempInt != -1);
// sort out the string by how many useful parts it has
switch((int)temp.size())
{
case 7: // format
theTime = atoi(temp.at(0).c_str());
user = atoi(temp.at(1).c_str());
command = temp.at(2);
param[0] = temp.at(3);
param[1] = temp.at(4);
param[2] = temp.at(5);
param[3] = temp.at(6);
numParams = 4;
break;
case 5: // install, mount, dumpfs
theTime = atoi(temp.at(0).c_str());
user = atoi(temp.at(1).c_str());
command = temp.at(2);
param[0] = temp.at(3);
param[1] = temp.at(4);
numParams = 2;
break;
case 4: // cfs, unmount
theTime = atoi(temp.at(0).c_str());
user = atoi(temp.at(1).c_str());
command = temp.at(2);
param[0] = temp.at(3);
numParams = 1;
break;
case 3: // showfs, showmounts
theTime = atoi(temp.at(0).c_str());
user = atoi(temp.at(1).c_str());
command = temp.at(2);
numParams = 0;
break;
default: // not a valid command
numParams = -1;
}
// clear out the temp container
for(itr = temp.begin(); itr < temp.end(); itr++)
{ temp.pop_back(); }
temp.clear();
}
int ProcessCmd::GetCommandNo()
/******************************************************************************
Returns:
1. the command index number if it is a valid command
2. -1 otherwise
******************************************************************************/
{
// check command array
for(int i = 0; i < SIZE_CMDS_ARRAY;i++)
{
if(command == CMDS[i])
return i; // command found
}
return -1; // command not in array
}
/*######################### accessor functions###############################*/
int ProcessCmd::GetUser()
{ return this->user; }
int ProcessCmd::GetTime()
{ return this->theTime; }
int ProcessCmd::GetNumParams()
{ return this->numParams; }
string ProcessCmd::GetCommand()
{ return this->command; }
string ProcessCmd::GetParam(int index)
{ return this->param[index]; }
string ProcessCmd::GetOriginal()
{ return this->original; }
#endif // PROCESS_CMD_CPP
|
/*******************************************************************************
* Copyright 2018 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
/*
* Cell execution LSTM
*/
#include "dnnl_thread.hpp"
#include "math_utils.hpp"
#include "jit_uni_rnn_common_postgemm_dispatcher.hpp"
namespace dnnl {
namespace impl {
namespace cpu {
using namespace dnnl::impl::utils;
using namespace dnnl::impl::math;
using namespace rnn_utils;
#define AOC array_offset_calculator
template <typename T1, typename T2, typename acc_data_t, typename src_data_t>
void gru_lbr_fwd_postgemm_template(T1 func1, T2 func2, const float *scales,
const rnn_utils::rnn_conf_t &rnn, acc_data_t *ws_gates_,
src_data_t *states_t_l_, src_data_t *states_tm1_l_, float *bias_,
float *ws_grid_, acc_data_t *ws_cell_) {
ws_gates_aoc_t ws_gates(rnn, ws_gates_);
bias_aoc_t bias(rnn, bias_);
ws_states_aoc_t states_t_l(rnn, states_t_l_);
ws_states_aoc_t states_tm1_l(rnn, states_tm1_l_);
ws_gates_aoc_t ws_gemm_state(rnn, ws_cell_);
AOC<float, 2> ws_Wh_b(ws_grid_, rnn.mb, rnn.dic);
parallel_nd(rnn.mb, [&](int i) {
PRAGMA_OMP_SIMD()
for (int j = 0; j < rnn.dic; j++) {
float Wh_b = ws_gemm_state(i, 2, j) + bias(3, j);
ws_gates(i, 0, j) = func1(scales, // default func1 is sigmoid
ws_gates(i, 0, j) + ws_gemm_state(i, 0, j) + bias(0, j));
ws_gates(i, 1, j) = func1(scales + 1, // default func1 is sigmoid
ws_gates(i, 1, j) + ws_gemm_state(i, 1, j) + bias(1, j));
ws_gates(i, 2, j) = func2(scales + 2, // default func2 is tanh
ws_gates(i, 2, j) + ws_gates(i, 1, j) * Wh_b + bias(2, j));
states_t_l(i, j) = states_tm1_l(i, j) * ws_gates(i, 0, j)
+ (1.0f - ws_gates(i, 0, j)) * ws_gates(i, 2, j);
if (rnn.is_training) ws_Wh_b(i, j) = Wh_b;
}
});
}
template <>
rnn_postgemm_sig(rnn_postgemm_fwd_f32_t::gru_lbr_postgemm) {
const float *scales = pd_->attr()->rnn_tparams_.scales_;
auto linear_f = [](const float *scale, float a) { return *scale * a; };
auto logistic_f = [](const float *scale, float a) {
return logistic_fwd<float>(a);
};
auto tanh_f
= [](const float *scale, float a) { return tanh_fwd<float>(a); };
if (!pd_->attr()->rnn_tparams_.test_mode_)
gru_lbr_fwd_postgemm_template(logistic_f, tanh_f, scales, rnn,
ws_gates_, states_t_l_, states_tm1_l_, bias_, ws_grid_,
ws_cell_);
else
gru_lbr_fwd_postgemm_template(linear_f, linear_f, scales, rnn,
ws_gates_, states_t_l_, states_tm1_l_, bias_, ws_grid_,
ws_cell_);
}
template <>
rnn_postgemm_sig(rnn_postgemm_fwd_u8_t::gru_lbr_postgemm) {
assert(!"GRU LBR int8 is not supported");
}
template <>
rnn_postgemm_sig(rnn_postgemm_bwd_f32_t::gru_lbr_postgemm) {
ws_gates_aoc_t ws_gates(rnn, ws_gates_);
ws_states_aoc_t states_tm1_l(rnn, states_tm1_l_);
ws_diff_states_aoc_t diff_states_t_l(rnn, diff_states_t_l_);
ws_diff_states_aoc_t diff_states_tp1_l(rnn, diff_states_tp1_l_);
ws_diff_states_aoc_t diff_states_t_lp1(rnn, diff_states_t_lp1_);
ws_gates_aoc_t ws_gates_r(rnn, ws_cell_);
AOC<float, 2> ws_Wh_b(ws_grid_, rnn.mb, rnn.dic);
// 1. calculate dG1 dG2 dG3
// dG0 = (dht - G2) * dht * (1 - G0) * G0
// dG1 = (W*h + b) * dG2 * (1 - G1) * G1
// dG2 = (1 - G0) * dht * (1 - G2*G2)
parallel_nd(rnn.mb, [&](int i) {
PRAGMA_OMP_SIMD()
for (int j = 0; j < rnn.dic; j++) {
float h = states_tm1_l(i, j);
float dHt = diff_states_tp1_l(0, i, j)
+ diff_states_t_lp1(rnn.n_states, i, j);
float dG0 = (h - ws_gates(i, 2, j)) * dHt
* x_m_square(ws_gates(i, 0, j));
float dG2 = (1.0f - ws_gates(i, 0, j))
* one_m_square(ws_gates(i, 2, j)) * dHt;
float dG1 = ws_Wh_b(i, j) * dG2 * x_m_square(ws_gates(i, 1, j));
diff_states_t_l(0, i, j) = dHt * ws_gates(i, 0, j);
ws_gates(i, 2, j) = dG2;
ws_gates_r(i, 2, j) = dG2 * ws_gates(i, 1, j);
ws_gates(i, 0, j) = ws_gates_r(i, 0, j) = dG0;
ws_gates(i, 1, j) = ws_gates_r(i, 1, j) = dG1;
}
});
}
} // namespace cpu
} // namespace impl
} // namespace dnnl
|
; A078545: Largest prime dividing tau(n), the number of divisors of n.
; 2,2,3,2,2,2,2,3,2,2,3,2,2,2,5,2,3,2,3,2,2,2,2,3,2,2,3,2,2,2,3,2,2,2,3,2,2,2,2,2,2,2,3,3,2,2,5,3,3,2,3,2,2,2,2,2,2,2,3,2,2,3,7,2,2,2,3,2,2,2,3,2,2,3,3,2,2,2,5,5,2,2,3,2,2,2,2,2,3,2,3,2,2,2,3,2,3,3,3,2
add $0,1
seq $0,5 ; d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n.
sub $0,1
seq $0,6530 ; Gpf(n): greatest prime dividing n, for n >= 2; a(1)=1.
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %r8
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x45b1, %rsi
lea addresses_UC_ht+0x1ea31, %rdi
cmp $41463, %r8
mov $19, %rcx
rep movsw
and $45030, %rbp
lea addresses_normal_ht+0x1b3d9, %r13
nop
nop
nop
cmp %rax, %rax
movb $0x61, (%r13)
nop
nop
nop
nop
nop
and $27352, %rdi
lea addresses_D_ht+0x3996, %r8
sub $20906, %rbp
movl $0x61626364, (%r8)
nop
nop
cmp $4501, %rax
lea addresses_WC_ht+0x1bdb1, %rsi
lea addresses_WT_ht+0xf5b1, %rdi
clflush (%rsi)
clflush (%rdi)
inc %r15
mov $53, %rcx
rep movsq
nop
and $17919, %r8
lea addresses_A_ht+0xf631, %rdi
nop
nop
nop
sub $57662, %rcx
mov $0x6162636465666768, %rbp
movq %rbp, %xmm3
movups %xmm3, (%rdi)
nop
xor %rax, %rax
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %rax
push %rbx
push %rcx
push %rdx
push %rsi
// Store
lea addresses_A+0xfbb1, %r12
nop
nop
nop
nop
sub %rdx, %rdx
mov $0x5152535455565758, %r10
movq %r10, %xmm5
movups %xmm5, (%r12)
nop
nop
nop
sub %rsi, %rsi
// Store
mov $0x792b110000000881, %rax
nop
nop
nop
nop
xor %rbx, %rbx
mov $0x5152535455565758, %rcx
movq %rcx, (%rax)
xor %rsi, %rsi
// Store
lea addresses_normal+0x190e1, %rcx
nop
nop
nop
nop
nop
cmp $23837, %rax
movb $0x51, (%rcx)
nop
nop
nop
xor $49939, %rsi
// Load
mov $0x6218900000003b1, %r10
nop
nop
nop
nop
inc %rdx
movups (%r10), %xmm1
vpextrq $0, %xmm1, %rcx
nop
nop
nop
nop
nop
and %rcx, %rcx
// Faulty Load
lea addresses_normal+0x1bb1, %r12
nop
nop
nop
nop
nop
cmp %rax, %rax
mov (%r12), %r10d
lea oracles, %rax
and $0xff, %r10
shlq $12, %r10
mov (%rax,%r10,1), %r10
pop %rsi
pop %rdx
pop %rcx
pop %rbx
pop %rax
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A', 'same': False, 'size': 16, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_NC', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_normal', 'same': False, 'size': 1, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_NC', 'same': False, 'size': 16, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 16, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'34': 53}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
.data
answer: .byte 'a','b','c','a','a'
ask_op: .asciiz"Answer: "
game: .asciiz"\n\tQUIZ"
line: .asciiz"______________________________"
fullmarks: .asciiz"\tF.M=5\n"
ques1: .asciiz"\n\n1. What is the capital of India ?\n"
q1opa: .asciiz"a)Delhi\n"
q1opb: .asciiz"b)Mumbai\n"
q1opc: .asciiz"c)Agra\n"
q1opd: .asciiz"d)Bhubaneswar\n"
ques2: .asciiz"\n\n2. What is my name ?\n"
q2opa: .asciiz"a)A.K.P\n"
q2opb: .asciiz"b)ASHIS\n"
q2opc: .asciiz"c)PADHI\n"
q2opd: .asciiz"d)AK\n"
ques3: .asciiz"\n\n3. What is my age ?\n"
q3opa: .asciiz"a)19\n"
q3opb: .asciiz"b)20\n"
q3opc: .asciiz"c)21\n"
q3opd: .asciiz"d)24\n"
ques4: .asciiz"\n\n4. What is my NUMBER ?\n"
q4opa: .asciiz"a)7064247858\n"
q4opb: .asciiz"b)7124568957\n"
q4opc: .asciiz"c)6987598545\n"
q4opd: .asciiz"d)9845687515\n"
ques5: .asciiz"\n\n5. What is my favourite game ?\n"
q5opa: .asciiz"a)FIFA\n"
q5opb: .asciiz"b)WWE\n"
q5opc: .asciiz"c)PUBG\n"
q5opd: .asciiz"d)CS\n"
score: .word 0
box1: .asciiz"\n -------------\n"
s_card: .asciiz" | SCORECARD |\n"
box2: .asciiz" -------------\n"
name: .asciiz"\nNAME:"
buffer: .space 30
ask_name: .asciiz"\nEnter your name(30 letters maximum)=>"
score_out: .asciiz"\nSCORE:"
percentile: .asciiz"\nPERCENTILE:"
.text
main:
#li $t6, 5
la $a0, ask_name
li $v0, 4
syscall
li $v0, 8
la $a0, buffer
li $a1,20
move $t4, $a0
syscall
la $a0, game
li $v0, 4
syscall
la $a0, fullmarks
li $v0, 4
syscall
la $a0,line
li $v0, 4
syscall
la $a0, ques1
li $v0, 4
syscall
la $a0, q1opa
li $v0, 4
syscall
la $a0, q1opb
li $v0, 4
syscall
la $a0, q1opc
li $v0, 4
syscall
la $a0, q1opd
li $v0, 4
syscall
la $a0, ask_op
li $v0, 4
syscall
li $v0, 12
syscall
#addi $t6, $t6, -1
#bnez $t6, EXIT
la $t0, answer
lb $t1, 0($t0)
bne $t1, $v0,L1
addi $t7,$t7,1
L1:move $v0, $0
la $a0, ques2
li $v0, 4
syscall
la $a0, q2opa
li $v0, 4
syscall
la $a0, q2opb
li $v0, 4
syscall
la $a0, q2opc
li $v0, 4
syscall
la $a0, q2opd
li $v0, 4
syscall
la $a0, ask_op
li $v0, 4
syscall
li $v0, 12
syscall
#addi $t6, $t6, -1
#bnez $t6, EXIT
lb $t1, 1($t0)
bne $t1, $v0,L2
addi $t7,$t7,1
L2:move $v0, $0
la $a0, ques3
li $v0, 4
syscall
la $a0, q3opa
li $v0, 4
syscall
la $a0, q3opb
li $v0, 4
syscall
la $a0, q3opc
li $v0, 4
syscall
la $a0, q3opd
li $v0, 4
syscall
la $a0, ask_op
li $v0, 4
syscall
li $v0, 12
syscall
lb $t1, 2($t0)
bne $t1, $v0,L3
addi $t7,$t7,1
L3:move $v0, $0
la $a0, ques4
li $v0, 4
syscall
la $a0, q4opa
li $v0, 4
syscall
la $a0, q4opb
li $v0, 4
syscall
la $a0, q4opc
li $v0, 4
syscall
la $a0, q4opd
li $v0, 4
syscall
la $a0, ask_op
li $v0, 4
syscall
li $v0, 12
syscall
lb $t1, 3($t0)
bne $t1, $v0,L4
addi $t7,$t7,1
L4:move $v0, $0
la $a0, ques5
li $v0, 4
syscall
la $a0, q5opa
li $v0, 4
syscall
la $a0, q5opb
li $v0, 4
syscall
la $a0, q5opc
li $v0, 4
syscall
la $a0, q5opd
li $v0, 4
syscall
la $a0, ask_op
li $v0, 4
syscall
li $v0, 12
syscall
lb $t1, 4($t0)
bne $t1, $v0, EXIT
addi $t7,$t7,1
EXIT:
add $t9,$t9,$t7
sw $t9,score
la $a0, box1
li $v0, 4
syscall
la $a0, s_card
li $v0, 4
syscall
la $a0, box2
li $v0, 4
syscall
la $a0, name
li $v0, 4
syscall
la $a0, buffer
move $a0, $t4
li $v0, 4
syscall
la $a0, score_out
li $v0, 4
syscall
move $a0, $t9
li $v0, 1
syscall
move $v0, $0
li $v0,10
syscall
|
_testTask1: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"
int main(int argc, char *argv[]) {
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
6: 83 ec 30 sub $0x30,%esp
int pid;
int k, numChild;
double x, z;
if(argc < 2)
9: 83 7d 08 01 cmpl $0x1,0x8(%ebp)
d: 7f 0a jg 19 <main+0x19>
numChild = 1; //Default
f: c7 44 24 28 01 00 00 movl $0x1,0x28(%esp)
16: 00
17: eb 14 jmp 2d <main+0x2d>
else
numChild = atoi(argv[1]);
19: 8b 45 0c mov 0xc(%ebp),%eax
1c: 83 c0 04 add $0x4,%eax
1f: 8b 00 mov (%eax),%eax
21: 89 04 24 mov %eax,(%esp)
24: e8 f7 02 00 00 call 320 <atoi>
29: 89 44 24 28 mov %eax,0x28(%esp)
if (numChild < 0 ||numChild > 20)
2d: 83 7c 24 28 00 cmpl $0x0,0x28(%esp)
32: 78 07 js 3b <main+0x3b>
34: 83 7c 24 28 14 cmpl $0x14,0x28(%esp)
39: 7e 08 jle 43 <main+0x43>
numChild = 2;
3b: c7 44 24 28 02 00 00 movl $0x2,0x28(%esp)
42: 00
if (argc>=3)
43: 83 7d 08 02 cmpl $0x2,0x8(%ebp)
47: 7e 14 jle 5d <main+0x5d>
numChild = atoi(argv[2]);
49: 8b 45 0c mov 0xc(%ebp),%eax
4c: 83 c0 08 add $0x8,%eax
4f: 8b 00 mov (%eax),%eax
51: 89 04 24 mov %eax,(%esp)
54: e8 c7 02 00 00 call 320 <atoi>
59: 89 44 24 28 mov %eax,0x28(%esp)
x = 0;
5d: d9 ee fldz
5f: dd 5c 24 20 fstpl 0x20(%esp)
pid = 0;
63: c7 44 24 14 00 00 00 movl $0x0,0x14(%esp)
6a: 00
for ( k = 0; k < numChild; k++ ) {
6b: c7 44 24 2c 00 00 00 movl $0x0,0x2c(%esp)
72: 00
73: e9 bf 00 00 00 jmp 137 <main+0x137>
pid = fork ();
78: e8 2d 03 00 00 call 3aa <fork>
7d: 89 44 24 14 mov %eax,0x14(%esp)
if ( pid < 0 ) {
81: 83 7c 24 14 00 cmpl $0x0,0x14(%esp)
86: 79 22 jns aa <main+0xaa>
printf(1, "%d failed in fork!\n", getpid());
88: e8 a5 03 00 00 call 432 <getpid>
8d: 89 44 24 08 mov %eax,0x8(%esp)
91: c7 44 24 04 20 09 00 movl $0x920,0x4(%esp)
98: 00
99: c7 04 24 01 00 00 00 movl $0x1,(%esp)
a0: e8 ad 04 00 00 call 552 <printf>
a5: e9 88 00 00 00 jmp 132 <main+0x132>
} else if (pid > 0) {
aa: 83 7c 24 14 00 cmpl $0x0,0x14(%esp)
af: 7e 2c jle dd <main+0xdd>
// parent
printf(1, "Parent %d creating child %d\n",getpid(), pid);
b1: e8 7c 03 00 00 call 432 <getpid>
b6: 8b 54 24 14 mov 0x14(%esp),%edx
ba: 89 54 24 0c mov %edx,0xc(%esp)
be: 89 44 24 08 mov %eax,0x8(%esp)
c2: c7 44 24 04 34 09 00 movl $0x934,0x4(%esp)
c9: 00
ca: c7 04 24 01 00 00 00 movl $0x1,(%esp)
d1: e8 7c 04 00 00 call 552 <printf>
wait();
d6: e8 df 02 00 00 call 3ba <wait>
db: eb 55 jmp 132 <main+0x132>
}
else{
printf(1,"Child %d created\n",getpid());
dd: e8 50 03 00 00 call 432 <getpid>
e2: 89 44 24 08 mov %eax,0x8(%esp)
e6: c7 44 24 04 51 09 00 movl $0x951,0x4(%esp)
ed: 00
ee: c7 04 24 01 00 00 00 movl $0x1,(%esp)
f5: e8 58 04 00 00 call 552 <printf>
//Wasting CPU time around 10 seconds
for(z = 0.0; z < 80000000.0; z+=1.0)
fa: d9 ee fldz
fc: dd 5c 24 18 fstpl 0x18(%esp)
100: eb 1c jmp 11e <main+0x11e>
x = x + 3.14*89.64;
102: dd 44 24 20 fldl 0x20(%esp)
106: dd 05 68 09 00 00 fldl 0x968
10c: de c1 faddp %st,%st(1)
10e: dd 5c 24 20 fstpl 0x20(%esp)
wait();
}
else{
printf(1,"Child %d created\n",getpid());
//Wasting CPU time around 10 seconds
for(z = 0.0; z < 80000000.0; z+=1.0)
112: dd 44 24 18 fldl 0x18(%esp)
116: d9 e8 fld1
118: de c1 faddp %st,%st(1)
11a: dd 5c 24 18 fstpl 0x18(%esp)
11e: dd 05 70 09 00 00 fldl 0x970
124: dd 44 24 18 fldl 0x18(%esp)
128: d9 c9 fxch %st(1)
12a: df e9 fucomip %st(1),%st
12c: dd d8 fstp %st(0)
12e: 77 d2 ja 102 <main+0x102>
x = x + 3.14*89.64;
break;
130: eb 13 jmp 145 <main+0x145>
if (argc>=3)
numChild = atoi(argv[2]);
x = 0;
pid = 0;
for ( k = 0; k < numChild; k++ ) {
132: 83 44 24 2c 01 addl $0x1,0x2c(%esp)
137: 8b 44 24 2c mov 0x2c(%esp),%eax
13b: 3b 44 24 28 cmp 0x28(%esp),%eax
13f: 0f 8c 33 ff ff ff jl 78 <main+0x78>
for(z = 0.0; z < 80000000.0; z+=1.0)
x = x + 3.14*89.64;
break;
}
}
exit();
145: e8 68 02 00 00 call 3b2 <exit>
0000014a <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
14a: 55 push %ebp
14b: 89 e5 mov %esp,%ebp
14d: 57 push %edi
14e: 53 push %ebx
asm volatile("cld; rep stosb" :
14f: 8b 4d 08 mov 0x8(%ebp),%ecx
152: 8b 55 10 mov 0x10(%ebp),%edx
155: 8b 45 0c mov 0xc(%ebp),%eax
158: 89 cb mov %ecx,%ebx
15a: 89 df mov %ebx,%edi
15c: 89 d1 mov %edx,%ecx
15e: fc cld
15f: f3 aa rep stos %al,%es:(%edi)
161: 89 ca mov %ecx,%edx
163: 89 fb mov %edi,%ebx
165: 89 5d 08 mov %ebx,0x8(%ebp)
168: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
16b: 5b pop %ebx
16c: 5f pop %edi
16d: 5d pop %ebp
16e: c3 ret
0000016f <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
16f: 55 push %ebp
170: 89 e5 mov %esp,%ebp
172: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
175: 8b 45 08 mov 0x8(%ebp),%eax
178: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
17b: 90 nop
17c: 8b 45 08 mov 0x8(%ebp),%eax
17f: 8d 50 01 lea 0x1(%eax),%edx
182: 89 55 08 mov %edx,0x8(%ebp)
185: 8b 55 0c mov 0xc(%ebp),%edx
188: 8d 4a 01 lea 0x1(%edx),%ecx
18b: 89 4d 0c mov %ecx,0xc(%ebp)
18e: 0f b6 12 movzbl (%edx),%edx
191: 88 10 mov %dl,(%eax)
193: 0f b6 00 movzbl (%eax),%eax
196: 84 c0 test %al,%al
198: 75 e2 jne 17c <strcpy+0xd>
;
return os;
19a: 8b 45 fc mov -0x4(%ebp),%eax
}
19d: c9 leave
19e: c3 ret
0000019f <strcmp>:
int
strcmp(const char *p, const char *q)
{
19f: 55 push %ebp
1a0: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
1a2: eb 08 jmp 1ac <strcmp+0xd>
p++, q++;
1a4: 83 45 08 01 addl $0x1,0x8(%ebp)
1a8: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1ac: 8b 45 08 mov 0x8(%ebp),%eax
1af: 0f b6 00 movzbl (%eax),%eax
1b2: 84 c0 test %al,%al
1b4: 74 10 je 1c6 <strcmp+0x27>
1b6: 8b 45 08 mov 0x8(%ebp),%eax
1b9: 0f b6 10 movzbl (%eax),%edx
1bc: 8b 45 0c mov 0xc(%ebp),%eax
1bf: 0f b6 00 movzbl (%eax),%eax
1c2: 38 c2 cmp %al,%dl
1c4: 74 de je 1a4 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
1c6: 8b 45 08 mov 0x8(%ebp),%eax
1c9: 0f b6 00 movzbl (%eax),%eax
1cc: 0f b6 d0 movzbl %al,%edx
1cf: 8b 45 0c mov 0xc(%ebp),%eax
1d2: 0f b6 00 movzbl (%eax),%eax
1d5: 0f b6 c0 movzbl %al,%eax
1d8: 29 c2 sub %eax,%edx
1da: 89 d0 mov %edx,%eax
}
1dc: 5d pop %ebp
1dd: c3 ret
000001de <strlen>:
uint
strlen(char *s)
{
1de: 55 push %ebp
1df: 89 e5 mov %esp,%ebp
1e1: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
1e4: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
1eb: eb 04 jmp 1f1 <strlen+0x13>
1ed: 83 45 fc 01 addl $0x1,-0x4(%ebp)
1f1: 8b 55 fc mov -0x4(%ebp),%edx
1f4: 8b 45 08 mov 0x8(%ebp),%eax
1f7: 01 d0 add %edx,%eax
1f9: 0f b6 00 movzbl (%eax),%eax
1fc: 84 c0 test %al,%al
1fe: 75 ed jne 1ed <strlen+0xf>
;
return n;
200: 8b 45 fc mov -0x4(%ebp),%eax
}
203: c9 leave
204: c3 ret
00000205 <memset>:
void*
memset(void *dst, int c, uint n)
{
205: 55 push %ebp
206: 89 e5 mov %esp,%ebp
208: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
20b: 8b 45 10 mov 0x10(%ebp),%eax
20e: 89 44 24 08 mov %eax,0x8(%esp)
212: 8b 45 0c mov 0xc(%ebp),%eax
215: 89 44 24 04 mov %eax,0x4(%esp)
219: 8b 45 08 mov 0x8(%ebp),%eax
21c: 89 04 24 mov %eax,(%esp)
21f: e8 26 ff ff ff call 14a <stosb>
return dst;
224: 8b 45 08 mov 0x8(%ebp),%eax
}
227: c9 leave
228: c3 ret
00000229 <strchr>:
char*
strchr(const char *s, char c)
{
229: 55 push %ebp
22a: 89 e5 mov %esp,%ebp
22c: 83 ec 04 sub $0x4,%esp
22f: 8b 45 0c mov 0xc(%ebp),%eax
232: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
235: eb 14 jmp 24b <strchr+0x22>
if(*s == c)
237: 8b 45 08 mov 0x8(%ebp),%eax
23a: 0f b6 00 movzbl (%eax),%eax
23d: 3a 45 fc cmp -0x4(%ebp),%al
240: 75 05 jne 247 <strchr+0x1e>
return (char*)s;
242: 8b 45 08 mov 0x8(%ebp),%eax
245: eb 13 jmp 25a <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
247: 83 45 08 01 addl $0x1,0x8(%ebp)
24b: 8b 45 08 mov 0x8(%ebp),%eax
24e: 0f b6 00 movzbl (%eax),%eax
251: 84 c0 test %al,%al
253: 75 e2 jne 237 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
255: b8 00 00 00 00 mov $0x0,%eax
}
25a: c9 leave
25b: c3 ret
0000025c <gets>:
char*
gets(char *buf, int max)
{
25c: 55 push %ebp
25d: 89 e5 mov %esp,%ebp
25f: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
262: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
269: eb 4c jmp 2b7 <gets+0x5b>
cc = read(0, &c, 1);
26b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
272: 00
273: 8d 45 ef lea -0x11(%ebp),%eax
276: 89 44 24 04 mov %eax,0x4(%esp)
27a: c7 04 24 00 00 00 00 movl $0x0,(%esp)
281: e8 44 01 00 00 call 3ca <read>
286: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
289: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
28d: 7f 02 jg 291 <gets+0x35>
break;
28f: eb 31 jmp 2c2 <gets+0x66>
buf[i++] = c;
291: 8b 45 f4 mov -0xc(%ebp),%eax
294: 8d 50 01 lea 0x1(%eax),%edx
297: 89 55 f4 mov %edx,-0xc(%ebp)
29a: 89 c2 mov %eax,%edx
29c: 8b 45 08 mov 0x8(%ebp),%eax
29f: 01 c2 add %eax,%edx
2a1: 0f b6 45 ef movzbl -0x11(%ebp),%eax
2a5: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
2a7: 0f b6 45 ef movzbl -0x11(%ebp),%eax
2ab: 3c 0a cmp $0xa,%al
2ad: 74 13 je 2c2 <gets+0x66>
2af: 0f b6 45 ef movzbl -0x11(%ebp),%eax
2b3: 3c 0d cmp $0xd,%al
2b5: 74 0b je 2c2 <gets+0x66>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
2b7: 8b 45 f4 mov -0xc(%ebp),%eax
2ba: 83 c0 01 add $0x1,%eax
2bd: 3b 45 0c cmp 0xc(%ebp),%eax
2c0: 7c a9 jl 26b <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
2c2: 8b 55 f4 mov -0xc(%ebp),%edx
2c5: 8b 45 08 mov 0x8(%ebp),%eax
2c8: 01 d0 add %edx,%eax
2ca: c6 00 00 movb $0x0,(%eax)
return buf;
2cd: 8b 45 08 mov 0x8(%ebp),%eax
}
2d0: c9 leave
2d1: c3 ret
000002d2 <stat>:
int
stat(char *n, struct stat *st)
{
2d2: 55 push %ebp
2d3: 89 e5 mov %esp,%ebp
2d5: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
2d8: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2df: 00
2e0: 8b 45 08 mov 0x8(%ebp),%eax
2e3: 89 04 24 mov %eax,(%esp)
2e6: e8 07 01 00 00 call 3f2 <open>
2eb: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
2ee: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2f2: 79 07 jns 2fb <stat+0x29>
return -1;
2f4: b8 ff ff ff ff mov $0xffffffff,%eax
2f9: eb 23 jmp 31e <stat+0x4c>
r = fstat(fd, st);
2fb: 8b 45 0c mov 0xc(%ebp),%eax
2fe: 89 44 24 04 mov %eax,0x4(%esp)
302: 8b 45 f4 mov -0xc(%ebp),%eax
305: 89 04 24 mov %eax,(%esp)
308: e8 fd 00 00 00 call 40a <fstat>
30d: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
310: 8b 45 f4 mov -0xc(%ebp),%eax
313: 89 04 24 mov %eax,(%esp)
316: e8 bf 00 00 00 call 3da <close>
return r;
31b: 8b 45 f0 mov -0x10(%ebp),%eax
}
31e: c9 leave
31f: c3 ret
00000320 <atoi>:
int
atoi(const char *s)
{
320: 55 push %ebp
321: 89 e5 mov %esp,%ebp
323: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
326: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
32d: eb 25 jmp 354 <atoi+0x34>
n = n*10 + *s++ - '0';
32f: 8b 55 fc mov -0x4(%ebp),%edx
332: 89 d0 mov %edx,%eax
334: c1 e0 02 shl $0x2,%eax
337: 01 d0 add %edx,%eax
339: 01 c0 add %eax,%eax
33b: 89 c1 mov %eax,%ecx
33d: 8b 45 08 mov 0x8(%ebp),%eax
340: 8d 50 01 lea 0x1(%eax),%edx
343: 89 55 08 mov %edx,0x8(%ebp)
346: 0f b6 00 movzbl (%eax),%eax
349: 0f be c0 movsbl %al,%eax
34c: 01 c8 add %ecx,%eax
34e: 83 e8 30 sub $0x30,%eax
351: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
354: 8b 45 08 mov 0x8(%ebp),%eax
357: 0f b6 00 movzbl (%eax),%eax
35a: 3c 2f cmp $0x2f,%al
35c: 7e 0a jle 368 <atoi+0x48>
35e: 8b 45 08 mov 0x8(%ebp),%eax
361: 0f b6 00 movzbl (%eax),%eax
364: 3c 39 cmp $0x39,%al
366: 7e c7 jle 32f <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
368: 8b 45 fc mov -0x4(%ebp),%eax
}
36b: c9 leave
36c: c3 ret
0000036d <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
36d: 55 push %ebp
36e: 89 e5 mov %esp,%ebp
370: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
373: 8b 45 08 mov 0x8(%ebp),%eax
376: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
379: 8b 45 0c mov 0xc(%ebp),%eax
37c: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
37f: eb 17 jmp 398 <memmove+0x2b>
*dst++ = *src++;
381: 8b 45 fc mov -0x4(%ebp),%eax
384: 8d 50 01 lea 0x1(%eax),%edx
387: 89 55 fc mov %edx,-0x4(%ebp)
38a: 8b 55 f8 mov -0x8(%ebp),%edx
38d: 8d 4a 01 lea 0x1(%edx),%ecx
390: 89 4d f8 mov %ecx,-0x8(%ebp)
393: 0f b6 12 movzbl (%edx),%edx
396: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
398: 8b 45 10 mov 0x10(%ebp),%eax
39b: 8d 50 ff lea -0x1(%eax),%edx
39e: 89 55 10 mov %edx,0x10(%ebp)
3a1: 85 c0 test %eax,%eax
3a3: 7f dc jg 381 <memmove+0x14>
*dst++ = *src++;
return vdst;
3a5: 8b 45 08 mov 0x8(%ebp),%eax
}
3a8: c9 leave
3a9: c3 ret
000003aa <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
3aa: b8 01 00 00 00 mov $0x1,%eax
3af: cd 40 int $0x40
3b1: c3 ret
000003b2 <exit>:
SYSCALL(exit)
3b2: b8 02 00 00 00 mov $0x2,%eax
3b7: cd 40 int $0x40
3b9: c3 ret
000003ba <wait>:
SYSCALL(wait)
3ba: b8 03 00 00 00 mov $0x3,%eax
3bf: cd 40 int $0x40
3c1: c3 ret
000003c2 <pipe>:
SYSCALL(pipe)
3c2: b8 04 00 00 00 mov $0x4,%eax
3c7: cd 40 int $0x40
3c9: c3 ret
000003ca <read>:
SYSCALL(read)
3ca: b8 05 00 00 00 mov $0x5,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <write>:
SYSCALL(write)
3d2: b8 10 00 00 00 mov $0x10,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <close>:
SYSCALL(close)
3da: b8 15 00 00 00 mov $0x15,%eax
3df: cd 40 int $0x40
3e1: c3 ret
000003e2 <kill>:
SYSCALL(kill)
3e2: b8 06 00 00 00 mov $0x6,%eax
3e7: cd 40 int $0x40
3e9: c3 ret
000003ea <exec>:
SYSCALL(exec)
3ea: b8 07 00 00 00 mov $0x7,%eax
3ef: cd 40 int $0x40
3f1: c3 ret
000003f2 <open>:
SYSCALL(open)
3f2: b8 0f 00 00 00 mov $0xf,%eax
3f7: cd 40 int $0x40
3f9: c3 ret
000003fa <mknod>:
SYSCALL(mknod)
3fa: b8 11 00 00 00 mov $0x11,%eax
3ff: cd 40 int $0x40
401: c3 ret
00000402 <unlink>:
SYSCALL(unlink)
402: b8 12 00 00 00 mov $0x12,%eax
407: cd 40 int $0x40
409: c3 ret
0000040a <fstat>:
SYSCALL(fstat)
40a: b8 08 00 00 00 mov $0x8,%eax
40f: cd 40 int $0x40
411: c3 ret
00000412 <link>:
SYSCALL(link)
412: b8 13 00 00 00 mov $0x13,%eax
417: cd 40 int $0x40
419: c3 ret
0000041a <mkdir>:
SYSCALL(mkdir)
41a: b8 14 00 00 00 mov $0x14,%eax
41f: cd 40 int $0x40
421: c3 ret
00000422 <chdir>:
SYSCALL(chdir)
422: b8 09 00 00 00 mov $0x9,%eax
427: cd 40 int $0x40
429: c3 ret
0000042a <dup>:
SYSCALL(dup)
42a: b8 0a 00 00 00 mov $0xa,%eax
42f: cd 40 int $0x40
431: c3 ret
00000432 <getpid>:
SYSCALL(getpid)
432: b8 0b 00 00 00 mov $0xb,%eax
437: cd 40 int $0x40
439: c3 ret
0000043a <sbrk>:
SYSCALL(sbrk)
43a: b8 0c 00 00 00 mov $0xc,%eax
43f: cd 40 int $0x40
441: c3 ret
00000442 <sleep>:
SYSCALL(sleep)
442: b8 0d 00 00 00 mov $0xd,%eax
447: cd 40 int $0x40
449: c3 ret
0000044a <uptime>:
SYSCALL(uptime)
44a: b8 0e 00 00 00 mov $0xe,%eax
44f: cd 40 int $0x40
451: c3 ret
00000452 <changepriority>:
SYSCALL(changepriority)
452: b8 16 00 00 00 mov $0x16,%eax
457: cd 40 int $0x40
459: c3 ret
0000045a <processstatus>:
SYSCALL(processstatus)
45a: b8 17 00 00 00 mov $0x17,%eax
45f: cd 40 int $0x40
461: c3 ret
00000462 <randomgen>:
SYSCALL(randomgen)
462: b8 18 00 00 00 mov $0x18,%eax
467: cd 40 int $0x40
469: c3 ret
0000046a <randomgenrange>:
SYSCALL(randomgenrange)
46a: b8 19 00 00 00 mov $0x19,%eax
46f: cd 40 int $0x40
471: c3 ret
00000472 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
472: 55 push %ebp
473: 89 e5 mov %esp,%ebp
475: 83 ec 18 sub $0x18,%esp
478: 8b 45 0c mov 0xc(%ebp),%eax
47b: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
47e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
485: 00
486: 8d 45 f4 lea -0xc(%ebp),%eax
489: 89 44 24 04 mov %eax,0x4(%esp)
48d: 8b 45 08 mov 0x8(%ebp),%eax
490: 89 04 24 mov %eax,(%esp)
493: e8 3a ff ff ff call 3d2 <write>
}
498: c9 leave
499: c3 ret
0000049a <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
49a: 55 push %ebp
49b: 89 e5 mov %esp,%ebp
49d: 56 push %esi
49e: 53 push %ebx
49f: 83 ec 30 sub $0x30,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
4a2: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
4a9: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
4ad: 74 17 je 4c6 <printint+0x2c>
4af: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
4b3: 79 11 jns 4c6 <printint+0x2c>
neg = 1;
4b5: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
4bc: 8b 45 0c mov 0xc(%ebp),%eax
4bf: f7 d8 neg %eax
4c1: 89 45 ec mov %eax,-0x14(%ebp)
4c4: eb 06 jmp 4cc <printint+0x32>
} else {
x = xx;
4c6: 8b 45 0c mov 0xc(%ebp),%eax
4c9: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
4cc: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
4d3: 8b 4d f4 mov -0xc(%ebp),%ecx
4d6: 8d 41 01 lea 0x1(%ecx),%eax
4d9: 89 45 f4 mov %eax,-0xc(%ebp)
4dc: 8b 5d 10 mov 0x10(%ebp),%ebx
4df: 8b 45 ec mov -0x14(%ebp),%eax
4e2: ba 00 00 00 00 mov $0x0,%edx
4e7: f7 f3 div %ebx
4e9: 89 d0 mov %edx,%eax
4eb: 0f b6 80 c4 0b 00 00 movzbl 0xbc4(%eax),%eax
4f2: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
4f6: 8b 75 10 mov 0x10(%ebp),%esi
4f9: 8b 45 ec mov -0x14(%ebp),%eax
4fc: ba 00 00 00 00 mov $0x0,%edx
501: f7 f6 div %esi
503: 89 45 ec mov %eax,-0x14(%ebp)
506: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
50a: 75 c7 jne 4d3 <printint+0x39>
if(neg)
50c: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
510: 74 10 je 522 <printint+0x88>
buf[i++] = '-';
512: 8b 45 f4 mov -0xc(%ebp),%eax
515: 8d 50 01 lea 0x1(%eax),%edx
518: 89 55 f4 mov %edx,-0xc(%ebp)
51b: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
520: eb 1f jmp 541 <printint+0xa7>
522: eb 1d jmp 541 <printint+0xa7>
putc(fd, buf[i]);
524: 8d 55 dc lea -0x24(%ebp),%edx
527: 8b 45 f4 mov -0xc(%ebp),%eax
52a: 01 d0 add %edx,%eax
52c: 0f b6 00 movzbl (%eax),%eax
52f: 0f be c0 movsbl %al,%eax
532: 89 44 24 04 mov %eax,0x4(%esp)
536: 8b 45 08 mov 0x8(%ebp),%eax
539: 89 04 24 mov %eax,(%esp)
53c: e8 31 ff ff ff call 472 <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
541: 83 6d f4 01 subl $0x1,-0xc(%ebp)
545: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
549: 79 d9 jns 524 <printint+0x8a>
putc(fd, buf[i]);
}
54b: 83 c4 30 add $0x30,%esp
54e: 5b pop %ebx
54f: 5e pop %esi
550: 5d pop %ebp
551: c3 ret
00000552 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
552: 55 push %ebp
553: 89 e5 mov %esp,%ebp
555: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
558: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
55f: 8d 45 0c lea 0xc(%ebp),%eax
562: 83 c0 04 add $0x4,%eax
565: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
568: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
56f: e9 7c 01 00 00 jmp 6f0 <printf+0x19e>
c = fmt[i] & 0xff;
574: 8b 55 0c mov 0xc(%ebp),%edx
577: 8b 45 f0 mov -0x10(%ebp),%eax
57a: 01 d0 add %edx,%eax
57c: 0f b6 00 movzbl (%eax),%eax
57f: 0f be c0 movsbl %al,%eax
582: 25 ff 00 00 00 and $0xff,%eax
587: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
58a: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
58e: 75 2c jne 5bc <printf+0x6a>
if(c == '%'){
590: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
594: 75 0c jne 5a2 <printf+0x50>
state = '%';
596: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
59d: e9 4a 01 00 00 jmp 6ec <printf+0x19a>
} else {
putc(fd, c);
5a2: 8b 45 e4 mov -0x1c(%ebp),%eax
5a5: 0f be c0 movsbl %al,%eax
5a8: 89 44 24 04 mov %eax,0x4(%esp)
5ac: 8b 45 08 mov 0x8(%ebp),%eax
5af: 89 04 24 mov %eax,(%esp)
5b2: e8 bb fe ff ff call 472 <putc>
5b7: e9 30 01 00 00 jmp 6ec <printf+0x19a>
}
} else if(state == '%'){
5bc: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
5c0: 0f 85 26 01 00 00 jne 6ec <printf+0x19a>
if(c == 'd'){
5c6: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
5ca: 75 2d jne 5f9 <printf+0xa7>
printint(fd, *ap, 10, 1);
5cc: 8b 45 e8 mov -0x18(%ebp),%eax
5cf: 8b 00 mov (%eax),%eax
5d1: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
5d8: 00
5d9: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
5e0: 00
5e1: 89 44 24 04 mov %eax,0x4(%esp)
5e5: 8b 45 08 mov 0x8(%ebp),%eax
5e8: 89 04 24 mov %eax,(%esp)
5eb: e8 aa fe ff ff call 49a <printint>
ap++;
5f0: 83 45 e8 04 addl $0x4,-0x18(%ebp)
5f4: e9 ec 00 00 00 jmp 6e5 <printf+0x193>
} else if(c == 'x' || c == 'p'){
5f9: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
5fd: 74 06 je 605 <printf+0xb3>
5ff: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
603: 75 2d jne 632 <printf+0xe0>
printint(fd, *ap, 16, 0);
605: 8b 45 e8 mov -0x18(%ebp),%eax
608: 8b 00 mov (%eax),%eax
60a: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
611: 00
612: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
619: 00
61a: 89 44 24 04 mov %eax,0x4(%esp)
61e: 8b 45 08 mov 0x8(%ebp),%eax
621: 89 04 24 mov %eax,(%esp)
624: e8 71 fe ff ff call 49a <printint>
ap++;
629: 83 45 e8 04 addl $0x4,-0x18(%ebp)
62d: e9 b3 00 00 00 jmp 6e5 <printf+0x193>
} else if(c == 's'){
632: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
636: 75 45 jne 67d <printf+0x12b>
s = (char*)*ap;
638: 8b 45 e8 mov -0x18(%ebp),%eax
63b: 8b 00 mov (%eax),%eax
63d: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
640: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
644: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
648: 75 09 jne 653 <printf+0x101>
s = "(null)";
64a: c7 45 f4 78 09 00 00 movl $0x978,-0xc(%ebp)
while(*s != 0){
651: eb 1e jmp 671 <printf+0x11f>
653: eb 1c jmp 671 <printf+0x11f>
putc(fd, *s);
655: 8b 45 f4 mov -0xc(%ebp),%eax
658: 0f b6 00 movzbl (%eax),%eax
65b: 0f be c0 movsbl %al,%eax
65e: 89 44 24 04 mov %eax,0x4(%esp)
662: 8b 45 08 mov 0x8(%ebp),%eax
665: 89 04 24 mov %eax,(%esp)
668: e8 05 fe ff ff call 472 <putc>
s++;
66d: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
671: 8b 45 f4 mov -0xc(%ebp),%eax
674: 0f b6 00 movzbl (%eax),%eax
677: 84 c0 test %al,%al
679: 75 da jne 655 <printf+0x103>
67b: eb 68 jmp 6e5 <printf+0x193>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
67d: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
681: 75 1d jne 6a0 <printf+0x14e>
putc(fd, *ap);
683: 8b 45 e8 mov -0x18(%ebp),%eax
686: 8b 00 mov (%eax),%eax
688: 0f be c0 movsbl %al,%eax
68b: 89 44 24 04 mov %eax,0x4(%esp)
68f: 8b 45 08 mov 0x8(%ebp),%eax
692: 89 04 24 mov %eax,(%esp)
695: e8 d8 fd ff ff call 472 <putc>
ap++;
69a: 83 45 e8 04 addl $0x4,-0x18(%ebp)
69e: eb 45 jmp 6e5 <printf+0x193>
} else if(c == '%'){
6a0: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
6a4: 75 17 jne 6bd <printf+0x16b>
putc(fd, c);
6a6: 8b 45 e4 mov -0x1c(%ebp),%eax
6a9: 0f be c0 movsbl %al,%eax
6ac: 89 44 24 04 mov %eax,0x4(%esp)
6b0: 8b 45 08 mov 0x8(%ebp),%eax
6b3: 89 04 24 mov %eax,(%esp)
6b6: e8 b7 fd ff ff call 472 <putc>
6bb: eb 28 jmp 6e5 <printf+0x193>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
6bd: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
6c4: 00
6c5: 8b 45 08 mov 0x8(%ebp),%eax
6c8: 89 04 24 mov %eax,(%esp)
6cb: e8 a2 fd ff ff call 472 <putc>
putc(fd, c);
6d0: 8b 45 e4 mov -0x1c(%ebp),%eax
6d3: 0f be c0 movsbl %al,%eax
6d6: 89 44 24 04 mov %eax,0x4(%esp)
6da: 8b 45 08 mov 0x8(%ebp),%eax
6dd: 89 04 24 mov %eax,(%esp)
6e0: e8 8d fd ff ff call 472 <putc>
}
state = 0;
6e5: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6ec: 83 45 f0 01 addl $0x1,-0x10(%ebp)
6f0: 8b 55 0c mov 0xc(%ebp),%edx
6f3: 8b 45 f0 mov -0x10(%ebp),%eax
6f6: 01 d0 add %edx,%eax
6f8: 0f b6 00 movzbl (%eax),%eax
6fb: 84 c0 test %al,%al
6fd: 0f 85 71 fe ff ff jne 574 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
703: c9 leave
704: c3 ret
00000705 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
705: 55 push %ebp
706: 89 e5 mov %esp,%ebp
708: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
70b: 8b 45 08 mov 0x8(%ebp),%eax
70e: 83 e8 08 sub $0x8,%eax
711: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
714: a1 e0 0b 00 00 mov 0xbe0,%eax
719: 89 45 fc mov %eax,-0x4(%ebp)
71c: eb 24 jmp 742 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
71e: 8b 45 fc mov -0x4(%ebp),%eax
721: 8b 00 mov (%eax),%eax
723: 3b 45 fc cmp -0x4(%ebp),%eax
726: 77 12 ja 73a <free+0x35>
728: 8b 45 f8 mov -0x8(%ebp),%eax
72b: 3b 45 fc cmp -0x4(%ebp),%eax
72e: 77 24 ja 754 <free+0x4f>
730: 8b 45 fc mov -0x4(%ebp),%eax
733: 8b 00 mov (%eax),%eax
735: 3b 45 f8 cmp -0x8(%ebp),%eax
738: 77 1a ja 754 <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
73a: 8b 45 fc mov -0x4(%ebp),%eax
73d: 8b 00 mov (%eax),%eax
73f: 89 45 fc mov %eax,-0x4(%ebp)
742: 8b 45 f8 mov -0x8(%ebp),%eax
745: 3b 45 fc cmp -0x4(%ebp),%eax
748: 76 d4 jbe 71e <free+0x19>
74a: 8b 45 fc mov -0x4(%ebp),%eax
74d: 8b 00 mov (%eax),%eax
74f: 3b 45 f8 cmp -0x8(%ebp),%eax
752: 76 ca jbe 71e <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
754: 8b 45 f8 mov -0x8(%ebp),%eax
757: 8b 40 04 mov 0x4(%eax),%eax
75a: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
761: 8b 45 f8 mov -0x8(%ebp),%eax
764: 01 c2 add %eax,%edx
766: 8b 45 fc mov -0x4(%ebp),%eax
769: 8b 00 mov (%eax),%eax
76b: 39 c2 cmp %eax,%edx
76d: 75 24 jne 793 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
76f: 8b 45 f8 mov -0x8(%ebp),%eax
772: 8b 50 04 mov 0x4(%eax),%edx
775: 8b 45 fc mov -0x4(%ebp),%eax
778: 8b 00 mov (%eax),%eax
77a: 8b 40 04 mov 0x4(%eax),%eax
77d: 01 c2 add %eax,%edx
77f: 8b 45 f8 mov -0x8(%ebp),%eax
782: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
785: 8b 45 fc mov -0x4(%ebp),%eax
788: 8b 00 mov (%eax),%eax
78a: 8b 10 mov (%eax),%edx
78c: 8b 45 f8 mov -0x8(%ebp),%eax
78f: 89 10 mov %edx,(%eax)
791: eb 0a jmp 79d <free+0x98>
} else
bp->s.ptr = p->s.ptr;
793: 8b 45 fc mov -0x4(%ebp),%eax
796: 8b 10 mov (%eax),%edx
798: 8b 45 f8 mov -0x8(%ebp),%eax
79b: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
79d: 8b 45 fc mov -0x4(%ebp),%eax
7a0: 8b 40 04 mov 0x4(%eax),%eax
7a3: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
7aa: 8b 45 fc mov -0x4(%ebp),%eax
7ad: 01 d0 add %edx,%eax
7af: 3b 45 f8 cmp -0x8(%ebp),%eax
7b2: 75 20 jne 7d4 <free+0xcf>
p->s.size += bp->s.size;
7b4: 8b 45 fc mov -0x4(%ebp),%eax
7b7: 8b 50 04 mov 0x4(%eax),%edx
7ba: 8b 45 f8 mov -0x8(%ebp),%eax
7bd: 8b 40 04 mov 0x4(%eax),%eax
7c0: 01 c2 add %eax,%edx
7c2: 8b 45 fc mov -0x4(%ebp),%eax
7c5: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
7c8: 8b 45 f8 mov -0x8(%ebp),%eax
7cb: 8b 10 mov (%eax),%edx
7cd: 8b 45 fc mov -0x4(%ebp),%eax
7d0: 89 10 mov %edx,(%eax)
7d2: eb 08 jmp 7dc <free+0xd7>
} else
p->s.ptr = bp;
7d4: 8b 45 fc mov -0x4(%ebp),%eax
7d7: 8b 55 f8 mov -0x8(%ebp),%edx
7da: 89 10 mov %edx,(%eax)
freep = p;
7dc: 8b 45 fc mov -0x4(%ebp),%eax
7df: a3 e0 0b 00 00 mov %eax,0xbe0
}
7e4: c9 leave
7e5: c3 ret
000007e6 <morecore>:
static Header*
morecore(uint nu)
{
7e6: 55 push %ebp
7e7: 89 e5 mov %esp,%ebp
7e9: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
7ec: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
7f3: 77 07 ja 7fc <morecore+0x16>
nu = 4096;
7f5: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
7fc: 8b 45 08 mov 0x8(%ebp),%eax
7ff: c1 e0 03 shl $0x3,%eax
802: 89 04 24 mov %eax,(%esp)
805: e8 30 fc ff ff call 43a <sbrk>
80a: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
80d: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
811: 75 07 jne 81a <morecore+0x34>
return 0;
813: b8 00 00 00 00 mov $0x0,%eax
818: eb 22 jmp 83c <morecore+0x56>
hp = (Header*)p;
81a: 8b 45 f4 mov -0xc(%ebp),%eax
81d: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
820: 8b 45 f0 mov -0x10(%ebp),%eax
823: 8b 55 08 mov 0x8(%ebp),%edx
826: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
829: 8b 45 f0 mov -0x10(%ebp),%eax
82c: 83 c0 08 add $0x8,%eax
82f: 89 04 24 mov %eax,(%esp)
832: e8 ce fe ff ff call 705 <free>
return freep;
837: a1 e0 0b 00 00 mov 0xbe0,%eax
}
83c: c9 leave
83d: c3 ret
0000083e <malloc>:
void*
malloc(uint nbytes)
{
83e: 55 push %ebp
83f: 89 e5 mov %esp,%ebp
841: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
844: 8b 45 08 mov 0x8(%ebp),%eax
847: 83 c0 07 add $0x7,%eax
84a: c1 e8 03 shr $0x3,%eax
84d: 83 c0 01 add $0x1,%eax
850: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
853: a1 e0 0b 00 00 mov 0xbe0,%eax
858: 89 45 f0 mov %eax,-0x10(%ebp)
85b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
85f: 75 23 jne 884 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
861: c7 45 f0 d8 0b 00 00 movl $0xbd8,-0x10(%ebp)
868: 8b 45 f0 mov -0x10(%ebp),%eax
86b: a3 e0 0b 00 00 mov %eax,0xbe0
870: a1 e0 0b 00 00 mov 0xbe0,%eax
875: a3 d8 0b 00 00 mov %eax,0xbd8
base.s.size = 0;
87a: c7 05 dc 0b 00 00 00 movl $0x0,0xbdc
881: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
884: 8b 45 f0 mov -0x10(%ebp),%eax
887: 8b 00 mov (%eax),%eax
889: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
88c: 8b 45 f4 mov -0xc(%ebp),%eax
88f: 8b 40 04 mov 0x4(%eax),%eax
892: 3b 45 ec cmp -0x14(%ebp),%eax
895: 72 4d jb 8e4 <malloc+0xa6>
if(p->s.size == nunits)
897: 8b 45 f4 mov -0xc(%ebp),%eax
89a: 8b 40 04 mov 0x4(%eax),%eax
89d: 3b 45 ec cmp -0x14(%ebp),%eax
8a0: 75 0c jne 8ae <malloc+0x70>
prevp->s.ptr = p->s.ptr;
8a2: 8b 45 f4 mov -0xc(%ebp),%eax
8a5: 8b 10 mov (%eax),%edx
8a7: 8b 45 f0 mov -0x10(%ebp),%eax
8aa: 89 10 mov %edx,(%eax)
8ac: eb 26 jmp 8d4 <malloc+0x96>
else {
p->s.size -= nunits;
8ae: 8b 45 f4 mov -0xc(%ebp),%eax
8b1: 8b 40 04 mov 0x4(%eax),%eax
8b4: 2b 45 ec sub -0x14(%ebp),%eax
8b7: 89 c2 mov %eax,%edx
8b9: 8b 45 f4 mov -0xc(%ebp),%eax
8bc: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
8bf: 8b 45 f4 mov -0xc(%ebp),%eax
8c2: 8b 40 04 mov 0x4(%eax),%eax
8c5: c1 e0 03 shl $0x3,%eax
8c8: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
8cb: 8b 45 f4 mov -0xc(%ebp),%eax
8ce: 8b 55 ec mov -0x14(%ebp),%edx
8d1: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
8d4: 8b 45 f0 mov -0x10(%ebp),%eax
8d7: a3 e0 0b 00 00 mov %eax,0xbe0
return (void*)(p + 1);
8dc: 8b 45 f4 mov -0xc(%ebp),%eax
8df: 83 c0 08 add $0x8,%eax
8e2: eb 38 jmp 91c <malloc+0xde>
}
if(p == freep)
8e4: a1 e0 0b 00 00 mov 0xbe0,%eax
8e9: 39 45 f4 cmp %eax,-0xc(%ebp)
8ec: 75 1b jne 909 <malloc+0xcb>
if((p = morecore(nunits)) == 0)
8ee: 8b 45 ec mov -0x14(%ebp),%eax
8f1: 89 04 24 mov %eax,(%esp)
8f4: e8 ed fe ff ff call 7e6 <morecore>
8f9: 89 45 f4 mov %eax,-0xc(%ebp)
8fc: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
900: 75 07 jne 909 <malloc+0xcb>
return 0;
902: b8 00 00 00 00 mov $0x0,%eax
907: eb 13 jmp 91c <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
909: 8b 45 f4 mov -0xc(%ebp),%eax
90c: 89 45 f0 mov %eax,-0x10(%ebp)
90f: 8b 45 f4 mov -0xc(%ebp),%eax
912: 8b 00 mov (%eax),%eax
914: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
917: e9 70 ff ff ff jmp 88c <malloc+0x4e>
}
91c: c9 leave
91d: c3 ret
|
; A071556: Smallest x > 1 such that x^prime(n) == 1 mod(prime(i)) 4<=i<=n.
; 8,78,1002,17018,323324,7436430,215656442,6685349672,247357937828,10141675450908,436092044389002,20496326086283048,1086305282573001492,64092011671807087970,3909612711980232366110,261944051702675568529304
add $0,4
seq $0,2110 ; Primorial numbers (first definition): product of first n primes. Sometimes written prime(n)#.
sub $0,210
div $0,30
add $0,8
|
; A336627: Coordination sequence for the Manhattan lattice.
; 1,2,4,8,11,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224
mov $2,$0
add $2,1
mov $8,$0
lpb $2
mov $0,$8
sub $2,1
sub $0,$2
mov $6,2
mov $9,$0
lpb $6
mov $0,$9
sub $6,1
add $0,$6
sub $0,2
mul $0,3
trn $0,2
mov $3,$0
mov $7,$0
lpb $0
mul $3,2
sub $3,7
mov $7,$0
mov $0,$3
trn $0,1
mov $3,1
lpe
mov $5,$6
lpb $5
mov $4,$7
sub $5,1
lpe
lpe
lpb $9
sub $4,$7
mov $9,0
lpe
mov $7,$4
add $7,1
add $1,$7
lpe
mov $0,$1
|
// 6/2 Struktúrák, tag-tömbökkel (DB 4)
#include <iostream>
#define DB 2
using namespace std;
struct step
{
char kar[DB];
int lep[DB];
};
void kiir(struct step sp1)
{
for (int fut = 0; fut < DB; fut++)
{
cout << "\n A kódolás " << fut + 1 << ". karaktere a léptetés után: '"
<< sp1.kar[fut] << "' lett!";
}
cout << endl;
}
int main(void)
{
struct step s1;
for (int fut = 0; fut < DB; fut++)
{
cout << "\n Kérem a kódolás " << fut + 1 << ". karakterét: ";
cin >> s1.kar[fut];
cout << "\t Kérem a kódolás " << fut + 1 << ". karakterének a lépésszámát: ";
cin >> s1.lep[fut];
}
for (int fut = 0; fut < DB; fut++)
{
s1.kar[fut] += s1.lep[fut];
}
kiir(s1);
return 0;
} |
/*
* Copyright (c) 2017, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include <tuple>
#include <vector>
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
#include "config/av1_rtcd.h"
#include "aom_ports/aom_timer.h"
#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h"
#include "test/util.h"
#include "av1/common/common_data.h"
namespace {
const int kTestIters = 10;
const int kPerfIters = 1000;
const int kVPad = 32;
const int kHPad = 32;
const int kXStepQn = 16;
const int kYStepQn = 20;
using libaom_test::ACMRandom;
using std::make_tuple;
using std::tuple;
enum NTaps { EIGHT_TAP, TEN_TAP, TWELVE_TAP };
int NTapsToInt(NTaps ntaps) { return 8 + static_cast<int>(ntaps) * 2; }
// A 16-bit filter with a configurable number of taps.
class TestFilter {
public:
void set(NTaps ntaps, bool backwards);
InterpFilterParams params_;
private:
std::vector<int16_t> coeffs_;
};
void TestFilter::set(NTaps ntaps, bool backwards) {
const int n = NTapsToInt(ntaps);
assert(n >= 8 && n <= 12);
// The filter has n * SUBPEL_SHIFTS proper elements and an extra 8 bogus
// elements at the end so that convolutions can read off the end safely.
coeffs_.resize(n * SUBPEL_SHIFTS + 8);
// The coefficients are pretty much arbitrary, but convolutions shouldn't
// over or underflow. For the first filter (subpels = 0), we use an
// increasing or decreasing ramp (depending on the backwards parameter). We
// don't want any zero coefficients, so we make it have an x-intercept at -1
// or n. To ensure absence of under/overflow, we normalise the area under the
// ramp to be I = 1 << FILTER_BITS (so that convolving a constant function
// gives the identity).
//
// When increasing, the function has the form:
//
// f(x) = A * (x + 1)
//
// Summing and rearranging for A gives A = 2 * I / (n * (n + 1)). If the
// filter is reversed, we have the same A but with formula
//
// g(x) = A * (n - x)
const int I = 1 << FILTER_BITS;
const float A = 2.f * I / (n * (n + 1.f));
for (int i = 0; i < n; ++i) {
coeffs_[i] = static_cast<int16_t>(A * (backwards ? (n - i) : (i + 1)));
}
// For the other filters, make them slightly different by swapping two
// columns. Filter k will have the columns (k % n) and (7 * k) % n swapped.
const size_t filter_size = sizeof(coeffs_[0] * n);
int16_t *const filter0 = &coeffs_[0];
for (int k = 1; k < SUBPEL_SHIFTS; ++k) {
int16_t *filterk = &coeffs_[k * n];
memcpy(filterk, filter0, filter_size);
const int idx0 = k % n;
const int idx1 = (7 * k) % n;
const int16_t tmp = filterk[idx0];
filterk[idx0] = filterk[idx1];
filterk[idx1] = tmp;
}
// Finally, write some rubbish at the end to make sure we don't use it.
for (int i = 0; i < 8; ++i) coeffs_[n * SUBPEL_SHIFTS + i] = 123 + i;
// Fill in params
params_.filter_ptr = &coeffs_[0];
params_.taps = n;
// These are ignored by the functions being tested. Set them to whatever.
params_.subpel_shifts = SUBPEL_SHIFTS;
params_.interp_filter = EIGHTTAP_REGULAR;
}
template <typename SrcPixel>
class TestImage {
public:
TestImage(int w, int h, int bd) : w_(w), h_(h), bd_(bd) {
assert(bd < 16);
assert(bd <= 8 * static_cast<int>(sizeof(SrcPixel)));
// Pad width by 2*kHPad and then round up to the next multiple of 16
// to get src_stride_. Add another 16 for dst_stride_ (to make sure
// something goes wrong if we use the wrong one)
src_stride_ = (w_ + 2 * kHPad + 15) & ~15;
dst_stride_ = src_stride_ + 16;
// Allocate image data
src_data_.resize(2 * src_block_size());
dst_data_.resize(2 * dst_block_size());
dst_16_data_.resize(2 * dst_block_size());
}
void Initialize(ACMRandom *rnd);
void Check() const;
int src_stride() const { return src_stride_; }
int dst_stride() const { return dst_stride_; }
int src_block_size() const { return (h_ + 2 * kVPad) * src_stride(); }
int dst_block_size() const { return (h_ + 2 * kVPad) * dst_stride(); }
const SrcPixel *GetSrcData(bool ref, bool borders) const {
const SrcPixel *block = &src_data_[ref ? 0 : src_block_size()];
return borders ? block : block + kHPad + src_stride_ * kVPad;
}
SrcPixel *GetDstData(bool ref, bool borders) {
SrcPixel *block = &dst_data_[ref ? 0 : dst_block_size()];
return borders ? block : block + kHPad + dst_stride_ * kVPad;
}
CONV_BUF_TYPE *GetDst16Data(bool ref, bool borders) {
CONV_BUF_TYPE *block = &dst_16_data_[ref ? 0 : dst_block_size()];
return borders ? block : block + kHPad + dst_stride_ * kVPad;
}
private:
int w_, h_, bd_;
int src_stride_, dst_stride_;
std::vector<SrcPixel> src_data_;
std::vector<SrcPixel> dst_data_;
std::vector<CONV_BUF_TYPE> dst_16_data_;
};
template <typename Pixel>
void FillEdge(ACMRandom *rnd, int num_pixels, int bd, bool trash, Pixel *data) {
if (!trash) {
memset(data, 0, sizeof(*data) * num_pixels);
return;
}
const Pixel mask = (1 << bd) - 1;
for (int i = 0; i < num_pixels; ++i) data[i] = rnd->Rand16() & mask;
}
template <typename Pixel>
void PrepBuffers(ACMRandom *rnd, int w, int h, int stride, int bd,
bool trash_edges, Pixel *data) {
assert(rnd);
const Pixel mask = (1 << bd) - 1;
// Fill in the first buffer with random data
// Top border
FillEdge(rnd, stride * kVPad, bd, trash_edges, data);
for (int r = 0; r < h; ++r) {
Pixel *row_data = data + (kVPad + r) * stride;
// Left border, contents, right border
FillEdge(rnd, kHPad, bd, trash_edges, row_data);
for (int c = 0; c < w; ++c) row_data[kHPad + c] = rnd->Rand16() & mask;
FillEdge(rnd, kHPad, bd, trash_edges, row_data + kHPad + w);
}
// Bottom border
FillEdge(rnd, stride * kVPad, bd, trash_edges, data + stride * (kVPad + h));
const int bpp = sizeof(*data);
const int block_elts = stride * (h + 2 * kVPad);
const int block_size = bpp * block_elts;
// Now copy that to the second buffer
memcpy(data + block_elts, data, block_size);
}
template <typename SrcPixel>
void TestImage<SrcPixel>::Initialize(ACMRandom *rnd) {
PrepBuffers(rnd, w_, h_, src_stride_, bd_, false, &src_data_[0]);
PrepBuffers(rnd, w_, h_, dst_stride_, bd_, true, &dst_data_[0]);
PrepBuffers(rnd, w_, h_, dst_stride_, bd_, true, &dst_16_data_[0]);
}
template <typename SrcPixel>
void TestImage<SrcPixel>::Check() const {
// If memcmp returns 0, there's nothing to do.
const int num_pixels = dst_block_size();
const SrcPixel *ref_dst = &dst_data_[0];
const SrcPixel *tst_dst = &dst_data_[num_pixels];
const CONV_BUF_TYPE *ref_16_dst = &dst_16_data_[0];
const CONV_BUF_TYPE *tst_16_dst = &dst_16_data_[num_pixels];
if (0 == memcmp(ref_dst, tst_dst, sizeof(*ref_dst) * num_pixels)) {
if (0 == memcmp(ref_16_dst, tst_16_dst, sizeof(*ref_16_dst) * num_pixels))
return;
}
// Otherwise, iterate through the buffer looking for differences (including
// the edges)
const int stride = dst_stride_;
for (int r = 0; r < h_ + 2 * kVPad; ++r) {
for (int c = 0; c < w_ + 2 * kHPad; ++c) {
const int32_t ref_value = ref_dst[r * stride + c];
const int32_t tst_value = tst_dst[r * stride + c];
EXPECT_EQ(tst_value, ref_value)
<< "Error at row: " << (r - kVPad) << ", col: " << (c - kHPad);
}
}
for (int r = 0; r < h_ + 2 * kVPad; ++r) {
for (int c = 0; c < w_ + 2 * kHPad; ++c) {
const int32_t ref_value = ref_16_dst[r * stride + c];
const int32_t tst_value = tst_16_dst[r * stride + c];
EXPECT_EQ(tst_value, ref_value)
<< "Error in 16 bit buffer "
<< "Error at row: " << (r - kVPad) << ", col: " << (c - kHPad);
}
}
}
typedef tuple<int, int> BlockDimension;
struct BaseParams {
BaseParams(BlockDimension dims, NTaps ntaps_x, NTaps ntaps_y, bool avg)
: dims(dims), ntaps_x(ntaps_x), ntaps_y(ntaps_y), avg(avg) {}
BlockDimension dims;
NTaps ntaps_x, ntaps_y;
bool avg;
};
template <typename SrcPixel>
class ConvolveScaleTestBase : public ::testing::Test {
public:
ConvolveScaleTestBase() : image_(NULL) {}
virtual ~ConvolveScaleTestBase() { delete image_; }
virtual void TearDown() { libaom_test::ClearSystemState(); }
// Implemented by subclasses (SetUp depends on the parameters passed
// in and RunOne depends on the function to be tested. These can't
// be templated for low/high bit depths because they have different
// numbers of parameters)
virtual void SetUp() = 0;
virtual void RunOne(bool ref) = 0;
protected:
void SetParams(const BaseParams ¶ms, int bd) {
width_ = std::get<0>(params.dims);
height_ = std::get<1>(params.dims);
ntaps_x_ = params.ntaps_x;
ntaps_y_ = params.ntaps_y;
bd_ = bd;
avg_ = params.avg;
filter_x_.set(ntaps_x_, false);
filter_y_.set(ntaps_y_, true);
convolve_params_ =
get_conv_params_no_round(avg_ != false, 0, NULL, 0, 1, bd);
delete image_;
image_ = new TestImage<SrcPixel>(width_, height_, bd_);
}
void SetConvParamOffset(int i, int j, int is_compound, int do_average,
int use_dist_wtd_comp_avg) {
if (i == -1 && j == -1) {
convolve_params_.use_dist_wtd_comp_avg = use_dist_wtd_comp_avg;
convolve_params_.is_compound = is_compound;
convolve_params_.do_average = do_average;
} else {
convolve_params_.use_dist_wtd_comp_avg = use_dist_wtd_comp_avg;
convolve_params_.fwd_offset = quant_dist_lookup_table[i][j][0];
convolve_params_.bck_offset = quant_dist_lookup_table[i][j][1];
convolve_params_.is_compound = is_compound;
convolve_params_.do_average = do_average;
}
}
void Run() {
ACMRandom rnd(ACMRandom::DeterministicSeed());
for (int i = 0; i < kTestIters; ++i) {
int is_compound = 0;
SetConvParamOffset(-1, -1, is_compound, 0, 0);
Prep(&rnd);
RunOne(true);
RunOne(false);
image_->Check();
is_compound = 1;
for (int do_average = 0; do_average < 2; do_average++) {
for (int use_dist_wtd_comp_avg = 0; use_dist_wtd_comp_avg < 2;
use_dist_wtd_comp_avg++) {
for (int j = 0; j < 2; ++j) {
for (int k = 0; k < 4; ++k) {
SetConvParamOffset(j, k, is_compound, do_average,
use_dist_wtd_comp_avg);
Prep(&rnd);
RunOne(true);
RunOne(false);
image_->Check();
}
}
}
}
}
}
void SpeedTest() {
ACMRandom rnd(ACMRandom::DeterministicSeed());
Prep(&rnd);
aom_usec_timer ref_timer;
aom_usec_timer_start(&ref_timer);
for (int i = 0; i < kPerfIters; ++i) RunOne(true);
aom_usec_timer_mark(&ref_timer);
const int64_t ref_time = aom_usec_timer_elapsed(&ref_timer);
aom_usec_timer tst_timer;
aom_usec_timer_start(&tst_timer);
for (int i = 0; i < kPerfIters; ++i) RunOne(false);
aom_usec_timer_mark(&tst_timer);
const int64_t tst_time = aom_usec_timer_elapsed(&tst_timer);
std::cout << "[ ] C time = " << ref_time / 1000
<< " ms, SIMD time = " << tst_time / 1000 << " ms\n";
EXPECT_GT(ref_time, tst_time)
<< "Error: CDEFSpeedTest, SIMD slower than C.\n"
<< "C time: " << ref_time << " us\n"
<< "SIMD time: " << tst_time << " us\n";
}
static int RandomSubpel(ACMRandom *rnd) {
const uint8_t subpel_mode = rnd->Rand8();
if ((subpel_mode & 7) == 0) {
return 0;
} else if ((subpel_mode & 7) == 1) {
return SCALE_SUBPEL_SHIFTS - 1;
} else {
return 1 + rnd->PseudoUniform(SCALE_SUBPEL_SHIFTS - 2);
}
}
void Prep(ACMRandom *rnd) {
assert(rnd);
// Choose subpel_x_ and subpel_y_. They should be less than
// SCALE_SUBPEL_SHIFTS; we also want to add extra weight to "interesting"
// values: 0 and SCALE_SUBPEL_SHIFTS - 1
subpel_x_ = RandomSubpel(rnd);
subpel_y_ = RandomSubpel(rnd);
image_->Initialize(rnd);
}
int width_, height_, bd_;
NTaps ntaps_x_, ntaps_y_;
bool avg_;
int subpel_x_, subpel_y_;
TestFilter filter_x_, filter_y_;
TestImage<SrcPixel> *image_;
ConvolveParams convolve_params_;
};
typedef tuple<int, int> BlockDimension;
typedef void (*LowbdConvolveFunc)(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_qn, const int x_step_qn,
const int subpel_y_qn, const int y_step_qn,
ConvolveParams *conv_params);
// Test parameter list:
// <tst_fun, dims, ntaps_x, ntaps_y, avg>
typedef tuple<LowbdConvolveFunc, BlockDimension, NTaps, NTaps, bool>
LowBDParams;
class LowBDConvolveScaleTest
: public ConvolveScaleTestBase<uint8_t>,
public ::testing::WithParamInterface<LowBDParams> {
public:
virtual ~LowBDConvolveScaleTest() {}
void SetUp() {
tst_fun_ = GET_PARAM(0);
const BlockDimension &block = GET_PARAM(1);
const NTaps ntaps_x = GET_PARAM(2);
const NTaps ntaps_y = GET_PARAM(3);
const int bd = 8;
const bool avg = GET_PARAM(4);
SetParams(BaseParams(block, ntaps_x, ntaps_y, avg), bd);
}
void RunOne(bool ref) {
const uint8_t *src = image_->GetSrcData(ref, false);
uint8_t *dst = image_->GetDstData(ref, false);
convolve_params_.dst = image_->GetDst16Data(ref, false);
const int src_stride = image_->src_stride();
const int dst_stride = image_->dst_stride();
if (ref) {
av1_convolve_2d_scale_c(src, src_stride, dst, dst_stride, width_, height_,
&filter_x_.params_, &filter_y_.params_, subpel_x_,
kXStepQn, subpel_y_, kYStepQn, &convolve_params_);
} else {
tst_fun_(src, src_stride, dst, dst_stride, width_, height_,
&filter_x_.params_, &filter_y_.params_, subpel_x_, kXStepQn,
subpel_y_, kYStepQn, &convolve_params_);
}
}
private:
LowbdConvolveFunc tst_fun_;
};
const BlockDimension kBlockDim[] = {
make_tuple(2, 2), make_tuple(2, 4), make_tuple(4, 4),
make_tuple(4, 8), make_tuple(8, 4), make_tuple(8, 8),
make_tuple(8, 16), make_tuple(16, 8), make_tuple(16, 16),
make_tuple(16, 32), make_tuple(32, 16), make_tuple(32, 32),
make_tuple(32, 64), make_tuple(64, 32), make_tuple(64, 64),
make_tuple(64, 128), make_tuple(128, 64), make_tuple(128, 128),
};
const NTaps kNTaps[] = { EIGHT_TAP };
TEST_P(LowBDConvolveScaleTest, Check) { Run(); }
TEST_P(LowBDConvolveScaleTest, DISABLED_Speed) { SpeedTest(); }
INSTANTIATE_TEST_SUITE_P(
SSE4_1, LowBDConvolveScaleTest,
::testing::Combine(::testing::Values(av1_convolve_2d_scale_sse4_1),
::testing::ValuesIn(kBlockDim),
::testing::ValuesIn(kNTaps), ::testing::ValuesIn(kNTaps),
::testing::Bool()));
#if CONFIG_AV1_HIGHBITDEPTH
typedef void (*HighbdConvolveFunc)(const uint16_t *src, int src_stride,
uint16_t *dst, int dst_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_qn, const int x_step_qn,
const int subpel_y_qn, const int y_step_qn,
ConvolveParams *conv_params, int bd);
// Test parameter list:
// <tst_fun, dims, ntaps_x, ntaps_y, avg, bd>
typedef tuple<HighbdConvolveFunc, BlockDimension, NTaps, NTaps, bool, int>
HighBDParams;
class HighBDConvolveScaleTest
: public ConvolveScaleTestBase<uint16_t>,
public ::testing::WithParamInterface<HighBDParams> {
public:
virtual ~HighBDConvolveScaleTest() {}
void SetUp() {
tst_fun_ = GET_PARAM(0);
const BlockDimension &block = GET_PARAM(1);
const NTaps ntaps_x = GET_PARAM(2);
const NTaps ntaps_y = GET_PARAM(3);
const bool avg = GET_PARAM(4);
const int bd = GET_PARAM(5);
SetParams(BaseParams(block, ntaps_x, ntaps_y, avg), bd);
}
void RunOne(bool ref) {
const uint16_t *src = image_->GetSrcData(ref, false);
uint16_t *dst = image_->GetDstData(ref, false);
convolve_params_.dst = image_->GetDst16Data(ref, false);
const int src_stride = image_->src_stride();
const int dst_stride = image_->dst_stride();
if (ref) {
av1_highbd_convolve_2d_scale_c(
src, src_stride, dst, dst_stride, width_, height_, &filter_x_.params_,
&filter_y_.params_, subpel_x_, kXStepQn, subpel_y_, kYStepQn,
&convolve_params_, bd_);
} else {
tst_fun_(src, src_stride, dst, dst_stride, width_, height_,
&filter_x_.params_, &filter_y_.params_, subpel_x_, kXStepQn,
subpel_y_, kYStepQn, &convolve_params_, bd_);
}
}
private:
HighbdConvolveFunc tst_fun_;
};
const int kBDs[] = { 8, 10, 12 };
TEST_P(HighBDConvolveScaleTest, Check) { Run(); }
TEST_P(HighBDConvolveScaleTest, DISABLED_Speed) { SpeedTest(); }
INSTANTIATE_TEST_SUITE_P(
SSE4_1, HighBDConvolveScaleTest,
::testing::Combine(::testing::Values(av1_highbd_convolve_2d_scale_sse4_1),
::testing::ValuesIn(kBlockDim),
::testing::ValuesIn(kNTaps), ::testing::ValuesIn(kNTaps),
::testing::Bool(), ::testing::ValuesIn(kBDs)));
#endif // CONFIG_AV1_HIGHBITDEPTH
} // namespace
|
; $Id: beeper.asm,v 1.2 2002/04/17 21:30:23 dom Exp $
;
; Generic 1 bit sound functions
;
XLIB beeper
INCLUDE "games/games.inc"
LIB bit_open_di
LIB bit_close_ei
;
; Ported by Dominic Morris
; Adapted by Stefano Bodrato
;
; Entry as for Spectrum beeper routine!!
;
; Direct transfer, of code..no point commenting really
;
.beeper
ld a,l
srl l
srl l
cpl
and 3
ld c,a
ld b,0
ld ix,beixp3
add ix,bc
call bit_open_di
.beixp3
nop
nop
nop
inc b
inc c
.behllp dec c
jr nz,behllp
ld c,$3F
dec b
jp nz,behllp
xor sndbit_mask
out (sndbit_port),a
ld b,h
ld c,a
bit sndbit_bit,a ;if o/p go again!
jr nz,be_again
ld a,d
or e
jr z,be_end
ld a,c
ld c,l
dec de
jp (ix)
.be_again
ld c,l
inc c
jp (ix)
.be_end
jp bit_close_ei
|
; A116091: Expansion of 1/sqrt(1+4*x+16*x^2).
; Submitted by Christian Krause
; 1,-2,-2,28,-74,-92,1324,-3656,-4826,70228,-197372,-267896,3921724,-11126936,-15347432,225505648,-643622906,-897078476,13214495764,-37869162392,-53170602284,784672445368,-2255295815192,-3183829452272,47051201187676,-135537088268792,-192142210448216,2842611223234384,-8202921415791176,-11667475400303792,172763921138765104,-499251941509145888,-712036257958597178,10550960835978797812,-30525694347618223436,-43633624994318605016,646954543996095751012,-1873578254775742247528,-2683167153403351249208
mov $1,1
mov $3,$0
mov $4,1
lpb $3
mul $1,$3
mul $1,$3
sub $4,2
add $5,$4
div $1,$5
mul $1,3
add $2,$1
sub $3,1
lpe
mov $0,$2
add $0,1
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "hud.h"
#include "hudelement.h"
#include "hud_macros.h"
#include "hud_numericdisplay.h"
#include "iclientmode.h"
#include "iclientvehicle.h"
#include <vgui_controls/AnimationController.h>
#include <vgui/ILocalize.h>
#include "ihudlcd.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// Purpose: Displays current ammunition level
//-----------------------------------------------------------------------------
class CHudAmmo : public CHudNumericDisplay, public CHudElement
{
DECLARE_CLASS_SIMPLE( CHudAmmo, CHudNumericDisplay );
public:
CHudAmmo( const char *pElementName );
void Init( void );
void VidInit( void );
void Reset();
void SetAmmo(int ammo, bool playAnimation);
void SetAmmo2(int ammo2, bool playAnimation);
protected:
virtual void OnThink();
void UpdateAmmoDisplays();
void UpdatePlayerAmmo( C_BasePlayer *player );
private:
CHandle< C_BaseCombatWeapon > m_hCurrentActiveWeapon;
CHandle< C_BaseEntity > m_hCurrentVehicle;
int m_iAmmo;
int m_iAmmo2;
};
DECLARE_HUDELEMENT( CHudAmmo );
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CHudAmmo::CHudAmmo( const char *pElementName ) : BaseClass(NULL, "HudAmmo"), CHudElement( pElementName )
{
SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT | HIDEHUD_WEAPONSELECTION );
hudlcd->SetGlobalStat( "(ammo_primary)", "0" );
hudlcd->SetGlobalStat( "(ammo_secondary)", "0" );
hudlcd->SetGlobalStat( "(weapon_print_name)", "" );
hudlcd->SetGlobalStat( "(weapon_name)", "" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudAmmo::Init( void )
{
m_iAmmo = -1;
m_iAmmo2 = -1;
wchar_t *tempString = g_pVGuiLocalize->Find("#Valve_Hud_AMMO");
if (tempString)
{
SetLabelText(tempString);
}
else
{
SetLabelText(L"AMMO");
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudAmmo::VidInit( void )
{
}
//-----------------------------------------------------------------------------
// Purpose: Resets hud after save/restore
//-----------------------------------------------------------------------------
void CHudAmmo::Reset()
{
BaseClass::Reset();
m_hCurrentActiveWeapon = NULL;
m_hCurrentVehicle = NULL;
m_iAmmo = 0;
m_iAmmo2 = 0;
UpdateAmmoDisplays();
}
//-----------------------------------------------------------------------------
// Purpose: called every frame to get ammo info from the weapon
//-----------------------------------------------------------------------------
void CHudAmmo::UpdatePlayerAmmo( C_BasePlayer *player )
{
// Clear out the vehicle entity
m_hCurrentVehicle = NULL;
C_BaseCombatWeapon *wpn = GetActiveWeapon();
hudlcd->SetGlobalStat( "(weapon_print_name)", wpn ? wpn->GetPrintName() : " " );
hudlcd->SetGlobalStat( "(weapon_name)", wpn ? wpn->GetName() : " " );
if ( !wpn || !player || !wpn->UsesPrimaryAmmo() )
{
hudlcd->SetGlobalStat( "(ammo_primary)", "n/a" );
hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" );
SetPaintEnabled(false);
SetPaintBackgroundEnabled(false);
return;
}
SetPaintEnabled(true);
SetPaintBackgroundEnabled(true);
// get the ammo in our clip
int ammo1 = wpn->Clip1();
int ammo2;
if (ammo1 < 0)
{
// we don't use clip ammo, just use the total ammo count
ammo1 = player->GetAmmoCount(wpn->GetPrimaryAmmoType());
ammo2 = 0;
}
else
{
// we use clip ammo, so the second ammo is the total ammo
ammo2 = player->GetAmmoCount(wpn->GetPrimaryAmmoType());
}
hudlcd->SetGlobalStat( "(ammo_primary)", VarArgs( "%d", ammo1 ) );
hudlcd->SetGlobalStat( "(ammo_secondary)", VarArgs( "%d", ammo2 ) );
if (wpn == m_hCurrentActiveWeapon)
{
// same weapon, just update counts
SetAmmo(ammo1, true);
SetAmmo2(ammo2, true);
}
else
{
// diferent weapon, change without triggering
SetAmmo(ammo1, false);
SetAmmo2(ammo2, false);
// update whether or not we show the total ammo display
if (wpn->UsesClipsForAmmo1())
{
SetShouldDisplaySecondaryValue(true);
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponUsesClips");
}
else
{
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponDoesNotUseClips");
SetShouldDisplaySecondaryValue(false);
}
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponChanged");
m_hCurrentActiveWeapon = wpn;
}
}
/*
void CHudAmmo::UpdateVehicleAmmo( C_BasePlayer *player, IClientVehicle *pVehicle )
{
m_hCurrentActiveWeapon = NULL;
CBaseEntity *pVehicleEnt = pVehicle->GetVehicleEnt();
if ( !pVehicleEnt || pVehicle->GetPrimaryAmmoType() < 0 )
{
SetPaintEnabled(false);
SetPaintBackgroundEnabled(false);
return;
}
SetPaintEnabled(true);
SetPaintBackgroundEnabled(true);
// get the ammo in our clip
int ammo1 = pVehicle->GetPrimaryAmmoClip();
int ammo2;
if (ammo1 < 0)
{
// we don't use clip ammo, just use the total ammo count
ammo1 = pVehicle->GetPrimaryAmmoCount();
ammo2 = 0;
}
else
{
// we use clip ammo, so the second ammo is the total ammo
ammo2 = pVehicle->GetPrimaryAmmoCount();
}
if (pVehicleEnt == m_hCurrentVehicle)
{
// same weapon, just update counts
SetAmmo(ammo1, true);
SetAmmo2(ammo2, true);
}
else
{
// diferent weapon, change without triggering
SetAmmo(ammo1, false);
SetAmmo2(ammo2, false);
// update whether or not we show the total ammo display
if (pVehicle->PrimaryAmmoUsesClips())
{
SetShouldDisplaySecondaryValue(true);
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponUsesClips");
}
else
{
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponDoesNotUseClips");
SetShouldDisplaySecondaryValue(false);
}
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponChanged");
m_hCurrentVehicle = pVehicleEnt;
}
}
*/
//-----------------------------------------------------------------------------
// Purpose: called every frame to get ammo info from the weapon
//-----------------------------------------------------------------------------
void CHudAmmo::OnThink()
{
UpdateAmmoDisplays();
}
//-----------------------------------------------------------------------------
// Purpose: updates the ammo display counts
//-----------------------------------------------------------------------------
void CHudAmmo::UpdateAmmoDisplays()
{
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
UpdatePlayerAmmo( player );
}
//-----------------------------------------------------------------------------
// Purpose: Updates ammo display
//-----------------------------------------------------------------------------
void CHudAmmo::SetAmmo(int ammo, bool playAnimation)
{
if (ammo != m_iAmmo)
{
if (ammo == 0)
{
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("AmmoEmpty");
}
else if (ammo < m_iAmmo)
{
// ammo has decreased
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("AmmoDecreased");
}
else
{
// ammunition has increased
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("AmmoIncreased");
}
m_iAmmo = ammo;
}
SetDisplayValue(ammo);
}
//-----------------------------------------------------------------------------
// Purpose: Updates 2nd ammo display
//-----------------------------------------------------------------------------
void CHudAmmo::SetAmmo2(int ammo2, bool playAnimation)
{
if (ammo2 != m_iAmmo2)
{
if (ammo2 == 0)
{
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("Ammo2Empty");
}
else if (ammo2 < m_iAmmo2)
{
// ammo has decreased
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("Ammo2Decreased");
}
else
{
// ammunition has increased
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("Ammo2Increased");
}
m_iAmmo2 = ammo2;
}
SetSecondaryValue(ammo2);
}
//-----------------------------------------------------------------------------
// Purpose: Displays the secondary ammunition level
//-----------------------------------------------------------------------------
class CHudSecondaryAmmo : public CHudNumericDisplay, public CHudElement
{
DECLARE_CLASS_SIMPLE( CHudSecondaryAmmo, CHudNumericDisplay );
public:
CHudSecondaryAmmo( const char *pElementName ) : BaseClass( NULL, "HudAmmoSecondary" ), CHudElement( pElementName )
{
m_iAmmo = -1;
SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_WEAPONSELECTION | HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT );
}
void Init( void )
{
}
void VidInit( void )
{
}
void SetAmmo( int ammo )
{
if (ammo != m_iAmmo)
{
if (ammo == 0)
{
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("AmmoSecondaryEmpty");
}
else if (ammo < m_iAmmo)
{
// ammo has decreased
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("AmmoSecondaryDecreased");
}
else
{
// ammunition has increased
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("AmmoSecondaryIncreased");
}
m_iAmmo = ammo;
}
SetDisplayValue( ammo );
}
void Reset()
{
// hud reset, update ammo state
BaseClass::Reset();
m_iAmmo = 0;
m_hCurrentActiveWeapon = NULL;
SetAlpha( 0 );
UpdateAmmoState();
}
protected:
virtual void OnThink()
{
// set whether or not the panel draws based on if we have a weapon that supports secondary ammo
C_BaseCombatWeapon *wpn = GetActiveWeapon();
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
IClientVehicle *pVehicle = player ? player->GetVehicle() : NULL;
if (!wpn || !player || pVehicle)
{
m_hCurrentActiveWeapon = NULL;
SetPaintEnabled(false);
SetPaintBackgroundEnabled(false);
return;
}
else
{
SetPaintEnabled(true);
SetPaintBackgroundEnabled(true);
}
UpdateAmmoState();
}
void UpdateAmmoState()
{
C_BaseCombatWeapon *wpn = GetActiveWeapon();
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
if (player && wpn && wpn->UsesSecondaryAmmo())
{
SetAmmo(player->GetAmmoCount(wpn->GetSecondaryAmmoType()));
}
if ( m_hCurrentActiveWeapon != wpn )
{
if ( wpn->UsesSecondaryAmmo() )
{
// we've changed to a weapon that uses secondary ammo
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponUsesSecondaryAmmo");
}
else
{
// we've changed away from a weapon that uses secondary ammo
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponDoesNotUseSecondaryAmmo");
}
m_hCurrentActiveWeapon = wpn;
}
}
private:
CHandle< C_BaseCombatWeapon > m_hCurrentActiveWeapon;
int m_iAmmo;
};
DECLARE_HUDELEMENT( CHudSecondaryAmmo );
|
.nds
.relativeinclude on
.erroronwarning on
; This patch makes it so getting a boss orb in Mystery Manor or Ecclesia will reload the room.
; This is because the cutscene after beating Albus/Barlowe won't play until the room is reloaded.
; Albus/Barlowe normally reload the room on defeat, but in boss randomizer something else needs to do it.
@Overlay86Start equ 0x022EB1A0
@FreeSpace equ @Overlay86Start + 0x48
.open "ftc/arm9.bin", 02000000h
.org 0x02061254 ; At the end of the function for the boss orb being picked up
b @BossOrbCheckReloadRoom
.close
.open "ftc/overlay9_86", @Overlay86Start ; Free space overlay
.org @FreeSpace
@BossOrbCheckReloadRoom:
ldr r0, =02100790h
ldrb r0, [r0] ; Read the current game mode
cmp r0, 0h ; Shanoa mode
bne @BossOrbCheckReloadRoomEnd
ldr r0, =020FFCB9h
ldrb r0, [r0] ; Read the current area index
cmp r0, 0Eh ; Mystery Manor
beq @BossOrbReloadRoomMysteryManor
cmp r0, 2h ; Ecclesia
bne @BossOrbCheckReloadRoomEnd
@BossOrbReloadRoomEcclesia:
mov r0, 2h ; Area, Ecclesia
mov r1, 0h ; Sector
mov r2, 6h ; Room
b @BossOrbReloadRoom
@BossOrbReloadRoomMysteryManor:
mov r0, 0Eh ; Area, Mystery Manor
mov r1, 0h ; Sector
mov r2, 9h ; Room
@BossOrbReloadRoom:
mov r3, 0C0h ; X pos
mov r4, 0B0h ; Y pos
str r3, [r13]
bl 0203AFD0h ; TeleportPlayer
bl 0203B014h ; TriggerRoomTransition
@BossOrbCheckReloadRoomEnd:
; Return to the normal boss orb code
add r13, r13, 34h ; Replace line overwritten to jump here
b 2061258h
.pool
.close
|
; this example program draws a rectangle on the screen
; pressing the a key on the keyboard will move the rectangle to the left
; pressing the b key on the keyboard will move the rectangle to the right
; some commonly used addresses
.def ADDR_VRAM 0x4000
.def ADDR_EVENT_TYPE 0x4903
.def ADDR_KEYBOARD_KEYCODE 0x4904
.def ADDR_DRAW_METHOD 0x490B
.def ADDR_DRAW_ARG1 0x490C
.def ADDR_DRAW_ARG2 0x490D
.def ADDR_DRAW_ARG3 0x490E
.def ADDR_DRAW_ARG4 0x490F
; method code of the draw rectangle IOChip intrinsic
.def DRAW_RECTANGLE 0x00
.def BRUSH_SET_BODY 0x80
.def BRUSH_SET_OUTLINE 0x81
; color codes
.def RED #$E0
.def BLUE #$03
; event types
.def EVENT_KEYDOWN 0x01
; keyboard keycodes
.def KEY_W 0x16
.def KEY_A 0x00
.def KEY_S 0x12
.def KEY_D 0x03
; load at reset entry
.RST
; set the body color to red
lda RED
sta ADDR_DRAW_ARG1
lda BRUSH_SET_BODY
sta ADDR_DRAW_METHOD
; set the outline color to blue
lda BLUE
sta ADDR_DRAW_ARG1
lda BRUSH_SET_OUTLINE
sta_ADDR_DRAW_METHOD
; Drawing loop
.DRAW
lda #$10 ; width / height
sta ADDR_DRAW_ARG3
sta ADDR_DRAW_ARG4
lda DRAW_RECTANGLE
.DRAWLOOP
stx ADDR_DRAW_ARG1 ; x coordinate
sty ADDR_DRAW_ARG2 ; y coordinate
sta ADDR_DRAW_METHOD
jmp .DRAWLOOP
; Move the rectangle with the WASD keys
.IRQ
; Backup A register
PHA
; Check if this is a keyboard event
lda ADDR_EVENT_TYPE
cmp EVENT_KEYDOWN
bne .RESTORE_AND_EXIT
; Check if either the A or D key were pressed
lda ADDR_KEYBOARD_KEYCODE
cmp KEY_W
beq .HANDLE_W_KEY
cmp KEY_A
beq .HANDLE_A_KEY
cmp KEY_S
beq .HANDLE_D_KEY
cmp KEY_D
beq .HANDLE_D_KEY
.RESTORE_AND_EXIT
PLA
rti
.HANDLE_W_KEY
PLA
dey
rti
.HANDLE_A_KEY
PLA
dex
rti
.HANDLE_S_KEY
PLA
iny
rti
.HANDLE_D_KEY
PLA
inx
rti
|
#include <iostream>
using namespace std;
int soma_b(int& a, const int& b) {
a = 4;
return a + b;
}
int main() {
int x = 2;
cout << soma_b(x, 3) << endl;
cout << x;
}
//https://pt.stackoverflow.com/q/320739/101
|
list p=16f628a, free
#include <p16f628a.inc>
ERRORLEVEL -302 ;removes warning message about using proper bank that occured on the line 'CLRF TRISB'
#include util_macros.INC
global twosComplement32bits, twosComplement16bits
global increment32bit, increment16bit
global Add32bit32bit
global argA, argB
global compare_unsigned_16, compare_signed16
global compare32bitReg, Div4824U
global mult_32_16, a1, b1, clear_mult_32_16_registers
global Div4824U,x, y, clear_mult_Div4824U_registers
complement32bitReg macro regName
comf regName,F
comf regName+1,F
comf regName+2,F
comf regName+3,F
endm
BANK1 udata
temp0 res 1
x res 6
y res 4
Count res 1
mathint res 6
Rem res 3
a1 res 1
a2 res 1
a3 res 1
a4 res 1
a5 res 1
a6 res 1
c1 res 1
c2 res 1
c3 res 1
c4 res 1
b1 res 1
b2 res 1
b3 res 1
b4 res 1
bitcnt res 1
argA res 4
argB res 4
; 32 bit dividend into argA0-4 lsb in 0
; 16 bit divisor into argB0-1
; 16 bit remainder into argB2-3
PROG code
twosComplement16bits:
movwf argA ; store w in argA for safe keeping
movwf FSR
comf INDF, F
incf FSR,F
comf INDF, F
movfw argA ; move the contents of argA back into w
call increment16bit
return
;Takes argument in W
; To call "movlw fileRegister" where fileRegister is 24 bits long
twosComplement32bits:
movwf argA ; store w in argA for safe keeping
movwf FSR
comf INDF, F
incf FSR,F
comf INDF, F
incf FSR,F
comf INDF, F
incf FSR,F
comf INDF, F
movfw argA ; move the contents of argA back into w
call increment32bit
return
; Takes the address in W
increment16bit:
movwf FSR
goto doIncrement16bits
return
;From Dmitry Kiryashov
increment32bit:
movwf FSR
bcf STATUS, Z
incfsz INDF,F
return
incfsz FSR,F
incfsz INDF,F
return
incfsz FSR,F
doIncrement16bits:
incfsz INDF,F
return
incfsz FSR,F
incf INDF,F
return
; Adds argA & argB leaving the result in argB
Add32bit32bit:
movf argA0,w
addwf argB0,f
movf argA1,w
btfsc STATUS,C
incfsz argA1,W
addwf argB1,f
movf argA2,w
btfsc STATUS,C
incfsz argA2,w
addwf argB2,f
movf argA3,w
btfsc STATUS,C
incfsz argA3,w
addwf argB3,f
return
; signed and unsigned 16 bit comparison routine:
; by David Cary 2001-03-30
; returns the correct flags (Z and C)
; to indicate the X=Y, Y<X, or X<Y.
; Does not modify X or Y.
compare_signed16: ; 7
; uses a "temp0" register.
movf argB1,w
xorlw 0x80
movwf temp0
movf argA1,w
xorlw 0x80
subwf temp0,w ; subtract Y-X
goto Are_they_equal
compare_unsigned_16: ; 7
movf argA1,w
subwf argB1,w ; subtract Y-X
Are_they_equal:
; Are they equal ?
skpz
goto results16
; yes, they are equal -- compare lo
movf argA0,w
subwf argB0,w ; subtract Y-X
results16:
; if X=Y then now Z=1.
; if Y<X then now C=0.
; if X<=Y then now C=1.
return
; Compares argA and argB
; Signed numbers so there are four sign combinations
; argA argB
; +ve +ve ; goto handlePositive
; +ve -ve ; return 1
; -ve +ve ; return -1
; -ve -ve ; goto handleNegative
;
; checkargA
; if -ve goto check argB
; if argB positive return -1
;
; A = B return 0x00
; A > B return 0x01
; A < B return 0x02
;
compare32bitReg:
movfw argA3
xorwf argB3, w
andlw 0x80
btfsc STATUS, Z ; If zero was computed
; it means the numbers have the same sign.
goto numbersSignSame
goto numbersSignDiffer
numbersSignDiffer:
movfw argA3
andlw 0x80
btfss STATUS, Z
goto returnAbigger
goto returnAsmaller
numbersSignSame:
complement32bitReg argB
increment32bitReg argB, onComplete
onComplete:
call Add32bit32bit
clrw
iorwf argB, W
iorwf argB+1, W
iorwf argB+2, W
iorwf argB+3, W ; crude way to check if argB is zero
skpnz
return ; returns with zero in W register
; meaning they are equal.
movfw argB+3
andlw 0x80
skpz ; if the z is set the result was positive
goto returnAsmaller
goto returnAbigger
returnAbigger:
movlw 0x01
return
returnAsmaller:
movlw 0x02
return
clear_mult_Div4824U_registers:
clear48bitReg x
clear32bitReg y
clrf Count
clrf Rem
clrf Rem+1
clrf Rem+2
return
;**************************************************************************
;Div4824U
;Inputs:
; x - x:6 (x) (0 - least significant!)
; y - Test:3 (y) (0 - least significant!)
;Temporary:
; Counter - Count
; Shift - Shift:6 (mathint)
;Output:
; Quotient - x:6 (x) (0 - least significant!)
; Remainder- Rem:3 (0 - least significant!)
;
;Adaptation to PIC 12/16 Assembly and error fix of code by Frank Finster 3/15/2005
;by Lewis Lineberger 4/24/2009
;Fixes overrun in Rem+2 when upper bit of y+2 and Rem+2 are set, but Rem+2 is still
;less than y+2. Overrun is illustrated by 0x34631A9FC / 0xDD39E9.
;Adaptation of 24x24 division by Tony Nixon with corrections
;PIC18 assembly instructions in comments for easy adaptation.
;by Frank Finster 3/15/2005.
;Code adapted by Andy Lee
;01-Sep-2006 Original version
;**************************************************************************
Div4824U:
;---------------------------------------------------
; SUBROUTINE - 48 by 24 BIT division
movlw d'48'
movwf Count
; movff x+0, Shift+0
movf x+0, W
movwf mathint+0
; movff x+1, Shift+1
movf x+1, W
movwf mathint+1
; movff x+2, Shift+2
movf x+2, W
movwf mathint+2
; movff x+3, Shift+3
movf x+3, W
movwf mathint+3
; movff x+4, Shift+4
movf x+4, W
movwf mathint+4
; movff x+5, Shift+5
movf x+5, W
movwf mathint+5
clrf x+0
clrf x+1
clrf x+2
clrf x+3
clrf x+4
clrf x+5
clrf Rem+2
clrf Rem+1
clrf Rem+0
dloop
bcf STATUS, C
rlf mathint+0, F
rlf mathint+1, F
rlf mathint+2, F
rlf mathint+3, F
rlf mathint+4, F
rlf mathint+5, F
rlf Rem+0, F
rlf Rem+1, F
rlf Rem+2, F
btfsc STATUS, C ; overrun
goto subtract
movf y+2, w
subwf Rem+2, w
btfss STATUS, Z
goto nochk
;bra nochk
movf y+1,w
subwf Rem+1,w
btfss STATUS, Z
goto nochk
;bra nochk
movf y+0,w
subwf Rem+0,w
nochk
btfss STATUS, C ; Rem >= y
goto nogo
;bra nogo
subtract movf y+0,w
subwf Rem+0, F
btfsc STATUS, C
goto nodec_remainM
;bra nodec_remainM
decf Rem+1, f
movf Rem+1, w
xorlw 0xff
btfsc STATUS, Z
decf Rem+2, f
nodec_remainM
movf y+1, w
subwf Rem+1, f
btfss STATUS, C
decf Rem+2, f
movf y+2, w
subwf Rem+2, f
bsf STATUS, C
nogo
rlf x+0, F
rlf x+1, F
rlf x+2, F
rlf x+3, F
rlf x+4, F
rlf x+5, F
decfsz Count, f
goto dloop
return
clear_mult_32_16_registers:
clear48bitReg a1
clrf c1
clrf c2
clrf c3
clrf c4
clrf b1
clrf b2
clrf b3
clrf b4
return
;As a thank you for all the code, here is a 32x16 bit Mult.
;Unsigned 32 bit by 16 bit multiplication
;This routine will take a4:a3:a2:a1*b2:b1 -> a6:a5:a4:a3:a2:a1
mult_32_16:
banksel a4
; Begin rearrange code
nop
movf a4,w
movwf a6
movf a3,w
movwf a5
movf a2,w
movwf a4
movf a1,w
movwf a3
; End rearrange code
CLRF a2 ; clear partial product
CLRF a1
MOVF a6,W
MOVWF c4
MOVF a5,W
MOVWF c3
MOVF a4,W
MOVWF c2
MOVF a3,W
MOVWF c1
MOVLW 0x08
MOVWF bitcnt
LOOPUM3216A:
RRF b1, F
BTFSC STATUS, C
GOTO ALUM3216NAP
DECFSZ bitcnt, F
GOTO LOOPUM3216A
MOVWF bitcnt
LOOPUM3216B:
RRF b2, F
BTFSC STATUS, C
GOTO BLUM3216NAP
DECFSZ bitcnt, F
GOTO LOOPUM3216B
CLRF a6
CLRF a5
CLRF a4
CLRF a3
RETLW 0x00
BLUM3216NAP:
BCF STATUS, C
GOTO BLUM3216NA
ALUM3216NAP:
BCF STATUS, C
GOTO ALUM3216NA
ALOOPUM3216:
RRF b1, F
BTFSS STATUS, C
GOTO ALUM3216NA
MOVF c1,W
ADDWF a3, F
MOVF c2,W
BTFSC STATUS, C
INCFSZ c2,W
ADDWF a4, F
MOVF c3,W
BTFSC STATUS, C
INCFSZ c3,W
ADDWF a5, F
MOVF c4,W
BTFSC STATUS, C
INCFSZ c4,W
ADDWF a6, F
ALUM3216NA:
RRF a6, F
RRF a5, F
RRF a4, F
RRF a3, F
RRF a2, F
DECFSZ bitcnt, f
GOTO ALOOPUM3216
MOVLW 0x08
MOVWF bitcnt
BLOOPUM3216:
RRF b2, F
BTFSS STATUS, C
GOTO BLUM3216NA
MOVF c1,W
ADDWF a3, F
MOVF c2,W
BTFSC STATUS, C
INCFSZ c2,W
ADDWF a4, F
MOVF c3,W
BTFSC STATUS, C
INCFSZ c3,W
ADDWF a5, F
MOVF c4,W
BTFSC STATUS, C
INCFSZ c4,W
ADDWF a6, F
BLUM3216NA
RRF a6, F
RRF a5, F
RRF a4, F
RRF a3, F
RRF a2, F
RRF a1, F
DECFSZ bitcnt, F
GOTO BLOOPUM3216
nop
return
end
|
_zombie: formato do arquivo elf32-i386
Desmontagem da seção .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(void)
{
0: f3 0f 1e fb endbr32
4: 8d 4c 24 04 lea 0x4(%esp),%ecx
8: 83 e4 f0 and $0xfffffff0,%esp
b: ff 71 fc pushl -0x4(%ecx)
e: 55 push %ebp
f: 89 e5 mov %esp,%ebp
11: 51 push %ecx
12: 83 ec 04 sub $0x4,%esp
if(fork() > 0)
15: e8 71 02 00 00 call 28b <fork>
1a: 85 c0 test %eax,%eax
1c: 7e 0d jle 2b <main+0x2b>
sleep(5); // Let child exit before parent.
1e: 83 ec 0c sub $0xc,%esp
21: 6a 05 push $0x5
23: e8 fb 02 00 00 call 323 <sleep>
28: 83 c4 10 add $0x10,%esp
exit();
2b: e8 63 02 00 00 call 293 <exit>
00000030 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
30: f3 0f 1e fb endbr32
34: 55 push %ebp
char *os;
os = s;
while((*s++ = *t++) != 0)
35: 31 c0 xor %eax,%eax
{
37: 89 e5 mov %esp,%ebp
39: 53 push %ebx
3a: 8b 4d 08 mov 0x8(%ebp),%ecx
3d: 8b 5d 0c mov 0xc(%ebp),%ebx
while((*s++ = *t++) != 0)
40: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
44: 88 14 01 mov %dl,(%ecx,%eax,1)
47: 83 c0 01 add $0x1,%eax
4a: 84 d2 test %dl,%dl
4c: 75 f2 jne 40 <strcpy+0x10>
;
return os;
}
4e: 89 c8 mov %ecx,%eax
50: 5b pop %ebx
51: 5d pop %ebp
52: c3 ret
53: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000060 <strcmp>:
int
strcmp(const char *p, const char *q)
{
60: f3 0f 1e fb endbr32
64: 55 push %ebp
65: 89 e5 mov %esp,%ebp
67: 53 push %ebx
68: 8b 4d 08 mov 0x8(%ebp),%ecx
6b: 8b 55 0c mov 0xc(%ebp),%edx
while(*p && *p == *q)
6e: 0f b6 01 movzbl (%ecx),%eax
71: 0f b6 1a movzbl (%edx),%ebx
74: 84 c0 test %al,%al
76: 75 19 jne 91 <strcmp+0x31>
78: eb 26 jmp a0 <strcmp+0x40>
7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
80: 0f b6 41 01 movzbl 0x1(%ecx),%eax
p++, q++;
84: 83 c1 01 add $0x1,%ecx
87: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
8a: 0f b6 1a movzbl (%edx),%ebx
8d: 84 c0 test %al,%al
8f: 74 0f je a0 <strcmp+0x40>
91: 38 d8 cmp %bl,%al
93: 74 eb je 80 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
95: 29 d8 sub %ebx,%eax
}
97: 5b pop %ebx
98: 5d pop %ebp
99: c3 ret
9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
a0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
a2: 29 d8 sub %ebx,%eax
}
a4: 5b pop %ebx
a5: 5d pop %ebp
a6: c3 ret
a7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
ae: 66 90 xchg %ax,%ax
000000b0 <strlen>:
uint
strlen(const char *s)
{
b0: f3 0f 1e fb endbr32
b4: 55 push %ebp
b5: 89 e5 mov %esp,%ebp
b7: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for(n = 0; s[n]; n++)
ba: 80 3a 00 cmpb $0x0,(%edx)
bd: 74 21 je e0 <strlen+0x30>
bf: 31 c0 xor %eax,%eax
c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
c8: 83 c0 01 add $0x1,%eax
cb: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
cf: 89 c1 mov %eax,%ecx
d1: 75 f5 jne c8 <strlen+0x18>
;
return n;
}
d3: 89 c8 mov %ecx,%eax
d5: 5d pop %ebp
d6: c3 ret
d7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
de: 66 90 xchg %ax,%ax
for(n = 0; s[n]; n++)
e0: 31 c9 xor %ecx,%ecx
}
e2: 5d pop %ebp
e3: 89 c8 mov %ecx,%eax
e5: c3 ret
e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
ed: 8d 76 00 lea 0x0(%esi),%esi
000000f0 <memset>:
void*
memset(void *dst, int c, uint n)
{
f0: f3 0f 1e fb endbr32
f4: 55 push %ebp
f5: 89 e5 mov %esp,%ebp
f7: 57 push %edi
f8: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
fb: 8b 4d 10 mov 0x10(%ebp),%ecx
fe: 8b 45 0c mov 0xc(%ebp),%eax
101: 89 d7 mov %edx,%edi
103: fc cld
104: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
106: 89 d0 mov %edx,%eax
108: 5f pop %edi
109: 5d pop %ebp
10a: c3 ret
10b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
10f: 90 nop
00000110 <strchr>:
char*
strchr(const char *s, char c)
{
110: f3 0f 1e fb endbr32
114: 55 push %ebp
115: 89 e5 mov %esp,%ebp
117: 8b 45 08 mov 0x8(%ebp),%eax
11a: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
11e: 0f b6 10 movzbl (%eax),%edx
121: 84 d2 test %dl,%dl
123: 75 16 jne 13b <strchr+0x2b>
125: eb 21 jmp 148 <strchr+0x38>
127: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
12e: 66 90 xchg %ax,%ax
130: 0f b6 50 01 movzbl 0x1(%eax),%edx
134: 83 c0 01 add $0x1,%eax
137: 84 d2 test %dl,%dl
139: 74 0d je 148 <strchr+0x38>
if(*s == c)
13b: 38 d1 cmp %dl,%cl
13d: 75 f1 jne 130 <strchr+0x20>
return (char*)s;
return 0;
}
13f: 5d pop %ebp
140: c3 ret
141: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
return 0;
148: 31 c0 xor %eax,%eax
}
14a: 5d pop %ebp
14b: c3 ret
14c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000150 <gets>:
char*
gets(char *buf, int max)
{
150: f3 0f 1e fb endbr32
154: 55 push %ebp
155: 89 e5 mov %esp,%ebp
157: 57 push %edi
158: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
159: 31 f6 xor %esi,%esi
{
15b: 53 push %ebx
15c: 89 f3 mov %esi,%ebx
15e: 83 ec 1c sub $0x1c,%esp
161: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
164: eb 33 jmp 199 <gets+0x49>
166: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
16d: 8d 76 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
170: 83 ec 04 sub $0x4,%esp
173: 8d 45 e7 lea -0x19(%ebp),%eax
176: 6a 01 push $0x1
178: 50 push %eax
179: 6a 00 push $0x0
17b: e8 2b 01 00 00 call 2ab <read>
if(cc < 1)
180: 83 c4 10 add $0x10,%esp
183: 85 c0 test %eax,%eax
185: 7e 1c jle 1a3 <gets+0x53>
break;
buf[i++] = c;
187: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
18b: 83 c7 01 add $0x1,%edi
18e: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
191: 3c 0a cmp $0xa,%al
193: 74 23 je 1b8 <gets+0x68>
195: 3c 0d cmp $0xd,%al
197: 74 1f je 1b8 <gets+0x68>
for(i=0; i+1 < max; ){
199: 83 c3 01 add $0x1,%ebx
19c: 89 fe mov %edi,%esi
19e: 3b 5d 0c cmp 0xc(%ebp),%ebx
1a1: 7c cd jl 170 <gets+0x20>
1a3: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
1a5: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
1a8: c6 03 00 movb $0x0,(%ebx)
}
1ab: 8d 65 f4 lea -0xc(%ebp),%esp
1ae: 5b pop %ebx
1af: 5e pop %esi
1b0: 5f pop %edi
1b1: 5d pop %ebp
1b2: c3 ret
1b3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1b7: 90 nop
1b8: 8b 75 08 mov 0x8(%ebp),%esi
1bb: 8b 45 08 mov 0x8(%ebp),%eax
1be: 01 de add %ebx,%esi
1c0: 89 f3 mov %esi,%ebx
buf[i] = '\0';
1c2: c6 03 00 movb $0x0,(%ebx)
}
1c5: 8d 65 f4 lea -0xc(%ebp),%esp
1c8: 5b pop %ebx
1c9: 5e pop %esi
1ca: 5f pop %edi
1cb: 5d pop %ebp
1cc: c3 ret
1cd: 8d 76 00 lea 0x0(%esi),%esi
000001d0 <stat>:
int
stat(const char *n, struct stat *st)
{
1d0: f3 0f 1e fb endbr32
1d4: 55 push %ebp
1d5: 89 e5 mov %esp,%ebp
1d7: 56 push %esi
1d8: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1d9: 83 ec 08 sub $0x8,%esp
1dc: 6a 00 push $0x0
1de: ff 75 08 pushl 0x8(%ebp)
1e1: e8 ed 00 00 00 call 2d3 <open>
if(fd < 0)
1e6: 83 c4 10 add $0x10,%esp
1e9: 85 c0 test %eax,%eax
1eb: 78 2b js 218 <stat+0x48>
return -1;
r = fstat(fd, st);
1ed: 83 ec 08 sub $0x8,%esp
1f0: ff 75 0c pushl 0xc(%ebp)
1f3: 89 c3 mov %eax,%ebx
1f5: 50 push %eax
1f6: e8 f0 00 00 00 call 2eb <fstat>
close(fd);
1fb: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
1fe: 89 c6 mov %eax,%esi
close(fd);
200: e8 b6 00 00 00 call 2bb <close>
return r;
205: 83 c4 10 add $0x10,%esp
}
208: 8d 65 f8 lea -0x8(%ebp),%esp
20b: 89 f0 mov %esi,%eax
20d: 5b pop %ebx
20e: 5e pop %esi
20f: 5d pop %ebp
210: c3 ret
211: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
return -1;
218: be ff ff ff ff mov $0xffffffff,%esi
21d: eb e9 jmp 208 <stat+0x38>
21f: 90 nop
00000220 <atoi>:
int
atoi(const char *s)
{
220: f3 0f 1e fb endbr32
224: 55 push %ebp
225: 89 e5 mov %esp,%ebp
227: 53 push %ebx
228: 8b 55 08 mov 0x8(%ebp),%edx
int n;
n = 0;
while('0' <= *s && *s <= '9')
22b: 0f be 02 movsbl (%edx),%eax
22e: 8d 48 d0 lea -0x30(%eax),%ecx
231: 80 f9 09 cmp $0x9,%cl
n = 0;
234: b9 00 00 00 00 mov $0x0,%ecx
while('0' <= *s && *s <= '9')
239: 77 1a ja 255 <atoi+0x35>
23b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
23f: 90 nop
n = n*10 + *s++ - '0';
240: 83 c2 01 add $0x1,%edx
243: 8d 0c 89 lea (%ecx,%ecx,4),%ecx
246: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx
while('0' <= *s && *s <= '9')
24a: 0f be 02 movsbl (%edx),%eax
24d: 8d 58 d0 lea -0x30(%eax),%ebx
250: 80 fb 09 cmp $0x9,%bl
253: 76 eb jbe 240 <atoi+0x20>
return n;
}
255: 89 c8 mov %ecx,%eax
257: 5b pop %ebx
258: 5d pop %ebp
259: c3 ret
25a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000260 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
260: f3 0f 1e fb endbr32
264: 55 push %ebp
265: 89 e5 mov %esp,%ebp
267: 57 push %edi
268: 8b 45 10 mov 0x10(%ebp),%eax
26b: 8b 55 08 mov 0x8(%ebp),%edx
26e: 56 push %esi
26f: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
272: 85 c0 test %eax,%eax
274: 7e 0f jle 285 <memmove+0x25>
276: 01 d0 add %edx,%eax
dst = vdst;
278: 89 d7 mov %edx,%edi
27a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
*dst++ = *src++;
280: a4 movsb %ds:(%esi),%es:(%edi)
while(n-- > 0)
281: 39 f8 cmp %edi,%eax
283: 75 fb jne 280 <memmove+0x20>
return vdst;
}
285: 5e pop %esi
286: 89 d0 mov %edx,%eax
288: 5f pop %edi
289: 5d pop %ebp
28a: c3 ret
0000028b <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
28b: b8 01 00 00 00 mov $0x1,%eax
290: cd 40 int $0x40
292: c3 ret
00000293 <exit>:
SYSCALL(exit)
293: b8 02 00 00 00 mov $0x2,%eax
298: cd 40 int $0x40
29a: c3 ret
0000029b <wait>:
SYSCALL(wait)
29b: b8 03 00 00 00 mov $0x3,%eax
2a0: cd 40 int $0x40
2a2: c3 ret
000002a3 <pipe>:
SYSCALL(pipe)
2a3: b8 04 00 00 00 mov $0x4,%eax
2a8: cd 40 int $0x40
2aa: c3 ret
000002ab <read>:
SYSCALL(read)
2ab: b8 05 00 00 00 mov $0x5,%eax
2b0: cd 40 int $0x40
2b2: c3 ret
000002b3 <write>:
SYSCALL(write)
2b3: b8 10 00 00 00 mov $0x10,%eax
2b8: cd 40 int $0x40
2ba: c3 ret
000002bb <close>:
SYSCALL(close)
2bb: b8 15 00 00 00 mov $0x15,%eax
2c0: cd 40 int $0x40
2c2: c3 ret
000002c3 <kill>:
SYSCALL(kill)
2c3: b8 06 00 00 00 mov $0x6,%eax
2c8: cd 40 int $0x40
2ca: c3 ret
000002cb <exec>:
SYSCALL(exec)
2cb: b8 07 00 00 00 mov $0x7,%eax
2d0: cd 40 int $0x40
2d2: c3 ret
000002d3 <open>:
SYSCALL(open)
2d3: b8 0f 00 00 00 mov $0xf,%eax
2d8: cd 40 int $0x40
2da: c3 ret
000002db <mknod>:
SYSCALL(mknod)
2db: b8 11 00 00 00 mov $0x11,%eax
2e0: cd 40 int $0x40
2e2: c3 ret
000002e3 <unlink>:
SYSCALL(unlink)
2e3: b8 12 00 00 00 mov $0x12,%eax
2e8: cd 40 int $0x40
2ea: c3 ret
000002eb <fstat>:
SYSCALL(fstat)
2eb: b8 08 00 00 00 mov $0x8,%eax
2f0: cd 40 int $0x40
2f2: c3 ret
000002f3 <link>:
SYSCALL(link)
2f3: b8 13 00 00 00 mov $0x13,%eax
2f8: cd 40 int $0x40
2fa: c3 ret
000002fb <mkdir>:
SYSCALL(mkdir)
2fb: b8 14 00 00 00 mov $0x14,%eax
300: cd 40 int $0x40
302: c3 ret
00000303 <chdir>:
SYSCALL(chdir)
303: b8 09 00 00 00 mov $0x9,%eax
308: cd 40 int $0x40
30a: c3 ret
0000030b <dup>:
SYSCALL(dup)
30b: b8 0a 00 00 00 mov $0xa,%eax
310: cd 40 int $0x40
312: c3 ret
00000313 <getpid>:
SYSCALL(getpid)
313: b8 0b 00 00 00 mov $0xb,%eax
318: cd 40 int $0x40
31a: c3 ret
0000031b <sbrk>:
SYSCALL(sbrk)
31b: b8 0c 00 00 00 mov $0xc,%eax
320: cd 40 int $0x40
322: c3 ret
00000323 <sleep>:
SYSCALL(sleep)
323: b8 0d 00 00 00 mov $0xd,%eax
328: cd 40 int $0x40
32a: c3 ret
0000032b <uptime>:
SYSCALL(uptime)
32b: b8 0e 00 00 00 mov $0xe,%eax
330: cd 40 int $0x40
332: c3 ret
00000333 <date>:
333: b8 16 00 00 00 mov $0x16,%eax
338: cd 40 int $0x40
33a: c3 ret
33b: 66 90 xchg %ax,%ax
33d: 66 90 xchg %ax,%ax
33f: 90 nop
00000340 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
340: 55 push %ebp
341: 89 e5 mov %esp,%ebp
343: 57 push %edi
344: 56 push %esi
345: 53 push %ebx
346: 83 ec 3c sub $0x3c,%esp
349: 89 4d c4 mov %ecx,-0x3c(%ebp)
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
34c: 89 d1 mov %edx,%ecx
{
34e: 89 45 b8 mov %eax,-0x48(%ebp)
if(sgn && xx < 0){
351: 85 d2 test %edx,%edx
353: 0f 89 7f 00 00 00 jns 3d8 <printint+0x98>
359: f6 45 08 01 testb $0x1,0x8(%ebp)
35d: 74 79 je 3d8 <printint+0x98>
neg = 1;
35f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp)
x = -xx;
366: f7 d9 neg %ecx
} else {
x = xx;
}
i = 0;
368: 31 db xor %ebx,%ebx
36a: 8d 75 d7 lea -0x29(%ebp),%esi
36d: 8d 76 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
370: 89 c8 mov %ecx,%eax
372: 31 d2 xor %edx,%edx
374: 89 cf mov %ecx,%edi
376: f7 75 c4 divl -0x3c(%ebp)
379: 0f b6 92 60 07 00 00 movzbl 0x760(%edx),%edx
380: 89 45 c0 mov %eax,-0x40(%ebp)
383: 89 d8 mov %ebx,%eax
385: 8d 5b 01 lea 0x1(%ebx),%ebx
}while((x /= base) != 0);
388: 8b 4d c0 mov -0x40(%ebp),%ecx
buf[i++] = digits[x % base];
38b: 88 14 1e mov %dl,(%esi,%ebx,1)
}while((x /= base) != 0);
38e: 39 7d c4 cmp %edi,-0x3c(%ebp)
391: 76 dd jbe 370 <printint+0x30>
if(neg)
393: 8b 4d bc mov -0x44(%ebp),%ecx
396: 85 c9 test %ecx,%ecx
398: 74 0c je 3a6 <printint+0x66>
buf[i++] = '-';
39a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1)
buf[i++] = digits[x % base];
39f: 89 d8 mov %ebx,%eax
buf[i++] = '-';
3a1: ba 2d 00 00 00 mov $0x2d,%edx
while(--i >= 0)
3a6: 8b 7d b8 mov -0x48(%ebp),%edi
3a9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx
3ad: eb 07 jmp 3b6 <printint+0x76>
3af: 90 nop
3b0: 0f b6 13 movzbl (%ebx),%edx
3b3: 83 eb 01 sub $0x1,%ebx
write(fd, &c, 1);
3b6: 83 ec 04 sub $0x4,%esp
3b9: 88 55 d7 mov %dl,-0x29(%ebp)
3bc: 6a 01 push $0x1
3be: 56 push %esi
3bf: 57 push %edi
3c0: e8 ee fe ff ff call 2b3 <write>
while(--i >= 0)
3c5: 83 c4 10 add $0x10,%esp
3c8: 39 de cmp %ebx,%esi
3ca: 75 e4 jne 3b0 <printint+0x70>
putc(fd, buf[i]);
}
3cc: 8d 65 f4 lea -0xc(%ebp),%esp
3cf: 5b pop %ebx
3d0: 5e pop %esi
3d1: 5f pop %edi
3d2: 5d pop %ebp
3d3: c3 ret
3d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
3d8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp)
3df: eb 87 jmp 368 <printint+0x28>
3e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
3e8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
3ef: 90 nop
000003f0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
3f0: f3 0f 1e fb endbr32
3f4: 55 push %ebp
3f5: 89 e5 mov %esp,%ebp
3f7: 57 push %edi
3f8: 56 push %esi
3f9: 53 push %ebx
3fa: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
3fd: 8b 75 0c mov 0xc(%ebp),%esi
400: 0f b6 1e movzbl (%esi),%ebx
403: 84 db test %bl,%bl
405: 0f 84 b4 00 00 00 je 4bf <printf+0xcf>
ap = (uint*)(void*)&fmt + 1;
40b: 8d 45 10 lea 0x10(%ebp),%eax
40e: 83 c6 01 add $0x1,%esi
write(fd, &c, 1);
411: 8d 7d e7 lea -0x19(%ebp),%edi
state = 0;
414: 31 d2 xor %edx,%edx
ap = (uint*)(void*)&fmt + 1;
416: 89 45 d0 mov %eax,-0x30(%ebp)
419: eb 33 jmp 44e <printf+0x5e>
41b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
41f: 90 nop
420: 89 55 d4 mov %edx,-0x2c(%ebp)
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
423: ba 25 00 00 00 mov $0x25,%edx
if(c == '%'){
428: 83 f8 25 cmp $0x25,%eax
42b: 74 17 je 444 <printf+0x54>
write(fd, &c, 1);
42d: 83 ec 04 sub $0x4,%esp
430: 88 5d e7 mov %bl,-0x19(%ebp)
433: 6a 01 push $0x1
435: 57 push %edi
436: ff 75 08 pushl 0x8(%ebp)
439: e8 75 fe ff ff call 2b3 <write>
43e: 8b 55 d4 mov -0x2c(%ebp),%edx
} else {
putc(fd, c);
441: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
444: 0f b6 1e movzbl (%esi),%ebx
447: 83 c6 01 add $0x1,%esi
44a: 84 db test %bl,%bl
44c: 74 71 je 4bf <printf+0xcf>
c = fmt[i] & 0xff;
44e: 0f be cb movsbl %bl,%ecx
451: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
454: 85 d2 test %edx,%edx
456: 74 c8 je 420 <printf+0x30>
}
} else if(state == '%'){
458: 83 fa 25 cmp $0x25,%edx
45b: 75 e7 jne 444 <printf+0x54>
if(c == 'd'){
45d: 83 f8 64 cmp $0x64,%eax
460: 0f 84 9a 00 00 00 je 500 <printf+0x110>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
466: 81 e1 f7 00 00 00 and $0xf7,%ecx
46c: 83 f9 70 cmp $0x70,%ecx
46f: 74 5f je 4d0 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
471: 83 f8 73 cmp $0x73,%eax
474: 0f 84 d6 00 00 00 je 550 <printf+0x160>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
47a: 83 f8 63 cmp $0x63,%eax
47d: 0f 84 8d 00 00 00 je 510 <printf+0x120>
putc(fd, *ap);
ap++;
} else if(c == '%'){
483: 83 f8 25 cmp $0x25,%eax
486: 0f 84 b4 00 00 00 je 540 <printf+0x150>
write(fd, &c, 1);
48c: 83 ec 04 sub $0x4,%esp
48f: c6 45 e7 25 movb $0x25,-0x19(%ebp)
493: 6a 01 push $0x1
495: 57 push %edi
496: ff 75 08 pushl 0x8(%ebp)
499: e8 15 fe ff ff call 2b3 <write>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
49e: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
4a1: 83 c4 0c add $0xc,%esp
4a4: 6a 01 push $0x1
4a6: 83 c6 01 add $0x1,%esi
4a9: 57 push %edi
4aa: ff 75 08 pushl 0x8(%ebp)
4ad: e8 01 fe ff ff call 2b3 <write>
for(i = 0; fmt[i]; i++){
4b2: 0f b6 5e ff movzbl -0x1(%esi),%ebx
putc(fd, c);
4b6: 83 c4 10 add $0x10,%esp
}
state = 0;
4b9: 31 d2 xor %edx,%edx
for(i = 0; fmt[i]; i++){
4bb: 84 db test %bl,%bl
4bd: 75 8f jne 44e <printf+0x5e>
}
}
}
4bf: 8d 65 f4 lea -0xc(%ebp),%esp
4c2: 5b pop %ebx
4c3: 5e pop %esi
4c4: 5f pop %edi
4c5: 5d pop %ebp
4c6: c3 ret
4c7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
4ce: 66 90 xchg %ax,%ax
printint(fd, *ap, 16, 0);
4d0: 83 ec 0c sub $0xc,%esp
4d3: b9 10 00 00 00 mov $0x10,%ecx
4d8: 6a 00 push $0x0
4da: 8b 5d d0 mov -0x30(%ebp),%ebx
4dd: 8b 45 08 mov 0x8(%ebp),%eax
4e0: 8b 13 mov (%ebx),%edx
4e2: e8 59 fe ff ff call 340 <printint>
ap++;
4e7: 89 d8 mov %ebx,%eax
4e9: 83 c4 10 add $0x10,%esp
state = 0;
4ec: 31 d2 xor %edx,%edx
ap++;
4ee: 83 c0 04 add $0x4,%eax
4f1: 89 45 d0 mov %eax,-0x30(%ebp)
4f4: e9 4b ff ff ff jmp 444 <printf+0x54>
4f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printint(fd, *ap, 10, 1);
500: 83 ec 0c sub $0xc,%esp
503: b9 0a 00 00 00 mov $0xa,%ecx
508: 6a 01 push $0x1
50a: eb ce jmp 4da <printf+0xea>
50c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
putc(fd, *ap);
510: 8b 5d d0 mov -0x30(%ebp),%ebx
write(fd, &c, 1);
513: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
516: 8b 03 mov (%ebx),%eax
write(fd, &c, 1);
518: 6a 01 push $0x1
ap++;
51a: 83 c3 04 add $0x4,%ebx
write(fd, &c, 1);
51d: 57 push %edi
51e: ff 75 08 pushl 0x8(%ebp)
putc(fd, *ap);
521: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
524: e8 8a fd ff ff call 2b3 <write>
ap++;
529: 89 5d d0 mov %ebx,-0x30(%ebp)
52c: 83 c4 10 add $0x10,%esp
state = 0;
52f: 31 d2 xor %edx,%edx
531: e9 0e ff ff ff jmp 444 <printf+0x54>
536: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
53d: 8d 76 00 lea 0x0(%esi),%esi
putc(fd, c);
540: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
543: 83 ec 04 sub $0x4,%esp
546: e9 59 ff ff ff jmp 4a4 <printf+0xb4>
54b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
54f: 90 nop
s = (char*)*ap;
550: 8b 45 d0 mov -0x30(%ebp),%eax
553: 8b 18 mov (%eax),%ebx
ap++;
555: 83 c0 04 add $0x4,%eax
558: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
55b: 85 db test %ebx,%ebx
55d: 74 17 je 576 <printf+0x186>
while(*s != 0){
55f: 0f b6 03 movzbl (%ebx),%eax
state = 0;
562: 31 d2 xor %edx,%edx
while(*s != 0){
564: 84 c0 test %al,%al
566: 0f 84 d8 fe ff ff je 444 <printf+0x54>
56c: 89 75 d4 mov %esi,-0x2c(%ebp)
56f: 89 de mov %ebx,%esi
571: 8b 5d 08 mov 0x8(%ebp),%ebx
574: eb 1a jmp 590 <printf+0x1a0>
s = "(null)";
576: bb 58 07 00 00 mov $0x758,%ebx
while(*s != 0){
57b: 89 75 d4 mov %esi,-0x2c(%ebp)
57e: b8 28 00 00 00 mov $0x28,%eax
583: 89 de mov %ebx,%esi
585: 8b 5d 08 mov 0x8(%ebp),%ebx
588: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
58f: 90 nop
write(fd, &c, 1);
590: 83 ec 04 sub $0x4,%esp
s++;
593: 83 c6 01 add $0x1,%esi
596: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
599: 6a 01 push $0x1
59b: 57 push %edi
59c: 53 push %ebx
59d: e8 11 fd ff ff call 2b3 <write>
while(*s != 0){
5a2: 0f b6 06 movzbl (%esi),%eax
5a5: 83 c4 10 add $0x10,%esp
5a8: 84 c0 test %al,%al
5aa: 75 e4 jne 590 <printf+0x1a0>
5ac: 8b 75 d4 mov -0x2c(%ebp),%esi
state = 0;
5af: 31 d2 xor %edx,%edx
5b1: e9 8e fe ff ff jmp 444 <printf+0x54>
5b6: 66 90 xchg %ax,%ax
5b8: 66 90 xchg %ax,%ax
5ba: 66 90 xchg %ax,%ax
5bc: 66 90 xchg %ax,%ax
5be: 66 90 xchg %ax,%ax
000005c0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5c0: f3 0f 1e fb endbr32
5c4: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5c5: a1 08 0a 00 00 mov 0xa08,%eax
{
5ca: 89 e5 mov %esp,%ebp
5cc: 57 push %edi
5cd: 56 push %esi
5ce: 53 push %ebx
5cf: 8b 5d 08 mov 0x8(%ebp),%ebx
5d2: 8b 10 mov (%eax),%edx
bp = (Header*)ap - 1;
5d4: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5d7: 39 c8 cmp %ecx,%eax
5d9: 73 15 jae 5f0 <free+0x30>
5db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
5df: 90 nop
5e0: 39 d1 cmp %edx,%ecx
5e2: 72 14 jb 5f8 <free+0x38>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5e4: 39 d0 cmp %edx,%eax
5e6: 73 10 jae 5f8 <free+0x38>
{
5e8: 89 d0 mov %edx,%eax
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5ea: 8b 10 mov (%eax),%edx
5ec: 39 c8 cmp %ecx,%eax
5ee: 72 f0 jb 5e0 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5f0: 39 d0 cmp %edx,%eax
5f2: 72 f4 jb 5e8 <free+0x28>
5f4: 39 d1 cmp %edx,%ecx
5f6: 73 f0 jae 5e8 <free+0x28>
break;
if(bp + bp->s.size == p->s.ptr){
5f8: 8b 73 fc mov -0x4(%ebx),%esi
5fb: 8d 3c f1 lea (%ecx,%esi,8),%edi
5fe: 39 fa cmp %edi,%edx
600: 74 1e je 620 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
602: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
605: 8b 50 04 mov 0x4(%eax),%edx
608: 8d 34 d0 lea (%eax,%edx,8),%esi
60b: 39 f1 cmp %esi,%ecx
60d: 74 28 je 637 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
60f: 89 08 mov %ecx,(%eax)
freep = p;
}
611: 5b pop %ebx
freep = p;
612: a3 08 0a 00 00 mov %eax,0xa08
}
617: 5e pop %esi
618: 5f pop %edi
619: 5d pop %ebp
61a: c3 ret
61b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
61f: 90 nop
bp->s.size += p->s.ptr->s.size;
620: 03 72 04 add 0x4(%edx),%esi
623: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
626: 8b 10 mov (%eax),%edx
628: 8b 12 mov (%edx),%edx
62a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
62d: 8b 50 04 mov 0x4(%eax),%edx
630: 8d 34 d0 lea (%eax,%edx,8),%esi
633: 39 f1 cmp %esi,%ecx
635: 75 d8 jne 60f <free+0x4f>
p->s.size += bp->s.size;
637: 03 53 fc add -0x4(%ebx),%edx
freep = p;
63a: a3 08 0a 00 00 mov %eax,0xa08
p->s.size += bp->s.size;
63f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
642: 8b 53 f8 mov -0x8(%ebx),%edx
645: 89 10 mov %edx,(%eax)
}
647: 5b pop %ebx
648: 5e pop %esi
649: 5f pop %edi
64a: 5d pop %ebp
64b: c3 ret
64c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000650 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
650: f3 0f 1e fb endbr32
654: 55 push %ebp
655: 89 e5 mov %esp,%ebp
657: 57 push %edi
658: 56 push %esi
659: 53 push %ebx
65a: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
65d: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
660: 8b 3d 08 0a 00 00 mov 0xa08,%edi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
666: 8d 70 07 lea 0x7(%eax),%esi
669: c1 ee 03 shr $0x3,%esi
66c: 83 c6 01 add $0x1,%esi
if((prevp = freep) == 0){
66f: 85 ff test %edi,%edi
671: 0f 84 a9 00 00 00 je 720 <malloc+0xd0>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
677: 8b 07 mov (%edi),%eax
if(p->s.size >= nunits){
679: 8b 48 04 mov 0x4(%eax),%ecx
67c: 39 f1 cmp %esi,%ecx
67e: 73 6d jae 6ed <malloc+0x9d>
680: 81 fe 00 10 00 00 cmp $0x1000,%esi
686: bb 00 10 00 00 mov $0x1000,%ebx
68b: 0f 43 de cmovae %esi,%ebx
p = sbrk(nu * sizeof(Header));
68e: 8d 0c dd 00 00 00 00 lea 0x0(,%ebx,8),%ecx
695: 89 4d e4 mov %ecx,-0x1c(%ebp)
698: eb 17 jmp 6b1 <malloc+0x61>
69a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
6a0: 8b 10 mov (%eax),%edx
if(p->s.size >= nunits){
6a2: 8b 4a 04 mov 0x4(%edx),%ecx
6a5: 39 f1 cmp %esi,%ecx
6a7: 73 4f jae 6f8 <malloc+0xa8>
6a9: 8b 3d 08 0a 00 00 mov 0xa08,%edi
6af: 89 d0 mov %edx,%eax
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
6b1: 39 c7 cmp %eax,%edi
6b3: 75 eb jne 6a0 <malloc+0x50>
p = sbrk(nu * sizeof(Header));
6b5: 83 ec 0c sub $0xc,%esp
6b8: ff 75 e4 pushl -0x1c(%ebp)
6bb: e8 5b fc ff ff call 31b <sbrk>
if(p == (char*)-1)
6c0: 83 c4 10 add $0x10,%esp
6c3: 83 f8 ff cmp $0xffffffff,%eax
6c6: 74 1b je 6e3 <malloc+0x93>
hp->s.size = nu;
6c8: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
6cb: 83 ec 0c sub $0xc,%esp
6ce: 83 c0 08 add $0x8,%eax
6d1: 50 push %eax
6d2: e8 e9 fe ff ff call 5c0 <free>
return freep;
6d7: a1 08 0a 00 00 mov 0xa08,%eax
if((p = morecore(nunits)) == 0)
6dc: 83 c4 10 add $0x10,%esp
6df: 85 c0 test %eax,%eax
6e1: 75 bd jne 6a0 <malloc+0x50>
return 0;
}
}
6e3: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
6e6: 31 c0 xor %eax,%eax
}
6e8: 5b pop %ebx
6e9: 5e pop %esi
6ea: 5f pop %edi
6eb: 5d pop %ebp
6ec: c3 ret
if(p->s.size >= nunits){
6ed: 89 c2 mov %eax,%edx
6ef: 89 f8 mov %edi,%eax
6f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p->s.size == nunits)
6f8: 39 ce cmp %ecx,%esi
6fa: 74 54 je 750 <malloc+0x100>
p->s.size -= nunits;
6fc: 29 f1 sub %esi,%ecx
6fe: 89 4a 04 mov %ecx,0x4(%edx)
p += p->s.size;
701: 8d 14 ca lea (%edx,%ecx,8),%edx
p->s.size = nunits;
704: 89 72 04 mov %esi,0x4(%edx)
freep = prevp;
707: a3 08 0a 00 00 mov %eax,0xa08
}
70c: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
70f: 8d 42 08 lea 0x8(%edx),%eax
}
712: 5b pop %ebx
713: 5e pop %esi
714: 5f pop %edi
715: 5d pop %ebp
716: c3 ret
717: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
71e: 66 90 xchg %ax,%ax
base.s.ptr = freep = prevp = &base;
720: c7 05 08 0a 00 00 0c movl $0xa0c,0xa08
727: 0a 00 00
base.s.size = 0;
72a: bf 0c 0a 00 00 mov $0xa0c,%edi
base.s.ptr = freep = prevp = &base;
72f: c7 05 0c 0a 00 00 0c movl $0xa0c,0xa0c
736: 0a 00 00
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
739: 89 f8 mov %edi,%eax
base.s.size = 0;
73b: c7 05 10 0a 00 00 00 movl $0x0,0xa10
742: 00 00 00
if(p->s.size >= nunits){
745: e9 36 ff ff ff jmp 680 <malloc+0x30>
74a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
prevp->s.ptr = p->s.ptr;
750: 8b 0a mov (%edx),%ecx
752: 89 08 mov %ecx,(%eax)
754: eb b1 jmp 707 <malloc+0xb7>
|
; A338524: prime(n) Gray code decoding.
; Submitted by Simon Strandgaard
; 3,2,6,5,13,9,30,29,26,22,21,57,49,50,53,38,45,41,125,122,113,117,98,110,65,70,69,77,73,94,85,253,241,242,230,229,233,194,197,201,221,217,213,129,134,133,157,149,189,185,177,181,161,173,510,506,502,501
seq $0,40 ; The prime numbers.
seq $0,6068 ; a(n) is Gray-coded into n.
|
title 'Root module of relocatable BIOS for CP/M 3.0'
; version 1.0 15 Sept 82
maclib options
; Copyright (C), 1982
; Digital Research, Inc
; P.O. Box 579
; Pacific Grove, CA 93950
; This is the invariant portion of the modular BIOS and is
; distributed as source for informational purposes only.
; All desired modifications should be performed by
; adding or changing externally defined modules.
; This allows producing "standard" I/O modules that
; can be combined to support a particular system
; configuration.
cr equ 13
lf equ 10
bell equ 7
ctlQ equ 'Q'-'@'
ctlS equ 'S'-'@'
ccp equ 0100h ; Console Command Processor gets loaded into the TPA
cseg ; GENCPM puts CSEG stuff in common memory
; variables in system data page
extrn @covec,@civec,@aovec,@aivec,@lovec ; I/O redirection vectors
extrn @mxtpa ; addr of system entry point
extrn @bnkbf ; 128 byte scratch buffer
; initialization
extrn ?init ; general initialization and signon
extrn ?ldccp,?rlccp ; load & reload CCP for BOOT & WBOOT
; user defined character I/O routines
extrn ?ci,?co,?cist,?cost ; each take device in <B>
extrn ?cinit ; (re)initialize device in <C>
extrn @ctbl ; physical character device table
; disk communication data items
extrn @dtbl ; table of pointers to XDPHs
public @adrv,@rdrv,@trk,@sect ; parameters for disk I/O
public @dma,@dbnk,@cnt ; '' '' '' ''
; memory control
public @cbnk ; current bank
extrn ?xmove,?move ; select move bank, and block move
extrn ?bank ; select CPU bank
; clock support
extrn ?time ; signal time operation
; general utility routines
public ?pmsg,?pdec ; print message, print number from 0 to 65535
public ?pderr ; print BIOS disk error message header
maclib modebaud ; define mode bits
; External names for BIOS entry points
public ?boot,?wboot,?const,?conin,?cono,?list,?auxo,?auxi
public ?home,?sldsk,?sttrk,?stsec,?stdma,?read,?write
public ?lists,?sctrn
public ?conos,?auxis,?auxos,?dvtbl,?devin,?drtbl
public ?mltio,?flush,?mov,?tim,?bnksl,?stbnk,?xmov
; BIOS Jump vector.
; All BIOS routines are invoked by calling these
; entry points.
?boot: jmp boot ; initial entry on cold start
?wboot: jmp wboot ; reentry on program exit, warm start
?const: jmp const ; return console input status
?conin: jmp conin ; return console input character
?cono: jmp conout ; send console output character
?list: jmp list ; send list output character
?auxo: jmp auxout ; send auxilliary output character
?auxi: jmp auxin ; return auxilliary input character
?home: jmp home ; set disks to logical home
?sldsk: jmp seldsk ; select disk drive, return disk parameter info
?sttrk: jmp settrk ; set disk track
?stsec: jmp setsec ; set disk sector
?stdma: jmp setdma ; set disk I/O memory address
?read: jmp read ; read physical block(s)
?write: jmp write ; write physical block(s)
?lists: jmp listst ; return list device status
?sctrn: jmp sectrn ; translate logical to physical sector
?conos: jmp conost ; return console output status
?auxis: jmp auxist ; return aux input status
?auxos: jmp auxost ; return aux output status
?dvtbl: jmp devtbl ; return address of device def table
?devin: jmp ?cinit ; change baud rate of device
?drtbl: jmp getdrv ; return address of disk drive table
?mltio: jmp multio ; set multiple record count for disk I/O
?flush: jmp flush ; flush BIOS maintained disk caching
?mov: jmp ?move ; block move memory to memory
?tim: jmp ?time ; Signal Time and Date operation
?bnksl: jmp bnksel ; select bank for code execution and default DMA
?stbnk: jmp setbnk ; select different bank for disk I/O DMA operations.
?xmov: jmp ?xmove ; set source and destination banks for one operation
jmp 0 ; reserved for future expansion
jmp 0 ; reserved for future expansion
jmp 0 ; reserved for future expansion
; BOOT
; Initial entry point for system startup.
dseg ; this part can be banked
boot:
lxi sp,boot$stack
mvi c,15 ; initialize all 16 character devices
c$init$loop:
push b ! call ?cinit ! pop b
dcr c ! jp c$init$loop
call ?init ; perform any additional system initialization
; and print signon message
lxi b,16*256+0 ! lxi h,@dtbl ; init all 16 logical disk drives
d$init$loop:
push b ; save remaining count and abs drive
mov e,m ! inx h ! mov d,m ! inx h ; grab @drv entry
mov a,e ! ora d ! jz d$init$next ; if null, no drive
push h ; save @drv pointer
xchg ; XDPH address in <HL>
dcx h ! dcx h ! mov a,m ! sta @RDRV ; get relative drive code
mov a,c ! sta @ADRV ; get absolute drive code
dcx h ; point to init pointer
mov d,m ! dcx h ! mov e,m ; get init pointer
xchg ! call ipchl ; call init routine
pop h ; recover @drv pointer
d$init$next:
pop b ; recover counter and drive #
inr c ! dcr b ! jnz d$init$loop ; and loop for each drive
jmp boot$1
cseg ; following in resident memory
boot$1:
call set$jumps
call ?ldccp ; fetch CCP for first time
jmp ccp
; WBOOT
; Entry for system restarts.
wboot:
lxi sp,boot$stack
call set$jumps ; initialize page zero
call ?rlccp ; reload CCP
jmp ccp ; then reset jmp vectors and exit to ccp
set$jumps:
if banked
mvi a,1 ! call ?bnksl
endif
mvi a,JMP
sta 0 ! sta 5 ; set up jumps in page zero
lxi h,?wboot ! shld 1 ; BIOS warm start entry
lhld @MXTPA ! shld 6 ; BDOS system call entry
ret
ds 64
boot$stack equ $
; DEVTBL
; Return address of character device table
devtbl:
lxi h,@ctbl ! ret
; GETDRV
; Return address of drive table
getdrv:
lxi h,@dtbl ! ret
; CONOUT
; Console Output. Send character in <C>
; to all selected devices
conout:
lhld @covec ; fetch console output bit vector
jmp out$scan
; AUXOUT
; Auxiliary Output. Send character in <C>
; to all selected devices
auxout:
lhld @aovec ; fetch aux output bit vector
jmp out$scan
; LIST
; List Output. Send character in <C>
; to all selected devices.
list:
lhld @lovec ; fetch list output bit vector
out$scan:
mvi b,0 ; start with device 0
co$next:
dad h ; shift out next bit
jnc not$out$device
push h ; save the vector
push b ; save the count and character
not$out$ready:
push b ! call coster ! pop b ! ora a ! jz not$out$ready
pop b ! push b ; restore and resave the character and device
call ?co ; if device selected, print it
pop b ; recover count and character
pop h ; recover the rest of the vector
not$out$device:
inr b ; next device number
mov a,h ! ora l ; see if any devices left
jnz co$next ; and go find them...
ret
; CONOST
; Console Output Status. Return true if
; all selected console output devices
; are ready.
conost:
lhld @covec ; get console output bit vector
jmp ost$scan
; AUXOST
; Auxiliary Output Status. Return true if
; all selected auxiliary output devices
; are ready.
auxost:
lhld @aovec ; get aux output bit vector
jmp ost$scan
; LISTST
; List Output Status. Return true if
; all selected list output devices
; are ready.
listst:
lhld @lovec ; get list output bit vector
ost$scan:
mvi b,0 ; start with device 0
cos$next:
dad h ; check next bit
push h ; save the vector
push b ; save the count
mvi a,0FFh ; assume device ready
cc coster ; check status for this device
pop b ; recover count
pop h ; recover bit vector
ora a ; see if device ready
rz ; if any not ready, return false
inr b ; drop device number
mov a,h ! ora l ; see if any more selected devices
jnz cos$next
ori 0FFh ; all selected were ready, return true
ret
coster: ; check for output device ready, including optional
; xon/xoff support
mov l,b ! mvi h,0 ; make device code 16 bits
push h ; save it in stack
dad h ! dad h ! dad h ; create offset into device characteristics tbl
lxi d,@ctbl+6 ! dad d ; make address of mode byte
mov a,m ! ani mb$xonxoff
pop h ; recover console number in <HL>
jz ?cost ; not a xon device, go get output status direct
lxi d,xofflist ! dad d ; make pointer to proper xon/xoff flag
call cist1 ; see if this keyboard has character
mov a,m ! cnz ci1 ; get flag or read key if any
cpi ctlq ! jnz not$q ; if its a ctl-Q,
mvi a,0FFh ; set the flag ready
not$q:
cpi ctls ! jnz not$s ; if its a ctl-S,
mvi a,00h ; clear the flag
not$s:
mov m,a ; save the flag
call cost1 ; get the actual output status,
ana m ; and mask with ctl-Q/ctl-S flag
ret ; return this as the status
cist1: ; get input status with <BC> and <HL> saved
push b ! push h
call ?cist
pop h ! pop b
ora a
ret
cost1: ; get output status, saving <BC> & <HL>
push b ! push h
call ?cost
pop h ! pop b
ora a
ret
ci1: ; get input, saving <BC> & <HL>
push b ! push h
call ?ci
pop h ! pop b
ret
; CONST
; Console Input Status. Return true if
; any selected console input device
; has an available character.
const:
lhld @civec ; get console input bit vector
jmp ist$scan
; AUXIST
; Auxiliary Input Status. Return true if
; any selected auxiliary input device
; has an available character.
auxist:
lhld @aivec ; get aux input bit vector
ist$scan:
mvi b,0 ; start with device 0
cis$next:
dad h ; check next bit
mvi a,0 ; assume device not ready
cc cist1 ; check status for this device
ora a ! rnz ; if any ready, return true
inr b ; drop device number
mov a,h ! ora l ; see if any more selected devices
jnz cis$next
xra a ; all selected were not ready, return false
ret
; CONIN
; Console Input. Return character from first
; ready console input device.
conin:
lhld @civec
jmp in$scan
; AUXIN
; Auxiliary Input. Return character from first
; ready auxiliary input device.
auxin:
lhld @aivec
in$scan:
push h ; save bit vector
mvi b,0
ci$next:
dad h ; shift out next bit
mvi a,0 ; insure zero a (nonexistant device not ready).
cc cist1 ; see if the device has a character
ora a
jnz ci$rdy ; this device has a character
inr b ; else, next device
mov a,h ! ora l ; see if any more devices
jnz ci$next ; go look at them
pop h ; recover bit vector
jmp in$scan ; loop til we find a character
ci$rdy:
pop h ; discard extra stack
jmp ?ci
; Utility Subroutines
ipchl: ; vectored CALL point
pchl
?pmsg: ; print message @<HL> up to a null
; saves <BC> & <DE>
push b
push d
pmsg$loop:
mov a,m ! ora a ! jz pmsg$exit
mov c,a ! push h
call ?cono ! pop h
inx h ! jmp pmsg$loop
pmsg$exit:
pop d
pop b
ret
?pdec: ; print binary number 0-65535 from <HL>
lxi b,table10! lxi d,-10000
next:
mvi a,'0'-1
pdecl:
push h! inr a! dad d! jnc stoploop
inx sp! inx sp! jmp pdecl
stoploop:
push d! push b
mov c,a! call ?cono
pop b! pop d
nextdigit:
pop h
ldax b! mov e,a! inx b
ldax b! mov d,a! inx b
mov a,e! ora d! jnz next
ret
table10:
dw -1000,-100,-10,-1,0
?pderr:
lxi h,drive$msg ! call ?pmsg ; error header
lda @adrv ! adi 'A' ! mov c,a ! call ?cono ; drive code
lxi h,track$msg ! call ?pmsg ; track header
lhld @trk ! call ?pdec ; track number
lxi h,sector$msg ! call ?pmsg ; sector header
lhld @sect ! call ?pdec ; sector number
ret
; BNKSEL
; Bank Select. Select CPU bank for further execution.
bnksel:
sta @cbnk ; remember current bank
jmp ?bank ; and go exit through users
; physical bank select routine
xofflist db -1,-1,-1,-1,-1,-1,-1,-1 ; ctl-s clears to zero
db -1,-1,-1,-1,-1,-1,-1,-1
dseg ; following resides in banked memory
; Disk I/O interface routines
; SELDSK
; Select Disk Drive. Drive code in <C>.
; Invoke login procedure for drive
; if this is first select. Return
; address of disk parameter header
; in <HL>
seldsk:
mov a,c ! sta @adrv ; save drive select code
mov l,c ! mvi h,0 ! dad h ; create index from drive code
lxi b,@dtbl ! dad b ; get pointer to dispatch table
mov a,m ! inx h ! mov h,m ! mov l,a ; point at disk descriptor
ora h ! rz ; if no entry in table, no disk
mov a,e ! ani 1 ! jnz not$first$select ; examine login bit
push h ! xchg ; put pointer in stack & <DE>
lxi h,-2 ! dad d ! mov a,m ! sta @RDRV ; get relative drive
lxi h,-6 ! dad d ; find LOGIN addr
mov a,m ! inx h ! mov h,m ! mov l,a ; get address of LOGIN routine
call ipchl ; call LOGIN
pop h ; recover DPH pointer
not$first$select:
ret
; HOME
; Home selected drive. Treated as SETTRK(0).
home:
lxi b,0 ; same as set track zero
; SETTRK
; Set Track. Saves track address from <BC>
; in @TRK for further operations.
settrk:
mov l,c ! mov h,b
shld @trk
ret
; SETSEC
; Set Sector. Saves sector number from <BC>
; in @sect for further operations.
setsec:
mov l,c ! mov h,b
shld @sect
ret
; SETDMA
; Set Disk Memory Address. Saves DMA address
; from <BC> in @DMA and sets @DBNK to @CBNK
; so that further disk operations take place
; in current bank.
setdma:
mov l,c ! mov h,b
shld @dma
lda @cbnk ; default DMA bank is current bank
; fall through to set DMA bank
; SETBNK
; Set Disk Memory Bank. Saves bank number
; in @DBNK for future disk data
; transfers.
setbnk:
sta @dbnk
ret
; SECTRN
; Sector Translate. Indexes skew table in <DE>
; with sector in <BC>. Returns physical sector
; in <HL>. If no skew table (<DE>=0) then
; returns physical=logical.
sectrn:
mov l,c ! mov h,b
mov a,d ! ora e ! rz
xchg ! dad b ! mov l,m ! mvi h,0
ret
; READ
; Read physical record from currently selected drive.
; Finds address of proper read routine from
; extended disk parameter header (XDPH).
read:
lhld @adrv ! mvi h,0 ! dad h ; get drive code and double it
lxi d,@dtbl ! dad d ; make address of table entry
mov a,m ! inx h ! mov h,m ! mov l,a ; fetch table entry
push h ; save address of table
lxi d,-8 ! dad d ; point to read routine address
jmp rw$common ; use common code
; WRITE
; Write physical sector from currently selected drive.
; Finds address of proper write routine from
; extended disk parameter header (XDPH).
write:
lhld @adrv ! mvi h,0 ! dad h ; get drive code and double it
lxi d,@dtbl ! dad d ; make address of table entry
mov a,m ! inx h ! mov h,m ! mov l,a ; fetch table entry
push h ; save address of table
lxi d,-10 ! dad d ; point to write routine address
rw$common:
mov a,m ! inx h ! mov h,m ! mov l,a ; get address of routine
pop d ; recover address of table
dcx d ! dcx d ; point to relative drive
ldax d ! sta @rdrv ; get relative drive code and post it
inx d ! inx d ; point to DPH again
pchl ; leap to driver
; MULTIO
; Set multiple sector count. Saves passed count in
; @CNT
multio:
sta @cnt ! ret
; FLUSH
; BIOS deblocking buffer flush. Not implemented.
flush:
xra a ! ret ; return with no error
; error message components
drive$msg db cr,lf,bell,'BIOS Error on ',0
track$msg db ': T-',0
sector$msg db ', S-',0
; disk communication data items
@adrv ds 1 ; currently selected disk drive
@rdrv ds 1 ; controller relative disk drive
@trk ds 2 ; current track number
@sect ds 2 ; current sector number
@dma ds 2 ; current DMA address
@cnt db 0 ; record count for multisector transfer
@dbnk db 0 ; bank for DMA operations
cseg ; common memory
@cbnk db 0 ; bank for processor operations
end
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0xc135, %r9
nop
nop
inc %r14
vmovups (%r9), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $0, %xmm3, %rbx
nop
nop
nop
nop
add $42644, %rax
lea addresses_normal_ht+0xa435, %rsi
lea addresses_UC_ht+0x2d35, %rdi
nop
nop
nop
nop
nop
add %r9, %r9
mov $35, %rcx
rep movsb
nop
add %rax, %rax
lea addresses_UC_ht+0x27eb, %rsi
clflush (%rsi)
nop
nop
nop
nop
nop
dec %rcx
vmovups (%rsi), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $1, %xmm7, %rdi
nop
nop
nop
nop
nop
cmp %r9, %r9
lea addresses_D_ht+0xbb35, %rax
nop
nop
nop
add %r14, %r14
movw $0x6162, (%rax)
nop
nop
nop
cmp $24465, %r9
lea addresses_UC_ht+0x3b35, %rbx
nop
nop
nop
cmp %r14, %r14
mov (%rbx), %cx
and $8990, %rbx
lea addresses_normal_ht+0xb0e0, %rsi
lea addresses_A_ht+0x6835, %rdi
nop
nop
nop
cmp $23151, %r11
mov $8, %rcx
rep movsq
nop
nop
and $53336, %rbx
lea addresses_UC_ht+0x17525, %r14
nop
inc %rsi
movb (%r14), %r11b
and $54993, %r11
lea addresses_WT_ht+0x1cf2b, %rbx
nop
inc %rsi
mov (%rbx), %edi
nop
sub %r11, %r11
lea addresses_WC_ht+0x3385, %rsi
lea addresses_WT_ht+0x5bf5, %rdi
nop
nop
nop
nop
cmp $53385, %r14
mov $31, %rcx
rep movsq
nop
nop
sub %rsi, %rsi
lea addresses_UC_ht+0x10135, %rsi
lea addresses_normal_ht+0x1e195, %rdi
nop
nop
cmp %r9, %r9
mov $97, %rcx
rep movsq
xor $11970, %rax
lea addresses_UC_ht+0x11935, %r9
sub $20868, %rdi
mov $0x6162636465666768, %rcx
movq %rcx, %xmm0
vmovups %ymm0, (%r9)
nop
nop
nop
nop
nop
sub $41459, %r9
lea addresses_UC_ht+0xc6fd, %rsi
nop
nop
nop
nop
xor $17984, %r11
mov $0x6162636465666768, %rax
movq %rax, %xmm3
vmovups %ymm3, (%rsi)
nop
xor $24476, %rsi
lea addresses_D_ht+0x131f9, %r14
add %rax, %rax
mov (%r14), %edi
nop
nop
nop
nop
add %rsi, %rsi
lea addresses_normal_ht+0x1e0c1, %rsi
lea addresses_UC_ht+0x1c135, %rdi
sub %r14, %r14
mov $77, %rcx
rep movsb
cmp %rcx, %rcx
lea addresses_D_ht+0xfff3, %rax
nop
cmp %rdi, %rdi
vmovups (%rax), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %r9
nop
nop
xor %r9, %r9
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %rax
push %rcx
push %rdi
// Faulty Load
mov $0x21a1540000000535, %r11
nop
nop
nop
nop
dec %r13
mov (%r11), %edi
lea oracles, %r13
and $0xff, %rdi
shlq $12, %rdi
mov (%r13,%rdi,1), %rdi
pop %rdi
pop %rcx
pop %rax
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 8, 'same': True, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 1, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': True, 'AVXalign': True, 'size': 2, 'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 8, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 4, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2, 'same': True, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 1, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
leituraTeclado:
MOV R0, #0
; scan row0
MOV P0, #0FFh
CLR P0.0
CALL colScan
JB F0, finish
; scan row1
SETB P0.0
CLR P0.1
CALL colScan
JB F0, finish
; scan row2
SETB P0.1
CLR P0.2
CALL colScan
JB F0, finish
; scan row3
SETB P0.2
CLR P0.3
CALL colScan
JB F0, finish
finish:
RET
colScan:
JNB P0.4, gotKey
INC R0
JNB P0.5, gotKey
INC R0
JNB P0.6, gotKey
INC R0
RET
gotKey:
SETB F0
CALL INCREMENT_CURSOR
RET
|
INCLUDE "_DEVELOPMENT/target/rc2014/config_rc2014-8085_private.inc"
SECTION code_driver
PUBLIC fgetc_cons_acia
EXTERN aciaRxCount, aciaRxOut, aciaRxBuffer, aciaControl
EXTERN asm_z80_push_di, asm_z80_pop_ei
.fgetc_cons_acia
; exit : l = char received
;
; modifies : af, hl
ld a,(aciaRxCount) ; get the number of bytes in the Rx buffer
or a ; see if there are zero bytes available
jp Z,fgetc_cons_acia ; wait, if there are no bytes available
cp __IO_ACIA_RX_EMPTYISH ; compare the count with the preferred empty size
jp NZ,fgetc_cons_rx ; if the buffer is too full, don't change the RTS
di ; critical section begin
ld a,(aciaControl) ; get the ACIA control echo byte
and ~__IO_ACIA_CR_TEI_MASK ; mask out the Tx interrupt bits
or __IO_ACIA_CR_TDI_RTS0 ; set RTS low.
ld (aciaControl),a ; write the ACIA control echo byte back
ei ; critical section end
out (__IO_ACIA_CONTROL_REGISTER),a ; set the ACIA CTRL register
.fgetc_cons_rx
ld hl,(aciaRxOut) ; get the pointer to place where we pop the Rx byte
ld a,(hl) ; get the Rx byte
inc l ; move the Rx pointer low byte along
IF __IO_ACIA_RX_SIZE != 0x100
push af
ld a,__IO_ACIA_RX_SIZE-1 ; load the buffer size, (n^2)-1
and l ; range check
or aciaRxBuffer&0xFF ; locate base
ld l,a ; return the low byte to l
pop af
ENDIF
ld (aciaRxOut),hl ; write where the next byte should be popped
ld hl,aciaRxCount
dec (hl) ; atomically decrement Rx count
ld l,a ; and put it in hl
ret
|
; A315264: Coordination sequence Gal.6.328.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; Submitted by Jamie Morken(s3)
; 1,6,10,15,20,26,30,36,41,46,50,56,62,66,71,76,82,86,92,97,102,106,112,118,122,127,132,138,142,148,153,158,162,168,174,178,183,188,194,198,204,209,214,218,224,230,234,239,244,250
mul $0,7
mov $2,$0
lpb $0
mul $2,4
mov $0,$2
add $0,1
add $2,10
mul $2,$0
mul $2,2
add $2,$0
mod $2,11
add $2,3
sub $2,$0
sub $0,$2
div $0,11
lpe
add $0,1
|
; A329964: a(n) = (n!/floor(1+n/2)!)^2.
; 1,1,1,9,16,400,900,44100,112896,9144576,25401600,3073593600,9032601600,1526509670400,4674935865600,1051860569760000,3324398837760000,960751264112640000,3112834095724953600,1123733108556708249600,3714820193575895040000
seq $0,262033 ; Number of permutations of [n] beginning with at least floor(n/2) ascents.
pow $0,2
mul $0,2
sub $0,2
div $0,2
add $0,1
|
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "base/logging.h"
namespace blink {
mojom::PermissionStatus ToPermissionStatus(const std::string& status) {
if (status == "granted")
return mojom::PermissionStatus::GRANTED;
if (status == "prompt")
return mojom::PermissionStatus::ASK;
if (status == "denied")
return mojom::PermissionStatus::DENIED;
NOTREACHED();
return mojom::PermissionStatus::DENIED;
}
} // namespace blink
|
;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.9.1 #11310 (Linux)
;--------------------------------------------------------
; Processed by Z88DK
;--------------------------------------------------------
EXTERN __divschar
EXTERN __divschar_callee
EXTERN __divsint
EXTERN __divsint_callee
EXTERN __divslong
EXTERN __divslong_callee
EXTERN __divslonglong
EXTERN __divslonglong_callee
EXTERN __divsuchar
EXTERN __divsuchar_callee
EXTERN __divuchar
EXTERN __divuchar_callee
EXTERN __divuint
EXTERN __divuint_callee
EXTERN __divulong
EXTERN __divulong_callee
EXTERN __divulonglong
EXTERN __divulonglong_callee
EXTERN __divuschar
EXTERN __divuschar_callee
EXTERN __modschar
EXTERN __modschar_callee
EXTERN __modsint
EXTERN __modsint_callee
EXTERN __modslong
EXTERN __modslong_callee
EXTERN __modslonglong
EXTERN __modslonglong_callee
EXTERN __modsuchar
EXTERN __modsuchar_callee
EXTERN __moduchar
EXTERN __moduchar_callee
EXTERN __moduint
EXTERN __moduint_callee
EXTERN __modulong
EXTERN __modulong_callee
EXTERN __modulonglong
EXTERN __modulonglong_callee
EXTERN __moduschar
EXTERN __moduschar_callee
EXTERN __mulint
EXTERN __mulint_callee
EXTERN __mullong
EXTERN __mullong_callee
EXTERN __mullonglong
EXTERN __mullonglong_callee
EXTERN __mulschar
EXTERN __mulschar_callee
EXTERN __mulsuchar
EXTERN __mulsuchar_callee
EXTERN __muluschar
EXTERN __muluschar_callee
EXTERN __rlslonglong
EXTERN __rlslonglong_callee
EXTERN __rlulonglong
EXTERN __rlulonglong_callee
EXTERN __rrslonglong
EXTERN __rrslonglong_callee
EXTERN __rrulonglong
EXTERN __rrulonglong_callee
EXTERN ___sdcc_call_hl
EXTERN ___sdcc_call_iy
EXTERN ___sdcc_enter_ix
EXTERN _banked_call
EXTERN _banked_ret
EXTERN ___fs2schar
EXTERN ___fs2schar_callee
EXTERN ___fs2sint
EXTERN ___fs2sint_callee
EXTERN ___fs2slong
EXTERN ___fs2slong_callee
EXTERN ___fs2slonglong
EXTERN ___fs2slonglong_callee
EXTERN ___fs2uchar
EXTERN ___fs2uchar_callee
EXTERN ___fs2uint
EXTERN ___fs2uint_callee
EXTERN ___fs2ulong
EXTERN ___fs2ulong_callee
EXTERN ___fs2ulonglong
EXTERN ___fs2ulonglong_callee
EXTERN ___fsadd
EXTERN ___fsadd_callee
EXTERN ___fsdiv
EXTERN ___fsdiv_callee
EXTERN ___fseq
EXTERN ___fseq_callee
EXTERN ___fsgt
EXTERN ___fsgt_callee
EXTERN ___fslt
EXTERN ___fslt_callee
EXTERN ___fsmul
EXTERN ___fsmul_callee
EXTERN ___fsneq
EXTERN ___fsneq_callee
EXTERN ___fssub
EXTERN ___fssub_callee
EXTERN ___schar2fs
EXTERN ___schar2fs_callee
EXTERN ___sint2fs
EXTERN ___sint2fs_callee
EXTERN ___slong2fs
EXTERN ___slong2fs_callee
EXTERN ___slonglong2fs
EXTERN ___slonglong2fs_callee
EXTERN ___uchar2fs
EXTERN ___uchar2fs_callee
EXTERN ___uint2fs
EXTERN ___uint2fs_callee
EXTERN ___ulong2fs
EXTERN ___ulong2fs_callee
EXTERN ___ulonglong2fs
EXTERN ___ulonglong2fs_callee
EXTERN ____sdcc_2_copy_src_mhl_dst_deix
EXTERN ____sdcc_2_copy_src_mhl_dst_bcix
EXTERN ____sdcc_4_copy_src_mhl_dst_deix
EXTERN ____sdcc_4_copy_src_mhl_dst_bcix
EXTERN ____sdcc_4_copy_src_mhl_dst_mbc
EXTERN ____sdcc_4_ldi_nosave_bc
EXTERN ____sdcc_4_ldi_save_bc
EXTERN ____sdcc_4_push_hlix
EXTERN ____sdcc_4_push_mhl
EXTERN ____sdcc_lib_setmem_hl
EXTERN ____sdcc_ll_add_de_bc_hl
EXTERN ____sdcc_ll_add_de_bc_hlix
EXTERN ____sdcc_ll_add_de_hlix_bc
EXTERN ____sdcc_ll_add_de_hlix_bcix
EXTERN ____sdcc_ll_add_deix_bc_hl
EXTERN ____sdcc_ll_add_deix_hlix
EXTERN ____sdcc_ll_add_hlix_bc_deix
EXTERN ____sdcc_ll_add_hlix_deix_bc
EXTERN ____sdcc_ll_add_hlix_deix_bcix
EXTERN ____sdcc_ll_asr_hlix_a
EXTERN ____sdcc_ll_asr_mbc_a
EXTERN ____sdcc_ll_copy_src_de_dst_hlix
EXTERN ____sdcc_ll_copy_src_de_dst_hlsp
EXTERN ____sdcc_ll_copy_src_deix_dst_hl
EXTERN ____sdcc_ll_copy_src_deix_dst_hlix
EXTERN ____sdcc_ll_copy_src_deixm_dst_hlsp
EXTERN ____sdcc_ll_copy_src_desp_dst_hlsp
EXTERN ____sdcc_ll_copy_src_hl_dst_de
EXTERN ____sdcc_ll_copy_src_hlsp_dst_de
EXTERN ____sdcc_ll_copy_src_hlsp_dst_deixm
EXTERN ____sdcc_ll_lsl_hlix_a
EXTERN ____sdcc_ll_lsl_mbc_a
EXTERN ____sdcc_ll_lsr_hlix_a
EXTERN ____sdcc_ll_lsr_mbc_a
EXTERN ____sdcc_ll_push_hlix
EXTERN ____sdcc_ll_push_mhl
EXTERN ____sdcc_ll_sub_de_bc_hl
EXTERN ____sdcc_ll_sub_de_bc_hlix
EXTERN ____sdcc_ll_sub_de_hlix_bc
EXTERN ____sdcc_ll_sub_de_hlix_bcix
EXTERN ____sdcc_ll_sub_deix_bc_hl
EXTERN ____sdcc_ll_sub_deix_hlix
EXTERN ____sdcc_ll_sub_hlix_bc_deix
EXTERN ____sdcc_ll_sub_hlix_deix_bc
EXTERN ____sdcc_ll_sub_hlix_deix_bcix
EXTERN ____sdcc_load_debc_deix
EXTERN ____sdcc_load_dehl_deix
EXTERN ____sdcc_load_debc_mhl
EXTERN ____sdcc_load_hlde_mhl
EXTERN ____sdcc_store_dehl_bcix
EXTERN ____sdcc_store_debc_hlix
EXTERN ____sdcc_store_debc_mhl
EXTERN ____sdcc_cpu_pop_ei
EXTERN ____sdcc_cpu_pop_ei_jp
EXTERN ____sdcc_cpu_push_di
EXTERN ____sdcc_outi
EXTERN ____sdcc_outi_128
EXTERN ____sdcc_outi_256
EXTERN ____sdcc_ldi
EXTERN ____sdcc_ldi_128
EXTERN ____sdcc_ldi_256
EXTERN ____sdcc_4_copy_srcd_hlix_dst_deix
EXTERN ____sdcc_4_and_src_mbc_mhl_dst_deix
EXTERN ____sdcc_4_or_src_mbc_mhl_dst_deix
EXTERN ____sdcc_4_xor_src_mbc_mhl_dst_deix
EXTERN ____sdcc_4_or_src_dehl_dst_bcix
EXTERN ____sdcc_4_xor_src_dehl_dst_bcix
EXTERN ____sdcc_4_and_src_dehl_dst_bcix
EXTERN ____sdcc_4_xor_src_mbc_mhl_dst_debc
EXTERN ____sdcc_4_or_src_mbc_mhl_dst_debc
EXTERN ____sdcc_4_and_src_mbc_mhl_dst_debc
EXTERN ____sdcc_4_cpl_src_mhl_dst_debc
EXTERN ____sdcc_4_xor_src_debc_mhl_dst_debc
EXTERN ____sdcc_4_or_src_debc_mhl_dst_debc
EXTERN ____sdcc_4_and_src_debc_mhl_dst_debc
EXTERN ____sdcc_4_and_src_debc_hlix_dst_debc
EXTERN ____sdcc_4_or_src_debc_hlix_dst_debc
EXTERN ____sdcc_4_xor_src_debc_hlix_dst_debc
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
GLOBAL _m32_modff
;--------------------------------------------------------
; Externals used
;--------------------------------------------------------
GLOBAL _m32_polyf
GLOBAL _m32_hypotf
GLOBAL _m32_ldexpf
GLOBAL _m32_frexpf
GLOBAL _m32_invsqrtf
GLOBAL _m32_sqrtf
GLOBAL _m32_invf
GLOBAL _m32_sqrf
GLOBAL _m32_div2f
GLOBAL _m32_mul2f
GLOBAL _m32_fmodf
GLOBAL _m32_roundf
GLOBAL _m32_floorf
GLOBAL _m32_fabsf
GLOBAL _m32_ceilf
GLOBAL _m32_powf
GLOBAL _m32_log10f
GLOBAL _m32_log2f
GLOBAL _m32_logf
GLOBAL _m32_exp10f
GLOBAL _m32_exp2f
GLOBAL _m32_expf
GLOBAL _m32_atanhf
GLOBAL _m32_acoshf
GLOBAL _m32_asinhf
GLOBAL _m32_tanhf
GLOBAL _m32_coshf
GLOBAL _m32_sinhf
GLOBAL _m32_atan2f
GLOBAL _m32_atanf
GLOBAL _m32_acosf
GLOBAL _m32_asinf
GLOBAL _m32_tanf
GLOBAL _m32_cosf
GLOBAL _m32_sinf
GLOBAL __MAX_OPEN
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
SECTION bss_compiler
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
IF 0
; .area _INITIALIZED removed by z88dk
ENDIF
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
SECTION IGNORE
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
SECTION code_crt_init
;--------------------------------------------------------
; Home
;--------------------------------------------------------
SECTION IGNORE
;--------------------------------------------------------
; code
;--------------------------------------------------------
SECTION code_compiler
; ---------------------------------
; Function m32_modff
; ---------------------------------
_m32_modff:
push ix
ld ix,0
add ix,sp
ld l,(ix+8)
ld h,(ix+9)
push hl
ld l,(ix+6)
ld h,(ix+7)
push hl
ld l,(ix+4)
ld h,(ix+5)
push hl
call ___fs2slong_callee
push de
push hl
call ___slong2fs_callee
ld c, l
ld b, h
pop hl
push hl
ld (hl), c
inc hl
ld (hl), b
inc hl
ld (hl), e
inc hl
ld (hl), d
push de
push bc
ld l,(ix+6)
ld h,(ix+7)
push hl
ld l,(ix+4)
ld h,(ix+5)
push hl
call ___fssub
ld sp,ix
pop ix
ret
SECTION IGNORE
|
;PROGRAM DO WYZNACZANIA LICZBY ROZWIĄZAŃ RÓWNANIA KWADRATOWEGO 2x^2-8x+8=0
A: DC INTEGER(2)
B: DC INTEGER(-8)
C: DC INTEGER(8)
WYNIK: DS INTEGER
ZERO: DC INTEGER(0)
JEDEN: DC INTEGER(1)
DWA: DC INTEGER(2)
CZTERY: DC INTEGER(4)
MAIN:
LD 0, B ;REJESTR 0 -> B
MUL 0, 0 ;REJESTR 0 -> B * B
LD 1, CZTERY ;REJESTR 1 -> CZTERY
MUL 1, A ;REJESTR 1 -> CZTERY * A
MUL 1, C ;REJESTR 1 -> CZTERY * A * C
SUB 0, 1 ;REJESTR 0 -> B * B - CZTERY * A * C
JG DWA_ROZWIAZANIA ;B * B - CZTERY * A * C >? 0
JZ JEDNO_ROZWIAZANIE ;B * B - CZTERY * A * C =? 0
JL ZERO_ROZWIAZAN ;B * B - CZTERY * A * C <? 0
DWA_ROZWIAZANIA: ;B * B - CZTERY * A * C > 0
LD 2, DWA ;REJESTR 2 -> DWA
ST 2, WYNIK ;ZAPISZ W PAMIĘCI WYNIK
JMP KONIEC_PROGRAMU
JEDNO_ROZWIAZANIE: ;B * B - CZTERY * A * C = 0
LD 2, JEDEN ;REJESTR 2 -> JEDEN
ST 2, WYNIK ;ZAPISZ W PAMIĘCI WYNIK
JMP KONIEC_PROGRAMU
ZERO_ROZWIAZAN: ;B * B - CZTERY * A * C < 0
LD 2, ZERO ;REJESTR 2 -> ZERO
ST 2, WYNIK ;ZAPISZ W PAMIĘCI WYNIK
JMP KONIEC_PROGRAMU
KONIEC_PROGRAMU:
OUT WYNIK ;WYPISZ WYNIK NA EKRAN
EXIT ;KONIEC |
; A234272: G.f.: (1+4*x+x^2)/(1-4*x+x^2).
; 1,8,32,120,448,1672,6240,23288,86912,324360,1210528,4517752,16860480,62924168,234836192,876420600,3270846208,12206964232,45557010720,170021078648,634527303872,2368088136840,8837825243488,32983212837112,123095026104960,459396891582728,1714492540225952,6398573269321080,23879800537058368,89120628878912392,332602714978591200,1241290231035452408,4632558209163218432,17288942605617421320,64523212213306466848,240803906247608446072,898692412777127317440,3353965744860900823688,12517170566666475977312,46714716521805003085560,174341695520553536364928,650652065560409142374152,2428266566721083033131680,9062414201323922990152568,33821390238574608927478592,126223146752974512719761800,471071196773323441951568608,1758061640340319255086512632,6561175364587953578394481920,24486639818011495058491415048,91385383907458026655571178272,341054895811820611563793298040,1272834199339824419599602013888,4750281901547477066834614757512,17728293406850083847738857016160,66162891725852858324120813307128,246923273496561349448744396212352,921530202260392539470856771542280,3439197535545008808434682689956768,12835259939919642694267873988284792,47901842224133561968636813263182400,178772108956614605180279379064444808,667186593602324858752480702994596832
mov $1,4
lpb $0
sub $0,1
add $2,$1
add $2,$1
add $1,$2
lpe
mov $1,1
mov $3,$2
trn $3,1
add $1,$3
mov $0,$1
|
%include "io.inc"
section .text
global CMAIN
CMAIN:
mov eax, zone2
jmp eax ; salt neconditionat catre adresa ce se afla in registrul eax
zone1:
mov eax, 1
mov ebx, 2
add eax, ebx
PRINT_UDEC 4, eax
jmp exit
zone2:
mov eax, 7
mov ebx, 8
add eax, ebx
PRINT_UDEC 4, eax
NEWLINE
jmp $-0x174 ; salt relativ cu deplasamanent
exit:
ret
|
; A073791: Replace 4^k with (-4)^k in base 4 expansion of n.
; Submitted by Christian Krause
; 0,1,2,3,-4,-3,-2,-1,-8,-7,-6,-5,-12,-11,-10,-9,16,17,18,19,12,13,14,15,8,9,10,11,4,5,6,7,32,33,34,35,28,29,30,31,24,25,26,27,20,21,22,23,48,49,50,51,44,45,46,47,40,41,42,43,36,37,38,39,-64,-63,-62,-61,-68,-67,-66,-65,-72,-71,-70,-69
mov $3,1
lpb $0
mov $2,$0
div $0,4
mod $2,4
mul $2,$3
add $1,$2
mul $3,-4
lpe
mov $0,$1
|
INCLUDE "clib_cfg.asm"
SECTION code_fcntl
PUBLIC console_01_output_fzx_oterm_msg_putc
PUBLIC console_01_output_fzx_oterm_msg_putc_raw
EXTERN l_jpix, l_offset_ix_de, asm_fzx_putc
EXTERN __fzx_puts_newline, __fzx_puts_newline_set_y
EXTERN console_01_output_fzx_proc_linefeed
EXTERN console_01_output_fzx_proc_check_scroll
EXTERN __fzx_puts_single_spacing
EXTERN console_01_output_fzx_proc_putchar_scroll
EXTERN OTERM_MSG_TTY, OTERM_MSG_BELL
console_01_output_fzx_oterm_msg_putc:
; enter : c = char to output
; can use: af, bc, de, hl
; char to print is coming from stdio
bit 5,(ix+6)
jr z, cooked ; if cook is disabled
; tty emulation is enabled
ld a,OTERM_MSG_TTY
call l_jpix
ret nc ; if tty absorbed char
ld a,c
cp CHAR_BELL
jr nz, cooked
putchar_bell:
ld a,OTERM_MSG_BELL
jp (ix)
cooked:
; c = ascii code
bit 4,(ix+6)
jr z, crlf_done ; if not processing crlf
ld a,c
cp CHAR_CR
ret z ; ignore cr
crlf_done:
console_01_output_fzx_oterm_msg_putc_raw:
; entry for input terminal
; c = ascii code
ld hl,30
call l_offset_ix_de
push hl
ex (sp),ix
; ix = struct fzx_state *
; c = ascii code
; stack = FDSTRUCT.JP *
ld a,c
cp CHAR_LF
jr z, putchar_lf
cp 32
jr nc, putchar_loop ; if printable
ld c,'?'
putchar_loop:
; ix = struct fzx_state *
; c = ascii code
; stack = FDSTRUCT.JP *
push bc
call asm_fzx_putc
pop bc ; c = ascii code
jr nc, putchar_done ; if successful
; char will not fit window
dec a
jr z, vertical ; if char does not fit vertically
horizontal:
; char will not fit horizontally
call console_01_output_fzx_proc_linefeed
jr c, putchar_loop ; if scroll not necessary
jr scroll_it
vertical:
; char will not fit vertically
call __fzx_puts_single_spacing
call console_01_output_fzx_proc_check_scroll
jr c, putchar_loop ; should not happen
scroll_it:
; ix = struct fzx_state *
; c = ascii code
; hl = scroll amount in pixels
; stack = FDSTRUCT.JP *
ex (sp),ix
push bc
; ix = FDSTRUCT.JP *
; hl = scroll amount in pixels
; stack = struct fzx_state *, ascii code
call console_01_output_fzx_proc_putchar_scroll
pop bc
ex (sp),ix
jr putchar_loop
putchar_lf:
; ix = struct fzx_state *
; stack = FDSTRUCT.JP *
call console_01_output_fzx_proc_linefeed
pop ix
ret c ; if scroll unnecessary
; ix = FDSTRUCT.JP *
; hl = scroll amount in pixels
jp console_01_output_fzx_proc_putchar_scroll
putchar_done:
; ix = struct fzx_state *
; stack = FDSTRUCT.JP *
pop ix
ret
|
;***********************************************************
; UTN-2014-Rutinas de Interrupcion
;***********************************************************
;***********************************************************
; Author : Fernandez Marcelo Joaquin
; Date : 23th May 2014
;***********************************************************
;http://support.microsoft.com/kb/117389/es ;buena descripcion resumida de fuentes de excepciones
[BITS 64]
%include "include/isr_pageFaultExceptionHandler.asm"
%include "include/isr_keyboardHandler.asm"
%include "include/isr_svc.asm"
%include "include/isr_int0_scheduler.asm"
%include "include/debug_registers.asm"
;http://sourceforge.net/p/nasm/mailman/nasm-users/thread/4DFE094A.9020105@computer.org/
%assign i 2
%rep 46
irsMSG_%+i: db "SALTO_EXCEPCION_N_"
irsMSG2_%+i:db 0,0,0,0,0,0,0,0,0,0
int_%+i:
push rdi
push rax
xchg bx,bx
mov edi,irsMSG_%+i
mov esi,10 ; esi (segundo argumento) char columna
mov edx,6 ; edx (tercer argumento) char fila
mov ecx,111b ; ECX (cuarto arguemto) char color
call Print_64
mov edi,i ;valor de la excepcion
mov esi,irsMSG2_%+i ;puntero a char
call my_itoa ;llamo a mi super funcion itoa
mov edi,irsMSG2_%+i
mov esi,28 ; esi (segundo argumento) char columna
mov edx,6 ; edx (tercer argumento) char fila
mov ecx,111b ; ECX (cuarto arguemto) char color
call Print_64 ;hago que imprima el numero
mov al,20h
out 20h,al
pop rax
pop rdi
iretq
%assign i i+1
%endrep
;-----------------------------------------------------------
; Handler de division por cero
; Recibe: Nada
; Devuelve: Nada
;------------------------------------------------------------
ex0_DIV0Handler:
mov al,20h
out 20h,al ; Send the EOI to the PIC
xchg bx,bx
iretq
G_DF_txt: db "GENERANDO DOBLE FAULT!! ", 00h
G_GP_txt: db "GENERANDO GENERAL PROTECTION:!!", 00h
G_PG_txt: db "GENERANDO PAGE FAULT!! ", 00h
GENERAR_DOBLE_FAULT:
mov edi,G_DF_txt
mov esi,5 ; esi (segundo argumento) char columna
mov edx,23 ; edx (tercer argumento) char fila
mov ecx,111b ; ECX (cuarto arguemto) char color
call Print_64
;divido por cero para generar una excepcion de division por cero
;o si esta mal definida que genere una general protection
mov rax,0x00000001 ;preguntar por que exploca y no explotaba
mov rbx,0x00000000
div rbx
ret
GENERAR_GENERAL_PROTECTION:
mov edi,G_GP_txt
mov esi,5 ; esi (segundo argumento) char columna
mov edx,23 ; edx (tercer argumento) char fila
mov ecx,111b ; ECX (cuarto arguemto) char color
call Print_64
;escribo en un bit reservado del cr4
mov rax,0x100000
mov cr4, rax
;xchg bx,bx
;divido por cero para generar una excepcion de division por cero
;o si esta mal definida que genere una general protection
;mov rax,0x00000000 preguntar por que exploca y no explotaba
;mov rbx,0x00000000
;div rbx
;salto a una sona no ejecutable
;jmp G_DF_txt
;pruebo de escribir en una direccion superior al primer megabyte
;donde posicione las tablas de paginacion
;mov edi,0x100000 ;me posiciono en el primer megabyte
;mov word [edi],0xA0BA0; ;escribo basura XD
ret
GENERAR_PAGE_FAULT:
mov edi,G_PG_txt
mov esi,5 ; esi (segundo argumento) char columna
mov edx,23 ; edx (tercer argumento) char fila
mov ecx,111b ; ECX (cuarto arguemto) char color
call Print_64
;trato de leer en una zona de memoria que no esta en pagina
mov rax,[0x70000000]
ret
;-----------------------------------------------------------
; Handler de DoubleFault
; Recibe: Nada
; Devuelve: Nada
;-----------------------------------------------------------
G_DFH_txt: db "ex8_DoubleFaultHandler!!...HLT!", 00h
ex8_DoubleFaultHandler:
pop rax
mov edi,G_DFH_txt
mov esi,5 ; esi (segundo argumento) char columna
mov edx,16 ; edx (tercer argumento) char fila
mov ecx,100b ; ECX (cuarto arguemto) char color
call Print_64
hlt
; pop rax ;incremento el eip en 3 para que siga con laproxima instruccion
; add rax, 11b
; push rax
iretq
;-----------------------------------------------------------
; Handler de General Protection
; Recibe: Nada
; Devuelve: Nada
;-----------------------------------------------------------
G_GPH_txt: db "ex13_GeneralProtectionHandler!! ", 00h
ex13_GeneralProtectionHandler:
pop rbx
mov edi,G_GPH_txt
mov esi,5 ; esi (segundo argumento) char columna
mov edx,16 ; edx (tercer argumento) char fila
mov ecx,100b ; ECX (cuarto arguemto) char color
call Print_64
hlt
iretq
;-----------------------------------------------------------
; Handler de General Protection
; Recibe: Nada
; Devuelve: Nada
;-----------------------------------------------------------
ex7_NMHandler:
;bajo el flag de TS
clts
;restauro los datos a las mmx
mov rbx,[Current_disp_Task]
mov rbx,[rbx + dispatcher_task_struct.current_task_struct]
mov rbx,[rbx + task_struct.MMX]
FXRSTOR [rbx]
iretq
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.