text
stringlengths
1
1.05M
; ; System Call for REX6000 ; ; $Id: DbUpdateRecord.asm,v 1.2 2015/01/19 01:33:06 pauloscustodio Exp $ ; ; extern INT DbUpdateRecord( int, ... ); ; PUBLIC DbUpdateRecord .DbUpdateRecord ld b,a ld ix,2 add ix,sp .DbUpdateRecord_1 ld l,(ix+0) ld h,(ix+1) push hl inc ix inc ix djnz DbUpdateRecord_1 ld de,$00e6 ;DB_UPDATERECORD ld ($c000),de ld ($c002),hl ld hl,2 add hl,sp push hl ld hl,0 add hl,sp ld ($c004),hl push af rst $10 pop af pop hl ld b,a .DbUpdateRecord_2 pop ix djnz DbUpdateRecord_2 ld hl,($c00e) ret
%ifdef CONFIG { "RegData": { "RAX": "0x4142434445464748", "RDX": "0x0", "RDI": "0xE000000E", "RSI": "0xDFFFFFFE" }, "MemoryRegions": { "0x100000000": "4096" } } %endif mov rdx, 0xe0000000 mov rax, 0x4142434445464748 mov [rdx + 8 * 0], rax mov rax, 0x5152535455565758 mov [rdx + 8 * 1], rax mov rax, 0x0 mov [rdx + 8 * 2], rax mov [rdx + 8 * 3], rax lea rdi, [rdx + 8 * 2 + 6] lea rsi, [rdx + 8 * 0 + 6] std mov rcx, 4 rep movsw ; rdi <- rsi mov rax, [rdx + 8 * 2] mov rdx, [rdx + 8 * 3] hlt
db "SCARECROW@" ; species name db "Packs of them" next "follow travelers" next "through the desert" page "until the group of" next "travelers are too" next "tired to move.@"
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #include "catch.hpp" #include "sum_range.h" TEST_CASE("Test sum range with while", "Range min to max") { REQUIRE(sum_range(1, 3) == 6); REQUIRE(sum_range(1, 4) == 10); REQUIRE(sum_range(50, 100) == 3825); }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r15 push %r8 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x7624, %r15 nop nop nop dec %r8 mov (%r15), %edx inc %r15 lea addresses_A_ht+0xd0d8, %r9 nop nop nop inc %rcx mov $0x6162636465666768, %r15 movq %r15, %xmm0 and $0xffffffffffffffc0, %r9 movntdq %xmm0, (%r9) nop cmp %r9, %r9 lea addresses_WC_ht+0x99d0, %rsi lea addresses_D_ht+0x8d0, %rdi nop cmp %r10, %r10 mov $79, %rcx rep movsb nop nop nop nop sub $56528, %rsi lea addresses_D_ht+0x3378, %rsi lea addresses_WC_ht+0x10550, %rdi clflush (%rsi) clflush (%rdi) nop sub $25009, %r9 mov $53, %rcx rep movsw nop nop nop inc %rdx lea addresses_D_ht+0xa750, %rdx nop inc %r9 movups (%rdx), %xmm7 vpextrq $0, %xmm7, %r10 nop nop nop nop sub %r8, %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r8 pop %r15 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r8 push %rbp // Load lea addresses_UC+0x8390, %r12 nop nop nop nop sub $55928, %r14 movups (%r12), %xmm2 vpextrq $0, %xmm2, %r8 nop nop nop nop nop cmp $1217, %rbp // Load lea addresses_UC+0x1f8f2, %r12 nop nop nop nop and %r11, %r11 mov (%r12), %r14d nop nop nop nop nop cmp $13892, %r11 // Faulty Load lea addresses_US+0x11150, %r8 sub $46084, %r11 movb (%r8), %r12b lea oracles, %rbp and $0xff, %r12 shlq $12, %r12 mov (%rbp,%r12,1), %r12 pop %rbp pop %r8 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC', 'AVXalign': True, 'size': 4, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 2}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': True, 'same': False, 'congruent': 2}} {'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}} {'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 8}, 'OP': 'LOAD'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
def main(en:bool, a0:i8<4>, b0:i8<4>, a1:i8<4>, b1:i8<4>, a2:i8<4>, b2:i8<4>, a3:i8<4>, b3:i8<4>, a4:i8<4>, b4:i8<4>, a5:i8<4>, b5:i8<4>, a6:i8<4>, b6:i8<4>, a7:i8<4>, b7:i8<4>, a8:i8<4>, b8:i8<4>, a9:i8<4>, b9:i8<4>, a10:i8<4>, b10:i8<4>, a11:i8<4>, b11:i8<4>, a12:i8<4>, b12:i8<4>, a13:i8<4>, b13:i8<4>, a14:i8<4>, b14:i8<4>, a15:i8<4>, b15:i8<4>) -> (y0:i8<4>, y1:i8<4>, y2:i8<4>, y3:i8<4>, y4:i8<4>, y5:i8<4>, y6:i8<4>, y7:i8<4>, y8:i8<4>, y9:i8<4>, y10:i8<4>, y11:i8<4>, y12:i8<4>, y13:i8<4>, y14:i8<4>, y15:i8<4>) { y0:i8<4> = daddrega_i8v4(a0, b0, en, en, en) @dsp(??, ??); y1:i8<4> = daddrega_i8v4(a1, b1, en, en, en) @dsp(??, ??); y2:i8<4> = daddrega_i8v4(a2, b2, en, en, en) @dsp(??, ??); y3:i8<4> = daddrega_i8v4(a3, b3, en, en, en) @dsp(??, ??); y4:i8<4> = daddrega_i8v4(a4, b4, en, en, en) @dsp(??, ??); y5:i8<4> = daddrega_i8v4(a5, b5, en, en, en) @dsp(??, ??); y6:i8<4> = daddrega_i8v4(a6, b6, en, en, en) @dsp(??, ??); y7:i8<4> = daddrega_i8v4(a7, b7, en, en, en) @dsp(??, ??); y8:i8<4> = daddrega_i8v4(a8, b8, en, en, en) @dsp(??, ??); y9:i8<4> = daddrega_i8v4(a9, b9, en, en, en) @dsp(??, ??); y10:i8<4> = daddrega_i8v4(a10, b10, en, en, en) @dsp(??, ??); y11:i8<4> = daddrega_i8v4(a11, b11, en, en, en) @dsp(??, ??); y12:i8<4> = daddrega_i8v4(a12, b12, en, en, en) @dsp(??, ??); y13:i8<4> = daddrega_i8v4(a13, b13, en, en, en) @dsp(??, ??); y14:i8<4> = daddrega_i8v4(a14, b14, en, en, en) @dsp(??, ??); y15:i8<4> = daddrega_i8v4(a15, b15, en, en, en) @dsp(??, ??); }
/* * Copyright (c) 2015 - Adjacent Link LLC, Bridgewater, New Jersey * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Adjacent Link LLC 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 "txslotinfosformatter.h" EMANE::Models::TDMA::TxSlotInfosFormatter:: TxSlotInfosFormatter(const TxSlotInfos & infos): infos_(infos) {} EMANE::Strings EMANE::Models::TDMA::TxSlotInfosFormatter::operator()() const { Strings strings; for(const auto & info : infos_) { strings.push_back(std::to_string(info.u64AbsoluteSlotIndex_) + "," + std::to_string(info.u32RelativeFrameIndex_) + "," + std::to_string(info.u32RelativeSlotIndex_)); } return strings; }
; A076510: Expansion of 3*(1+2*x+6 x^2)/(1-24*x^3). ; 3,6,18,72,144,432,1728,3456,10368,41472,82944,248832,995328,1990656,5971968,23887872,47775744,143327232,573308928,1146617856,3439853568,13759414272,27518828544,82556485632,330225942528,660451885056 mov $1,1 mov $2,1 lpb $0 sub $0,1 add $2,1 mul $1,$2 dif $2,4 lpe mul $1,3 mov $0,$1
; A091054: Expansion of (1 - 5*x - 2*x^2) / ((1 - x)*(1 + 2*x)*(1 - 6*x)). ; Submitted by Jamie Morken(s3) ; 1,0,6,18,138,762,4698,27930,168090,1007514,6047130,36278682,217680282,1306065306,7836424602,47018482074,282111023514,1692665878938,10155995797914,60935973738906,365615844530586,2193695062989210,13162170386323866,78973022301165978,473838133840550298,2843028802976192922,17058172817991375258,102349036907679816090,614094221446615767450,3684565328678620862874,22107391972073872660890,132644351832438940998042,795866110994642235922842,4775196665967836235667866,28651179995807051773745562 mov $3,2 lpb $0 sub $0,1 mov $2,$1 add $3,$1 mov $1,$3 mul $1,2 sub $1,2 mul $1,2 mul $2,3 mov $3,$2 lpe mov $0,$3 div $0,2
/** * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * The version of the OpenAPI document: 1.0.0 * * NOTE: This class is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ #include "CppRestPetstoreClient/model/Order.h" namespace org { namespace openapitools { namespace client { namespace model { Order::Order() { m_Id = 0L; m_IdIsSet = false; m_PetId = 0L; m_PetIdIsSet = false; m_Quantity = 0; m_QuantityIsSet = false; m_ShipDate = utility::datetime(); m_ShipDateIsSet = false; m_Status = utility::conversions::to_string_t(""); m_StatusIsSet = false; m_Complete = false; m_CompleteIsSet = false; } Order::~Order() { } void Order::validate() { // TODO: implement validation } web::json::value Order::toJson() const { web::json::value val = web::json::value::object(); if(m_IdIsSet) { val[utility::conversions::to_string_t(U("id"))] = ModelBase::toJson(m_Id); } if(m_PetIdIsSet) { val[utility::conversions::to_string_t(U("petId"))] = ModelBase::toJson(m_PetId); } if(m_QuantityIsSet) { val[utility::conversions::to_string_t(U("quantity"))] = ModelBase::toJson(m_Quantity); } if(m_ShipDateIsSet) { val[utility::conversions::to_string_t(U("shipDate"))] = ModelBase::toJson(m_ShipDate); } if(m_StatusIsSet) { val[utility::conversions::to_string_t(U("status"))] = ModelBase::toJson(m_Status); } if(m_CompleteIsSet) { val[utility::conversions::to_string_t(U("complete"))] = ModelBase::toJson(m_Complete); } return val; } bool Order::fromJson(const web::json::value& val) { bool ok = true; if(val.has_field(utility::conversions::to_string_t(U("id")))) { const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id"))); if(!fieldValue.is_null()) { int64_t refVal_setId; ok &= ModelBase::fromJson(fieldValue, refVal_setId); setId(refVal_setId); } } if(val.has_field(utility::conversions::to_string_t(U("petId")))) { const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("petId"))); if(!fieldValue.is_null()) { int64_t refVal_setPetId; ok &= ModelBase::fromJson(fieldValue, refVal_setPetId); setPetId(refVal_setPetId); } } if(val.has_field(utility::conversions::to_string_t(U("quantity")))) { const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("quantity"))); if(!fieldValue.is_null()) { int32_t refVal_setQuantity; ok &= ModelBase::fromJson(fieldValue, refVal_setQuantity); setQuantity(refVal_setQuantity); } } if(val.has_field(utility::conversions::to_string_t(U("shipDate")))) { const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("shipDate"))); if(!fieldValue.is_null()) { utility::datetime refVal_setShipDate; ok &= ModelBase::fromJson(fieldValue, refVal_setShipDate); setShipDate(refVal_setShipDate); } } if(val.has_field(utility::conversions::to_string_t(U("status")))) { const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("status"))); if(!fieldValue.is_null()) { utility::string_t refVal_setStatus; ok &= ModelBase::fromJson(fieldValue, refVal_setStatus); setStatus(refVal_setStatus); } } if(val.has_field(utility::conversions::to_string_t(U("complete")))) { const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("complete"))); if(!fieldValue.is_null()) { bool refVal_setComplete; ok &= ModelBase::fromJson(fieldValue, refVal_setComplete); setComplete(refVal_setComplete); } } return ok; } void Order::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const { utility::string_t namePrefix = prefix; if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) { namePrefix += utility::conversions::to_string_t(U(".")); } if(m_IdIsSet) { multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id)); } if(m_PetIdIsSet) { multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("petId")), m_PetId)); } if(m_QuantityIsSet) { multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("quantity")), m_Quantity)); } if(m_ShipDateIsSet) { multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("shipDate")), m_ShipDate)); } if(m_StatusIsSet) { multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("status")), m_Status)); } if(m_CompleteIsSet) { multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("complete")), m_Complete)); } } bool Order::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) { bool ok = true; utility::string_t namePrefix = prefix; if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) { namePrefix += utility::conversions::to_string_t(U(".")); } if(multipart->hasContent(utility::conversions::to_string_t(U("id")))) { int64_t refVal_setId; ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId ); setId(refVal_setId); } if(multipart->hasContent(utility::conversions::to_string_t(U("petId")))) { int64_t refVal_setPetId; ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("petId"))), refVal_setPetId ); setPetId(refVal_setPetId); } if(multipart->hasContent(utility::conversions::to_string_t(U("quantity")))) { int32_t refVal_setQuantity; ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("quantity"))), refVal_setQuantity ); setQuantity(refVal_setQuantity); } if(multipart->hasContent(utility::conversions::to_string_t(U("shipDate")))) { utility::datetime refVal_setShipDate; ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("shipDate"))), refVal_setShipDate ); setShipDate(refVal_setShipDate); } if(multipart->hasContent(utility::conversions::to_string_t(U("status")))) { utility::string_t refVal_setStatus; ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("status"))), refVal_setStatus ); setStatus(refVal_setStatus); } if(multipart->hasContent(utility::conversions::to_string_t(U("complete")))) { bool refVal_setComplete; ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("complete"))), refVal_setComplete ); setComplete(refVal_setComplete); } return ok; } int64_t Order::getId() const { return m_Id; } void Order::setId(int64_t value) { m_Id = value; m_IdIsSet = true; } bool Order::idIsSet() const { return m_IdIsSet; } void Order::unsetId() { m_IdIsSet = false; } int64_t Order::getPetId() const { return m_PetId; } void Order::setPetId(int64_t value) { m_PetId = value; m_PetIdIsSet = true; } bool Order::petIdIsSet() const { return m_PetIdIsSet; } void Order::unsetPetId() { m_PetIdIsSet = false; } int32_t Order::getQuantity() const { return m_Quantity; } void Order::setQuantity(int32_t value) { m_Quantity = value; m_QuantityIsSet = true; } bool Order::quantityIsSet() const { return m_QuantityIsSet; } void Order::unsetQuantity() { m_QuantityIsSet = false; } utility::datetime Order::getShipDate() const { return m_ShipDate; } void Order::setShipDate(const utility::datetime& value) { m_ShipDate = value; m_ShipDateIsSet = true; } bool Order::shipDateIsSet() const { return m_ShipDateIsSet; } void Order::unsetShipDate() { m_ShipDateIsSet = false; } utility::string_t Order::getStatus() const { return m_Status; } void Order::setStatus(const utility::string_t& value) { m_Status = value; m_StatusIsSet = true; } bool Order::statusIsSet() const { return m_StatusIsSet; } void Order::unsetStatus() { m_StatusIsSet = false; } bool Order::isComplete() const { return m_Complete; } void Order::setComplete(bool value) { m_Complete = value; m_CompleteIsSet = true; } bool Order::completeIsSet() const { return m_CompleteIsSet; } void Order::unsetComplete() { m_CompleteIsSet = false; } } } } }
BITS 32 ;TEST_FILE_META_BEGIN ;TEST_TYPE=TEST_F ;TEST_IGNOREFLAGS=FLAG_OF|FLAG_SF|FLAG_ZF|FLAG_AF|FLAG_PF|FLAG_CF ;TEST_FILE_META_END ; allocate 16 byte aligned stack space for the packed values ;TEST_BEGIN_RECORDING lea ecx, [esp-0x20] and ecx, 0xfffffff0 ; load 128 bit value into xmm0 mov DWORD [ecx], 0x82345678 mov DWORD [ecx+4], 0x155785f5 mov DWORD [ecx+8], 0xdeadbeef mov DWORD [ecx+12], 0x1f311c47 movaps xmm0, [ecx] pmovzxdq xmm0, [ecx] mov ecx, 0 ;TEST_END_RECORDING cvtsi2sd xmm0, ecx
.data msg1:.asciiz"Enter Number 1 " msg2:.asciiz"Enter Number 2 " msg3:.asciiz"The Sum Is: " .text li $v0,4 la $a0,msg1 syscall li $v0,5 syscall move $t0,$v0 li $v0,4 la $a0,msg2 syscall li $v0,5 syscall move $t1,$v0 li $v0,4 la $a0,msg3 syscall add $t2,$t1,$t0 li $v0,1 move $a0,$t2 syscall
; A059155: A hierarchical sequence (S(W'2{3}c) - see A059126). ; 12,120,1008,8160,65472,524160,4194048,33553920,268434432,2147481600,17179865088,137438945280,1099511611392,8796092989440,70368744112128,562949953290240,4503599627108352,36028797018439680,288230376150663168,2305843009211596800,18446744073705357312,147573952589668024320,1180591620717394526208,9444732965739256872960,75557863725914256310272,604462909807314453135360,4835703278458516430389248,38685626227668133053726720,309485009821345067651039232,2475880078570760547650764800 add $0,1 mov $1,2 pow $1,$0 add $1,1 bin $1,3 mul $1,12 mov $0,$1
//////////////////////////////////////////////////////////////////////////////// //! \file Attributes.hpp //! \brief The Attributes class declaration. //! \author Chris Oldwood // Check for previous inclusion #ifndef XML_ATTRIBUTES_HPP #define XML_ATTRIBUTES_HPP #if _MSC_VER > 1000 #pragma once #endif #include "Attribute.hpp" #include <vector> namespace XML { //////////////////////////////////////////////////////////////////////////////// //! The collection of attributes for a node. class Attributes { //! The underlying container type. typedef std::vector<AttributePtr> Container; public: //! Default constructor. Attributes(); //! Construction with a single attribute. Attributes(AttributePtr attribute); //! Destructor. ~Attributes(); // // Types. // //! The iterator type. typedef Container::const_iterator const_iterator; //! The const iterator type. typedef Container::iterator iterator; // // Properties. // //! Query if the collection is empty. bool isEmpty() const; //! Query how many attributes there are. size_t count() const; //! Get the start iterator for the collection. const_iterator begin() const; //! Get the end iterator for the collection. const_iterator end() const; //! Get the start iterator for the collection. iterator begin(); //! Get the end iterator for the collection. iterator end(); // // Methods. // //! Clear the set of attributes. void clear(); //! Set an attribute. void set(const AttributePtr& attribute); //! Set an attribute from the name/value pair. void set(const tstring& name, const tstring& value); //! Find an attribute by its name. AttributePtr find(const tstring& name) const; //! Get an attribute by its name or throw if not found. AttributePtr get(const tstring& name) const; // throw(InvalidArgException) //! Get the value for an attribute by its name or throw if not found. const tstring& getValue(const tstring& name) const; // throw(InvalidArgException) private: // // Members. // Container m_attributes; //!< The underlying container. }; //////////////////////////////////////////////////////////////////////////////// //! Query if the collection is empty. inline bool Attributes::isEmpty() const { return m_attributes.empty(); } //////////////////////////////////////////////////////////////////////////////// //! Query how many attributes there are. inline size_t Attributes::count() const { return m_attributes.size(); } //////////////////////////////////////////////////////////////////////////////// //! Get the start iterator for the collection. inline Attributes::const_iterator Attributes::begin() const { return m_attributes.begin(); } //////////////////////////////////////////////////////////////////////////////// //! Get the end iterator for the collection. inline Attributes::const_iterator Attributes::end() const { return m_attributes.end(); } //////////////////////////////////////////////////////////////////////////////// //! Get the start iterator for the collection. inline Attributes::iterator Attributes::begin() { return m_attributes.begin(); } //////////////////////////////////////////////////////////////////////////////// //! Get the end iterator for the collection. inline Attributes::iterator Attributes::end() { return m_attributes.end(); } //namespace XML } #endif // XML_ATTRIBUTES_HPP
; A107684: Union of sequences 2^k-1, 2^k and 2^k+1. ; 0,1,2,3,4,5,7,8,9,15,16,17,31,32,33,63,64,65,127,128,129,255,256,257,511,512,513,1023,1024,1025,2047,2048,2049,4095,4096,4097,8191,8192,8193,16383,16384,16385,32767,32768,32769,65535,65536,65537,131071 mov $2,$0 lpb $0 trn $1,$2 add $0,$1 add $1,$0 sub $2,3 mov $0,$2 trn $0,2 lpe mov $0,$1
;//////////////////////////////////////////////////////////////////////////////////////////////////////// ;// Part of Injectable Generic Camera System ;// Copyright(c) 2017, Frans Bouma ;// All rights reserved. ;// https://github.com/FransBouma/InjectableGenericCameraSystem ;// ;// 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. ;// ;// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE ;// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;//////////////////////////////////////////////////////////////////////////////////////////////////////// ;--------------------------------------------------------------- ; Game specific asm file to intercept execution flow to obtain addresses, prevent writes etc. ;--------------------------------------------------------------- .model flat,C .stack 4096 ;--------------------------------------------------------------- ; Public definitions so the linker knows which names are present in this file PUBLIC cameraStructInterceptor PUBLIC cameraWrite1Interceptor PUBLIC borderInterceptor PUBLIC fovReadInterceptor ;--------------------------------------------------------------- ;--------------------------------------------------------------- ; Externs which are used and set by the system. Read / write these ; values in asm to communicate with the system EXTERN g_cameraEnabled: byte EXTERN g_cameraStructAddress: dword EXTERN g_fovConstructAddress: dword ;--------------------------------------------------------------- ;--------------------------------------------------------------- ; Own externs, defined in InterceptorHelper.cpp EXTERN _cameraStructInterceptionContinue: dword EXTERN _cameraWrite1InterceptionContinue: dword EXTERN _borderInterceptionContinue: dword EXTERN _fovReadInterceptionContinue: dword .data .code bordervalue dd 0.0 cameraStructInterceptor PROC ;UnityPlayer.dll+923EF - 0F10 00 - movups xmm0,[eax] ;UnityPlayer.dll+923F2 - 0FC2 C1 04 - cmpps xmm0,xmm104 { 4 } ;UnityPlayer.dll+923F6 - 0F11 08 - movups [eax],xmm1 <<<intercept here ;UnityPlayer.dll+923F9 - 0F50 C0 - movmskps eax,xmm0 ;UnityPlayer.dll+923FC - A8 07 - test al,07 { 7 } <<<return here cmp esi, 00000005 je correctaddress originalcode: movups [eax],xmm1 movmskps eax,xmm0 jmp exit correctaddress: mov [g_cameraStructAddress], eax cmp byte ptr [g_cameraEnabled], 1 je writeskip movups [eax],xmm1 writeskip: movmskps eax,xmm0 exit: jmp dword ptr [_cameraStructInterceptionContinue] ; jmp back into the original game code, which is the location after the original statements above. cameraStructInterceptor ENDP cameraWrite1Interceptor PROC ;UnityPlayer.dll+929FB - 0F55 0D 508BF90F - andnps xmm1,[UnityPlayer.dll+EA8B50] { (0) } ;UnityPlayer.dll+92A02 - 0F56 D1 - orps xmm2,xmm1 ;UnityPlayer.dll+92A05 - 0FC2 C2 04 - cmpps xmm0,xmm204 { 4 } ;UnityPlayer.dll+92A09 - 0F11 51 10 - movups [ecx+10],xmm2 <<inject here ;UnityPlayer.dll+92A0D - 0F50 C0 - movmskps eax,xmm0 ;UnityPlayer.dll+92A10 - 85 C0 - test eax,eax <<return here cmp ecx, [g_cameraStructAddress] je correctcall originalcode: movups [ecx+10h],xmm2 movmskps eax,xmm0 jmp exit correctcall: cmp byte ptr [g_cameraEnabled], 1 je quaternionskip movups [ecx+10h],xmm2 quaternionskip: movmskps eax,xmm0 exit: jmp dword ptr [_cameraWrite1InterceptionContinue] ; jmp back into the original game code, which is the location after the original statements above. cameraWrite1Interceptor ENDP fovReadInterceptor PROC ;UnityPlayer.dll"+4E5D01: F3 0F 11 45 FC - movss [ebp-04],xmm0 ;UnityPlayer.dll"+4E5D06: D9 45 FC - fld dword ptr [ebp-04] ;UnityPlayer.dll"+4E5D09: F3 0F 11 86 3C 01 00 00 - movss [esi+0000013C],xmm0 ;UnityPlayer.dll"+4E5D11: 5E - pop esi ;UnityPlayer.dll"+4E5D12: 8B E5 - mov esp,ebp ;UnityPlayer.dll"+4E5D14: 5D - pop ebp ;UnityPlayer.dll"+4E5D15: C3 - ret ;UnityPlayer.dll"+4E5D16: F3 0F 10 86 3C 01 00 00 - movss xmm0,[esi+0000013C] <<intercept here ;UnityPlayer.dll"+4E5D1E: F3 0F 11 45 FC - movss [ebp-04],xmm0 <<return here ;UnityPlayer.dll"+4E5D23: D9 45 FC - fld dword ptr [ebp-04] ;UnityPlayer.dll"+4E5D26: 5E - pop esi ;UnityPlayer.dll"+4E5D27: 8B E5 - mov esp,ebp ;UnityPlayer.dll"+4E5D29: 5D - pop ebp mov [g_fovConstructAddress],esi movss xmm0, dword ptr [esi+0000013Ch] jmp dword ptr [_fovReadInterceptionContinue] fovReadInterceptor ENDP borderInterceptor PROC ;UnityPlayer.dll+68DFF6 - 56 - push esi ;UnityPlayer.dll+68DFF7 - 8B 75 08 - mov esi,[ebp+08] ;UnityPlayer.dll+68DFFA - 8B CE - mov ecx,esi ;UnityPlayer.dll+68DFFC - F3 0F10 86 A0 00 00 00 - movss xmm0,[esi+000000A0] <<<intercept here ;UnityPlayer.dll+68E004 - FF 05 14223710 - inc [UnityPlayer.dll+10C2214] { (0) } <<<return here ;UnityPlayer.dll+68E00A - 57 - push edi ;UnityPlayer.dll+68E00B - 8D BE 9C000000 - lea edi,[esi+0000009C] ;UnityPlayer.dll+68E011 - F3 0F11 45 FC - movss [ebp-04],xmm0 cmp byte ptr [g_cameraEnabled], 1 je borderremove originalcode: movss xmm0, dword ptr [esi+000000A0h] jmp exit borderremove: movss xmm0, [bordervalue] exit: jmp dword ptr [_borderInterceptionContinue] borderInterceptor ENDP END
; A298031: Coordination sequence of Dual(3.4.6.4) tiling with respect to a tetravalent node. ; 1,4,10,16,30,36,48,54,66,72,84,90,102,108,120,126,138,144,156,162,174,180,192,198,210,216,228,234,246,252,264,270,282,288,300,306,318,324,336,342,354,360,372,378,390,396,408,414,426,432,444,450,462,468,480,486,498,504,516,522,534,540,552,558,570,576,588,594,606,612,624,630,642,648,660,666,678,684,696,702,714,720,732,738,750,756,768,774,786,792,804,810,822,828,840,846,858,864,876,882 mov $3,$0 mov $4,$0 sub $0,3 mul $3,2 mov $1,$3 mov $2,2 lpb $0 sub $0,1 trn $0,1 trn $2,1 add $1,$2 add $1,3 lpe mul $1,2 trn $1,3 lpb $4 add $1,2 sub $4,1 lpe add $1,1 mov $0,$1
#include "ClusterProviderStep.h" using namespace arangodb::graph; namespace arangodb::graph { auto operator<<(std::ostream& out, ClusterProviderStep const& step) -> std::ostream& { out << step._vertex.getID(); return out; } } // namespace arangodb::graph ClusterProviderStep::ClusterProviderStep(const VertexType& v) : _vertex(v), _edge(), _fetched(false) {} ClusterProviderStep::ClusterProviderStep(const VertexType& v, const EdgeType& edge, size_t prev) : BaseStep(prev), _vertex(v), _edge(edge), _fetched(false) {} ClusterProviderStep::ClusterProviderStep(VertexType v, EdgeType edge, size_t prev, bool fetched) : BaseStep(prev), _vertex(std::move(v)), _edge(std::move(edge)), _fetched(fetched) {} ClusterProviderStep::~ClusterProviderStep() = default; VertexType const& ClusterProviderStep::Vertex::getID() const { return _vertex; } ClusterProviderStep::EdgeType const& ClusterProviderStep::Edge::getID() const { return _edge; } bool ClusterProviderStep::Edge::isValid() const { return !_edge.empty(); }; bool ClusterProviderStep::isResponsible(transaction::Methods* trx) { return true; }
; A077265: Number of cycles in the n-th order prism graph. ; 14,28,52,94,170,312,584,1114,2158,4228,8348,16566,32978,65776,131344,262450,524630,1048956,2097572,4194766,8389114,16777768,33555032,67109514,134218430,268436212,536871724,1073742694,2147484578,4294968288,8589935648,17179870306 add $0,2 mov $1,2 lpb $0 sub $1,$2 add $1,$0 add $2,$0 sub $0,1 mul $1,2 lpe
; A055217: a(n) = sum of the first n coefficients of (1+x+x^2)^n. ; Submitted by Jon Maiga ; 1,3,10,31,96,294,897,2727,8272,25048,75747,228826,690691,2083371,6280650,18925047,57002616,171633840,516632307,1554702516,4677501237,14069962041,42314975352,127240600050,382555886571,1150026301089,3456763664392,10389276050527,31221850867032,93819553163854,281898401713633,846952848390039,2544460663597368,7643713441711560,22960811338991307,68967751709641564,207148868505726877,622154460094492809,1868505542425687240,5611414120892598172,16851289618108289013,50603189798808294039,151952386370043296934 mov $1,1 mov $2,$0 mov $3,$0 lpb $2 mov $0,$3 sub $2,1 sub $0,$2 seq $0,5043 ; Riordan numbers: a(n) = (n-1)*(2*a(n-1) + 3*a(n-2))/(n+1). sub $0,$1 mul $1,4 add $1,$0 lpe mov $0,$1
; A067866: Numbers n such that n and 2^n end with the same three digits. ; 736,1736,2736,3736,4736,5736,6736,7736,8736,9736,10736,11736,12736,13736,14736,15736,16736,17736,18736,19736,20736,21736,22736,23736,24736,25736,26736,27736,28736,29736,30736,31736,32736,33736,34736 mul $0,1000 add $0,736
org 100h FOR_RED=$4 FOR_BLUE=$1 FOR_GREEN=$2 BACK_BLUE=$10 BACK_GREEN=$20 BACK_RED=$40 BLINK=$80 INTENSITY=$8 mov ah,FOR_BLUE call BatBox_ScreenInit mov ah,09 mov dx,lpEnter int 21h mov cx,30 Print: mov si,lpMsg2 mov [iAttr],cl call BatBox_Puts loop Print mov ch,10 Print1: mov si,lpMsg mov [iAttr],ch call BatBox_Puts loop Print1 mov ax,4C00h int 21h lpEnter db $0d,$0a, $0d,$0a, $0d,$0a, $0d,$0a, $0d,$0a, $0d,$0a, '$' lpMsg db "hello world!",$0d,0 lpMsg2 db "bye world!",$0d,0 ; args : ax -> text attribute BatBox_ScreenInit: mov [lpPointer],0h mov [iLine],0h mov [iAttr],ah mov ax,03h int 10h ret BatBox_Puts: push $b800 pop es mov di,[lpPointer] __Puts_Loop: cmp byte [ds:si],$0d jnz __Puts_Next inc [iLine] mov al,160 mul byte [iLine] mov di,ax inc si __Puts_Next: cmp byte [ds:si],$0 jz __Puts_Loop_End cmp di,25*80*2 jb __Puts_Not_Zero xor di,di __Puts_Not_Zero: movsb mov al,[iAttr] ; bgri bgr blink stosb jmp __Puts_Loop __Puts_Loop_End: mov [lpPointer],di ret BatBox_Cls: lpPointer dw ? iLine db ? iAttr db ?
; Define a border V2.01  1998 Tony Tebby ; ; 2003-10-06 2.01 Fixed extended colour calls with width=0. (MK) ; ; A border is put around the inside edge of the hit area, and the active ; area shrunk appropriately. ; ; Registers: ; Entry Exit ; D1 colour ; D2 width ; A0 cdb ; section con include 'dev8_keys_err' include 'dev8_keys_con' xdef cn_defbd xdef cn_borp xdef cn_bort xdef cn_born xdef cn_cksize xdef cn_cksize_p xdef cn_cksize_s xref cn_ql_bcolr xref cn_pal_bmcolr xref cn_pal_bccolr xref cn_24b_bmcolr xref cn_24b_bccolr xref cn_nat_bmcolr xref cn_nat_bccolr xref cn_bcnat xref cn_fblock cn_defbd move.b d1,d3 jsr cn_ql_bcolr ; colour moveq #0,d6 move.b d1,d6 ; QL compatibility bra.s cnb_set cn_borp lea cn_pal_bmcolr,a4 ; palette map to border colour lea cn_pal_bccolr,a5 bra.s cnb_ext_colr cn_bort lea cn_24b_bmcolr,a4 ; true colour to border colour lea cn_24b_bccolr,a5 bra.s cnb_ext_colr cn_born lea cn_nat_bmcolr,a4 ; native mode to border colour lea cn_nat_bccolr,a5 cnb_ext_colr move.l d1,d3 ; this is the colour tst.l d2 ; main colour or contrast bpl.s cnb_ext_contrast jsr (a4) ; set border main colour moveq #0,d6 ; no stipple bra.s cnb_setx cnb_ipar moveq #err.ipar,d0 rts cnb_ext_contrast move.l d2,d6 ; stipple swap d6 cmp.w #3,d6 bhi.s cnb_ipar move.w sd_bcolw(a0),d7 ; plain colour jsr (a5) ; set contrast colour add.b d6,d6 addq.b #1,d6 ; set arbitrary contrast colour lsl.b #5,d6 ; QL type stipple cnb_setx tst.w d2 ; for extended colour calls bpl.s cnb_set move.b d6,sd_bcolr(a0) ; set colour move.w d7,sd_bcolw(a0) moveq #0,d0 rts cnb_set cnb.reg reg d1/d2 movem.l cnb.reg,-(sp) and.w #$00ff,d2 ; byte only border width move.b d6,sd_bcolr(a0) ; set colour move.w d7,sd_bcolw(a0) move.w sd_borwd(a0),d5 cmp.w d5,d2 ; has border changed? beq.s cnb_sbwd ; no clr.l sd_xpos(a0) ; yes, set cursor to top left clr.b sd_nlsta(a0) ; clear pending newline bclr #sd..gmod,sd_cattr(a0) ; ... and graphics mode cnb_sbwd move.w d2,sd_borwd(a0) ; set border width movem.l sd_xmin(a0),d3/d4 ; get window area size/origin exg d3,d4 tst.w d5 ; and remove old border beq.s cnb_adj sub.w d5,d4 add.w d5,d5 add.w d5,d3 swap d3 swap d4 sub.w d5,d4 add.w d5,d5 add.w d5,d3 swap d3 swap d4 cnb_adj move.l d2,d5 move.l d3,d1 ; size in d1/d2 move.l d4,d2 ; we'll need the size again move.w d5,d0 ; smashable border width add.w d0,d4 ; possible new Y origin add.w d0,d0 ; this much... sub.w d0,d3 ; ...off height bmi.s cnb_exip ; ...oops swap d4 add.w d0,d4 ; new x origin swap d4 add.w d0,d0 ; this much... swap d3 ; ...off... sub.w d0,d3 ; ...width bmi.s cnb_exip ; ...oops swap d3 move.l d3,sd_xsize(a0) ; new descriptor is OK move.l d4,sd_xmin(a0) ; moveq #0,d0 cmp.b #$80,sd_bcolr(a0) ; transparent border? beq.s cnb_size ; yes, don't draw anything tst.b d5 ; any border? beq.s cnb_size ; ... no ; ; ; Having set up the parameters, we can draw the border, and modify ; the active area. ; jsr cn_bcnat ; set colours for block move.w d5,d1 ; narrow block at top bsr.s cnb_block ; fill it add.w d5,d2 ; top of window add.w sd_ysize(a0),d2 ; bottom of window bsr.s cnb_block ; do another ; add.w d5,d5 ; this wide move.w d5,d1 swap d1 move.w sd_ysize(a0),d1 ; tall blocks now move.w sd_ymin(a0),d2 ; at top left bsr.s cnb_block swap d2 add.w d5,d2 ; left of window add.w sd_xsize(a0),d2 ; right of window swap d2 bsr.s cnb_block ; cnb_size bsr.s cn_cksize moveq #0,d0 cnb_exit movem.l (sp)+,cnb.reg rts cnb_block move.l sd_scrb(a0),a1 ; point to area move.w sd_linel(a0),a2 ; and get its row increment movem.l d1-d7,-(sp) jsr cn_fblock movem.l (sp)+,d1-d7 rts ; cnb_exip moveq #err.orng,d0 bra.s cnb_exit ;+++ ; set x,y increments (d2) and check window size ; ; d0 arbitrary ; d2 p x,y increments ; ; returns LO is window too small ;--- cn_cksize_s move.l d2,sd_xinc(a0) ; increments ;+++ ; check window size against increments (all except d0,d2 preserved) ; ; d0 arbitrary ; ; returns LO is window too small ;--- cn_cksize_p ;+++ ; check window size against d2 ; ; d0 arbitrary ; d2 r x,y increments ; ; returns LO is window too small ;--- cn_cksize move.l sd_xinc(a0),d2 ; increments ;+++ ; check window size against d2 ; ; d0 arbitrary ; d2 c p x,y increments ; ; returns LO is window too small ;--- cn_ckszd2 move.l sd_xsize(a0),d0 ; xsize cmp.w d2,d0 ; high enough? blo.s cnb_setsf cmp.l d2,d0 cnb_setsf slo sd_sflag(a0) ; set too small flag rts end
; unsigned char esx_dos_catalog(struct esx_cat *cat) INCLUDE "config_private.inc" SECTION code_esxdos PUBLIC asm_esx_dos_catalog PUBLIC l_asm_esx_dos_catalog EXTERN error_znc, __esxdos_error_mc IF __ZXNEXT asm_esx_dos_catalog: ; enter : hl = struct esx_cat *cat (some members initialized) ; note that this structure must be in main memory ; ; exit : success ; ; hl = number of catalog entries filled in (0 if cat is done) ; carry reset ; ; fail ; ; hl = -1 ; carry set, errno set ; ; uses : all except af', iy scf ; indicate this is the first catalog call l_asm_esx_dos_catalog: ld c,(hl) ; c = filter inc hl ld e,(hl) inc hl ld d,(hl) ; de = filename inc hl push hl ; save & cat.dir_handle inc hl inc hl ld a,(hl) ; a = completed_sz inc hl ld b,(hl) ; b = n+1 >= 2 inc hl ex de,hl ; hl = filename, de = buffer jr c, first_call ; if this is a first call to dos_catalog next_call: inc a cp b jp nz, error_znc - 1 ; indicate catalog is finished push bc push de push hl ex de,hl ; hl = cat[] ld d,b ; d = cat_sz dec d ld e,13 ; e = size of cat entry mul de ex de,hl add hl,de ; hl = last cat entry, de = first cat entry ld bc,13 ldir rejoin: pop hl pop de pop bc catalog: exx ld de,__NEXTOS_DOS_CATALOG ld c,7 rst __ESX_RST_SYS defb __ESX_M_P3DOS pop de ; de = & cat.dir_handle jp nc, __esxdos_error_mc ; if error ex de,hl ld (hl),e inc hl ld (hl),d ; write directory handle inc hl dec b ; change to number of entries written ld (hl),b ; write completed sz xor a ld l,b ld h,a ; hl = number of completed entries ret first_call: push bc push de push hl ld l,e ld h,d inc de ld bc,12 ld (hl),b ldir ; zero first cat entry jr rejoin ELSE asm_esx_dos_catalog: l_asm_esx_dos_catalog: ld a,__ESX_ENONSENSE jp __esxdos_error_mc ENDIF
// Assembler: KickAssembler // Rasterbars met behulp van een interrupt service routine BasicUpstart2(start) .var scr_clear_char = ' ' .var scr_clear_color = $0f .var raster = 40 * = $0810 "start" start: jsr scr_clear lda #$00 sta $d020 sta $d021 jsr irq_init jmp * irq: asl $d019 // BEGIN kernel inc $d020 dec $d020 // wacht even ldx #$00 !l: dex bne !l- lda $d011 sta !herstel+ + 1 lda #$00 sta $d011 sta $d020 ldy #$7a ldx #$00 !l: lda colors, x cpy $d012 bne * - 3 sta $d020 sta $d021 cpx #51 beq !done+ inx iny jmp !l- !done: !herstel: lda #$00 sta $d011 // EIND kernel pla tay pla tax pla rti irq_init: sei lda #<irq sta $0314 lda #>irq sta $0315 asl $d019 lda #$7b sta $dc0d lda #$81 sta $d01a lda #$1b sta $d011 lda #raster sta $d012 cli rts scr_clear: lda #scr_clear_char ldx #0 // `wis' alle karakters door alles te vullen met spaties !l: sta $0400, x sta $0500, x sta $0600, x sta $06e8, x inx bne !l- // verander kleur van alle karakters lda #scr_clear_color ldx #0 !l: sta $d800, x sta $d900, x sta $da00, x sta $dae8, x inx bne !l- rts colors: .byte $06, $06, $06, $0e, $06, $0e .byte $0e, $06, $0e, $0e, $0e, $03 .byte $0e, $03, $03, $0e, $03, $03 .byte $03, $01, $03, $01, $01, $03 .byte $01, $01, $01, $03, $01, $01 .byte $03, $01, $03, $03, $03, $0e .byte $03, $03, $0e, $03, $0e, $0e .byte $0e, $06, $0e, $0e, $06, $0e .byte $06, $06, $06, $00, $00, $00 .byte $ff
; A061711: a(n) = n!*n^n. ; 1,1,8,162,6144,375000,33592320,4150656720,676457349120,140587147048320,36288000000000000,11388728893445164800,4270826380475341209600,1886009588552176549862400,968725766854884321342259200,572622616354851562500000000000,385957350371934133200258859008000,294238961167812617133047996116992000,251910408476122397329254951180828672000,240665057663605677243262663121634582528000,255108265612582846464000000000000000000000000,298503275489538511691223550284235482900234240000 mov $1,11 mov $2,$0 mul $2,$0 lpb $2 mul $1,$2 sub $2,$0 lpe mov $0,$1 div $0,11
OPTION DOTNAME .text$ SEGMENT ALIGN(256) 'CODE' EXTERN asm_AES_encrypt:NEAR EXTERN asm_AES_decrypt:NEAR ALIGN 64 _bsaes_encrypt8 PROC PRIVATE lea r11,QWORD PTR[$L$BS0] movdqa xmm8,XMMWORD PTR[rax] lea rax,QWORD PTR[16+rax] movdqa xmm7,XMMWORD PTR[80+r11] pxor xmm15,xmm8 pxor xmm0,xmm8 pxor xmm1,xmm8 pxor xmm2,xmm8 DB 102,68,15,56,0,255 DB 102,15,56,0,199 pxor xmm3,xmm8 pxor xmm4,xmm8 DB 102,15,56,0,207 DB 102,15,56,0,215 pxor xmm5,xmm8 pxor xmm6,xmm8 DB 102,15,56,0,223 DB 102,15,56,0,231 DB 102,15,56,0,239 DB 102,15,56,0,247 _bsaes_encrypt8_bitslice:: movdqa xmm7,XMMWORD PTR[r11] movdqa xmm8,XMMWORD PTR[16+r11] movdqa xmm9,xmm5 psrlq xmm5,1 movdqa xmm10,xmm3 psrlq xmm3,1 pxor xmm5,xmm6 pxor xmm3,xmm4 pand xmm5,xmm7 pand xmm3,xmm7 pxor xmm6,xmm5 psllq xmm5,1 pxor xmm4,xmm3 psllq xmm3,1 pxor xmm5,xmm9 pxor xmm3,xmm10 movdqa xmm9,xmm1 psrlq xmm1,1 movdqa xmm10,xmm15 psrlq xmm15,1 pxor xmm1,xmm2 pxor xmm15,xmm0 pand xmm1,xmm7 pand xmm15,xmm7 pxor xmm2,xmm1 psllq xmm1,1 pxor xmm0,xmm15 psllq xmm15,1 pxor xmm1,xmm9 pxor xmm15,xmm10 movdqa xmm7,XMMWORD PTR[32+r11] movdqa xmm9,xmm4 psrlq xmm4,2 movdqa xmm10,xmm3 psrlq xmm3,2 pxor xmm4,xmm6 pxor xmm3,xmm5 pand xmm4,xmm8 pand xmm3,xmm8 pxor xmm6,xmm4 psllq xmm4,2 pxor xmm5,xmm3 psllq xmm3,2 pxor xmm4,xmm9 pxor xmm3,xmm10 movdqa xmm9,xmm0 psrlq xmm0,2 movdqa xmm10,xmm15 psrlq xmm15,2 pxor xmm0,xmm2 pxor xmm15,xmm1 pand xmm0,xmm8 pand xmm15,xmm8 pxor xmm2,xmm0 psllq xmm0,2 pxor xmm1,xmm15 psllq xmm15,2 pxor xmm0,xmm9 pxor xmm15,xmm10 movdqa xmm9,xmm2 psrlq xmm2,4 movdqa xmm10,xmm1 psrlq xmm1,4 pxor xmm2,xmm6 pxor xmm1,xmm5 pand xmm2,xmm7 pand xmm1,xmm7 pxor xmm6,xmm2 psllq xmm2,4 pxor xmm5,xmm1 psllq xmm1,4 pxor xmm2,xmm9 pxor xmm1,xmm10 movdqa xmm9,xmm0 psrlq xmm0,4 movdqa xmm10,xmm15 psrlq xmm15,4 pxor xmm0,xmm4 pxor xmm15,xmm3 pand xmm0,xmm7 pand xmm15,xmm7 pxor xmm4,xmm0 psllq xmm0,4 pxor xmm3,xmm15 psllq xmm15,4 pxor xmm0,xmm9 pxor xmm15,xmm10 dec r10d jmp $L$enc_sbox ALIGN 16 $L$enc_loop:: pxor xmm15,XMMWORD PTR[rax] pxor xmm0,XMMWORD PTR[16+rax] pxor xmm1,XMMWORD PTR[32+rax] pxor xmm2,XMMWORD PTR[48+rax] DB 102,68,15,56,0,255 DB 102,15,56,0,199 pxor xmm3,XMMWORD PTR[64+rax] pxor xmm4,XMMWORD PTR[80+rax] DB 102,15,56,0,207 DB 102,15,56,0,215 pxor xmm5,XMMWORD PTR[96+rax] pxor xmm6,XMMWORD PTR[112+rax] DB 102,15,56,0,223 DB 102,15,56,0,231 DB 102,15,56,0,239 DB 102,15,56,0,247 lea rax,QWORD PTR[128+rax] $L$enc_sbox:: pxor xmm4,xmm5 pxor xmm1,xmm0 pxor xmm2,xmm15 pxor xmm5,xmm1 pxor xmm4,xmm15 pxor xmm5,xmm2 pxor xmm2,xmm6 pxor xmm6,xmm4 pxor xmm2,xmm3 pxor xmm3,xmm4 pxor xmm2,xmm0 pxor xmm1,xmm6 pxor xmm0,xmm4 movdqa xmm10,xmm6 movdqa xmm9,xmm0 movdqa xmm8,xmm4 movdqa xmm12,xmm1 movdqa xmm11,xmm5 pxor xmm10,xmm3 pxor xmm9,xmm1 pxor xmm8,xmm2 movdqa xmm13,xmm10 pxor xmm12,xmm3 movdqa xmm7,xmm9 pxor xmm11,xmm15 movdqa xmm14,xmm10 por xmm9,xmm8 por xmm10,xmm11 pxor xmm14,xmm7 pand xmm13,xmm11 pxor xmm11,xmm8 pand xmm7,xmm8 pand xmm14,xmm11 movdqa xmm11,xmm2 pxor xmm11,xmm15 pand xmm12,xmm11 pxor xmm10,xmm12 pxor xmm9,xmm12 movdqa xmm12,xmm6 movdqa xmm11,xmm4 pxor xmm12,xmm0 pxor xmm11,xmm5 movdqa xmm8,xmm12 pand xmm12,xmm11 por xmm8,xmm11 pxor xmm7,xmm12 pxor xmm10,xmm14 pxor xmm9,xmm13 pxor xmm8,xmm14 movdqa xmm11,xmm1 pxor xmm7,xmm13 movdqa xmm12,xmm3 pxor xmm8,xmm13 movdqa xmm13,xmm0 pand xmm11,xmm2 movdqa xmm14,xmm6 pand xmm12,xmm15 pand xmm13,xmm4 por xmm14,xmm5 pxor xmm10,xmm11 pxor xmm9,xmm12 pxor xmm8,xmm13 pxor xmm7,xmm14 movdqa xmm11,xmm10 pand xmm10,xmm8 pxor xmm11,xmm9 movdqa xmm13,xmm7 movdqa xmm14,xmm11 pxor xmm13,xmm10 pand xmm14,xmm13 movdqa xmm12,xmm8 pxor xmm14,xmm9 pxor xmm12,xmm7 pxor xmm10,xmm9 pand xmm12,xmm10 movdqa xmm9,xmm13 pxor xmm12,xmm7 pxor xmm9,xmm12 pxor xmm8,xmm12 pand xmm9,xmm7 pxor xmm13,xmm9 pxor xmm8,xmm9 pand xmm13,xmm14 pxor xmm13,xmm11 movdqa xmm11,xmm5 movdqa xmm7,xmm4 movdqa xmm9,xmm14 pxor xmm9,xmm13 pand xmm9,xmm5 pxor xmm5,xmm4 pand xmm4,xmm14 pand xmm5,xmm13 pxor xmm5,xmm4 pxor xmm4,xmm9 pxor xmm11,xmm15 pxor xmm7,xmm2 pxor xmm14,xmm12 pxor xmm13,xmm8 movdqa xmm10,xmm14 movdqa xmm9,xmm12 pxor xmm10,xmm13 pxor xmm9,xmm8 pand xmm10,xmm11 pand xmm9,xmm15 pxor xmm11,xmm7 pxor xmm15,xmm2 pand xmm7,xmm14 pand xmm2,xmm12 pand xmm11,xmm13 pand xmm15,xmm8 pxor xmm7,xmm11 pxor xmm15,xmm2 pxor xmm11,xmm10 pxor xmm2,xmm9 pxor xmm5,xmm11 pxor xmm15,xmm11 pxor xmm4,xmm7 pxor xmm2,xmm7 movdqa xmm11,xmm6 movdqa xmm7,xmm0 pxor xmm11,xmm3 pxor xmm7,xmm1 movdqa xmm10,xmm14 movdqa xmm9,xmm12 pxor xmm10,xmm13 pxor xmm9,xmm8 pand xmm10,xmm11 pand xmm9,xmm3 pxor xmm11,xmm7 pxor xmm3,xmm1 pand xmm7,xmm14 pand xmm1,xmm12 pand xmm11,xmm13 pand xmm3,xmm8 pxor xmm7,xmm11 pxor xmm3,xmm1 pxor xmm11,xmm10 pxor xmm1,xmm9 pxor xmm14,xmm12 pxor xmm13,xmm8 movdqa xmm10,xmm14 pxor xmm10,xmm13 pand xmm10,xmm6 pxor xmm6,xmm0 pand xmm0,xmm14 pand xmm6,xmm13 pxor xmm6,xmm0 pxor xmm0,xmm10 pxor xmm6,xmm11 pxor xmm3,xmm11 pxor xmm0,xmm7 pxor xmm1,xmm7 pxor xmm6,xmm15 pxor xmm0,xmm5 pxor xmm3,xmm6 pxor xmm5,xmm15 pxor xmm15,xmm0 pxor xmm0,xmm4 pxor xmm4,xmm1 pxor xmm1,xmm2 pxor xmm2,xmm4 pxor xmm3,xmm4 pxor xmm5,xmm2 dec r10d jl $L$enc_done pshufd xmm7,xmm15,093h pshufd xmm8,xmm0,093h pxor xmm15,xmm7 pshufd xmm9,xmm3,093h pxor xmm0,xmm8 pshufd xmm10,xmm5,093h pxor xmm3,xmm9 pshufd xmm11,xmm2,093h pxor xmm5,xmm10 pshufd xmm12,xmm6,093h pxor xmm2,xmm11 pshufd xmm13,xmm1,093h pxor xmm6,xmm12 pshufd xmm14,xmm4,093h pxor xmm1,xmm13 pxor xmm4,xmm14 pxor xmm8,xmm15 pxor xmm7,xmm4 pxor xmm8,xmm4 pshufd xmm15,xmm15,04Eh pxor xmm9,xmm0 pshufd xmm0,xmm0,04Eh pxor xmm12,xmm2 pxor xmm15,xmm7 pxor xmm13,xmm6 pxor xmm0,xmm8 pxor xmm11,xmm5 pshufd xmm7,xmm2,04Eh pxor xmm14,xmm1 pshufd xmm8,xmm6,04Eh pxor xmm10,xmm3 pshufd xmm2,xmm5,04Eh pxor xmm10,xmm4 pshufd xmm6,xmm4,04Eh pxor xmm11,xmm4 pshufd xmm5,xmm1,04Eh pxor xmm7,xmm11 pshufd xmm1,xmm3,04Eh pxor xmm8,xmm12 pxor xmm2,xmm10 pxor xmm6,xmm14 pxor xmm5,xmm13 movdqa xmm3,xmm7 pxor xmm1,xmm9 movdqa xmm4,xmm8 movdqa xmm7,XMMWORD PTR[48+r11] jnz $L$enc_loop movdqa xmm7,XMMWORD PTR[64+r11] jmp $L$enc_loop ALIGN 16 $L$enc_done:: movdqa xmm7,XMMWORD PTR[r11] movdqa xmm8,XMMWORD PTR[16+r11] movdqa xmm9,xmm1 psrlq xmm1,1 movdqa xmm10,xmm2 psrlq xmm2,1 pxor xmm1,xmm4 pxor xmm2,xmm6 pand xmm1,xmm7 pand xmm2,xmm7 pxor xmm4,xmm1 psllq xmm1,1 pxor xmm6,xmm2 psllq xmm2,1 pxor xmm1,xmm9 pxor xmm2,xmm10 movdqa xmm9,xmm3 psrlq xmm3,1 movdqa xmm10,xmm15 psrlq xmm15,1 pxor xmm3,xmm5 pxor xmm15,xmm0 pand xmm3,xmm7 pand xmm15,xmm7 pxor xmm5,xmm3 psllq xmm3,1 pxor xmm0,xmm15 psllq xmm15,1 pxor xmm3,xmm9 pxor xmm15,xmm10 movdqa xmm7,XMMWORD PTR[32+r11] movdqa xmm9,xmm6 psrlq xmm6,2 movdqa xmm10,xmm2 psrlq xmm2,2 pxor xmm6,xmm4 pxor xmm2,xmm1 pand xmm6,xmm8 pand xmm2,xmm8 pxor xmm4,xmm6 psllq xmm6,2 pxor xmm1,xmm2 psllq xmm2,2 pxor xmm6,xmm9 pxor xmm2,xmm10 movdqa xmm9,xmm0 psrlq xmm0,2 movdqa xmm10,xmm15 psrlq xmm15,2 pxor xmm0,xmm5 pxor xmm15,xmm3 pand xmm0,xmm8 pand xmm15,xmm8 pxor xmm5,xmm0 psllq xmm0,2 pxor xmm3,xmm15 psllq xmm15,2 pxor xmm0,xmm9 pxor xmm15,xmm10 movdqa xmm9,xmm5 psrlq xmm5,4 movdqa xmm10,xmm3 psrlq xmm3,4 pxor xmm5,xmm4 pxor xmm3,xmm1 pand xmm5,xmm7 pand xmm3,xmm7 pxor xmm4,xmm5 psllq xmm5,4 pxor xmm1,xmm3 psllq xmm3,4 pxor xmm5,xmm9 pxor xmm3,xmm10 movdqa xmm9,xmm0 psrlq xmm0,4 movdqa xmm10,xmm15 psrlq xmm15,4 pxor xmm0,xmm6 pxor xmm15,xmm2 pand xmm0,xmm7 pand xmm15,xmm7 pxor xmm6,xmm0 psllq xmm0,4 pxor xmm2,xmm15 psllq xmm15,4 pxor xmm0,xmm9 pxor xmm15,xmm10 movdqa xmm7,XMMWORD PTR[rax] pxor xmm3,xmm7 pxor xmm5,xmm7 pxor xmm2,xmm7 pxor xmm6,xmm7 pxor xmm1,xmm7 pxor xmm4,xmm7 pxor xmm15,xmm7 pxor xmm0,xmm7 DB 0F3h,0C3h ;repret _bsaes_encrypt8 ENDP ALIGN 64 _bsaes_decrypt8 PROC PRIVATE lea r11,QWORD PTR[$L$BS0] movdqa xmm8,XMMWORD PTR[rax] lea rax,QWORD PTR[16+rax] movdqa xmm7,XMMWORD PTR[((-48))+r11] pxor xmm15,xmm8 pxor xmm0,xmm8 pxor xmm1,xmm8 pxor xmm2,xmm8 DB 102,68,15,56,0,255 DB 102,15,56,0,199 pxor xmm3,xmm8 pxor xmm4,xmm8 DB 102,15,56,0,207 DB 102,15,56,0,215 pxor xmm5,xmm8 pxor xmm6,xmm8 DB 102,15,56,0,223 DB 102,15,56,0,231 DB 102,15,56,0,239 DB 102,15,56,0,247 movdqa xmm7,XMMWORD PTR[r11] movdqa xmm8,XMMWORD PTR[16+r11] movdqa xmm9,xmm5 psrlq xmm5,1 movdqa xmm10,xmm3 psrlq xmm3,1 pxor xmm5,xmm6 pxor xmm3,xmm4 pand xmm5,xmm7 pand xmm3,xmm7 pxor xmm6,xmm5 psllq xmm5,1 pxor xmm4,xmm3 psllq xmm3,1 pxor xmm5,xmm9 pxor xmm3,xmm10 movdqa xmm9,xmm1 psrlq xmm1,1 movdqa xmm10,xmm15 psrlq xmm15,1 pxor xmm1,xmm2 pxor xmm15,xmm0 pand xmm1,xmm7 pand xmm15,xmm7 pxor xmm2,xmm1 psllq xmm1,1 pxor xmm0,xmm15 psllq xmm15,1 pxor xmm1,xmm9 pxor xmm15,xmm10 movdqa xmm7,XMMWORD PTR[32+r11] movdqa xmm9,xmm4 psrlq xmm4,2 movdqa xmm10,xmm3 psrlq xmm3,2 pxor xmm4,xmm6 pxor xmm3,xmm5 pand xmm4,xmm8 pand xmm3,xmm8 pxor xmm6,xmm4 psllq xmm4,2 pxor xmm5,xmm3 psllq xmm3,2 pxor xmm4,xmm9 pxor xmm3,xmm10 movdqa xmm9,xmm0 psrlq xmm0,2 movdqa xmm10,xmm15 psrlq xmm15,2 pxor xmm0,xmm2 pxor xmm15,xmm1 pand xmm0,xmm8 pand xmm15,xmm8 pxor xmm2,xmm0 psllq xmm0,2 pxor xmm1,xmm15 psllq xmm15,2 pxor xmm0,xmm9 pxor xmm15,xmm10 movdqa xmm9,xmm2 psrlq xmm2,4 movdqa xmm10,xmm1 psrlq xmm1,4 pxor xmm2,xmm6 pxor xmm1,xmm5 pand xmm2,xmm7 pand xmm1,xmm7 pxor xmm6,xmm2 psllq xmm2,4 pxor xmm5,xmm1 psllq xmm1,4 pxor xmm2,xmm9 pxor xmm1,xmm10 movdqa xmm9,xmm0 psrlq xmm0,4 movdqa xmm10,xmm15 psrlq xmm15,4 pxor xmm0,xmm4 pxor xmm15,xmm3 pand xmm0,xmm7 pand xmm15,xmm7 pxor xmm4,xmm0 psllq xmm0,4 pxor xmm3,xmm15 psllq xmm15,4 pxor xmm0,xmm9 pxor xmm15,xmm10 dec r10d jmp $L$dec_sbox ALIGN 16 $L$dec_loop:: pxor xmm15,XMMWORD PTR[rax] pxor xmm0,XMMWORD PTR[16+rax] pxor xmm1,XMMWORD PTR[32+rax] pxor xmm2,XMMWORD PTR[48+rax] DB 102,68,15,56,0,255 DB 102,15,56,0,199 pxor xmm3,XMMWORD PTR[64+rax] pxor xmm4,XMMWORD PTR[80+rax] DB 102,15,56,0,207 DB 102,15,56,0,215 pxor xmm5,XMMWORD PTR[96+rax] pxor xmm6,XMMWORD PTR[112+rax] DB 102,15,56,0,223 DB 102,15,56,0,231 DB 102,15,56,0,239 DB 102,15,56,0,247 lea rax,QWORD PTR[128+rax] $L$dec_sbox:: pxor xmm2,xmm3 pxor xmm3,xmm6 pxor xmm1,xmm6 pxor xmm5,xmm3 pxor xmm6,xmm5 pxor xmm0,xmm6 pxor xmm15,xmm0 pxor xmm1,xmm4 pxor xmm2,xmm15 pxor xmm4,xmm15 pxor xmm0,xmm2 movdqa xmm10,xmm2 movdqa xmm9,xmm6 movdqa xmm8,xmm0 movdqa xmm12,xmm3 movdqa xmm11,xmm4 pxor xmm10,xmm15 pxor xmm9,xmm3 pxor xmm8,xmm5 movdqa xmm13,xmm10 pxor xmm12,xmm15 movdqa xmm7,xmm9 pxor xmm11,xmm1 movdqa xmm14,xmm10 por xmm9,xmm8 por xmm10,xmm11 pxor xmm14,xmm7 pand xmm13,xmm11 pxor xmm11,xmm8 pand xmm7,xmm8 pand xmm14,xmm11 movdqa xmm11,xmm5 pxor xmm11,xmm1 pand xmm12,xmm11 pxor xmm10,xmm12 pxor xmm9,xmm12 movdqa xmm12,xmm2 movdqa xmm11,xmm0 pxor xmm12,xmm6 pxor xmm11,xmm4 movdqa xmm8,xmm12 pand xmm12,xmm11 por xmm8,xmm11 pxor xmm7,xmm12 pxor xmm10,xmm14 pxor xmm9,xmm13 pxor xmm8,xmm14 movdqa xmm11,xmm3 pxor xmm7,xmm13 movdqa xmm12,xmm15 pxor xmm8,xmm13 movdqa xmm13,xmm6 pand xmm11,xmm5 movdqa xmm14,xmm2 pand xmm12,xmm1 pand xmm13,xmm0 por xmm14,xmm4 pxor xmm10,xmm11 pxor xmm9,xmm12 pxor xmm8,xmm13 pxor xmm7,xmm14 movdqa xmm11,xmm10 pand xmm10,xmm8 pxor xmm11,xmm9 movdqa xmm13,xmm7 movdqa xmm14,xmm11 pxor xmm13,xmm10 pand xmm14,xmm13 movdqa xmm12,xmm8 pxor xmm14,xmm9 pxor xmm12,xmm7 pxor xmm10,xmm9 pand xmm12,xmm10 movdqa xmm9,xmm13 pxor xmm12,xmm7 pxor xmm9,xmm12 pxor xmm8,xmm12 pand xmm9,xmm7 pxor xmm13,xmm9 pxor xmm8,xmm9 pand xmm13,xmm14 pxor xmm13,xmm11 movdqa xmm11,xmm4 movdqa xmm7,xmm0 movdqa xmm9,xmm14 pxor xmm9,xmm13 pand xmm9,xmm4 pxor xmm4,xmm0 pand xmm0,xmm14 pand xmm4,xmm13 pxor xmm4,xmm0 pxor xmm0,xmm9 pxor xmm11,xmm1 pxor xmm7,xmm5 pxor xmm14,xmm12 pxor xmm13,xmm8 movdqa xmm10,xmm14 movdqa xmm9,xmm12 pxor xmm10,xmm13 pxor xmm9,xmm8 pand xmm10,xmm11 pand xmm9,xmm1 pxor xmm11,xmm7 pxor xmm1,xmm5 pand xmm7,xmm14 pand xmm5,xmm12 pand xmm11,xmm13 pand xmm1,xmm8 pxor xmm7,xmm11 pxor xmm1,xmm5 pxor xmm11,xmm10 pxor xmm5,xmm9 pxor xmm4,xmm11 pxor xmm1,xmm11 pxor xmm0,xmm7 pxor xmm5,xmm7 movdqa xmm11,xmm2 movdqa xmm7,xmm6 pxor xmm11,xmm15 pxor xmm7,xmm3 movdqa xmm10,xmm14 movdqa xmm9,xmm12 pxor xmm10,xmm13 pxor xmm9,xmm8 pand xmm10,xmm11 pand xmm9,xmm15 pxor xmm11,xmm7 pxor xmm15,xmm3 pand xmm7,xmm14 pand xmm3,xmm12 pand xmm11,xmm13 pand xmm15,xmm8 pxor xmm7,xmm11 pxor xmm15,xmm3 pxor xmm11,xmm10 pxor xmm3,xmm9 pxor xmm14,xmm12 pxor xmm13,xmm8 movdqa xmm10,xmm14 pxor xmm10,xmm13 pand xmm10,xmm2 pxor xmm2,xmm6 pand xmm6,xmm14 pand xmm2,xmm13 pxor xmm2,xmm6 pxor xmm6,xmm10 pxor xmm2,xmm11 pxor xmm15,xmm11 pxor xmm6,xmm7 pxor xmm3,xmm7 pxor xmm0,xmm6 pxor xmm5,xmm4 pxor xmm3,xmm0 pxor xmm1,xmm6 pxor xmm4,xmm6 pxor xmm3,xmm1 pxor xmm6,xmm15 pxor xmm3,xmm4 pxor xmm2,xmm5 pxor xmm5,xmm0 pxor xmm2,xmm3 pxor xmm3,xmm15 pxor xmm6,xmm2 dec r10d jl $L$dec_done pshufd xmm7,xmm15,04Eh pshufd xmm13,xmm2,04Eh pxor xmm7,xmm15 pshufd xmm14,xmm4,04Eh pxor xmm13,xmm2 pshufd xmm8,xmm0,04Eh pxor xmm14,xmm4 pshufd xmm9,xmm5,04Eh pxor xmm8,xmm0 pshufd xmm10,xmm3,04Eh pxor xmm9,xmm5 pxor xmm15,xmm13 pxor xmm0,xmm13 pshufd xmm11,xmm1,04Eh pxor xmm10,xmm3 pxor xmm5,xmm7 pxor xmm3,xmm8 pshufd xmm12,xmm6,04Eh pxor xmm11,xmm1 pxor xmm0,xmm14 pxor xmm1,xmm9 pxor xmm12,xmm6 pxor xmm5,xmm14 pxor xmm3,xmm13 pxor xmm1,xmm13 pxor xmm6,xmm10 pxor xmm2,xmm11 pxor xmm1,xmm14 pxor xmm6,xmm14 pxor xmm4,xmm12 pshufd xmm7,xmm15,093h pshufd xmm8,xmm0,093h pxor xmm15,xmm7 pshufd xmm9,xmm5,093h pxor xmm0,xmm8 pshufd xmm10,xmm3,093h pxor xmm5,xmm9 pshufd xmm11,xmm1,093h pxor xmm3,xmm10 pshufd xmm12,xmm6,093h pxor xmm1,xmm11 pshufd xmm13,xmm2,093h pxor xmm6,xmm12 pshufd xmm14,xmm4,093h pxor xmm2,xmm13 pxor xmm4,xmm14 pxor xmm8,xmm15 pxor xmm7,xmm4 pxor xmm8,xmm4 pshufd xmm15,xmm15,04Eh pxor xmm9,xmm0 pshufd xmm0,xmm0,04Eh pxor xmm12,xmm1 pxor xmm15,xmm7 pxor xmm13,xmm6 pxor xmm0,xmm8 pxor xmm11,xmm3 pshufd xmm7,xmm1,04Eh pxor xmm14,xmm2 pshufd xmm8,xmm6,04Eh pxor xmm10,xmm5 pshufd xmm1,xmm3,04Eh pxor xmm10,xmm4 pshufd xmm6,xmm4,04Eh pxor xmm11,xmm4 pshufd xmm3,xmm2,04Eh pxor xmm7,xmm11 pshufd xmm2,xmm5,04Eh pxor xmm8,xmm12 pxor xmm10,xmm1 pxor xmm6,xmm14 pxor xmm13,xmm3 movdqa xmm3,xmm7 pxor xmm2,xmm9 movdqa xmm5,xmm13 movdqa xmm4,xmm8 movdqa xmm1,xmm2 movdqa xmm2,xmm10 movdqa xmm7,XMMWORD PTR[((-16))+r11] jnz $L$dec_loop movdqa xmm7,XMMWORD PTR[((-32))+r11] jmp $L$dec_loop ALIGN 16 $L$dec_done:: movdqa xmm7,XMMWORD PTR[r11] movdqa xmm8,XMMWORD PTR[16+r11] movdqa xmm9,xmm2 psrlq xmm2,1 movdqa xmm10,xmm1 psrlq xmm1,1 pxor xmm2,xmm4 pxor xmm1,xmm6 pand xmm2,xmm7 pand xmm1,xmm7 pxor xmm4,xmm2 psllq xmm2,1 pxor xmm6,xmm1 psllq xmm1,1 pxor xmm2,xmm9 pxor xmm1,xmm10 movdqa xmm9,xmm5 psrlq xmm5,1 movdqa xmm10,xmm15 psrlq xmm15,1 pxor xmm5,xmm3 pxor xmm15,xmm0 pand xmm5,xmm7 pand xmm15,xmm7 pxor xmm3,xmm5 psllq xmm5,1 pxor xmm0,xmm15 psllq xmm15,1 pxor xmm5,xmm9 pxor xmm15,xmm10 movdqa xmm7,XMMWORD PTR[32+r11] movdqa xmm9,xmm6 psrlq xmm6,2 movdqa xmm10,xmm1 psrlq xmm1,2 pxor xmm6,xmm4 pxor xmm1,xmm2 pand xmm6,xmm8 pand xmm1,xmm8 pxor xmm4,xmm6 psllq xmm6,2 pxor xmm2,xmm1 psllq xmm1,2 pxor xmm6,xmm9 pxor xmm1,xmm10 movdqa xmm9,xmm0 psrlq xmm0,2 movdqa xmm10,xmm15 psrlq xmm15,2 pxor xmm0,xmm3 pxor xmm15,xmm5 pand xmm0,xmm8 pand xmm15,xmm8 pxor xmm3,xmm0 psllq xmm0,2 pxor xmm5,xmm15 psllq xmm15,2 pxor xmm0,xmm9 pxor xmm15,xmm10 movdqa xmm9,xmm3 psrlq xmm3,4 movdqa xmm10,xmm5 psrlq xmm5,4 pxor xmm3,xmm4 pxor xmm5,xmm2 pand xmm3,xmm7 pand xmm5,xmm7 pxor xmm4,xmm3 psllq xmm3,4 pxor xmm2,xmm5 psllq xmm5,4 pxor xmm3,xmm9 pxor xmm5,xmm10 movdqa xmm9,xmm0 psrlq xmm0,4 movdqa xmm10,xmm15 psrlq xmm15,4 pxor xmm0,xmm6 pxor xmm15,xmm1 pand xmm0,xmm7 pand xmm15,xmm7 pxor xmm6,xmm0 psllq xmm0,4 pxor xmm1,xmm15 psllq xmm15,4 pxor xmm0,xmm9 pxor xmm15,xmm10 movdqa xmm7,XMMWORD PTR[rax] pxor xmm5,xmm7 pxor xmm3,xmm7 pxor xmm1,xmm7 pxor xmm6,xmm7 pxor xmm2,xmm7 pxor xmm4,xmm7 pxor xmm15,xmm7 pxor xmm0,xmm7 DB 0F3h,0C3h ;repret _bsaes_decrypt8 ENDP ALIGN 16 _bsaes_key_convert PROC PRIVATE lea r11,QWORD PTR[$L$masks] movdqu xmm7,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] movdqa xmm0,XMMWORD PTR[r11] movdqa xmm1,XMMWORD PTR[16+r11] movdqa xmm2,XMMWORD PTR[32+r11] movdqa xmm3,XMMWORD PTR[48+r11] movdqa xmm4,XMMWORD PTR[64+r11] pcmpeqd xmm5,xmm5 movdqu xmm6,XMMWORD PTR[rcx] movdqa XMMWORD PTR[rax],xmm7 lea rax,QWORD PTR[16+rax] dec r10d jmp $L$key_loop ALIGN 16 $L$key_loop:: DB 102,15,56,0,244 movdqa xmm8,xmm0 movdqa xmm9,xmm1 pand xmm8,xmm6 pand xmm9,xmm6 movdqa xmm10,xmm2 pcmpeqb xmm8,xmm0 psllq xmm0,4 movdqa xmm11,xmm3 pcmpeqb xmm9,xmm1 psllq xmm1,4 pand xmm10,xmm6 pand xmm11,xmm6 movdqa xmm12,xmm0 pcmpeqb xmm10,xmm2 psllq xmm2,4 movdqa xmm13,xmm1 pcmpeqb xmm11,xmm3 psllq xmm3,4 movdqa xmm14,xmm2 movdqa xmm15,xmm3 pxor xmm8,xmm5 pxor xmm9,xmm5 pand xmm12,xmm6 pand xmm13,xmm6 movdqa XMMWORD PTR[rax],xmm8 pcmpeqb xmm12,xmm0 psrlq xmm0,4 movdqa XMMWORD PTR[16+rax],xmm9 pcmpeqb xmm13,xmm1 psrlq xmm1,4 lea rcx,QWORD PTR[16+rcx] pand xmm14,xmm6 pand xmm15,xmm6 movdqa XMMWORD PTR[32+rax],xmm10 pcmpeqb xmm14,xmm2 psrlq xmm2,4 movdqa XMMWORD PTR[48+rax],xmm11 pcmpeqb xmm15,xmm3 psrlq xmm3,4 movdqu xmm6,XMMWORD PTR[rcx] pxor xmm13,xmm5 pxor xmm14,xmm5 movdqa XMMWORD PTR[64+rax],xmm12 movdqa XMMWORD PTR[80+rax],xmm13 movdqa XMMWORD PTR[96+rax],xmm14 movdqa XMMWORD PTR[112+rax],xmm15 lea rax,QWORD PTR[128+rax] dec r10d jnz $L$key_loop movdqa xmm7,XMMWORD PTR[80+r11] DB 0F3h,0C3h ;repret _bsaes_key_convert ENDP EXTERN asm_AES_cbc_encrypt:NEAR PUBLIC bsaes_cbc_encrypt ALIGN 16 bsaes_cbc_encrypt PROC PUBLIC mov r11d,DWORD PTR[48+rsp] cmp r11d,0 jne asm_AES_cbc_encrypt cmp r8,128 jb asm_AES_cbc_encrypt mov rax,rsp $L$cbc_dec_prologue:: push rbp push rbx push r12 push r13 push r14 push r15 lea rsp,QWORD PTR[((-72))+rsp] mov r10,QWORD PTR[160+rsp] lea rsp,QWORD PTR[((-160))+rsp] movaps XMMWORD PTR[64+rsp],xmm6 movaps XMMWORD PTR[80+rsp],xmm7 movaps XMMWORD PTR[96+rsp],xmm8 movaps XMMWORD PTR[112+rsp],xmm9 movaps XMMWORD PTR[128+rsp],xmm10 movaps XMMWORD PTR[144+rsp],xmm11 movaps XMMWORD PTR[160+rsp],xmm12 movaps XMMWORD PTR[176+rsp],xmm13 movaps XMMWORD PTR[192+rsp],xmm14 movaps XMMWORD PTR[208+rsp],xmm15 $L$cbc_dec_body:: mov rbp,rsp mov eax,DWORD PTR[240+r9] mov r12,rcx mov r13,rdx mov r14,r8 mov r15,r9 mov rbx,r10 shr r14,4 mov edx,eax shl rax,7 sub rax,96 sub rsp,rax mov rax,rsp mov rcx,r15 mov r10d,edx call _bsaes_key_convert pxor xmm7,XMMWORD PTR[rsp] movdqa XMMWORD PTR[rax],xmm6 movdqa XMMWORD PTR[rsp],xmm7 movdqu xmm14,XMMWORD PTR[rbx] sub r14,8 $L$cbc_dec_loop:: movdqu xmm15,XMMWORD PTR[r12] movdqu xmm0,XMMWORD PTR[16+r12] movdqu xmm1,XMMWORD PTR[32+r12] movdqu xmm2,XMMWORD PTR[48+r12] movdqu xmm3,XMMWORD PTR[64+r12] movdqu xmm4,XMMWORD PTR[80+r12] mov rax,rsp movdqu xmm5,XMMWORD PTR[96+r12] mov r10d,edx movdqu xmm6,XMMWORD PTR[112+r12] movdqa XMMWORD PTR[32+rbp],xmm14 call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[32+rbp] movdqu xmm7,XMMWORD PTR[r12] movdqu xmm8,XMMWORD PTR[16+r12] pxor xmm0,xmm7 movdqu xmm9,XMMWORD PTR[32+r12] pxor xmm5,xmm8 movdqu xmm10,XMMWORD PTR[48+r12] pxor xmm3,xmm9 movdqu xmm11,XMMWORD PTR[64+r12] pxor xmm1,xmm10 movdqu xmm12,XMMWORD PTR[80+r12] pxor xmm6,xmm11 movdqu xmm13,XMMWORD PTR[96+r12] pxor xmm2,xmm12 movdqu xmm14,XMMWORD PTR[112+r12] pxor xmm4,xmm13 movdqu XMMWORD PTR[r13],xmm15 lea r12,QWORD PTR[128+r12] movdqu XMMWORD PTR[16+r13],xmm0 movdqu XMMWORD PTR[32+r13],xmm5 movdqu XMMWORD PTR[48+r13],xmm3 movdqu XMMWORD PTR[64+r13],xmm1 movdqu XMMWORD PTR[80+r13],xmm6 movdqu XMMWORD PTR[96+r13],xmm2 movdqu XMMWORD PTR[112+r13],xmm4 lea r13,QWORD PTR[128+r13] sub r14,8 jnc $L$cbc_dec_loop add r14,8 jz $L$cbc_dec_done movdqu xmm15,XMMWORD PTR[r12] mov rax,rsp mov r10d,edx cmp r14,2 jb $L$cbc_dec_one movdqu xmm0,XMMWORD PTR[16+r12] je $L$cbc_dec_two movdqu xmm1,XMMWORD PTR[32+r12] cmp r14,4 jb $L$cbc_dec_three movdqu xmm2,XMMWORD PTR[48+r12] je $L$cbc_dec_four movdqu xmm3,XMMWORD PTR[64+r12] cmp r14,6 jb $L$cbc_dec_five movdqu xmm4,XMMWORD PTR[80+r12] je $L$cbc_dec_six movdqu xmm5,XMMWORD PTR[96+r12] movdqa XMMWORD PTR[32+rbp],xmm14 call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[32+rbp] movdqu xmm7,XMMWORD PTR[r12] movdqu xmm8,XMMWORD PTR[16+r12] pxor xmm0,xmm7 movdqu xmm9,XMMWORD PTR[32+r12] pxor xmm5,xmm8 movdqu xmm10,XMMWORD PTR[48+r12] pxor xmm3,xmm9 movdqu xmm11,XMMWORD PTR[64+r12] pxor xmm1,xmm10 movdqu xmm12,XMMWORD PTR[80+r12] pxor xmm6,xmm11 movdqu xmm14,XMMWORD PTR[96+r12] pxor xmm2,xmm12 movdqu XMMWORD PTR[r13],xmm15 movdqu XMMWORD PTR[16+r13],xmm0 movdqu XMMWORD PTR[32+r13],xmm5 movdqu XMMWORD PTR[48+r13],xmm3 movdqu XMMWORD PTR[64+r13],xmm1 movdqu XMMWORD PTR[80+r13],xmm6 movdqu XMMWORD PTR[96+r13],xmm2 jmp $L$cbc_dec_done ALIGN 16 $L$cbc_dec_six:: movdqa XMMWORD PTR[32+rbp],xmm14 call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[32+rbp] movdqu xmm7,XMMWORD PTR[r12] movdqu xmm8,XMMWORD PTR[16+r12] pxor xmm0,xmm7 movdqu xmm9,XMMWORD PTR[32+r12] pxor xmm5,xmm8 movdqu xmm10,XMMWORD PTR[48+r12] pxor xmm3,xmm9 movdqu xmm11,XMMWORD PTR[64+r12] pxor xmm1,xmm10 movdqu xmm14,XMMWORD PTR[80+r12] pxor xmm6,xmm11 movdqu XMMWORD PTR[r13],xmm15 movdqu XMMWORD PTR[16+r13],xmm0 movdqu XMMWORD PTR[32+r13],xmm5 movdqu XMMWORD PTR[48+r13],xmm3 movdqu XMMWORD PTR[64+r13],xmm1 movdqu XMMWORD PTR[80+r13],xmm6 jmp $L$cbc_dec_done ALIGN 16 $L$cbc_dec_five:: movdqa XMMWORD PTR[32+rbp],xmm14 call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[32+rbp] movdqu xmm7,XMMWORD PTR[r12] movdqu xmm8,XMMWORD PTR[16+r12] pxor xmm0,xmm7 movdqu xmm9,XMMWORD PTR[32+r12] pxor xmm5,xmm8 movdqu xmm10,XMMWORD PTR[48+r12] pxor xmm3,xmm9 movdqu xmm14,XMMWORD PTR[64+r12] pxor xmm1,xmm10 movdqu XMMWORD PTR[r13],xmm15 movdqu XMMWORD PTR[16+r13],xmm0 movdqu XMMWORD PTR[32+r13],xmm5 movdqu XMMWORD PTR[48+r13],xmm3 movdqu XMMWORD PTR[64+r13],xmm1 jmp $L$cbc_dec_done ALIGN 16 $L$cbc_dec_four:: movdqa XMMWORD PTR[32+rbp],xmm14 call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[32+rbp] movdqu xmm7,XMMWORD PTR[r12] movdqu xmm8,XMMWORD PTR[16+r12] pxor xmm0,xmm7 movdqu xmm9,XMMWORD PTR[32+r12] pxor xmm5,xmm8 movdqu xmm14,XMMWORD PTR[48+r12] pxor xmm3,xmm9 movdqu XMMWORD PTR[r13],xmm15 movdqu XMMWORD PTR[16+r13],xmm0 movdqu XMMWORD PTR[32+r13],xmm5 movdqu XMMWORD PTR[48+r13],xmm3 jmp $L$cbc_dec_done ALIGN 16 $L$cbc_dec_three:: movdqa XMMWORD PTR[32+rbp],xmm14 call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[32+rbp] movdqu xmm7,XMMWORD PTR[r12] movdqu xmm8,XMMWORD PTR[16+r12] pxor xmm0,xmm7 movdqu xmm14,XMMWORD PTR[32+r12] pxor xmm5,xmm8 movdqu XMMWORD PTR[r13],xmm15 movdqu XMMWORD PTR[16+r13],xmm0 movdqu XMMWORD PTR[32+r13],xmm5 jmp $L$cbc_dec_done ALIGN 16 $L$cbc_dec_two:: movdqa XMMWORD PTR[32+rbp],xmm14 call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[32+rbp] movdqu xmm7,XMMWORD PTR[r12] movdqu xmm14,XMMWORD PTR[16+r12] pxor xmm0,xmm7 movdqu XMMWORD PTR[r13],xmm15 movdqu XMMWORD PTR[16+r13],xmm0 jmp $L$cbc_dec_done ALIGN 16 $L$cbc_dec_one:: lea rcx,QWORD PTR[r12] lea rdx,QWORD PTR[32+rbp] lea r8,QWORD PTR[r15] call asm_AES_decrypt pxor xmm14,XMMWORD PTR[32+rbp] movdqu XMMWORD PTR[r13],xmm14 movdqa xmm14,xmm15 $L$cbc_dec_done:: movdqu XMMWORD PTR[rbx],xmm14 lea rax,QWORD PTR[rsp] pxor xmm0,xmm0 $L$cbc_dec_bzero:: movdqa XMMWORD PTR[rax],xmm0 movdqa XMMWORD PTR[16+rax],xmm0 lea rax,QWORD PTR[32+rax] cmp rbp,rax ja $L$cbc_dec_bzero lea rsp,QWORD PTR[rbp] movaps xmm6,XMMWORD PTR[64+rbp] movaps xmm7,XMMWORD PTR[80+rbp] movaps xmm8,XMMWORD PTR[96+rbp] movaps xmm9,XMMWORD PTR[112+rbp] movaps xmm10,XMMWORD PTR[128+rbp] movaps xmm11,XMMWORD PTR[144+rbp] movaps xmm12,XMMWORD PTR[160+rbp] movaps xmm13,XMMWORD PTR[176+rbp] movaps xmm14,XMMWORD PTR[192+rbp] movaps xmm15,XMMWORD PTR[208+rbp] lea rsp,QWORD PTR[160+rbp] mov r15,QWORD PTR[72+rsp] mov r14,QWORD PTR[80+rsp] mov r13,QWORD PTR[88+rsp] mov r12,QWORD PTR[96+rsp] mov rbx,QWORD PTR[104+rsp] mov rax,QWORD PTR[112+rsp] lea rsp,QWORD PTR[120+rsp] mov rbp,rax $L$cbc_dec_epilogue:: DB 0F3h,0C3h ;repret bsaes_cbc_encrypt ENDP PUBLIC bsaes_ctr32_encrypt_blocks ALIGN 16 bsaes_ctr32_encrypt_blocks PROC PUBLIC mov rax,rsp $L$ctr_enc_prologue:: push rbp push rbx push r12 push r13 push r14 push r15 lea rsp,QWORD PTR[((-72))+rsp] mov r10,QWORD PTR[160+rsp] lea rsp,QWORD PTR[((-160))+rsp] movaps XMMWORD PTR[64+rsp],xmm6 movaps XMMWORD PTR[80+rsp],xmm7 movaps XMMWORD PTR[96+rsp],xmm8 movaps XMMWORD PTR[112+rsp],xmm9 movaps XMMWORD PTR[128+rsp],xmm10 movaps XMMWORD PTR[144+rsp],xmm11 movaps XMMWORD PTR[160+rsp],xmm12 movaps XMMWORD PTR[176+rsp],xmm13 movaps XMMWORD PTR[192+rsp],xmm14 movaps XMMWORD PTR[208+rsp],xmm15 $L$ctr_enc_body:: mov rbp,rsp movdqu xmm0,XMMWORD PTR[r10] mov eax,DWORD PTR[240+r9] mov r12,rcx mov r13,rdx mov r14,r8 mov r15,r9 movdqa XMMWORD PTR[32+rbp],xmm0 cmp r8,8 jb $L$ctr_enc_short mov ebx,eax shl rax,7 sub rax,96 sub rsp,rax mov rax,rsp mov rcx,r15 mov r10d,ebx call _bsaes_key_convert pxor xmm7,xmm6 movdqa XMMWORD PTR[rax],xmm7 movdqa xmm8,XMMWORD PTR[rsp] lea r11,QWORD PTR[$L$ADD1] movdqa xmm15,XMMWORD PTR[32+rbp] movdqa xmm7,XMMWORD PTR[((-32))+r11] DB 102,68,15,56,0,199 DB 102,68,15,56,0,255 movdqa XMMWORD PTR[rsp],xmm8 jmp $L$ctr_enc_loop ALIGN 16 $L$ctr_enc_loop:: movdqa XMMWORD PTR[32+rbp],xmm15 movdqa xmm0,xmm15 movdqa xmm1,xmm15 paddd xmm0,XMMWORD PTR[r11] movdqa xmm2,xmm15 paddd xmm1,XMMWORD PTR[16+r11] movdqa xmm3,xmm15 paddd xmm2,XMMWORD PTR[32+r11] movdqa xmm4,xmm15 paddd xmm3,XMMWORD PTR[48+r11] movdqa xmm5,xmm15 paddd xmm4,XMMWORD PTR[64+r11] movdqa xmm6,xmm15 paddd xmm5,XMMWORD PTR[80+r11] paddd xmm6,XMMWORD PTR[96+r11] movdqa xmm8,XMMWORD PTR[rsp] lea rax,QWORD PTR[16+rsp] movdqa xmm7,XMMWORD PTR[((-16))+r11] pxor xmm15,xmm8 pxor xmm0,xmm8 pxor xmm1,xmm8 pxor xmm2,xmm8 DB 102,68,15,56,0,255 DB 102,15,56,0,199 pxor xmm3,xmm8 pxor xmm4,xmm8 DB 102,15,56,0,207 DB 102,15,56,0,215 pxor xmm5,xmm8 pxor xmm6,xmm8 DB 102,15,56,0,223 DB 102,15,56,0,231 DB 102,15,56,0,239 DB 102,15,56,0,247 lea r11,QWORD PTR[$L$BS0] mov r10d,ebx call _bsaes_encrypt8_bitslice sub r14,8 jc $L$ctr_enc_loop_done movdqu xmm7,XMMWORD PTR[r12] movdqu xmm8,XMMWORD PTR[16+r12] movdqu xmm9,XMMWORD PTR[32+r12] movdqu xmm10,XMMWORD PTR[48+r12] movdqu xmm11,XMMWORD PTR[64+r12] movdqu xmm12,XMMWORD PTR[80+r12] movdqu xmm13,XMMWORD PTR[96+r12] movdqu xmm14,XMMWORD PTR[112+r12] lea r12,QWORD PTR[128+r12] pxor xmm7,xmm15 movdqa xmm15,XMMWORD PTR[32+rbp] pxor xmm0,xmm8 movdqu XMMWORD PTR[r13],xmm7 pxor xmm3,xmm9 movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm5,xmm10 movdqu XMMWORD PTR[32+r13],xmm3 pxor xmm2,xmm11 movdqu XMMWORD PTR[48+r13],xmm5 pxor xmm6,xmm12 movdqu XMMWORD PTR[64+r13],xmm2 pxor xmm1,xmm13 movdqu XMMWORD PTR[80+r13],xmm6 pxor xmm4,xmm14 movdqu XMMWORD PTR[96+r13],xmm1 lea r11,QWORD PTR[$L$ADD1] movdqu XMMWORD PTR[112+r13],xmm4 lea r13,QWORD PTR[128+r13] paddd xmm15,XMMWORD PTR[112+r11] jnz $L$ctr_enc_loop jmp $L$ctr_enc_done ALIGN 16 $L$ctr_enc_loop_done:: add r14,8 movdqu xmm7,XMMWORD PTR[r12] pxor xmm15,xmm7 movdqu XMMWORD PTR[r13],xmm15 cmp r14,2 jb $L$ctr_enc_done movdqu xmm8,XMMWORD PTR[16+r12] pxor xmm0,xmm8 movdqu XMMWORD PTR[16+r13],xmm0 je $L$ctr_enc_done movdqu xmm9,XMMWORD PTR[32+r12] pxor xmm3,xmm9 movdqu XMMWORD PTR[32+r13],xmm3 cmp r14,4 jb $L$ctr_enc_done movdqu xmm10,XMMWORD PTR[48+r12] pxor xmm5,xmm10 movdqu XMMWORD PTR[48+r13],xmm5 je $L$ctr_enc_done movdqu xmm11,XMMWORD PTR[64+r12] pxor xmm2,xmm11 movdqu XMMWORD PTR[64+r13],xmm2 cmp r14,6 jb $L$ctr_enc_done movdqu xmm12,XMMWORD PTR[80+r12] pxor xmm6,xmm12 movdqu XMMWORD PTR[80+r13],xmm6 je $L$ctr_enc_done movdqu xmm13,XMMWORD PTR[96+r12] pxor xmm1,xmm13 movdqu XMMWORD PTR[96+r13],xmm1 jmp $L$ctr_enc_done ALIGN 16 $L$ctr_enc_short:: lea rcx,QWORD PTR[32+rbp] lea rdx,QWORD PTR[48+rbp] lea r8,QWORD PTR[r15] call asm_AES_encrypt movdqu xmm0,XMMWORD PTR[r12] lea r12,QWORD PTR[16+r12] mov eax,DWORD PTR[44+rbp] bswap eax pxor xmm0,XMMWORD PTR[48+rbp] inc eax movdqu XMMWORD PTR[r13],xmm0 bswap eax lea r13,QWORD PTR[16+r13] mov DWORD PTR[44+rsp],eax dec r14 jnz $L$ctr_enc_short $L$ctr_enc_done:: lea rax,QWORD PTR[rsp] pxor xmm0,xmm0 $L$ctr_enc_bzero:: movdqa XMMWORD PTR[rax],xmm0 movdqa XMMWORD PTR[16+rax],xmm0 lea rax,QWORD PTR[32+rax] cmp rbp,rax ja $L$ctr_enc_bzero lea rsp,QWORD PTR[rbp] movaps xmm6,XMMWORD PTR[64+rbp] movaps xmm7,XMMWORD PTR[80+rbp] movaps xmm8,XMMWORD PTR[96+rbp] movaps xmm9,XMMWORD PTR[112+rbp] movaps xmm10,XMMWORD PTR[128+rbp] movaps xmm11,XMMWORD PTR[144+rbp] movaps xmm12,XMMWORD PTR[160+rbp] movaps xmm13,XMMWORD PTR[176+rbp] movaps xmm14,XMMWORD PTR[192+rbp] movaps xmm15,XMMWORD PTR[208+rbp] lea rsp,QWORD PTR[160+rbp] mov r15,QWORD PTR[72+rsp] mov r14,QWORD PTR[80+rsp] mov r13,QWORD PTR[88+rsp] mov r12,QWORD PTR[96+rsp] mov rbx,QWORD PTR[104+rsp] mov rax,QWORD PTR[112+rsp] lea rsp,QWORD PTR[120+rsp] mov rbp,rax $L$ctr_enc_epilogue:: DB 0F3h,0C3h ;repret bsaes_ctr32_encrypt_blocks ENDP PUBLIC bsaes_xts_encrypt ALIGN 16 bsaes_xts_encrypt PROC PUBLIC mov rax,rsp $L$xts_enc_prologue:: push rbp push rbx push r12 push r13 push r14 push r15 lea rsp,QWORD PTR[((-72))+rsp] mov r10,QWORD PTR[160+rsp] mov r11,QWORD PTR[168+rsp] lea rsp,QWORD PTR[((-160))+rsp] movaps XMMWORD PTR[64+rsp],xmm6 movaps XMMWORD PTR[80+rsp],xmm7 movaps XMMWORD PTR[96+rsp],xmm8 movaps XMMWORD PTR[112+rsp],xmm9 movaps XMMWORD PTR[128+rsp],xmm10 movaps XMMWORD PTR[144+rsp],xmm11 movaps XMMWORD PTR[160+rsp],xmm12 movaps XMMWORD PTR[176+rsp],xmm13 movaps XMMWORD PTR[192+rsp],xmm14 movaps XMMWORD PTR[208+rsp],xmm15 $L$xts_enc_body:: mov rbp,rsp mov r12,rcx mov r13,rdx mov r14,r8 mov r15,r9 lea rcx,QWORD PTR[r11] lea rdx,QWORD PTR[32+rbp] lea r8,QWORD PTR[r10] call asm_AES_encrypt mov eax,DWORD PTR[240+r15] mov rbx,r14 mov edx,eax shl rax,7 sub rax,96 sub rsp,rax mov rax,rsp mov rcx,r15 mov r10d,edx call _bsaes_key_convert pxor xmm7,xmm6 movdqa XMMWORD PTR[rax],xmm7 and r14,-16 sub rsp,080h movdqa xmm6,XMMWORD PTR[32+rbp] pxor xmm14,xmm14 movdqa xmm12,XMMWORD PTR[$L$xts_magic] pcmpgtd xmm14,xmm6 sub r14,080h jc $L$xts_enc_short jmp $L$xts_enc_loop ALIGN 16 $L$xts_enc_loop:: pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm15,xmm6 movdqa XMMWORD PTR[rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm0,xmm6 movdqa XMMWORD PTR[16+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm7,XMMWORD PTR[r12] pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm1,xmm6 movdqa XMMWORD PTR[32+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm8,XMMWORD PTR[16+r12] pxor xmm15,xmm7 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm2,xmm6 movdqa XMMWORD PTR[48+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm9,XMMWORD PTR[32+r12] pxor xmm0,xmm8 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm3,xmm6 movdqa XMMWORD PTR[64+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm10,XMMWORD PTR[48+r12] pxor xmm1,xmm9 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm4,xmm6 movdqa XMMWORD PTR[80+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm11,XMMWORD PTR[64+r12] pxor xmm2,xmm10 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm5,xmm6 movdqa XMMWORD PTR[96+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm12,XMMWORD PTR[80+r12] pxor xmm3,xmm11 movdqu xmm13,XMMWORD PTR[96+r12] pxor xmm4,xmm12 movdqu xmm14,XMMWORD PTR[112+r12] lea r12,QWORD PTR[128+r12] movdqa XMMWORD PTR[112+rsp],xmm6 pxor xmm5,xmm13 lea rax,QWORD PTR[128+rsp] pxor xmm6,xmm14 mov r10d,edx call _bsaes_encrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm3,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm5,XMMWORD PTR[48+rsp] movdqu XMMWORD PTR[32+r13],xmm3 pxor xmm2,XMMWORD PTR[64+rsp] movdqu XMMWORD PTR[48+r13],xmm5 pxor xmm6,XMMWORD PTR[80+rsp] movdqu XMMWORD PTR[64+r13],xmm2 pxor xmm1,XMMWORD PTR[96+rsp] movdqu XMMWORD PTR[80+r13],xmm6 pxor xmm4,XMMWORD PTR[112+rsp] movdqu XMMWORD PTR[96+r13],xmm1 movdqu XMMWORD PTR[112+r13],xmm4 lea r13,QWORD PTR[128+r13] movdqa xmm6,XMMWORD PTR[112+rsp] pxor xmm14,xmm14 movdqa xmm12,XMMWORD PTR[$L$xts_magic] pcmpgtd xmm14,xmm6 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 sub r14,080h jnc $L$xts_enc_loop $L$xts_enc_short:: add r14,080h jz $L$xts_enc_done pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm15,xmm6 movdqa XMMWORD PTR[rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm0,xmm6 movdqa XMMWORD PTR[16+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm7,XMMWORD PTR[r12] cmp r14,16 je $L$xts_enc_1 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm1,xmm6 movdqa XMMWORD PTR[32+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm8,XMMWORD PTR[16+r12] cmp r14,32 je $L$xts_enc_2 pxor xmm15,xmm7 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm2,xmm6 movdqa XMMWORD PTR[48+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm9,XMMWORD PTR[32+r12] cmp r14,48 je $L$xts_enc_3 pxor xmm0,xmm8 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm3,xmm6 movdqa XMMWORD PTR[64+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm10,XMMWORD PTR[48+r12] cmp r14,64 je $L$xts_enc_4 pxor xmm1,xmm9 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm4,xmm6 movdqa XMMWORD PTR[80+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm11,XMMWORD PTR[64+r12] cmp r14,80 je $L$xts_enc_5 pxor xmm2,xmm10 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm5,xmm6 movdqa XMMWORD PTR[96+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm12,XMMWORD PTR[80+r12] cmp r14,96 je $L$xts_enc_6 pxor xmm3,xmm11 movdqu xmm13,XMMWORD PTR[96+r12] pxor xmm4,xmm12 movdqa XMMWORD PTR[112+rsp],xmm6 lea r12,QWORD PTR[112+r12] pxor xmm5,xmm13 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_encrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm3,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm5,XMMWORD PTR[48+rsp] movdqu XMMWORD PTR[32+r13],xmm3 pxor xmm2,XMMWORD PTR[64+rsp] movdqu XMMWORD PTR[48+r13],xmm5 pxor xmm6,XMMWORD PTR[80+rsp] movdqu XMMWORD PTR[64+r13],xmm2 pxor xmm1,XMMWORD PTR[96+rsp] movdqu XMMWORD PTR[80+r13],xmm6 movdqu XMMWORD PTR[96+r13],xmm1 lea r13,QWORD PTR[112+r13] movdqa xmm6,XMMWORD PTR[112+rsp] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_6:: pxor xmm3,xmm11 lea r12,QWORD PTR[96+r12] pxor xmm4,xmm12 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_encrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm3,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm5,XMMWORD PTR[48+rsp] movdqu XMMWORD PTR[32+r13],xmm3 pxor xmm2,XMMWORD PTR[64+rsp] movdqu XMMWORD PTR[48+r13],xmm5 pxor xmm6,XMMWORD PTR[80+rsp] movdqu XMMWORD PTR[64+r13],xmm2 movdqu XMMWORD PTR[80+r13],xmm6 lea r13,QWORD PTR[96+r13] movdqa xmm6,XMMWORD PTR[96+rsp] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_5:: pxor xmm2,xmm10 lea r12,QWORD PTR[80+r12] pxor xmm3,xmm11 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_encrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm3,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm5,XMMWORD PTR[48+rsp] movdqu XMMWORD PTR[32+r13],xmm3 pxor xmm2,XMMWORD PTR[64+rsp] movdqu XMMWORD PTR[48+r13],xmm5 movdqu XMMWORD PTR[64+r13],xmm2 lea r13,QWORD PTR[80+r13] movdqa xmm6,XMMWORD PTR[80+rsp] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_4:: pxor xmm1,xmm9 lea r12,QWORD PTR[64+r12] pxor xmm2,xmm10 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_encrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm3,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm5,XMMWORD PTR[48+rsp] movdqu XMMWORD PTR[32+r13],xmm3 movdqu XMMWORD PTR[48+r13],xmm5 lea r13,QWORD PTR[64+r13] movdqa xmm6,XMMWORD PTR[64+rsp] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_3:: pxor xmm0,xmm8 lea r12,QWORD PTR[48+r12] pxor xmm1,xmm9 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_encrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm3,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 movdqu XMMWORD PTR[32+r13],xmm3 lea r13,QWORD PTR[48+r13] movdqa xmm6,XMMWORD PTR[48+rsp] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_2:: pxor xmm15,xmm7 lea r12,QWORD PTR[32+r12] pxor xmm0,xmm8 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_encrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 movdqu XMMWORD PTR[16+r13],xmm0 lea r13,QWORD PTR[32+r13] movdqa xmm6,XMMWORD PTR[32+rsp] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_1:: pxor xmm7,xmm15 lea r12,QWORD PTR[16+r12] movdqa XMMWORD PTR[32+rbp],xmm7 lea rcx,QWORD PTR[32+rbp] lea rdx,QWORD PTR[32+rbp] lea r8,QWORD PTR[r15] call asm_AES_encrypt pxor xmm15,XMMWORD PTR[32+rbp] movdqu XMMWORD PTR[r13],xmm15 lea r13,QWORD PTR[16+r13] movdqa xmm6,XMMWORD PTR[16+rsp] $L$xts_enc_done:: and ebx,15 jz $L$xts_enc_ret mov rdx,r13 $L$xts_enc_steal:: movzx eax,BYTE PTR[r12] movzx ecx,BYTE PTR[((-16))+rdx] lea r12,QWORD PTR[1+r12] mov BYTE PTR[((-16))+rdx],al mov BYTE PTR[rdx],cl lea rdx,QWORD PTR[1+rdx] sub ebx,1 jnz $L$xts_enc_steal movdqu xmm15,XMMWORD PTR[((-16))+r13] lea rcx,QWORD PTR[32+rbp] pxor xmm15,xmm6 lea rdx,QWORD PTR[32+rbp] movdqa XMMWORD PTR[32+rbp],xmm15 lea r8,QWORD PTR[r15] call asm_AES_encrypt pxor xmm6,XMMWORD PTR[32+rbp] movdqu XMMWORD PTR[(-16)+r13],xmm6 $L$xts_enc_ret:: lea rax,QWORD PTR[rsp] pxor xmm0,xmm0 $L$xts_enc_bzero:: movdqa XMMWORD PTR[rax],xmm0 movdqa XMMWORD PTR[16+rax],xmm0 lea rax,QWORD PTR[32+rax] cmp rbp,rax ja $L$xts_enc_bzero lea rsp,QWORD PTR[rbp] movaps xmm6,XMMWORD PTR[64+rbp] movaps xmm7,XMMWORD PTR[80+rbp] movaps xmm8,XMMWORD PTR[96+rbp] movaps xmm9,XMMWORD PTR[112+rbp] movaps xmm10,XMMWORD PTR[128+rbp] movaps xmm11,XMMWORD PTR[144+rbp] movaps xmm12,XMMWORD PTR[160+rbp] movaps xmm13,XMMWORD PTR[176+rbp] movaps xmm14,XMMWORD PTR[192+rbp] movaps xmm15,XMMWORD PTR[208+rbp] lea rsp,QWORD PTR[160+rbp] mov r15,QWORD PTR[72+rsp] mov r14,QWORD PTR[80+rsp] mov r13,QWORD PTR[88+rsp] mov r12,QWORD PTR[96+rsp] mov rbx,QWORD PTR[104+rsp] mov rax,QWORD PTR[112+rsp] lea rsp,QWORD PTR[120+rsp] mov rbp,rax $L$xts_enc_epilogue:: DB 0F3h,0C3h ;repret bsaes_xts_encrypt ENDP PUBLIC bsaes_xts_decrypt ALIGN 16 bsaes_xts_decrypt PROC PUBLIC mov rax,rsp $L$xts_dec_prologue:: push rbp push rbx push r12 push r13 push r14 push r15 lea rsp,QWORD PTR[((-72))+rsp] mov r10,QWORD PTR[160+rsp] mov r11,QWORD PTR[168+rsp] lea rsp,QWORD PTR[((-160))+rsp] movaps XMMWORD PTR[64+rsp],xmm6 movaps XMMWORD PTR[80+rsp],xmm7 movaps XMMWORD PTR[96+rsp],xmm8 movaps XMMWORD PTR[112+rsp],xmm9 movaps XMMWORD PTR[128+rsp],xmm10 movaps XMMWORD PTR[144+rsp],xmm11 movaps XMMWORD PTR[160+rsp],xmm12 movaps XMMWORD PTR[176+rsp],xmm13 movaps XMMWORD PTR[192+rsp],xmm14 movaps XMMWORD PTR[208+rsp],xmm15 $L$xts_dec_body:: mov rbp,rsp mov r12,rcx mov r13,rdx mov r14,r8 mov r15,r9 lea rcx,QWORD PTR[r11] lea rdx,QWORD PTR[32+rbp] lea r8,QWORD PTR[r10] call asm_AES_encrypt mov eax,DWORD PTR[240+r15] mov rbx,r14 mov edx,eax shl rax,7 sub rax,96 sub rsp,rax mov rax,rsp mov rcx,r15 mov r10d,edx call _bsaes_key_convert pxor xmm7,XMMWORD PTR[rsp] movdqa XMMWORD PTR[rax],xmm6 movdqa XMMWORD PTR[rsp],xmm7 xor eax,eax and r14,-16 test ebx,15 setnz al shl rax,4 sub r14,rax sub rsp,080h movdqa xmm6,XMMWORD PTR[32+rbp] pxor xmm14,xmm14 movdqa xmm12,XMMWORD PTR[$L$xts_magic] pcmpgtd xmm14,xmm6 sub r14,080h jc $L$xts_dec_short jmp $L$xts_dec_loop ALIGN 16 $L$xts_dec_loop:: pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm15,xmm6 movdqa XMMWORD PTR[rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm0,xmm6 movdqa XMMWORD PTR[16+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm7,XMMWORD PTR[r12] pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm1,xmm6 movdqa XMMWORD PTR[32+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm8,XMMWORD PTR[16+r12] pxor xmm15,xmm7 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm2,xmm6 movdqa XMMWORD PTR[48+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm9,XMMWORD PTR[32+r12] pxor xmm0,xmm8 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm3,xmm6 movdqa XMMWORD PTR[64+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm10,XMMWORD PTR[48+r12] pxor xmm1,xmm9 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm4,xmm6 movdqa XMMWORD PTR[80+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm11,XMMWORD PTR[64+r12] pxor xmm2,xmm10 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm5,xmm6 movdqa XMMWORD PTR[96+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm12,XMMWORD PTR[80+r12] pxor xmm3,xmm11 movdqu xmm13,XMMWORD PTR[96+r12] pxor xmm4,xmm12 movdqu xmm14,XMMWORD PTR[112+r12] lea r12,QWORD PTR[128+r12] movdqa XMMWORD PTR[112+rsp],xmm6 pxor xmm5,xmm13 lea rax,QWORD PTR[128+rsp] pxor xmm6,xmm14 mov r10d,edx call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm5,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm3,XMMWORD PTR[48+rsp] movdqu XMMWORD PTR[32+r13],xmm5 pxor xmm1,XMMWORD PTR[64+rsp] movdqu XMMWORD PTR[48+r13],xmm3 pxor xmm6,XMMWORD PTR[80+rsp] movdqu XMMWORD PTR[64+r13],xmm1 pxor xmm2,XMMWORD PTR[96+rsp] movdqu XMMWORD PTR[80+r13],xmm6 pxor xmm4,XMMWORD PTR[112+rsp] movdqu XMMWORD PTR[96+r13],xmm2 movdqu XMMWORD PTR[112+r13],xmm4 lea r13,QWORD PTR[128+r13] movdqa xmm6,XMMWORD PTR[112+rsp] pxor xmm14,xmm14 movdqa xmm12,XMMWORD PTR[$L$xts_magic] pcmpgtd xmm14,xmm6 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 sub r14,080h jnc $L$xts_dec_loop $L$xts_dec_short:: add r14,080h jz $L$xts_dec_done pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm15,xmm6 movdqa XMMWORD PTR[rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm0,xmm6 movdqa XMMWORD PTR[16+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm7,XMMWORD PTR[r12] cmp r14,16 je $L$xts_dec_1 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm1,xmm6 movdqa XMMWORD PTR[32+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm8,XMMWORD PTR[16+r12] cmp r14,32 je $L$xts_dec_2 pxor xmm15,xmm7 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm2,xmm6 movdqa XMMWORD PTR[48+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm9,XMMWORD PTR[32+r12] cmp r14,48 je $L$xts_dec_3 pxor xmm0,xmm8 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm3,xmm6 movdqa XMMWORD PTR[64+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm10,XMMWORD PTR[48+r12] cmp r14,64 je $L$xts_dec_4 pxor xmm1,xmm9 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm4,xmm6 movdqa XMMWORD PTR[80+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm11,XMMWORD PTR[64+r12] cmp r14,80 je $L$xts_dec_5 pxor xmm2,xmm10 pshufd xmm13,xmm14,013h pxor xmm14,xmm14 movdqa xmm5,xmm6 movdqa XMMWORD PTR[96+rsp],xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 pcmpgtd xmm14,xmm6 pxor xmm6,xmm13 movdqu xmm12,XMMWORD PTR[80+r12] cmp r14,96 je $L$xts_dec_6 pxor xmm3,xmm11 movdqu xmm13,XMMWORD PTR[96+r12] pxor xmm4,xmm12 movdqa XMMWORD PTR[112+rsp],xmm6 lea r12,QWORD PTR[112+r12] pxor xmm5,xmm13 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm5,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm3,XMMWORD PTR[48+rsp] movdqu XMMWORD PTR[32+r13],xmm5 pxor xmm1,XMMWORD PTR[64+rsp] movdqu XMMWORD PTR[48+r13],xmm3 pxor xmm6,XMMWORD PTR[80+rsp] movdqu XMMWORD PTR[64+r13],xmm1 pxor xmm2,XMMWORD PTR[96+rsp] movdqu XMMWORD PTR[80+r13],xmm6 movdqu XMMWORD PTR[96+r13],xmm2 lea r13,QWORD PTR[112+r13] movdqa xmm6,XMMWORD PTR[112+rsp] jmp $L$xts_dec_done ALIGN 16 $L$xts_dec_6:: pxor xmm3,xmm11 lea r12,QWORD PTR[96+r12] pxor xmm4,xmm12 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm5,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm3,XMMWORD PTR[48+rsp] movdqu XMMWORD PTR[32+r13],xmm5 pxor xmm1,XMMWORD PTR[64+rsp] movdqu XMMWORD PTR[48+r13],xmm3 pxor xmm6,XMMWORD PTR[80+rsp] movdqu XMMWORD PTR[64+r13],xmm1 movdqu XMMWORD PTR[80+r13],xmm6 lea r13,QWORD PTR[96+r13] movdqa xmm6,XMMWORD PTR[96+rsp] jmp $L$xts_dec_done ALIGN 16 $L$xts_dec_5:: pxor xmm2,xmm10 lea r12,QWORD PTR[80+r12] pxor xmm3,xmm11 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm5,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm3,XMMWORD PTR[48+rsp] movdqu XMMWORD PTR[32+r13],xmm5 pxor xmm1,XMMWORD PTR[64+rsp] movdqu XMMWORD PTR[48+r13],xmm3 movdqu XMMWORD PTR[64+r13],xmm1 lea r13,QWORD PTR[80+r13] movdqa xmm6,XMMWORD PTR[80+rsp] jmp $L$xts_dec_done ALIGN 16 $L$xts_dec_4:: pxor xmm1,xmm9 lea r12,QWORD PTR[64+r12] pxor xmm2,xmm10 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm5,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 pxor xmm3,XMMWORD PTR[48+rsp] movdqu XMMWORD PTR[32+r13],xmm5 movdqu XMMWORD PTR[48+r13],xmm3 lea r13,QWORD PTR[64+r13] movdqa xmm6,XMMWORD PTR[64+rsp] jmp $L$xts_dec_done ALIGN 16 $L$xts_dec_3:: pxor xmm0,xmm8 lea r12,QWORD PTR[48+r12] pxor xmm1,xmm9 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 pxor xmm5,XMMWORD PTR[32+rsp] movdqu XMMWORD PTR[16+r13],xmm0 movdqu XMMWORD PTR[32+r13],xmm5 lea r13,QWORD PTR[48+r13] movdqa xmm6,XMMWORD PTR[48+rsp] jmp $L$xts_dec_done ALIGN 16 $L$xts_dec_2:: pxor xmm15,xmm7 lea r12,QWORD PTR[32+r12] pxor xmm0,xmm8 lea rax,QWORD PTR[128+rsp] mov r10d,edx call _bsaes_decrypt8 pxor xmm15,XMMWORD PTR[rsp] pxor xmm0,XMMWORD PTR[16+rsp] movdqu XMMWORD PTR[r13],xmm15 movdqu XMMWORD PTR[16+r13],xmm0 lea r13,QWORD PTR[32+r13] movdqa xmm6,XMMWORD PTR[32+rsp] jmp $L$xts_dec_done ALIGN 16 $L$xts_dec_1:: pxor xmm7,xmm15 lea r12,QWORD PTR[16+r12] movdqa XMMWORD PTR[32+rbp],xmm7 lea rcx,QWORD PTR[32+rbp] lea rdx,QWORD PTR[32+rbp] lea r8,QWORD PTR[r15] call asm_AES_decrypt pxor xmm15,XMMWORD PTR[32+rbp] movdqu XMMWORD PTR[r13],xmm15 lea r13,QWORD PTR[16+r13] movdqa xmm6,XMMWORD PTR[16+rsp] $L$xts_dec_done:: and ebx,15 jz $L$xts_dec_ret pxor xmm14,xmm14 movdqa xmm12,XMMWORD PTR[$L$xts_magic] pcmpgtd xmm14,xmm6 pshufd xmm13,xmm14,013h movdqa xmm5,xmm6 paddq xmm6,xmm6 pand xmm13,xmm12 movdqu xmm15,XMMWORD PTR[r12] pxor xmm6,xmm13 lea rcx,QWORD PTR[32+rbp] pxor xmm15,xmm6 lea rdx,QWORD PTR[32+rbp] movdqa XMMWORD PTR[32+rbp],xmm15 lea r8,QWORD PTR[r15] call asm_AES_decrypt pxor xmm6,XMMWORD PTR[32+rbp] mov rdx,r13 movdqu XMMWORD PTR[r13],xmm6 $L$xts_dec_steal:: movzx eax,BYTE PTR[16+r12] movzx ecx,BYTE PTR[rdx] lea r12,QWORD PTR[1+r12] mov BYTE PTR[rdx],al mov BYTE PTR[16+rdx],cl lea rdx,QWORD PTR[1+rdx] sub ebx,1 jnz $L$xts_dec_steal movdqu xmm15,XMMWORD PTR[r13] lea rcx,QWORD PTR[32+rbp] pxor xmm15,xmm5 lea rdx,QWORD PTR[32+rbp] movdqa XMMWORD PTR[32+rbp],xmm15 lea r8,QWORD PTR[r15] call asm_AES_decrypt pxor xmm5,XMMWORD PTR[32+rbp] movdqu XMMWORD PTR[r13],xmm5 $L$xts_dec_ret:: lea rax,QWORD PTR[rsp] pxor xmm0,xmm0 $L$xts_dec_bzero:: movdqa XMMWORD PTR[rax],xmm0 movdqa XMMWORD PTR[16+rax],xmm0 lea rax,QWORD PTR[32+rax] cmp rbp,rax ja $L$xts_dec_bzero lea rsp,QWORD PTR[rbp] movaps xmm6,XMMWORD PTR[64+rbp] movaps xmm7,XMMWORD PTR[80+rbp] movaps xmm8,XMMWORD PTR[96+rbp] movaps xmm9,XMMWORD PTR[112+rbp] movaps xmm10,XMMWORD PTR[128+rbp] movaps xmm11,XMMWORD PTR[144+rbp] movaps xmm12,XMMWORD PTR[160+rbp] movaps xmm13,XMMWORD PTR[176+rbp] movaps xmm14,XMMWORD PTR[192+rbp] movaps xmm15,XMMWORD PTR[208+rbp] lea rsp,QWORD PTR[160+rbp] mov r15,QWORD PTR[72+rsp] mov r14,QWORD PTR[80+rsp] mov r13,QWORD PTR[88+rsp] mov r12,QWORD PTR[96+rsp] mov rbx,QWORD PTR[104+rsp] mov rax,QWORD PTR[112+rsp] lea rsp,QWORD PTR[120+rsp] mov rbp,rax $L$xts_dec_epilogue:: DB 0F3h,0C3h ;repret bsaes_xts_decrypt ENDP ALIGN 64 _bsaes_const:: $L$M0ISR:: DQ 00a0e0206070b0f03h,00004080c0d010509h $L$ISRM0:: DQ 001040b0e0205080fh,00306090c00070a0dh $L$ISR:: DQ 00504070602010003h,00f0e0d0c080b0a09h $L$BS0:: DQ 05555555555555555h,05555555555555555h $L$BS1:: DQ 03333333333333333h,03333333333333333h $L$BS2:: DQ 00f0f0f0f0f0f0f0fh,00f0f0f0f0f0f0f0fh $L$SR:: DQ 00504070600030201h,00f0e0d0c0a09080bh $L$SRM0:: DQ 00304090e00050a0fh,001060b0c0207080dh $L$M0SR:: DQ 00a0e02060f03070bh,00004080c05090d01h $L$SWPUP:: DQ 00706050403020100h,00c0d0e0f0b0a0908h $L$SWPUPM0SR:: DQ 00a0d02060c03070bh,00004080f05090e01h $L$ADD1:: DQ 00000000000000000h,00000000100000000h $L$ADD2:: DQ 00000000000000000h,00000000200000000h $L$ADD3:: DQ 00000000000000000h,00000000300000000h $L$ADD4:: DQ 00000000000000000h,00000000400000000h $L$ADD5:: DQ 00000000000000000h,00000000500000000h $L$ADD6:: DQ 00000000000000000h,00000000600000000h $L$ADD7:: DQ 00000000000000000h,00000000700000000h $L$ADD8:: DQ 00000000000000000h,00000000800000000h $L$xts_magic:: DD 087h,0,1,0 $L$masks:: DQ 00101010101010101h,00101010101010101h DQ 00202020202020202h,00202020202020202h DQ 00404040404040404h,00404040404040404h DQ 00808080808080808h,00808080808080808h $L$M0:: DQ 002060a0e03070b0fh,00004080c0105090dh $L$63:: DQ 06363636363636363h,06363636363636363h DB 66,105,116,45,115,108,105,99,101,100,32,65,69,83,32,102 DB 111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44 DB 32,69,109,105,108,105,97,32,75,195,164,115,112,101,114,44 DB 32,80,101,116,101,114,32,83,99,104,119,97,98,101,44,32 DB 65,110,100,121,32,80,111,108,121,97,107,111,118,0 ALIGN 64 EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 se_handler PROC PRIVATE push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD PTR[120+r8] mov rbx,QWORD PTR[248+r8] mov rsi,QWORD PTR[8+r9] mov r11,QWORD PTR[56+r9] mov r10d,DWORD PTR[r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jb $L$in_prologue mov rax,QWORD PTR[152+r8] mov r10d,DWORD PTR[4+r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jae $L$in_prologue mov rax,QWORD PTR[160+r8] lea rsi,QWORD PTR[64+rax] lea rdi,QWORD PTR[512+r8] mov ecx,20 DD 0a548f3fch lea rax,QWORD PTR[160+rax] mov rbp,QWORD PTR[112+rax] mov rbx,QWORD PTR[104+rax] mov r12,QWORD PTR[96+rax] mov r13,QWORD PTR[88+rax] mov r14,QWORD PTR[80+rax] mov r15,QWORD PTR[72+rax] lea rax,QWORD PTR[120+rax] mov QWORD PTR[144+r8],rbx mov QWORD PTR[160+r8],rbp mov QWORD PTR[216+r8],r12 mov QWORD PTR[224+r8],r13 mov QWORD PTR[232+r8],r14 mov QWORD PTR[240+r8],r15 $L$in_prologue:: mov QWORD PTR[152+r8],rax mov rdi,QWORD PTR[40+r9] mov rsi,r8 mov ecx,154 DD 0a548f3fch mov rsi,r9 xor rcx,rcx mov rdx,QWORD PTR[8+rsi] mov r8,QWORD PTR[rsi] mov r9,QWORD PTR[16+rsi] mov r10,QWORD PTR[40+rsi] lea r11,QWORD PTR[56+rsi] lea r12,QWORD PTR[24+rsi] mov QWORD PTR[32+rsp],r10 mov QWORD PTR[40+rsp],r11 mov QWORD PTR[48+rsp],r12 mov QWORD PTR[56+rsp],rcx call QWORD PTR[__imp_RtlVirtualUnwind] mov eax,1 add rsp,64 popfq pop r15 pop r14 pop r13 pop r12 pop rbp pop rbx pop rdi pop rsi DB 0F3h,0C3h ;repret se_handler ENDP .text$ ENDS .pdata SEGMENT READONLY ALIGN(4) ALIGN 4 DD imagerel $L$cbc_dec_prologue DD imagerel $L$cbc_dec_epilogue DD imagerel $L$cbc_dec_info DD imagerel $L$ctr_enc_prologue DD imagerel $L$ctr_enc_epilogue DD imagerel $L$ctr_enc_info DD imagerel $L$xts_enc_prologue DD imagerel $L$xts_enc_epilogue DD imagerel $L$xts_enc_info DD imagerel $L$xts_dec_prologue DD imagerel $L$xts_dec_epilogue DD imagerel $L$xts_dec_info .pdata ENDS .xdata SEGMENT READONLY ALIGN(8) ALIGN 8 $L$cbc_dec_info:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$cbc_dec_body,imagerel $L$cbc_dec_epilogue $L$ctr_enc_info:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$ctr_enc_body,imagerel $L$ctr_enc_epilogue $L$xts_enc_info:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$xts_enc_body,imagerel $L$xts_enc_epilogue $L$xts_dec_info:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$xts_dec_body,imagerel $L$xts_dec_epilogue .xdata ENDS END
; --------------------------------------------------------------------------- ; Animation script - Eggman on the "TRY AGAIN" and "END" screens ; --------------------------------------------------------------------------- Ani_EEgg: dc.w @tryagain1-Ani_EEgg dc.w @tryagain2-Ani_EEgg dc.w @end-Ani_EEgg @tryagain1: dc.b 5, 0, afRoutine, 1 @tryagain2: dc.b 5, 2, afRoutine, 3 @end: dc.b 7, 4, 5, 6, 5, 4, 5, 6, 5, 4, 5, 6, 5, 7, 5, 6, 5, afEnd even
; A306367: a(n) = numerator of (n^2 + 2)/(n + 2). ; 1,1,3,11,3,27,19,17,33,83,17,123,73,57,99,227,43,291,163,121,201,443,81,531,289,209,339,731,131,843,451,321,513,1091,193,1227,649,457,723,1523,267,1683,883,617,969,2027,353,2211,1153,801,1251,2603,451,2811,1459,1009,1569,3251,561,3483,1801,1241,1923,3971,683,4227,2179,1497,2313,4763,817,5043,2593,1777,2739,5627,963,5931,3043,2081,3201,6563,1121,6891,3529,2409,3699,7571,1291,7923,4051,2761,4233,8651,1473,9027,4609,3137,4803,9803,1667,10203,5203,3537,5409,11027,1873,11451,5833,3961,6051,12323,2091,12771,6499,4409,6729,13691,2321,14163,7201,4881,7443,15131,2563,15627,7939,5377,8193,16643,2817,17163,8713,5897,8979,18227,3083,18771,9523,6441,9801,19883,3361,20451,10369,7009,10659,21611,3651,22203,11251,7601,11553,23411,3953,24027,12169,8217,12483,25283,4267,25923,13123,8857,13449,27227,4593,27891,14113,9521,14451,29243,4931,29931,15139,10209,15489,31331,5281,32043,16201,10921,16563,33491,5643,34227,17299,11657,17673,35723,6017,36483,18433,12417,18819,38027,6403,38811,19603,13201,20001,40403,6801,41211,20809,14009,21219,42851,7211,43683,22051,14841,22473,45371,7633,46227,23329,15697,23763,47963,8067,48843,24643,16577,25089,50627,8513,51531,25993,17481,26451,53363,8971,54291,27379,18409,27849,56171,9441,57123,28801,19361,29283,59051,9923,60027,30259,20337,30753,62003 mov $2,2 add $2,$0 pow $0,2 add $0,1 mov $1,$0 gcd $2,6 div $1,$2 div $1,2 mul $1,2 add $1,1
; A294305: Sum of the tenth powers of the parts in the partitions of n into two distinct parts. ; 0,0,1025,59050,1108650,10815226,71340451,352767124,1427557524,4904576300,14914341925,40791300350,102769130750,240345147350,529882277575,1105458926376,2206044295976,4218551412024,7792505423049,13913571680850,24163571680850,40817515234450,67403375450475,108767969299900,172233267629500,267462840778276,408767794923501,614369672363174,910855693713574,1330986276623150,1922052927013775,2740581702366800,3867581120837200,5397144112201200,7463537860161425,10218514746450426,13878243653740026 add $0,1 mov $2,$0 lpb $0 mov $3,$2 dif $3,$0 gcd $3,2 mul $3,$0 cmp $3,$2 cmp $3,0 mul $3,$0 sub $0,1 pow $3,10 add $1,$3 lpe mov $0,$1
unitInfoType = "vtx_uh60_rscUnitInfoMinimal"; unitInfoTypeLite = "vtx_uh60_rscUnitInfoMinimal"; unitInfoTypeRTD = "vtx_uh60_rscUnitInfoMinimal"; // unitInfoType = "RscUnitInfoAir"; // unitInfoTypeLite = "RscUnitInfoAirRTDBasic"; // unitInfoTypeRTD = "RscUnitInfoAirRTDFullDigital";
TITLE Indirect Recursion (Recurse.asm) ; Demonstration of the kind of indirect recursion that ; beginning programmers often use to avoid using ; a loop. As each call to ShowMenu occurs, it piles ; up a lot of return addresses on the stack, which ; must later be unwound before control returns to main. ; Last update: 8/1/01 INCLUDE Irvine32.inc .data menuStr BYTE "1. Choice one",0dh,0ah BYTE "2. Choice two",0dh,0ah BYTE "3. Exit",0dh,0ah,0dh,0ah BYTE "Choice: ",0 OneStr BYTE "Executing Choice One",0dh,0ah,0 TwoStr BYTE "Executing Choice Two",0dh,0ah,0 leavingMsg BYTE "Leaving ShowMenu",0dh,0ah,0 .code main PROC call ShowMenu exit main ENDP ShowMenu PROC call DumpRegs ; register dump mov edx,OFFSET menuStr ; display menu call WriteString call ReadInt call Dispatcher mov edx,OFFSET leavingMsg ; "leaving ShowMenu" call WriteString ret ShowMenu endp Dispatcher proc cmp eax,1 ; choice 1? jne L1 call ChoiceOne L1: cmp eax,2 ; choice 2? jne L2 call ChoiceTwo L2: cmp eax,3 ; choice 3? je L3 call ShowMenu ; unknown choice ; start unwinding the stack L3: ret Dispatcher endp ChoiceOne PROC ; menu choice 1 mov edx,OFFSET OneStr call WriteString call WaitMsg call ShowMenu ; recursive call ret ChoiceOne endp ChoiceTwo proc ; menu choice 2 mov edx,OFFSET TwoStr call WriteString call WaitMsg call ShowMenu ret ChoiceTwo endp END main
; A066713: RATS(2^n): Reverse Add the digits of 2^n, Then Sort: a(n) = A036839(2^n). ; Submitted by Jamie Morken(s3) ; 2,4,8,16,77,55,11,499,89,277,2255,145,11,1111,44567,111499,12299,1234,3467,113467,677789,144556,1222889,14445667,4577789,55669999,1134899,11356999,12237899,445557799,1223555555,11113366,1122222266,1133444455,33555666677,11123334577,122234566889,11234778889,124445667788,113333447788,2667777777788,4444445556667,222348899,11122666888999,1233456777899,2334556789999,11134567788899,12233346679999,123344566788899,1333456777777,23335566788888,1335666667777,1123333444556789,111345667778899 seq $0,79 ; Powers of 2: a(n) = 2^n. seq $0,36839 ; RATS(n): Reverse Add Then Sort the digits.
# Counter: Wraps an integer, can be incremented .class Counter:Obj .field i # Constructor takes a single argument, an # Int object .method $constructor .args n enter load n load $ store_field $:i load $ # Return the initialized object return 1 .method inc enter const 1 load $ load_field $:i call Int:plus load $ store_field $:i const nothing return 0 # check if counter has reached value; return Boolean .method check .args value load value load $ load_field $:i call Int:equals return 1 .method print enter load $ load_field $:i call Int:print return 0
//------------------------------------------------------------------------------ /* This file is part of rippled: https://github.com/ripple/rippled Copyright (c) 2012-2014 Ripple Labs Inc. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 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. */ //============================================================================== #include <ripple/app/paths/FindPaths.h> #include <ripple/basics/StringUtilities.h> #include <ripple/protocol/TxFlags.h> #include <ripple/rpc/impl/TransactionSign.h> #include <beast/unit_test.h> namespace ripple { //------------------------------------------------------------------------------ namespace RPC { /** Fill in the fee on behalf of the client. This is called when the client does not explicitly specify the fee. The client may also put a ceiling on the amount of the fee. This ceiling is expressed as a multiplier based on the current ledger's fee schedule. JSON fields "Fee" The fee paid by the transaction. Omitted when the client wants the fee filled in. "fee_mult_max" A multiplier applied to the current ledger's transaction fee that caps the maximum the fee server should auto fill. If this optional field is not specified, then a default multiplier is used. @param tx The JSON corresponding to the transaction to fill in @param ledger A ledger for retrieving the current fee schedule @param result A JSON object for injecting error results, if any @param admin `true` if this is called by an administrative endpoint. */ static void autofill_fee ( Json::Value& request, Ledger::pointer ledger, Json::Value& result, bool admin) { Json::Value& tx (request["tx_json"]); if (tx.isMember ("Fee")) return; int mult = Tuning::defaultAutoFillFeeMultiplier; if (request.isMember ("fee_mult_max")) { if (request["fee_mult_max"].isNumeric ()) { mult = request["fee_mult_max"].asInt(); } else { RPC::inject_error (rpcHIGH_FEE, RPC::expected_field_message ( "fee_mult_max", "a number"), result); return; } } // Default fee in fee units std::uint64_t const feeDefault = getConfig().TRANSACTION_FEE_BASE; // Administrative endpoints are exempt from local fees std::uint64_t const fee = ledger->scaleFeeLoad (feeDefault, admin); std::uint64_t const limit = mult * ledger->scaleFeeBase (feeDefault); if (fee > limit) { std::stringstream ss; ss << "Fee of " << fee << " exceeds the requested tx limit of " << limit; RPC::inject_error (rpcHIGH_FEE, ss.str(), result); return; } tx ["Fee"] = static_cast<int>(fee); } static Json::Value signPayment( Json::Value const& params, Json::Value& tx_json, RippleAddress const& raSrcAddressID, Ledger::pointer lSnapshot, Role role) { RippleAddress dstAccountID; if (!tx_json.isMember ("Amount")) return RPC::missing_field_error ("tx_json.Amount"); STAmount amount; if (! amountFromJsonNoThrow (amount, tx_json ["Amount"])) return RPC::invalid_field_error ("tx_json.Amount"); if (!tx_json.isMember ("Destination")) return RPC::missing_field_error ("tx_json.Destination"); if (!dstAccountID.setAccountID (tx_json["Destination"].asString ())) return RPC::invalid_field_error ("tx_json.Destination"); if (tx_json.isMember ("Paths") && params.isMember ("build_path")) return RPC::make_error (rpcINVALID_PARAMS, "Cannot specify both 'tx_json.Paths' and 'tx_json.build_path'"); if (!tx_json.isMember ("Paths") && tx_json.isMember ("Amount") && params.isMember ("build_path")) { // Need a ripple path. Currency uSrcCurrencyID; Account uSrcIssuerID; STAmount saSendMax; if (tx_json.isMember ("SendMax")) { if (! amountFromJsonNoThrow (saSendMax, tx_json ["SendMax"])) return RPC::invalid_field_error ("tx_json.SendMax"); } else { // If no SendMax, default to Amount with sender as issuer. saSendMax = amount; saSendMax.setIssuer (raSrcAddressID.getAccountID ()); } if (saSendMax.isNative () && amount.isNative ()) return RPC::make_error (rpcINVALID_PARAMS, "Cannot build XRP to XRP paths."); { LegacyPathFind lpf (role == Role::ADMIN); if (!lpf.isOk ()) return rpcError (rpcTOO_BUSY); auto cache = std::make_shared<RippleLineCache> (lSnapshot); STPathSet spsPaths; STPath fullLiquidityPath; auto valid = findPathsForOneIssuer ( cache, raSrcAddressID.getAccountID(), dstAccountID.getAccountID(), saSendMax.issue (), amount, getConfig ().PATH_SEARCH_OLD, 4, // iMaxPaths spsPaths, fullLiquidityPath); if (!valid) { WriteLog (lsDEBUG, RPCHandler) << "transactionSign: build_path: No paths found."; return rpcError (rpcNO_PATH); } WriteLog (lsDEBUG, RPCHandler) << "transactionSign: build_path: " << spsPaths.getJson (0); if (!spsPaths.empty ()) tx_json["Paths"] = spsPaths.getJson (0); } } return Json::Value(); } //------------------------------------------------------------------------------ // VFALCO TODO This function should take a reference to the params, modify it // as needed, and then there should be a separate function to // submit the tranaction // Json::Value transactionSign ( Json::Value params, bool bSubmit, bool bFailHard, NetworkOPs& netOps, Role role) { Json::Value jvResult; WriteLog (lsDEBUG, RPCHandler) << "transactionSign: " << params; if (! params.isMember ("secret")) return RPC::missing_field_error ("secret"); if (! params.isMember ("tx_json")) return RPC::missing_field_error ("tx_json"); RippleAddress naSeed; if (! naSeed.setSeedGeneric (params["secret"].asString ())) return RPC::make_error (rpcBAD_SEED, RPC::invalid_field_message ("secret")); Json::Value& tx_json (params ["tx_json"]); if (! tx_json.isObject ()) return RPC::object_field_error ("tx_json"); if (! tx_json.isMember ("TransactionType")) return RPC::missing_field_error ("tx_json.TransactionType"); std::string const sType = tx_json ["TransactionType"].asString (); if (! tx_json.isMember ("Account")) return RPC::make_error (rpcSRC_ACT_MISSING, RPC::missing_field_message ("tx_json.Account")); RippleAddress raSrcAddressID; if (! raSrcAddressID.setAccountID (tx_json["Account"].asString ())) return RPC::make_error (rpcSRC_ACT_MALFORMED, RPC::invalid_field_message ("tx_json.Account")); bool const verify = !(params.isMember ("offline") && params["offline"].asBool ()); if (!tx_json.isMember ("Sequence") && !verify) return RPC::missing_field_error ("tx_json.Sequence"); // Check for current ledger if (verify && !getConfig ().RUN_STANDALONE && (getApp().getLedgerMaster().getValidatedLedgerAge() > 120)) return rpcError (rpcNO_CURRENT); // Check for load if (getApp().getFeeTrack().isLoadedCluster() && (role != Role::ADMIN)) return rpcError(rpcTOO_BUSY); Ledger::pointer lSnapshot = netOps.getCurrentLedger (); AccountState::pointer asSrc; if (verify) { asSrc = netOps.getAccountState (lSnapshot, raSrcAddressID); if (!asSrc) { // If not offline and did not find account, error. WriteLog (lsDEBUG, RPCHandler) << "transactionSign: Failed to find source account " << "in current ledger: " << raSrcAddressID.humanAccountID (); return rpcError (rpcSRC_ACT_NOT_FOUND); } } autofill_fee (params, lSnapshot, jvResult, role == Role::ADMIN); if (RPC::contains_error (jvResult)) return jvResult; if ("Payment" == sType) { auto e = signPayment( params, tx_json, raSrcAddressID, lSnapshot, role); if (contains_error(e)) return e; } if (!tx_json.isMember ("Sequence")) tx_json["Sequence"] = asSrc->getSeq (); if (!tx_json.isMember ("Flags")) tx_json["Flags"] = tfFullyCanonicalSig; if (verify) { SLE::pointer sleAccountRoot = netOps.getSLEi (lSnapshot, Ledger::getAccountRootIndex (raSrcAddressID.getAccountID ())); if (!sleAccountRoot) // XXX Ignore transactions for accounts not created. return rpcError (rpcSRC_ACT_NOT_FOUND); } RippleAddress secret = RippleAddress::createSeedGeneric ( params["secret"].asString ()); RippleAddress masterGenerator = RippleAddress::createGeneratorPublic ( secret); RippleAddress masterAccountPublic = RippleAddress::createAccountPublic ( masterGenerator, 0); if (verify) { auto account = masterAccountPublic.getAccountID(); auto const& sle = asSrc->peekSLE(); WriteLog (lsWARNING, RPCHandler) << "verify: " << masterAccountPublic.humanAccountID () << " : " << raSrcAddressID.humanAccountID (); if (raSrcAddressID.getAccountID () == account) { if (sle.isFlag(lsfDisableMaster)) return rpcError (rpcMASTER_DISABLED); } else if (!sle.isFieldPresent(sfRegularKey) || account != sle.getFieldAccount160 (sfRegularKey)) { return rpcError (rpcBAD_SECRET); } } STParsedJSONObject parsed ("tx_json", tx_json); if (!parsed.object.get()) { jvResult ["error"] = parsed.error ["error"]; jvResult ["error_code"] = parsed.error ["error_code"]; jvResult ["error_message"] = parsed.error ["error_message"]; return jvResult; } std::unique_ptr<STObject> sopTrans = std::move(parsed.object); sopTrans->setFieldVL ( sfSigningPubKey, masterAccountPublic.getAccountPublic ()); SerializedTransaction::pointer stpTrans; try { stpTrans = std::make_shared<SerializedTransaction> (*sopTrans); } catch (std::exception&) { return RPC::make_error (rpcINTERNAL, "Exception occurred during transaction"); } std::string reason; if (!passesLocalChecks (*stpTrans, reason)) return RPC::make_error (rpcINVALID_PARAMS, reason); if (params.isMember ("debug_signing")) { jvResult["tx_unsigned"] = strHex ( stpTrans->getSerializer ().peekData ()); jvResult["tx_signing_hash"] = to_string (stpTrans->getSigningHash ()); } // FIXME: For performance, transactions should not be signed in this code // path. RippleAddress naAccountPrivate = RippleAddress::createAccountPrivate ( masterGenerator, secret, 0); stpTrans->sign (naAccountPrivate); Transaction::pointer tpTrans; try { tpTrans = std::make_shared<Transaction> (stpTrans, Validate::NO); } catch (std::exception&) { return RPC::make_error (rpcINTERNAL, "Exception occurred during transaction"); } try { // FIXME: For performance, should use asynch interface tpTrans = netOps.submitTransactionSync (tpTrans, role == Role::ADMIN, true, bFailHard, bSubmit); if (!tpTrans) { return RPC::make_error (rpcINTERNAL, "Unable to sterilize transaction."); } } catch (std::exception&) { return RPC::make_error (rpcINTERNAL, "Exception occurred during transaction submission."); } try { jvResult["tx_json"] = tpTrans->getJson (0); jvResult["tx_blob"] = strHex ( tpTrans->getSTransaction ()->getSerializer ().peekData ()); if (temUNCERTAIN != tpTrans->getResult ()) { std::string sToken; std::string sHuman; transResultInfo (tpTrans->getResult (), sToken, sHuman); jvResult["engine_result"] = sToken; jvResult["engine_result_code"] = tpTrans->getResult (); jvResult["engine_result_message"] = sHuman; } return jvResult; } catch (std::exception&) { return RPC::make_error (rpcINTERNAL, "Exception occurred during JSON handling."); } } class JSONRPC_test : public beast::unit_test::suite { public: void testAutoFillFees () { RippleAddress rootSeedMaster = RippleAddress::createSeedGeneric ("masterpassphrase"); RippleAddress rootGeneratorMaster = RippleAddress::createGeneratorPublic (rootSeedMaster); RippleAddress rootAddress = RippleAddress::createAccountPublic (rootGeneratorMaster, 0); std::uint64_t startAmount (100000); Ledger::pointer ledger (std::make_shared <Ledger> ( rootAddress, startAmount)); { Json::Value req; Json::Value result; Json::Reader ().parse ( "{ \"fee_mult_max\" : 1, \"tx_json\" : { } } " , req); autofill_fee (req, ledger, result, true); expect (! contains_error (result)); } { Json::Value req; Json::Value result; Json::Reader ().parse ( "{ \"fee_mult_max\" : 0, \"tx_json\" : { } } " , req); autofill_fee (req, ledger, result, true); expect (contains_error (result)); } } void run () { testAutoFillFees (); } }; BEAST_DEFINE_TESTSUITE(JSONRPC,ripple_app,ripple); } // RPC } // ripple
; ; Startup for Hübler/Evert-MC ; ; https://hc-ddr.hucki.net/wiki/doku.php/homecomputer/huebler#hueblerevert-mc ; module hemc_crt0 INCLUDE "target/hemc/def/hemc.def" ;-------- ; Include zcc_opt.def to find out some info ;-------- defc crt0 = 1 INCLUDE "zcc_opt.def" ;-------- ; Some scope definitions ;-------- EXTERN _main ;main() is always external to crt0 code EXTERN asm_im1_handler PUBLIC cleanup ;jp'd to by exit() PUBLIC l_dcal ;jp(hl) defc TAR__clib_exit_stack_size = 4 defc TAR__register_sp = $e800 defc CRT_KEY_DEL = 8 defc __CPU_CLOCK = 2457600 defc CONSOLE_COLUMNS = 64 defc CONSOLE_ROWS = 24 defc GRAPHICS_CHAR_SET = 128 + 32 defc GRAPHICS_CHAR_UNSET = 32 PUBLIC GRAPHICS_CHAR_SET PUBLIC GRAPHICS_CHAR_UNSET defc TAR__crt_enable_rst = $8080 EXTERN asm_im1_handler defc _z80_rst_38h = asm_im1_handler INCLUDE "crt/classic/crt_rules.inc" defc CRT_ORG_CODE = 0x0000 org CRT_ORG_CODE if (ASMPC<>$0000) defs CODE_ALIGNMENT_ERROR endif jp program INCLUDE "crt/classic/crt_z80_rsts.asm" program: INCLUDE "crt/classic/crt_init_sp.asm" INCLUDE "crt/classic/crt_init_atexit.asm" call crt0_init_bss ld hl,0 add hl,sp ld (exitsp),hl ei ; Optional definition for auto MALLOC init ; it assumes we have free space between the end of ; the compiled program and the stack pointer IF DEFINED_USING_amalloc INCLUDE "crt/classic/crt_init_amalloc.asm" ENDIF ld hl,0 push hl ;argv push hl ;argc call _main pop bc pop bc cleanup: jp RESTART l_dcal: jp (hl) ;Used for function pointer calls INCLUDE "crt/classic/crt_runtime_selection.asm" INCLUDE "crt/classic/crt_section.asm"
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .section .note.GNU-stack,"",%progbits .text .p2align 4, 0x90 .globl n8_cpAdd_BNU .type n8_cpAdd_BNU, @function n8_cpAdd_BNU: movslq %ecx, %rcx xor %rax, %rax cmp $(2), %rcx jge .LADD_GE2gas_1 add %rax, %rax movq (%rsi), %r8 adcq (%rdx), %r8 movq %r8, (%rdi) sbb %rax, %rax jmp .LFINALgas_1 .LADD_GE2gas_1: jg .LADD_GT2gas_1 add %rax, %rax movq (%rsi), %r8 adcq (%rdx), %r8 movq (8)(%rsi), %r9 adcq (8)(%rdx), %r9 movq %r8, (%rdi) movq %r9, (8)(%rdi) sbb %rax, %rax jmp .LFINALgas_1 .LADD_GT2gas_1: cmp $(4), %rcx jge .LADD_GE4gas_1 add %rax, %rax movq (%rsi), %r8 adcq (%rdx), %r8 movq (8)(%rsi), %r9 adcq (8)(%rdx), %r9 movq (16)(%rsi), %r10 adcq (16)(%rdx), %r10 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) sbb %rax, %rax jmp .LFINALgas_1 .LADD_GE4gas_1: jg .LADD_GT4gas_1 add %rax, %rax movq (%rsi), %r8 adcq (%rdx), %r8 movq (8)(%rsi), %r9 adcq (8)(%rdx), %r9 movq (16)(%rsi), %r10 adcq (16)(%rdx), %r10 movq (24)(%rsi), %r11 adcq (24)(%rdx), %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) sbb %rax, %rax jmp .LFINALgas_1 .LADD_GT4gas_1: cmp $(6), %rcx jge .LADD_GE6gas_1 add %rax, %rax movq (%rsi), %r8 adcq (%rdx), %r8 movq (8)(%rsi), %r9 adcq (8)(%rdx), %r9 movq (16)(%rsi), %r10 adcq (16)(%rdx), %r10 movq (24)(%rsi), %r11 adcq (24)(%rdx), %r11 movq (32)(%rsi), %rcx adcq (32)(%rdx), %rcx movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) movq %rcx, (32)(%rdi) sbb %rax, %rax jmp .LFINALgas_1 .LADD_GE6gas_1: jg .LADD_GT6gas_1 add %rax, %rax movq (%rsi), %r8 adcq (%rdx), %r8 movq (8)(%rsi), %r9 adcq (8)(%rdx), %r9 movq (16)(%rsi), %r10 adcq (16)(%rdx), %r10 movq (24)(%rsi), %r11 adcq (24)(%rdx), %r11 movq (32)(%rsi), %rcx adcq (32)(%rdx), %rcx movq (40)(%rsi), %rsi adcq (40)(%rdx), %rsi movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) movq %rcx, (32)(%rdi) movq %rsi, (40)(%rdi) sbb %rax, %rax jmp .LFINALgas_1 .LADD_GT6gas_1: cmp $(8), %rcx jge .LADD_GE8gas_1 .LADD_EQ7gas_1: add %rax, %rax movq (%rsi), %r8 adcq (%rdx), %r8 movq (8)(%rsi), %r9 adcq (8)(%rdx), %r9 movq (16)(%rsi), %r10 adcq (16)(%rdx), %r10 movq (24)(%rsi), %r11 adcq (24)(%rdx), %r11 movq (32)(%rsi), %rcx adcq (32)(%rdx), %rcx movq %r8, (%rdi) movq (40)(%rsi), %r8 adcq (40)(%rdx), %r8 movq (48)(%rsi), %rsi adcq (48)(%rdx), %rsi movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) movq %rcx, (32)(%rdi) movq %r8, (40)(%rdi) movq %rsi, (48)(%rdi) sbb %rax, %rax jmp .LFINALgas_1 .LADD_GE8gas_1: jg .LADD_GT8gas_1 add %rax, %rax movq (%rsi), %r8 adcq (%rdx), %r8 movq (8)(%rsi), %r9 adcq (8)(%rdx), %r9 movq (16)(%rsi), %r10 adcq (16)(%rdx), %r10 movq (24)(%rsi), %r11 adcq (24)(%rdx), %r11 movq (32)(%rsi), %rcx adcq (32)(%rdx), %rcx movq %r8, (%rdi) movq (40)(%rsi), %r8 adcq (40)(%rdx), %r8 movq %r9, (8)(%rdi) movq (48)(%rsi), %r9 adcq (48)(%rdx), %r9 movq (56)(%rsi), %rsi adcq (56)(%rdx), %rsi movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) movq %rcx, (32)(%rdi) movq %r8, (40)(%rdi) movq %r9, (48)(%rdi) movq %rsi, (56)(%rdi) sbb %rax, %rax jmp .LFINALgas_1 .LADD_GT8gas_1: mov %rax, %r8 mov %rcx, %rax and $(3), %rcx xor %rax, %rcx lea (%rsi,%rcx,8), %rsi lea (%rdx,%rcx,8), %rdx lea (%rdi,%rcx,8), %rdi neg %rcx add %r8, %r8 jmp .LADD_GLOOPgas_1 .p2align 4, 0x90 .LADD_GLOOPgas_1: movq (%rsi,%rcx,8), %r8 movq (8)(%rsi,%rcx,8), %r9 movq (16)(%rsi,%rcx,8), %r10 movq (24)(%rsi,%rcx,8), %r11 adcq (%rdx,%rcx,8), %r8 adcq (8)(%rdx,%rcx,8), %r9 adcq (16)(%rdx,%rcx,8), %r10 adcq (24)(%rdx,%rcx,8), %r11 movq %r8, (%rdi,%rcx,8) movq %r9, (8)(%rdi,%rcx,8) movq %r10, (16)(%rdi,%rcx,8) movq %r11, (24)(%rdi,%rcx,8) lea (4)(%rcx), %rcx jrcxz .LADD_LLAST0gas_1 jmp .LADD_GLOOPgas_1 .LADD_LLAST0gas_1: sbb %rcx, %rcx and $(3), %rax jz .LFIN0gas_1 .LADD_LLOOPgas_1: test $(2), %rax jz .LADD_LLAST1gas_1 add %rcx, %rcx movq (%rsi), %r8 movq (8)(%rsi), %r9 adcq (%rdx), %r8 adcq (8)(%rdx), %r9 movq %r8, (%rdi) movq %r9, (8)(%rdi) sbb %rcx, %rcx test $(1), %rax jz .LFIN0gas_1 add $(16), %rsi add $(16), %rdx add $(16), %rdi .LADD_LLAST1gas_1: add %rcx, %rcx movq (%rsi), %r8 adcq (%rdx), %r8 movq %r8, (%rdi) sbb %rcx, %rcx .LFIN0gas_1: mov %rcx, %rax .LFINALgas_1: neg %rax ret .Lfe1: .size n8_cpAdd_BNU, .Lfe1-(n8_cpAdd_BNU)
/* * 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: mov (1|M0) r22.5<1>:ud 0x1200120:ud mov (1|M0) f0.0<1>:uw r24.0<0;1,0>:ub (W&~f0.0)jmpi L592 L48: mov (8|M0) r17.0<1>:ud r26.0<8;8,1>:ud cmp (1|M0) (eq)f1.0 null.0<1>:w r24.2<0;1,0>:ub 0x1:uw mov (16|M0) r48.0<1>:uw 0xFFFF:uw mov (16|M0) r49.0<1>:uw 0xFFFF:uw mov (16|M0) r57.0<1>:uw 0xFFFF:uw mov (16|M0) r58.0<1>:uw 0xFFFF:uw add (1|M0) a0.0<1>:ud r24.5<0;1,0>:ud 0x43EA100:ud mov (1|M0) r16.2<1>:ud 0xE000:ud (~f1.0) mov (1|M0) r17.2<1>:f r9.1<0;1,0>:f (~f1.0) mov (1|M0) r17.3<1>:f r9.4<0;1,0>:f (f1.0) mov (1|M0) r17.2<1>:f r9.1<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r9.7<0;1,0>:f send (1|M0) r46:uw r16:ub 0x2 a0.0 (~f1.0) mov (1|M0) r17.2<1>:f r9.6<0;1,0>:f (~f1.0) mov (1|M0) r17.3<1>:f r9.4<0;1,0>:f (f1.0) mov (1|M0) r17.2<1>:f r9.6<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r9.7<0;1,0>:f send (1|M0) r55:uw r16:ub 0x2 a0.0 add (1|M0) a0.0<1>:ud r24.5<0;1,0>:ud 0x44EC201:ud mov (1|M0) r16.2<1>:ud 0xC000:ud (~f1.0) mov (1|M0) r17.2<1>:f r9.1<0;1,0>:f (~f1.0) mov (1|M0) r17.3<1>:f r9.4<0;1,0>:f (f1.0) mov (1|M0) r17.2<1>:f r9.1<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r9.7<0;1,0>:f send (1|M0) r50:uw r16:ub 0x2 a0.0 (~f1.0) mov (1|M0) r17.2<1>:f r9.6<0;1,0>:f (~f1.0) mov (1|M0) r17.3<1>:f r9.4<0;1,0>:f (f1.0) mov (1|M0) r17.2<1>:f r9.6<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r9.7<0;1,0>:f send (1|M0) r59:uw r16:ub 0x2 a0.0 mov (1|M0) a0.8<1>:uw 0x5C0:uw mov (1|M0) a0.9<1>:uw 0x640:uw mov (1|M0) a0.10<1>:uw 0x680:uw add (4|M0) a0.12<1>:uw a0.8<4;4,1>:uw 0x120:uw L592: nop
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r8 push %rbx push %rcx push %rdi push %rsi lea addresses_WT_ht+0x9e04, %r10 sub %r8, %r8 mov $0x6162636465666768, %rsi movq %rsi, %xmm7 movups %xmm7, (%r10) nop nop nop nop add $7601, %rsi lea addresses_WC_ht+0x10a74, %rsi lea addresses_D_ht+0x4c34, %rdi cmp %r8, %r8 mov $97, %rcx rep movsb nop dec %rcx lea addresses_WC_ht+0x14a74, %rsi lea addresses_UC_ht+0x5474, %rdi nop nop nop nop nop xor $46042, %rbx mov $110, %rcx rep movsq nop nop nop nop add %rsi, %rsi lea addresses_UC_ht+0x4134, %rsi lea addresses_D_ht+0x3b0c, %rdi clflush (%rsi) nop cmp $34967, %r10 mov $121, %rcx rep movsb nop sub $20342, %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %r8 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r8 push %rax push %rbp push %rbx // Store lea addresses_US+0x15a74, %rbx nop and $57011, %rax mov $0x5152535455565758, %r12 movq %r12, %xmm4 movaps %xmm4, (%rbx) nop add %r12, %r12 // Faulty Load mov $0x1fe0a30000000274, %r8 nop nop nop nop nop cmp %r12, %r12 movups (%r8), %xmm6 vpextrq $0, %xmm6, %rbx lea oracles, %r10 and $0xff, %rbx shlq $12, %rbx mov (%r10,%rbx,1), %rbx pop %rbx pop %rbp pop %rax pop %r8 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': True, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_US'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 6, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_D_ht'}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A021198: Decimal expansion of 1/194. ; 0,0,5,1,5,4,6,3,9,1,7,5,2,5,7,7,3,1,9,5,8,7,6,2,8,8,6,5,9,7,9,3,8,1,4,4,3,2,9,8,9,6,9,0,7,2,1,6,4,9,4,8,4,5,3,6,0,8,2,4,7,4,2,2,6,8,0,4,1,2,3,7,1,1,3,4,0,2,0,6,1,8,5,5,6,7,0,1,0,3,0,9,2,7,8,3,5,0,5 add $0,2 mov $2,10 pow $2,$0 div $2,1940 mov $0,$2 mod $0,10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; zx spectrum ram model ;; ;; generated by target/zx/startup/zx_crt_ram.m4 ;; ;; ;; ;; 48k memory model (flat 64k address space) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; CRT AND CLIB CONFIGURATION ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; include "../crt_defaults.inc" include "crt_target_defaults.inc" include "../crt_rules.inc" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; SET UP MEMORY MODEL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; include "memory_model.inc" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; GLOBAL SYMBOLS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; include "../clib_constants.inc" include "clib_target_constants.inc" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; INSTANTIATE DRIVERS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; When FILEs and FDSTRUCTs are instantiated labels are assigned ; to point at created structures. ; ; The label formats are: ; ; __i_stdio_file_n = address of static FILE structure #n (0..__I_STDIO_NUM_FILE-1) ; __i_fcntl_fdstruct_n = address of static FDSTRUCT #n (0..__I_FCNTL_NUM_FD-1) ; __i_fcntl_heap_n = address of allocation #n on heap (0..__I_FCNTL_NUM_HEAP-1) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FILE : _stdin ; ; driver: zx_01_input_kbd_inkey ; fd : 0 ; mode : read only ; type : 001 = input terminal ; tie : __i_fcntl_fdstruct_1 ; ; ioctl_flags : 0x03b0 ; buffer size : 64 bytes ; debounce : 1 ms ; repeat_start : 500 ms ; repeat_period : 15 ms ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SECTION data_clib SECTION data_stdio ; FILE * PUBLIC _stdin _stdin: defw __i_stdio_file_0 + 2 ; FILE structure __i_stdio_file_0: ; open files link defw 0 ; jump to underlying fd defb 195 defw __i_fcntl_fdstruct_0 ; state_flags_0 ; state_flags_1 ; conversion flags ; ungetc defb 0x40 ; read + stdio manages ungetc + normal file type defb 0x02 ; last operation was read defb 0 defb 0 ; mtx_recursive defb 0 ; thread owner = none defb 0x02 ; mtx_recursive defb 0 ; lock count = 0 defb 0xfe ; atomic spinlock defw 0 ; list of blocked threads ; fd table entry SECTION data_fcntl_fdtable_body defw __i_fcntl_fdstruct_0 ; FDSTRUCT structure SECTION data_fcntl_stdio_heap_body EXTERN console_01_input_terminal_fdriver EXTERN zx_01_input_kbd_inkey __i_fcntl_heap_0: ; heap header defw __i_fcntl_heap_1 defw 105 defw 0 __i_fcntl_fdstruct_0: ; FDSTRUCT structure ; call to first entry to driver defb 205 defw console_01_input_terminal_fdriver ; jump to driver defb 195 defw zx_01_input_kbd_inkey ; flags ; reference_count ; mode_byte defb 0x01 ; stdio handles ungetc + type = input terminal defb 2 defb 0x01 ; read only ; ioctl_flags defw 0x03b0 ; mtx_plain defb 0 ; thread owner = none defb 0x01 ; mtx_plain defb 0 ; lock count = 0 defb 0xfe ; atomic spinlock defw 0 ; list of blocked threads ; tied output terminal ; pending_char ; read_index defw __i_fcntl_fdstruct_1 defb 0 defw 0 ; b_array_t edit_buffer defw __edit_buffer_0 defw 0 defw 64 ; getk_state ; getk_lastk ; getk_debounce_ms ; getk_repeatbegin_ms ; getk_repeatperiod_ms defb 0 defb 0 defb 1 defw 500 defw 15 ; reserve space for edit buffer __edit_buffer_0: defs 64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FILE : _stdout ; ; driver: zx_01_output_char_32 ; fd : 1 ; mode : write only ; type : 002 = output terminal ; ; ioctl_flags : 0x2370 ; cursor coord : (0,0) ; window : (0,32,0,24) ; scroll limit : 0 ; font address : _font_8x8_rom ; text colour : 56 ; text mask : 0 ; background : 56 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SECTION data_clib SECTION data_stdio ; FILE * PUBLIC _stdout _stdout: defw __i_stdio_file_1 + 2 ; FILE structure __i_stdio_file_1: ; open files link defw __i_stdio_file_0 ; jump to underlying fd defb 195 defw __i_fcntl_fdstruct_1 ; state_flags_0 ; state_flags_1 ; conversion flags ; ungetc defb 0x80 ; write + normal file type defb 0 ; last operation was write defb 0 defb 0 ; mtx_recursive defb 0 ; thread owner = none defb 0x02 ; mtx_recursive defb 0 ; lock count = 0 defb 0xfe ; atomic spinlock defw 0 ; list of blocked threads ; fd table entry SECTION data_fcntl_fdtable_body defw __i_fcntl_fdstruct_1 ; FDSTRUCT structure SECTION data_fcntl_stdio_heap_body EXTERN console_01_output_terminal_fdriver EXTERN zx_01_output_char_32 __i_fcntl_heap_1: ; heap header defw __i_fcntl_heap_2 defw 35 defw __i_fcntl_heap_0 __i_fcntl_fdstruct_1: ; FDSTRUCT structure ; call to first entry to driver defb 205 defw console_01_output_terminal_fdriver ; jump to driver defb 195 defw zx_01_output_char_32 ; flags ; reference_count ; mode_byte defb 0x02 ; type = output terminal defb 2 defb 0x02 ; write only ; ioctl_flags defw 0x2370 ; mtx_plain defb 0 ; thread owner = none defb 0x01 ; mtx_plain defb 0 ; lock count = 0 defb 0xfe ; atomic spinlock defw 0 ; list of blocked threads ; cursor coordinate ; window rectangle ; scroll limit defb 0, 0 defb 0, 32, 0, 24 defb 0 ; font address ; text colour ; text mask ; background colour EXTERN _font_8x8_rom defw _font_8x8_rom - 256 defb 56 defb 0 defb 56 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; DUPED FILE DESCRIPTOR ; ; FILE : _stderr ; flags : 0x80 ; ; fd : 2 ; dup fd: __i_fcntl_fdstruct_1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SECTION data_clib SECTION data_stdio ; FILE * PUBLIC _stderr _stderr: defw __i_stdio_file_2 + 2 ; FILE structure __i_stdio_file_2: ; open files link defw __i_stdio_file_1 ; jump to duped fd defb 195 defw __i_fcntl_fdstruct_1 ; state_flags_0 ; state_flags_1 ; conversion flags ; ungetc defb 0x80 defb 0 defb 0 defb 0 ; mtx_recursive defb 0 ; thread owner = none defb 0x02 ; mtx_recursive defb 0 ; lock count = 0 defb 0xfe ; atomic spinlock defw 0 ; list of blocked threads ; fd table entry SECTION data_fcntl_fdtable_body defw __i_fcntl_fdstruct_1 ; FDSTRUCT structure defc __i_fcntl_fdstruct_2 = __i_fcntl_fdstruct_1 ; adjust reference count on duped FDSTRUCT SECTION code_crt_init ld hl,__i_fcntl_fdstruct_1 + 7 ; & FDSTRUCT.ref_count inc (hl) inc (hl) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; create open and closed FILE lists ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; __clib_fopen_max = max number of open FILEs specified by user ; 3 = number of static FILEs instantiated in crt ; __i_stdio_file_n = address of static FILE structure #n (0..I_STDIO_FILE_NUM-1) SECTION data_clib SECTION data_stdio IF (__clib_fopen_max > 0) || (3 > 0) ; number of FILEs > 0 ; construct list of open files IF 3 > 0 ; number of FILEs statically generated > 0 SECTION data_clib SECTION data_stdio PUBLIC __stdio_open_file_list __stdio_open_file_list: defw __i_stdio_file_2 ELSE ; number of FILEs statically generated = 0 SECTION bss_clib SECTION bss_stdio PUBLIC __stdio_open_file_list __stdio_open_file_list: defw 0 ENDIF ; construct list of closed / available FILEs SECTION data_clib SECTION data_stdio PUBLIC __stdio_closed_file_list __stdio_closed_file_list: defw 0, __stdio_closed_file_list IF __clib_fopen_max > 3 ; create extra FILE structures SECTION bss_clib SECTION bss_stdio __stdio_file_extra: defs (__clib_fopen_max - 3) * 15 SECTION code_crt_init ld bc,__stdio_closed_file_list ld de,__stdio_file_extra ld l,__clib_fopen_max - 3 loop: push hl EXTERN asm_p_forward_list_alt_push_front call asm_p_forward_list_alt_push_front ld de,15 add hl,de ex de,hl pop hl dec l jr nz, loop ENDIF ENDIF IF (__clib_fopen_max = 0) && (3 = 0) ; create empty file lists SECTION bss_clib SECTION bss_stdio PUBLIC __stdio_open_file_list __stdio_open_file_list: defw 0 SECTION data_clib SECTION data_stdio PUBLIC __stdio_closed_file_list __stdio_closed_file_list: defw 0, __stdio_closed_file_list ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; create fd table ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; __clib_open_max = max number of open fds specified by user ; 3 = number of static file descriptors created PUBLIC __fcntl_fdtbl PUBLIC __fcntl_fdtbl_size IF 3 > 0 ; create rest of fd table in data segment SECTION data_fcntl_fdtable_body EXTERN ASMHEAD_data_fcntl_fdtable_body defc __fcntl_fdtbl = ASMHEAD_data_fcntl_fdtable_body IF __clib_open_max > 3 SECTION data_fcntl_fdtable_body defs (__clib_open_max - 3) * 2 defc __fcntl_fdtbl_size = __clib_open_max ELSE defc __fcntl_fdtbl_size = 3 ENDIF ELSE IF __clib_open_max > 0 ; create fd table in bss segment SECTION bss_clib SECTION bss_fcntl __fcntl_fdtbl: defs __clib_open_max * 2 ELSE ; no fd table at all defc __fcntl_fdtbl = 0 ENDIF defc __fcntl_fdtbl_size = __clib_open_max ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; finalize stdio heap ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; __clib_stdio_heap_size = desired stdio heap size in bytes ; 140 = byte size of static FDSTRUCTs ; 2 = number of heap allocations ; __i_fcntl_heap_n = address of allocation #n on heap (0..__I_FCNTL_NUM_HEAP-1) IF 140 > 0 ; static FDSTRUCTs have been allocated in the heap SECTION data_clib SECTION data_fcntl PUBLIC __stdio_heap __stdio_heap: defw __stdio_block SECTION data_fcntl_stdio_heap_head __stdio_block: defb 0 ; no owner defb 0x01 ; mtx_plain defb 0 ; number of lock acquisitions defb 0xfe ; spinlock (unlocked) defw 0 ; list of threads blocked on mutex IF __clib_stdio_heap_size > (140 + 14) ; expand stdio heap to desired size SECTION data_fcntl_stdio_heap_body __i_fcntl_heap_2: defw __i_fcntl_heap_3 defw 0 defw __i_fcntl_heap_1 defs __clib_stdio_heap_size - 140 - 14 ; terminate stdio heap SECTION data_fcntl_stdio_heap_tail __i_fcntl_heap_3: defw 0 ELSE ; terminate stdio heap SECTION data_fcntl_stdio_heap_tail __i_fcntl_heap_2: defw 0 ENDIF ELSE ; no FDSTRUCTs statically created IF __clib_stdio_heap_size > 14 SECTION data_clib SECTION data_fcntl PUBLIC __stdio_heap __stdio_heap: defw __stdio_block SECTION bss_clib SECTION bss_fcntl PUBLIC __stdio_block __stdio_block: defs __clib_stdio_heap_size SECTION code_crt_init ld hl,__stdio_block ld bc,__clib_stdio_heap_size EXTERN asm_heap_init call asm_heap_init ENDIF ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; STARTUP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SECTION CODE PUBLIC __Start, __Exit EXTERN _main __Start: IF __crt_enable_restart = 0 ; returning to basic push iy exx push hl ENDIF ; set stack address IF (__register_sp = -1) || (__crt_enable_restart = 0) ; save current sp if sp not supplied or returning to basic ld (__sp),sp ENDIF __Restart: IF __register_sp != -1 ; crt supplies sp ld sp,__register_sp ENDIF ; parse command line IF __crt_enable_commandline ld hl,0 push hl ; argv[argc] = NULL add hl,sp push hl ; argv[0] = "" dec hl dec hl ; hl = argv ld bc,1 ; bc = argc = 1 IF __SDCC | __SDCC_IX | __SDCC_IY push hl ; argv push bc ; argc ELSE push bc ; argc push hl ; argv ENDIF ENDIF ; initialize sections include "../clib_init_data.inc" include "../clib_init_bss.inc" SECTION code_crt_init ; user and library initialization SECTION code_crt_main ; call user program call _main ; hl = return status ; run exit stack IF __clib_exit_stack_size > 0 EXTERN asm_exit jp asm_exit ; exit function jumps to __Exit ENDIF __Exit: IF __crt_enable_restart = 0 ; returning to basic push hl ; save return status ENDIF SECTION code_crt_exit ; user and library cleanup SECTION code_crt_return ; close files include "../clib_close.inc" ; exit program IF __crt_enable_restart = 0 ; returning to basic pop bc ; bc = return status ld sp,(__sp) ; reset stack location exx pop hl exx pop iy im 1 ei ret ELSE ; restart program IF __register_sp = -1 ; restore sp ld sp,(__sp) ENDIF jp __Restart ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; RUNTIME VARS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF (__register_sp = -1) || (__crt_enable_restart = 0) SECTION BSS_UNINITIALIZED __sp: defw 0 ENDIF include "../clib_variables.inc" include "clib_target_variables.inc" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; CLIB STUBS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; include "../clib_stubs.inc"
; A297619: a(n) = 2*a(n-1) + 2*a(n-2) - 4*a(n-3), a(1) = 0, a(2) = 0, a(3) = 8. ; 0,0,8,16,48,96,224,448,960,1920,3968,7936,16128,32256,65024,130048,261120,522240,1046528,2093056,4190208,8380416,16769024,33538048,67092480,134184960,268402688,536805376,1073676288,2147352576,4294836224,8589672448,17179607040,34359214080,68718952448,137437904896,274876858368,549753716736,1099509530624,2199019061248,4398042316800,8796084633600,17592177655808,35184355311616,70368727400448,140737454800896,281474943156224,562949886312448,1125899839733760,2251799679467520,4503599493152768,9007198986305536 trn $0,1 mov $2,$0 lpb $0,1 sub $0,1 mov $3,2 lpe mov $1,2 pow $3,$2 div $2,2 pow $1,$2 add $1,1 gcd $4,$3 add $4,7 sub $4,$1 add $0,$4 mov $1,$0 sub $1,6 mul $1,8
; A052536: Number of compositions of n when parts 1 and 2 are of two kinds. ; 1,2,6,17,49,141,406,1169,3366,9692,27907,80355,231373,666212,1918281,5523470,15904198,45794313,131859469,379674209,1093228314,3147825473,9063802210,26098178316,75146709475,216376326215,623030800329,1793945691512,5165460748321,14873351444634,42826108642390,123312865178849,355065244091913,1022369623633349,2943796005721198,8476322773071681,24406598695581694,70276000081023884,202351677469999971,582648433714418219,1677669301062230773,4830656225716692348,13909320243435658825,40050291429244745702 mov $1,1 lpb $0 sub $0,1 mov $2,$1 add $4,$1 add $3,$4 add $1,$3 mov $3,$2 lpe mov $0,$1
;Addition of 2 16-bit numbers jmp START num1: DB 00H,03H ;1st 16-bit number num2: DB 05H,06H ;2nd 16-bit number result: DB 00H,00H,00H ;16-bit result START: xra a lhld num1 ;get number 1 xchg lhld num2 ;get number 2 dad d ;add the numbers jnc NEXT ;skip if no carry is generated inr a ;increment if carry is generated NEXT: shld result ;store lower 16-bit result sta result+2 ;store carry if generated hlt
; the method used in the original PutInt8 is quite general and could be used with integers of any size ; this method on the other hand, is quite simple and straight-forward, but is not general at all global _start extern ExitProcess %include "lib.h" section .data newline db 10, 0 negative_sign db "-", 0 section .bss outBuffer resb 10 section .code _start: mov AL, -72 ;enter your number here to test the procedure call PutInt8 push 0 call ExitProcess ;----------------------------------------------------------- ;PutInt8 procedure displays a signed 8-bit integer that is ;in AL register. All registers are preserved. ;----------------------------------------------------------- PutInt8: push EAX push EBX push ECX xor AH, AH test AL, 80H jz print_first_digit negative_num: puts negative_sign neg AL print_first_digit: mov BL, 100 div BL xor EBX, EBX mov BL, AL cmp BL, 0 je skip i2a EBX, outBuffer puts outBuffer jmp print_rest skip: mov CL, 1 ;set flag for not displaying beginning 0's print_rest: mov BL, AH xor EAX, EAX mov AL, BL mov BL, 10 div BL print_second_digit: xor EBX, EBX mov BL, AL cmp BL, 0 je check_and_skip i2a EBX, outBuffer puts outBuffer jmp print_third_digit check_and_skip: cmp CL, 1 je print_third_digit ;if previous digit was 0, skip this 0 as well i2a EBX, outBuffer puts outBuffer print_third_digit: xor EBX, EBX mov BL, AH i2a EBX, outBuffer puts outBuffer puts newline finish_proc: pop ECX pop EBX pop EAX ret
; A082081: a(n) = fixed point when the pseudo-log function A008475[ ] is iterated. ; Submitted by Simon Strandgaard ; 0,2,3,4,5,5,7,8,9,7,11,7,13,9,8,16,17,11,19,9,7,13,23,11,25,8,27,11,29,7,31,32,9,19,7,13,37,7,16,13,41,7,43,8,9,25,47,19,49,27,9,17,53,29,16,8,13,31,59,7,61,9,16,64,11,16,67,7,8,9,71,17,73,16,11,23,11,11,79,7,81,43,83,9,13,9,32,19,89,16,9,27,19,49,11,7,97,9,9,29 add $0,1 lpb $0 trn $0,1 seq $0,8475 ; If n = Product (p_j^k_j) then a(n) = Sum (p_j^k_j) (a(1) = 0 by convention). lpe
Name: ys_w49.asm Type: file Size: 15766 Last-Modified: '2016-05-13T04:51:16Z' SHA-1: 8C676387C23DB032CBA3A00B0E0AD785646350D5 Description: null
#include "Platform.inc" #include "States.inc" radix decimal SunriseSunset code global calculateSunriseAndSunset calculateSunriseAndSunset: .unknownBank setSunriseSunsetState SUN_STATE_CALCULATESUNRISE return end
; ; Old School Computer Architecture - interfacing FLOS ; Stefano Bodrato, 2011 ; ; Get current volume ; ; $Id: get_volume_list.asm,v 1.1 2011/08/03 08:13:40 stefano Exp $ ; INCLUDE "flos.def" XLIB get_volume_list get_volume_list: jp kjt_get_volume_info
; O3 Ozone Project Lab ; main.asm ; link to another asm file icalc.asm ; Hudson Schumaker bits 64 extern _printf, _o3add, _o3sub, _o3mult, _o3pow, _o3div section .data fmtint db "%d", 0xa, 0x0 section .text global _main _main: mov rbp, rsp ; adjust the stack push rbp mov rax, 0 ; no floating point mov rdi, 3 ; 1st arg mov rsi, 2 ; 2sd arg call _o3add ; call extern function o3add, return will be in rax mov rsi, rax ; 2sd arg for printf, rax has the return value mov rax, 0 ; no floating point mov rdi, fmtint ; 1st arg, format for printf call _printf ; call printf no return mov rax, 0 ; no floating point mov rdi, 3 ; 1st arg mov rsi, 2 ; 1st arg call _o3sub ; call extern function o3sub, return will be in rax mov rsi, rax ; 2sd arg for printf, rax has the return value mov rax, 0 ; no floating point mov rdi, fmtint ; 1st arg, format for printf call _printf ; call printf no return mov rax, 0 ; no floating point mov rdi, 3 ; 1st arg mov rsi, 2 ; 1st arg call _o3mult ; call extern function o3mult, return will be in rax mov rsi, rax ; 2sd arg for printf, rax has the return value mov rax, 0 ; no floating point mov rdi, fmtint ; 1st arg, format for printf call _printf ; call printf no return mov rax, 0 ; no floating point mov rdi, 3 ; 1st arg call _o3pow ; call extern function o3pow, return will be in rax mov rsi, rax ; 2sd arg, value for be printed mov rax, 0 ; no floating point mov rdi, fmtint ; 1st arg, format for printf call _printf ; call printf no return mov rax, 0 ; no floating point mov rdi, 600 ; 1st arg mov rsi, 2 ; 2sd arg call _o3div ; call extern function o3div, return will be in rax mov rsi, rax ; 2sd arg, value for be printed mov rax, 0 ; no floating point mov rdi, fmtint ; 1st arg, format for printf call _printf ; call printf no return call _exit ; call exit _exit: mov rax, 0x02000001 ; exit system call xor rdi, rdi ; out error code 0 to exit successfully syscall
obj/__user_spin.out: 文件格式 elf32-i386 Disassembly of section .text: 00800020 <__panic>: #include <stdio.h> #include <ulib.h> #include <error.h> void __panic(const char *file, int line, const char *fmt, ...) { 800020: 55 push %ebp 800021: 89 e5 mov %esp,%ebp 800023: 83 ec 18 sub $0x18,%esp // print the 'message' va_list ap; va_start(ap, fmt); 800026: 8d 45 14 lea 0x14(%ebp),%eax 800029: 89 45 f4 mov %eax,-0xc(%ebp) cprintf("user panic at %s:%d:\n ", file, line); 80002c: 83 ec 04 sub $0x4,%esp 80002f: ff 75 0c pushl 0xc(%ebp) 800032: ff 75 08 pushl 0x8(%ebp) 800035: 68 40 10 80 00 push $0x801040 80003a: e8 9a 02 00 00 call 8002d9 <cprintf> 80003f: 83 c4 10 add $0x10,%esp vcprintf(fmt, ap); 800042: 8b 45 f4 mov -0xc(%ebp),%eax 800045: 83 ec 08 sub $0x8,%esp 800048: 50 push %eax 800049: ff 75 10 pushl 0x10(%ebp) 80004c: e8 5f 02 00 00 call 8002b0 <vcprintf> 800051: 83 c4 10 add $0x10,%esp cprintf("\n"); 800054: 83 ec 0c sub $0xc,%esp 800057: 68 5a 10 80 00 push $0x80105a 80005c: e8 78 02 00 00 call 8002d9 <cprintf> 800061: 83 c4 10 add $0x10,%esp va_end(ap); exit(-E_PANIC); 800064: 83 ec 0c sub $0xc,%esp 800067: 6a f6 push $0xfffffff6 800069: e8 49 01 00 00 call 8001b7 <exit> 0080006e <__warn>: } void __warn(const char *file, int line, const char *fmt, ...) { 80006e: 55 push %ebp 80006f: 89 e5 mov %esp,%ebp 800071: 83 ec 18 sub $0x18,%esp va_list ap; va_start(ap, fmt); 800074: 8d 45 14 lea 0x14(%ebp),%eax 800077: 89 45 f4 mov %eax,-0xc(%ebp) cprintf("user warning at %s:%d:\n ", file, line); 80007a: 83 ec 04 sub $0x4,%esp 80007d: ff 75 0c pushl 0xc(%ebp) 800080: ff 75 08 pushl 0x8(%ebp) 800083: 68 5c 10 80 00 push $0x80105c 800088: e8 4c 02 00 00 call 8002d9 <cprintf> 80008d: 83 c4 10 add $0x10,%esp vcprintf(fmt, ap); 800090: 8b 45 f4 mov -0xc(%ebp),%eax 800093: 83 ec 08 sub $0x8,%esp 800096: 50 push %eax 800097: ff 75 10 pushl 0x10(%ebp) 80009a: e8 11 02 00 00 call 8002b0 <vcprintf> 80009f: 83 c4 10 add $0x10,%esp cprintf("\n"); 8000a2: 83 ec 0c sub $0xc,%esp 8000a5: 68 5a 10 80 00 push $0x80105a 8000aa: e8 2a 02 00 00 call 8002d9 <cprintf> 8000af: 83 c4 10 add $0x10,%esp va_end(ap); } 8000b2: 90 nop 8000b3: c9 leave 8000b4: c3 ret 008000b5 <syscall>: #include <syscall.h> #define MAX_ARGS 5 static inline int syscall(int num, ...) { 8000b5: 55 push %ebp 8000b6: 89 e5 mov %esp,%ebp 8000b8: 57 push %edi 8000b9: 56 push %esi 8000ba: 53 push %ebx 8000bb: 83 ec 20 sub $0x20,%esp va_list ap; va_start(ap, num); 8000be: 8d 45 0c lea 0xc(%ebp),%eax 8000c1: 89 45 e8 mov %eax,-0x18(%ebp) uint32_t a[MAX_ARGS]; int i, ret; for (i = 0; i < MAX_ARGS; i ++) { 8000c4: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 8000cb: eb 16 jmp 8000e3 <syscall+0x2e> a[i] = va_arg(ap, uint32_t); 8000cd: 8b 45 e8 mov -0x18(%ebp),%eax 8000d0: 8d 50 04 lea 0x4(%eax),%edx 8000d3: 89 55 e8 mov %edx,-0x18(%ebp) 8000d6: 8b 10 mov (%eax),%edx 8000d8: 8b 45 f0 mov -0x10(%ebp),%eax 8000db: 89 54 85 d4 mov %edx,-0x2c(%ebp,%eax,4) syscall(int num, ...) { va_list ap; va_start(ap, num); uint32_t a[MAX_ARGS]; int i, ret; for (i = 0; i < MAX_ARGS; i ++) { 8000df: 83 45 f0 01 addl $0x1,-0x10(%ebp) 8000e3: 83 7d f0 04 cmpl $0x4,-0x10(%ebp) 8000e7: 7e e4 jle 8000cd <syscall+0x18> asm volatile ( "int %1;" : "=a" (ret) : "i" (T_SYSCALL), "a" (num), "d" (a[0]), 8000e9: 8b 55 d4 mov -0x2c(%ebp),%edx "c" (a[1]), 8000ec: 8b 4d d8 mov -0x28(%ebp),%ecx "b" (a[2]), 8000ef: 8b 5d dc mov -0x24(%ebp),%ebx "D" (a[3]), 8000f2: 8b 7d e0 mov -0x20(%ebp),%edi "S" (a[4]) 8000f5: 8b 75 e4 mov -0x1c(%ebp),%esi for (i = 0; i < MAX_ARGS; i ++) { a[i] = va_arg(ap, uint32_t); } va_end(ap); asm volatile ( 8000f8: 8b 45 08 mov 0x8(%ebp),%eax 8000fb: cd 80 int $0x80 8000fd: 89 45 ec mov %eax,-0x14(%ebp) "c" (a[1]), "b" (a[2]), "D" (a[3]), "S" (a[4]) : "cc", "memory"); return ret; 800100: 8b 45 ec mov -0x14(%ebp),%eax } 800103: 83 c4 20 add $0x20,%esp 800106: 5b pop %ebx 800107: 5e pop %esi 800108: 5f pop %edi 800109: 5d pop %ebp 80010a: c3 ret 0080010b <sys_exit>: int sys_exit(int error_code) { 80010b: 55 push %ebp 80010c: 89 e5 mov %esp,%ebp return syscall(SYS_exit, error_code); 80010e: ff 75 08 pushl 0x8(%ebp) 800111: 6a 01 push $0x1 800113: e8 9d ff ff ff call 8000b5 <syscall> 800118: 83 c4 08 add $0x8,%esp } 80011b: c9 leave 80011c: c3 ret 0080011d <sys_fork>: int sys_fork(void) { 80011d: 55 push %ebp 80011e: 89 e5 mov %esp,%ebp return syscall(SYS_fork); 800120: 6a 02 push $0x2 800122: e8 8e ff ff ff call 8000b5 <syscall> 800127: 83 c4 04 add $0x4,%esp } 80012a: c9 leave 80012b: c3 ret 0080012c <sys_wait>: int sys_wait(int pid, int *store) { 80012c: 55 push %ebp 80012d: 89 e5 mov %esp,%ebp return syscall(SYS_wait, pid, store); 80012f: ff 75 0c pushl 0xc(%ebp) 800132: ff 75 08 pushl 0x8(%ebp) 800135: 6a 03 push $0x3 800137: e8 79 ff ff ff call 8000b5 <syscall> 80013c: 83 c4 0c add $0xc,%esp } 80013f: c9 leave 800140: c3 ret 00800141 <sys_yield>: int sys_yield(void) { 800141: 55 push %ebp 800142: 89 e5 mov %esp,%ebp return syscall(SYS_yield); 800144: 6a 0a push $0xa 800146: e8 6a ff ff ff call 8000b5 <syscall> 80014b: 83 c4 04 add $0x4,%esp } 80014e: c9 leave 80014f: c3 ret 00800150 <sys_kill>: int sys_kill(int pid) { 800150: 55 push %ebp 800151: 89 e5 mov %esp,%ebp return syscall(SYS_kill, pid); 800153: ff 75 08 pushl 0x8(%ebp) 800156: 6a 0c push $0xc 800158: e8 58 ff ff ff call 8000b5 <syscall> 80015d: 83 c4 08 add $0x8,%esp } 800160: c9 leave 800161: c3 ret 00800162 <sys_getpid>: int sys_getpid(void) { 800162: 55 push %ebp 800163: 89 e5 mov %esp,%ebp return syscall(SYS_getpid); 800165: 6a 12 push $0x12 800167: e8 49 ff ff ff call 8000b5 <syscall> 80016c: 83 c4 04 add $0x4,%esp } 80016f: c9 leave 800170: c3 ret 00800171 <sys_putc>: int sys_putc(int c) { 800171: 55 push %ebp 800172: 89 e5 mov %esp,%ebp return syscall(SYS_putc, c); 800174: ff 75 08 pushl 0x8(%ebp) 800177: 6a 1e push $0x1e 800179: e8 37 ff ff ff call 8000b5 <syscall> 80017e: 83 c4 08 add $0x8,%esp } 800181: c9 leave 800182: c3 ret 00800183 <sys_pgdir>: int sys_pgdir(void) { 800183: 55 push %ebp 800184: 89 e5 mov %esp,%ebp return syscall(SYS_pgdir); 800186: 6a 1f push $0x1f 800188: e8 28 ff ff ff call 8000b5 <syscall> 80018d: 83 c4 04 add $0x4,%esp } 800190: c9 leave 800191: c3 ret 00800192 <sys_gettime>: size_t sys_gettime(void) { 800192: 55 push %ebp 800193: 89 e5 mov %esp,%ebp return syscall(SYS_gettime); 800195: 6a 11 push $0x11 800197: e8 19 ff ff ff call 8000b5 <syscall> 80019c: 83 c4 04 add $0x4,%esp } 80019f: c9 leave 8001a0: c3 ret 008001a1 <sys_lab6_set_priority>: void sys_lab6_set_priority(uint32_t priority) { 8001a1: 55 push %ebp 8001a2: 89 e5 mov %esp,%ebp syscall(SYS_lab6_set_priority, priority); 8001a4: ff 75 08 pushl 0x8(%ebp) 8001a7: 68 ff 00 00 00 push $0xff 8001ac: e8 04 ff ff ff call 8000b5 <syscall> 8001b1: 83 c4 08 add $0x8,%esp } 8001b4: 90 nop 8001b5: c9 leave 8001b6: c3 ret 008001b7 <exit>: #include <syscall.h> #include <stdio.h> #include <ulib.h> void exit(int error_code) { 8001b7: 55 push %ebp 8001b8: 89 e5 mov %esp,%ebp 8001ba: 83 ec 08 sub $0x8,%esp sys_exit(error_code); 8001bd: 83 ec 0c sub $0xc,%esp 8001c0: ff 75 08 pushl 0x8(%ebp) 8001c3: e8 43 ff ff ff call 80010b <sys_exit> 8001c8: 83 c4 10 add $0x10,%esp cprintf("BUG: exit failed.\n"); 8001cb: 83 ec 0c sub $0xc,%esp 8001ce: 68 78 10 80 00 push $0x801078 8001d3: e8 01 01 00 00 call 8002d9 <cprintf> 8001d8: 83 c4 10 add $0x10,%esp while (1); 8001db: eb fe jmp 8001db <exit+0x24> 008001dd <fork>: } int fork(void) { 8001dd: 55 push %ebp 8001de: 89 e5 mov %esp,%ebp 8001e0: 83 ec 08 sub $0x8,%esp return sys_fork(); 8001e3: e8 35 ff ff ff call 80011d <sys_fork> } 8001e8: c9 leave 8001e9: c3 ret 008001ea <wait>: int wait(void) { 8001ea: 55 push %ebp 8001eb: 89 e5 mov %esp,%ebp 8001ed: 83 ec 08 sub $0x8,%esp return sys_wait(0, NULL); 8001f0: 83 ec 08 sub $0x8,%esp 8001f3: 6a 00 push $0x0 8001f5: 6a 00 push $0x0 8001f7: e8 30 ff ff ff call 80012c <sys_wait> 8001fc: 83 c4 10 add $0x10,%esp } 8001ff: c9 leave 800200: c3 ret 00800201 <waitpid>: int waitpid(int pid, int *store) { 800201: 55 push %ebp 800202: 89 e5 mov %esp,%ebp 800204: 83 ec 08 sub $0x8,%esp return sys_wait(pid, store); 800207: 83 ec 08 sub $0x8,%esp 80020a: ff 75 0c pushl 0xc(%ebp) 80020d: ff 75 08 pushl 0x8(%ebp) 800210: e8 17 ff ff ff call 80012c <sys_wait> 800215: 83 c4 10 add $0x10,%esp } 800218: c9 leave 800219: c3 ret 0080021a <yield>: void yield(void) { 80021a: 55 push %ebp 80021b: 89 e5 mov %esp,%ebp 80021d: 83 ec 08 sub $0x8,%esp sys_yield(); 800220: e8 1c ff ff ff call 800141 <sys_yield> } 800225: 90 nop 800226: c9 leave 800227: c3 ret 00800228 <kill>: int kill(int pid) { 800228: 55 push %ebp 800229: 89 e5 mov %esp,%ebp 80022b: 83 ec 08 sub $0x8,%esp return sys_kill(pid); 80022e: 83 ec 0c sub $0xc,%esp 800231: ff 75 08 pushl 0x8(%ebp) 800234: e8 17 ff ff ff call 800150 <sys_kill> 800239: 83 c4 10 add $0x10,%esp } 80023c: c9 leave 80023d: c3 ret 0080023e <getpid>: int getpid(void) { 80023e: 55 push %ebp 80023f: 89 e5 mov %esp,%ebp 800241: 83 ec 08 sub $0x8,%esp return sys_getpid(); 800244: e8 19 ff ff ff call 800162 <sys_getpid> } 800249: c9 leave 80024a: c3 ret 0080024b <print_pgdir>: //print_pgdir - print the PDT&PT void print_pgdir(void) { 80024b: 55 push %ebp 80024c: 89 e5 mov %esp,%ebp 80024e: 83 ec 08 sub $0x8,%esp sys_pgdir(); 800251: e8 2d ff ff ff call 800183 <sys_pgdir> } 800256: 90 nop 800257: c9 leave 800258: c3 ret 00800259 <gettime_msec>: unsigned int gettime_msec(void) { 800259: 55 push %ebp 80025a: 89 e5 mov %esp,%ebp 80025c: 83 ec 08 sub $0x8,%esp return (unsigned int)sys_gettime(); 80025f: e8 2e ff ff ff call 800192 <sys_gettime> } 800264: c9 leave 800265: c3 ret 00800266 <lab6_set_priority>: void lab6_set_priority(uint32_t priority) { 800266: 55 push %ebp 800267: 89 e5 mov %esp,%ebp 800269: 83 ec 08 sub $0x8,%esp sys_lab6_set_priority(priority); 80026c: 83 ec 0c sub $0xc,%esp 80026f: ff 75 08 pushl 0x8(%ebp) 800272: e8 2a ff ff ff call 8001a1 <sys_lab6_set_priority> 800277: 83 c4 10 add $0x10,%esp } 80027a: 90 nop 80027b: c9 leave 80027c: c3 ret 0080027d <_start>: .text .globl _start _start: # set ebp for backtrace movl $0x0, %ebp 80027d: bd 00 00 00 00 mov $0x0,%ebp # move down the esp register # since it may cause page fault in backtrace subl $0x20, %esp 800282: 83 ec 20 sub $0x20,%esp # call user-program function call umain 800285: e8 c3 00 00 00 call 80034d <umain> 1: jmp 1b 80028a: eb fe jmp 80028a <_start+0xd> 0080028c <cputch>: /* * * cputch - writes a single character @c to stdout, and it will * increace the value of counter pointed by @cnt. * */ static void cputch(int c, int *cnt) { 80028c: 55 push %ebp 80028d: 89 e5 mov %esp,%ebp 80028f: 83 ec 08 sub $0x8,%esp sys_putc(c); 800292: 83 ec 0c sub $0xc,%esp 800295: ff 75 08 pushl 0x8(%ebp) 800298: e8 d4 fe ff ff call 800171 <sys_putc> 80029d: 83 c4 10 add $0x10,%esp (*cnt) ++; 8002a0: 8b 45 0c mov 0xc(%ebp),%eax 8002a3: 8b 00 mov (%eax),%eax 8002a5: 8d 50 01 lea 0x1(%eax),%edx 8002a8: 8b 45 0c mov 0xc(%ebp),%eax 8002ab: 89 10 mov %edx,(%eax) } 8002ad: 90 nop 8002ae: c9 leave 8002af: c3 ret 008002b0 <vcprintf>: * * Call this function if you are already dealing with a va_list. * Or you probably want cprintf() instead. * */ int vcprintf(const char *fmt, va_list ap) { 8002b0: 55 push %ebp 8002b1: 89 e5 mov %esp,%ebp 8002b3: 83 ec 18 sub $0x18,%esp int cnt = 0; 8002b6: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) vprintfmt((void*)cputch, &cnt, fmt, ap); 8002bd: ff 75 0c pushl 0xc(%ebp) 8002c0: ff 75 08 pushl 0x8(%ebp) 8002c3: 8d 45 f4 lea -0xc(%ebp),%eax 8002c6: 50 push %eax 8002c7: 68 8c 02 80 00 push $0x80028c 8002cc: e8 fc 06 00 00 call 8009cd <vprintfmt> 8002d1: 83 c4 10 add $0x10,%esp return cnt; 8002d4: 8b 45 f4 mov -0xc(%ebp),%eax } 8002d7: c9 leave 8002d8: c3 ret 008002d9 <cprintf>: * * The return value is the number of characters which would be * written to stdout. * */ int cprintf(const char *fmt, ...) { 8002d9: 55 push %ebp 8002da: 89 e5 mov %esp,%ebp 8002dc: 83 ec 18 sub $0x18,%esp va_list ap; va_start(ap, fmt); 8002df: 8d 45 0c lea 0xc(%ebp),%eax 8002e2: 89 45 f0 mov %eax,-0x10(%ebp) int cnt = vcprintf(fmt, ap); 8002e5: 8b 45 f0 mov -0x10(%ebp),%eax 8002e8: 83 ec 08 sub $0x8,%esp 8002eb: 50 push %eax 8002ec: ff 75 08 pushl 0x8(%ebp) 8002ef: e8 bc ff ff ff call 8002b0 <vcprintf> 8002f4: 83 c4 10 add $0x10,%esp 8002f7: 89 45 f4 mov %eax,-0xc(%ebp) va_end(ap); return cnt; 8002fa: 8b 45 f4 mov -0xc(%ebp),%eax } 8002fd: c9 leave 8002fe: c3 ret 008002ff <cputs>: /* * * cputs- writes the string pointed by @str to stdout and * appends a newline character. * */ int cputs(const char *str) { 8002ff: 55 push %ebp 800300: 89 e5 mov %esp,%ebp 800302: 83 ec 18 sub $0x18,%esp int cnt = 0; 800305: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) char c; while ((c = *str ++) != '\0') { 80030c: eb 14 jmp 800322 <cputs+0x23> cputch(c, &cnt); 80030e: 0f be 45 f7 movsbl -0x9(%ebp),%eax 800312: 83 ec 08 sub $0x8,%esp 800315: 8d 55 f0 lea -0x10(%ebp),%edx 800318: 52 push %edx 800319: 50 push %eax 80031a: e8 6d ff ff ff call 80028c <cputch> 80031f: 83 c4 10 add $0x10,%esp * */ int cputs(const char *str) { int cnt = 0; char c; while ((c = *str ++) != '\0') { 800322: 8b 45 08 mov 0x8(%ebp),%eax 800325: 8d 50 01 lea 0x1(%eax),%edx 800328: 89 55 08 mov %edx,0x8(%ebp) 80032b: 0f b6 00 movzbl (%eax),%eax 80032e: 88 45 f7 mov %al,-0x9(%ebp) 800331: 80 7d f7 00 cmpb $0x0,-0x9(%ebp) 800335: 75 d7 jne 80030e <cputs+0xf> cputch(c, &cnt); } cputch('\n', &cnt); 800337: 83 ec 08 sub $0x8,%esp 80033a: 8d 45 f0 lea -0x10(%ebp),%eax 80033d: 50 push %eax 80033e: 6a 0a push $0xa 800340: e8 47 ff ff ff call 80028c <cputch> 800345: 83 c4 10 add $0x10,%esp return cnt; 800348: 8b 45 f0 mov -0x10(%ebp),%eax } 80034b: c9 leave 80034c: c3 ret 0080034d <umain>: #include <ulib.h> int main(void); void umain(void) { 80034d: 55 push %ebp 80034e: 89 e5 mov %esp,%ebp 800350: 83 ec 18 sub $0x18,%esp int ret = main(); 800353: e8 d3 0b 00 00 call 800f2b <main> 800358: 89 45 f4 mov %eax,-0xc(%ebp) exit(ret); 80035b: 83 ec 0c sub $0xc,%esp 80035e: ff 75 f4 pushl -0xc(%ebp) 800361: e8 51 fe ff ff call 8001b7 <exit> 00800366 <strlen>: * @s: the input string * * The strlen() function returns the length of string @s. * */ size_t strlen(const char *s) { 800366: 55 push %ebp 800367: 89 e5 mov %esp,%ebp 800369: 83 ec 10 sub $0x10,%esp size_t cnt = 0; 80036c: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while (*s ++ != '\0') { 800373: eb 04 jmp 800379 <strlen+0x13> cnt ++; 800375: 83 45 fc 01 addl $0x1,-0x4(%ebp) * The strlen() function returns the length of string @s. * */ size_t strlen(const char *s) { size_t cnt = 0; while (*s ++ != '\0') { 800379: 8b 45 08 mov 0x8(%ebp),%eax 80037c: 8d 50 01 lea 0x1(%eax),%edx 80037f: 89 55 08 mov %edx,0x8(%ebp) 800382: 0f b6 00 movzbl (%eax),%eax 800385: 84 c0 test %al,%al 800387: 75 ec jne 800375 <strlen+0xf> cnt ++; } return cnt; 800389: 8b 45 fc mov -0x4(%ebp),%eax } 80038c: c9 leave 80038d: c3 ret 0080038e <strnlen>: * The return value is strlen(s), if that is less than @len, or * @len if there is no '\0' character among the first @len characters * pointed by @s. * */ size_t strnlen(const char *s, size_t len) { 80038e: 55 push %ebp 80038f: 89 e5 mov %esp,%ebp 800391: 83 ec 10 sub $0x10,%esp size_t cnt = 0; 800394: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while (cnt < len && *s ++ != '\0') { 80039b: eb 04 jmp 8003a1 <strnlen+0x13> cnt ++; 80039d: 83 45 fc 01 addl $0x1,-0x4(%ebp) * pointed by @s. * */ size_t strnlen(const char *s, size_t len) { size_t cnt = 0; while (cnt < len && *s ++ != '\0') { 8003a1: 8b 45 fc mov -0x4(%ebp),%eax 8003a4: 3b 45 0c cmp 0xc(%ebp),%eax 8003a7: 73 10 jae 8003b9 <strnlen+0x2b> 8003a9: 8b 45 08 mov 0x8(%ebp),%eax 8003ac: 8d 50 01 lea 0x1(%eax),%edx 8003af: 89 55 08 mov %edx,0x8(%ebp) 8003b2: 0f b6 00 movzbl (%eax),%eax 8003b5: 84 c0 test %al,%al 8003b7: 75 e4 jne 80039d <strnlen+0xf> cnt ++; } return cnt; 8003b9: 8b 45 fc mov -0x4(%ebp),%eax } 8003bc: c9 leave 8003bd: c3 ret 008003be <strcpy>: * To avoid overflows, the size of array pointed by @dst should be long enough to * contain the same string as @src (including the terminating null character), and * should not overlap in memory with @src. * */ char * strcpy(char *dst, const char *src) { 8003be: 55 push %ebp 8003bf: 89 e5 mov %esp,%ebp 8003c1: 57 push %edi 8003c2: 56 push %esi 8003c3: 83 ec 20 sub $0x20,%esp 8003c6: 8b 45 08 mov 0x8(%ebp),%eax 8003c9: 89 45 f4 mov %eax,-0xc(%ebp) 8003cc: 8b 45 0c mov 0xc(%ebp),%eax 8003cf: 89 45 f0 mov %eax,-0x10(%ebp) #ifndef __HAVE_ARCH_STRCPY #define __HAVE_ARCH_STRCPY static inline char * __strcpy(char *dst, const char *src) { int d0, d1, d2; asm volatile ( 8003d2: 8b 55 f0 mov -0x10(%ebp),%edx 8003d5: 8b 45 f4 mov -0xc(%ebp),%eax 8003d8: 89 d1 mov %edx,%ecx 8003da: 89 c2 mov %eax,%edx 8003dc: 89 ce mov %ecx,%esi 8003de: 89 d7 mov %edx,%edi 8003e0: ac lods %ds:(%esi),%al 8003e1: aa stos %al,%es:(%edi) 8003e2: 84 c0 test %al,%al 8003e4: 75 fa jne 8003e0 <strcpy+0x22> 8003e6: 89 fa mov %edi,%edx 8003e8: 89 f1 mov %esi,%ecx 8003ea: 89 4d ec mov %ecx,-0x14(%ebp) 8003ed: 89 55 e8 mov %edx,-0x18(%ebp) 8003f0: 89 45 e4 mov %eax,-0x1c(%ebp) "stosb;" "testb %%al, %%al;" "jne 1b;" : "=&S" (d0), "=&D" (d1), "=&a" (d2) : "0" (src), "1" (dst) : "memory"); return dst; 8003f3: 8b 45 f4 mov -0xc(%ebp),%eax #ifdef __HAVE_ARCH_STRCPY return __strcpy(dst, src); 8003f6: 90 nop char *p = dst; while ((*p ++ = *src ++) != '\0') /* nothing */; return dst; #endif /* __HAVE_ARCH_STRCPY */ } 8003f7: 83 c4 20 add $0x20,%esp 8003fa: 5e pop %esi 8003fb: 5f pop %edi 8003fc: 5d pop %ebp 8003fd: c3 ret 008003fe <strncpy>: * @len: maximum number of characters to be copied from @src * * The return value is @dst * */ char * strncpy(char *dst, const char *src, size_t len) { 8003fe: 55 push %ebp 8003ff: 89 e5 mov %esp,%ebp 800401: 83 ec 10 sub $0x10,%esp char *p = dst; 800404: 8b 45 08 mov 0x8(%ebp),%eax 800407: 89 45 fc mov %eax,-0x4(%ebp) while (len > 0) { 80040a: eb 21 jmp 80042d <strncpy+0x2f> if ((*p = *src) != '\0') { 80040c: 8b 45 0c mov 0xc(%ebp),%eax 80040f: 0f b6 10 movzbl (%eax),%edx 800412: 8b 45 fc mov -0x4(%ebp),%eax 800415: 88 10 mov %dl,(%eax) 800417: 8b 45 fc mov -0x4(%ebp),%eax 80041a: 0f b6 00 movzbl (%eax),%eax 80041d: 84 c0 test %al,%al 80041f: 74 04 je 800425 <strncpy+0x27> src ++; 800421: 83 45 0c 01 addl $0x1,0xc(%ebp) } p ++, len --; 800425: 83 45 fc 01 addl $0x1,-0x4(%ebp) 800429: 83 6d 10 01 subl $0x1,0x10(%ebp) * The return value is @dst * */ char * strncpy(char *dst, const char *src, size_t len) { char *p = dst; while (len > 0) { 80042d: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 800431: 75 d9 jne 80040c <strncpy+0xe> if ((*p = *src) != '\0') { src ++; } p ++, len --; } return dst; 800433: 8b 45 08 mov 0x8(%ebp),%eax } 800436: c9 leave 800437: c3 ret 00800438 <strcmp>: * - A value greater than zero indicates that the first character that does * not match has a greater value in @s1 than in @s2; * - And a value less than zero indicates the opposite. * */ int strcmp(const char *s1, const char *s2) { 800438: 55 push %ebp 800439: 89 e5 mov %esp,%ebp 80043b: 57 push %edi 80043c: 56 push %esi 80043d: 83 ec 20 sub $0x20,%esp 800440: 8b 45 08 mov 0x8(%ebp),%eax 800443: 89 45 f4 mov %eax,-0xc(%ebp) 800446: 8b 45 0c mov 0xc(%ebp),%eax 800449: 89 45 f0 mov %eax,-0x10(%ebp) #ifndef __HAVE_ARCH_STRCMP #define __HAVE_ARCH_STRCMP static inline int __strcmp(const char *s1, const char *s2) { int d0, d1, ret; asm volatile ( 80044c: 8b 55 f4 mov -0xc(%ebp),%edx 80044f: 8b 45 f0 mov -0x10(%ebp),%eax 800452: 89 d1 mov %edx,%ecx 800454: 89 c2 mov %eax,%edx 800456: 89 ce mov %ecx,%esi 800458: 89 d7 mov %edx,%edi 80045a: ac lods %ds:(%esi),%al 80045b: ae scas %es:(%edi),%al 80045c: 75 08 jne 800466 <strcmp+0x2e> 80045e: 84 c0 test %al,%al 800460: 75 f8 jne 80045a <strcmp+0x22> 800462: 31 c0 xor %eax,%eax 800464: eb 04 jmp 80046a <strcmp+0x32> 800466: 19 c0 sbb %eax,%eax 800468: 0c 01 or $0x1,%al 80046a: 89 fa mov %edi,%edx 80046c: 89 f1 mov %esi,%ecx 80046e: 89 45 ec mov %eax,-0x14(%ebp) 800471: 89 4d e8 mov %ecx,-0x18(%ebp) 800474: 89 55 e4 mov %edx,-0x1c(%ebp) "orb $1, %%al;" "3:" : "=a" (ret), "=&S" (d0), "=&D" (d1) : "1" (s1), "2" (s2) : "memory"); return ret; 800477: 8b 45 ec mov -0x14(%ebp),%eax #ifdef __HAVE_ARCH_STRCMP return __strcmp(s1, s2); 80047a: 90 nop while (*s1 != '\0' && *s1 == *s2) { s1 ++, s2 ++; } return (int)((unsigned char)*s1 - (unsigned char)*s2); #endif /* __HAVE_ARCH_STRCMP */ } 80047b: 83 c4 20 add $0x20,%esp 80047e: 5e pop %esi 80047f: 5f pop %edi 800480: 5d pop %ebp 800481: c3 ret 00800482 <strncmp>: * they are equal to each other, it continues with the following pairs until * the characters differ, until a terminating null-character is reached, or * until @n characters match in both strings, whichever happens first. * */ int strncmp(const char *s1, const char *s2, size_t n) { 800482: 55 push %ebp 800483: 89 e5 mov %esp,%ebp while (n > 0 && *s1 != '\0' && *s1 == *s2) { 800485: eb 0c jmp 800493 <strncmp+0x11> n --, s1 ++, s2 ++; 800487: 83 6d 10 01 subl $0x1,0x10(%ebp) 80048b: 83 45 08 01 addl $0x1,0x8(%ebp) 80048f: 83 45 0c 01 addl $0x1,0xc(%ebp) * the characters differ, until a terminating null-character is reached, or * until @n characters match in both strings, whichever happens first. * */ int strncmp(const char *s1, const char *s2, size_t n) { while (n > 0 && *s1 != '\0' && *s1 == *s2) { 800493: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 800497: 74 1a je 8004b3 <strncmp+0x31> 800499: 8b 45 08 mov 0x8(%ebp),%eax 80049c: 0f b6 00 movzbl (%eax),%eax 80049f: 84 c0 test %al,%al 8004a1: 74 10 je 8004b3 <strncmp+0x31> 8004a3: 8b 45 08 mov 0x8(%ebp),%eax 8004a6: 0f b6 10 movzbl (%eax),%edx 8004a9: 8b 45 0c mov 0xc(%ebp),%eax 8004ac: 0f b6 00 movzbl (%eax),%eax 8004af: 38 c2 cmp %al,%dl 8004b1: 74 d4 je 800487 <strncmp+0x5> n --, s1 ++, s2 ++; } return (n == 0) ? 0 : (int)((unsigned char)*s1 - (unsigned char)*s2); 8004b3: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 8004b7: 74 18 je 8004d1 <strncmp+0x4f> 8004b9: 8b 45 08 mov 0x8(%ebp),%eax 8004bc: 0f b6 00 movzbl (%eax),%eax 8004bf: 0f b6 d0 movzbl %al,%edx 8004c2: 8b 45 0c mov 0xc(%ebp),%eax 8004c5: 0f b6 00 movzbl (%eax),%eax 8004c8: 0f b6 c0 movzbl %al,%eax 8004cb: 29 c2 sub %eax,%edx 8004cd: 89 d0 mov %edx,%eax 8004cf: eb 05 jmp 8004d6 <strncmp+0x54> 8004d1: b8 00 00 00 00 mov $0x0,%eax } 8004d6: 5d pop %ebp 8004d7: c3 ret 008004d8 <strchr>: * * The strchr() function returns a pointer to the first occurrence of * character in @s. If the value is not found, the function returns 'NULL'. * */ char * strchr(const char *s, char c) { 8004d8: 55 push %ebp 8004d9: 89 e5 mov %esp,%ebp 8004db: 83 ec 04 sub $0x4,%esp 8004de: 8b 45 0c mov 0xc(%ebp),%eax 8004e1: 88 45 fc mov %al,-0x4(%ebp) while (*s != '\0') { 8004e4: eb 14 jmp 8004fa <strchr+0x22> if (*s == c) { 8004e6: 8b 45 08 mov 0x8(%ebp),%eax 8004e9: 0f b6 00 movzbl (%eax),%eax 8004ec: 3a 45 fc cmp -0x4(%ebp),%al 8004ef: 75 05 jne 8004f6 <strchr+0x1e> return (char *)s; 8004f1: 8b 45 08 mov 0x8(%ebp),%eax 8004f4: eb 13 jmp 800509 <strchr+0x31> } s ++; 8004f6: 83 45 08 01 addl $0x1,0x8(%ebp) * The strchr() function returns a pointer to the first occurrence of * character in @s. If the value is not found, the function returns 'NULL'. * */ char * strchr(const char *s, char c) { while (*s != '\0') { 8004fa: 8b 45 08 mov 0x8(%ebp),%eax 8004fd: 0f b6 00 movzbl (%eax),%eax 800500: 84 c0 test %al,%al 800502: 75 e2 jne 8004e6 <strchr+0xe> if (*s == c) { return (char *)s; } s ++; } return NULL; 800504: b8 00 00 00 00 mov $0x0,%eax } 800509: c9 leave 80050a: c3 ret 0080050b <strfind>: * The strfind() function is like strchr() except that if @c is * not found in @s, then it returns a pointer to the null byte at the * end of @s, rather than 'NULL'. * */ char * strfind(const char *s, char c) { 80050b: 55 push %ebp 80050c: 89 e5 mov %esp,%ebp 80050e: 83 ec 04 sub $0x4,%esp 800511: 8b 45 0c mov 0xc(%ebp),%eax 800514: 88 45 fc mov %al,-0x4(%ebp) while (*s != '\0') { 800517: eb 0f jmp 800528 <strfind+0x1d> if (*s == c) { 800519: 8b 45 08 mov 0x8(%ebp),%eax 80051c: 0f b6 00 movzbl (%eax),%eax 80051f: 3a 45 fc cmp -0x4(%ebp),%al 800522: 74 10 je 800534 <strfind+0x29> break; } s ++; 800524: 83 45 08 01 addl $0x1,0x8(%ebp) * not found in @s, then it returns a pointer to the null byte at the * end of @s, rather than 'NULL'. * */ char * strfind(const char *s, char c) { while (*s != '\0') { 800528: 8b 45 08 mov 0x8(%ebp),%eax 80052b: 0f b6 00 movzbl (%eax),%eax 80052e: 84 c0 test %al,%al 800530: 75 e7 jne 800519 <strfind+0xe> 800532: eb 01 jmp 800535 <strfind+0x2a> if (*s == c) { break; 800534: 90 nop } s ++; } return (char *)s; 800535: 8b 45 08 mov 0x8(%ebp),%eax } 800538: c9 leave 800539: c3 ret 0080053a <strtol>: * an optional "0x" or "0X" prefix. * * The strtol() function returns the converted integral number as a long int value. * */ long strtol(const char *s, char **endptr, int base) { 80053a: 55 push %ebp 80053b: 89 e5 mov %esp,%ebp 80053d: 83 ec 10 sub $0x10,%esp int neg = 0; 800540: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) long val = 0; 800547: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp) // gobble initial whitespace while (*s == ' ' || *s == '\t') { 80054e: eb 04 jmp 800554 <strtol+0x1a> s ++; 800550: 83 45 08 01 addl $0x1,0x8(%ebp) strtol(const char *s, char **endptr, int base) { int neg = 0; long val = 0; // gobble initial whitespace while (*s == ' ' || *s == '\t') { 800554: 8b 45 08 mov 0x8(%ebp),%eax 800557: 0f b6 00 movzbl (%eax),%eax 80055a: 3c 20 cmp $0x20,%al 80055c: 74 f2 je 800550 <strtol+0x16> 80055e: 8b 45 08 mov 0x8(%ebp),%eax 800561: 0f b6 00 movzbl (%eax),%eax 800564: 3c 09 cmp $0x9,%al 800566: 74 e8 je 800550 <strtol+0x16> s ++; } // plus/minus sign if (*s == '+') { 800568: 8b 45 08 mov 0x8(%ebp),%eax 80056b: 0f b6 00 movzbl (%eax),%eax 80056e: 3c 2b cmp $0x2b,%al 800570: 75 06 jne 800578 <strtol+0x3e> s ++; 800572: 83 45 08 01 addl $0x1,0x8(%ebp) 800576: eb 15 jmp 80058d <strtol+0x53> } else if (*s == '-') { 800578: 8b 45 08 mov 0x8(%ebp),%eax 80057b: 0f b6 00 movzbl (%eax),%eax 80057e: 3c 2d cmp $0x2d,%al 800580: 75 0b jne 80058d <strtol+0x53> s ++, neg = 1; 800582: 83 45 08 01 addl $0x1,0x8(%ebp) 800586: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%ebp) } // hex or octal base prefix if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x')) { 80058d: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 800591: 74 06 je 800599 <strtol+0x5f> 800593: 83 7d 10 10 cmpl $0x10,0x10(%ebp) 800597: 75 24 jne 8005bd <strtol+0x83> 800599: 8b 45 08 mov 0x8(%ebp),%eax 80059c: 0f b6 00 movzbl (%eax),%eax 80059f: 3c 30 cmp $0x30,%al 8005a1: 75 1a jne 8005bd <strtol+0x83> 8005a3: 8b 45 08 mov 0x8(%ebp),%eax 8005a6: 83 c0 01 add $0x1,%eax 8005a9: 0f b6 00 movzbl (%eax),%eax 8005ac: 3c 78 cmp $0x78,%al 8005ae: 75 0d jne 8005bd <strtol+0x83> s += 2, base = 16; 8005b0: 83 45 08 02 addl $0x2,0x8(%ebp) 8005b4: c7 45 10 10 00 00 00 movl $0x10,0x10(%ebp) 8005bb: eb 2a jmp 8005e7 <strtol+0xad> } else if (base == 0 && s[0] == '0') { 8005bd: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 8005c1: 75 17 jne 8005da <strtol+0xa0> 8005c3: 8b 45 08 mov 0x8(%ebp),%eax 8005c6: 0f b6 00 movzbl (%eax),%eax 8005c9: 3c 30 cmp $0x30,%al 8005cb: 75 0d jne 8005da <strtol+0xa0> s ++, base = 8; 8005cd: 83 45 08 01 addl $0x1,0x8(%ebp) 8005d1: c7 45 10 08 00 00 00 movl $0x8,0x10(%ebp) 8005d8: eb 0d jmp 8005e7 <strtol+0xad> } else if (base == 0) { 8005da: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 8005de: 75 07 jne 8005e7 <strtol+0xad> base = 10; 8005e0: c7 45 10 0a 00 00 00 movl $0xa,0x10(%ebp) // digits while (1) { int dig; if (*s >= '0' && *s <= '9') { 8005e7: 8b 45 08 mov 0x8(%ebp),%eax 8005ea: 0f b6 00 movzbl (%eax),%eax 8005ed: 3c 2f cmp $0x2f,%al 8005ef: 7e 1b jle 80060c <strtol+0xd2> 8005f1: 8b 45 08 mov 0x8(%ebp),%eax 8005f4: 0f b6 00 movzbl (%eax),%eax 8005f7: 3c 39 cmp $0x39,%al 8005f9: 7f 11 jg 80060c <strtol+0xd2> dig = *s - '0'; 8005fb: 8b 45 08 mov 0x8(%ebp),%eax 8005fe: 0f b6 00 movzbl (%eax),%eax 800601: 0f be c0 movsbl %al,%eax 800604: 83 e8 30 sub $0x30,%eax 800607: 89 45 f4 mov %eax,-0xc(%ebp) 80060a: eb 48 jmp 800654 <strtol+0x11a> } else if (*s >= 'a' && *s <= 'z') { 80060c: 8b 45 08 mov 0x8(%ebp),%eax 80060f: 0f b6 00 movzbl (%eax),%eax 800612: 3c 60 cmp $0x60,%al 800614: 7e 1b jle 800631 <strtol+0xf7> 800616: 8b 45 08 mov 0x8(%ebp),%eax 800619: 0f b6 00 movzbl (%eax),%eax 80061c: 3c 7a cmp $0x7a,%al 80061e: 7f 11 jg 800631 <strtol+0xf7> dig = *s - 'a' + 10; 800620: 8b 45 08 mov 0x8(%ebp),%eax 800623: 0f b6 00 movzbl (%eax),%eax 800626: 0f be c0 movsbl %al,%eax 800629: 83 e8 57 sub $0x57,%eax 80062c: 89 45 f4 mov %eax,-0xc(%ebp) 80062f: eb 23 jmp 800654 <strtol+0x11a> } else if (*s >= 'A' && *s <= 'Z') { 800631: 8b 45 08 mov 0x8(%ebp),%eax 800634: 0f b6 00 movzbl (%eax),%eax 800637: 3c 40 cmp $0x40,%al 800639: 7e 3c jle 800677 <strtol+0x13d> 80063b: 8b 45 08 mov 0x8(%ebp),%eax 80063e: 0f b6 00 movzbl (%eax),%eax 800641: 3c 5a cmp $0x5a,%al 800643: 7f 32 jg 800677 <strtol+0x13d> dig = *s - 'A' + 10; 800645: 8b 45 08 mov 0x8(%ebp),%eax 800648: 0f b6 00 movzbl (%eax),%eax 80064b: 0f be c0 movsbl %al,%eax 80064e: 83 e8 37 sub $0x37,%eax 800651: 89 45 f4 mov %eax,-0xc(%ebp) } else { break; } if (dig >= base) { 800654: 8b 45 f4 mov -0xc(%ebp),%eax 800657: 3b 45 10 cmp 0x10(%ebp),%eax 80065a: 7d 1a jge 800676 <strtol+0x13c> break; } s ++, val = (val * base) + dig; 80065c: 83 45 08 01 addl $0x1,0x8(%ebp) 800660: 8b 45 f8 mov -0x8(%ebp),%eax 800663: 0f af 45 10 imul 0x10(%ebp),%eax 800667: 89 c2 mov %eax,%edx 800669: 8b 45 f4 mov -0xc(%ebp),%eax 80066c: 01 d0 add %edx,%eax 80066e: 89 45 f8 mov %eax,-0x8(%ebp) // we don't properly detect overflow! } 800671: e9 71 ff ff ff jmp 8005e7 <strtol+0xad> } else { break; } if (dig >= base) { break; 800676: 90 nop } s ++, val = (val * base) + dig; // we don't properly detect overflow! } if (endptr) { 800677: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 80067b: 74 08 je 800685 <strtol+0x14b> *endptr = (char *) s; 80067d: 8b 45 0c mov 0xc(%ebp),%eax 800680: 8b 55 08 mov 0x8(%ebp),%edx 800683: 89 10 mov %edx,(%eax) } return (neg ? -val : val); 800685: 83 7d fc 00 cmpl $0x0,-0x4(%ebp) 800689: 74 07 je 800692 <strtol+0x158> 80068b: 8b 45 f8 mov -0x8(%ebp),%eax 80068e: f7 d8 neg %eax 800690: eb 03 jmp 800695 <strtol+0x15b> 800692: 8b 45 f8 mov -0x8(%ebp),%eax } 800695: c9 leave 800696: c3 ret 00800697 <memset>: * @n: number of bytes to be set to the value * * The memset() function returns @s. * */ void * memset(void *s, char c, size_t n) { 800697: 55 push %ebp 800698: 89 e5 mov %esp,%ebp 80069a: 57 push %edi 80069b: 83 ec 24 sub $0x24,%esp 80069e: 8b 45 0c mov 0xc(%ebp),%eax 8006a1: 88 45 d8 mov %al,-0x28(%ebp) #ifdef __HAVE_ARCH_MEMSET return __memset(s, c, n); 8006a4: 0f be 45 d8 movsbl -0x28(%ebp),%eax 8006a8: 8b 55 08 mov 0x8(%ebp),%edx 8006ab: 89 55 f8 mov %edx,-0x8(%ebp) 8006ae: 88 45 f7 mov %al,-0x9(%ebp) 8006b1: 8b 45 10 mov 0x10(%ebp),%eax 8006b4: 89 45 f0 mov %eax,-0x10(%ebp) #ifndef __HAVE_ARCH_MEMSET #define __HAVE_ARCH_MEMSET static inline void * __memset(void *s, char c, size_t n) { int d0, d1; asm volatile ( 8006b7: 8b 4d f0 mov -0x10(%ebp),%ecx 8006ba: 0f b6 45 f7 movzbl -0x9(%ebp),%eax 8006be: 8b 55 f8 mov -0x8(%ebp),%edx 8006c1: 89 d7 mov %edx,%edi 8006c3: f3 aa rep stos %al,%es:(%edi) 8006c5: 89 fa mov %edi,%edx 8006c7: 89 4d ec mov %ecx,-0x14(%ebp) 8006ca: 89 55 e8 mov %edx,-0x18(%ebp) "rep; stosb;" : "=&c" (d0), "=&D" (d1) : "0" (n), "a" (c), "1" (s) : "memory"); return s; 8006cd: 8b 45 f8 mov -0x8(%ebp),%eax 8006d0: 90 nop while (n -- > 0) { *p ++ = c; } return s; #endif /* __HAVE_ARCH_MEMSET */ } 8006d1: 83 c4 24 add $0x24,%esp 8006d4: 5f pop %edi 8006d5: 5d pop %ebp 8006d6: c3 ret 008006d7 <memmove>: * @n: number of bytes to copy * * The memmove() function returns @dst. * */ void * memmove(void *dst, const void *src, size_t n) { 8006d7: 55 push %ebp 8006d8: 89 e5 mov %esp,%ebp 8006da: 57 push %edi 8006db: 56 push %esi 8006dc: 53 push %ebx 8006dd: 83 ec 30 sub $0x30,%esp 8006e0: 8b 45 08 mov 0x8(%ebp),%eax 8006e3: 89 45 f0 mov %eax,-0x10(%ebp) 8006e6: 8b 45 0c mov 0xc(%ebp),%eax 8006e9: 89 45 ec mov %eax,-0x14(%ebp) 8006ec: 8b 45 10 mov 0x10(%ebp),%eax 8006ef: 89 45 e8 mov %eax,-0x18(%ebp) #ifndef __HAVE_ARCH_MEMMOVE #define __HAVE_ARCH_MEMMOVE static inline void * __memmove(void *dst, const void *src, size_t n) { if (dst < src) { 8006f2: 8b 45 f0 mov -0x10(%ebp),%eax 8006f5: 3b 45 ec cmp -0x14(%ebp),%eax 8006f8: 73 42 jae 80073c <memmove+0x65> 8006fa: 8b 45 f0 mov -0x10(%ebp),%eax 8006fd: 89 45 e4 mov %eax,-0x1c(%ebp) 800700: 8b 45 ec mov -0x14(%ebp),%eax 800703: 89 45 e0 mov %eax,-0x20(%ebp) 800706: 8b 45 e8 mov -0x18(%ebp),%eax 800709: 89 45 dc mov %eax,-0x24(%ebp) "andl $3, %%ecx;" "jz 1f;" "rep; movsb;" "1:" : "=&c" (d0), "=&D" (d1), "=&S" (d2) : "0" (n / 4), "g" (n), "1" (dst), "2" (src) 80070c: 8b 45 dc mov -0x24(%ebp),%eax 80070f: c1 e8 02 shr $0x2,%eax 800712: 89 c1 mov %eax,%ecx #ifndef __HAVE_ARCH_MEMCPY #define __HAVE_ARCH_MEMCPY static inline void * __memcpy(void *dst, const void *src, size_t n) { int d0, d1, d2; asm volatile ( 800714: 8b 55 e4 mov -0x1c(%ebp),%edx 800717: 8b 45 e0 mov -0x20(%ebp),%eax 80071a: 89 d7 mov %edx,%edi 80071c: 89 c6 mov %eax,%esi 80071e: f3 a5 rep movsl %ds:(%esi),%es:(%edi) 800720: 8b 4d dc mov -0x24(%ebp),%ecx 800723: 83 e1 03 and $0x3,%ecx 800726: 74 02 je 80072a <memmove+0x53> 800728: f3 a4 rep movsb %ds:(%esi),%es:(%edi) 80072a: 89 f0 mov %esi,%eax 80072c: 89 fa mov %edi,%edx 80072e: 89 4d d8 mov %ecx,-0x28(%ebp) 800731: 89 55 d4 mov %edx,-0x2c(%ebp) 800734: 89 45 d0 mov %eax,-0x30(%ebp) "rep; movsb;" "1:" : "=&c" (d0), "=&D" (d1), "=&S" (d2) : "0" (n / 4), "g" (n), "1" (dst), "2" (src) : "memory"); return dst; 800737: 8b 45 e4 mov -0x1c(%ebp),%eax #ifdef __HAVE_ARCH_MEMMOVE return __memmove(dst, src, n); 80073a: eb 36 jmp 800772 <memmove+0x9b> asm volatile ( "std;" "rep; movsb;" "cld;" : "=&c" (d0), "=&S" (d1), "=&D" (d2) : "0" (n), "1" (n - 1 + src), "2" (n - 1 + dst) 80073c: 8b 45 e8 mov -0x18(%ebp),%eax 80073f: 8d 50 ff lea -0x1(%eax),%edx 800742: 8b 45 ec mov -0x14(%ebp),%eax 800745: 01 c2 add %eax,%edx 800747: 8b 45 e8 mov -0x18(%ebp),%eax 80074a: 8d 48 ff lea -0x1(%eax),%ecx 80074d: 8b 45 f0 mov -0x10(%ebp),%eax 800750: 8d 1c 01 lea (%ecx,%eax,1),%ebx __memmove(void *dst, const void *src, size_t n) { if (dst < src) { return __memcpy(dst, src, n); } int d0, d1, d2; asm volatile ( 800753: 8b 45 e8 mov -0x18(%ebp),%eax 800756: 89 c1 mov %eax,%ecx 800758: 89 d8 mov %ebx,%eax 80075a: 89 d6 mov %edx,%esi 80075c: 89 c7 mov %eax,%edi 80075e: fd std 80075f: f3 a4 rep movsb %ds:(%esi),%es:(%edi) 800761: fc cld 800762: 89 f8 mov %edi,%eax 800764: 89 f2 mov %esi,%edx 800766: 89 4d cc mov %ecx,-0x34(%ebp) 800769: 89 55 c8 mov %edx,-0x38(%ebp) 80076c: 89 45 c4 mov %eax,-0x3c(%ebp) "rep; movsb;" "cld;" : "=&c" (d0), "=&S" (d1), "=&D" (d2) : "0" (n), "1" (n - 1 + src), "2" (n - 1 + dst) : "memory"); return dst; 80076f: 8b 45 f0 mov -0x10(%ebp),%eax *d ++ = *s ++; } } return dst; #endif /* __HAVE_ARCH_MEMMOVE */ } 800772: 83 c4 30 add $0x30,%esp 800775: 5b pop %ebx 800776: 5e pop %esi 800777: 5f pop %edi 800778: 5d pop %ebp 800779: c3 ret 0080077a <memcpy>: * it always copies exactly @n bytes. To avoid overflows, the size of arrays pointed * by both @src and @dst, should be at least @n bytes, and should not overlap * (for overlapping memory area, memmove is a safer approach). * */ void * memcpy(void *dst, const void *src, size_t n) { 80077a: 55 push %ebp 80077b: 89 e5 mov %esp,%ebp 80077d: 57 push %edi 80077e: 56 push %esi 80077f: 83 ec 20 sub $0x20,%esp 800782: 8b 45 08 mov 0x8(%ebp),%eax 800785: 89 45 f4 mov %eax,-0xc(%ebp) 800788: 8b 45 0c mov 0xc(%ebp),%eax 80078b: 89 45 f0 mov %eax,-0x10(%ebp) 80078e: 8b 45 10 mov 0x10(%ebp),%eax 800791: 89 45 ec mov %eax,-0x14(%ebp) "andl $3, %%ecx;" "jz 1f;" "rep; movsb;" "1:" : "=&c" (d0), "=&D" (d1), "=&S" (d2) : "0" (n / 4), "g" (n), "1" (dst), "2" (src) 800794: 8b 45 ec mov -0x14(%ebp),%eax 800797: c1 e8 02 shr $0x2,%eax 80079a: 89 c1 mov %eax,%ecx #ifndef __HAVE_ARCH_MEMCPY #define __HAVE_ARCH_MEMCPY static inline void * __memcpy(void *dst, const void *src, size_t n) { int d0, d1, d2; asm volatile ( 80079c: 8b 55 f4 mov -0xc(%ebp),%edx 80079f: 8b 45 f0 mov -0x10(%ebp),%eax 8007a2: 89 d7 mov %edx,%edi 8007a4: 89 c6 mov %eax,%esi 8007a6: f3 a5 rep movsl %ds:(%esi),%es:(%edi) 8007a8: 8b 4d ec mov -0x14(%ebp),%ecx 8007ab: 83 e1 03 and $0x3,%ecx 8007ae: 74 02 je 8007b2 <memcpy+0x38> 8007b0: f3 a4 rep movsb %ds:(%esi),%es:(%edi) 8007b2: 89 f0 mov %esi,%eax 8007b4: 89 fa mov %edi,%edx 8007b6: 89 4d e8 mov %ecx,-0x18(%ebp) 8007b9: 89 55 e4 mov %edx,-0x1c(%ebp) 8007bc: 89 45 e0 mov %eax,-0x20(%ebp) "rep; movsb;" "1:" : "=&c" (d0), "=&D" (d1), "=&S" (d2) : "0" (n / 4), "g" (n), "1" (dst), "2" (src) : "memory"); return dst; 8007bf: 8b 45 f4 mov -0xc(%ebp),%eax #ifdef __HAVE_ARCH_MEMCPY return __memcpy(dst, src, n); 8007c2: 90 nop while (n -- > 0) { *d ++ = *s ++; } return dst; #endif /* __HAVE_ARCH_MEMCPY */ } 8007c3: 83 c4 20 add $0x20,%esp 8007c6: 5e pop %esi 8007c7: 5f pop %edi 8007c8: 5d pop %ebp 8007c9: c3 ret 008007ca <memcmp>: * match in both memory blocks has a greater value in @v1 than in @v2 * as if evaluated as unsigned char values; * - And a value less than zero indicates the opposite. * */ int memcmp(const void *v1, const void *v2, size_t n) { 8007ca: 55 push %ebp 8007cb: 89 e5 mov %esp,%ebp 8007cd: 83 ec 10 sub $0x10,%esp const char *s1 = (const char *)v1; 8007d0: 8b 45 08 mov 0x8(%ebp),%eax 8007d3: 89 45 fc mov %eax,-0x4(%ebp) const char *s2 = (const char *)v2; 8007d6: 8b 45 0c mov 0xc(%ebp),%eax 8007d9: 89 45 f8 mov %eax,-0x8(%ebp) while (n -- > 0) { 8007dc: eb 30 jmp 80080e <memcmp+0x44> if (*s1 != *s2) { 8007de: 8b 45 fc mov -0x4(%ebp),%eax 8007e1: 0f b6 10 movzbl (%eax),%edx 8007e4: 8b 45 f8 mov -0x8(%ebp),%eax 8007e7: 0f b6 00 movzbl (%eax),%eax 8007ea: 38 c2 cmp %al,%dl 8007ec: 74 18 je 800806 <memcmp+0x3c> return (int)((unsigned char)*s1 - (unsigned char)*s2); 8007ee: 8b 45 fc mov -0x4(%ebp),%eax 8007f1: 0f b6 00 movzbl (%eax),%eax 8007f4: 0f b6 d0 movzbl %al,%edx 8007f7: 8b 45 f8 mov -0x8(%ebp),%eax 8007fa: 0f b6 00 movzbl (%eax),%eax 8007fd: 0f b6 c0 movzbl %al,%eax 800800: 29 c2 sub %eax,%edx 800802: 89 d0 mov %edx,%eax 800804: eb 1a jmp 800820 <memcmp+0x56> } s1 ++, s2 ++; 800806: 83 45 fc 01 addl $0x1,-0x4(%ebp) 80080a: 83 45 f8 01 addl $0x1,-0x8(%ebp) * */ int memcmp(const void *v1, const void *v2, size_t n) { const char *s1 = (const char *)v1; const char *s2 = (const char *)v2; while (n -- > 0) { 80080e: 8b 45 10 mov 0x10(%ebp),%eax 800811: 8d 50 ff lea -0x1(%eax),%edx 800814: 89 55 10 mov %edx,0x10(%ebp) 800817: 85 c0 test %eax,%eax 800819: 75 c3 jne 8007de <memcmp+0x14> if (*s1 != *s2) { return (int)((unsigned char)*s1 - (unsigned char)*s2); } s1 ++, s2 ++; } return 0; 80081b: b8 00 00 00 00 mov $0x0,%eax } 800820: c9 leave 800821: c3 ret 00800822 <printnum>: * @width: maximum number of digits, if the actual width is less than @width, use @padc instead * @padc: character that padded on the left if the actual width is less than @width * */ static void printnum(void (*putch)(int, void*), void *putdat, unsigned long long num, unsigned base, int width, int padc) { 800822: 55 push %ebp 800823: 89 e5 mov %esp,%ebp 800825: 83 ec 38 sub $0x38,%esp 800828: 8b 45 10 mov 0x10(%ebp),%eax 80082b: 89 45 d0 mov %eax,-0x30(%ebp) 80082e: 8b 45 14 mov 0x14(%ebp),%eax 800831: 89 45 d4 mov %eax,-0x2c(%ebp) unsigned long long result = num; 800834: 8b 45 d0 mov -0x30(%ebp),%eax 800837: 8b 55 d4 mov -0x2c(%ebp),%edx 80083a: 89 45 e8 mov %eax,-0x18(%ebp) 80083d: 89 55 ec mov %edx,-0x14(%ebp) unsigned mod = do_div(result, base); 800840: 8b 45 18 mov 0x18(%ebp),%eax 800843: 89 45 e4 mov %eax,-0x1c(%ebp) 800846: 8b 45 e8 mov -0x18(%ebp),%eax 800849: 8b 55 ec mov -0x14(%ebp),%edx 80084c: 89 45 e0 mov %eax,-0x20(%ebp) 80084f: 89 55 f0 mov %edx,-0x10(%ebp) 800852: 8b 45 f0 mov -0x10(%ebp),%eax 800855: 89 45 f4 mov %eax,-0xc(%ebp) 800858: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80085c: 74 1c je 80087a <printnum+0x58> 80085e: 8b 45 f0 mov -0x10(%ebp),%eax 800861: ba 00 00 00 00 mov $0x0,%edx 800866: f7 75 e4 divl -0x1c(%ebp) 800869: 89 55 f4 mov %edx,-0xc(%ebp) 80086c: 8b 45 f0 mov -0x10(%ebp),%eax 80086f: ba 00 00 00 00 mov $0x0,%edx 800874: f7 75 e4 divl -0x1c(%ebp) 800877: 89 45 f0 mov %eax,-0x10(%ebp) 80087a: 8b 45 e0 mov -0x20(%ebp),%eax 80087d: 8b 55 f4 mov -0xc(%ebp),%edx 800880: f7 75 e4 divl -0x1c(%ebp) 800883: 89 45 e0 mov %eax,-0x20(%ebp) 800886: 89 55 dc mov %edx,-0x24(%ebp) 800889: 8b 45 e0 mov -0x20(%ebp),%eax 80088c: 8b 55 f0 mov -0x10(%ebp),%edx 80088f: 89 45 e8 mov %eax,-0x18(%ebp) 800892: 89 55 ec mov %edx,-0x14(%ebp) 800895: 8b 45 dc mov -0x24(%ebp),%eax 800898: 89 45 d8 mov %eax,-0x28(%ebp) // first recursively print all preceding (more significant) digits if (num >= base) { 80089b: 8b 45 18 mov 0x18(%ebp),%eax 80089e: ba 00 00 00 00 mov $0x0,%edx 8008a3: 3b 55 d4 cmp -0x2c(%ebp),%edx 8008a6: 77 41 ja 8008e9 <printnum+0xc7> 8008a8: 3b 55 d4 cmp -0x2c(%ebp),%edx 8008ab: 72 05 jb 8008b2 <printnum+0x90> 8008ad: 3b 45 d0 cmp -0x30(%ebp),%eax 8008b0: 77 37 ja 8008e9 <printnum+0xc7> printnum(putch, putdat, result, base, width - 1, padc); 8008b2: 8b 45 1c mov 0x1c(%ebp),%eax 8008b5: 83 e8 01 sub $0x1,%eax 8008b8: 83 ec 04 sub $0x4,%esp 8008bb: ff 75 20 pushl 0x20(%ebp) 8008be: 50 push %eax 8008bf: ff 75 18 pushl 0x18(%ebp) 8008c2: ff 75 ec pushl -0x14(%ebp) 8008c5: ff 75 e8 pushl -0x18(%ebp) 8008c8: ff 75 0c pushl 0xc(%ebp) 8008cb: ff 75 08 pushl 0x8(%ebp) 8008ce: e8 4f ff ff ff call 800822 <printnum> 8008d3: 83 c4 20 add $0x20,%esp 8008d6: eb 1b jmp 8008f3 <printnum+0xd1> } else { // print any needed pad characters before first digit while (-- width > 0) putch(padc, putdat); 8008d8: 83 ec 08 sub $0x8,%esp 8008db: ff 75 0c pushl 0xc(%ebp) 8008de: ff 75 20 pushl 0x20(%ebp) 8008e1: 8b 45 08 mov 0x8(%ebp),%eax 8008e4: ff d0 call *%eax 8008e6: 83 c4 10 add $0x10,%esp // first recursively print all preceding (more significant) digits if (num >= base) { printnum(putch, putdat, result, base, width - 1, padc); } else { // print any needed pad characters before first digit while (-- width > 0) 8008e9: 83 6d 1c 01 subl $0x1,0x1c(%ebp) 8008ed: 83 7d 1c 00 cmpl $0x0,0x1c(%ebp) 8008f1: 7f e5 jg 8008d8 <printnum+0xb6> putch(padc, putdat); } // then print this (the least significant) digit putch("0123456789abcdef"[mod], putdat); 8008f3: 8b 45 d8 mov -0x28(%ebp),%eax 8008f6: 05 a4 11 80 00 add $0x8011a4,%eax 8008fb: 0f b6 00 movzbl (%eax),%eax 8008fe: 0f be c0 movsbl %al,%eax 800901: 83 ec 08 sub $0x8,%esp 800904: ff 75 0c pushl 0xc(%ebp) 800907: 50 push %eax 800908: 8b 45 08 mov 0x8(%ebp),%eax 80090b: ff d0 call *%eax 80090d: 83 c4 10 add $0x10,%esp } 800910: 90 nop 800911: c9 leave 800912: c3 ret 00800913 <getuint>: * getuint - get an unsigned int of various possible sizes from a varargs list * @ap: a varargs list pointer * @lflag: determines the size of the vararg that @ap points to * */ static unsigned long long getuint(va_list *ap, int lflag) { 800913: 55 push %ebp 800914: 89 e5 mov %esp,%ebp if (lflag >= 2) { 800916: 83 7d 0c 01 cmpl $0x1,0xc(%ebp) 80091a: 7e 14 jle 800930 <getuint+0x1d> return va_arg(*ap, unsigned long long); 80091c: 8b 45 08 mov 0x8(%ebp),%eax 80091f: 8b 00 mov (%eax),%eax 800921: 8d 48 08 lea 0x8(%eax),%ecx 800924: 8b 55 08 mov 0x8(%ebp),%edx 800927: 89 0a mov %ecx,(%edx) 800929: 8b 50 04 mov 0x4(%eax),%edx 80092c: 8b 00 mov (%eax),%eax 80092e: eb 30 jmp 800960 <getuint+0x4d> } else if (lflag) { 800930: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 800934: 74 16 je 80094c <getuint+0x39> return va_arg(*ap, unsigned long); 800936: 8b 45 08 mov 0x8(%ebp),%eax 800939: 8b 00 mov (%eax),%eax 80093b: 8d 48 04 lea 0x4(%eax),%ecx 80093e: 8b 55 08 mov 0x8(%ebp),%edx 800941: 89 0a mov %ecx,(%edx) 800943: 8b 00 mov (%eax),%eax 800945: ba 00 00 00 00 mov $0x0,%edx 80094a: eb 14 jmp 800960 <getuint+0x4d> } else { return va_arg(*ap, unsigned int); 80094c: 8b 45 08 mov 0x8(%ebp),%eax 80094f: 8b 00 mov (%eax),%eax 800951: 8d 48 04 lea 0x4(%eax),%ecx 800954: 8b 55 08 mov 0x8(%ebp),%edx 800957: 89 0a mov %ecx,(%edx) 800959: 8b 00 mov (%eax),%eax 80095b: ba 00 00 00 00 mov $0x0,%edx } } 800960: 5d pop %ebp 800961: c3 ret 00800962 <getint>: * getint - same as getuint but signed, we can't use getuint because of sign extension * @ap: a varargs list pointer * @lflag: determines the size of the vararg that @ap points to * */ static long long getint(va_list *ap, int lflag) { 800962: 55 push %ebp 800963: 89 e5 mov %esp,%ebp if (lflag >= 2) { 800965: 83 7d 0c 01 cmpl $0x1,0xc(%ebp) 800969: 7e 14 jle 80097f <getint+0x1d> return va_arg(*ap, long long); 80096b: 8b 45 08 mov 0x8(%ebp),%eax 80096e: 8b 00 mov (%eax),%eax 800970: 8d 48 08 lea 0x8(%eax),%ecx 800973: 8b 55 08 mov 0x8(%ebp),%edx 800976: 89 0a mov %ecx,(%edx) 800978: 8b 50 04 mov 0x4(%eax),%edx 80097b: 8b 00 mov (%eax),%eax 80097d: eb 28 jmp 8009a7 <getint+0x45> } else if (lflag) { 80097f: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 800983: 74 12 je 800997 <getint+0x35> return va_arg(*ap, long); 800985: 8b 45 08 mov 0x8(%ebp),%eax 800988: 8b 00 mov (%eax),%eax 80098a: 8d 48 04 lea 0x4(%eax),%ecx 80098d: 8b 55 08 mov 0x8(%ebp),%edx 800990: 89 0a mov %ecx,(%edx) 800992: 8b 00 mov (%eax),%eax 800994: 99 cltd 800995: eb 10 jmp 8009a7 <getint+0x45> } else { return va_arg(*ap, int); 800997: 8b 45 08 mov 0x8(%ebp),%eax 80099a: 8b 00 mov (%eax),%eax 80099c: 8d 48 04 lea 0x4(%eax),%ecx 80099f: 8b 55 08 mov 0x8(%ebp),%edx 8009a2: 89 0a mov %ecx,(%edx) 8009a4: 8b 00 mov (%eax),%eax 8009a6: 99 cltd } } 8009a7: 5d pop %ebp 8009a8: c3 ret 008009a9 <printfmt>: * @putch: specified putch function, print a single character * @putdat: used by @putch function * @fmt: the format string to use * */ void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) { 8009a9: 55 push %ebp 8009aa: 89 e5 mov %esp,%ebp 8009ac: 83 ec 18 sub $0x18,%esp va_list ap; va_start(ap, fmt); 8009af: 8d 45 14 lea 0x14(%ebp),%eax 8009b2: 89 45 f4 mov %eax,-0xc(%ebp) vprintfmt(putch, putdat, fmt, ap); 8009b5: 8b 45 f4 mov -0xc(%ebp),%eax 8009b8: 50 push %eax 8009b9: ff 75 10 pushl 0x10(%ebp) 8009bc: ff 75 0c pushl 0xc(%ebp) 8009bf: ff 75 08 pushl 0x8(%ebp) 8009c2: e8 06 00 00 00 call 8009cd <vprintfmt> 8009c7: 83 c4 10 add $0x10,%esp va_end(ap); } 8009ca: 90 nop 8009cb: c9 leave 8009cc: c3 ret 008009cd <vprintfmt>: * * Call this function if you are already dealing with a va_list. * Or you probably want printfmt() instead. * */ void vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap) { 8009cd: 55 push %ebp 8009ce: 89 e5 mov %esp,%ebp 8009d0: 56 push %esi 8009d1: 53 push %ebx 8009d2: 83 ec 20 sub $0x20,%esp register int ch, err; unsigned long long num; int base, width, precision, lflag, altflag; while (1) { while ((ch = *(unsigned char *)fmt ++) != '%') { 8009d5: eb 17 jmp 8009ee <vprintfmt+0x21> if (ch == '\0') { 8009d7: 85 db test %ebx,%ebx 8009d9: 0f 84 8e 03 00 00 je 800d6d <vprintfmt+0x3a0> return; } putch(ch, putdat); 8009df: 83 ec 08 sub $0x8,%esp 8009e2: ff 75 0c pushl 0xc(%ebp) 8009e5: 53 push %ebx 8009e6: 8b 45 08 mov 0x8(%ebp),%eax 8009e9: ff d0 call *%eax 8009eb: 83 c4 10 add $0x10,%esp register int ch, err; unsigned long long num; int base, width, precision, lflag, altflag; while (1) { while ((ch = *(unsigned char *)fmt ++) != '%') { 8009ee: 8b 45 10 mov 0x10(%ebp),%eax 8009f1: 8d 50 01 lea 0x1(%eax),%edx 8009f4: 89 55 10 mov %edx,0x10(%ebp) 8009f7: 0f b6 00 movzbl (%eax),%eax 8009fa: 0f b6 d8 movzbl %al,%ebx 8009fd: 83 fb 25 cmp $0x25,%ebx 800a00: 75 d5 jne 8009d7 <vprintfmt+0xa> } putch(ch, putdat); } // Process a %-escape sequence char padc = ' '; 800a02: c6 45 db 20 movb $0x20,-0x25(%ebp) width = precision = -1; 800a06: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp) 800a0d: 8b 45 e4 mov -0x1c(%ebp),%eax 800a10: 89 45 e8 mov %eax,-0x18(%ebp) lflag = altflag = 0; 800a13: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) 800a1a: 8b 45 dc mov -0x24(%ebp),%eax 800a1d: 89 45 e0 mov %eax,-0x20(%ebp) reswitch: switch (ch = *(unsigned char *)fmt ++) { 800a20: 8b 45 10 mov 0x10(%ebp),%eax 800a23: 8d 50 01 lea 0x1(%eax),%edx 800a26: 89 55 10 mov %edx,0x10(%ebp) 800a29: 0f b6 00 movzbl (%eax),%eax 800a2c: 0f b6 d8 movzbl %al,%ebx 800a2f: 8d 43 dd lea -0x23(%ebx),%eax 800a32: 83 f8 55 cmp $0x55,%eax 800a35: 0f 87 05 03 00 00 ja 800d40 <vprintfmt+0x373> 800a3b: 8b 04 85 c8 11 80 00 mov 0x8011c8(,%eax,4),%eax 800a42: ff e0 jmp *%eax // flag to pad on the right case '-': padc = '-'; 800a44: c6 45 db 2d movb $0x2d,-0x25(%ebp) goto reswitch; 800a48: eb d6 jmp 800a20 <vprintfmt+0x53> // flag to pad with 0's instead of spaces case '0': padc = '0'; 800a4a: c6 45 db 30 movb $0x30,-0x25(%ebp) goto reswitch; 800a4e: eb d0 jmp 800a20 <vprintfmt+0x53> // width field case '1' ... '9': for (precision = 0; ; ++ fmt) { 800a50: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) precision = precision * 10 + ch - '0'; 800a57: 8b 55 e4 mov -0x1c(%ebp),%edx 800a5a: 89 d0 mov %edx,%eax 800a5c: c1 e0 02 shl $0x2,%eax 800a5f: 01 d0 add %edx,%eax 800a61: 01 c0 add %eax,%eax 800a63: 01 d8 add %ebx,%eax 800a65: 83 e8 30 sub $0x30,%eax 800a68: 89 45 e4 mov %eax,-0x1c(%ebp) ch = *fmt; 800a6b: 8b 45 10 mov 0x10(%ebp),%eax 800a6e: 0f b6 00 movzbl (%eax),%eax 800a71: 0f be d8 movsbl %al,%ebx if (ch < '0' || ch > '9') { 800a74: 83 fb 2f cmp $0x2f,%ebx 800a77: 7e 39 jle 800ab2 <vprintfmt+0xe5> 800a79: 83 fb 39 cmp $0x39,%ebx 800a7c: 7f 34 jg 800ab2 <vprintfmt+0xe5> padc = '0'; goto reswitch; // width field case '1' ... '9': for (precision = 0; ; ++ fmt) { 800a7e: 83 45 10 01 addl $0x1,0x10(%ebp) precision = precision * 10 + ch - '0'; ch = *fmt; if (ch < '0' || ch > '9') { break; } } 800a82: eb d3 jmp 800a57 <vprintfmt+0x8a> goto process_precision; case '*': precision = va_arg(ap, int); 800a84: 8b 45 14 mov 0x14(%ebp),%eax 800a87: 8d 50 04 lea 0x4(%eax),%edx 800a8a: 89 55 14 mov %edx,0x14(%ebp) 800a8d: 8b 00 mov (%eax),%eax 800a8f: 89 45 e4 mov %eax,-0x1c(%ebp) goto process_precision; 800a92: eb 1f jmp 800ab3 <vprintfmt+0xe6> case '.': if (width < 0) 800a94: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 800a98: 79 86 jns 800a20 <vprintfmt+0x53> width = 0; 800a9a: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp) goto reswitch; 800aa1: e9 7a ff ff ff jmp 800a20 <vprintfmt+0x53> case '#': altflag = 1; 800aa6: c7 45 dc 01 00 00 00 movl $0x1,-0x24(%ebp) goto reswitch; 800aad: e9 6e ff ff ff jmp 800a20 <vprintfmt+0x53> ch = *fmt; if (ch < '0' || ch > '9') { break; } } goto process_precision; 800ab2: 90 nop case '#': altflag = 1; goto reswitch; process_precision: if (width < 0) 800ab3: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 800ab7: 0f 89 63 ff ff ff jns 800a20 <vprintfmt+0x53> width = precision, precision = -1; 800abd: 8b 45 e4 mov -0x1c(%ebp),%eax 800ac0: 89 45 e8 mov %eax,-0x18(%ebp) 800ac3: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp) goto reswitch; 800aca: e9 51 ff ff ff jmp 800a20 <vprintfmt+0x53> // long flag (doubled for long long) case 'l': lflag ++; 800acf: 83 45 e0 01 addl $0x1,-0x20(%ebp) goto reswitch; 800ad3: e9 48 ff ff ff jmp 800a20 <vprintfmt+0x53> // character case 'c': putch(va_arg(ap, int), putdat); 800ad8: 8b 45 14 mov 0x14(%ebp),%eax 800adb: 8d 50 04 lea 0x4(%eax),%edx 800ade: 89 55 14 mov %edx,0x14(%ebp) 800ae1: 8b 00 mov (%eax),%eax 800ae3: 83 ec 08 sub $0x8,%esp 800ae6: ff 75 0c pushl 0xc(%ebp) 800ae9: 50 push %eax 800aea: 8b 45 08 mov 0x8(%ebp),%eax 800aed: ff d0 call *%eax 800aef: 83 c4 10 add $0x10,%esp break; 800af2: e9 71 02 00 00 jmp 800d68 <vprintfmt+0x39b> // error message case 'e': err = va_arg(ap, int); 800af7: 8b 45 14 mov 0x14(%ebp),%eax 800afa: 8d 50 04 lea 0x4(%eax),%edx 800afd: 89 55 14 mov %edx,0x14(%ebp) 800b00: 8b 18 mov (%eax),%ebx if (err < 0) { 800b02: 85 db test %ebx,%ebx 800b04: 79 02 jns 800b08 <vprintfmt+0x13b> err = -err; 800b06: f7 db neg %ebx } if (err > MAXERROR || (p = error_string[err]) == NULL) { 800b08: 83 fb 18 cmp $0x18,%ebx 800b0b: 7f 0b jg 800b18 <vprintfmt+0x14b> 800b0d: 8b 34 9d 40 11 80 00 mov 0x801140(,%ebx,4),%esi 800b14: 85 f6 test %esi,%esi 800b16: 75 19 jne 800b31 <vprintfmt+0x164> printfmt(putch, putdat, "error %d", err); 800b18: 53 push %ebx 800b19: 68 b5 11 80 00 push $0x8011b5 800b1e: ff 75 0c pushl 0xc(%ebp) 800b21: ff 75 08 pushl 0x8(%ebp) 800b24: e8 80 fe ff ff call 8009a9 <printfmt> 800b29: 83 c4 10 add $0x10,%esp } else { printfmt(putch, putdat, "%s", p); } break; 800b2c: e9 37 02 00 00 jmp 800d68 <vprintfmt+0x39b> } if (err > MAXERROR || (p = error_string[err]) == NULL) { printfmt(putch, putdat, "error %d", err); } else { printfmt(putch, putdat, "%s", p); 800b31: 56 push %esi 800b32: 68 be 11 80 00 push $0x8011be 800b37: ff 75 0c pushl 0xc(%ebp) 800b3a: ff 75 08 pushl 0x8(%ebp) 800b3d: e8 67 fe ff ff call 8009a9 <printfmt> 800b42: 83 c4 10 add $0x10,%esp } break; 800b45: e9 1e 02 00 00 jmp 800d68 <vprintfmt+0x39b> // string case 's': if ((p = va_arg(ap, char *)) == NULL) { 800b4a: 8b 45 14 mov 0x14(%ebp),%eax 800b4d: 8d 50 04 lea 0x4(%eax),%edx 800b50: 89 55 14 mov %edx,0x14(%ebp) 800b53: 8b 30 mov (%eax),%esi 800b55: 85 f6 test %esi,%esi 800b57: 75 05 jne 800b5e <vprintfmt+0x191> p = "(null)"; 800b59: be c1 11 80 00 mov $0x8011c1,%esi } if (width > 0 && padc != '-') { 800b5e: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 800b62: 7e 76 jle 800bda <vprintfmt+0x20d> 800b64: 80 7d db 2d cmpb $0x2d,-0x25(%ebp) 800b68: 74 70 je 800bda <vprintfmt+0x20d> for (width -= strnlen(p, precision); width > 0; width --) { 800b6a: 8b 45 e4 mov -0x1c(%ebp),%eax 800b6d: 83 ec 08 sub $0x8,%esp 800b70: 50 push %eax 800b71: 56 push %esi 800b72: e8 17 f8 ff ff call 80038e <strnlen> 800b77: 83 c4 10 add $0x10,%esp 800b7a: 89 c2 mov %eax,%edx 800b7c: 8b 45 e8 mov -0x18(%ebp),%eax 800b7f: 29 d0 sub %edx,%eax 800b81: 89 45 e8 mov %eax,-0x18(%ebp) 800b84: eb 17 jmp 800b9d <vprintfmt+0x1d0> putch(padc, putdat); 800b86: 0f be 45 db movsbl -0x25(%ebp),%eax 800b8a: 83 ec 08 sub $0x8,%esp 800b8d: ff 75 0c pushl 0xc(%ebp) 800b90: 50 push %eax 800b91: 8b 45 08 mov 0x8(%ebp),%eax 800b94: ff d0 call *%eax 800b96: 83 c4 10 add $0x10,%esp case 's': if ((p = va_arg(ap, char *)) == NULL) { p = "(null)"; } if (width > 0 && padc != '-') { for (width -= strnlen(p, precision); width > 0; width --) { 800b99: 83 6d e8 01 subl $0x1,-0x18(%ebp) 800b9d: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 800ba1: 7f e3 jg 800b86 <vprintfmt+0x1b9> putch(padc, putdat); } } for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) { 800ba3: eb 35 jmp 800bda <vprintfmt+0x20d> if (altflag && (ch < ' ' || ch > '~')) { 800ba5: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) 800ba9: 74 1c je 800bc7 <vprintfmt+0x1fa> 800bab: 83 fb 1f cmp $0x1f,%ebx 800bae: 7e 05 jle 800bb5 <vprintfmt+0x1e8> 800bb0: 83 fb 7e cmp $0x7e,%ebx 800bb3: 7e 12 jle 800bc7 <vprintfmt+0x1fa> putch('?', putdat); 800bb5: 83 ec 08 sub $0x8,%esp 800bb8: ff 75 0c pushl 0xc(%ebp) 800bbb: 6a 3f push $0x3f 800bbd: 8b 45 08 mov 0x8(%ebp),%eax 800bc0: ff d0 call *%eax 800bc2: 83 c4 10 add $0x10,%esp 800bc5: eb 0f jmp 800bd6 <vprintfmt+0x209> } else { putch(ch, putdat); 800bc7: 83 ec 08 sub $0x8,%esp 800bca: ff 75 0c pushl 0xc(%ebp) 800bcd: 53 push %ebx 800bce: 8b 45 08 mov 0x8(%ebp),%eax 800bd1: ff d0 call *%eax 800bd3: 83 c4 10 add $0x10,%esp if (width > 0 && padc != '-') { for (width -= strnlen(p, precision); width > 0; width --) { putch(padc, putdat); } } for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) { 800bd6: 83 6d e8 01 subl $0x1,-0x18(%ebp) 800bda: 89 f0 mov %esi,%eax 800bdc: 8d 70 01 lea 0x1(%eax),%esi 800bdf: 0f b6 00 movzbl (%eax),%eax 800be2: 0f be d8 movsbl %al,%ebx 800be5: 85 db test %ebx,%ebx 800be7: 74 26 je 800c0f <vprintfmt+0x242> 800be9: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 800bed: 78 b6 js 800ba5 <vprintfmt+0x1d8> 800bef: 83 6d e4 01 subl $0x1,-0x1c(%ebp) 800bf3: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 800bf7: 79 ac jns 800ba5 <vprintfmt+0x1d8> } else { putch(ch, putdat); } } for (; width > 0; width --) { 800bf9: eb 14 jmp 800c0f <vprintfmt+0x242> putch(' ', putdat); 800bfb: 83 ec 08 sub $0x8,%esp 800bfe: ff 75 0c pushl 0xc(%ebp) 800c01: 6a 20 push $0x20 800c03: 8b 45 08 mov 0x8(%ebp),%eax 800c06: ff d0 call *%eax 800c08: 83 c4 10 add $0x10,%esp } else { putch(ch, putdat); } } for (; width > 0; width --) { 800c0b: 83 6d e8 01 subl $0x1,-0x18(%ebp) 800c0f: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 800c13: 7f e6 jg 800bfb <vprintfmt+0x22e> putch(' ', putdat); } break; 800c15: e9 4e 01 00 00 jmp 800d68 <vprintfmt+0x39b> // (signed) decimal case 'd': num = getint(&ap, lflag); 800c1a: 83 ec 08 sub $0x8,%esp 800c1d: ff 75 e0 pushl -0x20(%ebp) 800c20: 8d 45 14 lea 0x14(%ebp),%eax 800c23: 50 push %eax 800c24: e8 39 fd ff ff call 800962 <getint> 800c29: 83 c4 10 add $0x10,%esp 800c2c: 89 45 f0 mov %eax,-0x10(%ebp) 800c2f: 89 55 f4 mov %edx,-0xc(%ebp) if ((long long)num < 0) { 800c32: 8b 45 f0 mov -0x10(%ebp),%eax 800c35: 8b 55 f4 mov -0xc(%ebp),%edx 800c38: 85 d2 test %edx,%edx 800c3a: 79 23 jns 800c5f <vprintfmt+0x292> putch('-', putdat); 800c3c: 83 ec 08 sub $0x8,%esp 800c3f: ff 75 0c pushl 0xc(%ebp) 800c42: 6a 2d push $0x2d 800c44: 8b 45 08 mov 0x8(%ebp),%eax 800c47: ff d0 call *%eax 800c49: 83 c4 10 add $0x10,%esp num = -(long long)num; 800c4c: 8b 45 f0 mov -0x10(%ebp),%eax 800c4f: 8b 55 f4 mov -0xc(%ebp),%edx 800c52: f7 d8 neg %eax 800c54: 83 d2 00 adc $0x0,%edx 800c57: f7 da neg %edx 800c59: 89 45 f0 mov %eax,-0x10(%ebp) 800c5c: 89 55 f4 mov %edx,-0xc(%ebp) } base = 10; 800c5f: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp) goto number; 800c66: e9 9f 00 00 00 jmp 800d0a <vprintfmt+0x33d> // unsigned decimal case 'u': num = getuint(&ap, lflag); 800c6b: 83 ec 08 sub $0x8,%esp 800c6e: ff 75 e0 pushl -0x20(%ebp) 800c71: 8d 45 14 lea 0x14(%ebp),%eax 800c74: 50 push %eax 800c75: e8 99 fc ff ff call 800913 <getuint> 800c7a: 83 c4 10 add $0x10,%esp 800c7d: 89 45 f0 mov %eax,-0x10(%ebp) 800c80: 89 55 f4 mov %edx,-0xc(%ebp) base = 10; 800c83: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp) goto number; 800c8a: eb 7e jmp 800d0a <vprintfmt+0x33d> // (unsigned) octal case 'o': num = getuint(&ap, lflag); 800c8c: 83 ec 08 sub $0x8,%esp 800c8f: ff 75 e0 pushl -0x20(%ebp) 800c92: 8d 45 14 lea 0x14(%ebp),%eax 800c95: 50 push %eax 800c96: e8 78 fc ff ff call 800913 <getuint> 800c9b: 83 c4 10 add $0x10,%esp 800c9e: 89 45 f0 mov %eax,-0x10(%ebp) 800ca1: 89 55 f4 mov %edx,-0xc(%ebp) base = 8; 800ca4: c7 45 ec 08 00 00 00 movl $0x8,-0x14(%ebp) goto number; 800cab: eb 5d jmp 800d0a <vprintfmt+0x33d> // pointer case 'p': putch('0', putdat); 800cad: 83 ec 08 sub $0x8,%esp 800cb0: ff 75 0c pushl 0xc(%ebp) 800cb3: 6a 30 push $0x30 800cb5: 8b 45 08 mov 0x8(%ebp),%eax 800cb8: ff d0 call *%eax 800cba: 83 c4 10 add $0x10,%esp putch('x', putdat); 800cbd: 83 ec 08 sub $0x8,%esp 800cc0: ff 75 0c pushl 0xc(%ebp) 800cc3: 6a 78 push $0x78 800cc5: 8b 45 08 mov 0x8(%ebp),%eax 800cc8: ff d0 call *%eax 800cca: 83 c4 10 add $0x10,%esp num = (unsigned long long)(uintptr_t)va_arg(ap, void *); 800ccd: 8b 45 14 mov 0x14(%ebp),%eax 800cd0: 8d 50 04 lea 0x4(%eax),%edx 800cd3: 89 55 14 mov %edx,0x14(%ebp) 800cd6: 8b 00 mov (%eax),%eax 800cd8: 89 45 f0 mov %eax,-0x10(%ebp) 800cdb: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) base = 16; 800ce2: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp) goto number; 800ce9: eb 1f jmp 800d0a <vprintfmt+0x33d> // (unsigned) hexadecimal case 'x': num = getuint(&ap, lflag); 800ceb: 83 ec 08 sub $0x8,%esp 800cee: ff 75 e0 pushl -0x20(%ebp) 800cf1: 8d 45 14 lea 0x14(%ebp),%eax 800cf4: 50 push %eax 800cf5: e8 19 fc ff ff call 800913 <getuint> 800cfa: 83 c4 10 add $0x10,%esp 800cfd: 89 45 f0 mov %eax,-0x10(%ebp) 800d00: 89 55 f4 mov %edx,-0xc(%ebp) base = 16; 800d03: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp) number: printnum(putch, putdat, num, base, width, padc); 800d0a: 0f be 55 db movsbl -0x25(%ebp),%edx 800d0e: 8b 45 ec mov -0x14(%ebp),%eax 800d11: 83 ec 04 sub $0x4,%esp 800d14: 52 push %edx 800d15: ff 75 e8 pushl -0x18(%ebp) 800d18: 50 push %eax 800d19: ff 75 f4 pushl -0xc(%ebp) 800d1c: ff 75 f0 pushl -0x10(%ebp) 800d1f: ff 75 0c pushl 0xc(%ebp) 800d22: ff 75 08 pushl 0x8(%ebp) 800d25: e8 f8 fa ff ff call 800822 <printnum> 800d2a: 83 c4 20 add $0x20,%esp break; 800d2d: eb 39 jmp 800d68 <vprintfmt+0x39b> // escaped '%' character case '%': putch(ch, putdat); 800d2f: 83 ec 08 sub $0x8,%esp 800d32: ff 75 0c pushl 0xc(%ebp) 800d35: 53 push %ebx 800d36: 8b 45 08 mov 0x8(%ebp),%eax 800d39: ff d0 call *%eax 800d3b: 83 c4 10 add $0x10,%esp break; 800d3e: eb 28 jmp 800d68 <vprintfmt+0x39b> // unrecognized escape sequence - just print it literally default: putch('%', putdat); 800d40: 83 ec 08 sub $0x8,%esp 800d43: ff 75 0c pushl 0xc(%ebp) 800d46: 6a 25 push $0x25 800d48: 8b 45 08 mov 0x8(%ebp),%eax 800d4b: ff d0 call *%eax 800d4d: 83 c4 10 add $0x10,%esp for (fmt --; fmt[-1] != '%'; fmt --) 800d50: 83 6d 10 01 subl $0x1,0x10(%ebp) 800d54: eb 04 jmp 800d5a <vprintfmt+0x38d> 800d56: 83 6d 10 01 subl $0x1,0x10(%ebp) 800d5a: 8b 45 10 mov 0x10(%ebp),%eax 800d5d: 83 e8 01 sub $0x1,%eax 800d60: 0f b6 00 movzbl (%eax),%eax 800d63: 3c 25 cmp $0x25,%al 800d65: 75 ef jne 800d56 <vprintfmt+0x389> /* do nothing */; break; 800d67: 90 nop } } 800d68: e9 68 fc ff ff jmp 8009d5 <vprintfmt+0x8> int base, width, precision, lflag, altflag; while (1) { while ((ch = *(unsigned char *)fmt ++) != '%') { if (ch == '\0') { return; 800d6d: 90 nop for (fmt --; fmt[-1] != '%'; fmt --) /* do nothing */; break; } } } 800d6e: 8d 65 f8 lea -0x8(%ebp),%esp 800d71: 5b pop %ebx 800d72: 5e pop %esi 800d73: 5d pop %ebp 800d74: c3 ret 00800d75 <sprintputch>: * sprintputch - 'print' a single character in a buffer * @ch: the character will be printed * @b: the buffer to place the character @ch * */ static void sprintputch(int ch, struct sprintbuf *b) { 800d75: 55 push %ebp 800d76: 89 e5 mov %esp,%ebp b->cnt ++; 800d78: 8b 45 0c mov 0xc(%ebp),%eax 800d7b: 8b 40 08 mov 0x8(%eax),%eax 800d7e: 8d 50 01 lea 0x1(%eax),%edx 800d81: 8b 45 0c mov 0xc(%ebp),%eax 800d84: 89 50 08 mov %edx,0x8(%eax) if (b->buf < b->ebuf) { 800d87: 8b 45 0c mov 0xc(%ebp),%eax 800d8a: 8b 10 mov (%eax),%edx 800d8c: 8b 45 0c mov 0xc(%ebp),%eax 800d8f: 8b 40 04 mov 0x4(%eax),%eax 800d92: 39 c2 cmp %eax,%edx 800d94: 73 12 jae 800da8 <sprintputch+0x33> *b->buf ++ = ch; 800d96: 8b 45 0c mov 0xc(%ebp),%eax 800d99: 8b 00 mov (%eax),%eax 800d9b: 8d 48 01 lea 0x1(%eax),%ecx 800d9e: 8b 55 0c mov 0xc(%ebp),%edx 800da1: 89 0a mov %ecx,(%edx) 800da3: 8b 55 08 mov 0x8(%ebp),%edx 800da6: 88 10 mov %dl,(%eax) } } 800da8: 90 nop 800da9: 5d pop %ebp 800daa: c3 ret 00800dab <snprintf>: * @str: the buffer to place the result into * @size: the size of buffer, including the trailing null space * @fmt: the format string to use * */ int snprintf(char *str, size_t size, const char *fmt, ...) { 800dab: 55 push %ebp 800dac: 89 e5 mov %esp,%ebp 800dae: 83 ec 18 sub $0x18,%esp va_list ap; int cnt; va_start(ap, fmt); 800db1: 8d 45 14 lea 0x14(%ebp),%eax 800db4: 89 45 f0 mov %eax,-0x10(%ebp) cnt = vsnprintf(str, size, fmt, ap); 800db7: 8b 45 f0 mov -0x10(%ebp),%eax 800dba: 50 push %eax 800dbb: ff 75 10 pushl 0x10(%ebp) 800dbe: ff 75 0c pushl 0xc(%ebp) 800dc1: ff 75 08 pushl 0x8(%ebp) 800dc4: e8 0b 00 00 00 call 800dd4 <vsnprintf> 800dc9: 83 c4 10 add $0x10,%esp 800dcc: 89 45 f4 mov %eax,-0xc(%ebp) va_end(ap); return cnt; 800dcf: 8b 45 f4 mov -0xc(%ebp),%eax } 800dd2: c9 leave 800dd3: c3 ret 00800dd4 <vsnprintf>: * * Call this function if you are already dealing with a va_list. * Or you probably want snprintf() instead. * */ int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) { 800dd4: 55 push %ebp 800dd5: 89 e5 mov %esp,%ebp 800dd7: 83 ec 18 sub $0x18,%esp struct sprintbuf b = {str, str + size - 1, 0}; 800dda: 8b 45 08 mov 0x8(%ebp),%eax 800ddd: 89 45 ec mov %eax,-0x14(%ebp) 800de0: 8b 45 0c mov 0xc(%ebp),%eax 800de3: 8d 50 ff lea -0x1(%eax),%edx 800de6: 8b 45 08 mov 0x8(%ebp),%eax 800de9: 01 d0 add %edx,%eax 800deb: 89 45 f0 mov %eax,-0x10(%ebp) 800dee: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) if (str == NULL || b.buf > b.ebuf) { 800df5: 83 7d 08 00 cmpl $0x0,0x8(%ebp) 800df9: 74 0a je 800e05 <vsnprintf+0x31> 800dfb: 8b 55 ec mov -0x14(%ebp),%edx 800dfe: 8b 45 f0 mov -0x10(%ebp),%eax 800e01: 39 c2 cmp %eax,%edx 800e03: 76 07 jbe 800e0c <vsnprintf+0x38> return -E_INVAL; 800e05: b8 fd ff ff ff mov $0xfffffffd,%eax 800e0a: eb 20 jmp 800e2c <vsnprintf+0x58> } // print the string to the buffer vprintfmt((void*)sprintputch, &b, fmt, ap); 800e0c: ff 75 14 pushl 0x14(%ebp) 800e0f: ff 75 10 pushl 0x10(%ebp) 800e12: 8d 45 ec lea -0x14(%ebp),%eax 800e15: 50 push %eax 800e16: 68 75 0d 80 00 push $0x800d75 800e1b: e8 ad fb ff ff call 8009cd <vprintfmt> 800e20: 83 c4 10 add $0x10,%esp // null terminate the buffer *b.buf = '\0'; 800e23: 8b 45 ec mov -0x14(%ebp),%eax 800e26: c6 00 00 movb $0x0,(%eax) return b.cnt; 800e29: 8b 45 f4 mov -0xc(%ebp),%eax } 800e2c: c9 leave 800e2d: c3 ret 00800e2e <hash32>: * @bits: the number of bits in a return value * * High bits are more random, so we use them. * */ uint32_t hash32(uint32_t val, unsigned int bits) { 800e2e: 55 push %ebp 800e2f: 89 e5 mov %esp,%ebp 800e31: 83 ec 10 sub $0x10,%esp uint32_t hash = val * GOLDEN_RATIO_PRIME_32; 800e34: 8b 45 08 mov 0x8(%ebp),%eax 800e37: 69 c0 01 00 37 9e imul $0x9e370001,%eax,%eax 800e3d: 89 45 fc mov %eax,-0x4(%ebp) return (hash >> (32 - bits)); 800e40: b8 20 00 00 00 mov $0x20,%eax 800e45: 2b 45 0c sub 0xc(%ebp),%eax 800e48: 8b 55 fc mov -0x4(%ebp),%edx 800e4b: 89 c1 mov %eax,%ecx 800e4d: d3 ea shr %cl,%edx 800e4f: 89 d0 mov %edx,%eax } 800e51: c9 leave 800e52: c3 ret 00800e53 <rand>: * rand - returns a pseudo-random integer * * The rand() function return a value in the range [0, RAND_MAX]. * */ int rand(void) { 800e53: 55 push %ebp 800e54: 89 e5 mov %esp,%ebp 800e56: 57 push %edi 800e57: 56 push %esi 800e58: 53 push %ebx 800e59: 83 ec 24 sub $0x24,%esp next = (next * 0x5DEECE66DLL + 0xBLL) & ((1LL << 48) - 1); 800e5c: a1 00 20 80 00 mov 0x802000,%eax 800e61: 8b 15 04 20 80 00 mov 0x802004,%edx 800e67: 69 fa 6d e6 ec de imul $0xdeece66d,%edx,%edi 800e6d: 6b f0 05 imul $0x5,%eax,%esi 800e70: 01 fe add %edi,%esi 800e72: bf 6d e6 ec de mov $0xdeece66d,%edi 800e77: f7 e7 mul %edi 800e79: 01 d6 add %edx,%esi 800e7b: 89 f2 mov %esi,%edx 800e7d: 83 c0 0b add $0xb,%eax 800e80: 83 d2 00 adc $0x0,%edx 800e83: 89 c7 mov %eax,%edi 800e85: 83 e7 ff and $0xffffffff,%edi 800e88: 89 f9 mov %edi,%ecx 800e8a: 0f b7 da movzwl %dx,%ebx 800e8d: 89 0d 00 20 80 00 mov %ecx,0x802000 800e93: 89 1d 04 20 80 00 mov %ebx,0x802004 unsigned long long result = (next >> 12); 800e99: a1 00 20 80 00 mov 0x802000,%eax 800e9e: 8b 15 04 20 80 00 mov 0x802004,%edx 800ea4: 0f ac d0 0c shrd $0xc,%edx,%eax 800ea8: c1 ea 0c shr $0xc,%edx 800eab: 89 45 e0 mov %eax,-0x20(%ebp) 800eae: 89 55 e4 mov %edx,-0x1c(%ebp) return (int)do_div(result, RAND_MAX + 1); 800eb1: c7 45 dc 00 00 00 80 movl $0x80000000,-0x24(%ebp) 800eb8: 8b 45 e0 mov -0x20(%ebp),%eax 800ebb: 8b 55 e4 mov -0x1c(%ebp),%edx 800ebe: 89 45 d8 mov %eax,-0x28(%ebp) 800ec1: 89 55 e8 mov %edx,-0x18(%ebp) 800ec4: 8b 45 e8 mov -0x18(%ebp),%eax 800ec7: 89 45 ec mov %eax,-0x14(%ebp) 800eca: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 800ece: 74 1c je 800eec <rand+0x99> 800ed0: 8b 45 e8 mov -0x18(%ebp),%eax 800ed3: ba 00 00 00 00 mov $0x0,%edx 800ed8: f7 75 dc divl -0x24(%ebp) 800edb: 89 55 ec mov %edx,-0x14(%ebp) 800ede: 8b 45 e8 mov -0x18(%ebp),%eax 800ee1: ba 00 00 00 00 mov $0x0,%edx 800ee6: f7 75 dc divl -0x24(%ebp) 800ee9: 89 45 e8 mov %eax,-0x18(%ebp) 800eec: 8b 45 d8 mov -0x28(%ebp),%eax 800eef: 8b 55 ec mov -0x14(%ebp),%edx 800ef2: f7 75 dc divl -0x24(%ebp) 800ef5: 89 45 d8 mov %eax,-0x28(%ebp) 800ef8: 89 55 d4 mov %edx,-0x2c(%ebp) 800efb: 8b 45 d8 mov -0x28(%ebp),%eax 800efe: 8b 55 e8 mov -0x18(%ebp),%edx 800f01: 89 45 e0 mov %eax,-0x20(%ebp) 800f04: 89 55 e4 mov %edx,-0x1c(%ebp) 800f07: 8b 45 d4 mov -0x2c(%ebp),%eax } 800f0a: 83 c4 24 add $0x24,%esp 800f0d: 5b pop %ebx 800f0e: 5e pop %esi 800f0f: 5f pop %edi 800f10: 5d pop %ebp 800f11: c3 ret 00800f12 <srand>: /* * * srand - seed the random number generator with the given number * @seed: the required seed number * */ void srand(unsigned int seed) { 800f12: 55 push %ebp 800f13: 89 e5 mov %esp,%ebp next = seed; 800f15: 8b 45 08 mov 0x8(%ebp),%eax 800f18: ba 00 00 00 00 mov $0x0,%edx 800f1d: a3 00 20 80 00 mov %eax,0x802000 800f22: 89 15 04 20 80 00 mov %edx,0x802004 } 800f28: 90 nop 800f29: 5d pop %ebp 800f2a: c3 ret 00800f2b <main>: #include <stdio.h> #include <ulib.h> int main(void) { 800f2b: 8d 4c 24 04 lea 0x4(%esp),%ecx 800f2f: 83 e4 f0 and $0xfffffff0,%esp 800f32: ff 71 fc pushl -0x4(%ecx) 800f35: 55 push %ebp 800f36: 89 e5 mov %esp,%ebp 800f38: 51 push %ecx 800f39: 83 ec 14 sub $0x14,%esp int pid, ret; cprintf("I am the parent. Forking the child...\n"); 800f3c: 83 ec 0c sub $0xc,%esp 800f3f: 68 20 13 80 00 push $0x801320 800f44: e8 90 f3 ff ff call 8002d9 <cprintf> 800f49: 83 c4 10 add $0x10,%esp if ((pid = fork()) == 0) { 800f4c: e8 8c f2 ff ff call 8001dd <fork> 800f51: 89 45 f4 mov %eax,-0xc(%ebp) 800f54: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 800f58: 75 12 jne 800f6c <main+0x41> cprintf("I am the child. spinning ...\n"); 800f5a: 83 ec 0c sub $0xc,%esp 800f5d: 68 47 13 80 00 push $0x801347 800f62: e8 72 f3 ff ff call 8002d9 <cprintf> 800f67: 83 c4 10 add $0x10,%esp while (1); 800f6a: eb fe jmp 800f6a <main+0x3f> } cprintf("I am the parent. Running the child...\n"); 800f6c: 83 ec 0c sub $0xc,%esp 800f6f: 68 68 13 80 00 push $0x801368 800f74: e8 60 f3 ff ff call 8002d9 <cprintf> 800f79: 83 c4 10 add $0x10,%esp yield(); 800f7c: e8 99 f2 ff ff call 80021a <yield> yield(); 800f81: e8 94 f2 ff ff call 80021a <yield> yield(); 800f86: e8 8f f2 ff ff call 80021a <yield> cprintf("I am the parent. Killing the child...\n"); 800f8b: 83 ec 0c sub $0xc,%esp 800f8e: 68 90 13 80 00 push $0x801390 800f93: e8 41 f3 ff ff call 8002d9 <cprintf> 800f98: 83 c4 10 add $0x10,%esp assert((ret = kill(pid)) == 0); 800f9b: 83 ec 0c sub $0xc,%esp 800f9e: ff 75 f4 pushl -0xc(%ebp) 800fa1: e8 82 f2 ff ff call 800228 <kill> 800fa6: 83 c4 10 add $0x10,%esp 800fa9: 89 45 f0 mov %eax,-0x10(%ebp) 800fac: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 800fb0: 74 16 je 800fc8 <main+0x9d> 800fb2: 68 b8 13 80 00 push $0x8013b8 800fb7: 68 cf 13 80 00 push $0x8013cf 800fbc: 6a 14 push $0x14 800fbe: 68 e4 13 80 00 push $0x8013e4 800fc3: e8 58 f0 ff ff call 800020 <__panic> cprintf("kill returns %d\n", ret); 800fc8: 83 ec 08 sub $0x8,%esp 800fcb: ff 75 f0 pushl -0x10(%ebp) 800fce: 68 f0 13 80 00 push $0x8013f0 800fd3: e8 01 f3 ff ff call 8002d9 <cprintf> 800fd8: 83 c4 10 add $0x10,%esp assert((ret = waitpid(pid, NULL)) == 0); 800fdb: 83 ec 08 sub $0x8,%esp 800fde: 6a 00 push $0x0 800fe0: ff 75 f4 pushl -0xc(%ebp) 800fe3: e8 19 f2 ff ff call 800201 <waitpid> 800fe8: 83 c4 10 add $0x10,%esp 800feb: 89 45 f0 mov %eax,-0x10(%ebp) 800fee: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 800ff2: 74 16 je 80100a <main+0xdf> 800ff4: 68 04 14 80 00 push $0x801404 800ff9: 68 cf 13 80 00 push $0x8013cf 800ffe: 6a 17 push $0x17 801000: 68 e4 13 80 00 push $0x8013e4 801005: e8 16 f0 ff ff call 800020 <__panic> cprintf("wait returns %d\n", ret); 80100a: 83 ec 08 sub $0x8,%esp 80100d: ff 75 f0 pushl -0x10(%ebp) 801010: 68 24 14 80 00 push $0x801424 801015: e8 bf f2 ff ff call 8002d9 <cprintf> 80101a: 83 c4 10 add $0x10,%esp cprintf("spin may pass.\n"); 80101d: 83 ec 0c sub $0xc,%esp 801020: 68 35 14 80 00 push $0x801435 801025: e8 af f2 ff ff call 8002d9 <cprintf> 80102a: 83 c4 10 add $0x10,%esp return 0; 80102d: b8 00 00 00 00 mov $0x0,%eax } 801032: 8b 4d fc mov -0x4(%ebp),%ecx 801035: c9 leave 801036: 8d 61 fc lea -0x4(%ecx),%esp 801039: c3 ret
; A047330: Numbers that are congruent to {0, 1, 3, 5, 6} mod 7. ; 0,1,3,5,6,7,8,10,12,13,14,15,17,19,20,21,22,24,26,27,28,29,31,33,34,35,36,38,40,41,42,43,45,47,48,49,50,52,54,55,56,57,59,61,62,63,64,66,68,69,70,71,73,75,76,77,78 mov $1,$0 lpb $0 add $1,$0 sub $1,1 mov $3,$0 sub $0,4 trn $0,1 mov $2,$3 trn $2,3 sub $1,$2 lpe
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r14 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_UC_ht+0xa410, %r10 nop nop nop nop nop cmp $54177, %r9 movl $0x61626364, (%r10) nop nop nop nop nop sub $40046, %rax lea addresses_WC_ht+0x3510, %rsi lea addresses_WC_ht+0x15c4a, %rdi nop nop nop add $37828, %r12 mov $107, %rcx rep movsb add %rcx, %rcx lea addresses_D_ht+0x1a2b0, %rsi lea addresses_WC_ht+0x15b28, %rdi nop nop nop add %r14, %r14 mov $43, %rcx rep movsq nop nop nop nop nop cmp $53223, %r10 lea addresses_A_ht+0x1afb0, %rsi lea addresses_WT_ht+0x90b0, %rdi nop nop nop nop nop xor $64614, %r9 mov $40, %rcx rep movsl nop nop nop nop nop cmp $635, %r9 lea addresses_normal_ht+0x11630, %rsi lea addresses_D_ht+0x12570, %rdi nop inc %r12 mov $89, %rcx rep movsq nop nop nop nop nop add $1385, %r12 lea addresses_WT_ht+0x11af0, %rsi lea addresses_WC_ht+0x18c0, %rdi sub $63266, %r14 mov $28, %rcx rep movsb nop nop nop inc %r10 lea addresses_WT_ht+0x1c0a8, %rsi nop nop nop nop lfence mov $0x6162636465666768, %rdi movq %rdi, (%rsi) nop nop dec %rsi lea addresses_D_ht+0x8eb0, %rdi nop add %rsi, %rsi movb $0x61, (%rdi) nop dec %r14 lea addresses_WT_ht+0x784c, %r9 nop nop nop nop xor %rdi, %rdi movl $0x61626364, (%r9) nop nop nop nop xor $57736, %rdi pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r14 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r15 push %r9 push %rbx push %rdi // Load lea addresses_D+0x16130, %r10 nop nop nop nop nop xor %rdi, %rdi mov (%r10), %r13w nop xor $64470, %r15 // Store lea addresses_WT+0xdf30, %r15 nop nop nop and %rbx, %rbx mov $0x5152535455565758, %r13 movq %r13, (%r15) nop nop nop nop nop xor $33706, %r15 // Faulty Load lea addresses_D+0x10630, %r15 nop nop nop and $49504, %r12 mov (%r15), %bx lea oracles, %r13 and $0xff, %rbx shlq $12, %rbx mov (%r13,%rbx,1), %rbx pop %rdi pop %rbx pop %r9 pop %r15 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 7}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_D', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 0}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_D_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 2}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
; A316964: Same as A316669, except numbering of the squares starts at 0 rather than 1.. ; 0,1,2,4,3,5,8,6,7,9,13,10,11,12,14,19,15,16,17,18,20,26,21,22,23,24,25,27,34,28,29,30,31,32,33,35,43,36,37,38,39,40,41,42,44,53,45,46,47,48,49,50,51,52,54,64,55,56,57,58,59,60,61,62,63,65,76,66,67,68,69,70,71,72,73,74,75,77,89,78,79,80,81,82,83,84,85,86,87,88,90,103,91,92,93,94,95,96,97,98,99,100,101,102,104,118,105,106,107,108,109,110,111,112,113,114,115,116,117,119,134,120,121,122,123,124,125,126,127,128,129,130,131,132,133,135,151,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,152,169,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,170,188,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,189,208,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,209,229,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,230,251,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248 mov $1,1 mov $2,$0 lpb $0,1 trn $0,$1 sub $0,1 add $1,1 lpe bin $1,$0 add $1,$2 sub $1,1
test START 0 EXTDEF foo foo +ADD #10 EXTREF baz EXTDEF foo, bar, bar, baz . warning: duplicate export, error: export imported END test
; A152009: (L)-sieve transform of {1,4,7,10,...,3n-2,...} (A016777) ; 1,3,6,10,16,25,39,60,91,138,208,313,471,708,1063,1596,2395,3594,5392,8089,12135,18204,27307,40962,61444,92167 mov $2,7 lpb $0,1 sub $0,1 mul $2,12 sub $2,9 div $2,8 lpe add $1,$2 sub $1,6
// dsu implementation using a map (or unordered_map) template <typename T> struct dsu { map<T, T> root; map<T, int> size; T find(T u) { if (!root.count(u)) return root[u] = u; return root[u] == u ? u : root[u] = find(root[u]); } bool join(T u, T v) { u = find(u); v = find(v); if (u == v) return false; if (!size.count(u)) size[u] = 1; if (!size.count(v)) size[v] = 1; if (size[u] < size[v]) swap(u, v); root[v] = u; size[u] += size[v]; return true; } }; // dsu implementation using a vactor struct dsu { vector<int> root, size; dsu(int n) { size.resize(n + 1, 1); root.resize(n + 1); for (int i = 1; i < n; i++) root[i] = i; } int find(int u) { return root[u] == u ? u : root[u] = find(root[u]); } bool join(int u, int v) { u = find(u); v = find(v); if (u == v) return false; if (size[u] < size[v]) swap(u, v); root[v] = u; size[u] += size[v]; return true; } };
;;; Copyright 2020 Tadashi G. Takaoka ;;; ;;; 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. cpu 6801 org $0100 include "test_mc6800.inc" align 32 include "test_mc6801.inc" end ;;; Local Variables: ;;; mode: asm ;;; End: ;;; vim: set ft=asm:
#include <GLFW/glfw3.h> int main(void) { GLFWwindow* window; /* Initialize the library */ if (!glfwInit()) return -1; /* Create a windowed mode window and its OpenGL context */ window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); if (!window) { glfwTerminate(); return -1; } /* Make the window's context current */ glfwMakeContextCurrent(window); /* Loop until the user closes the window */ while (!glfwWindowShouldClose(window)) { /* Render here */ glClear(GL_COLOR_BUFFER_BIT); /* Swap front and back buffers */ glfwSwapBuffers(window); /* Poll for and process events */ glfwPollEvents(); } glfwTerminate(); return 0; }
lda {m1}+1 bpl {la1}
; A246507: a(n) = 70*(n+1)*binomial(2*n+1,n+1)/(n+5). ; Submitted by Jon Maiga ; 14,70,300,1225,4900,19404,76440,300300,1178100,4618900,18106088,70984095,278369000,1092063000,4286142000,16830250920,66118842900,259878874500,1021939149000,4020523757250,15824781508536,62313700079400,245478212434000,967428110493000,3814113125277000,15042862166092488,59350250233466640,234241149648288475,924796227182853200,3652288548326602800,14428278950913093728,57014973273769483280,225363238953750998100,891029456724639113700,3523799751933640657800,13939145018720358544926,55152172702795998578840 add $0,1 mov $1,$0 mul $0,2 bin $0,$1 mul $0,280 mul $0,$1 add $1,4 div $0,$1 div $0,8
; A049648: T(n,n+1), array T as in A049687 and T(2n,2n+2), array T given by A049639. ; 1,4,7,11,17,23,31,41,51,61,75,89,105,123,137,153,177,199,223,249,269,291,323,353,381,413,443,473,513,549,587,633,669,705,745,781,829,883,925,965,1021,1073,1127,1189,1233,1279,1347,1409,1467,1529,1581,1637 lpb $0 mov $2,$0 cal $2,49697 ; a(n)=T(n,n+1), array T as in A049695. mov $0,0 add $1,1 sub $2,1 add $1,$2 lpe add $1,1
//-------------------------------------------------------------- // ofApp.h //-------------------------------------------------------------- #include "ofMain.h" #include "ofxGui.h" #include "ofxOscPlus.h" #include "client.h" class ofApp : public ofBaseApp{ public: // common OF methods void setup(); void update(); void draw(); void keyPressed(int key); private: // methods void setupServerGui(); private: // callbacks void onLayoutUpdate(ofxOscPlus::ParameterClient & client); void onAddParamBtn(); void onAddClientBtn(); private: // attributes // params ofParameterGroup serverParams, subGroup, clientParams; ofParameter<float> sizeParam; ofParameter<bool> bParam; ofParameter<ofPoint> pointParam; ofParameter<ofColor> colorParam; ofParameter<string> strParam; vector<shared_ptr<ofAbstractParameter>> dynamicParams; // gui ofxPanel serverGui; // ofxOscPlus demo; server/clients ofxOscPlus::ParameterServer server; vector<shared_ptr<Client>> clients; }; //-------------------------------------------------------------- // ofApp.cpp //-------------------------------------------------------------- void ofApp::setup(){ ofLogToFile("log.txt"); ofSetWindowTitle("ofxOscPlus - example"); ofSetWindowShape(600,400); ofSetWindowPosition(5,10); // setup server serverParams.setName("TestParams"); serverParams.add(sizeParam.set("size", 5.0f)); serverParams.add(strParam.set("name", "undefined")); subGroup.setName("SubParams"); subGroup.add(bParam.set("yesno", false)); subGroup.add(pointParam.set("pnt", ofPoint(0.0f))); subGroup.add(colorParam.set("clr", ofColor::green)); serverParams.add(subGroup); server.setup(serverParams); setupServerGui(); } //-------------------------------------------------------------- void ofApp::update(){ server.update(); for(auto client : clients){ client->update(); } } //-------------------------------------------------------------- void ofApp::draw(){ serverGui.draw(); ofDrawBitmapStringHighlight("Press;\n1 - to add a param\n2 - to create a new client", 10, 20); server.drawDebug(10, 70); for(auto client : clients){ client->draw(); } } void ofApp::onAddParamBtn(){ shared_ptr<ofParameter<float>> param = make_shared<ofParameter<float>>(); serverParams.add(param->set("DynamicParamNo" + ofToString(dynamicParams.size()+1), ofRandom(10.0f))); dynamicParams.push_back(param); setupServerGui(); } void ofApp::onAddClientBtn(){ shared_ptr<Client> client = make_shared<Client>(); client->setup(8085+clients.size(), ofRandom(ofGetWidth()), ofRandom(ofGetHeight())); clients.push_back(client); } void ofApp::setupServerGui(){ serverGui.setup(serverParams, "", 250.0f, 10.0f); } //-------------------------------------------------------------- void ofApp::keyPressed(int key){ if(key == '1'){ onAddParamBtn(); return; } if(key == '2'){ onAddClientBtn(); } } //-------------------------------------------------------------- // main.cpp //-------------------------------------------------------------- int main( ){ ofSetupOpenGL(1024,768,OF_WINDOW); ofRunApp(new ofApp()); }
; SCCSID = @(#)IBMIOCTL.INC 1.1 85/04/10 IBM EQU 0FFFFH ;TRUE INCLUDE IOCTL.INC  SCCSID = @(#)IBMIOCTL.INC 1.1 85/04/10
; A104293: a(n) = prime((prime(n)-1)/2). ; 2,3,5,11,13,19,23,31,43,47,61,71,73,83,101,109,113,137,149,151,167,179,193,223,229,233,241,251,263,307,313,337,347,373,379,397,419,431,443,461,463,499,503,521,523,571,607,617,619 seq $0,98090 ; Numbers k such that 2k-3 is prime. sub $0,3 seq $0,6093 ; a(n) = prime(n) - 1. add $0,1
copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 004D54 move.b #$0, ($5e,A0) 004D5A bra $4dd6 004D6C move.b #$10, ($5e,A0) [123p+ 2] 004D72 bra $4dd6 [123p+ 5E] 004D84 move.b #$20, ($5e,A0) [123p+ 2] 004D8A bra $4dd6 [123p+ 5E] 004D94 move.l D1, (A1)+ 004D96 dbra D0, $4d94 0106A8 move.b ($5e,A2), D0 0106AC cmp.b ($e9,A3), D0 [123p+ 5E] 01097C move.b ($5e,A2), D0 010980 cmp.b ($5e,A3), D0 [123p+ 5E] 010D2A move.b ($5e,A2), D0 010D2E cmp.b ($5e,A3), D0 [123p+ 5E] 010E12 cmp.b ($5e,A3), D0 [item+5E] 010E16 beq $10e28 [123p+ 5E] 0119C4 move.b ($5e,A2), D0 0119C8 cmp.b ($5e,A3), D0 [123p+ 5E] 011AF2 move.b ($5e,A2), D0 011AF6 cmp.b ($5e,A3), D0 [123p+ 5E] 0193FE move.b ($67be,A5), ($5e,A6) 019404 addq.b #1, ($67be,A5) [123p+ 5E] 01952A move.b ($67be,A5), ($5e,A6) 019530 addq.b #1, ($67be,A5) [123p+ 5E] 019588 move.b ($67be,A5), ($5e,A6) 01958E addq.b #1, ($67be,A5) [123p+ 5E] 019646 move.b ($67be,A5), ($5e,A6) 01964C addq.b #1, ($67be,A5) [123p+ 5E] 0196CC move.b ($67be,A5), ($5e,A6) 0196D2 addq.b #1, ($67be,A5) [123p+ 5E] 019752 move.b ($67be,A5), ($5e,A6) 019758 addq.b #1, ($67be,A5) [123p+ 5E] 0197E8 move.b ($67be,A5), ($5e,A6) 0197EE addq.b #1, ($67be,A5) [123p+ 5E] 019802 move.b ($67be,A5), ($5e,A6) 019808 addq.b #1, ($67be,A5) [123p+ 5E] 019DF6 move.b ($67be,A5), ($5e,A6) 019DFC addq.b #1, ($67be,A5) [123p+ 5E] 01A53A move.b ($67be,A5), ($5e,A6) 01A540 addq.b #1, ($67be,A5) [123p+ 5E] 01A9FE move.b ($67be,A5), ($5e,A6) 01AA04 addq.b #1, ($67be,A5) [123p+ 5E] 01AA88 move.b ($67be,A5), ($5e,A6) 01AA8E addq.b #1, ($67be,A5) [123p+ 5E] 01AB06 move.b ($67be,A5), ($5e,A6) 01AB0C addq.b #1, ($67be,A5) [123p+ 5E] 01ABE8 move.b ($67be,A5), ($5e,A6) 01ABEE addq.b #1, ($67be,A5) [123p+ 5E] 01AC96 move.b ($67be,A5), ($5e,A6) 01AC9C addq.b #1, ($67be,A5) [123p+ 5E] 01ACB0 move.b ($67be,A5), ($5e,A6) 01ACB6 addq.b #1, ($67be,A5) [123p+ 5E] 01AD22 move.b ($67be,A5), ($5e,A6) 01AD28 addq.b #1, ($67be,A5) [123p+ 5E] 01AD6A move.b ($67be,A5), ($5e,A6) 01AD70 addq.b #1, ($67be,A5) [123p+ 5E] 01B4B2 move.b ($67be,A5), ($5e,A6) 01B4B8 addq.b #1, ($67be,A5) [123p+ 5E] 01B50C move.b ($67be,A5), ($5e,A6) 01B512 addq.b #1, ($67be,A5) [123p+ 5E] 01B52C move.b ($67be,A5), ($5e,A6) 01B532 addq.b #1, ($67be,A5) [123p+ 5E] 01B584 move.b ($67be,A5), ($5e,A6) 01B58A addq.b #1, ($67be,A5) [123p+ 5E] 01B5F0 move.b ($67be,A5), ($5e,A6) 01B5F6 addq.b #1, ($67be,A5) [123p+ 5E] 01B640 move.b ($67be,A5), ($5e,A6) 01B646 addq.b #1, ($67be,A5) [123p+ 5E] 01B760 move.b ($67be,A5), ($5e,A6) 01B766 addq.b #1, ($67be,A5) [123p+ 5E] 01B7F2 move.b ($67be,A5), ($5e,A6) 01B7F8 addq.b #1, ($67be,A5) [123p+ 5E] 01B80C move.b ($67be,A5), ($5e,A6) 01B812 addq.b #1, ($67be,A5) [123p+ 5E] 01B87C move.b ($67be,A5), ($5e,A6) 01B882 addq.b #1, ($67be,A5) [123p+ 5E] 01B8B6 move.b ($67be,A5), ($5e,A6) 01B8BC addq.b #1, ($67be,A5) [123p+ 5E] 01B944 move.b ($67be,A5), ($5e,A6) 01B94A addq.b #1, ($67be,A5) [123p+ 5E] 01B95E move.b ($67be,A5), ($5e,A6) 01B964 addq.b #1, ($67be,A5) [123p+ 5E] 01B9AC move.b ($67be,A5), ($5e,A6) 01B9B2 addq.b #1, ($67be,A5) [123p+ 5E] 01BA3C move.b ($67be,A5), ($5e,A6) 01BA42 addq.b #1, ($67be,A5) [123p+ 5E] 01BA96 move.b ($67be,A5), ($5e,A6) 01BA9C addq.b #1, ($67be,A5) [123p+ 5E] 01D76A move.b ($67be,A5), ($5e,A6) 01D770 addq.b #1, ($67be,A5) [123p+ 5E] 01D802 move.b ($67be,A5), ($5e,A6) 01D808 addq.b #1, ($67be,A5) [123p+ 5E] 01D8A4 move.b ($67be,A5), ($5e,A6) 01D8AA addq.b #1, ($67be,A5) [123p+ 5E] 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
;; @file ; This file provides assembly 64-bit atomic reads/writes required for memory initialization. ; ; Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ;; .686p .xmm .model small, c .CODE ;----------------------------------------------------------------------------- ; ; Section: SaMmioRead64 ; ; Description: Read 64 bits from the Memory Mapped I/O space. ; Use MMX instruction for atomic access, because some MC registers have side effect. ; ; @param[in] Address - Memory mapped I/O address. ; ;----------------------------------------------------------------------------- ;UINT64 ;SaMmioRead64 ( ; IN UINTN Address ; ) SaMmioRead64 PROC NEAR PUBLIC sub esp, 16 movq [esp], mm0 ;Save mm0 on stack mov edx, [esp + 20] ;edx = Address movq mm0, [edx] ;mm0 = [Address] movq [esp + 8], mm0 ;Store mm0 on Stack movq mm0, [esp] ;Restore mm0 emms mov eax, [esp + 8] ;eax = [Address][31:0] mov edx, [esp + 12] ;edx = [Address][64:32] add esp, 16 ret SaMmioRead64 ENDP ;----------------------------------------------------------------------------- ; ; Section: SaMmioWrite64 ; ; Description: Write 64 bits to the Memory Mapped I/O space. ; Use MMX instruction for atomic access, because some MC registers have side effect. ; ; @param[in] Address - Memory mapped I/O address. ; @param[in] Value - The value to write. ; ;----------------------------------------------------------------------------- ;UINT64 ;SaMmioWrite64 ( ; IN UINTN Address, ; IN UINT64 Value ; ) SaMmioWrite64 PROC NEAR PUBLIC sub esp, 8 movq [esp], mm0 ;Save mm0 on Stack mov edx, [esp + 12] ;edx = Address movq mm0, [esp + 16] ;mm0 = Value movq [edx], mm0 ;[Address] = Value movq mm0, [esp] ;Restore mm0 emms mov eax, [esp + 16] ;eax = Value[31:0] mov edx, [esp + 20] ;edx = Value[64:32] add esp, 8 ret SaMmioWrite64 ENDP end
; ;/* ; * FreeRTOS Kernel V10.4.1 ; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in ; * the Software without restriction, including without limitation the rights to ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of ; * the Software, and to permit persons to whom the Software is furnished to do so, ; * subject to the following conditions: ; * ; * The above copyright notice and this permission notice shall be included in all ; * copies or substantial portions of the Software. ; * ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ; * ; * http://www.FreeRTOS.org ; * http://aws.amazon.com/freertos ; * ; * 1 tab == 4 spaces! ; */ ; * The definition of the "register test" tasks, as described at the top of ; * main.c .include data_model.h .if $DEFINED( __LARGE_DATA_MODEL__ ) .define "cmp.a", cmp_x .define "incx.w", inc_x .else .define "cmp.w", cmp_x .define "inc.w", inc_x .endif .global usRegTest1LoopCounter .global usRegTest2LoopCounter .global vPortYield .def vRegTest1Implementation .def vRegTest2Implementation .text .align 2 vRegTest1Implementation: .asmfunc ; Fill each general purpose register with a known value. mov_x #0x4444, r4 mov_x #0x5555, r5 mov_x #0x6666, r6 mov_x #0x7777, r7 mov_x #0x8888, r8 mov_x #0x9999, r9 mov_x #0xaaaa, r10 mov_x #0xbbbb, r11 mov_x #0xcccc, r12 mov_x #0xdddd, r13 mov_x #0xeeee, r14 mov_x #0xffff, r15 prvRegTest1Loop: ; Test each general purpose register to check that it still contains the ; expected known value, jumping to vRegTest1Error if any register contains ; an unexpected value. cmp_x #0x4444, r4 jne vRegTest1Error cmp_x #0x5555, r5 jne vRegTest1Error cmp_x #0x6666, r6 jne vRegTest1Error cmp_x #0x7777, r7 jne vRegTest1Error cmp_x #0x8888, r8 jne vRegTest1Error cmp_x #0x9999, r9 jne vRegTest1Error cmp_x #0xaaaa, r10 jne vRegTest1Error cmp_x #0xbbbb, r11 jne vRegTest1Error cmp_x #0xcccc, r12 jne vRegTest1Error cmp_x #0xdddd, r13 jne vRegTest1Error cmp_x #0xeeee, r14 jne vRegTest1Error cmp_x #0xffff, r15 jne vRegTest1Error ; This task is still running without jumping to vRegTest1Error, so increment ; the loop counter so the check task knows the task is running error free. inc_x &usRegTest1LoopCounter ; Loop again, performing the same tests. jmp prvRegTest1Loop nop vRegTest1Error: jmp vRegTest1Error nop .endasmfunc ; ----------------------------------------------------------- ; See the comments in vRegTest1Implementation. This task is the same, it just uses ; different values in its registers. .align 2 vRegTest2Implementation: .asmfunc mov_x #0x4441, r4 mov_x #0x5551, r5 mov_x #0x6661, r6 mov_x #0x7771, r7 mov_x #0x8881, r8 mov_x #0x9991, r9 mov_x #0xaaa1, r10 mov_x #0xbbb1, r11 mov_x #0xccc1, r12 mov_x #0xddd1, r13 mov_x #0xeee1, r14 mov_x #0xfff1, r15 prvRegTest2Loop: cmp_x #0x4441, r4 jne vRegTest2Error cmp_x #0x5551, r5 jne vRegTest2Error cmp_x #0x6661, r6 jne vRegTest2Error cmp_x #0x7771, r7 jne vRegTest2Error cmp_x #0x8881, r8 jne vRegTest2Error cmp_x #0x9991, r9 jne vRegTest2Error cmp_x #0xaaa1, r10 jne vRegTest2Error cmp_x #0xbbb1, r11 jne vRegTest2Error cmp_x #0xccc1, r12 jne vRegTest2Error cmp_x #0xddd1, r13 jne vRegTest2Error cmp_x #0xeee1, r14 jne vRegTest2Error cmp_x #0xfff1, r15 jne vRegTest2Error ; Also perform a manual yield, just to increase the scope of the test. call_x #vPortYield inc_x &usRegTest2LoopCounter jmp prvRegTest2Loop nop vRegTest2Error: jmp vRegTest2Error nop .endasmfunc ; /*----------------------------------------------------------- .end
; A290059: a(n) = binomial(2*prime(n)-1, prime(n)-1) where prime(n) is the n-th prime. ; 3,10,126,1716,352716,5200300,1166803110,17672631900,4116715363800,15033633249770520,232714176627630544,873065282167813104916,212392290424395860814420,3318776542511877736535400,812850570172585125274307760,3136262529306125724764953838760,12178349853827309571919303301013360,191645966716130525165099506263706416,749146650746521593754190788877936298300,186320517287259800139081846983822365788600,2940149106507862980124704792396922948726500,11578003247010595978171353841179630690575689200 seq $0,6005 ; The odd prime numbers together with 1. max $0,2 mov $1,$0 mul $1,2 bin $1,$0 mov $0,$1 div $0,2
;; Sub-routine for printing new line ;; using BIOS interrupts print two ASCII symbols: ;; new line = 0x0A ;; carriage return = 0x0D [bits 16] print_nl: ;; store all register values pusha ;; prepare for BIOS interrupt mov ah, 0x0E mov al, 0x0A int 0x10 mov al, 0x0D int 0x10 ;; restore all registers popa ret
!!ARBfp1.0 # This is the fragment program for one # component data with shading # We need some temporary variables TEMP index, normal, finalColor; TEMP temp1, temp2, temp3; TEMP sampleColor; TEMP ndotl, ndoth, ndotv; TEMP lightInfo, lightResult; # We are going to use the first # texture coordinate ATTRIB tex0 = fragment.texcoord[0]; # This is the lighting information PARAM lightDirection = program.local[0]; PARAM halfwayVector = program.local[1]; PARAM coefficient = program.local[2]; PARAM lightDiffColor = program.local[3]; PARAM lightSpecColor = program.local[4]; PARAM viewVector = program.local[5]; PARAM constants = program.local[6]; # This is our output color OUTPUT out = result.color; # Look up the scalar value / gradient # magnitude in the first volume TEX temp1, tex0, texture[0], 3D; # Look up the gradient direction # in the third volume TEX temp2, tex0, texture[2], 3D; # This normal is stored 0 to 1, change to -1 to 1 # by multiplying by 2.0 then adding -1.0. MAD normal, temp2, constants.x, constants.y; # Swizzle this to use (a,r) as texture # coordinates SWZ index, temp1, a, r, 1, 1; # Use this coordinate to look up a # final color in the third texture # (this is a 2D texture) TEX sampleColor, index, texture[1], 2D; # Take the dot product of the light # direction and the normal DP3 ndotl, normal, lightDirection; # Take the dot product of the halfway # vector and the normal DP3 ndoth, normal, halfwayVector; DP3 ndotv, normal, viewVector; # flip if necessary for two sided lighting MUL temp3, ndotl, constants.y; CMP ndotl, ndotv, ndotl, temp3; MUL temp3, ndoth, constants.y; CMP ndoth, ndotv, ndoth, temp3; # put the pieces together for a LIT operation MOV lightInfo.x, ndotl.x; MOV lightInfo.y, ndoth.x; MOV lightInfo.w, coefficient.w; # compute the lighting LIT lightResult, lightInfo; # This is the ambient contribution MUL finalColor, coefficient.x, sampleColor; # This is the diffuse contribution MUL temp3, lightDiffColor, sampleColor; MUL temp3, temp3, lightResult.y; ADD finalColor, finalColor, temp3; # This is th specular contribution MUL temp3, lightSpecColor, lightResult.z; # Add specular into result so far, and replace # with the original alpha. ADD out, finalColor, temp3; MOV out.w, sampleColor.w; END
/* ///////////////////////////////////////////////////////////////////////// * File: comstl/functional/functionals.hpp * * Purpose: Interface-specific predicates and functions. * * Created: 14th June 2002 * Updated: 19th February 2017 * * Home: http://stlsoft.org/ * * Copyright (c) 2002-2017, Matthew Wilson and Synesis Software * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the * names of any 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. * * ////////////////////////////////////////////////////////////////////// */ /** \file comstl/functional/functionals.hpp * * \brief [C++ only] Main include for COM type manipulating function classes, * including interface pointers, and release of various COM resoures * (\ref group__library__Functional "Functional" Library). */ #ifndef COMSTL_INCL_COMSTL_FUNCTIONAL_HPP_INTERFACE_FUNCTIONALS #define COMSTL_INCL_COMSTL_FUNCTIONAL_HPP_INTERFACE_FUNCTIONALS #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define COMSTL_VER_COMSTL_FUNCTIONAL_HPP_INTERFACE_FUNCTIONALS_MAJOR 4 # define COMSTL_VER_COMSTL_FUNCTIONAL_HPP_INTERFACE_FUNCTIONALS_MINOR 0 # define COMSTL_VER_COMSTL_FUNCTIONAL_HPP_INTERFACE_FUNCTIONALS_REVISION 3 # define COMSTL_VER_COMSTL_FUNCTIONAL_HPP_INTERFACE_FUNCTIONALS_EDIT 70 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* ///////////////////////////////////////////////////////////////////////// * Auto-generation and compatibility */ /* [Incompatibilies-start] [Incompatibilies-end] STLSOFT_COMPILER_IS_GCC: __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) */ /* ///////////////////////////////////////////////////////////////////////// * includes */ #ifndef COMSTL_INCL_COMSTL_H_COMSTL # include <comstl/comstl.h> #endif /* !COMSTL_INCL_COMSTL_H_COMSTL */ #ifdef STLSOFT_TRACE_INCLUDE # pragma message(__FILE__) #endif /* STLSOFT_TRACE_INCLUDE */ #ifndef COMSTL_INCL_COMSTL_FUNCTIONAL_HPP_INTERFACE_FUNCTIONALS # include <comstl/functional/interface_functionals.hpp> #endif /* !COMSTL_INCL_COMSTL_FUNCTIONAL_HPP_INTERFACE_FUNCTIONALS */ #ifndef COMSTL_INCL_COMSTL_FUNCTIONAL_HPP_TYPE_FUNCTIONALS # include <comstl/functional/type_functionals.hpp> #endif /* !COMSTL_INCL_COMSTL_FUNCTIONAL_HPP_TYPE_FUNCTIONALS */ /* ///////////////////////////////////////////////////////////////////////// * inclusion control */ #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT # pragma once #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */ #endif /* !COMSTL_INCL_COMSTL_FUNCTIONAL_HPP_INTERFACE_FUNCTIONALS */ /* ///////////////////////////// end of file //////////////////////////// */
; A017020: a(n) = (7*n + 3)^4. ; 81,10000,83521,331776,923521,2085136,4100625,7311616,12117361,18974736,28398241,40960000,57289761,78074896,104060401,136048896,174900625,221533456,276922881,342102016,418161601,506250000,607573201,723394816,855036081,1003875856,1171350625,1358954496,1568239201,1800814096,2058346161,2342560000,2655237841,2998219536,3373402561,3782742016,4228250625,4711998736,5236114321,5802782976,6414247921,7072810000,7780827681,8540717056,9354951841,10226063376,11156640625,12149330176,13206836241,14331920656,15527402881,16796160000,18141126721,19565295376,21071715921,22663495936,24343800625,26115852816,27982932961,29948379136,32015587041,34188010000,36469158961,38862602496,41371966801,44000935696,46753250625,49632710656,52643172481,55788550416,59072816401,62500000000,66074188401,69799526416,73680216481,77720518656,81924750625,86297287696,90842562801,95565066496,100469346961,105560010000,110841719041,116319195136,121997216961,127880620816,133974300625,140283207936,146812351921,153566799376,160551674721,167772160000,175233494881,182940976656,190899960241,199115858176,207594140625,216340335376,225360027841,234658861056,244242535681,254116810000,264287499921,274760478976,285541678321,296637086736,308052750625,319794774016,331869318561,344282603536,357040905841,370150560000,383617958161,397449550096,411651843201,426231402496,441194850625,456548867856,472300192081,488455618816,505022001201,522006250000,539415333601,557256278016,575536166881,594262141456,613441400625,633081200896,653188856401,673771738896,694837277761,716392960000,738446330241,761004990736,784076601361,807668879616,831789600625,856446597136,881647759521,907401035776,933714431521,960596010000,988053892081,1016096256256,1044731338641,1073967432976,1103812890625,1134276120576,1165365589441,1197089821456,1229457398481,1262476960000,1296157203121,1330506882576,1365534810721,1401249857536,1437660950625,1474777075216,1512607274161,1551160647936,1590446354641,1630473610000,1671251687361,1712789917696,1755097689601,1798184449296,1842059700625,1886733005056,1932213981681,1978512307216,2025637716001,2073600000000,2122409008801,2172074649616,2222606887281,2274015744256,2326311300625,2379503694096,2433603120001,2488619831296,2544564138561,2601446410000,2659277071441,2718066606336,2777825555761,2838564518416,2900294150625,2963025166336,3026768337121,3091534492176,3157334518321,3224179360000,3292080019281,3361047555856,3431093087041,3502227787776,3574462890625,3647809685776,3722279521041,3797883801856,3874633991281,3952541610000,4031618236321,4111875506176,4193325113121,4275978808336,4359848400625,4444945756416,4531282799761,4618871512336,4707723933441,4797852160000,4889268346561,4981984705296,5076013506001,5171367076096,5268057800625,5366098122256,5465500541281,5566277615616,5668441960801,5772006250000,5876983214001,5983385641216,6091226377681,6200518327056,6311274450625,6423507767296,6537231353601,6652458343696,6769201929361,6887475360000,7007291942641,7128665041936,7251608080161,7376134537216,7502257950625,7629991915536,7759350084721,7890346168576,8022993935121,8157307210000,8293299876481,8430985875456,8570379205441,8711493922576,8854344140625,8998944030976,9145307822641,9293449802256 mov $1,$0 mul $1,7 add $1,3 pow $1,4
; ; Copyright 2018-2021 Mahdi Khanalizadeh ; ; 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. ; BITS 64 GLOBAL linux_syscall1 linux_syscall1: mov rax, rsi ; arg2 -> # syscall ret
; A129937: The central binomial numbers Binomial[n,Floor[n/2] minus the SO(n) dimension as an algebraic projective variety dimension. ; 1,1,0,0,0,5,14,42,90,207,407,858,1638,3341,6330,12750,24174,48467,92207,184566,352506,705201,1351825,2703880,5200000,10400275,20057949,40116222,77558354,155117085 mov $2,$0 add $0,1 seq $0,51920 ; a(n) = binomial(n, floor(n/2)) + 1. add $1,$0 add $2,1 mov $3,$2 bin $3,2 sub $1,$3 sub $1,1 mov $0,$1
; DV3 QL Format Table V3.00  1992 Tony Tebby section dv3 xdef qlf_table xdef qlf_tbwa include 'dev8_mac_vec' include 'dev8_dv3_keys' ;+++ ; DV3 QL5A/B Format Table ; ;--- qlf_table vec msd_table ; next dc.b ddf.qdos ; QL5A / QL5B / QLWA format dc.b 0 ; real date dc.b 0,4,'QDOS',0,0,0,0 dc.b $ff ; zero length file has first sector allocated dc.b 0 ; spare vec dv3_iqdt ; internal to pathname translate vec dv3_qdit ; pathname to internal translate vec dv3_iqct ; internal to checking translate vec qlf_check ; check format vec qlf_drname ; search for name in directory vec qlf_drmake ; make directory vec qlf_drent ; fetch directory entry vec qlf_drefile ; ... for file novec ; ... selected vec qlf_drsfile ; set directory entry for file vec qlf_sa5b ; sector allocate vec qlf_sl5b ; sector locate vec qlf_st5b ; sector truncate vec qlf_ld5b ; scatter load novec ; scatter save vec qlf_fsel ; format select vec qlf_ft5b ; format novec ; logical group to physical vec qlf_lg5b ; logical group to physical novec ; reset medium information novec ; set medium name vec qlf_um5b ; update map ;+++ ; DV3 QLWA Format Table ; ;--- qlf_tbwa novec ; next dc.b ddf.qdos ; QL5A / QL5B / QLWA format dc.b 0 ; real date dc.b 0,4,'QDOS',0,0,0,0 dc.b $ff ; zero length file has first sector allocated dc.b 0 ; spare vec dv3_iqdt ; internal to pathname translate vec dv3_qdit ; pathname to internal translate vec dv3_iqct ; internal to checking translate vec qlf_check ; check format vec qlf_drname ; search for name in directory vec qlf_drmake ; make directory vec qlf_drent ; fetch directory entry vec qlf_drefile ; ... for file novec ; ... selected vec qlf_drsfile ; set directory entry for file vec qlf_sawa ; sector allocate vec qlf_slwa ; sector locate vec qlf_stwa ; sector truncate vec qlf_ldwa ; scatter load novec ; scatter save vec qlf_fsel ; format select vec qlf_ftwa ; format novec ; logical group to physical vec dv3_logp ; logical group to physical novec ; reset medium information novec ; set medium name vec qlf_umwa ; update map end
;Rusu Cosmin - gr. 917, 26.11.2015, homework for lab08, problem 08 ;8. Write a program which reads the name of a file and two characters from the keyboard. ;The program should replace all occurrences of the first character in that file with the ;second character given by the user. assume cs:code, ds:data data segment msg db 'Name of the file: $' msgCh1 db 'Character to replace: $' msgCh2 db 'New character: $' ch1 db ? ch2 db ? maxFileName db 12 lFileName db ? fileName db 12 dup (?) buffer db 100 dup (?), '$' openErrorMsg db 'File does not exist.$' readErrorMsg db "Can't read the file.$" newLine db 0ah, 0dh, '$' ; \n character data ends code segment start: mov ax, data mov ds, ax ; print the string 'msg' to the screen mov ah, 09h mov dx, offset msg int 21h ;read from the keyboard the name of the file mov ah, 0ah mov dx, offset maxFileName int 21h ;print newline mov ah, 09h mov dx, offset newLine int 21h ;print msgCh1 mov ah, 09h mov dx, offset msgCh1 int 21h ;read first character mov ah, 01h int 21h mov ch1, al ;print newline mov ah, 09h mov dx, offset newLine int 21h ;print msgCh2 mov ah, 09h mov dx, offset msgCh2 int 21h ;read second character mov ah, 01h int 21h mov ch2, al ;print newline mov ah, 09h mov dx, offset newLine int 21h mov al, lFileName xor ah, ah mov si, ax mov fileName[si], 0 ;open the file mov ah, 3dh mov al, 0 mov dx, offset fileName int 21h jc openError mov bx, ax goOn: mov ah, 3fh mov dx, offset buffer mov cx, 100 int 21h jc readError mov si, ax mov buffer[si], '$' mov cx, ax mov di, 0 ; now iterate through the buffer and change the letters where needed replace_ch: mov ah, ch1 mov al, ch2 cmp buffer[di], ah jne _nu mov buffer[di], al _nu: inc di loop replace_ch mov ah, 09h int 21h cmp si, 100 je goOn jmp endPrg openError: mov ah, 09h mov dx, offset openErrorMsg int 21h jmp endPrg readError: mov ah, 09h mov dx, offset readErrorMsg int 21h endPrg: mov ax, 4c00h int 21h code ends end start
ORG 2000H MVI C, 0AH LXI H, 3000H LXI D, 3500H LINK: MOV A, M STAX D INX H INX D DCR C JNZ LINK HLT ORG 3000H DB 01H, 02H, 03H, 04H, 05H, 06H, 07H, 08H, 09H, 0AH END
#include "Arduino.h" #include <AS5147P.h> #define AS5147P_DEBUG // 1MHz clock (AMS should be able to accept up to 10MHz) #define SPI_SETTINGS SPISettings(1000000, MSBFIRST, SPI_MODE1) #define READCOMMAND 0b0100000000000000 // PAR=0 R/W=R #define WRITECOMMAND 0b0000000000000000 // PAR=0 R/W=W namespace AS5147P_REGISTERS { //Volatile Registers const int CLEAR_ERROR_FLAG = 0x0001; const int PROGRAMMING_CONTROL = 0x0003; const int DIAG_AGC = 0x3FFC; const int MAGNITUDE = 0x3FFD; const int ANGLE_UNCOM = 0x3FFE; const int ANGLE = 0x3FFF; /*Non-Volatile Registers //not implemented const int OTP_ZERO_POS_HIGH = 0x0016; const int OTP_ZERO_POS_LOW = 0x0017; const int OTP_SETTINGS1 = 0x0018; const int OTP_SETTINGS2 = 0x0019; const int OTP_REDUNDANCY = 0x001A; */ } /** * Constructor */ AS5147P::AS5147P(uint8_t arg_cs){ _cs = arg_cs; } /** * Initialiser * Sets up the SPI interface */ void AS5147P::init(){ //setup pins pinMode(_cs, OUTPUT); digitalWrite(_cs, HIGH); //SPI has an internal SPI-device counter, it is possible to call "begin()" from different devices SPI.begin(); } /** * Closes the SPI connection * SPI has an internal SPI-device counter, for each init()-call the close() function must be called exactly 1 time */ void AS5147P::close(){ SPI.end(); } /** * Utility function used to calculate even parity of uint16_t */ bool AS5147P::_spiCalcEvenParity(uint16_t value){ bool even = 0; uint8_t i; for (i = 0; i < 16; i++) { if (value & (0x0001 << i) ) { even = !even; } } return even; } /** * Get the rotation of the sensor relative to the zero position. * * @return {int} between -2^13 and 2^13 */ int AS5147P::getRotation(){ int rotation; rotation = AS5147P::getRawRotation() - _zero_position; if(rotation > 8191) rotation = -((0x3FFF)-rotation); //more than -180 return rotation; } /** * Get the angle in degrees of the sensor relative to the zero position, and -1 if error flag is set. * * @return {int} between -1 and 359 */ int AS5147P::getDegree(){ uint16_t rotation; rotation = AS5147P::getRawRotation() - _zero_position; if(_errorFlag){ return -1; } else if (rotation >> 15){ //rotation is negative rotation += 0x3FFF; } return map(rotation, 0, 0x4000, 0, 360); } /** * Returns the raw rotation directly from the sensor */ uint16_t AS5147P::getRawRotation(){ return AS5147P::read(AS5147P_REGISTERS::ANGLE); } /** * returns the value of the state register * @return 16 bit uint16_t containing flags */ uint16_t AS5147P::getState(){ return AS5147P::read(AS5147P_REGISTERS::DIAG_AGC); } /** * Returns the value used for Automatic Gain Control (Part of diagnostic * register) */ uint8_t AS5147P::getGain(){ uint16_t data = AS5147P::getState(); return (uint8_t) data & 0xFF; } /** * Get the 13-bit CORDIC Magnitude * @return uint16_t */ uint16_t AS5147P::getMagnitude(){ return AS5147P::read(AS5147P_REGISTERS::MAGNITUDE); } /* * Get and clear the error register by reading it */ uint16_t AS5147P::getErrors(){ return AS5147P::read(AS5147P_REGISTERS::CLEAR_ERROR_FLAG); } /* * Set the zero position */ void AS5147P::setZeroPosition(){_zero_position = getRawRotation();} void AS5147P::setZeroPosition(uint16_t arg_position){ _zero_position = arg_position % 0x3FFF; } /* * Returns the current zero position */ uint16_t AS5147P::getZeroPosition(){ return _zero_position; } /* * Check if an error has been encountered. */ bool AS5147P::error(){ return _errorFlag; } /* * Read a register from the sensor * Takes the address of the register as a 16 bit uint16_t * Returns the value of the register */ uint16_t AS5147P::read(uint16_t registerAddress){ uint16_t command = registerAddress | READCOMMAND; //Add a parity bit on the the MSB command |= ((uint16_t)_spiCalcEvenParity(command)<<15); //Split the command into two uint8_ts uint8_t right_byte = command & 0xFF; uint8_t left_byte = ( command >> 8 ) & 0xFF; #ifdef AS5147P_DEBUG Serial.print(F("Read (0x")); Serial.print(registerAddress, HEX); Serial.print(F(") with command: 0b")); Serial.println(command, HEX); #endif //SPI - begin transaction SPI.beginTransaction(SPI_SETTINGS); //Send the command digitalWrite(_cs, LOW); SPI.transfer(left_byte); SPI.transfer(right_byte); digitalWrite(_cs,HIGH); delayMicroseconds(1); //Now read the response digitalWrite(_cs, LOW); left_byte = SPI.transfer(0x00); right_byte = SPI.transfer(0x00); digitalWrite(_cs, HIGH); //SPI - end transaction SPI.endTransaction(); #ifdef AS5147P_DEBUG Serial.print(F("Read returned: ")); Serial.print(left_byte, BIN); Serial.print(F(" ")); Serial.println(right_byte, BIN); #endif //Check if the error bit is set if (left_byte & 0x40) { #ifdef AS5147P_DEBUG Serial.println(F("Setting error bit")); #endif _errorFlag = true; } else { _errorFlag = false; } //Return the data, stripping the parity and error bits return (( ( left_byte & 0xFF ) << 8 ) | ( right_byte & 0xFF )) & ~0xC000; } /* * Write to a register * Takes the 16-bit address of the target register and the 16 bit uint16_t of data * to be written to that register * Returns the value of the register after the write has been performed. This * is read back from the sensor to ensure a sucessful write. */ uint16_t AS5147P::write(uint16_t registerAddress, uint16_t data) { uint16_t command = registerAddress | WRITECOMMAND; //Add a parity bit on the the MSB command |= ((uint16_t)_spiCalcEvenParity(command)<<15); //Split the command into two uint8_ts uint8_t right_byte = command & 0xFF; uint8_t left_byte = ( command >> 8 ) & 0xFF; #ifdef AS5147P_DEBUG Serial.print(F("Write (0x")); Serial.print(registerAddress, HEX); Serial.print(F(") with command: 0b")); Serial.println(command, BIN); #endif //SPI - begin transaction SPI.beginTransaction(SPI_SETTINGS); //Start the write command with the target address digitalWrite(_cs, LOW); SPI.transfer(left_byte); SPI.transfer(right_byte); digitalWrite(_cs,HIGH); uint16_t dataToSend = data | WRITECOMMAND ; //Craft another packet including the data and parity dataToSend |= ((uint16_t)_spiCalcEvenParity(dataToSend)<<15); right_byte = dataToSend & 0xFF; left_byte = ( dataToSend >> 8 ) & 0xFF; #ifdef AS5147P_DEBUG Serial.print(F("Sending data to write: ")); Serial.println(dataToSend, BIN); #endif //Now send the data packet digitalWrite(_cs,LOW); SPI.transfer(left_byte); SPI.transfer(right_byte); digitalWrite(_cs,HIGH); //Send a NOP to read the new data in the register digitalWrite(_cs, LOW); left_byte =-SPI.transfer(0x00); right_byte = SPI.transfer(0x00); digitalWrite(_cs, HIGH); //SPI - end transaction SPI.endTransaction(); //Return the data, stripping the parity and error bits return (( ( left_byte & 0xFF ) << 8 ) | ( right_byte & 0xFF )) & ~0xC000; }
_init: formato del fichero elf32-i386 Desensamblado de la sección .text: 00000000 <main>: char *argv[] = { "sh", 0 }; int main(void) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 53 push %ebx e: 51 push %ecx int pid, wpid; if(open("console", O_RDWR) < 0){ f: 83 ec 08 sub $0x8,%esp 12: 6a 02 push $0x2 14: 68 f8 07 00 00 push $0x7f8 19: e8 64 03 00 00 call 382 <open> 1e: 83 c4 10 add $0x10,%esp 21: 85 c0 test %eax,%eax 23: 0f 88 9f 00 00 00 js c8 <main+0xc8> mknod("console", 1, 1); open("console", O_RDWR); } dup(0); // stdout 29: 83 ec 0c sub $0xc,%esp 2c: 6a 00 push $0x0 2e: e8 87 03 00 00 call 3ba <dup> dup(0); // stderr 33: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3a: e8 7b 03 00 00 call 3ba <dup> 3f: 83 c4 10 add $0x10,%esp 42: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(;;){ printf(1, "init: starting sh\n"); 48: 83 ec 08 sub $0x8,%esp 4b: 68 00 08 00 00 push $0x800 50: 6a 01 push $0x1 52: e8 49 04 00 00 call 4a0 <printf> pid = fork(); 57: e8 de 02 00 00 call 33a <fork> if(pid < 0){ 5c: 83 c4 10 add $0x10,%esp 5f: 85 c0 test %eax,%eax pid = fork(); 61: 89 c3 mov %eax,%ebx if(pid < 0){ 63: 78 2c js 91 <main+0x91> printf(1, "init: fork failed\n"); exit(); } if(pid == 0){ 65: 74 3d je a4 <main+0xa4> 67: 89 f6 mov %esi,%esi 69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi exec("sh", argv); printf(1, "init: exec sh failed\n"); exit(); } while((wpid=wait()) >= 0 && wpid != pid) 70: e8 d5 02 00 00 call 34a <wait> 75: 85 c0 test %eax,%eax 77: 78 cf js 48 <main+0x48> 79: 39 c3 cmp %eax,%ebx 7b: 74 cb je 48 <main+0x48> printf(1, "zombie!\n"); 7d: 83 ec 08 sub $0x8,%esp 80: 68 3f 08 00 00 push $0x83f 85: 6a 01 push $0x1 87: e8 14 04 00 00 call 4a0 <printf> 8c: 83 c4 10 add $0x10,%esp 8f: eb df jmp 70 <main+0x70> printf(1, "init: fork failed\n"); 91: 53 push %ebx 92: 53 push %ebx 93: 68 13 08 00 00 push $0x813 98: 6a 01 push $0x1 9a: e8 01 04 00 00 call 4a0 <printf> exit(); 9f: e8 9e 02 00 00 call 342 <exit> exec("sh", argv); a4: 50 push %eax a5: 50 push %eax a6: 68 f8 0a 00 00 push $0xaf8 ab: 68 26 08 00 00 push $0x826 b0: e8 c5 02 00 00 call 37a <exec> printf(1, "init: exec sh failed\n"); b5: 5a pop %edx b6: 59 pop %ecx b7: 68 29 08 00 00 push $0x829 bc: 6a 01 push $0x1 be: e8 dd 03 00 00 call 4a0 <printf> exit(); c3: e8 7a 02 00 00 call 342 <exit> mknod("console", 1, 1); c8: 50 push %eax c9: 6a 01 push $0x1 cb: 6a 01 push $0x1 cd: 68 f8 07 00 00 push $0x7f8 d2: e8 b3 02 00 00 call 38a <mknod> open("console", O_RDWR); d7: 58 pop %eax d8: 5a pop %edx d9: 6a 02 push $0x2 db: 68 f8 07 00 00 push $0x7f8 e0: e8 9d 02 00 00 call 382 <open> e5: 83 c4 10 add $0x10,%esp e8: e9 3c ff ff ff jmp 29 <main+0x29> ed: 66 90 xchg %ax,%ax ef: 90 nop 000000f0 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { f0: 55 push %ebp f1: 89 e5 mov %esp,%ebp f3: 53 push %ebx f4: 8b 45 08 mov 0x8(%ebp),%eax f7: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) fa: 89 c2 mov %eax,%edx fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 100: 83 c1 01 add $0x1,%ecx 103: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 107: 83 c2 01 add $0x1,%edx 10a: 84 db test %bl,%bl 10c: 88 5a ff mov %bl,-0x1(%edx) 10f: 75 ef jne 100 <strcpy+0x10> ; return os; } 111: 5b pop %ebx 112: 5d pop %ebp 113: c3 ret 114: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 11a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000120 <strcmp>: int strcmp(const char *p, const char *q) { 120: 55 push %ebp 121: 89 e5 mov %esp,%ebp 123: 53 push %ebx 124: 8b 55 08 mov 0x8(%ebp),%edx 127: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 12a: 0f b6 02 movzbl (%edx),%eax 12d: 0f b6 19 movzbl (%ecx),%ebx 130: 84 c0 test %al,%al 132: 75 1c jne 150 <strcmp+0x30> 134: eb 2a jmp 160 <strcmp+0x40> 136: 8d 76 00 lea 0x0(%esi),%esi 139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 140: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 143: 0f b6 02 movzbl (%edx),%eax p++, q++; 146: 83 c1 01 add $0x1,%ecx 149: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) 14c: 84 c0 test %al,%al 14e: 74 10 je 160 <strcmp+0x40> 150: 38 d8 cmp %bl,%al 152: 74 ec je 140 <strcmp+0x20> return (uchar)*p - (uchar)*q; 154: 29 d8 sub %ebx,%eax } 156: 5b pop %ebx 157: 5d pop %ebp 158: c3 ret 159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 160: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 162: 29 d8 sub %ebx,%eax } 164: 5b pop %ebx 165: 5d pop %ebp 166: c3 ret 167: 89 f6 mov %esi,%esi 169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000170 <strlen>: uint strlen(char *s) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 176: 80 39 00 cmpb $0x0,(%ecx) 179: 74 15 je 190 <strlen+0x20> 17b: 31 d2 xor %edx,%edx 17d: 8d 76 00 lea 0x0(%esi),%esi 180: 83 c2 01 add $0x1,%edx 183: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 187: 89 d0 mov %edx,%eax 189: 75 f5 jne 180 <strlen+0x10> ; return n; } 18b: 5d pop %ebp 18c: c3 ret 18d: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 190: 31 c0 xor %eax,%eax } 192: 5d pop %ebp 193: c3 ret 194: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 19a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000001a0 <memset>: void* memset(void *dst, int c, uint n) { 1a0: 55 push %ebp 1a1: 89 e5 mov %esp,%ebp 1a3: 57 push %edi 1a4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 1a7: 8b 4d 10 mov 0x10(%ebp),%ecx 1aa: 8b 45 0c mov 0xc(%ebp),%eax 1ad: 89 d7 mov %edx,%edi 1af: fc cld 1b0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 1b2: 89 d0 mov %edx,%eax 1b4: 5f pop %edi 1b5: 5d pop %ebp 1b6: c3 ret 1b7: 89 f6 mov %esi,%esi 1b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001c0 <strchr>: char* strchr(const char *s, char c) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 53 push %ebx 1c4: 8b 45 08 mov 0x8(%ebp),%eax 1c7: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 1ca: 0f b6 10 movzbl (%eax),%edx 1cd: 84 d2 test %dl,%dl 1cf: 74 1d je 1ee <strchr+0x2e> if(*s == c) 1d1: 38 d3 cmp %dl,%bl 1d3: 89 d9 mov %ebx,%ecx 1d5: 75 0d jne 1e4 <strchr+0x24> 1d7: eb 17 jmp 1f0 <strchr+0x30> 1d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1e0: 38 ca cmp %cl,%dl 1e2: 74 0c je 1f0 <strchr+0x30> for(; *s; s++) 1e4: 83 c0 01 add $0x1,%eax 1e7: 0f b6 10 movzbl (%eax),%edx 1ea: 84 d2 test %dl,%dl 1ec: 75 f2 jne 1e0 <strchr+0x20> return (char*)s; return 0; 1ee: 31 c0 xor %eax,%eax } 1f0: 5b pop %ebx 1f1: 5d pop %ebp 1f2: c3 ret 1f3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000200 <gets>: char* gets(char *buf, int max) { 200: 55 push %ebp 201: 89 e5 mov %esp,%ebp 203: 57 push %edi 204: 56 push %esi 205: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 206: 31 f6 xor %esi,%esi 208: 89 f3 mov %esi,%ebx { 20a: 83 ec 1c sub $0x1c,%esp 20d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 210: eb 2f jmp 241 <gets+0x41> 212: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 218: 8d 45 e7 lea -0x19(%ebp),%eax 21b: 83 ec 04 sub $0x4,%esp 21e: 6a 01 push $0x1 220: 50 push %eax 221: 6a 00 push $0x0 223: e8 32 01 00 00 call 35a <read> if(cc < 1) 228: 83 c4 10 add $0x10,%esp 22b: 85 c0 test %eax,%eax 22d: 7e 1c jle 24b <gets+0x4b> break; buf[i++] = c; 22f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 233: 83 c7 01 add $0x1,%edi 236: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 239: 3c 0a cmp $0xa,%al 23b: 74 23 je 260 <gets+0x60> 23d: 3c 0d cmp $0xd,%al 23f: 74 1f je 260 <gets+0x60> for(i=0; i+1 < max; ){ 241: 83 c3 01 add $0x1,%ebx 244: 3b 5d 0c cmp 0xc(%ebp),%ebx 247: 89 fe mov %edi,%esi 249: 7c cd jl 218 <gets+0x18> 24b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 24d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 250: c6 03 00 movb $0x0,(%ebx) } 253: 8d 65 f4 lea -0xc(%ebp),%esp 256: 5b pop %ebx 257: 5e pop %esi 258: 5f pop %edi 259: 5d pop %ebp 25a: c3 ret 25b: 90 nop 25c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 260: 8b 75 08 mov 0x8(%ebp),%esi 263: 8b 45 08 mov 0x8(%ebp),%eax 266: 01 de add %ebx,%esi 268: 89 f3 mov %esi,%ebx buf[i] = '\0'; 26a: c6 03 00 movb $0x0,(%ebx) } 26d: 8d 65 f4 lea -0xc(%ebp),%esp 270: 5b pop %ebx 271: 5e pop %esi 272: 5f pop %edi 273: 5d pop %ebp 274: c3 ret 275: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000280 <stat>: int stat(char *n, struct stat *st) { 280: 55 push %ebp 281: 89 e5 mov %esp,%ebp 283: 56 push %esi 284: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 285: 83 ec 08 sub $0x8,%esp 288: 6a 00 push $0x0 28a: ff 75 08 pushl 0x8(%ebp) 28d: e8 f0 00 00 00 call 382 <open> if(fd < 0) 292: 83 c4 10 add $0x10,%esp 295: 85 c0 test %eax,%eax 297: 78 27 js 2c0 <stat+0x40> return -1; r = fstat(fd, st); 299: 83 ec 08 sub $0x8,%esp 29c: ff 75 0c pushl 0xc(%ebp) 29f: 89 c3 mov %eax,%ebx 2a1: 50 push %eax 2a2: e8 f3 00 00 00 call 39a <fstat> close(fd); 2a7: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 2aa: 89 c6 mov %eax,%esi close(fd); 2ac: e8 b9 00 00 00 call 36a <close> return r; 2b1: 83 c4 10 add $0x10,%esp } 2b4: 8d 65 f8 lea -0x8(%ebp),%esp 2b7: 89 f0 mov %esi,%eax 2b9: 5b pop %ebx 2ba: 5e pop %esi 2bb: 5d pop %ebp 2bc: c3 ret 2bd: 8d 76 00 lea 0x0(%esi),%esi return -1; 2c0: be ff ff ff ff mov $0xffffffff,%esi 2c5: eb ed jmp 2b4 <stat+0x34> 2c7: 89 f6 mov %esi,%esi 2c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002d0 <atoi>: int atoi(const char *s) { 2d0: 55 push %ebp 2d1: 89 e5 mov %esp,%ebp 2d3: 53 push %ebx 2d4: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 2d7: 0f be 11 movsbl (%ecx),%edx 2da: 8d 42 d0 lea -0x30(%edx),%eax 2dd: 3c 09 cmp $0x9,%al n = 0; 2df: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 2e4: 77 1f ja 305 <atoi+0x35> 2e6: 8d 76 00 lea 0x0(%esi),%esi 2e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 2f0: 8d 04 80 lea (%eax,%eax,4),%eax 2f3: 83 c1 01 add $0x1,%ecx 2f6: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 2fa: 0f be 11 movsbl (%ecx),%edx 2fd: 8d 5a d0 lea -0x30(%edx),%ebx 300: 80 fb 09 cmp $0x9,%bl 303: 76 eb jbe 2f0 <atoi+0x20> return n; } 305: 5b pop %ebx 306: 5d pop %ebp 307: c3 ret 308: 90 nop 309: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000310 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 310: 55 push %ebp 311: 89 e5 mov %esp,%ebp 313: 56 push %esi 314: 53 push %ebx 315: 8b 5d 10 mov 0x10(%ebp),%ebx 318: 8b 45 08 mov 0x8(%ebp),%eax 31b: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 31e: 85 db test %ebx,%ebx 320: 7e 14 jle 336 <memmove+0x26> 322: 31 d2 xor %edx,%edx 324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 328: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 32c: 88 0c 10 mov %cl,(%eax,%edx,1) 32f: 83 c2 01 add $0x1,%edx while(n-- > 0) 332: 39 d3 cmp %edx,%ebx 334: 75 f2 jne 328 <memmove+0x18> return vdst; } 336: 5b pop %ebx 337: 5e pop %esi 338: 5d pop %ebp 339: c3 ret 0000033a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 33a: b8 01 00 00 00 mov $0x1,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <exit>: SYSCALL(exit) 342: b8 02 00 00 00 mov $0x2,%eax 347: cd 40 int $0x40 349: c3 ret 0000034a <wait>: SYSCALL(wait) 34a: b8 03 00 00 00 mov $0x3,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <pipe>: SYSCALL(pipe) 352: b8 04 00 00 00 mov $0x4,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <read>: SYSCALL(read) 35a: b8 05 00 00 00 mov $0x5,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <write>: SYSCALL(write) 362: b8 10 00 00 00 mov $0x10,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <close>: SYSCALL(close) 36a: b8 15 00 00 00 mov $0x15,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <kill>: SYSCALL(kill) 372: b8 06 00 00 00 mov $0x6,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <exec>: SYSCALL(exec) 37a: b8 07 00 00 00 mov $0x7,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <open>: SYSCALL(open) 382: b8 0f 00 00 00 mov $0xf,%eax 387: cd 40 int $0x40 389: c3 ret 0000038a <mknod>: SYSCALL(mknod) 38a: b8 11 00 00 00 mov $0x11,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <unlink>: SYSCALL(unlink) 392: b8 12 00 00 00 mov $0x12,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <fstat>: SYSCALL(fstat) 39a: b8 08 00 00 00 mov $0x8,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <link>: SYSCALL(link) 3a2: b8 13 00 00 00 mov $0x13,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 000003aa <mkdir>: SYSCALL(mkdir) 3aa: b8 14 00 00 00 mov $0x14,%eax 3af: cd 40 int $0x40 3b1: c3 ret 000003b2 <chdir>: SYSCALL(chdir) 3b2: b8 09 00 00 00 mov $0x9,%eax 3b7: cd 40 int $0x40 3b9: c3 ret 000003ba <dup>: SYSCALL(dup) 3ba: b8 0a 00 00 00 mov $0xa,%eax 3bf: cd 40 int $0x40 3c1: c3 ret 000003c2 <getpid>: SYSCALL(getpid) 3c2: b8 0b 00 00 00 mov $0xb,%eax 3c7: cd 40 int $0x40 3c9: c3 ret 000003ca <sbrk>: SYSCALL(sbrk) 3ca: b8 0c 00 00 00 mov $0xc,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <sleep>: SYSCALL(sleep) 3d2: b8 0d 00 00 00 mov $0xd,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <uptime>: SYSCALL(uptime) 3da: b8 0e 00 00 00 mov $0xe,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <csc>: SYSCALL(csc) 3e2: b8 16 00 00 00 mov $0x16,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 000003ea <cps>: SYSCALL(cps) 3ea: b8 17 00 00 00 mov $0x17,%eax 3ef: cd 40 int $0x40 3f1: c3 ret 000003f2 <chpr>: SYSCALL(chpr) 3f2: b8 18 00 00 00 mov $0x18,%eax 3f7: cd 40 int $0x40 3f9: c3 ret 3fa: 66 90 xchg %ax,%ax 3fc: 66 90 xchg %ax,%ax 3fe: 66 90 xchg %ax,%ax 00000400 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 400: 55 push %ebp 401: 89 e5 mov %esp,%ebp 403: 57 push %edi 404: 56 push %esi 405: 53 push %ebx 406: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 409: 85 d2 test %edx,%edx { 40b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 40e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 410: 79 76 jns 488 <printint+0x88> 412: f6 45 08 01 testb $0x1,0x8(%ebp) 416: 74 70 je 488 <printint+0x88> x = -xx; 418: f7 d8 neg %eax neg = 1; 41a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 421: 31 f6 xor %esi,%esi 423: 8d 5d d7 lea -0x29(%ebp),%ebx 426: eb 0a jmp 432 <printint+0x32> 428: 90 nop 429: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 430: 89 fe mov %edi,%esi 432: 31 d2 xor %edx,%edx 434: 8d 7e 01 lea 0x1(%esi),%edi 437: f7 f1 div %ecx 439: 0f b6 92 50 08 00 00 movzbl 0x850(%edx),%edx }while((x /= base) != 0); 440: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 442: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 445: 75 e9 jne 430 <printint+0x30> if(neg) 447: 8b 45 c4 mov -0x3c(%ebp),%eax 44a: 85 c0 test %eax,%eax 44c: 74 08 je 456 <printint+0x56> buf[i++] = '-'; 44e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 453: 8d 7e 02 lea 0x2(%esi),%edi 456: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 45a: 8b 7d c0 mov -0x40(%ebp),%edi 45d: 8d 76 00 lea 0x0(%esi),%esi 460: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 463: 83 ec 04 sub $0x4,%esp 466: 83 ee 01 sub $0x1,%esi 469: 6a 01 push $0x1 46b: 53 push %ebx 46c: 57 push %edi 46d: 88 45 d7 mov %al,-0x29(%ebp) 470: e8 ed fe ff ff call 362 <write> while(--i >= 0) 475: 83 c4 10 add $0x10,%esp 478: 39 de cmp %ebx,%esi 47a: 75 e4 jne 460 <printint+0x60> putc(fd, buf[i]); } 47c: 8d 65 f4 lea -0xc(%ebp),%esp 47f: 5b pop %ebx 480: 5e pop %esi 481: 5f pop %edi 482: 5d pop %ebp 483: c3 ret 484: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 488: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 48f: eb 90 jmp 421 <printint+0x21> 491: eb 0d jmp 4a0 <printf> 493: 90 nop 494: 90 nop 495: 90 nop 496: 90 nop 497: 90 nop 498: 90 nop 499: 90 nop 49a: 90 nop 49b: 90 nop 49c: 90 nop 49d: 90 nop 49e: 90 nop 49f: 90 nop 000004a0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 4a0: 55 push %ebp 4a1: 89 e5 mov %esp,%ebp 4a3: 57 push %edi 4a4: 56 push %esi 4a5: 53 push %ebx 4a6: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4a9: 8b 75 0c mov 0xc(%ebp),%esi 4ac: 0f b6 1e movzbl (%esi),%ebx 4af: 84 db test %bl,%bl 4b1: 0f 84 b3 00 00 00 je 56a <printf+0xca> ap = (uint*)(void*)&fmt + 1; 4b7: 8d 45 10 lea 0x10(%ebp),%eax 4ba: 83 c6 01 add $0x1,%esi state = 0; 4bd: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 4bf: 89 45 d4 mov %eax,-0x2c(%ebp) 4c2: eb 2f jmp 4f3 <printf+0x53> 4c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4c8: 83 f8 25 cmp $0x25,%eax 4cb: 0f 84 a7 00 00 00 je 578 <printf+0xd8> write(fd, &c, 1); 4d1: 8d 45 e2 lea -0x1e(%ebp),%eax 4d4: 83 ec 04 sub $0x4,%esp 4d7: 88 5d e2 mov %bl,-0x1e(%ebp) 4da: 6a 01 push $0x1 4dc: 50 push %eax 4dd: ff 75 08 pushl 0x8(%ebp) 4e0: e8 7d fe ff ff call 362 <write> 4e5: 83 c4 10 add $0x10,%esp 4e8: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 4eb: 0f b6 5e ff movzbl -0x1(%esi),%ebx 4ef: 84 db test %bl,%bl 4f1: 74 77 je 56a <printf+0xca> if(state == 0){ 4f3: 85 ff test %edi,%edi c = fmt[i] & 0xff; 4f5: 0f be cb movsbl %bl,%ecx 4f8: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 4fb: 74 cb je 4c8 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 4fd: 83 ff 25 cmp $0x25,%edi 500: 75 e6 jne 4e8 <printf+0x48> if(c == 'd'){ 502: 83 f8 64 cmp $0x64,%eax 505: 0f 84 05 01 00 00 je 610 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 50b: 81 e1 f7 00 00 00 and $0xf7,%ecx 511: 83 f9 70 cmp $0x70,%ecx 514: 74 72 je 588 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 516: 83 f8 73 cmp $0x73,%eax 519: 0f 84 99 00 00 00 je 5b8 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 51f: 83 f8 63 cmp $0x63,%eax 522: 0f 84 08 01 00 00 je 630 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 528: 83 f8 25 cmp $0x25,%eax 52b: 0f 84 ef 00 00 00 je 620 <printf+0x180> write(fd, &c, 1); 531: 8d 45 e7 lea -0x19(%ebp),%eax 534: 83 ec 04 sub $0x4,%esp 537: c6 45 e7 25 movb $0x25,-0x19(%ebp) 53b: 6a 01 push $0x1 53d: 50 push %eax 53e: ff 75 08 pushl 0x8(%ebp) 541: e8 1c fe ff ff call 362 <write> 546: 83 c4 0c add $0xc,%esp 549: 8d 45 e6 lea -0x1a(%ebp),%eax 54c: 88 5d e6 mov %bl,-0x1a(%ebp) 54f: 6a 01 push $0x1 551: 50 push %eax 552: ff 75 08 pushl 0x8(%ebp) 555: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 558: 31 ff xor %edi,%edi write(fd, &c, 1); 55a: e8 03 fe ff ff call 362 <write> for(i = 0; fmt[i]; i++){ 55f: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 563: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 566: 84 db test %bl,%bl 568: 75 89 jne 4f3 <printf+0x53> } } } 56a: 8d 65 f4 lea -0xc(%ebp),%esp 56d: 5b pop %ebx 56e: 5e pop %esi 56f: 5f pop %edi 570: 5d pop %ebp 571: c3 ret 572: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 578: bf 25 00 00 00 mov $0x25,%edi 57d: e9 66 ff ff ff jmp 4e8 <printf+0x48> 582: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 588: 83 ec 0c sub $0xc,%esp 58b: b9 10 00 00 00 mov $0x10,%ecx 590: 6a 00 push $0x0 592: 8b 7d d4 mov -0x2c(%ebp),%edi 595: 8b 45 08 mov 0x8(%ebp),%eax 598: 8b 17 mov (%edi),%edx 59a: e8 61 fe ff ff call 400 <printint> ap++; 59f: 89 f8 mov %edi,%eax 5a1: 83 c4 10 add $0x10,%esp state = 0; 5a4: 31 ff xor %edi,%edi ap++; 5a6: 83 c0 04 add $0x4,%eax 5a9: 89 45 d4 mov %eax,-0x2c(%ebp) 5ac: e9 37 ff ff ff jmp 4e8 <printf+0x48> 5b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 5b8: 8b 45 d4 mov -0x2c(%ebp),%eax 5bb: 8b 08 mov (%eax),%ecx ap++; 5bd: 83 c0 04 add $0x4,%eax 5c0: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 5c3: 85 c9 test %ecx,%ecx 5c5: 0f 84 8e 00 00 00 je 659 <printf+0x1b9> while(*s != 0){ 5cb: 0f b6 01 movzbl (%ecx),%eax state = 0; 5ce: 31 ff xor %edi,%edi s = (char*)*ap; 5d0: 89 cb mov %ecx,%ebx while(*s != 0){ 5d2: 84 c0 test %al,%al 5d4: 0f 84 0e ff ff ff je 4e8 <printf+0x48> 5da: 89 75 d0 mov %esi,-0x30(%ebp) 5dd: 89 de mov %ebx,%esi 5df: 8b 5d 08 mov 0x8(%ebp),%ebx 5e2: 8d 7d e3 lea -0x1d(%ebp),%edi 5e5: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 5e8: 83 ec 04 sub $0x4,%esp s++; 5eb: 83 c6 01 add $0x1,%esi 5ee: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 5f1: 6a 01 push $0x1 5f3: 57 push %edi 5f4: 53 push %ebx 5f5: e8 68 fd ff ff call 362 <write> while(*s != 0){ 5fa: 0f b6 06 movzbl (%esi),%eax 5fd: 83 c4 10 add $0x10,%esp 600: 84 c0 test %al,%al 602: 75 e4 jne 5e8 <printf+0x148> 604: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 607: 31 ff xor %edi,%edi 609: e9 da fe ff ff jmp 4e8 <printf+0x48> 60e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 610: 83 ec 0c sub $0xc,%esp 613: b9 0a 00 00 00 mov $0xa,%ecx 618: 6a 01 push $0x1 61a: e9 73 ff ff ff jmp 592 <printf+0xf2> 61f: 90 nop write(fd, &c, 1); 620: 83 ec 04 sub $0x4,%esp 623: 88 5d e5 mov %bl,-0x1b(%ebp) 626: 8d 45 e5 lea -0x1b(%ebp),%eax 629: 6a 01 push $0x1 62b: e9 21 ff ff ff jmp 551 <printf+0xb1> putc(fd, *ap); 630: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 633: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 636: 8b 07 mov (%edi),%eax write(fd, &c, 1); 638: 6a 01 push $0x1 ap++; 63a: 83 c7 04 add $0x4,%edi putc(fd, *ap); 63d: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 640: 8d 45 e4 lea -0x1c(%ebp),%eax 643: 50 push %eax 644: ff 75 08 pushl 0x8(%ebp) 647: e8 16 fd ff ff call 362 <write> ap++; 64c: 89 7d d4 mov %edi,-0x2c(%ebp) 64f: 83 c4 10 add $0x10,%esp state = 0; 652: 31 ff xor %edi,%edi 654: e9 8f fe ff ff jmp 4e8 <printf+0x48> s = "(null)"; 659: bb 48 08 00 00 mov $0x848,%ebx while(*s != 0){ 65e: b8 28 00 00 00 mov $0x28,%eax 663: e9 72 ff ff ff jmp 5da <printf+0x13a> 668: 66 90 xchg %ax,%ax 66a: 66 90 xchg %ax,%ax 66c: 66 90 xchg %ax,%ax 66e: 66 90 xchg %ax,%ax 00000670 <free>: static Header base; static Header *freep; void free(void *ap) { 670: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 671: a1 00 0b 00 00 mov 0xb00,%eax { 676: 89 e5 mov %esp,%ebp 678: 57 push %edi 679: 56 push %esi 67a: 53 push %ebx 67b: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 67e: 8d 4b f8 lea -0x8(%ebx),%ecx 681: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 688: 39 c8 cmp %ecx,%eax 68a: 8b 10 mov (%eax),%edx 68c: 73 32 jae 6c0 <free+0x50> 68e: 39 d1 cmp %edx,%ecx 690: 72 04 jb 696 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 692: 39 d0 cmp %edx,%eax 694: 72 32 jb 6c8 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 696: 8b 73 fc mov -0x4(%ebx),%esi 699: 8d 3c f1 lea (%ecx,%esi,8),%edi 69c: 39 fa cmp %edi,%edx 69e: 74 30 je 6d0 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 6a0: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 6a3: 8b 50 04 mov 0x4(%eax),%edx 6a6: 8d 34 d0 lea (%eax,%edx,8),%esi 6a9: 39 f1 cmp %esi,%ecx 6ab: 74 3a je 6e7 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 6ad: 89 08 mov %ecx,(%eax) freep = p; 6af: a3 00 0b 00 00 mov %eax,0xb00 } 6b4: 5b pop %ebx 6b5: 5e pop %esi 6b6: 5f pop %edi 6b7: 5d pop %ebp 6b8: c3 ret 6b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6c0: 39 d0 cmp %edx,%eax 6c2: 72 04 jb 6c8 <free+0x58> 6c4: 39 d1 cmp %edx,%ecx 6c6: 72 ce jb 696 <free+0x26> { 6c8: 89 d0 mov %edx,%eax 6ca: eb bc jmp 688 <free+0x18> 6cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 6d0: 03 72 04 add 0x4(%edx),%esi 6d3: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 6d6: 8b 10 mov (%eax),%edx 6d8: 8b 12 mov (%edx),%edx 6da: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 6dd: 8b 50 04 mov 0x4(%eax),%edx 6e0: 8d 34 d0 lea (%eax,%edx,8),%esi 6e3: 39 f1 cmp %esi,%ecx 6e5: 75 c6 jne 6ad <free+0x3d> p->s.size += bp->s.size; 6e7: 03 53 fc add -0x4(%ebx),%edx freep = p; 6ea: a3 00 0b 00 00 mov %eax,0xb00 p->s.size += bp->s.size; 6ef: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6f2: 8b 53 f8 mov -0x8(%ebx),%edx 6f5: 89 10 mov %edx,(%eax) } 6f7: 5b pop %ebx 6f8: 5e pop %esi 6f9: 5f pop %edi 6fa: 5d pop %ebp 6fb: c3 ret 6fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000700 <malloc>: return freep; } void* malloc(uint nbytes) { 700: 55 push %ebp 701: 89 e5 mov %esp,%ebp 703: 57 push %edi 704: 56 push %esi 705: 53 push %ebx 706: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 709: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 70c: 8b 15 00 0b 00 00 mov 0xb00,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 712: 8d 78 07 lea 0x7(%eax),%edi 715: c1 ef 03 shr $0x3,%edi 718: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 71b: 85 d2 test %edx,%edx 71d: 0f 84 9d 00 00 00 je 7c0 <malloc+0xc0> 723: 8b 02 mov (%edx),%eax 725: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 728: 39 cf cmp %ecx,%edi 72a: 76 6c jbe 798 <malloc+0x98> 72c: 81 ff 00 10 00 00 cmp $0x1000,%edi 732: bb 00 10 00 00 mov $0x1000,%ebx 737: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 73a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 741: eb 0e jmp 751 <malloc+0x51> 743: 90 nop 744: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 748: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 74a: 8b 48 04 mov 0x4(%eax),%ecx 74d: 39 f9 cmp %edi,%ecx 74f: 73 47 jae 798 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 751: 39 05 00 0b 00 00 cmp %eax,0xb00 757: 89 c2 mov %eax,%edx 759: 75 ed jne 748 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 75b: 83 ec 0c sub $0xc,%esp 75e: 56 push %esi 75f: e8 66 fc ff ff call 3ca <sbrk> if(p == (char*)-1) 764: 83 c4 10 add $0x10,%esp 767: 83 f8 ff cmp $0xffffffff,%eax 76a: 74 1c je 788 <malloc+0x88> hp->s.size = nu; 76c: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 76f: 83 ec 0c sub $0xc,%esp 772: 83 c0 08 add $0x8,%eax 775: 50 push %eax 776: e8 f5 fe ff ff call 670 <free> return freep; 77b: 8b 15 00 0b 00 00 mov 0xb00,%edx if((p = morecore(nunits)) == 0) 781: 83 c4 10 add $0x10,%esp 784: 85 d2 test %edx,%edx 786: 75 c0 jne 748 <malloc+0x48> return 0; } } 788: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 78b: 31 c0 xor %eax,%eax } 78d: 5b pop %ebx 78e: 5e pop %esi 78f: 5f pop %edi 790: 5d pop %ebp 791: c3 ret 792: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 798: 39 cf cmp %ecx,%edi 79a: 74 54 je 7f0 <malloc+0xf0> p->s.size -= nunits; 79c: 29 f9 sub %edi,%ecx 79e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 7a1: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 7a4: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 7a7: 89 15 00 0b 00 00 mov %edx,0xb00 } 7ad: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 7b0: 83 c0 08 add $0x8,%eax } 7b3: 5b pop %ebx 7b4: 5e pop %esi 7b5: 5f pop %edi 7b6: 5d pop %ebp 7b7: c3 ret 7b8: 90 nop 7b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 7c0: c7 05 00 0b 00 00 04 movl $0xb04,0xb00 7c7: 0b 00 00 7ca: c7 05 04 0b 00 00 04 movl $0xb04,0xb04 7d1: 0b 00 00 base.s.size = 0; 7d4: b8 04 0b 00 00 mov $0xb04,%eax 7d9: c7 05 08 0b 00 00 00 movl $0x0,0xb08 7e0: 00 00 00 7e3: e9 44 ff ff ff jmp 72c <malloc+0x2c> 7e8: 90 nop 7e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 7f0: 8b 08 mov (%eax),%ecx 7f2: 89 0a mov %ecx,(%edx) 7f4: eb b1 jmp 7a7 <malloc+0xa7>
; ; Amstrad CPC library ; ****************************************************** ; ** Librería de rutinas para Amstrad CPC ** ; ** Raúl Simarro, Artaburu 2009 ** ; ****************************************************** ; ; $Id: cpc_ScanKeyboard.asm $ ; SECTION code_clib PUBLIC cpc_ScanKeyboard PUBLIC _cpc_ScanKeyboard ;EXTERN cpc_KeysData EXTERN keymap .cpc_ScanKeyboard ._cpc_ScanKeyboard di ;1 $$%%$$ C P C VERSION $$%%$$ FROM CPCWIKI ld hl,keymap ;3 ld bc,$f782 ;3 out (c),c ;4 ld bc,$f40e ;3 ld e,b ;1 out (c),c ;4 ld bc,$f6c0 ;3 ld d,b ;1 out (c),c ;4 ld c,0 ;2 out (c),c ;4 ld bc,$f792 ;3 out (c),c ;4 ld a,$40 ;2 ld c,$4a ;2 44 .loop ld b,d ;1 out (c),a ;4 select line ld b,e ;1 ini ;5 read bits and write into KEYMAP inc a ;1 cp c ;1 jr c,loop ;2/3 9*16+1*15=159 ld bc,$f782 ;3 out (c),c ;4 ei ;1 8 =211 microseconds ret
_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 38 0c 00 movl $0xc38,0x4(%esp) 33: 00 34: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3b: e8 84 05 00 00 call 5c4 <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 13 02 00 00 call 26f <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 a6 03 00 00 call 414 <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 4b 0c 00 movl $0xc4b,0x4(%esp) 98: 00 99: c7 04 24 01 00 00 00 movl $0x1,(%esp) a0: e8 1f 05 00 00 call 5c4 <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 86 03 00 00 call 45c <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 33 03 00 00 call 43c <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 1a 03 00 00 call 444 <close> printf(1, "read\n"); 12a: c7 44 24 04 55 0c 00 movl $0xc55,0x4(%esp) 131: 00 132: c7 04 24 01 00 00 00 movl $0x1,(%esp) 139: e8 86 04 00 00 call 5c4 <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 07 03 00 00 call 45c <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 ac 02 00 00 call 434 <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 9b 02 00 00 call 444 <close> wait(); 1a9: e8 76 02 00 00 call 424 <wait> exit(); 1ae: e8 69 02 00 00 call 41c <exit> 1b3: 90 nop 000001b4 <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 1b4: 55 push %ebp 1b5: 89 e5 mov %esp,%ebp 1b7: 57 push %edi 1b8: 53 push %ebx asm volatile("cld; rep stosb" : 1b9: 8b 4d 08 mov 0x8(%ebp),%ecx 1bc: 8b 55 10 mov 0x10(%ebp),%edx 1bf: 8b 45 0c mov 0xc(%ebp),%eax 1c2: 89 cb mov %ecx,%ebx 1c4: 89 df mov %ebx,%edi 1c6: 89 d1 mov %edx,%ecx 1c8: fc cld 1c9: f3 aa rep stos %al,%es:(%edi) 1cb: 89 ca mov %ecx,%edx 1cd: 89 fb mov %edi,%ebx 1cf: 89 5d 08 mov %ebx,0x8(%ebp) 1d2: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 1d5: 5b pop %ebx 1d6: 5f pop %edi 1d7: 5d pop %ebp 1d8: c3 ret 000001d9 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 1d9: 55 push %ebp 1da: 89 e5 mov %esp,%ebp 1dc: 83 ec 10 sub $0x10,%esp char *os; os = s; 1df: 8b 45 08 mov 0x8(%ebp),%eax 1e2: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 1e5: 90 nop 1e6: 8b 45 08 mov 0x8(%ebp),%eax 1e9: 8d 50 01 lea 0x1(%eax),%edx 1ec: 89 55 08 mov %edx,0x8(%ebp) 1ef: 8b 55 0c mov 0xc(%ebp),%edx 1f2: 8d 4a 01 lea 0x1(%edx),%ecx 1f5: 89 4d 0c mov %ecx,0xc(%ebp) 1f8: 0f b6 12 movzbl (%edx),%edx 1fb: 88 10 mov %dl,(%eax) 1fd: 0f b6 00 movzbl (%eax),%eax 200: 84 c0 test %al,%al 202: 75 e2 jne 1e6 <strcpy+0xd> ; return os; 204: 8b 45 fc mov -0x4(%ebp),%eax } 207: c9 leave 208: c3 ret 00000209 <strcmp>: int strcmp(const char *p, const char *q) { 209: 55 push %ebp 20a: 89 e5 mov %esp,%ebp while(*p && *p == *q) 20c: eb 08 jmp 216 <strcmp+0xd> p++, q++; 20e: 83 45 08 01 addl $0x1,0x8(%ebp) 212: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 216: 8b 45 08 mov 0x8(%ebp),%eax 219: 0f b6 00 movzbl (%eax),%eax 21c: 84 c0 test %al,%al 21e: 74 10 je 230 <strcmp+0x27> 220: 8b 45 08 mov 0x8(%ebp),%eax 223: 0f b6 10 movzbl (%eax),%edx 226: 8b 45 0c mov 0xc(%ebp),%eax 229: 0f b6 00 movzbl (%eax),%eax 22c: 38 c2 cmp %al,%dl 22e: 74 de je 20e <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 230: 8b 45 08 mov 0x8(%ebp),%eax 233: 0f b6 00 movzbl (%eax),%eax 236: 0f b6 d0 movzbl %al,%edx 239: 8b 45 0c mov 0xc(%ebp),%eax 23c: 0f b6 00 movzbl (%eax),%eax 23f: 0f b6 c0 movzbl %al,%eax 242: 29 c2 sub %eax,%edx 244: 89 d0 mov %edx,%eax } 246: 5d pop %ebp 247: c3 ret 00000248 <strlen>: uint strlen(char *s) { 248: 55 push %ebp 249: 89 e5 mov %esp,%ebp 24b: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 24e: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 255: eb 04 jmp 25b <strlen+0x13> 257: 83 45 fc 01 addl $0x1,-0x4(%ebp) 25b: 8b 55 fc mov -0x4(%ebp),%edx 25e: 8b 45 08 mov 0x8(%ebp),%eax 261: 01 d0 add %edx,%eax 263: 0f b6 00 movzbl (%eax),%eax 266: 84 c0 test %al,%al 268: 75 ed jne 257 <strlen+0xf> ; return n; 26a: 8b 45 fc mov -0x4(%ebp),%eax } 26d: c9 leave 26e: c3 ret 0000026f <memset>: void* memset(void *dst, int c, uint n) { 26f: 55 push %ebp 270: 89 e5 mov %esp,%ebp 272: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 275: 8b 45 10 mov 0x10(%ebp),%eax 278: 89 44 24 08 mov %eax,0x8(%esp) 27c: 8b 45 0c mov 0xc(%ebp),%eax 27f: 89 44 24 04 mov %eax,0x4(%esp) 283: 8b 45 08 mov 0x8(%ebp),%eax 286: 89 04 24 mov %eax,(%esp) 289: e8 26 ff ff ff call 1b4 <stosb> return dst; 28e: 8b 45 08 mov 0x8(%ebp),%eax } 291: c9 leave 292: c3 ret 00000293 <strchr>: char* strchr(const char *s, char c) { 293: 55 push %ebp 294: 89 e5 mov %esp,%ebp 296: 83 ec 04 sub $0x4,%esp 299: 8b 45 0c mov 0xc(%ebp),%eax 29c: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 29f: eb 14 jmp 2b5 <strchr+0x22> if(*s == c) 2a1: 8b 45 08 mov 0x8(%ebp),%eax 2a4: 0f b6 00 movzbl (%eax),%eax 2a7: 3a 45 fc cmp -0x4(%ebp),%al 2aa: 75 05 jne 2b1 <strchr+0x1e> return (char*)s; 2ac: 8b 45 08 mov 0x8(%ebp),%eax 2af: eb 13 jmp 2c4 <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 2b1: 83 45 08 01 addl $0x1,0x8(%ebp) 2b5: 8b 45 08 mov 0x8(%ebp),%eax 2b8: 0f b6 00 movzbl (%eax),%eax 2bb: 84 c0 test %al,%al 2bd: 75 e2 jne 2a1 <strchr+0xe> if(*s == c) return (char*)s; return 0; 2bf: b8 00 00 00 00 mov $0x0,%eax } 2c4: c9 leave 2c5: c3 ret 000002c6 <gets>: char* gets(char *buf, int max) { 2c6: 55 push %ebp 2c7: 89 e5 mov %esp,%ebp 2c9: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 2cc: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 2d3: eb 4c jmp 321 <gets+0x5b> cc = read(0, &c, 1); 2d5: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 2dc: 00 2dd: 8d 45 ef lea -0x11(%ebp),%eax 2e0: 89 44 24 04 mov %eax,0x4(%esp) 2e4: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2eb: e8 44 01 00 00 call 434 <read> 2f0: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 2f3: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 2f7: 7f 02 jg 2fb <gets+0x35> break; 2f9: eb 31 jmp 32c <gets+0x66> buf[i++] = c; 2fb: 8b 45 f4 mov -0xc(%ebp),%eax 2fe: 8d 50 01 lea 0x1(%eax),%edx 301: 89 55 f4 mov %edx,-0xc(%ebp) 304: 89 c2 mov %eax,%edx 306: 8b 45 08 mov 0x8(%ebp),%eax 309: 01 c2 add %eax,%edx 30b: 0f b6 45 ef movzbl -0x11(%ebp),%eax 30f: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 311: 0f b6 45 ef movzbl -0x11(%ebp),%eax 315: 3c 0a cmp $0xa,%al 317: 74 13 je 32c <gets+0x66> 319: 0f b6 45 ef movzbl -0x11(%ebp),%eax 31d: 3c 0d cmp $0xd,%al 31f: 74 0b je 32c <gets+0x66> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 321: 8b 45 f4 mov -0xc(%ebp),%eax 324: 83 c0 01 add $0x1,%eax 327: 3b 45 0c cmp 0xc(%ebp),%eax 32a: 7c a9 jl 2d5 <gets+0xf> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 32c: 8b 55 f4 mov -0xc(%ebp),%edx 32f: 8b 45 08 mov 0x8(%ebp),%eax 332: 01 d0 add %edx,%eax 334: c6 00 00 movb $0x0,(%eax) return buf; 337: 8b 45 08 mov 0x8(%ebp),%eax } 33a: c9 leave 33b: c3 ret 0000033c <stat>: int stat(char *n, struct stat *st) { 33c: 55 push %ebp 33d: 89 e5 mov %esp,%ebp 33f: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 342: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 349: 00 34a: 8b 45 08 mov 0x8(%ebp),%eax 34d: 89 04 24 mov %eax,(%esp) 350: e8 07 01 00 00 call 45c <open> 355: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 358: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 35c: 79 07 jns 365 <stat+0x29> return -1; 35e: b8 ff ff ff ff mov $0xffffffff,%eax 363: eb 23 jmp 388 <stat+0x4c> r = fstat(fd, st); 365: 8b 45 0c mov 0xc(%ebp),%eax 368: 89 44 24 04 mov %eax,0x4(%esp) 36c: 8b 45 f4 mov -0xc(%ebp),%eax 36f: 89 04 24 mov %eax,(%esp) 372: e8 fd 00 00 00 call 474 <fstat> 377: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 37a: 8b 45 f4 mov -0xc(%ebp),%eax 37d: 89 04 24 mov %eax,(%esp) 380: e8 bf 00 00 00 call 444 <close> return r; 385: 8b 45 f0 mov -0x10(%ebp),%eax } 388: c9 leave 389: c3 ret 0000038a <atoi>: int atoi(const char *s) { 38a: 55 push %ebp 38b: 89 e5 mov %esp,%ebp 38d: 83 ec 10 sub $0x10,%esp int n; n = 0; 390: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 397: eb 25 jmp 3be <atoi+0x34> n = n*10 + *s++ - '0'; 399: 8b 55 fc mov -0x4(%ebp),%edx 39c: 89 d0 mov %edx,%eax 39e: c1 e0 02 shl $0x2,%eax 3a1: 01 d0 add %edx,%eax 3a3: 01 c0 add %eax,%eax 3a5: 89 c1 mov %eax,%ecx 3a7: 8b 45 08 mov 0x8(%ebp),%eax 3aa: 8d 50 01 lea 0x1(%eax),%edx 3ad: 89 55 08 mov %edx,0x8(%ebp) 3b0: 0f b6 00 movzbl (%eax),%eax 3b3: 0f be c0 movsbl %al,%eax 3b6: 01 c8 add %ecx,%eax 3b8: 83 e8 30 sub $0x30,%eax 3bb: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 3be: 8b 45 08 mov 0x8(%ebp),%eax 3c1: 0f b6 00 movzbl (%eax),%eax 3c4: 3c 2f cmp $0x2f,%al 3c6: 7e 0a jle 3d2 <atoi+0x48> 3c8: 8b 45 08 mov 0x8(%ebp),%eax 3cb: 0f b6 00 movzbl (%eax),%eax 3ce: 3c 39 cmp $0x39,%al 3d0: 7e c7 jle 399 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 3d2: 8b 45 fc mov -0x4(%ebp),%eax } 3d5: c9 leave 3d6: c3 ret 000003d7 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 3d7: 55 push %ebp 3d8: 89 e5 mov %esp,%ebp 3da: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 3dd: 8b 45 08 mov 0x8(%ebp),%eax 3e0: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 3e3: 8b 45 0c mov 0xc(%ebp),%eax 3e6: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 3e9: eb 17 jmp 402 <memmove+0x2b> *dst++ = *src++; 3eb: 8b 45 fc mov -0x4(%ebp),%eax 3ee: 8d 50 01 lea 0x1(%eax),%edx 3f1: 89 55 fc mov %edx,-0x4(%ebp) 3f4: 8b 55 f8 mov -0x8(%ebp),%edx 3f7: 8d 4a 01 lea 0x1(%edx),%ecx 3fa: 89 4d f8 mov %ecx,-0x8(%ebp) 3fd: 0f b6 12 movzbl (%edx),%edx 400: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 402: 8b 45 10 mov 0x10(%ebp),%eax 405: 8d 50 ff lea -0x1(%eax),%edx 408: 89 55 10 mov %edx,0x10(%ebp) 40b: 85 c0 test %eax,%eax 40d: 7f dc jg 3eb <memmove+0x14> *dst++ = *src++; return vdst; 40f: 8b 45 08 mov 0x8(%ebp),%eax } 412: c9 leave 413: c3 ret 00000414 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 414: b8 01 00 00 00 mov $0x1,%eax 419: cd 40 int $0x40 41b: c3 ret 0000041c <exit>: SYSCALL(exit) 41c: b8 02 00 00 00 mov $0x2,%eax 421: cd 40 int $0x40 423: c3 ret 00000424 <wait>: SYSCALL(wait) 424: b8 03 00 00 00 mov $0x3,%eax 429: cd 40 int $0x40 42b: c3 ret 0000042c <pipe>: SYSCALL(pipe) 42c: b8 04 00 00 00 mov $0x4,%eax 431: cd 40 int $0x40 433: c3 ret 00000434 <read>: SYSCALL(read) 434: b8 05 00 00 00 mov $0x5,%eax 439: cd 40 int $0x40 43b: c3 ret 0000043c <write>: SYSCALL(write) 43c: b8 10 00 00 00 mov $0x10,%eax 441: cd 40 int $0x40 443: c3 ret 00000444 <close>: SYSCALL(close) 444: b8 15 00 00 00 mov $0x15,%eax 449: cd 40 int $0x40 44b: c3 ret 0000044c <kill>: SYSCALL(kill) 44c: b8 06 00 00 00 mov $0x6,%eax 451: cd 40 int $0x40 453: c3 ret 00000454 <exec>: SYSCALL(exec) 454: b8 07 00 00 00 mov $0x7,%eax 459: cd 40 int $0x40 45b: c3 ret 0000045c <open>: SYSCALL(open) 45c: b8 0f 00 00 00 mov $0xf,%eax 461: cd 40 int $0x40 463: c3 ret 00000464 <mknod>: SYSCALL(mknod) 464: b8 11 00 00 00 mov $0x11,%eax 469: cd 40 int $0x40 46b: c3 ret 0000046c <unlink>: SYSCALL(unlink) 46c: b8 12 00 00 00 mov $0x12,%eax 471: cd 40 int $0x40 473: c3 ret 00000474 <fstat>: SYSCALL(fstat) 474: b8 08 00 00 00 mov $0x8,%eax 479: cd 40 int $0x40 47b: c3 ret 0000047c <link>: SYSCALL(link) 47c: b8 13 00 00 00 mov $0x13,%eax 481: cd 40 int $0x40 483: c3 ret 00000484 <mkdir>: SYSCALL(mkdir) 484: b8 14 00 00 00 mov $0x14,%eax 489: cd 40 int $0x40 48b: c3 ret 0000048c <chdir>: SYSCALL(chdir) 48c: b8 09 00 00 00 mov $0x9,%eax 491: cd 40 int $0x40 493: c3 ret 00000494 <dup>: SYSCALL(dup) 494: b8 0a 00 00 00 mov $0xa,%eax 499: cd 40 int $0x40 49b: c3 ret 0000049c <getpid>: SYSCALL(getpid) 49c: b8 0b 00 00 00 mov $0xb,%eax 4a1: cd 40 int $0x40 4a3: c3 ret 000004a4 <sbrk>: SYSCALL(sbrk) 4a4: b8 0c 00 00 00 mov $0xc,%eax 4a9: cd 40 int $0x40 4ab: c3 ret 000004ac <sleep>: SYSCALL(sleep) 4ac: b8 0d 00 00 00 mov $0xd,%eax 4b1: cd 40 int $0x40 4b3: c3 ret 000004b4 <uptime>: SYSCALL(uptime) 4b4: b8 0e 00 00 00 mov $0xe,%eax 4b9: cd 40 int $0x40 4bb: c3 ret 000004bc <date>: SYSCALL(date) 4bc: b8 16 00 00 00 mov $0x16,%eax 4c1: cd 40 int $0x40 4c3: c3 ret 000004c4 <clone>: SYSCALL(clone) 4c4: b8 17 00 00 00 mov $0x17,%eax 4c9: cd 40 int $0x40 4cb: c3 ret 000004cc <join>: SYSCALL(join) 4cc: b8 18 00 00 00 mov $0x18,%eax 4d1: cd 40 int $0x40 4d3: c3 ret 000004d4 <threadSleep>: SYSCALL(threadSleep) 4d4: b8 19 00 00 00 mov $0x19,%eax 4d9: cd 40 int $0x40 4db: c3 ret 000004dc <threadWake>: SYSCALL(threadWake) 4dc: b8 1a 00 00 00 mov $0x1a,%eax 4e1: cd 40 int $0x40 4e3: c3 ret 000004e4 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 4e4: 55 push %ebp 4e5: 89 e5 mov %esp,%ebp 4e7: 83 ec 18 sub $0x18,%esp 4ea: 8b 45 0c mov 0xc(%ebp),%eax 4ed: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 4f0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4f7: 00 4f8: 8d 45 f4 lea -0xc(%ebp),%eax 4fb: 89 44 24 04 mov %eax,0x4(%esp) 4ff: 8b 45 08 mov 0x8(%ebp),%eax 502: 89 04 24 mov %eax,(%esp) 505: e8 32 ff ff ff call 43c <write> } 50a: c9 leave 50b: c3 ret 0000050c <printint>: static void printint(int fd, int xx, int base, int sgn) { 50c: 55 push %ebp 50d: 89 e5 mov %esp,%ebp 50f: 56 push %esi 510: 53 push %ebx 511: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 514: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 51b: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 51f: 74 17 je 538 <printint+0x2c> 521: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 525: 79 11 jns 538 <printint+0x2c> neg = 1; 527: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 52e: 8b 45 0c mov 0xc(%ebp),%eax 531: f7 d8 neg %eax 533: 89 45 ec mov %eax,-0x14(%ebp) 536: eb 06 jmp 53e <printint+0x32> } else { x = xx; 538: 8b 45 0c mov 0xc(%ebp),%eax 53b: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 53e: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 545: 8b 4d f4 mov -0xc(%ebp),%ecx 548: 8d 41 01 lea 0x1(%ecx),%eax 54b: 89 45 f4 mov %eax,-0xc(%ebp) 54e: 8b 5d 10 mov 0x10(%ebp),%ebx 551: 8b 45 ec mov -0x14(%ebp),%eax 554: ba 00 00 00 00 mov $0x0,%edx 559: f7 f3 div %ebx 55b: 89 d0 mov %edx,%eax 55d: 0f b6 80 58 10 00 00 movzbl 0x1058(%eax),%eax 564: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 568: 8b 75 10 mov 0x10(%ebp),%esi 56b: 8b 45 ec mov -0x14(%ebp),%eax 56e: ba 00 00 00 00 mov $0x0,%edx 573: f7 f6 div %esi 575: 89 45 ec mov %eax,-0x14(%ebp) 578: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 57c: 75 c7 jne 545 <printint+0x39> if(neg) 57e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 582: 74 10 je 594 <printint+0x88> buf[i++] = '-'; 584: 8b 45 f4 mov -0xc(%ebp),%eax 587: 8d 50 01 lea 0x1(%eax),%edx 58a: 89 55 f4 mov %edx,-0xc(%ebp) 58d: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 592: eb 1f jmp 5b3 <printint+0xa7> 594: eb 1d jmp 5b3 <printint+0xa7> putc(fd, buf[i]); 596: 8d 55 dc lea -0x24(%ebp),%edx 599: 8b 45 f4 mov -0xc(%ebp),%eax 59c: 01 d0 add %edx,%eax 59e: 0f b6 00 movzbl (%eax),%eax 5a1: 0f be c0 movsbl %al,%eax 5a4: 89 44 24 04 mov %eax,0x4(%esp) 5a8: 8b 45 08 mov 0x8(%ebp),%eax 5ab: 89 04 24 mov %eax,(%esp) 5ae: e8 31 ff ff ff call 4e4 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 5b3: 83 6d f4 01 subl $0x1,-0xc(%ebp) 5b7: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 5bb: 79 d9 jns 596 <printint+0x8a> putc(fd, buf[i]); } 5bd: 83 c4 30 add $0x30,%esp 5c0: 5b pop %ebx 5c1: 5e pop %esi 5c2: 5d pop %ebp 5c3: c3 ret 000005c4 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 5c4: 55 push %ebp 5c5: 89 e5 mov %esp,%ebp 5c7: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 5ca: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 5d1: 8d 45 0c lea 0xc(%ebp),%eax 5d4: 83 c0 04 add $0x4,%eax 5d7: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 5da: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 5e1: e9 7c 01 00 00 jmp 762 <printf+0x19e> c = fmt[i] & 0xff; 5e6: 8b 55 0c mov 0xc(%ebp),%edx 5e9: 8b 45 f0 mov -0x10(%ebp),%eax 5ec: 01 d0 add %edx,%eax 5ee: 0f b6 00 movzbl (%eax),%eax 5f1: 0f be c0 movsbl %al,%eax 5f4: 25 ff 00 00 00 and $0xff,%eax 5f9: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 5fc: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 600: 75 2c jne 62e <printf+0x6a> if(c == '%'){ 602: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 606: 75 0c jne 614 <printf+0x50> state = '%'; 608: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 60f: e9 4a 01 00 00 jmp 75e <printf+0x19a> } else { putc(fd, c); 614: 8b 45 e4 mov -0x1c(%ebp),%eax 617: 0f be c0 movsbl %al,%eax 61a: 89 44 24 04 mov %eax,0x4(%esp) 61e: 8b 45 08 mov 0x8(%ebp),%eax 621: 89 04 24 mov %eax,(%esp) 624: e8 bb fe ff ff call 4e4 <putc> 629: e9 30 01 00 00 jmp 75e <printf+0x19a> } } else if(state == '%'){ 62e: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 632: 0f 85 26 01 00 00 jne 75e <printf+0x19a> if(c == 'd'){ 638: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 63c: 75 2d jne 66b <printf+0xa7> printint(fd, *ap, 10, 1); 63e: 8b 45 e8 mov -0x18(%ebp),%eax 641: 8b 00 mov (%eax),%eax 643: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 64a: 00 64b: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 652: 00 653: 89 44 24 04 mov %eax,0x4(%esp) 657: 8b 45 08 mov 0x8(%ebp),%eax 65a: 89 04 24 mov %eax,(%esp) 65d: e8 aa fe ff ff call 50c <printint> ap++; 662: 83 45 e8 04 addl $0x4,-0x18(%ebp) 666: e9 ec 00 00 00 jmp 757 <printf+0x193> } else if(c == 'x' || c == 'p'){ 66b: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 66f: 74 06 je 677 <printf+0xb3> 671: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 675: 75 2d jne 6a4 <printf+0xe0> printint(fd, *ap, 16, 0); 677: 8b 45 e8 mov -0x18(%ebp),%eax 67a: 8b 00 mov (%eax),%eax 67c: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 683: 00 684: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 68b: 00 68c: 89 44 24 04 mov %eax,0x4(%esp) 690: 8b 45 08 mov 0x8(%ebp),%eax 693: 89 04 24 mov %eax,(%esp) 696: e8 71 fe ff ff call 50c <printint> ap++; 69b: 83 45 e8 04 addl $0x4,-0x18(%ebp) 69f: e9 b3 00 00 00 jmp 757 <printf+0x193> } else if(c == 's'){ 6a4: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 6a8: 75 45 jne 6ef <printf+0x12b> s = (char*)*ap; 6aa: 8b 45 e8 mov -0x18(%ebp),%eax 6ad: 8b 00 mov (%eax),%eax 6af: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 6b2: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 6b6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 6ba: 75 09 jne 6c5 <printf+0x101> s = "(null)"; 6bc: c7 45 f4 5b 0c 00 00 movl $0xc5b,-0xc(%ebp) while(*s != 0){ 6c3: eb 1e jmp 6e3 <printf+0x11f> 6c5: eb 1c jmp 6e3 <printf+0x11f> putc(fd, *s); 6c7: 8b 45 f4 mov -0xc(%ebp),%eax 6ca: 0f b6 00 movzbl (%eax),%eax 6cd: 0f be c0 movsbl %al,%eax 6d0: 89 44 24 04 mov %eax,0x4(%esp) 6d4: 8b 45 08 mov 0x8(%ebp),%eax 6d7: 89 04 24 mov %eax,(%esp) 6da: e8 05 fe ff ff call 4e4 <putc> s++; 6df: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 6e3: 8b 45 f4 mov -0xc(%ebp),%eax 6e6: 0f b6 00 movzbl (%eax),%eax 6e9: 84 c0 test %al,%al 6eb: 75 da jne 6c7 <printf+0x103> 6ed: eb 68 jmp 757 <printf+0x193> putc(fd, *s); s++; } } else if(c == 'c'){ 6ef: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 6f3: 75 1d jne 712 <printf+0x14e> putc(fd, *ap); 6f5: 8b 45 e8 mov -0x18(%ebp),%eax 6f8: 8b 00 mov (%eax),%eax 6fa: 0f be c0 movsbl %al,%eax 6fd: 89 44 24 04 mov %eax,0x4(%esp) 701: 8b 45 08 mov 0x8(%ebp),%eax 704: 89 04 24 mov %eax,(%esp) 707: e8 d8 fd ff ff call 4e4 <putc> ap++; 70c: 83 45 e8 04 addl $0x4,-0x18(%ebp) 710: eb 45 jmp 757 <printf+0x193> } else if(c == '%'){ 712: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 716: 75 17 jne 72f <printf+0x16b> putc(fd, c); 718: 8b 45 e4 mov -0x1c(%ebp),%eax 71b: 0f be c0 movsbl %al,%eax 71e: 89 44 24 04 mov %eax,0x4(%esp) 722: 8b 45 08 mov 0x8(%ebp),%eax 725: 89 04 24 mov %eax,(%esp) 728: e8 b7 fd ff ff call 4e4 <putc> 72d: eb 28 jmp 757 <printf+0x193> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 72f: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 736: 00 737: 8b 45 08 mov 0x8(%ebp),%eax 73a: 89 04 24 mov %eax,(%esp) 73d: e8 a2 fd ff ff call 4e4 <putc> putc(fd, c); 742: 8b 45 e4 mov -0x1c(%ebp),%eax 745: 0f be c0 movsbl %al,%eax 748: 89 44 24 04 mov %eax,0x4(%esp) 74c: 8b 45 08 mov 0x8(%ebp),%eax 74f: 89 04 24 mov %eax,(%esp) 752: e8 8d fd ff ff call 4e4 <putc> } state = 0; 757: 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++){ 75e: 83 45 f0 01 addl $0x1,-0x10(%ebp) 762: 8b 55 0c mov 0xc(%ebp),%edx 765: 8b 45 f0 mov -0x10(%ebp),%eax 768: 01 d0 add %edx,%eax 76a: 0f b6 00 movzbl (%eax),%eax 76d: 84 c0 test %al,%al 76f: 0f 85 71 fe ff ff jne 5e6 <printf+0x22> putc(fd, c); } state = 0; } } } 775: c9 leave 776: c3 ret 777: 90 nop 00000778 <free>: static Header base; static Header *freep; void free(void *ap) { 778: 55 push %ebp 779: 89 e5 mov %esp,%ebp 77b: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 77e: 8b 45 08 mov 0x8(%ebp),%eax 781: 83 e8 08 sub $0x8,%eax 784: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 787: a1 74 10 00 00 mov 0x1074,%eax 78c: 89 45 fc mov %eax,-0x4(%ebp) 78f: eb 24 jmp 7b5 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 791: 8b 45 fc mov -0x4(%ebp),%eax 794: 8b 00 mov (%eax),%eax 796: 3b 45 fc cmp -0x4(%ebp),%eax 799: 77 12 ja 7ad <free+0x35> 79b: 8b 45 f8 mov -0x8(%ebp),%eax 79e: 3b 45 fc cmp -0x4(%ebp),%eax 7a1: 77 24 ja 7c7 <free+0x4f> 7a3: 8b 45 fc mov -0x4(%ebp),%eax 7a6: 8b 00 mov (%eax),%eax 7a8: 3b 45 f8 cmp -0x8(%ebp),%eax 7ab: 77 1a ja 7c7 <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) 7ad: 8b 45 fc mov -0x4(%ebp),%eax 7b0: 8b 00 mov (%eax),%eax 7b2: 89 45 fc mov %eax,-0x4(%ebp) 7b5: 8b 45 f8 mov -0x8(%ebp),%eax 7b8: 3b 45 fc cmp -0x4(%ebp),%eax 7bb: 76 d4 jbe 791 <free+0x19> 7bd: 8b 45 fc mov -0x4(%ebp),%eax 7c0: 8b 00 mov (%eax),%eax 7c2: 3b 45 f8 cmp -0x8(%ebp),%eax 7c5: 76 ca jbe 791 <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 7c7: 8b 45 f8 mov -0x8(%ebp),%eax 7ca: 8b 40 04 mov 0x4(%eax),%eax 7cd: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 7d4: 8b 45 f8 mov -0x8(%ebp),%eax 7d7: 01 c2 add %eax,%edx 7d9: 8b 45 fc mov -0x4(%ebp),%eax 7dc: 8b 00 mov (%eax),%eax 7de: 39 c2 cmp %eax,%edx 7e0: 75 24 jne 806 <free+0x8e> bp->s.size += p->s.ptr->s.size; 7e2: 8b 45 f8 mov -0x8(%ebp),%eax 7e5: 8b 50 04 mov 0x4(%eax),%edx 7e8: 8b 45 fc mov -0x4(%ebp),%eax 7eb: 8b 00 mov (%eax),%eax 7ed: 8b 40 04 mov 0x4(%eax),%eax 7f0: 01 c2 add %eax,%edx 7f2: 8b 45 f8 mov -0x8(%ebp),%eax 7f5: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 7f8: 8b 45 fc mov -0x4(%ebp),%eax 7fb: 8b 00 mov (%eax),%eax 7fd: 8b 10 mov (%eax),%edx 7ff: 8b 45 f8 mov -0x8(%ebp),%eax 802: 89 10 mov %edx,(%eax) 804: eb 0a jmp 810 <free+0x98> } else bp->s.ptr = p->s.ptr; 806: 8b 45 fc mov -0x4(%ebp),%eax 809: 8b 10 mov (%eax),%edx 80b: 8b 45 f8 mov -0x8(%ebp),%eax 80e: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 810: 8b 45 fc mov -0x4(%ebp),%eax 813: 8b 40 04 mov 0x4(%eax),%eax 816: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 81d: 8b 45 fc mov -0x4(%ebp),%eax 820: 01 d0 add %edx,%eax 822: 3b 45 f8 cmp -0x8(%ebp),%eax 825: 75 20 jne 847 <free+0xcf> p->s.size += bp->s.size; 827: 8b 45 fc mov -0x4(%ebp),%eax 82a: 8b 50 04 mov 0x4(%eax),%edx 82d: 8b 45 f8 mov -0x8(%ebp),%eax 830: 8b 40 04 mov 0x4(%eax),%eax 833: 01 c2 add %eax,%edx 835: 8b 45 fc mov -0x4(%ebp),%eax 838: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 83b: 8b 45 f8 mov -0x8(%ebp),%eax 83e: 8b 10 mov (%eax),%edx 840: 8b 45 fc mov -0x4(%ebp),%eax 843: 89 10 mov %edx,(%eax) 845: eb 08 jmp 84f <free+0xd7> } else p->s.ptr = bp; 847: 8b 45 fc mov -0x4(%ebp),%eax 84a: 8b 55 f8 mov -0x8(%ebp),%edx 84d: 89 10 mov %edx,(%eax) freep = p; 84f: 8b 45 fc mov -0x4(%ebp),%eax 852: a3 74 10 00 00 mov %eax,0x1074 } 857: c9 leave 858: c3 ret 00000859 <morecore>: static Header* morecore(uint nu) { 859: 55 push %ebp 85a: 89 e5 mov %esp,%ebp 85c: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 85f: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 866: 77 07 ja 86f <morecore+0x16> nu = 4096; 868: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 86f: 8b 45 08 mov 0x8(%ebp),%eax 872: c1 e0 03 shl $0x3,%eax 875: 89 04 24 mov %eax,(%esp) 878: e8 27 fc ff ff call 4a4 <sbrk> 87d: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 880: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 884: 75 07 jne 88d <morecore+0x34> return 0; 886: b8 00 00 00 00 mov $0x0,%eax 88b: eb 22 jmp 8af <morecore+0x56> hp = (Header*)p; 88d: 8b 45 f4 mov -0xc(%ebp),%eax 890: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 893: 8b 45 f0 mov -0x10(%ebp),%eax 896: 8b 55 08 mov 0x8(%ebp),%edx 899: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 89c: 8b 45 f0 mov -0x10(%ebp),%eax 89f: 83 c0 08 add $0x8,%eax 8a2: 89 04 24 mov %eax,(%esp) 8a5: e8 ce fe ff ff call 778 <free> return freep; 8aa: a1 74 10 00 00 mov 0x1074,%eax } 8af: c9 leave 8b0: c3 ret 000008b1 <malloc>: void* malloc(uint nbytes) { 8b1: 55 push %ebp 8b2: 89 e5 mov %esp,%ebp 8b4: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 8b7: 8b 45 08 mov 0x8(%ebp),%eax 8ba: 83 c0 07 add $0x7,%eax 8bd: c1 e8 03 shr $0x3,%eax 8c0: 83 c0 01 add $0x1,%eax 8c3: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 8c6: a1 74 10 00 00 mov 0x1074,%eax 8cb: 89 45 f0 mov %eax,-0x10(%ebp) 8ce: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8d2: 75 23 jne 8f7 <malloc+0x46> base.s.ptr = freep = prevp = &base; 8d4: c7 45 f0 6c 10 00 00 movl $0x106c,-0x10(%ebp) 8db: 8b 45 f0 mov -0x10(%ebp),%eax 8de: a3 74 10 00 00 mov %eax,0x1074 8e3: a1 74 10 00 00 mov 0x1074,%eax 8e8: a3 6c 10 00 00 mov %eax,0x106c base.s.size = 0; 8ed: c7 05 70 10 00 00 00 movl $0x0,0x1070 8f4: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 8f7: 8b 45 f0 mov -0x10(%ebp),%eax 8fa: 8b 00 mov (%eax),%eax 8fc: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 8ff: 8b 45 f4 mov -0xc(%ebp),%eax 902: 8b 40 04 mov 0x4(%eax),%eax 905: 3b 45 ec cmp -0x14(%ebp),%eax 908: 72 4d jb 957 <malloc+0xa6> if(p->s.size == nunits) 90a: 8b 45 f4 mov -0xc(%ebp),%eax 90d: 8b 40 04 mov 0x4(%eax),%eax 910: 3b 45 ec cmp -0x14(%ebp),%eax 913: 75 0c jne 921 <malloc+0x70> prevp->s.ptr = p->s.ptr; 915: 8b 45 f4 mov -0xc(%ebp),%eax 918: 8b 10 mov (%eax),%edx 91a: 8b 45 f0 mov -0x10(%ebp),%eax 91d: 89 10 mov %edx,(%eax) 91f: eb 26 jmp 947 <malloc+0x96> else { p->s.size -= nunits; 921: 8b 45 f4 mov -0xc(%ebp),%eax 924: 8b 40 04 mov 0x4(%eax),%eax 927: 2b 45 ec sub -0x14(%ebp),%eax 92a: 89 c2 mov %eax,%edx 92c: 8b 45 f4 mov -0xc(%ebp),%eax 92f: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 932: 8b 45 f4 mov -0xc(%ebp),%eax 935: 8b 40 04 mov 0x4(%eax),%eax 938: c1 e0 03 shl $0x3,%eax 93b: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 93e: 8b 45 f4 mov -0xc(%ebp),%eax 941: 8b 55 ec mov -0x14(%ebp),%edx 944: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 947: 8b 45 f0 mov -0x10(%ebp),%eax 94a: a3 74 10 00 00 mov %eax,0x1074 return (void*)(p + 1); 94f: 8b 45 f4 mov -0xc(%ebp),%eax 952: 83 c0 08 add $0x8,%eax 955: eb 38 jmp 98f <malloc+0xde> } if(p == freep) 957: a1 74 10 00 00 mov 0x1074,%eax 95c: 39 45 f4 cmp %eax,-0xc(%ebp) 95f: 75 1b jne 97c <malloc+0xcb> if((p = morecore(nunits)) == 0) 961: 8b 45 ec mov -0x14(%ebp),%eax 964: 89 04 24 mov %eax,(%esp) 967: e8 ed fe ff ff call 859 <morecore> 96c: 89 45 f4 mov %eax,-0xc(%ebp) 96f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 973: 75 07 jne 97c <malloc+0xcb> return 0; 975: b8 00 00 00 00 mov $0x0,%eax 97a: eb 13 jmp 98f <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){ 97c: 8b 45 f4 mov -0xc(%ebp),%eax 97f: 89 45 f0 mov %eax,-0x10(%ebp) 982: 8b 45 f4 mov -0xc(%ebp),%eax 985: 8b 00 mov (%eax),%eax 987: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 98a: e9 70 ff ff ff jmp 8ff <malloc+0x4e> } 98f: c9 leave 990: c3 ret 991: 66 90 xchg %ax,%ax 993: 90 nop 00000994 <xchg>: asm volatile("sti"); } static inline uint xchg(volatile uint *addr, uint newval) { 994: 55 push %ebp 995: 89 e5 mov %esp,%ebp 997: 83 ec 10 sub $0x10,%esp uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 99a: 8b 55 08 mov 0x8(%ebp),%edx 99d: 8b 45 0c mov 0xc(%ebp),%eax 9a0: 8b 4d 08 mov 0x8(%ebp),%ecx 9a3: f0 87 02 lock xchg %eax,(%edx) 9a6: 89 45 fc mov %eax,-0x4(%ebp) "+m" (*addr), "=a" (result) : "1" (newval) : "cc"); return result; 9a9: 8b 45 fc mov -0x4(%ebp),%eax } 9ac: c9 leave 9ad: c3 ret 000009ae <pthread_create>: #define NULL 0 #define PGSIZE (4096) int pthread_create(mpthread_t *thread, mpthread_attr_t *attr, void(*func)(void*), void*arg){ 9ae: 55 push %ebp 9af: 89 e5 mov %esp,%ebp 9b1: 83 ec 28 sub $0x28,%esp void *stack = malloc((uint)PGSIZE*2); 9b4: c7 04 24 00 20 00 00 movl $0x2000,(%esp) 9bb: e8 f1 fe ff ff call 8b1 <malloc> 9c0: 89 45 f4 mov %eax,-0xc(%ebp) if((uint)stack <= 0){ 9c3: 8b 45 f4 mov -0xc(%ebp),%eax 9c6: 85 c0 test %eax,%eax 9c8: 75 1b jne 9e5 <pthread_create+0x37> printf(1, "Malloc new stack failed in pthread_create\n"); 9ca: c7 44 24 04 64 0c 00 movl $0xc64,0x4(%esp) 9d1: 00 9d2: c7 04 24 01 00 00 00 movl $0x1,(%esp) 9d9: e8 e6 fb ff ff call 5c4 <printf> return -1; 9de: b8 ff ff ff ff mov $0xffffffff,%eax 9e3: eb 43 jmp a28 <pthread_create+0x7a> } if((uint)stack % PGSIZE){ 9e5: 8b 45 f4 mov -0xc(%ebp),%eax 9e8: 25 ff 0f 00 00 and $0xfff,%eax 9ed: 85 c0 test %eax,%eax 9ef: 74 14 je a05 <pthread_create+0x57> stack += 4096 - ((uint)stack % PGSIZE); 9f1: 8b 45 f4 mov -0xc(%ebp),%eax 9f4: 25 ff 0f 00 00 and $0xfff,%eax 9f9: 89 c2 mov %eax,%edx 9fb: b8 00 10 00 00 mov $0x1000,%eax a00: 29 d0 sub %edx,%eax a02: 01 45 f4 add %eax,-0xc(%ebp) } *thread = clone(func, arg, stack); a05: 8b 45 f4 mov -0xc(%ebp),%eax a08: 89 44 24 08 mov %eax,0x8(%esp) a0c: 8b 45 14 mov 0x14(%ebp),%eax a0f: 89 44 24 04 mov %eax,0x4(%esp) a13: 8b 45 10 mov 0x10(%ebp),%eax a16: 89 04 24 mov %eax,(%esp) a19: e8 a6 fa ff ff call 4c4 <clone> a1e: 8b 55 08 mov 0x8(%ebp),%edx a21: 89 02 mov %eax,(%edx) return *thread; a23: 8b 45 08 mov 0x8(%ebp),%eax a26: 8b 00 mov (%eax),%eax } a28: c9 leave a29: c3 ret 00000a2a <pthread_join>: int pthread_join(mpthread_t thread, void **retval){ a2a: 55 push %ebp a2b: 89 e5 mov %esp,%ebp a2d: 83 ec 28 sub $0x28,%esp void *stack; if(join((uint)thread, &stack)<0){ a30: 8d 45 f4 lea -0xc(%ebp),%eax a33: 89 44 24 04 mov %eax,0x4(%esp) a37: 8b 45 08 mov 0x8(%ebp),%eax a3a: 89 04 24 mov %eax,(%esp) a3d: e8 8a fa ff ff call 4cc <join> a42: 85 c0 test %eax,%eax a44: 79 07 jns a4d <pthread_join+0x23> return -1; a46: b8 ff ff ff ff mov $0xffffffff,%eax a4b: eb 10 jmp a5d <pthread_join+0x33> } free(stack); a4d: 8b 45 f4 mov -0xc(%ebp),%eax a50: 89 04 24 mov %eax,(%esp) a53: e8 20 fd ff ff call 778 <free> return 0; a58: b8 00 00 00 00 mov $0x0,%eax } a5d: c9 leave a5e: c3 ret 00000a5f <pthread_mutex_init>: void pthread_mutex_init(mpthread_mutex_t *mutex){ a5f: 55 push %ebp a60: 89 e5 mov %esp,%ebp *mutex = 0; a62: 8b 45 08 mov 0x8(%ebp),%eax a65: c7 00 00 00 00 00 movl $0x0,(%eax) return; a6b: 90 nop } a6c: 5d pop %ebp a6d: c3 ret 00000a6e <pthread_mutex_lock>: void pthread_mutex_lock(mpthread_mutex_t *mutex){ a6e: 55 push %ebp a6f: 89 e5 mov %esp,%ebp a71: 83 ec 08 sub $0x8,%esp while(xchg(mutex, 1) != 0); a74: 90 nop a75: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) a7c: 00 a7d: 8b 45 08 mov 0x8(%ebp),%eax a80: 89 04 24 mov %eax,(%esp) a83: e8 0c ff ff ff call 994 <xchg> a88: 85 c0 test %eax,%eax a8a: 75 e9 jne a75 <pthread_mutex_lock+0x7> return; a8c: 90 nop } a8d: c9 leave a8e: c3 ret 00000a8f <pthread_mutex_unlock>: void pthread_mutex_unlock(mpthread_mutex_t *mutex){ a8f: 55 push %ebp a90: 89 e5 mov %esp,%ebp a92: 83 ec 08 sub $0x8,%esp xchg(mutex, 0); a95: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) a9c: 00 a9d: 8b 45 08 mov 0x8(%ebp),%eax aa0: 89 04 24 mov %eax,(%esp) aa3: e8 ec fe ff ff call 994 <xchg> return; aa8: 90 nop } aa9: c9 leave aaa: c3 ret 00000aab <pthread_cond_init>: void pthread_cond_init(mpthread_cond_t *cond){ aab: 55 push %ebp aac: 89 e5 mov %esp,%ebp cond->threadId = -1; aae: 8b 45 08 mov 0x8(%ebp),%eax ab1: c7 00 ff ff ff ff movl $0xffffffff,(%eax) cond->next = NULL; ab7: 8b 45 08 mov 0x8(%ebp),%eax aba: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) return; ac1: 90 nop } ac2: 5d pop %ebp ac3: c3 ret 00000ac4 <pthread_cond_wait>: void pthread_cond_wait(mpthread_cond_t *cond, mpthread_mutex_t *mutex){ ac4: 55 push %ebp ac5: 89 e5 mov %esp,%ebp ac7: 53 push %ebx ac8: 83 ec 24 sub $0x24,%esp mpthread_cond_t *mycond = cond; acb: 8b 45 08 mov 0x8(%ebp),%eax ace: 89 45 f4 mov %eax,-0xc(%ebp) pthread_mutex_unlock(mutex); ad1: 8b 45 0c mov 0xc(%ebp),%eax ad4: 89 04 24 mov %eax,(%esp) ad7: e8 b3 ff ff ff call a8f <pthread_mutex_unlock> //iterate the linked-list pointer to the end; while(mycond->next != NULL) adc: eb 09 jmp ae7 <pthread_cond_wait+0x23> mycond = mycond->next; ade: 8b 45 f4 mov -0xc(%ebp),%eax ae1: 8b 40 04 mov 0x4(%eax),%eax ae4: 89 45 f4 mov %eax,-0xc(%ebp) void pthread_cond_wait(mpthread_cond_t *cond, mpthread_mutex_t *mutex){ mpthread_cond_t *mycond = cond; pthread_mutex_unlock(mutex); //iterate the linked-list pointer to the end; while(mycond->next != NULL) ae7: 8b 45 f4 mov -0xc(%ebp),%eax aea: 8b 40 04 mov 0x4(%eax),%eax aed: 85 c0 test %eax,%eax aef: 75 ed jne ade <pthread_cond_wait+0x1a> mycond = mycond->next; mycond->next = (mpthread_cond_t *)malloc(sizeof(mpthread_cond_t)); af1: c7 04 24 08 00 00 00 movl $0x8,(%esp) af8: e8 b4 fd ff ff call 8b1 <malloc> afd: 8b 55 f4 mov -0xc(%ebp),%edx b00: 89 42 04 mov %eax,0x4(%edx) mycond->next->threadId = getpid(); b03: 8b 45 f4 mov -0xc(%ebp),%eax b06: 8b 58 04 mov 0x4(%eax),%ebx b09: e8 8e f9 ff ff call 49c <getpid> b0e: 89 03 mov %eax,(%ebx) mycond->next->next = NULL; b10: 8b 45 f4 mov -0xc(%ebp),%eax b13: 8b 40 04 mov 0x4(%eax),%eax b16: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) pthread_mutex_lock(mutex); b1d: 8b 45 0c mov 0xc(%ebp),%eax b20: 89 04 24 mov %eax,(%esp) b23: e8 46 ff ff ff call a6e <pthread_mutex_lock> pthread_mutex_unlock(mutex); b28: 8b 45 0c mov 0xc(%ebp),%eax b2b: 89 04 24 mov %eax,(%esp) b2e: e8 5c ff ff ff call a8f <pthread_mutex_unlock> threadSleep(mutex); b33: 8b 45 0c mov 0xc(%ebp),%eax b36: 89 04 24 mov %eax,(%esp) b39: e8 96 f9 ff ff call 4d4 <threadSleep> pthread_mutex_lock(mutex); b3e: 8b 45 0c mov 0xc(%ebp),%eax b41: 89 04 24 mov %eax,(%esp) b44: e8 25 ff ff ff call a6e <pthread_mutex_lock> return; b49: 90 nop } b4a: 83 c4 24 add $0x24,%esp b4d: 5b pop %ebx b4e: 5d pop %ebp b4f: c3 ret 00000b50 <pthread_cond_signal>: void pthread_cond_signal(mpthread_cond_t *cond){ b50: 55 push %ebp b51: 89 e5 mov %esp,%ebp b53: 83 ec 28 sub $0x28,%esp mpthread_cond_t *mycond = cond; b56: 8b 45 08 mov 0x8(%ebp),%eax b59: 89 45 f4 mov %eax,-0xc(%ebp) while(mycond->threadId==-1) b5c: eb 09 jmp b67 <pthread_cond_signal+0x17> mycond = mycond->next; b5e: 8b 45 f4 mov -0xc(%ebp),%eax b61: 8b 40 04 mov 0x4(%eax),%eax b64: 89 45 f4 mov %eax,-0xc(%ebp) return; } void pthread_cond_signal(mpthread_cond_t *cond){ mpthread_cond_t *mycond = cond; while(mycond->threadId==-1) b67: 8b 45 f4 mov -0xc(%ebp),%eax b6a: 8b 00 mov (%eax),%eax b6c: 83 f8 ff cmp $0xffffffff,%eax b6f: 74 ed je b5e <pthread_cond_signal+0xe> mycond = mycond->next; if(mycond!=NULL){ b71: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) b75: 74 33 je baa <pthread_cond_signal+0x5a> int threadId = mycond->threadId; b77: 8b 45 f4 mov -0xc(%ebp),%eax b7a: 8b 00 mov (%eax),%eax b7c: 89 45 f0 mov %eax,-0x10(%ebp) mpthread_cond_t *garbage = mycond; b7f: 8b 45 f4 mov -0xc(%ebp),%eax b82: 89 45 ec mov %eax,-0x14(%ebp) cond->next = cond->next->next; b85: 8b 45 08 mov 0x8(%ebp),%eax b88: 8b 40 04 mov 0x4(%eax),%eax b8b: 8b 50 04 mov 0x4(%eax),%edx b8e: 8b 45 08 mov 0x8(%ebp),%eax b91: 89 50 04 mov %edx,0x4(%eax) free(garbage); b94: 8b 45 ec mov -0x14(%ebp),%eax b97: 89 04 24 mov %eax,(%esp) b9a: e8 d9 fb ff ff call 778 <free> threadWake(threadId); b9f: 8b 45 f0 mov -0x10(%ebp),%eax ba2: 89 04 24 mov %eax,(%esp) ba5: e8 32 f9 ff ff call 4dc <threadWake> } return; baa: 90 nop } bab: c9 leave bac: c3 ret 00000bad <pthread_sem_init>: void pthread_sem_init(mpthread_sem_t* sem, int flag, int value){ bad: 55 push %ebp bae: 89 e5 mov %esp,%ebp bb0: 83 ec 04 sub $0x4,%esp sem->value = value; bb3: 8b 45 08 mov 0x8(%ebp),%eax bb6: 8b 55 10 mov 0x10(%ebp),%edx bb9: 89 10 mov %edx,(%eax) pthread_cond_init(&sem->cond); bbb: 8b 45 08 mov 0x8(%ebp),%eax bbe: 83 c0 04 add $0x4,%eax bc1: 89 04 24 mov %eax,(%esp) bc4: e8 e2 fe ff ff call aab <pthread_cond_init> pthread_mutex_init(&sem->mutex); bc9: 8b 45 08 mov 0x8(%ebp),%eax bcc: 83 c0 0c add $0xc,%eax bcf: 89 04 24 mov %eax,(%esp) bd2: e8 88 fe ff ff call a5f <pthread_mutex_init> return; bd7: 90 nop } bd8: c9 leave bd9: c3 ret 00000bda <pthread_sem_wait>: void pthread_sem_wait(mpthread_sem_t* sem){ bda: 55 push %ebp bdb: 89 e5 mov %esp,%ebp bdd: 83 ec 18 sub $0x18,%esp sem->value --; be0: 8b 45 08 mov 0x8(%ebp),%eax be3: 8b 00 mov (%eax),%eax be5: 8d 50 ff lea -0x1(%eax),%edx be8: 8b 45 08 mov 0x8(%ebp),%eax beb: 89 10 mov %edx,(%eax) if(sem->value < 0){ bed: 8b 45 08 mov 0x8(%ebp),%eax bf0: 8b 00 mov (%eax),%eax bf2: 85 c0 test %eax,%eax bf4: 79 18 jns c0e <pthread_sem_wait+0x34> pthread_cond_wait(&sem->cond, &sem->mutex); bf6: 8b 45 08 mov 0x8(%ebp),%eax bf9: 8d 50 0c lea 0xc(%eax),%edx bfc: 8b 45 08 mov 0x8(%ebp),%eax bff: 83 c0 04 add $0x4,%eax c02: 89 54 24 04 mov %edx,0x4(%esp) c06: 89 04 24 mov %eax,(%esp) c09: e8 b6 fe ff ff call ac4 <pthread_cond_wait> } return; c0e: 90 nop } c0f: c9 leave c10: c3 ret 00000c11 <pthread_sem_post>: void pthread_sem_post(mpthread_sem_t* sem){ c11: 55 push %ebp c12: 89 e5 mov %esp,%ebp c14: 83 ec 18 sub $0x18,%esp sem->value ++; c17: 8b 45 08 mov 0x8(%ebp),%eax c1a: 8b 00 mov (%eax),%eax c1c: 8d 50 01 lea 0x1(%eax),%edx c1f: 8b 45 08 mov 0x8(%ebp),%eax c22: 89 10 mov %edx,(%eax) pthread_cond_signal(&sem->cond); c24: 8b 45 08 mov 0x8(%ebp),%eax c27: 83 c0 04 add $0x4,%eax c2a: 89 04 24 mov %eax,(%esp) c2d: e8 1e ff ff ff call b50 <pthread_cond_signal> return; c32: 90 nop } c33: c9 leave c34: c3 ret
; A063107: Dimension of the space of weight 2n cusp forms for Gamma_0( 39 ). ; 3,12,22,30,40,50,58,68,78,86,96,106,114,124,134,142,152,162,170,180,190,198,208,218,226,236,246,254,264,274,282,292,302,310,320,330,338,348,358,366,376,386,394,404,414,422,432,442,450,460 mov $1,$0 mul $1,28 div $1,3 mov $2,$0 cmp $2,0 add $0,$2 mod $0,3 add $0,$1 add $0,2
/* Before anyone kicks off, yes this file is based on shallan50k's library file I just dont like _ and prefer to use camel case */ .const sprite0X = $d000 .const sprite0Y = $d001 .const sprite_1_x = $d002 .const sprite_1_y = $d003 .const sprite_2_x = $d004 .const sprite_2_y = $d005 .const sprite_3_x = $d006 .const sprite_3_y = $d007 .const sprite_4_x = $d008 .const sprite_4_y = $d009 .const sprite_5_x = $d00a .const sprite_5_y = $d00b .const sprite_6_x = $d00c .const sprite_6_y = $d00d .const sprite_7_x = $d00e .const sprite_7_y = $d00f .const spriteXMSB = $d010 .const raster_y = $d012 .const spriteEnable = $d015 .const scrollControl = $d016 .const memorySetup = $d018 .const interrupt_control = $d01a .const spriteMulticolour = $d01c .const borderColour = $d020 .const backgroundColour = $d021 .const extended_bg_color_1 = $d022 .const extended_bg_color_2 = $d023 .const sprite_multicolor_1 = $d025 .const sprite_multicolor_2 = $d026 .const spriteColour0 = $d027 .const sprite_color_1 = $d028 .const sprite_color_2 = $d029 .const sprite_color_3 = $d02a .const sprite_color_4 = $d02b .const sprite_color_5 = $d02c .const sprite_color_6 = $d02d .const sprite_color_7 = $d02e .const screenRam = $c000 .const colourRam = $d800 .const spritePriority = $d01b .const sprite2SpriteCollision = $d01e .const spritePointers = screenRam + $3f8 .const joystickPort2 = $dc00 .const charMemory = $f000
/* * Copyright (C) 2005-2020 Centre National d'Etudes Spatiales (CNES) * * This file is part of Orfeo Toolbox * * https://www.orfeo-toolbox.org/ * * 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 "otbIkonosImageMetadataInterface.h" #include "otbStringUtils.h" #include "itkMetaDataObject.h" #include "otbImageKeywordlist.h" #include "itksys/SystemTools.hxx" #include "otbStringUtilities.h" namespace otb { bool IkonosImageMetadataInterface::CanRead() const { std::string sensorID = GetSensorID(); if (sensorID.find("IKONOS-2") != std::string::npos) return true; else return false; } IkonosImageMetadataInterface::VariableLengthVectorType IkonosImageMetadataInterface::GetSolarIrradiance() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } VariableLengthVectorType outputValuesVariableLengthVector; outputValuesVariableLengthVector.SetSize(1); if (!imageKeywordlist.HasKey("support_data.band_name")) { outputValuesVariableLengthVector[0] = -1; return outputValuesVariableLengthVector; } std::string keywordString = imageKeywordlist.GetMetadataByKey("support_data.band_name"); // values from geoeye // TODO are these the correct values ???? if (keywordString == "Pan") { outputValuesVariableLengthVector[0] = 1375.8; } else if (keywordString == "Blue") { outputValuesVariableLengthVector[0] = 1930.9; } else if (keywordString == "Green") { outputValuesVariableLengthVector[0] = 1854.8; } else if (keywordString == "Red") { outputValuesVariableLengthVector[0] = 1556.5; } else if (keywordString == "NIR") { outputValuesVariableLengthVector[0] = 1156.9; } return outputValuesVariableLengthVector; } int IkonosImageMetadataInterface::GetDay() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } if (!imageKeywordlist.HasKey("support_data.acquisition_date")) { return -1; } std::string valueString = imageKeywordlist.GetMetadataByKey("support_data.acquisition_date"); std::vector<std::string> outputValues; boost::split(outputValues, valueString, boost::is_any_of(" T:-")); if (outputValues.size() <= 2) itkExceptionMacro(<< "Invalid Day"); int value = atoi(outputValues[2].c_str()); return value; } int IkonosImageMetadataInterface::GetMonth() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } if (!imageKeywordlist.HasKey("support_data.acquisition_date")) { return -1; } std::string valueString = imageKeywordlist.GetMetadataByKey("support_data.acquisition_date"); std::vector<std::string> outputValues; boost::split(outputValues, valueString, boost::is_any_of(" T:-")); if (outputValues.size() <= 2) itkExceptionMacro(<< "Invalid Month"); int value = atoi(outputValues[1].c_str()); return value; } int IkonosImageMetadataInterface::GetYear() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } if (!imageKeywordlist.HasKey("support_data.acquisition_date")) { return -1; } std::string valueString = imageKeywordlist.GetMetadataByKey("support_data.acquisition_date"); std::vector<std::string> outputValues; boost::split(outputValues, valueString, boost::is_any_of(" T:-")); if (outputValues.size() <= 2) itkExceptionMacro(<< "Invalid Year"); int value = atoi(outputValues[0].c_str()); return value; } int IkonosImageMetadataInterface::GetHour() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } if (!imageKeywordlist.HasKey("support_data.acquisition_time")) { return -1; } std::string valueString = imageKeywordlist.GetMetadataByKey("support_data.acquisition_time"); std::vector<std::string> outputValues; boost::split(outputValues, valueString, boost::is_any_of(" T:-")); if (outputValues.size() < 2) itkExceptionMacro(<< "Invalid Hour"); int value = atoi(outputValues[0].c_str()); return value; } int IkonosImageMetadataInterface::GetMinute() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } if (!imageKeywordlist.HasKey("support_data.acquisition_time")) { return -1; } std::string valueString = imageKeywordlist.GetMetadataByKey("support_data.acquisition_time"); std::vector<std::string> outputValues; boost::split(outputValues, valueString, boost::is_any_of(" T:-")); if (outputValues.size() < 2) itkExceptionMacro(<< "Invalid Minute"); int value = atoi(outputValues[1].c_str()); return value; } int IkonosImageMetadataInterface::GetProductionDay() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } if (!imageKeywordlist.HasKey("support_data.production_date")) { return -1; } std::string valueString = imageKeywordlist.GetMetadataByKey("support_data.production_date"); std::vector<std::string> outputValues; boost::split(outputValues, valueString, boost::is_any_of(" T:-/")); if (outputValues.size() <= 2) itkExceptionMacro(<< "Invalid Day"); // MM/DD/YY int value = atoi(outputValues[1].c_str()); return value; } int IkonosImageMetadataInterface::GetProductionMonth() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } if (!imageKeywordlist.HasKey("support_data.production_date")) { return -1; } std::string valueString = imageKeywordlist.GetMetadataByKey("support_data.production_date"); std::vector<std::string> outputValues; boost::split(outputValues, valueString, boost::is_any_of(" T:-/")); if (outputValues.size() <= 2) itkExceptionMacro(<< "Invalid Month"); // MM/DD/YY int value = atoi(outputValues[0].c_str()); return value; } int IkonosImageMetadataInterface::GetProductionYear() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } if (!imageKeywordlist.HasKey("support_data.production_date")) { return -1; } std::string valueString = imageKeywordlist.GetMetadataByKey("support_data.production_date"); std::vector<std::string> outputValues; boost::split(outputValues, valueString, boost::is_any_of(" T:-/")); if (outputValues.size() <= 2) itkExceptionMacro(<< "Invalid Year"); // MM/DD/YY int year = atoi(outputValues[2].c_str()); if (year == 99) year += 1900; else year += 2000; return year; } IkonosImageMetadataInterface::VariableLengthVectorType IkonosImageMetadataInterface::GetPhysicalBias() const { if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } VariableLengthVectorType outputValuesVariableLengthVector; outputValuesVariableLengthVector.SetSize(GetNumberOfBands()); outputValuesVariableLengthVector.Fill(0.0); return outputValuesVariableLengthVector; } IkonosImageMetadataInterface::VariableLengthVectorType IkonosImageMetadataInterface::GetPhysicalGain() const { if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } int productionYear = this->GetProductionYear(); int productionMonth = this->GetProductionMonth(); int productionDay = this->GetProductionDay(); bool isPost20010122 = false; if ((productionDay + 100 * productionMonth + 10000 * productionYear) >= 20010122) { isPost20010122 = true; } // Value computed from // http://www.geoeye.com/CorpSite/assets/docs/technical-papers/2009/IKONOS_Esun_Calculations.pdf // to get the equivalent of the SPOT alpha VariableLengthVectorType gain; gain.SetSize(5); if (isPost20010122) { gain[0] = 6.48830; // Pan gain[1] = 5.19064; // Blue gain[2] = 6.44122; // Green gain[3] = 6.24442; // Red gain[4] = 8.04222; // NIR } else { gain[0] = 6.48830; // Pan gain[1] = 4.51329; // Blue gain[2] = 5.75014; // Green gain[3] = 5.52720; // Red gain[4] = 7.11684; // NIR } std::vector<std::string> bandName = GetBandName(); VariableLengthVectorType outputValuesVariableLengthVector; unsigned int numBands = GetNumberOfBands(); /** Tests if the number of bands in metadata are the same as bandName size*/ if (numBands != bandName.size()) { itkExceptionMacro(<< "Invalid number of bands..."); } outputValuesVariableLengthVector.SetSize(numBands); for (unsigned int i = 0; i < numBands; ++i) { if (bandName[i].find("Pan") != std::string::npos) outputValuesVariableLengthVector[i] = gain[0]; if (bandName[i].find("Blue") != std::string::npos) outputValuesVariableLengthVector[i] = gain[1]; if (bandName[i].find("Green") != std::string::npos) outputValuesVariableLengthVector[i] = gain[2]; if (bandName[i].find("Red") != std::string::npos) outputValuesVariableLengthVector[i] = gain[3]; if (bandName[i].find("NIR") != std::string::npos) outputValuesVariableLengthVector[i] = gain[4]; } return outputValuesVariableLengthVector; } double IkonosImageMetadataInterface::GetSatElevation() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } if (!imageKeywordlist.HasKey("support_data.nominal_collection_elevation_angle")) { return 0; } std::string valueString = imageKeywordlist.GetMetadataByKey("support_data.nominal_collection_elevation_angle"); double value = atof(valueString.c_str()); return value; } double IkonosImageMetadataInterface::GetSatAzimuth() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } if (!imageKeywordlist.HasKey("support_data.nominal_collection_azimuth_angle")) { return 0; } std::string valueString = imageKeywordlist.GetMetadataByKey("support_data.nominal_collection_azimuth_angle"); double value = atof(valueString.c_str()); return value; } IkonosImageMetadataInterface::VariableLengthVectorType IkonosImageMetadataInterface::GetFirstWavelengths() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } VariableLengthVectorType wavel(1); wavel.Fill(0.); int nbBands = this->GetNumberOfBands(); // Panchromatic case if (nbBands == 1) { wavel.SetSize(1); wavel.Fill(0.526); } else if (nbBands == 4) { wavel.SetSize(4); wavel[0] = 0.445; wavel[1] = 0.506; wavel[2] = 0.632; wavel[3] = 0.757; } else itkExceptionMacro(<< "Invalid number of bands..."); return wavel; } IkonosImageMetadataInterface::VariableLengthVectorType IkonosImageMetadataInterface::GetLastWavelengths() const { const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); if (!this->CanRead()) { itkExceptionMacro(<< "Invalid Metadata, no Ikonos Image"); } ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); } VariableLengthVectorType wavel(1); wavel.Fill(0.); int nbBands = this->GetNumberOfBands(); // Panchromatic case if (nbBands == 1) { wavel.SetSize(1); wavel.Fill(0.929); } else if (nbBands == 4) { wavel.SetSize(4); wavel[0] = 0.516; wavel[1] = 0.595; wavel[2] = 0.698; wavel[3] = 0.853; } else itkExceptionMacro(<< "Invalid number of bands..."); return wavel; } std::vector<unsigned int> IkonosImageMetadataInterface::GetDefaultDisplay() const { std::vector<unsigned int> rgb(3); rgb[0] = 2; rgb[1] = 1; rgb[2] = 0; return rgb; } std::vector<std::string> IkonosImageMetadataInterface::GetEnhancedBandNames() const { // Already done for the current file return this->Superclass::GetBandName(); } IkonosImageMetadataInterface::WavelengthSpectralBandVectorType IkonosImageMetadataInterface::GetSpectralSensitivity() const { // TODO tabulate spectral responses WavelengthSpectralBandVectorType wavelengthSpectralBand = InternalWavelengthSpectralBandVectorType::New(); std::vector<std::string> bandName = GetBandName(); unsigned int numBands = GetNumberOfBands(); /** Tests if the number of bands in metadata are the same as bandName size*/ if (numBands != bandName.size()) { itkExceptionMacro(<< "Invalid number of bands..."); } for (unsigned int i = 0; i < numBands; ++i) { float b0[275]; if (bandName[i].find("Pan") != std::string::npos) { const float tmp[275] = { 0.000777411f, 0.000698442f, 0.000619473f, 0.000490086f, 0.000360699f, 0.000302118f, 0.000243538f, 0.000339101f, 0.000434664f, 0.000674356f, 0.000914047f, 0.00165711f, 0.00240018f, 0.00382524f, 0.00525031f, 0.00774772f, 0.0102451f, 0.0136149f, 0.0169847f, 0.0216852f, 0.0263858f, 0.0322139f, 0.0380419f, 0.0451535f, 0.052265f, 0.059372f, 0.066479f, 0.0749836f, 0.0834881f, 0.0922321f, 0.100976f, 0.11238f, 0.123783f, 0.135806f, 0.147828f, 0.158671f, 0.169515f, 0.181498f, 0.193481f, 0.199257f, 0.205034f, 0.224842f, 0.24465f, 0.252955f, 0.26126f, 0.271512f, 0.281764f, 0.291251f, 0.300738f, 0.30953f, 0.318322f, 0.321402f, 0.324481f, 0.329386f, 0.33429f, 0.338595f, 0.342899f, 0.346889f, 0.350879f, 0.354954f, 0.359028f, 0.366986f, 0.374944f, 0.383555f, 0.392166f, 0.407887f, 0.423609f, 0.439638f, 0.455668f, 0.472286f, 0.488904f, 0.509193f, 0.529483f, 0.549106f, 0.56873f, 0.592408f, 0.616086f, 0.639134f, 0.662182f, 0.680563f, 0.698943f, 0.720886f, 0.742829f, 0.764357f, 0.785886f, 0.805496f, 0.825106f, 0.843924f, 0.862743f, 0.882061f, 0.901379f, 0.923168f, 0.944958f, 0.948979f, 0.952999f, 0.960789f, 0.968579f, 0.973284f, 0.977989f, 0.972502f, 0.967015f, 0.980472f, 0.993929f, 0.993271f, 0.992614f, 0.988076f, 0.983538f, 0.991769f, 1.0f, 0.996457f, 0.992914f, 0.996456f, 0.999998f, 0.993659f, 0.98732f, 0.980205f, 0.973089f, 0.957487f, 0.941886f, 0.939394f, 0.936901f, 0.920086f, 0.90327f, 0.895178f, 0.887086f, 0.878162f, 0.869238f, 0.876515f, 0.883791f, 0.883182f, 0.882573f, 0.883526f, 0.884479f, 0.889877f, 0.895275f, 0.895902f, 0.89653f, 0.911267f, 0.926004f, 0.924618f, 0.923232f, 0.91542f, 0.907607f, 0.904518f, 0.90143f, 0.903022f, 0.904613f, 0.902261f, 0.899908f, 0.893658f, 0.887407f, 0.890136f, 0.892866f, 0.889693f, 0.88652f, 0.892279f, 0.898039f, 0.904587f, 0.911135f, 0.927581f, 0.944026f, 0.951458f, 0.95889f, 0.947059f, 0.935229f, 0.946541f, 0.957854f, 0.965818f, 0.973781f, 0.973879f, 0.973978f, 0.971217f, 0.968457f, 0.96373f, 0.959003f, 0.95437f, 0.949736f, 0.932402f, 0.915067f, 0.906743f, 0.898418f, 0.90573f, 0.913042f, 0.923885f, 0.934728f, 0.931538f, 0.928349f, 0.934038f, 0.939728f, 0.923287f, 0.906846f, 0.914615f, 0.922384f, 0.929317f, 0.93625f, 0.943838f, 0.951427f, 0.948289f, 0.945151f, 0.949082f, 0.953013f, 0.938094f, 0.923176f, 0.921154f, 0.919132f, 0.890009f, 0.860885f, 0.867236f, 0.873588f, 0.850292f, 0.826995f, 0.817882f, 0.808768f, 0.800406f, 0.792044f, 0.777065f, 0.762087f, 0.755304f, 0.748521f, 0.727815f, 0.707108f, 0.696978f, 0.686848f, 0.68378f, 0.680711f, 0.675044f, 0.669377f, 0.641688f, 0.613999f, 0.596144f, 0.578289f, 0.567037f, 0.555785f, 0.536112f, 0.516439f, 0.498523f, 0.480606f, 0.475695f, 0.470783f, 0.452628f, 0.434473f, 0.415006f, 0.395538f, 0.373581f, 0.351624f, 0.344258f, 0.336893f, 0.323178f, 0.309463f, 0.296963f, 0.284464f, 0.277545f, 0.270627f, 0.259838f, 0.249049f, 0.242783f, 0.236516f, 0.226031f, 0.215545f, 0.205517f, 0.195489f, 0.187778f, 0.180066f, 0.172017f, 0.163968f, 0.156649f, 0.14933f, 0.142851f, 0.136372f, 0.127527f, 0.118682f, 0.111158f, 0.103634f, 0.0963653f, 0.0f}; for (unsigned int j = 0; j < 275; ++j) { b0[j] = tmp[j]; } } else if (bandName[i].find("Blue") != std::string::npos) { const float tmp[275] = { 0.000773147f, 0.00111792f, 0.00146269f, 0.00116425f, 0.000865817f, 0.000798356f, 0.000730896f, 0.000724069f, 0.000717243f, 0.000983961f, 0.00125068f, 0.00147711f, 0.00170354f, 0.00181267f, 0.0019218f, 0.00235592f, 0.00279004f, 0.00398685f, 0.00518366f, 0.00642842f, 0.00767318f, 0.00823188f, 0.00879058f, 0.0103296f, 0.0118686f, 0.0146603f, 0.017452f, 0.0262281f, 0.0350041f, 0.0602011f, 0.085398f, 0.139163f, 0.192928f, 0.261737f, 0.330546f, 0.375015f, 0.419484f, 0.463835f, 0.508186f, 0.560708f, 0.613231f, 0.643718f, 0.674206f, 0.697319f, 0.720432f, 0.740631f, 0.760831f, 0.760468f, 0.760104f, 0.77422f, 0.788336f, 0.822457f, 0.856578f, 0.872968f, 0.889358f, 0.916497f, 0.943636f, 0.971818f, 1.0f, 0.993393f, 0.986786f, 0.956164f, 0.925542f, 0.843438f, 0.761333f, 0.651888f, 0.542443f, 0.428187f, 0.31393f, 0.259011f, 0.204092f, 0.178009f, 0.151925f, 0.118774f, 0.0856216f, 0.0643982f, 0.0431748f, 0.0370744f, 0.030974f, 0.0288085f, 0.0266429f, 0.0243978f, 0.0221527f, 0.0221454f, 0.0221381f, 0.0241802f, 0.0262224f, 0.027894f, 0.0295655f, 0.0282719f, 0.0269782f, 0.0247994f, 0.0226207f, 0.0240241f, 0.0254275f, 0.0279644f, 0.0305013f, 0.0289285f, 0.0273557f, 0.0243127f, 0.0212697f, 0.021495f, 0.0217203f, 0.0256572f, 0.0295941f, 0.0319082f, 0.0342224f, 0.0306457f, 0.027069f, 0.0232825f, 0.019496f, 0.0194953f, 0.0194945f, 0.019262f, 0.0190295f, 0.0165004f, 0.0139713f, 0.0106605f, 0.00734963f, 0.00665076f, 0.00595189f, 0.00555088f, 0.00514986f, 0.00651302f, 0.00787617f, 0.0101045f, 0.0123327f, 0.0161468f, 0.0199609f, 0.0210092f, 0.0220576f, 0.021422f, 0.0207864f, 0.0198958f, 0.0190052f, 0.0172422f, 0.0154792f, 0.012607f, 0.00973489f, 0.00827171f, 0.00680854f, 0.00586579f, 0.00492304f, 0.00515291f, 0.00538278f, 0.00845239f, 0.011522f, 0.0168842f, 0.0222464f, 0.0231172f, 0.023988f, 0.0180264f, 0.0120648f, 0.0080432f, 0.00402165f, 0.00311771f, 0.00221378f, 0.00238421f, 0.00255463f, 0.00240824f, 0.00226184f, 0.00286143f, 0.00346102f, 0.00296337f, 0.00246571f, 0.00239388f, 0.00232204f, 0.00315372f, 0.0039854f, 0.0037969f, 0.00360839f, 0.00315481f, 0.00270124f, 0.00254147f, 0.0023817f, 0.00250869f, 0.00263568f, 0.00244201f, 0.00224833f, 0.00192361f, 0.00159888f, 0.00157883f, 0.00155879f, 0.00177376f, 0.00198873f, 0.00199198f, 0.00199522f, 0.00225955f, 0.00252388f, 0.00306228f, 0.00360067f, 0.00461183f, 0.00562299f, 0.00610986f, 0.00659673f, 0.00707311f, 0.00754949f, 0.00775649f, 0.00796349f, 0.00871715f, 0.00947081f, 0.00887752f, 0.00828423f, 0.00852913f, 0.00877403f, 0.00901617f, 0.00925831f, 0.00995926f, 0.0106602f, 0.0115813f, 0.0125024f, 0.0128068f, 0.0131113f, 0.0130847f, 0.0130581f, 0.0124604f, 0.0118627f, 0.0111828f, 0.0105029f, 0.00998883f, 0.00947476f, 0.00913233f, 0.00878991f, 0.00859062f, 0.00839133f, 0.00830986f, 0.0082284f, 0.00812489f, 0.00802138f, 0.00818694f, 0.0083525f, 0.00823223f, 0.00811195f, 0.00805303f, 0.00799411f, 0.00800437f, 0.00801463f, 0.00743377f, 0.00685291f, 0.00615093f, 0.00544896f, 0.00512429f, 0.00479963f, 0.00463363f, 0.00446762f, 0.00428193f, 0.00409623f, 0.00384906f, 0.00360189f, 0.00353085f, 0.00345981f, 0.00336041f, 0.00326101f, 0.00300593f, 0.00275086f, 0.00278287f, 0.00281488f, 0.00259549f, 0.00237609f, 0.00236111f, 0.00234613f, 0.00248306f, 0.00261998f, 0.00263357f, 0.00264716f, 0.0026242f, 0.00260124f, 0.00210138f, 0.00160152f, 0.00177352f, 0.00194551f, 0.00218138f, 0.00241724f, 0.00185843f, 0.0f}; for (unsigned int j = 0; j < 275; ++j) { b0[j] = tmp[j]; } } else if (bandName[i].find("Green") != std::string::npos) { const float tmp[275] = { 0.000643373f, 0.000721567f, 0.000799761f, 0.000764593f, 0.000729425f, 0.000767756f, 0.000806087f, 0.000691702f, 0.000577317f, 0.000709642f, 0.000841967f, 0.000741458f, 0.000640949f, 0.000754853f, 0.000868757f, 0.000732192f, 0.000595627f, 0.000952731f, 0.00130983f, 0.00125601f, 0.00120219f, 0.00194445f, 0.00268671f, 0.00183813f, 0.000989541f, 0.00113105f, 0.00127256f, 0.00160875f, 0.00194493f, 0.00229841f, 0.00265189f, 0.00301361f, 0.00337532f, 0.00370611f, 0.00403689f, 0.00486952f, 0.00570216f, 0.00738653f, 0.0090709f, 0.010205f, 0.011339f, 0.0113175f, 0.011296f, 0.0121669f, 0.0130378f, 0.0151163f, 0.0171948f, 0.0208267f, 0.0244586f, 0.0305813f, 0.036704f, 0.0434839f, 0.0502638f, 0.0565094f, 0.0627551f, 0.0860566f, 0.109358f, 0.151232f, 0.193107f, 0.242087f, 0.291067f, 0.365317f, 0.439568f, 0.545145f, 0.650723f, 0.728637f, 0.806551f, 0.839149f, 0.871746f, 0.88005f, 0.888355f, 0.889065f, 0.889775f, 0.882352f, 0.874928f, 0.863518f, 0.852108f, 0.872214f, 0.89232f, 0.944994f, 0.997669f, 0.981902f, 0.966134f, 0.936936f, 0.907737f, 0.900477f, 0.893218f, 0.919539f, 0.94586f, 0.971546f, 0.997232f, 0.978528f, 0.959823f, 0.918631f, 0.877439f, 0.813588f, 0.749737f, 0.625854f, 0.50197f, 0.392566f, 0.283162f, 0.22152f, 0.159878f, 0.133355f, 0.106831f, 0.0946597f, 0.0824881f, 0.0732495f, 0.0640108f, 0.0556904f, 0.0473701f, 0.039668f, 0.031966f, 0.0273263f, 0.0226867f, 0.0196283f, 0.0165699f, 0.0155271f, 0.0144843f, 0.0146602f, 0.0148362f, 0.0155289f, 0.0162216f, 0.0174317f, 0.0186418f, 0.0192574f, 0.019873f, 0.0193336f, 0.0187943f, 0.0169768f, 0.0151594f, 0.0138395f, 0.0125197f, 0.0122022f, 0.0118846f, 0.0113754f, 0.0108661f, 0.0122059f, 0.0135457f, 0.0150274f, 0.0165092f, 0.0174059f, 0.0183026f, 0.0170915f, 0.0158804f, 0.0135402f, 0.0112001f, 0.00877389f, 0.00634772f, 0.00592819f, 0.00550866f, 0.00444963f, 0.0033906f, 0.00363493f, 0.00387926f, 0.00369547f, 0.00351167f, 0.00323999f, 0.0029683f, 0.00304107f, 0.00311383f, 0.00269225f, 0.00227067f, 0.00285765f, 0.00344463f, 0.0035057f, 0.00356676f, 0.00444226f, 0.00531776f, 0.00591164f, 0.00650553f, 0.00683137f, 0.00715721f, 0.00801677f, 0.00887633f, 0.00920412f, 0.0095319f, 0.00876825f, 0.00800459f, 0.00751842f, 0.00703224f, 0.00673578f, 0.00643931f, 0.00627542f, 0.00611152f, 0.00586377f, 0.00561602f, 0.00543874f, 0.00526147f, 0.0057041f, 0.00614673f, 0.00676773f, 0.00738874f, 0.00702707f, 0.00666541f, 0.0066904f, 0.0067154f, 0.00807246f, 0.00942952f, 0.0111187f, 0.0128079f, 0.0135393f, 0.0142706f, 0.015097f, 0.0159234f, 0.0165052f, 0.017087f, 0.0171597f, 0.0172324f, 0.0167555f, 0.0162786f, 0.0157604f, 0.0152423f, 0.0143205f, 0.0133987f, 0.0126828f, 0.0119669f, 0.0112674f, 0.0105679f, 0.0102702f, 0.00997248f, 0.00958224f, 0.009192f, 0.00947248f, 0.00975296f, 0.00932626f, 0.00889956f, 0.00866396f, 0.00842837f, 0.0081121f, 0.00779583f, 0.00765918f, 0.00752253f, 0.00724579f, 0.00696906f, 0.0064155f, 0.00586195f, 0.00563761f, 0.00541328f, 0.00499098f, 0.00456868f, 0.00425882f, 0.00394895f, 0.00377609f, 0.00360322f, 0.00343181f, 0.00326041f, 0.00310311f, 0.00294581f, 0.00285307f, 0.00276034f, 0.00277242f, 0.0027845f, 0.00250953f, 0.00223456f, 0.00235165f, 0.00246875f, 0.00235075f, 0.00223275f, 0.00238435f, 0.00253594f, 0.00230124f, 0.00206653f, 0.00190024f, 0.00173395f, 0.00191697f, 0.00209999f, 0.00206986f, 0.00203973f, 0.002129f, 0.00221828f, 0.00179734f, 0.00137641f, 0.00148945f, 0.0f}; for (unsigned int j = 0; j < 275; ++j) { b0[j] = tmp[j]; } } else if (bandName[i].find("Red") != std::string::npos) { const float tmp[275] = { 0.0f, 0.000251974f, 0.000503948f, 0.000447294f, 0.000390639f, 0.000493587f, 0.000596534f, 0.000462484f, 0.000328434f, 0.000587581f, 0.000846728f, 0.000748537f, 0.000650345f, 0.000516444f, 0.000382543f, 0.000939994f, 0.00149745f, 0.00175874f, 0.00202003f, 0.00252033f, 0.00302063f, 0.00326826f, 0.00351589f, 0.00376182f, 0.00400775f, 0.00406784f, 0.00412793f, 0.00595608f, 0.00778423f, 0.0080879f, 0.00839158f, 0.00829197f, 0.00819236f, 0.00662469f, 0.00505701f, 0.00383289f, 0.00260876f, 0.00345153f, 0.00429429f, 0.00487448f, 0.00545468f, 0.00545833f, 0.00546199f, 0.00418794f, 0.00291388f, 0.00230581f, 0.00169773f, 0.00162001f, 0.0015423f, 0.00259185f, 0.00364139f, 0.00396142f, 0.00428144f, 0.00339831f, 0.00251517f, 0.00227348f, 0.00203179f, 0.00167973f, 0.00132766f, 0.00141316f, 0.00149866f, 0.00150402f, 0.00150938f, 0.0018186f, 0.00212782f, 0.00224531f, 0.0023628f, 0.0025393f, 0.0027158f, 0.00304882f, 0.00338183f, 0.00312524f, 0.00286866f, 0.00286392f, 0.00285919f, 0.00345904f, 0.0040589f, 0.00503972f, 0.00602055f, 0.00659323f, 0.00716591f, 0.00825183f, 0.00933776f, 0.00929585f, 0.00925395f, 0.00899875f, 0.00874355f, 0.00912988f, 0.0095162f, 0.00993024f, 0.0103443f, 0.0118352f, 0.0133262f, 0.0168796f, 0.020433f, 0.0244432f, 0.0284535f, 0.0315921f, 0.0347306f, 0.0387702f, 0.0428098f, 0.0501643f, 0.0575189f, 0.0714861f, 0.0854534f, 0.105156f, 0.124858f, 0.150634f, 0.17641f, 0.217427f, 0.258444f, 0.338645f, 0.418847f, 0.528481f, 0.638116f, 0.721314f, 0.804512f, 0.841436f, 0.87836f, 0.898975f, 0.91959f, 0.936413f, 0.953235f, 0.954545f, 0.955856f, 0.942354f, 0.928852f, 0.933873f, 0.938894f, 0.962762f, 0.98663f, 0.991712f, 0.996794f, 0.952358f, 0.907922f, 0.838837f, 0.769753f, 0.68084f, 0.591927f, 0.506722f, 0.421517f, 0.363416f, 0.305314f, 0.265769f, 0.226224f, 0.192279f, 0.158334f, 0.131456f, 0.104578f, 0.0859652f, 0.067352f, 0.0560433f, 0.0447347f, 0.0373336f, 0.0299325f, 0.0269409f, 0.0239493f, 0.0229628f, 0.0219762f, 0.0201699f, 0.0183636f, 0.0171332f, 0.0159029f, 0.0160653f, 0.0162278f, 0.0159488f, 0.0156697f, 0.0160819f, 0.0164941f, 0.0168042f, 0.0171144f, 0.0167051f, 0.0162959f, 0.0141966f, 0.0120973f, 0.0105832f, 0.00906906f, 0.00792008f, 0.0067711f, 0.00649551f, 0.00621991f, 0.00588748f, 0.00555504f, 0.00486398f, 0.00417292f, 0.00419873f, 0.00422454f, 0.00461445f, 0.00500436f, 0.00449582f, 0.00398727f, 0.00397629f, 0.00396531f, 0.00332414f, 0.00268297f, 0.00284406f, 0.00300515f, 0.00277493f, 0.00254471f, 0.00290075f, 0.00325678f, 0.00290726f, 0.00255773f, 0.00259229f, 0.00262684f, 0.00269255f, 0.00275825f, 0.00271562f, 0.00267299f, 0.00275871f, 0.00284443f, 0.00269768f, 0.00255094f, 0.00257098f, 0.00259103f, 0.00253264f, 0.00247425f, 0.00242522f, 0.00237619f, 0.00235338f, 0.00233057f, 0.00261103f, 0.00289149f, 0.0028024f, 0.00271332f, 0.00290319f, 0.00309306f, 0.00350249f, 0.00391192f, 0.00395984f, 0.00400776f, 0.00401089f, 0.00401403f, 0.0037349f, 0.00345576f, 0.00305136f, 0.00264696f, 0.00241812f, 0.00218929f, 0.00191393f, 0.00163858f, 0.00153304f, 0.00142751f, 0.00137032f, 0.00131312f, 0.00134518f, 0.00137723f, 0.0012429f, 0.00110858f, 0.00114136f, 0.00117415f, 0.00116687f, 0.00115959f, 0.00108165f, 0.00100371f, 0.00131319f, 0.00162267f, 0.00130164f, 0.000980609f, 0.00115412f, 0.00132762f, 0.0013807f, 0.00143378f, 0.00218704f, 0.00294031f, 0.00234605f, 0.00175179f, 0.0020462f, 0.0023406f, 0.00180012f, 0.00125963f, 0.00107872f, 0.000897814f, 0.000448907f, 0.0f}; for (unsigned int j = 0; j < 275; ++j) { b0[j] = tmp[j]; } } else if (bandName[i].find("NIR") != std::string::npos) { const float tmp[275] = { 0.000894394f, 0.000713315f, 0.000532235f, 0.000603058f, 0.000673881f, 0.000760361f, 0.00084684f, 0.000787802f, 0.000728763f, 0.000817305f, 0.000905846f, 0.000904774f, 0.000903701f, 0.00160409f, 0.00230447f, 0.00221407f, 0.00212367f, 0.00314219f, 0.00416071f, 0.00470014f, 0.00523956f, 0.00641267f, 0.00758578f, 0.0090575f, 0.0105292f, 0.0156041f, 0.0206791f, 0.027643f, 0.0346069f, 0.0395911f, 0.0445753f, 0.0408266f, 0.0370779f, 0.0276002f, 0.0181225f, 0.017135f, 0.0161476f, 0.0168906f, 0.0176337f, 0.0172355f, 0.0168373f, 0.0168014f, 0.0167656f, 0.0178122f, 0.0188588f, 0.0165949f, 0.0143311f, 0.0120729f, 0.0098147f, 0.0125599f, 0.0153051f, 0.0187014f, 0.0220978f, 0.0244686f, 0.0268393f, 0.0270579f, 0.0272765f, 0.0223541f, 0.0174318f, 0.0124528f, 0.00747381f, 0.00633578f, 0.00519774f, 0.00546479f, 0.00573183f, 0.00496663f, 0.00420143f, 0.00375248f, 0.00330354f, 0.00289353f, 0.00248353f, 0.00252329f, 0.00256304f, 0.00431351f, 0.00606397f, 0.00864978f, 0.0112356f, 0.0122617f, 0.0132878f, 0.0113116f, 0.00933533f, 0.00834238f, 0.00734942f, 0.00698854f, 0.00662766f, 0.00662135f, 0.00661504f, 0.00802641f, 0.00943779f, 0.0113662f, 0.0132947f, 0.0126595f, 0.0120243f, 0.00943568f, 0.0068471f, 0.00523536f, 0.00362362f, 0.00341318f, 0.00320274f, 0.00318157f, 0.00316041f, 0.00303014f, 0.00289988f, 0.00349364f, 0.0040874f, 0.00427183f, 0.00445627f, 0.00425418f, 0.0040521f, 0.00432398f, 0.00459586f, 0.00500329f, 0.00541072f, 0.0052616f, 0.00511248f, 0.00619044f, 0.0072684f, 0.007209f, 0.0071496f, 0.00780861f, 0.00846762f, 0.0103595f, 0.0122514f, 0.014548f, 0.0168445f, 0.0180774f, 0.0193103f, 0.0203458f, 0.0213814f, 0.021739f, 0.0220966f, 0.0227061f, 0.0233155f, 0.0241796f, 0.0250438f, 0.0249493f, 0.0248548f, 0.0257403f, 0.0266259f, 0.0274829f, 0.0283399f, 0.0315445f, 0.034749f, 0.0392491f, 0.0437491f, 0.0488567f, 0.0539644f, 0.0651598f, 0.0763552f, 0.0905082f, 0.104661f, 0.125801f, 0.146941f, 0.17194f, 0.196939f, 0.22805f, 0.25916f, 0.283963f, 0.308767f, 0.332943f, 0.357119f, 0.400422f, 0.443726f, 0.504385f, 0.565045f, 0.633202f, 0.701359f, 0.76896f, 0.83656f, 0.889646f, 0.942732f, 0.971366f, 1.0f, 0.997999f, 0.995998f, 0.963345f, 0.930691f, 0.881401f, 0.832111f, 0.811504f, 0.790896f, 0.782153f, 0.773411f, 0.768032f, 0.762653f, 0.735848f, 0.709043f, 0.707354f, 0.705666f, 0.697871f, 0.690076f, 0.672979f, 0.655882f, 0.638978f, 0.622073f, 0.601538f, 0.581002f, 0.557459f, 0.533915f, 0.524241f, 0.514567f, 0.501153f, 0.487739f, 0.452918f, 0.418097f, 0.370059f, 0.32202f, 0.285355f, 0.248689f, 0.209974f, 0.171259f, 0.142537f, 0.113816f, 0.092517f, 0.0712178f, 0.0646218f, 0.0580258f, 0.050796f, 0.0435662f, 0.0353664f, 0.0271667f, 0.0232974f, 0.0194282f, 0.0176517f, 0.0158752f, 0.0144977f, 0.0131202f, 0.0118952f, 0.0106703f, 0.0101536f, 0.00963684f, 0.00921561f, 0.00879438f, 0.00794162f, 0.00708886f, 0.00654941f, 0.00600996f, 0.00563429f, 0.00525862f, 0.00510421f, 0.00494981f, 0.00454041f, 0.00413101f, 0.00410078f, 0.00407056f, 0.00396389f, 0.00385722f, 0.00364911f, 0.00344101f, 0.00333006f, 0.00321911f, 0.00300415f, 0.00278918f, 0.00317632f, 0.00356346f, 0.00312642f, 0.00268937f, 0.00260112f, 0.00251287f, 0.00263123f, 0.00274958f, 0.00362147f, 0.00449336f, 0.00413978f, 0.0037862f, 0.0028968f, 0.0020074f, 0.00190022f, 0.00179303f, 0.00227357f, 0.0027541f, 0.00137705f, 0.0f, 0.0f, 0.0f}; for (unsigned int j = 0; j < 275; ++j) { b0[j] = tmp[j]; } } else { itkExceptionMacro(<< "Invalid band name..."); } // create wavelength band vector const std::vector<float> vb0(b0, b0 + sizeof(b0) / sizeof(float)); wavelengthSpectralBand->PushBack(FilterFunctionValues::New()); wavelengthSpectralBand->GetNthElement(i)->SetFilterFunctionValues(vb0); wavelengthSpectralBand->GetNthElement(i)->SetMinSpectralValue(0.350); wavelengthSpectralBand->GetNthElement(i)->SetMaxSpectralValue(1.035); wavelengthSpectralBand->GetNthElement(i)->SetUserStep(0.0025); } return wavelengthSpectralBand; } namespace { template<class T> bool ContainsIkonosMetadata(const T & associativeContainer) { const auto pastTheEnd = associativeContainer.end(); return associativeContainer.find("productionDate") != pastTheEnd && associativeContainer.find("sensorID") != pastTheEnd && associativeContainer.find("nominalCollectionAzimuth") != pastTheEnd && associativeContainer.find("nominalCollectionElevation") != pastTheEnd && associativeContainer.find("sunAzimuth")!= pastTheEnd && associativeContainer.find("sunElevation") != pastTheEnd && associativeContainer.find("acquisitionDate") != pastTheEnd; } // Read Ikonos metadata from a geom file template<class T> void ParseGeomFile(const MetadataSupplierInterface & mds, T& metadataAssociativeContainer) { metadataAssociativeContainer["productionDate"] = mds.GetAs<std::string>("support_data.production_date"); metadataAssociativeContainer["sensorID"] = mds.GetAs<std::string>("support_data.sensor"); metadataAssociativeContainer["nominalCollectionAzimuth"] = mds.GetAs<std::string>("support_data.nominal_collection_azimuth_angle"); metadataAssociativeContainer["nominalCollectionElevation"] = mds.GetAs<std::string>("support_data.nominal_collection_elevation_angle"); metadataAssociativeContainer["sunAzimuth"] = mds.GetAs<std::string>("support_data.azimuth_angle"); metadataAssociativeContainer["sunElevation"] = mds.GetAs<std::string>("support_data.elevation_angle"); metadataAssociativeContainer["acquisitionDate"] = mds.GetAs<std::string>("support_data.acquisition_date"); metadataAssociativeContainer["acquisitionTime"] = mds.GetAs<std::string>("support_data.acquisition_time"); metadataAssociativeContainer["bandName"] = mds.GetAs<std::string>("support_data.band_name"); } template<class T> void ParseMetadataFile(const std::string & metadataFilename, T& metadataAssociativeContainer) { std::ifstream file(metadataFilename); if (file.is_open()) { std::string line; auto fetchMetadata = [&metadataAssociativeContainer, &line] (const std::string & key, const std::string & metadataPath, int pos = 0, const std::string & separator = " ") { if (starts_with(line, metadataPath)) { std::string metadata = line.substr(metadataPath.size(), line.size()-metadataPath.size()); // Remove carriage return and new line caracters. metadata.erase(std::remove(metadata.begin(), metadata.end(), '\r'), metadata.end()); metadata.erase(std::remove(metadata.begin(), metadata.end(), '\n'), metadata.end()); std::vector<std::string> metadataParts; boost::split(metadataParts, metadata, boost::is_any_of(separator)); metadataAssociativeContainer[key] = metadataParts[pos]; } }; while (std::getline(file, line)) { fetchMetadata("productionDate", "Creation Date: "); fetchMetadata("sensorID", "Sensor: "); fetchMetadata("nominalCollectionAzimuth", "Nominal Collection Azimuth: "); fetchMetadata("nominalCollectionElevation", "Nominal Collection Elevation: "); fetchMetadata("sunAzimuth", "Sun Angle Azimuth: "); fetchMetadata("sunElevation", "Sun Angle Elevation: "); fetchMetadata("acquisitionDate", "Acquisition Date/Time: "); fetchMetadata("acquisitionTime", "Acquisition Date/Time: ", 1); } } else { otbGenericExceptionMacro(MissingMetadataException, << "Cannot open the Ikonos metadata file: " << metadataFilename); } } template<class T> void ParseHeaderFile(const std::string & hdrFilename, T& metadataAssociativeContainer) { std::ifstream file(hdrFilename); if (file.is_open()) { std::string line; auto fetchMetadata = [&metadataAssociativeContainer, &line] (const std::string & key, const std::string & metadataPath, int pos = 0, const std::string & separator = " ") { if (starts_with(line, metadataPath)) { std::string metadata = line.substr(metadataPath.size(), line.size()-metadataPath.size()); // Remove carriage return and new line caracters. metadata.erase(std::remove(metadata.begin(), metadata.end(), '\r'), metadata.end()); metadata.erase(std::remove(metadata.begin(), metadata.end(), '\n'), metadata.end()); std::vector<std::string> metadataParts; boost::split(metadataParts, metadata, boost::is_any_of(separator)); metadataAssociativeContainer[key] = metadataParts[pos]; } }; while (std::getline(file, line)) { fetchMetadata("bandName", "Band: "); } } else { otbGenericExceptionMacro(MissingMetadataException, << "Cannot open the Ikonos header file: " << hdrFilename); } } std::unordered_map<std::string, double> ikonosSolarIrradiance = { {"Pan", 1375.8}, {"Blue", 1930.9}, {"Green", 1854.8}, {"Red", 1556.5}, {"NIR", 1156.9}}; // Value computed from // http://www.geoeye.com/CorpSite/assets/docs/technical-papers/2009/IKONOS_Esun_Calculations.pdf // to get the equivalent of the SPOT alpha std::unordered_map<std::string, double> ikonosPhysicalGainPre20010122 = { {"Pan", 6.48830}, {"Blue", 4.51329}, {"Green", 5.75014}, {"Red", 5.52720}, {"NIR", 7.11684}}; std::unordered_map<std::string, double> ikonosPhysicalGainPost20010122 = { {"Pan", 6.48830}, {"Blue", 5.19064}, {"Green", 6.44122}, {"Red", 6.24442}, {"NIR", 8.04222}}; } void IkonosImageMetadataInterface::FetchProductionDate(const std::string & productionDate, ImageMetadata& imd) { std::vector<std::string> dateParts; // Producion date format: MM/DD/YY boost::split(dateParts, productionDate, boost::is_any_of("/")); if(dateParts.size() != 3) { otbGenericExceptionMacro(MissingMetadataException, "Invalid production date: " << productionDate) } otb::MetaData::Time productionDateMD; productionDateMD.tm_sec = 0; productionDateMD.tm_min = 0; productionDateMD.tm_hour = 0; productionDateMD.frac_sec = 0; productionDateMD.tm_isdst = 0; productionDateMD.tm_mday = boost::lexical_cast<int>(dateParts[1]); // tm_mon: number of months since january (0-11) productionDateMD.tm_mon = boost::lexical_cast<int>(dateParts[0]) - 1; auto productionYear = boost::lexical_cast<int>(dateParts[2]); // 1999 is the only possible year before 2000 for Ikonos dates // as the satellite was launched the 09/24/1999 if (productionYear != 99) { productionYear += 100; } // tm year: number of years since 1900 productionDateMD.tm_year = productionYear; imd.Add(MDTime::ProductionDate, productionDateMD); } void IkonosImageMetadataInterface::FetchAcquisitionDate(const std::string & acquisitionDate, const std::string & acquisitionTime, ImageMetadata& imd) { std::vector<std::string> dateParts; otb::MetaData::Time acquisitionDateMD; // Acquisition date format: YYYY-MM-DD boost::split(dateParts, acquisitionDate, boost::is_any_of("-")); if(dateParts.size() != 3) { otbGenericExceptionMacro(MissingMetadataException, "Invalid acquistion date: " << acquisitionDate) } acquisitionDateMD.tm_year = boost::lexical_cast<int>(dateParts[0]) - 1900; acquisitionDateMD.tm_mon = boost::lexical_cast<int>(dateParts[1]) - 1; acquisitionDateMD.tm_mday = boost::lexical_cast<int>(dateParts[2]); // Acquisition time format: hh:mm boost::split(dateParts, acquisitionTime , boost::is_any_of(":")); if(dateParts.size() != 2) { otbGenericExceptionMacro(MissingMetadataException, "Invalid acquistion time: " << acquisitionTime) } acquisitionDateMD.tm_hour = boost::lexical_cast<int>(dateParts[0]); acquisitionDateMD.tm_min = boost::lexical_cast<int>(dateParts[1]); acquisitionDateMD.tm_sec = 0; acquisitionDateMD.frac_sec = 0; imd.Add(MDTime::AcquisitionDate, acquisitionDateMD); } void IkonosImageMetadataInterface::FetchSpectralSensitivity(const std::string & bandName, ImageMetadata& imd) { otb::MetaData::LUT1D spectralSensitivity; spectralSensitivity.Axis[0].Size = 275; spectralSensitivity.Axis[0].Origin = 0.35; spectralSensitivity.Axis[0].Spacing = 0.0025; if (bandName == "Pan") { spectralSensitivity.Array = { 0.000777411f, 0.000698442f, 0.000619473f, 0.000490086f, 0.000360699f, 0.000302118f, 0.000243538f, 0.000339101f, 0.000434664f, 0.000674356f, 0.000914047f, 0.00165711f, 0.00240018f, 0.00382524f, 0.00525031f, 0.00774772f, 0.0102451f, 0.0136149f, 0.0169847f, 0.0216852f, 0.0263858f, 0.0322139f, 0.0380419f, 0.0451535f, 0.052265f, 0.059372f, 0.066479f, 0.0749836f, 0.0834881f, 0.0922321f, 0.100976f, 0.11238f, 0.123783f, 0.135806f, 0.147828f, 0.158671f, 0.169515f, 0.181498f, 0.193481f, 0.199257f, 0.205034f, 0.224842f, 0.24465f, 0.252955f, 0.26126f, 0.271512f, 0.281764f, 0.291251f, 0.300738f, 0.30953f, 0.318322f, 0.321402f, 0.324481f, 0.329386f, 0.33429f, 0.338595f, 0.342899f, 0.346889f, 0.350879f, 0.354954f, 0.359028f, 0.366986f, 0.374944f, 0.383555f, 0.392166f, 0.407887f, 0.423609f, 0.439638f, 0.455668f, 0.472286f, 0.488904f, 0.509193f, 0.529483f, 0.549106f, 0.56873f, 0.592408f, 0.616086f, 0.639134f, 0.662182f, 0.680563f, 0.698943f, 0.720886f, 0.742829f, 0.764357f, 0.785886f, 0.805496f, 0.825106f, 0.843924f, 0.862743f, 0.882061f, 0.901379f, 0.923168f, 0.944958f, 0.948979f, 0.952999f, 0.960789f, 0.968579f, 0.973284f, 0.977989f, 0.972502f, 0.967015f, 0.980472f, 0.993929f, 0.993271f, 0.992614f, 0.988076f, 0.983538f, 0.991769f, 1.0f, 0.996457f, 0.992914f, 0.996456f, 0.999998f, 0.993659f, 0.98732f, 0.980205f, 0.973089f, 0.957487f, 0.941886f, 0.939394f, 0.936901f, 0.920086f, 0.90327f, 0.895178f, 0.887086f, 0.878162f, 0.869238f, 0.876515f, 0.883791f, 0.883182f, 0.882573f, 0.883526f, 0.884479f, 0.889877f, 0.895275f, 0.895902f, 0.89653f, 0.911267f, 0.926004f, 0.924618f, 0.923232f, 0.91542f, 0.907607f, 0.904518f, 0.90143f, 0.903022f, 0.904613f, 0.902261f, 0.899908f, 0.893658f, 0.887407f, 0.890136f, 0.892866f, 0.889693f, 0.88652f, 0.892279f, 0.898039f, 0.904587f, 0.911135f, 0.927581f, 0.944026f, 0.951458f, 0.95889f, 0.947059f, 0.935229f, 0.946541f, 0.957854f, 0.965818f, 0.973781f, 0.973879f, 0.973978f, 0.971217f, 0.968457f, 0.96373f, 0.959003f, 0.95437f, 0.949736f, 0.932402f, 0.915067f, 0.906743f, 0.898418f, 0.90573f, 0.913042f, 0.923885f, 0.934728f, 0.931538f, 0.928349f, 0.934038f, 0.939728f, 0.923287f, 0.906846f, 0.914615f, 0.922384f, 0.929317f, 0.93625f, 0.943838f, 0.951427f, 0.948289f, 0.945151f, 0.949082f, 0.953013f, 0.938094f, 0.923176f, 0.921154f, 0.919132f, 0.890009f, 0.860885f, 0.867236f, 0.873588f, 0.850292f, 0.826995f, 0.817882f, 0.808768f, 0.800406f, 0.792044f, 0.777065f, 0.762087f, 0.755304f, 0.748521f, 0.727815f, 0.707108f, 0.696978f, 0.686848f, 0.68378f, 0.680711f, 0.675044f, 0.669377f, 0.641688f, 0.613999f, 0.596144f, 0.578289f, 0.567037f, 0.555785f, 0.536112f, 0.516439f, 0.498523f, 0.480606f, 0.475695f, 0.470783f, 0.452628f, 0.434473f, 0.415006f, 0.395538f, 0.373581f, 0.351624f, 0.344258f, 0.336893f, 0.323178f, 0.309463f, 0.296963f, 0.284464f, 0.277545f, 0.270627f, 0.259838f, 0.249049f, 0.242783f, 0.236516f, 0.226031f, 0.215545f, 0.205517f, 0.195489f, 0.187778f, 0.180066f, 0.172017f, 0.163968f, 0.156649f, 0.14933f, 0.142851f, 0.136372f, 0.127527f, 0.118682f, 0.111158f, 0.103634f, 0.0963653f, 0.0f}; } else if (bandName == "Blue") { spectralSensitivity.Array = { 0.000773147f, 0.00111792f, 0.00146269f, 0.00116425f, 0.000865817f, 0.000798356f, 0.000730896f, 0.000724069f, 0.000717243f, 0.000983961f, 0.00125068f, 0.00147711f, 0.00170354f, 0.00181267f, 0.0019218f, 0.00235592f, 0.00279004f, 0.00398685f, 0.00518366f, 0.00642842f, 0.00767318f, 0.00823188f, 0.00879058f, 0.0103296f, 0.0118686f, 0.0146603f, 0.017452f, 0.0262281f, 0.0350041f, 0.0602011f, 0.085398f, 0.139163f, 0.192928f, 0.261737f, 0.330546f, 0.375015f, 0.419484f, 0.463835f, 0.508186f, 0.560708f, 0.613231f, 0.643718f, 0.674206f, 0.697319f, 0.720432f, 0.740631f, 0.760831f, 0.760468f, 0.760104f, 0.77422f, 0.788336f, 0.822457f, 0.856578f, 0.872968f, 0.889358f, 0.916497f, 0.943636f, 0.971818f, 1.0f, 0.993393f, 0.986786f, 0.956164f, 0.925542f, 0.843438f, 0.761333f, 0.651888f, 0.542443f, 0.428187f, 0.31393f, 0.259011f, 0.204092f, 0.178009f, 0.151925f, 0.118774f, 0.0856216f, 0.0643982f, 0.0431748f, 0.0370744f, 0.030974f, 0.0288085f, 0.0266429f, 0.0243978f, 0.0221527f, 0.0221454f, 0.0221381f, 0.0241802f, 0.0262224f, 0.027894f, 0.0295655f, 0.0282719f, 0.0269782f, 0.0247994f, 0.0226207f, 0.0240241f, 0.0254275f, 0.0279644f, 0.0305013f, 0.0289285f, 0.0273557f, 0.0243127f, 0.0212697f, 0.021495f, 0.0217203f, 0.0256572f, 0.0295941f, 0.0319082f, 0.0342224f, 0.0306457f, 0.027069f, 0.0232825f, 0.019496f, 0.0194953f, 0.0194945f, 0.019262f, 0.0190295f, 0.0165004f, 0.0139713f, 0.0106605f, 0.00734963f, 0.00665076f, 0.00595189f, 0.00555088f, 0.00514986f, 0.00651302f, 0.00787617f, 0.0101045f, 0.0123327f, 0.0161468f, 0.0199609f, 0.0210092f, 0.0220576f, 0.021422f, 0.0207864f, 0.0198958f, 0.0190052f, 0.0172422f, 0.0154792f, 0.012607f, 0.00973489f, 0.00827171f, 0.00680854f, 0.00586579f, 0.00492304f, 0.00515291f, 0.00538278f, 0.00845239f, 0.011522f, 0.0168842f, 0.0222464f, 0.0231172f, 0.023988f, 0.0180264f, 0.0120648f, 0.0080432f, 0.00402165f, 0.00311771f, 0.00221378f, 0.00238421f, 0.00255463f, 0.00240824f, 0.00226184f, 0.00286143f, 0.00346102f, 0.00296337f, 0.00246571f, 0.00239388f, 0.00232204f, 0.00315372f, 0.0039854f, 0.0037969f, 0.00360839f, 0.00315481f, 0.00270124f, 0.00254147f, 0.0023817f, 0.00250869f, 0.00263568f, 0.00244201f, 0.00224833f, 0.00192361f, 0.00159888f, 0.00157883f, 0.00155879f, 0.00177376f, 0.00198873f, 0.00199198f, 0.00199522f, 0.00225955f, 0.00252388f, 0.00306228f, 0.00360067f, 0.00461183f, 0.00562299f, 0.00610986f, 0.00659673f, 0.00707311f, 0.00754949f, 0.00775649f, 0.00796349f, 0.00871715f, 0.00947081f, 0.00887752f, 0.00828423f, 0.00852913f, 0.00877403f, 0.00901617f, 0.00925831f, 0.00995926f, 0.0106602f, 0.0115813f, 0.0125024f, 0.0128068f, 0.0131113f, 0.0130847f, 0.0130581f, 0.0124604f, 0.0118627f, 0.0111828f, 0.0105029f, 0.00998883f, 0.00947476f, 0.00913233f, 0.00878991f, 0.00859062f, 0.00839133f, 0.00830986f, 0.0082284f, 0.00812489f, 0.00802138f, 0.00818694f, 0.0083525f, 0.00823223f, 0.00811195f, 0.00805303f, 0.00799411f, 0.00800437f, 0.00801463f, 0.00743377f, 0.00685291f, 0.00615093f, 0.00544896f, 0.00512429f, 0.00479963f, 0.00463363f, 0.00446762f, 0.00428193f, 0.00409623f, 0.00384906f, 0.00360189f, 0.00353085f, 0.00345981f, 0.00336041f, 0.00326101f, 0.00300593f, 0.00275086f, 0.00278287f, 0.00281488f, 0.00259549f, 0.00237609f, 0.00236111f, 0.00234613f, 0.00248306f, 0.00261998f, 0.00263357f, 0.00264716f, 0.0026242f, 0.00260124f, 0.00210138f, 0.00160152f, 0.00177352f, 0.00194551f, 0.00218138f, 0.00241724f, 0.00185843f, 0.0f}; } else if (bandName == "Green") { spectralSensitivity.Array = { 0.000643373f, 0.000721567f, 0.000799761f, 0.000764593f, 0.000729425f, 0.000767756f, 0.000806087f, 0.000691702f, 0.000577317f, 0.000709642f, 0.000841967f, 0.000741458f, 0.000640949f, 0.000754853f, 0.000868757f, 0.000732192f, 0.000595627f, 0.000952731f, 0.00130983f, 0.00125601f, 0.00120219f, 0.00194445f, 0.00268671f, 0.00183813f, 0.000989541f, 0.00113105f, 0.00127256f, 0.00160875f, 0.00194493f, 0.00229841f, 0.00265189f, 0.00301361f, 0.00337532f, 0.00370611f, 0.00403689f, 0.00486952f, 0.00570216f, 0.00738653f, 0.0090709f, 0.010205f, 0.011339f, 0.0113175f, 0.011296f, 0.0121669f, 0.0130378f, 0.0151163f, 0.0171948f, 0.0208267f, 0.0244586f, 0.0305813f, 0.036704f, 0.0434839f, 0.0502638f, 0.0565094f, 0.0627551f, 0.0860566f, 0.109358f, 0.151232f, 0.193107f, 0.242087f, 0.291067f, 0.365317f, 0.439568f, 0.545145f, 0.650723f, 0.728637f, 0.806551f, 0.839149f, 0.871746f, 0.88005f, 0.888355f, 0.889065f, 0.889775f, 0.882352f, 0.874928f, 0.863518f, 0.852108f, 0.872214f, 0.89232f, 0.944994f, 0.997669f, 0.981902f, 0.966134f, 0.936936f, 0.907737f, 0.900477f, 0.893218f, 0.919539f, 0.94586f, 0.971546f, 0.997232f, 0.978528f, 0.959823f, 0.918631f, 0.877439f, 0.813588f, 0.749737f, 0.625854f, 0.50197f, 0.392566f, 0.283162f, 0.22152f, 0.159878f, 0.133355f, 0.106831f, 0.0946597f, 0.0824881f, 0.0732495f, 0.0640108f, 0.0556904f, 0.0473701f, 0.039668f, 0.031966f, 0.0273263f, 0.0226867f, 0.0196283f, 0.0165699f, 0.0155271f, 0.0144843f, 0.0146602f, 0.0148362f, 0.0155289f, 0.0162216f, 0.0174317f, 0.0186418f, 0.0192574f, 0.019873f, 0.0193336f, 0.0187943f, 0.0169768f, 0.0151594f, 0.0138395f, 0.0125197f, 0.0122022f, 0.0118846f, 0.0113754f, 0.0108661f, 0.0122059f, 0.0135457f, 0.0150274f, 0.0165092f, 0.0174059f, 0.0183026f, 0.0170915f, 0.0158804f, 0.0135402f, 0.0112001f, 0.00877389f, 0.00634772f, 0.00592819f, 0.00550866f, 0.00444963f, 0.0033906f, 0.00363493f, 0.00387926f, 0.00369547f, 0.00351167f, 0.00323999f, 0.0029683f, 0.00304107f, 0.00311383f, 0.00269225f, 0.00227067f, 0.00285765f, 0.00344463f, 0.0035057f, 0.00356676f, 0.00444226f, 0.00531776f, 0.00591164f, 0.00650553f, 0.00683137f, 0.00715721f, 0.00801677f, 0.00887633f, 0.00920412f, 0.0095319f, 0.00876825f, 0.00800459f, 0.00751842f, 0.00703224f, 0.00673578f, 0.00643931f, 0.00627542f, 0.00611152f, 0.00586377f, 0.00561602f, 0.00543874f, 0.00526147f, 0.0057041f, 0.00614673f, 0.00676773f, 0.00738874f, 0.00702707f, 0.00666541f, 0.0066904f, 0.0067154f, 0.00807246f, 0.00942952f, 0.0111187f, 0.0128079f, 0.0135393f, 0.0142706f, 0.015097f, 0.0159234f, 0.0165052f, 0.017087f, 0.0171597f, 0.0172324f, 0.0167555f, 0.0162786f, 0.0157604f, 0.0152423f, 0.0143205f, 0.0133987f, 0.0126828f, 0.0119669f, 0.0112674f, 0.0105679f, 0.0102702f, 0.00997248f, 0.00958224f, 0.009192f, 0.00947248f, 0.00975296f, 0.00932626f, 0.00889956f, 0.00866396f, 0.00842837f, 0.0081121f, 0.00779583f, 0.00765918f, 0.00752253f, 0.00724579f, 0.00696906f, 0.0064155f, 0.00586195f, 0.00563761f, 0.00541328f, 0.00499098f, 0.00456868f, 0.00425882f, 0.00394895f, 0.00377609f, 0.00360322f, 0.00343181f, 0.00326041f, 0.00310311f, 0.00294581f, 0.00285307f, 0.00276034f, 0.00277242f, 0.0027845f, 0.00250953f, 0.00223456f, 0.00235165f, 0.00246875f, 0.00235075f, 0.00223275f, 0.00238435f, 0.00253594f, 0.00230124f, 0.00206653f, 0.00190024f, 0.00173395f, 0.00191697f, 0.00209999f, 0.00206986f, 0.00203973f, 0.002129f, 0.00221828f, 0.00179734f, 0.00137641f, 0.00148945f, 0.0f}; } else if (bandName == "Red") { spectralSensitivity.Array = { 0.0f, 0.000251974f, 0.000503948f, 0.000447294f, 0.000390639f, 0.000493587f, 0.000596534f, 0.000462484f, 0.000328434f, 0.000587581f, 0.000846728f, 0.000748537f, 0.000650345f, 0.000516444f, 0.000382543f, 0.000939994f, 0.00149745f, 0.00175874f, 0.00202003f, 0.00252033f, 0.00302063f, 0.00326826f, 0.00351589f, 0.00376182f, 0.00400775f, 0.00406784f, 0.00412793f, 0.00595608f, 0.00778423f, 0.0080879f, 0.00839158f, 0.00829197f, 0.00819236f, 0.00662469f, 0.00505701f, 0.00383289f, 0.00260876f, 0.00345153f, 0.00429429f, 0.00487448f, 0.00545468f, 0.00545833f, 0.00546199f, 0.00418794f, 0.00291388f, 0.00230581f, 0.00169773f, 0.00162001f, 0.0015423f, 0.00259185f, 0.00364139f, 0.00396142f, 0.00428144f, 0.00339831f, 0.00251517f, 0.00227348f, 0.00203179f, 0.00167973f, 0.00132766f, 0.00141316f, 0.00149866f, 0.00150402f, 0.00150938f, 0.0018186f, 0.00212782f, 0.00224531f, 0.0023628f, 0.0025393f, 0.0027158f, 0.00304882f, 0.00338183f, 0.00312524f, 0.00286866f, 0.00286392f, 0.00285919f, 0.00345904f, 0.0040589f, 0.00503972f, 0.00602055f, 0.00659323f, 0.00716591f, 0.00825183f, 0.00933776f, 0.00929585f, 0.00925395f, 0.00899875f, 0.00874355f, 0.00912988f, 0.0095162f, 0.00993024f, 0.0103443f, 0.0118352f, 0.0133262f, 0.0168796f, 0.020433f, 0.0244432f, 0.0284535f, 0.0315921f, 0.0347306f, 0.0387702f, 0.0428098f, 0.0501643f, 0.0575189f, 0.0714861f, 0.0854534f, 0.105156f, 0.124858f, 0.150634f, 0.17641f, 0.217427f, 0.258444f, 0.338645f, 0.418847f, 0.528481f, 0.638116f, 0.721314f, 0.804512f, 0.841436f, 0.87836f, 0.898975f, 0.91959f, 0.936413f, 0.953235f, 0.954545f, 0.955856f, 0.942354f, 0.928852f, 0.933873f, 0.938894f, 0.962762f, 0.98663f, 0.991712f, 0.996794f, 0.952358f, 0.907922f, 0.838837f, 0.769753f, 0.68084f, 0.591927f, 0.506722f, 0.421517f, 0.363416f, 0.305314f, 0.265769f, 0.226224f, 0.192279f, 0.158334f, 0.131456f, 0.104578f, 0.0859652f, 0.067352f, 0.0560433f, 0.0447347f, 0.0373336f, 0.0299325f, 0.0269409f, 0.0239493f, 0.0229628f, 0.0219762f, 0.0201699f, 0.0183636f, 0.0171332f, 0.0159029f, 0.0160653f, 0.0162278f, 0.0159488f, 0.0156697f, 0.0160819f, 0.0164941f, 0.0168042f, 0.0171144f, 0.0167051f, 0.0162959f, 0.0141966f, 0.0120973f, 0.0105832f, 0.00906906f, 0.00792008f, 0.0067711f, 0.00649551f, 0.00621991f, 0.00588748f, 0.00555504f, 0.00486398f, 0.00417292f, 0.00419873f, 0.00422454f, 0.00461445f, 0.00500436f, 0.00449582f, 0.00398727f, 0.00397629f, 0.00396531f, 0.00332414f, 0.00268297f, 0.00284406f, 0.00300515f, 0.00277493f, 0.00254471f, 0.00290075f, 0.00325678f, 0.00290726f, 0.00255773f, 0.00259229f, 0.00262684f, 0.00269255f, 0.00275825f, 0.00271562f, 0.00267299f, 0.00275871f, 0.00284443f, 0.00269768f, 0.00255094f, 0.00257098f, 0.00259103f, 0.00253264f, 0.00247425f, 0.00242522f, 0.00237619f, 0.00235338f, 0.00233057f, 0.00261103f, 0.00289149f, 0.0028024f, 0.00271332f, 0.00290319f, 0.00309306f, 0.00350249f, 0.00391192f, 0.00395984f, 0.00400776f, 0.00401089f, 0.00401403f, 0.0037349f, 0.00345576f, 0.00305136f, 0.00264696f, 0.00241812f, 0.00218929f, 0.00191393f, 0.00163858f, 0.00153304f, 0.00142751f, 0.00137032f, 0.00131312f, 0.00134518f, 0.00137723f, 0.0012429f, 0.00110858f, 0.00114136f, 0.00117415f, 0.00116687f, 0.00115959f, 0.00108165f, 0.00100371f, 0.00131319f, 0.00162267f, 0.00130164f, 0.000980609f, 0.00115412f, 0.00132762f, 0.0013807f, 0.00143378f, 0.00218704f, 0.00294031f, 0.00234605f, 0.00175179f, 0.0020462f, 0.0023406f, 0.00180012f, 0.00125963f, 0.00107872f, 0.000897814f, 0.000448907f, 0.0f}; } else if (bandName == "NIR") { spectralSensitivity.Array = { 0.000894394f, 0.000713315f, 0.000532235f, 0.000603058f, 0.000673881f, 0.000760361f, 0.00084684f, 0.000787802f, 0.000728763f, 0.000817305f, 0.000905846f, 0.000904774f, 0.000903701f, 0.00160409f, 0.00230447f, 0.00221407f, 0.00212367f, 0.00314219f, 0.00416071f, 0.00470014f, 0.00523956f, 0.00641267f, 0.00758578f, 0.0090575f, 0.0105292f, 0.0156041f, 0.0206791f, 0.027643f, 0.0346069f, 0.0395911f, 0.0445753f, 0.0408266f, 0.0370779f, 0.0276002f, 0.0181225f, 0.017135f, 0.0161476f, 0.0168906f, 0.0176337f, 0.0172355f, 0.0168373f, 0.0168014f, 0.0167656f, 0.0178122f, 0.0188588f, 0.0165949f, 0.0143311f, 0.0120729f, 0.0098147f, 0.0125599f, 0.0153051f, 0.0187014f, 0.0220978f, 0.0244686f, 0.0268393f, 0.0270579f, 0.0272765f, 0.0223541f, 0.0174318f, 0.0124528f, 0.00747381f, 0.00633578f, 0.00519774f, 0.00546479f, 0.00573183f, 0.00496663f, 0.00420143f, 0.00375248f, 0.00330354f, 0.00289353f, 0.00248353f, 0.00252329f, 0.00256304f, 0.00431351f, 0.00606397f, 0.00864978f, 0.0112356f, 0.0122617f, 0.0132878f, 0.0113116f, 0.00933533f, 0.00834238f, 0.00734942f, 0.00698854f, 0.00662766f, 0.00662135f, 0.00661504f, 0.00802641f, 0.00943779f, 0.0113662f, 0.0132947f, 0.0126595f, 0.0120243f, 0.00943568f, 0.0068471f, 0.00523536f, 0.00362362f, 0.00341318f, 0.00320274f, 0.00318157f, 0.00316041f, 0.00303014f, 0.00289988f, 0.00349364f, 0.0040874f, 0.00427183f, 0.00445627f, 0.00425418f, 0.0040521f, 0.00432398f, 0.00459586f, 0.00500329f, 0.00541072f, 0.0052616f, 0.00511248f, 0.00619044f, 0.0072684f, 0.007209f, 0.0071496f, 0.00780861f, 0.00846762f, 0.0103595f, 0.0122514f, 0.014548f, 0.0168445f, 0.0180774f, 0.0193103f, 0.0203458f, 0.0213814f, 0.021739f, 0.0220966f, 0.0227061f, 0.0233155f, 0.0241796f, 0.0250438f, 0.0249493f, 0.0248548f, 0.0257403f, 0.0266259f, 0.0274829f, 0.0283399f, 0.0315445f, 0.034749f, 0.0392491f, 0.0437491f, 0.0488567f, 0.0539644f, 0.0651598f, 0.0763552f, 0.0905082f, 0.104661f, 0.125801f, 0.146941f, 0.17194f, 0.196939f, 0.22805f, 0.25916f, 0.283963f, 0.308767f, 0.332943f, 0.357119f, 0.400422f, 0.443726f, 0.504385f, 0.565045f, 0.633202f, 0.701359f, 0.76896f, 0.83656f, 0.889646f, 0.942732f, 0.971366f, 1.0f, 0.997999f, 0.995998f, 0.963345f, 0.930691f, 0.881401f, 0.832111f, 0.811504f, 0.790896f, 0.782153f, 0.773411f, 0.768032f, 0.762653f, 0.735848f, 0.709043f, 0.707354f, 0.705666f, 0.697871f, 0.690076f, 0.672979f, 0.655882f, 0.638978f, 0.622073f, 0.601538f, 0.581002f, 0.557459f, 0.533915f, 0.524241f, 0.514567f, 0.501153f, 0.487739f, 0.452918f, 0.418097f, 0.370059f, 0.32202f, 0.285355f, 0.248689f, 0.209974f, 0.171259f, 0.142537f, 0.113816f, 0.092517f, 0.0712178f, 0.0646218f, 0.0580258f, 0.050796f, 0.0435662f, 0.0353664f, 0.0271667f, 0.0232974f, 0.0194282f, 0.0176517f, 0.0158752f, 0.0144977f, 0.0131202f, 0.0118952f, 0.0106703f, 0.0101536f, 0.00963684f, 0.00921561f, 0.00879438f, 0.00794162f, 0.00708886f, 0.00654941f, 0.00600996f, 0.00563429f, 0.00525862f, 0.00510421f, 0.00494981f, 0.00454041f, 0.00413101f, 0.00410078f, 0.00407056f, 0.00396389f, 0.00385722f, 0.00364911f, 0.00344101f, 0.00333006f, 0.00321911f, 0.00300415f, 0.00278918f, 0.00317632f, 0.00356346f, 0.00312642f, 0.00268937f, 0.00260112f, 0.00251287f, 0.00263123f, 0.00274958f, 0.00362147f, 0.00449336f, 0.00413978f, 0.0037862f, 0.0028968f, 0.0020074f, 0.00190022f, 0.00179303f, 0.00227357f, 0.0027541f, 0.00137705f, 0.0f, 0.0f, 0.0f}; } imd.Bands[0].Add(MDL1D::SpectralSensitivity, spectralSensitivity); } void IkonosImageMetadataInterface::Parse(ImageMetadata &imd) { std::unordered_map<std::string, std::string> ikonosMetadata; if (m_MetadataSupplierInterface->GetAs<std::string>("", "METADATATYPE") == "GE") { FetchRPC(imd); auto inputFilenameWithDir = m_MetadataSupplierInterface->GetResourceFile(); auto inputFilename = itksys::SystemTools::GetFilenameName(inputFilenameWithDir); // Find hdr and metadata files : std::vector<std::string> inputFilenameParts; boost::split(inputFilenameParts, inputFilename, boost::is_any_of("_")); auto metadataFilename = itksys::SystemTools::GetParentDirectory(inputFilenameWithDir) + "/" + inputFilenameParts[0] + "_" + inputFilenameParts[1] + "_metadata.txt"; if (!itksys::SystemTools::FileExists(metadataFilename)) { otbGenericExceptionMacro(MissingMetadataException, << "Cannot find the Ikonos metadata file, tried: " << metadataFilename) } // Read metadata from the metadata file ParseMetadataFile(metadataFilename, ikonosMetadata); if (!ContainsIkonosMetadata(ikonosMetadata)) { otbGenericExceptionMacro(MissingMetadataException, << "The Ikonos metadata file is incomplete: " << metadataFilename) } auto hdrFilename = itksys::SystemTools::GetParentDirectory(inputFilenameWithDir) + "/" + itksys::SystemTools::GetFilenameWithoutExtension(inputFilenameWithDir) + ".hdr"; if (!itksys::SystemTools::FileExists(hdrFilename)) { otbGenericExceptionMacro(MissingMetadataException, << "Cannot find the Ikonos hdr file, tried: " << hdrFilename) } ParseHeaderFile(hdrFilename, ikonosMetadata); } else if (m_MetadataSupplierInterface->GetAs<std::string>("", "support_data.sensor") == "IKONOS-2") { ParseGeomFile(*m_MetadataSupplierInterface, ikonosMetadata); } else { otbGenericExceptionMacro(MissingMetadataException, << "No Geo-Eye metadata has been found") } try { imd.Add(MDStr::SensorID, ikonosMetadata["sensorID"]); imd.Add(MDNum::SunElevation, boost::lexical_cast<double>(ikonosMetadata["sunElevation"])); imd.Add(MDNum::SunAzimuth, boost::lexical_cast<double>(ikonosMetadata["sunAzimuth"])); imd.Add(MDNum::SatElevation, boost::lexical_cast<double>(ikonosMetadata["nominalCollectionElevation"])); imd.Add(MDNum::SatAzimuth, boost::lexical_cast<double>(ikonosMetadata["nominalCollectionAzimuth"])); FetchProductionDate(ikonosMetadata["productionDate"], imd); FetchAcquisitionDate(ikonosMetadata["acquisitionDate"], ikonosMetadata["acquisitionTime"], imd); } catch (boost::bad_lexical_cast&) { otbGenericExceptionMacro(MissingMetadataException, "Cannot read Ikonos metadata") } const auto & bandName = ikonosMetadata["bandName"]; imd.Bands[0].Add(MDStr::BandName, bandName); otb::MetaData::Time date; date.tm_year = 101; date.tm_mon = 0; date.tm_mday = 22; date.tm_hour = 0; date.tm_min = 0; date.tm_sec = 0; date.frac_sec = 0; if (imd[MDTime::AcquisitionDate] < date) { imd.Bands[0].Add(MDNum::PhysicalGain, ikonosPhysicalGainPre20010122[bandName]); } else { imd.Bands[0].Add(MDNum::PhysicalGain, ikonosPhysicalGainPost20010122[bandName]); } imd.Bands[0].Add(MDNum::PhysicalBias, 0.); imd.Bands[0].Add(MDNum::SolarIrradiance, ikonosSolarIrradiance[bandName]); FetchSpectralSensitivity(bandName, imd); } } // end namespace otb
; test of IRRE_ASM assembly v4 ; specify the label to be used as an entry point. optional. %entry :main ; items here are placfed in the executable code section %section code ; use BIND ("@") to define a macro ; the argument list is followed by MARK (":") add2@ rA rB v0 : ; this macro sets rA = rB + v0 set ad v0 add rA rB ad :: main: set r1 $0 set r2 $4 add2 r2 r2 $8 ; labels can be ahead-referenced ; any relative offsets will be resolved later set r4 ::func1 cal r4 ; labels can be accessed with positive offsets set r3 ::data1 ; pointer to "hello" string set r5 ::data0^#4 hlt func1: set r7 $ff ret ; indicate that items here should be placed in the data section %section data ; data must appear in the data section data0: %d \x $22000000 ; $22 in little endian data1: %d \' hello ; data string support %d \x $00 ; null terminator
#pragma once #include <algorithm> #include <cassert> #include <limits> #include <queue> #include <vector> // CUT begin // MinCostFlow based on AtCoder Library, no namespace, no private variables, compatible with C++11 // **NO NEGATIVE COST EDGES** // Reference: https://atcoder.github.io/ac-library/production/document_ja/mincostflow.html // Remark: You can use [radix heap](https://github.com/iwiwi/radix-heap) for Dijkstra acceleration template <class Cap, class Cost> struct mcf_graph { mcf_graph() {} mcf_graph(int n) : _n(n), g(n) { static_assert(std::numeric_limits<Cap>::max() > 0, "max() must be greater than 0"); } int add_edge(int from, int to, Cap cap, Cost cost) { assert(0 <= from && from < _n); assert(0 <= to && to < _n); assert(0 <= cap); assert(0 <= cost); int m = int(pos.size()); pos.push_back({from, int(g[from].size())}); int from_id = int(g[from].size()); int to_id = int(g[to].size()); if (from == to) to_id++; g[from].push_back(_edge{to, to_id, cap, cost}); g[to].push_back(_edge{from, from_id, 0, -cost}); return m; } struct edge { int from, to; Cap cap, flow; Cost cost; }; edge get_edge(int i) { int m = int(pos.size()); assert(0 <= i && i < m); auto _e = g[pos[i].first][pos[i].second]; auto _re = g[_e.to][_e.rev]; return edge{ pos[i].first, _e.to, _e.cap + _re.cap, _re.cap, _e.cost, }; } std::vector<edge> edges() { int m = int(pos.size()); std::vector<edge> result(m); for (int i = 0; i < m; i++) { result[i] = get_edge(i); } return result; } std::pair<Cap, Cost> flow(int s, int t) { return flow(s, t, std::numeric_limits<Cap>::max()); } std::pair<Cap, Cost> flow(int s, int t, Cap flow_limit) { return slope(s, t, flow_limit).back(); } std::vector<std::pair<Cap, Cost>> slope(int s, int t) { return slope(s, t, std::numeric_limits<Cap>::max()); } std::vector<Cost> dual, dist; std::vector<int> pv, pe; std::vector<bool> vis; struct Q { Cost key; int to; bool operator<(Q r) const { return key > r.key; } }; std::vector<Q> que; bool _dual_ref(int s, int t) { std::fill(dist.begin(), dist.end(), std::numeric_limits<Cost>::max()); std::fill(vis.begin(), vis.end(), false); que.clear(); dist[s] = 0; que.push_back(Q{0, s}); std::push_heap(que.begin(), que.end()); while (!que.empty()) { int v = que.front().to; std::pop_heap(que.begin(), que.end()); que.pop_back(); if (vis[v]) continue; vis[v] = true; if (v == t) break; // dist[v] = shortest(s, v) + dual[s] - dual[v] // dist[v] >= 0 (all reduced cost are positive) // dist[v] <= (n-1)C for (int i = 0; i < int(g[v].size()); i++) { auto e = g[v][i]; if (vis[e.to] || !e.cap) continue; // |-dual[e.to] + dual[v]| <= (n-1)C // cost <= C - -(n-1)C + 0 = nC Cost cost = e.cost - dual[e.to] + dual[v]; if (dist[e.to] - dist[v] > cost) { dist[e.to] = dist[v] + cost; pv[e.to] = v; pe[e.to] = i; que.push_back(Q{dist[e.to], e.to}); std::push_heap(que.begin(), que.end()); } } } if (!vis[t]) { return false; } for (int v = 0; v < _n; v++) { if (!vis[v]) continue; // dual[v] = dual[v] - dist[t] + dist[v] // = dual[v] - (shortest(s, t) + dual[s] - dual[t]) + (shortest(s, v) + dual[s] - dual[v]) // = - shortest(s, t) + dual[t] + shortest(s, v) // = shortest(s, v) - shortest(s, t) >= 0 - (n-1)C dual[v] -= dist[t] - dist[v]; } return true; } std::vector<std::pair<Cap, Cost>> slope(int s, int t, Cap flow_limit) { assert(0 <= s && s < _n); assert(0 <= t && t < _n); assert(s != t); // variants (C = maxcost): // -(n-1)C <= dual[s] <= dual[i] <= dual[t] = 0 // reduced cost (= e.cost + dual[e.from] - dual[e.to]) >= 0 for all edge dual.assign(_n, 0), dist.assign(_n, 0); pv.assign(_n, 0), pe.assign(_n, 0); vis.assign(_n, false); Cap flow = 0; Cost cost = 0, prev_cost_per_flow = -1; std::vector<std::pair<Cap, Cost>> result; result.push_back({flow, cost}); while (flow < flow_limit) { if (!_dual_ref(s, t)) break; Cap c = flow_limit - flow; for (int v = t; v != s; v = pv[v]) { c = std::min(c, g[pv[v]][pe[v]].cap); } for (int v = t; v != s; v = pv[v]) { auto& e = g[pv[v]][pe[v]]; e.cap -= c; g[v][e.rev].cap += c; } Cost d = -dual[s]; flow += c; cost += c * d; if (prev_cost_per_flow == d) { result.pop_back(); } result.push_back({flow, cost}); prev_cost_per_flow = d; } return result; } struct _edge { int to, rev; Cap cap; Cost cost; }; int _n; std::vector<std::pair<int, int>> pos; std::vector<std::vector<_edge>> g; };
; ASM code generated by mikroVirtualMachine for PIC - V. 8.0.0.0 ; Date/Time: 18-Jun-20 11:26:38 PM ; Info: http://www.mikroe.com ; ADDRESS OPCODE ASM ; ---------------------------------------------- $0000 $EF6A F002 GOTO _main $0008 $ _Delay_1us: $0008 $0000 NOP $000A $0000 NOP $000C $0012 RETURN $000E $ _Delay_5500us: $000E $0E0F MOVLW 15 $0010 $6E0B MOVWF STACK_11, 0 $0012 $0EFF MOVLW 255 $0014 $6E0A MOVWF STACK_10, 0 $0016 $2E0B DECFSZ STACK_11, F, 0 $0018 $D001 BRA $+2 $001A $D003 BRA $+4 $001C $2E0A DECFSZ STACK_10, F, 0 $001E $D7FE BRA $-1 $0020 $D7FA BRA $-5 $0022 $0E3E MOVLW 62 $0024 $6E0A MOVWF STACK_10, 0 $0026 $2E0A DECFSZ STACK_10, F, 0 $0028 $D7FE BRA $-1 $002A $0000 NOP $002C $0012 RETURN $002E $ _Delay_50us: $002E $0E21 MOVLW 33 $0030 $6E0A MOVWF STACK_10, 0 $0032 $2E0A DECFSZ STACK_10, F, 0 $0034 $D7FE BRA $-1 $0036 $0012 RETURN $0038 $ SoftI2C_PutZerosToLAT: $0038 $0E09 MOVLW 9 $003A $5C15 SUBWF ___porti2c, 0, 0 $003C $6EE1 MOVWF FSR1L, 0 $003E $0E0F MOVLW 15 $0040 $6EE2 MOVWF FSR1H, 0 $0042 $98E7 BCF INDF1, ____sdai2c, 0 $0044 $96E7 BCF INDF1, ____scli2c, 0 $0046 $0012 RETURN $0048 $ _Lcd8_Cmd: $0048 $C016 FFE9 MOVFF Lcd8bit_main_global_dataAddress, FSR0L $004C $C017 FFEA MOVFF Lcd8bit_main_global_dataAddress+1, FSR0H $0050 $C018 FFE1 MOVFF Lcd8bit_main_global_ctrlAddress, FSR1L $0054 $C019 FFE2 MOVFF Lcd8bit_main_global_ctrlAddress+1, FSR1H $0058 $6AEF CLRF INDF0, 0 $005A $5279 MOVF FARG_Lcd8_Cmd+0, 1, 0 $005C $E000 BZ L_Lcd8_Cmd_0 $005E $ L_Lcd8_Cmd_0: $005E $BE79 BTFSC FARG_Lcd8_Cmd+0, 7, 0 $0060 $8EEF BSF INDF0, __LCD8_DB7, 0 $0062 $BC79 BTFSC FARG_Lcd8_Cmd+0, 6, 0 $0064 $8CEF BSF INDF0, __LCD8_DB6, 0 $0066 $BA79 BTFSC FARG_Lcd8_Cmd+0, 5, 0 $0068 $8AEF BSF INDF0, __LCD8_DB5, 0 $006A $B879 BTFSC FARG_Lcd8_Cmd+0, 4, 0 $006C $88EF BSF INDF0, __LCD8_DB4, 0 $006E $B679 BTFSC FARG_Lcd8_Cmd+0, 3, 0 $0070 $86EF BSF INDF0, __LCD8_DB3, 0 $0072 $B479 BTFSC FARG_Lcd8_Cmd+0, 2, 0 $0074 $84EF BSF INDF0, __LCD8_DB2, 0 $0076 $B279 BTFSC FARG_Lcd8_Cmd+0, 1, 0 $0078 $82EF BSF INDF0, __LCD8_DB1, 0 $007A $B079 BTFSC FARG_Lcd8_Cmd+0, 0, 0 $007C $80EF BSF INDF0, __LCD8_DB0, 0 $007E $501A MOVF Lcd8bit_main_global_cmd, 0, 0 $0080 $0A01 XORLW 1 $0082 $E103 BNZ L_Lcd8_Cmd_1 $0084 $94E7 BCF INDF1, __LCD8_RS, 0 $0086 $EF46 F000 GOTO L_Lcd8_Cmd_2 $008A $ L_Lcd8_Cmd_1: $008A $84E7 BSF INDF1, __LCD8_RS, 0 $008C $ L_Lcd8_Cmd_2: $008C $82E7 BSF INDF1, __LCD8_ENABLE, 0 $008E $EC04 F000 CALL _Delay_1us $0092 $92E7 BCF INDF1, __LCD8_ENABLE, 0 $0094 $501A MOVF Lcd8bit_main_global_cmd, 0, 0 $0096 $0A01 XORLW 1 $0098 $E103 BNZ L_Lcd8_Cmd_3 $009A $EC07 F000 CALL _Delay_5500us $009E $D002 BRA L_Lcd8_Cmd_4 $00A0 $ L_Lcd8_Cmd_3: $00A0 $EC17 F000 CALL _Delay_50us $00A4 $ L_Lcd8_Cmd_4: $00A4 $0012 RETURN $00A6 $ _read_keypad: ;part1.c,15 :: char read_keypad() ;part1.c,19 :: PORTD = 0xFF; $00A6 $0EFF MOVLW 255 $00A8 $6E83 MOVWF PORTD, 0 ;part1.c,20 :: TRISD = 0xFF; //configure PORT D as inpout $00AA $0EFF MOVLW 255 $00AC $6E95 MOVWF TRISD, 0 ;part1.c,22 :: TRISB = 0x00; //configure PORT B as outpout $00AE $6A93 CLRF TRISB, 0 ;part1.c,23 :: PORTB = 0xFF; //set all pins of PORT B to 1; $00B0 $0EFF MOVLW 255 $00B2 $6E81 MOVWF PORTB, 0 ;part1.c,25 :: key =0; $00B4 $6A75 CLRF read_keypad_key_L0, 0 ;part1.c,26 :: do { //1-5 buttons $00B6 $ L_read_keypad_0: ;part1.c,28 :: PORTB.F0 = 0; $00B6 $9081 BCF PORTB, 0, 0 ;part1.c,29 :: delay_ms(10); $00B8 $0E1A MOVLW 26 $00BA $6E0B MOVWF STACK_11, 0 $00BC $0EFF MOVLW 255 $00BE $6E0A MOVWF STACK_10, 0 $00C0 $2E0B DECFSZ STACK_11, F, 0 $00C2 $D001 BRA $+2 $00C4 $D003 BRA $+4 $00C6 $2E0A DECFSZ STACK_10, F, 0 $00C8 $D7FE BRA $-1 $00CA $D7FA BRA $-5 $00CC $0EE7 MOVLW 231 $00CE $6E0A MOVWF STACK_10, 0 $00D0 $2E0A DECFSZ STACK_10, F, 0 $00D2 $D7FE BRA $-1 $00D4 $0000 NOP ;part1.c,30 :: var = PORTD; $00D6 $CF83 F074 MOVFF PORTD, read_keypad_var_L0 ;part1.c,32 :: if (var.F2 == 0) key = '4'; $00DA $6A01 CLRF STACK_1, 0 $00DC $B474 BTFSC read_keypad_var_L0, 2, 0 $00DE $2A01 INCF STACK_1, 1, 0 $00E0 $5001 MOVF STACK_1, 0, 0 $00E2 $0A00 XORLW 0 $00E4 $E103 BNZ L_read_keypad_2 $00E6 $0E34 MOVLW 52 $00E8 $6E75 MOVWF read_keypad_key_L0, 0 $00EA $D008 BRA L_read_keypad_3 $00EC $ L_read_keypad_2: ;part1.c,33 :: else if (var.F3 == 0) key = '1'; $00EC $6A01 CLRF STACK_1, 0 $00EE $B674 BTFSC read_keypad_var_L0, 3, 0 $00F0 $2A01 INCF STACK_1, 1, 0 $00F2 $5001 MOVF STACK_1, 0, 0 $00F4 $0A00 XORLW 0 $00F6 $E102 BNZ L_read_keypad_4 $00F8 $0E31 MOVLW 49 $00FA $6E75 MOVWF read_keypad_key_L0, 0 $00FC $ L_read_keypad_4: $00FC $ L_read_keypad_3: ;part1.c,34 :: PORTB.F0 =1; $00FC $8081 BSF PORTB, 0, 0 ;part1.c,37 :: PORTB.F1 = 0; $00FE $9281 BCF PORTB, 1, 0 ;part1.c,38 :: delay_ms(10); $0100 $0E1A MOVLW 26 $0102 $6E0B MOVWF STACK_11, 0 $0104 $0EFF MOVLW 255 $0106 $6E0A MOVWF STACK_10, 0 $0108 $2E0B DECFSZ STACK_11, F, 0 $010A $D001 BRA $+2 $010C $D003 BRA $+4 $010E $2E0A DECFSZ STACK_10, F, 0 $0110 $D7FE BRA $-1 $0112 $D7FA BRA $-5 $0114 $0EE7 MOVLW 231 $0116 $6E0A MOVWF STACK_10, 0 $0118 $2E0A DECFSZ STACK_10, F, 0 $011A $D7FE BRA $-1 $011C $0000 NOP ;part1.c,39 :: var = PORTD; $011E $CF83 F074 MOVFF PORTD, read_keypad_var_L0 ;part1.c,41 :: if (var.F2 == 0)key = '5'; $0122 $6A01 CLRF STACK_1, 0 $0124 $B474 BTFSC read_keypad_var_L0, 2, 0 $0126 $2A01 INCF STACK_1, 1, 0 $0128 $5001 MOVF STACK_1, 0, 0 $012A $0A00 XORLW 0 $012C $E103 BNZ L_read_keypad_5 $012E $0E35 MOVLW 53 $0130 $6E75 MOVWF read_keypad_key_L0, 0 $0132 $D008 BRA L_read_keypad_6 $0134 $ L_read_keypad_5: ;part1.c,42 :: else if (var.F3 == 0)key = '2'; $0134 $6A01 CLRF STACK_1, 0 $0136 $B674 BTFSC read_keypad_var_L0, 3, 0 $0138 $2A01 INCF STACK_1, 1, 0 $013A $5001 MOVF STACK_1, 0, 0 $013C $0A00 XORLW 0 $013E $E102 BNZ L_read_keypad_7 $0140 $0E32 MOVLW 50 $0142 $6E75 MOVWF read_keypad_key_L0, 0 $0144 $ L_read_keypad_7: $0144 $ L_read_keypad_6: ;part1.c,43 :: PORTB.F1 =1; $0144 $8281 BSF PORTB, 1, 0 ;part1.c,46 :: PORTB.F2 =0; $0146 $9481 BCF PORTB, 2, 0 ;part1.c,47 :: delay_ms(10); $0148 $0E1A MOVLW 26 $014A $6E0B MOVWF STACK_11, 0 $014C $0EFF MOVLW 255 $014E $6E0A MOVWF STACK_10, 0 $0150 $2E0B DECFSZ STACK_11, F, 0 $0152 $D001 BRA $+2 $0154 $D003 BRA $+4 $0156 $2E0A DECFSZ STACK_10, F, 0 $0158 $D7FE BRA $-1 $015A $D7FA BRA $-5 $015C $0EE7 MOVLW 231 $015E $6E0A MOVWF STACK_10, 0 $0160 $2E0A DECFSZ STACK_10, F, 0 $0162 $D7FE BRA $-1 $0164 $0000 NOP ;part1.c,48 :: var = PORTD; $0166 $CF83 F074 MOVFF PORTD, read_keypad_var_L0 ;part1.c,50 :: if (var.F3 == 0) key = '3'; $016A $6A01 CLRF STACK_1, 0 $016C $B674 BTFSC read_keypad_var_L0, 3, 0 $016E $2A01 INCF STACK_1, 1, 0 $0170 $5001 MOVF STACK_1, 0, 0 $0172 $0A00 XORLW 0 $0174 $E102 BNZ L_read_keypad_8 $0176 $0E33 MOVLW 51 $0178 $6E75 MOVWF read_keypad_key_L0, 0 $017A $ L_read_keypad_8: ;part1.c,51 :: PORTB.F2 =1; $017A $8481 BSF PORTB, 2, 0 ;part1.c,52 :: }while (key == 0); $017C $5075 MOVF read_keypad_key_L0, 0, 0 $017E $0A00 XORLW 0 $0180 $E09A BZ L_read_keypad_0 $0182 $ L_read_keypad_1: ;part1.c,54 :: return key; $0182 $C075 F000 MOVFF read_keypad_key_L0, STACK_0 ;part1.c,55 :: } $0186 $0012 RETURN $0188 $ _function_numbers: ;part1.c,57 :: unsigned char function_numbers(unsigned char v) ;part1.c,59 :: switch(v) $0188 $D00F BRA L_function_numbers_9 ;part1.c,61 :: case 1: $018A $ L_function_numbers_11: ;part1.c,62 :: return 0x06; $018A $0E06 MOVLW 6 $018C $6E00 MOVWF STACK_0, 0 $018E $0012 RETURN ;part1.c,63 :: case 2: $0190 $ L_function_numbers_12: ;part1.c,64 :: return 0x5B; $0190 $0E5B MOVLW 91 $0192 $6E00 MOVWF STACK_0, 0 $0194 $0012 RETURN ;part1.c,65 :: case 3: $0196 $ L_function_numbers_13: ;part1.c,66 :: return 0x4F; $0196 $0E4F MOVLW 79 $0198 $6E00 MOVWF STACK_0, 0 $019A $0012 RETURN ;part1.c,67 :: case 4: $019C $ L_function_numbers_14: ;part1.c,68 :: return 0x66; $019C $0E66 MOVLW 102 $019E $6E00 MOVWF STACK_0, 0 $01A0 $0012 RETURN ;part1.c,69 :: case 5: $01A2 $ L_function_numbers_15: ;part1.c,70 :: return 0x6D; $01A2 $0E6D MOVLW 109 $01A4 $6E00 MOVWF STACK_0, 0 $01A6 $0012 RETURN ;part1.c,72 :: } $01A8 $ L_function_numbers_9: $01A8 $5074 MOVF FARG_function_numbers+0, 0, 0 $01AA $0A01 XORLW 1 $01AC $E0EE BZ L_function_numbers_11 $01AE $5074 MOVF FARG_function_numbers+0, 0, 0 $01B0 $0A02 XORLW 2 $01B2 $E0EE BZ L_function_numbers_12 $01B4 $5074 MOVF FARG_function_numbers+0, 0, 0 $01B6 $0A03 XORLW 3 $01B8 $E0EE BZ L_function_numbers_13 $01BA $5074 MOVF FARG_function_numbers+0, 0, 0 $01BC $0A04 XORLW 4 $01BE $E0EE BZ L_function_numbers_14 $01C0 $5074 MOVF FARG_function_numbers+0, 0, 0 $01C2 $0A05 XORLW 5 $01C4 $E0EE BZ L_function_numbers_15 $01C6 $ L_function_numbers_10: ;part1.c,73 :: return 0; $01C6 $6A00 CLRF STACK_0, 0 ;part1.c,74 :: } $01C8 $0012 RETURN $01CA $ _Soft_I2C_Start: $01CA $C015 FFE9 MOVFF ___porti2c, FSR0L $01CE $0E0F MOVLW 15 $01D0 $6EEA MOVWF FSR0H, 0 $01D2 $88EF BSF INDF0, ____sdai2c, 0 $01D4 $EC04 F000 CALL _Delay_1us $01D8 $86EF BSF INDF0, ____scli2c, 0 $01DA $EC04 F000 CALL _Delay_1us $01DE $EC1C F000 CALL SoftI2C_PutZerosToLAT $01E2 $98EF BCF INDF0, ____sdai2c, 0 $01E4 $EC04 F000 CALL _Delay_1us $01E8 $EC1C F000 CALL SoftI2C_PutZerosToLAT $01EC $96EF BCF INDF0, ____scli2c, 0 $01EE $0012 RETURN $01F0 $ _Soft_I2C_Write: $01F0 $0E01 MOVLW 1 $01F2 $6E76 MOVWF Soft_I2C_Write_result_L0, 0 $01F4 $0E08 MOVLW 8 $01F6 $6E75 MOVWF Soft_I2C_Write_temp_L0, 0 $01F8 $C015 FFE9 MOVFF ___porti2c, FSR0L $01FC $0E0F MOVLW 15 $01FE $6EEA MOVWF FSR0H, 0 $0200 $ L_Soft_I2C_Write_4: $0200 $5275 MOVF Soft_I2C_Write_temp_L0, 1, 0 $0202 $E022 BZ L_Soft_I2C_Write_5 $0204 $EC04 F000 CALL _Delay_1us $0208 $EC04 F000 CALL _Delay_1us $020C $EC1C F000 CALL SoftI2C_PutZerosToLAT $0210 $96EF BCF INDF0, ____scli2c, 0 $0212 $EC04 F000 CALL _Delay_1us $0216 $5274 MOVF FARG_Soft_I2C_Write+0, 1, 0 $0218 $E000 BZ L_Soft_I2C_Write_6 $021A $ L_Soft_I2C_Write_6: $021A $EC1C F000 CALL SoftI2C_PutZerosToLAT $021E $3674 RLCF FARG_soft_i2c_write+0, F, 0 $0220 $A0D8 BTFSS STATUS, 0, 0 $0222 $EF16 F001 GOTO l_018 $0226 $88EF BSF INDF0, ____sdai2c, 0 $0228 $EF17 F001 GOTO l_01C $022C $ l_018: $022C $98EF BCF INDF0, ____sdai2c, 0 $022E $ l_01C: $022E $0000 NOP $0230 $EC04 F000 CALL _Delay_1us $0234 $86EF BSF INDF0, ____scli2c, 0 $0236 $0E12 MOVLW 18 $0238 $5EE9 SUBWF FSR0L, F, 0 $023A $A6EF BTFSS INDF0, ____scli2c, 0 $023C $EF1D F001 GOTO $-1 $0240 $0E12 MOVLW 18 $0242 $26E9 ADDWF FSR0L, F, 0 $0244 $0675 DECF Soft_I2C_Write_temp_L0, 1, 0 $0246 $D7DC BRA L_Soft_I2C_Write_4 $0248 $ L_Soft_I2C_Write_5: $0248 $6A76 CLRF Soft_I2C_Write_result_L0, 0 $024A $EC04 F000 CALL _Delay_1us $024E $EC1C F000 CALL SoftI2C_PutZerosToLAT $0252 $0000 NOP $0254 $96EF BCF INDF0, ____scli2c, 0 $0256 $EC04 F000 CALL _Delay_1us $025A $88EF BSF INDF0, ____sdai2c, 0 $025C $EC04 F000 CALL _Delay_1us $0260 $EC04 F000 CALL _Delay_1us $0264 $5276 MOVF Soft_I2C_Write_result_L0, 1, 0 $0266 $E000 BZ L_Soft_I2C_Write_7 $0268 $ L_Soft_I2C_Write_7: $0268 $86EF BSF INDF0, ____scli2c, 0 $026A $0E12 MOVLW 18 $026C $5EE9 SUBWF FSR0L, F, 0 $026E $A6EF BTFSS INDF0, ____scli2c, 0 $0270 $EF37 F001 GOTO $-1 $0274 $6A76 CLRF FLOC_soft_i2c_write+1, 0 $0276 $EC04 F000 CALL _Delay_1us $027A $B8EF BTFSC INDF0, ____sdai2c, 0 $027C $8076 BSF FLOC_soft_i2c_write+1, 0, 0 $027E $EC04 F000 CALL _Delay_1us $0282 $EC04 F000 CALL _Delay_1us $0286 $EC04 F000 CALL _Delay_1us $028A $EC04 F000 CALL _Delay_1us $028E $EC04 F000 CALL _Delay_1us $0292 $EC04 F000 CALL _Delay_1us $0296 $EC04 F000 CALL _Delay_1us $029A $EC04 F000 CALL _Delay_1us $029E $EC1C F000 CALL SoftI2C_PutZerosToLAT $02A2 $0E12 MOVLW 18 $02A4 $26E9 ADDWF FSR0L, F, 0 $02A6 $96EF BCF INDF0, ____scli2c, 0 $02A8 $98EF BCF INDF0, ____sdai2c, 0 $02AA $C076 F000 MOVFF Soft_I2C_Write_result_L0, STACK_0 $02AE $0012 RETURN $02B0 $ _Soft_I2C_Read: $02B0 $6A75 CLRF Soft_I2C_Read_result_L0, 0 $02B2 $0E08 MOVLW 8 $02B4 $6E76 MOVWF Soft_I2C_Read_temp_L0, 0 $02B6 $C015 FFE9 MOVFF ___porti2c, FSR0L $02BA $0E0F MOVLW 15 $02BC $6EEA MOVWF FSR0H, 0 $02BE $ L_Soft_I2C_Read_0: $02BE $5276 MOVF Soft_I2C_Read_temp_L0, 1, 0 $02C0 $E01C BZ L_Soft_I2C_Read_1 $02C2 $EC04 F000 CALL _Delay_1us $02C6 $0000 NOP $02C8 $88EF BSF INDF0, ____sdai2c, 0 $02CA $EC04 F000 CALL _Delay_1us $02CE $5275 MOVF Soft_I2C_Read_result_L0, 1, 0 $02D0 $E000 BZ L_Soft_I2C_Read_2 $02D2 $ L_Soft_I2C_Read_2: $02D2 $86EF BSF INDF0, ____scli2c, 0 $02D4 $0E12 MOVLW 18 $02D6 $5EE9 SUBWF FSR0L, F, 0 $02D8 $A6EF BTFSS INDF0, ____scli2c, 0 $02DA $EF6C F001 GOTO $-1 $02DE $B8EF BTFSC INDF0, ____sdai2c, 0 $02E0 $80D8 BSF STATUS, C, 0 $02E2 $A8EF BTFSS INDF0, ____sdai2c, 0 $02E4 $90D8 BCF STATUS, C, 0 $02E6 $3675 RLCF FLOC_soft_i2c_read+0, F, 0 $02E8 $EC04 F000 CALL _Delay_1us $02EC $EC1C F000 CALL SoftI2C_PutZerosToLAT $02F0 $0E12 MOVLW 18 $02F2 $26E9 ADDWF FSR0L, F, 0 $02F4 $96EF BCF INDF0, ____scli2c, 0 $02F6 $0676 DECF Soft_I2C_Read_temp_L0, 1, 0 $02F8 $D7E2 BRA L_Soft_I2C_Read_0 $02FA $ L_Soft_I2C_Read_1: $02FA $88EF BSF INDF0, ____sdai2c, 0 $02FC $EC04 F000 CALL _Delay_1us $0300 $5274 MOVF FARG_Soft_I2C_Read+0, 1, 0 $0302 $E002 BZ L_Soft_I2C_Read_3 $0304 $EC1C F000 CALL SoftI2C_PutZerosToLAT $0308 $ L_Soft_I2C_Read_3: $0308 $5074 MOVF FARG_soft_i2c_read+0, W, 0 $030A $B4D8 BTFSC STATUS, 2, 0 $030C $EF89 F001 GOTO L_07C $0310 $98EF BCF INDF0, ____sdai2c, 0 $0312 $ L_07C: $0312 $0000 NOP $0314 $EC04 F000 CALL _Delay_1us $0318 $86EF BSF INDF0, ____scli2c, 0 $031A $0E12 MOVLW 18 $031C $5EE9 SUBWF FSR0L, F, 0 $031E $A6EF BTFSS INDF0, ____scli2c, 0 $0320 $EF8F F001 GOTO $-1 $0324 $0E12 MOVLW 18 $0326 $26E9 ADDWF FSR0L, F, 0 $0328 $EC04 F000 CALL _Delay_1us $032C $EC1C F000 CALL SoftI2C_PutZerosToLAT $0330 $96EF BCF INDF0, ____scli2c, 0 $0332 $EC04 F000 CALL _Delay_1us $0336 $EC1C F000 CALL SoftI2C_PutZerosToLAT $033A $98EF BCF INDF0, ____sdai2c, 0 $033C $C075 F000 MOVFF Soft_I2C_Read_result_L0, STACK_0 $0340 $0012 RETURN $0342 $ _Soft_I2C_Stop: $0342 $C015 FFE9 MOVFF ___porti2c, FSR0L $0346 $0E0F MOVLW 15 $0348 $6EEA MOVWF FSR0H, 0 $034A $EC1C F000 CALL SoftI2C_PutZerosToLAT $034E $98EF BCF INDF0, ____sdai2c, 0 $0350 $EC04 F000 CALL _Delay_1us $0354 $86EF BSF INDF0, ____scli2c, 0 $0356 $0E12 MOVLW 18 $0358 $5EE9 SUBWF FSR0L, F, 0 $035A $A6EF BTFSS INDF0, ____scli2c, 0 $035C $EFAD F001 GOTO $-1 $0360 $0E12 MOVLW 18 $0362 $26E9 ADDWF FSR0L, F, 0 $0364 $EC04 F000 CALL _Delay_1us $0368 $EC04 F000 CALL _Delay_1us $036C $EC04 F000 CALL _Delay_1us $0370 $EC04 F000 CALL _Delay_1us $0374 $88EF BSF INDF0, ____sdai2c, 0 $0376 $EC04 F000 CALL _Delay_1us $037A $0012 RETURN $037C $ _LCD8_Out: $037C $D00F BRA L_LCD8_Out_12 $037E $ L_LCD8_Out_14: $037E $0E80 MOVLW 128 $0380 $6E74 MOVWF FARG_LCD8_Out+0, 0 $0382 $D019 BRA L_LCD8_Out_13 $0384 $ L_LCD8_Out_15: $0384 $0EC0 MOVLW 192 $0386 $6E74 MOVWF FARG_LCD8_Out+0, 0 $0388 $D016 BRA L_LCD8_Out_13 $038A $ L_LCD8_Out_16: $038A $0E94 MOVLW 148 $038C $6E74 MOVWF FARG_LCD8_Out+0, 0 $038E $D013 BRA L_LCD8_Out_13 $0390 $ L_LCD8_Out_17: $0390 $0ED4 MOVLW 212 $0392 $6E74 MOVWF FARG_LCD8_Out+0, 0 $0394 $D010 BRA L_LCD8_Out_13 $0396 $ L_LCD8_Out_18: $0396 $0E80 MOVLW 128 $0398 $6E74 MOVWF FARG_LCD8_Out+0, 0 $039A $D00D BRA L_LCD8_Out_13 $039C $ L_LCD8_Out_12: $039C $5074 MOVF FARG_LCD8_Out+0, 0, 0 $039E $0A01 XORLW 1 $03A0 $E0EE BZ L_LCD8_Out_14 $03A2 $5074 MOVF FARG_LCD8_Out+0, 0, 0 $03A4 $0A02 XORLW 2 $03A6 $E0EE BZ L_LCD8_Out_15 $03A8 $5074 MOVF FARG_LCD8_Out+0, 0, 0 $03AA $0A03 XORLW 3 $03AC $E0EE BZ L_LCD8_Out_16 $03AE $5074 MOVF FARG_LCD8_Out+0, 0, 0 $03B0 $0A04 XORLW 4 $03B2 $E0EE BZ L_LCD8_Out_17 $03B4 $D7F0 BRA L_LCD8_Out_18 $03B6 $ L_LCD8_Out_13: $03B6 $0475 DECF FARG_LCD8_Out+1, 0, 0 $03B8 $6E00 MOVWF STACK_0, 0 $03BA $5074 MOVF FARG_LCD8_Out+0, 0, 0 $03BC $2600 ADDWF STACK_0, 1, 0 $03BE $C000 F074 MOVFF STACK_0, FARG_LCD8_Out+0 $03C2 $0E01 MOVLW 1 $03C4 $6E1A MOVWF Lcd8bit_main_global_cmd, 0 $03C6 $C000 F079 MOVFF STACK_0, FARG_Lcd8_Cmd+0 $03CA $EC24 F000 CALL _Lcd8_Cmd $03CE $6A1A CLRF Lcd8bit_main_global_cmd, 0 $03D0 $6A78 CLRF LCD8_Out_i_L0, 0 $03D2 $ L_LCD8_Out_19: $03D2 $5078 MOVF LCD8_Out_i_L0, 0, 0 $03D4 $2476 ADDWF FARG_LCD8_Out+2, 0, 0 $03D6 $6EE9 MOVWF FSR0L, 0 $03D8 $0E00 MOVLW 0 $03DA $2077 ADDWFC FARG_LCD8_Out+3, 0, 0 $03DC $6EEA MOVWF FSR0L+1, 0 $03DE $CFEE F000 MOVFF POSTINC0, STACK_0 $03E2 $5200 MOVF STACK_0, 1, 0 $03E4 $E00C BZ L_LCD8_Out_20 $03E6 $5078 MOVF LCD8_Out_i_L0, 0, 0 $03E8 $2476 ADDWF FARG_LCD8_Out+2, 0, 0 $03EA $6EE9 MOVWF FSR0L, 0 $03EC $0E00 MOVLW 0 $03EE $2077 ADDWFC FARG_LCD8_Out+3, 0, 0 $03F0 $6EEA MOVWF FSR0L+1, 0 $03F2 $CFEE F079 MOVFF POSTINC0, FARG_Lcd8_Cmd+0 $03F6 $EC24 F000 CALL _Lcd8_Cmd $03FA $2A78 INCF LCD8_Out_i_L0, 1, 0 $03FC $D7EA BRA L_LCD8_Out_19 $03FE $ L_LCD8_Out_20: $03FE $0E01 MOVLW 1 $0400 $6E1A MOVWF Lcd8bit_main_global_cmd, 0 $0402 $0012 RETURN $0404 $ _I2C_Init: $0404 $9CC7 BCF SSPSTAT, 6, 0 $0406 $9EC7 BCF SSPSTAT, 7, 0 $0408 $8894 BSF TRISC, 4, 0 $040A $8694 BSF TRISC, 3, 0 $040C $0E38 MOVLW 56 $040E $6EC6 MOVWF SSPCON1, 0 $0410 $0012 RETURN $0412 $ _Soft_I2C_Init: $0412 $C074 FFE9 MOVFF FARG_Soft_I2C_Init+0, FSR0L $0416 $C075 FFEA MOVFF FARG_Soft_I2C_Init+1, FSR0H $041A $0E12 MOVLW 18 $041C $2474 ADDWF FARG_Soft_I2C_Init+0, 0, 0 $041E $6E00 MOVWF STACK_0, 0 $0420 $C000 F015 MOVFF STACK_0, ___porti2c $0424 $C000 FFE9 MOVFF STACK_0, FSR0L $0428 $88EF BSF INDF0, ____sdai2c, 0 $042A $86EF BSF INDF0, ____scli2c, 0 $042C $0E12 MOVLW 18 $042E $5EE9 SUBWF FSR0L, 1, 0 $0430 $A6EF BTFSS INDF0, ____scli2c, 0 $0432 $EF18 F002 GOTO $-1 $0436 $0012 RETURN $0438 $ _Lcd8_Init: $0438 $EC07 F000 CALL _Delay_5500us $043C $EC07 F000 CALL _Delay_5500us $0440 $EC07 F000 CALL _Delay_5500us $0444 $C076 F016 MOVFF FARG_Lcd8_Init+2, Lcd8bit_main_global_dataAddress $0448 $C077 F017 MOVFF FARG_Lcd8_Init+3, Lcd8bit_main_global_dataAddress+1 $044C $C074 F018 MOVFF FARG_Lcd8_Init+0, Lcd8bit_main_global_ctrlAddress $0450 $C075 F019 MOVFF FARG_Lcd8_Init+1, Lcd8bit_main_global_ctrlAddress+1 $0454 $C074 FFE9 MOVFF FARG_Lcd8_Init+0, FSR0L $0458 $C075 FFEA MOVFF FARG_Lcd8_Init+1, FSR0H $045C $90EF BCF INDF0, __LCD8_RW, 0 $045E $C076 FFE1 MOVFF FARG_Lcd8_Init+2, FSR1L $0462 $C077 FFE2 MOVFF FARG_Lcd8_Init+3, FSR1H $0466 $6AE6 CLRF POSTINC1, 0 $0468 $0E11 MOVLW 17 $046A $24E1 ADDWF FSR1L, 0, 0 $046C $6E00 MOVWF STACK_0, 0 $046E $C000 FFE1 MOVFF STACK_0, FSR1L $0472 $6AE7 CLRF INDF1, 0 $0474 $0E12 MOVLW 18 $0476 $5C00 SUBWF STACK_0, 0, 0 $0478 $6EE1 MOVWF FSR1L, 0 $047A $0E12 MOVLW 18 $047C $26E9 ADDWF FSR0L, 1, 0 $047E $92EF BCF INDF0, __LCD8_ENABLE, 0 $0480 $94EF BCF INDF0, __LCD8_RS, 0 $0482 $90EF BCF INDF0, __LCD8_RW, 0 $0484 $0E12 MOVLW 18 $0486 $5EE9 SUBWF FSR0L, 1, 0 $0488 $94EF BCF INDF0, __LCD8_RS, 0 $048A $92EF BCF INDF0, __LCD8_ENABLE, 0 $048C $90EF BCF INDF0, __LCD8_RW, 0 $048E $0E30 MOVLW 48 $0490 $6E79 MOVWF FARG_Lcd8_Cmd+0, 0 $0492 $EC24 F000 CALL _Lcd8_Cmd $0496 $0E30 MOVLW 48 $0498 $6E79 MOVWF FARG_Lcd8_Cmd+0, 0 $049A $EC24 F000 CALL _Lcd8_Cmd $049E $0E30 MOVLW 48 $04A0 $6E79 MOVWF FARG_Lcd8_Cmd+0, 0 $04A2 $EC24 F000 CALL _Lcd8_Cmd $04A6 $0E38 MOVLW 56 $04A8 $6E79 MOVWF FARG_Lcd8_Cmd+0, 0 $04AA $EC24 F000 CALL _Lcd8_Cmd $04AE $0E08 MOVLW 8 $04B0 $6E79 MOVWF FARG_Lcd8_Cmd+0, 0 $04B2 $EC24 F000 CALL _Lcd8_Cmd $04B6 $0E01 MOVLW 1 $04B8 $6E79 MOVWF FARG_Lcd8_Cmd+0, 0 $04BA $EC24 F000 CALL _Lcd8_Cmd $04BE $0E06 MOVLW 6 $04C0 $6E79 MOVWF FARG_Lcd8_Cmd+0, 0 $04C2 $EC24 F000 CALL _Lcd8_Cmd $04C6 $0E0C MOVLW 12 $04C8 $6E79 MOVWF FARG_Lcd8_Cmd+0, 0 $04CA $EC24 F000 CALL _Lcd8_Cmd $04CE $0E01 MOVLW 1 $04D0 $6E1A MOVWF Lcd8bit_main_global_cmd, 0 $04D2 $0012 RETURN $04D4 $ _main: $04D4 $0E54 MOVLW 84 $04D6 $6E54 MOVWF lstr1_part1+0, 0 $04D8 $0E69 MOVLW 105 $04DA $6E55 MOVWF lstr1_part1+1, 0 $04DC $0E6D MOVLW 109 $04DE $6E56 MOVWF lstr1_part1+2, 0 $04E0 $0E65 MOVLW 101 $04E2 $6E57 MOVWF lstr1_part1+3, 0 $04E4 $0E3D MOVLW 61 $04E6 $6E58 MOVWF lstr1_part1+4, 0 $04E8 $6A59 CLRF lstr1_part1+5, 0 $04EA $0E3A MOVLW 58 $04EC $6E5A MOVWF lstr2_part1+0, 0 $04EE $6A5B CLRF lstr2_part1+1, 0 $04F0 $0E20 MOVLW 32 $04F2 $6E5C MOVWF lstr3_part1+0, 0 $04F4 $6A5D CLRF lstr3_part1+1, 0 $04F6 $0E20 MOVLW 32 $04F8 $6E5E MOVWF lstr4_part1+0, 0 $04FA $6A5F CLRF lstr4_part1+1, 0 $04FC $0E20 MOVLW 32 $04FE $6E60 MOVWF lstr5_part1+0, 0 $0500 $6A61 CLRF lstr5_part1+1, 0 $0502 $0E20 MOVLW 32 $0504 $6E62 MOVWF lstr6_part1+0, 0 $0506 $6A63 CLRF lstr6_part1+1, 0 $0508 $0E20 MOVLW 32 $050A $6E64 MOVWF lstr7_part1+0, 0 $050C $6A65 CLRF lstr7_part1+1, 0 $050E $0E20 MOVLW 32 $0510 $6E66 MOVWF lstr8_part1+0, 0 $0512 $6A67 CLRF lstr8_part1+1, 0 $0514 $0E44 MOVLW 68 $0516 $6E68 MOVWF lstr9_part1+0, 0 $0518 $0E61 MOVLW 97 $051A $6E69 MOVWF lstr9_part1+1, 0 $051C $0E74 MOVLW 116 $051E $6E6A MOVWF lstr9_part1+2, 0 $0520 $0E65 MOVLW 101 $0522 $6E6B MOVWF lstr9_part1+3, 0 $0524 $0E3D MOVLW 61 $0526 $6E6C MOVWF lstr9_part1+4, 0 $0528 $6A6D CLRF lstr9_part1+5, 0 $052A $0E2F MOVLW 47 $052C $6E6E MOVWF lstr10_part1+0, 0 $052E $6A6F CLRF lstr10_part1+1, 0 $0530 $0E2F MOVLW 47 $0532 $6E70 MOVWF lstr11_part1+0, 0 $0534 $6A71 CLRF lstr11_part1+1, 0 ;part1.c,77 :: void main() { ;part1.c,83 :: keypressed = read_keypad(); $0536 $EC53 F000 CALL _read_keypad $053A $C000 F072 MOVFF STACK_0, main_keypressed_L0 ;part1.c,86 :: TRISD = 0x00; //Define PORTD to operate as outpout $053E $6A95 CLRF TRISD, 0 ;part1.c,87 :: TRISA = 0xFB; // Define PORTA pin 2 as output. $0540 $0EFB MOVLW 251 $0542 $6E92 MOVWF TRISA, 0 ;part1.c,90 :: keypressed = keypressed - 0x30; $0544 $0E30 MOVLW 48 $0546 $5E00 SUBWF STACK_0, 1, 0 $0548 $C000 F072 MOVFF STACK_0, main_keypressed_L0 ;part1.c,92 :: PORTD = function_numbers(keypressed); //Write the appropriate combination of bits to PORTD $054C $C000 F074 MOVFF STACK_0, FARG_function_numbers+0 $0550 $ECC4 F000 CALL _function_numbers $0554 $C000 FF83 MOVFF STACK_0, PORTD ;part1.c,93 :: switch (function_numbers(keypressed)) $0558 $C072 F074 MOVFF main_keypressed_L0, FARG_function_numbers+0 $055C $ECC4 F000 CALL _function_numbers $0560 $C000 F073 MOVFF STACK_0, FLOC_main+31 $0564 $D22E BRA L_main_16 ;part1.c,95 :: case 0x06: $0566 $ L_main_18: ;part1.c,97 :: TRISE = 0x00; // PORTE is output $0566 $6A96 CLRF TRISE, 0 ;part1.c,98 :: TRISD = 0x00; // PORTD is output $0568 $6A95 CLRF TRISD, 0 ;part1.c,99 :: I2C_Init(100000); $056A $0E14 MOVLW 20 $056C $6EC8 MOVWF SSPADD, 0 $056E $EC02 F002 CALL _I2C_Init ;part1.c,102 :: Soft_I2C_Config(&PORTC, 4, 3); //Use Port C pins 4 and 3 $0572 $0E82 MOVLW PORTC $0574 $6E74 MOVWF FARG_Soft_I2C_Init+0, 0 $0576 $0E0F MOVLW @PORTC $0578 $6E75 MOVWF FARG_Soft_I2C_Init+1, 0 $057A $EC09 F002 CALL _Soft_I2C_Init ;part1.c,103 :: Soft_I2C_Start(); // Issue I2C start signal $057E $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,104 :: Soft_I2C_Write(0xD0); // Send byte (device address + W) $0582 $0ED0 MOVLW 208 $0584 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0586 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,105 :: Soft_I2C_Write(1); // Send byte (Location of minutes register) $058A $0E01 MOVLW 1 $058C $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $058E $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,106 :: Soft_I2C_Start(); // Issue I2C start signal $0592 $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,107 :: Soft_I2C_Write(0xD1); // Send byte (device address + R) $0596 $0ED1 MOVLW 209 $0598 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $059A $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,108 :: tempm = Soft_I2C_Read(0); // Read data (NO ACK) $059E $6A74 CLRF FARG_Soft_I2C_Read+0, 0 $05A0 $EC58 F001 CALL _Soft_I2C_Read $05A4 $C000 F01B MOVFF STACK_0, _tempm ;part1.c,109 :: Soft_I2C_Stop(); $05A8 $ECA1 F001 CALL _Soft_I2C_Stop ;part1.c,110 :: minutes[0]=((tempm & 0x70)>>4)+0x30; $05AC $0E70 MOVLW 112 $05AE $141B ANDWF _tempm, 0, 0 $05B0 $6E1C MOVWF _minutes, 0 $05B2 $321C RRCF _minutes, 1, 0 $05B4 $9E1C BCF _minutes, 7, 0 $05B6 $321C RRCF _minutes, 1, 0 $05B8 $9E1C BCF _minutes, 7, 0 $05BA $321C RRCF _minutes, 1, 0 $05BC $9E1C BCF _minutes, 7, 0 $05BE $321C RRCF _minutes, 1, 0 $05C0 $9E1C BCF _minutes, 7, 0 $05C2 $0E30 MOVLW 48 $05C4 $261C ADDWF _minutes, 1, 0 ;part1.c,111 :: minutes[1]= (tempm & 0x0F) +0x30; $05C6 $0E0F MOVLW 15 $05C8 $141B ANDWF _tempm, 0, 0 $05CA $6E1D MOVWF _minutes+1, 0 $05CC $0E30 MOVLW 48 $05CE $261D ADDWF _minutes+1, 1, 0 ;part1.c,114 :: Soft_I2C_Config(&PORTC, 4, 3); //Use Port C pins 4 and 3 $05D0 $0E82 MOVLW PORTC $05D2 $6E74 MOVWF FARG_Soft_I2C_Init+0, 0 $05D4 $0E0F MOVLW @PORTC $05D6 $6E75 MOVWF FARG_Soft_I2C_Init+1, 0 $05D8 $EC09 F002 CALL _Soft_I2C_Init ;part1.c,115 :: Soft_I2C_Start(); // Issue I2C start signal $05DC $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,116 :: Soft_I2C_Write(0xD0); // Send byte (device address + W) $05E0 $0ED0 MOVLW 208 $05E2 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $05E4 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,117 :: Soft_I2C_Write(2); // Send byte (Location of hours register) $05E8 $0E02 MOVLW 2 $05EA $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $05EC $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,118 :: Soft_I2C_Start(); // Issue I2C start signal $05F0 $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,119 :: Soft_I2C_Write(0xD1); // Send byte (device address + R) $05F4 $0ED1 MOVLW 209 $05F6 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $05F8 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,120 :: temph = Soft_I2C_Read(0); // Read data (NO ACK) $05FC $6A74 CLRF FARG_Soft_I2C_Read+0, 0 $05FE $EC58 F001 CALL _Soft_I2C_Read $0602 $C000 F01E MOVFF STACK_0, _temph ;part1.c,121 :: Soft_I2C_Stop(); $0606 $ECA1 F001 CALL _Soft_I2C_Stop ;part1.c,122 :: hours[0]=((temph & 0x30)>>4)+0x30; $060A $0E30 MOVLW 48 $060C $141E ANDWF _temph, 0, 0 $060E $6E1F MOVWF _hours, 0 $0610 $321F RRCF _hours, 1, 0 $0612 $9E1F BCF _hours, 7, 0 $0614 $321F RRCF _hours, 1, 0 $0616 $9E1F BCF _hours, 7, 0 $0618 $321F RRCF _hours, 1, 0 $061A $9E1F BCF _hours, 7, 0 $061C $321F RRCF _hours, 1, 0 $061E $9E1F BCF _hours, 7, 0 $0620 $0E30 MOVLW 48 $0622 $261F ADDWF _hours, 1, 0 ;part1.c,123 :: hours[1]= (temph & 0x0F) +0x30; $0624 $0E0F MOVLW 15 $0626 $141E ANDWF _temph, 0, 0 $0628 $6E20 MOVWF _hours+1, 0 $062A $0E30 MOVLW 48 $062C $2620 ADDWF _hours+1, 1, 0 ;part1.c,127 :: Soft_I2C_Config(&PORTC, 4, 3); //Use PortC pins 4 and 3 $062E $0E82 MOVLW PORTC $0630 $6E74 MOVWF FARG_Soft_I2C_Init+0, 0 $0632 $0E0F MOVLW @PORTC $0634 $6E75 MOVWF FARG_Soft_I2C_Init+1, 0 $0636 $EC09 F002 CALL _Soft_I2C_Init ;part1.c,128 :: Soft_I2C_Start(); // Issue I2C start signal $063A $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,129 :: Soft_I2C_Write(0xA2); // Send byte via I2C (Address of 24cO2) $063E $0EA2 MOVLW 162 $0640 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0642 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,130 :: Soft_I2C_Write(2); // Send byte (address of EEPROM location) $0646 $0E02 MOVLW 2 $0648 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $064A $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,131 :: Soft_I2C_Write(hours); // Send data (data to be written) $064E $0E1F MOVLW _hours $0650 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0652 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,132 :: Soft_I2C_Write(minutes); // Send data (data to be written) $0656 $0E1C MOVLW _minutes $0658 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $065A $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,133 :: Soft_I2C_Stop(); $065E $ECA1 F001 CALL _Soft_I2C_Stop ;part1.c,135 :: Soft_I2C_Start(); // Issue I2C start signal $0662 $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,136 :: Soft_I2C_Write(0xA2); // Send byte (device address + W) $0666 $0EA2 MOVLW 162 $0668 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $066A $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,137 :: Soft_I2C_Write(2); // Send byte (EEPROM location to read from) $066E $0E02 MOVLW 2 $0670 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0672 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,138 :: Soft_I2C_Start(); // Issue I2C start signal $0676 $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,139 :: Soft_I2C_Write(0xA3); // Send byte (device address + R) $067A $0EA3 MOVLW 163 $067C $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $067E $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,140 :: mem_data[0] = Soft_I2C_Read(1); // Read data (send ACK) $0682 $0E01 MOVLW 1 $0684 $6E74 MOVWF FARG_Soft_I2C_Read+0, 0 $0686 $EC58 F001 CALL _Soft_I2C_Read $068A $C000 F021 MOVFF STACK_0, _mem_data $068E $0E00 MOVLW 0 $0690 $6E22 MOVWF _mem_data+1, 0 ;part1.c,141 :: mem_data[1] = Soft_I2C_Read(1); // Read data (send ACK) $0692 $0E01 MOVLW 1 $0694 $6E74 MOVWF FARG_Soft_I2C_Read+0, 0 $0696 $EC58 F001 CALL _Soft_I2C_Read $069A $C000 F023 MOVFF STACK_0, _mem_data+2 $069E $0E00 MOVLW 0 $06A0 $6E24 MOVWF _mem_data+3, 0 ;part1.c,145 :: Soft_I2C_Config(&PORTC, 4, 3); //Use Port C pins 4 and 3 $06A2 $0E82 MOVLW PORTC $06A4 $6E74 MOVWF FARG_Soft_I2C_Init+0, 0 $06A6 $0E0F MOVLW @PORTC $06A8 $6E75 MOVWF FARG_Soft_I2C_Init+1, 0 $06AA $EC09 F002 CALL _Soft_I2C_Init ;part1.c,146 :: Soft_I2C_Start(); // Issue I2C start signal $06AE $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,147 :: Soft_I2C_Write(0xD0); // Send byte (device address + W) $06B2 $0ED0 MOVLW 208 $06B4 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $06B6 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,148 :: Soft_I2C_Write(4); // Send byte (Location of day register) $06BA $0E04 MOVLW 4 $06BC $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $06BE $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,149 :: Soft_I2C_Start(); // Issue I2C start signal $06C2 $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,150 :: Soft_I2C_Write(0xD1); // Send byte (device address + R) $06C6 $0ED1 MOVLW 209 $06C8 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $06CA $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,151 :: tempDay = Soft_I2C_Read(0); // Read data (NO ACK) $06CE $6A74 CLRF FARG_Soft_I2C_Read+0, 0 $06D0 $EC58 F001 CALL _Soft_I2C_Read $06D4 $C000 F035 MOVFF STACK_0, _tempDay ;part1.c,152 :: Soft_I2C_Stop(); $06D8 $ECA1 F001 CALL _Soft_I2C_Stop ;part1.c,153 :: day[0]=((tempDay & 0x70)>>4)+0x30; $06DC $0E70 MOVLW 112 $06DE $1435 ANDWF _tempDay, 0, 0 $06E0 $6E36 MOVWF _day, 0 $06E2 $3236 RRCF _day, 1, 0 $06E4 $9E36 BCF _day, 7, 0 $06E6 $3236 RRCF _day, 1, 0 $06E8 $9E36 BCF _day, 7, 0 $06EA $3236 RRCF _day, 1, 0 $06EC $9E36 BCF _day, 7, 0 $06EE $3236 RRCF _day, 1, 0 $06F0 $9E36 BCF _day, 7, 0 $06F2 $0E30 MOVLW 48 $06F4 $2636 ADDWF _day, 1, 0 ;part1.c,154 :: day[1]= (tempDay & 0x0F) +0x30; $06F6 $0E0F MOVLW 15 $06F8 $1435 ANDWF _tempDay, 0, 0 $06FA $6E37 MOVWF _day+1, 0 $06FC $0E30 MOVLW 48 $06FE $2637 ADDWF _day+1, 1, 0 ;part1.c,157 :: Soft_I2C_Config(&PORTC, 4, 3); //Use Port C pins 4 and 3 $0700 $0E82 MOVLW PORTC $0702 $6E74 MOVWF FARG_Soft_I2C_Init+0, 0 $0704 $0E0F MOVLW @PORTC $0706 $6E75 MOVWF FARG_Soft_I2C_Init+1, 0 $0708 $EC09 F002 CALL _Soft_I2C_Init ;part1.c,158 :: Soft_I2C_Start(); // Issue I2C start signal $070C $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,159 :: Soft_I2C_Write(0xD0); // Send byte (device address + W) $0710 $0ED0 MOVLW 208 $0712 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0714 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,160 :: Soft_I2C_Write(5); // Send byte (Location of month register) $0718 $0E05 MOVLW 5 $071A $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $071C $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,161 :: Soft_I2C_Start(); // Issue I2C start signal $0720 $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,162 :: Soft_I2C_Write(0xD1); // Send byte (device address + R) $0724 $0ED1 MOVLW 209 $0726 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0728 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,163 :: tempMonth = Soft_I2C_Read(0); // Read data (NO ACK) $072C $6A74 CLRF FARG_Soft_I2C_Read+0, 0 $072E $EC58 F001 CALL _Soft_I2C_Read $0732 $C000 F038 MOVFF STACK_0, _tempMonth ;part1.c,164 :: Soft_I2C_Stop(); $0736 $ECA1 F001 CALL _Soft_I2C_Stop ;part1.c,165 :: month[0]=((tempMonth & 0x30)>>4)+0x30; $073A $0E30 MOVLW 48 $073C $1438 ANDWF _tempMonth, 0, 0 $073E $6E39 MOVWF _month, 0 $0740 $3239 RRCF _month, 1, 0 $0742 $9E39 BCF _month, 7, 0 $0744 $3239 RRCF _month, 1, 0 $0746 $9E39 BCF _month, 7, 0 $0748 $3239 RRCF _month, 1, 0 $074A $9E39 BCF _month, 7, 0 $074C $3239 RRCF _month, 1, 0 $074E $9E39 BCF _month, 7, 0 $0750 $0E30 MOVLW 48 $0752 $2639 ADDWF _month, 1, 0 ;part1.c,166 :: month[1]= (tempMonth & 0x0F) +0x30; $0754 $0E0F MOVLW 15 $0756 $1438 ANDWF _tempMonth, 0, 0 $0758 $6E3A MOVWF _month+1, 0 $075A $0E30 MOVLW 48 $075C $263A ADDWF _month+1, 1, 0 ;part1.c,169 :: Soft_I2C_Config(&PORTC, 4, 3); //Use Port C pins 4 and 3 $075E $0E82 MOVLW PORTC $0760 $6E74 MOVWF FARG_Soft_I2C_Init+0, 0 $0762 $0E0F MOVLW @PORTC $0764 $6E75 MOVWF FARG_Soft_I2C_Init+1, 0 $0766 $EC09 F002 CALL _Soft_I2C_Init ;part1.c,170 :: Soft_I2C_Start(); // Issue I2C start signal $076A $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,171 :: Soft_I2C_Write(0xD0); // Send byte (device address + W) $076E $0ED0 MOVLW 208 $0770 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0772 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,172 :: Soft_I2C_Write(6); // Send byte (Location of year register) $0776 $0E06 MOVLW 6 $0778 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $077A $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,173 :: Soft_I2C_Start(); // Issue I2C start signal $077E $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,174 :: Soft_I2C_Write(0xD1); // Send byte (device address + R) $0782 $0ED1 MOVLW 209 $0784 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0786 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,175 :: tempYear = Soft_I2C_Read(0); // Read data (NO ACK) $078A $6A74 CLRF FARG_Soft_I2C_Read+0, 0 $078C $EC58 F001 CALL _Soft_I2C_Read $0790 $C000 F03B MOVFF STACK_0, _tempYear ;part1.c,176 :: Soft_I2C_Stop(); $0794 $ECA1 F001 CALL _Soft_I2C_Stop ;part1.c,177 :: year[0]=((tempYear & 0x70)>>4)+0x30; $0798 $0E70 MOVLW 112 $079A $143B ANDWF _tempYear, 0, 0 $079C $6E3C MOVWF _year, 0 $079E $323C RRCF _year, 1, 0 $07A0 $9E3C BCF _year, 7, 0 $07A2 $323C RRCF _year, 1, 0 $07A4 $9E3C BCF _year, 7, 0 $07A6 $323C RRCF _year, 1, 0 $07A8 $9E3C BCF _year, 7, 0 $07AA $323C RRCF _year, 1, 0 $07AC $9E3C BCF _year, 7, 0 $07AE $0E30 MOVLW 48 $07B0 $263C ADDWF _year, 1, 0 ;part1.c,178 :: year[1]= (tempYear & 0x0F) +0x30; $07B2 $0E0F MOVLW 15 $07B4 $143B ANDWF _tempYear, 0, 0 $07B6 $6E3D MOVWF _year+1, 0 $07B8 $0E30 MOVLW 48 $07BA $263D ADDWF _year+1, 1, 0 ;part1.c,183 :: Soft_I2C_Config(&PORTC, 4, 3); //Use PortC pins 4 and 3 $07BC $0E82 MOVLW PORTC $07BE $6E74 MOVWF FARG_Soft_I2C_Init+0, 0 $07C0 $0E0F MOVLW @PORTC $07C2 $6E75 MOVWF FARG_Soft_I2C_Init+1, 0 $07C4 $EC09 F002 CALL _Soft_I2C_Init ;part1.c,184 :: Soft_I2C_Start(); // Issue I2C start signal $07C8 $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,185 :: Soft_I2C_Write(0xA2); // Send byte via I2C (Address of 24cO2) $07CC $0EA2 MOVLW 162 $07CE $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $07D0 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,186 :: Soft_I2C_Write(2); // Send byte (address of EEPROM location) $07D4 $0E02 MOVLW 2 $07D6 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $07D8 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,187 :: Soft_I2C_Write(day); // Send data (data to be written) $07DC $0E36 MOVLW _day $07DE $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $07E0 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,189 :: Soft_I2C_Write(month); // Send data (data to be written) $07E4 $0E39 MOVLW _month $07E6 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $07E8 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,190 :: Soft_I2C_Write(year); // Send data (data to be written) $07EC $0E3C MOVLW _year $07EE $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $07F0 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,192 :: Soft_I2C_Stop(); $07F4 $ECA1 F001 CALL _Soft_I2C_Stop ;part1.c,194 :: Soft_I2C_Start(); // Issue I2C start signal $07F8 $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,195 :: Soft_I2C_Write(0xA2); // Send byte (device address + W) $07FC $0EA2 MOVLW 162 $07FE $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0800 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,196 :: Soft_I2C_Write(2); // Send byte (EEPROM location to read from) $0804 $0E02 MOVLW 2 $0806 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0808 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,197 :: Soft_I2C_Start(); // Issue I2C start signal $080C $ECE5 F000 CALL _Soft_I2C_Start ;part1.c,198 :: Soft_I2C_Write(0xA3); // Send byte (device address + R) $0810 $0EA3 MOVLW 163 $0812 $6E74 MOVWF FARG_Soft_I2C_Write+0, 0 $0814 $ECF8 F000 CALL _Soft_I2C_Write ;part1.c,199 :: mem2_data[0] = Soft_I2C_Read(1); // Read data (send ACK) $0818 $0E01 MOVLW 1 $081A $6E74 MOVWF FARG_Soft_I2C_Read+0, 0 $081C $EC58 F001 CALL _Soft_I2C_Read $0820 $C000 F040 MOVFF STACK_0, _mem2_data $0824 $0E00 MOVLW 0 $0826 $6E41 MOVWF _mem2_data+1, 0 ;part1.c,200 :: mem2_data[1] = Soft_I2C_Read(1); // Read data (send ACK) $0828 $0E01 MOVLW 1 $082A $6E74 MOVWF FARG_Soft_I2C_Read+0, 0 $082C $EC58 F001 CALL _Soft_I2C_Read $0830 $C000 F042 MOVFF STACK_0, _mem2_data+2 $0834 $0E00 MOVLW 0 $0836 $6E43 MOVWF _mem2_data+3, 0 ;part1.c,201 :: mem2_data[2] = Soft_I2C_Read(1); // Read data (send ACK) $0838 $0E01 MOVLW 1 $083A $6E74 MOVWF FARG_Soft_I2C_Read+0, 0 $083C $EC58 F001 CALL _Soft_I2C_Read $0840 $C000 F044 MOVFF STACK_0, _mem2_data+4 $0844 $0E00 MOVLW 0 $0846 $6E45 MOVWF _mem2_data+5, 0 ;part1.c,206 :: Lcd8_Config(&PORTE, &PORTD, 2,1,0, 7,6,5,4,3,2,1,0); $0848 $0E84 MOVLW PORTE $084A $6E74 MOVWF FARG_Lcd8_Init+0, 0 $084C $0E0F MOVLW @PORTE $084E $6E75 MOVWF FARG_Lcd8_Init+1, 0 $0850 $0E83 MOVLW PORTD $0852 $6E76 MOVWF FARG_Lcd8_Init+2, 0 $0854 $0E0F MOVLW @PORTD $0856 $6E77 MOVWF FARG_Lcd8_Init+3, 0 $0858 $EC1C F002 CALL _Lcd8_Init ;part1.c,207 :: Lcd8_Cmd(LCD_CURSOR_OFF); // Turn on blinking cursor $085C $0E0C MOVLW 12 $085E $6E79 MOVWF FARG_Lcd8_Cmd+0, 0 $0860 $EC24 F000 CALL _Lcd8_Cmd ;part1.c,208 :: Lcd8_Cmd(LCD_CLEAR); // Clear screen $0864 $0E01 MOVLW 1 $0866 $6E79 MOVWF FARG_Lcd8_Cmd+0, 0 $0868 $EC24 F000 CALL _Lcd8_Cmd ;part1.c,211 :: Lcd8_Out(1, 1,"Time="); $086C $0E01 MOVLW 1 $086E $6E74 MOVWF FARG_LCD8_Out+0, 0 $0870 $0E01 MOVLW 1 $0872 $6E75 MOVWF FARG_LCD8_Out+1, 0 $0874 $0E54 MOVLW lstr1_part1 $0876 $6E76 MOVWF FARG_LCD8_Out+2, 0 $0878 $0E00 MOVLW @lstr1_part1 $087A $6E77 MOVWF FARG_LCD8_Out+3, 0 $087C $ECBE F001 CALL _LCD8_Out ;part1.c,212 :: Lcd8_Out(1, 6,mem_data[0]); $0880 $0E01 MOVLW 1 $0882 $6E74 MOVWF FARG_LCD8_Out+0, 0 $0884 $0E06 MOVLW 6 $0886 $6E75 MOVWF FARG_LCD8_Out+1, 0 $0888 $C021 F076 MOVFF _mem_data, FARG_LCD8_Out+2 $088C $C022 F077 MOVFF _mem_data+1, FARG_LCD8_Out+3 $0890 $ECBE F001 CALL _LCD8_Out ;part1.c,213 :: Lcd8_Out(1, 8,":") ; $0894 $0E01 MOVLW 1 $0896 $6E74 MOVWF FARG_LCD8_Out+0, 0 $0898 $0E08 MOVLW 8 $089A $6E75 MOVWF FARG_LCD8_Out+1, 0 $089C $0E5A MOVLW lstr2_part1 $089E $6E76 MOVWF FARG_LCD8_Out+2, 0 $08A0 $0E00 MOVLW @lstr2_part1 $08A2 $6E77 MOVWF FARG_LCD8_Out+3, 0 $08A4 $ECBE F001 CALL _LCD8_Out ;part1.c,214 :: Lcd8_Out(1, 9,mem_data[1]); // Print time on LCD $08A8 $0E01 MOVLW 1 $08AA $6E74 MOVWF FARG_LCD8_Out+0, 0 $08AC $0E09 MOVLW 9 $08AE $6E75 MOVWF FARG_LCD8_Out+1, 0 $08B0 $C023 F076 MOVFF _mem_data+2, FARG_LCD8_Out+2 $08B4 $C024 F077 MOVFF _mem_data+3, FARG_LCD8_Out+3 $08B8 $ECBE F001 CALL _LCD8_Out ;part1.c,216 :: Lcd8_Out(1, 11," ") ; $08BC $0E01 MOVLW 1 $08BE $6E74 MOVWF FARG_LCD8_Out+0, 0 $08C0 $0E0B MOVLW 11 $08C2 $6E75 MOVWF FARG_LCD8_Out+1, 0 $08C4 $0E5C MOVLW lstr3_part1 $08C6 $6E76 MOVWF FARG_LCD8_Out+2, 0 $08C8 $0E00 MOVLW @lstr3_part1 $08CA $6E77 MOVWF FARG_LCD8_Out+3, 0 $08CC $ECBE F001 CALL _LCD8_Out ;part1.c,217 :: Lcd8_Out(1, 12," ") ; $08D0 $0E01 MOVLW 1 $08D2 $6E74 MOVWF FARG_LCD8_Out+0, 0 $08D4 $0E0C MOVLW 12 $08D6 $6E75 MOVWF FARG_LCD8_Out+1, 0 $08D8 $0E5E MOVLW lstr4_part1 $08DA $6E76 MOVWF FARG_LCD8_Out+2, 0 $08DC $0E00 MOVLW @lstr4_part1 $08DE $6E77 MOVWF FARG_LCD8_Out+3, 0 $08E0 $ECBE F001 CALL _LCD8_Out ;part1.c,218 :: Lcd8_Out(1, 13," ") ; $08E4 $0E01 MOVLW 1 $08E6 $6E74 MOVWF FARG_LCD8_Out+0, 0 $08E8 $0E0D MOVLW 13 $08EA $6E75 MOVWF FARG_LCD8_Out+1, 0 $08EC $0E60 MOVLW lstr5_part1 $08EE $6E76 MOVWF FARG_LCD8_Out+2, 0 $08F0 $0E00 MOVLW @lstr5_part1 $08F2 $6E77 MOVWF FARG_LCD8_Out+3, 0 $08F4 $ECBE F001 CALL _LCD8_Out ;part1.c,219 :: Lcd8_Out(1, 14," ") ; $08F8 $0E01 MOVLW 1 $08FA $6E74 MOVWF FARG_LCD8_Out+0, 0 $08FC $0E0E MOVLW 14 $08FE $6E75 MOVWF FARG_LCD8_Out+1, 0 $0900 $0E62 MOVLW lstr6_part1 $0902 $6E76 MOVWF FARG_LCD8_Out+2, 0 $0904 $0E00 MOVLW @lstr6_part1 $0906 $6E77 MOVWF FARG_LCD8_Out+3, 0 $0908 $ECBE F001 CALL _LCD8_Out ;part1.c,220 :: Lcd8_Out(1, 15," ") ; $090C $0E01 MOVLW 1 $090E $6E74 MOVWF FARG_LCD8_Out+0, 0 $0910 $0E0F MOVLW 15 $0912 $6E75 MOVWF FARG_LCD8_Out+1, 0 $0914 $0E64 MOVLW lstr7_part1 $0916 $6E76 MOVWF FARG_LCD8_Out+2, 0 $0918 $0E00 MOVLW @lstr7_part1 $091A $6E77 MOVWF FARG_LCD8_Out+3, 0 $091C $ECBE F001 CALL _LCD8_Out ;part1.c,221 :: Lcd8_Out(1, 16," ") ; $0920 $0E01 MOVLW 1 $0922 $6E74 MOVWF FARG_LCD8_Out+0, 0 $0924 $0E10 MOVLW 16 $0926 $6E75 MOVWF FARG_LCD8_Out+1, 0 $0928 $0E66 MOVLW lstr8_part1 $092A $6E76 MOVWF FARG_LCD8_Out+2, 0 $092C $0E00 MOVLW @lstr8_part1 $092E $6E77 MOVWF FARG_LCD8_Out+3, 0 $0930 $ECBE F001 CALL _LCD8_Out ;part1.c,223 :: Lcd8_Out(2, 1,"Date="); $0934 $0E02 MOVLW 2 $0936 $6E74 MOVWF FARG_LCD8_Out+0, 0 $0938 $0E01 MOVLW 1 $093A $6E75 MOVWF FARG_LCD8_Out+1, 0 $093C $0E68 MOVLW lstr9_part1 $093E $6E76 MOVWF FARG_LCD8_Out+2, 0 $0940 $0E00 MOVLW @lstr9_part1 $0942 $6E77 MOVWF FARG_LCD8_Out+3, 0 $0944 $ECBE F001 CALL _LCD8_Out ;part1.c,224 :: Lcd8_Out(2, 6,mem2_data[0]); $0948 $0E02 MOVLW 2 $094A $6E74 MOVWF FARG_LCD8_Out+0, 0 $094C $0E06 MOVLW 6 $094E $6E75 MOVWF FARG_LCD8_Out+1, 0 $0950 $C040 F076 MOVFF _mem2_data, FARG_LCD8_Out+2 $0954 $C041 F077 MOVFF _mem2_data+1, FARG_LCD8_Out+3 $0958 $ECBE F001 CALL _LCD8_Out ;part1.c,225 :: Lcd8_Out(2, 8,"/") ; $095C $0E02 MOVLW 2 $095E $6E74 MOVWF FARG_LCD8_Out+0, 0 $0960 $0E08 MOVLW 8 $0962 $6E75 MOVWF FARG_LCD8_Out+1, 0 $0964 $0E6E MOVLW lstr10_part1 $0966 $6E76 MOVWF FARG_LCD8_Out+2, 0 $0968 $0E00 MOVLW @lstr10_part1 $096A $6E77 MOVWF FARG_LCD8_Out+3, 0 $096C $ECBE F001 CALL _LCD8_Out ;part1.c,226 :: Lcd8_Out(2, 9,mem2_data[1]); // Print month on LCD $0970 $0E02 MOVLW 2 $0972 $6E74 MOVWF FARG_LCD8_Out+0, 0 $0974 $0E09 MOVLW 9 $0976 $6E75 MOVWF FARG_LCD8_Out+1, 0 $0978 $C042 F076 MOVFF _mem2_data+2, FARG_LCD8_Out+2 $097C $C043 F077 MOVFF _mem2_data+3, FARG_LCD8_Out+3 $0980 $ECBE F001 CALL _LCD8_Out ;part1.c,227 :: Lcd8_Out(2, 11,"/") ; $0984 $0E02 MOVLW 2 $0986 $6E74 MOVWF FARG_LCD8_Out+0, 0 $0988 $0E0B MOVLW 11 $098A $6E75 MOVWF FARG_LCD8_Out+1, 0 $098C $0E70 MOVLW lstr11_part1 $098E $6E76 MOVWF FARG_LCD8_Out+2, 0 $0990 $0E00 MOVLW @lstr11_part1 $0992 $6E77 MOVWF FARG_LCD8_Out+3, 0 $0994 $ECBE F001 CALL _LCD8_Out ;part1.c,228 :: Lcd8_Out(2, 12,mem2_data[2]); // Print year on LCD $0998 $0E02 MOVLW 2 $099A $6E74 MOVWF FARG_LCD8_Out+0, 0 $099C $0E0C MOVLW 12 $099E $6E75 MOVWF FARG_LCD8_Out+1, 0 $09A0 $C044 F076 MOVFF _mem2_data+4, FARG_LCD8_Out+2 $09A4 $C045 F077 MOVFF _mem2_data+5, FARG_LCD8_Out+3 $09A8 $ECBE F001 CALL _LCD8_Out ;part1.c,229 :: Lcd8_Out(2, 14,mem2_data[2]); // Print year on LCD $09AC $0E02 MOVLW 2 $09AE $6E74 MOVWF FARG_LCD8_Out+0, 0 $09B0 $0E0E MOVLW 14 $09B2 $6E75 MOVWF FARG_LCD8_Out+1, 0 $09B4 $C044 F076 MOVFF _mem2_data+4, FARG_LCD8_Out+2 $09B8 $C045 F077 MOVFF _mem2_data+5, FARG_LCD8_Out+3 $09BC $ECBE F001 CALL _LCD8_Out ;part1.c,230 :: } $09C0 $D004 BRA L_main_17 $09C2 $ L_main_16: $09C2 $5073 MOVF FLOC_main+31, 0, 0 $09C4 $0A06 XORLW 6 $09C6 $B4D8 BTFSC STATUS, Z, 0 $09C8 $D5CE BRA L_main_18 $09CA $ L_main_17: ;part1.c,231 :: } $09CA $D7FF BRA $
; A258710: Motzkin numbers A001006 read mod 11. ; Submitted by Christian Krause ; 1,1,2,4,9,10,7,6,4,10,10,1,1,2,4,9,10,7,6,4,9,0,3,3,6,1,5,8,10,7,1,6,10,7,7,3,6,8,4,5,9,6,9,10,8,8,5,10,6,3,1,4,10,9,8,7,7,3,6,8,4,5,9,6,3,5,9,9,7,3,4,2,8,10,3,8,7,8,8,5,10,6,3,1,4,10 seq $0,1006 ; Motzkin numbers: number of ways of drawing any number of nonintersecting chords joining n (labeled) points on a circle. mod $0,11
// // Copyright 2016 Pixar // // Licensed under the Apache License, Version 2.0 (the "Apache License") // with the following modification; you may not use this file except in // compliance with the Apache License and the following modification to it: // Section 6. Trademarks. is deleted and replaced with: // // 6. Trademarks. This License does not grant permission to use the trade // names, trademarks, service marks, or product names of the Licensor // and its affiliates, except as required to comply with Section 4(c) of // the License and to reproduce the content of the NOTICE file. // // You may obtain a copy of the Apache License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the Apache License with the above modification is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // #include "pxr/base/arch/stackTrace.h" #include "pxr/base/tf/diagnostic.h" #include <stdio.h> /** * This executable performs an integer divide by zero (SIGFPE) * for testing of the Tf crash handler */ int main(int argc, char **argv) { ArchSetFatalStackLogging( true ); // Make sure handlers have been installed // This isn't guaranteed in external environments // as we leave them off by default. TfInstallTerminateAndCrashHandlers(); int a = 1; int b = 0; int c = a/b; printf("%d",c); }
// dear imgui: Platform Backend for GLFW // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..) // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) // (Requires: GLFW 3.1+. Prefer GLFW 3.3+ for full feature support.) // Implemented features: // [X] Platform: Clipboard support. // [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+). // [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). // [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // Issues: // [ ] Platform: Multi-viewport support: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor). // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. // Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) // 2021-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface. // 2020-01-17: Inputs: Disable error callback while assigning mouse cursors because some X11 setup don't have them and it generates errors. // 2019-12-05: Inputs: Added support for new mouse cursors added in GLFW 3.4+ (resizing cursors, not allowed cursor). // 2019-10-18: Misc: Previously installed user callbacks are now restored on shutdown. // 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter. // 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter(). // 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized. // 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window. // 2018-11-07: Inputs: When installing our GLFW callbacks, we save user's previously installed ones - if any - and chain call them. // 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls. // 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor. // 2018-06-08: Misc: Extracted imgui_impl_glfw.cpp/.h away from the old combined GLFW+OpenGL/Vulkan examples. // 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag. // 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value, passed to glfwSetCursor()). // 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. // 2018-02-06: Inputs: Added mapping for ImGuiKey_Space. // 2018-01-25: Inputs: Added gamepad support if ImGuiConfigFlags_NavEnableGamepad is set. // 2018-01-25: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set). // 2018-01-20: Inputs: Added Horizontal Mouse Wheel support. // 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert. // 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1). // 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers. #include "imgui.h" #include "imgui_impl_glfw.h" // GLFW #include <GLFW/glfw3.h> #ifdef _WIN32 #undef APIENTRY #define GLFW_EXPOSE_NATIVE_WIN32 #include <GLFW/glfw3native.h> // for glfwGetWin32Window #endif #define GLFW_HAS_WINDOW_TOPMOST (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ GLFW_FLOATING #define GLFW_HAS_WINDOW_HOVERED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ GLFW_HOVERED #define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwSetWindowOpacity #define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorContentScale #define GLFW_HAS_VULKAN (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwCreateWindowSurface #define GLFW_HAS_FOCUS_WINDOW (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwFocusWindow #define GLFW_HAS_FOCUS_ON_SHOW (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ GLFW_FOCUS_ON_SHOW #define GLFW_HAS_MONITOR_WORK_AREA (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorWorkarea #define GLFW_HAS_OSX_WINDOW_POS_FIX (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 + GLFW_VERSION_REVISION * 10 >= 3310) // 3.3.1+ Fixed: Resizing window repositions it on MacOS #1553 #ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released? #define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR #else #define GLFW_HAS_NEW_CURSORS (0) #endif #ifdef GLFW_MOUSE_PASSTHROUGH // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2020-07-17 (passthrough) #define GLFW_HAS_MOUSE_PASSTHROUGH (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3400) // 3.4+ GLFW_MOUSE_PASSTHROUGH #else #define GLFW_HAS_MOUSE_PASSTHROUGH (0) #endif // Data enum GlfwClientApi { GlfwClientApi_Unknown, GlfwClientApi_OpenGL, GlfwClientApi_Vulkan, GlfwClientApi_WebGPU }; static GLFWwindow* g_Window = NULL; // Main window static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown; static double g_Time = 0.0; static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {}; static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {}; static bool g_InstalledCallbacks = false; static bool g_WantUpdateMonitors = true; // Chain GLFW callbacks for main viewport: our callbacks will call the user's previously installed callbacks, if any. static GLFWmousebuttonfun g_PrevUserCallbackMousebutton = NULL; static GLFWscrollfun g_PrevUserCallbackScroll = NULL; static GLFWkeyfun g_PrevUserCallbackKey = NULL; static GLFWcharfun g_PrevUserCallbackChar = NULL; static GLFWmonitorfun g_PrevUserCallbackMonitor = NULL; // Forward Declarations static void ImGui_ImplGlfw_UpdateMonitors(); static void ImGui_ImplGlfw_InitPlatformInterface(); static void ImGui_ImplGlfw_ShutdownPlatformInterface(); static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data) { return glfwGetClipboardString((GLFWwindow*)user_data); } static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text) { glfwSetClipboardString((GLFWwindow*)user_data, text); } void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods) { if (g_PrevUserCallbackMousebutton != NULL && window == g_Window) g_PrevUserCallbackMousebutton(window, button, action, mods); if (action == GLFW_PRESS && button >= 0 && button < IM_ARRAYSIZE(g_MouseJustPressed)) g_MouseJustPressed[button] = true; } void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset) { if (g_PrevUserCallbackScroll != NULL && window == g_Window) g_PrevUserCallbackScroll(window, xoffset, yoffset); ImGuiIO& io = ImGui::GetIO(); io.MouseWheelH += (float)xoffset; io.MouseWheel += (float)yoffset; } void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (g_PrevUserCallbackKey != NULL && window == g_Window) g_PrevUserCallbackKey(window, key, scancode, action, mods); ImGuiIO& io = ImGui::GetIO(); if (action == GLFW_PRESS) io.KeysDown[key] = true; if (action == GLFW_RELEASE) io.KeysDown[key] = false; // Modifiers are not reliable across systems io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL]; io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT]; io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT]; #ifdef _WIN32 io.KeySuper = false; #else io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER]; #endif } void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c) { if (g_PrevUserCallbackChar != NULL && window == g_Window) g_PrevUserCallbackChar(window, c); ImGuiIO& io = ImGui::GetIO(); io.AddInputCharacter(c); } void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int) { g_WantUpdateMonitors = true; } static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api) { g_Window = window; g_Time = 0.0; // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional) #if GLFW_HAS_MOUSE_PASSTHROUGH || (GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)) io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can set io.MouseHoveredViewport correctly (optional, not easy) #endif io.BackendPlatformName = "imgui_impl_glfw"; // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array. io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP; io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN; io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP; io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN; io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME; io.KeyMap[ImGuiKey_End] = GLFW_KEY_END; io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT; io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE; io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE; io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE; io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER; io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE; io.KeyMap[ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER; io.KeyMap[ImGuiKey_A] = GLFW_KEY_A; io.KeyMap[ImGuiKey_C] = GLFW_KEY_C; io.KeyMap[ImGuiKey_V] = GLFW_KEY_V; io.KeyMap[ImGuiKey_X] = GLFW_KEY_X; io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y; io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z; io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText; io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText; io.ClipboardUserData = g_Window; // Create mouse cursors // (By design, on X11 cursors are user configurable and some cursors may be missing. When a cursor doesn't exist, // GLFW will emit an error which will often be printed by the app, so we temporarily disable error reporting. // Missing cursors will return NULL and our _UpdateMouseCursor() function will use the Arrow cursor instead.) GLFWerrorfun prev_error_callback = glfwSetErrorCallback(NULL); g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR); g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR); g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR); #if GLFW_HAS_NEW_CURSORS g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_RESIZE_ALL_CURSOR); g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_RESIZE_NESW_CURSOR); g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_RESIZE_NWSE_CURSOR); g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_NOT_ALLOWED_CURSOR); #else g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); #endif glfwSetErrorCallback(prev_error_callback); // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any. g_PrevUserCallbackMousebutton = NULL; g_PrevUserCallbackScroll = NULL; g_PrevUserCallbackKey = NULL; g_PrevUserCallbackChar = NULL; g_PrevUserCallbackMonitor = NULL; if (install_callbacks) { g_InstalledCallbacks = true; g_PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback); g_PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback); g_PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback); g_PrevUserCallbackChar = glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback); g_PrevUserCallbackMonitor = glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback); } // Update monitors the first time (note: monitor callback are broken in GLFW 3.2 and earlier, see github.com/glfw/glfw/issues/784) ImGui_ImplGlfw_UpdateMonitors(); glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback); // Our mouse update function expect PlatformHandle to be filled for the main viewport ImGuiViewport* main_viewport = ImGui::GetMainViewport(); main_viewport->PlatformHandle = (void*)g_Window; #ifdef _WIN32 main_viewport->PlatformHandleRaw = glfwGetWin32Window(g_Window); #endif if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) ImGui_ImplGlfw_InitPlatformInterface(); g_ClientApi = client_api; return true; } bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks) { return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL); } bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks) { return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan); } bool ImGui_ImplGlfw_InitForWebGPU(GLFWwindow* window, bool install_callbacks) { return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_WebGPU); } bool ImGui_ImplGlfw_InitNoAPI(GLFWwindow* window, bool install_callbacks) { return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Unknown); } void ImGui_ImplGlfw_Shutdown() { ImGui_ImplGlfw_ShutdownPlatformInterface(); if (g_InstalledCallbacks) { glfwSetMouseButtonCallback(g_Window, g_PrevUserCallbackMousebutton); glfwSetScrollCallback(g_Window, g_PrevUserCallbackScroll); glfwSetKeyCallback(g_Window, g_PrevUserCallbackKey); glfwSetCharCallback(g_Window, g_PrevUserCallbackChar); g_InstalledCallbacks = false; } for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++) { glfwDestroyCursor(g_MouseCursors[cursor_n]); g_MouseCursors[cursor_n] = NULL; } g_ClientApi = GlfwClientApi_Unknown; } static void ImGui_ImplGlfw_UpdateMousePosAndButtons() { // Update buttons ImGuiIO& io = ImGui::GetIO(); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) { // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0; g_MouseJustPressed[i] = false; } // Update mouse position const ImVec2 mouse_pos_backup = io.MousePos; io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); io.MouseHoveredViewport = 0; ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); for (int n = 0; n < platform_io.Viewports.Size; n++) { ImGuiViewport* viewport = platform_io.Viewports[n]; GLFWwindow* window = (GLFWwindow*)viewport->PlatformHandle; IM_ASSERT(window != NULL); #ifdef __EMSCRIPTEN__ const bool focused = true; IM_ASSERT(platform_io.Viewports.Size == 1); #else const bool focused = glfwGetWindowAttrib(window, GLFW_FOCUSED) != 0; #endif if (focused) { if (io.WantSetMousePos) { glfwSetCursorPos(window, (double)(mouse_pos_backup.x - viewport->Pos.x), (double)(mouse_pos_backup.y - viewport->Pos.y)); } else { double mouse_x, mouse_y; glfwGetCursorPos(window, &mouse_x, &mouse_y); if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { // Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor) int window_x, window_y; glfwGetWindowPos(window, &window_x, &window_y); io.MousePos = ImVec2((float)mouse_x + window_x, (float)mouse_y + window_y); } else { // Single viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window) io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); } } for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) io.MouseDown[i] |= glfwGetMouseButton(window, i) != 0; } // (Optional) When using multiple viewports: set io.MouseHoveredViewport to the viewport the OS mouse cursor is hovering. // Important: this information is not easy to provide and many high-level windowing library won't be able to provide it correctly, because // - This is _ignoring_ viewports with the ImGuiViewportFlags_NoInputs flag (pass-through windows). // - This is _regardless_ of whether another viewport is focused or being dragged from. // If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, imgui will ignore this field and infer the information by relying on the // rectangles and last focused time of every viewports it knows about. It will be unaware of other windows that may be sitting between or over your windows. // [GLFW] FIXME: This is currently only correct on Win32. See what we do below with the WM_NCHITTEST, missing an equivalent for other systems. // See https://github.com/glfw/glfw/issues/1236 if you want to help in making this a GLFW feature. #if GLFW_HAS_MOUSE_PASSTHROUGH || (GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)) const bool window_no_input = (viewport->Flags & ImGuiViewportFlags_NoInputs) != 0; #if GLFW_HAS_MOUSE_PASSTHROUGH glfwSetWindowAttrib(window, GLFW_MOUSE_PASSTHROUGH, window_no_input); #endif if (glfwGetWindowAttrib(window, GLFW_HOVERED) && !window_no_input) io.MouseHoveredViewport = viewport->ID; #endif } } static void ImGui_ImplGlfw_UpdateMouseCursor() { ImGuiIO& io = ImGui::GetIO(); if ((io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) || glfwGetInputMode(g_Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED) return; ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); for (int n = 0; n < platform_io.Viewports.Size; n++) { GLFWwindow* window = (GLFWwindow*)platform_io.Viewports[n]->PlatformHandle; if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor) { // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); } else { // Show OS mouse cursor // FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here. glfwSetCursor(window, g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); } } } static void ImGui_ImplGlfw_UpdateGamepads() { ImGuiIO& io = ImGui::GetIO(); memset(io.NavInputs, 0, sizeof(io.NavInputs)); if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) return; // Update gamepad inputs #define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; } #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; } int axes_count = 0, buttons_count = 0; const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count); const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count); MAP_BUTTON(ImGuiNavInput_Activate, 0); // Cross / A MAP_BUTTON(ImGuiNavInput_Cancel, 1); // Circle / B MAP_BUTTON(ImGuiNavInput_Menu, 2); // Square / X MAP_BUTTON(ImGuiNavInput_Input, 3); // Triangle / Y MAP_BUTTON(ImGuiNavInput_DpadLeft, 13); // D-Pad Left MAP_BUTTON(ImGuiNavInput_DpadRight, 11); // D-Pad Right MAP_BUTTON(ImGuiNavInput_DpadUp, 10); // D-Pad Up MAP_BUTTON(ImGuiNavInput_DpadDown, 12); // D-Pad Down MAP_BUTTON(ImGuiNavInput_FocusPrev, 4); // L1 / LB MAP_BUTTON(ImGuiNavInput_FocusNext, 5); // R1 / RB MAP_BUTTON(ImGuiNavInput_TweakSlow, 4); // L1 / LB MAP_BUTTON(ImGuiNavInput_TweakFast, 5); // R1 / RB MAP_ANALOG(ImGuiNavInput_LStickLeft, 0, -0.3f, -0.9f); MAP_ANALOG(ImGuiNavInput_LStickRight,0, +0.3f, +0.9f); MAP_ANALOG(ImGuiNavInput_LStickUp, 1, +0.3f, +0.9f); MAP_ANALOG(ImGuiNavInput_LStickDown, 1, -0.3f, -0.9f); #undef MAP_BUTTON #undef MAP_ANALOG if (axes_count > 0 && buttons_count > 0) io.BackendFlags |= ImGuiBackendFlags_HasGamepad; else io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; } static void ImGui_ImplGlfw_UpdateMonitors() { ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); int monitors_count = 0; GLFWmonitor** glfw_monitors = glfwGetMonitors(&monitors_count); platform_io.Monitors.resize(0); for (int n = 0; n < monitors_count; n++) { ImGuiPlatformMonitor monitor; int x, y; glfwGetMonitorPos(glfw_monitors[n], &x, &y); const GLFWvidmode* vid_mode = glfwGetVideoMode(glfw_monitors[n]); monitor.MainPos = monitor.WorkPos = ImVec2((float)x, (float)y); monitor.MainSize = monitor.WorkSize = ImVec2((float)vid_mode->width, (float)vid_mode->height); #if GLFW_HAS_MONITOR_WORK_AREA int w, h; glfwGetMonitorWorkarea(glfw_monitors[n], &x, &y, &w, &h); if (w > 0 && h > 0) // Workaround a small GLFW issue reporting zero on monitor changes: https://github.com/glfw/glfw/pull/1761 { monitor.WorkPos = ImVec2((float)x, (float)y); monitor.WorkSize = ImVec2((float)w, (float)h); } #endif #if GLFW_HAS_PER_MONITOR_DPI // Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime. float x_scale, y_scale; glfwGetMonitorContentScale(glfw_monitors[n], &x_scale, &y_scale); monitor.DpiScale = x_scale; #endif platform_io.Monitors.push_back(monitor); } g_WantUpdateMonitors = false; } void ImGui_ImplGlfw_NewFrame() { ImGuiIO& io = ImGui::GetIO(); IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); // Setup display size (every frame to accommodate for window resizing) int w, h; int display_w, display_h; glfwGetWindowSize(g_Window, &w, &h); glfwGetFramebufferSize(g_Window, &display_w, &display_h); io.DisplaySize = ImVec2((float)w, (float)h); if (w > 0 && h > 0) io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h); if (g_WantUpdateMonitors) ImGui_ImplGlfw_UpdateMonitors(); // Setup time step double current_time = glfwGetTime(); io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f); g_Time = current_time; ImGui_ImplGlfw_UpdateMousePosAndButtons(); ImGui_ImplGlfw_UpdateMouseCursor(); // Update game controllers (if enabled and available) ImGui_ImplGlfw_UpdateGamepads(); } //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT // This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- // Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. struct ImGuiViewportDataGlfw { GLFWwindow* Window; bool WindowOwned; int IgnoreWindowPosEventFrame; int IgnoreWindowSizeEventFrame; ImGuiViewportDataGlfw() { Window = NULL; WindowOwned = false; IgnoreWindowSizeEventFrame = IgnoreWindowPosEventFrame = -1; } ~ImGuiViewportDataGlfw() { IM_ASSERT(Window == NULL); } }; static void ImGui_ImplGlfw_WindowCloseCallback(GLFWwindow* window) { if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window)) viewport->PlatformRequestClose = true; } // GLFW may dispatch window pos/size events after calling glfwSetWindowPos()/glfwSetWindowSize(). // However: depending on the platform the callback may be invoked at different time: // - on Windows it appears to be called within the glfwSetWindowPos()/glfwSetWindowSize() call // - on Linux it is queued and invoked during glfwPollEvents() // Because the event doesn't always fire on glfwSetWindowXXX() we use a frame counter tag to only // ignore recent glfwSetWindowXXX() calls. static void ImGui_ImplGlfw_WindowPosCallback(GLFWwindow* window, int, int) { if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window)) { if (ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData) { bool ignore_event = (ImGui::GetFrameCount() <= data->IgnoreWindowPosEventFrame + 1); //data->IgnoreWindowPosEventFrame = -1; if (ignore_event) return; } viewport->PlatformRequestMove = true; } } static void ImGui_ImplGlfw_WindowSizeCallback(GLFWwindow* window, int, int) { if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window)) { if (ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData) { bool ignore_event = (ImGui::GetFrameCount() <= data->IgnoreWindowSizeEventFrame + 1); //data->IgnoreWindowSizeEventFrame = -1; if (ignore_event) return; } viewport->PlatformRequestResize = true; } } static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport) { ImGuiViewportDataGlfw* data = IM_NEW(ImGuiViewportDataGlfw)(); viewport->PlatformUserData = data; // GLFW 3.2 unfortunately always set focus on glfwCreateWindow() if GLFW_VISIBLE is set, regardless of GLFW_FOCUSED // With GLFW 3.3, the hint GLFW_FOCUS_ON_SHOW fixes this problem glfwWindowHint(GLFW_VISIBLE, false); glfwWindowHint(GLFW_FOCUSED, false); #if GLFW_HAS_FOCUS_ON_SHOW glfwWindowHint(GLFW_FOCUS_ON_SHOW, false); #endif glfwWindowHint(GLFW_DECORATED, (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? false : true); #if GLFW_HAS_WINDOW_TOPMOST glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false); #endif GLFWwindow* share_window = (g_ClientApi == GlfwClientApi_OpenGL) ? g_Window : NULL; data->Window = glfwCreateWindow((int)viewport->Size.x, (int)viewport->Size.y, "No Title Yet", NULL, share_window); data->WindowOwned = true; viewport->PlatformHandle = (void*)data->Window; #ifdef _WIN32 viewport->PlatformHandleRaw = glfwGetWin32Window(data->Window); #endif glfwSetWindowPos(data->Window, (int)viewport->Pos.x, (int)viewport->Pos.y); // Install GLFW callbacks for secondary viewports glfwSetMouseButtonCallback(data->Window, ImGui_ImplGlfw_MouseButtonCallback); glfwSetScrollCallback(data->Window, ImGui_ImplGlfw_ScrollCallback); glfwSetKeyCallback(data->Window, ImGui_ImplGlfw_KeyCallback); glfwSetCharCallback(data->Window, ImGui_ImplGlfw_CharCallback); glfwSetWindowCloseCallback(data->Window, ImGui_ImplGlfw_WindowCloseCallback); glfwSetWindowPosCallback(data->Window, ImGui_ImplGlfw_WindowPosCallback); glfwSetWindowSizeCallback(data->Window, ImGui_ImplGlfw_WindowSizeCallback); if (g_ClientApi == GlfwClientApi_OpenGL) { glfwMakeContextCurrent(data->Window); glfwSwapInterval(0); } } static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport) { if (ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData) { if (data->WindowOwned) { #if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32) HWND hwnd = (HWND)viewport->PlatformHandleRaw; ::RemovePropA(hwnd, "IMGUI_VIEWPORT"); #endif glfwDestroyWindow(data->Window); } data->Window = NULL; IM_DELETE(data); } viewport->PlatformUserData = viewport->PlatformHandle = NULL; } // We have submitted https://github.com/glfw/glfw/pull/1568 to allow GLFW to support "transparent inputs". // In the meanwhile we implement custom per-platform workarounds here (FIXME-VIEWPORT: Implement same work-around for Linux/OSX!) #if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32) static WNDPROC g_GlfwWndProc = NULL; static LRESULT CALLBACK WndProcNoInputs(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_NCHITTEST) { // Let mouse pass-through the window. This will allow the backend to set io.MouseHoveredViewport properly (which is OPTIONAL). // The ImGuiViewportFlags_NoInputs flag is set while dragging a viewport, as want to detect the window behind the one we are dragging. // If you cannot easily access those viewport flags from your windowing/event code: you may manually synchronize its state e.g. in // your main loop after calling UpdatePlatformWindows(). Iterate all viewports/platform windows and pass the flag to your windowing system. ImGuiViewport* viewport = (ImGuiViewport*)::GetPropA(hWnd, "IMGUI_VIEWPORT"); if (viewport->Flags & ImGuiViewportFlags_NoInputs) return HTTRANSPARENT; } return ::CallWindowProc(g_GlfwWndProc, hWnd, msg, wParam, lParam); } #endif static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; #if defined(_WIN32) // GLFW hack: Hide icon from task bar HWND hwnd = (HWND)viewport->PlatformHandleRaw; if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) { LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE); ex_style &= ~WS_EX_APPWINDOW; ex_style |= WS_EX_TOOLWINDOW; ::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style); } // GLFW hack: install hook for WM_NCHITTEST message handler #if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32) ::SetPropA(hwnd, "IMGUI_VIEWPORT", viewport); if (g_GlfwWndProc == NULL) g_GlfwWndProc = (WNDPROC)::GetWindowLongPtr(hwnd, GWLP_WNDPROC); ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WndProcNoInputs); #endif #if !GLFW_HAS_FOCUS_ON_SHOW // GLFW hack: GLFW 3.2 has a bug where glfwShowWindow() also activates/focus the window. // The fix was pushed to GLFW repository on 2018/01/09 and should be included in GLFW 3.3 via a GLFW_FOCUS_ON_SHOW window attribute. // See https://github.com/glfw/glfw/issues/1189 // FIXME-VIEWPORT: Implement same work-around for Linux/OSX in the meanwhile. if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing) { ::ShowWindow(hwnd, SW_SHOWNA); return; } #endif #endif glfwShowWindow(data->Window); } static ImVec2 ImGui_ImplGlfw_GetWindowPos(ImGuiViewport* viewport) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; int x = 0, y = 0; glfwGetWindowPos(data->Window, &x, &y); return ImVec2((float)x, (float)y); } static void ImGui_ImplGlfw_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; data->IgnoreWindowPosEventFrame = ImGui::GetFrameCount(); glfwSetWindowPos(data->Window, (int)pos.x, (int)pos.y); } static ImVec2 ImGui_ImplGlfw_GetWindowSize(ImGuiViewport* viewport) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; int w = 0, h = 0; glfwGetWindowSize(data->Window, &w, &h); return ImVec2((float)w, (float)h); } static void ImGui_ImplGlfw_SetWindowSize(ImGuiViewport* viewport, ImVec2 size) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; #if __APPLE__ && !GLFW_HAS_OSX_WINDOW_POS_FIX // Native OS windows are positioned from the bottom-left corner on macOS, whereas on other platforms they are // positioned from the upper-left corner. GLFW makes an effort to convert macOS style coordinates, however it // doesn't handle it when changing size. We are manually moving the window in order for changes of size to be based // on the upper-left corner. int x, y, width, height; glfwGetWindowPos(data->Window, &x, &y); glfwGetWindowSize(data->Window, &width, &height); glfwSetWindowPos(data->Window, x, y - height + size.y); #endif data->IgnoreWindowSizeEventFrame = ImGui::GetFrameCount(); glfwSetWindowSize(data->Window, (int)size.x, (int)size.y); } static void ImGui_ImplGlfw_SetWindowTitle(ImGuiViewport* viewport, const char* title) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; glfwSetWindowTitle(data->Window, title); } static void ImGui_ImplGlfw_SetWindowFocus(ImGuiViewport* viewport) { #if GLFW_HAS_FOCUS_WINDOW ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; glfwFocusWindow(data->Window); #else // FIXME: What are the effect of not having this function? At the moment imgui doesn't actually call SetWindowFocus - we set that up ahead, will answer that question later. (void)viewport; #endif } static bool ImGui_ImplGlfw_GetWindowFocus(ImGuiViewport* viewport) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; return glfwGetWindowAttrib(data->Window, GLFW_FOCUSED) != 0; } static bool ImGui_ImplGlfw_GetWindowMinimized(ImGuiViewport* viewport) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; return glfwGetWindowAttrib(data->Window, GLFW_ICONIFIED) != 0; } #if GLFW_HAS_WINDOW_ALPHA static void ImGui_ImplGlfw_SetWindowAlpha(ImGuiViewport* viewport, float alpha) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; glfwSetWindowOpacity(data->Window, alpha); } #endif static void ImGui_ImplGlfw_RenderWindow(ImGuiViewport* viewport, void*) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; if (g_ClientApi == GlfwClientApi_OpenGL) glfwMakeContextCurrent(data->Window); } static void ImGui_ImplGlfw_SwapBuffers(ImGuiViewport* viewport, void*) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; if (g_ClientApi == GlfwClientApi_OpenGL) { glfwMakeContextCurrent(data->Window); glfwSwapBuffers(data->Window); } } //-------------------------------------------------------------------------------------------------------- // IME (Input Method Editor) basic support for e.g. Asian language users //-------------------------------------------------------------------------------------------------------- // We provide a Win32 implementation because this is such a common issue for IME users #if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(__GNUC__) #define HAS_WIN32_IME 1 #include <imm.h> #ifdef _MSC_VER #pragma comment(lib, "imm32") #endif static void ImGui_ImplWin32_SetImeInputPos(ImGuiViewport* viewport, ImVec2 pos) { COMPOSITIONFORM cf = { CFS_FORCE_POSITION, { (LONG)(pos.x - viewport->Pos.x), (LONG)(pos.y - viewport->Pos.y) }, { 0, 0, 0, 0 } }; if (HWND hwnd = (HWND)viewport->PlatformHandleRaw) if (HIMC himc = ::ImmGetContext(hwnd)) { ::ImmSetCompositionWindow(himc, &cf); ::ImmReleaseContext(hwnd, himc); } } #else #define HAS_WIN32_IME 0 #endif //-------------------------------------------------------------------------------------------------------- // Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface) //-------------------------------------------------------------------------------------------------------- // Avoid including <vulkan.h> so we can build without it #if GLFW_HAS_VULKAN #ifndef VULKAN_H_ #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; #if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; #else #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; #endif VK_DEFINE_HANDLE(VkInstance) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) struct VkAllocationCallbacks; enum VkResult { VK_RESULT_MAX_ENUM = 0x7FFFFFFF }; #endif // VULKAN_H_ extern "C" { extern GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); } static int ImGui_ImplGlfw_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface) { ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData; IM_ASSERT(g_ClientApi == GlfwClientApi_Vulkan); VkResult err = glfwCreateWindowSurface((VkInstance)vk_instance, data->Window, (const VkAllocationCallbacks*)vk_allocator, (VkSurfaceKHR*)out_vk_surface); return (int)err; } #endif // GLFW_HAS_VULKAN static void ImGui_ImplGlfw_InitPlatformInterface() { // Register platform interface (will be coupled with a renderer interface) ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); platform_io.Platform_CreateWindow = ImGui_ImplGlfw_CreateWindow; platform_io.Platform_DestroyWindow = ImGui_ImplGlfw_DestroyWindow; platform_io.Platform_ShowWindow = ImGui_ImplGlfw_ShowWindow; platform_io.Platform_SetWindowPos = ImGui_ImplGlfw_SetWindowPos; platform_io.Platform_GetWindowPos = ImGui_ImplGlfw_GetWindowPos; platform_io.Platform_SetWindowSize = ImGui_ImplGlfw_SetWindowSize; platform_io.Platform_GetWindowSize = ImGui_ImplGlfw_GetWindowSize; platform_io.Platform_SetWindowFocus = ImGui_ImplGlfw_SetWindowFocus; platform_io.Platform_GetWindowFocus = ImGui_ImplGlfw_GetWindowFocus; platform_io.Platform_GetWindowMinimized = ImGui_ImplGlfw_GetWindowMinimized; platform_io.Platform_SetWindowTitle = ImGui_ImplGlfw_SetWindowTitle; platform_io.Platform_RenderWindow = ImGui_ImplGlfw_RenderWindow; platform_io.Platform_SwapBuffers = ImGui_ImplGlfw_SwapBuffers; #if GLFW_HAS_WINDOW_ALPHA platform_io.Platform_SetWindowAlpha = ImGui_ImplGlfw_SetWindowAlpha; #endif #if GLFW_HAS_VULKAN platform_io.Platform_CreateVkSurface = ImGui_ImplGlfw_CreateVkSurface; #endif #if HAS_WIN32_IME platform_io.Platform_SetImeInputPos = ImGui_ImplWin32_SetImeInputPos; #endif // Register main window handle (which is owned by the main application, not by us) // This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports. ImGuiViewport* main_viewport = ImGui::GetMainViewport(); ImGuiViewportDataGlfw* data = IM_NEW(ImGuiViewportDataGlfw)(); data->Window = g_Window; data->WindowOwned = false; main_viewport->PlatformUserData = data; main_viewport->PlatformHandle = (void*)g_Window; } static void ImGui_ImplGlfw_ShutdownPlatformInterface() { }
#initial lui $1,0x2819 ori $1,$1,0x9384 lui $2,0x7cfd ori $2,$2,0x5738 lui $3,0x883c ori $3,$3,0x8847 lui $4,0x9382 ori $4,$4,0xacfe sw $1,0($0) sw $2,4($0) sw $3,8($0) sw $4,12($0) #lh ori $5,$0,5 addi $5,$5,1 lh $1,0($5) ori $6,$0,6 ori $7,$0,7 lh $2,2($6) xori $5,$2,0x8846 addiu $7,$7,1 lui $4,0xfffe xor $4,$5,$4 lh $3,2($7) #lb ori $1,$0,0x827f xori $1,$1,0x827e lb $2,0($1) addiu $1,$1,2 or $3,$1,$2 lb $3,2($1) ori $2,$0,0x000e andi $3,$2,0x0006 ori $2,$0,0x9827 andi $5,$2,0x3826 lb $5,1($3) #lhu ori $5,$0,5 addi $5,$5,1 lhu $1,0($5) ori $6,$0,6 ori $7,$0,7 lhu $2,2($6) xori $5,$2,0x8846 addiu $7,$7,1 lui $4,0xfffe xor $4,$5,$4 lhu $3,2($7) #lbu ori $1,$0,0x827f xori $1,$1,0x827e lbu $2,0($1) addiu $1,$1,2 or $3,$1,$2 lbu $3,2($1) ori $2,$0,0x000e andi $3,$2,0x0006 ori $2,$0,0x9827 andi $5,$2,0x3826 lbu $5,1($3)
; A138297: Rows of triangle A138060 converge to this sequence. ; 1,2,3,4,1,1,2,1,2,3,1,2,3,4,1,2,3,4,1 lpb $0 sub $0,4 lpb $0 add $1,1 sub $0,$1 lpe lpe add $0,1
SECTION code_fp_math48 PUBLIC asm_llround EXTERN am48_llround defc asm_llround = am48_llround
/* io/getchar.asm * Read a char from stdin * * Programmer: Mayer Goldberg, 2010 */ GETCHAR: IN(R0, IMM(1)); RETURN;
; -*- fundamental -*- (asm-mode sucks) ; **************************************************************************** ; ; pxelinux.asm ; ; A program to boot Linux kernels off a TFTP server using the Intel PXE ; network booting API. It is based on the SYSLINUX boot loader for ; MS-DOS floppies. ; ; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved ; Copyright 2009 Intel Corporation; author: H. Peter Anvin ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation, Inc., 53 Temple Place Ste 330, ; Boston MA 02111-1307, USA; either version 2 of the License, or ; (at your option) any later version; incorporated herein by reference. ; ; **************************************************************************** %define IS_PXELINUX 1 %include "head.inc" %include "pxe.inc" ; gPXE extensions support %define GPXE 1 ; ; Some semi-configurable constants... change on your own risk. ; my_id equ pxelinux_id NULLFILE equ 0 ; Zero byte == null file name NULLOFFSET equ 0 ; Position in which to look REBOOT_TIME equ 5*60 ; If failure, time until full reset %assign HIGHMEM_SLOP 128*1024 ; Avoid this much memory near the top TFTP_BLOCKSIZE_LG2 equ 9 ; log2(bytes/block) TFTP_BLOCKSIZE equ (1 << TFTP_BLOCKSIZE_LG2) SECTOR_SHIFT equ TFTP_BLOCKSIZE_LG2 SECTOR_SIZE equ TFTP_BLOCKSIZE ; --------------------------------------------------------------------------- ; BEGIN CODE ; --------------------------------------------------------------------------- ; ; Memory below this point is reserved for the BIOS and the MBR ; section .earlybss global trackbuf trackbufsize equ 8192 trackbuf resb trackbufsize ; Track buffer goes here ; ends at 2800h ; These fields save information from before the time ; .bss is zeroed... must be in .earlybss global InitStack InitStack resd 1 section .bss16 alignb FILENAME_MAX PXEStack resd 1 ; Saved stack during PXE call alignb 4 global DHCPMagic, RebootTime, APIVer, BIOSName RebootTime resd 1 ; Reboot timeout, if set by option StrucPtr resw 2 ; Pointer to PXENV+ or !PXE structure APIVer resw 1 ; PXE API version found LocalBootType resw 1 ; Local boot return code DHCPMagic resb 1 ; PXELINUX magic flags BIOSName resw 1 ; Dummy variable - always 0 section .text16 global StackBuf StackBuf equ STACK_TOP-44 ; Base of stack if we use our own StackHome equ StackBuf ; PXE loads the whole file, but assume it can't be more ; than (384-31)K in size. MaxLMA equ 384*1024 ; ; Primary entry point. ; bootsec equ $ _start: jmp 0:_start1 ; Canonicalize the address and skip ; the patch header ; ; Patch area for adding hardwired DHCP options ; align 4 hcdhcp_magic dd 0x2983c8ac ; Magic number hcdhcp_len dd 7*4 ; Size of this structure hcdhcp_flags dd 0 ; Reserved for the future ; Parameters to be parsed before the ones from PXE bdhcp_offset dd 0 ; Offset (entered by patcher) bdhcp_len dd 0 ; Length (entered by patcher) ; Parameters to be parsed *after* the ones from PXE adhcp_offset dd 0 ; Offset (entered by patcher) adhcp_len dd 0 ; Length (entered by patcher) _start1: pushfd ; Paranoia... in case of return to PXE pushad ; ... save as much state as possible push ds push es push fs push gs cld ; Copy upwards xor ax,ax mov ds,ax mov es,ax %if 0 ; debugging code only... not intended for production use ; Clobber the stack segment, to test for specific pathologies mov di,STACK_BASE mov cx,STACK_LEN >> 1 mov ax,0xf4f4 rep stosw ; Clobber the tail of the 64K segment, too extern __bss1_end mov di,__bss1_end sub cx,di ; CX = 0 previously shr cx,1 rep stosw %endif ; That is all pushed onto the PXE stack. Save the pointer ; to it and switch to an internal stack. mov [InitStack],sp mov [InitStack+2],ss lss esp,[BaseStack] sti ; Stack set up and ready ; ; Initialize screen (if we're using one) ; %include "init.inc" ; ; Tell the user we got this far ; mov si,syslinux_banner call writestr_early mov si,copyright_str call writestr_early ; ; do fs initialize ; mov eax,ROOT_FS_OPS xor ebp,ebp pm_call fs_init section .rodata alignz 4 ROOT_FS_OPS: extern pxe_fs_ops dd pxe_fs_ops dd 0 section .text16 ; ; Initialize the idle mechanism ; call reset_idle ; ; Now we're all set to start with our *real* business. ; ; In previous versions I avoided using 32-bit registers because of a ; rumour some BIOSes clobbered the upper half of 32-bit registers at ; random. I figure, though, that if there are any of those still left ; they probably won't be trying to install Linux on them... ; ; The code is still ripe with 16-bitisms, though. Not worth the hassle ; to take'm out. In fact, we may want to put them back if we're going ; to boot ELKS at some point. ; ; ; Linux kernel loading code is common. However, we need to define ; a couple of helper macros... ; ; Unload PXE stack %define HAVE_UNLOAD_PREP %macro UNLOAD_PREP 0 pm_call unload_pxe %endmacro ; ; Jump to 32-bit ELF space ; pm_call load_env32 jmp kaboom ; load_env32() shouldn't return. If it does, then kaboom! print_hello: enter_command: auto_boot: pm_call hello ; ; Save hardwired DHCP options. This is done before the C environment ; is initialized, so it has to be done in assembly. ; %define MAX_DHCP_OPTS 4096 bits 32 section .savedata global bdhcp_data, adhcp_data bdhcp_data: resb MAX_DHCP_OPTS adhcp_data: resb MAX_DHCP_OPTS section .textnr pm_save_data: mov eax,MAX_DHCP_OPTS movzx ecx,word [bdhcp_len] cmp ecx,eax jna .oksize mov ecx,eax mov [bdhcp_len],ax .oksize: mov esi,[bdhcp_offset] add esi,_start mov edi,bdhcp_data add ecx,3 shr ecx,2 rep movsd adhcp_copy: movzx ecx,word [adhcp_len] cmp ecx,eax jna .oksize mov ecx,eax mov [adhcp_len],ax .oksize: mov esi,[adhcp_offset] add esi,_start mov edi,adhcp_data add ecx,3 shr ecx,2 rep movsd ret bits 16 ; As core/ui.inc used to be included here in core/pxelinux.asm, and it's no ; longer used, its global variables that were previously used by ; core/pxelinux.asm are now declared here. section .bss16 alignb 4 Kernel_EAX resd 1 Kernel_SI resw 1 section .bss16 alignb 4 ThisKbdTo resd 1 ; Temporary holder for KbdTimeout ThisTotalTo resd 1 ; Temporary holder for TotalTimeout KernelExtPtr resw 1 ; During search, final null pointer FuncFlag resb 1 ; Escape sequences received from keyboard KernelType resb 1 ; Kernel type, from vkernel, if known global KernelName KernelName resb FILENAME_MAX ; Mangled name for kernel section .text16 ; ; COMBOOT-loading code ; %include "comboot.inc" %include "com32.inc" ; ; Boot sector loading code ; ; ; Abort loading code ; ; ; Hardware cleanup common code ; %include "localboot.inc" ; ; kaboom: write a message and bail out. Wait for quite a while, ; or a user keypress, then do a hard reboot. ; ; Note: use BIOS_timer here; we may not have jiffies set up. ; global kaboom kaboom: RESET_STACK_AND_SEGS AX .patch: mov si,bailmsg call writestr_early ; Returns with AL = 0 .drain: call pollchar jz .drained call getchar jmp short .drain .drained: mov edi,[RebootTime] mov al,[DHCPMagic] and al,09h ; Magic+Timeout cmp al,09h je .time_set mov edi,REBOOT_TIME .time_set: mov cx,18 .wait1: push cx mov ecx,edi .wait2: mov dx,[BIOS_timer] .wait3: call pollchar jnz .keypress call do_idle cmp dx,[BIOS_timer] je .wait3 loop .wait2,ecx mov al,'.' pm_call pm_writechr pop cx loop .wait1 .keypress: pm_call crlf mov word [BIOS_magic],0 ; Cold reboot jmp 0F000h:0FFF0h ; Reset vector address ; ; pxenv ; ; This is the main PXENV+/!PXE entry point, using the PXENV+ ; calling convention. This is a separate local routine so ; we can hook special things from it if necessary. In particular, ; some PXE stacks seem to not like being invoked from anything but ; the initial stack, so humour it. ; ; While we're at it, save and restore all registers. ; global pxenv pxenv: pushfd pushad ; We may be removing ourselves from memory cmp bx,PXENV_RESTART_TFTP jz .disable_timer cmp bx,PXENV_FILE_EXEC jnz .store_stack .disable_timer: call timer_cleanup .store_stack: pushf cli inc word [cs:PXEStackLock] jnz .skip1 mov [cs:PXEStack],sp mov [cs:PXEStack+2],ss lss sp,[cs:InitStack] .skip1: popf ; Pre-clear the Status field mov word [es:di],cs ; This works either for the PXENV+ or the !PXE calling ; convention, as long as we ignore CF (which is redundant ; with AX anyway.) push es push di push bx .jump: call 0:0 add sp,6 mov [cs:PXEStatus],ax pushf cli dec word [cs:PXEStackLock] jns .skip2 lss sp,[cs:PXEStack] .skip2: popf mov bp,sp and ax,ax setnz [bp+32] ; If AX != 0 set CF on return ; This clobbers the AX return, but we already saved it into ; the PXEStatus variable. popad ; If the call failed, it could return. cmp bx,PXENV_RESTART_TFTP jz .enable_timer cmp bx,PXENV_FILE_EXEC jnz .pop_flags .enable_timer: call timer_init .pop_flags: popfd ; Restore flags (incl. IF, DF) ret ; Must be after function def due to NASM bug global PXEEntry PXEEntry equ pxenv.jump+1 ; ; The PXEStackLock keeps us from switching stacks if we take an interrupt ; (which ends up calling pxenv) while we are already on the PXE stack. ; It will be -1 normally, 0 inside a PXE call, and a positive value ; inside a *nested* PXE call. ; section .data16 alignb 2 PXEStackLock dw -1 section .bss16 alignb 2 PXEStatus resb 2 section .text16 ; ; Invoke INT 1Ah on the PXE stack. This is used by the "Plan C" method ; for finding the PXE entry point. ; global pxe_int1a pxe_int1a: mov [cs:PXEStack],sp mov [cs:PXEStack+2],ss lss sp,[cs:InitStack] int 1Ah ; May trash registers lss sp,[cs:PXEStack] ret ; ; Special unload for gPXE: this switches the InitStack from ; gPXE to the ROM PXE stack. ; %if GPXE global gpxe_unload gpxe_unload: mov bx,PXENV_FILE_EXIT_HOOK mov di,pxe_file_exit_hook call pxenv jc .plain ; Now we actually need to exit back to gPXE, which will ; give control back to us on the *new* "original stack"... pushfd push ds push es mov [PXEStack],sp mov [PXEStack+2],ss lss sp,[InitStack] pop gs pop fs pop es pop ds popad popfd xor ax,ax retf .resume: cli ; gPXE will have a stack frame looking much like our ; InitStack, except it has a magic cookie at the top, ; and the segment registers are in reverse order. pop eax pop ax pop bx pop cx pop dx push ax push bx push cx push dx mov [cs:InitStack],sp mov [cs:InitStack+2],ss lss sp,[cs:PXEStack] pop es pop ds popfd .plain: ret writestr_early: pm_call pm_writestr ret pollchar: pm_call pm_pollchar ret getchar: pm_call pm_getchar ret section .data16 alignz 4 pxe_file_exit_hook: .status: dw 0 .offset: dw gpxe_unload.resume .seg: dw 0 %endif section .text16 ; ----------------------------------------------------------------------------- ; PXE modules ; ----------------------------------------------------------------------------- %if IS_LPXELINUX %include "pxeisr.inc" %endif ; ----------------------------------------------------------------------------- ; Common modules ; ----------------------------------------------------------------------------- %include "common.inc" ; Universal modules ; ----------------------------------------------------------------------------- ; Begin data section ; ----------------------------------------------------------------------------- section .data16 global copyright_str, syslinux_banner copyright_str db ' Copyright (C) 1994-' asciidec YEAR db ' H. Peter Anvin et al', CR, LF, 0 err_bootfailed db CR, LF, 'Boot failed: press a key to retry, or wait for reset...', CR, LF, 0 bailmsg equ err_bootfailed localboot_msg db 'Booting from local disk...', CR, LF, 0 syslinux_banner db CR, LF, MY_NAME, ' ', VERSION_STR, ' ', DATE_STR, ' ', 0 ; ; Misc initialized (data) variables ; section .data16 global KeepPXE KeepPXE db 0 ; Should PXE be kept around? ; ; IP information. Note that the field are in the same order as the ; Linux kernel expects in the ip= option. ; section .bss16 alignb 4 global IPInfo IPInfo: .IPv4 resd 1 ; IPv4 information .MyIP resd 1 ; My IP address .ServerIP resd 1 .GatewayIP resd 1 .Netmask resd 1
#define USE_SYNTAX #define USE_PGMEM #define USE_PGMCNV #define USE_PGMXMS #define USE_STDIO #define USE_STDLIB #define USE_MEM #define USE_ERROR #include <pub\config.hpp> #include <inccnt.list.hpp> struct pair { pg_mem pgm; uint16 seed; }; pair table[pg_mem_page_cmax]; word table_cnt; void alloc_page() { printf("page allocation: "); table_cnt=0; try { while(table_cnt<pg_mem_page_cmax) { table[table_cnt].pgm.alloc(); table[table_cnt].seed=table_cnt; //rand(); printf("alloc page %d with %X\n",table_cnt,table[table_cnt].seed); table_cnt++; } printf("max pages (%d) allocated.\n",table_cnt); } catch( pg_mem::err_no_mem ) { printf("%d pages allocated.\n",table_cnt); } printf("total %d KB allocated.\n",table_cnt*pg_mem_page_size_k); printf("press a key"); getchar(); } void alloc_and_set_page() { printf("page allocation: "); table_cnt=0; try { while(table_cnt<pg_mem_page_cmax) { table[table_cnt].pgm.alloc(); table[table_cnt].seed=table_cnt; //rand(); void* p=table[table_cnt].pgm.lock(); mem_set_16(p,table[table_cnt].seed,pg_mem_page_size/2); ASSERT(sh_mem_check_bp(p)); table[table_cnt].pgm.unlock(); printf("alloc and set page %d with %X\n",table_cnt,table[table_cnt].seed); table_cnt++; } printf("max pages (%d) allocated.\n",table_cnt); } catch( pg_mem::err_no_mem ) { printf("%d pages allocated.\n",table_cnt); } printf("total %d KB allocated.\n",table_cnt*pg_mem_page_size_k); printf("press a key"); getchar(); } void set_page() { word i; void* p; forcnt(i,table_cnt) { p=table[i].pgm.lock(); mem_set_16(p,table[i].seed,pg_mem_page_size_k*1024/2); ASSERT(sh_mem_check_bp(p)); table[i].pgm.unlock(); printf("set page %d with %X\n",i,table[i].seed); } printf("press a key"); getchar(); } void compare_data() { word i,j; void* p; forcnt(i,table_cnt) { p=table[i].pgm.lock(); printf("compare data: page %d : table val %X , page val %X %X\n", i,table[i].seed,*(uint16*)p,*((uint16*)p+1) ); /**/ table[i].pgm.unlock(); } printf("press a key"); getchar(); } void verify_page() { word i,j; void* p; forcnt(i,table_cnt) { p=table[i].pgm.lock(); forcnt(j,pg_mem_page_size_k*1024/2) { if ( *((uint16*)p+j)!=table[i].seed ) halt("not match"); } table[i].pgm.unlock(); printf("verify page %d with %X OK\n",i,table[i].seed); } printf("press a key"); getchar(); } void free_page() { word i; forcnt(i,table_cnt) { table[i].pgm.free(); printf("free page %d\n",i); } printf("press a key"); getchar(); } void cdecl main(void) { // printf("size of pg_mem %d\n",sizeof (pg_mem)); // halt(); pg_mem_xms::max_size_k(1024); pg_mem_cnv::init(); pg_mem_xms::init(); pg_mem::init(); alloc_page(); set_page(); compare_data(); verify_page(); free_page(); // verify_page(); // alloc_page(); // set_page(); // verify_page(); }
db "DRAGON@" ; species name db "It sheds many lay-" next "ers of skin as it" next "grows larger. Dur-" page "ing this process," next "it is protected by" next "a rapid waterfall.@"
; the TRAP vector table .ORIG x0000 .FILL 612 ; x00 .FILL 612 ; x01 .FILL 612 ; x02 .FILL 612 ; x03 .FILL 612 ; x04 .FILL 612 ; x05 .FILL 612 ; x06 .FILL 612 ; x07 .FILL 612 ; x08 .FILL 612 ; x09 .FILL 612 ; x0A .FILL 612 ; x0B .FILL 612 ; x0C .FILL 612 ; x0D .FILL 612 ; x0E .FILL 612 ; x0F .FILL 612 ; x10 .FILL 612 ; x11 .FILL 612 ; x12 .FILL 612 ; x13 .FILL 612 ; x14 .FILL 612 ; x15 .FILL 612 ; x16 .FILL 612 ; x17 .FILL 612 ; x18 .FILL 612 ; x19 .FILL 612 ; x1A .FILL 612 ; x1B .FILL 612 ; x1C .FILL 612 ; x1D .FILL 612 ; x1E .FILL 612 ; x1F .FILL 541 ; x20 .FILL 545 ; x21 .FILL 551 ; x22 .FILL 564 ; x23 .FILL 576 ; x24 .FILL 607 ; x25 .FILL 612 ; x26 .FILL 612 ; x27 .FILL 612 ; x28 .FILL 612 ; x29 .FILL 612 ; x2A .FILL 612 ; x2B .FILL 612 ; x2C .FILL 612 ; x2D .FILL 612 ; x2E .FILL 612 ; x2F .FILL 612 ; x30 .FILL 612 ; x31 .FILL 612 ; x32 .FILL 612 ; x33 .FILL 612 ; x34 .FILL 612 ; x35 .FILL 612 ; x36 .FILL 612 ; x37 .FILL 612 ; x38 .FILL 612 ; x39 .FILL 612 ; x3A .FILL 612 ; x3B .FILL 612 ; x3C .FILL 612 ; x3D .FILL 612 ; x3E .FILL 612 ; x3F .FILL 612 ; x40 .FILL 612 ; x41 .FILL 612 ; x42 .FILL 612 ; x43 .FILL 612 ; x44 .FILL 612 ; x45 .FILL 612 ; x46 .FILL 612 ; x47 .FILL 612 ; x48 .FILL 612 ; x49 .FILL 612 ; x4A .FILL 612 ; x4B .FILL 612 ; x4C .FILL 612 ; x4D .FILL 612 ; x4E .FILL 612 ; x4F .FILL 612 ; x50 .FILL 612 ; x51 .FILL 612 ; x52 .FILL 612 ; x53 .FILL 612 ; x54 .FILL 612 ; x55 .FILL 612 ; x56 .FILL 612 ; x57 .FILL 612 ; x58 .FILL 612 ; x59 .FILL 612 ; x5A .FILL 612 ; x5B .FILL 612 ; x5C .FILL 612 ; x5D .FILL 612 ; x5E .FILL 612 ; x5F .FILL 612 ; x60 .FILL 612 ; x61 .FILL 612 ; x62 .FILL 612 ; x63 .FILL 612 ; x64 .FILL 612 ; x65 .FILL 612 ; x66 .FILL 612 ; x67 .FILL 612 ; x68 .FILL 612 ; x69 .FILL 612 ; x6A .FILL 612 ; x6B .FILL 612 ; x6C .FILL 612 ; x6D .FILL 612 ; x6E .FILL 612 ; x6F .FILL 612 ; x70 .FILL 612 ; x71 .FILL 612 ; x72 .FILL 612 ; x73 .FILL 612 ; x74 .FILL 612 ; x75 .FILL 612 ; x76 .FILL 612 ; x77 .FILL 612 ; x78 .FILL 612 ; x79 .FILL 612 ; x7A .FILL 612 ; x7B .FILL 612 ; x7C .FILL 612 ; x7D .FILL 612 ; x7E .FILL 612 ; x7F .FILL 612 ; x80 .FILL 612 ; x81 .FILL 612 ; x82 .FILL 612 ; x83 .FILL 612 ; x84 .FILL 612 ; x85 .FILL 612 ; x86 .FILL 612 ; x87 .FILL 612 ; x88 .FILL 612 ; x89 .FILL 612 ; x8A .FILL 612 ; x8B .FILL 612 ; x8C .FILL 612 ; x8D .FILL 612 ; x8E .FILL 612 ; x8F .FILL 612 ; x90 .FILL 612 ; x91 .FILL 612 ; x92 .FILL 612 ; x93 .FILL 612 ; x94 .FILL 612 ; x95 .FILL 612 ; x96 .FILL 612 ; x97 .FILL 612 ; x98 .FILL 612 ; x99 .FILL 612 ; x9A .FILL 612 ; x9B .FILL 612 ; x9C .FILL 612 ; x9D .FILL 612 ; x9E .FILL 612 ; x9F .FILL 612 ; xA0 .FILL 612 ; xA1 .FILL 612 ; xA2 .FILL 612 ; xA3 .FILL 612 ; xA4 .FILL 612 ; xA5 .FILL 612 ; xA6 .FILL 612 ; xA7 .FILL 612 ; xA8 .FILL 612 ; xA9 .FILL 612 ; xAA .FILL 612 ; xAB .FILL 612 ; xAC .FILL 612 ; xAD .FILL 612 ; xAE .FILL 612 ; xAF .FILL 612 ; xB0 .FILL 612 ; xB1 .FILL 612 ; xB2 .FILL 612 ; xB3 .FILL 612 ; xB4 .FILL 612 ; xB5 .FILL 612 ; xB6 .FILL 612 ; xB7 .FILL 612 ; xB8 .FILL 612 ; xB9 .FILL 612 ; xBA .FILL 612 ; xBB .FILL 612 ; xBC .FILL 612 ; xBD .FILL 612 ; xBE .FILL 612 ; xBF .FILL 612 ; xC0 .FILL 612 ; xC1 .FILL 612 ; xC2 .FILL 612 ; xC3 .FILL 612 ; xC4 .FILL 612 ; xC5 .FILL 612 ; xC6 .FILL 612 ; xC7 .FILL 612 ; xC8 .FILL 612 ; xC9 .FILL 612 ; xCA .FILL 612 ; xCB .FILL 612 ; xCC .FILL 612 ; xCD .FILL 612 ; xCE .FILL 612 ; xCF .FILL 612 ; xD0 .FILL 612 ; xD1 .FILL 612 ; xD2 .FILL 612 ; xD3 .FILL 612 ; xD4 .FILL 612 ; xD5 .FILL 612 ; xD6 .FILL 612 ; xD7 .FILL 612 ; xD8 .FILL 612 ; xD9 .FILL 612 ; xDA .FILL 612 ; xDB .FILL 612 ; xDC .FILL 612 ; xDD .FILL 612 ; xDE .FILL 612 ; xDF .FILL 612 ; xE0 .FILL 612 ; xE1 .FILL 612 ; xE2 .FILL 612 ; xE3 .FILL 612 ; xE4 .FILL 612 ; xE5 .FILL 612 ; xE6 .FILL 612 ; xE7 .FILL 612 ; xE8 .FILL 612 ; xE9 .FILL 612 ; xEA .FILL 612 ; xEB .FILL 612 ; xEC .FILL 612 ; xED .FILL 612 ; xEE .FILL 612 ; xEF .FILL 612 ; xF0 .FILL 612 ; xF1 .FILL 612 ; xF2 .FILL 612 ; xF3 .FILL 612 ; xF4 .FILL 612 ; xF5 .FILL 612 ; xF6 .FILL 612 ; xF7 .FILL 612 ; xF8 .FILL 612 ; xF9 .FILL 612 ; xFA .FILL 612 ; xFB .FILL 612 ; xFC .FILL 612 ; xFD .FILL 612 ; xFE .FILL 612 ; xFF ; the interrupt vector table ; interrupts are not currently implemented .FILL 613 ; x00 .FILL 613 ; x01 .FILL 613 ; x02 .FILL 613 ; x03 .FILL 613 ; x04 .FILL 613 ; x05 .FILL 613 ; x06 .FILL 613 ; x07 .FILL 613 ; x08 .FILL 613 ; x09 .FILL 613 ; x0A .FILL 613 ; x0B .FILL 613 ; x0C .FILL 613 ; x0D .FILL 613 ; x0E .FILL 613 ; x0F .FILL 613 ; x10 .FILL 613 ; x11 .FILL 613 ; x12 .FILL 613 ; x13 .FILL 613 ; x14 .FILL 613 ; x15 .FILL 613 ; x16 .FILL 613 ; x17 .FILL 613 ; x18 .FILL 613 ; x19 .FILL 613 ; x1A .FILL 613 ; x1B .FILL 613 ; x1C .FILL 613 ; x1D .FILL 613 ; x1E .FILL 613 ; x1F .FILL 613 ; x20 .FILL 613 ; x21 .FILL 613 ; x22 .FILL 613 ; x23 .FILL 613 ; x24 .FILL 613 ; x25 .FILL 613 ; x26 .FILL 613 ; x27 .FILL 613 ; x28 .FILL 613 ; x29 .FILL 613 ; x2A .FILL 613 ; x2B .FILL 613 ; x2C .FILL 613 ; x2D .FILL 613 ; x2E .FILL 613 ; x2F .FILL 613 ; x30 .FILL 613 ; x31 .FILL 613 ; x32 .FILL 613 ; x33 .FILL 613 ; x34 .FILL 613 ; x35 .FILL 613 ; x36 .FILL 613 ; x37 .FILL 613 ; x38 .FILL 613 ; x39 .FILL 613 ; x3A .FILL 613 ; x3B .FILL 613 ; x3C .FILL 613 ; x3D .FILL 613 ; x3E .FILL 613 ; x3F .FILL 613 ; x40 .FILL 613 ; x41 .FILL 613 ; x42 .FILL 613 ; x43 .FILL 613 ; x44 .FILL 613 ; x45 .FILL 613 ; x46 .FILL 613 ; x47 .FILL 613 ; x48 .FILL 613 ; x49 .FILL 613 ; x4A .FILL 613 ; x4B .FILL 613 ; x4C .FILL 613 ; x4D .FILL 613 ; x4E .FILL 613 ; x4F .FILL 613 ; x50 .FILL 613 ; x51 .FILL 613 ; x52 .FILL 613 ; x53 .FILL 613 ; x54 .FILL 613 ; x55 .FILL 613 ; x56 .FILL 613 ; x57 .FILL 613 ; x58 .FILL 613 ; x59 .FILL 613 ; x5A .FILL 613 ; x5B .FILL 613 ; x5C .FILL 613 ; x5D .FILL 613 ; x5E .FILL 613 ; x5F .FILL 613 ; x60 .FILL 613 ; x61 .FILL 613 ; x62 .FILL 613 ; x63 .FILL 613 ; x64 .FILL 613 ; x65 .FILL 613 ; x66 .FILL 613 ; x67 .FILL 613 ; x68 .FILL 613 ; x69 .FILL 613 ; x6A .FILL 613 ; x6B .FILL 613 ; x6C .FILL 613 ; x6D .FILL 613 ; x6E .FILL 613 ; x6F .FILL 613 ; x70 .FILL 613 ; x71 .FILL 613 ; x72 .FILL 613 ; x73 .FILL 613 ; x74 .FILL 613 ; x75 .FILL 613 ; x76 .FILL 613 ; x77 .FILL 613 ; x78 .FILL 613 ; x79 .FILL 613 ; x7A .FILL 613 ; x7B .FILL 613 ; x7C .FILL 613 ; x7D .FILL 613 ; x7E .FILL 613 ; x7F .FILL 613 ; x80 .FILL 613 ; x81 .FILL 613 ; x82 .FILL 613 ; x83 .FILL 613 ; x84 .FILL 613 ; x85 .FILL 613 ; x86 .FILL 613 ; x87 .FILL 613 ; x88 .FILL 613 ; x89 .FILL 613 ; x8A .FILL 613 ; x8B .FILL 613 ; x8C .FILL 613 ; x8D .FILL 613 ; x8E .FILL 613 ; x8F .FILL 613 ; x90 .FILL 613 ; x91 .FILL 613 ; x92 .FILL 613 ; x93 .FILL 613 ; x94 .FILL 613 ; x95 .FILL 613 ; x96 .FILL 613 ; x97 .FILL 613 ; x98 .FILL 613 ; x99 .FILL 613 ; x9A .FILL 613 ; x9B .FILL 613 ; x9C .FILL 613 ; x9D .FILL 613 ; x9E .FILL 613 ; x9F .FILL 613 ; xA0 .FILL 613 ; xA1 .FILL 613 ; xA2 .FILL 613 ; xA3 .FILL 613 ; xA4 .FILL 613 ; xA5 .FILL 613 ; xA6 .FILL 613 ; xA7 .FILL 613 ; xA8 .FILL 613 ; xA9 .FILL 613 ; xAA .FILL 613 ; xAB .FILL 613 ; xAC .FILL 613 ; xAD .FILL 613 ; xAE .FILL 613 ; xAF .FILL 613 ; xB0 .FILL 613 ; xB1 .FILL 613 ; xB2 .FILL 613 ; xB3 .FILL 613 ; xB4 .FILL 613 ; xB5 .FILL 613 ; xB6 .FILL 613 ; xB7 .FILL 613 ; xB8 .FILL 613 ; xB9 .FILL 613 ; xBA .FILL 613 ; xBB .FILL 613 ; xBC .FILL 613 ; xBD .FILL 613 ; xBE .FILL 613 ; xBF .FILL 613 ; xC0 .FILL 613 ; xC1 .FILL 613 ; xC2 .FILL 613 ; xC3 .FILL 613 ; xC4 .FILL 613 ; xC5 .FILL 613 ; xC6 .FILL 613 ; xC7 .FILL 613 ; xC8 .FILL 613 ; xC9 .FILL 613 ; xCA .FILL 613 ; xCB .FILL 613 ; xCC .FILL 613 ; xCD .FILL 613 ; xCE .FILL 613 ; xCF .FILL 613 ; xD0 .FILL 613 ; xD1 .FILL 613 ; xD2 .FILL 613 ; xD3 .FILL 613 ; xD4 .FILL 613 ; xD5 .FILL 613 ; xD6 .FILL 613 ; xD7 .FILL 613 ; xD8 .FILL 613 ; xD9 .FILL 613 ; xDA .FILL 613 ; xDB .FILL 613 ; xDC .FILL 613 ; xDD .FILL 613 ; xDE .FILL 613 ; xDF .FILL 613 ; xE0 .FILL 613 ; xE1 .FILL 613 ; xE2 .FILL 613 ; xE3 .FILL 613 ; xE4 .FILL 613 ; xE5 .FILL 613 ; xE6 .FILL 613 ; xE7 .FILL 613 ; xE8 .FILL 613 ; xE9 .FILL 613 ; xEA .FILL 613 ; xEB .FILL 613 ; xEC .FILL 613 ; xED .FILL 613 ; xEE .FILL 613 ; xEF .FILL 613 ; xF0 .FILL 613 ; xF1 .FILL 613 ; xF2 .FILL 613 ; xF3 .FILL 613 ; xF4 .FILL 613 ; xF5 .FILL 613 ; xF6 .FILL 613 ; xF7 .FILL 613 ; xF8 .FILL 613 ; xF9 .FILL 613 ; xFA .FILL 613 ; xFB .FILL 613 ; xFC .FILL 613 ; xFD .FILL 613 ; xFE .FILL 613 ; xFF ;;; OS_START - operating system entry point (always starts at x0200) ;; set MPR OS_START LD R0, MPR_INIT ; STI R0, OS_MPR ; ;; set timer interval LD R0, TIM_INIT ; STI R0, OS_TMI ; ;; start running user code (clear Privilege bit w/ JMPT) LD R7, USER_CODE_ADDR ; JMPT R7 ; OS_KBSR .FILL xFE00 ; keyboard status register OS_KBDR .FILL xFE02 ; keyboard data register OS_DSR .FILL xFE04 ; display status register OS_DDR .FILL xFE06 ; display data register OS_TR .FILL xFE08 ; timer register OS_TMI .FILL xFE0A ; timer interval register OS_MPR .FILL xFE12 ; memory protection register OS_MCR .FILL xFFFE ; machine control register OS_SAVE_R0 .FILL x0000 OS_SAVE_R1 .FILL x0000 OS_SAVE_R2 .FILL x0000 OS_SAVE_R3 .FILL x0000 OS_SAVE_R4 .FILL x0000 OS_SAVE_R5 .FILL x0000 OS_SAVE_R6 .FILL x0000 OS_SAVE_R7 .FILL x0000 OS_OUT_SAVE_R1 .FILL x0000 OS_IN_SAVE_R7 .FILL x0000 MASK_HI .FILL x7FFF LOW_8_BITS .FILL x00FF TIM_INIT .FILL x0028 ;MPR_INIT .FILL xFFFF ; user can access everything MPR_INIT .FILL x0FF8 ; user can access x3000 to xbfff USER_CODE_ADDR .FILL x3000 ; user code starts at x3000 ;;; GETC - Read a single character of input from keyboard device into R0 TRAP_GETC LDI R0, OS_KBSR ; wait for a keystroke BRzp TRAP_GETC LDI R0, OS_KBDR ; read it and return RET ;;; OUT - Write the character in R0 to the console. TRAP_OUT ST R1, OS_OUT_SAVE_R1 ; save R1 TRAP_OUT_WAIT LDI R1, OS_DSR ; wait for the display to be ready BRzp TRAP_OUT_WAIT STI R0, OS_DDR ; write the character and return LD R1, OS_OUT_SAVE_R1 ; restore R1 RET ;;; PUTS - Write a NUL-terminated string of characters to the console, ;;; starting from the address in R0. TRAP_PUTS ST R0, OS_SAVE_R0 ; save R0, R1, and R7 ST R1, OS_SAVE_R1 ST R7, OS_SAVE_R7 ADD R1, R0, #0 ; move string pointer (R0) into R1 TRAP_PUTS_LOOP LDR R0, R1, #0 ; write characters in string using OUT BRz TRAP_PUTS_DONE OUT ADD R1, R1, #1 BR TRAP_PUTS_LOOP TRAP_PUTS_DONE LD R0, OS_SAVE_R0 ; restore R0, R1, and R7 LD R1, OS_SAVE_R1 LD R7, OS_SAVE_R7 RET ;;; IN - prompt the user for a single character input, which is stored ;;; in R0 and also echoed to the console. TRAP_IN ST R7, OS_IN_SAVE_R7 ; save R7 (no need to save R0, since we; overwrite later LEA R0, TRAP_IN_MSG ; prompt for input PUTS GETC ; read a character OUT ; echo back to monitor ST R0, OS_SAVE_R0 ; save the character AND R0, R0, #0 ; write a linefeed, too ADD R0, R0, #10 OUT LD R0, OS_SAVE_R0 ; restore the character LD R7, OS_IN_SAVE_R7 ; restore R7 RET ; this doesn't work, because ;;; PUTSP - Write a NUL-terminated string of characters, packed 2 per ;;; memory location, to the console, starting from the address in R0. ; NOTE: This trap will end when it sees any NUL, even in ; packed form, despite the P&P second edition's requirement ; of a double NUL. TRAP_PUTSP ST R0, OS_SAVE_R0 ; save R0, R1, R2, R3, and R7 ST R1, OS_SAVE_R1 ST R2, OS_SAVE_R2 ST R3, OS_SAVE_R3 ST R7, OS_SAVE_R7 ADD R1, R0, #0 ; move string pointer (R0) into R1 TRAP_PUTSP_LOOP LDR R2, R1, #0 ; read the next two characters LD R0, LOW_8_BITS ; use mask to get low byte AND R0, R0, R2 ; if low byte is NUL, quit printing BRz TRAP_PUTSP_DONE OUT ; otherwise print the low byte AND R0, R0, #0 ; shift high byte into R0 ADD R3, R0, #8 TRAP_PUTSP_S_LOOP ADD R0, R0, R0 ; shift R0 left ADD R2, R2, #0 ; move MSB from R2 into R0 BRzp TRAP_PUTSP_MSB_0 ADD R0, R0, #1 TRAP_PUTSP_MSB_0 ADD R2, R2, R2 ; shift R2 left ADD R3, R3, #-1 BRp TRAP_PUTSP_S_LOOP ADD R0, R0, #0 ; if high byte is NUL, quit printing BRz TRAP_PUTSP_DONE OUT ; otherwise print the low byte ADD R1, R1, #1 ; and keep going BR TRAP_PUTSP_LOOP TRAP_PUTSP_DONE LD R0, OS_SAVE_R0 ; restore R0, R1, R2, R3, and R7 LD R1, OS_SAVE_R1 LD R2, OS_SAVE_R2 LD R3, OS_SAVE_R3 LD R7, OS_SAVE_R7 RET ;;; HALT - trap handler for halting machine TRAP_HALT LDI R0, OS_MCR LD R1, MASK_HI ; clear run bit in MCR AND R0, R0, R1 STI R0, OS_MCR ; halt! BR OS_START ; restart machine ;;; BAD_TRAP - code to execute for undefined trap BAD_TRAP BR TRAP_HALT ; execute HALT ;;; BAD_INT - code to execute for undefined interrupt. There won't ;;; actually be any interrupts, so this will never actually get called. BAD_INT RTI TRAP_IN_MSG .FILL x000A .FILL x0049 .FILL x006E .FILL x0070 .FILL x0075 .FILL x0074 .FILL x0020 .FILL x0061 .FILL x0020 .FILL x0063 .FILL x0068 .FILL x0061 .FILL x0072 .FILL x0061 .FILL x0063 .FILL x0074 .FILL x0065 .FILL x0072 .FILL x003E .FILL x0020 .FILL x0000 x0000 .END
#include "XMLHttpRequest.h" #include <Babylon/JsRuntime.h> #include <Babylon/Polyfills/XMLHttpRequest.h> namespace Babylon::Polyfills::Internal { namespace { namespace ResponseType { constexpr const char* Text = "text"; constexpr const char* ArrayBuffer = "arraybuffer"; UrlLib::UrlResponseType StringToEnum(const std::string& value) { if (value == Text) return UrlLib::UrlResponseType::String; if (value == ArrayBuffer) return UrlLib::UrlResponseType::Buffer; throw std::runtime_error{"Unsupported response type: " + value}; } const char* EnumToString(UrlLib::UrlResponseType value) { switch (value) { case UrlLib::UrlResponseType::String: return Text; case UrlLib::UrlResponseType::Buffer: return ArrayBuffer; } throw std::runtime_error{"Invalid response type"}; } } namespace MethodType { constexpr const char* Get = "GET"; UrlLib::UrlMethod StringToEnum(const std::string& value) { if (value == Get) return UrlLib::UrlMethod::Get; throw std::runtime_error{"Unsupported url method: " + value}; } } namespace EventType { constexpr const char* ReadyStateChange = "readystatechange"; constexpr const char* LoadEnd = "loadend"; } } void XMLHttpRequest::Initialize(Napi::Env env) { Napi::HandleScope scope{env}; static constexpr auto JS_XML_HTTP_REQUEST_CONSTRUCTOR_NAME = "XMLHttpRequest"; Napi::Function func = DefineClass( env, JS_XML_HTTP_REQUEST_CONSTRUCTOR_NAME, { StaticValue("UNSENT", Napi::Value::From(env, 0)), StaticValue("OPENED", Napi::Value::From(env, 1)), StaticValue("HEADERS_RECEIVED", Napi::Value::From(env, 2)), StaticValue("LOADING", Napi::Value::From(env, 3)), StaticValue("DONE", Napi::Value::From(env, 4)), InstanceAccessor("readyState", &XMLHttpRequest::GetReadyState, nullptr), InstanceAccessor("response", &XMLHttpRequest::GetResponse, nullptr), InstanceAccessor("responseText", &XMLHttpRequest::GetResponseText, nullptr), InstanceAccessor("responseType", &XMLHttpRequest::GetResponseType, &XMLHttpRequest::SetResponseType), InstanceAccessor("responseURL", &XMLHttpRequest::GetResponseURL, nullptr), InstanceAccessor("status", &XMLHttpRequest::GetStatus, nullptr), InstanceMethod("addEventListener", &XMLHttpRequest::AddEventListener), InstanceMethod("removeEventListener", &XMLHttpRequest::RemoveEventListener), InstanceMethod("abort", &XMLHttpRequest::Abort), InstanceMethod("open", &XMLHttpRequest::Open), InstanceMethod("send", &XMLHttpRequest::Send), }); if (env.Global().Get(JS_XML_HTTP_REQUEST_CONSTRUCTOR_NAME).IsUndefined()) { env.Global().Set(JS_XML_HTTP_REQUEST_CONSTRUCTOR_NAME, func); } JsRuntime::NativeObject::GetFromJavaScript(env).Set(JS_XML_HTTP_REQUEST_CONSTRUCTOR_NAME, func); } XMLHttpRequest::XMLHttpRequest(const Napi::CallbackInfo& info) : Napi::ObjectWrap<XMLHttpRequest>{info} , m_runtimeScheduler{JsRuntime::GetFromJavaScript(info.Env())} { } Napi::Value XMLHttpRequest::GetReadyState(const Napi::CallbackInfo&) { return Napi::Value::From(Env(), arcana::underlying_cast(m_readyState)); } Napi::Value XMLHttpRequest::GetResponse(const Napi::CallbackInfo&) { gsl::span<const std::byte> responseBuffer{m_request.ResponseBuffer()}; auto arrayBuffer{Napi::ArrayBuffer::New(Env(), responseBuffer.size())}; std::memcpy(arrayBuffer.Data(), responseBuffer.data(), arrayBuffer.ByteLength()); return std::move(arrayBuffer); } Napi::Value XMLHttpRequest::GetResponseText(const Napi::CallbackInfo&) { return Napi::Value::From(Env(), m_request.ResponseString().data()); } Napi::Value XMLHttpRequest::GetResponseType(const Napi::CallbackInfo&) { return Napi::Value::From(Env(), ResponseType::EnumToString(m_request.ResponseType())); } void XMLHttpRequest::SetResponseType(const Napi::CallbackInfo&, const Napi::Value& value) { m_request.ResponseType(ResponseType::StringToEnum(value.As<Napi::String>().Utf8Value())); } Napi::Value XMLHttpRequest::GetResponseURL(const Napi::CallbackInfo&) { return Napi::Value::From(Env(), m_request.ResponseUrl().data()); } Napi::Value XMLHttpRequest::GetStatus(const Napi::CallbackInfo&) { return Napi::Value::From(Env(), arcana::underlying_cast(m_request.StatusCode())); } void XMLHttpRequest::AddEventListener(const Napi::CallbackInfo& info) { std::string eventType = info[0].As<Napi::String>().Utf8Value(); Napi::Function eventHandler = info[1].As<Napi::Function>(); const auto& eventHandlerRefs = m_eventHandlerRefs[eventType]; for (auto it = eventHandlerRefs.begin(); it != eventHandlerRefs.end(); ++it) { if (it->Value() == eventHandler) { throw Napi::Error::New(info.Env(), "Cannot add the same event handler twice"); } } m_eventHandlerRefs[eventType].push_back(Napi::Persistent(eventHandler)); } void XMLHttpRequest::RemoveEventListener(const Napi::CallbackInfo& info) { std::string eventType = info[0].As<Napi::String>().Utf8Value(); Napi::Function eventHandler = info[1].As<Napi::Function>(); auto itType = m_eventHandlerRefs.find(eventType); if (itType != m_eventHandlerRefs.end()) { auto& eventHandlerRefs = itType->second; for (auto it = eventHandlerRefs.begin(); it != eventHandlerRefs.end(); ++it) { if (it->Value() == eventHandler) { eventHandlerRefs.erase(it); break; } } } } void XMLHttpRequest::Abort(const Napi::CallbackInfo&) { m_request.Abort(); } void XMLHttpRequest::Open(const Napi::CallbackInfo& info) { m_request.Open(MethodType::StringToEnum(info[0].As<Napi::String>().Utf8Value()), info[1].As<Napi::String>().Utf8Value()); SetReadyState(ReadyState::Opened); } void XMLHttpRequest::Send(const Napi::CallbackInfo& info) { m_request.SendAsync().then(m_runtimeScheduler, arcana::cancellation::none(), [env{info.Env()}, this](arcana::expected<void, std::exception_ptr> result) { if (result.has_error()) { // Bail if UrlLib throws an exception. std::abort(); } SetReadyState(ReadyState::Done); RaiseEvent(EventType::LoadEnd); // Assume the XMLHttpRequest will only be used for a single request and clear the event handlers. // Single use seems to be the standard pattern, and we need to release our strong refs to event handlers. m_eventHandlerRefs.clear(); }); } void XMLHttpRequest::SetReadyState(ReadyState readyState) { m_readyState = readyState; RaiseEvent(EventType::ReadyStateChange); } void XMLHttpRequest::RaiseEvent(const char* eventType) { auto it = m_eventHandlerRefs.find(eventType); if (it != m_eventHandlerRefs.end()) { const auto& eventHandlerRefs = it->second; for (const auto& eventHandlerRef : eventHandlerRefs) { eventHandlerRef.Call({}); } } } } namespace Babylon::Polyfills::XMLHttpRequest { void Initialize(Napi::Env env) { Internal::XMLHttpRequest::Initialize(env); } }