text stringlengths 1 1.05M |
|---|
db 0, 1, 3, 4, 6, 7, 9, 10, 12, 14, 15, 17, 18, 20, 21, 23
db 24, 25, 27, 28, 30, 31, 32, 34, 35, 36, 38, 39, 40, 41, 42, 44
db 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 54, 55, 56, 57, 57, 58
db 59, 59, 60, 60, 61, 61, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63
db 64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 61, 60, 60, 59
db 59, 58, 57, 57, 56, 55, 54, 54, 53, 52, 51, 50, 49, 48, 47, 46
db 45, 44, 42, 41, 40, 39, 38, 36, 35, 34, 32, 31, 30, 28, 27, 25
db 24, 23, 21, 20, 18, 17, 15, 14, 12, 10, 9, 7, 6, 4, 3, 1
db 0, 255, 253, 252, 250, 249, 247, 246, 244, 242, 241, 239, 238, 236, 235, 233
db 232, 231, 229, 228, 226, 225, 224, 222, 221, 220, 218, 217, 216, 215, 214, 212
db 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 202, 201, 200, 199, 199, 198
db 197, 197, 196, 196, 195, 195, 194, 194, 194, 193, 193, 193, 193, 193, 193, 193
db 192, 193, 193, 193, 193, 193, 193, 193, 194, 194, 194, 195, 195, 196, 196, 197
db 197, 198, 199, 199, 200, 201, 202, 202, 203, 204, 205, 206, 207, 208, 209, 210
db 211, 212, 214, 215, 216, 217, 218, 220, 221, 222, 224, 225, 226, 228, 229, 231
db 232, 233, 235, 236, 238, 239, 241, 242, 244, 246, 247, 249, 250, 252, 253, 255
|
#include "wmpch.h"
#include "WormEventHandle.h"
#include "InGame/Entity/World/WorldFSMHandler.h"
void InGame::WormWorldEventHandler::Handle(std::any data, int entityID, bool & handled)
{
auto worldData = std::any_cast<WorldData>(data);
if (worldData.DataType == WorldDataType::PrepareNextPhase)
{
auto status = Gear::EntitySystem::GetStatus(entityID);
if (GameMode::Bit::ModeBit == GameMode::NetWork)
{
if (!Gear::EntitySystem::IsComponenetActivate(entityID, Gear::ComponentID::NetController))
{
handled = true;
return;
}
}
else
{
if (!Gear::EntitySystem::IsComponenetActivate(entityID, Gear::ComponentID::Controller))
{
handled = true;
return;
}
}
auto FSM = Gear::EntitySystem::GetFSM(entityID);
auto prevState = FSM->GetCurrentState();
if (prevState == WormState::OnReadyItemUse)
{
ItemWithdraw(entityID);
FSM->GetHandler(WormState::OnReadyItemUse)->OnOut(entityID);
prevState = WormState::OnItemWithdraw;
FSM->SetCurrentState(WormState::OnItemWithdraw);
}
if (prevState != WormState::OnBreath && prevState != WormState::OnWaiting && prevState != WormState::OnNotMyTurn && prevState != WormState::OnNothing)
{
handled = false;
return;
}
auto timer = Gear::EntitySystem::GetTimer(entityID);
FSM->SetCurrentState(WormState::OnTurnOver);
timer->SetTimer(1.5f);
timer->Start();
handleAnimator(entityID, prevState);
if (prevState == WormState::OnWaiting)
{
status->SetNeedHandleData(WormStatusHandleType::WaitingDisplay, true);
status->SetNeedHandleData(WormStatusHandleType::Display, false);
}
else
{
status->PushNeedHandleData(WormStatusHandleType::DisplayPosChange, Gear::Status::StatHandleData(std::make_pair(-0.2f, 0.0f)));
}
handled = true;
return;
}
handled = true;
}
|
###############################################################################
# Copyright 2019 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
.text
.p2align 5, 0x90
.globl _cpAESCMAC_Update_AES_NI
_cpAESCMAC_Update_AES_NI:
movslq %edx, %rdx
movdqu (%rdi), %xmm0
.p2align 5, 0x90
.Lblks_loopgas_1:
movdqu (%rsi), %xmm1
movdqa (%r8), %xmm4
mov %r8, %r9
pxor %xmm1, %xmm0
pxor %xmm4, %xmm0
movdqa (16)(%r9), %xmm4
add $(16), %r9
mov %rcx, %r10
sub $(1), %r10
.p2align 5, 0x90
.Lcipher_loopgas_1:
aesenc %xmm4, %xmm0
movdqa (16)(%r9), %xmm4
add $(16), %r9
dec %r10
jnz .Lcipher_loopgas_1
aesenclast %xmm4, %xmm0
add $(16), %rsi
sub $(16), %rdx
jnz .Lblks_loopgas_1
pxor %xmm4, %xmm4
movdqu %xmm0, (%rdi)
vzeroupper
ret
|
Route2_h:
db 00 ; Tileset
db ROUTE_2_HEIGHT,ROUTE_2_WIDTH ;Height,Width blocks (1 block = 4x4 tiles)
dw Route2Blocks, Route2TextPointers, Route2Script
db NORTH | SOUTH ;Connection Byte
NORTH_MAP_CONNECTION ROUTE_2, PEWTER_CITY, -3, 2, PewterCityBlocks
SOUTH_MAP_CONNECTION ROUTE_2, VIRIDIAN_CITY, -3, 2, ViridianCityBlocks, 1
dw Route2Object ;Object Data Pointer
|
; A232866: Positions of the nonnegative integers in the sequence (or tree) of complex numbers generated by these rules: 0 is in S, and if x is in S, then x + 1 and i*x are in S, where duplicates are deleted as they occur.
; 1,2,3,5,9,16,27,42,61,84,111,142,177,216,259,306,357,412,471,534,601,672,747,826,909,996,1087,1182,1281,1384,1491,1602,1717,1836,1959,2086,2217,2352,2491,2634,2781,2932,3087,3246,3409,3576,3747,3922,4101,4284,4471,4662,4857,5056,5259,5466,5677,5892,6111,6334,6561,6792,7027,7266,7509,7756,8007,8262,8521,8784,9051,9322,9597,9876,10159,10446,10737,11032,11331,11634,11941,12252,12567,12886,13209,13536,13867,14202,14541,14884,15231,15582,15937,16296,16659,17026,17397,17772,18151,18534
lpb $0
add $1,1
add $2,$3
trn $2,5
mov $3,$0
add $4,$0
sub $0,1
trn $3,4
trn $4,2
add $4,$3
add $1,$4
add $1,$2
mov $2,$0
sub $2,$3
mov $4,$3
mov $3,$2
mov $2,$0
trn $4,1
lpe
add $1,1
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r14
push %r15
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0xb0bd, %rdx
nop
nop
nop
nop
xor $63749, %r8
mov $0x6162636465666768, %r15
movq %r15, (%rdx)
and $25655, %rcx
lea addresses_UC_ht+0x24bd, %r12
xor $59551, %r14
movw $0x6162, (%r12)
nop
nop
nop
nop
nop
add $57407, %r15
lea addresses_D_ht+0x1757d, %rsi
lea addresses_WC_ht+0x37bd, %rdi
nop
nop
nop
nop
nop
add %r12, %r12
mov $86, %rcx
rep movsl
nop
add $41469, %r8
lea addresses_D_ht+0x4edd, %rsi
nop
nop
nop
cmp $34308, %rdi
mov $0x6162636465666768, %rdx
movq %rdx, %xmm4
and $0xffffffffffffffc0, %rsi
vmovaps %ymm4, (%rsi)
xor $24036, %r12
lea addresses_UC_ht+0x1c2fd, %rsi
lea addresses_A_ht+0xcbbd, %rdi
nop
nop
nop
and %r15, %r15
mov $80, %rcx
rep movsl
nop
nop
nop
and %r13, %r13
lea addresses_WC_ht+0xe5ad, %rdi
xor $32014, %r8
mov (%rdi), %dx
nop
nop
nop
xor $46840, %rdx
lea addresses_WC_ht+0xabbd, %rsi
lea addresses_UC_ht+0x1cbbd, %rdi
nop
nop
nop
nop
nop
xor %r15, %r15
mov $29, %rcx
rep movsq
dec %rdx
lea addresses_WC_ht+0x9a54, %rsi
lea addresses_normal_ht+0x1dbd, %rdi
nop
nop
inc %rdx
mov $127, %rcx
rep movsb
nop
nop
cmp $47963, %rdi
lea addresses_UC_ht+0x12815, %rsi
lea addresses_D_ht+0xcb9d, %rdi
clflush (%rdi)
nop
add %rdx, %rdx
mov $104, %rcx
rep movsl
nop
xor $59273, %rdi
lea addresses_D_ht+0x12bf5, %r13
nop
nop
nop
sub $44575, %rcx
mov $0x6162636465666768, %r15
movq %r15, %xmm7
vmovups %ymm7, (%r13)
nop
and %r8, %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r14
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r9
push %rax
push %rbp
push %rbx
push %rcx
push %rsi
// Load
lea addresses_WT+0x1a0ce, %rax
nop
nop
dec %rsi
movups (%rax), %xmm0
vpextrq $1, %xmm0, %r10
nop
nop
nop
nop
and $62881, %rax
// Store
lea addresses_PSE+0x2d6d, %rbp
nop
nop
and %rcx, %rcx
movw $0x5152, (%rbp)
nop
nop
nop
nop
add %rbx, %rbx
// Store
lea addresses_WC+0xeaf5, %rsi
nop
nop
dec %rbp
movw $0x5152, (%rsi)
nop
xor $23081, %rbx
// Faulty Load
lea addresses_US+0xe7bd, %rsi
nop
nop
nop
and $27183, %rax
movb (%rsi), %r10b
lea oracles, %rcx
and $0xff, %r10
shlq $12, %r10
mov (%rcx,%r10,1), %r10
pop %rsi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r9
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 8, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'00': 16016}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
#include <string>
#include "envoy/registry/registry.h"
#include "external/envoy/source/common/protobuf/message_validator_impl.h"
#include "api/server/response_options.pb.h"
#include "api/server/response_options.pb.validate.h"
#include "server/http_test_server_filter.h"
namespace Nighthawk {
namespace Server {
namespace Configuration {
class HttpTestServerDecoderFilterConfig
: public Envoy::Server::Configuration::NamedHttpFilterConfigFactory {
public:
Envoy::Http::FilterFactoryCb
createFilterFactoryFromProto(const Envoy::Protobuf::Message& proto_config, const std::string&,
Envoy::Server::Configuration::FactoryContext& context) override {
auto& validation_visitor = Envoy::ProtobufMessage::getStrictValidationVisitor();
return createFilter(
Envoy::MessageUtil::downcastAndValidate<const nighthawk::server::ResponseOptions&>(
proto_config, validation_visitor),
context);
}
Envoy::ProtobufTypes::MessagePtr createEmptyConfigProto() override {
return Envoy::ProtobufTypes::MessagePtr{new nighthawk::server::ResponseOptions()};
}
std::string name() const override { return "test-server"; }
private:
Envoy::Http::FilterFactoryCb createFilter(const nighthawk::server::ResponseOptions& proto_config,
Envoy::Server::Configuration::FactoryContext&) {
Nighthawk::Server::HttpTestServerDecoderFilterConfigSharedPtr config =
std::make_shared<Nighthawk::Server::HttpTestServerDecoderFilterConfig>(
Nighthawk::Server::HttpTestServerDecoderFilterConfig(proto_config));
return [config](Envoy::Http::FilterChainFactoryCallbacks& callbacks) -> void {
auto* filter = new Nighthawk::Server::HttpTestServerDecoderFilter(config);
callbacks.addStreamDecoderFilter(Envoy::Http::StreamDecoderFilterSharedPtr{filter});
};
}
};
static Envoy::Registry::RegisterFactory<HttpTestServerDecoderFilterConfig,
Envoy::Server::Configuration::NamedHttpFilterConfigFactory>
register_;
} // namespace Configuration
} // namespace Server
} // namespace Nighthawk
|
;
; Z88 Graphics Functions - Small C+ stubs
;
; Written around the Interlogic Standard Library
;
; Stubs Written by D Morris - 30/9/98
;
;
; $Id: w_circle.asm,v 1.1 2010/11/25 13:46:40 stefano Exp $
;
;Usage: circle(struct *pixels)
XLIB circle
LIB w_draw_circle
LIB w_plotpixel
LIB swapgfxbk
XREF swapgfxbk1
.circle
ld ix,0
add ix,sp
; de = x0, hl = y0, bc = radius, a = scale factor
ld a,(ix+2) ;skip
ld c,(ix+4) ;radius
ld b,(ix+5)
ld l,(ix+6) ;y
ld h,(ix+7)
ld e,(ix+8) ;x
ld d,(ix+9)
ld ix,w_plotpixel
call swapgfxbk
call w_draw_circle
jp swapgfxbk1
|
; A173653: Partial sums of floor(n^2/10) (A056865)
; 0,0,0,0,1,3,6,10,16,24,34,46,60,76,95,117,142,170,202,238,278,322,370,422,479,541,608,680,758,842,932,1028,1130,1238,1353,1475,1604,1740,1884,2036,2196,2364,2540,2724,2917,3119,3330,3550,3780
mov $2,$0
mov $3,$0
lpb $3
mov $0,$2
sub $3,1
sub $0,$3
mov $4,$0
pow $4,2
div $4,10
add $1,$4
lpe
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r15
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x1b3ea, %rsi
lea addresses_UC_ht+0x181ea, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
add %rbx, %rbx
mov $78, %rcx
rep movsb
nop
nop
inc %rbp
lea addresses_WT_ht+0xdbea, %rbx
nop
dec %r12
movb $0x61, (%rbx)
nop
nop
lfence
lea addresses_A_ht+0xe025, %rdi
nop
nop
nop
add $13367, %r11
mov $0x6162636465666768, %rbp
movq %rbp, %xmm4
movups %xmm4, (%rdi)
nop
sub %rbp, %rbp
lea addresses_WT_ht+0xa22a, %rbx
nop
nop
nop
nop
nop
and $36080, %r12
and $0xffffffffffffffc0, %rbx
movntdqa (%rbx), %xmm1
vpextrq $1, %xmm1, %rdi
nop
nop
nop
nop
add %rbx, %rbx
lea addresses_A_ht+0xe7b6, %rsi
nop
nop
nop
nop
add %rbx, %rbx
mov $0x6162636465666768, %rdi
movq %rdi, (%rsi)
nop
add %r12, %r12
lea addresses_WC_ht+0x1e9ea, %rsi
lea addresses_UC_ht+0x111ea, %rdi
nop
add %r15, %r15
mov $55, %rcx
rep movsw
nop
nop
nop
cmp $61175, %rcx
lea addresses_WC_ht+0x18b1d, %r12
nop
cmp $53327, %rcx
mov (%r12), %r11w
nop
nop
nop
inc %rbx
lea addresses_normal_ht+0x336a, %rsi
lea addresses_WC_ht+0x100ea, %rdi
nop
cmp %r15, %r15
mov $112, %rcx
rep movsq
nop
dec %r15
lea addresses_normal_ht+0x1978a, %rbx
nop
add %rcx, %rcx
movw $0x6162, (%rbx)
nop
nop
nop
nop
and $22384, %rbp
lea addresses_UC_ht+0xaf2a, %rsi
lea addresses_normal_ht+0x1c22a, %rdi
nop
nop
nop
sub %rbx, %rbx
mov $80, %rcx
rep movsl
nop
and %r12, %r12
lea addresses_WT_ht+0x71ea, %rcx
cmp %rbp, %rbp
vmovups (%rcx), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $1, %xmm0, %r12
nop
cmp $60430, %r11
lea addresses_WT_ht+0x1cdea, %rsi
lea addresses_WC_ht+0x925a, %rdi
xor %rbx, %rbx
mov $18, %rcx
rep movsw
nop
nop
nop
nop
inc %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r8
push %r9
push %rbp
push %rcx
push %rdx
// Load
lea addresses_RW+0x15dea, %rcx
nop
nop
add %rbp, %rbp
movups (%rcx), %xmm5
vpextrq $1, %xmm5, %r10
xor %rdx, %rdx
// Faulty Load
lea addresses_UC+0x79ea, %rcx
nop
nop
xor %r8, %r8
mov (%rcx), %rbp
lea oracles, %r11
and $0xff, %rbp
shlq $12, %rbp
mov (%r11,%rbp,1), %rbp
pop %rdx
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 10, 'size': 16, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 5, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 10, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; A169018: Number of reduced words of length n in Coxeter group on 5 generators S_i with relations (S_i)^2 = (S_i S_j)^24 = I.
; 1,5,20,80,320,1280,5120,20480,81920,327680,1310720,5242880,20971520,83886080,335544320,1342177280,5368709120,21474836480,85899345920,343597383680,1374389534720,5497558138880,21990232555520,87960930222080
mov $1,4
pow $1,$0
mul $1,5
div $1,4
mov $0,$1
|
/*=============================================================================
Copyright (c) 2010-2016 Bolero MURAKAMI
https://github.com/bolero-MURAKAMI/Sprig
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 SPRIG_SERIALIZATION_BOOST_FUSION_LIST_HPP
#define SPRIG_SERIALIZATION_BOOST_FUSION_LIST_HPP
#include <sprig/config/config.hpp>
#ifdef SPRIG_USING_PRAGMA_ONCE
# pragma once
#endif // #ifdef SPRIG_USING_PRAGMA_ONCE
#include <boost/fusion/include/list.hpp>
#include <sprig/serialization/boost/fusion/fusion_sequence_serialize_def.hpp>
//
// boost::fusion::list
//
SPRIG_SERIALIZATION_BOOST_FUSION_SEQUENCE_SERIALIZE_DEF(
FUSION_MAX_LIST_SIZE,
boost::fusion::list
);
#endif // #ifndef SPRIG_SERIALIZATION_BOOST_FUSION_LIST_HPP
|
; A084859: Binomial transform of Cullen numbers A002064.
; 1,4,16,62,232,842,2980,10334,35248,118610,394684,1301126,4255624,13825658,44657428,143521838,459230560,1463719586,4649308012,14722502870,46491507256,146447041994,460259735236,1443537130622
mov $1,$0
mov $3,1
lpb $0
sub $0,1
mul $1,2
add $2,$1
mov $1,$2
mul $3,2
lpe
add $1,$3
|
/*=============================================================================
Copyright (C) 2015 Kohei Takahshi
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)
==============================================================================*/
#include <boost/fusion/container/list/list.hpp>
#include <boost/core/lightweight_test.hpp>
#define FUSION_SEQUENCE list
#include "nest.hpp"
int
main()
{
test();
return boost::report_errors();
}
|
ADDI 1
STORE 1
|
;/*!
; @file
;
; @ingroup fapi
;
; @brief BadDynLink
;
; (c) osFree Project 2018, <http://www.osFree.org>
; for licence see licence.txt in root directory, or project website
;
; This is Family API implementation for DOS, used with BIND tools
; to link required API
;
; @author Yuri Prokushev (yuri.prokushev@gmail.com)
;
;*/
.8086
INCLUDE dos.inc
INCLUDE bseerr.inc
_TEXT SEGMENT BYTE PUBLIC 'CODE' USE16
BADDYNLINK PROC FAR
END_PROCESS ERROR_BAD_DYNALINK
BADDYNLINK ENDP
_TEXT ENDS
END
|
include uXmx86asm.inc
option casemap:none
ifndef __X64__
.686P
.xmm
.model flat, c
else
.X64P
.xmm
option win64:11
option stackbase:rsp
endif
option frame:auto
.code
align 16
uXm_has_AVX512_VBMI_VL proto VECCALL (byte)
align 16
uXm_has_AVX512_VBMI_VL proc VECCALL (byte)
mov eax, 0
cpuid
cmp ecx, bit_ntel ; 'GenuineIntel'
jne not_supported
mov eax, 1
cpuid
and ecx, bit_OSXSAVE
cmp ecx, bit_OSXSAVE ; check OSXSAVE
jne not_supported
; processor XGETBV is enabled by OS
mov ecx, 0 ; specify 0 for XCR0 register
xgetbv ; result in edx:eax
and eax, 0E6h
cmp eax, 0E6h ; check OS has enabled both XMM and YMM and ZMM state support
jne not_supported
mov eax, 7
cpuid
and ebx, bit_AVX512F_VL
cmp ebx, bit_AVX512F_VL ; AVX512F AVX512VL support by microprocessor
jne not_supported
and ecx, bit_AVX512_VBMI
cmp ecx, bit_AVX512_VBMI ; AVX512_VBMI support by microprocessor
jne not_supported
mov al, true
jmp done
not_supported:
mov al, false
done:
ret
uXm_has_AVX512_VBMI_VL endp
end ;.code |
test START 0
LDA a
. make sure PC-relative is not selected with extended
+LDA a
+LDB b
BASE c
LDA b
. make sure base is not selected with extended
+LDA b
BASE a
+LDA b
ORG 0x300
a WORD 1
ORG 0x40000
c EQU *
RESB 1000
b WORD 2
END test
|
//********************************************************************************
// Copyright (c) 2007-2014 Intel Corporation. All rights reserved. **
// **
// Redistribution and use in source and binary forms, with or without **
// modification, are permitted provided that the following conditions are met: **
// * Redistributions of source code must retain the above copyright notice, **
// this list of conditions and the following disclaimer. **
// * Redistributions in binary form must reproduce the above copyright **
// notice, this list of conditions and the following disclaimer in the **
// documentation and/or other materials provided with the distribution. **
// * Neither the name of Intel Corporation nor the names of its contributors **
// may be used to endorse or promote products derived from this software **
// without specific prior written permission. **
// **
// This software is provided by the copyright holders and contributors "as is" **
// and any express or implied warranties, including, but not limited to, the **
// implied warranties of merchantability and fitness for a particular purpose **
// are disclaimed. In no event shall the copyright owner or contributors be **
// liable for any direct, indirect, incidental, special, exemplary, or **
// consequential damages (including, but not limited to, procurement of **
// substitute goods or services; loss of use, data, or profits; or business **
// interruption) however caused and on any theory of liability, whether in **
// contract, strict liability, or tort (including negligence or otherwise) **
// arising in any way out of the use of this software, even if advised of **
// the possibility of such damage. **
//********************************************************************************
#include <stdio.h>
#include <stdlib.h>
#include "tbb/tick_count.h"
#include "cnc/cnc.h"
#include "cnc/debug.h"
//there was a hash issue as far as I recall
//typedef std::pair<int,int> intPair;
//
typedef int intPair;
intPair makePair(int i, int j) {return (i << 16) + j; }
int getFirst(intPair givenPair) { return givenPair >> 16;}
int getSecond(intPair givenPair) { return givenPair & 0xffff;}
int ceiling(int dividend, int divisor)
{
int tmp = dividend / divisor;
if(tmp*divisor != dividend) ++tmp;
return tmp;
}
struct sorContext;
struct iterationStep{
int execute(int i, sorContext& graph) const;
};
struct relaxation{
int execute(intPair tileIndex2D, sorContext& graph) const;
};
struct sorContext : public CnC::context<sorContext>
{
CnC::step_collection< relaxation > m_rlxSteps;
CnC::step_collection< iterationStep > m_itSteps;
CnC::tag_collection<intPair> tileSpace;
CnC::tag_collection<int> iterationSpace;
CnC::item_collection<intPair, double> prevIterMatrix, currIterMatrix;
CnC::item_collection<int, int> nRowsInTile, nColumnsInTile, nRowsOfTiles,nColumnsOfTiles;
CnC::item_collection<int, double> omega;
sorContext()
: CnC::context< sorContext >(),
m_rlxSteps( *this ),
m_itSteps( *this ),
tileSpace(*this),
iterationSpace(*this),
prevIterMatrix(*this),
currIterMatrix(*this),
nRowsInTile(*this),
nColumnsInTile(*this),
nRowsOfTiles(*this),
nColumnsOfTiles(*this),
omega(*this)
{
iterationSpace.prescribes( m_itSteps, *this );
tileSpace.prescribes( m_rlxSteps, *this );
}
};
int iterationStep::execute(int iterationNumber, sorContext& graph) const
{
int nRowsOfTiles;
graph.nRowsOfTiles.get(444, nRowsOfTiles);
int nColumnsOfTiles;
graph.nColumnsOfTiles.get(555, nColumnsOfTiles);
for(int i = 0; i < nRowsOfTiles; ++i)
for(int j = 0; j < nColumnsOfTiles; ++j)
graph.tileSpace.put(makePair(i,j));
#if 0
for(int i = nRowsOfTiles-1; i >= 0; --i)
for(int j = nColumnsOfTiles-1; j >= 0 ; --j)
graph.tileSpace.put(makePair(i,j));
#endif
return CnC::CNC_Success;
}
int relaxation::execute(intPair tileIndex2D, sorContext& graph) const
{
int rowIndexOfTile = getFirst(tileIndex2D);
int columnIndexOfTile = getSecond(tileIndex2D);
// these are from curr, already computed matrix
bool hasAbove = rowIndexOfTile != 0;
bool hasLeft = columnIndexOfTile != 0;
int nRowsOfTiles;
graph.nRowsOfTiles.get(444, nRowsOfTiles);
int nColumnsOfTiles;
graph.nColumnsOfTiles.get(555, nColumnsOfTiles);
// these are from prev, input matrix
// also these are the corner cases
bool hasBelow = rowIndexOfTile != nRowsOfTiles-1;
bool hasRight= columnIndexOfTile != nColumnsOfTiles-1;
int nRowsInTile;
graph.nRowsInTile.get(222,nRowsInTile );
int nColumnsInTile;
graph.nColumnsInTile.get(333, nColumnsInTile);
int firstElementI = rowIndexOfTile*nRowsInTile;
int firstElementJ = columnIndexOfTile*nColumnsInTile;
double *above, *left, *below, *right;
if(hasAbove) {
above = new double[nColumnsInTile];
for(int j = 0; j < nColumnsInTile; ++j)
graph.currIterMatrix.get(makePair(firstElementI-1,firstElementJ+j)+0x8000, above[j]);
}
if(hasLeft) {
left = new double[nRowsInTile];
for(int i = 0; i < nRowsInTile; ++i)
graph.currIterMatrix.get(makePair(firstElementI+i,firstElementJ-1)+0x8000, left[i]);
}
if(hasBelow) {
below = new double[nColumnsInTile];
for(int j = 0; j < nColumnsInTile; ++j)
graph.prevIterMatrix.get(makePair(firstElementI+nRowsInTile,firstElementJ+j), below[j]);
}
if(hasRight) {
right = new double[nRowsInTile];
for(int i = 0; i < nRowsInTile; ++i)
graph.prevIterMatrix.get(makePair(firstElementI+i,firstElementJ+nColumnsInTile), right[i]);
}
double** tile = new double*[nRowsInTile];
for(int i = 0; i < nRowsInTile; ++i) {
double* currRow = tile[i] = new double[nColumnsInTile];
for(int j = 0; j < nColumnsInTile; ++j)
graph.prevIterMatrix.get(makePair(firstElementI+i,firstElementJ+j), currRow[j]);
}
double omega;
graph.omega.get(111, omega);
double omegaOver4 = omega * 0.25;
double oneMinusOmega = 1-omega;
for(int i = 0; i < nRowsInTile; ++i) {
double* currRow = tile[i], *aboveRow = NULL, *belowRow = NULL;
if(i) aboveRow = tile[i-1]; //non zero row
else if(hasAbove) aboveRow = above; //zero row
if(i != nRowsInTile-1) belowRow = tile[i+1]; //not last row
else if(hasBelow) belowRow = below; //zero row
if(aboveRow && belowRow) {
if(hasLeft && (nColumnsInTile > 1 || hasRight)) {
double valueRight;
if(nColumnsInTile > 1) valueRight = tile[i][1];
else valueRight = right[i];
currRow[0] = omegaOver4*(belowRow[0]+valueRight+aboveRow[0]+left[i]) + oneMinusOmega*currRow[0];
}
for(int j = 1; j < nColumnsInTile-1; ++j)
currRow[j] = omegaOver4*(belowRow[j]+currRow[j+1]+aboveRow[j]+currRow[j-1])+oneMinusOmega*currRow[j];
if(hasRight && nColumnsInTile > 1) {
int j = nColumnsInTile-1;
currRow[j] = omegaOver4*(belowRow[j]+right[i]+aboveRow[j]+tile[i][j-1]) + oneMinusOmega*currRow[j];
}
}
}
if(hasAbove)
delete [] above;
if(hasLeft)
delete [] left;
if(hasBelow)
delete [] below;
if(hasRight)
delete [] right;
for(int i = 0; i < nRowsInTile; ++i) {
double* currRow = tile[i];
for(int j = 0; j < nColumnsInTile; ++j)
graph.currIterMatrix.put(makePair(firstElementI+i,firstElementJ+j)+0x8000, currRow[j]);
}
for(int i = 0; i < nRowsInTile; ++i)
delete [] tile[i];
delete [] tile;
return CnC::CNC_Success;
}
// may use math.h ceil but do not know how efficient
int main(int argc, char* argv[])
{
int toBeReturned = 0;
if(argc < 5) {
std::cerr<<"usage: sor omega nRowsInMatrix nColumnsInMatrix nIterations nRowsInTile nColumnsInTile [-v]\n";
toBeReturned = 1;
} else{
// srand(0xdeadbeef);
double omega = atof(argv[1]);
int nRowsInMatrix = (int)atoi(argv[2]);
int nColumnsInMatrix = (int)atoi(argv[3]);
int nIterations = (int)atoi(argv[4]);
int nRowsInTile = (int)atoi(argv[5]);
int nColumnsInTile = (int)atoi(argv[6]);
int nRowsOfTiles = ceiling (nRowsInMatrix, nRowsInTile);
int nColumnsOfTiles =ceiling (nColumnsInMatrix, nColumnsInTile);
bool verbose = argc==8 && !strcmp("-v", argv[7]);
double** inputArray = new double*[nRowsInMatrix];
// not the best rand but this is a test program anyway
for(int i = 0; i < nRowsInMatrix; ++i) {
double* currRow = inputArray[i] = new double[nColumnsInMatrix];
for(int j = 0; j < nColumnsInMatrix; ++j)
// currRow[j] = (rand() % 100) *0.01;
currRow[j] = ((j*11) % 100) *0.01;
}
if(verbose) {
printf("omega=%lf, M=%d, N=%d, nIterations=%d, nRowsInTile=%d and nColumnsInTile=%d\n",
omega, nRowsInMatrix, nColumnsInMatrix, nIterations, nRowsInTile, nColumnsInTile);
printf("before\n");
for(int i = 0; i < nRowsInMatrix; ++i) {
for(int j = 0; j < nColumnsInMatrix-1; ++j)
printf("%lf, ",inputArray[i][j]);
printf("%lf\n",inputArray[i][nColumnsInMatrix-1]);
}
}
tbb::tick_count t0 = tbb::tick_count::now();
for(int iteration = 0; iteration < nIterations; ++iteration) {
sorContext graph;
// CnC::debug::trace_all(graph, "tiled sor");
graph.omega.put(111, omega);
graph.nRowsInTile.put(222, nRowsInTile);
graph.nColumnsInTile.put(333, nColumnsInTile);
graph.nRowsOfTiles.put(444, nRowsOfTiles);
graph.nColumnsOfTiles.put(555, nColumnsOfTiles);
graph.iterationSpace.put(666+iteration);
for(int i = 0; i < nRowsInMatrix; ++i)
for(int j = 0; j < nColumnsInMatrix; ++j)
graph.prevIterMatrix.put(makePair(i,j), inputArray[i][j]);
graph.wait();
// since execution finished I can now write over **inputArray
for(int i = 0; i < nRowsInMatrix; ++i)
for(int j = 0; j < nColumnsInMatrix; ++j)
graph.currIterMatrix.get(0x8000+makePair(i,j), inputArray[i][j]);
}
tbb::tick_count t1 = tbb::tick_count::now();
printf("Computed in %g seconds\n", (t1-t0).seconds());
if(verbose) {
printf("after\n");
for(int i = 0; i < nRowsInMatrix; ++i) {
for(int j = 0; j < nColumnsInMatrix-1; ++j)
printf("%lf, ",inputArray[i][j]);
printf("%lf\n",inputArray[i][nColumnsInMatrix-1]);
}
}
for(int i = 0; i < nRowsInMatrix; ++i)
delete [] inputArray[i];
delete [] inputArray;
}
return toBeReturned;
}
|
; A283590: Binary representation of the x-axis, from the origin to the right edge, of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 657", based on the 5-celled von Neumann neighborhood.
; Submitted by Jamie Morken(s1)
; 1,0,101,111,1111,11111,111111,1111111,11111111,111111111,1111111111,11111111111,111111111111,1111111111111,11111111111111,111111111111111,1111111111111111,11111111111111111,111111111111111111,1111111111111111111,11111111111111111111,111111111111111111111,1111111111111111111111,11111111111111111111111,111111111111111111111111,1111111111111111111111111,11111111111111111111111111,111111111111111111111111111,1111111111111111111111111111,11111111111111111111111111111,111111111111111111111111111111
seq $0,283592 ; Decimal representation of the x-axis, from the origin to the right edge, of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 657", based on the 5-celled von Neumann neighborhood.
seq $0,7088 ; The binary numbers (or binary words, or binary vectors, or binary expansion of n): numbers written in base 2.
|
_sh: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
return 0;
}
int
main(void)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 51 push %ecx
e: 83 ec 04 sub $0x4,%esp
static char buf[100];
int fd;
// Ensure that three file descriptors are open.
while((fd = open("console", O_RDWR)) >= 0){
11: eb 0a jmp 1d <main+0x1d>
13: 90 nop
14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(fd >= 3){
18: 83 f8 02 cmp $0x2,%eax
1b: 7f 76 jg 93 <main+0x93>
while((fd = open("console", O_RDWR)) >= 0){
1d: 83 ec 08 sub $0x8,%esp
20: 6a 02 push $0x2
22: 68 35 15 00 00 push $0x1535
27: e8 26 0d 00 00 call d52 <open>
2c: 83 c4 10 add $0x10,%esp
2f: 85 c0 test %eax,%eax
31: 79 e5 jns 18 <main+0x18>
33: eb 1f jmp 54 <main+0x54>
35: 8d 76 00 lea 0x0(%esi),%esi
}
}
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
38: 80 3d a2 1c 00 00 20 cmpb $0x20,0x1ca2
3f: 74 7a je bb <main+0xbb>
int
fork1(void)
{
int pid;
pid = fork();
41: e8 c4 0c 00 00 call d0a <fork>
if(pid == -1)
46: 83 f8 ff cmp $0xffffffff,%eax
49: 74 3b je 86 <main+0x86>
if(fork1() == 0)
4b: 85 c0 test %eax,%eax
4d: 74 57 je a6 <main+0xa6>
wait();
4f: e8 c6 0c 00 00 call d1a <wait>
while(getcmd(buf, sizeof(buf)) >= 0){
54: 83 ec 08 sub $0x8,%esp
57: 6a 64 push $0x64
59: 68 a0 1c 00 00 push $0x1ca0
5e: e8 9d 00 00 00 call 100 <getcmd>
63: 83 c4 10 add $0x10,%esp
66: 85 c0 test %eax,%eax
68: 78 37 js a1 <main+0xa1>
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
6a: 80 3d a0 1c 00 00 63 cmpb $0x63,0x1ca0
71: 75 ce jne 41 <main+0x41>
73: 80 3d a1 1c 00 00 64 cmpb $0x64,0x1ca1
7a: 74 bc je 38 <main+0x38>
pid = fork();
7c: e8 89 0c 00 00 call d0a <fork>
if(pid == -1)
81: 83 f8 ff cmp $0xffffffff,%eax
84: 75 c5 jne 4b <main+0x4b>
panic("fork");
86: 83 ec 0c sub $0xc,%esp
89: 68 be 14 00 00 push $0x14be
8e: e8 bd 00 00 00 call 150 <panic>
close(fd);
93: 83 ec 0c sub $0xc,%esp
96: 50 push %eax
97: e8 9e 0c 00 00 call d3a <close>
break;
9c: 83 c4 10 add $0x10,%esp
9f: eb b3 jmp 54 <main+0x54>
exit();
a1: e8 6c 0c 00 00 call d12 <exit>
runcmd(parsecmd(buf));
a6: 83 ec 0c sub $0xc,%esp
a9: 68 a0 1c 00 00 push $0x1ca0
ae: e8 9d 09 00 00 call a50 <parsecmd>
b3: 89 04 24 mov %eax,(%esp)
b6: e8 b5 00 00 00 call 170 <runcmd>
buf[strlen(buf)-1] = 0; // chop \n
bb: 83 ec 0c sub $0xc,%esp
be: 68 a0 1c 00 00 push $0x1ca0
c3: e8 78 0a 00 00 call b40 <strlen>
if(chdir(buf+3) < 0)
c8: c7 04 24 a3 1c 00 00 movl $0x1ca3,(%esp)
buf[strlen(buf)-1] = 0; // chop \n
cf: c6 80 9f 1c 00 00 00 movb $0x0,0x1c9f(%eax)
if(chdir(buf+3) < 0)
d6: e8 a7 0c 00 00 call d82 <chdir>
db: 83 c4 10 add $0x10,%esp
de: 85 c0 test %eax,%eax
e0: 0f 89 6e ff ff ff jns 54 <main+0x54>
printf(2, "cannot cd %s\n", buf+3);
e6: 50 push %eax
e7: 68 a3 1c 00 00 push $0x1ca3
ec: 68 3d 15 00 00 push $0x153d
f1: 6a 02 push $0x2
f3: e8 a8 0d 00 00 call ea0 <printf>
f8: 83 c4 10 add $0x10,%esp
fb: e9 54 ff ff ff jmp 54 <main+0x54>
00000100 <getcmd>:
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 56 push %esi
104: 53 push %ebx
105: 8b 75 0c mov 0xc(%ebp),%esi
108: 8b 5d 08 mov 0x8(%ebp),%ebx
printf(2, "$ ");
10b: 83 ec 08 sub $0x8,%esp
10e: 68 94 14 00 00 push $0x1494
113: 6a 02 push $0x2
115: e8 86 0d 00 00 call ea0 <printf>
memset(buf, 0, nbuf);
11a: 83 c4 0c add $0xc,%esp
11d: 56 push %esi
11e: 6a 00 push $0x0
120: 53 push %ebx
121: e8 4a 0a 00 00 call b70 <memset>
gets(buf, nbuf);
126: 58 pop %eax
127: 5a pop %edx
128: 56 push %esi
129: 53 push %ebx
12a: e8 a1 0a 00 00 call bd0 <gets>
if(buf[0] == 0) // EOF
12f: 83 c4 10 add $0x10,%esp
132: 31 c0 xor %eax,%eax
134: 80 3b 00 cmpb $0x0,(%ebx)
137: 0f 94 c0 sete %al
}
13a: 8d 65 f8 lea -0x8(%ebp),%esp
if(buf[0] == 0) // EOF
13d: f7 d8 neg %eax
}
13f: 5b pop %ebx
140: 5e pop %esi
141: 5d pop %ebp
142: c3 ret
143: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000150 <panic>:
{
150: 55 push %ebp
151: 89 e5 mov %esp,%ebp
153: 83 ec 0c sub $0xc,%esp
printf(2, "%s\n", s);
156: ff 75 08 pushl 0x8(%ebp)
159: 68 31 15 00 00 push $0x1531
15e: 6a 02 push $0x2
160: e8 3b 0d 00 00 call ea0 <printf>
exit();
165: e8 a8 0b 00 00 call d12 <exit>
16a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000170 <runcmd>:
{
170: 55 push %ebp
171: 89 e5 mov %esp,%ebp
173: 53 push %ebx
174: 83 ec 14 sub $0x14,%esp
177: 8b 5d 08 mov 0x8(%ebp),%ebx
if(cmd == 0)
17a: 85 db test %ebx,%ebx
17c: 74 3a je 1b8 <runcmd+0x48>
switch(cmd->type){
17e: 83 3b 05 cmpl $0x5,(%ebx)
181: 0f 87 06 01 00 00 ja 28d <runcmd+0x11d>
187: 8b 03 mov (%ebx),%eax
189: ff 24 85 4c 15 00 00 jmp *0x154c(,%eax,4)
if(ecmd->argv[0] == 0)
190: 8b 43 04 mov 0x4(%ebx),%eax
193: 85 c0 test %eax,%eax
195: 74 21 je 1b8 <runcmd+0x48>
exec(ecmd->argv[0], ecmd->argv);
197: 52 push %edx
198: 52 push %edx
199: 8d 53 04 lea 0x4(%ebx),%edx
19c: 52 push %edx
19d: 50 push %eax
19e: e8 a7 0b 00 00 call d4a <exec>
printf(2, "exec %s failed\n", ecmd->argv[0]);
1a3: 83 c4 0c add $0xc,%esp
1a6: ff 73 04 pushl 0x4(%ebx)
1a9: 68 9e 14 00 00 push $0x149e
1ae: 6a 02 push $0x2
1b0: e8 eb 0c 00 00 call ea0 <printf>
break;
1b5: 83 c4 10 add $0x10,%esp
exit();
1b8: e8 55 0b 00 00 call d12 <exit>
pid = fork();
1bd: e8 48 0b 00 00 call d0a <fork>
if(pid == -1)
1c2: 83 f8 ff cmp $0xffffffff,%eax
1c5: 0f 84 cf 00 00 00 je 29a <runcmd+0x12a>
if(fork1() == 0)
1cb: 85 c0 test %eax,%eax
1cd: 75 e9 jne 1b8 <runcmd+0x48>
runcmd(bcmd->cmd);
1cf: 83 ec 0c sub $0xc,%esp
1d2: ff 73 04 pushl 0x4(%ebx)
1d5: e8 96 ff ff ff call 170 <runcmd>
close(rcmd->fd);
1da: 83 ec 0c sub $0xc,%esp
1dd: ff 73 14 pushl 0x14(%ebx)
1e0: e8 55 0b 00 00 call d3a <close>
if(open(rcmd->file, rcmd->mode) < 0){
1e5: 59 pop %ecx
1e6: 58 pop %eax
1e7: ff 73 10 pushl 0x10(%ebx)
1ea: ff 73 08 pushl 0x8(%ebx)
1ed: e8 60 0b 00 00 call d52 <open>
1f2: 83 c4 10 add $0x10,%esp
1f5: 85 c0 test %eax,%eax
1f7: 79 d6 jns 1cf <runcmd+0x5f>
printf(2, "open %s failed\n", rcmd->file);
1f9: 52 push %edx
1fa: ff 73 08 pushl 0x8(%ebx)
1fd: 68 ae 14 00 00 push $0x14ae
202: 6a 02 push $0x2
204: e8 97 0c 00 00 call ea0 <printf>
exit();
209: e8 04 0b 00 00 call d12 <exit>
if(pipe(p) < 0)
20e: 8d 45 f0 lea -0x10(%ebp),%eax
211: 83 ec 0c sub $0xc,%esp
214: 50 push %eax
215: e8 08 0b 00 00 call d22 <pipe>
21a: 83 c4 10 add $0x10,%esp
21d: 85 c0 test %eax,%eax
21f: 0f 88 b0 00 00 00 js 2d5 <runcmd+0x165>
pid = fork();
225: e8 e0 0a 00 00 call d0a <fork>
if(pid == -1)
22a: 83 f8 ff cmp $0xffffffff,%eax
22d: 74 6b je 29a <runcmd+0x12a>
if(fork1() == 0){
22f: 85 c0 test %eax,%eax
231: 0f 84 ab 00 00 00 je 2e2 <runcmd+0x172>
pid = fork();
237: e8 ce 0a 00 00 call d0a <fork>
if(pid == -1)
23c: 83 f8 ff cmp $0xffffffff,%eax
23f: 74 59 je 29a <runcmd+0x12a>
if(fork1() == 0){
241: 85 c0 test %eax,%eax
243: 74 62 je 2a7 <runcmd+0x137>
close(p[0]);
245: 83 ec 0c sub $0xc,%esp
248: ff 75 f0 pushl -0x10(%ebp)
24b: e8 ea 0a 00 00 call d3a <close>
close(p[1]);
250: 58 pop %eax
251: ff 75 f4 pushl -0xc(%ebp)
254: e8 e1 0a 00 00 call d3a <close>
wait();
259: e8 bc 0a 00 00 call d1a <wait>
wait();
25e: e8 b7 0a 00 00 call d1a <wait>
break;
263: 83 c4 10 add $0x10,%esp
266: e9 4d ff ff ff jmp 1b8 <runcmd+0x48>
pid = fork();
26b: e8 9a 0a 00 00 call d0a <fork>
if(pid == -1)
270: 83 f8 ff cmp $0xffffffff,%eax
273: 74 25 je 29a <runcmd+0x12a>
if(fork1() == 0)
275: 85 c0 test %eax,%eax
277: 0f 84 52 ff ff ff je 1cf <runcmd+0x5f>
wait();
27d: e8 98 0a 00 00 call d1a <wait>
runcmd(lcmd->right);
282: 83 ec 0c sub $0xc,%esp
285: ff 73 08 pushl 0x8(%ebx)
288: e8 e3 fe ff ff call 170 <runcmd>
panic("runcmd");
28d: 83 ec 0c sub $0xc,%esp
290: 68 97 14 00 00 push $0x1497
295: e8 b6 fe ff ff call 150 <panic>
panic("fork");
29a: 83 ec 0c sub $0xc,%esp
29d: 68 be 14 00 00 push $0x14be
2a2: e8 a9 fe ff ff call 150 <panic>
close(0);
2a7: 83 ec 0c sub $0xc,%esp
2aa: 6a 00 push $0x0
2ac: e8 89 0a 00 00 call d3a <close>
dup(p[0]);
2b1: 5a pop %edx
2b2: ff 75 f0 pushl -0x10(%ebp)
2b5: e8 d0 0a 00 00 call d8a <dup>
close(p[0]);
2ba: 59 pop %ecx
2bb: ff 75 f0 pushl -0x10(%ebp)
2be: e8 77 0a 00 00 call d3a <close>
close(p[1]);
2c3: 58 pop %eax
2c4: ff 75 f4 pushl -0xc(%ebp)
2c7: e8 6e 0a 00 00 call d3a <close>
runcmd(pcmd->right);
2cc: 58 pop %eax
2cd: ff 73 08 pushl 0x8(%ebx)
2d0: e8 9b fe ff ff call 170 <runcmd>
panic("pipe");
2d5: 83 ec 0c sub $0xc,%esp
2d8: 68 c3 14 00 00 push $0x14c3
2dd: e8 6e fe ff ff call 150 <panic>
close(1);
2e2: 83 ec 0c sub $0xc,%esp
2e5: 6a 01 push $0x1
2e7: e8 4e 0a 00 00 call d3a <close>
dup(p[1]);
2ec: 58 pop %eax
2ed: ff 75 f4 pushl -0xc(%ebp)
2f0: e8 95 0a 00 00 call d8a <dup>
close(p[0]);
2f5: 58 pop %eax
2f6: ff 75 f0 pushl -0x10(%ebp)
2f9: e8 3c 0a 00 00 call d3a <close>
close(p[1]);
2fe: 58 pop %eax
2ff: ff 75 f4 pushl -0xc(%ebp)
302: e8 33 0a 00 00 call d3a <close>
runcmd(pcmd->left);
307: 58 pop %eax
308: ff 73 04 pushl 0x4(%ebx)
30b: e8 60 fe ff ff call 170 <runcmd>
00000310 <fork1>:
{
310: 55 push %ebp
311: 89 e5 mov %esp,%ebp
313: 83 ec 08 sub $0x8,%esp
pid = fork();
316: e8 ef 09 00 00 call d0a <fork>
if(pid == -1)
31b: 83 f8 ff cmp $0xffffffff,%eax
31e: 74 02 je 322 <fork1+0x12>
return pid;
}
320: c9 leave
321: c3 ret
panic("fork");
322: 83 ec 0c sub $0xc,%esp
325: 68 be 14 00 00 push $0x14be
32a: e8 21 fe ff ff call 150 <panic>
32f: 90 nop
00000330 <execcmd>:
//PAGEBREAK!
// Constructors
struct cmd*
execcmd(void)
{
330: 55 push %ebp
331: 89 e5 mov %esp,%ebp
333: 53 push %ebx
334: 83 ec 10 sub $0x10,%esp
struct execcmd *cmd;
cmd = malloc(sizeof(*cmd));
337: 6a 54 push $0x54
339: e8 c2 0d 00 00 call 1100 <malloc>
memset(cmd, 0, sizeof(*cmd));
33e: 83 c4 0c add $0xc,%esp
cmd = malloc(sizeof(*cmd));
341: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
343: 6a 54 push $0x54
345: 6a 00 push $0x0
347: 50 push %eax
348: e8 23 08 00 00 call b70 <memset>
cmd->type = EXEC;
34d: c7 03 01 00 00 00 movl $0x1,(%ebx)
return (struct cmd*)cmd;
}
353: 89 d8 mov %ebx,%eax
355: 8b 5d fc mov -0x4(%ebp),%ebx
358: c9 leave
359: c3 ret
35a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000360 <redircmd>:
struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 53 push %ebx
364: 83 ec 10 sub $0x10,%esp
struct redircmd *cmd;
cmd = malloc(sizeof(*cmd));
367: 6a 18 push $0x18
369: e8 92 0d 00 00 call 1100 <malloc>
memset(cmd, 0, sizeof(*cmd));
36e: 83 c4 0c add $0xc,%esp
cmd = malloc(sizeof(*cmd));
371: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
373: 6a 18 push $0x18
375: 6a 00 push $0x0
377: 50 push %eax
378: e8 f3 07 00 00 call b70 <memset>
cmd->type = REDIR;
cmd->cmd = subcmd;
37d: 8b 45 08 mov 0x8(%ebp),%eax
cmd->type = REDIR;
380: c7 03 02 00 00 00 movl $0x2,(%ebx)
cmd->cmd = subcmd;
386: 89 43 04 mov %eax,0x4(%ebx)
cmd->file = file;
389: 8b 45 0c mov 0xc(%ebp),%eax
38c: 89 43 08 mov %eax,0x8(%ebx)
cmd->efile = efile;
38f: 8b 45 10 mov 0x10(%ebp),%eax
392: 89 43 0c mov %eax,0xc(%ebx)
cmd->mode = mode;
395: 8b 45 14 mov 0x14(%ebp),%eax
398: 89 43 10 mov %eax,0x10(%ebx)
cmd->fd = fd;
39b: 8b 45 18 mov 0x18(%ebp),%eax
39e: 89 43 14 mov %eax,0x14(%ebx)
return (struct cmd*)cmd;
}
3a1: 89 d8 mov %ebx,%eax
3a3: 8b 5d fc mov -0x4(%ebp),%ebx
3a6: c9 leave
3a7: c3 ret
3a8: 90 nop
3a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000003b0 <pipecmd>:
struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
3b0: 55 push %ebp
3b1: 89 e5 mov %esp,%ebp
3b3: 53 push %ebx
3b4: 83 ec 10 sub $0x10,%esp
struct pipecmd *cmd;
cmd = malloc(sizeof(*cmd));
3b7: 6a 0c push $0xc
3b9: e8 42 0d 00 00 call 1100 <malloc>
memset(cmd, 0, sizeof(*cmd));
3be: 83 c4 0c add $0xc,%esp
cmd = malloc(sizeof(*cmd));
3c1: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
3c3: 6a 0c push $0xc
3c5: 6a 00 push $0x0
3c7: 50 push %eax
3c8: e8 a3 07 00 00 call b70 <memset>
cmd->type = PIPE;
cmd->left = left;
3cd: 8b 45 08 mov 0x8(%ebp),%eax
cmd->type = PIPE;
3d0: c7 03 03 00 00 00 movl $0x3,(%ebx)
cmd->left = left;
3d6: 89 43 04 mov %eax,0x4(%ebx)
cmd->right = right;
3d9: 8b 45 0c mov 0xc(%ebp),%eax
3dc: 89 43 08 mov %eax,0x8(%ebx)
return (struct cmd*)cmd;
}
3df: 89 d8 mov %ebx,%eax
3e1: 8b 5d fc mov -0x4(%ebp),%ebx
3e4: c9 leave
3e5: c3 ret
3e6: 8d 76 00 lea 0x0(%esi),%esi
3e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000003f0 <listcmd>:
struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
3f0: 55 push %ebp
3f1: 89 e5 mov %esp,%ebp
3f3: 53 push %ebx
3f4: 83 ec 10 sub $0x10,%esp
struct listcmd *cmd;
cmd = malloc(sizeof(*cmd));
3f7: 6a 0c push $0xc
3f9: e8 02 0d 00 00 call 1100 <malloc>
memset(cmd, 0, sizeof(*cmd));
3fe: 83 c4 0c add $0xc,%esp
cmd = malloc(sizeof(*cmd));
401: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
403: 6a 0c push $0xc
405: 6a 00 push $0x0
407: 50 push %eax
408: e8 63 07 00 00 call b70 <memset>
cmd->type = LIST;
cmd->left = left;
40d: 8b 45 08 mov 0x8(%ebp),%eax
cmd->type = LIST;
410: c7 03 04 00 00 00 movl $0x4,(%ebx)
cmd->left = left;
416: 89 43 04 mov %eax,0x4(%ebx)
cmd->right = right;
419: 8b 45 0c mov 0xc(%ebp),%eax
41c: 89 43 08 mov %eax,0x8(%ebx)
return (struct cmd*)cmd;
}
41f: 89 d8 mov %ebx,%eax
421: 8b 5d fc mov -0x4(%ebp),%ebx
424: c9 leave
425: c3 ret
426: 8d 76 00 lea 0x0(%esi),%esi
429: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000430 <backcmd>:
struct cmd*
backcmd(struct cmd *subcmd)
{
430: 55 push %ebp
431: 89 e5 mov %esp,%ebp
433: 53 push %ebx
434: 83 ec 10 sub $0x10,%esp
struct backcmd *cmd;
cmd = malloc(sizeof(*cmd));
437: 6a 08 push $0x8
439: e8 c2 0c 00 00 call 1100 <malloc>
memset(cmd, 0, sizeof(*cmd));
43e: 83 c4 0c add $0xc,%esp
cmd = malloc(sizeof(*cmd));
441: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
443: 6a 08 push $0x8
445: 6a 00 push $0x0
447: 50 push %eax
448: e8 23 07 00 00 call b70 <memset>
cmd->type = BACK;
cmd->cmd = subcmd;
44d: 8b 45 08 mov 0x8(%ebp),%eax
cmd->type = BACK;
450: c7 03 05 00 00 00 movl $0x5,(%ebx)
cmd->cmd = subcmd;
456: 89 43 04 mov %eax,0x4(%ebx)
return (struct cmd*)cmd;
}
459: 89 d8 mov %ebx,%eax
45b: 8b 5d fc mov -0x4(%ebp),%ebx
45e: c9 leave
45f: c3 ret
00000460 <gettoken>:
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";
int
gettoken(char **ps, char *es, char **q, char **eq)
{
460: 55 push %ebp
461: 89 e5 mov %esp,%ebp
463: 57 push %edi
464: 56 push %esi
465: 53 push %ebx
466: 83 ec 0c sub $0xc,%esp
char *s;
int ret;
s = *ps;
469: 8b 45 08 mov 0x8(%ebp),%eax
{
46c: 8b 5d 0c mov 0xc(%ebp),%ebx
46f: 8b 7d 10 mov 0x10(%ebp),%edi
s = *ps;
472: 8b 30 mov (%eax),%esi
while(s < es && strchr(whitespace, *s))
474: 39 de cmp %ebx,%esi
476: 72 0f jb 487 <gettoken+0x27>
478: eb 25 jmp 49f <gettoken+0x3f>
47a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
s++;
480: 83 c6 01 add $0x1,%esi
while(s < es && strchr(whitespace, *s))
483: 39 f3 cmp %esi,%ebx
485: 74 18 je 49f <gettoken+0x3f>
487: 0f be 06 movsbl (%esi),%eax
48a: 83 ec 08 sub $0x8,%esp
48d: 50 push %eax
48e: 68 7c 1c 00 00 push $0x1c7c
493: e8 f8 06 00 00 call b90 <strchr>
498: 83 c4 10 add $0x10,%esp
49b: 85 c0 test %eax,%eax
49d: 75 e1 jne 480 <gettoken+0x20>
if(q)
49f: 85 ff test %edi,%edi
4a1: 74 02 je 4a5 <gettoken+0x45>
*q = s;
4a3: 89 37 mov %esi,(%edi)
ret = *s;
4a5: 0f be 06 movsbl (%esi),%eax
switch(*s){
4a8: 3c 29 cmp $0x29,%al
4aa: 7f 54 jg 500 <gettoken+0xa0>
4ac: 3c 28 cmp $0x28,%al
4ae: 0f 8d c8 00 00 00 jge 57c <gettoken+0x11c>
4b4: 31 ff xor %edi,%edi
4b6: 84 c0 test %al,%al
4b8: 0f 85 d2 00 00 00 jne 590 <gettoken+0x130>
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
s++;
break;
}
if(eq)
4be: 8b 55 14 mov 0x14(%ebp),%edx
4c1: 85 d2 test %edx,%edx
4c3: 74 05 je 4ca <gettoken+0x6a>
*eq = s;
4c5: 8b 45 14 mov 0x14(%ebp),%eax
4c8: 89 30 mov %esi,(%eax)
while(s < es && strchr(whitespace, *s))
4ca: 39 de cmp %ebx,%esi
4cc: 72 09 jb 4d7 <gettoken+0x77>
4ce: eb 1f jmp 4ef <gettoken+0x8f>
s++;
4d0: 83 c6 01 add $0x1,%esi
while(s < es && strchr(whitespace, *s))
4d3: 39 f3 cmp %esi,%ebx
4d5: 74 18 je 4ef <gettoken+0x8f>
4d7: 0f be 06 movsbl (%esi),%eax
4da: 83 ec 08 sub $0x8,%esp
4dd: 50 push %eax
4de: 68 7c 1c 00 00 push $0x1c7c
4e3: e8 a8 06 00 00 call b90 <strchr>
4e8: 83 c4 10 add $0x10,%esp
4eb: 85 c0 test %eax,%eax
4ed: 75 e1 jne 4d0 <gettoken+0x70>
*ps = s;
4ef: 8b 45 08 mov 0x8(%ebp),%eax
4f2: 89 30 mov %esi,(%eax)
return ret;
}
4f4: 8d 65 f4 lea -0xc(%ebp),%esp
4f7: 89 f8 mov %edi,%eax
4f9: 5b pop %ebx
4fa: 5e pop %esi
4fb: 5f pop %edi
4fc: 5d pop %ebp
4fd: c3 ret
4fe: 66 90 xchg %ax,%ax
switch(*s){
500: 3c 3e cmp $0x3e,%al
502: 75 1c jne 520 <gettoken+0xc0>
if(*s == '>'){
504: 80 7e 01 3e cmpb $0x3e,0x1(%esi)
s++;
508: 8d 46 01 lea 0x1(%esi),%eax
if(*s == '>'){
50b: 0f 84 a4 00 00 00 je 5b5 <gettoken+0x155>
s++;
511: 89 c6 mov %eax,%esi
513: bf 3e 00 00 00 mov $0x3e,%edi
518: eb a4 jmp 4be <gettoken+0x5e>
51a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
switch(*s){
520: 7f 56 jg 578 <gettoken+0x118>
522: 8d 48 c5 lea -0x3b(%eax),%ecx
525: 80 f9 01 cmp $0x1,%cl
528: 76 52 jbe 57c <gettoken+0x11c>
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
52a: 39 f3 cmp %esi,%ebx
52c: 77 24 ja 552 <gettoken+0xf2>
52e: eb 70 jmp 5a0 <gettoken+0x140>
530: 0f be 06 movsbl (%esi),%eax
533: 83 ec 08 sub $0x8,%esp
536: 50 push %eax
537: 68 74 1c 00 00 push $0x1c74
53c: e8 4f 06 00 00 call b90 <strchr>
541: 83 c4 10 add $0x10,%esp
544: 85 c0 test %eax,%eax
546: 75 1f jne 567 <gettoken+0x107>
s++;
548: 83 c6 01 add $0x1,%esi
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
54b: 39 f3 cmp %esi,%ebx
54d: 74 51 je 5a0 <gettoken+0x140>
54f: 0f be 06 movsbl (%esi),%eax
552: 83 ec 08 sub $0x8,%esp
555: 50 push %eax
556: 68 7c 1c 00 00 push $0x1c7c
55b: e8 30 06 00 00 call b90 <strchr>
560: 83 c4 10 add $0x10,%esp
563: 85 c0 test %eax,%eax
565: 74 c9 je 530 <gettoken+0xd0>
ret = 'a';
567: bf 61 00 00 00 mov $0x61,%edi
56c: e9 4d ff ff ff jmp 4be <gettoken+0x5e>
571: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
switch(*s){
578: 3c 7c cmp $0x7c,%al
57a: 75 ae jne 52a <gettoken+0xca>
ret = *s;
57c: 0f be f8 movsbl %al,%edi
s++;
57f: 83 c6 01 add $0x1,%esi
break;
582: e9 37 ff ff ff jmp 4be <gettoken+0x5e>
587: 89 f6 mov %esi,%esi
589: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
switch(*s){
590: 3c 26 cmp $0x26,%al
592: 75 96 jne 52a <gettoken+0xca>
594: eb e6 jmp 57c <gettoken+0x11c>
596: 8d 76 00 lea 0x0(%esi),%esi
599: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
if(eq)
5a0: 8b 45 14 mov 0x14(%ebp),%eax
5a3: bf 61 00 00 00 mov $0x61,%edi
5a8: 85 c0 test %eax,%eax
5aa: 0f 85 15 ff ff ff jne 4c5 <gettoken+0x65>
5b0: e9 3a ff ff ff jmp 4ef <gettoken+0x8f>
s++;
5b5: 83 c6 02 add $0x2,%esi
ret = '+';
5b8: bf 2b 00 00 00 mov $0x2b,%edi
5bd: e9 fc fe ff ff jmp 4be <gettoken+0x5e>
5c2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
5c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000005d0 <peek>:
int
peek(char **ps, char *es, char *toks)
{
5d0: 55 push %ebp
5d1: 89 e5 mov %esp,%ebp
5d3: 57 push %edi
5d4: 56 push %esi
5d5: 53 push %ebx
5d6: 83 ec 0c sub $0xc,%esp
5d9: 8b 7d 08 mov 0x8(%ebp),%edi
5dc: 8b 75 0c mov 0xc(%ebp),%esi
char *s;
s = *ps;
5df: 8b 1f mov (%edi),%ebx
while(s < es && strchr(whitespace, *s))
5e1: 39 f3 cmp %esi,%ebx
5e3: 72 12 jb 5f7 <peek+0x27>
5e5: eb 28 jmp 60f <peek+0x3f>
5e7: 89 f6 mov %esi,%esi
5e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
s++;
5f0: 83 c3 01 add $0x1,%ebx
while(s < es && strchr(whitespace, *s))
5f3: 39 de cmp %ebx,%esi
5f5: 74 18 je 60f <peek+0x3f>
5f7: 0f be 03 movsbl (%ebx),%eax
5fa: 83 ec 08 sub $0x8,%esp
5fd: 50 push %eax
5fe: 68 7c 1c 00 00 push $0x1c7c
603: e8 88 05 00 00 call b90 <strchr>
608: 83 c4 10 add $0x10,%esp
60b: 85 c0 test %eax,%eax
60d: 75 e1 jne 5f0 <peek+0x20>
*ps = s;
60f: 89 1f mov %ebx,(%edi)
return *s && strchr(toks, *s);
611: 0f be 13 movsbl (%ebx),%edx
614: 31 c0 xor %eax,%eax
616: 84 d2 test %dl,%dl
618: 74 17 je 631 <peek+0x61>
61a: 83 ec 08 sub $0x8,%esp
61d: 52 push %edx
61e: ff 75 10 pushl 0x10(%ebp)
621: e8 6a 05 00 00 call b90 <strchr>
626: 83 c4 10 add $0x10,%esp
629: 85 c0 test %eax,%eax
62b: 0f 95 c0 setne %al
62e: 0f b6 c0 movzbl %al,%eax
}
631: 8d 65 f4 lea -0xc(%ebp),%esp
634: 5b pop %ebx
635: 5e pop %esi
636: 5f pop %edi
637: 5d pop %ebp
638: c3 ret
639: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000640 <parseredirs>:
return cmd;
}
struct cmd*
parseredirs(struct cmd *cmd, char **ps, char *es)
{
640: 55 push %ebp
641: 89 e5 mov %esp,%ebp
643: 57 push %edi
644: 56 push %esi
645: 53 push %ebx
646: 83 ec 1c sub $0x1c,%esp
649: 8b 75 0c mov 0xc(%ebp),%esi
64c: 8b 5d 10 mov 0x10(%ebp),%ebx
64f: 90 nop
int tok;
char *q, *eq;
while(peek(ps, es, "<>")){
650: 83 ec 04 sub $0x4,%esp
653: 68 e5 14 00 00 push $0x14e5
658: 53 push %ebx
659: 56 push %esi
65a: e8 71 ff ff ff call 5d0 <peek>
65f: 83 c4 10 add $0x10,%esp
662: 85 c0 test %eax,%eax
664: 74 6a je 6d0 <parseredirs+0x90>
tok = gettoken(ps, es, 0, 0);
666: 6a 00 push $0x0
668: 6a 00 push $0x0
66a: 53 push %ebx
66b: 56 push %esi
66c: e8 ef fd ff ff call 460 <gettoken>
671: 89 c7 mov %eax,%edi
if(gettoken(ps, es, &q, &eq) != 'a')
673: 8d 45 e4 lea -0x1c(%ebp),%eax
676: 50 push %eax
677: 8d 45 e0 lea -0x20(%ebp),%eax
67a: 50 push %eax
67b: 53 push %ebx
67c: 56 push %esi
67d: e8 de fd ff ff call 460 <gettoken>
682: 83 c4 20 add $0x20,%esp
685: 83 f8 61 cmp $0x61,%eax
688: 75 51 jne 6db <parseredirs+0x9b>
panic("missing file for redirection");
switch(tok){
68a: 83 ff 3c cmp $0x3c,%edi
68d: 74 31 je 6c0 <parseredirs+0x80>
68f: 83 ff 3e cmp $0x3e,%edi
692: 74 05 je 699 <parseredirs+0x59>
694: 83 ff 2b cmp $0x2b,%edi
697: 75 b7 jne 650 <parseredirs+0x10>
break;
case '>':
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
break;
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
699: 83 ec 0c sub $0xc,%esp
69c: 6a 01 push $0x1
69e: 68 01 02 00 00 push $0x201
6a3: ff 75 e4 pushl -0x1c(%ebp)
6a6: ff 75 e0 pushl -0x20(%ebp)
6a9: ff 75 08 pushl 0x8(%ebp)
6ac: e8 af fc ff ff call 360 <redircmd>
break;
6b1: 83 c4 20 add $0x20,%esp
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
6b4: 89 45 08 mov %eax,0x8(%ebp)
break;
6b7: eb 97 jmp 650 <parseredirs+0x10>
6b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
cmd = redircmd(cmd, q, eq, O_RDONLY, 0);
6c0: 83 ec 0c sub $0xc,%esp
6c3: 6a 00 push $0x0
6c5: 6a 00 push $0x0
6c7: eb da jmp 6a3 <parseredirs+0x63>
6c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
}
}
return cmd;
}
6d0: 8b 45 08 mov 0x8(%ebp),%eax
6d3: 8d 65 f4 lea -0xc(%ebp),%esp
6d6: 5b pop %ebx
6d7: 5e pop %esi
6d8: 5f pop %edi
6d9: 5d pop %ebp
6da: c3 ret
panic("missing file for redirection");
6db: 83 ec 0c sub $0xc,%esp
6de: 68 c8 14 00 00 push $0x14c8
6e3: e8 68 fa ff ff call 150 <panic>
6e8: 90 nop
6e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000006f0 <parseexec>:
return cmd;
}
struct cmd*
parseexec(char **ps, char *es)
{
6f0: 55 push %ebp
6f1: 89 e5 mov %esp,%ebp
6f3: 57 push %edi
6f4: 56 push %esi
6f5: 53 push %ebx
6f6: 83 ec 30 sub $0x30,%esp
6f9: 8b 75 08 mov 0x8(%ebp),%esi
6fc: 8b 7d 0c mov 0xc(%ebp),%edi
char *q, *eq;
int tok, argc;
struct execcmd *cmd;
struct cmd *ret;
if(peek(ps, es, "("))
6ff: 68 e8 14 00 00 push $0x14e8
704: 57 push %edi
705: 56 push %esi
706: e8 c5 fe ff ff call 5d0 <peek>
70b: 83 c4 10 add $0x10,%esp
70e: 85 c0 test %eax,%eax
710: 0f 85 92 00 00 00 jne 7a8 <parseexec+0xb8>
716: 89 c3 mov %eax,%ebx
return parseblock(ps, es);
ret = execcmd();
718: e8 13 fc ff ff call 330 <execcmd>
cmd = (struct execcmd*)ret;
argc = 0;
ret = parseredirs(ret, ps, es);
71d: 83 ec 04 sub $0x4,%esp
ret = execcmd();
720: 89 45 d0 mov %eax,-0x30(%ebp)
ret = parseredirs(ret, ps, es);
723: 57 push %edi
724: 56 push %esi
725: 50 push %eax
726: e8 15 ff ff ff call 640 <parseredirs>
72b: 83 c4 10 add $0x10,%esp
72e: 89 45 d4 mov %eax,-0x2c(%ebp)
731: eb 18 jmp 74b <parseexec+0x5b>
733: 90 nop
734: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
cmd->argv[argc] = q;
cmd->eargv[argc] = eq;
argc++;
if(argc >= MAXARGS)
panic("too many args");
ret = parseredirs(ret, ps, es);
738: 83 ec 04 sub $0x4,%esp
73b: 57 push %edi
73c: 56 push %esi
73d: ff 75 d4 pushl -0x2c(%ebp)
740: e8 fb fe ff ff call 640 <parseredirs>
745: 83 c4 10 add $0x10,%esp
748: 89 45 d4 mov %eax,-0x2c(%ebp)
while(!peek(ps, es, "|)&;")){
74b: 83 ec 04 sub $0x4,%esp
74e: 68 ff 14 00 00 push $0x14ff
753: 57 push %edi
754: 56 push %esi
755: e8 76 fe ff ff call 5d0 <peek>
75a: 83 c4 10 add $0x10,%esp
75d: 85 c0 test %eax,%eax
75f: 75 67 jne 7c8 <parseexec+0xd8>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
761: 8d 45 e4 lea -0x1c(%ebp),%eax
764: 50 push %eax
765: 8d 45 e0 lea -0x20(%ebp),%eax
768: 50 push %eax
769: 57 push %edi
76a: 56 push %esi
76b: e8 f0 fc ff ff call 460 <gettoken>
770: 83 c4 10 add $0x10,%esp
773: 85 c0 test %eax,%eax
775: 74 51 je 7c8 <parseexec+0xd8>
if(tok != 'a')
777: 83 f8 61 cmp $0x61,%eax
77a: 75 6b jne 7e7 <parseexec+0xf7>
cmd->argv[argc] = q;
77c: 8b 45 e0 mov -0x20(%ebp),%eax
77f: 8b 55 d0 mov -0x30(%ebp),%edx
782: 89 44 9a 04 mov %eax,0x4(%edx,%ebx,4)
cmd->eargv[argc] = eq;
786: 8b 45 e4 mov -0x1c(%ebp),%eax
789: 89 44 9a 2c mov %eax,0x2c(%edx,%ebx,4)
argc++;
78d: 83 c3 01 add $0x1,%ebx
if(argc >= MAXARGS)
790: 83 fb 0a cmp $0xa,%ebx
793: 75 a3 jne 738 <parseexec+0x48>
panic("too many args");
795: 83 ec 0c sub $0xc,%esp
798: 68 f1 14 00 00 push $0x14f1
79d: e8 ae f9 ff ff call 150 <panic>
7a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
return parseblock(ps, es);
7a8: 83 ec 08 sub $0x8,%esp
7ab: 57 push %edi
7ac: 56 push %esi
7ad: e8 5e 01 00 00 call 910 <parseblock>
7b2: 83 c4 10 add $0x10,%esp
7b5: 89 45 d4 mov %eax,-0x2c(%ebp)
}
cmd->argv[argc] = 0;
cmd->eargv[argc] = 0;
return ret;
}
7b8: 8b 45 d4 mov -0x2c(%ebp),%eax
7bb: 8d 65 f4 lea -0xc(%ebp),%esp
7be: 5b pop %ebx
7bf: 5e pop %esi
7c0: 5f pop %edi
7c1: 5d pop %ebp
7c2: c3 ret
7c3: 90 nop
7c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
7c8: 8b 45 d0 mov -0x30(%ebp),%eax
7cb: 8d 04 98 lea (%eax,%ebx,4),%eax
cmd->argv[argc] = 0;
7ce: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
cmd->eargv[argc] = 0;
7d5: c7 40 2c 00 00 00 00 movl $0x0,0x2c(%eax)
}
7dc: 8b 45 d4 mov -0x2c(%ebp),%eax
7df: 8d 65 f4 lea -0xc(%ebp),%esp
7e2: 5b pop %ebx
7e3: 5e pop %esi
7e4: 5f pop %edi
7e5: 5d pop %ebp
7e6: c3 ret
panic("syntax");
7e7: 83 ec 0c sub $0xc,%esp
7ea: 68 ea 14 00 00 push $0x14ea
7ef: e8 5c f9 ff ff call 150 <panic>
7f4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
7fa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000800 <parsepipe>:
{
800: 55 push %ebp
801: 89 e5 mov %esp,%ebp
803: 57 push %edi
804: 56 push %esi
805: 53 push %ebx
806: 83 ec 14 sub $0x14,%esp
809: 8b 5d 08 mov 0x8(%ebp),%ebx
80c: 8b 75 0c mov 0xc(%ebp),%esi
cmd = parseexec(ps, es);
80f: 56 push %esi
810: 53 push %ebx
811: e8 da fe ff ff call 6f0 <parseexec>
if(peek(ps, es, "|")){
816: 83 c4 0c add $0xc,%esp
cmd = parseexec(ps, es);
819: 89 c7 mov %eax,%edi
if(peek(ps, es, "|")){
81b: 68 04 15 00 00 push $0x1504
820: 56 push %esi
821: 53 push %ebx
822: e8 a9 fd ff ff call 5d0 <peek>
827: 83 c4 10 add $0x10,%esp
82a: 85 c0 test %eax,%eax
82c: 75 12 jne 840 <parsepipe+0x40>
}
82e: 8d 65 f4 lea -0xc(%ebp),%esp
831: 89 f8 mov %edi,%eax
833: 5b pop %ebx
834: 5e pop %esi
835: 5f pop %edi
836: 5d pop %ebp
837: c3 ret
838: 90 nop
839: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
gettoken(ps, es, 0, 0);
840: 6a 00 push $0x0
842: 6a 00 push $0x0
844: 56 push %esi
845: 53 push %ebx
846: e8 15 fc ff ff call 460 <gettoken>
cmd = pipecmd(cmd, parsepipe(ps, es));
84b: 58 pop %eax
84c: 5a pop %edx
84d: 56 push %esi
84e: 53 push %ebx
84f: e8 ac ff ff ff call 800 <parsepipe>
854: 89 7d 08 mov %edi,0x8(%ebp)
857: 89 45 0c mov %eax,0xc(%ebp)
85a: 83 c4 10 add $0x10,%esp
}
85d: 8d 65 f4 lea -0xc(%ebp),%esp
860: 5b pop %ebx
861: 5e pop %esi
862: 5f pop %edi
863: 5d pop %ebp
cmd = pipecmd(cmd, parsepipe(ps, es));
864: e9 47 fb ff ff jmp 3b0 <pipecmd>
869: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000870 <parseline>:
{
870: 55 push %ebp
871: 89 e5 mov %esp,%ebp
873: 57 push %edi
874: 56 push %esi
875: 53 push %ebx
876: 83 ec 14 sub $0x14,%esp
879: 8b 5d 08 mov 0x8(%ebp),%ebx
87c: 8b 75 0c mov 0xc(%ebp),%esi
cmd = parsepipe(ps, es);
87f: 56 push %esi
880: 53 push %ebx
881: e8 7a ff ff ff call 800 <parsepipe>
while(peek(ps, es, "&")){
886: 83 c4 10 add $0x10,%esp
cmd = parsepipe(ps, es);
889: 89 c7 mov %eax,%edi
while(peek(ps, es, "&")){
88b: eb 1b jmp 8a8 <parseline+0x38>
88d: 8d 76 00 lea 0x0(%esi),%esi
gettoken(ps, es, 0, 0);
890: 6a 00 push $0x0
892: 6a 00 push $0x0
894: 56 push %esi
895: 53 push %ebx
896: e8 c5 fb ff ff call 460 <gettoken>
cmd = backcmd(cmd);
89b: 89 3c 24 mov %edi,(%esp)
89e: e8 8d fb ff ff call 430 <backcmd>
8a3: 83 c4 10 add $0x10,%esp
8a6: 89 c7 mov %eax,%edi
while(peek(ps, es, "&")){
8a8: 83 ec 04 sub $0x4,%esp
8ab: 68 06 15 00 00 push $0x1506
8b0: 56 push %esi
8b1: 53 push %ebx
8b2: e8 19 fd ff ff call 5d0 <peek>
8b7: 83 c4 10 add $0x10,%esp
8ba: 85 c0 test %eax,%eax
8bc: 75 d2 jne 890 <parseline+0x20>
if(peek(ps, es, ";")){
8be: 83 ec 04 sub $0x4,%esp
8c1: 68 02 15 00 00 push $0x1502
8c6: 56 push %esi
8c7: 53 push %ebx
8c8: e8 03 fd ff ff call 5d0 <peek>
8cd: 83 c4 10 add $0x10,%esp
8d0: 85 c0 test %eax,%eax
8d2: 75 0c jne 8e0 <parseline+0x70>
}
8d4: 8d 65 f4 lea -0xc(%ebp),%esp
8d7: 89 f8 mov %edi,%eax
8d9: 5b pop %ebx
8da: 5e pop %esi
8db: 5f pop %edi
8dc: 5d pop %ebp
8dd: c3 ret
8de: 66 90 xchg %ax,%ax
gettoken(ps, es, 0, 0);
8e0: 6a 00 push $0x0
8e2: 6a 00 push $0x0
8e4: 56 push %esi
8e5: 53 push %ebx
8e6: e8 75 fb ff ff call 460 <gettoken>
cmd = listcmd(cmd, parseline(ps, es));
8eb: 58 pop %eax
8ec: 5a pop %edx
8ed: 56 push %esi
8ee: 53 push %ebx
8ef: e8 7c ff ff ff call 870 <parseline>
8f4: 89 7d 08 mov %edi,0x8(%ebp)
8f7: 89 45 0c mov %eax,0xc(%ebp)
8fa: 83 c4 10 add $0x10,%esp
}
8fd: 8d 65 f4 lea -0xc(%ebp),%esp
900: 5b pop %ebx
901: 5e pop %esi
902: 5f pop %edi
903: 5d pop %ebp
cmd = listcmd(cmd, parseline(ps, es));
904: e9 e7 fa ff ff jmp 3f0 <listcmd>
909: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000910 <parseblock>:
{
910: 55 push %ebp
911: 89 e5 mov %esp,%ebp
913: 57 push %edi
914: 56 push %esi
915: 53 push %ebx
916: 83 ec 10 sub $0x10,%esp
919: 8b 5d 08 mov 0x8(%ebp),%ebx
91c: 8b 75 0c mov 0xc(%ebp),%esi
if(!peek(ps, es, "("))
91f: 68 e8 14 00 00 push $0x14e8
924: 56 push %esi
925: 53 push %ebx
926: e8 a5 fc ff ff call 5d0 <peek>
92b: 83 c4 10 add $0x10,%esp
92e: 85 c0 test %eax,%eax
930: 74 4a je 97c <parseblock+0x6c>
gettoken(ps, es, 0, 0);
932: 6a 00 push $0x0
934: 6a 00 push $0x0
936: 56 push %esi
937: 53 push %ebx
938: e8 23 fb ff ff call 460 <gettoken>
cmd = parseline(ps, es);
93d: 58 pop %eax
93e: 5a pop %edx
93f: 56 push %esi
940: 53 push %ebx
941: e8 2a ff ff ff call 870 <parseline>
if(!peek(ps, es, ")"))
946: 83 c4 0c add $0xc,%esp
cmd = parseline(ps, es);
949: 89 c7 mov %eax,%edi
if(!peek(ps, es, ")"))
94b: 68 24 15 00 00 push $0x1524
950: 56 push %esi
951: 53 push %ebx
952: e8 79 fc ff ff call 5d0 <peek>
957: 83 c4 10 add $0x10,%esp
95a: 85 c0 test %eax,%eax
95c: 74 2b je 989 <parseblock+0x79>
gettoken(ps, es, 0, 0);
95e: 6a 00 push $0x0
960: 6a 00 push $0x0
962: 56 push %esi
963: 53 push %ebx
964: e8 f7 fa ff ff call 460 <gettoken>
cmd = parseredirs(cmd, ps, es);
969: 83 c4 0c add $0xc,%esp
96c: 56 push %esi
96d: 53 push %ebx
96e: 57 push %edi
96f: e8 cc fc ff ff call 640 <parseredirs>
}
974: 8d 65 f4 lea -0xc(%ebp),%esp
977: 5b pop %ebx
978: 5e pop %esi
979: 5f pop %edi
97a: 5d pop %ebp
97b: c3 ret
panic("parseblock");
97c: 83 ec 0c sub $0xc,%esp
97f: 68 08 15 00 00 push $0x1508
984: e8 c7 f7 ff ff call 150 <panic>
panic("syntax - missing )");
989: 83 ec 0c sub $0xc,%esp
98c: 68 13 15 00 00 push $0x1513
991: e8 ba f7 ff ff call 150 <panic>
996: 8d 76 00 lea 0x0(%esi),%esi
999: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000009a0 <nulterminate>:
// NUL-terminate all the counted strings.
struct cmd*
nulterminate(struct cmd *cmd)
{
9a0: 55 push %ebp
9a1: 89 e5 mov %esp,%ebp
9a3: 53 push %ebx
9a4: 83 ec 04 sub $0x4,%esp
9a7: 8b 5d 08 mov 0x8(%ebp),%ebx
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
9aa: 85 db test %ebx,%ebx
9ac: 74 20 je 9ce <nulterminate+0x2e>
return 0;
switch(cmd->type){
9ae: 83 3b 05 cmpl $0x5,(%ebx)
9b1: 77 1b ja 9ce <nulterminate+0x2e>
9b3: 8b 03 mov (%ebx),%eax
9b5: ff 24 85 64 15 00 00 jmp *0x1564(,%eax,4)
9bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
nulterminate(lcmd->right);
break;
case BACK:
bcmd = (struct backcmd*)cmd;
nulterminate(bcmd->cmd);
9c0: 83 ec 0c sub $0xc,%esp
9c3: ff 73 04 pushl 0x4(%ebx)
9c6: e8 d5 ff ff ff call 9a0 <nulterminate>
break;
9cb: 83 c4 10 add $0x10,%esp
}
return cmd;
}
9ce: 89 d8 mov %ebx,%eax
9d0: 8b 5d fc mov -0x4(%ebp),%ebx
9d3: c9 leave
9d4: c3 ret
9d5: 8d 76 00 lea 0x0(%esi),%esi
nulterminate(lcmd->left);
9d8: 83 ec 0c sub $0xc,%esp
9db: ff 73 04 pushl 0x4(%ebx)
9de: e8 bd ff ff ff call 9a0 <nulterminate>
nulterminate(lcmd->right);
9e3: 58 pop %eax
9e4: ff 73 08 pushl 0x8(%ebx)
9e7: e8 b4 ff ff ff call 9a0 <nulterminate>
}
9ec: 89 d8 mov %ebx,%eax
break;
9ee: 83 c4 10 add $0x10,%esp
}
9f1: 8b 5d fc mov -0x4(%ebp),%ebx
9f4: c9 leave
9f5: c3 ret
9f6: 8d 76 00 lea 0x0(%esi),%esi
9f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
for(i=0; ecmd->argv[i]; i++)
a00: 8b 4b 04 mov 0x4(%ebx),%ecx
a03: 8d 43 08 lea 0x8(%ebx),%eax
a06: 85 c9 test %ecx,%ecx
a08: 74 c4 je 9ce <nulterminate+0x2e>
a0a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
*ecmd->eargv[i] = 0;
a10: 8b 50 24 mov 0x24(%eax),%edx
a13: 83 c0 04 add $0x4,%eax
a16: c6 02 00 movb $0x0,(%edx)
for(i=0; ecmd->argv[i]; i++)
a19: 8b 50 fc mov -0x4(%eax),%edx
a1c: 85 d2 test %edx,%edx
a1e: 75 f0 jne a10 <nulterminate+0x70>
}
a20: 89 d8 mov %ebx,%eax
a22: 8b 5d fc mov -0x4(%ebp),%ebx
a25: c9 leave
a26: c3 ret
a27: 89 f6 mov %esi,%esi
a29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
nulterminate(rcmd->cmd);
a30: 83 ec 0c sub $0xc,%esp
a33: ff 73 04 pushl 0x4(%ebx)
a36: e8 65 ff ff ff call 9a0 <nulterminate>
*rcmd->efile = 0;
a3b: 8b 43 0c mov 0xc(%ebx),%eax
break;
a3e: 83 c4 10 add $0x10,%esp
*rcmd->efile = 0;
a41: c6 00 00 movb $0x0,(%eax)
}
a44: 89 d8 mov %ebx,%eax
a46: 8b 5d fc mov -0x4(%ebp),%ebx
a49: c9 leave
a4a: c3 ret
a4b: 90 nop
a4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000a50 <parsecmd>:
{
a50: 55 push %ebp
a51: 89 e5 mov %esp,%ebp
a53: 56 push %esi
a54: 53 push %ebx
es = s + strlen(s);
a55: 8b 5d 08 mov 0x8(%ebp),%ebx
a58: 83 ec 0c sub $0xc,%esp
a5b: 53 push %ebx
a5c: e8 df 00 00 00 call b40 <strlen>
cmd = parseline(&s, es);
a61: 59 pop %ecx
es = s + strlen(s);
a62: 01 c3 add %eax,%ebx
cmd = parseline(&s, es);
a64: 8d 45 08 lea 0x8(%ebp),%eax
a67: 5e pop %esi
a68: 53 push %ebx
a69: 50 push %eax
a6a: e8 01 fe ff ff call 870 <parseline>
a6f: 89 c6 mov %eax,%esi
peek(&s, es, "");
a71: 8d 45 08 lea 0x8(%ebp),%eax
a74: 83 c4 0c add $0xc,%esp
a77: 68 ad 14 00 00 push $0x14ad
a7c: 53 push %ebx
a7d: 50 push %eax
a7e: e8 4d fb ff ff call 5d0 <peek>
if(s != es){
a83: 8b 45 08 mov 0x8(%ebp),%eax
a86: 83 c4 10 add $0x10,%esp
a89: 39 d8 cmp %ebx,%eax
a8b: 75 12 jne a9f <parsecmd+0x4f>
nulterminate(cmd);
a8d: 83 ec 0c sub $0xc,%esp
a90: 56 push %esi
a91: e8 0a ff ff ff call 9a0 <nulterminate>
}
a96: 8d 65 f8 lea -0x8(%ebp),%esp
a99: 89 f0 mov %esi,%eax
a9b: 5b pop %ebx
a9c: 5e pop %esi
a9d: 5d pop %ebp
a9e: c3 ret
printf(2, "leftovers: %s\n", s);
a9f: 52 push %edx
aa0: 50 push %eax
aa1: 68 26 15 00 00 push $0x1526
aa6: 6a 02 push $0x2
aa8: e8 f3 03 00 00 call ea0 <printf>
panic("syntax");
aad: c7 04 24 ea 14 00 00 movl $0x14ea,(%esp)
ab4: e8 97 f6 ff ff call 150 <panic>
ab9: 66 90 xchg %ax,%ax
abb: 66 90 xchg %ax,%ax
abd: 66 90 xchg %ax,%ax
abf: 90 nop
00000ac0 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
ac0: 55 push %ebp
ac1: 89 e5 mov %esp,%ebp
ac3: 53 push %ebx
ac4: 8b 45 08 mov 0x8(%ebp),%eax
ac7: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
aca: 89 c2 mov %eax,%edx
acc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
ad0: 83 c1 01 add $0x1,%ecx
ad3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
ad7: 83 c2 01 add $0x1,%edx
ada: 84 db test %bl,%bl
adc: 88 5a ff mov %bl,-0x1(%edx)
adf: 75 ef jne ad0 <strcpy+0x10>
;
return os;
}
ae1: 5b pop %ebx
ae2: 5d pop %ebp
ae3: c3 ret
ae4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
aea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000af0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
af0: 55 push %ebp
af1: 89 e5 mov %esp,%ebp
af3: 53 push %ebx
af4: 8b 55 08 mov 0x8(%ebp),%edx
af7: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
afa: 0f b6 02 movzbl (%edx),%eax
afd: 0f b6 19 movzbl (%ecx),%ebx
b00: 84 c0 test %al,%al
b02: 75 1c jne b20 <strcmp+0x30>
b04: eb 2a jmp b30 <strcmp+0x40>
b06: 8d 76 00 lea 0x0(%esi),%esi
b09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
b10: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
b13: 0f b6 02 movzbl (%edx),%eax
p++, q++;
b16: 83 c1 01 add $0x1,%ecx
b19: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
b1c: 84 c0 test %al,%al
b1e: 74 10 je b30 <strcmp+0x40>
b20: 38 d8 cmp %bl,%al
b22: 74 ec je b10 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
b24: 29 d8 sub %ebx,%eax
}
b26: 5b pop %ebx
b27: 5d pop %ebp
b28: c3 ret
b29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
b30: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
b32: 29 d8 sub %ebx,%eax
}
b34: 5b pop %ebx
b35: 5d pop %ebp
b36: c3 ret
b37: 89 f6 mov %esi,%esi
b39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000b40 <strlen>:
uint
strlen(const char *s)
{
b40: 55 push %ebp
b41: 89 e5 mov %esp,%ebp
b43: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
b46: 80 39 00 cmpb $0x0,(%ecx)
b49: 74 15 je b60 <strlen+0x20>
b4b: 31 d2 xor %edx,%edx
b4d: 8d 76 00 lea 0x0(%esi),%esi
b50: 83 c2 01 add $0x1,%edx
b53: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
b57: 89 d0 mov %edx,%eax
b59: 75 f5 jne b50 <strlen+0x10>
;
return n;
}
b5b: 5d pop %ebp
b5c: c3 ret
b5d: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
b60: 31 c0 xor %eax,%eax
}
b62: 5d pop %ebp
b63: c3 ret
b64: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
b6a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000b70 <memset>:
void*
memset(void *dst, int c, uint n)
{
b70: 55 push %ebp
b71: 89 e5 mov %esp,%ebp
b73: 57 push %edi
b74: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
b77: 8b 4d 10 mov 0x10(%ebp),%ecx
b7a: 8b 45 0c mov 0xc(%ebp),%eax
b7d: 89 d7 mov %edx,%edi
b7f: fc cld
b80: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
b82: 89 d0 mov %edx,%eax
b84: 5f pop %edi
b85: 5d pop %ebp
b86: c3 ret
b87: 89 f6 mov %esi,%esi
b89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000b90 <strchr>:
char*
strchr(const char *s, char c)
{
b90: 55 push %ebp
b91: 89 e5 mov %esp,%ebp
b93: 53 push %ebx
b94: 8b 45 08 mov 0x8(%ebp),%eax
b97: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
b9a: 0f b6 10 movzbl (%eax),%edx
b9d: 84 d2 test %dl,%dl
b9f: 74 1d je bbe <strchr+0x2e>
if(*s == c)
ba1: 38 d3 cmp %dl,%bl
ba3: 89 d9 mov %ebx,%ecx
ba5: 75 0d jne bb4 <strchr+0x24>
ba7: eb 17 jmp bc0 <strchr+0x30>
ba9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
bb0: 38 ca cmp %cl,%dl
bb2: 74 0c je bc0 <strchr+0x30>
for(; *s; s++)
bb4: 83 c0 01 add $0x1,%eax
bb7: 0f b6 10 movzbl (%eax),%edx
bba: 84 d2 test %dl,%dl
bbc: 75 f2 jne bb0 <strchr+0x20>
return (char*)s;
return 0;
bbe: 31 c0 xor %eax,%eax
}
bc0: 5b pop %ebx
bc1: 5d pop %ebp
bc2: c3 ret
bc3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
bc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000bd0 <gets>:
char*
gets(char *buf, int max)
{
bd0: 55 push %ebp
bd1: 89 e5 mov %esp,%ebp
bd3: 57 push %edi
bd4: 56 push %esi
bd5: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
bd6: 31 f6 xor %esi,%esi
bd8: 89 f3 mov %esi,%ebx
{
bda: 83 ec 1c sub $0x1c,%esp
bdd: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
be0: eb 2f jmp c11 <gets+0x41>
be2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
be8: 8d 45 e7 lea -0x19(%ebp),%eax
beb: 83 ec 04 sub $0x4,%esp
bee: 6a 01 push $0x1
bf0: 50 push %eax
bf1: 6a 00 push $0x0
bf3: e8 32 01 00 00 call d2a <read>
if(cc < 1)
bf8: 83 c4 10 add $0x10,%esp
bfb: 85 c0 test %eax,%eax
bfd: 7e 1c jle c1b <gets+0x4b>
break;
buf[i++] = c;
bff: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
c03: 83 c7 01 add $0x1,%edi
c06: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
c09: 3c 0a cmp $0xa,%al
c0b: 74 23 je c30 <gets+0x60>
c0d: 3c 0d cmp $0xd,%al
c0f: 74 1f je c30 <gets+0x60>
for(i=0; i+1 < max; ){
c11: 83 c3 01 add $0x1,%ebx
c14: 3b 5d 0c cmp 0xc(%ebp),%ebx
c17: 89 fe mov %edi,%esi
c19: 7c cd jl be8 <gets+0x18>
c1b: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
c1d: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
c20: c6 03 00 movb $0x0,(%ebx)
}
c23: 8d 65 f4 lea -0xc(%ebp),%esp
c26: 5b pop %ebx
c27: 5e pop %esi
c28: 5f pop %edi
c29: 5d pop %ebp
c2a: c3 ret
c2b: 90 nop
c2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c30: 8b 75 08 mov 0x8(%ebp),%esi
c33: 8b 45 08 mov 0x8(%ebp),%eax
c36: 01 de add %ebx,%esi
c38: 89 f3 mov %esi,%ebx
buf[i] = '\0';
c3a: c6 03 00 movb $0x0,(%ebx)
}
c3d: 8d 65 f4 lea -0xc(%ebp),%esp
c40: 5b pop %ebx
c41: 5e pop %esi
c42: 5f pop %edi
c43: 5d pop %ebp
c44: c3 ret
c45: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000c50 <stat>:
int
stat(const char *n, struct stat *st)
{
c50: 55 push %ebp
c51: 89 e5 mov %esp,%ebp
c53: 56 push %esi
c54: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
c55: 83 ec 08 sub $0x8,%esp
c58: 6a 00 push $0x0
c5a: ff 75 08 pushl 0x8(%ebp)
c5d: e8 f0 00 00 00 call d52 <open>
if(fd < 0)
c62: 83 c4 10 add $0x10,%esp
c65: 85 c0 test %eax,%eax
c67: 78 27 js c90 <stat+0x40>
return -1;
r = fstat(fd, st);
c69: 83 ec 08 sub $0x8,%esp
c6c: ff 75 0c pushl 0xc(%ebp)
c6f: 89 c3 mov %eax,%ebx
c71: 50 push %eax
c72: e8 f3 00 00 00 call d6a <fstat>
close(fd);
c77: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
c7a: 89 c6 mov %eax,%esi
close(fd);
c7c: e8 b9 00 00 00 call d3a <close>
return r;
c81: 83 c4 10 add $0x10,%esp
}
c84: 8d 65 f8 lea -0x8(%ebp),%esp
c87: 89 f0 mov %esi,%eax
c89: 5b pop %ebx
c8a: 5e pop %esi
c8b: 5d pop %ebp
c8c: c3 ret
c8d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
c90: be ff ff ff ff mov $0xffffffff,%esi
c95: eb ed jmp c84 <stat+0x34>
c97: 89 f6 mov %esi,%esi
c99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000ca0 <atoi>:
int
atoi(const char *s)
{
ca0: 55 push %ebp
ca1: 89 e5 mov %esp,%ebp
ca3: 53 push %ebx
ca4: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
ca7: 0f be 11 movsbl (%ecx),%edx
caa: 8d 42 d0 lea -0x30(%edx),%eax
cad: 3c 09 cmp $0x9,%al
n = 0;
caf: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
cb4: 77 1f ja cd5 <atoi+0x35>
cb6: 8d 76 00 lea 0x0(%esi),%esi
cb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
cc0: 8d 04 80 lea (%eax,%eax,4),%eax
cc3: 83 c1 01 add $0x1,%ecx
cc6: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
cca: 0f be 11 movsbl (%ecx),%edx
ccd: 8d 5a d0 lea -0x30(%edx),%ebx
cd0: 80 fb 09 cmp $0x9,%bl
cd3: 76 eb jbe cc0 <atoi+0x20>
return n;
}
cd5: 5b pop %ebx
cd6: 5d pop %ebp
cd7: c3 ret
cd8: 90 nop
cd9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000ce0 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
ce0: 55 push %ebp
ce1: 89 e5 mov %esp,%ebp
ce3: 56 push %esi
ce4: 53 push %ebx
ce5: 8b 5d 10 mov 0x10(%ebp),%ebx
ce8: 8b 45 08 mov 0x8(%ebp),%eax
ceb: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
cee: 85 db test %ebx,%ebx
cf0: 7e 14 jle d06 <memmove+0x26>
cf2: 31 d2 xor %edx,%edx
cf4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
cf8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
cfc: 88 0c 10 mov %cl,(%eax,%edx,1)
cff: 83 c2 01 add $0x1,%edx
while(n-- > 0)
d02: 39 d3 cmp %edx,%ebx
d04: 75 f2 jne cf8 <memmove+0x18>
return vdst;
}
d06: 5b pop %ebx
d07: 5e pop %esi
d08: 5d pop %ebp
d09: c3 ret
00000d0a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
d0a: b8 01 00 00 00 mov $0x1,%eax
d0f: cd 40 int $0x40
d11: c3 ret
00000d12 <exit>:
SYSCALL(exit)
d12: b8 02 00 00 00 mov $0x2,%eax
d17: cd 40 int $0x40
d19: c3 ret
00000d1a <wait>:
SYSCALL(wait)
d1a: b8 03 00 00 00 mov $0x3,%eax
d1f: cd 40 int $0x40
d21: c3 ret
00000d22 <pipe>:
SYSCALL(pipe)
d22: b8 04 00 00 00 mov $0x4,%eax
d27: cd 40 int $0x40
d29: c3 ret
00000d2a <read>:
SYSCALL(read)
d2a: b8 05 00 00 00 mov $0x5,%eax
d2f: cd 40 int $0x40
d31: c3 ret
00000d32 <write>:
SYSCALL(write)
d32: b8 10 00 00 00 mov $0x10,%eax
d37: cd 40 int $0x40
d39: c3 ret
00000d3a <close>:
SYSCALL(close)
d3a: b8 15 00 00 00 mov $0x15,%eax
d3f: cd 40 int $0x40
d41: c3 ret
00000d42 <kill>:
SYSCALL(kill)
d42: b8 06 00 00 00 mov $0x6,%eax
d47: cd 40 int $0x40
d49: c3 ret
00000d4a <exec>:
SYSCALL(exec)
d4a: b8 07 00 00 00 mov $0x7,%eax
d4f: cd 40 int $0x40
d51: c3 ret
00000d52 <open>:
SYSCALL(open)
d52: b8 0f 00 00 00 mov $0xf,%eax
d57: cd 40 int $0x40
d59: c3 ret
00000d5a <mknod>:
SYSCALL(mknod)
d5a: b8 11 00 00 00 mov $0x11,%eax
d5f: cd 40 int $0x40
d61: c3 ret
00000d62 <unlink>:
SYSCALL(unlink)
d62: b8 12 00 00 00 mov $0x12,%eax
d67: cd 40 int $0x40
d69: c3 ret
00000d6a <fstat>:
SYSCALL(fstat)
d6a: b8 08 00 00 00 mov $0x8,%eax
d6f: cd 40 int $0x40
d71: c3 ret
00000d72 <link>:
SYSCALL(link)
d72: b8 13 00 00 00 mov $0x13,%eax
d77: cd 40 int $0x40
d79: c3 ret
00000d7a <mkdir>:
SYSCALL(mkdir)
d7a: b8 14 00 00 00 mov $0x14,%eax
d7f: cd 40 int $0x40
d81: c3 ret
00000d82 <chdir>:
SYSCALL(chdir)
d82: b8 09 00 00 00 mov $0x9,%eax
d87: cd 40 int $0x40
d89: c3 ret
00000d8a <dup>:
SYSCALL(dup)
d8a: b8 0a 00 00 00 mov $0xa,%eax
d8f: cd 40 int $0x40
d91: c3 ret
00000d92 <getpid>:
SYSCALL(getpid)
d92: b8 0b 00 00 00 mov $0xb,%eax
d97: cd 40 int $0x40
d99: c3 ret
00000d9a <sbrk>:
SYSCALL(sbrk)
d9a: b8 0c 00 00 00 mov $0xc,%eax
d9f: cd 40 int $0x40
da1: c3 ret
00000da2 <sleep>:
SYSCALL(sleep)
da2: b8 0d 00 00 00 mov $0xd,%eax
da7: cd 40 int $0x40
da9: c3 ret
00000daa <uptime>:
SYSCALL(uptime)
daa: b8 0e 00 00 00 mov $0xe,%eax
daf: cd 40 int $0x40
db1: c3 ret
00000db2 <kthread_create>:
//kthread
SYSCALL(kthread_create)
db2: b8 16 00 00 00 mov $0x16,%eax
db7: cd 40 int $0x40
db9: c3 ret
00000dba <kthread_id>:
SYSCALL(kthread_id)
dba: b8 17 00 00 00 mov $0x17,%eax
dbf: cd 40 int $0x40
dc1: c3 ret
00000dc2 <kthread_exit>:
SYSCALL(kthread_exit)
dc2: b8 18 00 00 00 mov $0x18,%eax
dc7: cd 40 int $0x40
dc9: c3 ret
00000dca <kthread_join>:
SYSCALL(kthread_join)
dca: b8 19 00 00 00 mov $0x19,%eax
dcf: cd 40 int $0x40
dd1: c3 ret
00000dd2 <kthread_mutex_alloc>:
//kthread_mutex
SYSCALL(kthread_mutex_alloc)
dd2: b8 1a 00 00 00 mov $0x1a,%eax
dd7: cd 40 int $0x40
dd9: c3 ret
00000dda <kthread_mutex_dealloc>:
SYSCALL(kthread_mutex_dealloc)
dda: b8 1b 00 00 00 mov $0x1b,%eax
ddf: cd 40 int $0x40
de1: c3 ret
00000de2 <kthread_mutex_lock>:
SYSCALL(kthread_mutex_lock)
de2: b8 1c 00 00 00 mov $0x1c,%eax
de7: cd 40 int $0x40
de9: c3 ret
00000dea <kthread_mutex_unlock>:
SYSCALL(kthread_mutex_unlock)
dea: b8 1d 00 00 00 mov $0x1d,%eax
def: cd 40 int $0x40
df1: c3 ret
00000df2 <safe_tree_dealloc>:
SYSCALL(safe_tree_dealloc)
df2: b8 1e 00 00 00 mov $0x1e,%eax
df7: cd 40 int $0x40
df9: c3 ret
dfa: 66 90 xchg %ax,%ax
dfc: 66 90 xchg %ax,%ax
dfe: 66 90 xchg %ax,%ax
00000e00 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
e00: 55 push %ebp
e01: 89 e5 mov %esp,%ebp
e03: 57 push %edi
e04: 56 push %esi
e05: 53 push %ebx
e06: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
e09: 85 d2 test %edx,%edx
{
e0b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
e0e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
e10: 79 76 jns e88 <printint+0x88>
e12: f6 45 08 01 testb $0x1,0x8(%ebp)
e16: 74 70 je e88 <printint+0x88>
x = -xx;
e18: f7 d8 neg %eax
neg = 1;
e1a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
e21: 31 f6 xor %esi,%esi
e23: 8d 5d d7 lea -0x29(%ebp),%ebx
e26: eb 0a jmp e32 <printint+0x32>
e28: 90 nop
e29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
e30: 89 fe mov %edi,%esi
e32: 31 d2 xor %edx,%edx
e34: 8d 7e 01 lea 0x1(%esi),%edi
e37: f7 f1 div %ecx
e39: 0f b6 92 84 15 00 00 movzbl 0x1584(%edx),%edx
}while((x /= base) != 0);
e40: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
e42: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
e45: 75 e9 jne e30 <printint+0x30>
if(neg)
e47: 8b 45 c4 mov -0x3c(%ebp),%eax
e4a: 85 c0 test %eax,%eax
e4c: 74 08 je e56 <printint+0x56>
buf[i++] = '-';
e4e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
e53: 8d 7e 02 lea 0x2(%esi),%edi
e56: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
e5a: 8b 7d c0 mov -0x40(%ebp),%edi
e5d: 8d 76 00 lea 0x0(%esi),%esi
e60: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
e63: 83 ec 04 sub $0x4,%esp
e66: 83 ee 01 sub $0x1,%esi
e69: 6a 01 push $0x1
e6b: 53 push %ebx
e6c: 57 push %edi
e6d: 88 45 d7 mov %al,-0x29(%ebp)
e70: e8 bd fe ff ff call d32 <write>
while(--i >= 0)
e75: 83 c4 10 add $0x10,%esp
e78: 39 de cmp %ebx,%esi
e7a: 75 e4 jne e60 <printint+0x60>
putc(fd, buf[i]);
}
e7c: 8d 65 f4 lea -0xc(%ebp),%esp
e7f: 5b pop %ebx
e80: 5e pop %esi
e81: 5f pop %edi
e82: 5d pop %ebp
e83: c3 ret
e84: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
e88: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
e8f: eb 90 jmp e21 <printint+0x21>
e91: eb 0d jmp ea0 <printf>
e93: 90 nop
e94: 90 nop
e95: 90 nop
e96: 90 nop
e97: 90 nop
e98: 90 nop
e99: 90 nop
e9a: 90 nop
e9b: 90 nop
e9c: 90 nop
e9d: 90 nop
e9e: 90 nop
e9f: 90 nop
00000ea0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
ea0: 55 push %ebp
ea1: 89 e5 mov %esp,%ebp
ea3: 57 push %edi
ea4: 56 push %esi
ea5: 53 push %ebx
ea6: 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++){
ea9: 8b 75 0c mov 0xc(%ebp),%esi
eac: 0f b6 1e movzbl (%esi),%ebx
eaf: 84 db test %bl,%bl
eb1: 0f 84 b3 00 00 00 je f6a <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
eb7: 8d 45 10 lea 0x10(%ebp),%eax
eba: 83 c6 01 add $0x1,%esi
state = 0;
ebd: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
ebf: 89 45 d4 mov %eax,-0x2c(%ebp)
ec2: eb 2f jmp ef3 <printf+0x53>
ec4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
ec8: 83 f8 25 cmp $0x25,%eax
ecb: 0f 84 a7 00 00 00 je f78 <printf+0xd8>
write(fd, &c, 1);
ed1: 8d 45 e2 lea -0x1e(%ebp),%eax
ed4: 83 ec 04 sub $0x4,%esp
ed7: 88 5d e2 mov %bl,-0x1e(%ebp)
eda: 6a 01 push $0x1
edc: 50 push %eax
edd: ff 75 08 pushl 0x8(%ebp)
ee0: e8 4d fe ff ff call d32 <write>
ee5: 83 c4 10 add $0x10,%esp
ee8: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
eeb: 0f b6 5e ff movzbl -0x1(%esi),%ebx
eef: 84 db test %bl,%bl
ef1: 74 77 je f6a <printf+0xca>
if(state == 0){
ef3: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
ef5: 0f be cb movsbl %bl,%ecx
ef8: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
efb: 74 cb je ec8 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
efd: 83 ff 25 cmp $0x25,%edi
f00: 75 e6 jne ee8 <printf+0x48>
if(c == 'd'){
f02: 83 f8 64 cmp $0x64,%eax
f05: 0f 84 05 01 00 00 je 1010 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
f0b: 81 e1 f7 00 00 00 and $0xf7,%ecx
f11: 83 f9 70 cmp $0x70,%ecx
f14: 74 72 je f88 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
f16: 83 f8 73 cmp $0x73,%eax
f19: 0f 84 99 00 00 00 je fb8 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
f1f: 83 f8 63 cmp $0x63,%eax
f22: 0f 84 08 01 00 00 je 1030 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
f28: 83 f8 25 cmp $0x25,%eax
f2b: 0f 84 ef 00 00 00 je 1020 <printf+0x180>
write(fd, &c, 1);
f31: 8d 45 e7 lea -0x19(%ebp),%eax
f34: 83 ec 04 sub $0x4,%esp
f37: c6 45 e7 25 movb $0x25,-0x19(%ebp)
f3b: 6a 01 push $0x1
f3d: 50 push %eax
f3e: ff 75 08 pushl 0x8(%ebp)
f41: e8 ec fd ff ff call d32 <write>
f46: 83 c4 0c add $0xc,%esp
f49: 8d 45 e6 lea -0x1a(%ebp),%eax
f4c: 88 5d e6 mov %bl,-0x1a(%ebp)
f4f: 6a 01 push $0x1
f51: 50 push %eax
f52: ff 75 08 pushl 0x8(%ebp)
f55: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
f58: 31 ff xor %edi,%edi
write(fd, &c, 1);
f5a: e8 d3 fd ff ff call d32 <write>
for(i = 0; fmt[i]; i++){
f5f: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
f63: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
f66: 84 db test %bl,%bl
f68: 75 89 jne ef3 <printf+0x53>
}
}
}
f6a: 8d 65 f4 lea -0xc(%ebp),%esp
f6d: 5b pop %ebx
f6e: 5e pop %esi
f6f: 5f pop %edi
f70: 5d pop %ebp
f71: c3 ret
f72: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
f78: bf 25 00 00 00 mov $0x25,%edi
f7d: e9 66 ff ff ff jmp ee8 <printf+0x48>
f82: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
f88: 83 ec 0c sub $0xc,%esp
f8b: b9 10 00 00 00 mov $0x10,%ecx
f90: 6a 00 push $0x0
f92: 8b 7d d4 mov -0x2c(%ebp),%edi
f95: 8b 45 08 mov 0x8(%ebp),%eax
f98: 8b 17 mov (%edi),%edx
f9a: e8 61 fe ff ff call e00 <printint>
ap++;
f9f: 89 f8 mov %edi,%eax
fa1: 83 c4 10 add $0x10,%esp
state = 0;
fa4: 31 ff xor %edi,%edi
ap++;
fa6: 83 c0 04 add $0x4,%eax
fa9: 89 45 d4 mov %eax,-0x2c(%ebp)
fac: e9 37 ff ff ff jmp ee8 <printf+0x48>
fb1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
fb8: 8b 45 d4 mov -0x2c(%ebp),%eax
fbb: 8b 08 mov (%eax),%ecx
ap++;
fbd: 83 c0 04 add $0x4,%eax
fc0: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
fc3: 85 c9 test %ecx,%ecx
fc5: 0f 84 8e 00 00 00 je 1059 <printf+0x1b9>
while(*s != 0){
fcb: 0f b6 01 movzbl (%ecx),%eax
state = 0;
fce: 31 ff xor %edi,%edi
s = (char*)*ap;
fd0: 89 cb mov %ecx,%ebx
while(*s != 0){
fd2: 84 c0 test %al,%al
fd4: 0f 84 0e ff ff ff je ee8 <printf+0x48>
fda: 89 75 d0 mov %esi,-0x30(%ebp)
fdd: 89 de mov %ebx,%esi
fdf: 8b 5d 08 mov 0x8(%ebp),%ebx
fe2: 8d 7d e3 lea -0x1d(%ebp),%edi
fe5: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
fe8: 83 ec 04 sub $0x4,%esp
s++;
feb: 83 c6 01 add $0x1,%esi
fee: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
ff1: 6a 01 push $0x1
ff3: 57 push %edi
ff4: 53 push %ebx
ff5: e8 38 fd ff ff call d32 <write>
while(*s != 0){
ffa: 0f b6 06 movzbl (%esi),%eax
ffd: 83 c4 10 add $0x10,%esp
1000: 84 c0 test %al,%al
1002: 75 e4 jne fe8 <printf+0x148>
1004: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
1007: 31 ff xor %edi,%edi
1009: e9 da fe ff ff jmp ee8 <printf+0x48>
100e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
1010: 83 ec 0c sub $0xc,%esp
1013: b9 0a 00 00 00 mov $0xa,%ecx
1018: 6a 01 push $0x1
101a: e9 73 ff ff ff jmp f92 <printf+0xf2>
101f: 90 nop
write(fd, &c, 1);
1020: 83 ec 04 sub $0x4,%esp
1023: 88 5d e5 mov %bl,-0x1b(%ebp)
1026: 8d 45 e5 lea -0x1b(%ebp),%eax
1029: 6a 01 push $0x1
102b: e9 21 ff ff ff jmp f51 <printf+0xb1>
putc(fd, *ap);
1030: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
1033: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
1036: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
1038: 6a 01 push $0x1
ap++;
103a: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
103d: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
1040: 8d 45 e4 lea -0x1c(%ebp),%eax
1043: 50 push %eax
1044: ff 75 08 pushl 0x8(%ebp)
1047: e8 e6 fc ff ff call d32 <write>
ap++;
104c: 89 7d d4 mov %edi,-0x2c(%ebp)
104f: 83 c4 10 add $0x10,%esp
state = 0;
1052: 31 ff xor %edi,%edi
1054: e9 8f fe ff ff jmp ee8 <printf+0x48>
s = "(null)";
1059: bb 7c 15 00 00 mov $0x157c,%ebx
while(*s != 0){
105e: b8 28 00 00 00 mov $0x28,%eax
1063: e9 72 ff ff ff jmp fda <printf+0x13a>
1068: 66 90 xchg %ax,%ax
106a: 66 90 xchg %ax,%ax
106c: 66 90 xchg %ax,%ax
106e: 66 90 xchg %ax,%ax
00001070 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
1070: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1071: a1 04 1d 00 00 mov 0x1d04,%eax
{
1076: 89 e5 mov %esp,%ebp
1078: 57 push %edi
1079: 56 push %esi
107a: 53 push %ebx
107b: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
107e: 8d 4b f8 lea -0x8(%ebx),%ecx
1081: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1088: 39 c8 cmp %ecx,%eax
108a: 8b 10 mov (%eax),%edx
108c: 73 32 jae 10c0 <free+0x50>
108e: 39 d1 cmp %edx,%ecx
1090: 72 04 jb 1096 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1092: 39 d0 cmp %edx,%eax
1094: 72 32 jb 10c8 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
1096: 8b 73 fc mov -0x4(%ebx),%esi
1099: 8d 3c f1 lea (%ecx,%esi,8),%edi
109c: 39 fa cmp %edi,%edx
109e: 74 30 je 10d0 <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;
10a0: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
10a3: 8b 50 04 mov 0x4(%eax),%edx
10a6: 8d 34 d0 lea (%eax,%edx,8),%esi
10a9: 39 f1 cmp %esi,%ecx
10ab: 74 3a je 10e7 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
10ad: 89 08 mov %ecx,(%eax)
freep = p;
10af: a3 04 1d 00 00 mov %eax,0x1d04
}
10b4: 5b pop %ebx
10b5: 5e pop %esi
10b6: 5f pop %edi
10b7: 5d pop %ebp
10b8: c3 ret
10b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
10c0: 39 d0 cmp %edx,%eax
10c2: 72 04 jb 10c8 <free+0x58>
10c4: 39 d1 cmp %edx,%ecx
10c6: 72 ce jb 1096 <free+0x26>
{
10c8: 89 d0 mov %edx,%eax
10ca: eb bc jmp 1088 <free+0x18>
10cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
10d0: 03 72 04 add 0x4(%edx),%esi
10d3: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
10d6: 8b 10 mov (%eax),%edx
10d8: 8b 12 mov (%edx),%edx
10da: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
10dd: 8b 50 04 mov 0x4(%eax),%edx
10e0: 8d 34 d0 lea (%eax,%edx,8),%esi
10e3: 39 f1 cmp %esi,%ecx
10e5: 75 c6 jne 10ad <free+0x3d>
p->s.size += bp->s.size;
10e7: 03 53 fc add -0x4(%ebx),%edx
freep = p;
10ea: a3 04 1d 00 00 mov %eax,0x1d04
p->s.size += bp->s.size;
10ef: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
10f2: 8b 53 f8 mov -0x8(%ebx),%edx
10f5: 89 10 mov %edx,(%eax)
}
10f7: 5b pop %ebx
10f8: 5e pop %esi
10f9: 5f pop %edi
10fa: 5d pop %ebp
10fb: c3 ret
10fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00001100 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
1100: 55 push %ebp
1101: 89 e5 mov %esp,%ebp
1103: 57 push %edi
1104: 56 push %esi
1105: 53 push %ebx
1106: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1109: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
110c: 8b 15 04 1d 00 00 mov 0x1d04,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1112: 8d 78 07 lea 0x7(%eax),%edi
1115: c1 ef 03 shr $0x3,%edi
1118: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
111b: 85 d2 test %edx,%edx
111d: 0f 84 9d 00 00 00 je 11c0 <malloc+0xc0>
1123: 8b 02 mov (%edx),%eax
1125: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
1128: 39 cf cmp %ecx,%edi
112a: 76 6c jbe 1198 <malloc+0x98>
112c: 81 ff 00 10 00 00 cmp $0x1000,%edi
1132: bb 00 10 00 00 mov $0x1000,%ebx
1137: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
113a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
1141: eb 0e jmp 1151 <malloc+0x51>
1143: 90 nop
1144: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1148: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
114a: 8b 48 04 mov 0x4(%eax),%ecx
114d: 39 f9 cmp %edi,%ecx
114f: 73 47 jae 1198 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
1151: 39 05 04 1d 00 00 cmp %eax,0x1d04
1157: 89 c2 mov %eax,%edx
1159: 75 ed jne 1148 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
115b: 83 ec 0c sub $0xc,%esp
115e: 56 push %esi
115f: e8 36 fc ff ff call d9a <sbrk>
if(p == (char*)-1)
1164: 83 c4 10 add $0x10,%esp
1167: 83 f8 ff cmp $0xffffffff,%eax
116a: 74 1c je 1188 <malloc+0x88>
hp->s.size = nu;
116c: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
116f: 83 ec 0c sub $0xc,%esp
1172: 83 c0 08 add $0x8,%eax
1175: 50 push %eax
1176: e8 f5 fe ff ff call 1070 <free>
return freep;
117b: 8b 15 04 1d 00 00 mov 0x1d04,%edx
if((p = morecore(nunits)) == 0)
1181: 83 c4 10 add $0x10,%esp
1184: 85 d2 test %edx,%edx
1186: 75 c0 jne 1148 <malloc+0x48>
return 0;
}
}
1188: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
118b: 31 c0 xor %eax,%eax
}
118d: 5b pop %ebx
118e: 5e pop %esi
118f: 5f pop %edi
1190: 5d pop %ebp
1191: c3 ret
1192: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
1198: 39 cf cmp %ecx,%edi
119a: 74 54 je 11f0 <malloc+0xf0>
p->s.size -= nunits;
119c: 29 f9 sub %edi,%ecx
119e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
11a1: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
11a4: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
11a7: 89 15 04 1d 00 00 mov %edx,0x1d04
}
11ad: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
11b0: 83 c0 08 add $0x8,%eax
}
11b3: 5b pop %ebx
11b4: 5e pop %esi
11b5: 5f pop %edi
11b6: 5d pop %ebp
11b7: c3 ret
11b8: 90 nop
11b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
11c0: c7 05 04 1d 00 00 08 movl $0x1d08,0x1d04
11c7: 1d 00 00
11ca: c7 05 08 1d 00 00 08 movl $0x1d08,0x1d08
11d1: 1d 00 00
base.s.size = 0;
11d4: b8 08 1d 00 00 mov $0x1d08,%eax
11d9: c7 05 0c 1d 00 00 00 movl $0x0,0x1d0c
11e0: 00 00 00
11e3: e9 44 ff ff ff jmp 112c <malloc+0x2c>
11e8: 90 nop
11e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
11f0: 8b 08 mov (%eax),%ecx
11f2: 89 0a mov %ecx,(%edx)
11f4: eb b1 jmp 11a7 <malloc+0xa7>
11f6: 66 90 xchg %ax,%ax
11f8: 66 90 xchg %ax,%ax
11fa: 66 90 xchg %ax,%ax
11fc: 66 90 xchg %ax,%ax
11fe: 66 90 xchg %ax,%ax
00001200 <ourpower.part.0>:
struct {
//struct spinlock lock;
trnmnt_tree trnmnt_tree[NPROC];
} treetable;
int ourpower(int num) {
1200: 55 push %ebp
if (num < 0) {
//cprintf("Illegal input: for a^b: a= %d, b= %d \n", a, b);
return -1;
}
int output = 1;
for (int i = 0; i < num; i++)
1201: 85 c0 test %eax,%eax
int ourpower(int num) {
1203: 89 e5 mov %esp,%ebp
for (int i = 0; i < num; i++)
1205: 7e 19 jle 1220 <ourpower.part.0+0x20>
1207: 31 d2 xor %edx,%edx
int output = 1;
1209: b9 01 00 00 00 mov $0x1,%ecx
120e: 66 90 xchg %ax,%ax
for (int i = 0; i < num; i++)
1210: 83 c2 01 add $0x1,%edx
output *= 2;
1213: 01 c9 add %ecx,%ecx
for (int i = 0; i < num; i++)
1215: 39 c2 cmp %eax,%edx
1217: 75 f7 jne 1210 <ourpower.part.0+0x10>
return output;
}
1219: 89 c8 mov %ecx,%eax
121b: 5d pop %ebp
121c: c3 ret
121d: 8d 76 00 lea 0x0(%esi),%esi
int output = 1;
1220: b9 01 00 00 00 mov $0x1,%ecx
}
1225: 89 c8 mov %ecx,%eax
1227: 5d pop %ebp
1228: c3 ret
1229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00001230 <ourpower>:
int ourpower(int num) {
1230: 55 push %ebp
1231: 89 e5 mov %esp,%ebp
1233: 8b 45 08 mov 0x8(%ebp),%eax
if (num < 0) {
1236: 85 c0 test %eax,%eax
1238: 78 03 js 123d <ourpower+0xd>
}
123a: 5d pop %ebp
123b: eb c3 jmp 1200 <ourpower.part.0>
123d: 83 c8 ff or $0xffffffff,%eax
1240: 5d pop %ebp
1241: c3 ret
1242: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001250 <trnmnt_tree_alloc>:
struct trnmnt_tree*
trnmnt_tree_alloc(int depth){
1250: 55 push %ebp
1251: 89 e5 mov %esp,%ebp
1253: 57 push %edi
1254: 56 push %esi
1255: 53 push %ebx
trnmnt_tree *t;
for (t = treetable.trnmnt_tree ; t < &treetable.trnmnt_tree[NPROC] ; t++) {
1256: bb 20 1d 00 00 mov $0x1d20,%ebx
trnmnt_tree_alloc(int depth){
125b: 83 ec 0c sub $0xc,%esp
125e: 8b 45 08 mov 0x8(%ebp),%eax
1261: eb 13 jmp 1276 <trnmnt_tree_alloc+0x26>
1263: 90 nop
1264: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for (t = treetable.trnmnt_tree ; t < &treetable.trnmnt_tree[NPROC] ; t++) {
1268: 81 c3 08 01 00 00 add $0x108,%ebx
126e: 81 fb 20 5f 00 00 cmp $0x5f20,%ebx
1274: 73 42 jae 12b8 <trnmnt_tree_alloc+0x68>
if (t->active == INACTIVE)
1276: 8b 13 mov (%ebx),%edx
1278: 85 d2 test %edx,%edx
127a: 75 ec jne 1268 <trnmnt_tree_alloc+0x18>
if (num < 0) {
127c: 85 c0 test %eax,%eax
goto found_tree;
}
return 0;
found_tree:
t->active = ACTIVE;
127e: c7 03 01 00 00 00 movl $0x1,(%ebx)
t->depth = depth;
1284: 89 43 04 mov %eax,0x4(%ebx)
if (num < 0) {
1287: 78 1f js 12a8 <trnmnt_tree_alloc+0x58>
1289: e8 72 ff ff ff call 1200 <ourpower.part.0>
for(int i=0; i<(ourpower(depth)-1); i++)
128e: 31 f6 xor %esi,%esi
1290: 8d 78 ff lea -0x1(%eax),%edi
1293: eb 0f jmp 12a4 <trnmnt_tree_alloc+0x54>
1295: 8d 76 00 lea 0x0(%esi),%esi
t->trnmntMutex[i] = kthread_mutex_alloc();
1298: e8 35 fb ff ff call dd2 <kthread_mutex_alloc>
129d: 89 44 b3 08 mov %eax,0x8(%ebx,%esi,4)
for(int i=0; i<(ourpower(depth)-1); i++)
12a1: 83 c6 01 add $0x1,%esi
12a4: 39 f7 cmp %esi,%edi
12a6: 7f f0 jg 1298 <trnmnt_tree_alloc+0x48>
return t;
}
12a8: 83 c4 0c add $0xc,%esp
12ab: 89 d8 mov %ebx,%eax
12ad: 5b pop %ebx
12ae: 5e pop %esi
12af: 5f pop %edi
12b0: 5d pop %ebp
12b1: c3 ret
12b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
12b8: 83 c4 0c add $0xc,%esp
return 0;
12bb: 31 db xor %ebx,%ebx
}
12bd: 89 d8 mov %ebx,%eax
12bf: 5b pop %ebx
12c0: 5e pop %esi
12c1: 5f pop %edi
12c2: 5d pop %ebp
12c3: c3 ret
12c4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
12ca: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000012d0 <trnmnt_tree_dealloc>:
int
trnmnt_tree_dealloc(trnmnt_tree* tree){
12d0: 55 push %ebp
12d1: 89 e5 mov %esp,%ebp
12d3: 57 push %edi
12d4: 56 push %esi
12d5: 53 push %ebx
12d6: 83 ec 0c sub $0xc,%esp
12d9: 8b 75 08 mov 0x8(%ebp),%esi
if(tree->active == INACTIVE )
12dc: 8b 06 mov (%esi),%eax
12de: 85 c0 test %eax,%eax
12e0: 74 56 je 1338 <trnmnt_tree_dealloc+0x68>
return -1;
for(int j=0; j<(ourpower(tree->depth)-1); j++){
12e2: 31 ff xor %edi,%edi
12e4: eb 2e jmp 1314 <trnmnt_tree_dealloc+0x44>
12e6: 8d 76 00 lea 0x0(%esi),%esi
12e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
12f0: 89 d8 mov %ebx,%eax
12f2: e8 09 ff ff ff call 1200 <ourpower.part.0>
12f7: 83 e8 01 sub $0x1,%eax
12fa: 39 c7 cmp %eax,%edi
12fc: 7d 47 jge 1345 <trnmnt_tree_dealloc+0x75>
if(safe_tree_dealloc(tree->trnmntMutex[j]) == 0 )
12fe: 83 ec 0c sub $0xc,%esp
1301: ff 74 be 08 pushl 0x8(%esi,%edi,4)
1305: e8 e8 fa ff ff call df2 <safe_tree_dealloc>
130a: 83 c4 10 add $0x10,%esp
130d: 85 c0 test %eax,%eax
130f: 74 27 je 1338 <trnmnt_tree_dealloc+0x68>
for(int j=0; j<(ourpower(tree->depth)-1); j++){
1311: 83 c7 01 add $0x1,%edi
1314: 8b 5e 04 mov 0x4(%esi),%ebx
if (num < 0) {
1317: 85 db test %ebx,%ebx
1319: 79 d5 jns 12f0 <trnmnt_tree_dealloc+0x20>
//printf(1," WERE ARE FUCKED %d \n" , i);
return -1;
}
}
tree->depth=0;
131b: c7 46 04 00 00 00 00 movl $0x0,0x4(%esi)
tree->active = INACTIVE;
1322: c7 06 00 00 00 00 movl $0x0,(%esi)
return 0;
}
1328: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
132b: 31 c0 xor %eax,%eax
}
132d: 5b pop %ebx
132e: 5e pop %esi
132f: 5f pop %edi
1330: 5d pop %ebp
1331: c3 ret
1332: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1338: 8d 65 f4 lea -0xc(%ebp),%esp
return -1;
133b: b8 ff ff ff ff mov $0xffffffff,%eax
}
1340: 5b pop %ebx
1341: 5e pop %esi
1342: 5f pop %edi
1343: 5d pop %ebp
1344: c3 ret
for(int i=0; i<(ourpower(tree->depth)-1); i++){
1345: 31 ff xor %edi,%edi
1347: 89 f6 mov %esi,%esi
1349: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
1350: 89 d8 mov %ebx,%eax
1352: e8 a9 fe ff ff call 1200 <ourpower.part.0>
1357: 83 e8 01 sub $0x1,%eax
135a: 39 f8 cmp %edi,%eax
135c: 7e bd jle 131b <trnmnt_tree_dealloc+0x4b>
if(kthread_mutex_dealloc(tree->trnmntMutex[i]) == -1 ){
135e: 83 ec 0c sub $0xc,%esp
1361: ff 74 be 08 pushl 0x8(%esi,%edi,4)
1365: e8 70 fa ff ff call dda <kthread_mutex_dealloc>
136a: 83 c4 10 add $0x10,%esp
136d: 83 f8 ff cmp $0xffffffff,%eax
1370: 74 c6 je 1338 <trnmnt_tree_dealloc+0x68>
for(int i=0; i<(ourpower(tree->depth)-1); i++){
1372: 8b 5e 04 mov 0x4(%esi),%ebx
1375: 83 c7 01 add $0x1,%edi
if (num < 0) {
1378: 85 db test %ebx,%ebx
137a: 79 d4 jns 1350 <trnmnt_tree_dealloc+0x80>
137c: eb 9d jmp 131b <trnmnt_tree_dealloc+0x4b>
137e: 66 90 xchg %ax,%ax
00001380 <trnmnt_tree_acquire>:
int
trnmnt_tree_acquire(trnmnt_tree* tree,int ID){
1380: 55 push %ebp
1381: 89 e5 mov %esp,%ebp
1383: 57 push %edi
1384: 56 push %esi
1385: 53 push %ebx
1386: 83 ec 1c sub $0x1c,%esp
1389: 8b 75 08 mov 0x8(%ebp),%esi
138c: 8b 5d 0c mov 0xc(%ebp),%ebx
int x=0, localID=ID;
for(int lvl=1; lvl<=tree->depth; lvl++){
138f: 8b 46 04 mov 0x4(%esi),%eax
1392: 85 c0 test %eax,%eax
1394: 7e 62 jle 13f8 <trnmnt_tree_acquire+0x78>
1396: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp)
int x=0, localID=ID;
139d: 31 ff xor %edi,%edi
139f: 90 nop
localID= localID/2; //wich lock try to lock in current level
13a0: 89 d8 mov %ebx,%eax
if(kthread_mutex_lock(tree->trnmntMutex[x+localID]) == -1)
13a2: 83 ec 0c sub $0xc,%esp
localID= localID/2; //wich lock try to lock in current level
13a5: c1 e8 1f shr $0x1f,%eax
13a8: 01 c3 add %eax,%ebx
13aa: d1 fb sar %ebx
if(kthread_mutex_lock(tree->trnmntMutex[x+localID]) == -1)
13ac: 8d 04 3b lea (%ebx,%edi,1),%eax
13af: ff 74 86 08 pushl 0x8(%esi,%eax,4)
13b3: e8 2a fa ff ff call de2 <kthread_mutex_lock>
13b8: 83 c4 10 add $0x10,%esp
13bb: 83 f8 ff cmp $0xffffffff,%eax
13be: 74 3a je 13fa <trnmnt_tree_acquire+0x7a>
return -1; //lock ->if not succeed sleep (in mutex implementation)
x+=((ourpower(tree->depth))/(ourpower(lvl))); //move x to point to the next level for localID
13c0: 8b 4e 04 mov 0x4(%esi),%ecx
if (num < 0) {
13c3: 85 c9 test %ecx,%ecx
13c5: 78 31 js 13f8 <trnmnt_tree_acquire+0x78>
13c7: 89 c8 mov %ecx,%eax
13c9: 89 4d dc mov %ecx,-0x24(%ebp)
13cc: e8 2f fe ff ff call 1200 <ourpower.part.0>
13d1: 89 45 e0 mov %eax,-0x20(%ebp)
13d4: 8b 45 e4 mov -0x1c(%ebp),%eax
13d7: e8 24 fe ff ff call 1200 <ourpower.part.0>
13dc: 89 c1 mov %eax,%ecx
x+=((ourpower(tree->depth))/(ourpower(lvl))); //move x to point to the next level for localID
13de: 8b 45 e0 mov -0x20(%ebp),%eax
for(int lvl=1; lvl<=tree->depth; lvl++){
13e1: 83 45 e4 01 addl $0x1,-0x1c(%ebp)
x+=((ourpower(tree->depth))/(ourpower(lvl))); //move x to point to the next level for localID
13e5: 99 cltd
13e6: f7 f9 idiv %ecx
for(int lvl=1; lvl<=tree->depth; lvl++){
13e8: 8b 4d dc mov -0x24(%ebp),%ecx
x+=((ourpower(tree->depth))/(ourpower(lvl))); //move x to point to the next level for localID
13eb: 01 c7 add %eax,%edi
for(int lvl=1; lvl<=tree->depth; lvl++){
13ed: 8b 45 e4 mov -0x1c(%ebp),%eax
13f0: 39 c1 cmp %eax,%ecx
13f2: 7d ac jge 13a0 <trnmnt_tree_acquire+0x20>
13f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
}
return 0;
13f8: 31 c0 xor %eax,%eax
}
13fa: 8d 65 f4 lea -0xc(%ebp),%esp
13fd: 5b pop %ebx
13fe: 5e pop %esi
13ff: 5f pop %edi
1400: 5d pop %ebp
1401: c3 ret
1402: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1409: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001410 <trnmnt_tree_release>:
int
trnmnt_tree_release(trnmnt_tree* tree,int ID){
1410: 55 push %ebp
1411: 89 e5 mov %esp,%ebp
1413: 57 push %edi
1414: 56 push %esi
1415: 53 push %ebx
1416: 83 ec 0c sub $0xc,%esp
1419: 8b 7d 08 mov 0x8(%ebp),%edi
int x=ourpower(tree->depth)-2, localID;
141c: 8b 5f 04 mov 0x4(%edi),%ebx
if (num < 0) {
141f: 85 db test %ebx,%ebx
1421: 78 65 js 1488 <trnmnt_tree_release+0x78>
1423: 89 d8 mov %ebx,%eax
1425: e8 d6 fd ff ff call 1200 <ourpower.part.0>
for(int lvl=tree->depth; lvl>=1; lvl--){
142a: 85 db test %ebx,%ebx
142c: 8d 70 fe lea -0x2(%eax),%esi
142f: 7f 24 jg 1455 <trnmnt_tree_release+0x45>
1431: eb 55 jmp 1488 <trnmnt_tree_release+0x78>
1433: 90 nop
1434: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
localID= ID/ourpower(lvl); //wich lock try to lock in current level
if(kthread_mutex_unlock(tree->trnmntMutex[x+localID]) == -1)
return -1; //unlock ->if not curthead holds this lock -> return -1 (in mutex implementation)
x -= ourpower(tree->depth-lvl+1); //move x to point to the next level for localID
1438: 8b 57 04 mov 0x4(%edi),%edx
return -1;
143b: b8 ff ff ff ff mov $0xffffffff,%eax
x -= ourpower(tree->depth-lvl+1); //move x to point to the next level for localID
1440: 29 da sub %ebx,%edx
if (num < 0) {
1442: 83 c2 01 add $0x1,%edx
1445: 78 07 js 144e <trnmnt_tree_release+0x3e>
1447: 89 d0 mov %edx,%eax
1449: e8 b2 fd ff ff call 1200 <ourpower.part.0>
x -= ourpower(tree->depth-lvl+1); //move x to point to the next level for localID
144e: 29 c6 sub %eax,%esi
for(int lvl=tree->depth; lvl>=1; lvl--){
1450: 83 eb 01 sub $0x1,%ebx
1453: 74 33 je 1488 <trnmnt_tree_release+0x78>
1455: 89 d8 mov %ebx,%eax
1457: e8 a4 fd ff ff call 1200 <ourpower.part.0>
145c: 89 c1 mov %eax,%ecx
localID= ID/ourpower(lvl); //wich lock try to lock in current level
145e: 8b 45 0c mov 0xc(%ebp),%eax
if(kthread_mutex_unlock(tree->trnmntMutex[x+localID]) == -1)
1461: 83 ec 0c sub $0xc,%esp
localID= ID/ourpower(lvl); //wich lock try to lock in current level
1464: 99 cltd
1465: f7 f9 idiv %ecx
if(kthread_mutex_unlock(tree->trnmntMutex[x+localID]) == -1)
1467: 01 f0 add %esi,%eax
1469: ff 74 87 08 pushl 0x8(%edi,%eax,4)
146d: e8 78 f9 ff ff call dea <kthread_mutex_unlock>
1472: 83 c4 10 add $0x10,%esp
1475: 83 f8 ff cmp $0xffffffff,%eax
1478: 75 be jne 1438 <trnmnt_tree_release+0x28>
}
return 0;
}
147a: 8d 65 f4 lea -0xc(%ebp),%esp
147d: 5b pop %ebx
147e: 5e pop %esi
147f: 5f pop %edi
1480: 5d pop %ebp
1481: c3 ret
1482: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1488: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
148b: 31 c0 xor %eax,%eax
}
148d: 5b pop %ebx
148e: 5e pop %esi
148f: 5f pop %edi
1490: 5d pop %ebp
1491: c3 ret
|
; Get the status of a key
; Input:
; - BC: Key to get; B will hold the row number, C the bit to check
; Output:
; - A: 0 if key is pressed, other value if pressed
GET_KEY_STATE:
ld a, c ; save the bit to check in A
ld c, $fe ; ready to read!
in e,(c) ; get the row in e
and e
ret ; the key is pressed if A = 0, and not pressed if A != 0
; Here are all the key definitions
KEY_CAPS: EQU &fe01
KEY_Z: EQU &fe02
KEY_X: EQU &fe04
KEY_C: EQU &fe08
KEY_V: EQU &fe10
KEY_A: EQU &fd01
KEY_S: EQU &fd02
KEY_D: EQU &fd04
KEY_F: EQU &fd08
KEY_G: EQU &fd10
KEY_Q: EQU &fb01
KEY_W: EQU &fb02
KEY_E: EQU &fb04
KEY_R: EQU &fb08
KEY_T: EQU &fb10
KEY_1: EQU &f701
KEY_2: EQU &f702
KEY_3: EQU &f704
KEY_4: EQU &f708
KEY_5: EQU &f710
KEY_0: EQU &ef01
KEY_9: EQU &ef02
KEY_8: EQU &ef04
KEY_7: EQU &ef08
KEY_6: EQU &ef10
KEY_P: EQU &df01
KEY_O: EQU &df02
KEY_I: EQU &df04
KEY_U: EQU &df08
KEY_Y: EQU &df10
KEY_ENTER: EQU &bf01
KEY_L: EQU &bf02
KEY_K: EQU &bf04
KEY_J: EQU &bf08
KEY_H: EQU &bf10
KEY_SPACE: EQU &7f01
KEY_SS: EQU &7f02
KEY_M: EQU &7f04
KEY_N: EQU &7f08
KEY_B: EQU &7f10
; Get joystick state
; joynum: 0 (Kempston), 1 (Sinclair 1), 2 (Sinclair 2), 3 (Keys)
; If joynum == 3, HL holds a pointer a 5 int array with the Key definitions (UP,DOWN, LEFT, RIGHT, FIRE)
; Input:
; A: joynum
; Returns:
; A: joystick state
; Bit #: 765 4 3210
; ||| | ||||
; XXX BUT1 RLDU
;
; 1 means pressed, 0 means not pressed
get_joystick:
push bc ; save all the registers that may be modified
push de
push hl
and a
jr nz, check_sinclair1 ; A==0, so Kempston
call read_kempston_joystick
jr get_joy_end
check_sinclair1:
dec a
jr nz, check_sinclair2
call read_sinclair1_joystick
jr get_joy_end
check_sinclair2:
dec a
jr nz, get_joy_redef
call read_sinclair2_joystick
jr get_joy_end
get_joy_redef:
call read_redefined
get_joy_end:
pop hl
pop de
pop bc
ret
;------------------------------------
; Read routine for kempston joysticks
;------------------------------------
read_kempston_joystick:
ld c, 31
in c, (c)
ld a, 255
cp c
jr z, nokempston ; if the value read is 255, then there is no kempston interface
xor a ; clear carry and A
kempston_right:
rr c
jr nc, kempston_left
or $08 ; right is pressed
kempston_left:
rr c
jr nc, kempston_down
or $04 ; left is pressed
kempston_down:
rr c
jr nc, kempston_up
or $02 ; down is pressed
kempston_up:
rr c
jr nc, kempston_fire
or $01 ; up is pressed
kempston_fire:
rr c
ret nc ; no carry, just return
or $10
ret
nokempston: xor a
ret ; nothing read
;--------------------------------------
; Read routine for Sinclair 1 joysticks
;--------------------------------------
read_sinclair1_joystick:
ld bc, $effe
in c, (c) ; Leemos solo la fila 6-0. Los bits a 0 están pulsados
xor a
sinclair1_fire:
rr c
jr c, sinclair1_up
or $10 ; fire is pressed
sinclair1_up:
rr c
jr c, sinclair1_down
or $01 ; up is pressed
sinclair1_down:
rr c
jr c, sinclair1_right
or $02 ; down is pressed
sinclair1_right:
rr c
jr c, sinclair1_left
or $08 ; right is pressed
sinclair1_left:
rr c
ret c ; no carry, just return
or $04 ; left pressed
ret
;--------------------------------------
; Read routine for Sinclair 2 joysticks
;--------------------------------------
read_sinclair2_joystick:
ld bc, $f7fe
in c, (c) ; Leemos solo la fila 1-5. Los bits a 0 están pulsados
xor a
sinclair2_left:
rr c
jr c, sinclair2_right
or $04 ; left is pressed
sinclair2_right:
rr c
jr c, sinclair2_down
or $08 ; right is pressed
sinclair2_down:
rr c
jr c, sinclair2_up
or $02 ; down is pressed
sinclair2_up:
rr c
jr c, sinclair2_fire
or $01 ; up is pressed
sinclair2_fire:
rr c
ret c ; no carry, just return
or $10 ; left pressed
ret
;--------------------------------------
; Read routine for Redefined Keys
;--------------------------------------
read_redefined:; we use d as an A
redefined_up:
ld d,0
ld c, $fe ; ready to read!
ld e,(hl)
inc hl
ld b,(hl)
inc hl
in a,(c) ; get the row in e
and e
jr nz, redefined_down
inc d
redefined_down:
ld e,(hl)
inc hl
ld b,(hl)
inc hl
in a,(c) ; get the row in e
and e
jr nz, redefined_left
inc d
inc d
redefined_left:
ld e,(hl)
inc hl
ld b,(hl)
inc hl
in a,(c) ; get the row in e
and e
jr nz, redefined_right
inc d
inc d
inc d
inc d
redefined_right:
ld e,(hl)
inc hl
ld b,(hl)
inc hl
in a,(c) ; get the row in e
and e
jr nz, redefined_fire
ld a, d
or $08
ld d, a
redefined_fire:
ld e,(hl)
inc hl
ld b,(hl)
inc hl
in a,(c) ; get the row in e
and e
jr nz, redefined_end
ld a, d
or $10
ret
redefined_end:
ld a,d
ret
|
; A206817: Sum_{0<j<k<=n} (k!-j!).
; 1,10,73,520,3967,33334,309661,3166468,35416555,430546642,5655609529,79856902816,1206424711303,19419937594990,331860183278677,6000534640290364,114462875817046051,2297294297649673738,48394006967070653425,1067651522907147633112,24618014536571087652799,592184729794597144792486,14835468299922775844492173,386457031268396871615551860,10452584871318737207386611547,293143740432954487197941671234,8513820725349568962388368730921,255766959885849850070757931790608,7938941935781439474950308550850295
lpb $0
mov $1,$0
sub $0,1
seq $1,206816 ; Sum_{0<j<n} (n!-j!).
add $2,$1
lpe
mov $0,$2
add $0,1
|
; ----------------------------------------------------------------
; Z88DK INTERFACE LIBRARY FOR THE BIFROST* ENGINE - RELEASE 1.2/L
;
; See "bifrost_h.h" for further details
; ----------------------------------------------------------------
; void BIFROSTH_drawTileH(unsigned char lin,unsigned char col,unsigned char tile)
SECTION code_clib
SECTION code_bifrost_h
PUBLIC _BIFROSTH_drawTileH
EXTERN asm_BIFROSTH_drawTileH
_BIFROSTH_drawTileH:
ld hl,2
add hl,sp
ld d,(hl) ; D = lin
inc hl
ld e,(hl) ; E = col
inc hl
ld a,(hl) ; A = tile
jp asm_BIFROSTH_drawTileH
|
copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
0006D6 move.w ($864,A5), D0 [base+85C, base+85E]
0006DA add.w D1, D0 [base+864]
0006E2 move.l ($744,A5), ($864,A5)
0006E8 move.w ($86c,A5), D0 [base+864, base+866]
0AAACA move.l (A0), D2
0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAACE move.w D0, ($2,A0)
0AAAD2 cmp.l (A0), D0
0AAAD4 bne $aaafc
0AAAD8 move.l D2, (A0)+
0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAE6 move.l (A0), D2
0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAF4 move.l D2, (A0)+
0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
copyright zengfr site:http://github.com/zengfr/romhack
|
// Time: O(m * n)
// Space: O(m * n)
// A* Search Algorithm without heap
class Solution {
public:
int minCost(vector<vector<int>>& grid) {
const pair<int, int> b = {0, 0}, t = {grid.size() - 1, grid[0].size() - 1};
return a_star(grid, b, t);
}
private:
int a_star(const vector<vector<int>>& grid,
const pair<int, int>& b,
const pair<int, int>& t) {
static const vector<tuple<int, int, int>> directions = {{1, 0, 1}, {2, 0, -1},
{3, 1, 0}, {4, -1, 0}};
int f = 0, dh = 1;
vector<pair<int, int>> closer = {b}, detour;
vector<vector<bool>> lookup(size(grid), vector<bool>(size(grid[0])));
while (!closer.empty() || !detour.empty()) {
if (closer.empty()) {
f += dh;
swap(closer, detour);
}
const auto b = closer.back(); closer.pop_back();
if (b == t) {
return f;
}
if (lookup[b.first][b.second]) {
continue;
}
lookup[b.first][b.second] = true;
for (const auto& [nd, dr, dc] : directions) {
const pair<int, int>& nb = {b.first + dr, b.second + dc};
if (!(0 <= nb.first && nb.first < grid.size() &&
0 <= nb.second && nb.second < grid[0].size() &&
!lookup[nb.first][nb.second])) {
continue;
}
if (nd == grid[b.first][b.second]) {
closer.emplace_back(nb);
} else {
detour.emplace_back(nb);
}
}
}
return -1;
}
};
// Time: O(m * n)
// Space: O(m * n)
// 0-1 bfs solution
class Solution2 {
public:
int minCost(vector<vector<int>>& grid) {
static const vector<tuple<int, int, int>> directions = {{1, 0, 1}, {2, 0, -1},
{3, 1, 0}, {4, -1, 0}};
const pair<int, int> b = {0, 0}, t = {grid.size() - 1, grid[0].size() - 1};
deque<pair<pair<int, int>, int>> dq = {{b, 0}};
vector<vector<bool>> lookup(size(grid), vector<bool>(size(grid[0])));
while (!dq.empty()) {
const auto [b, d] = dq.front(); dq.pop_front();
if (b == t) {
return d;
}
if (lookup[b.first][b.second]) {
continue;
}
lookup[b.first][b.second] = true;
for (const auto& [nd, dr, dc] : directions) {
const auto& nb = make_pair(b.first + dr, b.second + dc);
const auto& cost = nd != grid[b.first][b.second] ? 1 : 0;
if (!(0 <= nb.first && nb.first < grid.size() &&
0 <= nb.second && nb.second < grid[0].size() &&
!lookup[nb.first][nb.second])) {
continue;
}
if (!cost) {
dq.emplace_front(nb, d);
} else {
dq.emplace_back(nb, d + cost);
}
}
}
return -1; // never reach here
}
};
|
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "precomp.h"
#include "readDataDirect.hpp"
#include "dbcs.h"
#include "misc.h"
#include "../interactivity/inc/ServiceLocator.hpp"
// Routine Description:
// - Constructs direct read data class to hold context across sessions
// generally when there's not enough data to return. Also used a bit
// internally to just pass some information along the stack
// (regardless of wait necessity).
// Arguments:
// - pInputBuffer - Buffer that data will be read from.
// - pInputReadHandleData - Context stored across calls from the same
// input handle to return partial data appropriately.
// the user's buffer (pOutRecords)
// - eventReadCount - the number of events to read
// - partialEvents - any partial events already read
// Return Value:
// - THROW: Throws E_INVALIDARG for invalid pointers.
DirectReadData::DirectReadData(_In_ InputBuffer* const pInputBuffer,
_In_ INPUT_READ_HANDLE_DATA* const pInputReadHandleData,
const size_t eventReadCount,
_In_ std::deque<std::unique_ptr<IInputEvent>> partialEvents) :
ReadData(pInputBuffer, pInputReadHandleData),
_eventReadCount{ eventReadCount },
_partialEvents{ std::move(partialEvents) },
_outEvents{}
{
}
// Routine Description:
// - Destructs a read data class.
// - Decrements count of readers waiting on the given handle.
DirectReadData::~DirectReadData()
{
}
// Routine Description:
// - This routine is called to complete a direct read that blocked in
// ReadInputBuffer. The context of the read was saved in the DirectReadData
// structure. This routine is called when events have been written to
// the input buffer. It is called in the context of the writing thread.
// Arguments:
// - TerminationReason - if this routine is called because a ctrl-c or
// ctrl-break was seen, this argument contains CtrlC or CtrlBreak. If
// the owning thread is exiting, it will have ThreadDying. Otherwise 0.
// - fIsUnicode - Should we return UCS-2 unicode data, or should we
// run the final data through the current Input Codepage before
// returning?
// - pReplyStatus - The status code to return to the client
// application that originally called the API (before it was queued to
// wait)
// - pNumBytes - not used
// - pControlKeyState - For certain types of reads, this specifies
// which modifier keys were held.
// - pOutputData - a pointer to a
// std::deque<std::unique_ptr<IInputEvent>> that is used to the read
// input events back to the server
// Return Value:
// - true if the wait is done and result buffer/status code can be sent back to the client.
// - false if we need to continue to wait until more data is available.
bool DirectReadData::Notify(const WaitTerminationReason TerminationReason,
const bool fIsUnicode,
_Out_ NTSTATUS* const pReplyStatus,
_Out_ size_t* const pNumBytes,
_Out_ DWORD* const pControlKeyState,
_Out_ void* const pOutputData)
{
FAIL_FAST_IF_NULL(pOutputData);
FAIL_FAST_IF(_pInputReadHandleData->GetReadCount() == 0);
const auto& gci = Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals().getConsoleInformation();
FAIL_FAST_IF(!gci.IsConsoleLocked());
*pReplyStatus = STATUS_SUCCESS;
*pControlKeyState = 0;
*pNumBytes = 0;
auto retVal = true;
std::deque<std::unique_ptr<IInputEvent>> readEvents;
// If ctrl-c or ctrl-break was seen, ignore it.
if (WI_IsAnyFlagSet(TerminationReason, (WaitTerminationReason::CtrlC | WaitTerminationReason::CtrlBreak)))
{
return false;
}
// check if a partial byte is already stored that we should read
if (!fIsUnicode &&
_pInputBuffer->IsReadPartialByteSequenceAvailable() &&
_eventReadCount == 1)
{
_partialEvents.push_back(_pInputBuffer->FetchReadPartialByteSequence(false));
}
// See if called by CsrDestroyProcess or CsrDestroyThread
// via ConsoleNotifyWaitBlock. If so, just decrement the ReadCount and return.
if (WI_IsFlagSet(TerminationReason, WaitTerminationReason::ThreadDying))
{
*pReplyStatus = STATUS_THREAD_IS_TERMINATING;
}
// We must see if we were woken up because the handle is being
// closed. If so, we decrement the read count. If it goes to
// zero, we wake up the close thread. Otherwise, we wake up any
// other thread waiting for data.
else if (WI_IsFlagSet(TerminationReason, WaitTerminationReason::HandleClosing))
{
*pReplyStatus = STATUS_ALERTED;
}
else
{
// if we get to here, this routine was called either by the input
// thread or a write routine. both of these callers grab the
// current console lock.
// calculate how many events we need to read
size_t amountAlreadyRead;
if (FAILED(SizeTAdd(_partialEvents.size(), _outEvents.size(), &amountAlreadyRead)))
{
*pReplyStatus = STATUS_INTEGER_OVERFLOW;
return retVal;
}
size_t amountToRead;
if (FAILED(SizeTSub(_eventReadCount, amountAlreadyRead, &amountToRead)))
{
*pReplyStatus = STATUS_INTEGER_OVERFLOW;
return retVal;
}
*pReplyStatus = _pInputBuffer->Read(readEvents,
amountToRead,
false,
false,
fIsUnicode,
false);
if (*pReplyStatus == CONSOLE_STATUS_WAIT)
{
retVal = false;
}
}
if (*pReplyStatus != CONSOLE_STATUS_WAIT)
{
// split key events to oem chars if necessary
if (*pReplyStatus == STATUS_SUCCESS && !fIsUnicode)
{
try
{
SplitToOem(readEvents);
}
CATCH_LOG();
}
// combine partial and whole events
while (!_partialEvents.empty())
{
readEvents.push_front(std::move(_partialEvents.back()));
_partialEvents.pop_back();
}
// move read events to out storage
for (size_t i = 0; i < _eventReadCount; ++i)
{
if (readEvents.empty())
{
break;
}
_outEvents.push_back(std::move(readEvents.front()));
readEvents.pop_front();
}
// store partial event if necessary
if (!readEvents.empty())
{
_pInputBuffer->StoreReadPartialByteSequence(std::move(readEvents.front()));
readEvents.pop_front();
FAIL_FAST_IF(!(readEvents.empty()));
}
// move events to pOutputData
const auto pOutputDeque = reinterpret_cast<std::deque<std::unique_ptr<IInputEvent>>* const>(pOutputData);
*pNumBytes = _outEvents.size() * sizeof(INPUT_RECORD);
pOutputDeque->swap(_outEvents);
}
return retVal;
}
void DirectReadData::MigrateUserBuffersOnTransitionToBackgroundWait(const void* /*oldBuffer*/, void* /*newBuffer*/)
{
// Direct read doesn't hold API message buffers
}
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2007,2008 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
*/
#include "wimax-helper.h"
#include "ns3/simulator.h"
#include "ns3/packet.h"
#include "ns3/log.h"
#include <string>
#include "ns3/config.h"
#include "ns3/wimax-net-device.h"
#include "ns3/bs-net-device.h"
#include "ns3/ss-net-device.h"
#include "ns3/wimax-channel.h"
#include "ns3/simple-ofdm-wimax-channel.h"
#include "ns3/wimax-phy.h"
#include "ns3/simple-ofdm-wimax-phy.h"
#include "ns3/pointer.h"
#include "ns3/wimax-mac-to-mac-header.h"
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("WimaxHelper");
WimaxHelper::WimaxHelper (void)
: m_channel (0)
{
}
WimaxHelper::~WimaxHelper (void)
{
}
void WimaxHelper::EnableAsciiForConnection (Ptr<OutputStreamWrapper> os,
uint32_t nodeid,
uint32_t deviceid,
char *netdevice,
char *connection)
{
std::ostringstream oss;
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::" << netdevice << "/" << connection
<< "/TxQueue/Enqueue";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultEnqueueSinkWithContext, os));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::" << netdevice << "/" << connection
<< "/TxQueue/Dequeue";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDequeueSinkWithContext, os));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::" << netdevice << "/" << connection
<< "/TxQueue/Drop";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, os));
}
Ptr<WimaxPhy> WimaxHelper::CreatePhy (PhyType phyType)
{
Ptr<WimaxPhy> phy;
switch (phyType)
{
case SIMPLE_PHY_TYPE_OFDM:
phy = CreateObject<SimpleOfdmWimaxPhy> ();
if (!m_channel)
{
m_channel = CreateObject<SimpleOfdmWimaxChannel> (SimpleOfdmWimaxChannel::COST231_PROPAGATION);
}
break;
default:
NS_FATAL_ERROR ("Invalid physical type");
break;
}
return phy;
}
void WimaxHelper::SetPropagationLossModel (SimpleOfdmWimaxChannel::PropModel propagationModel)
{
if (!m_channel)
{
m_channel = CreateObject<SimpleOfdmWimaxChannel> ();
}
m_channel->GetObject<SimpleOfdmWimaxChannel> ()->SetPropagationModel (propagationModel);
}
Ptr<WimaxPhy> WimaxHelper::CreatePhy (PhyType phyType, char * SNRTraceFilePath, bool activateLoss)
{
Ptr<WimaxPhy> phy;
Ptr<SimpleOfdmWimaxPhy> sphy;
switch (phyType)
{
case SIMPLE_PHY_TYPE_OFDM:
sphy = CreateObject<SimpleOfdmWimaxPhy> ();
phy = sphy;
sphy->SetSNRToBlockErrorRateTracesPath (SNRTraceFilePath);
sphy->ActivateLoss (activateLoss);
if (!m_channel)
{
m_channel = CreateObject<SimpleOfdmWimaxChannel> (SimpleOfdmWimaxChannel::COST231_PROPAGATION);
}
break;
default:
NS_FATAL_ERROR ("Invalid physical type");
break;
}
return phy;
}
Ptr<WimaxPhy> WimaxHelper::CreatePhyWithoutChannel (PhyType phyType)
{
Ptr<WimaxPhy> phy;
switch (phyType)
{
case SIMPLE_PHY_TYPE_OFDM:
phy = CreateObject<SimpleOfdmWimaxPhy> ();
break;
default:
NS_FATAL_ERROR ("Invalid physical type");
break;
}
return phy;
}
Ptr<WimaxPhy> WimaxHelper::CreatePhyWithoutChannel (PhyType phyType, char * SNRTraceFilePath, bool activateLoss)
{
Ptr<WimaxPhy> phy;
Ptr<SimpleOfdmWimaxPhy> sphy;
switch (phyType)
{
case SIMPLE_PHY_TYPE_OFDM:
sphy = CreateObject<SimpleOfdmWimaxPhy> ();
phy = sphy;
sphy->SetSNRToBlockErrorRateTracesPath (SNRTraceFilePath);
sphy->ActivateLoss (activateLoss);
break;
default:
NS_FATAL_ERROR ("Invalid physical type");
break;
}
return phy;
}
Ptr<UplinkScheduler> WimaxHelper::CreateUplinkScheduler (SchedulerType schedulerType)
{
Ptr<UplinkScheduler> uplinkScheduler;
switch (schedulerType)
{
case SCHED_TYPE_SIMPLE:
uplinkScheduler = CreateObject<UplinkSchedulerSimple> ();
break;
case SCHED_TYPE_RTPS:
uplinkScheduler = CreateObject<UplinkSchedulerRtps> ();
break;
case SCHED_TYPE_MBQOS:
uplinkScheduler = CreateObject<UplinkSchedulerMBQoS> (Seconds (0.25));
break;
default:
NS_FATAL_ERROR ("Invalid scheduling type");
break;
}
return uplinkScheduler;
}
Ptr<BSScheduler> WimaxHelper::CreateBSScheduler (SchedulerType schedulerType)
{
Ptr<BSScheduler> bsScheduler;
switch (schedulerType)
{
case SCHED_TYPE_SIMPLE:
bsScheduler = CreateObject<BSSchedulerSimple> ();
break;
case SCHED_TYPE_RTPS:
bsScheduler = CreateObject<BSSchedulerRtps> ();
break;
case SCHED_TYPE_MBQOS:
bsScheduler = CreateObject<BSSchedulerSimple> ();
break;
default:
NS_FATAL_ERROR ("Invalid scheduling type");
break;
}
return bsScheduler;
}
NetDeviceContainer WimaxHelper::Install (NodeContainer c,
NetDeviceType deviceType,
PhyType phyType,
SchedulerType schedulerType,
double frameDuration)
{
NetDeviceContainer devices;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++)
{
Ptr<Node> node = *i;
Ptr<WimaxPhy> phy = CreatePhy (phyType);
// Set SuperFrame Duration
phy->SetFrameDuration (Seconds (frameDuration));
Ptr<WimaxNetDevice> device;
Ptr<UplinkScheduler> uplinkScheduler = CreateUplinkScheduler (schedulerType);
Ptr<BSScheduler> bsScheduler = CreateBSScheduler (schedulerType);
if (deviceType == DEVICE_TYPE_BASE_STATION)
{
// attach phy
Ptr<BaseStationNetDevice> deviceBS;
deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
device = deviceBS;
uplinkScheduler->SetBs (deviceBS);
bsScheduler->SetBs (deviceBS);
}
else
{
device = CreateObject<SubscriberStationNetDevice> (node, phy);
}
device->SetAddress (Mac48Address::Allocate ());
phy->SetDevice (device);
device->Start ();
device->Attach (m_channel); // attach channel
node->AddDevice (device);
devices.Add (device);
}
return devices;
}
NetDeviceContainer WimaxHelper::Install (NodeContainer c,
NetDeviceType deviceType,
PhyType phyType,
SchedulerType schedulerType)
{
NetDeviceContainer devices;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++)
{
Ptr<Node> node = *i;
Ptr<WimaxPhy> phy = CreatePhy (phyType);
Ptr<WimaxNetDevice> device;
Ptr<UplinkScheduler> uplinkScheduler = CreateUplinkScheduler (schedulerType);
Ptr<BSScheduler> bsScheduler = CreateBSScheduler (schedulerType);
if (deviceType == DEVICE_TYPE_BASE_STATION)
{
// attach phy
Ptr<BaseStationNetDevice> deviceBS;
deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
device = deviceBS;
uplinkScheduler->SetBs (deviceBS);
bsScheduler->SetBs (deviceBS);
}
else
{
device = CreateObject<SubscriberStationNetDevice> (node, phy);
}
device->SetAddress (Mac48Address::Allocate ());
phy->SetDevice (device);
device->Start ();
device->Attach (m_channel); // attach channel
node->AddDevice (device);
devices.Add (device);
}
return devices;
}
NetDeviceContainer WimaxHelper::Install (NodeContainer c,
NetDeviceType deviceType,
PhyType phyType,
Ptr<WimaxChannel> channel,
SchedulerType schedulerType)
{
NetDeviceContainer devices;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++)
{
Ptr<Node> node = *i;
Ptr<WimaxPhy> phy = CreatePhyWithoutChannel (phyType, (char*) "dummy", 0);
Ptr<WimaxNetDevice> device;
Ptr<UplinkScheduler> uplinkScheduler = CreateUplinkScheduler (schedulerType);
Ptr<BSScheduler> bsScheduler = CreateBSScheduler (schedulerType);
if (deviceType == DEVICE_TYPE_BASE_STATION)
{
Ptr<BaseStationNetDevice> deviceBS;
deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
device = deviceBS;
uplinkScheduler->SetBs (deviceBS);
bsScheduler->SetBs (deviceBS);
}
else
{
device = CreateObject<SubscriberStationNetDevice> (node, phy);
}
device->SetAddress (Mac48Address::Allocate ());
phy->SetDevice (device);
device->Start ();
device->Attach (channel);
node->AddDevice (device);
devices.Add (device);
}
return devices;
}
Ptr<WimaxNetDevice> WimaxHelper::Install (Ptr<Node> node,
NetDeviceType deviceType,
PhyType phyType,
Ptr<WimaxChannel> channel,
SchedulerType schedulerType)
{
// Ptr<WimaxPhy> phy = CreatePhyWithoutChannel (phyType);
Ptr<WimaxPhy> phy = CreatePhyWithoutChannel (phyType, (char*) "dummy", 0);
Ptr<WimaxNetDevice> device;
Ptr<UplinkScheduler> uplinkScheduler = CreateUplinkScheduler (schedulerType);
Ptr<BSScheduler> bsScheduler = CreateBSScheduler (schedulerType);
if (deviceType == DEVICE_TYPE_BASE_STATION)
{
Ptr<BaseStationNetDevice> deviceBS;
deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
device = deviceBS;
uplinkScheduler->SetBs (deviceBS);
bsScheduler->SetBs (deviceBS);
}
else
{
device = CreateObject<SubscriberStationNetDevice> (node, phy);
}
device->SetAddress (Mac48Address::Allocate ());
phy->SetDevice (device);
device->Start ();
device->Attach (channel);
node->AddDevice (device);
return device;
}
void
WimaxHelper::EnableLogComponents (void)
{
LogComponentEnable ("BandwidthManager", LOG_LEVEL_ALL);
LogComponentEnable ("BSLinkManager", LOG_LEVEL_ALL);
LogComponentEnable ("BaseStationNetDevice", LOG_LEVEL_ALL);
LogComponentEnable ("BSSchedulerRtps", LOG_LEVEL_ALL);
LogComponentEnable ("BSSchedulerSimple", LOG_LEVEL_ALL);
LogComponentEnable ("BSScheduler", LOG_LEVEL_ALL);
LogComponentEnable ("BsServiceFlowManager", LOG_LEVEL_ALL);
LogComponentEnable ("UplinkSchedulerMBQoS", LOG_LEVEL_ALL);
LogComponentEnable ("UplinkSchedulerRtps", LOG_LEVEL_ALL);
LogComponentEnable ("UplinkSchedulerSimple", LOG_LEVEL_ALL);
LogComponentEnable ("UplinkScheduler", LOG_LEVEL_ALL);
LogComponentEnable ("BurstProfileManager", LOG_LEVEL_ALL);
LogComponentEnable ("ConnectionManager", LOG_LEVEL_ALL);
LogComponentEnable ("IpcsClassifierRecord", LOG_LEVEL_ALL);
LogComponentEnable ("IpcsClassifier", LOG_LEVEL_ALL);
LogComponentEnable ("MACMESSAGES", LOG_LEVEL_ALL);
LogComponentEnable ("PacketBurst", LOG_LEVEL_ALL);
LogComponentEnable ("ServiceFlowManager", LOG_LEVEL_ALL);
LogComponentEnable ("simpleOfdmWimaxChannel", LOG_LEVEL_ALL);
LogComponentEnable ("SimpleOfdmWimaxPhy", LOG_LEVEL_ALL);
LogComponentEnable ("SNRToBlockErrorRateManager", LOG_LEVEL_ALL);
LogComponentEnable ("SSLinkManager", LOG_LEVEL_ALL);
LogComponentEnable ("SSManager", LOG_LEVEL_ALL);
LogComponentEnable ("SubscriberStationNetDevice", LOG_LEVEL_ALL);
LogComponentEnable ("SSScheduler", LOG_LEVEL_ALL);
LogComponentEnable ("SsServiceFlowManager", LOG_LEVEL_ALL);
LogComponentEnable ("WimaxChannel", LOG_LEVEL_ALL);
LogComponentEnable ("WimaxMacQueue", LOG_LEVEL_ALL);
LogComponentEnable ("WimaxNetDevice", LOG_LEVEL_ALL);
LogComponentEnable ("WimaxPhy", LOG_LEVEL_ALL);
LogComponentEnable ("Tlv", LOG_LEVEL_ALL);
LogComponentEnable ("BandwidthManager", LOG_LEVEL_ALL);
LogComponentEnable ("BaseStationNetDevice", LOG_LEVEL_ALL);
LogComponentEnable ("BSSchedulerRtps", LOG_LEVEL_ALL);
LogComponentEnable ("BSSchedulerSimple", LOG_LEVEL_ALL);
LogComponentEnable ("BSScheduler", LOG_LEVEL_ALL);
LogComponentEnable ("SubscriberStationNetDevice", LOG_LEVEL_ALL);
LogComponentEnable ("SSScheduler", LOG_LEVEL_ALL);
LogComponentEnable ("WimaxMacQueue", LOG_LEVEL_ALL);
}
void WimaxHelper::AsciiRxEvent (Ptr<OutputStreamWrapper> stream,
std::string path,
Ptr<const Packet> packet,
const Mac48Address &source)
{
*stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " from: " << source << " ";
*stream->GetStream () << path << std::endl;
}
void WimaxHelper::AsciiTxEvent (Ptr<OutputStreamWrapper> stream, std::string path, Ptr<const Packet> packet, const Mac48Address &dest)
{
*stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " to: " << dest << " ";
*stream->GetStream () << path << std::endl;
}
ServiceFlow WimaxHelper::CreateServiceFlow (ServiceFlow::Direction direction,
ServiceFlow::SchedulingType schedulinType,
IpcsClassifierRecord classifier)
{
CsParameters csParam (CsParameters::ADD, classifier);
ServiceFlow serviceFlow = ServiceFlow (direction);
serviceFlow.SetConvergenceSublayerParam (csParam);
serviceFlow.SetCsSpecification (ServiceFlow::IPV4);
serviceFlow.SetServiceSchedulingType (schedulinType);
serviceFlow.SetMaxSustainedTrafficRate (100);
serviceFlow.SetMinReservedTrafficRate (1000000);
serviceFlow.SetMinTolerableTrafficRate (1000000);
serviceFlow.SetMaximumLatency (100);
serviceFlow.SetMaxTrafficBurst (2000);
serviceFlow.SetTrafficPriority (1);
serviceFlow.SetUnsolicitedGrantInterval (1);
serviceFlow.SetMaxSustainedTrafficRate (70);
serviceFlow.SetToleratedJitter (10);
serviceFlow.SetSduSize (49);
serviceFlow.SetRequestTransmissionPolicy (0);
return serviceFlow;
}
void
WimaxHelper::EnableAsciiInternal (Ptr<OutputStreamWrapper> stream,
std::string prefix,
Ptr<NetDevice> nd,
bool explicitFilename)
{
//
// All of the ascii enable functions vector through here including the ones
// that are wandering through all of devices on perhaps all of the nodes in
// the system. We can only deal with devices of type CsmaNetDevice.
//
Ptr<WimaxNetDevice> device = nd->GetObject<WimaxNetDevice> ();
if (device == 0)
{
NS_LOG_INFO ("WimaxHelper::EnableAsciiInternal(): Device " << device << " not of type ns3::WimaxNetDevice");
return;
}
//
// Our default trace sinks are going to use packet printing, so we have to
// make sure that is turned on.
//
Packet::EnablePrinting ();
//
// If we are not provided an OutputStreamWrapper, we are expected to create
// one using the usual trace filename conventions and do a Hook*WithoutContext
// since there will be one file per context and therefore the context would
// be redundant.
//
if (stream == 0)
{
//
// Set up an output stream object to deal with private ofstream copy
// constructor and lifetime issues. Let the helper decide the actual
// name of the file given the prefix.
//
AsciiTraceHelper asciiTraceHelper;
std::string filename;
if (explicitFilename)
{
filename = prefix;
}
else
{
filename = asciiTraceHelper.GetFilenameFromDevice (prefix, device);
}
Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
uint32_t nodeid = nd->GetNode ()->GetId ();
uint32_t deviceid = nd->GetIfIndex ();
std::ostringstream oss;
//
// The MacRx trace source provides our "r" event.
//
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Rx";
Config::Connect (oss.str (), MakeBoundCallback (&WimaxHelper::AsciiRxEvent, theStream));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Tx";
Config::Connect (oss.str (), MakeBoundCallback (&WimaxHelper::AsciiTxEvent, theStream));
//
// The "+", '-', and 'd' events are driven by trace sources actually in the
// transmit queue.
//
EnableAsciiForConnection (theStream, nodeid, deviceid, (char*) "WimaxNetDevice", (char*) "InitialRangingConnection");
EnableAsciiForConnection (theStream, nodeid, deviceid, (char*) "WimaxNetDevice", (char*) "BroadcastConnection");
EnableAsciiForConnection (theStream, nodeid, deviceid, (char*) "SubscriberStationNetDevice", (char*) "BasicConnection");
EnableAsciiForConnection (theStream, nodeid, deviceid, (char*) "SubscriberStationNetDevice", (char*) "PrimaryConnection");
return;
}
//
// If we are provided an OutputStreamWrapper, we are expected to use it, and
// to providd a context. We are free to come up with our own context if we
// want, and use the AsciiTraceHelper Hook*WithContext functions, but for
// compatibility and simplicity, we just use Config::Connect and let it deal
// with the context.
//
// Note that we are going to use the default trace sinks provided by the
// ascii trace helper. There is actually no AsciiTraceHelper in sight here,
// but the default trace sinks are actually publicly available static
// functions that are always there waiting for just such a case.
//
uint32_t nodeid = nd->GetNode ()->GetId ();
uint32_t deviceid = nd->GetIfIndex ();
std::ostringstream oss;
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Rx";
Config::Connect (oss.str (), MakeBoundCallback (&WimaxHelper::AsciiRxEvent, stream));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Tx";
Config::Connect (oss.str (), MakeBoundCallback (&WimaxHelper::AsciiTxEvent, stream));
EnableAsciiForConnection (stream, nodeid, deviceid, (char*) "WimaxNetDevice", (char*) "InitialRangingConnection");
EnableAsciiForConnection (stream, nodeid, deviceid, (char*) "WimaxNetDevice", (char*) "BroadcastConnection");
EnableAsciiForConnection (stream, nodeid, deviceid, (char*) "SubscriberStationNetDevice", (char*) "BasicConnection");
EnableAsciiForConnection (stream, nodeid, deviceid, (char*) "SubscriberStationNetDevice", (char*) "PrimaryConnection");
}
/**
* \brief print pcap record
* \param file pcap file
* \param burst packet burst to print
*/
static void PcapSniffTxRxEvent (Ptr<PcapFileWrapper> file,
Ptr<const PacketBurst> burst)
{
std::list<Ptr<Packet> > packets = burst->GetPackets ();
for (std::list<Ptr<Packet> >::iterator iter = packets.begin (); iter != packets.end (); ++iter)
{
Ptr<Packet> p = (*iter)->Copy ();
WimaxMacToMacHeader m2m (p->GetSize ());
p->AddHeader (m2m);
file->Write (Simulator::Now (), p);
}
}
void
WimaxHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool explicitFilename, bool promiscuous)
{
//
// All of the Pcap enable functions vector through here including the ones
// that are wandering through all of devices on perhaps all of the nodes in
// the system. We can only deal with devices of type WimaxNetDevice.
//
Ptr<WimaxNetDevice> device = nd->GetObject<WimaxNetDevice> ();
if (device == 0)
{
NS_LOG_INFO ("WimaxHelper::EnablePcapInternal(): Device " << &device << " not of type ns3::WimaxNetDevice");
return;
}
Ptr<WimaxPhy> phy = device->GetPhy ();
PcapHelper pcapHelper;
std::string filename;
if (explicitFilename)
{
filename = prefix;
}
else
{
filename = pcapHelper.GetFilenameFromDevice (prefix, device);
}
Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_EN10MB);
phy->TraceConnectWithoutContext ("Tx", MakeBoundCallback (&PcapSniffTxRxEvent, file));
phy->TraceConnectWithoutContext ("Rx", MakeBoundCallback (&PcapSniffTxRxEvent, file));
}
int64_t
WimaxHelper::AssignStreams (int64_t stream)
{
NS_LOG_FUNCTION (this << stream);
return m_channel->AssignStreams (stream);
}
int64_t
WimaxHelper::AssignStreams (NetDeviceContainer c, int64_t stream)
{
int64_t currentStream = stream;
Ptr<NetDevice> netDevice;
for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
netDevice = (*i);
Ptr<WimaxNetDevice> wimax = DynamicCast<WimaxNetDevice> (netDevice);
if (wimax)
{
// Handle any random numbers in the PHY objects.
currentStream += wimax->GetPhy ()->AssignStreams (currentStream);
}
}
// Handle any random numbers in the channel.
currentStream += m_channel->AssignStreams (currentStream);
return (currentStream - stream);
}
} // namespace ns3
|
extern printf
extern scanf
section .data
msg db "enter two numbers: ", 0
fmt_in db "%d%d", 0
fmt_out db "maximum: %d", 0
section .text
global start
start:
enter 8, 0
push msg
call printf
add esp, 4
lea eax, [ebp - 4]
lea ebx, [ebp - 8]
push eax
push ebx
push fmt_in
call scanf
add esp, 12
push dword [ebp - 4]
push dword [ebp - 8]
call maximum
add esp, 8
push eax
push fmt_out
call printf
add esp, 8
leave
ret
maximum:
enter 0, 0
mov eax, [ebp + 8]
cmp eax, [ebp + 12]
jg _done
mov eax, [ebp + 12]
leave
ret
_done:
leave
ret
|
TITLE ECE291 Your Name Today's Date
COMMENT % Text Mode BlackJack
ECE291 - Machine Problem 3
Prof. Constantine Polychronopoulos
Guest Author: Alex Jurcik
University of Illinois at Urbana Champaign
Dept. of Electrical & Computer Engineering
Spring 2000
Ver. 1.0
%
;--------------------------------------------------------------
;-- Defining Constants --
;--------------------------------------------------------------
ESCKEY EQU 01
HKEY EQU 35
SKEY EQU 31
ENTER EQU 28
SPACE EQU 39h
public ESCKEY, HKEY, SKEY, ENTER, SPACE
;--------------------------------------------------------------
;-- Declaring External Procedures --
;--------------------------------------------------------------
; Functions in LIB291.LIB These functions are free to
; be used by you. Complete descriptions of the LIB291
; functions can be found in your lab manuals. Use these
; functions for displaying output on the screen.
extrn rsave:near, rrest:near, binasc:near, dspout:near, dspmsg:near
; Functions in LIBMP3.LIB
; You will need to write these functions for this program.
extrn libKbdInstall:near, libKbdUninstall:near, libKbdHandler:near
extrn libDrawBackground:near, libStartGame:near, libDisplayCard:near
extrn libDrawCardFromDeck:near, libCalculateScore:near, libDisplayScore:near
extrn libPlayerTurn:near, libDealerTurn:near, libMP3Main:near
; This function terminates the program.
extrn mp3xit:near
;--------------------------------------------------------------
;-- Defining the Stack Segment --
;--------------------------------------------------------------
stkseg SEGMENT stack
db 64 dup ('STACK ')
stkseg ENDS
;--------------------------------------------------------------
;-- Defining the Code Segment --
;--------------------------------------------------------------
cseg SEGMENT PUBLIC 'CODE'
assume cs:cseg, ds:cseg, ss:stkseg, es:nothing
;--------------------------------------------------------------
;-- Declaring variables for Lib Procedures --
;--------------------------------------------------------------
oldKbdV dd ? ; Address of old Kbd Handler
exitFlag db 0 ; Flag to signify if ESC pressed
randomCard dw ? ; Random card position in array
; (0-51)
cardArray db 52 dup(0) ; Array of cards(1=chosen, 0=not)
playerHand db 5 dup(?) ; Array of cards in the players hand
; indexed 0 - 51
playerCards db 0 ; Number of cards in the player's hand
dealerHand db 5 dup(?) ; Array of cards in the dealers hand
; indexed 0 - 51
dealerCards db 0 ; Number of cards in the dealer's hand
drawCard db 0 ; Flag for if the player wants to "hit"
stayPlayer db 0 ; Flag for if the player wants to "stay"
spaceFlag db 0 ; Flag for a waiting loop
playerScore1 dw 0 ; First player's score
playerScore2 dw 0 ; Second player's score
dealerScore dw 0 ; Dealer's score
scoreBuffer db 7 dup(' '),'$' ; Buffer for BINASC
blackjackString db 'Blackjack','$' ; Various strings to show a game's
winString db 'Win','$' ; outcome
drawString db 'Draw','$'
loseString db 'Lose','$'
blackjackFlag db 0 ; Flag to signify if the player has
; blackjack
include bground.dat ; 2000 byte character array to define our
; wallpaper
public oldKbdV, exitFlag, randomCard, cardArray, playerHand, playerCards
public dealerHand, dealerCards, drawCard, stayPlayer, spaceFlag
public playerScore1, playerScore2, dealerScore, scoreBuffer, blackjackString
public winString, loseString, drawString, blackjackFlag, wallpaper
public KbdInstall, KbdUninstall, DrawBackground
public StartGame, DisplayCard, DrawCardFromDeck
public CalculateScore, DisplayScore, PlayerTurn
public DealerTurn
;--------------------------------------------------------------
;-- Main Procedure --
;--------------------------------------------------------------
MAIN PROC FAR
mov ax, cseg ; Use common code and data segment
mov ds, ax
mov ax, 0B800h ; Use extra segment to access video screen
mov es, ax ;
mov ah, 1 ; Set up the video screen
mov cx, 2000h ;
int 10h ;
call MP3Main ; This is where everything begins
mov ax, 0700h ;
mov cx, 160*25 ; clearing
mov di, 0 ; the
; screen
rep stosw
call mp3xit
MAIN ENDP
;--------------------------------------------------------------
;-- Replace Library Calls with your Code! --
;-- [Save all reg values that you modify] --
;-- Do not forget to add Function Headers --
;--------------------------------------------------------------
;--------------------------------------------------------------
;-- KbdInstall() --
;--------------------------------------------------------------
KbdInstall PROC NEAR
call libKbdInstall
ret
KbdInstall ENDP
;--------------------------------------------------------------
;-- KbdUnInstall() --
;--------------------------------------------------------------
KbdUninstall PROC NEAR
call libKbdUninstall
ret
KbdUninstall ENDP
;--------------------------------------------------------------
;-- KbdHandler() --
;--------------------------------------------------------------
KbdHandler PROC NEAR
KbdHandler ENDP
;--------------------------------------------------------------
;-- DrawBackground() --
;--------------------------------------------------------------
DrawBackground PROC NEAR
call libDrawBackground
ret
DrawBackground ENDP
;--------------------------------------------------------------
;-- StartGame() --
;--------------------------------------------------------------
StartGame PROC NEAR
call libStartGame
ret
StartGame ENDP
;--------------------------------------------------------------
;-- DisplayCard() --
;--------------------------------------------------------------
DisplayCard PROC NEAR
call libDisplayCard
ret
DisplayCard ENDP
;--------------------------------------------------------------
;-- DrawCardFromDeck() --
;--------------------------------------------------------------
DrawCardFromDeck PROC NEAR
call libDrawCardFromDeck
ret
DrawCardFromDeck ENDP
;--------------------------------------------------------------
;-- CalculateScore() --
;--------------------------------------------------------------
CalculateScore PROC NEAR
call libCalculateScore
ret
CalculateScore ENDP
;--------------------------------------------------------------
;-- DisplayScore() --
;--------------------------------------------------------------
DisplayScore PROC NEAR
call libDisplayScore
ret
DisplayScore ENDP
;--------------------------------------------------------------
;-- PlayerTurn() --
;--------------------------------------------------------------
PlayerTurn PROC NEAR
call libPlayerTurn
ret
PlayerTurn ENDP
;--------------------------------------------------------------
;-- DealerTurn() --
;--------------------------------------------------------------
DealerTurn PROC NEAR
call libDealerTurn
ret
DealerTurn ENDP
;--------------------------------------------------------------
;-- MP3Main() --
;--------------------------------------------------------------
MP3Main PROC NEAR
call libMP3Main
ret
MP3Main ENDP
CSEG ENDS
END MAIN
|
; A329997: Beatty sequence for 3^x, where 1/x^3 + 1/3^x = 1.
; 3,6,10,13,17,20,24,27,30,34,37,41,44,48,51,54,58,61,65,68,72,75,78,82,85,89,92,96,99,102,106,109,113,116,120,123,126,130,133,137,140,144,147,150,154,157,161,164,168,171,174,178,181,185,188,192,195,198
add $0,1
mov $1,24
mul $1,$0
div $1,7
|
#include "../Binding_pch.h"
#include <glbinding/gl/functions.h>
namespace gl
{
void glLabelObjectEXT(GLenum type, GLuint object, GLsizei length, const GLchar * label)
{
return glbinding::Binding::LabelObjectEXT(type, object, length, label);
}
void glLGPUCopyImageSubDataNVX(GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth)
{
return glbinding::Binding::LGPUCopyImageSubDataNVX(sourceGpu, destinationGpuMask, srcName, srcTarget, srcLevel, srcX, srxY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, width, height, depth);
}
void glLGPUInterlockNVX()
{
return glbinding::Binding::LGPUInterlockNVX();
}
void glLGPUNamedBufferSubDataNVX(GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void * data)
{
return glbinding::Binding::LGPUNamedBufferSubDataNVX(gpuMask, buffer, offset, size, data);
}
void glLightEnviSGIX(GLenum pname, GLint param)
{
return glbinding::Binding::LightEnviSGIX(pname, param);
}
void glLightf(GLenum light, GLenum pname, GLfloat param)
{
return glbinding::Binding::Lightf(light, pname, param);
}
void glLightfv(GLenum light, GLenum pname, const GLfloat * params)
{
return glbinding::Binding::Lightfv(light, pname, params);
}
void glLighti(GLenum light, GLenum pname, GLint param)
{
return glbinding::Binding::Lighti(light, pname, param);
}
void glLightiv(GLenum light, GLenum pname, const GLint * params)
{
return glbinding::Binding::Lightiv(light, pname, params);
}
void glLightModelf(GLenum pname, GLfloat param)
{
return glbinding::Binding::LightModelf(pname, param);
}
void glLightModelfv(GLenum pname, const GLfloat * params)
{
return glbinding::Binding::LightModelfv(pname, params);
}
void glLightModeli(GLenum pname, GLint param)
{
return glbinding::Binding::LightModeli(pname, param);
}
void glLightModeliv(GLenum pname, const GLint * params)
{
return glbinding::Binding::LightModeliv(pname, params);
}
void glLightModelxOES(GLenum pname, GLfixed param)
{
return glbinding::Binding::LightModelxOES(pname, param);
}
void glLightModelxvOES(GLenum pname, const GLfixed * param)
{
return glbinding::Binding::LightModelxvOES(pname, param);
}
void glLightxOES(GLenum light, GLenum pname, GLfixed param)
{
return glbinding::Binding::LightxOES(light, pname, param);
}
void glLightxvOES(GLenum light, GLenum pname, const GLfixed * params)
{
return glbinding::Binding::LightxvOES(light, pname, params);
}
void glLineStipple(GLint factor, GLushort pattern)
{
return glbinding::Binding::LineStipple(factor, pattern);
}
void glLineWidth(GLfloat width)
{
return glbinding::Binding::LineWidth(width);
}
void glLineWidthxOES(GLfixed width)
{
return glbinding::Binding::LineWidthxOES(width);
}
void glLinkProgram(GLuint program)
{
return glbinding::Binding::LinkProgram(program);
}
void glLinkProgramARB(GLhandleARB programObj)
{
return glbinding::Binding::LinkProgramARB(programObj);
}
void glListBase(GLuint base)
{
return glbinding::Binding::ListBase(base);
}
void glListDrawCommandsStatesClientNV(GLuint list, GLuint segment, const void ** indirects, const GLsizei * sizes, const GLuint * states, const GLuint * fbos, GLuint count)
{
return glbinding::Binding::ListDrawCommandsStatesClientNV(list, segment, indirects, sizes, states, fbos, count);
}
void glListParameterfSGIX(GLuint list, GLenum pname, GLfloat param)
{
return glbinding::Binding::ListParameterfSGIX(list, pname, param);
}
void glListParameterfvSGIX(GLuint list, GLenum pname, const GLfloat * params)
{
return glbinding::Binding::ListParameterfvSGIX(list, pname, params);
}
void glListParameteriSGIX(GLuint list, GLenum pname, GLint param)
{
return glbinding::Binding::ListParameteriSGIX(list, pname, param);
}
void glListParameterivSGIX(GLuint list, GLenum pname, const GLint * params)
{
return glbinding::Binding::ListParameterivSGIX(list, pname, params);
}
void glLoadIdentity()
{
return glbinding::Binding::LoadIdentity();
}
void glLoadIdentityDeformationMapSGIX(FfdMaskSGIX mask)
{
return glbinding::Binding::LoadIdentityDeformationMapSGIX(mask);
}
void glLoadMatrixd(const GLdouble * m)
{
return glbinding::Binding::LoadMatrixd(m);
}
void glLoadMatrixf(const GLfloat * m)
{
return glbinding::Binding::LoadMatrixf(m);
}
void glLoadMatrixxOES(const GLfixed * m)
{
return glbinding::Binding::LoadMatrixxOES(m);
}
void glLoadName(GLuint name)
{
return glbinding::Binding::LoadName(name);
}
void glLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte * program)
{
return glbinding::Binding::LoadProgramNV(target, id, len, program);
}
void glLoadTransposeMatrixd(const GLdouble * m)
{
return glbinding::Binding::LoadTransposeMatrixd(m);
}
void glLoadTransposeMatrixdARB(const GLdouble * m)
{
return glbinding::Binding::LoadTransposeMatrixdARB(m);
}
void glLoadTransposeMatrixf(const GLfloat * m)
{
return glbinding::Binding::LoadTransposeMatrixf(m);
}
void glLoadTransposeMatrixfARB(const GLfloat * m)
{
return glbinding::Binding::LoadTransposeMatrixfARB(m);
}
void glLoadTransposeMatrixxOES(const GLfixed * m)
{
return glbinding::Binding::LoadTransposeMatrixxOES(m);
}
void glLockArraysEXT(GLint first, GLsizei count)
{
return glbinding::Binding::LockArraysEXT(first, count);
}
void glLogicOp(GLenum opcode)
{
return glbinding::Binding::LogicOp(opcode);
}
} // namespace gl |
/******************************************************************************
** Filename: intmatcher.c
** Purpose: Generic high level classification routines.
** Author: Robert Moss
** History: Wed Feb 13 17:35:28 MST 1991, RWM, Created.
** Mon Mar 11 16:33:02 MST 1991, RWM, Modified to add
** support for adaptive matching.
** (c) Copyright Hewlett-Packard Company, 1988.
** 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 automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
/*----------------------------------------------------------------------------
Include Files and Type Defines
----------------------------------------------------------------------------*/
#include "intmatcher.h"
#include "fontinfo.h"
#include "intproto.h"
#include "callcpp.h"
#include "scrollview.h"
#include "float2int.h"
#include "globals.h"
#include "helpers.h"
#include "classify.h"
#include "shapetable.h"
#include <math.h>
using tesseract::ScoredFont;
using tesseract::UnicharRating;
/*----------------------------------------------------------------------------
Global Data Definitions and Declarations
----------------------------------------------------------------------------*/
// Parameters of the sigmoid used to convert similarity to evidence in the
// similarity_evidence_table_ that is used to convert distance metric to an
// 8 bit evidence value in the secondary matcher. (See IntMatcher::Init).
const float IntegerMatcher::kSEExponentialMultiplier = 0.0;
const float IntegerMatcher::kSimilarityCenter = 0.0075;
#define offset_table_entries \
255, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \
0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, \
0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, \
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \
0, 1, 0, 2, 0, 1, 0, 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, \
0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, \
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \
0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
#define INTMATCHER_OFFSET_TABLE_SIZE 256
#define next_table_entries \
0, 0, 0, 0x2, 0, 0x4, 0x4, 0x6, 0, 0x8, 0x8, 0x0a, 0x08, 0x0c, 0x0c, 0x0e, \
0, 0x10, 0x10, 0x12, 0x10, 0x14, 0x14, 0x16, 0x10, 0x18, 0x18, 0x1a, \
0x18, 0x1c, 0x1c, 0x1e, 0, 0x20, 0x20, 0x22, 0x20, 0x24, 0x24, 0x26, \
0x20, 0x28, 0x28, 0x2a, 0x28, 0x2c, 0x2c, 0x2e, 0x20, 0x30, 0x30, 0x32, \
0x30, 0x34, 0x34, 0x36, 0x30, 0x38, 0x38, 0x3a, 0x38, 0x3c, 0x3c, 0x3e, \
0, 0x40, 0x40, 0x42, 0x40, 0x44, 0x44, 0x46, 0x40, 0x48, 0x48, 0x4a, \
0x48, 0x4c, 0x4c, 0x4e, 0x40, 0x50, 0x50, 0x52, 0x50, 0x54, 0x54, 0x56, \
0x50, 0x58, 0x58, 0x5a, 0x58, 0x5c, 0x5c, 0x5e, 0x40, 0x60, 0x60, 0x62, \
0x60, 0x64, 0x64, 0x66, 0x60, 0x68, 0x68, 0x6a, 0x68, 0x6c, 0x6c, 0x6e, \
0x60, 0x70, 0x70, 0x72, 0x70, 0x74, 0x74, 0x76, 0x70, 0x78, 0x78, 0x7a, \
0x78, 0x7c, 0x7c, 0x7e, 0, 0x80, 0x80, 0x82, 0x80, 0x84, 0x84, 0x86, \
0x80, 0x88, 0x88, 0x8a, 0x88, 0x8c, 0x8c, 0x8e, 0x80, 0x90, 0x90, 0x92, \
0x90, 0x94, 0x94, 0x96, 0x90, 0x98, 0x98, 0x9a, 0x98, 0x9c, 0x9c, 0x9e, \
0x80, 0xa0, 0xa0, 0xa2, 0xa0, 0xa4, 0xa4, 0xa6, 0xa0, 0xa8, 0xa8, 0xaa, \
0xa8, 0xac, 0xac, 0xae, 0xa0, 0xb0, 0xb0, 0xb2, 0xb0, 0xb4, 0xb4, 0xb6, \
0xb0, 0xb8, 0xb8, 0xba, 0xb8, 0xbc, 0xbc, 0xbe, 0x80, 0xc0, 0xc0, 0xc2, \
0xc0, 0xc4, 0xc4, 0xc6, 0xc0, 0xc8, 0xc8, 0xca, 0xc8, 0xcc, 0xcc, 0xce, \
0xc0, 0xd0, 0xd0, 0xd2, 0xd0, 0xd4, 0xd4, 0xd6, 0xd0, 0xd8, 0xd8, 0xda, \
0xd8, 0xdc, 0xdc, 0xde, 0xc0, 0xe0, 0xe0, 0xe2, 0xe0, 0xe4, 0xe4, 0xe6, \
0xe0, 0xe8, 0xe8, 0xea, 0xe8, 0xec, 0xec, 0xee, 0xe0, 0xf0, 0xf0, 0xf2, \
0xf0, 0xf4, 0xf4, 0xf6, 0xf0, 0xf8, 0xf8, 0xfa, 0xf8, 0xfc, 0xfc, 0xfe
// See http://b/19318793 (#6) for a complete discussion. Merging arrays
// offset_table and next_table helps improve performance of PIE code.
static const uinT8 data_table[512] = {offset_table_entries, next_table_entries};
static const uinT8* const offset_table = &data_table[0];
static const uinT8* const next_table =
&data_table[INTMATCHER_OFFSET_TABLE_SIZE];
namespace tesseract {
// Encapsulation of the intermediate data and computations made by the class
// pruner. The class pruner implements a simple linear classifier on binary
// features by heavily quantizing the feature space, and applying
// NUM_BITS_PER_CLASS (2)-bit weights to the features. Lack of resolution in
// weights is compensated by a non-constant bias that is dependent on the
// number of features present.
class ClassPruner {
public:
ClassPruner(int max_classes) {
// The unrolled loop in ComputeScores means that the array sizes need to
// be rounded up so that the array is big enough to accommodate the extra
// entries accessed by the unrolling. Each pruner word is of sized
// BITS_PER_WERD and each entry is NUM_BITS_PER_CLASS, so there are
// BITS_PER_WERD / NUM_BITS_PER_CLASS entries.
// See ComputeScores.
max_classes_ = max_classes;
rounded_classes_ = RoundUp(
max_classes, WERDS_PER_CP_VECTOR * BITS_PER_WERD / NUM_BITS_PER_CLASS);
class_count_ = new int[rounded_classes_];
norm_count_ = new int[rounded_classes_];
sort_key_ = new int[rounded_classes_ + 1];
sort_index_ = new int[rounded_classes_ + 1];
for (int i = 0; i < rounded_classes_; i++) {
class_count_[i] = 0;
}
pruning_threshold_ = 0;
num_features_ = 0;
num_classes_ = 0;
}
~ClassPruner() {
delete []class_count_;
delete []norm_count_;
delete []sort_key_;
delete []sort_index_;
}
/// Computes the scores for every class in the character set, by summing the
/// weights for each feature and stores the sums internally in class_count_.
void ComputeScores(const INT_TEMPLATES_STRUCT* int_templates,
int num_features, const INT_FEATURE_STRUCT* features) {
num_features_ = num_features;
int num_pruners = int_templates->NumClassPruners;
for (int f = 0; f < num_features; ++f) {
const INT_FEATURE_STRUCT* feature = &features[f];
// Quantize the feature to NUM_CP_BUCKETS*NUM_CP_BUCKETS*NUM_CP_BUCKETS.
int x = feature->X * NUM_CP_BUCKETS >> 8;
int y = feature->Y * NUM_CP_BUCKETS >> 8;
int theta = feature->Theta * NUM_CP_BUCKETS >> 8;
int class_id = 0;
// Each CLASS_PRUNER_STRUCT only covers CLASSES_PER_CP(32) classes, so
// we need a collection of them, indexed by pruner_set.
for (int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
// Look up quantized feature in a 3-D array, an array of weights for
// each class.
const uinT32* pruner_word_ptr =
int_templates->ClassPruners[pruner_set]->p[x][y][theta];
for (int word = 0; word < WERDS_PER_CP_VECTOR; ++word) {
uinT32 pruner_word = *pruner_word_ptr++;
// This inner loop is unrolled to speed up the ClassPruner.
// Currently gcc would not unroll it unless it is set to O3
// level of optimization or -funroll-loops is specified.
/*
uinT32 class_mask = (1 << NUM_BITS_PER_CLASS) - 1;
for (int bit = 0; bit < BITS_PER_WERD/NUM_BITS_PER_CLASS; bit++) {
class_count_[class_id++] += pruner_word & class_mask;
pruner_word >>= NUM_BITS_PER_CLASS;
}
*/
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
pruner_word >>= NUM_BITS_PER_CLASS;
class_count_[class_id++] += pruner_word & CLASS_PRUNER_CLASS_MASK;
}
}
}
}
/// Adjusts the scores according to the number of expected features. Used
/// in lieu of a constant bias, this penalizes classes that expect more
/// features than there are present. Thus an actual c will score higher for c
/// than e, even though almost all the features match e as well as c, because
/// e expects more features to be present.
void AdjustForExpectedNumFeatures(const uinT16* expected_num_features,
int cutoff_strength) {
for (int class_id = 0; class_id < max_classes_; ++class_id) {
if (num_features_ < expected_num_features[class_id]) {
int deficit = expected_num_features[class_id] - num_features_;
class_count_[class_id] -= class_count_[class_id] * deficit /
(num_features_ * cutoff_strength + deficit);
}
}
}
/// Zeros the scores for classes disabled in the unicharset.
/// Implements the black-list to recognize a subset of the character set.
void DisableDisabledClasses(const UNICHARSET& unicharset) {
for (int class_id = 0; class_id < max_classes_; ++class_id) {
if (!unicharset.get_enabled(class_id))
class_count_[class_id] = 0; // This char is disabled!
}
}
/** Zeros the scores of fragments. */
void DisableFragments(const UNICHARSET& unicharset) {
for (int class_id = 0; class_id < max_classes_; ++class_id) {
// Do not include character fragments in the class pruner
// results if disable_character_fragments is true.
if (unicharset.get_fragment(class_id)) {
class_count_[class_id] = 0;
}
}
}
/// Normalizes the counts for xheight, putting the normalized result in
/// norm_count_. Applies a simple subtractive penalty for incorrect vertical
/// position provided by the normalization_factors array, indexed by
/// character class, and scaled by the norm_multiplier.
void NormalizeForXheight(int norm_multiplier,
const uinT8* normalization_factors) {
for (int class_id = 0; class_id < max_classes_; class_id++) {
norm_count_[class_id] = class_count_[class_id] -
((norm_multiplier * normalization_factors[class_id]) >> 8);
}
}
/** The nop normalization copies the class_count_ array to norm_count_. */
void NoNormalization() {
for (int class_id = 0; class_id < max_classes_; class_id++) {
norm_count_[class_id] = class_count_[class_id];
}
}
/// Prunes the classes using <the maximum count> * pruning_factor/256 as a
/// threshold for keeping classes. If max_of_non_fragments, then ignore
/// fragments in computing the maximum count.
void PruneAndSort(int pruning_factor, int keep_this,
bool max_of_non_fragments, const UNICHARSET& unicharset) {
int max_count = 0;
for (int c = 0; c < max_classes_; ++c) {
if (norm_count_[c] > max_count &&
// This additional check is added in order to ensure that
// the classifier will return at least one non-fragmented
// character match.
// TODO(daria): verify that this helps accuracy and does not
// hurt performance.
(!max_of_non_fragments || !unicharset.get_fragment(c))) {
max_count = norm_count_[c];
}
}
// Prune Classes.
pruning_threshold_ = (max_count * pruning_factor) >> 8;
// Select Classes.
if (pruning_threshold_ < 1)
pruning_threshold_ = 1;
num_classes_ = 0;
for (int class_id = 0; class_id < max_classes_; class_id++) {
if (norm_count_[class_id] >= pruning_threshold_ ||
class_id == keep_this) {
++num_classes_;
sort_index_[num_classes_] = class_id;
sort_key_[num_classes_] = norm_count_[class_id];
}
}
// Sort Classes using Heapsort Algorithm.
if (num_classes_ > 1)
HeapSort(num_classes_, sort_key_, sort_index_);
}
/** Prints debug info on the class pruner matches for the pruned classes only.
*/
void DebugMatch(const Classify& classify,
const INT_TEMPLATES_STRUCT* int_templates,
const INT_FEATURE_STRUCT* features) const {
int num_pruners = int_templates->NumClassPruners;
int max_num_classes = int_templates->NumClasses;
for (int f = 0; f < num_features_; ++f) {
const INT_FEATURE_STRUCT* feature = &features[f];
tprintf("F=%3d(%d,%d,%d),", f, feature->X, feature->Y, feature->Theta);
// Quantize the feature to NUM_CP_BUCKETS*NUM_CP_BUCKETS*NUM_CP_BUCKETS.
int x = feature->X * NUM_CP_BUCKETS >> 8;
int y = feature->Y * NUM_CP_BUCKETS >> 8;
int theta = feature->Theta * NUM_CP_BUCKETS >> 8;
int class_id = 0;
for (int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
// Look up quantized feature in a 3-D array, an array of weights for
// each class.
const uinT32* pruner_word_ptr =
int_templates->ClassPruners[pruner_set]->p[x][y][theta];
for (int word = 0; word < WERDS_PER_CP_VECTOR; ++word) {
uinT32 pruner_word = *pruner_word_ptr++;
for (int word_class = 0; word_class < 16 &&
class_id < max_num_classes; ++word_class, ++class_id) {
if (norm_count_[class_id] >= pruning_threshold_) {
tprintf(" %s=%d,",
classify.ClassIDToDebugStr(int_templates,
class_id, 0).string(),
pruner_word & CLASS_PRUNER_CLASS_MASK);
}
pruner_word >>= NUM_BITS_PER_CLASS;
}
}
tprintf("\n");
}
}
}
/** Prints a summary of the pruner result. */
void SummarizeResult(const Classify& classify,
const INT_TEMPLATES_STRUCT* int_templates,
const uinT16* expected_num_features,
int norm_multiplier,
const uinT8* normalization_factors) const {
tprintf("CP:%d classes, %d features:\n", num_classes_, num_features_);
for (int i = 0; i < num_classes_; ++i) {
int class_id = sort_index_[num_classes_ - i];
STRING class_string = classify.ClassIDToDebugStr(int_templates,
class_id, 0);
tprintf("%s:Initial=%d, E=%d, Xht-adj=%d, N=%d, Rat=%.2f\n",
class_string.string(),
class_count_[class_id],
expected_num_features[class_id],
(norm_multiplier * normalization_factors[class_id]) >> 8,
sort_key_[num_classes_ - i],
100.0 - 100.0 * sort_key_[num_classes_ - i] /
(CLASS_PRUNER_CLASS_MASK * num_features_));
}
}
/// Copies the pruned, sorted classes into the output results and returns
/// the number of classes.
int SetupResults(GenericVector<CP_RESULT_STRUCT>* results) const {
CP_RESULT_STRUCT empty;
results->init_to_size(num_classes_, empty);
for (int c = 0; c < num_classes_; ++c) {
(*results)[c].Class = sort_index_[num_classes_ - c];
(*results)[c].Rating = 1.0 - sort_key_[num_classes_ - c] /
(static_cast<float>(CLASS_PRUNER_CLASS_MASK) * num_features_);
}
return num_classes_;
}
private:
/** Array[rounded_classes_] of initial counts for each class. */
int *class_count_;
/// Array[rounded_classes_] of modified counts for each class after
/// normalizing for expected number of features, disabled classes, fragments,
/// and xheights.
int *norm_count_;
/** Array[rounded_classes_ +1] of pruned counts that gets sorted */
int *sort_key_;
/** Array[rounded_classes_ +1] of classes corresponding to sort_key_. */
int *sort_index_;
/** Number of classes in this class pruner. */
int max_classes_;
/** Rounded up number of classes used for array sizes. */
int rounded_classes_;
/** Threshold count applied to prune classes. */
int pruning_threshold_;
/** The number of features used to compute the scores. */
int num_features_;
/** Final number of pruned classes. */
int num_classes_;
};
/*----------------------------------------------------------------------------
Public Code
----------------------------------------------------------------------------*/
/**
* Runs the class pruner from int_templates on the given features, returning
* the number of classes output in results.
* @param int_templates Class pruner tables
* @param num_features Number of features in blob
* @param features Array of features
* @param normalization_factors Array of fudge factors from blob
* normalization process (by CLASS_INDEX)
* @param expected_num_features Array of expected number of features
* for each class (by CLASS_INDEX)
* @param results Sorted Array of pruned classes. Must be an
* array of size at least
* int_templates->NumClasses.
* @param keep_this
*/
int Classify::PruneClasses(const INT_TEMPLATES_STRUCT* int_templates,
int num_features, int keep_this,
const INT_FEATURE_STRUCT* features,
const uinT8* normalization_factors,
const uinT16* expected_num_features,
GenericVector<CP_RESULT_STRUCT>* results) {
ClassPruner pruner(int_templates->NumClasses);
// Compute initial match scores for all classes.
pruner.ComputeScores(int_templates, num_features, features);
// Adjust match scores for number of expected features.
pruner.AdjustForExpectedNumFeatures(expected_num_features,
classify_cp_cutoff_strength);
// Apply disabled classes in unicharset - only works without a shape_table.
if (shape_table_ == NULL)
pruner.DisableDisabledClasses(unicharset);
// If fragments are disabled, remove them, also only without a shape table.
if (disable_character_fragments && shape_table_ == NULL)
pruner.DisableFragments(unicharset);
// If we have good x-heights, apply the given normalization factors.
if (normalization_factors != NULL) {
pruner.NormalizeForXheight(classify_class_pruner_multiplier,
normalization_factors);
} else {
pruner.NoNormalization();
}
// Do the actual pruning and sort the short-list.
pruner.PruneAndSort(classify_class_pruner_threshold, keep_this,
shape_table_ == NULL, unicharset);
if (classify_debug_level > 2) {
pruner.DebugMatch(*this, int_templates, features);
}
if (classify_debug_level > 1) {
pruner.SummarizeResult(*this, int_templates, expected_num_features,
classify_class_pruner_multiplier,
normalization_factors);
}
// Convert to the expected output format.
return pruner.SetupResults(results);
}
} // namespace tesseract
/**
* IntegerMatcher returns the best configuration and rating
* for a single class. The class matched against is determined
* by the uniqueness of the ClassTemplate parameter. The
* best rating and its associated configuration are returned.
*
* Globals:
* - local_matcher_multiplier_ Normalization factor multiplier
* param ClassTemplate Prototypes & tables for a class
* param BlobLength Length of unormalized blob
* param NumFeatures Number of features in blob
* param Features Array of features
* param NormalizationFactor Fudge factor from blob normalization process
* param Result Class rating & configuration: (0.0 -> 1.0), 0=bad, 1=good
* param Debug Debugger flag: 1=debugger on
* @return none
* @note Exceptions: none
* @note History: Tue Feb 19 16:36:23 MST 1991, RWM, Created.
*/
void IntegerMatcher::Match(INT_CLASS ClassTemplate,
BIT_VECTOR ProtoMask,
BIT_VECTOR ConfigMask,
inT16 NumFeatures,
const INT_FEATURE_STRUCT* Features,
UnicharRating* Result,
int AdaptFeatureThreshold,
int Debug,
bool SeparateDebugWindows) {
ScratchEvidence *tables = new ScratchEvidence();
int Feature;
int BestMatch;
if (MatchDebuggingOn (Debug))
cprintf ("Integer Matcher -------------------------------------------\n");
tables->Clear(ClassTemplate);
Result->feature_misses = 0;
for (Feature = 0; Feature < NumFeatures; Feature++) {
int csum = UpdateTablesForFeature(ClassTemplate, ProtoMask, ConfigMask,
Feature, &Features[Feature],
tables, Debug);
// Count features that were missed over all configs.
if (csum == 0)
++Result->feature_misses;
}
#ifndef GRAPHICS_DISABLED
if (PrintProtoMatchesOn(Debug) || PrintMatchSummaryOn(Debug)) {
DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
NumFeatures, Debug);
}
if (DisplayProtoMatchesOn(Debug)) {
DisplayProtoDebugInfo(ClassTemplate, ProtoMask, ConfigMask,
*tables, SeparateDebugWindows);
}
if (DisplayFeatureMatchesOn(Debug)) {
DisplayFeatureDebugInfo(ClassTemplate, ProtoMask, ConfigMask, NumFeatures,
Features, AdaptFeatureThreshold, Debug,
SeparateDebugWindows);
}
#endif
tables->UpdateSumOfProtoEvidences(ClassTemplate, ConfigMask, NumFeatures);
tables->NormalizeSums(ClassTemplate, NumFeatures, NumFeatures);
BestMatch = FindBestMatch(ClassTemplate, *tables, Result);
#ifndef GRAPHICS_DISABLED
if (PrintMatchSummaryOn(Debug))
Result->Print();
if (MatchDebuggingOn(Debug))
cprintf("Match Complete --------------------------------------------\n");
#endif
delete tables;
}
/**
* FindGoodProtos finds all protos whose normalized proto-evidence
* exceed classify_adapt_proto_thresh. The list is ordered by increasing
* proto id number.
*
* Globals:
* - local_matcher_multiplier_ Normalization factor multiplier
* param ClassTemplate Prototypes & tables for a class
* param ProtoMask AND Mask for proto word
* param ConfigMask AND Mask for config word
* param BlobLength Length of unormalized blob
* param NumFeatures Number of features in blob
* param Features Array of features
* param ProtoArray Array of good protos
* param AdaptProtoThreshold Threshold for good protos
* param Debug Debugger flag: 1=debugger on
* @return Number of good protos in ProtoArray.
* @note Exceptions: none
* @note History: Tue Mar 12 17:09:26 MST 1991, RWM, Created
*/
int IntegerMatcher::FindGoodProtos(
INT_CLASS ClassTemplate,
BIT_VECTOR ProtoMask,
BIT_VECTOR ConfigMask,
uinT16 BlobLength,
inT16 NumFeatures,
INT_FEATURE_ARRAY Features,
PROTO_ID *ProtoArray,
int AdaptProtoThreshold,
int Debug) {
ScratchEvidence *tables = new ScratchEvidence();
int NumGoodProtos = 0;
/* DEBUG opening heading */
if (MatchDebuggingOn (Debug))
cprintf
("Find Good Protos -------------------------------------------\n");
tables->Clear(ClassTemplate);
for (int Feature = 0; Feature < NumFeatures; Feature++)
UpdateTablesForFeature(
ClassTemplate, ProtoMask, ConfigMask, Feature, &(Features[Feature]),
tables, Debug);
#ifndef GRAPHICS_DISABLED
if (PrintProtoMatchesOn (Debug) || PrintMatchSummaryOn (Debug))
DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
NumFeatures, Debug);
#endif
/* Average Proto Evidences & Find Good Protos */
for (int proto = 0; proto < ClassTemplate->NumProtos; proto++) {
/* Compute Average for Actual Proto */
int Temp = 0;
for (int i = 0; i < ClassTemplate->ProtoLengths[proto]; i++)
Temp += tables->proto_evidence_[proto][i];
Temp /= ClassTemplate->ProtoLengths[proto];
/* Find Good Protos */
if (Temp >= AdaptProtoThreshold) {
*ProtoArray = proto;
ProtoArray++;
NumGoodProtos++;
}
}
if (MatchDebuggingOn (Debug))
cprintf ("Match Complete --------------------------------------------\n");
delete tables;
return NumGoodProtos;
}
/**
* FindBadFeatures finds all features with maximum feature-evidence <
* AdaptFeatureThresh. The list is ordered by increasing feature number.
* @param ClassTemplate Prototypes & tables for a class
* @param ProtoMask AND Mask for proto word
* @param ConfigMask AND Mask for config word
* @param BlobLength Length of unormalized blob
* @param NumFeatures Number of features in blob
* @param Features Array of features
* @param FeatureArray Array of bad features
* @param AdaptFeatureThreshold Threshold for bad features
* @param Debug Debugger flag: 1=debugger on
* @return Number of bad features in FeatureArray.
* @note History: Tue Mar 12 17:09:26 MST 1991, RWM, Created
*/
int IntegerMatcher::FindBadFeatures(
INT_CLASS ClassTemplate,
BIT_VECTOR ProtoMask,
BIT_VECTOR ConfigMask,
uinT16 BlobLength,
inT16 NumFeatures,
INT_FEATURE_ARRAY Features,
FEATURE_ID *FeatureArray,
int AdaptFeatureThreshold,
int Debug) {
ScratchEvidence *tables = new ScratchEvidence();
int NumBadFeatures = 0;
/* DEBUG opening heading */
if (MatchDebuggingOn(Debug))
cprintf("Find Bad Features -------------------------------------------\n");
tables->Clear(ClassTemplate);
for (int Feature = 0; Feature < NumFeatures; Feature++) {
UpdateTablesForFeature(
ClassTemplate, ProtoMask, ConfigMask, Feature, &Features[Feature],
tables, Debug);
/* Find Best Evidence for Current Feature */
int best = 0;
for (int i = 0; i < ClassTemplate->NumConfigs; i++)
if (tables->feature_evidence_[i] > best)
best = tables->feature_evidence_[i];
/* Find Bad Features */
if (best < AdaptFeatureThreshold) {
*FeatureArray = Feature;
FeatureArray++;
NumBadFeatures++;
}
}
#ifndef GRAPHICS_DISABLED
if (PrintProtoMatchesOn(Debug) || PrintMatchSummaryOn(Debug))
DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
NumFeatures, Debug);
#endif
if (MatchDebuggingOn(Debug))
cprintf("Match Complete --------------------------------------------\n");
delete tables;
return NumBadFeatures;
}
void IntegerMatcher::Init(tesseract::IntParam *classify_debug_level) {
classify_debug_level_ = classify_debug_level;
/* Initialize table for evidence to similarity lookup */
for (int i = 0; i < SE_TABLE_SIZE; i++) {
uinT32 IntSimilarity = i << (27 - SE_TABLE_BITS);
double Similarity = ((double) IntSimilarity) / 65536.0 / 65536.0;
double evidence = Similarity / kSimilarityCenter;
evidence = 255.0 / (evidence * evidence + 1.0);
if (kSEExponentialMultiplier > 0.0) {
double scale = 1.0 - exp(-kSEExponentialMultiplier) *
exp(kSEExponentialMultiplier * ((double) i / SE_TABLE_SIZE));
evidence *= ClipToRange(scale, 0.0, 1.0);
}
similarity_evidence_table_[i] = (uinT8) (evidence + 0.5);
}
/* Initialize evidence computation variables */
evidence_table_mask_ =
((1 << kEvidenceTableBits) - 1) << (9 - kEvidenceTableBits);
mult_trunc_shift_bits_ = (14 - kIntEvidenceTruncBits);
table_trunc_shift_bits_ = (27 - SE_TABLE_BITS - (mult_trunc_shift_bits_ << 1));
evidence_mult_mask_ = ((1 << kIntEvidenceTruncBits) - 1);
}
/*----------------------------------------------------------------------------
Private Code
----------------------------------------------------------------------------*/
void ScratchEvidence::Clear(const INT_CLASS class_template) {
memset(sum_feature_evidence_, 0,
class_template->NumConfigs * sizeof(sum_feature_evidence_[0]));
memset(proto_evidence_, 0,
class_template->NumProtos * sizeof(proto_evidence_[0]));
}
void ScratchEvidence::ClearFeatureEvidence(const INT_CLASS class_template) {
memset(feature_evidence_, 0,
class_template->NumConfigs * sizeof(feature_evidence_[0]));
}
/**
* Print debugging information for Configuations
* @return none
* @note Exceptions: none
* @note History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
*/
void IMDebugConfiguration(int FeatureNum,
uinT16 ActualProtoNum,
uinT8 Evidence,
BIT_VECTOR ConfigMask,
uinT32 ConfigWord) {
cprintf ("F = %3d, P = %3d, E = %3d, Configs = ",
FeatureNum, (int) ActualProtoNum, (int) Evidence);
while (ConfigWord) {
if (ConfigWord & 1)
cprintf ("1");
else
cprintf ("0");
ConfigWord >>= 1;
}
cprintf ("\n");
}
/**
* Print debugging information for Configuations
* @return none
* @note Exceptions: none
* @note History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
*/
void IMDebugConfigurationSum(int FeatureNum,
uinT8 *FeatureEvidence,
inT32 ConfigCount) {
cprintf("F=%3d, C=", FeatureNum);
for (int ConfigNum = 0; ConfigNum < ConfigCount; ConfigNum++) {
cprintf("%4d", FeatureEvidence[ConfigNum]);
}
cprintf("\n");
}
/**
* For the given feature: prune protos, compute evidence,
* update Feature Evidence, Proto Evidence, and Sum of Feature
* Evidence tables.
* @param ClassTemplate Prototypes & tables for a class
* @param FeatureNum Current feature number (for DEBUG only)
* @param Feature Pointer to a feature struct
* @param tables Evidence tables
* @param Debug Debugger flag: 1=debugger on
* @return none
*/
int IntegerMatcher::UpdateTablesForFeature(
INT_CLASS ClassTemplate,
BIT_VECTOR ProtoMask,
BIT_VECTOR ConfigMask,
int FeatureNum,
const INT_FEATURE_STRUCT* Feature,
ScratchEvidence *tables,
int Debug) {
uinT32 ConfigWord;
uinT32 ProtoWord;
uinT32 ProtoNum;
uinT32 ActualProtoNum;
uinT8 proto_byte;
inT32 proto_word_offset;
inT32 proto_offset;
uinT8 config_byte;
inT32 config_offset;
PROTO_SET ProtoSet;
uinT32 *ProtoPrunerPtr;
INT_PROTO Proto;
int ProtoSetIndex;
uinT8 Evidence;
uinT32 XFeatureAddress;
uinT32 YFeatureAddress;
uinT32 ThetaFeatureAddress;
uinT8* UINT8Pointer;
int ProtoIndex;
uinT8 Temp;
int* IntPointer;
int ConfigNum;
inT32 M3;
inT32 A3;
uinT32 A4;
tables->ClearFeatureEvidence(ClassTemplate);
/* Precompute Feature Address offset for Proto Pruning */
XFeatureAddress = ((Feature->X >> 2) << 1);
YFeatureAddress = (NUM_PP_BUCKETS << 1) + ((Feature->Y >> 2) << 1);
ThetaFeatureAddress = (NUM_PP_BUCKETS << 2) + ((Feature->Theta >> 2) << 1);
for (ProtoSetIndex = 0, ActualProtoNum = 0;
ProtoSetIndex < ClassTemplate->NumProtoSets; ProtoSetIndex++) {
ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex];
ProtoPrunerPtr = (uinT32 *) ((*ProtoSet).ProtoPruner);
for (ProtoNum = 0; ProtoNum < PROTOS_PER_PROTO_SET;
ProtoNum += (PROTOS_PER_PROTO_SET >> 1), ActualProtoNum +=
(PROTOS_PER_PROTO_SET >> 1), ProtoMask++, ProtoPrunerPtr++) {
/* Prune Protos of current Proto Set */
ProtoWord = *(ProtoPrunerPtr + XFeatureAddress);
ProtoWord &= *(ProtoPrunerPtr + YFeatureAddress);
ProtoWord &= *(ProtoPrunerPtr + ThetaFeatureAddress);
ProtoWord &= *ProtoMask;
if (ProtoWord != 0) {
proto_byte = ProtoWord & 0xff;
ProtoWord >>= 8;
proto_word_offset = 0;
while (ProtoWord != 0 || proto_byte != 0) {
while (proto_byte == 0) {
proto_byte = ProtoWord & 0xff;
ProtoWord >>= 8;
proto_word_offset += 8;
}
proto_offset = offset_table[proto_byte] + proto_word_offset;
proto_byte = next_table[proto_byte];
Proto = &(ProtoSet->Protos[ProtoNum + proto_offset]);
ConfigWord = Proto->Configs[0];
A3 = (((Proto->A * (Feature->X - 128)) << 1)
- (Proto->B * (Feature->Y - 128)) + (Proto->C << 9));
M3 =
(((inT8) (Feature->Theta - Proto->Angle)) * kIntThetaFudge) << 1;
if (A3 < 0)
A3 = ~A3;
if (M3 < 0)
M3 = ~M3;
A3 >>= mult_trunc_shift_bits_;
M3 >>= mult_trunc_shift_bits_;
if (A3 > evidence_mult_mask_)
A3 = evidence_mult_mask_;
if (M3 > evidence_mult_mask_)
M3 = evidence_mult_mask_;
A4 = (A3 * A3) + (M3 * M3);
A4 >>= table_trunc_shift_bits_;
if (A4 > evidence_table_mask_)
Evidence = 0;
else
Evidence = similarity_evidence_table_[A4];
if (PrintFeatureMatchesOn (Debug))
IMDebugConfiguration (FeatureNum,
ActualProtoNum + proto_offset,
Evidence, ConfigMask, ConfigWord);
ConfigWord &= *ConfigMask;
UINT8Pointer = tables->feature_evidence_ - 8;
config_byte = 0;
while (ConfigWord != 0 || config_byte != 0) {
while (config_byte == 0) {
config_byte = ConfigWord & 0xff;
ConfigWord >>= 8;
UINT8Pointer += 8;
}
config_offset = offset_table[config_byte];
config_byte = next_table[config_byte];
if (Evidence > UINT8Pointer[config_offset])
UINT8Pointer[config_offset] = Evidence;
}
UINT8Pointer =
&(tables->proto_evidence_[ActualProtoNum + proto_offset][0]);
for (ProtoIndex =
ClassTemplate->ProtoLengths[ActualProtoNum + proto_offset];
ProtoIndex > 0; ProtoIndex--, UINT8Pointer++) {
if (Evidence > *UINT8Pointer) {
Temp = *UINT8Pointer;
*UINT8Pointer = Evidence;
Evidence = Temp;
}
else if (Evidence == 0)
break;
}
}
}
}
}
if (PrintFeatureMatchesOn(Debug)) {
IMDebugConfigurationSum(FeatureNum, tables->feature_evidence_,
ClassTemplate->NumConfigs);
}
IntPointer = tables->sum_feature_evidence_;
UINT8Pointer = tables->feature_evidence_;
int SumOverConfigs = 0;
for (ConfigNum = ClassTemplate->NumConfigs; ConfigNum > 0; ConfigNum--) {
int evidence = *UINT8Pointer++;
SumOverConfigs += evidence;
*IntPointer++ += evidence;
}
return SumOverConfigs;
}
/**
* Print debugging information for Configuations
* @return none
* @note Exceptions: none
* @note History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
*/
#ifndef GRAPHICS_DISABLED
void IntegerMatcher::DebugFeatureProtoError(
INT_CLASS ClassTemplate,
BIT_VECTOR ProtoMask,
BIT_VECTOR ConfigMask,
const ScratchEvidence& tables,
inT16 NumFeatures,
int Debug) {
FLOAT32 ProtoConfigs[MAX_NUM_CONFIGS];
int ConfigNum;
uinT32 ConfigWord;
int ProtoSetIndex;
uinT16 ProtoNum;
uinT8 ProtoWordNum;
PROTO_SET ProtoSet;
uinT16 ActualProtoNum;
if (PrintMatchSummaryOn(Debug)) {
cprintf("Configuration Mask:\n");
for (ConfigNum = 0; ConfigNum < ClassTemplate->NumConfigs; ConfigNum++)
cprintf("%1d", (((*ConfigMask) >> ConfigNum) & 1));
cprintf("\n");
cprintf("Feature Error for Configurations:\n");
for (ConfigNum = 0; ConfigNum < ClassTemplate->NumConfigs; ConfigNum++) {
cprintf(
" %5.1f",
100.0 * (1.0 -
(FLOAT32) tables.sum_feature_evidence_[ConfigNum]
/ NumFeatures / 256.0));
}
cprintf("\n\n\n");
}
if (PrintMatchSummaryOn (Debug)) {
cprintf ("Proto Mask:\n");
for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets;
ProtoSetIndex++) {
ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET);
for (ProtoWordNum = 0; ProtoWordNum < 2;
ProtoWordNum++, ProtoMask++) {
ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET);
for (ProtoNum = 0;
((ProtoNum < (PROTOS_PER_PROTO_SET >> 1))
&& (ActualProtoNum < ClassTemplate->NumProtos));
ProtoNum++, ActualProtoNum++)
cprintf ("%1d", (((*ProtoMask) >> ProtoNum) & 1));
cprintf ("\n");
}
}
cprintf ("\n");
}
for (int i = 0; i < ClassTemplate->NumConfigs; i++)
ProtoConfigs[i] = 0;
if (PrintProtoMatchesOn (Debug)) {
cprintf ("Proto Evidence:\n");
for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets;
ProtoSetIndex++) {
ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex];
ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET);
for (ProtoNum = 0;
((ProtoNum < PROTOS_PER_PROTO_SET) &&
(ActualProtoNum < ClassTemplate->NumProtos));
ProtoNum++, ActualProtoNum++) {
cprintf ("P %3d =", ActualProtoNum);
int temp = 0;
for (int j = 0; j < ClassTemplate->ProtoLengths[ActualProtoNum]; j++) {
uinT8 data = tables.proto_evidence_[ActualProtoNum][j];
cprintf(" %d", data);
temp += data;
}
cprintf(" = %6.4f%%\n",
temp / 256.0 / ClassTemplate->ProtoLengths[ActualProtoNum]);
ConfigWord = ProtoSet->Protos[ProtoNum].Configs[0];
ConfigNum = 0;
while (ConfigWord) {
cprintf ("%5d", ConfigWord & 1 ? temp : 0);
if (ConfigWord & 1)
ProtoConfigs[ConfigNum] += temp;
ConfigNum++;
ConfigWord >>= 1;
}
cprintf("\n");
}
}
}
if (PrintMatchSummaryOn (Debug)) {
cprintf ("Proto Error for Configurations:\n");
for (ConfigNum = 0; ConfigNum < ClassTemplate->NumConfigs; ConfigNum++)
cprintf (" %5.1f",
100.0 * (1.0 -
ProtoConfigs[ConfigNum] /
ClassTemplate->ConfigLengths[ConfigNum] / 256.0));
cprintf ("\n\n");
}
if (PrintProtoMatchesOn (Debug)) {
cprintf ("Proto Sum for Configurations:\n");
for (ConfigNum = 0; ConfigNum < ClassTemplate->NumConfigs; ConfigNum++)
cprintf (" %4.1f", ProtoConfigs[ConfigNum] / 256.0);
cprintf ("\n\n");
cprintf ("Proto Length for Configurations:\n");
for (ConfigNum = 0; ConfigNum < ClassTemplate->NumConfigs; ConfigNum++)
cprintf (" %4.1f",
(float) ClassTemplate->ConfigLengths[ConfigNum]);
cprintf ("\n\n");
}
}
void IntegerMatcher::DisplayProtoDebugInfo(
INT_CLASS ClassTemplate,
BIT_VECTOR ProtoMask,
BIT_VECTOR ConfigMask,
const ScratchEvidence& tables,
bool SeparateDebugWindows) {
uinT16 ProtoNum;
uinT16 ActualProtoNum;
PROTO_SET ProtoSet;
int ProtoSetIndex;
InitIntMatchWindowIfReqd();
if (SeparateDebugWindows) {
InitFeatureDisplayWindowIfReqd();
InitProtoDisplayWindowIfReqd();
}
for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets;
ProtoSetIndex++) {
ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex];
ActualProtoNum = ProtoSetIndex * PROTOS_PER_PROTO_SET;
for (ProtoNum = 0;
((ProtoNum < PROTOS_PER_PROTO_SET) &&
(ActualProtoNum < ClassTemplate->NumProtos));
ProtoNum++, ActualProtoNum++) {
/* Compute Average for Actual Proto */
int temp = 0;
for (int i = 0; i < ClassTemplate->ProtoLengths[ActualProtoNum]; i++)
temp += tables.proto_evidence_[ActualProtoNum][i];
temp /= ClassTemplate->ProtoLengths[ActualProtoNum];
if ((ProtoSet->Protos[ProtoNum]).Configs[0] & (*ConfigMask)) {
DisplayIntProto(ClassTemplate, ActualProtoNum, temp / 255.0);
}
}
}
}
void IntegerMatcher::DisplayFeatureDebugInfo(
INT_CLASS ClassTemplate,
BIT_VECTOR ProtoMask,
BIT_VECTOR ConfigMask,
inT16 NumFeatures,
const INT_FEATURE_STRUCT* Features,
int AdaptFeatureThreshold,
int Debug,
bool SeparateDebugWindows) {
ScratchEvidence *tables = new ScratchEvidence();
tables->Clear(ClassTemplate);
InitIntMatchWindowIfReqd();
if (SeparateDebugWindows) {
InitFeatureDisplayWindowIfReqd();
InitProtoDisplayWindowIfReqd();
}
for (int Feature = 0; Feature < NumFeatures; Feature++) {
UpdateTablesForFeature(
ClassTemplate, ProtoMask, ConfigMask, Feature, &Features[Feature],
tables, 0);
/* Find Best Evidence for Current Feature */
int best = 0;
for (int i = 0; i < ClassTemplate->NumConfigs; i++)
if (tables->feature_evidence_[i] > best)
best = tables->feature_evidence_[i];
/* Update display for current feature */
if (ClipMatchEvidenceOn(Debug)) {
if (best < AdaptFeatureThreshold)
DisplayIntFeature(&Features[Feature], 0.0);
else
DisplayIntFeature(&Features[Feature], 1.0);
} else {
DisplayIntFeature(&Features[Feature], best / 255.0);
}
}
delete tables;
}
#endif
/**
* Add sum of Proto Evidences into Sum Of Feature Evidence Array
*/
void ScratchEvidence::UpdateSumOfProtoEvidences(
INT_CLASS ClassTemplate, BIT_VECTOR ConfigMask, inT16 NumFeatures) {
int *IntPointer;
uinT32 ConfigWord;
int ProtoSetIndex;
uinT16 ProtoNum;
PROTO_SET ProtoSet;
int NumProtos;
uinT16 ActualProtoNum;
NumProtos = ClassTemplate->NumProtos;
for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets;
ProtoSetIndex++) {
ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex];
ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET);
for (ProtoNum = 0;
((ProtoNum < PROTOS_PER_PROTO_SET) && (ActualProtoNum < NumProtos));
ProtoNum++, ActualProtoNum++) {
int temp = 0;
for (int i = 0; i < ClassTemplate->ProtoLengths[ActualProtoNum]; i++)
temp += proto_evidence_[ActualProtoNum] [i];
ConfigWord = ProtoSet->Protos[ProtoNum].Configs[0];
ConfigWord &= *ConfigMask;
IntPointer = sum_feature_evidence_;
while (ConfigWord) {
if (ConfigWord & 1)
*IntPointer += temp;
IntPointer++;
ConfigWord >>= 1;
}
}
}
}
/**
* Normalize Sum of Proto and Feature Evidence by dividing by the sum of
* the Feature Lengths and the Proto Lengths for each configuration.
*/
void ScratchEvidence::NormalizeSums(
INT_CLASS ClassTemplate, inT16 NumFeatures, inT32 used_features) {
for (int i = 0; i < ClassTemplate->NumConfigs; i++) {
sum_feature_evidence_[i] = (sum_feature_evidence_[i] << 8) /
(NumFeatures + ClassTemplate->ConfigLengths[i]);
}
}
/**
* Find the best match for the current class and update the Result
* with the configuration and match rating.
* @return The best normalized sum of evidences
* @note Exceptions: none
* @note History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
*/
int IntegerMatcher::FindBestMatch(
INT_CLASS class_template,
const ScratchEvidence &tables,
UnicharRating* result) {
int best_match = 0;
result->config = 0;
result->fonts.truncate(0);
result->fonts.reserve(class_template->NumConfigs);
/* Find best match */
for (int c = 0; c < class_template->NumConfigs; ++c) {
int rating = tables.sum_feature_evidence_[c];
if (*classify_debug_level_ > 2)
tprintf("Config %d, rating=%d\n", c, rating);
if (rating > best_match) {
result->config = c;
best_match = rating;
}
result->fonts.push_back(ScoredFont(c, rating));
}
// Compute confidence on a Probability scale.
result->rating = best_match / 65536.0f;
return best_match;
}
/**
* Applies the CN normalization factor to the given rating and returns
* the modified rating.
*/
float IntegerMatcher::ApplyCNCorrection(float rating, int blob_length,
int normalization_factor,
int matcher_multiplier) {
return (rating * blob_length +
matcher_multiplier * normalization_factor / 256.0) /
(blob_length + matcher_multiplier);
}
/**
* Sort Key array in ascending order using heap sort
* algorithm. Also sort Index array that is tied to
* the key array.
* @param n Number of elements to sort
* @param ra Key array [1..n]
* @param rb Index array [1..n]
* @return none
* @note Exceptions: none
* @note History: Tue Feb 19 10:24:24 MST 1991, RWM, Created.
*/
void
HeapSort (int n, register int ra[], register int rb[]) {
int i, rra, rrb;
int l, j, ir;
l = (n >> 1) + 1;
ir = n;
for (;;) {
if (l > 1) {
rra = ra[--l];
rrb = rb[l];
}
else {
rra = ra[ir];
rrb = rb[ir];
ra[ir] = ra[1];
rb[ir] = rb[1];
if (--ir == 1) {
ra[1] = rra;
rb[1] = rrb;
return;
}
}
i = l;
j = l << 1;
while (j <= ir) {
if (j < ir && ra[j] < ra[j + 1])
++j;
if (rra < ra[j]) {
ra[i] = ra[j];
rb[i] = rb[j];
j += (i = j);
}
else
j = ir + 1;
}
ra[i] = rra;
rb[i] = rrb;
}
}
|
#include <fc/thread/thread.hpp>
#include <fc/string.hpp>
#include <fc/time.hpp>
#include <boost/thread.hpp>
#include "context.hpp"
#include <boost/thread/condition_variable.hpp>
#include <boost/thread.hpp>
#include <boost/atomic.hpp>
#include <vector>
//#include <fc/logger.hpp>
namespace fc {
struct sleep_priority_less {
bool operator()( const context::ptr& a, const context::ptr& b ) {
return a->resume_time > b->resume_time;
}
};
class thread_d {
public:
thread_d(fc::thread& s)
:self(s), boost_thread(0),
task_in_queue(0),
next_posted_num(1),
done(false),
current(0),
pt_head(0),
blocked(0),
next_unused_task_storage_slot(0)
#ifndef NDEBUG
,non_preemptable_scope_count(0)
#endif
{
static boost::atomic<int> cnt(0);
name = fc::string("th_") + char('a'+cnt++);
// printf("thread=%p\n",this);
}
~thread_d()
{
delete current;
fc::context* temp;
for (fc::context* ready_context : ready_heap)
delete ready_context;
ready_heap.clear();
while (blocked)
{
temp = blocked->next;
delete blocked;
blocked = temp;
}
/*
while (pt_head)
{
temp = pt_head->next;
delete pt_head;
pt_head = temp;
}
*/
//ilog("");
if (boost_thread)
{
boost_thread->detach();
delete boost_thread;
}
}
fc::thread& self;
boost::thread* boost_thread;
stack_allocator stack_alloc;
boost::condition_variable task_ready;
boost::mutex task_ready_mutex;
boost::atomic<task_base*> task_in_queue;
std::vector<task_base*> task_pqueue; // heap of tasks that have never started, ordered by proirity & scheduling time
uint64_t next_posted_num; // each task or context gets assigned a number in the order it is ready to execute, tracked here
std::vector<task_base*> task_sch_queue; // heap of tasks that have never started but are scheduled for a time in the future, ordered by the time they should be run
std::vector<fc::context*> sleep_pqueue; // heap of running tasks that have sleeped, ordered by the time they should resume
std::vector<fc::context*> free_list; // list of unused contexts that are ready for deletion
bool done;
fc::string name;
fc::context* current; // the currently-executing task in this thread
fc::context* pt_head; // list of contexts that can be reused for new tasks
std::vector<fc::context*> ready_heap; // priority heap of contexts that are ready to run
fc::context* blocked; // linked list of contexts (using 'next_blocked') blocked on promises via wait()
// values for thread specific data objects for this thread
std::vector<detail::specific_data_info> thread_specific_data;
// values for task_specific data for code executing on a thread that's
// not a task launched by async (usually the default task on the main
// thread in a process)
std::vector<detail::specific_data_info> non_task_specific_data;
unsigned next_unused_task_storage_slot;
#ifndef NDEBUG
unsigned non_preemptable_scope_count;
#endif
#if 0
void debug( const fc::string& s ) {
return;
//boost::unique_lock<boost::mutex> lock(log_mutex());
fc::cerr<<"--------------------- "<<s.c_str()<<" - "<<current;
if( current && current->cur_task ) fc::cerr<<'('<<current->cur_task->get_desc()<<')';
fc::cerr<<" ---------------------------\n";
fc::cerr<<" Ready\n";
fc::context* c = ready_head;
while( c ) {
fc::cerr<<" "<<c;
if( c->cur_task ) fc::cerr<<'('<<c->cur_task->get_desc()<<')';
fc::context* p = c->caller_context;
while( p ) {
fc::cerr<<" -> "<<p;
p = p->caller_context;
}
fc::cerr<<"\n";
c = c->next;
}
fc::cerr<<" Blocked\n";
c = blocked;
while( c ) {
fc::cerr<<" ctx: "<< c;
if( c->cur_task ) fc::cerr<<'('<<c->cur_task->get_desc()<<')';
fc::cerr << " blocked on prom: ";
for( uint32_t i = 0; i < c->blocking_prom.size(); ++i ) {
fc::cerr<<c->blocking_prom[i].prom<<'('<<c->blocking_prom[i].prom->get_desc()<<')';
if( i + 1 < c->blocking_prom.size() ) {
fc::cerr<<",";
}
}
fc::context* p = c->caller_context;
while( p ) {
fc::cerr<<" -> "<<p;
p = p->caller_context;
}
fc::cerr<<"\n";
c = c->next_blocked;
}
fc::cerr<<"-------------------------------------------------\n";
}
#endif
// insert at from of blocked linked list
inline void add_to_blocked( fc::context* c )
{
c->next_blocked = blocked;
blocked = c;
}
void pt_push_back(fc::context* c)
{
c->next = pt_head;
pt_head = c;
/*
fc::context* n = pt_head;
int i = 0;
while( n ) {
++i;
n = n->next;
}
wlog( "idle context...%2% %1%", c, i );
*/
}
fc::context::ptr ready_pop_front()
{
fc::context* highest_priority_context = ready_heap.front();
std::pop_heap(ready_heap.begin(), ready_heap.end(), task_priority_less());
ready_heap.pop_back();
return highest_priority_context;
}
void add_context_to_ready_list(context* context_to_add, bool at_end = false)
{
context_to_add->context_posted_num = next_posted_num++;
ready_heap.push_back(context_to_add);
std::push_heap(ready_heap.begin(), ready_heap.end(), task_priority_less());
}
struct task_priority_less
{
bool operator()(const task_base* a, const task_base* b) const
{
return a->_prio.value < b->_prio.value ? true :
(a->_prio.value > b->_prio.value ? false :
a->_posted_num > b->_posted_num);
}
bool operator()(const task_base* a, const context* b) const
{
return a->_prio.value < b->prio.value ? true :
(a->_prio.value > b->prio.value ? false :
a->_posted_num > b->context_posted_num);
}
bool operator()(const context* a, const task_base* b) const
{
return a->prio.value < b->_prio.value ? true :
(a->prio.value > b->_prio.value ? false :
a->context_posted_num > b->_posted_num);
}
bool operator()(const context* a, const context* b) const
{
return a->prio.value < b->prio.value ? true :
(a->prio.value > b->prio.value ? false :
a->context_posted_num > b->context_posted_num);
}
};
struct task_when_less
{
bool operator()( task_base* a, task_base* b )
{
return a->_when > b->_when;
}
};
void enqueue( task_base* t )
{
time_point now = time_point::now();
task_base* cur = t;
// the linked list of tasks passed to enqueue is in the reverse order of
// what you'd expect -- the first task to be scheduled is at the end of
// the list. We'll rectify the ordering by assigning the _posted_num
// in reverse order
unsigned num_ready_tasks = 0;
while (cur)
{
if (cur->_when <= now)
++num_ready_tasks;
cur = cur->_next;
}
cur = t;
next_posted_num += num_ready_tasks;
unsigned tasks_posted = 0;
while (cur)
{
if (cur->_when > now)
{
task_sch_queue.push_back(cur);
std::push_heap(task_sch_queue.begin(),
task_sch_queue.end(), task_when_less());
}
else
{
cur->_posted_num = next_posted_num - (++tasks_posted);
task_pqueue.push_back(cur);
std::push_heap(task_pqueue.begin(),
task_pqueue.end(), task_priority_less());
BOOST_ASSERT(this == thread::current().my);
}
cur = cur->_next;
}
}
void move_newly_scheduled_tasks_to_task_pqueue()
{
BOOST_ASSERT(this == thread::current().my);
// first, if there are any new tasks on 'task_in_queue', which is tasks that
// have been just been async or scheduled, but we haven't processed them.
// move them into the task_sch_queue or task_pqueue, as appropriate
//DLN: changed from memory_order_consume for boost 1.55.
//This appears to be safest replacement for now, maybe
//can be changed to relaxed later, but needs analysis.
task_base* pending_list = task_in_queue.exchange(0, boost::memory_order_seq_cst);
if (pending_list)
enqueue(pending_list);
// second, walk through task_sch_queue and move any scheduled tasks that are now
// able to run (because their scheduled time has arrived) to task_pqueue
while (!task_sch_queue.empty() &&
task_sch_queue.front()->_when <= time_point::now())
{
task_base* ready_task = task_sch_queue.front();
std::pop_heap(task_sch_queue.begin(), task_sch_queue.end(), task_when_less());
task_sch_queue.pop_back();
ready_task->_posted_num = next_posted_num++;
task_pqueue.push_back(ready_task);
std::push_heap(task_pqueue.begin(), task_pqueue.end(), task_priority_less());
}
}
task_base* dequeue()
{
// get a new task
BOOST_ASSERT( this == thread::current().my );
assert(!task_pqueue.empty());
task_base* p = task_pqueue.front();
std::pop_heap(task_pqueue.begin(), task_pqueue.end(), task_priority_less() );
task_pqueue.pop_back();
return p;
}
bool process_canceled_tasks()
{
bool canceled_task = false;
for( auto task_itr = task_sch_queue.begin();
task_itr != task_sch_queue.end();
)
{
if( (*task_itr)->canceled() )
{
(*task_itr)->run();
(*task_itr)->release();
task_itr = task_sch_queue.erase(task_itr);
canceled_task = true;
continue;
}
++task_itr;
}
if( canceled_task )
std::make_heap( task_sch_queue.begin(), task_sch_queue.end(), task_when_less() );
return canceled_task;
}
/**
* This should be before or after a context switch to
* detect quit/cancel operations and throw an exception.
*/
void check_fiber_exceptions()
{
if( current && current->canceled )
{
#ifdef NDEBUG
FC_THROW_EXCEPTION( canceled_exception, "" );
#else
FC_THROW_EXCEPTION( canceled_exception, "cancellation reason: ${reason}", ("reason", current->cancellation_reason ? current->cancellation_reason : "[none given]"));
#endif
}
else if( done )
{
ilog( "throwing canceled exception" );
FC_THROW_EXCEPTION( canceled_exception, "cancellation reason: thread quitting" );
// BOOST_THROW_EXCEPTION( thread_quit() );
}
}
/**
* Find the next available context and switch to it.
* If none are available then create a new context and
* have it wait for something to do.
*/
bool start_next_fiber( bool reschedule = false )
{
/* If this assert fires, it means you are executing an operation that is causing
* the current task to yield, but there is a ASSERT_TASK_NOT_PREEMPTED() in effect
* (somewhere up the stack) */
assert(non_preemptable_scope_count == 0);
/* If this assert fires, it means you are causing the current task to yield while
* in the middle of handling an exception. The boost::context library's behavior
* is not well-defined in this case, and this has the potential to corrupt the
* exception stack, often resulting in a crash very soon after this */
/* NB: At least on Win64, this only catches a yield while in the body of
* a catch block; it fails to catch a yield while unwinding the stack, which
* is probably just as likely to cause crashes */
assert(std::current_exception() == std::exception_ptr());
check_for_timeouts();
if( !current )
current = new fc::context( &fc::thread::current() );
priority original_priority = current->prio;
// check to see if any other contexts are ready
if (!ready_heap.empty())
{
fc::context* next = ready_pop_front();
if (next == current)
{
// elog( "next == current... something went wrong" );
assert(next != current);
return false;
}
BOOST_ASSERT(next != current);
// jump to next context, saving current context
fc::context* prev = current;
current = next;
if (reschedule)
{
current->prio = priority::_internal__priority_for_short_sleeps();
add_context_to_ready_list(prev, true);
}
// slog( "jump to %p from %p", next, prev );
// fc_dlog( logger::get("fc_context"), "from ${from} to ${to}", ( "from", int64_t(prev) )( "to", int64_t(next) ) );
#if BOOST_VERSION >= 105600
bc::jump_fcontext( &prev->my_context, next->my_context, 0 );
#elif BOOST_VERSION >= 105300
bc::jump_fcontext( prev->my_context, next->my_context, 0 );
#else
bc::jump_fcontext( &prev->my_context, &next->my_context, 0 );
#endif
BOOST_ASSERT( current );
BOOST_ASSERT( current == prev );
//current = prev;
}
else
{
// all contexts are blocked, create a new context
// that will process posted tasks...
fc::context* prev = current;
fc::context* next = nullptr;
if( pt_head )
{
// grab cached context
next = pt_head;
pt_head = pt_head->next;
next->next = 0;
next->reinitialize();
}
else
{
// create new context.
next = new fc::context( &thread_d::start_process_tasks, stack_alloc,
&fc::thread::current() );
}
current = next;
if( reschedule )
{
current->prio = priority::_internal__priority_for_short_sleeps();
add_context_to_ready_list(prev, true);
}
// slog( "jump to %p from %p", next, prev );
// fc_dlog( logger::get("fc_context"), "from ${from} to ${to}", ( "from", int64_t(prev) )( "to", int64_t(next) ) );
#if BOOST_VERSION >= 105600
bc::jump_fcontext( &prev->my_context, next->my_context, (intptr_t)this );
#elif BOOST_VERSION >= 105300
bc::jump_fcontext( prev->my_context, next->my_context, (intptr_t)this );
#else
bc::jump_fcontext( &prev->my_context, &next->my_context, (intptr_t)this );
#endif
BOOST_ASSERT( current );
BOOST_ASSERT( current == prev );
//current = prev;
}
if (reschedule)
current->prio = original_priority;
if( current->canceled )
{
//current->canceled = false;
#ifdef NDEBUG
FC_THROW_EXCEPTION( canceled_exception, "" );
#else
FC_THROW_EXCEPTION( canceled_exception, "cancellation reason: ${reason}", ("reason", current->cancellation_reason ? current->cancellation_reason : "[none given]"));
#endif
}
return true;
}
static void start_process_tasks( intptr_t my )
{
thread_d* self = (thread_d*)my;
try
{
self->process_tasks();
}
catch ( canceled_exception& ) { /* allowed exception */ }
catch ( ... )
{
elog( "fiber ${name} exited with uncaught exception: ${e}", ("e",fc::except_str())("name", self->name) );
// assert( !"fiber exited with uncaught exception" );
//TODO replace errror fc::cerr<<"fiber exited with uncaught exception:\n "<<
// boost::current_exception_diagnostic_information() <<std::endl;
}
self->free_list.push_back(self->current);
self->start_next_fiber( false );
}
void run_next_task()
{
task_base* next = dequeue();
next->_set_active_context( current );
current->cur_task = next;
next->run();
current->cur_task = 0;
next->_set_active_context(0);
next->release();
current->reinitialize();
}
bool has_next_task()
{
if( task_pqueue.size() ||
(task_sch_queue.size() && task_sch_queue.front()->_when <= time_point::now()) ||
task_in_queue.load( boost::memory_order_relaxed ) )
return true;
return false;
}
void clear_free_list()
{
for( uint32_t i = 0; i < free_list.size(); ++i )
delete free_list[i];
free_list.clear();
}
void process_tasks()
{
while( !done || blocked )
{
// move all new tasks to the task_pqueue
move_newly_scheduled_tasks_to_task_pqueue();
// move all now-ready sleeping tasks to the ready list
check_for_timeouts();
if (!task_pqueue.empty())
{
if (!ready_heap.empty())
{
// a new task and an existing task are both ready to go
if (task_priority_less()(task_pqueue.front(), ready_heap.front()))
{
// run the existing task first
pt_push_back(current);
start_next_fiber(false);
continue;
}
}
// if we made it here, either there's no ready context, or the ready context is
// scheduled after the ready task, so we should run the task first
run_next_task();
continue;
}
// if I have something else to do other than
// process tasks... do it.
if (!ready_heap.empty())
{
pt_push_back( current );
start_next_fiber(false);
continue;
}
if( process_canceled_tasks() )
continue;
clear_free_list();
{ // lock scope
boost::unique_lock<boost::mutex> lock(task_ready_mutex);
if( has_next_task() )
continue;
time_point timeout_time = check_for_timeouts();
if( done )
return;
if( timeout_time == time_point::maximum() )
task_ready.wait( lock );
else if( timeout_time != time_point::min() )
{
// there may be tasks that have been canceled we should filter them out now
// rather than waiting...
/* This bit is kind of sloppy -- this wait was originally implemented as a wait
* with respect to boost::chrono::system_clock. This behaved rather comically
* if you were to do a:
* fc::usleep(fc::seconds(60));
* and then set your system's clock back a month, it would sleep for a month
* plus a minute before waking back up (this happened on Linux, it seems
* Windows' behavior in this case was less unexpected).
*
* Boost Chrono's steady_clock will always increase monotonically so it will
* avoid this behavior.
*
* Right now we don't really have a way to distinguish when a timeout_time is coming
* from a function that takes a relative time like fc::usleep() vs something
* that takes an absolute time like fc::promise::wait_until(), so we can't always
* do the right thing here.
*/
task_ready.wait_until( lock, boost::chrono::steady_clock::now() +
boost::chrono::microseconds(timeout_time.time_since_epoch().count() - time_point::now().time_since_epoch().count()) );
}
}
}
}
/**
* Return system_clock::time_point::min() if tasks have timed out
* Retunn system_clock::time_point::max() if there are no scheduled tasks
* Return the time the next task needs to be run if there is anything scheduled.
*/
time_point check_for_timeouts()
{
if( !sleep_pqueue.size() && !task_sch_queue.size() )
{
// ilog( "no timeouts ready" );
return time_point::maximum();
}
time_point next = time_point::maximum();
if( !sleep_pqueue.empty() && next > sleep_pqueue.front()->resume_time )
next = sleep_pqueue.front()->resume_time;
if( !task_sch_queue.empty() && next > task_sch_queue.front()->_when )
next = task_sch_queue.front()->_when;
time_point now = time_point::now();
if( now < next )
return next;
// move all expired sleeping tasks to the ready queue
while( sleep_pqueue.size() && sleep_pqueue.front()->resume_time < now )
{
fc::context::ptr c = sleep_pqueue.front();
std::pop_heap(sleep_pqueue.begin(), sleep_pqueue.end(), sleep_priority_less() );
// ilog( "sleep pop back..." );
sleep_pqueue.pop_back();
if( c->blocking_prom.size() )
{
// ilog( "timeout blocking prom" );
c->timeout_blocking_promises();
}
else
{
// ilog( "..." );
// ilog( "ready_push_front" );
if (c != current)
add_context_to_ready_list(c);
}
}
return time_point::min();
}
void unblock( fc::context* c )
{
if( fc::thread::current().my != this )
{
self.async( [=](){ unblock(c); }, "thread_d::unblock" );
return;
}
if (c != current)
add_context_to_ready_list(c);
}
void yield_until( const time_point& tp, bool reschedule ) {
check_fiber_exceptions();
if( tp <= (time_point::now()+fc::microseconds(10000)) )
return;
FC_ASSERT(std::current_exception() == std::exception_ptr(),
"Attempting to yield while processing an exception");
if( !current )
current = new fc::context(&fc::thread::current());
current->resume_time = tp;
current->clear_blocking_promises();
sleep_pqueue.push_back(current);
std::push_heap( sleep_pqueue.begin(),
sleep_pqueue.end(), sleep_priority_less() );
start_next_fiber(reschedule);
// clear current context from sleep queue...
for( uint32_t i = 0; i < sleep_pqueue.size(); ++i )
{
if( sleep_pqueue[i] == current )
{
sleep_pqueue[i] = sleep_pqueue.back();
sleep_pqueue.pop_back();
std::make_heap( sleep_pqueue.begin(),
sleep_pqueue.end(), sleep_priority_less() );
break;
}
}
current->resume_time = time_point::maximum();
check_fiber_exceptions();
}
void wait( const promise_base::ptr& p, const time_point& timeout ) {
if( p->ready() )
return;
FC_ASSERT(std::current_exception() == std::exception_ptr(),
"Attempting to yield while processing an exception");
if( timeout < time_point::now() )
FC_THROW_EXCEPTION( timeout_exception, "" );
if( !current )
current = new fc::context(&fc::thread::current());
// slog( " %1% blocking on %2%", current, p.get() );
current->add_blocking_promise(p.get(),true);
// if not max timeout, added to sleep pqueue
if( timeout != time_point::maximum() )
{
current->resume_time = timeout;
sleep_pqueue.push_back(current);
std::push_heap( sleep_pqueue.begin(),
sleep_pqueue.end(),
sleep_priority_less() );
}
// elog( "blocking %1%", current );
add_to_blocked( current );
// debug("swtiching fibers..." );
start_next_fiber();
// slog( "resuming %1%", current );
// slog( " %1% unblocking blocking on %2%", current, p.get() );
current->remove_blocking_promise(p.get());
check_fiber_exceptions();
}
void cleanup_thread_specific_data()
{
for (auto iter = non_task_specific_data.begin(); iter != non_task_specific_data.end(); ++iter)
if (iter->cleanup)
iter->cleanup(iter->value);
for (auto iter = thread_specific_data.begin(); iter != thread_specific_data.end(); ++iter)
if (iter->cleanup)
iter->cleanup(iter->value);
}
void notify_task_has_been_canceled()
{
for (fc::context** iter = &blocked; *iter;)
{
if ((*iter)->canceled)
{
fc::context* next_blocked = (*iter)->next_blocked;
(*iter)->next_blocked = nullptr;
add_context_to_ready_list(*iter);
*iter = next_blocked;
continue;
}
iter = &(*iter)->next_blocked;
}
bool task_removed_from_sleep_pqueue = false;
for (auto sleep_iter = sleep_pqueue.begin(); sleep_iter != sleep_pqueue.end();)
{
if ((*sleep_iter)->canceled)
{
bool already_on_ready_list = std::find(ready_heap.begin(), ready_heap.end(),
*sleep_iter) != ready_heap.end();
if (!already_on_ready_list)
add_context_to_ready_list(*sleep_iter);
sleep_iter = sleep_pqueue.erase(sleep_iter);
task_removed_from_sleep_pqueue = true;
}
else
++sleep_iter;
}
if (task_removed_from_sleep_pqueue)
std::make_heap(sleep_pqueue.begin(), sleep_pqueue.end(), sleep_priority_less());
}
};
} // namespace fc
|
li t0, 1
li t1, 3
sub s6, t0 ,t1 |
global main
extern puts
section .data
message db "Hello, World!"
section .text
main:
mov rdi, message
call puts
ret
|
BITS 32
; The address operands of instructions can be encoded in various ways.
; Unfortunately, NASM does not always use the alphanumeric variant. Which is why
; these are used:
%define IMUL___ESI__xESPx_(x) db 0x6B, 0x34, 0x64, x ; IMUL ESI, [ESP], x
%define XOR____ESI__xESPx db 0x33, 0x34, 0x64 ; XOR ESI, [ESP]
%define XOR____xESPx__ESI db 0x31, 0x34, 0x64 ; XOR [ESP], ESI
%define XOR____xESIxECXx__ESI db 0x31, 0x34, 0x31 ; XOR [ESI+ECX], ESI
%define XOR____ESI__xESIxECXx db 0x33, 0x34, 0x31 ; XOR ESI, [ESI+ECX]
; ...nopslide goes here...
patcher:
PUSH 0x40404040 ; [ESP0] = code1, ESP = ESP0
IMUL___ESI__xESPx_(0x30) ; ESI = code1 * code2
PUSH 0x40404040 ; [ESP1] = code3, ESP = ESP1
XOR____ESI__xESPx ; ESI = (code1 * 30) ^ code2 = (A + D * 3 + P)
XOR____xESIxECXx__ESI ; [return address pointer] ^= ESI
XOR____ESI__xESIxECXx ; ESI ^= ([return address] ^ ESI) = [return address pointer] = return address = A + D
PUSH ESI ; [ESP2] = A + D
POP ECX ; ECX = A + D
PUSH 0x40404040 ; [ESP3] = code1, ESP = ESP3
IMUL___ESI__xESPx_(0x30) ; ESI = code1 * code2
PUSH 0x40404040 ; [ESP4] = code3, ESP = ESP4
XOR____ESI__xESPx ; ESI = (code1 * 30) ^ code2 = (D * 2 + P)
PUSH ESI ; [ESP5] = (D * 2 + P), ESP = ESP5
PUSH ESP ; [ESP6] = ESP5, ESP = ESP6
POP EAX ; EAX = [ESP6] = ESP5
XOR [EAX], EDI ; [ESP5] = (D * 2 + P) ^ EDI
XOR EDI, [EAX] ; EDI ^= (D * 2 + P) ^ EDI = (D * 2 + P)
; 8D 54 0F 04 -> LEA EDX, [ECX+EDI+4] => 0x040F548D
; 0x040F548D ^ 0x42424242 == 464D16CF
; 0x464D16CF == 0x4D4D3738 * 0x30 ^ 0x38374C4F
PUSH 0x4D4D3738 ; [ESP3] = code1, ESP = ESP3
IMUL___ESI__xESPx_(0x30) ; ESI = code1 * code2
PUSH 0x38374C4F ; [ESP4] = code3, ESP = ESP4
XOR____ESI__xESPx ; ESI = (code1 * 30) ^ code2 = (D * 2 + P)
XOR [ECX+EDI], ESI ; [A + D * 3 + P] = LEA EDX, [ECX+EDI+4]
; ...count slide goes here...
; INC EDX
; INC EDX
; INC EDX
; ...
; ...at address (A + D * 3 + P):
; LEA EDX, [ECX+EDI+4] ; EDX = A + D * 3 + P + 4
; ...count slide continues at A + D * 3 + P + 5...
; INC EDX ; ECX = A + D * 3 + P + 5
; INC EDX ; ECX = A + D * 3 + P + 6
; ...
; INC EDX ; EDX = A + D * 3 + P + 1 + (D - O)
; EDX now points to the base address of shellcode:
shellcode:
|
// MIT License
//
// Copyright (c) 2020, The Regents of the University of California,
// through Lawrence Berkeley National Laboratory (subject to receipt of any
// required approvals from the U.S. Dept. of Energy). All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#include "timemory/compat/macros.h"
#include <cassert>
#if defined(TIMEMORY_CORE_SOURCE)
# define TIMEMORY_SETTINGS_SOURCE
#elif defined(TIMEMORY_USE_CORE_EXTERN)
# define TIMEMORY_USE_SETTINGS_EXTERN
#endif
//
#if defined(TIMEMORY_USE_EXTERN) && !defined(TIMEMORY_USE_SETTINGS_EXTERN)
# define TIMEMORY_USE_SETTINGS_EXTERN
#endif
//
#if defined(TIMEMORY_SETTINGS_SOURCE)
# define TIMEMORY_SETTINGS_COMPILE_MODE
# define TIMEMORY_SETTINGS_INLINE
# define TIMEMORY_SETTINGS_LINKAGE(...) __VA_ARGS__
#elif defined(TIMEMORY_USE_SETTINGS_EXTERN)
# define TIMEMORY_SETTINGS_EXTERN_MODE
# define TIMEMORY_SETTINGS_INLINE
# define TIMEMORY_SETTINGS_LINKAGE(...) __VA_ARGS__
#else
# define TIMEMORY_SETTINGS_HEADER_MODE
# define TIMEMORY_SETTINGS_INLINE inline
# define TIMEMORY_SETTINGS_LINKAGE(...) inline __VA_ARGS__
#endif
//
#if !defined(TIMEMORY_SETTINGS_PREFIX)
# define TIMEMORY_SETTINGS_PREFIX "TIMEMORY_"
#endif
//
#if !defined(TIMEMORY_SETTINGS_KEY)
# define TIMEMORY_SETTINGS_KEY(...) TIMEMORY_SETTINGS_PREFIX __VA_ARGS__
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_SETTINGS_MEMBER_DECL)
// memory leak w/ _key is intentional due to potential calls during _cxa_finalize
// which may have already deleted a non-heap allocation
# define TIMEMORY_SETTINGS_MEMBER_DECL(TYPE, FUNC) \
public: \
TYPE& get_##FUNC() TIMEMORY_NEVER_INSTRUMENT TIMEMORY_VISIBILITY("default"); \
TYPE get_##FUNC() \
const TIMEMORY_NEVER_INSTRUMENT TIMEMORY_VISIBILITY("default"); \
static TYPE& FUNC() TIMEMORY_NEVER_INSTRUMENT TIMEMORY_VISIBILITY("default");
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_SETTINGS_REFERENCE_DECL)
// memory leak w/ _key is intentional due to potential calls during _cxa_finalize
// which may have already deleted a non-heap allocation
# define TIMEMORY_SETTINGS_REFERENCE_DECL(TYPE, FUNC) \
public: \
TYPE& get_##FUNC() TIMEMORY_NEVER_INSTRUMENT TIMEMORY_VISIBILITY("default"); \
TYPE get_##FUNC() \
const TIMEMORY_NEVER_INSTRUMENT TIMEMORY_VISIBILITY("default"); \
static TYPE& FUNC() TIMEMORY_NEVER_INSTRUMENT TIMEMORY_VISIBILITY("default");
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_SETTINGS_MEMBER_DEF)
// memory leak w/ _key is intentional due to potential calls during _cxa_finalize
// which may have already deleted a non-heap allocation
# define TIMEMORY_SETTINGS_MEMBER_DEF(TYPE, FUNC, ENV_VAR) \
TIMEMORY_SETTINGS_INLINE TYPE& settings::get_##FUNC() \
{ \
return static_cast<tsettings<TYPE>*>(m_data.at(ENV_VAR).get())->get(); \
} \
\
TIMEMORY_SETTINGS_INLINE TYPE settings::get_##FUNC() const \
{ \
auto ret = m_data.find(ENV_VAR); \
if(ret == m_data.end()) \
return TYPE{}; \
if(!ret->second) \
return TYPE{}; \
return static_cast<tsettings<TYPE>*>(ret->second.get())->get(); \
} \
\
TIMEMORY_SETTINGS_INLINE TYPE& settings::FUNC() \
{ \
return shared_instance()->get_##FUNC(); \
}
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_SETTINGS_REFERENCE_DEF)
// memory leak w/ _key is intentional due to potential calls during _cxa_finalize
// which may have already deleted a non-heap allocation
# define TIMEMORY_SETTINGS_REFERENCE_DEF(TYPE, FUNC, ENV_VAR) \
TIMEMORY_SETTINGS_INLINE TYPE& settings::get_##FUNC() \
{ \
return static_cast<tsettings<TYPE, TYPE&>*>(m_data.at(ENV_VAR).get()) \
->get(); \
} \
\
TIMEMORY_SETTINGS_INLINE TYPE settings::get_##FUNC() const \
{ \
auto ret = m_data.find(ENV_VAR); \
if(ret == m_data.end()) \
return TYPE{}; \
if(!ret->second) \
return TYPE{}; \
return static_cast<tsettings<TYPE, TYPE&>*>(ret->second.get())->get(); \
} \
\
TIMEMORY_SETTINGS_INLINE TYPE& settings::FUNC() \
{ \
return shared_instance()->get_##FUNC(); \
}
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_SETTINGS_MEMBER_IMPL)
# define TIMEMORY_SETTINGS_MEMBER_IMPL(TYPE, FUNC, ENV_VAR, DESC, INIT) \
\
if(m_data \
.insert({ ENV_VAR, std::make_shared<tsettings<TYPE>>( \
INIT, std::string{ #FUNC }, \
std::string{ ENV_VAR }, std::string{ DESC }) }) \
.second) \
m_order.push_back(ENV_VAR);
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_SETTINGS_MEMBER_ARG_IMPL)
# define TIMEMORY_SETTINGS_MEMBER_ARG_IMPL(TYPE, FUNC, ENV_VAR, DESC, INIT, ...) \
\
if(m_data \
.insert( \
{ ENV_VAR, std::make_shared<tsettings<TYPE>>( \
INIT, std::string{ #FUNC }, std::string{ ENV_VAR }, \
std::string{ DESC }, __VA_ARGS__) }) \
.second) \
m_order.push_back(ENV_VAR);
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_SETTINGS_REFERENCE_IMPL)
# define TIMEMORY_SETTINGS_REFERENCE_IMPL(TYPE, FUNC, ENV_VAR, DESC, INIT) \
\
if(m_data \
.insert({ ENV_VAR, std::make_shared<tsettings<TYPE, TYPE&>>( \
INIT, std::string{ #FUNC }, \
std::string{ ENV_VAR }, std::string{ DESC }) }) \
.second) \
m_order.push_back(ENV_VAR);
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_SETTINGS_REFERENCE_ARG_IMPL)
# define TIMEMORY_SETTINGS_REFERENCE_ARG_IMPL(TYPE, FUNC, ENV_VAR, DESC, INIT, ...) \
if(m_data \
.insert( \
{ ENV_VAR, std::make_shared<tsettings<TYPE, TYPE&>>( \
INIT, std::string{ #FUNC }, std::string{ ENV_VAR }, \
std::string{ DESC }, __VA_ARGS__) }) \
.second) \
m_order.push_back(ENV_VAR);
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_ERROR_FUNCTION_MACRO)
# if defined(__PRETTY_FUNCTION__)
# define TIMEMORY_ERROR_FUNCTION_MACRO __PRETTY_FUNCTION__
# else
# define TIMEMORY_ERROR_FUNCTION_MACRO __FUNCTION__
# endif
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_SETTINGS_TRY_CATCH_NVP)
# define TIMEMORY_SETTINGS_TRY_CATCH_NVP(ENV_VAR, FUNC) \
try \
{ \
ar(cereal::make_nvp(ENV_VAR, FUNC())); \
} catch(...) \
{}
#endif
//
//--------------------------------------------------------------------------------------//
//
#if !defined(TIMEMORY_SETTINGS_EXTERN_TEMPLATE)
//
# if defined(TIMEMORY_SETTINGS_SOURCE)
//
# define TIMEMORY_SETTINGS_EXTERN_TEMPLATE(API) \
namespace tim \
{ \
template std::shared_ptr<settings> settings::shared_instance<API>(); \
template settings* settings::instance<API>(); \
template void settings::serialize_settings(cereal::JSONInputArchive&); \
template void settings::serialize_settings( \
cereal::PrettyJSONOutputArchive&); \
template void settings::serialize_settings( \
cereal::MinimalJSONOutputArchive&); \
template void settings::serialize_settings(cereal::JSONInputArchive&, \
settings&); \
template void settings::serialize_settings(cereal::PrettyJSONOutputArchive&, \
settings&); \
template void settings::serialize_settings( \
cereal::MinimalJSONOutputArchive&, settings&); \
template void settings::save(cereal::PrettyJSONOutputArchive&, \
const unsigned int) const; \
template void settings::save(cereal::MinimalJSONOutputArchive&, \
const unsigned int) const; \
template void settings::load(cereal::JSONInputArchive&, const unsigned int); \
}
//
# elif defined(TIMEMORY_USE_SETTINGS_EXTERN)
//
# define TIMEMORY_SETTINGS_EXTERN_TEMPLATE(API) \
namespace tim \
{ \
extern template std::shared_ptr<settings> settings::shared_instance<API>(); \
extern template settings* settings::instance<API>(); \
extern template void settings::serialize_settings( \
cereal::JSONInputArchive&); \
extern template void settings::serialize_settings( \
cereal::PrettyJSONOutputArchive&); \
extern template void settings::serialize_settings( \
cereal::MinimalJSONOutputArchive&); \
extern template void settings::serialize_settings(cereal::JSONInputArchive&, \
settings&); \
extern template void settings::serialize_settings( \
cereal::PrettyJSONOutputArchive&, settings&); \
extern template void settings::serialize_settings( \
cereal::MinimalJSONOutputArchive&, settings&); \
extern template void settings::save(cereal::PrettyJSONOutputArchive&, \
const unsigned int) const; \
extern template void settings::save(cereal::MinimalJSONOutputArchive&, \
const unsigned int) const; \
extern template void settings::load(cereal::JSONInputArchive&, \
const unsigned int); \
}
//
# else
//
# define TIMEMORY_SETTINGS_EXTERN_TEMPLATE(...)
//
# endif
#endif
//
//======================================================================================//
//
|
// SPDX-License-Identifier: AGPL-3.0-or-later
// SPDX-FileCopyrightText: 2020 Everton Fernando Patitucci da Silva
#include "../Renderer/RenderAPI.h"
#define RENDERER_INTERNAL
#include "Renderer/RenderInternal.h"
bool RenderAdd_SetTexture(RenderCmdList *cmdList, const SetTextureCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_SetTexture(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetFrameBuffer(RenderCmdList *cmdList, const SetFrameBufferCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_SetFrameBuffer(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DrawQuad(RenderCmdList *cmdList, const DrawQuadCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DrawQuad(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DrawRotatedQuad(RenderCmdList *cmdList, const DrawRotatedQuadCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DrawRotatedQuad(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DrawCharacterSitting(RenderCmdList *cmdList, const DrawCharacterSittingCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DrawCharacterSitting(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DrawLandTile(RenderCmdList *cmdList, const DrawLandTileCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DrawLandTile(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DrawShadow(RenderCmdList *cmdList, const DrawShadowCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DrawShadow(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DrawCircle(RenderCmdList *cmdList, const DrawCircleCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DrawCircle(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DrawUntexturedQuad(RenderCmdList *cmdList, const DrawUntexturedQuadCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DrawUntexturedQuad(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DrawLine(RenderCmdList *cmdList, const DrawLineCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DrawLine(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetAlphaTest(RenderCmdList *cmdList, const AlphaTestCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_AlphaTest(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DisableAlphaTest(RenderCmdList *cmdList)
{
DisableAlphaTestCmd cmd;
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DisableAlphaTest(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetBlend(RenderCmdList *cmdList, const BlendStateCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_BlendState(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DisableBlend(RenderCmdList *cmdList)
{
DisableBlendStateCmd cmd;
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DisableBlendState(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetStencil(RenderCmdList *cmdList, const StencilStateCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_StencilState(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DisableStencil(RenderCmdList *cmdList)
{
DisableStencilStateCmd cmd;
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DisableStencilState(cmd, &cmdList->state);
return true;
}
bool RenderAdd_EnableStencil(RenderCmdList *cmdList)
{
EnableStencilStateCmd cmd;
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_EnableStencilState(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetDepth(RenderCmdList *cmdList, const DepthStateCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DepthState(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DisableDepth(RenderCmdList *cmdList)
{
DisableDepthStateCmd cmd;
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DisableDepthState(cmd, &cmdList->state);
return true;
}
bool RenderAdd_EnableDepth(RenderCmdList *cmdList)
{
EnableDepthStateCmd cmd;
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_EnableDepthState(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetColorMask(RenderCmdList *cmdList, const SetColorMaskCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_SetColorMask(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetColor(RenderCmdList *cmdList, const SetColorCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_SetColor(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetClearColor(RenderCmdList *cmdList, const SetClearColorCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_SetClearColor(cmd, &cmdList->state);
return true;
}
bool RenderAdd_ClearRT(RenderCmdList *cmdList, const ClearRTCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_ClearRT(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetShaderUniform(RenderCmdList *cmdList, const ShaderUniformCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_ShaderUniform(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetShaderLargeUniform(RenderCmdList *cmdList, const ShaderLargeUniformCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_ShaderLargeUniform(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetShaderPipeline(RenderCmdList *cmdList, ShaderPipeline *pipeline)
{
// commenting this out to avoid vs2015 bug
// ShaderPipelineCmd cmd{ pipeline };
ShaderPipelineCmd cmd;
cmd.pipeline = pipeline;
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_ShaderPipeline(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DisableShaderPipeline(RenderCmdList *cmdList)
{
DisableShaderPipelineCmd cmd{};
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DisableShaderPipeline(cmd, &cmdList->state);
return true;
}
bool RenderAdd_FlushState(RenderCmdList *cmdList)
{
FlushStateCmd cmd;
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_FlushState(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetViewParams(RenderCmdList *cmdList, const SetViewParamsCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_SetViewParams(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetModelViewTranslation(
RenderCmdList *cmdList, const SetModelViewTranslationCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_SetModelViewTranslation(cmd, &cmdList->state);
return true;
}
bool RenderAdd_SetScissor(RenderCmdList *cmdList, const SetScissorCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_SetScissor(cmd, &cmdList->state);
return true;
}
bool RenderAdd_DisableScissor(RenderCmdList *cmdList)
{
DisableScissorCmd cmd;
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_DisableScissor(cmd, &cmdList->state);
return true;
}
bool RenderAdd_GetFrameBufferPixels(RenderCmdList *cmdList, const GetFrameBufferPixelsCmd &cmd)
{
auto ret = Render_AppendCmdType(cmdList, cmd._type, &cmd, sizeof(cmd));
if (!cmdList->immediateMode)
{
return ret;
}
RenderDraw_GetFrameBufferPixels(cmd, &cmdList->state);
return true;
} |
load SUBROUTINE
jsr openfile
bcc .pollblock
rts
.pollblock
jsr loadblock
bcc .pollblock
lda #$00
sta load_end
sta load_end+1
ldx storebyte + $01
cpx load_end
ldy storebyte + $02
iny
tya
sbc load_end+1
bcc .bla
stx load_end
sty load_end+1
.bla
rts
zp53 = $0c
zp54 = $0d
zp55 = $0e
; Zeropage vectors
;zp55 = $55 ;(6)
zp64 = $64 ;(7)
zpFA = $FA ;(9)
zpFC = $FC ;(16)
zpFE = $FE ;(2)
;---------
; Zeropage variables
zp00 = $00 ;(9)
zp01 = $01 ;(27)
zp02 = $02 ;(4)
zp03 = $03 ;(7)
zp18 = $18 ;(1)
zp22 = $22 ;(1)
zp23 = $23 ;(1)
zp24 = $24 ;(2)
zp33 = $33 ;(1)
zp34 = $34 ;(1)
;zp53 = $53 ;(2)
;zp54 = $54 ;(2)
zp61 = $61 ;(3)
zp62 = $62 ;(1)
zp63 = $63 ;(1)
zp66 = $66 ;(8)
zp90 = $90 ;(2)
zp99 = $99 ;(1)
zp9E = $9E ;(2)
zp9F = $9F ;(2)
zpA0 = $A0 ;(2)
zpA1 = $A1 ;(2)
zpAE = $AE ;(13)
zpEA = $EA ;(3)
zpF9 = $F9 ;(1)
;---------
V_FF93 = $FF93
S_FFA8 = $FFA8
S_FFAE = $FFAE
S_FFB1 = $FFB1
S_FFB7 = $FFB7
S_FFBA = $FFBA
S_FFBD = $FFBD
S_FFC0 = $FFC0
S_FFC3 = $FFC3
S_FFC6 = $FFC6
S_FFCC = $FFCC
S_FFCF = $FFCF
S_FFD2 = $FFD2
openfile
S_6600:
STY zp55+1
LDA #$09
STA zp01
LDA #$17
STA zp00
B_660A:
BIT zp01
BVC B_660A
STX zp55
LDY #$00
B_6612:
LDA (zp55),Y
PHA
PHA
LDA #$02
ORA $FF13 ; Char. Gen
STA $FF13 ; Char. Gen
PLA
LDX #$08
B_6621:
LSR
PHA
LDA zp01
AND #$FE
BCC B_662B
ORA #$01
B_662B:
EOR #$02
STA zp01
PLA
DEX
BNE B_6621
PHA
PLA
LDA #$FD
AND $FF13 ; Char. Gen
STA $FF13 ; Char. Gen
PLA
BEQ B_6645
INY
CPY #$10
BNE B_6612
B_6645:
LDA #$08
STA zp01
CLC
B_664A:
LDA #$00
TAX
B_664D:
RTS
;$664E --------
loadblock
S_664E:
LDA #$F8
LDX #$07
CPX zp00
BEQ B_664D
JSR S_6674
BCS B_6663
LDA #$07
BIT zp01
BPL B_664D
BCC B_664A
B_6663:
LDX #$0F
STX zp01
LDX #$07
STX zp00
CMP #$FE
BEQ B_664A
CLC
ADC #$FB
S_6672:
SEC
RTS
;$6674 --------
S_6674:
LDA #$00
LDX #$04
B_6678:
BIT zp01
BVC B_6678
BMI S_6672
STX zp01
JSR S_6672
LDA zp01
AND #$38
STA V_669E + 1
ORA #$00
LSR
LSR
EOR #$04
EOR V_669E + 1
LSR
LSR
EOR #$00
EOR V_669E + 1
LSR
LSR
EOR #$04
V_669E:
EOR #$00
STA V_6722 + 1
LDA #$00
STA zp01
LDA #$02
ORA $FF13 ; Char. Gen
STA $FF13 ; Char. Gen
JSR S_66ED
STA zp55+1
BNE B_66CF
JSR S_66ED
PHA
JSR S_66ED
STA zp53
STA zp55
JSR S_66ED
STA zp54
STA V_672B + 2
PLA
SEC
SBC #$02
BCS B_66EA
B_66CF:
CMP #$FE
BCS B_6732
LDA zp53
SBC zp55+1
PHP
CLC
SBC zp55+1
STA zp55
LDA zp54
ADC zp55+1
PLP
SBC #$01
STA V_672B + 2
JSR S_66ED
B_66EA:
LDY #$99
dc.b $2C
S_66ED:
LDY #$60
STY V_672B
TAX
EOR #$FF
CPY #$99
BNE B_6705
TAY
TXA
ADC zp55
STA V_672B + 1
BCS B_6705
DEC V_672B + 2
B_6705:
LDX #$04
LDA zp01
STX zp01
LSR
LSR
NOP
NOP
LDX #$00
EOR zp01
STX zp01
LSR
LSR
NOP
NOP
LDX #$04
EOR zp01
STX zp01
LSR
LSR
NOP
V_6722:
EOR #$00
LDX #$00
EOR.w $0001
STX zp01
storebyte
V_672B:
dc.b $99,$00,$00 ;STA.w $00,Y
INY
BNE B_6705
CLC
B_6732:
PHA
LDA #$FD
AND $FF13 ; Char. Gen
STA $FF13 ; Char. Gen
PLA
RTS
;$673D --------
; EOF
|
ADD R0 R0 3 ; 011
ADD R1 R1 6 ; 110
AND R2 R0 R1 ; 010
TRAP x25 |
architecture wdc65816-strict
include "../../../src/common/assert.inc"
constant a = 0x7e0100
assertZeroPage(a) // ERROR
|
; A152948: a(n) = (n^2 - 3*n + 6)/2.
; 2,2,3,5,8,12,17,23,30,38,47,57,68,80,93,107,122,138,155,173,192,212,233,255,278,302,327,353,380,408,437,467,498,530,563,597,632,668,705,743,782,822,863,905,948,992,1037,1083,1130,1178,1227,1277,1328,1380,1433,1487,1542,1598,1655,1713,1772,1832,1893,1955,2018,2082,2147,2213,2280,2348,2417,2487,2558,2630,2703,2777,2852,2928,3005,3083,3162,3242,3323,3405,3488,3572,3657,3743,3830,3918,4007,4097,4188,4280,4373,4467,4562,4658,4755,4853,4952,5052,5153,5255,5358,5462,5567,5673,5780,5888,5997,6107,6218,6330,6443,6557,6672,6788,6905,7023,7142,7262,7383,7505,7628,7752,7877,8003,8130,8258,8387,8517,8648,8780,8913,9047,9182,9318,9455,9593,9732,9872,10013,10155,10298,10442,10587,10733,10880,11028,11177,11327,11478,11630,11783,11937,12092,12248,12405,12563,12722,12882,13043,13205,13368,13532,13697,13863,14030,14198,14367,14537,14708,14880,15053,15227,15402,15578,15755,15933,16112,16292,16473,16655,16838,17022,17207,17393,17580,17768,17957,18147,18338,18530,18723,18917,19112,19308,19505,19703,19902,20102,20303,20505,20708,20912,21117,21323,21530,21738,21947,22157,22368,22580,22793,23007,23222,23438,23655,23873,24092,24312,24533,24755,24978,25202,25427,25653,25880,26108,26337,26567,26798,27030,27263,27497,27732,27968,28205,28443,28682,28922,29163,29405,29648,29892,30137,30383,30630,30878
bin $0,2
mov $1,$0
add $1,2
|
; int tape_save_block(void *addr, size_t len, unsigned char type)
; CALLER linkage for function pointers
PUBLIC tape_save_block
EXTERN asm_tape_save_block
.tape_save_block
pop de
pop bc
ld a,c
pop bc
pop hl
push hl
push bc
push bc ; altered !
push de
jp asm_tape_save_block
|
; A099487: Expansion of (1-3x+x^2)/((1+x^2)(1-4x+x^2)).
; 1,1,3,14,53,195,727,2716,10137,37829,141179,526890,1966381,7338631,27388143,102213944,381467633,1423656585,5313158707,19828978246,74002754277,276182038859,1030725401159,3846719565780,14356152861961
mov $5,$0
mov $7,2
lpb $7,1
clr $0,5
mov $0,$5
sub $7,1
add $0,$7
sub $0,1
mov $1,2
lpb $0,1
sub $0,1
add $3,1
add $1,$3
add $3,$1
add $1,$3
add $1,2
lpe
div $3,4
add $3,1
mov $1,$3
mov $8,$7
lpb $8,1
mov $6,$1
sub $8,1
lpe
lpe
lpb $5,1
mov $5,0
sub $6,$1
lpe
mov $1,$6
|
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) {
if (list1 == NULL)
return list2;
if(list2 == NULL)
return list1;
ListNode* head = new ListNode(-1);
ListNode* dummy = head;
ListNode* temp1 = list1;
ListNode* temp2 = list2;
while(temp1!=NULL && temp2!=NULL)
{
if(temp1->val<temp2->val)
{
ListNode* nextnode = new ListNode(temp1->val);
dummy->next = nextnode;
temp1 = temp1->next;
cout<<dummy->val;
}
else
{
ListNode* nextnode = new ListNode(temp2->val);
dummy->next = nextnode;
temp2 = temp2->next;
cout<<dummy->val;
}
dummy=dummy->next;
}
if(temp1!=NULL)
dummy->next = temp1;
if(temp2!=NULL)
dummy->next = temp2;
return head->next;
}
}; |
; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
org 100h
.MODEL SMALL
.STACK 100H
.DATA
PROMPT_1 DB 'Enter int 1 : $'
PROMPT_2 DB 'Enter int 2 : $'
PROMPT_3 DB 'Smallest int : $'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA DX, PROMPT_1
MOV AH, 9
INT 21H
MOV AH, 1
INT 21H
MOV BL, AL
MOV AH, 2
MOV DL, 0DH
INT 21H
MOV DL, 0AH
INT 21H
LEA DX, PROMPT_2
MOV AH, 9
INT 21H
MOV AH, 1
INT 21H
MOV BH, AL
MOV AH, 2
MOV DL, 0DH
INT 21H
MOV DL, 0AH
INT 21H
LEA DX, PROMPT_3
MOV AH, 9
INT 21H
CMP BL, BH
JNBE @ELSE
MOV DL, BL
JMP @DISPLAY
@ELSE:
MOV DL, BH
@DISPLAY:
MOV AH, 2
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
ret
|
// Copyright 2020 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 <fuchsia/sysmem/cpp/fidl.h>
#include <lib/sys/cpp/component_context.h>
#include <zircon/status.h>
#include <zircon/types.h>
#include "src/camera/lib/fake_camera/fake_camera.h"
#include "src/lib/testing/loop_fixture/real_loop_fixture.h"
constexpr auto kCameraIdentifier = "FakeCameraTest";
class FakeCameraTest : public gtest::RealLoopFixture {
public:
FakeCameraTest() { context_ = sys::ComponentContext::Create(); }
protected:
virtual void SetUp() override {
context_->svc()->Connect(allocator_.NewRequest());
allocator_.set_error_handler(MakeErrorHandler("Sysmem Allocator"));
}
virtual void TearDown() override {
allocator_ = nullptr;
RunLoopUntilIdle();
}
static fit::function<void(zx_status_t status)> MakeErrorHandler(std::string server) {
return [server](zx_status_t status) {
ADD_FAILURE() << server << " server disconnected - " << status;
};
}
template <class T>
static void SetFailOnError(fidl::InterfacePtr<T>& ptr, std::string name = T::Name_) {
ptr.set_error_handler([=](zx_status_t status) {
ADD_FAILURE() << name << " server disconnected: " << zx_status_get_string(status);
});
}
std::unique_ptr<sys::ComponentContext> context_;
fuchsia::sysmem::AllocatorPtr allocator_;
};
TEST_F(FakeCameraTest, InvalidArgs) {
{ // No configurations.
auto result = camera::FakeCamera::Create(kCameraIdentifier, {});
ASSERT_TRUE(result.is_error());
EXPECT_EQ(result.error(), ZX_ERR_INVALID_ARGS);
}
{ // No streams.
std::vector<camera::FakeConfiguration> configs;
configs.push_back({});
auto result = camera::FakeCamera::Create(kCameraIdentifier, std::move(configs));
ASSERT_TRUE(result.is_error());
EXPECT_EQ(result.error(), ZX_ERR_INVALID_ARGS);
}
{ // Null stream.
camera::FakeConfiguration config;
config.push_back(nullptr);
std::vector<camera::FakeConfiguration> configs;
configs.push_back(std::move(config));
auto result = camera::FakeCamera::Create(kCameraIdentifier, std::move(configs));
ASSERT_TRUE(result.is_error());
EXPECT_EQ(result.error(), ZX_ERR_INVALID_ARGS);
}
}
TEST_F(FakeCameraTest, SetBufferCollectionInvokesCallback) {
fuchsia::camera3::StreamProperties properties{
.image_format{.pixel_format{.type = fuchsia::sysmem::PixelFormatType::NV12},
.coded_width = 256,
.coded_height = 128,
.bytes_per_row = 256,
.color_space{.type = fuchsia::sysmem::ColorSpaceType::REC601_NTSC}},
.frame_rate{
.numerator = 30,
.denominator = 1,
}};
bool callback_invoked = false;
auto stream_result = camera::FakeStream::Create(
std::move(properties),
[&](fidl::InterfaceHandle<fuchsia::sysmem::BufferCollectionToken> token) {
callback_invoked = true;
});
ASSERT_TRUE(stream_result.is_ok());
std::shared_ptr<camera::FakeStream> stream = stream_result.take_value();
camera::FakeConfiguration config;
config.push_back(stream);
std::vector<camera::FakeConfiguration> configs;
configs.push_back(std::move(config));
auto camera_result = camera::FakeCamera::Create(kCameraIdentifier, std::move(configs));
ASSERT_TRUE(camera_result.is_ok());
auto camera = camera_result.take_value();
fuchsia::camera3::DevicePtr device_protocol;
SetFailOnError(device_protocol, "Device");
fuchsia::camera3::StreamPtr stream_protocol;
SetFailOnError(stream_protocol, "Stream");
camera->GetHandler()(device_protocol.NewRequest());
device_protocol->GetConfigurations(
[&](std::vector<fuchsia::camera3::Configuration> configurations) {
ASSERT_FALSE(configurations.empty());
ASSERT_FALSE(configurations[0].streams.empty());
device_protocol->ConnectToStream(0, stream_protocol.NewRequest());
fidl::InterfaceHandle<fuchsia::sysmem::BufferCollectionToken> token;
allocator_->AllocateSharedCollection(token.NewRequest());
stream_protocol->SetBufferCollection(std::move(token));
});
RunLoopUntil([&]() { return HasFailure() || callback_invoked; });
}
|
; A273053: Numbers n such that 15*n^2 + 16 is a square.
; Submitted by Jon Maiga
; 0,4,32,252,1984,15620,122976,968188,7622528,60012036,472473760,3719778044,29285750592,230566226692,1815244062944,14291386276860,112515846151936,885835382938628,6974167217357088,54907502355918076,432285851629987520,3403379310683982084,26794748633841869152,210954609760050971132,1660842129446565899904,13075782425812476228100,102945417277053243924896,810487555790613475171068,6380955029047854557443648,50237152676592222984378116,395516266383689929317581280,3113892978392927211556272124
mov $3,1
lpb $0
sub $0,1
mul $1,6
add $3,$1
add $2,$3
mov $1,$2
lpe
mov $0,$2
mul $0,4
|
/*
*********************************************************************************************************
* uC/CPU
* CPU CONFIGURATION & PORT LAYER
*
* (c) Copyright 2004-2015; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/CPU is provided in source form to registered licensees ONLY. It is
* illegal to distribute this source code to any third party unless you receive
* written permission by an authorized Micrium representative. Knowledge of
* the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*
* You can find our product's user manual, API reference, release notes and
* more information at https://doc.micrium.com.
* You can contact us at www.micrium.com.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* CPU PORT FILE
*
* Atmel AVR32 UC3
* IAR C Compiler
*
* Filename : cpu_a.asm
* Version : V1.30.02.00
* Programmer(s) : FGK
* ITJ
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* ASM HEADER
*********************************************************************************************************
*/
MODULE CPU_A
RSEG CODE32:CODE
EXTERN __program_start
/*
*********************************************************************************************************
* DEFINES
*********************************************************************************************************
*/
CPU_SR_OFFSET EQU 0 /* Status Register offset in System Register */
CPU_SR_GM_OFFSET EQU 16 /* Status Register, Global Interrupt Mask Offset */
CPU_SR_GM_MASK EQU 0x00010000 /* Status Register, Global Interrupt Mask */
CPU_SR_EM_OFFSET EQU 21 /* Status Register, Exception Mask Offset */
CPU_SR_M0_MASK EQU 0x00400000 /* Status Register, Supervisor Execution Mode Mask */
CPU_SR_MX_OFFSET EQU 22 /* Status Register, Execution Mode Mask offset */
CPU_SR_MX_SUPERVISOR_MODE EQU 0x00000001 /* Status Register, Execution Mode Supervisor */
CPU_COUNT_OFFSET EQU 0x00000108 /* Count Register offset in System Register */
CPU_CONFIG0_OFFSET EQU 0x00000100 /* Config0 Register offset in System Register */
CPU_COMPARE_OFFSET EQU 0x0000010C /* Compare Register offset in System Register */
/*
*********************************************************************************************************
* PUBLIC DECLARATIONS
*********************************************************************************************************
*/
PUBLIC CPU_SR_Save
PUBLIC CPU_SR_Restore
PUBLIC CPU_IntDis
PUBLIC CPU_IntEn
PUBLIC CPU_ExceptDis
PUBLIC CPU_ExceptEn
PUBLIC CPU_Reset
PUBLIC CPU_SysReg_Get_Count
PUBLIC CPU_SysReg_Get_Config0
PUBLIC CPU_SysReg_Set_Compare
PUBLIC CPU_SysReg_Get_Compare
PUBLIC CPU_CntLeadZeros
/*
*********************************************************************************************************
* CRITICAL SECTION FUNCTIONS
*
* Description : These functions are used to enter and exit critical sections using Critical Method #3.
*
* CPU_SR CPU_SR_Save (void)
* Get current global interrupt mask bit value from SR
* Disable interrupts
* Return global interrupt mask bit
*
* void CPU_SR_Restore (CPU_SR cpu_sr)
* Set global interrupt mask bit on SR according to parameter sr
* Return
*
* Argument(s) : cpu_sr global interrupt mask status.
*
* Note(s) : (1) Besides global interrupt mask bit, all other status register bits are kept unchanged.
*
* (2) Two NOP are required for properly disable interrupts.
*********************************************************************************************************
*/
CPU_SR_Save:
CSRFCZ CPU_SR_GM_OFFSET /* Retrieve GM bit from SR */
SRCS R12 /* if (GM == 1) set R12 */
SSRF CPU_SR_GM_OFFSET /* set global interrupt mask (disable interrupts) */
NOP
NOP
MOV PC, LR /* Restore Program Counter (return) */
CPU_SR_Restore:
PUSHM R11 /* Save R11 into stack */
MFSR R11, CPU_SR_OFFSET /* Retrieve current Status Register */
LSR R12, 1 /* Copy interrupt status to Carry */
BST R11, CPU_SR_GM_OFFSET /* Overwrite GM bit based on Carry */
MTSR CPU_SR_OFFSET, R11 /* Restore Status Register GM with previous interrupt */
/* ... status value */
POPM R11 /* Restore R11 from stack */
MOV PC, LR /* Restore Program Counter (return) */
/*
*********************************************************************************************************
* DISABLE/ENABLE INTERRUPTS
*
* Description : Disable/Enable interrupts by setting or clearing the global interrupt mask in the cpu
* status register.
*
* void CPU_IntDis (void)
* Set global interrupt mask bit on SR
* Return
*
* void CPU_IntEn (void)
* Clear global interrupt mask bit on SR
* Return
*********************************************************************************************************
*/
CPU_IntDis:
SSRF CPU_SR_GM_OFFSET /* set global interrupt mask (disable interrupts) */
NOP
NOP
MOV PC, LR /* Restore Program Counter (return) */
CPU_IntEn:
CSRF CPU_SR_GM_OFFSET /* clear global interrupt mask (enable interrupts) */
MOV PC, LR /* Restore Program Counter (return) */
/*
*********************************************************************************************************
* DISABLE/ENABLE EXCEPTIONS
*
* Description : These functions are used to disable and enable exceptions by setting or clearing the
* exception mask in the cpu status register.
*
* void CPU_ExceptDis (void)
* Set exception mask bit on SR
* Return
*
* void CPU_ExcepttEn (void)
* Clear exception mask bit on SR
* Return
*********************************************************************************************************
*/
CPU_ExceptDis:
SSRF CPU_SR_EM_OFFSET /* set exception mask (disable exceptions) */
MOV PC, LR /* Restore Program Counter (return) */
CPU_ExceptEn:
CSRF CPU_SR_EM_OFFSET /* clear exceptions mask (enable exceptions) */
MOV PC, LR /* Restore Program Counter (return) */
/*
*********************************************************************************************************
* RESET CPU
*
* Description : This function is used to reset the CPU by returning to the reset vector.
*
* void CPU_Reset (void)
* if (current SR == 001b) {
* Push PC (START)
* Push clean SR (GM | M0)
* RETS
* } else {
* Push clean R8 (0x08080808)
* Push clean R9 (0x09090909)
* Push clean R10 (0x10101010)
* Push clean R11 (0x11111111)
* Push clean R12 (0x00000000)
* Push clean LR (0x14141414)
* Push PC (START)
* Push clean SR (GM | M0)
* RETE
* }
*********************************************************************************************************
*/
CPU_Reset:
MFSR R8, CPU_SR_OFFSET
BFEXTU R8, R8, CPU_SR_MX_OFFSET, 3
CP.W R8, CPU_SR_MX_SUPERVISOR_MODE
BRNE CPU_Reset_RETE
MOV R8, LWRD(__program_start)
ORH R8, HWRD(__program_start)
MOV R9, LWRD(CPU_SR_GM_MASK | CPU_SR_M0_MASK)
ORH R9, HWRD(CPU_SR_GM_MASK | CPU_SR_M0_MASK)
STM --SP, R8-R9 /* Push PC and SR */
RETS
CPU_Reset_RETE:
MOV R8, 0x0808
ORH R8, 0x0808
MOV R9, 0x0909
ORH R9, 0x0909
MOV R10, 0x1010
ORH R10, 0x1010
MOV R11, 0x1111
ORH R11, 0x1111
MOV R12, 0x0000
ORH R12, 0x0000
MOV LR, 0x1414
ORH LR, 0x1414
STM --SP, R8-R12, LR /* Push R8-R12, LR */
MOV R8, LWRD(__program_start)
ORH R8, HWRD(__program_start)
MOV R9, LWRD(CPU_SR_GM_MASK | CPU_SR_M0_MASK)
ORH R9, HWRD(CPU_SR_GM_MASK | CPU_SR_M0_MASK)
STM --SP, R8-R9 /* Push PC and SR */
RETE
/*
*********************************************************************************************************
* GET/SET SYSTEM REGISTERS
*
* Description : These functions are used to get/set specific system registers.
*
* CPU_INT32U CPU_SysReg_Get_Count (void)
* CPU_INT32U CPU_SysReg_Get_Config0 (void)
* CPU_INT32U CPU_SysReg_Get_Compare (void)
* void CPU_SysReg_Set_Compare (CPU_INT32U value)
*********************************************************************************************************
*/
CPU_SysReg_Get_Count:
MFSR R12, CPU_COUNT_OFFSET /* Retrieve COUNT system register */
MOV PC, LR /* Restore Program Counter (return) */
CPU_SysReg_Get_Config0:
MFSR R12, CPU_CONFIG0_OFFSET /* Retrieve CONFIG0 system register */
MOV PC, LR /* Restore Program Counter (return) */
CPU_SysReg_Get_Compare:
MFSR R12, CPU_COMPARE_OFFSET /* Retrieve COMPARE system register */
MOV PC, LR /* Restore Program Counter (return) */
CPU_SysReg_Set_Compare:
MTSR CPU_COMPARE_OFFSET, R12 /* Save COMPARE system register */
MOV PC, LR /* Restore Program Counter (return) */
/*
*********************************************************************************************************
* CPU_CntLeadZeros()
* COUNT LEADING ZEROS
*
* Description : Counts the number of contiguous, most-significant, leading zero bits before the
* first binary one bit in a data value.
*
* Prototype : CPU_DATA CPU_CntLeadZeros(CPU_DATA val);
*
* Argument(s) : val Data value to count leading zero bits.
*
* Return(s) : Number of contiguous, most-significant, leading zero bits in 'val'.
*
* Caller(s) : Application.
*
* This function is an INTERNAL CPU module function but MAY be called by application
* function(s).
*
* Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h
* CPU WORD CONFIGURATION Note #1').
*
* (b) For 32-bit values :
*
* b31 b30 b29 ... b04 b03 b02 b01 b00 # Leading Zeros
* --- --- --- --- --- --- --- --- ---------------
* 1 x x x x x x x 0
* 0 1 x x x x x x 1
* 0 0 1 x x x x x 2
* : : : : : : : : :
* : : : : : : : : :
* 0 0 0 1 x x x x 27
* 0 0 0 0 1 x x x 28
* 0 0 0 0 0 1 x x 29
* 0 0 0 0 0 0 1 x 30
* 0 0 0 0 0 0 0 1 31
* 0 0 0 0 0 0 0 0 32
*
*
* (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_LEAD_ZEROS_ASM_PRESENT
* is #define'd in 'cpu_cfg.h' or 'cpu.h'.
*********************************************************************************************************
*/
CPU_CntLeadZeros:
CLZ R12, R12 /* Count leading zeros */
MOV PC, LR /* Restore Program Counter (return) */
/*
*********************************************************************************************************
* CPU ASSEMBLY PORT FILE END
*********************************************************************************************************
*/
END
|
SECTION code_fp_am9511
PUBLIC ___fsneq
EXTERN cam32_sdcc___fsneq
defc ___fsneq = cam32_sdcc___fsneq
|
DOWNLOAD_CHUNK_SIZE = 1024 * 1024
proc Download Url:DWORD, Size:DWORD
local Internet:DWORD
local UrlHandle:DWORD
local File:DWORD
local BytesRead:DWORD
local TotalBytesRead:DWORD
local ReadSuccess:DWORD
mov [Internet], 0
mov [UrlHandle], 0
mov [File], 0
mov [BytesRead], 0
mov [TotalBytesRead], 0
; Create internet connection
pebcall PEB_WininetDll, PEB_InternetOpenW, NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0
test eax, eax
jz .ret
mov [Internet], eax
; Create URL handle
pebcall PEB_WininetDll, PEB_InternetOpenUrlW, [Internet], [Url], NULL, 0, 0, 0
test eax, eax
jz .ret
mov [UrlHandle], eax
; Allocate buffer
pebcall PEB_Kernel32Dll, PEB_GetProcessHeap
pebcall PEB_NtdllDll, PEB_RtlAllocateHeap, eax, 0, DOWNLOAD_CHUNK_SIZE
test eax, eax
jz .ret
mov [File], eax
.L_download:
; Download chunk
mov eax, [File]
add eax, [TotalBytesRead]
lea ebx, [BytesRead]
pebcall PEB_WininetDll, PEB_InternetReadFile, [UrlHandle], eax, DOWNLOAD_CHUNK_SIZE, ebx
mov [ReadSuccess], eax
; Add to total size
mov eax, [BytesRead]
add [TotalBytesRead], eax
; Increase buffer size
pebcall PEB_Kernel32Dll, PEB_GetProcessHeap
mov ebx, [TotalBytesRead]
add ebx, DOWNLOAD_CHUNK_SIZE
pebcall PEB_NtdllDll, PEB_RtlReAllocateHeap, eax, 0, [File], ebx
mov [File], eax
test eax, eax
jz .ret
; InternetReadFile completed, if it returned TRUE and BytesRead == 0
cmp [ReadSuccess], 0
je .L_download
cmp [BytesRead], 0
jne .L_download
.ret:
; Close handles
pebcall PEB_WininetDll, PEB_InternetCloseHandle, [UrlHandle]
pebcall PEB_WininetDll, PEB_InternetCloseHandle, [Internet]
; Store allocated memory in eax
mov eax, [File]
; Store size of downloaded file in [Size] out parameter
mov edx, [TotalBytesRead]
mov ebx, [Size]
mov [ebx], edx
ret
endp |
// Copyright 2014 the V8 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.
#include "src/compiler/instruction-selector.h"
#include "src/compiler/graph.h"
#include "src/compiler/instruction-selector-impl.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties-inl.h"
#include "src/compiler/pipeline.h"
namespace v8 {
namespace internal {
namespace compiler {
InstructionSelector::InstructionSelector(Zone* local_zone, Graph* graph,
Linkage* linkage,
InstructionSequence* sequence,
Schedule* schedule,
SourcePositionTable* source_positions,
Features features)
: zone_(local_zone),
linkage_(linkage),
sequence_(sequence),
source_positions_(source_positions),
features_(features),
schedule_(schedule),
node_map_(graph->NodeCount(), kNodeUnmapped, zone()),
current_block_(NULL),
instructions_(zone()),
defined_(graph->NodeCount(), false, zone()),
used_(graph->NodeCount(), false, zone()) {}
void InstructionSelector::SelectInstructions() {
// Mark the inputs of all phis in loop headers as used.
BasicBlockVector* blocks = schedule()->rpo_order();
for (BasicBlockVectorIter i = blocks->begin(); i != blocks->end(); ++i) {
BasicBlock* block = *i;
if (!block->IsLoopHeader()) continue;
DCHECK_NE(0, static_cast<int>(block->PredecessorCount()));
DCHECK_NE(1, static_cast<int>(block->PredecessorCount()));
for (BasicBlock::const_iterator j = block->begin(); j != block->end();
++j) {
Node* phi = *j;
if (phi->opcode() != IrOpcode::kPhi) continue;
// Mark all inputs as used.
for (Node* const k : phi->inputs()) {
MarkAsUsed(k);
}
}
}
// Visit each basic block in post order.
for (BasicBlockVectorRIter i = blocks->rbegin(); i != blocks->rend(); ++i) {
VisitBlock(*i);
}
// Schedule the selected instructions.
for (BasicBlockVectorIter i = blocks->begin(); i != blocks->end(); ++i) {
BasicBlock* block = *i;
InstructionBlock* instruction_block =
sequence()->InstructionBlockAt(block->GetRpoNumber());
size_t end = instruction_block->code_end();
size_t start = instruction_block->code_start();
sequence()->StartBlock(block->GetRpoNumber());
while (start-- > end) {
sequence()->AddInstruction(instructions_[start]);
}
sequence()->EndBlock(block->GetRpoNumber());
}
}
Instruction* InstructionSelector::Emit(InstructionCode opcode,
InstructionOperand* output,
size_t temp_count,
InstructionOperand** temps) {
size_t output_count = output == NULL ? 0 : 1;
return Emit(opcode, output_count, &output, 0, NULL, temp_count, temps);
}
Instruction* InstructionSelector::Emit(InstructionCode opcode,
InstructionOperand* output,
InstructionOperand* a, size_t temp_count,
InstructionOperand** temps) {
size_t output_count = output == NULL ? 0 : 1;
return Emit(opcode, output_count, &output, 1, &a, temp_count, temps);
}
Instruction* InstructionSelector::Emit(InstructionCode opcode,
InstructionOperand* output,
InstructionOperand* a,
InstructionOperand* b, size_t temp_count,
InstructionOperand** temps) {
size_t output_count = output == NULL ? 0 : 1;
InstructionOperand* inputs[] = {a, b};
size_t input_count = arraysize(inputs);
return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
temps);
}
Instruction* InstructionSelector::Emit(InstructionCode opcode,
InstructionOperand* output,
InstructionOperand* a,
InstructionOperand* b,
InstructionOperand* c, size_t temp_count,
InstructionOperand** temps) {
size_t output_count = output == NULL ? 0 : 1;
InstructionOperand* inputs[] = {a, b, c};
size_t input_count = arraysize(inputs);
return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
temps);
}
Instruction* InstructionSelector::Emit(
InstructionCode opcode, InstructionOperand* output, InstructionOperand* a,
InstructionOperand* b, InstructionOperand* c, InstructionOperand* d,
size_t temp_count, InstructionOperand** temps) {
size_t output_count = output == NULL ? 0 : 1;
InstructionOperand* inputs[] = {a, b, c, d};
size_t input_count = arraysize(inputs);
return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
temps);
}
Instruction* InstructionSelector::Emit(
InstructionCode opcode, InstructionOperand* output, InstructionOperand* a,
InstructionOperand* b, InstructionOperand* c, InstructionOperand* d,
InstructionOperand* e, size_t temp_count, InstructionOperand** temps) {
size_t output_count = output == NULL ? 0 : 1;
InstructionOperand* inputs[] = {a, b, c, d, e};
size_t input_count = arraysize(inputs);
return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
temps);
}
Instruction* InstructionSelector::Emit(
InstructionCode opcode, InstructionOperand* output, InstructionOperand* a,
InstructionOperand* b, InstructionOperand* c, InstructionOperand* d,
InstructionOperand* e, InstructionOperand* f, size_t temp_count,
InstructionOperand** temps) {
size_t output_count = output == NULL ? 0 : 1;
InstructionOperand* inputs[] = {a, b, c, d, e, f};
size_t input_count = arraysize(inputs);
return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
temps);
}
Instruction* InstructionSelector::Emit(
InstructionCode opcode, size_t output_count, InstructionOperand** outputs,
size_t input_count, InstructionOperand** inputs, size_t temp_count,
InstructionOperand** temps) {
Instruction* instr =
Instruction::New(instruction_zone(), opcode, output_count, outputs,
input_count, inputs, temp_count, temps);
return Emit(instr);
}
Instruction* InstructionSelector::Emit(Instruction* instr) {
instructions_.push_back(instr);
return instr;
}
bool InstructionSelector::CanCover(Node* user, Node* node) const {
return node->OwnedBy(user) &&
schedule()->block(node) == schedule()->block(user);
}
int InstructionSelector::GetVirtualRegister(const Node* node) {
if (node_map_[node->id()] == kNodeUnmapped) {
node_map_[node->id()] = sequence()->NextVirtualRegister();
}
return node_map_[node->id()];
}
int InstructionSelector::GetMappedVirtualRegister(const Node* node) const {
return node_map_[node->id()];
}
bool InstructionSelector::IsDefined(Node* node) const {
DCHECK_NOT_NULL(node);
NodeId id = node->id();
DCHECK(id >= 0);
DCHECK(id < static_cast<NodeId>(defined_.size()));
return defined_[id];
}
void InstructionSelector::MarkAsDefined(Node* node) {
DCHECK_NOT_NULL(node);
NodeId id = node->id();
DCHECK(id >= 0);
DCHECK(id < static_cast<NodeId>(defined_.size()));
defined_[id] = true;
}
bool InstructionSelector::IsUsed(Node* node) const {
if (!node->op()->HasProperty(Operator::kEliminatable)) return true;
NodeId id = node->id();
DCHECK(id >= 0);
DCHECK(id < static_cast<NodeId>(used_.size()));
return used_[id];
}
void InstructionSelector::MarkAsUsed(Node* node) {
DCHECK_NOT_NULL(node);
NodeId id = node->id();
DCHECK(id >= 0);
DCHECK(id < static_cast<NodeId>(used_.size()));
used_[id] = true;
}
bool InstructionSelector::IsDouble(const Node* node) const {
DCHECK_NOT_NULL(node);
int virtual_register = GetMappedVirtualRegister(node);
if (virtual_register == kNodeUnmapped) return false;
return sequence()->IsDouble(virtual_register);
}
void InstructionSelector::MarkAsDouble(Node* node) {
DCHECK_NOT_NULL(node);
DCHECK(!IsReference(node));
sequence()->MarkAsDouble(GetVirtualRegister(node));
}
bool InstructionSelector::IsReference(const Node* node) const {
DCHECK_NOT_NULL(node);
int virtual_register = GetMappedVirtualRegister(node);
if (virtual_register == kNodeUnmapped) return false;
return sequence()->IsReference(virtual_register);
}
void InstructionSelector::MarkAsReference(Node* node) {
DCHECK_NOT_NULL(node);
DCHECK(!IsDouble(node));
sequence()->MarkAsReference(GetVirtualRegister(node));
}
void InstructionSelector::MarkAsRepresentation(MachineType rep,
InstructionOperand* op) {
UnallocatedOperand* unalloc = UnallocatedOperand::cast(op);
switch (RepresentationOf(rep)) {
case kRepFloat32:
case kRepFloat64:
sequence()->MarkAsDouble(unalloc->virtual_register());
break;
case kRepTagged:
sequence()->MarkAsReference(unalloc->virtual_register());
break;
default:
break;
}
}
void InstructionSelector::MarkAsRepresentation(MachineType rep, Node* node) {
DCHECK_NOT_NULL(node);
switch (RepresentationOf(rep)) {
case kRepFloat32:
case kRepFloat64:
MarkAsDouble(node);
break;
case kRepTagged:
MarkAsReference(node);
break;
default:
break;
}
}
// TODO(bmeurer): Get rid of the CallBuffer business and make
// InstructionSelector::VisitCall platform independent instead.
CallBuffer::CallBuffer(Zone* zone, const CallDescriptor* d,
FrameStateDescriptor* frame_desc)
: descriptor(d),
frame_state_descriptor(frame_desc),
output_nodes(zone),
outputs(zone),
instruction_args(zone),
pushed_nodes(zone) {
output_nodes.reserve(d->ReturnCount());
outputs.reserve(d->ReturnCount());
pushed_nodes.reserve(input_count());
instruction_args.reserve(input_count() + frame_state_value_count());
}
// TODO(bmeurer): Get rid of the CallBuffer business and make
// InstructionSelector::VisitCall platform independent instead.
void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
bool call_code_immediate,
bool call_address_immediate) {
OperandGenerator g(this);
DCHECK_EQ(call->op()->ValueOutputCount(),
static_cast<int>(buffer->descriptor->ReturnCount()));
DCHECK_EQ(
call->op()->ValueInputCount(),
static_cast<int>(buffer->input_count() + buffer->frame_state_count()));
if (buffer->descriptor->ReturnCount() > 0) {
// Collect the projections that represent multiple outputs from this call.
if (buffer->descriptor->ReturnCount() == 1) {
buffer->output_nodes.push_back(call);
} else {
buffer->output_nodes.resize(buffer->descriptor->ReturnCount(), NULL);
call->CollectProjections(&buffer->output_nodes);
}
// Filter out the outputs that aren't live because no projection uses them.
size_t outputs_needed_by_framestate =
buffer->frame_state_descriptor == NULL
? 0
: buffer->frame_state_descriptor->state_combine()
.ConsumedOutputCount();
for (size_t i = 0; i < buffer->output_nodes.size(); i++) {
bool output_is_live =
buffer->output_nodes[i] != NULL || i < outputs_needed_by_framestate;
if (output_is_live) {
MachineType type =
buffer->descriptor->GetReturnType(static_cast<int>(i));
LinkageLocation location =
buffer->descriptor->GetReturnLocation(static_cast<int>(i));
Node* output = buffer->output_nodes[i];
InstructionOperand* op =
output == NULL ? g.TempLocation(location, type)
: g.DefineAsLocation(output, location, type);
MarkAsRepresentation(type, op);
buffer->outputs.push_back(op);
}
}
}
// The first argument is always the callee code.
Node* callee = call->InputAt(0);
switch (buffer->descriptor->kind()) {
case CallDescriptor::kCallCodeObject:
buffer->instruction_args.push_back(
(call_code_immediate && callee->opcode() == IrOpcode::kHeapConstant)
? g.UseImmediate(callee)
: g.UseRegister(callee));
break;
case CallDescriptor::kCallAddress:
buffer->instruction_args.push_back(
(call_address_immediate &&
(callee->opcode() == IrOpcode::kInt32Constant ||
callee->opcode() == IrOpcode::kInt64Constant))
? g.UseImmediate(callee)
: g.UseRegister(callee));
break;
case CallDescriptor::kCallJSFunction:
buffer->instruction_args.push_back(
g.UseLocation(callee, buffer->descriptor->GetInputLocation(0),
buffer->descriptor->GetInputType(0)));
break;
}
DCHECK_EQ(1, static_cast<int>(buffer->instruction_args.size()));
// If the call needs a frame state, we insert the state information as
// follows (n is the number of value inputs to the frame state):
// arg 1 : deoptimization id.
// arg 2 - arg (n + 1) : value inputs to the frame state.
if (buffer->frame_state_descriptor != NULL) {
InstructionSequence::StateId state_id =
sequence()->AddFrameStateDescriptor(buffer->frame_state_descriptor);
buffer->instruction_args.push_back(g.TempImmediate(state_id.ToInt()));
Node* frame_state =
call->InputAt(static_cast<int>(buffer->descriptor->InputCount()));
AddFrameStateInputs(frame_state, &buffer->instruction_args,
buffer->frame_state_descriptor);
}
DCHECK(1 + buffer->frame_state_value_count() ==
buffer->instruction_args.size());
size_t input_count = static_cast<size_t>(buffer->input_count());
// Split the arguments into pushed_nodes and instruction_args. Pushed
// arguments require an explicit push instruction before the call and do
// not appear as arguments to the call. Everything else ends up
// as an InstructionOperand argument to the call.
auto iter(call->inputs().begin());
int pushed_count = 0;
for (size_t index = 0; index < input_count; ++iter, ++index) {
DCHECK(iter != call->inputs().end());
DCHECK((*iter)->op()->opcode() != IrOpcode::kFrameState);
if (index == 0) continue; // The first argument (callee) is already done.
InstructionOperand* op =
g.UseLocation(*iter, buffer->descriptor->GetInputLocation(index),
buffer->descriptor->GetInputType(index));
if (UnallocatedOperand::cast(op)->HasFixedSlotPolicy()) {
int stack_index = -UnallocatedOperand::cast(op)->fixed_slot_index() - 1;
if (static_cast<size_t>(stack_index) >= buffer->pushed_nodes.size()) {
buffer->pushed_nodes.resize(stack_index + 1, NULL);
}
DCHECK_EQ(NULL, buffer->pushed_nodes[stack_index]);
buffer->pushed_nodes[stack_index] = *iter;
pushed_count++;
} else {
buffer->instruction_args.push_back(op);
}
}
CHECK_EQ(pushed_count, static_cast<int>(buffer->pushed_nodes.size()));
DCHECK(static_cast<size_t>(input_count) ==
(buffer->instruction_args.size() + buffer->pushed_nodes.size() -
buffer->frame_state_value_count()));
}
void InstructionSelector::VisitBlock(BasicBlock* block) {
DCHECK_EQ(NULL, current_block_);
current_block_ = block;
int current_block_end = static_cast<int>(instructions_.size());
// Generate code for the block control "top down", but schedule the code
// "bottom up".
VisitControl(block);
std::reverse(instructions_.begin() + current_block_end, instructions_.end());
// Visit code in reverse control flow order, because architecture-specific
// matching may cover more than one node at a time.
for (BasicBlock::reverse_iterator i = block->rbegin(); i != block->rend();
++i) {
Node* node = *i;
// Skip nodes that are unused or already defined.
if (!IsUsed(node) || IsDefined(node)) continue;
// Generate code for this node "top down", but schedule the code "bottom
// up".
size_t current_node_end = instructions_.size();
VisitNode(node);
std::reverse(instructions_.begin() + current_node_end, instructions_.end());
}
// We're done with the block.
InstructionBlock* instruction_block =
sequence()->InstructionBlockAt(block->GetRpoNumber());
instruction_block->set_code_start(static_cast<int>(instructions_.size()));
instruction_block->set_code_end(current_block_end);
current_block_ = NULL;
}
static inline void CheckNoPhis(const BasicBlock* block) {
#ifdef DEBUG
// Branch targets should not have phis.
for (BasicBlock::const_iterator i = block->begin(); i != block->end(); ++i) {
const Node* node = *i;
CHECK_NE(IrOpcode::kPhi, node->opcode());
}
#endif
}
void InstructionSelector::VisitControl(BasicBlock* block) {
Node* input = block->control_input();
switch (block->control()) {
case BasicBlock::kGoto:
return VisitGoto(block->SuccessorAt(0));
case BasicBlock::kBranch: {
DCHECK_EQ(IrOpcode::kBranch, input->opcode());
BasicBlock* tbranch = block->SuccessorAt(0);
BasicBlock* fbranch = block->SuccessorAt(1);
// SSA deconstruction requires targets of branches not to have phis.
// Edge split form guarantees this property, but is more strict.
CheckNoPhis(tbranch);
CheckNoPhis(fbranch);
if (tbranch == fbranch) return VisitGoto(tbranch);
return VisitBranch(input, tbranch, fbranch);
}
case BasicBlock::kReturn: {
// If the result itself is a return, return its input.
Node* value = (input != NULL && input->opcode() == IrOpcode::kReturn)
? input->InputAt(0)
: input;
return VisitReturn(value);
}
case BasicBlock::kThrow:
return VisitThrow(input);
case BasicBlock::kNone: {
// TODO(titzer): exit block doesn't have control.
DCHECK(input == NULL);
break;
}
default:
UNREACHABLE();
break;
}
}
MachineType InstructionSelector::GetMachineType(Node* node) {
DCHECK_NOT_NULL(schedule()->block(node)); // should only use scheduled nodes.
switch (node->opcode()) {
case IrOpcode::kStart:
case IrOpcode::kLoop:
case IrOpcode::kEnd:
case IrOpcode::kBranch:
case IrOpcode::kIfTrue:
case IrOpcode::kIfFalse:
case IrOpcode::kEffectPhi:
case IrOpcode::kMerge:
case IrOpcode::kTerminate:
// No code needed for these graph artifacts.
return kMachNone;
case IrOpcode::kFinish:
return kMachAnyTagged;
case IrOpcode::kParameter:
return linkage()->GetParameterType(OpParameter<int>(node));
case IrOpcode::kPhi:
return OpParameter<MachineType>(node);
case IrOpcode::kProjection:
// TODO(jarin) Really project from outputs.
return kMachAnyTagged;
case IrOpcode::kInt32Constant:
return kMachInt32;
case IrOpcode::kInt64Constant:
return kMachInt64;
case IrOpcode::kExternalConstant:
return kMachPtr;
case IrOpcode::kFloat64Constant:
return kMachFloat64;
case IrOpcode::kHeapConstant:
case IrOpcode::kNumberConstant:
return kMachAnyTagged;
case IrOpcode::kCall:
return kMachAnyTagged;
case IrOpcode::kFrameState:
case IrOpcode::kStateValues:
return kMachNone;
case IrOpcode::kLoad:
return OpParameter<LoadRepresentation>(node);
case IrOpcode::kStore:
return kMachNone;
case IrOpcode::kCheckedLoad:
return OpParameter<MachineType>(node);
case IrOpcode::kCheckedStore:
return kMachNone;
case IrOpcode::kWord32And:
case IrOpcode::kWord32Or:
case IrOpcode::kWord32Xor:
case IrOpcode::kWord32Shl:
case IrOpcode::kWord32Shr:
case IrOpcode::kWord32Sar:
case IrOpcode::kWord32Ror:
return kMachInt32;
case IrOpcode::kWord32Equal:
return kMachBool;
case IrOpcode::kWord64And:
case IrOpcode::kWord64Or:
case IrOpcode::kWord64Xor:
case IrOpcode::kWord64Shl:
case IrOpcode::kWord64Shr:
case IrOpcode::kWord64Sar:
case IrOpcode::kWord64Ror:
return kMachInt64;
case IrOpcode::kWord64Equal:
return kMachBool;
case IrOpcode::kInt32Add:
case IrOpcode::kInt32AddWithOverflow:
case IrOpcode::kInt32Sub:
case IrOpcode::kInt32SubWithOverflow:
case IrOpcode::kInt32Mul:
case IrOpcode::kInt32Div:
case IrOpcode::kInt32Mod:
return kMachInt32;
case IrOpcode::kInt32LessThan:
case IrOpcode::kInt32LessThanOrEqual:
case IrOpcode::kUint32LessThan:
case IrOpcode::kUint32LessThanOrEqual:
return kMachBool;
case IrOpcode::kInt64Add:
case IrOpcode::kInt64Sub:
case IrOpcode::kInt64Mul:
case IrOpcode::kInt64Div:
case IrOpcode::kInt64Mod:
return kMachInt64;
case IrOpcode::kInt64LessThan:
case IrOpcode::kInt64LessThanOrEqual:
return kMachBool;
case IrOpcode::kChangeFloat32ToFloat64:
case IrOpcode::kChangeInt32ToFloat64:
case IrOpcode::kChangeUint32ToFloat64:
return kMachFloat64;
case IrOpcode::kChangeFloat64ToInt32:
return kMachInt32;
case IrOpcode::kChangeFloat64ToUint32:
return kMachUint32;
case IrOpcode::kChangeInt32ToInt64:
return kMachInt64;
case IrOpcode::kChangeUint32ToUint64:
return kMachUint64;
case IrOpcode::kTruncateFloat64ToFloat32:
return kMachFloat32;
case IrOpcode::kTruncateFloat64ToInt32:
case IrOpcode::kTruncateInt64ToInt32:
return kMachInt32;
case IrOpcode::kFloat64Add:
case IrOpcode::kFloat64Sub:
case IrOpcode::kFloat64Mul:
case IrOpcode::kFloat64Div:
case IrOpcode::kFloat64Mod:
case IrOpcode::kFloat64Sqrt:
case IrOpcode::kFloat64Floor:
case IrOpcode::kFloat64Ceil:
case IrOpcode::kFloat64RoundTruncate:
case IrOpcode::kFloat64RoundTiesAway:
return kMachFloat64;
case IrOpcode::kFloat64Equal:
case IrOpcode::kFloat64LessThan:
case IrOpcode::kFloat64LessThanOrEqual:
return kMachBool;
default:
V8_Fatal(__FILE__, __LINE__, "Unexpected operator #%d:%s @ node #%d",
node->opcode(), node->op()->mnemonic(), node->id());
}
return kMachNone;
}
void InstructionSelector::VisitNode(Node* node) {
DCHECK_NOT_NULL(schedule()->block(node)); // should only use scheduled nodes.
SourcePosition source_position = source_positions_->GetSourcePosition(node);
if (!source_position.IsUnknown()) {
DCHECK(!source_position.IsInvalid());
if (FLAG_turbo_source_positions || node->opcode() == IrOpcode::kCall) {
Emit(SourcePositionInstruction::New(instruction_zone(), source_position));
}
}
switch (node->opcode()) {
case IrOpcode::kStart:
case IrOpcode::kLoop:
case IrOpcode::kEnd:
case IrOpcode::kBranch:
case IrOpcode::kIfTrue:
case IrOpcode::kIfFalse:
case IrOpcode::kEffectPhi:
case IrOpcode::kMerge:
// No code needed for these graph artifacts.
return;
case IrOpcode::kFinish:
return MarkAsReference(node), VisitFinish(node);
case IrOpcode::kParameter: {
MachineType type = linkage()->GetParameterType(OpParameter<int>(node));
MarkAsRepresentation(type, node);
return VisitParameter(node);
}
case IrOpcode::kPhi: {
MachineType type = OpParameter<MachineType>(node);
MarkAsRepresentation(type, node);
return VisitPhi(node);
}
case IrOpcode::kProjection:
return VisitProjection(node);
case IrOpcode::kInt32Constant:
case IrOpcode::kInt64Constant:
case IrOpcode::kExternalConstant:
return VisitConstant(node);
case IrOpcode::kFloat32Constant:
return MarkAsDouble(node), VisitConstant(node);
case IrOpcode::kFloat64Constant:
return MarkAsDouble(node), VisitConstant(node);
case IrOpcode::kHeapConstant:
case IrOpcode::kNumberConstant:
// TODO(turbofan): only mark non-smis as references.
return MarkAsReference(node), VisitConstant(node);
case IrOpcode::kCall:
return VisitCall(node);
case IrOpcode::kFrameState:
case IrOpcode::kStateValues:
return;
case IrOpcode::kLoad: {
LoadRepresentation rep = OpParameter<LoadRepresentation>(node);
MarkAsRepresentation(rep, node);
return VisitLoad(node);
}
case IrOpcode::kStore:
return VisitStore(node);
case IrOpcode::kWord32And:
return VisitWord32And(node);
case IrOpcode::kWord32Or:
return VisitWord32Or(node);
case IrOpcode::kWord32Xor:
return VisitWord32Xor(node);
case IrOpcode::kWord32Shl:
return VisitWord32Shl(node);
case IrOpcode::kWord32Shr:
return VisitWord32Shr(node);
case IrOpcode::kWord32Sar:
return VisitWord32Sar(node);
case IrOpcode::kWord32Ror:
return VisitWord32Ror(node);
case IrOpcode::kWord32Equal:
return VisitWord32Equal(node);
case IrOpcode::kWord64And:
return VisitWord64And(node);
case IrOpcode::kWord64Or:
return VisitWord64Or(node);
case IrOpcode::kWord64Xor:
return VisitWord64Xor(node);
case IrOpcode::kWord64Shl:
return VisitWord64Shl(node);
case IrOpcode::kWord64Shr:
return VisitWord64Shr(node);
case IrOpcode::kWord64Sar:
return VisitWord64Sar(node);
case IrOpcode::kWord64Ror:
return VisitWord64Ror(node);
case IrOpcode::kWord64Equal:
return VisitWord64Equal(node);
case IrOpcode::kInt32Add:
return VisitInt32Add(node);
case IrOpcode::kInt32AddWithOverflow:
return VisitInt32AddWithOverflow(node);
case IrOpcode::kInt32Sub:
return VisitInt32Sub(node);
case IrOpcode::kInt32SubWithOverflow:
return VisitInt32SubWithOverflow(node);
case IrOpcode::kInt32Mul:
return VisitInt32Mul(node);
case IrOpcode::kInt32MulHigh:
return VisitInt32MulHigh(node);
case IrOpcode::kInt32Div:
return VisitInt32Div(node);
case IrOpcode::kInt32Mod:
return VisitInt32Mod(node);
case IrOpcode::kInt32LessThan:
return VisitInt32LessThan(node);
case IrOpcode::kInt32LessThanOrEqual:
return VisitInt32LessThanOrEqual(node);
case IrOpcode::kUint32Div:
return VisitUint32Div(node);
case IrOpcode::kUint32LessThan:
return VisitUint32LessThan(node);
case IrOpcode::kUint32LessThanOrEqual:
return VisitUint32LessThanOrEqual(node);
case IrOpcode::kUint32Mod:
return VisitUint32Mod(node);
case IrOpcode::kUint32MulHigh:
return VisitUint32MulHigh(node);
case IrOpcode::kInt64Add:
return VisitInt64Add(node);
case IrOpcode::kInt64Sub:
return VisitInt64Sub(node);
case IrOpcode::kInt64Mul:
return VisitInt64Mul(node);
case IrOpcode::kInt64Div:
return VisitInt64Div(node);
case IrOpcode::kInt64Mod:
return VisitInt64Mod(node);
case IrOpcode::kInt64LessThan:
return VisitInt64LessThan(node);
case IrOpcode::kInt64LessThanOrEqual:
return VisitInt64LessThanOrEqual(node);
case IrOpcode::kUint64Div:
return VisitUint64Div(node);
case IrOpcode::kUint64LessThan:
return VisitUint64LessThan(node);
case IrOpcode::kUint64Mod:
return VisitUint64Mod(node);
case IrOpcode::kChangeFloat32ToFloat64:
return MarkAsDouble(node), VisitChangeFloat32ToFloat64(node);
case IrOpcode::kChangeInt32ToFloat64:
return MarkAsDouble(node), VisitChangeInt32ToFloat64(node);
case IrOpcode::kChangeUint32ToFloat64:
return MarkAsDouble(node), VisitChangeUint32ToFloat64(node);
case IrOpcode::kChangeFloat64ToInt32:
return VisitChangeFloat64ToInt32(node);
case IrOpcode::kChangeFloat64ToUint32:
return VisitChangeFloat64ToUint32(node);
case IrOpcode::kChangeInt32ToInt64:
return VisitChangeInt32ToInt64(node);
case IrOpcode::kChangeUint32ToUint64:
return VisitChangeUint32ToUint64(node);
case IrOpcode::kTruncateFloat64ToFloat32:
return MarkAsDouble(node), VisitTruncateFloat64ToFloat32(node);
case IrOpcode::kTruncateFloat64ToInt32:
return VisitTruncateFloat64ToInt32(node);
case IrOpcode::kTruncateInt64ToInt32:
return VisitTruncateInt64ToInt32(node);
case IrOpcode::kFloat64Add:
return MarkAsDouble(node), VisitFloat64Add(node);
case IrOpcode::kFloat64Sub:
return MarkAsDouble(node), VisitFloat64Sub(node);
case IrOpcode::kFloat64Mul:
return MarkAsDouble(node), VisitFloat64Mul(node);
case IrOpcode::kFloat64Div:
return MarkAsDouble(node), VisitFloat64Div(node);
case IrOpcode::kFloat64Mod:
return MarkAsDouble(node), VisitFloat64Mod(node);
case IrOpcode::kFloat64Sqrt:
return MarkAsDouble(node), VisitFloat64Sqrt(node);
case IrOpcode::kFloat64Equal:
return VisitFloat64Equal(node);
case IrOpcode::kFloat64LessThan:
return VisitFloat64LessThan(node);
case IrOpcode::kFloat64LessThanOrEqual:
return VisitFloat64LessThanOrEqual(node);
case IrOpcode::kFloat64Floor:
return MarkAsDouble(node), VisitFloat64Floor(node);
case IrOpcode::kFloat64Ceil:
return MarkAsDouble(node), VisitFloat64Ceil(node);
case IrOpcode::kFloat64RoundTruncate:
return MarkAsDouble(node), VisitFloat64RoundTruncate(node);
case IrOpcode::kFloat64RoundTiesAway:
return MarkAsDouble(node), VisitFloat64RoundTiesAway(node);
case IrOpcode::kLoadStackPointer:
return VisitLoadStackPointer(node);
case IrOpcode::kCheckedLoad: {
MachineType rep = OpParameter<MachineType>(node);
MarkAsRepresentation(rep, node);
return VisitCheckedLoad(node);
}
case IrOpcode::kCheckedStore:
return VisitCheckedStore(node);
default:
V8_Fatal(__FILE__, __LINE__, "Unexpected operator #%d:%s @ node #%d",
node->opcode(), node->op()->mnemonic(), node->id());
break;
}
}
#if V8_TURBOFAN_BACKEND
void InstructionSelector::VisitTruncateFloat64ToInt32(Node* node) {
OperandGenerator g(this);
Emit(kArchTruncateDoubleToI, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)));
}
void InstructionSelector::VisitLoadStackPointer(Node* node) {
OperandGenerator g(this);
Emit(kArchStackPointer, g.DefineAsRegister(node));
}
#endif // V8_TURBOFAN_BACKEND
// 32 bit targets do not implement the following instructions.
#if V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_X64 && V8_TURBOFAN_BACKEND
void InstructionSelector::VisitWord64And(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Or(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Xor(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Shl(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Shr(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Sar(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Ror(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Equal(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64Add(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64Sub(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64Mul(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64Div(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64LessThan(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitUint64Div(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64Mod(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitUint64LessThan(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitUint64Mod(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitChangeInt32ToInt64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitChangeUint32ToUint64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) {
UNIMPLEMENTED();
}
#endif // V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_X64 && V8_TURBOFAN_BACKEND
void InstructionSelector::VisitFinish(Node* node) {
OperandGenerator g(this);
Node* value = node->InputAt(0);
Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value));
}
void InstructionSelector::VisitParameter(Node* node) {
OperandGenerator g(this);
int index = OpParameter<int>(node);
Emit(kArchNop,
g.DefineAsLocation(node, linkage()->GetParameterLocation(index),
linkage()->GetParameterType(index)));
}
void InstructionSelector::VisitPhi(Node* node) {
const int input_count = node->op()->ValueInputCount();
PhiInstruction* phi = new (instruction_zone())
PhiInstruction(instruction_zone(), GetVirtualRegister(node),
static_cast<size_t>(input_count));
sequence()->InstructionBlockAt(current_block_->GetRpoNumber())->AddPhi(phi);
for (int i = 0; i < input_count; ++i) {
Node* const input = node->InputAt(i);
MarkAsUsed(input);
phi->Extend(instruction_zone(), GetVirtualRegister(input));
}
}
void InstructionSelector::VisitProjection(Node* node) {
OperandGenerator g(this);
Node* value = node->InputAt(0);
switch (value->opcode()) {
case IrOpcode::kInt32AddWithOverflow:
case IrOpcode::kInt32SubWithOverflow:
if (OpParameter<size_t>(node) == 0) {
Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value));
} else {
DCHECK(OpParameter<size_t>(node) == 1u);
MarkAsUsed(value);
}
break;
default:
break;
}
}
void InstructionSelector::VisitConstant(Node* node) {
// We must emit a NOP here because every live range needs a defining
// instruction in the register allocator.
OperandGenerator g(this);
Emit(kArchNop, g.DefineAsConstant(node));
}
void InstructionSelector::VisitGoto(BasicBlock* target) {
// jump to the next block.
OperandGenerator g(this);
Emit(kArchJmp, NULL, g.Label(target))->MarkAsControl();
}
void InstructionSelector::VisitReturn(Node* value) {
OperandGenerator g(this);
if (value != NULL) {
Emit(kArchRet, NULL, g.UseLocation(value, linkage()->GetReturnLocation(),
linkage()->GetReturnType()));
} else {
Emit(kArchRet, NULL);
}
}
void InstructionSelector::VisitThrow(Node* value) {
UNIMPLEMENTED(); // TODO(titzer)
}
void InstructionSelector::FillTypeVectorFromStateValues(
ZoneVector<MachineType>* types, Node* state_values) {
DCHECK(state_values->opcode() == IrOpcode::kStateValues);
int count = state_values->InputCount();
types->reserve(static_cast<size_t>(count));
for (int i = 0; i < count; i++) {
types->push_back(GetMachineType(state_values->InputAt(i)));
}
}
FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor(
Node* state) {
DCHECK(state->opcode() == IrOpcode::kFrameState);
DCHECK_EQ(5, state->InputCount());
DCHECK_EQ(IrOpcode::kStateValues, state->InputAt(0)->opcode());
DCHECK_EQ(IrOpcode::kStateValues, state->InputAt(1)->opcode());
DCHECK_EQ(IrOpcode::kStateValues, state->InputAt(2)->opcode());
FrameStateCallInfo state_info = OpParameter<FrameStateCallInfo>(state);
int parameters = state->InputAt(0)->InputCount();
int locals = state->InputAt(1)->InputCount();
int stack = state->InputAt(2)->InputCount();
FrameStateDescriptor* outer_state = NULL;
Node* outer_node = state->InputAt(4);
if (outer_node->opcode() == IrOpcode::kFrameState) {
outer_state = GetFrameStateDescriptor(outer_node);
}
return new (instruction_zone()) FrameStateDescriptor(
instruction_zone(), state_info, parameters, locals, stack, outer_state);
}
static InstructionOperand* UseOrImmediate(OperandGenerator* g, Node* input) {
switch (input->opcode()) {
case IrOpcode::kInt32Constant:
case IrOpcode::kNumberConstant:
case IrOpcode::kFloat64Constant:
case IrOpcode::kHeapConstant:
return g->UseImmediate(input);
default:
return g->UseUnique(input);
}
}
void InstructionSelector::AddFrameStateInputs(
Node* state, InstructionOperandVector* inputs,
FrameStateDescriptor* descriptor) {
DCHECK_EQ(IrOpcode::kFrameState, state->op()->opcode());
if (descriptor->outer_state() != NULL) {
AddFrameStateInputs(state->InputAt(4), inputs, descriptor->outer_state());
}
Node* parameters = state->InputAt(0);
Node* locals = state->InputAt(1);
Node* stack = state->InputAt(2);
Node* context = state->InputAt(3);
DCHECK_EQ(IrOpcode::kStateValues, parameters->op()->opcode());
DCHECK_EQ(IrOpcode::kStateValues, locals->op()->opcode());
DCHECK_EQ(IrOpcode::kStateValues, stack->op()->opcode());
DCHECK_EQ(static_cast<int>(descriptor->parameters_count()),
parameters->InputCount());
DCHECK_EQ(static_cast<int>(descriptor->locals_count()), locals->InputCount());
DCHECK_EQ(static_cast<int>(descriptor->stack_count()), stack->InputCount());
ZoneVector<MachineType> types(instruction_zone());
types.reserve(descriptor->GetSize());
OperandGenerator g(this);
size_t value_index = 0;
for (int i = 0; i < static_cast<int>(descriptor->parameters_count()); i++) {
Node* input_node = parameters->InputAt(i);
inputs->push_back(UseOrImmediate(&g, input_node));
descriptor->SetType(value_index++, GetMachineType(input_node));
}
if (descriptor->HasContext()) {
inputs->push_back(UseOrImmediate(&g, context));
descriptor->SetType(value_index++, kMachAnyTagged);
}
for (int i = 0; i < static_cast<int>(descriptor->locals_count()); i++) {
Node* input_node = locals->InputAt(i);
inputs->push_back(UseOrImmediate(&g, input_node));
descriptor->SetType(value_index++, GetMachineType(input_node));
}
for (int i = 0; i < static_cast<int>(descriptor->stack_count()); i++) {
Node* input_node = stack->InputAt(i);
inputs->push_back(UseOrImmediate(&g, input_node));
descriptor->SetType(value_index++, GetMachineType(input_node));
}
DCHECK(value_index == descriptor->GetSize());
}
#if !V8_TURBOFAN_BACKEND
#define DECLARE_UNIMPLEMENTED_SELECTOR(x) \
void InstructionSelector::Visit##x(Node* node) { UNIMPLEMENTED(); }
MACHINE_OP_LIST(DECLARE_UNIMPLEMENTED_SELECTOR)
#undef DECLARE_UNIMPLEMENTED_SELECTOR
void InstructionSelector::VisitCall(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
BasicBlock* fbranch) {
UNIMPLEMENTED();
}
// static
MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() {
return MachineOperatorBuilder::Flag::kNoFlags;
}
#endif // !V8_TURBOFAN_BACKEND
} // namespace compiler
} // namespace internal
} // namespace v8
|
; A033372: a(n) = floor(52/n).
; 52,26,17,13,10,8,7,6,5,5,4,4,4,3,3,3,3,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
add $0,1
mov $1,52
div $1,$0
mov $0,$1
|
reset_bird:
mov word [bird_pos+0], 60
mov word [bird_pos+2], 60
ret
center_bird:
mov word [bird_pos+0], 144
mov word [bird_pos+2], 60
ret
update_bird:
mov ax, word [bird_pos + 2] ; sy
cmp ax, 0 ; top
jle .collide ; reached sky?
add ax, word [bird_pos + 6] ; sh
cmp ax, 156 ; bottom (ground)
jg .collide ; reached ground?
call kbhit
test al, al ; no key was ...
jz .fall ; pressed then just fall ...
call animate_bird ; animate bird
.move:
sub word [bird_pos + 2], 6 ; move 4 pixels up on the Y axis
clc
ret
.fall:
add word [bird_pos + 2], 2 ; move 2 pixels down on the Y axis
clc
ret
.collide:
stc
ret
animate_bird:
add word [bird_frm], 32 ; advance fly animation by one frame
cmp word [bird_frm], 64 ; did we reach the last frame yet?
jle .end ; if not, then we can jump right away
mov word [bird_frm], 0 ; reset animation to the first frame
.end:
ret
draw_bird:
push bird
push 96 ; pw
push 24 ; ph
push word [bird_frm] ; sx
push 0 ; sy
push word [bird_pos + 4] ; sw
push word [bird_pos + 6] ; sh
push word [bird_pos + 0] ; dx
push word [bird_pos + 2] ; dy
push 0 ; transparent color
push word [bird_tint] ; tint
call blit_fast
ret
randomize_birdcolor:
call random
add ax, ax
mov word [bird_tint], ax
ret
bird_pos: dw 60, 60, 32, 24 ; x, y, w, h
bird_frm: dw 0 ; current animation frame (X in pixels)
bird_tint: dw 0 ; crazy tint :P
|
;
; Copyright (c) 2010 The WebM 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.
;
%include "vpx_ports/x86_abi_support.asm"
;int vp8_fast_quantize_b_impl_mmx(short *coeff_ptr, short *zbin_ptr,
; short *qcoeff_ptr,short *dequant_ptr,
; short *scan_mask, short *round_ptr,
; short *quant_ptr, short *dqcoeff_ptr);
global sym(vp8_fast_quantize_b_impl_mmx) PRIVATE
sym(vp8_fast_quantize_b_impl_mmx):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 8
push rsi
push rdi
; end prolog
mov rsi, arg(0) ;coeff_ptr
movq mm0, [rsi]
mov rax, arg(1) ;zbin_ptr
movq mm1, [rax]
movq mm3, mm0
psraw mm0, 15
pxor mm3, mm0
psubw mm3, mm0 ; abs
movq mm2, mm3
pcmpgtw mm1, mm2
pandn mm1, mm2
movq mm3, mm1
mov rdx, arg(6) ;quant_ptr
movq mm1, [rdx]
mov rcx, arg(5) ;round_ptr
movq mm2, [rcx]
paddw mm3, mm2
pmulhuw mm3, mm1
pxor mm3, mm0
psubw mm3, mm0 ;gain the sign back
mov rdi, arg(2) ;qcoeff_ptr
movq mm0, mm3
movq [rdi], mm3
mov rax, arg(3) ;dequant_ptr
movq mm2, [rax]
pmullw mm3, mm2
mov rax, arg(7) ;dqcoeff_ptr
movq [rax], mm3
; next 8
movq mm4, [rsi+8]
mov rax, arg(1) ;zbin_ptr
movq mm5, [rax+8]
movq mm7, mm4
psraw mm4, 15
pxor mm7, mm4
psubw mm7, mm4 ; abs
movq mm6, mm7
pcmpgtw mm5, mm6
pandn mm5, mm6
movq mm7, mm5
movq mm5, [rdx+8]
movq mm6, [rcx+8]
paddw mm7, mm6
pmulhuw mm7, mm5
pxor mm7, mm4
psubw mm7, mm4;gain the sign back
mov rdi, arg(2) ;qcoeff_ptr
movq mm1, mm7
movq [rdi+8], mm7
mov rax, arg(3) ;dequant_ptr
movq mm6, [rax+8]
pmullw mm7, mm6
mov rax, arg(7) ;dqcoeff_ptr
movq [rax+8], mm7
; next 8
movq mm4, [rsi+16]
mov rax, arg(1) ;zbin_ptr
movq mm5, [rax+16]
movq mm7, mm4
psraw mm4, 15
pxor mm7, mm4
psubw mm7, mm4 ; abs
movq mm6, mm7
pcmpgtw mm5, mm6
pandn mm5, mm6
movq mm7, mm5
movq mm5, [rdx+16]
movq mm6, [rcx+16]
paddw mm7, mm6
pmulhuw mm7, mm5
pxor mm7, mm4
psubw mm7, mm4;gain the sign back
mov rdi, arg(2) ;qcoeff_ptr
movq mm1, mm7
movq [rdi+16], mm7
mov rax, arg(3) ;dequant_ptr
movq mm6, [rax+16]
pmullw mm7, mm6
mov rax, arg(7) ;dqcoeff_ptr
movq [rax+16], mm7
; next 8
movq mm4, [rsi+24]
mov rax, arg(1) ;zbin_ptr
movq mm5, [rax+24]
movq mm7, mm4
psraw mm4, 15
pxor mm7, mm4
psubw mm7, mm4 ; abs
movq mm6, mm7
pcmpgtw mm5, mm6
pandn mm5, mm6
movq mm7, mm5
movq mm5, [rdx+24]
movq mm6, [rcx+24]
paddw mm7, mm6
pmulhuw mm7, mm5
pxor mm7, mm4
psubw mm7, mm4;gain the sign back
mov rdi, arg(2) ;qcoeff_ptr
movq mm1, mm7
movq [rdi+24], mm7
mov rax, arg(3) ;dequant_ptr
movq mm6, [rax+24]
pmullw mm7, mm6
mov rax, arg(7) ;dqcoeff_ptr
movq [rax+24], mm7
mov rdi, arg(4) ;scan_mask
mov rsi, arg(2) ;qcoeff_ptr
pxor mm5, mm5
pxor mm7, mm7
movq mm0, [rsi]
movq mm1, [rsi+8]
movq mm2, [rdi]
movq mm3, [rdi+8];
pcmpeqw mm0, mm7
pcmpeqw mm1, mm7
pcmpeqw mm6, mm6
pxor mm0, mm6
pxor mm1, mm6
psrlw mm0, 15
psrlw mm1, 15
pmaddwd mm0, mm2
pmaddwd mm1, mm3
movq mm5, mm0
paddd mm5, mm1
movq mm0, [rsi+16]
movq mm1, [rsi+24]
movq mm2, [rdi+16]
movq mm3, [rdi+24];
pcmpeqw mm0, mm7
pcmpeqw mm1, mm7
pcmpeqw mm6, mm6
pxor mm0, mm6
pxor mm1, mm6
psrlw mm0, 15
psrlw mm1, 15
pmaddwd mm0, mm2
pmaddwd mm1, mm3
paddd mm5, mm0
paddd mm5, mm1
movq mm0, mm5
psrlq mm5, 32
paddd mm0, mm5
; eob adjustment begins here
movq rcx, mm0
and rcx, 0xffff
xor rdx, rdx
sub rdx, rcx ; rdx=-rcx
bsr rax, rcx
inc rax
sar rdx, 31
and rax, rdx
; Substitute the sse assembly for the old mmx mixed assembly/C. The
; following is kept as reference
; movq rcx, mm0
; bsr rax, rcx
;
; mov eob, rax
; mov eee, rcx
;
;if(eee==0)
;{
; eob=-1;
;}
;else if(eee<0)
;{
; eob=15;
;}
;d->eob = eob+1;
; begin epilog
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
|
#include <stdio.h>
#include <stdlib.h>
#include "phmm.h"
#include <string.h>
#include "structure/structure_object.h"
#include "utils/xmath/log/xlog_math.h"
#include "utils/file/utils.h"
char t_phmm::state_names[N_STATES][100] = {"STATE_INS1", "STATE_INS2", "STATE_ALN"};
t_phmm::t_phmm(double new_emission_probs[N_OUTPUTS][N_STATES], double new_trans_probs[N_STATES][N_STATES])
{
this->alloc_init_params();
// Copy transition matrix.
for(int cnt1 = 0; cnt1 < N_STATES; cnt1++)
{
for(int cnt2 = 0; cnt2 < N_STATES; cnt2++)
{
this->trans_probs[cnt1][cnt2] = xlog(new_trans_probs[cnt1][cnt2]);
} // cnt2 loop
} // cnt1 loop
// Copy emission probabilities.
for(int cnt1 = 0; cnt1 < N_OUTPUTS; cnt1++)
{
for(int cnt2 = 0; cnt2 < N_STATES; cnt2++)
{
this->emission_probs[cnt1][cnt2] = xlog(new_emission_probs[cnt1][cnt2]);
} // cnt2 loop
} // cnt1 loop
}
t_phmm::t_phmm(char* phmm_pars_file)
{
this->alloc_init_params();
// Read the parameters file. This parameters file contains 10 different parameter sets and thresholds.
FILE* fam_par_file = open_f(phmm_pars_file, "r");
if(fam_par_file == NULL)
{
double* p=0;
*p = 0;
printf("Cannot find phmm parameters file, exiting @ %s(%d).\n", __FILE__, __LINE__);
exit(0);
}
// Load all parameters from file.
for(int cnt = 0; cnt < N_BINZ * (N_STATES + N_OUTPUTS) * N_STATES; cnt++)
{
fscanf(fam_par_file, "%lf", &fam_hmm_pars[cnt]);
//printf("%d: %.3f\n", cnt, fam_hmm_pars[cnt]);
}
//printf("\n\n\nReading thresholds!!!\n");
// Read thresholds.
for(int cnt = 0; cnt < N_BINZ; cnt++)
{
fscanf(fam_par_file, "%lf", &fam_thresholds[cnt]);
//printf("%d: %f\n", cnt, fam_thresholds[cnt]);
}
fclose(fam_par_file);
}
void t_phmm::alloc_init_params()
{
// Copy transition matrix.
this->trans_probs = (double**)malloc(sizeof(double*) * (N_STATES + 2));
for(int cnt1 = 0; cnt1 < N_STATES; cnt1++)
{
this->trans_probs[cnt1] = (double*)malloc(sizeof(double) * (N_STATES + 2));
for(int cnt2 = 0; cnt2 < N_STATES; cnt2++)
{
trans_probs[cnt1][cnt2] = xlog(0.0f);
} // cnt2 loop
} // cnt1 loop
// Copy emission probabilities.
this->emission_probs = (double**)malloc(sizeof(double*) * (N_OUTPUTS + 2));
for(int cnt1 = 0; cnt1 < N_OUTPUTS; cnt1++)
{
this->emission_probs[cnt1] = (double*)malloc(sizeof(double) * (N_STATES + 2));
for(int cnt2 = 0; cnt2 < N_STATES; cnt2++)
{
emission_probs[cnt1][cnt2] = xlog(0.0f);
} // cnt2 loop
} // cnt1 loop
this->fam_hmm_pars = (double*)malloc(sizeof(double) * (N_BINZ * (N_STATES + N_OUTPUTS) * N_STATES + 2));
this->fam_thresholds = (double*)malloc(sizeof(double) * (N_BINZ + 2));
}
void t_phmm::free_params()
{
// Free transition matrix.
for(int cnt1 = 0; cnt1 < N_STATES; cnt1++)
{
free(this->trans_probs[cnt1]);
} // cnt1 loop
free(this->trans_probs);
// Free emission probabilities.
for(int cnt1 = 0; cnt1 < N_OUTPUTS; cnt1++)
{
free(this->emission_probs[cnt1]);
} // cnt1 loop
free(this->emission_probs);
free(this->fam_hmm_pars);
free(this->fam_thresholds);
}
t_phmm::~t_phmm()
{
this->free_params();
}
void t_phmm::dump_parameters()
{
// Dump emission probabilities.
for(int cnt1 = 0; cnt1 < N_OUTPUTS; cnt1++)
{
for(int cnt2 = 0; cnt2 < N_STATES; cnt2++)
{
printf("%.3f ", xexp(emission_probs[cnt1][cnt2]));
}
printf("\n");
}
// Dump transition probabilities.
printf("\n");
for(int cnt1 = 0; cnt1 < N_STATES; cnt1++)
{
for(int cnt2 = 0; cnt2 < N_STATES; cnt2++)
{
printf("%.3f ", xexp(trans_probs[cnt1][cnt2]));
}
printf("\n");
}
}
void t_phmm::set_parameters_by_sim(double similarity)
{
//int fam_par_set_index = (int)(similarity * (double)N_BINZ);
int fam_par_set_index = get_bin_index(similarity, N_BINZ);
// Load emission probabilities.
// Each parameter set is (N_STATES + N_OUTPUTS) * N_STATES doubles long.
int start_linear_index = (N_STATES + N_OUTPUTS) * N_STATES * get_bin_index(similarity, N_BINZ);
double* par_ptr = fam_hmm_pars + start_linear_index;
for(int cnt1 = 0; cnt1 < N_OUTPUTS; cnt1++)
{
for(int cnt2 = 0; cnt2 < N_STATES; cnt2++)
{
//emission_probs[cnt1][cnt2] = *(par_ptr + cnt1 * N_STATES + cnt2);
emission_probs[cnt1][cnt2] = xlog(par_ptr[cnt1 * N_STATES + cnt2]);
}
}
start_linear_index = (N_STATES + N_OUTPUTS) * N_STATES * fam_par_set_index + N_STATES * N_OUTPUTS;
par_ptr = fam_hmm_pars + start_linear_index;
// Load trans probabilities.
for(int cnt1 = 0; cnt1 < N_STATES; cnt1++)
{
for(int cnt2 = 0; cnt2 < N_STATES; cnt2++)
{
//trans_probs[cnt1][cnt2] = *(par_ptr + cnt1 * N_STATES + cnt2);
trans_probs[cnt1][cnt2] = xlog(par_ptr[cnt1 * N_STATES + cnt2]);
}
}
}
// Get index of bin of parameters for a sequence alignment.
int t_phmm::get_bin_index(double similarity, int n_bins)
{
if(similarity == 1.0)
{
return(n_bins - 1);
}
else
{
return((int)(n_bins * similarity));
}
}
double t_phmm::get_fam_threshold(double similarity)
{
int bin_index = get_bin_index(similarity, N_BINZ);
return(fam_thresholds[bin_index]);
}
double t_phmm::get_trans_prob(int prev, int next)
{
return(this->trans_probs[prev][next]);
}
double t_phmm::get_emit_prob(int sym_index, int state)
{
return(this->emission_probs[sym_index][state]);
}
|
; A039274: Numbers n such that representation in base 12 has same number of 10's and 11's.
; 0,1,2,3,4,5,6,7,8,9,12,13,14,15,16,17,18,19,20,21,24,25,26,27,28,29,30,31,32,33,36,37,38,39,40,41,42,43,44,45,48,49,50,51,52,53,54,55,56,57,60,61,62,63,64,65,66,67,68,69,72,73,74,75,76,77,78,79,80,81
mov $1,$0
div $0,10
mul $0,2
add $1,$0
|
; A315185: Coordination sequence Gal.5.115.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,10,14,18,24,28,32,36,42,48,52,56,60,66,70,74,78,84,90,94,98,102,108,112,116,120,126,132,136,140,144,150,154,158,162,168,174,178,182,186,192,196,200,204,210,216,220,224,228
mov $3,$0
add $3,1
mov $5,$0
lpb $3
mov $0,$5
sub $3,1
sub $0,$3
mul $0,4
mov $2,4
mov $4,0
lpb $0
div $0,6
add $4,$2
sub $4,1
gcd $0,$4
add $0,$4
sub $0,1
lpe
mov $2,$0
add $2,1
add $1,$2
lpe
|
; this file is part of Release, written by Malban in 2017
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; All the different explosions were done "on the fly"
; they were not "planned", and certainly do not consist of good or nice code
; please do not look further!
;
explosionBehaviour ;#isfunction
stb VIA_t1_cnt_lo ; also stores to scale :-() VIA_t1_cnt_lo ; to timer t1 (lo)
ldb X_POS+u_offset1,u
; start the move to
; following calcs can be done within that move
MY_MOVE_TO_D_START ; move to last know position of object
tst EXPLOSION_TYPE+u_offset1,u
bne noxxplosion1 ; if not explosion 0 - jump, xplosion 0 is the terribe x - the implosion...
lda EXPLOSION_SCALE+u_offset1,u
ldb EXPLOSION_DATA+u_offset1,u
bne xxplosionPart2
cmpa #30 ; max * 2 ; if the maximum extend of the explosion is init "implosion"
blo noxxplosion1_2_0
inc EXPLOSION_DATA+u_offset1,u
xxplosionPart2
suba #3 ; implosion slightly fatser than explosion (2 vs 3)
bmi removeIt_ex ; if negative - than remove the explosion - finally!
bra scalingDone_ex
noxxplosion1_2_0 ; " no x explosion"
adda #2
sta EXPLOSION_SCALE+u_offset1,u
bra explosion_alive_eb
noxxplosion1
lda EXPLOSION_SCALE+u_offset1,u
noxxplosion1_2
adda #2
ldb EXPLOSION_TYPE+u_offset1,u
cmpb #5 ; star - stars expland double fast -> and are brighter
bne noStarExplosion
adda #2
scalingDone_ex
sta EXPLOSION_SCALE+u_offset1,u
cmpa #80 ; max * 2 ; if the maximum extend of the explosion is reached -> remove it
ble explosion_alive_eb
bra starExplodeDone
noStarExplosion
sta EXPLOSION_SCALE+u_offset1,u
adda explosionActiveCounter ; trick that not all explosion "die" in the same round - saves cleanup time
; also - the more explosions, the less far they reach :-)
cmpa explosionMax ; if the maximum extend of the explosion is reached -> remove it
ble explosion_alive_eb
removeIt_ex
lda explosionMax ; add a little to the explosion max extend...
adda #5 ; since now there is are less explosions about
sta explosionMax
starExplodeDone
dec explosionActiveCounter ; and also decrement the explosion active counter
jmp removeObject ; remove the object, "returns" via puls of next object
starScaleDone:
explosion_alive_eb:
sta VIA_t1_cnt_lo ; explosion scale
ldx #rotList ; reuse of the rotation list of shield/base
lda ,x+ ; get count of vectors
sta tmp_count2
lda #$7f ; explosions are bright!
tfr u,y
ldu NEXT_OBJECT+u_offset1,u ; correct U for going out later
MY_MOVE_TO_B_END ; end a move to
_INTENSITY_A
next_edd:
ldd ,x ; load the corners of the polygon
MY_MOVE_TO_D_START_NT ; move to the corner, and draw a dot at every corner
leax 2,x ; little time saving, the ++ of x moved into the MOVE
ldb EXPLOSION_TYPE+u_offset1,y
beq doXExplosion
cmpb #1
beq doBomberExplosion
cmpb #2
lbeq doDragonExplosion
cmpb #3
lbeq doHunterExplosion
cmpb #4
bge doBonusExplosion
; bhs doBonusExplosion
doXExplosion
; cmpb #5 ; star
; beq doBonusExplosion
; do normal explosion here
lda #$ff ; preload shift
MY_MOVE_TO_B_END ; end a move to
STA <VIA_shift_reg ; Store in VIA shift register
; the next MoveTo blanks anyways
; CLR <VIA_shift_reg ; Blank beam in VIA shift register
dec tmp_count2 ; check if vector count finished
bpl next_edd ; if not - draw next dot
clra
LDB #$CC
sta <VIA_shift_reg
STB VIA_cntl ;/BLANK low and /ZERO low
; _ZERO_VECTOR_BEAM
pulu d,x,pc ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
; same as above, but with a quite longer "dwelling"
doBonusExplosion
lda #$ff ; preload shift
MY_MOVE_TO_B_END ; end a move to
STA <VIA_shift_reg ; Store in VIA shift register
ldb #20 ; dot dwell for ? explosion - they are bright! (and take some cycles)!
dodecagain
decb
bpl dodecagain
; the next MoveTo blanks anyways
; CLR <VIA_shift_reg ; Blank beam in VIA shift register
dec tmp_count2 ; check if vector count finished
bpl next_edd ; if not - draw next dot
clra
sta <VIA_shift_reg
_ZERO_VECTOR_BEAM
pulu d,x,pc ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
doBomberExplosion
ldd #$8006
stb VIA_t1_cnt_lo ; to timer t1 (lo=
MY_MOVE_TO_B_END ; end a move to
; bomber explosions are terrible cycle wise -
; here I inline the drawing of 4 lines
STA <VIA_aux_cntl ; Shift reg mode = 000 free disable, T1 PB7 enabled
ldb #$28
STB <VIA_port_a ;(2) [4] Send Y to A/D
CLR <VIA_port_b ;(2) [4] enable mux, thus y integrators are set to Y
INC <VIA_port_b ;[6] Disable mux
; ONE LINE
STB <VIA_port_a ; [6] Send X to A/D
ldb #$ee
CLR <VIA_t1_cnt_hi ; [4] enable timer 1
; light on
stb <VIA_cntl ; [4] ZERO disabled, and BLANK disabled
ldd #$d828
STA <VIA_port_a ; [4] Send Y to A/D
clr <VIA_port_b ; [6]
lda #$ce ; [2]
; light off
sta <VIA_cntl ; [4] ZERO disabled, and BLANK enabled
INC <VIA_port_b ; [6] Disable mux
; ONE LINE
STB <VIA_port_a ; [6] Send X to A/D
ldb #$ee
CLR <VIA_t1_cnt_hi ; [4] enable timer 1
; light on
stb <VIA_cntl ; [4] ZERO disabled, and BLANK disabled
ldd #$d8d8
STA <VIA_port_a ; [4] Send Y to A/D
clr <VIA_port_b ; [6]
lda #$ce ; [2]
; light off
sta <VIA_cntl ; [4] ZERO disabled, and BLANK enabled
INC <VIA_port_b ; [6] Disable mux
; ONE LINE
STB <VIA_port_a ; [6] Send X to A/D
ldb #$ee
CLR <VIA_t1_cnt_hi ; [4] enable timer 1
; light on
stb <VIA_cntl ; [4] ZERO disabled, and BLANK disabled
ldd #$28d8
STA <VIA_port_a ; [4] Send Y to A/D
clr <VIA_port_b ; [6]
lda #$ce ; [2]
; light off
sta <VIA_cntl ; [4] ZERO disabled, and BLANK enabled
INC <VIA_port_b ; [6] Disable mux
STB <VIA_port_a ; [6] Send X to A/D
; light on
ldb #$ee
CLR <VIA_t1_cnt_hi ; [4] enable timer 1
stb <VIA_cntl ; ZERO disabled, and BLANK disabled
lda EXPLOSION_SCALE+u_offset1,y
sta VIA_t1_cnt_lo ; to timer t1 (lo=
dec tmp_count2 ; check if vector count finished
lbpl next_edd ; if not - draw next dot
ldd #$CC98
STb <VIA_aux_cntl ;
STa VIA_cntl ;/BLANK low and /ZERO low
pulu d,x,pc ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
doDragonExplosion
; DB $ff, +$24, +$24 ; mode, y, x
; DB $00, +$00, -$24 ; mode, y, x
; DB $ff, -$24, +$24 ; mode, y, x
ldd #$8006
stb VIA_t1_cnt_lo ; to timer t1 (lo=
MY_MOVE_TO_B_END ; end a move to
; dragon explosions are terrible cycle wise -
; here I inline the drawing of 4 lines
STA <VIA_aux_cntl ; Shift reg mode = 000 free disable, T1 PB7 enabled
ldb #$24
STb <VIA_port_a ;(2) [4] Send Y to A/D
CLR <VIA_port_b ;(2) [4] enable mux, thus y integrators are set to Y
INC <VIA_port_b ;[6] Disable mux
; ONE LINE
STB <VIA_port_a ; [6] Send X to A/D
ldb #$ee
CLR <VIA_t1_cnt_hi ; [4] enable timer 1
; light on
stb <VIA_cntl ; [4] ZERO disabled, and BLANK disabled
ldd #$00dc
STA <VIA_port_a ; [4] Send Y to A/D
clr <VIA_port_b ; [6]
lda #$ce ; [2]
; light off
sta <VIA_cntl ; [4] ZERO disabled, and BLANK enabled
INC <VIA_port_b ; [6] Disable mux
; ONE LINE
STB <VIA_port_a ; [6] Send X to A/D
ldb #$ce
CLR <VIA_t1_cnt_hi ; [4] enable timer 1
; light on
stb <VIA_cntl ; [4] ZERO disabled, and BLANK disabled
ldd #$dc24
STA <VIA_port_a ; [4] Send Y to A/D
clr <VIA_port_b ; [6]
lda #$ce ; [2]
; light off
sta <VIA_cntl ; [4] ZERO disabled, and BLANK enabled
INC <VIA_port_b ; [6] Disable mux
; ONE LINE
STB <VIA_port_a ; [6] Send X to A/D
ldb #$ee
CLR <VIA_t1_cnt_hi ; [4] enable timer 1
; light on
stb <VIA_cntl ; [4] ZERO disabled, and BLANK disabled
ldd #$00dc
STA <VIA_port_a ; [4] Send Y to A/D
clr <VIA_port_b ; [6]
lda #$ce ; [2]
; light off
sta <VIA_cntl ; [4] ZERO disabled, and BLANK enabled
INC <VIA_port_b ; [6] Disable mux
STB <VIA_port_a ; [6] Send X to A/D
; light on
ldb #$ce
CLR <VIA_t1_cnt_hi ; [4] enable timer 1
stb <VIA_cntl ; ZERO disabled, and BLANK disabled
lda EXPLOSION_SCALE+u_offset1,y
sta VIA_t1_cnt_lo ; to timer t1 (lo=
dec tmp_count2 ; check if vector count finished
lbpl next_edd ; if not - draw next dot
ldd #$CC98
STb <VIA_aux_cntl ;
STa VIA_cntl ;/BLANK low and /ZERO low
pulu d,x,pc ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
doHunterExplosion
lda #$7f
suba EXPLOSION_SCALE+u_offset1,y
suba EXPLOSION_SCALE+u_offset1,y
suba EXPLOSION_SCALE+u_offset1,y
MY_MOVE_TO_B_END ; end a move to
_INTENSITY_A
next_line_dr_ds4_eh:
LDD ,X
STA <VIA_port_a ;Send Y to A/D
CLR <VIA_port_b ;Enable mux
INC <VIA_port_b ;Disable mux
STB <VIA_port_a ;Send X to A/D
LDD #$00FF ;Shift reg=$FF (solid line), T1H=0
STB <VIA_shift_reg ;Put pattern in shift register
STA <VIA_t1_cnt_hi ;Set T1H (scale factor?)
LDB #$40 ;B-reg = T1 interrupt bit
LEAX 2,X ;Point to next coordinate pair
wait_draw_dr_ds4_eh:
BITB <VIA_int_flags ;Wait for T1 to time out
BEQ wait_draw_dr_ds4_eh
STA <VIA_shift_reg ;Clear shift register (blank output)
dec tmp_count2 ;Decrement line count
bpl next_line_dr_ds4_eh ; if not - draw next dot
_ZERO_VECTOR_BEAM
pulu d,x,pc ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
******************************
***** SCORE ******************
******************************
; scores displayed by ONE vectorlist,
; these are "destruction" scores
scoreBehaviour ;#isfunction
stb VIA_t1_cnt_lo ; also stores to scale :-() VIA_t1_cnt_lo ; to timer t1 (lo)
ldb X_POS+u_offset1,u
MY_MOVE_TO_D_START_NT
lda SCALE+u_offset1,u ; if score is far away
cmpa shield_max
lbhi removeObject ; if score scale is higher than max shield - don't bother displaying it
cmpa #$80
blo noMusic_ssb1
jsr [inMovePointer] ; decrunch a music part
noMusic_ssb1
lda SCORE_COUNTDOWN+u_offset1,u ; scores shown round counter
inca
sta SCORE_COUNTDOWN+u_offset1,u
cmpa score_display_time ; scores are displayed in "rounds" not in movement, if shown long enough
lbhi removeObject ; remove it
lda RecalCounterLow ; scores move slowly only 1 "point" every second round
bita #$01 ; use some counter to access a single bit as compare
beq noAdd_sb
inc SCALE+u_offset1,u ; and only if bit is set increase the score scale
noAdd_sb:
ldd #$5f03 ; tiny little score
stb VIA_t1_cnt_lo ; to timer t1 (lo=
ldu NEXT_OBJECT+u_offset1,u ; prepare next object to u
MY_MOVE_TO_B_END ; end a move to
_INTENSITY_A
jmp myDraw_VL_mode_direct ; draw the list
; _ZERO_VECTOR_BEAM ; and zero as fast as you can!
; pulu d,x,pc ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
******************************
***** SCORE X*****************
******************************
; special
; the X vectorlist(s)
; are generated in move to display a 3 digit score (max) generated by the starlets
scoreXBehaviour ;#isfunction
stb VIA_t1_cnt_lo ; also stores to scale :-() VIA_t1_cnt_lo ; to timer t1 (lo)
ldb X_POS+u_offset1,u
MY_MOVE_TO_D_START_NT
lda SCORE_COUNTDOWN+u_offset1,u ; timer countdown for score display
inca
sta SCORE_COUNTDOWN+u_offset1,u
cmpa score_display_time ; if count down reached max
lbhi removeObject ; remove the score
lda RecalCounterLow ; scores move slowly only 1 "point" every second round
bita #$01 ; use some counter to access a single bit as compare
beq noAdd_sxb
inc SCALE+u_offset1,u ; and only if bit is set increase the score scale
noAdd_sxb:
ldd #$5f03 ; tiny little score
stb VIA_t1_cnt_lo ; to timer t1 (lo=
MY_MOVE_TO_B_END ; end a move to
_INTENSITY_A
; generate display from score: SCORE_TO_DISPLAY
; the vectorlist of the scores are generated in the spawner
; if list is 0, than nothing is displayed (leading zero of a score)
ldx SCORE_POINTER_3+u_offset1,u
beq not_3_score_xb
jsr myDraw_VL_mode
not_3_score_xb
ldx SCORE_POINTER_2+u_offset1,u
beq not_2_score_xb
jsr myDraw_VL_mode
not_2_score_xb
ldx SCORE_POINTER_1+u_offset1,u
ldu NEXT_OBJECT+u_offset1,u ; prepare next object to u
; jsr myDraw_VL_mode
; _ZERO_VECTOR_BEAM
; pulu d,x,pc ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
jmp myDraw_VL_mode_direct ; draw the list
******************************
***** TIMER ******************
******************************
; this is a special object in the middle of our base
; that displays the timer that is left for our current activated bonus
; special
; the X vectorlist(s)
; are generated in move to
timerBehaviour ;#isfunction
ldd timerObject+Y_POS
stb VIA_t1_cnt_lo ; also stores to scale :-() VIA_t1_cnt_lo ; to timer t1 (lo)
ldb X_POS+timerObject
MY_MOVE_TO_D_START
tst bonus_time_1 ; the position of a two digit timer is different from a one digit timer, here we determine that
beq smallBonusTimer
; large bonus timer
ldy bonusCounter ; contains 50 * times seconds bonus counter - meaning the complete timer in ticks
leay -1,y
sty bonusCounter
lbeq endBonus ; must stay here, if shield was used, than the counter will be rest to 0 here!
dec SECOND_COUNTER+timerObject ; 50Hz that means every 50 ticks is one second
bne noTimerChange_tblarge
lda #50
sta SECOND_COUNTER+timerObject
dec bonus_time_0 ; csa string print version of digit 0 of timer
bpl no_hi_timer_change_tb
lda #9
sta bonus_time_0
dec bonus_time_1 ; csa string print version of digit 1 of timer
bne still_large_timer_tb
lda #$e0 ; y,x pos -1,-10
sta Y_POS+timerObject
sta X_POS+timerObject
bra entry_small_timer_tb
still_large_timer_tb
no_hi_timer_change_tb
noTimerChange_tblarge
ldd #$5f03
stb VIA_t1_cnt_lo ; to timer t1 (lo=
_INTENSITY_A
ldy #NumberList ; list of pointers to number vectorlists
lda bonus_time_1
lsla ; times two
ldx a,y
jsr myDraw_VL_mode
lda bonus_time_0
lsla ; times two
ldx a,y
jsr myDraw_VL_mode
_ZERO_VECTOR_BEAM
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
smallBonusTimer:
ldy bonusCounter ; contains 50 * times seconds bonus counter - meaning the complete timer in ticks
leay -1,y
sty bonusCounter
beq endBonus ; if zero is reached - than bonus is discarded
dec SECOND_COUNTER+timerObject
bne noTimerChange_tb
lda #50
sta SECOND_COUNTER+timerObject
dec bonus_time_0
entry_small_timer_tb:
ldy #NumberList ; list of pointers to number vectorlists
lda bonus_time_0
lsla ; times two
ldd a,y
std CURRENT_LIST+timerObject
noTimerChange_tb:
ldx CURRENT_LIST+timerObject
ldd #$5f03
stb VIA_t1_cnt_lo ; to timer t1 (lo=
_INTENSITY_A
jsr myDraw_VL_mode
_ZERO_VECTOR_BEAM
rts
endBonus
_ZERO_VECTOR_BEAM
; deinit the actual bonus
ldy currentPhaseData ; load data of current "level" - e use this to restore the speed/growth settings
lda bonusActiveType
cmpa #BONUS_TYPE_FASTER
beq deactiveFaster
cmpa #BONUS_TYPE_EXPAND
beq deactiveExpand
cmpa #BONUS_TYPE_SHIELD
beq deactiveShield
deactiveShield:
bra deactivateDone_bb ; nothing realy to deactivate here
deactiveFaster
lda 2,y
sta shieldSpeed ;
lda 5,y
sta shield_width_adder
bra deactivateDone_bb
deactiveExpand
lda 1,y
sta shieldWidthGrowth
lda 5,y
sta shield_width_adder
bra deactivateDone_bb
deactivateDone_bb:
clr bonusActiveType
ldd #0
std timerObject+BEHAVIOUR
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; behaviours control (action) and draw all objects
; each object type has an individual behaviour
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; values are set from "u" list as:
; pulu pc,d,x,y ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
DO_ONE_STAR macro mPos, mScale
sta VIA_t1_cnt_lo ; load and set the correct scale
cmpb #$ff ; if $ffff than not
lbeq inInit1\?
; 17 cycles per star more to calc os from angle, instead of old "pos" version
; saving another 6 cycled by ldd instead of lda + ldb above (pos+scale)
; 11 per star more
; saving one ldd due to puls = 6 cycles
; 11*4-6
; 38 cycles for one star cluster more due to using "angle" instead of pos
; in b star angle 0-240
clra
;CIRCLE_ADR gotton from puls in y
ldy #circle
leay d,y; y circle + starangle 0-240
MY_LSL_D ; in d 0 - 480
; angle final d value 0-762
; corrected in first move to 0 - 720
ldd d,y ; load from y 0 - 720 (angle)
; TODO?
; it is possible to precalculate in a cluster of 4 stars
; the next 3 stars within the previous move
; might save another 20 cycles or so...
MY_MOVE_TO_D_START_NT ; otherwise move to the pos
; in move - don't bother about cycle waste
; lda RecalCounterLow
; bita #$01
; bne noChangests\?
lda mPos+u_offset1,u
tst star_swirl
bpl posAdd_dos\?
adda star_swirl ; since pos is already times 2
cmpa #241
blo angleStarOk\?
lda #240
bra angleStarOk\?
posAdd_dos\?
adda star_swirl ; since pos is already times 2
cmpa #241
blo angleStarOk\?
suba #240
angleStarOk\?:
sta mPos+u_offset1,u
; change star direction everey 10 seconds (nearly)
lda RecalCounterHi
anda #%000000010
bne noChangests\?
tst RecalCounterLow
bne noChangests\?
inc RecalCounterLow ; do only once
ldb star_swirl
lda my_random2
bmi decswirl\?
incswirl\?
addb #2
cmpb #4
beq decswirl\?
bra storeswirl\?
decswirl\?
subb #2
cmpb #-4
beq incswirl\?
storeswirl\?
stb star_swirl
noChangests\?
lda mScale+u_offset1,u ; load scale
cmpa spawn_max ; and see if star is not out of bounds yet
bhi doInit1\? ; jump to init if out of bounds
; cmpa #$80 ; see if star is pretty far away
; blo noMusic\? ; if not jump
; jsr [inMovePointer] ; if yes, decrunch a piece of music
; lda mScale+u_offset1,u ; reload the scale
; and depending on ho "big" the scale is - add even more to the scale
;noMusic\?
adda #5
cmpa #$b0
bhi s1_done\?
deca
cmpa #$80
bhi s1_done\?
deca
cmpa #$40
bhi s1_done\?
deca
cmpa #$20
bhi s1_done\?
deca
s1_done\?
sta mScale+u_offset1,u ; and store the after add
adda #10 ; also depending on the scale calc an intensity level
cmpa #$2f ; minimum intensity
blo b_ok_1\?
lda #$2f
b_ok_1\?
MY_MOVE_TO_B_END ; end a move to
_INTENSITY_A
lda #$ff
STA <VIA_shift_reg ; Store in VIA shift register
; delay for dot dwell
LDB #$CC
clra
sta VIA_shift_reg ; Blank beam in VIA shift register
STB VIA_cntl ;/BLANK low and /ZERO low
bra do_pos3\? ; jump to done
inInit1\?
dec mScale+u_offset1,u ; we are in initi phase, dec the init delay counter
bne do_pos2\? ; if not zero yet - jump out
inc IS_NEW_STARFIELD+u_offset1,u
doInit1\?:
_ZERO_VECTOR_BEAM ; in case we are here from an oob, zero the beam
ldd #$0a00 ; and also "break" current ramping (move)
std VIA_t1_cnt_lo ; disable ramping
lda #8 ; minimum scale at star birth
sta mScale+u_offset1,u ; store the scale
ldb my_random2 ;
andb #%01111111 ; 0 - 127
; in a random number between 0 - 127
aslb ; between 0-254
stb mPos+u_offset1,u
do_pos2\?:
do_pos3\?
endm
starfieldBehaviour ;#isfunction
; four stars per star "atom"
DO_ONE_STAR POS_1, SCALE_1
ldd SCALE_2+u_offset1,u ; load scale and pos to d
DO_ONE_STAR POS_2, SCALE_2
ldd SCALE_3+u_offset1,u ; load scale and pos to d
DO_ONE_STAR POS_3, SCALE_3
ldd SCALE_4+u_offset1,u ; load scale and pos to d
DO_ONE_STAR POS_4, SCALE_4
ldu NEXT_OBJECT+u_offset1,u ; preload next user stack
pulu d,x,pc ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; behaviours control (action) and draw all objects
; each object type has an individual behaviour
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; values are set from "u" list as:
; pulu pc,d,x,y ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
letterBehaviour ;#isfunction
; do the scaling
stb VIA_t1_cnt_lo ; also stores to scale :-() VIA_t1_cnt_lo ; to timer t1 (lo)
ldb X_POS+u_offset1,u
; start the move to
; following calcs can be done within that move
MY_MOVE_TO_D_START_NT
ldd ANGLE+u_offset1,u ; load current scale to a - for later calcs
std tmp_angle
ldy PREVIOUS_LETTER+u_offset1,u ; if we are the "R" than there is no previous letter
beq np_previousLetter ; we have the lead and do not depend on other letters (jump)
; CSA dec DIF_DELAY+u_offset1,u
; bne no_space_changenow_lb
; CSA lda #ADD_DELAY
; CSA sta DIF_DELAY+u_offset1,u
ldd print_angle_2 ; the current "sinus" position of the space pulsation between letters
ldy #circle ;
ldd d,y
tstb ; b is the -sin of the circle
bmi do_minus
beq no_space_changenow_lb ; if we happen to get a 0 do nothing, if we count zero as plus or minus, than the spaces change over time!
ldd SPACE_TO_PREVIOUS+u_offset1,u ;space between each letter
addd #2 ; space change per "add"
bra change_space_done_lb
do_minus
ldd SPACE_TO_PREVIOUS+u_offset1,u
subd #2 ; space change per sub
change_space_done_lb
std SPACE_TO_PREVIOUS+u_offset1,u ; and store the changed space offset
no_space_changenow_lb:
ldy PREVIOUS_LETTER+u_offset1,u ; our own position is always dependened on our prvious letter
ldd ANGLE,y ; load angle of previous
addd SPACE_TO_PREVIOUS+u_offset1,u ; and add our space to that letter
bpl no_anglecircle_overflow_lb ; and correct if over or underflow
addd #720
no_anglecircle_overflow_lb:
cmpd #720
blt no_anglecircle_overflow2_lb
subd #720
no_anglecircle_overflow2_lb:
bra angle_lb_done
np_previousLetter
ldd print_angle ; print angle has the major "circle angle" ("R" moves with that angle)
angle_lb_done
std ANGLE+u_offset1,u ; store current angle
ldy #circle ; and get a pos from that angle
leay d,y ; u pointer to spwan angle coordinates
ldd ,y
sta Y_POS+u_offset1,u ; save start pos
stb X_POS+u_offset1,u ; save start pos
ldu NEXT_OBJECT+u_offset1,u ; preload next user stack
lda #$5f ; intensity
pshs u
MY_MOVE_TO_B_END ; end a move to
_INTENSITY_A
lda #20 ;SHIFT_TITLE_UP ; this title is shifted a little bit upwards to better display the scroller
_SCALE_A
ldd #$7f00 ; $7f is maximum possible positive strength to move
MY_MOVE_TO_D_START_NT
lda vector_print_scale ; strength in that the letters are printed
_SCALE_A
MY_MOVE_TO_B_END ; end a move to
jsr myDraw_VL_mode4
puls u
_ZERO_VECTOR_BEAM
pulu d,x,pc ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
gimmikBehaviour ;
ldd timerObject+Y_POS
stb VIA_t1_cnt_lo ; also stores to scale :-() VIA_t1_cnt_lo ; to timer t1 (lo)
ldb X_POS+timerObject
MY_MOVE_TO_D_START
dec SECOND_COUNTER+timerObject
beq endGimmik ; if zero is reached - than bonus is discarded
dec 2+SECOND_COUNTER+timerObject
bne no_clist_change_g
lda #3
sta 2+SECOND_COUNTER+timerObject ; anim counter
lda 1+SECOND_COUNTER+timerObject ; type of bonus
cmpa #1
beq gimickPac
cmpa #2
beq gimickWorm
gimickGhost
ldd CURRENT_LIST+timerObject
addd #(GhostSmall_1- GhostSmall_0)
cmpd #(GhostSmall_2+(GhostSmall_1- GhostSmall_0))
bne store_vlist_gimmick
ldd #GhostSmall_0
bra store_vlist_gimmick
gimickWorm
inc X_POS+timerObject
ldd CURRENT_LIST+timerObject
addd #(WormSmall_1- WormSmall_0)
cmpd #(WormSmall_6+(WormSmall_1- WormSmall_0))
bne store_vlist_gimmick
ldd #WormSmall_0
bra store_vlist_gimmick
gimickPac
ldd CURRENT_LIST+timerObject
addd #(PacmanSmall_1- PacmanSmall_0)
cmpd #(PacmanSmall_3+(PacmanSmall_1- PacmanSmall_0))
bne store_vlist_gimmick
ldd #PacmanSmall_0
store_vlist_gimmick:
std CURRENT_LIST+timerObject
no_clist_change_g
ldx CURRENT_LIST+timerObject
ldd #$4f03
stb VIA_t1_cnt_lo ; to timer t1 (lo=
_INTENSITY_A
ldy ,x++ ; load offset of vector list draw
leay >(unloop_start_addressSub_2+LENGTH_OF_HEADER),y ;
jsr my_drawVLC_inner
ldd #$cc98
sta <VIA_cntl ; 22 cycles from switch on ZERO disabled, and BLANK enabled
STb <VIA_aux_cntl ;
rts
endGimmik:
ldd #0
std timerObject+BEHAVIOUR
_ZERO_VECTOR_BEAM
rts
|
; A133889: Binomial(n+9,n) mod 9.
; 1,1,1,4,4,4,1,1,1,2,2,2,8,8,8,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,7,7,7,4,4,4,5,5,5,2,2,2,5,5,5,6,6,6,6,6,6,6,6,6,7,7,7,1,1,1,7,7,7,8,8,8,5,5,5,8,8,8,0,0,0,0,0,0,0,0,0,1,1,1,4,4,4,1,1,1,2,2,2,8,8,8,2,2,2,3,3,3,3,3,3
mov $1,$0
mov $0,10
add $1,9
mov $2,9
lpb $0,1
gcd $0,4
bin $1,$2
mod $1,9
add $1,8
lpe
sub $1,8
|
#include "duckdb/planner/binder.hpp"
#include "duckdb/parser/statement/alter_table_statement.hpp"
#include "duckdb/parser/statement/transaction_statement.hpp"
#include "duckdb/parser/statement/pragma_statement.hpp"
#include "duckdb/planner/operator/logical_simple.hpp"
#include "duckdb/catalog/catalog.hpp"
using namespace std;
//! This file contains the binder definitions for statements that do not need to be bound at all and only require a
//! straightforward conversion
namespace duckdb {
BoundStatement Binder::Bind(AlterTableStatement &stmt) {
BoundStatement result;
result.names = {"Success"};
result.types = {SQLType::BOOLEAN};
auto table =
Catalog::GetCatalog(context).GetEntry<TableCatalogEntry>(context, stmt.info->schema, stmt.info->table, true);
if (table && !table->temporary) {
// we can only alter temporary tables in read-only mode
this->read_only = false;
}
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::ALTER, move(stmt.info));
return result;
}
BoundStatement Binder::Bind(PragmaStatement &stmt) {
BoundStatement result;
result.names = {"Success"};
result.types = {SQLType::BOOLEAN};
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::PRAGMA, move(stmt.info));
return result;
}
BoundStatement Binder::Bind(TransactionStatement &stmt) {
// transaction statements do not require a valid transaction
this->requires_valid_transaction = false;
BoundStatement result;
result.names = {"Success"};
result.types = {SQLType::BOOLEAN};
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::TRANSACTION, move(stmt.info));
return result;
}
} // namespace duckdb
|
.outfile "snake.prg"
.require "platform/c64_0.oph"
.require "platform/c64kernal.oph"
.require "head.asm"
main:
.scope
`init
jsr getchar ; 等待输入任意字符开始游戏
jsr erasehint ; 游戏开始,清空提示
* clc
jsr judgeout ; 判断是否出界
bcc +
jsr printfail
jsr getchar
rts
* clc
lda #0
sta eat
jsr judgefood ; 判断是否吃到食物
bcc +
lda #1
sta eat
jsr addfood
* jsr move ; 蛇移动一格
jsr calcscore ; 计算得分
jsr printscore ; 打印分数
lda d
sta prev_d ; 备份前一个按键
lda #20
jsr delay ; 延时期间最后一个按键位于d
lda d
cmp #ed_g
beq _end
cmp #st_g
bne ---
jsr getchar
lda prev_d
sta d ; 恢复按键
jmp ---
_end:
rts
.scend
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; init 初始化界面、变量
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.macro init
lda #147 ; 清屏
jsr chrout
lda #$00
sta s
sta eat
sta s + 1 ; 初始化分数为0
jsr printscore ; 打印分数
jsr move_init
jsr printfield ; 打印蛇,包括边框
jsr printhint ; 打印开始提示
lda #go_d ; 初始化方向为下
sta d
jsr srand ; 初始化随机数种子
jsr addfood ; 增加食物
.macend
.require "printscore.asm"
.require "print16.asm"
.require "printfield.asm"
.require "hint.asm"
.require "getchar.asm"
.require "addfood.asm"
.require "delay.asm"
.require "judge.asm"
.require "move.asm"
.require "calcscore.asm"
.require "print.asm"
.checkpc $a000 ; text段边界
.data zp ; 零页段边界
.checkpc $80
.data
.checkpc $d000 ; data段边界 |
TITL "6800/6801 Cross-Assembler Test Source File"
PAGE 60
;
; The 6801 opcodes in opcode numerical order:
;
CPU 6801
IMMEDIATE EQU 0
OFFSET EQU 0
DIRECT ORG 0
EXTENDED ORG $100
; $00 - $0F.
; $00 is undefined.
NOP
; $02 - $03 are undefined.
LSRD
ASLD
TAP
TPA
INX
DEX
CLV
SEV
CLC
SEC
CLI
SEI
; $10 - $1F.
SBA
CBA
; $12 - $15 are undefined.
TAB
TBA
; $18 is undefined.
DAA
; $1A is undefined.
ABA
; $1B - $1F are undefined.
; $20 - $2F.
BRA * + 2
BRN * + 2
BHI * + 2
BLS * + 2
BCC * + 2
BCS * + 2
BNE * + 2
BEQ * + 2
BVC * + 2
BVS * + 2
BPL * + 2
BMI * + 2
BGE * + 2
BLT * + 2
BGT * + 2
BLE * + 2
; $30 - $3F.
TSX
INS
PULA
PULB
DES
TXS
PSHA
PSHB
PULX
RTS
ABX
RTI
PSHX
MUL
WAI
SWI
; $40 - $4F.
NEGA
; $41 - $42 are undefined.
COMA
LSRA
; $45 is undefined.
RORA
ASRA
ASLA
ROLA
DECA
; $4B is undefined.
INCA
TSTA
; $5E is undefined.
CLRA
; $50 - $5F.
NEGB
; $51 - $52 are undefined.
COMB
LSRB
; $55 is undefined.
RORB
ASRB
ASLB
ROLB
DECB
; $5B is undefined.
INCB
TSTB
; $5E is undefined.
CLRB
; $60 - $6F.
NEG X, OFFSET
; $61 - $62 are undefined.
COM X, OFFSET
LSR X, OFFSET
; $65 is undefined.
ROR X, OFFSET
ASR X, OFFSET
ASL X, OFFSET
ROL X, OFFSET
DEC X, OFFSET
; $6B is undefined.
INC X, OFFSET
TST X, OFFSET
JMP X, OFFSET
CLR X, OFFSET
; $70 - $7F.
NEG EXTENDED
; $71 - $72 are undefined.
COM EXTENDED
LSR EXTENDED
; $75 is undefined.
ROR EXTENDED
ASR EXTENDED
ASL EXTENDED
ROL EXTENDED
DEC EXTENDED
; $7B is undefined.
INC EXTENDED
TST EXTENDED
JMP EXTENDED
CLR EXTENDED
; $80 - $8F.
SUBA #IMMEDIATE
CMPA #IMMEDIATE
SBCA #IMMEDIATE
SUBD #IMMEDIATE
ANDA #IMMEDIATE
BITA #IMMEDIATE
LDAA #IMMEDIATE
; $87 is undefined.
EORA #IMMEDIATE
ADCA #IMMEDIATE
ORAA #IMMEDIATE
ADDA #IMMEDIATE
CPX #IMMEDIATE
BSR * + 2
LDS #IMMEDIATE
; $8F is undefined.
; $90 - $9F.
SUBA DIRECT
CMPA DIRECT
SBCA DIRECT
SUBD DIRECT
ANDA DIRECT
BITA DIRECT
LDAA DIRECT
STAA DIRECT
EORA DIRECT
ADCA DIRECT
ORAA DIRECT
ADDA DIRECT
CPX DIRECT
JSR DIRECT
LDS DIRECT
STS DIRECT
; $A0 - $AF.
SUBA X, OFFSET
CMPA X, OFFSET
SBCA X, OFFSET
SUBD X, OFFSET
ANDA X, OFFSET
BITA X, OFFSET
LDAA X, OFFSET
STAA X, OFFSET
EORA X, OFFSET
ADCA X, OFFSET
ORAA X, OFFSET
ADDA X, OFFSET
CPX X, OFFSET
JSR X, OFFSET
LDS X, OFFSET
STS X, OFFSET
; $B0 - $BF.
SUBA EXTENDED
CMPA EXTENDED
SBCA EXTENDED
SUBD EXTENDED
ANDA EXTENDED
BITA EXTENDED
LDAA EXTENDED
STAA EXTENDED
EORA EXTENDED
ADCA EXTENDED
ORAA EXTENDED
ADDA EXTENDED
CPX EXTENDED
JSR EXTENDED
LDS EXTENDED
STS EXTENDED
; $C0 - $CF.
SUBB #IMMEDIATE
CMPB #IMMEDIATE
SBCB #IMMEDIATE
ADDD #IMMEDIATE
ANDB #IMMEDIATE
BITB #IMMEDIATE
LDAB #IMMEDIATE
; $C7 is undefined.
EORB #IMMEDIATE
ADCB #IMMEDIATE
ORAB #IMMEDIATE
ADDB #IMMEDIATE
LDD #IMMEDIATE
; $CD is undefined.
LDX #IMMEDIATE
; $CF is undefined.
; $D0 - $DF.
SUBB DIRECT
CMPB DIRECT
SBCB DIRECT
ADDD DIRECT
ANDB DIRECT
BITB DIRECT
LDAB DIRECT
STAB DIRECT
EORB DIRECT
ADCB DIRECT
ORAB DIRECT
ADDB DIRECT
LDD DIRECT
STD DIRECT
LDX DIRECT
STX DIRECT
; $E0 - $EF.
SUBB X, OFFSET
CMPB X, OFFSET
SBCB X, OFFSET
ADDD X, OFFSET
ANDB X, OFFSET
BITB X, OFFSET
LDAB X, OFFSET
STAB X, OFFSET
EORB X, OFFSET
ADCB X, OFFSET
ORAB X, OFFSET
ADDB X, OFFSET
LDD X, OFFSET
STD X, OFFSET
LDX X, OFFSET
STX X, OFFSET
; $F0 - $FF.
SUBB EXTENDED
CMPB EXTENDED
SBCB EXTENDED
ADDD EXTENDED
ANDB EXTENDED
BITB EXTENDED
LDAB EXTENDED
STAB EXTENDED
EORB EXTENDED
ADCB EXTENDED
ORAB EXTENDED
ADDB EXTENDED
LDD EXTENDED
STD EXTENDED
LDX EXTENDED
STX EXTENDED
;
; Let's test the rest of the pseudo-ops while we're at it:
;
VARIABLE SET -1
IF VARIABLE
FCB -1, , +1
ELSE
FCB +1, , -1
ENDI
VARIABLE SET VARIABLE EQ 0
IF VARIABLE
FDB , +1
ELSE
FDB , -1
ENDI
RMB 10H
FCC "EXPLOSION"
END
BITB DIRECT
LDAB DIRECT
STAB DIRECT
EORB DIRECT
|
;*****************************************************************************
;* sad16-a.asm: x86 high depth sad functions
;*****************************************************************************
;* Copyright (C) 2010-2013 x264 project
;*
;* Authors: Oskar Arvidsson <oskar@irock.se>
;* Henrik Gramner <henrik@gramner.com>
;*
;* This program is free software; you can redistribute it and/or modify
;* it under the terms of the GNU General Public License as published by
;* the Free Software Foundation; either version 2 of the License, or
;* (at your option) any later version.
;*
;* This program is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;* GNU General Public License for more details.
;*
;* You should have received a copy of the GNU General Public License
;* along with this program; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
;*
;* This program is also available under a commercial proprietary license.
;* For more information, contact us at licensing@x264.com.
;*****************************************************************************
%include "x86inc.asm"
%include "x86util.asm"
SECTION .text
cextern pw_1
cextern pw_4
cextern pw_8
;=============================================================================
; SAD MMX
;=============================================================================
%macro SAD_INC_1x16P_MMX 0
movu m1, [r0+ 0]
movu m2, [r0+ 8]
movu m3, [r0+16]
movu m4, [r0+24]
psubw m1, [r2+ 0]
psubw m2, [r2+ 8]
psubw m3, [r2+16]
psubw m4, [r2+24]
ABSW2 m1, m2, m1, m2, m5, m6
ABSW2 m3, m4, m3, m4, m7, m5
lea r0, [r0+2*r1]
lea r2, [r2+2*r3]
paddw m1, m2
paddw m3, m4
paddw m0, m1
paddw m0, m3
%endmacro
%macro SAD_INC_2x8P_MMX 0
movu m1, [r0+0]
movu m2, [r0+8]
movu m3, [r0+2*r1+0]
movu m4, [r0+2*r1+8]
psubw m1, [r2+0]
psubw m2, [r2+8]
psubw m3, [r2+2*r3+0]
psubw m4, [r2+2*r3+8]
ABSW2 m1, m2, m1, m2, m5, m6
ABSW2 m3, m4, m3, m4, m7, m5
lea r0, [r0+4*r1]
lea r2, [r2+4*r3]
paddw m1, m2
paddw m3, m4
paddw m0, m1
paddw m0, m3
%endmacro
%macro SAD_INC_2x4P_MMX 0
movu m1, [r0]
movu m2, [r0+2*r1]
psubw m1, [r2]
psubw m2, [r2+2*r3]
ABSW2 m1, m2, m1, m2, m3, m4
lea r0, [r0+4*r1]
lea r2, [r2+4*r3]
paddw m0, m1
paddw m0, m2
%endmacro
;-----------------------------------------------------------------------------
; int pixel_sad_NxM( uint16_t *, intptr_t, uint16_t *, intptr_t )
;-----------------------------------------------------------------------------
%macro SAD_MMX 3
cglobal pixel_sad_%1x%2, 4,5-(%2&4/4)
pxor m0, m0
%if %2 == 4
SAD_INC_%3x%1P_MMX
SAD_INC_%3x%1P_MMX
%else
mov r4d, %2/%3
.loop:
SAD_INC_%3x%1P_MMX
dec r4d
jg .loop
%endif
%if %1*%2 == 256
HADDUW m0, m1
%else
HADDW m0, m1
%endif
movd eax, m0
RET
%endmacro
INIT_MMX mmx2
SAD_MMX 16, 16, 1
SAD_MMX 16, 8, 1
SAD_MMX 8, 16, 2
SAD_MMX 8, 8, 2
SAD_MMX 8, 4, 2
SAD_MMX 4, 8, 2
SAD_MMX 4, 4, 2
INIT_MMX ssse3
SAD_MMX 4, 8, 2
SAD_MMX 4, 4, 2
;=============================================================================
; SAD XMM
;=============================================================================
%macro SAD_INC_2ROW 1
%if 2*%1 > mmsize
movu m1, [r2+ 0]
movu m2, [r2+16]
movu m3, [r2+2*r3+ 0]
movu m4, [r2+2*r3+16]
psubw m1, [r0+ 0]
psubw m2, [r0+16]
psubw m3, [r0+2*r1+ 0]
psubw m4, [r0+2*r1+16]
ABSW2 m1, m2, m1, m2, m5, m6
lea r0, [r0+4*r1]
lea r2, [r2+4*r3]
ABSW2 m3, m4, m3, m4, m7, m5
paddw m1, m2
paddw m3, m4
paddw m0, m1
paddw m0, m3
%else
movu m1, [r2]
movu m2, [r2+2*r3]
psubw m1, [r0]
psubw m2, [r0+2*r1]
ABSW2 m1, m2, m1, m2, m3, m4
lea r0, [r0+4*r1]
lea r2, [r2+4*r3]
paddw m0, m1
paddw m0, m2
%endif
%endmacro
;-----------------------------------------------------------------------------
; int pixel_sad_NxM( uint16_t *, intptr_t, uint16_t *, intptr_t )
;-----------------------------------------------------------------------------
%macro SAD 2
cglobal pixel_sad_%1x%2, 4,5-(%2&4/4),8*(%1/mmsize)
pxor m0, m0
%if %2 == 4
SAD_INC_2ROW %1
SAD_INC_2ROW %1
%else
mov r4d, %2/2
.loop:
SAD_INC_2ROW %1
dec r4d
jg .loop
%endif
HADDW m0, m1
movd eax, xm0
RET
%endmacro
INIT_XMM sse2
SAD 16, 16
SAD 16, 8
SAD 8, 16
SAD 8, 8
SAD 8, 4
INIT_XMM sse2, aligned
SAD 16, 16
SAD 16, 8
SAD 8, 16
SAD 8, 8
INIT_XMM ssse3
SAD 16, 16
SAD 16, 8
SAD 8, 16
SAD 8, 8
SAD 8, 4
INIT_XMM ssse3, aligned
SAD 16, 16
SAD 16, 8
SAD 8, 16
SAD 8, 8
INIT_YMM avx2
SAD 16, 16
SAD 16, 8
;=============================================================================
; SAD x3/x4
;=============================================================================
%macro SAD_X3_INC_P 0
add r0, 4*FENC_STRIDE
lea r1, [r1+4*r4]
lea r2, [r2+4*r4]
lea r3, [r3+4*r4]
%endmacro
%macro SAD_X3_ONE_START 0
mova m3, [r0]
movu m0, [r1]
movu m1, [r2]
movu m2, [r3]
psubw m0, m3
psubw m1, m3
psubw m2, m3
ABSW2 m0, m1, m0, m1, m4, m5
ABSW m2, m2, m6
%endmacro
%macro SAD_X3_ONE 2
mova m6, [r0+%1]
movu m3, [r1+%2]
movu m4, [r2+%2]
movu m5, [r3+%2]
psubw m3, m6
psubw m4, m6
psubw m5, m6
ABSW2 m3, m4, m3, m4, m7, m6
ABSW m5, m5, m6
paddw m0, m3
paddw m1, m4
paddw m2, m5
%endmacro
%macro SAD_X3_END 2
%if mmsize == 8 && %1*%2 == 256
HADDUW m0, m3
HADDUW m1, m4
HADDUW m2, m5
%else
HADDW m0, m3
HADDW m1, m4
HADDW m2, m5
%endif
%if UNIX64
movd [r5+0], xm0
movd [r5+4], xm1
movd [r5+8], xm2
%else
mov r0, r5mp
movd [r0+0], xm0
movd [r0+4], xm1
movd [r0+8], xm2
%endif
RET
%endmacro
%macro SAD_X4_INC_P 0
add r0, 4*FENC_STRIDE
lea r1, [r1+4*r5]
lea r2, [r2+4*r5]
lea r3, [r3+4*r5]
lea r4, [r4+4*r5]
%endmacro
%macro SAD_X4_ONE_START 0
mova m4, [r0]
movu m0, [r1]
movu m1, [r2]
movu m2, [r3]
movu m3, [r4]
psubw m0, m4
psubw m1, m4
psubw m2, m4
psubw m3, m4
ABSW2 m0, m1, m0, m1, m5, m6
ABSW2 m2, m3, m2, m3, m4, m7
%endmacro
%macro SAD_X4_ONE 2
mova m4, [r0+%1]
movu m5, [r1+%2]
movu m6, [r2+%2]
%if num_mmregs > 8
movu m7, [r3+%2]
movu m8, [r4+%2]
psubw m5, m4
psubw m6, m4
psubw m7, m4
psubw m8, m4
ABSW2 m5, m6, m5, m6, m9, m10
ABSW2 m7, m8, m7, m8, m9, m10
paddw m0, m5
paddw m1, m6
paddw m2, m7
paddw m3, m8
%elif cpuflag(ssse3)
movu m7, [r3+%2]
psubw m5, m4
psubw m6, m4
psubw m7, m4
movu m4, [r4+%2]
pabsw m5, m5
psubw m4, [r0+%1]
pabsw m6, m6
pabsw m7, m7
pabsw m4, m4
paddw m0, m5
paddw m1, m6
paddw m2, m7
paddw m3, m4
%else ; num_mmregs == 8 && !ssse3
psubw m5, m4
psubw m6, m4
ABSW m5, m5, m7
ABSW m6, m6, m7
paddw m0, m5
paddw m1, m6
movu m5, [r3+%2]
movu m6, [r4+%2]
psubw m5, m4
psubw m6, m4
ABSW2 m5, m6, m5, m6, m7, m4
paddw m2, m5
paddw m3, m6
%endif
%endmacro
%macro SAD_X4_END 2
%if mmsize == 8 && %1*%2 == 256
HADDUW m0, m4
HADDUW m1, m5
HADDUW m2, m6
HADDUW m3, m7
%else
HADDW m0, m4
HADDW m1, m5
HADDW m2, m6
HADDW m3, m7
%endif
mov r0, r6mp
movd [r0+ 0], xm0
movd [r0+ 4], xm1
movd [r0+ 8], xm2
movd [r0+12], xm3
RET
%endmacro
%macro SAD_X_2xNP 4
%assign x %3
%rep %4
SAD_X%1_ONE x*mmsize, x*mmsize
SAD_X%1_ONE 2*FENC_STRIDE+x*mmsize, 2*%2+x*mmsize
%assign x x+1
%endrep
%endmacro
%macro PIXEL_VSAD 0
cglobal pixel_vsad, 3,3,8
mova m0, [r0]
mova m1, [r0+16]
mova m2, [r0+2*r1]
mova m3, [r0+2*r1+16]
lea r0, [r0+4*r1]
psubw m0, m2
psubw m1, m3
ABSW2 m0, m1, m0, m1, m4, m5
paddw m0, m1
sub r2d, 2
je .end
.loop:
mova m4, [r0]
mova m5, [r0+16]
mova m6, [r0+2*r1]
mova m7, [r0+2*r1+16]
lea r0, [r0+4*r1]
psubw m2, m4
psubw m3, m5
psubw m4, m6
psubw m5, m7
ABSW m2, m2, m1
ABSW m3, m3, m1
ABSW m4, m4, m1
ABSW m5, m5, m1
paddw m0, m2
paddw m0, m3
paddw m0, m4
paddw m0, m5
mova m2, m6
mova m3, m7
sub r2d, 2
jg .loop
.end:
%if BIT_DEPTH == 9
HADDW m0, m1 ; max sum: 62(pixel diffs)*511(pixel_max)=31682
%else
HADDUW m0, m1 ; max sum: 62(pixel diffs)*1023(pixel_max)=63426
%endif
movd eax, m0
RET
%endmacro
INIT_XMM sse2
PIXEL_VSAD
INIT_XMM ssse3
PIXEL_VSAD
INIT_XMM xop
PIXEL_VSAD
INIT_YMM avx2
cglobal pixel_vsad, 3,3
mova m0, [r0]
mova m1, [r0+2*r1]
lea r0, [r0+4*r1]
psubw m0, m1
pabsw m0, m0
sub r2d, 2
je .end
.loop:
mova m2, [r0]
mova m3, [r0+2*r1]
lea r0, [r0+4*r1]
psubw m1, m2
psubw m2, m3
pabsw m1, m1
pabsw m2, m2
paddw m0, m1
paddw m0, m2
mova m1, m3
sub r2d, 2
jg .loop
.end:
%if BIT_DEPTH == 9
HADDW m0, m1
%else
HADDUW m0, m1
%endif
movd eax, xm0
RET
;-----------------------------------------------------------------------------
; void pixel_sad_xN_WxH( uint16_t *fenc, uint16_t *pix0, uint16_t *pix1,
; uint16_t *pix2, intptr_t i_stride, int scores[3] )
;-----------------------------------------------------------------------------
%macro SAD_X 3
cglobal pixel_sad_x%1_%2x%3, 6,7,XMM_REGS
%assign regnum %1+1
%xdefine STRIDE r %+ regnum
mov r6, %3/2-1
SAD_X%1_ONE_START
SAD_X%1_ONE 2*FENC_STRIDE, 2*STRIDE
SAD_X_2xNP %1, STRIDE, 1, %2/(mmsize/2)-1
.loop:
SAD_X%1_INC_P
SAD_X_2xNP %1, STRIDE, 0, %2/(mmsize/2)
dec r6
jg .loop
%if %1 == 4
mov r6, r6m
%endif
SAD_X%1_END %2, %3
%endmacro
INIT_MMX mmx2
%define XMM_REGS 0
SAD_X 3, 16, 16
SAD_X 3, 16, 8
SAD_X 3, 8, 16
SAD_X 3, 8, 8
SAD_X 3, 8, 4
SAD_X 3, 4, 8
SAD_X 3, 4, 4
SAD_X 4, 16, 16
SAD_X 4, 16, 8
SAD_X 4, 8, 16
SAD_X 4, 8, 8
SAD_X 4, 8, 4
SAD_X 4, 4, 8
SAD_X 4, 4, 4
INIT_MMX ssse3
SAD_X 3, 4, 8
SAD_X 3, 4, 4
SAD_X 4, 4, 8
SAD_X 4, 4, 4
INIT_XMM ssse3
%define XMM_REGS 7
SAD_X 3, 16, 16
SAD_X 3, 16, 8
SAD_X 3, 8, 16
SAD_X 3, 8, 8
SAD_X 3, 8, 4
%define XMM_REGS 9
SAD_X 4, 16, 16
SAD_X 4, 16, 8
SAD_X 4, 8, 16
SAD_X 4, 8, 8
SAD_X 4, 8, 4
INIT_XMM sse2
%define XMM_REGS 8
SAD_X 3, 16, 16
SAD_X 3, 16, 8
SAD_X 3, 8, 16
SAD_X 3, 8, 8
SAD_X 3, 8, 4
%define XMM_REGS 11
SAD_X 4, 16, 16
SAD_X 4, 16, 8
SAD_X 4, 8, 16
SAD_X 4, 8, 8
SAD_X 4, 8, 4
INIT_YMM avx2
%define XMM_REGS 7
SAD_X 3, 16, 16
SAD_X 3, 16, 8
%define XMM_REGS 9
SAD_X 4, 16, 16
SAD_X 4, 16, 8
;-----------------------------------------------------------------------------
; void intra_sad_x3_4x4( uint16_t *fenc, uint16_t *fdec, int res[3] );
;-----------------------------------------------------------------------------
%macro INTRA_SAD_X3_4x4 0
cglobal intra_sad_x3_4x4, 3,3,7
movddup m0, [r1-1*FDEC_STRIDEB]
movq m1, [r0+0*FENC_STRIDEB]
movq m2, [r0+2*FENC_STRIDEB]
pshuflw m6, m0, q1032
paddw m6, m0
pshuflw m5, m6, q2301
paddw m6, m5
punpcklqdq m6, m6 ; A+B+C+D 8 times
movhps m1, [r0+1*FENC_STRIDEB]
movhps m2, [r0+3*FENC_STRIDEB]
psubw m3, m1, m0
psubw m0, m2
ABSW2 m3, m0, m3, m0, m4, m5
paddw m0, m3
movd m3, [r1+0*FDEC_STRIDEB-4]
movd m4, [r1+2*FDEC_STRIDEB-4]
movhps m3, [r1+1*FDEC_STRIDEB-8]
movhps m4, [r1+3*FDEC_STRIDEB-8]
pshufhw m3, m3, q3333
pshufhw m4, m4, q3333
pshuflw m3, m3, q1111 ; FF FF EE EE
pshuflw m4, m4, q1111 ; HH HH GG GG
paddw m5, m3, m4
paddw m6, [pw_4]
paddw m6, m5
pshufd m5, m5, q1032
paddw m5, m6
psrlw m5, 3
psubw m6, m5, m2
psubw m5, m1
psubw m1, m3
psubw m2, m4
ABSW2 m5, m6, m5, m6, m3, m4
ABSW2 m1, m2, m1, m2, m3, m4
paddw m5, m6
paddw m1, m2
%if cpuflag(ssse3)
phaddw m0, m1
movhlps m3, m5
paddw m5, m3
phaddw m0, m5
pmaddwd m0, [pw_1]
mova [r2], m0
%else
HADDW m0, m3
HADDW m1, m3
HADDW m5, m3
movd [r2], m0 ; V prediction cost
movd [r2+4], m1 ; H prediction cost
movd [r2+8], m5 ; DC prediction cost
%endif
RET
%endmacro
INIT_XMM sse2
INTRA_SAD_X3_4x4
INIT_XMM ssse3
INTRA_SAD_X3_4x4
INIT_XMM avx
INTRA_SAD_X3_4x4
;-----------------------------------------------------------------------------
; void intra_sad_x3_8x8( pixel *fenc, pixel edge[36], int res[3] );
;-----------------------------------------------------------------------------
;m0 = DC
;m6 = V
;m7 = H
;m1 = DC score
;m2 = V score
;m3 = H score
;m5 = temp
;m4 = pixel row
%macro INTRA_SAD_HVDC_ITER 2
mova m4, [r0+(%1-4)*FENC_STRIDEB]
psubw m4, m0
ABSW m4, m4, m5
ACCUM paddw, 1, 4, %1
mova m4, [r0+(%1-4)*FENC_STRIDEB]
psubw m4, m6
ABSW m4, m4, m5
ACCUM paddw, 2, 4, %1
pshufd m5, m7, %2
psubw m5, [r0+(%1-4)*FENC_STRIDEB]
ABSW m5, m5, m4
ACCUM paddw, 3, 5, %1
%endmacro
%macro INTRA_SAD_X3_8x8 0
cglobal intra_sad_x3_8x8, 3,3,8
add r0, 4*FENC_STRIDEB
movu m0, [r1+7*SIZEOF_PIXEL]
mova m6, [r1+16*SIZEOF_PIXEL] ;V prediction
mova m7, m0
paddw m0, m6
punpckhwd m7, m7
HADDW m0, m4
paddw m0, [pw_8]
psrlw m0, 4
SPLATW m0, m0
INTRA_SAD_HVDC_ITER 0, q3333
INTRA_SAD_HVDC_ITER 1, q2222
INTRA_SAD_HVDC_ITER 2, q1111
INTRA_SAD_HVDC_ITER 3, q0000
movq m7, [r1+7*SIZEOF_PIXEL]
punpcklwd m7, m7
INTRA_SAD_HVDC_ITER 4, q3333
INTRA_SAD_HVDC_ITER 5, q2222
INTRA_SAD_HVDC_ITER 6, q1111
INTRA_SAD_HVDC_ITER 7, q0000
%if cpuflag(ssse3)
phaddw m2, m3 ; 2 2 2 2 3 3 3 3
movhlps m3, m1
paddw m1, m3 ; 1 1 1 1 _ _ _ _
phaddw m2, m1 ; 2 2 3 3 1 1 _ _
pmaddwd m2, [pw_1] ; 2 3 1 _
mova [r2], m2
%else
HADDW m2, m4
HADDW m3, m4
HADDW m1, m4
movd [r2+0], m2
movd [r2+4], m3
movd [r2+8], m1
%endif
RET
%endmacro
INIT_XMM sse2
INTRA_SAD_X3_8x8
INIT_XMM ssse3
INTRA_SAD_X3_8x8
%macro INTRA_SAD_HVDC_ITER_YMM 2
mova xm4, [r0+(%1-4)*FENC_STRIDEB]
vinserti128 m4, m4, [r0+%1*FENC_STRIDEB], 1
pshufd m5, m7, %2
psubw m5, m4
pabsw m5, m5
ACCUM paddw, 2, 5, %1 ; H
psubw m5, m4, m6
psubw m4, m0
pabsw m5, m5
pabsw m4, m4
ACCUM paddw, 1, 5, %1 ; V
ACCUM paddw, 3, 4, %1 ; DC
%endmacro
INIT_YMM avx2
cglobal intra_sad_x3_8x8, 3,3,8
add r0, 4*FENC_STRIDEB
movu xm0, [r1+7*SIZEOF_PIXEL]
vbroadcasti128 m6, [r1+16*SIZEOF_PIXEL] ; V prediction
vpermq m7, m0, q0011
paddw xm0, xm6
paddw xm0, [pw_1] ; equal to +8 after HADDW
HADDW xm0, xm4
psrld xm0, 4
vpbroadcastw m0, xm0
punpcklwd m7, m7
INTRA_SAD_HVDC_ITER_YMM 0, q3333
INTRA_SAD_HVDC_ITER_YMM 1, q2222
INTRA_SAD_HVDC_ITER_YMM 2, q1111
INTRA_SAD_HVDC_ITER_YMM 3, q0000
phaddw m1, m2 ; 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2
punpckhqdq m2, m3, m3
paddw m3, m2 ; 3 3 3 3 _ _ _ _ 3 3 3 3 _ _ _ _
phaddw m1, m3 ; 1 1 2 2 3 3 _ _ 1 1 2 2 3 3 _ _
vextracti128 xm2, m1, 1
paddw xm1, xm2 ; 1 1 2 2 3 3 _ _
pmaddwd xm1, [pw_1] ; 1 2 3 _
mova [r2], xm1
RET
|
SECTION code_clib
SECTION code_fp_math48
PUBLIC am48_dinv
EXTERN am48_dconst_1, am48_ddiv
am48_dinv:
; invert
; AC' = 1/AC'
;
; enter : AC'= double x
;
; exit : AC = double x
;
; success
;
; AC' = 1/x
; carry reset
;
; fail if overflow
;
; AC' = +-infinity
; carry set, errno set
;
; uses : af, bc, de, hl, af', bc', de', hl'
call am48_dconst_1 ; AC = 1
exx
jp am48_ddiv
|
_ln: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 53 push %ebx
e: 51 push %ecx
f: 89 cb mov %ecx,%ebx
if(argc != 3){
11: 83 3b 03 cmpl $0x3,(%ebx)
14: 74 17 je 2d <main+0x2d>
printf(2, "Usage: ln old new\n");
16: 83 ec 08 sub $0x8,%esp
19: 68 18 08 00 00 push $0x818
1e: 6a 02 push $0x2
20: e8 3d 04 00 00 call 462 <printf>
25: 83 c4 10 add $0x10,%esp
exit();
28: e8 9e 02 00 00 call 2cb <exit>
}
if(link(argv[1], argv[2]) < 0)
2d: 8b 43 04 mov 0x4(%ebx),%eax
30: 83 c0 08 add $0x8,%eax
33: 8b 10 mov (%eax),%edx
35: 8b 43 04 mov 0x4(%ebx),%eax
38: 83 c0 04 add $0x4,%eax
3b: 8b 00 mov (%eax),%eax
3d: 83 ec 08 sub $0x8,%esp
40: 52 push %edx
41: 50 push %eax
42: e8 e4 02 00 00 call 32b <link>
47: 83 c4 10 add $0x10,%esp
4a: 85 c0 test %eax,%eax
4c: 79 21 jns 6f <main+0x6f>
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
4e: 8b 43 04 mov 0x4(%ebx),%eax
51: 83 c0 08 add $0x8,%eax
54: 8b 10 mov (%eax),%edx
56: 8b 43 04 mov 0x4(%ebx),%eax
59: 83 c0 04 add $0x4,%eax
5c: 8b 00 mov (%eax),%eax
5e: 52 push %edx
5f: 50 push %eax
60: 68 2b 08 00 00 push $0x82b
65: 6a 02 push $0x2
67: e8 f6 03 00 00 call 462 <printf>
6c: 83 c4 10 add $0x10,%esp
exit();
6f: e8 57 02 00 00 call 2cb <exit>
00000074 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
74: 55 push %ebp
75: 89 e5 mov %esp,%ebp
77: 57 push %edi
78: 53 push %ebx
asm volatile("cld; rep stosb" :
79: 8b 4d 08 mov 0x8(%ebp),%ecx
7c: 8b 55 10 mov 0x10(%ebp),%edx
7f: 8b 45 0c mov 0xc(%ebp),%eax
82: 89 cb mov %ecx,%ebx
84: 89 df mov %ebx,%edi
86: 89 d1 mov %edx,%ecx
88: fc cld
89: f3 aa rep stos %al,%es:(%edi)
8b: 89 ca mov %ecx,%edx
8d: 89 fb mov %edi,%ebx
8f: 89 5d 08 mov %ebx,0x8(%ebp)
92: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
95: 90 nop
96: 5b pop %ebx
97: 5f pop %edi
98: 5d pop %ebp
99: c3 ret
0000009a <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
9a: 55 push %ebp
9b: 89 e5 mov %esp,%ebp
9d: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
a0: 8b 45 08 mov 0x8(%ebp),%eax
a3: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
a6: 90 nop
a7: 8b 45 08 mov 0x8(%ebp),%eax
aa: 8d 50 01 lea 0x1(%eax),%edx
ad: 89 55 08 mov %edx,0x8(%ebp)
b0: 8b 55 0c mov 0xc(%ebp),%edx
b3: 8d 4a 01 lea 0x1(%edx),%ecx
b6: 89 4d 0c mov %ecx,0xc(%ebp)
b9: 0f b6 12 movzbl (%edx),%edx
bc: 88 10 mov %dl,(%eax)
be: 0f b6 00 movzbl (%eax),%eax
c1: 84 c0 test %al,%al
c3: 75 e2 jne a7 <strcpy+0xd>
;
return os;
c5: 8b 45 fc mov -0x4(%ebp),%eax
}
c8: c9 leave
c9: c3 ret
000000ca <strcmp>:
int
strcmp(const char *p, const char *q)
{
ca: 55 push %ebp
cb: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
cd: eb 08 jmp d7 <strcmp+0xd>
p++, q++;
cf: 83 45 08 01 addl $0x1,0x8(%ebp)
d3: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
d7: 8b 45 08 mov 0x8(%ebp),%eax
da: 0f b6 00 movzbl (%eax),%eax
dd: 84 c0 test %al,%al
df: 74 10 je f1 <strcmp+0x27>
e1: 8b 45 08 mov 0x8(%ebp),%eax
e4: 0f b6 10 movzbl (%eax),%edx
e7: 8b 45 0c mov 0xc(%ebp),%eax
ea: 0f b6 00 movzbl (%eax),%eax
ed: 38 c2 cmp %al,%dl
ef: 74 de je cf <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
f1: 8b 45 08 mov 0x8(%ebp),%eax
f4: 0f b6 00 movzbl (%eax),%eax
f7: 0f b6 d0 movzbl %al,%edx
fa: 8b 45 0c mov 0xc(%ebp),%eax
fd: 0f b6 00 movzbl (%eax),%eax
100: 0f b6 c0 movzbl %al,%eax
103: 29 c2 sub %eax,%edx
105: 89 d0 mov %edx,%eax
}
107: 5d pop %ebp
108: c3 ret
00000109 <strlen>:
uint
strlen(char *s)
{
109: 55 push %ebp
10a: 89 e5 mov %esp,%ebp
10c: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
10f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
116: eb 04 jmp 11c <strlen+0x13>
118: 83 45 fc 01 addl $0x1,-0x4(%ebp)
11c: 8b 55 fc mov -0x4(%ebp),%edx
11f: 8b 45 08 mov 0x8(%ebp),%eax
122: 01 d0 add %edx,%eax
124: 0f b6 00 movzbl (%eax),%eax
127: 84 c0 test %al,%al
129: 75 ed jne 118 <strlen+0xf>
;
return n;
12b: 8b 45 fc mov -0x4(%ebp),%eax
}
12e: c9 leave
12f: c3 ret
00000130 <memset>:
void*
memset(void *dst, int c, uint n)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
133: 8b 45 10 mov 0x10(%ebp),%eax
136: 50 push %eax
137: ff 75 0c pushl 0xc(%ebp)
13a: ff 75 08 pushl 0x8(%ebp)
13d: e8 32 ff ff ff call 74 <stosb>
142: 83 c4 0c add $0xc,%esp
return dst;
145: 8b 45 08 mov 0x8(%ebp),%eax
}
148: c9 leave
149: c3 ret
0000014a <strchr>:
char*
strchr(const char *s, char c)
{
14a: 55 push %ebp
14b: 89 e5 mov %esp,%ebp
14d: 83 ec 04 sub $0x4,%esp
150: 8b 45 0c mov 0xc(%ebp),%eax
153: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
156: eb 14 jmp 16c <strchr+0x22>
if(*s == c)
158: 8b 45 08 mov 0x8(%ebp),%eax
15b: 0f b6 00 movzbl (%eax),%eax
15e: 3a 45 fc cmp -0x4(%ebp),%al
161: 75 05 jne 168 <strchr+0x1e>
return (char*)s;
163: 8b 45 08 mov 0x8(%ebp),%eax
166: eb 13 jmp 17b <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
168: 83 45 08 01 addl $0x1,0x8(%ebp)
16c: 8b 45 08 mov 0x8(%ebp),%eax
16f: 0f b6 00 movzbl (%eax),%eax
172: 84 c0 test %al,%al
174: 75 e2 jne 158 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
176: b8 00 00 00 00 mov $0x0,%eax
}
17b: c9 leave
17c: c3 ret
0000017d <gets>:
char*
gets(char *buf, int max)
{
17d: 55 push %ebp
17e: 89 e5 mov %esp,%ebp
180: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
183: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
18a: eb 42 jmp 1ce <gets+0x51>
cc = read(0, &c, 1);
18c: 83 ec 04 sub $0x4,%esp
18f: 6a 01 push $0x1
191: 8d 45 ef lea -0x11(%ebp),%eax
194: 50 push %eax
195: 6a 00 push $0x0
197: e8 47 01 00 00 call 2e3 <read>
19c: 83 c4 10 add $0x10,%esp
19f: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
1a2: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1a6: 7e 33 jle 1db <gets+0x5e>
break;
buf[i++] = c;
1a8: 8b 45 f4 mov -0xc(%ebp),%eax
1ab: 8d 50 01 lea 0x1(%eax),%edx
1ae: 89 55 f4 mov %edx,-0xc(%ebp)
1b1: 89 c2 mov %eax,%edx
1b3: 8b 45 08 mov 0x8(%ebp),%eax
1b6: 01 c2 add %eax,%edx
1b8: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1bc: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
1be: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1c2: 3c 0a cmp $0xa,%al
1c4: 74 16 je 1dc <gets+0x5f>
1c6: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1ca: 3c 0d cmp $0xd,%al
1cc: 74 0e je 1dc <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1ce: 8b 45 f4 mov -0xc(%ebp),%eax
1d1: 83 c0 01 add $0x1,%eax
1d4: 3b 45 0c cmp 0xc(%ebp),%eax
1d7: 7c b3 jl 18c <gets+0xf>
1d9: eb 01 jmp 1dc <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
1db: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1dc: 8b 55 f4 mov -0xc(%ebp),%edx
1df: 8b 45 08 mov 0x8(%ebp),%eax
1e2: 01 d0 add %edx,%eax
1e4: c6 00 00 movb $0x0,(%eax)
return buf;
1e7: 8b 45 08 mov 0x8(%ebp),%eax
}
1ea: c9 leave
1eb: c3 ret
000001ec <stat>:
int
stat(char *n, struct stat *st)
{
1ec: 55 push %ebp
1ed: 89 e5 mov %esp,%ebp
1ef: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1f2: 83 ec 08 sub $0x8,%esp
1f5: 6a 00 push $0x0
1f7: ff 75 08 pushl 0x8(%ebp)
1fa: e8 0c 01 00 00 call 30b <open>
1ff: 83 c4 10 add $0x10,%esp
202: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
205: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
209: 79 07 jns 212 <stat+0x26>
return -1;
20b: b8 ff ff ff ff mov $0xffffffff,%eax
210: eb 25 jmp 237 <stat+0x4b>
r = fstat(fd, st);
212: 83 ec 08 sub $0x8,%esp
215: ff 75 0c pushl 0xc(%ebp)
218: ff 75 f4 pushl -0xc(%ebp)
21b: e8 03 01 00 00 call 323 <fstat>
220: 83 c4 10 add $0x10,%esp
223: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
226: 83 ec 0c sub $0xc,%esp
229: ff 75 f4 pushl -0xc(%ebp)
22c: e8 c2 00 00 00 call 2f3 <close>
231: 83 c4 10 add $0x10,%esp
return r;
234: 8b 45 f0 mov -0x10(%ebp),%eax
}
237: c9 leave
238: c3 ret
00000239 <atoi>:
int
atoi(const char *s)
{
239: 55 push %ebp
23a: 89 e5 mov %esp,%ebp
23c: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
23f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
246: eb 25 jmp 26d <atoi+0x34>
n = n*10 + *s++ - '0';
248: 8b 55 fc mov -0x4(%ebp),%edx
24b: 89 d0 mov %edx,%eax
24d: c1 e0 02 shl $0x2,%eax
250: 01 d0 add %edx,%eax
252: 01 c0 add %eax,%eax
254: 89 c1 mov %eax,%ecx
256: 8b 45 08 mov 0x8(%ebp),%eax
259: 8d 50 01 lea 0x1(%eax),%edx
25c: 89 55 08 mov %edx,0x8(%ebp)
25f: 0f b6 00 movzbl (%eax),%eax
262: 0f be c0 movsbl %al,%eax
265: 01 c8 add %ecx,%eax
267: 83 e8 30 sub $0x30,%eax
26a: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
26d: 8b 45 08 mov 0x8(%ebp),%eax
270: 0f b6 00 movzbl (%eax),%eax
273: 3c 2f cmp $0x2f,%al
275: 7e 0a jle 281 <atoi+0x48>
277: 8b 45 08 mov 0x8(%ebp),%eax
27a: 0f b6 00 movzbl (%eax),%eax
27d: 3c 39 cmp $0x39,%al
27f: 7e c7 jle 248 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
281: 8b 45 fc mov -0x4(%ebp),%eax
}
284: c9 leave
285: c3 ret
00000286 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
286: 55 push %ebp
287: 89 e5 mov %esp,%ebp
289: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
28c: 8b 45 08 mov 0x8(%ebp),%eax
28f: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
292: 8b 45 0c mov 0xc(%ebp),%eax
295: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
298: eb 17 jmp 2b1 <memmove+0x2b>
*dst++ = *src++;
29a: 8b 45 fc mov -0x4(%ebp),%eax
29d: 8d 50 01 lea 0x1(%eax),%edx
2a0: 89 55 fc mov %edx,-0x4(%ebp)
2a3: 8b 55 f8 mov -0x8(%ebp),%edx
2a6: 8d 4a 01 lea 0x1(%edx),%ecx
2a9: 89 4d f8 mov %ecx,-0x8(%ebp)
2ac: 0f b6 12 movzbl (%edx),%edx
2af: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2b1: 8b 45 10 mov 0x10(%ebp),%eax
2b4: 8d 50 ff lea -0x1(%eax),%edx
2b7: 89 55 10 mov %edx,0x10(%ebp)
2ba: 85 c0 test %eax,%eax
2bc: 7f dc jg 29a <memmove+0x14>
*dst++ = *src++;
return vdst;
2be: 8b 45 08 mov 0x8(%ebp),%eax
}
2c1: c9 leave
2c2: c3 ret
000002c3 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2c3: b8 01 00 00 00 mov $0x1,%eax
2c8: cd 40 int $0x40
2ca: c3 ret
000002cb <exit>:
SYSCALL(exit)
2cb: b8 02 00 00 00 mov $0x2,%eax
2d0: cd 40 int $0x40
2d2: c3 ret
000002d3 <wait>:
SYSCALL(wait)
2d3: b8 03 00 00 00 mov $0x3,%eax
2d8: cd 40 int $0x40
2da: c3 ret
000002db <pipe>:
SYSCALL(pipe)
2db: b8 04 00 00 00 mov $0x4,%eax
2e0: cd 40 int $0x40
2e2: c3 ret
000002e3 <read>:
SYSCALL(read)
2e3: b8 05 00 00 00 mov $0x5,%eax
2e8: cd 40 int $0x40
2ea: c3 ret
000002eb <write>:
SYSCALL(write)
2eb: b8 10 00 00 00 mov $0x10,%eax
2f0: cd 40 int $0x40
2f2: c3 ret
000002f3 <close>:
SYSCALL(close)
2f3: b8 15 00 00 00 mov $0x15,%eax
2f8: cd 40 int $0x40
2fa: c3 ret
000002fb <kill>:
SYSCALL(kill)
2fb: b8 06 00 00 00 mov $0x6,%eax
300: cd 40 int $0x40
302: c3 ret
00000303 <exec>:
SYSCALL(exec)
303: b8 07 00 00 00 mov $0x7,%eax
308: cd 40 int $0x40
30a: c3 ret
0000030b <open>:
SYSCALL(open)
30b: b8 0f 00 00 00 mov $0xf,%eax
310: cd 40 int $0x40
312: c3 ret
00000313 <mknod>:
SYSCALL(mknod)
313: b8 11 00 00 00 mov $0x11,%eax
318: cd 40 int $0x40
31a: c3 ret
0000031b <unlink>:
SYSCALL(unlink)
31b: b8 12 00 00 00 mov $0x12,%eax
320: cd 40 int $0x40
322: c3 ret
00000323 <fstat>:
SYSCALL(fstat)
323: b8 08 00 00 00 mov $0x8,%eax
328: cd 40 int $0x40
32a: c3 ret
0000032b <link>:
SYSCALL(link)
32b: b8 13 00 00 00 mov $0x13,%eax
330: cd 40 int $0x40
332: c3 ret
00000333 <mkdir>:
SYSCALL(mkdir)
333: b8 14 00 00 00 mov $0x14,%eax
338: cd 40 int $0x40
33a: c3 ret
0000033b <chdir>:
SYSCALL(chdir)
33b: b8 09 00 00 00 mov $0x9,%eax
340: cd 40 int $0x40
342: c3 ret
00000343 <dup>:
SYSCALL(dup)
343: b8 0a 00 00 00 mov $0xa,%eax
348: cd 40 int $0x40
34a: c3 ret
0000034b <getpid>:
SYSCALL(getpid)
34b: b8 0b 00 00 00 mov $0xb,%eax
350: cd 40 int $0x40
352: c3 ret
00000353 <sbrk>:
SYSCALL(sbrk)
353: b8 0c 00 00 00 mov $0xc,%eax
358: cd 40 int $0x40
35a: c3 ret
0000035b <sleep>:
SYSCALL(sleep)
35b: b8 0d 00 00 00 mov $0xd,%eax
360: cd 40 int $0x40
362: c3 ret
00000363 <uptime>:
SYSCALL(uptime)
363: b8 0e 00 00 00 mov $0xe,%eax
368: cd 40 int $0x40
36a: c3 ret
0000036b <getMagic>:
SYSCALL(getMagic)
36b: b8 17 00 00 00 mov $0x17,%eax
370: cd 40 int $0x40
372: c3 ret
00000373 <incrementMagic>:
SYSCALL(incrementMagic)
373: b8 16 00 00 00 mov $0x16,%eax
378: cd 40 int $0x40
37a: c3 ret
0000037b <getCurrentProcessName>:
SYSCALL(getCurrentProcessName)
37b: b8 18 00 00 00 mov $0x18,%eax
380: cd 40 int $0x40
382: c3 ret
00000383 <modifyCurrentProcessName>:
SYSCALL(modifyCurrentProcessName)
383: b8 19 00 00 00 mov $0x19,%eax
388: cd 40 int $0x40
38a: c3 ret
0000038b <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
38b: 55 push %ebp
38c: 89 e5 mov %esp,%ebp
38e: 83 ec 18 sub $0x18,%esp
391: 8b 45 0c mov 0xc(%ebp),%eax
394: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
397: 83 ec 04 sub $0x4,%esp
39a: 6a 01 push $0x1
39c: 8d 45 f4 lea -0xc(%ebp),%eax
39f: 50 push %eax
3a0: ff 75 08 pushl 0x8(%ebp)
3a3: e8 43 ff ff ff call 2eb <write>
3a8: 83 c4 10 add $0x10,%esp
}
3ab: 90 nop
3ac: c9 leave
3ad: c3 ret
000003ae <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
3ae: 55 push %ebp
3af: 89 e5 mov %esp,%ebp
3b1: 53 push %ebx
3b2: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
3b5: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
3bc: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
3c0: 74 17 je 3d9 <printint+0x2b>
3c2: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
3c6: 79 11 jns 3d9 <printint+0x2b>
neg = 1;
3c8: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
3cf: 8b 45 0c mov 0xc(%ebp),%eax
3d2: f7 d8 neg %eax
3d4: 89 45 ec mov %eax,-0x14(%ebp)
3d7: eb 06 jmp 3df <printint+0x31>
} else {
x = xx;
3d9: 8b 45 0c mov 0xc(%ebp),%eax
3dc: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
3df: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
3e6: 8b 4d f4 mov -0xc(%ebp),%ecx
3e9: 8d 41 01 lea 0x1(%ecx),%eax
3ec: 89 45 f4 mov %eax,-0xc(%ebp)
3ef: 8b 5d 10 mov 0x10(%ebp),%ebx
3f2: 8b 45 ec mov -0x14(%ebp),%eax
3f5: ba 00 00 00 00 mov $0x0,%edx
3fa: f7 f3 div %ebx
3fc: 89 d0 mov %edx,%eax
3fe: 0f b6 80 94 0a 00 00 movzbl 0xa94(%eax),%eax
405: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
409: 8b 5d 10 mov 0x10(%ebp),%ebx
40c: 8b 45 ec mov -0x14(%ebp),%eax
40f: ba 00 00 00 00 mov $0x0,%edx
414: f7 f3 div %ebx
416: 89 45 ec mov %eax,-0x14(%ebp)
419: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
41d: 75 c7 jne 3e6 <printint+0x38>
if(neg)
41f: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
423: 74 2d je 452 <printint+0xa4>
buf[i++] = '-';
425: 8b 45 f4 mov -0xc(%ebp),%eax
428: 8d 50 01 lea 0x1(%eax),%edx
42b: 89 55 f4 mov %edx,-0xc(%ebp)
42e: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
433: eb 1d jmp 452 <printint+0xa4>
putc(fd, buf[i]);
435: 8d 55 dc lea -0x24(%ebp),%edx
438: 8b 45 f4 mov -0xc(%ebp),%eax
43b: 01 d0 add %edx,%eax
43d: 0f b6 00 movzbl (%eax),%eax
440: 0f be c0 movsbl %al,%eax
443: 83 ec 08 sub $0x8,%esp
446: 50 push %eax
447: ff 75 08 pushl 0x8(%ebp)
44a: e8 3c ff ff ff call 38b <putc>
44f: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
452: 83 6d f4 01 subl $0x1,-0xc(%ebp)
456: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
45a: 79 d9 jns 435 <printint+0x87>
putc(fd, buf[i]);
}
45c: 90 nop
45d: 8b 5d fc mov -0x4(%ebp),%ebx
460: c9 leave
461: c3 ret
00000462 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
462: 55 push %ebp
463: 89 e5 mov %esp,%ebp
465: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
468: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
46f: 8d 45 0c lea 0xc(%ebp),%eax
472: 83 c0 04 add $0x4,%eax
475: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
478: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
47f: e9 59 01 00 00 jmp 5dd <printf+0x17b>
c = fmt[i] & 0xff;
484: 8b 55 0c mov 0xc(%ebp),%edx
487: 8b 45 f0 mov -0x10(%ebp),%eax
48a: 01 d0 add %edx,%eax
48c: 0f b6 00 movzbl (%eax),%eax
48f: 0f be c0 movsbl %al,%eax
492: 25 ff 00 00 00 and $0xff,%eax
497: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
49a: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
49e: 75 2c jne 4cc <printf+0x6a>
if(c == '%'){
4a0: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
4a4: 75 0c jne 4b2 <printf+0x50>
state = '%';
4a6: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
4ad: e9 27 01 00 00 jmp 5d9 <printf+0x177>
} else {
putc(fd, c);
4b2: 8b 45 e4 mov -0x1c(%ebp),%eax
4b5: 0f be c0 movsbl %al,%eax
4b8: 83 ec 08 sub $0x8,%esp
4bb: 50 push %eax
4bc: ff 75 08 pushl 0x8(%ebp)
4bf: e8 c7 fe ff ff call 38b <putc>
4c4: 83 c4 10 add $0x10,%esp
4c7: e9 0d 01 00 00 jmp 5d9 <printf+0x177>
}
} else if(state == '%'){
4cc: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
4d0: 0f 85 03 01 00 00 jne 5d9 <printf+0x177>
if(c == 'd'){
4d6: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
4da: 75 1e jne 4fa <printf+0x98>
printint(fd, *ap, 10, 1);
4dc: 8b 45 e8 mov -0x18(%ebp),%eax
4df: 8b 00 mov (%eax),%eax
4e1: 6a 01 push $0x1
4e3: 6a 0a push $0xa
4e5: 50 push %eax
4e6: ff 75 08 pushl 0x8(%ebp)
4e9: e8 c0 fe ff ff call 3ae <printint>
4ee: 83 c4 10 add $0x10,%esp
ap++;
4f1: 83 45 e8 04 addl $0x4,-0x18(%ebp)
4f5: e9 d8 00 00 00 jmp 5d2 <printf+0x170>
} else if(c == 'x' || c == 'p'){
4fa: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
4fe: 74 06 je 506 <printf+0xa4>
500: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
504: 75 1e jne 524 <printf+0xc2>
printint(fd, *ap, 16, 0);
506: 8b 45 e8 mov -0x18(%ebp),%eax
509: 8b 00 mov (%eax),%eax
50b: 6a 00 push $0x0
50d: 6a 10 push $0x10
50f: 50 push %eax
510: ff 75 08 pushl 0x8(%ebp)
513: e8 96 fe ff ff call 3ae <printint>
518: 83 c4 10 add $0x10,%esp
ap++;
51b: 83 45 e8 04 addl $0x4,-0x18(%ebp)
51f: e9 ae 00 00 00 jmp 5d2 <printf+0x170>
} else if(c == 's'){
524: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
528: 75 43 jne 56d <printf+0x10b>
s = (char*)*ap;
52a: 8b 45 e8 mov -0x18(%ebp),%eax
52d: 8b 00 mov (%eax),%eax
52f: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
532: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
536: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
53a: 75 25 jne 561 <printf+0xff>
s = "(null)";
53c: c7 45 f4 3f 08 00 00 movl $0x83f,-0xc(%ebp)
while(*s != 0){
543: eb 1c jmp 561 <printf+0xff>
putc(fd, *s);
545: 8b 45 f4 mov -0xc(%ebp),%eax
548: 0f b6 00 movzbl (%eax),%eax
54b: 0f be c0 movsbl %al,%eax
54e: 83 ec 08 sub $0x8,%esp
551: 50 push %eax
552: ff 75 08 pushl 0x8(%ebp)
555: e8 31 fe ff ff call 38b <putc>
55a: 83 c4 10 add $0x10,%esp
s++;
55d: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
561: 8b 45 f4 mov -0xc(%ebp),%eax
564: 0f b6 00 movzbl (%eax),%eax
567: 84 c0 test %al,%al
569: 75 da jne 545 <printf+0xe3>
56b: eb 65 jmp 5d2 <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
56d: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
571: 75 1d jne 590 <printf+0x12e>
putc(fd, *ap);
573: 8b 45 e8 mov -0x18(%ebp),%eax
576: 8b 00 mov (%eax),%eax
578: 0f be c0 movsbl %al,%eax
57b: 83 ec 08 sub $0x8,%esp
57e: 50 push %eax
57f: ff 75 08 pushl 0x8(%ebp)
582: e8 04 fe ff ff call 38b <putc>
587: 83 c4 10 add $0x10,%esp
ap++;
58a: 83 45 e8 04 addl $0x4,-0x18(%ebp)
58e: eb 42 jmp 5d2 <printf+0x170>
} else if(c == '%'){
590: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
594: 75 17 jne 5ad <printf+0x14b>
putc(fd, c);
596: 8b 45 e4 mov -0x1c(%ebp),%eax
599: 0f be c0 movsbl %al,%eax
59c: 83 ec 08 sub $0x8,%esp
59f: 50 push %eax
5a0: ff 75 08 pushl 0x8(%ebp)
5a3: e8 e3 fd ff ff call 38b <putc>
5a8: 83 c4 10 add $0x10,%esp
5ab: eb 25 jmp 5d2 <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
5ad: 83 ec 08 sub $0x8,%esp
5b0: 6a 25 push $0x25
5b2: ff 75 08 pushl 0x8(%ebp)
5b5: e8 d1 fd ff ff call 38b <putc>
5ba: 83 c4 10 add $0x10,%esp
putc(fd, c);
5bd: 8b 45 e4 mov -0x1c(%ebp),%eax
5c0: 0f be c0 movsbl %al,%eax
5c3: 83 ec 08 sub $0x8,%esp
5c6: 50 push %eax
5c7: ff 75 08 pushl 0x8(%ebp)
5ca: e8 bc fd ff ff call 38b <putc>
5cf: 83 c4 10 add $0x10,%esp
}
state = 0;
5d2: 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++){
5d9: 83 45 f0 01 addl $0x1,-0x10(%ebp)
5dd: 8b 55 0c mov 0xc(%ebp),%edx
5e0: 8b 45 f0 mov -0x10(%ebp),%eax
5e3: 01 d0 add %edx,%eax
5e5: 0f b6 00 movzbl (%eax),%eax
5e8: 84 c0 test %al,%al
5ea: 0f 85 94 fe ff ff jne 484 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
5f0: 90 nop
5f1: c9 leave
5f2: c3 ret
000005f3 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5f3: 55 push %ebp
5f4: 89 e5 mov %esp,%ebp
5f6: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
5f9: 8b 45 08 mov 0x8(%ebp),%eax
5fc: 83 e8 08 sub $0x8,%eax
5ff: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
602: a1 b0 0a 00 00 mov 0xab0,%eax
607: 89 45 fc mov %eax,-0x4(%ebp)
60a: eb 24 jmp 630 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
60c: 8b 45 fc mov -0x4(%ebp),%eax
60f: 8b 00 mov (%eax),%eax
611: 3b 45 fc cmp -0x4(%ebp),%eax
614: 77 12 ja 628 <free+0x35>
616: 8b 45 f8 mov -0x8(%ebp),%eax
619: 3b 45 fc cmp -0x4(%ebp),%eax
61c: 77 24 ja 642 <free+0x4f>
61e: 8b 45 fc mov -0x4(%ebp),%eax
621: 8b 00 mov (%eax),%eax
623: 3b 45 f8 cmp -0x8(%ebp),%eax
626: 77 1a ja 642 <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)
628: 8b 45 fc mov -0x4(%ebp),%eax
62b: 8b 00 mov (%eax),%eax
62d: 89 45 fc mov %eax,-0x4(%ebp)
630: 8b 45 f8 mov -0x8(%ebp),%eax
633: 3b 45 fc cmp -0x4(%ebp),%eax
636: 76 d4 jbe 60c <free+0x19>
638: 8b 45 fc mov -0x4(%ebp),%eax
63b: 8b 00 mov (%eax),%eax
63d: 3b 45 f8 cmp -0x8(%ebp),%eax
640: 76 ca jbe 60c <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
642: 8b 45 f8 mov -0x8(%ebp),%eax
645: 8b 40 04 mov 0x4(%eax),%eax
648: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
64f: 8b 45 f8 mov -0x8(%ebp),%eax
652: 01 c2 add %eax,%edx
654: 8b 45 fc mov -0x4(%ebp),%eax
657: 8b 00 mov (%eax),%eax
659: 39 c2 cmp %eax,%edx
65b: 75 24 jne 681 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
65d: 8b 45 f8 mov -0x8(%ebp),%eax
660: 8b 50 04 mov 0x4(%eax),%edx
663: 8b 45 fc mov -0x4(%ebp),%eax
666: 8b 00 mov (%eax),%eax
668: 8b 40 04 mov 0x4(%eax),%eax
66b: 01 c2 add %eax,%edx
66d: 8b 45 f8 mov -0x8(%ebp),%eax
670: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
673: 8b 45 fc mov -0x4(%ebp),%eax
676: 8b 00 mov (%eax),%eax
678: 8b 10 mov (%eax),%edx
67a: 8b 45 f8 mov -0x8(%ebp),%eax
67d: 89 10 mov %edx,(%eax)
67f: eb 0a jmp 68b <free+0x98>
} else
bp->s.ptr = p->s.ptr;
681: 8b 45 fc mov -0x4(%ebp),%eax
684: 8b 10 mov (%eax),%edx
686: 8b 45 f8 mov -0x8(%ebp),%eax
689: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
68b: 8b 45 fc mov -0x4(%ebp),%eax
68e: 8b 40 04 mov 0x4(%eax),%eax
691: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
698: 8b 45 fc mov -0x4(%ebp),%eax
69b: 01 d0 add %edx,%eax
69d: 3b 45 f8 cmp -0x8(%ebp),%eax
6a0: 75 20 jne 6c2 <free+0xcf>
p->s.size += bp->s.size;
6a2: 8b 45 fc mov -0x4(%ebp),%eax
6a5: 8b 50 04 mov 0x4(%eax),%edx
6a8: 8b 45 f8 mov -0x8(%ebp),%eax
6ab: 8b 40 04 mov 0x4(%eax),%eax
6ae: 01 c2 add %eax,%edx
6b0: 8b 45 fc mov -0x4(%ebp),%eax
6b3: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
6b6: 8b 45 f8 mov -0x8(%ebp),%eax
6b9: 8b 10 mov (%eax),%edx
6bb: 8b 45 fc mov -0x4(%ebp),%eax
6be: 89 10 mov %edx,(%eax)
6c0: eb 08 jmp 6ca <free+0xd7>
} else
p->s.ptr = bp;
6c2: 8b 45 fc mov -0x4(%ebp),%eax
6c5: 8b 55 f8 mov -0x8(%ebp),%edx
6c8: 89 10 mov %edx,(%eax)
freep = p;
6ca: 8b 45 fc mov -0x4(%ebp),%eax
6cd: a3 b0 0a 00 00 mov %eax,0xab0
}
6d2: 90 nop
6d3: c9 leave
6d4: c3 ret
000006d5 <morecore>:
static Header*
morecore(uint nu)
{
6d5: 55 push %ebp
6d6: 89 e5 mov %esp,%ebp
6d8: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
6db: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
6e2: 77 07 ja 6eb <morecore+0x16>
nu = 4096;
6e4: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
6eb: 8b 45 08 mov 0x8(%ebp),%eax
6ee: c1 e0 03 shl $0x3,%eax
6f1: 83 ec 0c sub $0xc,%esp
6f4: 50 push %eax
6f5: e8 59 fc ff ff call 353 <sbrk>
6fa: 83 c4 10 add $0x10,%esp
6fd: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
700: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
704: 75 07 jne 70d <morecore+0x38>
return 0;
706: b8 00 00 00 00 mov $0x0,%eax
70b: eb 26 jmp 733 <morecore+0x5e>
hp = (Header*)p;
70d: 8b 45 f4 mov -0xc(%ebp),%eax
710: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
713: 8b 45 f0 mov -0x10(%ebp),%eax
716: 8b 55 08 mov 0x8(%ebp),%edx
719: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
71c: 8b 45 f0 mov -0x10(%ebp),%eax
71f: 83 c0 08 add $0x8,%eax
722: 83 ec 0c sub $0xc,%esp
725: 50 push %eax
726: e8 c8 fe ff ff call 5f3 <free>
72b: 83 c4 10 add $0x10,%esp
return freep;
72e: a1 b0 0a 00 00 mov 0xab0,%eax
}
733: c9 leave
734: c3 ret
00000735 <malloc>:
void*
malloc(uint nbytes)
{
735: 55 push %ebp
736: 89 e5 mov %esp,%ebp
738: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
73b: 8b 45 08 mov 0x8(%ebp),%eax
73e: 83 c0 07 add $0x7,%eax
741: c1 e8 03 shr $0x3,%eax
744: 83 c0 01 add $0x1,%eax
747: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
74a: a1 b0 0a 00 00 mov 0xab0,%eax
74f: 89 45 f0 mov %eax,-0x10(%ebp)
752: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
756: 75 23 jne 77b <malloc+0x46>
base.s.ptr = freep = prevp = &base;
758: c7 45 f0 a8 0a 00 00 movl $0xaa8,-0x10(%ebp)
75f: 8b 45 f0 mov -0x10(%ebp),%eax
762: a3 b0 0a 00 00 mov %eax,0xab0
767: a1 b0 0a 00 00 mov 0xab0,%eax
76c: a3 a8 0a 00 00 mov %eax,0xaa8
base.s.size = 0;
771: c7 05 ac 0a 00 00 00 movl $0x0,0xaac
778: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
77b: 8b 45 f0 mov -0x10(%ebp),%eax
77e: 8b 00 mov (%eax),%eax
780: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
783: 8b 45 f4 mov -0xc(%ebp),%eax
786: 8b 40 04 mov 0x4(%eax),%eax
789: 3b 45 ec cmp -0x14(%ebp),%eax
78c: 72 4d jb 7db <malloc+0xa6>
if(p->s.size == nunits)
78e: 8b 45 f4 mov -0xc(%ebp),%eax
791: 8b 40 04 mov 0x4(%eax),%eax
794: 3b 45 ec cmp -0x14(%ebp),%eax
797: 75 0c jne 7a5 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
799: 8b 45 f4 mov -0xc(%ebp),%eax
79c: 8b 10 mov (%eax),%edx
79e: 8b 45 f0 mov -0x10(%ebp),%eax
7a1: 89 10 mov %edx,(%eax)
7a3: eb 26 jmp 7cb <malloc+0x96>
else {
p->s.size -= nunits;
7a5: 8b 45 f4 mov -0xc(%ebp),%eax
7a8: 8b 40 04 mov 0x4(%eax),%eax
7ab: 2b 45 ec sub -0x14(%ebp),%eax
7ae: 89 c2 mov %eax,%edx
7b0: 8b 45 f4 mov -0xc(%ebp),%eax
7b3: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
7b6: 8b 45 f4 mov -0xc(%ebp),%eax
7b9: 8b 40 04 mov 0x4(%eax),%eax
7bc: c1 e0 03 shl $0x3,%eax
7bf: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
7c2: 8b 45 f4 mov -0xc(%ebp),%eax
7c5: 8b 55 ec mov -0x14(%ebp),%edx
7c8: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
7cb: 8b 45 f0 mov -0x10(%ebp),%eax
7ce: a3 b0 0a 00 00 mov %eax,0xab0
return (void*)(p + 1);
7d3: 8b 45 f4 mov -0xc(%ebp),%eax
7d6: 83 c0 08 add $0x8,%eax
7d9: eb 3b jmp 816 <malloc+0xe1>
}
if(p == freep)
7db: a1 b0 0a 00 00 mov 0xab0,%eax
7e0: 39 45 f4 cmp %eax,-0xc(%ebp)
7e3: 75 1e jne 803 <malloc+0xce>
if((p = morecore(nunits)) == 0)
7e5: 83 ec 0c sub $0xc,%esp
7e8: ff 75 ec pushl -0x14(%ebp)
7eb: e8 e5 fe ff ff call 6d5 <morecore>
7f0: 83 c4 10 add $0x10,%esp
7f3: 89 45 f4 mov %eax,-0xc(%ebp)
7f6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
7fa: 75 07 jne 803 <malloc+0xce>
return 0;
7fc: b8 00 00 00 00 mov $0x0,%eax
801: eb 13 jmp 816 <malloc+0xe1>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
803: 8b 45 f4 mov -0xc(%ebp),%eax
806: 89 45 f0 mov %eax,-0x10(%ebp)
809: 8b 45 f4 mov -0xc(%ebp),%eax
80c: 8b 00 mov (%eax),%eax
80e: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
811: e9 6d ff ff ff jmp 783 <malloc+0x4e>
}
816: c9 leave
817: c3 ret
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0xb2fd, %r10
nop
xor %rax, %rax
movb (%r10), %dl
nop
nop
nop
dec %r8
lea addresses_UC_ht+0x1d539, %rdx
nop
nop
nop
nop
xor $13644, %rbx
mov $0x6162636465666768, %r11
movq %r11, (%rdx)
nop
nop
nop
nop
nop
and %rdx, %rdx
lea addresses_D_ht+0x11239, %r11
nop
nop
nop
nop
nop
sub %r14, %r14
movb $0x61, (%r11)
nop
nop
nop
nop
inc %rax
lea addresses_normal_ht+0x14379, %rax
add $63469, %r14
mov $0x6162636465666768, %r8
movq %r8, %xmm4
vmovups %ymm4, (%rax)
nop
nop
nop
nop
nop
cmp %r8, %r8
lea addresses_WC_ht+0x1aa39, %rsi
lea addresses_normal_ht+0x14239, %rdi
nop
nop
nop
nop
nop
inc %rax
mov $30, %rcx
rep movsq
nop
nop
nop
nop
xor %r10, %r10
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r15
push %r8
push %rax
push %rbp
push %rbx
// Load
lea addresses_US+0x5739, %r15
nop
nop
nop
xor $20534, %rax
movb (%r15), %bl
nop
nop
nop
nop
and %rbp, %rbp
// Faulty Load
lea addresses_WT+0x6a39, %rax
nop
nop
nop
and %r13, %r13
movups (%rax), %xmm1
vpextrq $0, %xmm1, %rbp
lea oracles, %r13
and $0xff, %rbp
shlq $12, %rbp
mov (%r13,%rbp,1), %rbp
pop %rbx
pop %rbp
pop %rax
pop %r8
pop %r15
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 7, 'size': 1, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 1, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 6, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 11, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': True, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}}
{'80': 46, '3c': 172, '26': 426, '02': 166, '49': 7, '00': 1898, 'c0': 86, 'de': 281, '04': 71, '48': 1593, 'e0': 43, '25': 17040}
25 25 25 25 25 25 25 3c 25 25 25 25 25 02 25 25 25 25 25 25 00 25 25 25 48 25 48 25 3c 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 00 25 25 00 25 00 25 48 25 25 25 25 25 48 25 25 00 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 48 25 25 25 25 25 25 48 25 25 48 25 00 48 00 25 48 de 25 25 25 25 25 25 25 48 25 25 25 25 25 25 00 00 00 25 25 00 00 25 25 25 48 25 25 00 48 25 25 48 25 48 25 25 48 00 25 00 e0 25 25 25 25 25 25 00 25 00 25 25 48 00 25 25 25 00 00 48 25 25 25 25 25 48 25 25 25 25 25 25 48 25 48 25 48 25 25 00 25 00 25 25 25 25 25 00 25 00 25 25 25 25 00 25 25 de 25 25 25 25 25 25 25 25 00 25 25 25 48 25 25 25 48 25 25 25 25 48 00 48 48 48 25 de 25 25 25 25 25 25 25 25 25 25 25 25 00 3c 25 25 00 25 3c 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 48 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 80 25 25 25 25 25 25 25 25 25 25 00 25 25 25 00 25 25 25 25 25 00 48 25 48 48 25 de 25 25 25 25 00 25 25 48 00 25 25 48 25 00 25 25 de de 25 25 25 25 25 48 48 25 25 00 25 48 25 25 25 25 25 25 25 48 25 00 00 25 25 25 25 25 de 00 c0 25 25 25 48 25 25 25 48 25 48 25 25 25 48 25 25 48 25 25 25 25 48 25 25 25 25 25 48 25 25 25 00 48 25 25 25 25 25 25 25 25 00 00 25 00 25 25 25 25 25 25 25 25 25 25 25 25 00 25 3c 25 25 25 25 25 25 25 25 02 25 25 25 25 25 25 25 25 25 25 00 25 25 00 25 25 25 25 25 25 25 25 25 25 00 25 25 25 25 25 25 25 25 25 25 02 00 25 25 00 25 25 25 25 25 25 25 25 3c 00 25 02 25 25 25 25 48 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 00 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 00 25 00 48 48 00 25 25 25 25 25 25 25 25 25 00 25 00 25 48 00 00 25 48 25 25 48 48 25 00 25 25 48 de 25 25 25 00 25 25 25 25 48 25 25 25 25 25 48 25 25 25 25 25 00 25 25 48 25 00 25 48 25 25 25 25 25 25 00 25 04 25 25 25 25 25 25 25 25 25 25 25 25 25 48 48 48 48 de 25 00 00 25 48 25 48 00 25 25 25 25 25 25 25 25 48 00 25 25 25 25 25 48 48 de 00 25 25 25 25 25 00 25 25 25 25 25 25 25 25 48 25 25 25 25 25 25 25 25 25 c0 25 00 de 25 25 25 00 25 de de 25 48 25 48 48 25 25 25 04 25 3c 25 25 25 25 25 25 25 25 25 25 00 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 00 25 25 02 25 25 25 25 00 25 25 25 02 25 25 25 25 25 25 25 48 00 25 00 25 25 25 25 00 25 25 25 00 25 25 25 25 80 25 25 25 00 25 25 25 25 25 25 25 02 00 25 25 25 00 25 25 25 25 25 25 25 25 48 25 25 25 00 25 25 25 25 25 25 25 00 25 25 25 25 25 25 3c 25 25 25 25 3c 00 25 25 25 25 48 25 25 25 25 25 25 25 25 25 00 25 25 25 25 25 25 25 25 25 25 04 25 25 25 25 25 25 25 25 00 25 25 25 25 25 25 48 00 25 25 48 25 25 00 25 00 25 25 25 48 48 25 25 25 25 25 25 25 25 48 25 48 25 de 25 25 25 48 25 00 00 25 25 48 25 00 25 25 48 25 48 48 25 25 25 25 00 25 25 25 48 25 48 48 25 00 25 25 48 48 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 00 25 48 25 25 25 25 25 25 25 25 25 25 25 de 25 25 25 25 25 25 25 48 25 25 48 25 00 25 25 25 25 25 00 25 48 de 25 25 de 25 25 25 00 25 00 25 25 48
*/
|
SECTION code_fp_math48
PUBLIC _atan
EXTERN cm48_sdccix_atan
defc _atan = cm48_sdccix_atan
|
; A161726: a(n) = n^2 - 917*n + 9479.
; 9479,8563,7649,6737,5827,4919,4013,3109,2207,1307,409,-487,-1381,-2273,-3163,-4051,-4937,-5821,-6703,-7583,-8461,-9337,-10211,-11083,-11953,-12821,-13687,-14551,-15413,-16273,-17131,-17987,-18841,-19693,-20543,-21391,-22237,-23081,-23923,-24763,-25601,-26437,-27271,-28103,-28933,-29761,-30587,-31411,-32233,-33053,-33871,-34687,-35501,-36313,-37123,-37931,-38737,-39541,-40343,-41143,-41941,-42737,-43531,-44323,-45113,-45901,-46687,-47471,-48253,-49033,-49811,-50587,-51361,-52133,-52903,-53671,-54437,-55201,-55963,-56723,-57481,-58237,-58991,-59743,-60493,-61241,-61987,-62731,-63473,-64213,-64951,-65687,-66421,-67153,-67883,-68611,-69337,-70061,-70783,-71503,-72221,-72937,-73651,-74363,-75073,-75781,-76487,-77191,-77893,-78593,-79291,-79987,-80681,-81373,-82063,-82751,-83437,-84121,-84803,-85483,-86161,-86837,-87511,-88183,-88853,-89521,-90187,-90851,-91513,-92173,-92831,-93487,-94141,-94793,-95443,-96091,-96737,-97381,-98023,-98663,-99301,-99937,-100571,-101203,-101833,-102461,-103087,-103711,-104333,-104953,-105571,-106187,-106801,-107413,-108023,-108631,-109237,-109841,-110443,-111043,-111641,-112237,-112831,-113423,-114013,-114601,-115187,-115771,-116353,-116933,-117511,-118087,-118661,-119233,-119803,-120371,-120937,-121501,-122063,-122623,-123181,-123737,-124291,-124843,-125393,-125941,-126487,-127031,-127573,-128113,-128651,-129187,-129721,-130253,-130783,-131311,-131837,-132361,-132883,-133403,-133921,-134437,-134951,-135463,-135973,-136481,-136987,-137491,-137993,-138493,-138991,-139487,-139981,-140473,-140963,-141451,-141937,-142421,-142903,-143383,-143861,-144337,-144811,-145283,-145753,-146221,-146687,-147151,-147613,-148073,-148531,-148987,-149441,-149893,-150343,-150791,-151237,-151681,-152123,-152563,-153001,-153437,-153871,-154303,-154733,-155161,-155587,-156011,-156433,-156853
mov $2,$0
mul $2,2
mov $1,$2
sub $1,1
mov $0,$1
sub $0,16
mov $2,2
add $2,$0
sub $0,3
sub $2,1799
mul $0,$2
mov $1,$0
div $1,8
mul $1,2
add $1,409
|
include ksamd64.inc
public _get_fpsr
_status$ = 0
NESTED_ENTRY _get_fpsr, _TEXT$00
sub rsp, 8
.allocstack 8
.endprolog
stmxcsr DWORD PTR _status$[rsp]
mov eax, DWORD PTR _status$[rsp]
add rsp, 8
ret
NESTED_END _get_fpsr, _TEXT$00
PUBLIC _set_fpsr
_TEXT SEGMENT
_status$ = 8
_set_fpsr PROC NEAR
mov DWORD PTR _status$[rsp], ecx
ldmxcsr DWORD PTR _status$[rsp]
ret
_set_fpsr ENDP
_TEXT ENDS
PUBLIC _fclrf
_TEXT SEGMENT
_fclrf PROC NEAR
stmxcsr DWORD PTR _status$[rsp]
mov ecx, 0ffffffc0h
and DWORD PTR _status$[rsp], ecx
ldmxcsr DWORD PTR _status$[rsp]
ret
_fclrf ENDP
_TEXT ENDS
PUBLIC _frnd
_TEXT SEGMENT
_frnd PROC NEAR
cvtpd2dq xmm(1), xmm(0)
cvtdq2pd xmm(0), xmm(1)
ret
_frnd ENDP
_TEXT ENDS
END
|
; A259410: a(n) = 1 - sigma(n) + sigma(n)^2 - sigma(n)^3 + sigma(n)^4.
; 1,61,205,2101,1111,19141,3641,47461,26521,99451,19141,593461,35855,318505,318505,894661,99451,2255605,152381,3039331,1016801,1634221,318505,12747541,894661,3039331,2497561,9661961,783871,26505721,1016801,15506821,5200081,8348455,5200081,67829581,2031671,12747541,9661961,64889011,3039331,84059041,3664805,49201405,36546511,26505721,5200081,234530005,10374001,74009401,26505721,91305131,8348455,205646281,26505721,205646281,40454321,64889011,12747541,791880601,14541791,84059041,115871705,258112261
seq $0,203 ; a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n).
seq $0,60884 ; a(n) = n^4 - n^3 + n^2 - n + 1.
|
; A000203: a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n).
; 1,3,4,7,6,12,8,15,13,18,12,28,14,24,24,31,18,39,20,42,32,36,24,60,31,42,40,56,30,72,32,63,48,54,48,91,38,60,56,90,42,96,44,84,78,72,48,124,57,93,72,98,54,120,72,120,80,90,60,168,62,96,104,127,84,144,68,126,96,144,72,195,74,114,124,140,96,168,80,186,121,126,84,224,108,132,120,180,90,234,112,168,128,144,120,252,98,171,156,217,102,216,104,210,192,162,108,280,110,216,152,248,114,240,144,210,182,180,144,360,133,186,168,224,156,312,128,255,176,252,132,336,160,204,240,270,138,288,140,336,192,216,168,403,180,222,228,266,150,372,152,300,234,288,192,392,158,240,216,378,192,363,164,294,288,252,168,480,183,324,260,308,174,360,248,372,240,270,180,546,182,336,248,360,228,384,216,336,320,360,192,508,194,294,336,399,198,468,200,465,272,306,240,504,252,312,312,434,240,576,212,378,288,324,264,600,256,330,296,504,252,456,224,504,403,342,228,560,230,432,384,450,234,546,288,420,320,432,240,744,242,399,364,434,342,504,280,480,336,468
mov $3,$0
mov $5,$0
mov $7,2
lpb $7
mov $0,$5
sub $7,1
add $0,$7
sub $0,1
cal $0,244049 ; Sum of all proper divisors of all positive integers <= n.
mov $4,$0
mul $4,2
sub $4,3
mov $1,$4
mov $8,$7
lpb $8
mov $6,$1
sub $8,1
lpe
lpe
lpb $5
mov $5,0
sub $6,$1
lpe
mov $1,$6
add $1,3
mul $1,3
add $1,5
mov $2,$3
mul $2,6
add $1,$2
sub $1,8
div $1,6
add $1,1
|
; A111223: Numbers n such that 5*n + 2 is prime.
; 0,1,3,7,9,13,19,21,25,27,31,33,39,45,51,55,61,63,67,69,73,79,91,93,97,109,111,115,117,121,123,129,135,145,151,157,159,165,171,175,177,181,187,189,193,195,199,217,219,223,237,243,247,255,259,261,265,273,285,289,297,313,319,321,325,327,331,333,339,349,355,357,369,373,375,381,397,399,403,405,417,427,441,447,453,457,459,469,471,475,483,487,489,493,495,511,523,529,531,535
mov $2,$0
sub $0,1
pow $2,2
add $2,1
lpb $2
sub $2,1
mov $3,$5
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $4,$0
mul $5,$3
add $6,2
mov $1,$6
max $4,0
cmp $4,$0
mul $2,$4
add $7,5
add $5,$7
add $5,1
lpe
sub $1,2
div $1,2
mov $0,$1
|
;---------------------------------------
; Editline print (output) module
;---------------------------------------
_editInit ld de,#0000 ; начальная инициализация
ld (printEX),de
editClear ld hl,edit256 ; очистка редактируемой строки 256 (ASCII)
ld de,edit256+1
ld bc,127
ld a," "
ld (hl),a
ldir
ld hl,edit256+128 ; очистка буфера256 (Colors)
ld de,edit256+129
ld bc,127
;ld a,defaultCol
ld a,(curColor)
ld (hl),a
ldir
ret
_printInLine push hl
ld hl,#0000
ld (printEX),hl
pop hl
call printEStr
ld hl,edit256
ld a,#01
ld bc,#0000 ; reserved
call BUF_UPD
ret
;---------------------------------------
printEStr xor a ; Печать в строке ввода
ld (eStrLen),a
printEStr_0 ld a,(hl)
cp #00
jr z,printEExit
cp #09 ; Управляющий код: 09 - tab
jp z,codeETab
cp #10 ; Управляющий код: 16 - ink
jp z,codeEInk
cp #11 ; Управляющий код: 17 - paper
jp z,codeEPaper
cp #14 ; Управляющий код: 20 - inverse
jp z,codeEInverse
push hl
call printEChar
ld a,(printEX)
inc a
cp 80 ; Конец буфера edit256
jr nz,printEStr_1
call printEUp
xor a
printEStr_1 ld (printEX),a
ld a,(eStrLen)
inc a
ld (eStrLen),a
pop hl
inc hl
jp printEStr_0
printEUp push hl
ld hl,edit256
ld a,#00
call BUF_UPD ; забирается буфер
call editInit
pop hl
ret
printEExit ld a,(eStrLen)
ret
printEChar ld hl,edit256 ; печать символа в редактируемой строке
ld de,(printEX)
add hl,de
ld (hl),a
;ld a,(curEColor) ; печать аттрибутов
ld a,(curColor)
ld de,128
add hl,de
ld (hl),a
ret
;---------------------------------------
showCursor
curTimeOut ld a,#00
cp #00
jr z,sc_01
dec a
ld (curTimeOut+1),a
ret
sc_01 ld hl,curAnimPos
ld a,(hl)
add a,a
ld d,#00
ld e,a
inc (hl)
ld hl,curAnim
add hl,de ; frame
ld a,(hl)
cp #00
jr nz,sc_02
ld (curAnimPos),a
ld hl,curAnim
ld a,(hl)
sc_02 ld (curTimeOut+1),a
inc hl
ld a,(hl)
and %00001111
ld c,a
;ld a,(curEColor)
ld a,(curColor)
and %11110000
or c
;ld (curEColor),a
ld (curColor),a
ld a,cursorType
call printEChar
ld a,defaultCol
;ld (curEColor),a
ld (curColor),a
ret
;---------------------------------------
; in A - ASCII code
printKey ld hl,iBuffer
ld b,#00
push af
ld a,(iBufferPos)
;cp iBufferSize-1
cp 80-3 ;TODO: iBufferSize
jr z,buffOverload ; Конец строки! Бип и выход!
ld c,a
add hl,bc
inc a
ld (iBufferPos),a
pop af
ld (hl),a
call printEChar
ld a,(printEX)
inc a
cp 80 ; Конец буфера edit256
jr nz,printKey_00
call printEUp
xor a
printKey_00 ld (printEX),a
ld a,(iBufferPos)
ld b,0
ld c,a
ld hl,iBuffer
add hl,bc
ld a,(hl)
ld (storeKey),a
ret
buffOverload pop af
halt
ld a,#02
call setBorder
halt
call restBorder
ret
;---------------------------------------
codeETab ld a,(printEX)
srl a ; /2
srl a ; /4
srl a ; /8
cp #09
jp z,printEStr_0
inc a
push hl
ld hl,tabTable
ld b,0
ld c,a
add hl,bc
ld a,(hl)
ld (printEX),a
pop hl
inc hl
jp printEStr_0
;---------------------------------------
codeEInk inc hl
ld a,(hl)
inc hl
codeEInk_0 cp 16 ; 16 ? взять цвет по умолчанию
jr nz,codeEInk_1
ld a,defaultCol
codeEInk_1 and %00001111
ld c,a
ld a,(curColor)
and %11110000
or c
ld (curColor),a
jp printEStr_0
codeEPaper inc hl
ld a,(hl)
inc hl
codeEPaper_0 cp 16 ; 16 ? взять цвет по умолчанию
jr nz,codeEPaper_1
ld a,defaultCol
and %11110000
jr codeEPaper_2
codeEPaper_1 and %00001111
sla a
sla a
sla a
sla a
codeEPaper_2 ld c,a
ld a,(curColor)
and %00001111
or c
ld (curColor),a
jp printEStr_0
codeEInverse inc hl
ld a,(curColor)
and %00001111
sla a
sla a
sla a
sla a
ld b,a
ld a,(curColor)
and %11110000
srl a
srl a
srl a
srl a
or b
ld (curColor),a
jp printEStr_0
;---------------------------------------
printEX dw #0000 ; позиция X для печати в edit256
eStrLen db #00
|
/*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tencentcloud/clb/v20180317/model/RuleInput.h>
using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Clb::V20180317::Model;
using namespace rapidjson;
using namespace std;
RuleInput::RuleInput() :
m_domainHasBeenSet(false),
m_urlHasBeenSet(false),
m_sessionExpireTimeHasBeenSet(false),
m_healthCheckHasBeenSet(false),
m_certificateHasBeenSet(false),
m_schedulerHasBeenSet(false),
m_forwardTypeHasBeenSet(false),
m_defaultServerHasBeenSet(false),
m_http2HasBeenSet(false),
m_targetTypeHasBeenSet(false),
m_trpcCalleeHasBeenSet(false),
m_trpcFuncHasBeenSet(false),
m_quicHasBeenSet(false)
{
}
CoreInternalOutcome RuleInput::Deserialize(const Value &value)
{
string requestId = "";
if (value.HasMember("Domain") && !value["Domain"].IsNull())
{
if (!value["Domain"].IsString())
{
return CoreInternalOutcome(Error("response `RuleInput.Domain` IsString=false incorrectly").SetRequestId(requestId));
}
m_domain = string(value["Domain"].GetString());
m_domainHasBeenSet = true;
}
if (value.HasMember("Url") && !value["Url"].IsNull())
{
if (!value["Url"].IsString())
{
return CoreInternalOutcome(Error("response `RuleInput.Url` IsString=false incorrectly").SetRequestId(requestId));
}
m_url = string(value["Url"].GetString());
m_urlHasBeenSet = true;
}
if (value.HasMember("SessionExpireTime") && !value["SessionExpireTime"].IsNull())
{
if (!value["SessionExpireTime"].IsInt64())
{
return CoreInternalOutcome(Error("response `RuleInput.SessionExpireTime` IsInt64=false incorrectly").SetRequestId(requestId));
}
m_sessionExpireTime = value["SessionExpireTime"].GetInt64();
m_sessionExpireTimeHasBeenSet = true;
}
if (value.HasMember("HealthCheck") && !value["HealthCheck"].IsNull())
{
if (!value["HealthCheck"].IsObject())
{
return CoreInternalOutcome(Error("response `RuleInput.HealthCheck` is not object type").SetRequestId(requestId));
}
CoreInternalOutcome outcome = m_healthCheck.Deserialize(value["HealthCheck"]);
if (!outcome.IsSuccess())
{
outcome.GetError().SetRequestId(requestId);
return outcome;
}
m_healthCheckHasBeenSet = true;
}
if (value.HasMember("Certificate") && !value["Certificate"].IsNull())
{
if (!value["Certificate"].IsObject())
{
return CoreInternalOutcome(Error("response `RuleInput.Certificate` is not object type").SetRequestId(requestId));
}
CoreInternalOutcome outcome = m_certificate.Deserialize(value["Certificate"]);
if (!outcome.IsSuccess())
{
outcome.GetError().SetRequestId(requestId);
return outcome;
}
m_certificateHasBeenSet = true;
}
if (value.HasMember("Scheduler") && !value["Scheduler"].IsNull())
{
if (!value["Scheduler"].IsString())
{
return CoreInternalOutcome(Error("response `RuleInput.Scheduler` IsString=false incorrectly").SetRequestId(requestId));
}
m_scheduler = string(value["Scheduler"].GetString());
m_schedulerHasBeenSet = true;
}
if (value.HasMember("ForwardType") && !value["ForwardType"].IsNull())
{
if (!value["ForwardType"].IsString())
{
return CoreInternalOutcome(Error("response `RuleInput.ForwardType` IsString=false incorrectly").SetRequestId(requestId));
}
m_forwardType = string(value["ForwardType"].GetString());
m_forwardTypeHasBeenSet = true;
}
if (value.HasMember("DefaultServer") && !value["DefaultServer"].IsNull())
{
if (!value["DefaultServer"].IsBool())
{
return CoreInternalOutcome(Error("response `RuleInput.DefaultServer` IsBool=false incorrectly").SetRequestId(requestId));
}
m_defaultServer = value["DefaultServer"].GetBool();
m_defaultServerHasBeenSet = true;
}
if (value.HasMember("Http2") && !value["Http2"].IsNull())
{
if (!value["Http2"].IsBool())
{
return CoreInternalOutcome(Error("response `RuleInput.Http2` IsBool=false incorrectly").SetRequestId(requestId));
}
m_http2 = value["Http2"].GetBool();
m_http2HasBeenSet = true;
}
if (value.HasMember("TargetType") && !value["TargetType"].IsNull())
{
if (!value["TargetType"].IsString())
{
return CoreInternalOutcome(Error("response `RuleInput.TargetType` IsString=false incorrectly").SetRequestId(requestId));
}
m_targetType = string(value["TargetType"].GetString());
m_targetTypeHasBeenSet = true;
}
if (value.HasMember("TrpcCallee") && !value["TrpcCallee"].IsNull())
{
if (!value["TrpcCallee"].IsString())
{
return CoreInternalOutcome(Error("response `RuleInput.TrpcCallee` IsString=false incorrectly").SetRequestId(requestId));
}
m_trpcCallee = string(value["TrpcCallee"].GetString());
m_trpcCalleeHasBeenSet = true;
}
if (value.HasMember("TrpcFunc") && !value["TrpcFunc"].IsNull())
{
if (!value["TrpcFunc"].IsString())
{
return CoreInternalOutcome(Error("response `RuleInput.TrpcFunc` IsString=false incorrectly").SetRequestId(requestId));
}
m_trpcFunc = string(value["TrpcFunc"].GetString());
m_trpcFuncHasBeenSet = true;
}
if (value.HasMember("Quic") && !value["Quic"].IsNull())
{
if (!value["Quic"].IsBool())
{
return CoreInternalOutcome(Error("response `RuleInput.Quic` IsBool=false incorrectly").SetRequestId(requestId));
}
m_quic = value["Quic"].GetBool();
m_quicHasBeenSet = true;
}
return CoreInternalOutcome(true);
}
void RuleInput::ToJsonObject(Value &value, Document::AllocatorType& allocator) const
{
if (m_domainHasBeenSet)
{
Value iKey(kStringType);
string key = "Domain";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, Value(m_domain.c_str(), allocator).Move(), allocator);
}
if (m_urlHasBeenSet)
{
Value iKey(kStringType);
string key = "Url";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, Value(m_url.c_str(), allocator).Move(), allocator);
}
if (m_sessionExpireTimeHasBeenSet)
{
Value iKey(kStringType);
string key = "SessionExpireTime";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_sessionExpireTime, allocator);
}
if (m_healthCheckHasBeenSet)
{
Value iKey(kStringType);
string key = "HealthCheck";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, Value(kObjectType).Move(), allocator);
m_healthCheck.ToJsonObject(value[key.c_str()], allocator);
}
if (m_certificateHasBeenSet)
{
Value iKey(kStringType);
string key = "Certificate";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, Value(kObjectType).Move(), allocator);
m_certificate.ToJsonObject(value[key.c_str()], allocator);
}
if (m_schedulerHasBeenSet)
{
Value iKey(kStringType);
string key = "Scheduler";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, Value(m_scheduler.c_str(), allocator).Move(), allocator);
}
if (m_forwardTypeHasBeenSet)
{
Value iKey(kStringType);
string key = "ForwardType";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, Value(m_forwardType.c_str(), allocator).Move(), allocator);
}
if (m_defaultServerHasBeenSet)
{
Value iKey(kStringType);
string key = "DefaultServer";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_defaultServer, allocator);
}
if (m_http2HasBeenSet)
{
Value iKey(kStringType);
string key = "Http2";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_http2, allocator);
}
if (m_targetTypeHasBeenSet)
{
Value iKey(kStringType);
string key = "TargetType";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, Value(m_targetType.c_str(), allocator).Move(), allocator);
}
if (m_trpcCalleeHasBeenSet)
{
Value iKey(kStringType);
string key = "TrpcCallee";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, Value(m_trpcCallee.c_str(), allocator).Move(), allocator);
}
if (m_trpcFuncHasBeenSet)
{
Value iKey(kStringType);
string key = "TrpcFunc";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, Value(m_trpcFunc.c_str(), allocator).Move(), allocator);
}
if (m_quicHasBeenSet)
{
Value iKey(kStringType);
string key = "Quic";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_quic, allocator);
}
}
string RuleInput::GetDomain() const
{
return m_domain;
}
void RuleInput::SetDomain(const string& _domain)
{
m_domain = _domain;
m_domainHasBeenSet = true;
}
bool RuleInput::DomainHasBeenSet() const
{
return m_domainHasBeenSet;
}
string RuleInput::GetUrl() const
{
return m_url;
}
void RuleInput::SetUrl(const string& _url)
{
m_url = _url;
m_urlHasBeenSet = true;
}
bool RuleInput::UrlHasBeenSet() const
{
return m_urlHasBeenSet;
}
int64_t RuleInput::GetSessionExpireTime() const
{
return m_sessionExpireTime;
}
void RuleInput::SetSessionExpireTime(const int64_t& _sessionExpireTime)
{
m_sessionExpireTime = _sessionExpireTime;
m_sessionExpireTimeHasBeenSet = true;
}
bool RuleInput::SessionExpireTimeHasBeenSet() const
{
return m_sessionExpireTimeHasBeenSet;
}
HealthCheck RuleInput::GetHealthCheck() const
{
return m_healthCheck;
}
void RuleInput::SetHealthCheck(const HealthCheck& _healthCheck)
{
m_healthCheck = _healthCheck;
m_healthCheckHasBeenSet = true;
}
bool RuleInput::HealthCheckHasBeenSet() const
{
return m_healthCheckHasBeenSet;
}
CertificateInput RuleInput::GetCertificate() const
{
return m_certificate;
}
void RuleInput::SetCertificate(const CertificateInput& _certificate)
{
m_certificate = _certificate;
m_certificateHasBeenSet = true;
}
bool RuleInput::CertificateHasBeenSet() const
{
return m_certificateHasBeenSet;
}
string RuleInput::GetScheduler() const
{
return m_scheduler;
}
void RuleInput::SetScheduler(const string& _scheduler)
{
m_scheduler = _scheduler;
m_schedulerHasBeenSet = true;
}
bool RuleInput::SchedulerHasBeenSet() const
{
return m_schedulerHasBeenSet;
}
string RuleInput::GetForwardType() const
{
return m_forwardType;
}
void RuleInput::SetForwardType(const string& _forwardType)
{
m_forwardType = _forwardType;
m_forwardTypeHasBeenSet = true;
}
bool RuleInput::ForwardTypeHasBeenSet() const
{
return m_forwardTypeHasBeenSet;
}
bool RuleInput::GetDefaultServer() const
{
return m_defaultServer;
}
void RuleInput::SetDefaultServer(const bool& _defaultServer)
{
m_defaultServer = _defaultServer;
m_defaultServerHasBeenSet = true;
}
bool RuleInput::DefaultServerHasBeenSet() const
{
return m_defaultServerHasBeenSet;
}
bool RuleInput::GetHttp2() const
{
return m_http2;
}
void RuleInput::SetHttp2(const bool& _http2)
{
m_http2 = _http2;
m_http2HasBeenSet = true;
}
bool RuleInput::Http2HasBeenSet() const
{
return m_http2HasBeenSet;
}
string RuleInput::GetTargetType() const
{
return m_targetType;
}
void RuleInput::SetTargetType(const string& _targetType)
{
m_targetType = _targetType;
m_targetTypeHasBeenSet = true;
}
bool RuleInput::TargetTypeHasBeenSet() const
{
return m_targetTypeHasBeenSet;
}
string RuleInput::GetTrpcCallee() const
{
return m_trpcCallee;
}
void RuleInput::SetTrpcCallee(const string& _trpcCallee)
{
m_trpcCallee = _trpcCallee;
m_trpcCalleeHasBeenSet = true;
}
bool RuleInput::TrpcCalleeHasBeenSet() const
{
return m_trpcCalleeHasBeenSet;
}
string RuleInput::GetTrpcFunc() const
{
return m_trpcFunc;
}
void RuleInput::SetTrpcFunc(const string& _trpcFunc)
{
m_trpcFunc = _trpcFunc;
m_trpcFuncHasBeenSet = true;
}
bool RuleInput::TrpcFuncHasBeenSet() const
{
return m_trpcFuncHasBeenSet;
}
bool RuleInput::GetQuic() const
{
return m_quic;
}
void RuleInput::SetQuic(const bool& _quic)
{
m_quic = _quic;
m_quicHasBeenSet = true;
}
bool RuleInput::QuicHasBeenSet() const
{
return m_quicHasBeenSet;
}
|
; A069345: n minus the number of its prime-factors: a(n) = n - A001222(n).
; 1,1,2,2,4,4,6,5,7,8,10,9,12,12,13,12,16,15,18,17,19,20,22,20,23,24,24,25,28,27,30,27,31,32,33,32,36,36,37,36,40,39,42,41,42,44,46,43,47,47,49,49,52,50,53,52,55,56,58,56,60,60,60,58,63,63,66,65,67,67,70,67,72,72,72,73,75,75,78,75,77,80,82,80,83,84,85,84,88,86,89,89,91,92,93,90,96,95,96,96,100,99,102,100,102,104,106,103,108,107,109,107,112,111,113,113,114,116,117,115,119,120,121,121,122,122,126,121,127,127,130,128,131,132,131,132,136,135,138,136,139,140,141,138,143,144,144,145,148,146,150,148,150,151,153,152,156,156,157,154,159,157,162,161,162,164,166,163,167,167,168,169,172,171,172,171,175,176,178,175,180,179,181,180,183,183,185,185,185,187,190,185,192,192,192,192,196,194,198,195,199,200,201,200,203,204,204,203,207,206,210,209,211,212,213,210,215,216,217,216,219,219,222,218,221,224,226,224,228,227,228,228,232,230,233,233,235,235,238,234,240,239,238,241,242,243,245,244,247,246
mov $3,1
add $3,$0
add $0,$3
cal $0,73093 ; Number of prime power divisors of n.
mov $2,1
add $2,$0
mov $0,44
sub $3,$2
mul $3,2
add $0,$3
mov $1,$0
sub $1,40
div $1,2
add $1,1
|
//snippet-sourcedescription:[update_template.cpp demonstrates how to update an Amazon SES email template.]
//snippet-service:[ses]
//snippet-keyword:[Amazon Simple Email Service]
//snippet-keyword:[C++]
//snippet-sourcesyntax:[cpp]
//snippet-keyword:[Code Sample]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[tapasweni-pathak]
/*
Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
This file is licensed under the Apache License, Version 2.0 (the "License").
You may not use this file except in compliance with the License. A copy of
the License is located at
http://aws.amazon.com/apache2.0/
This file 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 <aws/core/Aws.h>
#include <aws/email/SESClient.h>
#include <aws/email/model/UpdateTemplateRequest.h>
#include <aws/email/model/UpdateTemplateResult.h>
#include <aws/email/model/Template.h>
#include <iostream>
int main(int argc, char **argv)
{
if (argc != 6)
{
std::cout << "Usage: update_template <template_name> <html_content>"
"<subject_line> <text_content>";
return 1;
}
Aws::SDKOptions options;
Aws::InitAPI(options);
{
Aws::String template_name(argv[1]);
Aws::String html_content(argv[2]);
Aws::String subject_line(argv[3]);
Aws::String text_content(argv[4]);
Aws::SES::SESClient ses;
Aws::SES::Model::Template template_values;
Aws::SES::Model::UpdateTemplateRequest ut_req;
template_values.SetTemplateName(template_name);
template_values.SetSubjectPart(subject_line);
template_values.SetHtmlPart(html_content);
template_values.SetTextPart(text_content);
ut_req.SetTemplate(template_values);
auto ut_out = ses.UpdateTemplate(ut_req);
if (ut_out.IsSuccess())
{
std::cout << "Successfully updated template" << std::endl;
}
else
{
std::cout << "Error updating template" << ut_out.GetError().GetMessage()
<< std::endl;
}
}
Aws::ShutdownAPI(options);
return 0;
}
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; KEYPAD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;This file is for storing the MAIN code used to control and read from the
;keypad. This file contains a large segment of code, due to the keypad
;being such an integral part of the whole system. It is split into sub sections
;where appropriate to make the flow of the timer more easily seen.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Timer2OVF: ;keypad loop
push yl
push yh
push temp
in temp, SREG
push temp
lds yl, keypadTimer
lds yh, keypadTimer+1
adiw Y, 1
sts keypadTimer, yl
sts keypadTimer+1, yh
ldi temp, high(390)
cpi yl, low(390)
cpc yh, temp
breq continueTimer2
rjmp endTimer2
continueTimer2:
clear_datamem keypadTimer
push col
push row
push rmask
push cmask
push temp2
clr col
clr row
clr rmask
clr temp
clr temp2
ldi cmask, INITCOLMASK ; initial column mask
colloop:
cpi col, 4
brne contColloop; If all keys are scanned, repeat.
;all keys were scanned, and nothing found...
cpii screenStageFol, stage_code_find
breq motorKill
clr keyButtonPressed ;deal with debouncing
rjmp epilogueTimer2
motorKill: ;if on code find, handle the motor stopping
in temp, PORTE
andi temp, 0b11110111 ;kill off motor pin
out PORTE, temp
clr counter ;restart holding counter
rjmp epilogueTimer2
contColloop:
sts PORTL, cmask; Otherwise, scan a column.
ldi temp, 0xFF ; Slow down the scan operation.
delay:
dec temp
brne delay
lds temp, PINL; Read PORTA
andi temp, ROWMASK; Get the keypad output value
cpi temp, 0xF; Check if any row is low
breq nextcol; If yes, find which row - is low
ldi rmask, INITROWMASK ; Initialize for row check
clr row
rowloop:
cpi row, 4
breq nextcol ; the row scan is over.
mov temp2, temp
and temp2, rmask ; check un-masked bit
breq convert ; if bit is clear, the key is pressed
inc row; else move to the next row
lsl rmask
jmp rowloop
nextcol: ; if row scan is over
lsl cmask
inc col ; increase column value
rjmp colloop
convert:
rcall backlightFadeIn ;initialise the backlight to begin to fade in
;find button pushed..
mov temp, row
lsl temp
lsl temp
add temp, col ; temp = row*4 + col
cpii screenStage, stage_win
breq winLoseReset
cpii screenStage, stage_lose
brne checkRemaindingStages
;when at win/lose screen and a button was pushed...
winLoseReset:
cpii keyButtonPressed, 1
breq endConvert
ldi gameShouldReset, 1
rjmp epilogueTimer2
checkRemaindingStages:
cpii screenStage, stage_start
breq startScreenKeypad
cpii screenStageFol, stage_code_find
brne checkIfCodeEnter
rjmp compareCode
checkIfCodeEnter:
cpii screenStageFol, stage_code_enter
brne endConvert
rjmp keypadCodeEnter
endConvert:
rjmp epilogueTimer2
startScreenKeypad:
rcall StartScreenButtonClick
rjmp epilogueTimer2
keypadCodeEnter:
cpii keyButtonPressed, 1
brne enterKey
rjmp epilogueTimer2
enterKey:
clr cmask
ldi yl, low(randomcode) ;get the data memory for the consecutive stored keys
ldi yh, high(randomcode)
add yl, counter
adc yh, cmask ;assuming number of rounds doesn't exceed 255...
ld temp2, Y
cp temp, temp2
breq correctKey ;the correct key was entered
clr counter
do_lcd_write_str str_entercode_msg
rjmp epilogueTimer2
correctKey:
inc counter ;increment number of correct keys
do_lcd_data_i '*' ;draw correct key on screen
ldii keyButtonPressed, 1 ;debouncing..
cpii counter, max_num_rounds ;check if this is the last key
brne endkeypadCodeEnter
ldii screenStage, stage_win ;yay we win!!
endkeypadCodeEnter:
rjmp epilogueTimer2
compareCode:
cp temp, keypadCode ;check if the key entered was the correct one
breq codeMatches
;otherwise...
clr counter
rjmp epilogueTimer2
codeMatches:
inc counter
;turn on the motor
in temp, PORTE
ori temp, (1 << 3)
out PORTE, temp
cpii counter, 20 ;key has been held for 1 second
brne epilogueTimer2
;store the correct key entered into data memory to check later..
clr temp
ldi yl, low(randomcode)
ldi yh, high(randomcode)
add yl, curRound
adc yh, temp ;unless rounds exceeds 255....
st Y, keypadCode
;increment current round and clear some stuff..
inc curRound
clr counter
out PORTC, temp
out PORTG, temp
;kill the motor for good
in temp, PORTE
andi temp, 0b11110111 ;kill off motor pin
out PORTE, temp
ldii screenStageFol, -1 ;just a prevent method, so that motor doesn't run when the view changes
cpi curRound, (max_num_rounds) ;is the game over yet?
breq prepCodeEnter
speakerBeepFor speaker500 ;beeeep
toggle TIMSK1, 1<<TOIE1 ;enable countdown timer
ldii screenStage, stage_pot_reset
clr counter ;clear timer stuff
clear_datamem counterTimer ;clear timer stuff
rjmp epilogueTimer2
prepCodeEnter:
ldii screenStage, stage_code_enter ;go to code enter screen
ldii keyButtonPressed, 1 ;debouncing
epilogueTimer2:
pop temp2
pop cmask
pop rmask
pop row
pop col
endTimer2:
pop temp
out SREG, temp
pop temp
pop yh
pop yl
reti
;handles the keypresses on the start screen
;from setting difficulty to reseting and viewing
;highscores
StartScreenButtonClick:
Akey:
cpi temp, 3 ;A
brne Bkey
ldi difficultyCount, 20
do_lcd_show_custom 2, 0
rjmp storeDiff
Bkey:
cpi temp, 7 ;B
brne Ckey
ldi difficultyCount, 15
do_lcd_show_custom 1, 5
rjmp storeDiff
Ckey:
cpi temp, 11 ;C
brne Dkey
ldi difficultyCount, 10
do_lcd_show_custom 1, 0
rjmp storeDiff
Dkey:
cpi temp, 15 ;D
brne StarKey
ldi difficultyCount, 6
do_lcd_show_custom 0, 6
rjmp storeDiff
StarKey:
cpi temp, 12 ;*
breq showScore20
rjmp HashKey
showScore20:
cpi difficultyCount, 20
brne showScore15
do_lcd_command 0b10001110
lds temp, highScores
rcall asciiconv
rjmp performJMPtimer2End
showScore15:
cpi difficultyCount, 15
brne showScore10
do_lcd_command 0b10001110
lds temp, highScores + 1
rcall asciiconv
rjmp performJMPtimer2End
showScore10:
cpi difficultyCount, 10
brne showScore6
do_lcd_command 0b10001110
lds temp, highScores + 2
rcall asciiconv
rjmp performJMPtimer2End
showScore6:
cpi difficultyCount, 6
breq doShowScore6
rjmp performJMPtimer2End
doShowScore6:
do_lcd_command 0b10001110
lds temp, highScores + 3
rcall asciiconv
rjmp performJMPtimer2End
HashKey:
cpi temp, 14 ;hash key (reset highscores)
breq doScoreClear
rjmp performJMPtimer2End
doScoreClear:
ldi temp, 0
writeToEEPROM 2, temp
writeToEEPROM 3, temp
writeToEEPROM 4, temp
writeToEEPROM 5, temp
sts highScores, temp
sts highScores + 1, temp
sts highScores + 2, temp
sts highScores + 3, temp
rjmp showScore20
storeDiff:
writeToEEPROM 0, difficultyCount
performJMPtimer2End:
ret
|
// Copyright (c) 2013, 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.
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include "minidump_writer/proc_cpuinfo_reader.h"
#include "breakpad_googletest_includes.h"
#include "common/linux/tests/auto_testfile.h"
using namespace google_breakpad;
#if !defined(__ANDROID__)
#define TEMPDIR "/tmp"
#else
#define TEMPDIR "/data/local/tmp"
#endif
namespace {
typedef testing::Test ProcCpuInfoReaderTest;
class ScopedTestFile : public AutoTestFile {
public:
explicit ScopedTestFile(const char* text)
: AutoTestFile("proc_cpuinfo_reader", text) {
}
};
}
TEST(ProcCpuInfoReaderTest, EmptyFile) {
ScopedTestFile file("");
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char *field;
ASSERT_FALSE(reader.GetNextField(&field));
}
TEST(ProcCpuInfoReaderTest, OneLineTerminated) {
ScopedTestFile file("foo : bar\n");
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char *field;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);
ASSERT_STREQ("bar", reader.GetValue());
ASSERT_FALSE(reader.GetNextField(&field));
}
TEST(ProcCpuInfoReaderTest, OneLine) {
ScopedTestFile file("foo : bar");
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char *field;
size_t value_len;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);
ASSERT_STREQ("bar", reader.GetValueAndLen(&value_len));
ASSERT_EQ(3U, value_len);
ASSERT_FALSE(reader.GetNextField(&field));
}
TEST(ProcCpuInfoReaderTest, TwoLinesTerminated) {
ScopedTestFile file("foo : bar\nzoo : tut\n");
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char* field;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);
ASSERT_STREQ("bar", reader.GetValue());
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("zoo", field);
ASSERT_STREQ("tut", reader.GetValue());
ASSERT_FALSE(reader.GetNextField(&field));
}
TEST(ProcCpuInfoReaderTest, SkipMalformedLine) {
ScopedTestFile file("this line should have a column\nfoo : bar\n");
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char* field;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);
ASSERT_STREQ("bar", reader.GetValue());
ASSERT_FALSE(reader.GetNextField(&field));
}
TEST(ProcCpuInfoReaderTest, SkipOneEmptyLine) {
ScopedTestFile file("\n\nfoo : bar\n");
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char* field;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);
ASSERT_STREQ("bar", reader.GetValue());
ASSERT_FALSE(reader.GetNextField(&field));
}
TEST(ProcCpuInfoReaderTest, SkipEmptyField) {
ScopedTestFile file(" : bar\nzoo : tut\n");
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char* field;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("zoo", field);
ASSERT_STREQ("tut", reader.GetValue());
ASSERT_FALSE(reader.GetNextField(&field));
}
TEST(ProcCpuInfoReaderTest, SkipTwoEmptyLines) {
ScopedTestFile file("foo : bar\n\n\nfoo : bar\n");
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char* field;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);
ASSERT_STREQ("bar", reader.GetValue());
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);
ASSERT_STREQ("bar", reader.GetValue());
ASSERT_FALSE(reader.GetNextField(&field));
}
TEST(ProcCpuInfoReaderTest, FieldWithSpaces) {
ScopedTestFile file("foo bar : zoo\n");
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char* field;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo bar", field);
ASSERT_STREQ("zoo", reader.GetValue());
ASSERT_FALSE(reader.GetNextField(&field));
}
TEST(ProcCpuInfoReaderTest, EmptyValue) {
ScopedTestFile file("foo :\n");
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char* field;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);
size_t value_len;
ASSERT_STREQ("", reader.GetValueAndLen(&value_len));
ASSERT_EQ(0U, value_len);
ASSERT_FALSE(reader.GetNextField(&field));
}
|
; A062918: Sum of the digit reversals of the first n natural numbers.
; 1,3,6,10,15,21,28,36,45,46,57,78,109,150,201,262,333,414,505,507,519,541,573,615,667,729,801,883,975,978,991,1014,1047,1090,1143,1206,1279,1362,1455,1459,1473,1497,1531,1575,1629,1693,1767,1851,1945,1950,1965,1990,2025,2070,2125,2190,2265,2350,2445,2451,2467,2493,2529,2575,2631,2697,2773,2859,2955,2962,2979,3006,3043,3090,3147,3214,3291,3378,3475,3483,3501,3529,3567,3615,3673,3741,3819,3907,4005,4014,4033,4062,4101,4150,4209,4278,4357,4446,4545,4546
mov $2,$0
add $2,1
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
add $0,1
seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences).
add $1,$0
lpe
mov $0,$1
|
// converted from BASIC from the Commodore 64 Programmer's reference guide page 123
.pc = $0801 "Basic Upstart Program"
:BasicUpstart($0810)
.pc = $0810 "Main Program"
lda $d018
ora #8
sta $d018
lda $d011
ora #32
sta $d011
// clear bitmap to black
ldx #0
lda #0
!l:
.for (var i = 0; i < 32; i++) {
sta $2000 + $100 * i, x
}
inx
bne !l-
// current screen still has some characters on it
// remove these and set background to cyan
ldx #0
lda #3
!l:
sta $0400, x
sta $0500, x
sta $0600, x
sta $0700, x
inx
bne !l-
loop:
jmp loop
|
; A021556: Decimal expansion of 1/552.
; 0,0,1,8,1,1,5,9,4,2,0,2,8,9,8,5,5,0,7,2,4,6,3,7,6,8,1,1,5,9,4,2,0,2,8,9,8,5,5,0,7,2,4,6,3,7,6,8,1,1,5,9,4,2,0,2,8,9,8,5,5,0,7,2,4,6,3,7,6,8,1,1,5,9,4,2,0,2,8,9,8,5,5,0,7,2,4,6,3,7,6,8,1,1,5,9,4,2,0
add $0,1
mov $2,10
pow $2,$0
mov $0,$2
div $0,552
mod $0,10
|
#pragma once
#ifndef _ABSTRACTSUBAPPFACTORY_H_
#define _ABSTRACTSUBAPPFACTORY_H_
// Library includes
#include <cstddef>
#include <string>
// Includes
namespace LightBulb
{
// Forward declarations
class AbstractSubApp;
class AbstractWindow;
class AbstractMainApp;
/**
* \brief A sub app factory.
*/
class AbstractSubAppFactory
{
protected:
public:
virtual ~AbstractSubAppFactory() {};
/**
* \brief Creates a sub app.
* \param mainApp The main app which should control the sub app.
* \param parent The parent window.
* \return The new sub app.
*/
virtual AbstractSubApp* createSupApp(AbstractMainApp& mainApp, AbstractWindow& parent) const = 0;
/**
* \brief Returns the label of the sub app.
* \return The label.
*/
virtual std::string getLabel() const = 0;
};
}
#endif
|
cpx #0
beq !e+
!:
asl {m1}
rol {m1}+1
rol {m1}+2
rol {m1}+3
dex
bne !-
!e:
|
; A152966: Twice repdigit numbers.
; 0,2,4,6,8,10,12,14,16,18,22,44,66,88,110,132,154,176,198,222,444,666,888,1110,1332,1554,1776,1998,2222,4444,6666,8888,11110,13332,15554,17776,19998,22222,44444,66666,88888,111110,133332,155554,177776,199998,222222,444444,666666,888888,1111110,1333332,1555554,1777776,1999998,2222222,4444444,6666666,8888888,11111110,13333332,15555554,17777776,19999998,22222222,44444444,66666666,88888888,111111110,133333332,155555554,177777776,199999998,222222222,444444444,666666666,888888888,1111111110,1333333332
lpb $0
sub $0,1
mov $2,$0
trn $0,8
max $2,0
seq $2,51596 ; Numerical values or Gematriahs of Hebrew letters {aleph, bet, ..., tav}.
add $1,$2
lpe
mul $1,2
mov $0,$1
|
; A178719: Partial sums of (1/5)*floor(6^n/7).
; 0,0,1,7,44,266,1599,9597,57586,345520,2073125,12438755,74632536,447795222,2686771339,16120628041,96723768254,580342609532,3482055657201,20892333943215,125354003659300,752124021955810,4512744131734871,27076464790409237,162458788742455434,974752732454732616,5848516394728395709,35091098368370374267,210546590210222245616,1263279541261333473710,7579677247568000842275,45478063485408005053665,272868380912448030322006,1637210285474688181932052,9823261712848129091592329,58939570277088774549553991,353637421662532647297323964,2121824529975195883783943802,12730947179851175302703662831,76385683079107051816221977005,458314098474642310897331862050,2749884590847853865383991172320,16499307545087123192303947033941,98995845270522739153823682203667,593975071623136434922942093222024,3563850429738818609537652559332166,21383102578432911657225915355993019,128298615470597469943355492135958137,769791692823584819660132952815748846
lpb $0
mov $2,$0
sub $0,2
sub $1,1
seq $2,3464 ; a(n) = (6^n - 1)/5.
add $1,$2
lpe
div $1,6
mov $0,$1
|
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
add 0;
read main; write 0;
main:
read 80;
write 8;
i2c_wait_0:
read *11;
and 4;
branch i2c_wait_0;
i2c_wait_1:
read 0;
write 10;
read 1;
write 11;
i2c_wait_a:
read *11;
and 4;
eq 0;
branch i2c_wait_a;
i2c_wait_5:
read *11;
and 4;
branch i2c_wait_5;
i2c_wait_2:
read 0;
write 10;
read 1;
write 11;
i2c_wait_b:
read *11;
and 4;
eq 0;
branch i2c_wait_b;
read 0;
write 11;
i2c_wait_6:
read *11;
and 4;
branch i2c_wait_6;
read 1024;
write 128;
i2c_read_loop:
i2c_wait_4:
read 3;
write 11;
i2c_wait_c:
read *11;
and 4;
eq 0;
branch i2c_wait_c;
i2c_wait_3:
read *11;
and 4;
branch i2c_wait_3;
read *9;
write *128;
read *128;
add 1;
write 128;
read i2c_read_loop; write 0;
|
; int getc_unlocked_fastcall(FILE *stream)
SECTION code_clib
SECTION code_stdio
PUBLIC _getc_unlocked_fastcall
EXTERN _fgetc_unlocked_fastcall
defc _getc_unlocked_fastcall = _fgetc_unlocked_fastcall
|
; A053641: Rotate one binary digit to the right, calculate, then rotate one binary digit to the left.
; 1,1,3,1,5,3,7,1,9,3,11,5,13,7,15,1,17,3,19,5,21,7,23,9,25,11,27,13,29,15,31,1,33,3,35,5,37,7,39,9,41,11,43,13,45,15,47,17,49,19,51,21,53,23,55,25,57,27,59,29,61,31,63,1
add $0,2
mov $1,$0
mov $2,1
lpb $1
sub $1,$2
mov $2,$0
dif $2,2
sub $2,$1
lpe
mov $0,$1
|
/*
* A test for noexcept on_exit/on_enter handlers.
*/
#include <iostream>
#include <so_5/all.hpp>
#include <test/3rd_party/various_helpers/time_limited_execution.hpp>
#include <test/3rd_party/various_helpers/ensure.hpp>
class a_supervisor_t final : public so_5::agent_t
{
state_t first_state_entered{ this, "first_state_entered" };
public :
struct first_state_enter : public so_5::signal_t {};
struct first_state_exit : public so_5::signal_t {};
a_supervisor_t( context_t ctx )
: so_5::agent_t(std::move(ctx))
{
so_default_state().event( &a_supervisor_t::on_enter );
first_state_entered.event( &a_supervisor_t::on_exit );
}
private :
void
on_enter(mhood_t<first_state_enter>)
{
this >>= first_state_entered;
}
void
on_exit(mhood_t<first_state_exit>)
{
so_deregister_agent_coop_normally();
}
};
class a_test_t final : public so_5::agent_t
{
state_t first_state{ this, "first" };
const so_5::mbox_t m_supervisor;
public :
a_test_t( context_t ctx, so_5::mbox_t supervisor )
: so_5::agent_t{ ctx }
, m_supervisor{ std::move(supervisor) }
{
first_state.on_enter( &a_test_t::on_enter );
first_state.on_exit( &a_test_t::on_exit );
}
virtual void
so_evt_start() override
{
this >>= first_state;
this >>= so_default_state();
}
private :
void on_enter() noexcept
{
so_5::send<a_supervisor_t::first_state_enter>( m_supervisor );
}
void on_exit() const noexcept
{
so_5::send<a_supervisor_t::first_state_exit>( m_supervisor );
}
};
int
main()
{
try
{
run_with_time_limit(
[]()
{
so_5::launch( []( so_5::environment_t & env ) {
env.introduce_coop( []( so_5::coop_t & coop ) {
auto supervisor = coop.make_agent< a_supervisor_t >();
coop.make_agent< a_test_t >( supervisor->so_direct_mbox() );
} );
}/*,
[]( so_5::environment_params_t & params ) {
params.message_delivery_tracer(
so_5::msg_tracing::std_cout_tracer() );
}*/ );
},
20 );
}
catch( const std::exception & ex )
{
std::cerr << "Error: " << ex.what() << std::endl;
return 1;
}
return 0;
}
|
/*
* Copyright 2016 Alex Andres
*
* 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 "CoreAudioManager.h"
#include "CoreAudioPlaybackDevice.h"
#include "CoreAudioCaptureDevice.h"
#include "MacOSHelper.h"
#include "Log.h"
#import <Foundation/Foundation.h>
namespace avdev
{
CoreAudioManager::CoreAudioManager() :
AudioManager()
{
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioObjectPropertySelectorWildcard;
pa.mScope = kAudioObjectPropertyScopeWildcard;
pa.mElement = kAudioObjectPropertyElementWildcard;
OSStatus status = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &pa, deviceListenerProc, this);
THROW_IF_FAILED(status, "CoreAudio: Add device hotplug listener failed.");
}
CoreAudioManager::~CoreAudioManager()
{
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioObjectPropertySelectorWildcard;
pa.mScope = kAudioObjectPropertyScopeWildcard;
pa.mElement = kAudioObjectPropertyElementWildcard;
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &pa, deviceListenerProc, this);
}
std::set<PAudioCaptureDevice> CoreAudioManager::getAudioCaptureDevices()
{
if (captureDevices.empty()) {
enumerateDevices(kAudioObjectPropertyScopeInput);
}
return captureDevices.devices();
}
std::set<PAudioPlaybackDevice> CoreAudioManager::getAudioPlaybackDevices()
{
if (playbackDevices.empty()) {
enumerateDevices(kAudioObjectPropertyScopeOutput);
}
return playbackDevices.devices();
}
void CoreAudioManager::enumerateDevices(AudioObjectPropertyScope scope) {
// Get default device ID.
AudioDeviceID defaultID = getDefaultDeviceID(scope);
UInt32 dataSize;
// Get all devices.
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioHardwarePropertyDevices;
pa.mScope = kAudioObjectPropertyScopeGlobal;
pa.mElement = kAudioObjectPropertyElementMaster;
OSStatus status = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &pa, 0, nullptr, &dataSize);
THROW_IF_FAILED(status, "CoreAudio: Enumerate audio endpoints failed.");
const int numDevices = dataSize / sizeof(AudioDeviceID);
AudioDeviceID * devIDs = new AudioDeviceID[numDevices];
status = AudioObjectGetPropertyData(kAudioObjectSystemObject, &pa, 0, nullptr, &dataSize, devIDs);
THROW_IF_FAILED(status, "CoreAudio: Enumerate audio endpoints failed.");
for (int i = 0; i < numDevices; i++) {
std::shared_ptr<AudioDevice> device = createAudioDevice(devIDs[i], scope);
if (device != nullptr) {
insertAudioDevice(device, scope);
// Set default device.
bool isDefault = (defaultID == devIDs[i]);
if (isDefault && scope == kAudioObjectPropertyScopeInput) {
setDefaultCaptureDevice(std::static_pointer_cast<CoreAudioCaptureDevice>(device));
}
else if (isDefault && scope == kAudioObjectPropertyScopeOutput) {
setDefaultPlaybackDevice(std::static_pointer_cast<CoreAudioPlaybackDevice>(device));
}
}
}
delete[] devIDs;
}
void CoreAudioManager::onDevicesChanged()
{
UInt32 dataSize;
// Get all devices.
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioHardwarePropertyDevices;
pa.mScope = kAudioObjectPropertyScopeGlobal;
pa.mElement = kAudioObjectPropertyElementMaster;
OSStatus status = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &pa, 0, nullptr, &dataSize);
THROW_IF_FAILED(status, "CoreAudio: Enumerate audio endpoints failed.");
const int numDevices = dataSize / sizeof(AudioDeviceID);
AudioDeviceID * devIDs = new AudioDeviceID[numDevices];
status = AudioObjectGetPropertyData(kAudioObjectSystemObject, &pa, 0, nullptr, &dataSize, devIDs);
THROW_IF_FAILED(status, "CoreAudio: Enumerate audio endpoints failed.");
// Check, if a new device is available.
for (int i = 0; i < numDevices; i++) {
bool found = false;
for (const PAudioCaptureDevice & dev : captureDevices.devices()) {
AudioDeviceID devID = std::stoi(dev->getDescriptor());
if (devIDs[i] == devID) {
found = true;
break;
}
}
for (const PAudioPlaybackDevice & dev : playbackDevices.devices()) {
AudioDeviceID devID = std::stoi(dev->getDescriptor());
if (devIDs[i] == devID) {
found = true;
break;
}
}
if (!found) {
// New device found.
unsigned inChannels = getChannelCount(devIDs[i], kAudioObjectPropertyScopeInput);
unsigned outChannels = getChannelCount(devIDs[i], kAudioObjectPropertyScopeOutput);
if (inChannels > 0) {
AudioObjectPropertyScope scope = kAudioObjectPropertyScopeInput;
std::shared_ptr<AudioDevice> device = createAudioDevice(devIDs[i], scope);
if (device != nullptr) {
insertAudioDevice(device, scope);
// Update default capture device.
PAudioCaptureDevice def = getDefaultCaptureDevice();
onDefaultDeviceChanged<PAudioCaptureDevice>(scope, captureDevices, def);
notifyDeviceConnected(device);
}
}
if (outChannels > 0) {
AudioObjectPropertyScope scope = kAudioObjectPropertyScopeOutput;
std::shared_ptr<AudioDevice> device = createAudioDevice(devIDs[i], scope);
if (device != nullptr) {
insertAudioDevice(device, scope);
// Update default playback device.
PAudioPlaybackDevice def = getDefaultPlaybackDevice();
onDefaultDeviceChanged<PAudioPlaybackDevice>(scope, playbackDevices, def);
notifyDeviceConnected(device);
}
}
}
}
// Check, if a device was disconnected.
checkDeviceGone<PAudioCaptureDevice>(captureDevices, devIDs, numDevices, kAudioObjectPropertyScopeInput);
checkDeviceGone<PAudioPlaybackDevice>(playbackDevices, devIDs, numDevices, kAudioObjectPropertyScopeOutput);
delete[] devIDs;
}
template<typename T>
void CoreAudioManager::onDefaultDeviceChanged(AudioObjectPropertyScope scope, DeviceList<T> & devices, T & device)
{
AudioDeviceID defaultID = getDefaultDeviceID(scope);
AudioDeviceID deviceID = (device == nullptr) ? 0 : std::stoi(device->getDescriptor());
if (defaultID != deviceID) {
auto predicate = [defaultID](const T & dev) {
AudioDeviceID devID = std::stoi(dev->getDescriptor());
return defaultID == devID;
};
T found = devices.findDevice(predicate);
if (found == nullptr) {
LOGDEV_WARN("CoreAudio: Find device failed.");
return;
}
switch (scope) {
case kAudioObjectPropertyScopeInput:
setDefaultCaptureDevice(std::dynamic_pointer_cast<CoreAudioCaptureDevice>(found));
break;
case kAudioObjectPropertyScopeOutput:
setDefaultPlaybackDevice(std::dynamic_pointer_cast<CoreAudioPlaybackDevice>(found));
break;
}
}
}
template<typename T>
void CoreAudioManager::checkDeviceGone(DeviceList<T> & devices, AudioDeviceID * devIDs, const int numDevIDs, AudioObjectPropertyScope scope)
{
auto predicate = [devIDs, numDevIDs](const T & dev) {
AudioDeviceID devID = std::stoi(dev->getDescriptor());
bool found = false;
for (int i = 0; i < numDevIDs; i++) {
if (devIDs[i] == devID) {
found = true;
break;
}
}
return !found;
};
T removed = devices.removeDevice(predicate);
if (removed != nullptr) {
switch (scope) {
case kAudioObjectPropertyScopeInput:
{
PAudioCaptureDevice def = getDefaultAudioCaptureDevice();
PAudioCaptureDevice rem = std::dynamic_pointer_cast<CoreAudioCaptureDevice>(removed);
if (rem == def) {
onDefaultDeviceChanged<PAudioCaptureDevice>(scope, captureDevices, def);
}
break;
}
case kAudioObjectPropertyScopeOutput:
{
PAudioPlaybackDevice def = getDefaultAudioPlaybackDevice();
PAudioPlaybackDevice rem = std::dynamic_pointer_cast<CoreAudioPlaybackDevice>(removed);
if (rem == def) {
onDefaultDeviceChanged<PAudioPlaybackDevice>(scope, playbackDevices, def);
}
break;
}
}
notifyDeviceDisconnected(removed);
}
}
std::shared_ptr<AudioDevice> CoreAudioManager::createAudioDevice(AudioDeviceID deviceID, AudioObjectPropertyScope scope) {
std::shared_ptr<AudioDevice> device = nullptr;
CFStringRef devNameRef;
UInt32 dataSize = sizeof(devNameRef);
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioObjectPropertyName;
pa.mScope = kAudioObjectPropertyScopeGlobal;
pa.mElement = kAudioObjectPropertyElementMaster;
OSStatus status = AudioObjectGetPropertyData(deviceID, &pa, 0, nullptr, &dataSize, &devNameRef);
THROW_IF_FAILED(status, "CoreAudio: Get device name failed.");
CFIndex length = CFStringGetLength(devNameRef) + 1;
char deviceName[length];
CFStringGetCString(devNameRef, deviceName, length, kCFStringEncodingUTF8);
CFRelease(devNameRef);
std::string name(deviceName, length);
std::string id = std::to_string(deviceID);
unsigned channels = getChannelCount(deviceID, scope);
if (channels > 0) {
if (scope == kAudioObjectPropertyScopeOutput) {
device = std::make_shared<CoreAudioPlaybackDevice>(name, id, deviceID);
}
else if (scope == kAudioObjectPropertyScopeInput) {
device = std::make_shared<CoreAudioCaptureDevice>(name, id, deviceID);
}
}
return device;
}
bool CoreAudioManager::insertAudioDevice(std::shared_ptr<AudioDevice> device, AudioObjectPropertyScope scope)
{
if (device == nullptr)
return false;
if (scope == kAudioObjectPropertyScopeOutput) {
return playbackDevices.insertDevice(std::static_pointer_cast<CoreAudioPlaybackDevice>(device));
}
else if (scope == kAudioObjectPropertyScopeInput) {
return captureDevices.insertDevice(std::static_pointer_cast<CoreAudioCaptureDevice>(device));
}
return false;
}
int CoreAudioManager::getChannelCount(AudioDeviceID deviceID, AudioObjectPropertyScope scope) {
int channels = 0;
UInt32 dataSize;
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioDevicePropertyStreamConfiguration;
pa.mElement = kAudioObjectPropertyElementMaster;
pa.mScope = scope;
if (AudioObjectGetPropertyDataSize(deviceID, &pa, 0, nullptr, &dataSize) == noErr) {
AudioBufferList * buffers = new AudioBufferList[dataSize];
if (AudioObjectGetPropertyData(deviceID, &pa, 0, nullptr, &dataSize, buffers) == noErr) {
for (int i = 0; i < buffers->mNumberBuffers; i++) {
channels += buffers->mBuffers[i].mNumberChannels;
}
}
delete[] buffers;
}
return channels;
}
AudioDeviceID CoreAudioManager::getDefaultDeviceID(AudioObjectPropertyScope scope) {
AudioDeviceID defaultID = 0;
UInt32 dataSize = sizeof(AudioDeviceID);
AudioObjectPropertyAddress pa;
pa.mScope = kAudioObjectPropertyScopeGlobal;
pa.mElement = kAudioObjectPropertyElementMaster;
switch (scope) {
case kAudioObjectPropertyScopeInput:
pa.mSelector = kAudioHardwarePropertyDefaultInputDevice;
break;
case kAudioObjectPropertyScopeOutput:
pa.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
break;
}
OSStatus status = AudioObjectGetPropertyData(kAudioObjectSystemObject, &pa, 0, nullptr, &dataSize, &defaultID);
if (status != noErr) {
LOGDEV_ERROR("CoreAudio: Get default device ID failed: Status = %d.", status);
}
return defaultID;
}
OSStatus CoreAudioManager::deviceListenerProc(AudioObjectID objectID, UInt32 numberAddresses, const AudioObjectPropertyAddress addresses[], void * clientData) {
CoreAudioManager * const manager = static_cast<CoreAudioManager *>(clientData);
for (int i = 0; i < numberAddresses; i++) {
switch (addresses[i].mSelector) {
case kAudioHardwarePropertyDevices:
{
manager->onDevicesChanged();
break;
}
case kAudioHardwarePropertyDefaultInputDevice:
{
PAudioCaptureDevice def = manager->getDefaultCaptureDevice();
manager->onDefaultDeviceChanged<PAudioCaptureDevice>(kAudioObjectPropertyScopeInput, manager->captureDevices, def);
break;
}
case kAudioHardwarePropertyDefaultOutputDevice:
{
PAudioPlaybackDevice defp = manager->getDefaultPlaybackDevice();
manager->onDefaultDeviceChanged<PAudioPlaybackDevice>(kAudioObjectPropertyScopeOutput, manager->playbackDevices, defp);
break;
}
}
}
return noErr;
}
}
|
Name: zel_int0.asm
Type: file
Size: 4680
Last-Modified: '2016-05-13T04:20:48Z'
SHA-1: 560BDBA429CB8ADE1EB3C9772E885914FC778A5C
Description: null
|
/*******************************<GINKGO LICENSE>******************************
Copyright (c) 2017-2020, the Ginkgo authors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************<GINKGO LICENSE>*******************************/
#ifndef GKO_CORE_BASE_ITERATOR_FACTORY_HPP_
#define GKO_CORE_BASE_ITERATOR_FACTORY_HPP_
#include <iterator>
#include <ginkgo/core/base/types.hpp>
namespace gko {
namespace detail {
/**
* @internal
* @brief This class is used to sort two distinct arrays (`dominant_values` and
* `secondary_values`) with the same number of elements (it can be different
* types) according to the `dominant_values` in ascending order.
*
* Stores the pointers of two arrays, one storing the type `SecondaryType`, and
* one storing the type `ToSortType`. This class also provides an iterator
* class, which can be used for `std::sort`. Without a custom iterator, memory
* copies would be necessary to create, for example, one array of `std::pairs`
* to use `std::sort`, or a self written sort function.
*
* Example of using this class to sort a list of people according to their age:
* -----------------------------------------------------------------
* ```cpp
* std::vector<int> age{50, 44, 43, 42};
* std::vector<std::string> person{"Karl", "Susanne", "Max", "Hannah"};
* IteratorFactory<int, std::string> factory{age.data(), person.data(), 4};
* std::sort(factory.begin(), factory.end());
* ```
* Here, `person` now contains: `{"Hannah", "Max", "Susanne", "Karl"}` and
* `age` is now `{42, 43, 44, 50}`. Therefore, both arrays are now sorted
* according to the values in ascending order of `age`.
*
* @tparam ToSortType Type of the values which will be used for sorting.
* It must support `operator<`.
* @tparam SecondaryType Type of the values which will be moved synchronous
* to the array of type `ToSortType`. No comparisons
* with this type will be performed.
*/
template <typename ToSortType, typename SecondaryType>
class IteratorFactory {
// All nested classes are hidden, so they can't be misused
private:
/**
* Helper struct, needed for the default construction and assignment inside
* `std::sort` through Reference. They are used as an intermediate data
* type for some of the swaps `std::sort` performs.
*/
struct element {
ToSortType dominant;
SecondaryType secondary;
friend bool operator<(const element &left, const element &right)
{
return left.dominant < right.dominant;
}
};
/**
* This class is used as a reference to a sorting target, which abstracts
* the existence of two distinct arrays.
* It meets the requirements of `MoveAssignable`, `MoveConstructible`
* In all comparisons, only the values of `dominant_values_` matter, while
* the corresponding value of `secondary_values_` will always be copied /
* moved / swapped to the same place.
*/
class Reference {
public:
using array_index_type = int64;
// An empty reference makes no sense, so is is disabled
Reference() = delete;
~Reference() {}
Reference(IteratorFactory &parent, array_index_type array_index)
: parent_(parent), arr_index_(array_index)
{}
// Since it must be `MoveConstructible`
Reference(Reference &&other)
: parent_(other.parent_), arr_index_(std::move(other.arr_index_))
{}
Reference(const Reference &other)
: parent_(other.parent_), arr_index_(other.arr_index_)
{}
Reference &operator=(element other)
{
dominant() = other.dominant;
secondary() = other.secondary;
return *this;
}
Reference &operator=(const Reference &other)
{
dominant() = other.dominant();
secondary() = other.secondary();
return *this;
}
// Since it must be `MoveAssignable`
Reference &operator=(Reference &&other)
{
// In C++11, it is legal for a nested class to access private
// members of the parent class.
parent_.dominant_values_[arr_index_] =
std::move(other.parent_.dominant_values_[other.arr_index_]);
parent_.secondary_values_[arr_index_] =
std::move(other.parent_.secondary_values_[other.arr_index_]);
return *this;
}
// Conversion operator to `element`
operator element() const { return {dominant(), secondary()}; }
friend void swap(Reference a, Reference b)
{
std::swap(a.dominant(), b.dominant());
std::swap(a.secondary(), b.secondary());
}
friend bool operator<(const Reference &left, const Reference &right)
{
return left.dominant() < right.dominant();
}
friend bool operator<(const Reference &left, const element &right)
{
return left.dominant() < right.dominant;
}
friend bool operator<(const element &left, const Reference &right)
{
return left.dominant < right.dominant();
}
ToSortType &dominant() { return parent_.dominant_values_[arr_index_]; }
const ToSortType &dominant() const
{
return parent_.dominant_values_[arr_index_];
}
SecondaryType &secondary()
{
return parent_.secondary_values_[arr_index_];
}
const SecondaryType &secondary() const
{
return parent_.secondary_values_[arr_index_];
}
private:
IteratorFactory &parent_;
array_index_type arr_index_;
};
/**
* The iterator that can be used for `std::sort`. It meets the requirements
* of `LegacyRandomAccessIterator` and `ValueSwappable`.
* For performance reasons, it is expected that all iterators that are
* compared / used with each other have the same `parent`, so the check
* if they are the same can be omitted.
* This class uses a single variable to keep track of where the iterator
* points to both arrays.
*/
class Iterator {
public:
// Needed to count as a `LegacyRandomAccessIterator`
using difference_type = typename Reference::array_index_type;
using value_type = element;
using pointer = Reference;
using reference = Reference;
using iterator_category = std::random_access_iterator_tag;
~Iterator() {}
Iterator(IteratorFactory &parent, difference_type array_index)
: parent_(parent), arr_index_(array_index)
{}
Iterator(const Iterator &other)
: parent_(other.parent_), arr_index_(other.arr_index_)
{}
Iterator &operator=(const Iterator &other)
{
arr_index_ = other.arr_index_;
return *this;
}
// Operators needed for the std::sort requirement of
// `LegacyRandomAccessIterator`
Iterator &operator+=(difference_type i)
{
arr_index_ += i;
return *this;
}
Iterator &operator-=(difference_type i)
{
arr_index_ -= i;
return *this;
}
Iterator &operator++() // Prefix increment (++i)
{
++arr_index_;
return *this;
}
Iterator operator++(int) // Postfix increment (i++)
{
Iterator temp(*this);
++arr_index_;
return temp;
}
Iterator &operator--() // Prefix decrement (--i)
{
--arr_index_;
return *this;
}
Iterator operator--(int) // Postfix decrement (i--)
{
Iterator temp(*this);
--arr_index_;
return temp;
}
Iterator operator+(difference_type i) const
{
return {parent_, arr_index_ + i};
}
friend Iterator operator+(difference_type i, const Iterator &iter)
{
return {iter.parent_, iter.arr_index_ + i};
}
Iterator operator-(difference_type i) const
{
return {parent_, arr_index_ - i};
}
difference_type operator-(const Iterator &other) const
{
return arr_index_ - other.arr_index_;
}
Reference operator*() const { return {parent_, arr_index_}; }
Reference operator[](size_t idx) const
{
return {parent_, arr_index_ + idx};
}
// Comparable operators
bool operator==(const Iterator &other)
{
return arr_index_ == other.arr_index_;
}
bool operator!=(const Iterator &other)
{
return arr_index_ != other.arr_index_;
}
bool operator<(const Iterator &other) const
{
return arr_index_ < other.arr_index_;
}
bool operator<=(const Iterator &other) const
{
return arr_index_ <= other.arr_index_;
}
bool operator>(const Iterator &other) const
{
return arr_index_ > other.arr_index_;
}
bool operator>=(const Iterator &other) const
{
return arr_index_ >= other.arr_index_;
}
private:
IteratorFactory &parent_;
difference_type arr_index_;
};
public:
/**
* Allows creating an iterator, which makes it look like the data consists
* of `size` `std::pair<ToSortType, SecondaryType>`s, which are also
* sortable (according to the value of `dominant_values`) as long as
* `ToSortType` can be comparable with `operator<`. No additional data is
* allocated, all operations performed through the Iterator object will be
* done on the given arrays. The iterators given by this object (through
* `begin()` and `end()`) can be used with `std::sort()`.
* @param dominant_values Array of at least `size` values, which are the
* only values considered when comparing values (for example while sorting)
* @param secondary_values Array of at least `size` values, which will not
* be considered when comparing. However, they will be moved / copied to the
* same place as their corresponding value in `dominant_values` (with the
* same index).
* @param size Size of the arrays when constructiong the iterators.
* @note Both arrays must have at least `size` elements, otherwise, the
* behaviour is undefined.
*/
IteratorFactory(ToSortType *dominant_values,
SecondaryType *secondary_values, size_type size)
: dominant_values_(dominant_values),
secondary_values_(secondary_values),
size_(size)
{}
/**
* Creates an iterator pointing to the beginning of both arrays
* @returns an iterator pointing to the beginning of both arrays
*/
Iterator begin() { return {*this, 0}; }
/**
* Creates an iterator pointing to the (excluding) end of both arrays
* @returns an iterator pointing to the (excluding) end of both arrays
*/
Iterator end()
{
return {*this, static_cast<typename Iterator::difference_type>(size_)};
}
private:
ToSortType *dominant_values_;
SecondaryType *secondary_values_;
size_type size_;
};
} // namespace detail
} // namespace gko
#endif // GKO_CORE_BASE_ITERATOR_FACTORY_HPP_
|
//---------------------------------------------------------------------------//
// Copyright (c) 2018-2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
//
// MIT License
//
// 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.
//---------------------------------------------------------------------------//
// @file Template aliasing for prettifying R1CS PCD interfaces.
//---------------------------------------------------------------------------//
#ifndef CRYPTO3_ZK_PPZKPCD_COMPLIANCE_PREDICATE_HPP
#define CRYPTO3_ZK_PPZKPCD_COMPLIANCE_PREDICATE_HPP
#include <nil/crypto3/zk/snark/schemes/pcd/r1cs_pcd/compliance_predicate.hpp>
namespace nil {
namespace crypto3 {
namespace zk {
namespace snark {
/* template aliasing for R1CS (multi-predicate) ppzkPCD: */
template<typename PCD_ppT>
using r1cs_mp_ppzkpcd_compliance_predicate =
r1cs_pcd_compliance_predicate<algebra::Fr<typename PCD_ppT::curve_A_pp>>;
template<typename PCD_ppT>
using r1cs_mp_ppzkpcd_message = r1cs_pcd_message<algebra::Fr<typename PCD_ppT::curve_A_pp>>;
template<typename PCD_ppT>
using r1cs_mp_ppzkpcd_local_data = r1cs_pcd_local_data<algebra::Fr<typename PCD_ppT::curve_A_pp>>;
template<typename PCD_ppT>
using r1cs_mp_ppzkpcd_variable_assignment =
r1cs_variable_assignment<algebra::Fr<typename PCD_ppT::curve_A_pp>>;
} // namespace snark
} // namespace zk
} // namespace crypto3
} // namespace nil
#endif // PPZKPCD_COMPLIANCE_PREDICATE_HPP
|
; A259755: Numbers that are congruent to {4,20} mod 24.
; 4,20,28,44,52,68,76,92,100,116,124,140,148,164,172,188,196,212,220,236,244,260,268,284,292,308,316,332,340,356,364,380,388,404,412,428,436,452,460,476,484,500,508,524,532,548,556,572,580,596,604,620,628,644,652,668,676,692,700,716,724,740,748,764,772,788,796,812,820,836,844,860,868,884,892,908,916,932,940,956,964,980,988,1004,1012,1028,1036,1052,1060,1076,1084,1100,1108,1124,1132,1148,1156,1172,1180,1196,1204,1220,1228,1244,1252,1268,1276,1292,1300,1316,1324,1340,1348,1364,1372,1388,1396,1412,1420,1436,1444,1460,1468,1484,1492,1508,1516,1532,1540,1556,1564,1580,1588,1604,1612,1628,1636,1652,1660,1676,1684,1700,1708,1724,1732,1748,1756,1772,1780,1796,1804,1820,1828,1844,1852,1868,1876,1892,1900,1916,1924,1940,1948,1964,1972,1988,1996,2012,2020,2036,2044,2060,2068,2084,2092,2108,2116,2132,2140,2156,2164,2180,2188,2204,2212,2228,2236,2252,2260,2276,2284,2300,2308,2324,2332,2348,2356,2372,2380,2396,2404,2420,2428,2444,2452,2468,2476,2492,2500,2516,2524,2540,2548,2564,2572,2588,2596,2612,2620,2636,2644,2660,2668,2684,2692,2708,2716,2732,2740,2756,2764,2780,2788,2804,2812,2828,2836,2852,2860,2876,2884,2900,2908,2924,2932,2948,2956,2972,2980,2996
mov $1,$0
mul $1,3
add $1,1
div $1,2
mul $1,8
add $1,4
|
// Copyright 2022 HX2003
//
// 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 "faze4_driver.hpp"
#include <chrono>
#include <iostream>
#include <thread>
#include <boost/format.hpp>
#include <boost/tokenizer.hpp>
#include "rclcpp/rclcpp.hpp"
namespace faze4_hardware_driver
{
bool Faze4HardwareDriver::init(const std::string & device, int baudrate)
{
try
{
serial_ = std::make_shared<TimeoutSerial>(
device, baudrate,
boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none),
boost::asio::serial_port_base::character_size(8),
boost::asio::serial_port_base::flow_control(
boost::asio::serial_port_base::flow_control::none),
boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one));
serial_->setTimeout(boost::posix_time::seconds(1));
serial_->writeString("INIT: \n");
}
catch (boost::system::system_error & e)
{
RCLCPP_ERROR(rclcpp::get_logger("Faze4HardwareDriver"), "%s", e.what());
return false;
}
return true;
}
void Faze4HardwareDriver::set_angles(std::vector<double> angles)
{
boost::format fmt = boost::format("SET: %6.5f, %6.5f, %6.5f, %6.5f, %6.5f, %6.5f\n") % angles[0] %
angles[1] % angles[2] % angles[3] % angles[4] % angles[5];
serial_->writeString(fmt.str());
}
void Faze4HardwareDriver::get_angles(std::vector<double> & angles)
{
serial_->writeString("GET:\n");
std::string inputString;
try
{
inputString = serial_->readStringUntil("\n");
}
catch (timeout_exception & e)
{
RCLCPP_INFO(rclcpp::get_logger("Faze4HardwareDriver"), "Timeout!");
return;
}
catch (boost::system::system_error & e)
{
RCLCPP_ERROR(rclcpp::get_logger("Faze4HardwareDriver"), "%s", e.what());
return;
}
std::sscanf(
inputString.c_str(), "SEND: %lf, %lf, %lf, %lf, %lf, %lf", &angles[0], &angles[1], &angles[2],
&angles[3], &angles[4], &angles[5]);
}
void Faze4HardwareDriver::home(void) { serial_->writeString("HOME:\n"); }
} // namespace faze4_hardware_driver
|
#include <iostream>
#include "Person.h"
int main()
{
Person person("Harry", 29);
for (std::string& data : person)
{
std::cout << data << std::endl;
}
return 0;
}
|
; A228297: Generalized meta-Fibonacci sequence a(n) with parameters s=0 and k=5.
; 1,2,3,4,5,5,6,7,8,9,10,10,11,12,13,14,15,15,16,17,18,19,20,20,21,22,23,24,25,25,25,26,27,28,29,30,30,31,32,33,34,35,35,36,37,38,39,40,40,41,42,43,44,45,45,46,47,48,49,50,50,50,51,52,53,54,55,55,56,57,58,59,60,60,61,62,63,64,65,65,66,67,68,69,70,70,71,72,73,74,75,75,75,76,77,78,79,80,80,81
add $0,1
mov $2,$0
lpb $0
lpb $2,$2
lpb $0
sub $2,$0
div $0,5
lpe
lpe
sub $0,1
lpe
add $0,1
|
//
// Created by damian on 23.07.2020.
//
#include <catch2/catch.hpp>
#include <Tuple.h>
#include <misc/AABB.h>
#include <shapes/Sphere.h>
#include <shapes/Plane.h>
#include <shapes/Cube.h>
#include <shapes/Cylinder.h>
#include <shapes/Group.h>
SCENARIO("Creating a bounding box")
{
GIVEN("")
{
auto aabb = rt::AABB(util::Tuple::point(-1, -1, -1), util::Tuple::point(1, 1, 1));
THEN("")
{
REQUIRE(aabb.min() == util::Tuple::point(-1, -1, -1));
REQUIRE(aabb.max() == util::Tuple::point(1, 1, 1));
}
}
}
SCENARIO("Creating empty bounding box")
{
GIVEN("")
{
auto aabb = rt::AABB();
WHEN("AABB is not modified")
{
THEN("")
{
REQUIRE(aabb.max().x() == Approx(math::ninf<>));
REQUIRE(aabb.max().y() == Approx(math::ninf<>));
REQUIRE(aabb.max().z() == Approx(math::ninf<>));
REQUIRE(aabb.min().x() == Approx(math::inf<>));
REQUIRE(aabb.min().y() == Approx(math::inf<>));
REQUIRE(aabb.min().z() == Approx(math::inf<>));
}
}
}
}
SCENARIO("Expanding empty bounding box by points")
{
GIVEN("")
{
auto aabb = rt::AABB();
WHEN("Adding points")
{
aabb.add(util::Tuple::point(2, 2, 2));
aabb.add(util::Tuple::point(-2, -2, -2));
THEN("")
{
REQUIRE(aabb.max() == util::Tuple::point(2, 2, 2));
REQUIRE(aabb.min() == util::Tuple::point(-2, -2, -2));
}
}
}
}
SCENARIO("Expanding empty bounding box by another box")
{
GIVEN("")
{
auto aabb1 = rt::AABB(util::Tuple::point(-1, -1, -1), util::Tuple::point(1, 1, 1));
auto aabb2 = rt::AABB(util::Tuple::point(0, 0, 0), util::Tuple::point(3, 3, 3));
WHEN("Adding")
{
auto aabb = aabb1.add(aabb2);
THEN("")
{
REQUIRE(aabb.max() == util::Tuple::point(3, 3, 3));
REQUIRE(aabb.min() == util::Tuple::point(-1, -1, -1));
}
}
}
}
SCENARIO("Shape return it's bounding box")
{
GIVEN("")
{
auto sphere = rt::Sphere();
auto result = rt::AABB(util::Tuple::point(-1, -1, -1), util::Tuple::point(1, 1, 1));
auto aabb = sphere.bounds();
THEN("")
{
REQUIRE(aabb == result);
}
}
}
SCENARIO("Plane return it's bounding box")
{
GIVEN("")
{
auto sphere = rt::Plane();
auto result = rt::AABB(
util::Tuple::point(math::ninf<>, 0, math::ninf<>),
util::Tuple::point(math::inf<>, 0, math::inf<>));
auto aabb = sphere.bounds();
THEN("")
{
REQUIRE(aabb.max() == result.max());
}
}
}
SCENARIO("Cube return it's bounding box")
{
GIVEN("")
{
auto sphere = rt::Cube();
auto result = rt::AABB(
util::Tuple::point(-1, -1, -1),
util::Tuple::point(1, 1, 1));
auto aabb = sphere.bounds();
THEN("")
{
REQUIRE(aabb.max() == result.max());
}
}
}
SCENARIO("boundless cylinder return it's bounding box")
{
GIVEN("")
{
auto sphere = rt::Cylinder();
auto result = rt::AABB(
util::Tuple::point(-1, math::ninf<>, -1),
util::Tuple::point(1, math::inf<>, 1));
auto aabb = sphere.bounds();
THEN("")
{
REQUIRE(aabb == result);
}
}
}
SCENARIO("Transforming the bounding box")
{
GIVEN("")
{
auto aabb1 = rt::AABB(util::Tuple::point(-1, -1, -1), util::Tuple::point(1, 1, 1));
auto transform = util::Matrixd::scaling(2, 3, 4);
auto aabb2 = aabb1.transform(transform);
auto result = rt::AABB(
util::Tuple::point(-2, -3, -4),
util::Tuple::point(2, 3, 4));
THEN("")
{
REQUIRE(aabb2 == result);
}
}
}
SCENARIO("Bounding box of untransformed group")
{
GIVEN("")
{
auto sphere = std::make_shared<rt::Sphere>();
auto cube = std::make_shared<rt::Cube>();
auto group = std::make_shared<rt::Group>();
auto result = rt::AABB(util::Tuple::point(-1, -1, -1), util::Tuple::point(3, 1, 1));
group->addChild(sphere).addChild(cube);
sphere->setTransform(util::Matrixd::translation(2, 0, 0));
WHEN("")
{
auto bounds = group->bounds();
THEN("")
{
REQUIRE(bounds == result);
}
}
}
}
SCENARIO("Bounding box of transformed group")
{
GIVEN("")
{
auto sphere = std::make_shared<rt::Sphere>();
auto cube = std::make_shared<rt::Cube>();
auto group = std::make_shared<rt::Group>();
auto result = rt::AABB(util::Tuple::point(-sqrt(2), -sqrt(2), -1), util::Tuple::point(sqrt(2), sqrt(2), 1));
group->addChild(sphere).addChild(cube);
//sphere->setTransform(util::Matrixd::translation(2,0,0));
group->setTransform(util::Matrixd::rotation_z(45 * math::pi<> / 180));
WHEN("")
{
auto bounds = group->parentSpaceBounds();
THEN("")
{
REQUIRE(bounds == result);
}
}
}
}
SCENARIO("Check if ray intersectes a group")
{
GIVEN("")
{
auto sphere = std::make_shared<rt::Sphere>();
auto cube = std::make_shared<rt::Cube>();
auto group = std::make_shared<rt::Group>();
//auto result = rt::AABB(util::Tuple::point(-sqrt(2), -sqrt(2), -1), util::Tuple::point(sqrt(2), sqrt(2), 1));
group->addChild(sphere).addChild(cube);
group->setTransform(util::Matrixd::rotation_z(45 * math::pi<> / 180));
auto ray = rt::Ray(util::Tuple::point(-3,0,0), util::Tuple::vector(1,0,0));
THEN("") {
REQUIRE(group->bounds().intersect(ray) == true);
}
}
}
SCENARIO("Check if ray does intersect a group")
{
GIVEN("")
{
auto sphere = std::make_shared<rt::Sphere>();
auto cube = std::make_shared<rt::Cube>();
auto group = std::make_shared<rt::Group>();
//auto result = rt::AABB(util::Tuple::point(-sqrt(2), -sqrt(2), -1), util::Tuple::point(sqrt(2), sqrt(2), 1));
group->addChild(sphere).addChild(cube);
group->setTransform(util::Matrixd::rotation_z(45 * math::pi<> / 180));
auto ray = rt::Ray(util::Tuple::point(-4,0,0), util::Tuple::vector(0,3,0));
THEN("") {
REQUIRE(group->bounds().intersect(ray) == false);
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.