text
stringlengths
1
1.05M
; A195034: Vertex number of a square spiral in which the length of the first two edges are the legs of the primitive Pythagorean triple [21, 20, 29]. The edges of the spiral have length A195033. ; 0,21,41,83,123,186,246,330,410,515,615,741,861,1008,1148,1316,1476,1665,1845,2055,2255,2486,2706,2958,3198,3471,3731,4025,4305,4620,4920,5256,5576,5933,6273,6651,7011,7410,7790,8210,8610,9051,9471,9933,10373,10856,11316,11820,12300,12825,13325,13871,14391,14958,15498,16086,16646,17255,17835,18465,19065,19716,20336,21008,21648,22341,23001,23715,24395,25130,25830,26586,27306,28083,28823,29621,30381,31200,31980,32820,33620,34481,35301,36183,37023,37926,38786,39710,40590,41535,42435,43401,44321,45308,46248,47256,48216,49245,50225,51275,52275,53346,54366,55458,56498,57611,58671,59805,60885,62040,63140,64316,65436,66633,67773,68991,70151,71390,72570,73830,75030,76311,77531,78833,80073,81396,82656,84000,85280,86645,87945,89331,90651,92058,93398,94826,96186,97635,99015,100485,101885,103376,104796,106308,107748,109281,110741,112295,113775,115350,116850,118446,119966,121583,123123,124761,126321,127980,129560,131240,132840,134541,136161,137883,139523,141266,142926,144690,146370,148155,149855,151661,153381,155208,156948,158796,160556,162425,164205,166095,167895,169806,171626,173558,175398,177351,179211,181185,183065,185060,186960,188976,190896,192933,194873,196931,198891,200970,202950,205050,207050,209171,211191,213333,215373,217536,219596,221780,223860,226065,228165,230391,232511,234758,236898,239166,241326,243615,245795,248105,250305,252636,254856,257208,259448,261821,264081,266475,268755,271170,273470,275906,278226,280683,283023,285501,287861,290360,292740,295260,297660,300201,302621,305183,307623,310206,312666,315270,317750,320375 mov $2,3 mov $3,2 mov $7,5 mov $8,$0 mov $9,$0 lpb $2 mov $5,$9 mul $7,2 lpb $5 add $7,1 add $1,$7 trn $5,$3 lpe mov $2,2 lpe mov $4,$8 mul $4,5 add $1,$4 mov $6,$8 mul $6,$8 mov $4,$6 mul $4,5 add $1,$4
;; ;; Copyright (c) 2020-2021, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; %include "include/os.asm" %include "include/reg_sizes.asm" %include "include/crc32_const.inc" %include "include/clear_regs.asm" %include "include/cet.inc" [bits 64] default rel %ifdef LINUX %define arg1 rdi %define arg2 rsi %define arg3 rdx %define arg4 rcx %else %define arg1 rcx %define arg2 rdx %define arg3 r8 %define arg4 r9 %endif struc STACK_FRAME _xmm_save: resq 8 * 2 _rsp_save: resq 1 endstruc section .text ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; arg1 - buffer pointer ;; arg2 - buffer size in bytes ;; Returns CRC value through RAX align 32 MKGLOBAL(crc32_sctp_avx512, function,) crc32_sctp_avx512: endbranch64 %ifdef SAFE_PARAM or arg1, arg1 jz .wrong_param %endif %ifndef LINUX mov rax, rsp sub rsp, STACK_FRAME_size and rsp, -16 mov [rsp + _rsp_save], rax vmovdqa [rsp + _xmm_save + 16*0], xmm6 vmovdqa [rsp + _xmm_save + 16*1], xmm7 vmovdqa [rsp + _xmm_save + 16*2], xmm8 vmovdqa [rsp + _xmm_save + 16*3], xmm9 vmovdqa [rsp + _xmm_save + 16*4], xmm10 vmovdqa [rsp + _xmm_save + 16*5], xmm11 vmovdqa [rsp + _xmm_save + 16*6], xmm12 vmovdqa [rsp + _xmm_save + 16*7], xmm13 %endif lea arg4, [rel crc32_sctp_const] mov arg3, arg2 mov arg2, arg1 xor DWORD(arg1), DWORD(arg1) call crc32_by16_vclmul_avx512 %ifdef SAFE_DATA clear_scratch_zmms_asm %endif %ifndef LINUX vmovdqa xmm6, [rsp + _xmm_save + 16*0] vmovdqa xmm7, [rsp + _xmm_save + 16*1] vmovdqa xmm8, [rsp + _xmm_save + 16*2] vmovdqa xmm9, [rsp + _xmm_save + 16*3] vmovdqa xmm10, [rsp + _xmm_save + 16*4] vmovdqa xmm11, [rsp + _xmm_save + 16*5] vmovdqa xmm12, [rsp + _xmm_save + 16*6] vmovdqa xmm13, [rsp + _xmm_save + 16*7] mov rsp, [rsp + _rsp_save] %endif .wrong_param: ret %ifdef LINUX section .note.GNU-stack noalloc noexec nowrite progbits %endif
; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 10 ; Bound: 267 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %9 %119 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 320 OpName %4 "main" OpName %9 "_GLF_color" OpName %14 "buf1" OpMemberName %14 0 "_GLF_uniform_int_values" OpName %16 "" OpName %35 "m24" OpName %38 "buf0" OpMemberName %38 0 "_GLF_uniform_float_values" OpName %40 "" OpName %50 "a" OpName %53 "i" OpName %67 "j" OpName %77 "k" OpName %88 "l" OpName %119 "gl_FragCoord" OpName %144 "arr" OpName %167 "b" OpName %170 "i" OpName %178 "j" OpName %196 "idx" OpName %205 "k" OpName %214 "l" OpDecorate %9 Location 0 OpDecorate %13 ArrayStride 16 OpMemberDecorate %14 0 Offset 0 OpDecorate %14 Block OpDecorate %16 DescriptorSet 0 OpDecorate %16 Binding 1 OpDecorate %37 ArrayStride 16 OpMemberDecorate %38 0 Offset 0 OpDecorate %38 Block OpDecorate %40 DescriptorSet 0 OpDecorate %40 Binding 0 OpDecorate %119 BuiltIn FragCoord %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 %7 = OpTypeVector %6 4 %8 = OpTypePointer Output %7 %9 = OpVariable %8 Output %10 = OpTypeInt 32 1 %11 = OpTypeInt 32 0 %12 = OpConstant %11 5 %13 = OpTypeArray %10 %12 %14 = OpTypeStruct %13 %15 = OpTypePointer Uniform %14 %16 = OpVariable %15 Uniform %17 = OpConstant %10 0 %18 = OpTypePointer Uniform %10 %22 = OpConstant %10 1 %33 = OpTypeMatrix %7 2 %34 = OpTypePointer Function %33 %36 = OpConstant %11 11 %37 = OpTypeArray %6 %36 %38 = OpTypeStruct %37 %39 = OpTypePointer Uniform %38 %40 = OpVariable %39 Uniform %41 = OpTypePointer Uniform %6 %44 = OpConstant %6 1 %45 = OpConstant %6 0 %49 = OpTypePointer Function %10 %62 = OpConstant %10 4 %65 = OpTypeBool %68 = OpConstant %10 2 %75 = OpConstant %10 5 %107 = OpConstant %10 3 %109 = OpConstant %10 6 %112 = OpTypePointer Function %6 %118 = OpTypePointer Input %7 %119 = OpVariable %118 Input %120 = OpConstant %11 1 %121 = OpTypePointer Input %6 %141 = OpConstant %11 9 %142 = OpTypeArray %6 %141 %143 = OpTypePointer Function %142 %147 = OpConstant %10 7 %150 = OpConstant %10 8 %153 = OpConstant %10 9 %186 = OpConstant %11 0 %189 = OpConstant %10 10 %265 = OpTypePointer Output %6 %4 = OpFunction %2 None %3 %5 = OpLabel %35 = OpVariable %34 Function %50 = OpVariable %49 Function %53 = OpVariable %49 Function %67 = OpVariable %49 Function %77 = OpVariable %49 Function %88 = OpVariable %49 Function %144 = OpVariable %143 Function %167 = OpVariable %49 Function %170 = OpVariable %49 Function %178 = OpVariable %49 Function %196 = OpVariable %49 Function %205 = OpVariable %49 Function %214 = OpVariable %49 Function %19 = OpAccessChain %18 %16 %17 %17 %20 = OpLoad %10 %19 %21 = OpConvertSToF %6 %20 %23 = OpAccessChain %18 %16 %17 %22 %24 = OpLoad %10 %23 %25 = OpConvertSToF %6 %24 %26 = OpAccessChain %18 %16 %17 %22 %27 = OpLoad %10 %26 %28 = OpConvertSToF %6 %27 %29 = OpAccessChain %18 %16 %17 %17 %30 = OpLoad %10 %29 %31 = OpConvertSToF %6 %30 %32 = OpCompositeConstruct %7 %21 %25 %28 %31 OpStore %9 %32 %42 = OpAccessChain %41 %40 %17 %17 %43 = OpLoad %6 %42 %46 = OpCompositeConstruct %7 %43 %45 %45 %45 %47 = OpCompositeConstruct %7 %45 %43 %45 %45 %48 = OpCompositeConstruct %33 %46 %47 OpStore %35 %48 %51 = OpAccessChain %18 %16 %17 %22 %52 = OpLoad %10 %51 OpStore %50 %52 %54 = OpAccessChain %18 %16 %17 %17 %55 = OpLoad %10 %54 OpStore %53 %55 OpBranch %56 %56 = OpLabel OpLoopMerge %58 %59 None OpBranch %60 %60 = OpLabel %61 = OpLoad %10 %53 %63 = OpAccessChain %18 %16 %17 %62 %64 = OpLoad %10 %63 %66 = OpSLessThan %65 %61 %64 OpBranchConditional %66 %57 %58 %57 = OpLabel OpStore %67 %68 OpBranch %69 %69 = OpLabel OpLoopMerge %71 %72 None OpBranch %73 %73 = OpLabel %74 = OpLoad %10 %67 %76 = OpSLessThan %65 %74 %75 OpBranchConditional %76 %70 %71 %70 = OpLabel %78 = OpAccessChain %18 %16 %17 %22 %79 = OpLoad %10 %78 OpStore %77 %79 OpBranch %80 %80 = OpLabel OpLoopMerge %82 %83 None OpBranch %84 %84 = OpLabel %85 = OpLoad %10 %77 %86 = OpLoad %10 %53 %87 = OpSLessThan %65 %85 %86 OpBranchConditional %87 %81 %82 %81 = OpLabel OpStore %88 %17 OpBranch %89 %89 = OpLabel OpLoopMerge %91 %92 None OpBranch %93 %93 = OpLabel %94 = OpLoad %10 %88 %95 = OpLoad %10 %67 %96 = OpSLessThan %65 %94 %95 OpBranchConditional %96 %90 %91 %90 = OpLabel %97 = OpLoad %10 %50 OpSelectionMerge %103 None OpSwitch %97 %103 2 %98 553 %99 554 %100 556 %101 558 %102 %98 = OpLabel %104 = OpLoad %10 %77 %105 = OpExtInst %10 %1 SClamp %104 %17 %22 %106 = OpLoad %10 %88 %108 = OpExtInst %10 %1 SClamp %106 %17 %107 %110 = OpAccessChain %41 %40 %17 %109 %111 = OpLoad %6 %110 %113 = OpAccessChain %112 %35 %105 %108 OpStore %113 %111 OpBranch %103 %99 = OpLabel OpKill %100 = OpLabel OpKill %101 = OpLabel OpKill %102 = OpLabel %122 = OpAccessChain %121 %119 %120 %123 = OpLoad %6 %122 %124 = OpAccessChain %41 %40 %17 %109 %125 = OpLoad %6 %124 %126 = OpFOrdLessThan %65 %123 %125 OpSelectionMerge %128 None OpBranchConditional %126 %127 %128 %127 = OpLabel OpKill %128 = OpLabel OpBranch %103 %103 = OpLabel OpBranch %92 %92 = OpLabel %131 = OpLoad %10 %88 %132 = OpIAdd %10 %131 %22 OpStore %88 %132 OpBranch %89 %91 = OpLabel OpBranch %83 %83 = OpLabel %133 = OpLoad %10 %77 %134 = OpIAdd %10 %133 %22 OpStore %77 %134 OpBranch %80 %82 = OpLabel %135 = OpLoad %10 %50 %136 = OpIAdd %10 %135 %22 OpStore %50 %136 OpBranch %72 %72 = OpLabel %137 = OpLoad %10 %67 %138 = OpIAdd %10 %137 %22 OpStore %67 %138 OpBranch %69 %71 = OpLabel OpBranch %59 %59 = OpLabel %139 = OpLoad %10 %53 %140 = OpIAdd %10 %139 %22 OpStore %53 %140 OpBranch %56 %58 = OpLabel %145 = OpAccessChain %41 %40 %17 %109 %146 = OpLoad %6 %145 %148 = OpAccessChain %41 %40 %17 %147 %149 = OpLoad %6 %148 %151 = OpAccessChain %41 %40 %17 %150 %152 = OpLoad %6 %151 %154 = OpAccessChain %41 %40 %17 %153 %155 = OpLoad %6 %154 %156 = OpAccessChain %41 %40 %17 %22 %157 = OpLoad %6 %156 %158 = OpAccessChain %41 %40 %17 %68 %159 = OpLoad %6 %158 %160 = OpAccessChain %41 %40 %17 %107 %161 = OpLoad %6 %160 %162 = OpAccessChain %41 %40 %17 %62 %163 = OpLoad %6 %162 %164 = OpAccessChain %41 %40 %17 %75 %165 = OpLoad %6 %164 %166 = OpCompositeConstruct %142 %146 %149 %152 %155 %157 %159 %161 %163 %165 OpStore %144 %166 %168 = OpAccessChain %18 %16 %17 %17 %169 = OpLoad %10 %168 OpStore %167 %169 OpStore %170 %17 OpBranch %171 %171 = OpLabel OpLoopMerge %173 %174 None OpBranch %175 %175 = OpLabel %176 = OpLoad %10 %170 %177 = OpSLessThan %65 %176 %75 OpBranchConditional %177 %172 %173 %172 = OpLabel OpStore %178 %22 OpBranch %179 %179 = OpLabel OpLoopMerge %181 %182 None OpBranch %183 %183 = OpLabel %184 = OpLoad %10 %178 %185 = OpSLessThan %65 %184 %75 OpBranchConditional %185 %180 %181 %180 = OpLabel %187 = OpAccessChain %121 %119 %186 %188 = OpLoad %6 %187 %190 = OpAccessChain %41 %40 %17 %189 %191 = OpLoad %6 %190 %192 = OpFOrdLessThan %65 %188 %191 OpSelectionMerge %194 None OpBranchConditional %192 %193 %194 %193 = OpLabel OpBranch %182 %194 = OpLabel %197 = OpLoad %10 %167 %198 = OpAccessChain %18 %16 %17 %107 %199 = OpLoad %10 %198 %200 = OpExtInst %10 %1 SMin %197 %199 OpStore %196 %200 %201 = OpLoad %10 %196 %202 = OpAccessChain %41 %40 %17 %17 %203 = OpLoad %6 %202 %204 = OpAccessChain %112 %144 %201 OpStore %204 %203 OpStore %205 %17 OpBranch %206 %206 = OpLabel OpLoopMerge %208 %209 None OpBranch %210 %210 = OpLabel %211 = OpLoad %10 %205 %212 = OpLoad %10 %170 %213 = OpSLessThan %65 %211 %212 OpBranchConditional %213 %207 %208 %207 = OpLabel %215 = OpAccessChain %18 %16 %17 %22 %216 = OpLoad %10 %215 OpStore %214 %216 OpBranch %217 %217 = OpLabel OpLoopMerge %219 %220 None OpBranch %221 %221 = OpLabel %222 = OpLoad %10 %214 %223 = OpLoad %10 %178 %224 = OpSLessThan %65 %222 %223 OpBranchConditional %224 %218 %219 %218 = OpLabel %225 = OpLoad %10 %196 %226 = OpAccessChain %18 %16 %17 %62 %227 = OpLoad %10 %226 %228 = OpISub %10 %225 %227 OpSelectionMerge %231 None OpSwitch %228 %231 0 %229 2 %230 %229 = OpLabel %232 = OpLoad %10 %196 %233 = OpAccessChain %41 %40 %17 %109 %234 = OpLoad %6 %233 %235 = OpAccessChain %112 %144 %232 %236 = OpLoad %6 %235 %237 = OpFAdd %6 %236 %234 %238 = OpAccessChain %112 %144 %232 OpStore %238 %237 OpBranch %231 %230 = OpLabel %240 = OpLoad %10 %196 %241 = OpAccessChain %18 %16 %17 %17 %242 = OpLoad %10 %241 %243 = OpAccessChain %18 %16 %17 %17 %244 = OpLoad %10 %243 %245 = OpAccessChain %112 %35 %242 %244 %246 = OpLoad %6 %245 %247 = OpAccessChain %112 %144 %240 %248 = OpLoad %6 %247 %249 = OpFAdd %6 %248 %246 %250 = OpAccessChain %112 %144 %240 OpStore %250 %249 OpBranch %231 %231 = OpLabel OpBranch %220 %220 = OpLabel %253 = OpLoad %10 %214 %254 = OpIAdd %10 %253 %22 OpStore %214 %254 OpBranch %217 %219 = OpLabel OpBranch %209 %209 = OpLabel %255 = OpLoad %10 %205 %256 = OpIAdd %10 %255 %22 OpStore %205 %256 OpBranch %206 %208 = OpLabel %257 = OpLoad %10 %167 %258 = OpIAdd %10 %257 %22 OpStore %167 %258 OpBranch %182 %182 = OpLabel %259 = OpLoad %10 %178 %260 = OpIAdd %10 %259 %22 OpStore %178 %260 OpBranch %179 %181 = OpLabel OpBranch %174 %174 = OpLabel %261 = OpLoad %10 %170 %262 = OpIAdd %10 %261 %22 OpStore %170 %262 OpBranch %171 %173 = OpLabel %263 = OpAccessChain %112 %144 %17 %264 = OpLoad %6 %263 %266 = OpAccessChain %265 %9 %186 OpStore %266 %264 OpReturn OpFunctionEnd
; A193553: Sum of divisors of 4*n. ; 7,15,28,31,42,60,56,63,91,90,84,124,98,120,168,127,126,195,140,186,224,180,168,252,217,210,280,248,210,360,224,255,336,270,336,403,266,300,392,378,294,480,308,372,546,360,336,508,399,465,504,434,378,600,504,504,560,450,420,744,434,480,728,511,588,720,476,558,672,720,504,819,518,570,868,620,672,840,560,762,847,630,588,992,756,660,840,756,630,1170,784,744,896,720,840,1020,686,855,1092,961,714,1080,728,882,1344,810,756,1240,770,1080,1064,1016,798,1200,1008,930,1274,900,1008,1512,931,930,1176,992,1092,1560,896,1023,1232,1260,924,1488,1120,1020,1680,1134,966,1440,980,1488,1344,1080,1176,1651,1260,1110,1596,1178,1050,1860,1064,1260,1638,1440,1344,1736,1106,1200,1512,1530,1344,1815,1148,1302,2016,1260,1176,2016,1281,1620,1820,1364,1218,1800,1736,1524,1680,1350,1260,2418,1274,1680,1736,1512,1596,1920,1512,1488,2240,1800,1344,2044,1358,1470,2352,1767,1386,2340,1400,1953,1904,1530,1680,2232,1764,1560,2184,1778,1680,2880,1484,1674,2016,1620,1848,2520,1792,1650,2072,2232,1764,2280,1568,2040,2821,1710,1596,2480,1610,2160,2688,1890,1638,2730,2016,1860,2240,2160,1680,3048,1694,1995,2548,1922,2394,2520,1960,2016,2352,2340 mul $0,4 add $0,3 cal $0,203 ; a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n). mov $1,$0
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x1580a, %rsi lea addresses_D_ht+0x810a, %rdi nop nop add %rdx, %rdx mov $22, %rcx rep movsq nop nop nop nop add %rbp, %rbp lea addresses_WC_ht+0xe60a, %rdx nop nop nop nop xor $43194, %r12 movb (%rdx), %cl nop nop nop add %rdi, %rdi lea addresses_A_ht+0x12a0a, %rbp nop sub $54709, %rbx movl $0x61626364, (%rbp) nop nop xor %rcx, %rcx lea addresses_WC_ht+0x14a5a, %rbp clflush (%rbp) nop nop nop lfence movb (%rbp), %dl nop nop nop dec %rdx lea addresses_WT_ht+0x1159a, %rdi nop and %rsi, %rsi and $0xffffffffffffffc0, %rdi vmovntdqa (%rdi), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %rdx nop nop nop nop nop add $30080, %rdx lea addresses_WT_ht+0x1da0a, %r12 nop nop dec %rcx mov (%r12), %rbx nop nop nop nop nop sub %rsi, %rsi lea addresses_UC_ht+0x1e252, %rsi nop and %r12, %r12 movw $0x6162, (%rsi) nop nop nop nop add $54318, %rbp lea addresses_WT_ht+0x8282, %rbx nop dec %rdx mov $0x6162636465666768, %rcx movq %rcx, (%rbx) nop nop nop nop cmp $15130, %rsi lea addresses_WC_ht+0x123c0, %rsi add $40423, %r12 movb $0x61, (%rsi) nop nop nop nop sub %rdx, %rdx lea addresses_normal_ht+0x20c2, %rbp nop nop inc %rsi vmovups (%rbp), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $1, %xmm0, %r12 nop nop nop nop cmp $8998, %rdi lea addresses_D_ht+0x5f7a, %rsi lea addresses_WC_ht+0x1ccca, %rdi nop nop nop nop nop dec %r13 mov $76, %rcx rep movsl nop nop xor $14632, %rcx lea addresses_WT_ht+0xb60a, %r13 nop nop nop sub $53023, %rsi mov $0x6162636465666768, %rdi movq %rdi, %xmm5 vmovups %ymm5, (%r13) nop nop nop nop dec %rsi lea addresses_D_ht+0x1920a, %rdi nop nop nop nop nop add %r13, %r13 mov (%rdi), %r12w nop nop nop add $64031, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r14 push %rcx push %rdi push %rdx push %rsi // Store mov $0x47a, %r14 sub %rcx, %rcx mov $0x5152535455565758, %r11 movq %r11, %xmm2 vmovups %ymm2, (%r14) nop nop nop inc %rdi // Store lea addresses_WC+0xc20a, %rcx nop nop nop nop cmp %rsi, %rsi movb $0x51, (%rcx) xor $37537, %rcx // Store lea addresses_WC+0xc20a, %r13 nop dec %rdx mov $0x5152535455565758, %rcx movq %rcx, (%r13) inc %rcx // Faulty Load lea addresses_WC+0xc20a, %r14 nop and %r13, %r13 mov (%r14), %rcx lea oracles, %rsi and $0xff, %rcx shlq $12, %rcx mov (%rsi,%rcx,1), %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %r14 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': True, 'congruent': 3, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 11, 'same': False}} {'58': 118, '51': 19, '00': 2, 'e0': 2} 58 58 51 58 58 58 00 58 58 58 58 58 58 58 58 e0 58 58 58 58 58 58 58 58 58 58 51 58 58 51 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 51 58 58 58 51 58 58 58 58 51 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 51 58 58 58 58 58 58 51 58 58 58 58 58 58 58 58 58 51 58 58 58 58 58 58 58 58 58 58 58 58 51 51 58 58 58 58 58 58 58 58 51 58 58 58 51 51 58 51 58 51 58 51 58 51 58 58 00 51 58 e0 */
;################################################################################ ;# Título: Modulo de inicializacion en 16 bits # ;# # ;# Versión: 1.0 Fecha: 06/09/2015 # ;# Autor: J. Balloffet Tab: 4 # ;# Compilación: Usar Makefile # ;# Uso: - # ;# ------------------------------------------------------------------------# ;# Descripción: Inicializacion de PCI y perifericos basicos para una PC # ;# Reemplaza el BIOS iniciando en 0xFFFFFFF0 # ;# ------------------------------------------------------------------------# ;# Revisiones: # ;# 1.0 | 06/09/2015 | J.BALLOFFET | Inicial # ;# ------------------------------------------------------------------------# ;# TODO: # ;# - # ;################################################################################ USE16 %ifndef ROM_LOCATION ; Macro definida externamente %error "ROM_LOCATION no definido" %endif ;-------------------------------------------------------------------------------- ; Macros ;-------------------------------------------------------------------------------- %define CR0_PE 0x00000001 ; Protection Enable %define CR0_PG 0x80000000 ; Paginacion %macro leer_registro_pci 1 ; 1 parámetro mov eax, %1 or eax, esi mov dx, 0x0CF8 out dx, eax ; Escribir palabra de configuración. mov dx, 0x0CFC in eax, dx ; Verificar si existe el dispositivo. %endmacro ;-------------------------------------------------------------------------------- ; Salto a punto de entrada ;-------------------------------------------------------------------------------- jmp bios_init ; Inicio del codigo de inicializacion ;-------------------------------------------------------------------------------- ; Tablas de datos para inicializacion ;-------------------------------------------------------------------------------- seq_regs_data: db 0x03 ; Reset Register db 0x00 ; Clocking Mode Register db 0x03 ; Map Mask Register db 0x00 ; Character Map Select Register db 0x02 ; Sequencer Memory Mode Register crtc_regs_data: db 0x5F ; Cantidad caracteres menos 5 incluyendo borde. db 0x4F ; Cantidad caracteres visualizados menos 1. db 0x50 ; Carácter en el que comienza el blanqueo. db 0x82 ; Fin de blanqueo horizontal. db 0x55 ; Carácter donde comienza el retrazo horizontal. db 0x81 ; Fin del retrazo horizontal. db 0xBF ; Cantidad de scan lines - 2 (0x1BF = 447). db 0x1F ; Bits 9 y 8 de varios registros. db 0x00 ; Primer scan line a ser visualizado. db 0x4F ; Bits 4-0: máxima línea de scan. db 0x0D ; Scan line donde comienza el cursor. db 0x0E ; Scan line donde termina el cursor. db 0x00 ; Bits 15-8 del inicio del buffer de video. db 0x00 ; Bits 7-0 del inicio del buffer de video. db 0x05 ; Bits 15-8 de la posición del cursor en pantalla. db 0x50 ; Bits 7-0 de la posición del cursor en pantalla. db 0x9C ; Inicio retrazado vertical (0x19C = 412). db 0x8E ; Fin retrazado vertical (bits 3-0) y protección de ; escritura para registros cero a 7 (bit 7). db 0x8F ; Fin de refresco vertical (0x18F = 409) db 0x28 ; Cantidad de bytes por scan line dividido 4. db 0x1F ; Scan line para el subrayado. db 0x96 ; Inicio blanqueo vertical (0x196 = 406) db 0xB9 ; Fin blanqueo vertical (0x1B9 = 441) db 0xA3 ; Registro de control de modo. db 0xFF ; Registro de comparación de líneas. graphics_regs_data: db 0x00 ; Set/Reset Register db 0x00 ; Enable Set/Reset Register db 0x00 ; Color Compare Register db 0x00 ; Data Rotate Register db 0x00 ; Graphics Mode Register db 0x10 ; Miscellaneous Graphics Register db 0x0E ; Color Don't Care Register db 0x00 ; Bit Mask Register db 0xFF attrcon_regs_data: db 0x00 ; Paleta para color 0. db 0x01 ; Paleta para color 1. db 0x02 ; Paleta para color 2. db 0x03 ; Paleta para color 3. db 0x04 ; Paleta para color 4. db 0x05 ; Paleta para color 5. db 0x14 ; Paleta para color 6. db 0x07 ; Paleta para color 7. db 0x38 ; Paleta para color 8. db 0x39 ; Paleta para color 9. db 0x3A ; Paleta para color 10. db 0x3B ; Paleta para color 11. db 0x3C ; Paleta para color 12. db 0x3D ; Paleta para color 13. db 0x3E ; Paleta para color 14. db 0x3F ; Paleta para color 15. db 0x0C ; Registro de control de atributos. ; * Bit 7: Fuente de los bits de video P5 y P4 al DAC de video ; * Bit 6: Habilitación de 256 colores. ; * Bit 5: Modo de desplazamiento de píxeles ; * Bit 4: No usado ; * Bit 3: "1" para habilitar blink, "0" para tener 16 colores de fondo. ; * Bit 2: Replicación de octava a novena columna para caracteres ; 0xC0 - 0xDF (para dibujar bloques en modo texto). ; * Bit 1: Sin uso ; * Bit 0: Habilitación de gráficos. db 0x00 ; Color usado para el borde en algunos modos. db 0x0F ; Habilitación de planos de color. db 0x08 ; Desplazamiento de píxeles de video hacia la izquierda. db 0x00 ; Registro de selección de color. palette_data: db 0x00, 0x00, 0x00 ;RGB of color #0 db 0x00, 0x00, 0x2a db 0x00, 0x2a, 0x00 db 0x00, 0x2a, 0x2a db 0x2a, 0x00, 0x00 ;RGB of color #4 db 0x2a, 0x00, 0x2a db 0x2a, 0x2a, 0x00 db 0x2a, 0x2a, 0x2a db 0x00, 0x00, 0x15 ;RGB of color #8 db 0x00, 0x00, 0x3f db 0x00, 0x2a, 0x15 db 0x00, 0x2a, 0x3f db 0x2a, 0x00, 0x15 ;RGB of color #12 db 0x2a, 0x00, 0x3f db 0x2a, 0x2a, 0x15 db 0x2a, 0x2a, 0x3f db 0x00, 0x15, 0x00 ;RGB of color #16 db 0x00, 0x15, 0x2a db 0x00, 0x3f, 0x00 db 0x00, 0x3f, 0x2a db 0x2a, 0x15, 0x00 ;RGB of color #20 db 0x2a, 0x15, 0x2a db 0x2a, 0x3f, 0x00 db 0x2a, 0x3f, 0x2a db 0x00, 0x15, 0x15 ;RGB of color #24 db 0x00, 0x15, 0x3f db 0x00, 0x3f, 0x15 db 0x00, 0x3f, 0x3f db 0x2a, 0x15, 0x15 ;RGB of color #28 db 0x2a, 0x15, 0x3f db 0x2a, 0x3f, 0x15 db 0x2a, 0x3f, 0x3f db 0x15, 0x00, 0x00 ;RGB of color #32 db 0x15, 0x00, 0x2a db 0x15, 0x2a, 0x00 db 0x15, 0x2a, 0x2a db 0x3f, 0x00, 0x00 ;RGB of color #36 db 0x3f, 0x00, 0x2a db 0x3f, 0x2a, 0x00 db 0x3f, 0x2a, 0x2a db 0x15, 0x00, 0x15 ;RGB of color #40 db 0x15, 0x00, 0x3f db 0x15, 0x2a, 0x15 db 0x15, 0x2a, 0x3f db 0x3f, 0x00, 0x15 ;RGB of color #44 db 0x3f, 0x00, 0x3f db 0x3f, 0x2a, 0x15 db 0x3f, 0x2a, 0x3f db 0x15, 0x15, 0x00 ;RGB of color #48 db 0x15, 0x15, 0x2a db 0x15, 0x3f, 0x00 db 0x15, 0x3f, 0x2a db 0x3f, 0x15, 0x00 ;RGB of color #52 db 0x3f, 0x15, 0x2a db 0x3f, 0x3f, 0x00 db 0x3f, 0x3f, 0x2a db 0x15, 0x15, 0x15 ;RGB of color #56 db 0x15, 0x15, 0x3f db 0x15, 0x3f, 0x15 db 0x15, 0x3f, 0x3f db 0x3f, 0x15, 0x15 ;RGB of color #60 db 0x3f, 0x15, 0x3f db 0x3f, 0x3f, 0x15 db 0x3f, 0x3f, 0x3f ;-------------------------------------------------------------------------------- ; Fonts de dominio público de Joseph Gil ;-------------------------------------------------------------------------------- font16x8: db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff db 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00 db 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff db 0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00 db 0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x06, 0x86, 0xc6, 0x7c, 0x18, 0x18, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x3c, 0x66, 0xc3, 0xc3, 0xdb, 0xdb, 0xc3, 0xc3, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00 db 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xff, 0xdb, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x3c, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xff, 0xc3, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc1, 0xc3, 0xff, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00 db 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00 db 0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00 db 0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xff, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00 db 0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xcc, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 0x3c, 0x00, 0x00, 0x00 db 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0xc6, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00 db 0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00 db 0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x3b, 0x1b, 0x7e, 0xd8, 0xdc, 0x77, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x3e, 0x6c, 0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc6, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00 db 0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x18, 0x18, 0x7e, 0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0xfc, 0x66, 0x66, 0x7c, 0x62, 0x66, 0x6f, 0x66, 0x66, 0x66, 0xf3, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, 0x00, 0x00 db 0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00 db 0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xce, 0x9b, 0x06, 0x0c, 0x1f, 0x00, 0x00 db 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xce, 0x96, 0x3e, 0x06, 0x06, 0x00, 0x00 db 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44 db 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa db 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77 db 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 db 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff db 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 db 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f db 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xdb, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 db 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00 db 0x00, 0xd8, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x70, 0xd8, 0x30, 0x60, 0xc8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;-------------------------------------------------------------------------------- ; Punto de entrada ;-------------------------------------------------------------------------------- bios_init: ;xchg bx, bx ; Magic breakpoint ; Recorrer bus PCI. Bochs solo soporta bus cero ya que no tiene "PCI to PCI bridge". ; Cada bus tiene hasta 32 dispositivos. ; Si el dispositivo es compuesto puede tener hasta 8 funciones. ; Formato puerto 0x0CF8: ; Bit 31 = Siempre a "1" ; Bits 30-24 = Reservado (siempre a "0") ; Bits 23-16 = Número de bus (0 en nuestra aplicación) ; Bits 15-11 = Número de dispositivo (0-31) ; Bits 10-8 = Número de función (0-7) ; Bits 7-2 = Número de registro ; Bits 1-0: Siempre cero. recorrer_bus_pci: mov ebp, 0x4000 ; Primera dirección de entrada/salida para PCI. mov edi, 0xC0000000 ; Primera dirección a asignar a dispositivos PCI. mov esi, 0x80000000 ; Bus 0, dispositivo 0, función 0. ciclo_recorrer_bus_pci: cmp esi, 0x80010000 ; Verificar si se recorrió todo el bus 0. jz fin_recorrido_pci ; Leer registro 0: Bits 31-16: device ID, leer_registro_pci 0 ; Bits 15-0: vendor ID. cmp ax, 0xFFFF ; Vendor ID 0xFFFF no existe. jnz dispositivo_hallado add esi,0x0800 ; Ir al siguiente dispositivo jmp ciclo_recorrer_bus_pci dispositivo_hallado: ; Leer registro 0x0C: Bit 23: multiple function bit leer_registro_pci 0x0C mov ch, 8 ; Cantidad de funciones a procesar. bt eax, 23 jc procesar_funcion mov ch, 1 procesar_funcion: ; Leer registro 0: Bits 31-16: device ID, leer_registro_pci 0 ; Bits 15-0: vendor ID. cmp ax, 0xFFFF ; Vendor ID 0xFFFF no existe. jnz funcion_hallada ir_a_siguiente_funcion: add esi, 0x0100 ; Ir a la siguiente función dec ch jnz procesar_funcion sub esi, 0x0100 ; Ir al siguiente dispositivo or esi, 0x0700 add esi, 0x0100 jmp ciclo_recorrer_bus_pci funcion_hallada: ; Leer registro 0x0C: Bits 22-16: header type leer_registro_pci 0x0C test eax,0x007F0000 ; Solo soportamos header type cero. jnz ir_a_siguiente_funcion leer_registro_pci 0x08 ; Leer clase y subclase. mov cl, 0x10 ; Apuntar al primer Base Address Register (BAR) ciclo_llenar_BAR: movzx eax, cl or eax, esi mov dx, 0x0CF8 out dx, eax mov eax, 0xFFFFFFFF ; Escribir 0xFFFFFFFF en el BAR mov dx, 0x0CFC out dx, eax movzx eax, cl leer_registro_pci eax ; Leerlo. test al, 1 ; Ver si el dispositivo está mapeado en memoria. jz mapeado_en_memoria and ax, 0xFFFC ; Eliminar los dos bits que no se usan para ports. jz ajustar_siguiente_BAR ; El dispositivo no usa este BAR. not eax ; Convertir en cantidad de bytes que se usa - 1. mov ebx, eax dec bp ; Poner BP en dirección múltiplo de la cantidad or bp, ax ; de bytes que usa esta función. inc bp movzx eax, cl or eax, esi mov dx, 0x0CF8 mov eax, ebp jmp ajustar_BAR mapeado_en_memoria: and eax, 0xFFFFFFF0 ; Eliminar los 4 bits que no se usan para puntero. jz ajustar_siguiente_BAR ; El dispositivo no usa este BAR. not eax ; Convertir en cantidad de bytes que se usa - 1. mov ebx, eax dec edi ; Poner EDI en dirección múltiplo de la cantidad or edi, eax ; de bytes que usa esta función. inc edi movzx eax, cl or eax, esi mov dx, 0x0CF8 out dx, eax mov eax, edi ajustar_BAR: mov dx, 0x0CFC out dx, eax add ebp, ebx ; Apuntar a puerto después de esta función. inc ebp ajustar_siguiente_BAR: add cl, 4 ; Apuntar al siguiente BAR. cmp cl, 0x28 ; Todos los BAR listos? jnz ciclo_llenar_BAR jmp ir_a_siguiente_funcion fin_recorrido_pci: ;-------------------------------------------------------------------------------- ; Inicializar pantalla con texto ;-------------------------------------------------------------------------------- habilitar_modo_texto: ; Set MISC regs mov dx, 0x3C2 ; VGA_MISC_ADDR mov al, 0x67 out dx, al mov dx, 0x3DA ; VGA_STATUS_ADDR mov al, 0 out dx, al ; Send SEQ regs cld mov cl, 0 mov si, seq_regs_data seq_regs_loop: mov dx, 0x3C4 ; Puerto del secuenciador VGA (índice) mov al, cl out dx, al inc dx ; Puerto del secuenciador VGA (datos) cs lodsb ; Leer dato a escribit en puerto. out dx, al ; Escribir en controlador VGA. ; continue loop inc cl ; Siguiente índice. cmp cl, 5 jne seq_regs_loop ; Eliminar protección de los registros 0 a 7 del controlador VGA. mov ax, 0x2C11 mov dx, 0x3D4 ; VGA_CRTC_ADDR out dx, ax ; send CRTC regs mov cl, 0 mov si, crtc_regs_data crtc_regs_loop: mov dx, 0x3D4 ; Puerto de índice del controlador VGA mov al, cl out dx, al cs lodsb inc dx ; Puerto de datos del controlador VGA. out dx, al inc cl cmp cl, 25 jb crtc_regs_loop inicializar_paleta: mov cl, 0 mov si, palette_data inicializar_paleta_loop: mov dx, 0x3C8 ; Puerto de índice paleta mov al, cl ; Escribir número de registro out dx, al inc dx ; Apuntar al puerto de datos. cs lodsb ; Leer dato a cargar en el registro. out dx, al ; Cargar dato en el registro. cs lodsb ; Leer dato a cargar en el registro. out dx, al ; Cargar dato en el registro. cs lodsb ; Leer dato a cargar en el registro. out dx, al ; Cargar dato en el registro. inc cl cmp cl,64 jb inicializar_paleta_loop ;Inicializar registros del controlador gráfico de VGA. mov cl, 0 mov si, graphics_regs_data graphics_regs_loop: ; send register number to 3CE mov dx, 0x3CE ; VGA_GRAPHICS_CONTROLLER_ADDR mov al, cl out dx, al ; send register value to 3CF cs lodsb inc dx out dx, al ; continue GRAPHICS loop inc cl cmp cl, 9 jb graphics_regs_loop ; Habilitar escritura al puerto del controlador de atributos mov dx, 0x3DA ; VGA STATUS ADDR in al, dx ; Inicializar registros del controlador de atributos. mov cl, 0 mov si, attrcon_regs_data attrcon_regs_loop: ; Apuntar al controlador de atributos. mov dx, 0x3C0 ; VGA_ATTRCON_ADDR mov al, cl ; Escribir número de registro out dx, al cs lodsb ; Leer dato a cargar en el registro. out dx, al ; Cargar dato en el registro. inc cl ; Apuntar al siguiente registro. cmp cl, 21 ; Ver si se escribieron todos los registros del ATTRCON. jb attrcon_regs_loop ; Saltar si no es así. mov al, 0x20 ; Reactivar el refresco de pantalla porque la out dx, al ; escritura a registros de ATTRCON lo desactiva. mov dx, 0x03ce ; borrar modo par/impar mov ax, 5 out dx, ax mov ax, 0x0406 ; Mapear memoria VGA a 0xA0000. out dx, ax mov dx, 0x03c4 ; Poner el plano de bits número 2 mov ax, 0x0402 out dx, ax mov ax, 0x0604 ; Borrar modo par/impar. out dx, ax mov ax, 0xA000 ; Copiar mapa de caracteres. mov es, ax mov di, 0x0000 mov si, font16x8 mov cx, 256 ciclo_copia_fonts: cs movsd ; Copiar 16 bytes al bitmap. cs movsd cs movsd cs movsd add di, 16 ; Saltear 16 bytes (VGA requiere 32 bytes/carácter) loop ciclo_copia_fonts mov ax, 0x0302 ; Volver a la operación normal. out dx, ax mov ax, 0x0204 out dx, ax mov dx, 0x03ce mov ax, 0x1005 out dx, ax mov ax, 0x0E06 out dx, ax ;xchg bx, bx cli mov ax, ROM_LOCATION >> 4 ; Segmento ubicado al comienzo del bloque mov ds, ax mov es, ax call HabilitarA20 lgdt [gdtr_img] ; GDTR provisoria para 16 bits smsw eax or eax, CR0_PE ; Establecer el uP en MP lmsw ax ; o32 jmp dowrd CS_SEL_32:flush_prefetch_queue db 066h ; Prefijo db 0EAh ; jmp dw flush_prefetch_queue ; offset parte baja dw ROM_LOCATION >> 16 ; offset parte alta dw CS_SEL ; selector fault_end: hlt jmp fault_end ;-------------------------------------------------------------------------------------------------------- ; Habilito puerta A20 ;-------------------------------------------------------------------------------------------------------- HabilitarA20: mov ax, 0xFFFF ; AX=0xFFFF mov es, ax cmp word [es:0x7E0E], 0xAA55 ; vemos si 0x107E0E coincide con 0x7E0E je GateA20_disabled ; Coincide => A20 deshabilitada rol word [0x7DFE], 1 ; Modifico 0x7E0E cmp word [es:0x7E0E], 0x55AA ; Cambió 0x107E0E? jne GateA20_enabled ; Si no cambió entonces A20 está enabled GateA20_disabled: mov al, 0xDF ; Comando de habilitación de A20 call Gate_A20 ; habilitar Gate A20 cmp al, 0 ; OK? je GateA20_enabled ; OK => seguimos... Fail: hlt ; colgamos el micro sin pasar por MP jmp Fail GateA20_enabled: mov word [0x7DFE], 0xAA55 ; restituimos la firma del bootloader ret ;-------------------------------------------------------------------------------------------------------- ; GATE_A20: ; Controla la señal que maneja la compuerta del bit de direcciones A20. La señal de compuerta del bit A20 ; toma una salida del procesador de teclado 8042. ; Se debe utilizar cuando se planea acceder en Modo Protegido a direcciones de memoria mas allá del ; 1er. Mbyte. ; El port 60h como entrada lee el scan code de la última tecla presionada, o liberada por el operador de ; la PC. Como salida tiene funciones muy específicas bit a bit: En particular el Bit 1 se utiliza para ; activar el Gate de A20 si se pone en 1 y desactivarlo si está en 0. ; Por otra parte el port 64h es el registro de comandos/estados según se escriba o lea respectivamente ; Llamar con : AH = 0DDh, si se desea apagar esta se#al. (A20 siempre cero). ; AL = 0DFh, si se desea disparar esta se#al. (x86 controla A20) ; Devuelve : AL = 00, si hubo exito. El 8042 acepto el comando. ; AL = 02, si fallo. El 8042 no acepto el comando. ; En BIOS nuevos aparece la INT 15h con ax 2400 disable, o 2401 enable ;-------------------------------------------------------------------------------------------------------- %define port_a 060h ; Direccion de E/S del Port A del 8042 %define ctrl_port 064h ; port de Estados del 8042 Gate_A20: cli ; Mientras usa el 8042, no INTR call _8042_empty? ; Ve si buffer del 8042 está vacío. jnz gate_a20_exit ; No lo está =>retorna con AL=2. mov al, 0xD1 ; Comando Write port del 8042.. out ctrl_port,al ; ...se env¡a al port 64h. call _8042_empty? ; Espera se acepte el comando. jnz gate_a20_exit ; Si no se acepta, Ret con AL=2 mov al,ah ; Pone en AL el dato a escribir. out port_a, al ; Lo env¡a al 8042. call _8042_empty? ; Espera se acepte el comando. gate_a20_exit: ret ;-------------------------------------------------------------------------------------------------------- ;8042_empty?: ;Espera que se vac¡e el buffer del 8042. ;Llamar con : Nada. ;Devuelve : AL = 00, el buffer del 8042 est  vac¡o.(ZF = 1) ; AL = 02, time out. El buffer del 8042 sigue lleno. (ZF = 0) ;-------------------------------------------------------------------------------------------------------- _8042_empty?: push cx ; salva CX. sub cx, cx ; CX = 0 : valor de time out. empty_8042_01: in al, ctrl_port ; Lee port de estado del 8042. and al, 00000010b ; si el bit 1 est  seteado o... loopnz empty_8042_01 ; no alcanzó time out, espera. pop cx ; recupera cx ret ; retorna con AL=0, si se limpió bit 1, o AL=2 si no. ;-------------------------------------------------------------------------------- ; GDT provisoria para inicio en 16 bits. Queda dentro del binario init16.bin ;-------------------------------------------------------------------------------- ALIGN 4 GDT16: NULL_SEL equ $-GDT16 dq 0x0 CS_SEL equ $-GDT16 dw 0xFFFF dw 0x0000 db 0x00 db 0x9A db 0xCF db 0 DS_SEL equ $-GDT16 dw 0xFFFF dw 0x0000 db 0x00 db 0x92 db 0xCF db 0 GDT_LENGTH equ $-GDT16 gdtr_img: dw GDT_LENGTH-1 dd GDT16 + ROM_LOCATION ;******************************************************************************** ; Modo protegido ;******************************************************************************** USE32 flush_prefetch_queue: mov ax, DS_SEL mov ds, ax mov es, ax ; Continua ejecutando en init32.asm ;******************************************************************************** ; - -- --- Fin de archivo --- -- - ; J. Balloffet c2015 ;********************************************************************************
; A192970: Coefficient of x in the reduction by x^2 -> x+1 of the polynomial p(n,x) defined at Comments. ; 0,1,3,9,21,44,85,156,276,476,806,1347,2230,3667,6001,9787,15923,25862,41955,68006,110170,178406,288828,467509,756636,1224469,1981455,3206301,5188161,8394896,13583521,21978912,35562960,57542432,93105986,150649047,243755698,394405447,638161885,1032568111,1670730815,2703299786,4374031503,7077332234,11451364726,18528697994,29980063800,48508762921,78488827896,126997592041,205486421211,332484014577,537970437165,870454453172,1408424891821,2278879346532,3687304239948,5966183588132,9653487829790,15619671419691,25273159251310,40892830672891,66165989926153,107058820601059,173224810529291,280283631132494,453508441663995,733792072798766,1187300514465106,1921092587266286,3108393101733876,5029485689002717,8137878790739220 mov $2,$0 add $2,1 mov $4,$0 lpb $2,1 mov $0,$4 sub $2,1 sub $0,$2 add $3,1 mov $5,$0 lpb $3,1 mov $0,$5 sub $0,1 sub $3,1 cal $0,192969 ; Constant term of the reduction by x^2 -> x+1 of the polynomial p(n,x) defined at Comments. lpe add $1,$0 lpe sub $1,1
.data msg1: .asciiz "o arithmos vrethike!" msg2: .asciiz "dwse to plhthos ton arithmwn ston pinaka: " msg3: .asciiz "dwse arithmo: " msg4: .asciiz "dn vrethike" .align 2 pinakas: .space 24 .text main: addi $v0,$0,4 la $a0, msg2 syscall add $t1,$0,$0 addi $t3,$0,0 addi $v0,$0,5 #diavazei to plhthos twn stoixeiwn toy pinaka syscall add $t0,$v0,$0 add $t1,$0,$0 for: beq $t0,$t1,endfor addi $v0,$0,4 la $a0, msg3 syscall addi $t1,$t1,1 addi $v0,$0,5 syscall add $t2,$0,$v0 sw $t2,pinakas($t3) #apothikeuontai oi times ston pinaka addi $t3,$t3,4 j for endfor: add $t7,$0,$0 add $t8,$0,$0 addi $v0,$0,5 syscall add $t4,$0,$v0 #diavazei thn timh pou psaxnoume ston pinaka loop: lw $t6,pinakas($t7) beq $t6,$t4,vrethike addi $t7,$t7,4 addi $t8,$t8,1 beq $t8,$t0,dnvrethike j loop vrethike: addi $v0,$0,4 la $a0, msg1 syscall #fdgffdgd j end dnvrethike: addi $v0,$0,4 la $a0, msg4 syscall end: add $t0,$v0,$0 li $v0,10 syscall
ldi $s0, 100 ldi $s1, 512 or $s0, $s1 wp $rr, 3 ldi $s0, 100 ldi $s1, 1024 or $s0, $s1 wp $rr, 3 ldi $s0, 2 ldi $s1, 1536 or $s0, $s1 wp $rr, 3 ldi $s0, 200 ldi $s1, 2560 or $s0, $s1 wp $rr, 3 ldi $s0, 200 ldi $s1, 2560 or $s0, $s1 wp $rr, 3 ldi $s0, 200 ldi $s1, 3072 or $s0, $s1 wp $rr, 3 ldi $s1, 4096 wp $s1, 3 infinite: j infinite
//#include "mediadatabase.h" //#include <QtSql/qsqlquery.h> //#include <QVariant> //#include <QSqlError> //// 连接music数据库 //void mediaDataBase::connectSongInfo() //{ // QSqlDatabase datebase; // if(QSqlDatabase::contains("qt_sql_default_connection")) // datebase = QSqlDatabase::database("qt_sql_default_connection"); // else // datebase = QSqlDatabase::addDatabase("QSQLITE"); // datebase.setDatabaseName("SongDateBase.db"); // datebase.open(); // datebase.exec(QString("create table if not exists songinfo(id INT ,songname TEXT,songurl TEXT,duration TEXT)")); //} //void mediaDataBase::addSong(const QString& songname,const QString& url,const QString& duration) //{ // connectSongInfo(); // QSqlQuery query; // query.prepare(QString("select * from songinfo where id = (select max(id) from songinfo)")); // query.exec(); // int index=0; // while(query.next()) // 取最大值 // { // index= query.value("id").toInt(); // index++; // } // query.prepare(QString("INSERT INTO songinfo(id,songname,songurl,duration)" // "VALUES (:id,:songname,:songurl,:duration)")); // query.bindValue(":id", index); // query.bindValue(":songname", songname); // query.bindValue(":songurl", url); // query.bindValue(":duration", duration); // query.exec(); //} //QVector<QStringList> mediaDataBase::getSongInfo() //{ // connectSongInfo(); // QStringList list1; // QStringList list2; // QStringList list3; // QSqlQuery sql_query; // sql_query.prepare(QString("select * from songinfo order by id")); // if(!sql_query.exec()) // { //// qDebug()<<sql_query.lastError(); // } // else // { // while(sql_query.next()) // { // QString songname = sql_query.value("songname").toString(); // QString songurl = sql_query.value("songurl").toString(); // QString songdur=sql_query.value("duration").toString(); // list1<<songname; // list2<<songurl; // list3<<songdur; // } // } // QVector<QStringList> vec; // vec<<list1<<list2<<list3; // return vec; //}
; A100147: Structured icosidodecahedral numbers. ; 1,30,135,364,765,1386,2275,3480,5049,7030,9471,12420,15925,20034,24795,30256,36465,43470,51319,60060,69741,80410,92115,104904,118825,133926,150255,167860,186789,207090,228811,252000,276705,302974,330855,360396,391645,424650,459459,496120,534681,575190,617695,662244,708885,757666,808635,861840,917329,975150,1035351,1097980,1163085,1230714,1300915,1373736,1449225,1527430,1608399,1692180,1778821,1868370,1960875,2056384,2154945,2256606,2361415,2469420,2580669,2695210,2813091,2934360,3059065,3187254 mov $2,$0 add $0,1 add $2,$0 mul $2,2 bin $2,2 mul $0,$2
############################################################################### # 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 y8_cpAddMulDgt_BNU .type y8_cpAddMulDgt_BNU, @function y8_cpAddMulDgt_BNU: push %rbx push %r12 mov %edx, %edx movq (%rsi), %rax cmp $(1), %rdx jnz .Lgeneral_casegas_1 mul %rcx addq %rax, (%rdi) adc $(0), %rdx mov %rdx, %rax pop %r12 pop %rbx ret .Lgeneral_casegas_1: lea (-40)(%rsi,%rdx,8), %rsi lea (-40)(%rdi,%rdx,8), %rdi mov $(5), %rbx sub %rdx, %rbx mul %rcx mov %rax, %r8 movq (8)(%rsi,%rbx,8), %rax mov %rdx, %r9 cmp $(0), %rbx jge .Lskip_muladd_loop4gas_1 .p2align 4, 0x90 .Lmuladd_loop4gas_1: mul %rcx xor %r10, %r10 addq %r8, (%rdi,%rbx,8) adc %rax, %r9 movq (16)(%rsi,%rbx,8), %rax adc %rdx, %r10 mul %rcx xor %r11, %r11 addq %r9, (8)(%rdi,%rbx,8) adc %rax, %r10 movq (24)(%rsi,%rbx,8), %rax adc %rdx, %r11 mul %rcx xor %r8, %r8 addq %r10, (16)(%rdi,%rbx,8) adc %rax, %r11 movq (32)(%rsi,%rbx,8), %rax adc %rdx, %r8 mul %rcx xor %r9, %r9 addq %r11, (24)(%rdi,%rbx,8) adc %rax, %r8 movq (40)(%rsi,%rbx,8), %rax adc %rdx, %r9 add $(4), %rbx jnc .Lmuladd_loop4gas_1 .Lskip_muladd_loop4gas_1: mul %rcx xor %r10, %r10 addq %r8, (%rdi,%rbx,8) adc %rax, %r9 adc %rdx, %r10 cmp $(2), %rbx ja .Lfin_mul1x4n_2gas_1 jz .Lfin_mul1x4n_3gas_1 jp .Lfin_mul1x4n_4gas_1 .Lfin_mul1x4n_1gas_1: movq (16)(%rsi,%rbx,8), %rax mul %rcx xor %r11, %r11 addq %r9, (8)(%rdi,%rbx,8) adc %rax, %r10 movq (24)(%rsi,%rbx,8), %rax adc %rdx, %r11 mul %rcx xor %r8, %r8 addq %r10, (16)(%rdi,%rbx,8) adc %rax, %r11 movq (32)(%rsi,%rbx,8), %rax adc %rdx, %r8 mul %rcx xor %r9, %r9 addq %r11, (24)(%rdi,%rbx,8) adc %rax, %r8 adc $(0), %rdx addq %r8, (32)(%rdi,%rbx,8) adc $(0), %rdx mov %rdx, %rax jmp .Lexitgas_1 .Lfin_mul1x4n_4gas_1: movq (16)(%rsi,%rbx,8), %rax mul %rcx xor %r11, %r11 addq %r9, (8)(%rdi,%rbx,8) adc %rax, %r10 movq (24)(%rsi,%rbx,8), %rax adc %rdx, %r11 mul %rcx xor %r8, %r8 addq %r10, (16)(%rdi,%rbx,8) adc %rax, %r11 adc $(0), %rdx addq %r11, (24)(%rdi,%rbx,8) adc $(0), %rdx mov %rdx, %rax jmp .Lexitgas_1 .Lfin_mul1x4n_3gas_1: movq (16)(%rsi,%rbx,8), %rax mul %rcx xor %r11, %r11 addq %r9, (8)(%rdi,%rbx,8) adc %rax, %r10 adc $(0), %rdx addq %r10, (16)(%rdi,%rbx,8) adc $(0), %rdx mov %rdx, %rax jmp .Lexitgas_1 .Lfin_mul1x4n_2gas_1: addq %r9, (8)(%rdi,%rbx,8) adc $(0), %r10 mov %r10, %rax .Lexitgas_1: pop %r12 pop %rbx ret .Lfe1: .size y8_cpAddMulDgt_BNU, .Lfe1-(y8_cpAddMulDgt_BNU)
// // 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/usd/usdRi/pxrCookieLightFilter.h" #include "pxr/usd/usd/schemaRegistry.h" #include "pxr/usd/usd/typed.h" #include "pxr/usd/sdf/types.h" #include "pxr/usd/sdf/assetPath.h" PXR_NAMESPACE_OPEN_SCOPE // Register the schema with the TfType system. TF_REGISTRY_FUNCTION(TfType) { TfType::Define<UsdRiPxrCookieLightFilter, TfType::Bases< UsdLuxLightFilter > >(); // Register the usd prim typename as an alias under UsdSchemaBase. This // enables one to call // TfType::Find<UsdSchemaBase>().FindDerivedByName("PxrCookieLightFilter") // to find TfType<UsdRiPxrCookieLightFilter>, which is how IsA queries are // answered. TfType::AddAlias<UsdSchemaBase, UsdRiPxrCookieLightFilter>("PxrCookieLightFilter"); } /* virtual */ UsdRiPxrCookieLightFilter::~UsdRiPxrCookieLightFilter() { } /* static */ UsdRiPxrCookieLightFilter UsdRiPxrCookieLightFilter::Get(const UsdStagePtr &stage, const SdfPath &path) { if (!stage) { TF_CODING_ERROR("Invalid stage"); return UsdRiPxrCookieLightFilter(); } return UsdRiPxrCookieLightFilter(stage->GetPrimAtPath(path)); } /* static */ UsdRiPxrCookieLightFilter UsdRiPxrCookieLightFilter::Define( const UsdStagePtr &stage, const SdfPath &path) { static TfToken usdPrimTypeName("PxrCookieLightFilter"); if (!stage) { TF_CODING_ERROR("Invalid stage"); return UsdRiPxrCookieLightFilter(); } return UsdRiPxrCookieLightFilter( stage->DefinePrim(path, usdPrimTypeName)); } /* static */ const TfType & UsdRiPxrCookieLightFilter::_GetStaticTfType() { static TfType tfType = TfType::Find<UsdRiPxrCookieLightFilter>(); return tfType; } /* static */ bool UsdRiPxrCookieLightFilter::_IsTypedSchema() { static bool isTyped = _GetStaticTfType().IsA<UsdTyped>(); return isTyped; } /* virtual */ const TfType & UsdRiPxrCookieLightFilter::_GetTfType() const { return _GetStaticTfType(); } UsdAttribute UsdRiPxrCookieLightFilter::GetCookieModeAttr() const { return GetPrim().GetAttribute(UsdRiTokens->cookieMode); } UsdAttribute UsdRiPxrCookieLightFilter::CreateCookieModeAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->cookieMode, SdfValueTypeNames->Token, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetWidthAttr() const { return GetPrim().GetAttribute(UsdRiTokens->width); } UsdAttribute UsdRiPxrCookieLightFilter::CreateWidthAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->width, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetHeightAttr() const { return GetPrim().GetAttribute(UsdRiTokens->height); } UsdAttribute UsdRiPxrCookieLightFilter::CreateHeightAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->height, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetTextureMapAttr() const { return GetPrim().GetAttribute(UsdRiTokens->textureMap); } UsdAttribute UsdRiPxrCookieLightFilter::CreateTextureMapAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->textureMap, SdfValueTypeNames->Asset, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetTextureWrapModeAttr() const { return GetPrim().GetAttribute(UsdRiTokens->textureWrapMode); } UsdAttribute UsdRiPxrCookieLightFilter::CreateTextureWrapModeAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->textureWrapMode, SdfValueTypeNames->Token, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetTextureFillColorAttr() const { return GetPrim().GetAttribute(UsdRiTokens->textureFillColor); } UsdAttribute UsdRiPxrCookieLightFilter::CreateTextureFillColorAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->textureFillColor, SdfValueTypeNames->Color3f, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetTextureInvertUAttr() const { return GetPrim().GetAttribute(UsdRiTokens->textureInvertU); } UsdAttribute UsdRiPxrCookieLightFilter::CreateTextureInvertUAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->textureInvertU, SdfValueTypeNames->Bool, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetTextureInvertVAttr() const { return GetPrim().GetAttribute(UsdRiTokens->textureInvertV); } UsdAttribute UsdRiPxrCookieLightFilter::CreateTextureInvertVAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->textureInvertV, SdfValueTypeNames->Bool, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetTextureScaleUAttr() const { return GetPrim().GetAttribute(UsdRiTokens->textureScaleU); } UsdAttribute UsdRiPxrCookieLightFilter::CreateTextureScaleUAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->textureScaleU, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetTextureScaleVAttr() const { return GetPrim().GetAttribute(UsdRiTokens->textureScaleV); } UsdAttribute UsdRiPxrCookieLightFilter::CreateTextureScaleVAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->textureScaleV, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetTextureOffsetUAttr() const { return GetPrim().GetAttribute(UsdRiTokens->textureOffsetU); } UsdAttribute UsdRiPxrCookieLightFilter::CreateTextureOffsetUAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->textureOffsetU, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetTextureOffsetVAttr() const { return GetPrim().GetAttribute(UsdRiTokens->textureOffsetV); } UsdAttribute UsdRiPxrCookieLightFilter::CreateTextureOffsetVAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->textureOffsetV, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticDirectionalAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticDirectional); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticDirectionalAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticDirectional, SdfValueTypeNames->Bool, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticShearXAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticShearX); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticShearXAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticShearX, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticShearYAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticShearY); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticShearYAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticShearY, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticApexAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticApex); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticApexAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticApex, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticUseLightDirectionAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticUseLightDirection); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticUseLightDirectionAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticUseLightDirection, SdfValueTypeNames->Bool, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticBlurAmountAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticBlurAmount); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticBlurAmountAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticBlurAmount, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticBlurSMultAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticBlurSMult); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticBlurSMultAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticBlurSMult, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticBlurTMultAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticBlurTMult); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticBlurTMultAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticBlurTMult, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticBlurNearDistanceAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticBlurNearDistance); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticBlurNearDistanceAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticBlurNearDistance, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticBlurMidpointAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticBlurMidpoint); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticBlurMidpointAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticBlurMidpoint, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticBlurFarDistanceAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticBlurFarDistance); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticBlurFarDistanceAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticBlurFarDistance, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticBlurNearValueAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticBlurNearValue); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticBlurNearValueAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticBlurNearValue, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticBlurMidValueAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticBlurMidValue); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticBlurMidValueAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticBlurMidValue, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticBlurFarValueAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticBlurFarValue); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticBlurFarValueAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticBlurFarValue, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticBlurExponentAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticBlurExponent); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticBlurExponentAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticBlurExponent, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticDensityNearDistanceAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticDensityNearDistance); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticDensityNearDistanceAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticDensityNearDistance, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticDensityMidpointAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticDensityMidpoint); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticDensityMidpointAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticDensityMidpoint, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticDensityFarDistanceAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticDensityFarDistance); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticDensityFarDistanceAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticDensityFarDistance, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticDensityNearValueAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticDensityNearValue); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticDensityNearValueAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticDensityNearValue, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticDensityMidValueAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticDensityMidValue); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticDensityMidValueAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticDensityMidValue, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticDensityFarValueAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticDensityFarValue); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticDensityFarValueAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticDensityFarValue, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetAnalyticDensityExponentAttr() const { return GetPrim().GetAttribute(UsdRiTokens->analyticDensityExponent); } UsdAttribute UsdRiPxrCookieLightFilter::CreateAnalyticDensityExponentAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->analyticDensityExponent, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetColorSaturationAttr() const { return GetPrim().GetAttribute(UsdRiTokens->colorSaturation); } UsdAttribute UsdRiPxrCookieLightFilter::CreateColorSaturationAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->colorSaturation, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetColorMidpointAttr() const { return GetPrim().GetAttribute(UsdRiTokens->colorMidpoint); } UsdAttribute UsdRiPxrCookieLightFilter::CreateColorMidpointAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->colorMidpoint, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetColorContrastAttr() const { return GetPrim().GetAttribute(UsdRiTokens->colorContrast); } UsdAttribute UsdRiPxrCookieLightFilter::CreateColorContrastAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->colorContrast, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetColorWhitepointAttr() const { return GetPrim().GetAttribute(UsdRiTokens->colorWhitepoint); } UsdAttribute UsdRiPxrCookieLightFilter::CreateColorWhitepointAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->colorWhitepoint, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } UsdAttribute UsdRiPxrCookieLightFilter::GetColorTintAttr() const { return GetPrim().GetAttribute(UsdRiTokens->colorTint); } UsdAttribute UsdRiPxrCookieLightFilter::CreateColorTintAttr(VtValue const &defaultValue, bool writeSparsely) const { return UsdSchemaBase::_CreateAttr(UsdRiTokens->colorTint, SdfValueTypeNames->Color3f, /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); } namespace { static inline TfTokenVector _ConcatenateAttributeNames(const TfTokenVector& left,const TfTokenVector& right) { TfTokenVector result; result.reserve(left.size() + right.size()); result.insert(result.end(), left.begin(), left.end()); result.insert(result.end(), right.begin(), right.end()); return result; } } /*static*/ const TfTokenVector& UsdRiPxrCookieLightFilter::GetSchemaAttributeNames(bool includeInherited) { static TfTokenVector localNames = { UsdRiTokens->cookieMode, UsdRiTokens->width, UsdRiTokens->height, UsdRiTokens->textureMap, UsdRiTokens->textureWrapMode, UsdRiTokens->textureFillColor, UsdRiTokens->textureInvertU, UsdRiTokens->textureInvertV, UsdRiTokens->textureScaleU, UsdRiTokens->textureScaleV, UsdRiTokens->textureOffsetU, UsdRiTokens->textureOffsetV, UsdRiTokens->analyticDirectional, UsdRiTokens->analyticShearX, UsdRiTokens->analyticShearY, UsdRiTokens->analyticApex, UsdRiTokens->analyticUseLightDirection, UsdRiTokens->analyticBlurAmount, UsdRiTokens->analyticBlurSMult, UsdRiTokens->analyticBlurTMult, UsdRiTokens->analyticBlurNearDistance, UsdRiTokens->analyticBlurMidpoint, UsdRiTokens->analyticBlurFarDistance, UsdRiTokens->analyticBlurNearValue, UsdRiTokens->analyticBlurMidValue, UsdRiTokens->analyticBlurFarValue, UsdRiTokens->analyticBlurExponent, UsdRiTokens->analyticDensityNearDistance, UsdRiTokens->analyticDensityMidpoint, UsdRiTokens->analyticDensityFarDistance, UsdRiTokens->analyticDensityNearValue, UsdRiTokens->analyticDensityMidValue, UsdRiTokens->analyticDensityFarValue, UsdRiTokens->analyticDensityExponent, UsdRiTokens->colorSaturation, UsdRiTokens->colorMidpoint, UsdRiTokens->colorContrast, UsdRiTokens->colorWhitepoint, UsdRiTokens->colorTint, }; static TfTokenVector allNames = _ConcatenateAttributeNames( UsdLuxLightFilter::GetSchemaAttributeNames(true), localNames); if (includeInherited) return allNames; else return localNames; } PXR_NAMESPACE_CLOSE_SCOPE // ===================================================================== // // Feel free to add custom code below this line. It will be preserved by // the code generator. // // Just remember to wrap code in the appropriate delimiters: // 'PXR_NAMESPACE_OPEN_SCOPE', 'PXR_NAMESPACE_CLOSE_SCOPE'. // ===================================================================== // // --(BEGIN CUSTOM CODE)--
/* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** \file * \ingroup freestyle * \brief Classes to define a Winged Edge data structure. */ #include <iostream> #include "WEdge.h" namespace Freestyle { /*! Temporary structures */ class vertexdata { public: WVertex *_copy; }; class oedgedata { public: WOEdge *_copy; }; class edgedata { public: WEdge *_copy; }; class facedata { public: WFace *_copy; }; /********************************** * * * * * WVertex * * * * * **********************************/ WVertex::WVertex(WVertex &iBrother) { _Id = iBrother._Id; _Vertex = iBrother._Vertex; _EdgeList = iBrother._EdgeList; _Shape = iBrother._Shape; _Smooth = iBrother._Smooth; _Border = iBrother._Border; userdata = nullptr; iBrother.userdata = new vertexdata; ((vertexdata *)(iBrother.userdata))->_copy = this; } WVertex *WVertex::duplicate() { WVertex *clone = new WVertex(*this); return clone; } WOEdge *WVertex::incoming_edge_iterator::operator*() { return _current; } void WVertex::incoming_edge_iterator::increment() { WOEdge *twin = _current->twin(); if (!twin) { // we reached a hole _current = nullptr; return; } WOEdge *next = twin->getPrevOnFace(); if (next == _begin) { next = nullptr; } _current = next; } WFace *WVertex::face_iterator::operator*() { WOEdge *woedge = *_edge_it; if (!woedge) { return nullptr; } return (woedge)->GetbFace(); } #if 0 bool WVertex::isBoundary() const { return _Border; } #endif bool WVertex::isBoundary() { if (_Border == 1) { return true; } if (_Border == 0) { return false; } vector<WEdge *>::const_iterator it; for (it = _EdgeList.begin(); it != _EdgeList.end(); it++) { if ((*it)->GetNumberOfOEdges() == 1) { _Border = 1; return true; } } #if 0 if (!(*it)->GetaOEdge()->GetaFace()) { return true; } #endif _Border = 0; return false; } void WVertex::AddEdge(WEdge *iEdge) { _EdgeList.push_back(iEdge); } WVertex::incoming_edge_iterator WVertex::incoming_edges_begin() { WOEdge *begin; WEdge *wedge = _EdgeList.front(); WOEdge *aOEdge = wedge->GetaOEdge(); if (aOEdge->GetbVertex() == this) { begin = aOEdge; } else { begin = _EdgeList.front()->GetbOEdge(); } return incoming_edge_iterator(this, begin, begin); } WVertex::incoming_edge_iterator WVertex::incoming_edges_end() { WOEdge *begin; WOEdge *aOEdge = _EdgeList.front()->GetaOEdge(); if (aOEdge->GetbVertex() == this) { begin = aOEdge; } else { begin = _EdgeList.front()->GetbOEdge(); } return incoming_edge_iterator(this, begin, nullptr); } #if 0 WOEdge **WVertex::incoming_edge_iterator::operator->() { WOEdge **ppaOEdge = (*_iter)->GetaOEdge(); if (aOEdge->GetbVertex() == _vertex) { return ppaOEdge; } else { WOEdge *bOEdge = (*_iter)->GetbOEdge(); return &bOEdge; } } #endif /********************************** * * * * * WOEdge * * * * * **********************************/ WOEdge::WOEdge(WOEdge &iBrother) { _paVertex = iBrother.GetaVertex(); _pbVertex = iBrother.GetbVertex(); _paFace = iBrother.GetaFace(); _pbFace = iBrother.GetbFace(); _pOwner = iBrother.GetOwner(); userdata = nullptr; iBrother.userdata = new oedgedata; ((oedgedata *)(iBrother.userdata))->_copy = this; _vec = iBrother._vec; _angle = iBrother._angle; } WOEdge *WOEdge::duplicate() { WOEdge *clone = new WOEdge(*this); return clone; } WOEdge *WOEdge::twin() { return GetOwner()->GetOtherOEdge(this); } WOEdge *WOEdge::getPrevOnFace() { return _pbFace->GetPrevOEdge(this); } /********************************** * * * * * WEdge * * * * * **********************************/ WEdge::WEdge(WEdge &iBrother) { _paOEdge = nullptr; _pbOEdge = nullptr; WOEdge *aoedge = iBrother.GetaOEdge(); WOEdge *boedge = iBrother.GetbOEdge(); userdata = nullptr; if (aoedge) { //_paOEdge = new WOEdge(*aoedge); _paOEdge = aoedge->duplicate(); } if (boedge) { //_pbOEdge = new WOEdge(*boedge); _pbOEdge = boedge->duplicate(); } _nOEdges = iBrother.GetNumberOfOEdges(); _Id = iBrother.GetId(); iBrother.userdata = new edgedata; ((edgedata *)(iBrother.userdata))->_copy = this; } WEdge *WEdge::duplicate() { WEdge *clone = new WEdge(*this); return clone; } /********************************** * * * * * WFace * * * * * **********************************/ WFace::WFace(WFace &iBrother) { _OEdgeList = iBrother.getEdgeList(); _Normal = iBrother.GetNormal(); _VerticesNormals = iBrother._VerticesNormals; _VerticesTexCoords = iBrother._VerticesTexCoords; _Id = iBrother.GetId(); _FrsMaterialIndex = iBrother._FrsMaterialIndex; _Mark = iBrother._Mark; userdata = nullptr; iBrother.userdata = new facedata; ((facedata *)(iBrother.userdata))->_copy = this; } WFace *WFace::duplicate() { WFace *clone = new WFace(*this); return clone; } const FrsMaterial &WFace::frs_material() { return getShape()->frs_material(_FrsMaterialIndex); } WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2) { // First check whether the same oriented edge already exists or not: vector<WEdge *> &v1Edges = v1->GetEdges(); for (vector<WEdge *>::iterator it1 = v1Edges.begin(), end = v1Edges.end(); it1 != end; it1++) { WEdge *we = (*it1); WOEdge *woea = we->GetaOEdge(); if ((woea->GetaVertex() == v1) && (woea->GetbVertex() == v2)) { // The oriented edge already exists cerr << "Warning: edge " << v1->GetId() << " - " << v2->GetId() << " appears twice, correcting" << endl; // Adds the edge to the face AddEdge(woea); (*it1)->setNumberOfOEdges((*it1)->GetNumberOfOEdges() + 1); // sets these vertices as border: v1->setBorder(true); v2->setBorder(true); return woea; } WOEdge *woeb = we->GetbOEdge(); if (woeb && (woeb->GetaVertex() == v1) && (woeb->GetbVertex() == v2)) { // The oriented edge already exists cerr << "Warning: edge " << v1->GetId() << " - " << v2->GetId() << " appears twice, correcting" << endl; // Adds the edge to the face AddEdge(woeb); (*it1)->setNumberOfOEdges((*it1)->GetNumberOfOEdges() + 1); // sets these vertices as border: v1->setBorder(true); v2->setBorder(true); return woeb; } } // the oriented edge we're about to build WOEdge *pOEdge = new WOEdge; // The edge containing the oriented edge. WEdge *edge; // checks whether this edge already exists or not // If it exists, it points outward v2 bool exist = false; WOEdge *pInvertEdge = nullptr; // The inverted edge if it exists vector<WEdge *> &v2Edges = v2->GetEdges(); vector<WEdge *>::iterator it; for (it = v2Edges.begin(); it != v2Edges.end(); it++) { if ((*it)->GetbVertex() == v1) { // The invert edge already exists exist = true; pInvertEdge = (*it)->GetaOEdge(); break; } } // DEBUG: if (true == exist) { // The invert edge already exists // Retrieves the corresponding edge edge = pInvertEdge->GetOwner(); // Sets the a Face (retrieved from pInvertEdge pOEdge->setaFace(pInvertEdge->GetbFace()); // Updates the invert edge: pInvertEdge->setaFace(this); } else { // The invert edge does not exist yet // we must create a new edge // edge = new WEdge; edge = instanciateEdge(); // updates the a,b vertex edges list: v1->AddEdge(edge); v2->AddEdge(edge); } pOEdge->setOwner(edge); // Add the vertices: pOEdge->setaVertex(v1); pOEdge->setbVertex(v2); // Debug: if (v1->GetId() == v2->GetId()) { cerr << "Warning: edge " << this << " null with vertex " << v1->GetId() << endl; } edge->AddOEdge(pOEdge); // edge->setNumberOfOEdges(edge->GetNumberOfOEdges() + 1); // Add this face (the b face) pOEdge->setbFace(this); // Adds the edge to the face AddEdge(pOEdge); return pOEdge; } bool WFace::getOppositeEdge(const WVertex *v, WOEdge *&e) { if (_OEdgeList.size() != 3) { return false; } vector<WOEdge *>::iterator it; e = nullptr; for (it = _OEdgeList.begin(); it != _OEdgeList.end(); it++) { if ((*it)->GetaVertex() == v) { e = *it; } } if (!e) { return false; } e = nullptr; for (it = _OEdgeList.begin(); it != _OEdgeList.end(); it++) { if (((*it)->GetaVertex() != v) && ((*it)->GetbVertex() != v)) { e = *it; } } if (!e) { return false; } return true; } float WFace::getArea() { vector<WOEdge *>::iterator it; Vec3f origin = (*(_OEdgeList.begin()))->GetaVertex()->GetVertex(); it = _OEdgeList.begin(); float a = 0; for (it = it++; it != _OEdgeList.end(); it++) { Vec3f v1 = Vec3f((*it)->GetaVertex()->GetVertex() - origin); Vec3f v2 = Vec3f((*it)->GetbVertex()->GetVertex() - origin); a += (v1 ^ v2).norm() / 2.0f; } return a; } WOEdge *WFace::GetPrevOEdge(WOEdge *iOEdge) { vector<WOEdge *>::iterator woe, woend, woefirst; woefirst = _OEdgeList.begin(); woend = _OEdgeList.end(); WOEdge *prev = *woefirst; woe = woefirst; ++woe; for (; woe != woend; woe++) { if ((*woe) == iOEdge) { return prev; } prev = *woe; } // We left the loop. That means that the first OEdge was the good one: if ((*woefirst) == iOEdge) { return prev; } return nullptr; } WShape *WFace::getShape() { return GetVertex(0)->shape(); } /********************************** * * * * * WShape * * * * * **********************************/ unsigned WShape::_SceneCurrentId = 0; WShape *WShape::duplicate() { WShape *clone = new WShape(*this); return clone; } WShape::WShape(WShape &iBrother) { _Id = iBrother.GetId(); _Name = iBrother._Name; _LibraryPath = iBrother._LibraryPath; _FrsMaterials = iBrother._FrsMaterials; #if 0 _meanEdgeSize = iBrother._meanEdgeSize; iBrother.bbox(_min, _max); #endif vector<WVertex *> &vertexList = iBrother.getVertexList(); vector<WVertex *>::iterator v = vertexList.begin(), vend = vertexList.end(); for (; v != vend; ++v) { // WVertex *newVertex = new WVertex(*(*v)); WVertex *newVertex = (*v)->duplicate(); newVertex->setShape(this); AddVertex(newVertex); } vector<WEdge *> &edgeList = iBrother.getEdgeList(); vector<WEdge *>::iterator e = edgeList.begin(), eend = edgeList.end(); for (; e != eend; ++e) { // WEdge *newEdge = new WEdge(*(*e)); WEdge *newEdge = (*e)->duplicate(); AddEdge(newEdge); } vector<WFace *> &faceList = iBrother.GetFaceList(); vector<WFace *>::iterator f = faceList.begin(), fend = faceList.end(); for (; f != fend; ++f) { // WFace *newFace = new WFace(*(*f)); WFace *newFace = (*f)->duplicate(); AddFace(newFace); } // update all pointed addresses thanks to the newly created objects: vend = _VertexList.end(); for (v = _VertexList.begin(); v != vend; ++v) { const vector<WEdge *> &vedgeList = (*v)->GetEdges(); vector<WEdge *> newvedgelist; unsigned int i; for (i = 0; i < vedgeList.size(); i++) { WEdge *current = vedgeList[i]; edgedata *currentvedata = (edgedata *)current->userdata; newvedgelist.push_back(currentvedata->_copy); } (*v)->setEdges(newvedgelist); } eend = _EdgeList.end(); for (e = _EdgeList.begin(); e != eend; ++e) { // update aOedge: WOEdge *aoEdge = (*e)->GetaOEdge(); aoEdge->setaVertex(((vertexdata *)(aoEdge->GetaVertex()->userdata))->_copy); aoEdge->setbVertex(((vertexdata *)(aoEdge->GetbVertex()->userdata))->_copy); if (aoEdge->GetaFace()) { aoEdge->setaFace(((facedata *)(aoEdge->GetaFace()->userdata))->_copy); } aoEdge->setbFace(((facedata *)(aoEdge->GetbFace()->userdata))->_copy); aoEdge->setOwner(((edgedata *)(aoEdge->GetOwner()->userdata))->_copy); // update bOedge: WOEdge *boEdge = (*e)->GetbOEdge(); if (boEdge) { boEdge->setaVertex(((vertexdata *)(boEdge->GetaVertex()->userdata))->_copy); boEdge->setbVertex(((vertexdata *)(boEdge->GetbVertex()->userdata))->_copy); if (boEdge->GetaFace()) { boEdge->setaFace(((facedata *)(boEdge->GetaFace()->userdata))->_copy); } boEdge->setbFace(((facedata *)(boEdge->GetbFace()->userdata))->_copy); boEdge->setOwner(((edgedata *)(boEdge->GetOwner()->userdata))->_copy); } } fend = _FaceList.end(); for (f = _FaceList.begin(); f != fend; ++f) { unsigned int i; const vector<WOEdge *> &oedgeList = (*f)->getEdgeList(); vector<WOEdge *> newoedgelist; unsigned int n = oedgeList.size(); for (i = 0; i < n; i++) { WOEdge *current = oedgeList[i]; oedgedata *currentoedata = (oedgedata *)current->userdata; newoedgelist.push_back(currentoedata->_copy); // oedgeList[i] = currentoedata->_copy; // oedgeList[i] = ((oedgedata *)(oedgeList[i]->userdata))->_copy; } (*f)->setEdgeList(newoedgelist); } // Free all memory (arghh!) // Vertex vend = iBrother.getVertexList().end(); for (v = iBrother.getVertexList().begin(); v != vend; ++v) { delete (vertexdata *)((*v)->userdata); (*v)->userdata = nullptr; } // Edges and OEdges: eend = iBrother.getEdgeList().end(); for (e = iBrother.getEdgeList().begin(); e != eend; ++e) { delete (edgedata *)((*e)->userdata); (*e)->userdata = nullptr; // OEdge a: delete (oedgedata *)((*e)->GetaOEdge()->userdata); (*e)->GetaOEdge()->userdata = nullptr; // OEdge b: WOEdge *oedgeb = (*e)->GetbOEdge(); if (oedgeb) { delete (oedgedata *)(oedgeb->userdata); oedgeb->userdata = nullptr; } } // Faces fend = iBrother.GetFaceList().end(); for (f = iBrother.GetFaceList().begin(); f != fend; ++f) { delete (facedata *)((*f)->userdata); (*f)->userdata = nullptr; } } WFace *WShape::MakeFace(vector<WVertex *> &iVertexList, vector<bool> &iFaceEdgeMarksList, unsigned iMaterial) { // allocate the new face WFace *face = instanciateFace(); WFace *result = MakeFace(iVertexList, iFaceEdgeMarksList, iMaterial, face); if (!result) { delete face; } return result; } WFace *WShape::MakeFace(vector<WVertex *> &iVertexList, vector<Vec3f> &iNormalsList, vector<Vec2f> &iTexCoordsList, vector<bool> &iFaceEdgeMarksList, unsigned iMaterial) { // allocate the new face WFace *face = MakeFace(iVertexList, iFaceEdgeMarksList, iMaterial); if (!face) { return nullptr; } // set the list of per-vertex normals face->setNormalList(iNormalsList); // set the list of per-vertex tex coords face->setTexCoordsList(iTexCoordsList); return face; } WFace *WShape::MakeFace(vector<WVertex *> &iVertexList, vector<bool> &iFaceEdgeMarksList, unsigned iMaterial, WFace *face) { int id = _FaceList.size(); face->setFrsMaterialIndex(iMaterial); // Check whether we have a degenerated face: // LET'S HACK IT FOR THE TRIANGLE CASE: if (3 == iVertexList.size()) { if ((iVertexList[0] == iVertexList[1]) || (iVertexList[0] == iVertexList[2]) || (iVertexList[2] == iVertexList[1])) { cerr << "Warning: degenerated triangle detected, correcting" << endl; return nullptr; } } vector<WVertex *>::iterator it; // compute the face normal (v1v2 ^ v1v3) // Double precision numbers are used here to avoid truncation errors [T47705] Vec3r v1, v2, v3; it = iVertexList.begin(); v1 = (*it)->GetVertex(); it++; v2 = (*it)->GetVertex(); it++; v3 = (*it)->GetVertex(); Vec3r vector1(v2 - v1); Vec3r vector2(v3 - v1); Vec3r normal(vector1 ^ vector2); normal.normalize(); face->setNormal(normal); vector<bool>::iterator mit = iFaceEdgeMarksList.begin(); face->setMark(*mit); mit++; // vertex pointers used to build each edge vector<WVertex *>::iterator va, vb; va = iVertexList.begin(); vb = va; for (; va != iVertexList.end(); va = vb) { ++vb; // Adds va to the vertex list: // face->AddVertex(*va); WOEdge *oedge; if (*va == iVertexList.back()) { oedge = face->MakeEdge(*va, iVertexList.front()); // for the last (closing) edge } else { oedge = face->MakeEdge(*va, *vb); } if (!oedge) { return nullptr; } WEdge *edge = oedge->GetOwner(); if (1 == edge->GetNumberOfOEdges()) { // means that we just created a new edge and that we must add it to the shape's edges list edge->setId(_EdgeList.size()); AddEdge(edge); #if 0 // compute the mean edge value: _meanEdgeSize += edge->GetaOEdge()->GetVec().norm(); #endif } edge->setMark(*mit); ++mit; } // Add the face to the shape's faces list: face->setId(id); AddFace(face); return face; } real WShape::ComputeMeanEdgeSize() const { real meanEdgeSize = 0.0; for (vector<WEdge *>::const_iterator it = _EdgeList.begin(), itend = _EdgeList.end(); it != itend; it++) { meanEdgeSize += (*it)->GetaOEdge()->GetVec().norm(); } return meanEdgeSize / (real)_EdgeList.size(); } } /* namespace Freestyle */
; showing 8-bit unsigned division ; - done in sub-routine ; - input: dividend in b and divisor in c ; - result: quotient in b and remainder in c org 0000h lxi sp,4000h mvi b,20h mvi c,30h call do_divs hlt do_divs: push h mov l,b mvi b,8 ; loop 8-times (8-bit) xra a mov h,a loop: dad h mov a,h cmp c jc next sub c mov h,a mov a,l ori 01h mov l,a next: dcr b jnz loop mov b,l mov c,h pop h ret
dnl AMD K6-2 mpn_copyd -- copy limb vector, decrementing. dnl dnl K6-2: 0.56 or 1.0 cycles/limb (at 32 limbs/loop), depending on data dnl alignment. dnl Copyright (C) 1999, 2000 Free Software Foundation, Inc. dnl dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or dnl modify it under the terms of the GNU Lesser General Public License as dnl published by the Free Software Foundation; either version 2.1 of the dnl License, or (at your option) any later version. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl Lesser General Public License for more details. dnl dnl You should have received a copy of the GNU Lesser General Public dnl License along with the GNU MP Library; see the file COPYING.LIB. If dnl not, write to the Free Software Foundation, Inc., 59 Temple Place - dnl Suite 330, Boston, MA 02111-1307, USA. include(`../config.m4') dnl K6-2 aligned: dnl UNROLL_COUNT cycles/limb dnl 8 0.75 dnl 16 0.625 dnl 32 0.5625 dnl 64 0.53 dnl Maximum possible with the current code is 64, the minimum is 2. deflit(UNROLL_COUNT, 32) C void mpn_copyd (mp_ptr dst, mp_srcptr src, mp_size_t size); C C Copy src,size to dst,size, processing limbs from high to low addresses. C C The comments in copyi.asm apply here too. defframe(PARAM_SIZE,12) defframe(PARAM_SRC, 8) defframe(PARAM_DST, 4) deflit(`FRAME',0) .text ALIGN(32) PROLOGUE(mpn_copyd) movl PARAM_SIZE, %ecx movl %esi, %eax movl PARAM_SRC, %esi movl %edi, %edx std movl PARAM_DST, %edi cmpl $UNROLL_COUNT, %ecx leal -4(%esi,%ecx,4), %esi leal -4(%edi,%ecx,4), %edi ja L(unroll) L(simple): rep movsl cld movl %eax, %esi movl %edx, %edi ret L(unroll): C if src and dst are different alignments mod8, then use rep movs C if src and dst are both 4mod8 then process one limb to get 0mod8 pushl %ebx leal (%esi,%edi), %ebx testb $4, %bl popl %ebx jnz L(simple) testl $4, %esi leal -UNROLL_COUNT(%ecx), %ecx jnz L(already_aligned) movsl decl %ecx L(already_aligned): ifelse(UNROLL_BYTES,256,` subl $128, %esi subl $128, %edi ') C offset 0x3D here, but gets full speed without further alignment L(top): C eax saved esi C ebx C ecx counter, limbs C edx saved edi C esi src, incrementing C edi dst, incrementing C ebp C C `disp' is never 0, so don't need to force 0(%esi). deflit(CHUNK_COUNT, 2) forloop(`i', 0, UNROLL_COUNT/CHUNK_COUNT-1, ` deflit(`disp', eval(-4-i*CHUNK_COUNT*4 ifelse(UNROLL_BYTES,256,+128))) movq disp(%esi), %mm0 movq %mm0, disp(%edi) ') leal -UNROLL_BYTES(%esi), %esi subl $UNROLL_COUNT, %ecx leal -UNROLL_BYTES(%edi), %edi jns L(top) C now %ecx is -UNROLL_COUNT to -1 representing repectively 0 to C UNROLL_COUNT-1 limbs remaining testb $eval(UNROLL_COUNT/2), %cl leal UNROLL_COUNT(%ecx), %ecx jz L(not_half) C at an unroll count of 32 this block of code is 16 cycles faster than C the rep movs, less 3 or 4 to test whether to do it forloop(`i', 0, UNROLL_COUNT/CHUNK_COUNT/2-1, ` deflit(`disp', eval(-4-i*CHUNK_COUNT*4 ifelse(UNROLL_BYTES,256,+128))) movq disp(%esi), %mm0 movq %mm0, disp(%edi) ') subl $eval(UNROLL_BYTES/2), %esi subl $eval(UNROLL_BYTES/2), %edi subl $eval(UNROLL_COUNT/2), %ecx L(not_half): ifelse(UNROLL_BYTES,256,` addl $128, %esi addl $128, %edi ') rep movsl cld movl %eax, %esi movl %edx, %edi femms ret EPILOGUE()
; A186371: Number of up-down runs in all permutations of {1,2,...,n}. ; Submitted by Jamie Morken(s1) ; 0,1,3,13,68,420,3000,24360,221760,2237760,24796800,299376000,3911846400,55005350400,828193766400,13294689408000,226663557120000,4090405423104000,77895546753024000,1561112121913344000,32844177110384640000,723788347432550400000 seq $0,82034 ; a(n) = (4*n + 1)*n!. div $0,3 dif $0,2
ld hl, #1 ld de, #2 ld bc, #3 call $0621
; A188510: Expansion of x*(1 + x^2)/(1 + x^4) in powers of x. ; 0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1,0,1,0,-1,0,-1,0,1 lpb $0,1 sub $0,8 lpe mod $0,2 mov $1,$0
dc.w word_37002-Map_2PGoalMarker dc.w word_37010-Map_2PGoalMarker dc.w word_3701E-Map_2PGoalMarker dc.w word_3702C-Map_2PGoalMarker word_37002: dc.w 2 ; DATA XREF: ROM:00036FFAo dc.b $EC, 2, 0, 0, $FF, $FC dc.b 4, 1, 0, 3, $FF, $FC word_37010: dc.w 2 ; DATA XREF: ROM:00036FFAo dc.b $EC, 2, 0, 5, $FF, $FC dc.b 4, 1, 0, 3, $FF, $FC word_3701E: dc.w 2 ; DATA XREF: ROM:00036FFAo dc.b $EC, 2, 0, 8, $FF, $FC dc.b 4, 1, 0, 3, $FF, $FC word_3702C: dc.w 2 ; DATA XREF: ROM:00036FFAo dc.b $EC, 2, 0, $B, $FF, $FC dc.b 4, 1, 0, 3, $FF, $FC
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org Copyright (c) 2000-2014 Torus Knot Software Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ #include "Vao/OgreGL3PlusConstBufferPacked.h" #include "Vao/OgreGL3PlusBufferInterface.h" namespace Ogre { GL3PlusConstBufferPacked::GL3PlusConstBufferPacked( size_t internalBufferStartBytes, size_t numElements, uint32 bytesPerElement, uint32 numElementsPadding, BufferType bufferType, void *initialData, bool keepAsShadow, VaoManager *vaoManager, BufferInterface *bufferInterface ) : ConstBufferPacked( internalBufferStartBytes, numElements, bytesPerElement, numElementsPadding, bufferType, initialData, keepAsShadow, vaoManager, bufferInterface ) { } //----------------------------------------------------------------------------------- GL3PlusConstBufferPacked::~GL3PlusConstBufferPacked() { } //----------------------------------------------------------------------------------- inline void GL3PlusConstBufferPacked::bindBuffer( uint16 slot ) { assert( dynamic_cast<GL3PlusBufferInterface*>( mBufferInterface ) ); GL3PlusBufferInterface *bufferInterface = static_cast<GL3PlusBufferInterface*>( mBufferInterface ); OCGE( glBindBufferRange( GL_UNIFORM_BUFFER, slot, bufferInterface->getVboName(), mFinalBufferStart * mBytesPerElement, mNumElements * mBytesPerElement ) ); } //----------------------------------------------------------------------------------- void GL3PlusConstBufferPacked::bindBufferVS( uint16 slot ) { bindBuffer( slot ); } //----------------------------------------------------------------------------------- void GL3PlusConstBufferPacked::bindBufferPS( uint16 slot ) { bindBuffer( slot ); } //----------------------------------------------------------------------------------- void GL3PlusConstBufferPacked::bindBufferGS( uint16 slot ) { bindBuffer( slot ); } //----------------------------------------------------------------------------------- void GL3PlusConstBufferPacked::bindBufferHS( uint16 slot ) { bindBuffer( slot ); } //----------------------------------------------------------------------------------- void GL3PlusConstBufferPacked::bindBufferDS( uint16 slot ) { bindBuffer( slot ); } //----------------------------------------------------------------------------------- void GL3PlusConstBufferPacked::bindBufferCS( uint16 slot ) { bindBuffer( slot ); } //----------------------------------------------------------------------------------- }
; A263846: Floor of cube root of n-th prime. ; 1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8 seq $0,6005 ; The odd prime numbers together with 1. seq $0,48766 ; Integer part of cube root of n. Or, number of cubes <= n. Or, n appears 3n^2 + 3n + 1 times.
; A199031: 2*12^n-1. ; 1,23,287,3455,41471,497663,5971967,71663615,859963391,10319560703,123834728447,1486016741375,17832200896511,213986410758143,2567836929097727,30814043149172735,369768517790072831,4437222213480873983,53246666561770487807,638959998741245853695,7667519984894950244351,92010239818739402932223,1104122877824872835186687,13249474533898474022240255,158993694406781688266883071,1907924332881380259202596863,22895091994576563110431162367,274741103934918757325173948415,3296893247219025087902087380991,39562718966628301054825048571903,474752627599539612657900582862847,5697031531194475351894806994354175,68364378374333704222737683932250111,820372540492004450672852207187001343 mov $1,12 pow $1,$0 sub $1,1 mul $1,2 add $1,1 mov $0,$1
#include "cbase.h" #include "c_basehlcombatweapon.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" class C_WeaponHandGrenade : public C_BaseHLCombatWeapon { public: DECLARE_CLASS( C_WeaponHandGrenade, C_BaseHLCombatWeapon ); DECLARE_CLIENTCLASS(); DECLARE_PREDICTABLE(); DECLARE_DATADESC(); #ifdef HOE_THIRDPERSON DECLARE_ACTTABLE(); #endif // HOE_THIRDPERSON C_WeaponHandGrenade() {}; ~C_WeaponHandGrenade() {}; Activity ActivityOverride( Activity baseAct, bool *pRequired ) { #if 0 // Grenade is drawn back for throwing if ( baseAct == ACT_IDLE_ANGRY && m_fDrawbackFinished ) return ACT_HL2MP_IDLE_GRENADE; // Grenade is drawn back for throwing if ( baseAct == ACT_RUN_AIM && m_fDrawbackFinished ) return ACT_HL2MP_RUN_GRENADE; #endif return BaseClass::ActivityOverride( baseAct, pRequired ); } bool m_fDrawbackFinished; }; BEGIN_PREDICTION_DATA( C_WeaponHandGrenade ) END_PREDICTION_DATA() #ifdef HOE_THIRDPERSON acttable_t C_WeaponHandGrenade::m_acttable[] = { { ACT_GESTURE_RANGE_ATTACK1, ACT_MP_GRENADE1_ATTACK, true }, { ACT_GESTURE_RANGE_ATTACK2, ACT_MP_GRENADE2_ATTACK, true }, { ACT_MP_GRENADE1_DRAW, ACT_MP_GRENADE1_DRAW, false }, { ACT_MP_GRENADE2_DRAW, ACT_MP_GRENADE2_DRAW, false }, { ACT_IDLE, ACT_IDLE_ANGRY_MELEE, false }, { ACT_IDLE_ANGRY, ACT_IDLE_ANGRY_MELEE, false }, { ACT_RUN_AIM, ACT_HL2MP_RUN_MELEE, false }, }; IMPLEMENT_ACTTABLE(C_WeaponHandGrenade); #endif // HOE_THIRDPERSON IMPLEMENT_CLIENTCLASS_DT( C_WeaponHandGrenade, DT_WeaponHandGrenade, CWeaponHandGrenade ) RecvPropBool( RECVINFO( m_fDrawbackFinished ) ), END_RECV_TABLE() BEGIN_DATADESC( C_WeaponHandGrenade ) DEFINE_FIELD( m_fDrawbackFinished, FIELD_BOOLEAN ), END_DATADESC() LINK_ENTITY_TO_CLASS( weapon_handgrenade, C_WeaponHandGrenade );
ICW1 equ 00010001b ; ICW4 needed ICW3_MASTER equ 00000100b ICW3_SLAVE equ 00000010b ICW4 equ 00000001b ; 8086/88 mode PIC1 equ 0x20 ; IO base address for master 8259 PIC PIC2 equ 0xa0 ; addr for slave PIC PIC1_CMD equ PIC1 PIC1_DAT equ PIC1 + 1 PIC2_CMD equ PIC2 PIC2_DAT equ PIC2 + 1 PIC_EOI equ 0x20 ; byte to send to PIC CMD port to acknowledge end of interrupt pic_init: ; https://www.eeeguide.com/programming-8259/ cli ; I will map the master PIC to 0x60+0:7 = 0110,0000b ; and the slave PIC to 0x70+0:7 = 0111,0000b (which is actually the default for it anyway) mov al, ICW1 out PIC1_CMD, al out PIC2_CMD, al mov al, PIC_MASTER_OFFSET out PIC1_DAT, al mov al, PIC_SLAVE_OFFSET out PIC2_DAT, al mov al, ICW3_MASTER out PIC1_DAT, al mov al, ICW3_SLAVE out PIC2_DAT, al mov al, ICW4 out PIC1_DAT, al out PIC2_DAT, al ; Set masks to only enable the keyboard and PIT mov al, 11111100b out PIC1_DAT, al mov al, 0xff out PIC2_DAT, al mov al, 0xae out 0x64, al ; Now both of the PICs are initialised correctly sti ret
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r15 push %r8 push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0xf59c, %rdx and $6315, %rdi mov (%rdx), %r12w nop nop add $1642, %r15 lea addresses_normal_ht+0x1d6e8, %rsi lea addresses_A_ht+0x18188, %rdi nop xor $52538, %r12 mov $104, %rcx rep movsb nop add %rcx, %rcx lea addresses_WT_ht+0x18448, %rsi lea addresses_WC_ht+0x5188, %rdi nop nop nop xor %r8, %r8 mov $117, %rcx rep movsw nop nop nop nop dec %rcx lea addresses_WC_ht+0x4448, %rsi lea addresses_WC_ht+0xc38, %rdi clflush (%rsi) nop nop xor $49353, %r8 mov $59, %rcx rep movsb nop nop nop xor %rdx, %rdx lea addresses_WC_ht+0xfc48, %rsi lea addresses_D_ht+0x1d448, %rdi nop nop inc %r13 mov $20, %rcx rep movsb nop nop sub %rsi, %rsi lea addresses_UC_ht+0x131c8, %rsi clflush (%rsi) nop nop nop nop nop add %rdi, %rdi mov (%rsi), %r15 nop dec %rcx lea addresses_A_ht+0x1c888, %r13 and $17390, %rdx vmovups (%r13), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $1, %xmm5, %r12 nop nop nop xor $20162, %rdx lea addresses_WT_ht+0x5448, %rcx dec %r15 mov (%rcx), %r8d nop nop nop nop nop inc %rcx lea addresses_UC_ht+0x14c48, %rsi lea addresses_WC_ht+0xe648, %rdi add $21202, %r8 mov $30, %rcx rep movsl nop nop nop nop add %r8, %r8 lea addresses_UC_ht+0x5c48, %rdx nop nop cmp %r13, %r13 mov (%rdx), %di nop nop nop nop nop sub %rdx, %rdx lea addresses_normal_ht+0x17448, %r8 clflush (%r8) nop dec %r12 vmovups (%r8), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $1, %xmm6, %rsi nop xor %rdi, %rdi lea addresses_WT_ht+0xf048, %rsi nop nop nop cmp $20780, %rdi mov $0x6162636465666768, %rdx movq %rdx, %xmm5 vmovups %ymm5, (%rsi) nop nop and %r8, %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 pop %r15 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r15 push %r8 push %rax push %rcx push %rdi push %rsi // Store lea addresses_PSE+0x19728, %rcx nop nop nop nop add %r10, %r10 movb $0x51, (%rcx) nop cmp %r15, %r15 // REPMOV lea addresses_normal+0x1ad68, %rsi lea addresses_PSE+0x17448, %rdi nop nop nop sub $12412, %r8 mov $93, %rcx rep movsb nop nop nop add $44507, %r8 // Faulty Load lea addresses_normal+0x8c48, %rdi add $32000, %r15 mov (%rdi), %r10 lea oracles, %rdi and $0xff, %r10 shlq $12, %r10 mov (%rdi,%r10,1), %r10 pop %rsi pop %rdi pop %rcx pop %rax pop %r8 pop %r15 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_normal'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_PSE'}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_normal', 'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 1}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_WC_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_D_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 10}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
_ln: 檔案格式 elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp if(argc != 3){ 7: 83 39 03 cmpl $0x3,(%ecx) #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { a: ff 71 fc pushl -0x4(%ecx) d: 55 push %ebp e: 89 e5 mov %esp,%ebp 10: 53 push %ebx 11: 51 push %ecx 12: 8b 59 04 mov 0x4(%ecx),%ebx if(argc != 3){ 15: 74 14 je 2b <main+0x2b> printf(2, "Usage: ln old new\n"); 17: 83 ec 08 sub $0x8,%esp 1a: 68 10 07 00 00 push $0x710 1f: 6a 02 push $0x2 21: e8 ca 03 00 00 call 3f0 <printf> exit(); 26: e8 77 02 00 00 call 2a2 <exit> } if(link(argv[1], argv[2]) < 0) 2b: 50 push %eax 2c: 50 push %eax 2d: ff 73 08 pushl 0x8(%ebx) 30: ff 73 04 pushl 0x4(%ebx) 33: e8 ca 02 00 00 call 302 <link> 38: 83 c4 10 add $0x10,%esp 3b: 85 c0 test %eax,%eax 3d: 78 05 js 44 <main+0x44> printf(2, "link %s %s: failed\n", argv[1], argv[2]); exit(); 3f: e8 5e 02 00 00 call 2a2 <exit> if(argc != 3){ printf(2, "Usage: ln old new\n"); exit(); } if(link(argv[1], argv[2]) < 0) printf(2, "link %s %s: failed\n", argv[1], argv[2]); 44: ff 73 08 pushl 0x8(%ebx) 47: ff 73 04 pushl 0x4(%ebx) 4a: 68 23 07 00 00 push $0x723 4f: 6a 02 push $0x2 51: e8 9a 03 00 00 call 3f0 <printf> 56: 83 c4 10 add $0x10,%esp 59: eb e4 jmp 3f <main+0x3f> 5b: 66 90 xchg %ax,%ax 5d: 66 90 xchg %ax,%ax 5f: 90 nop 00000060 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp 63: 53 push %ebx 64: 8b 45 08 mov 0x8(%ebp),%eax 67: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 6a: 89 c2 mov %eax,%edx 6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 70: 83 c1 01 add $0x1,%ecx 73: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 77: 83 c2 01 add $0x1,%edx 7a: 84 db test %bl,%bl 7c: 88 5a ff mov %bl,-0x1(%edx) 7f: 75 ef jne 70 <strcpy+0x10> ; return os; } 81: 5b pop %ebx 82: 5d pop %ebp 83: c3 ret 84: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000090 <strcmp>: int strcmp(const char *p, const char *q) { 90: 55 push %ebp 91: 89 e5 mov %esp,%ebp 93: 56 push %esi 94: 53 push %ebx 95: 8b 55 08 mov 0x8(%ebp),%edx 98: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 9b: 0f b6 02 movzbl (%edx),%eax 9e: 0f b6 19 movzbl (%ecx),%ebx a1: 84 c0 test %al,%al a3: 75 1e jne c3 <strcmp+0x33> a5: eb 29 jmp d0 <strcmp+0x40> a7: 89 f6 mov %esi,%esi a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; b0: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) b3: 0f b6 02 movzbl (%edx),%eax p++, q++; b6: 8d 71 01 lea 0x1(%ecx),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) b9: 0f b6 59 01 movzbl 0x1(%ecx),%ebx bd: 84 c0 test %al,%al bf: 74 0f je d0 <strcmp+0x40> c1: 89 f1 mov %esi,%ecx c3: 38 d8 cmp %bl,%al c5: 74 e9 je b0 <strcmp+0x20> p++, q++; return (uchar)*p - (uchar)*q; c7: 29 d8 sub %ebx,%eax } c9: 5b pop %ebx ca: 5e pop %esi cb: 5d pop %ebp cc: c3 ret cd: 8d 76 00 lea 0x0(%esi),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) d0: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; d2: 29 d8 sub %ebx,%eax } d4: 5b pop %ebx d5: 5e pop %esi d6: 5d pop %ebp d7: c3 ret d8: 90 nop d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000000e0 <strlen>: uint strlen(const char *s) { e0: 55 push %ebp e1: 89 e5 mov %esp,%ebp e3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) e6: 80 39 00 cmpb $0x0,(%ecx) e9: 74 12 je fd <strlen+0x1d> eb: 31 d2 xor %edx,%edx ed: 8d 76 00 lea 0x0(%esi),%esi f0: 83 c2 01 add $0x1,%edx f3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) f7: 89 d0 mov %edx,%eax f9: 75 f5 jne f0 <strlen+0x10> ; return n; } fb: 5d pop %ebp fc: c3 ret uint strlen(const char *s) { int n; for(n = 0; s[n]; n++) fd: 31 c0 xor %eax,%eax ; return n; } ff: 5d pop %ebp 100: c3 ret 101: eb 0d jmp 110 <memset> 103: 90 nop 104: 90 nop 105: 90 nop 106: 90 nop 107: 90 nop 108: 90 nop 109: 90 nop 10a: 90 nop 10b: 90 nop 10c: 90 nop 10d: 90 nop 10e: 90 nop 10f: 90 nop 00000110 <memset>: void* memset(void *dst, int c, uint n) { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 57 push %edi 114: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 117: 8b 4d 10 mov 0x10(%ebp),%ecx 11a: 8b 45 0c mov 0xc(%ebp),%eax 11d: 89 d7 mov %edx,%edi 11f: fc cld 120: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 122: 89 d0 mov %edx,%eax 124: 5f pop %edi 125: 5d pop %ebp 126: c3 ret 127: 89 f6 mov %esi,%esi 129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000130 <strchr>: char* strchr(const char *s, char c) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp 133: 53 push %ebx 134: 8b 45 08 mov 0x8(%ebp),%eax 137: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 13a: 0f b6 10 movzbl (%eax),%edx 13d: 84 d2 test %dl,%dl 13f: 74 1d je 15e <strchr+0x2e> if(*s == c) 141: 38 d3 cmp %dl,%bl 143: 89 d9 mov %ebx,%ecx 145: 75 0d jne 154 <strchr+0x24> 147: eb 17 jmp 160 <strchr+0x30> 149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 150: 38 ca cmp %cl,%dl 152: 74 0c je 160 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 154: 83 c0 01 add $0x1,%eax 157: 0f b6 10 movzbl (%eax),%edx 15a: 84 d2 test %dl,%dl 15c: 75 f2 jne 150 <strchr+0x20> if(*s == c) return (char*)s; return 0; 15e: 31 c0 xor %eax,%eax } 160: 5b pop %ebx 161: 5d pop %ebp 162: c3 ret 163: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000170 <gets>: char* gets(char *buf, int max) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 57 push %edi 174: 56 push %esi 175: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 176: 31 f6 xor %esi,%esi cc = read(0, &c, 1); 178: 8d 7d e7 lea -0x19(%ebp),%edi return 0; } char* gets(char *buf, int max) { 17b: 83 ec 1c sub $0x1c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 17e: eb 29 jmp 1a9 <gets+0x39> cc = read(0, &c, 1); 180: 83 ec 04 sub $0x4,%esp 183: 6a 01 push $0x1 185: 57 push %edi 186: 6a 00 push $0x0 188: e8 2d 01 00 00 call 2ba <read> if(cc < 1) 18d: 83 c4 10 add $0x10,%esp 190: 85 c0 test %eax,%eax 192: 7e 1d jle 1b1 <gets+0x41> break; buf[i++] = c; 194: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 198: 8b 55 08 mov 0x8(%ebp),%edx 19b: 89 de mov %ebx,%esi if(c == '\n' || c == '\r') 19d: 3c 0a cmp $0xa,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 19f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 1a3: 74 1b je 1c0 <gets+0x50> 1a5: 3c 0d cmp $0xd,%al 1a7: 74 17 je 1c0 <gets+0x50> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1a9: 8d 5e 01 lea 0x1(%esi),%ebx 1ac: 3b 5d 0c cmp 0xc(%ebp),%ebx 1af: 7c cf jl 180 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1b1: 8b 45 08 mov 0x8(%ebp),%eax 1b4: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 1b8: 8d 65 f4 lea -0xc(%ebp),%esp 1bb: 5b pop %ebx 1bc: 5e pop %esi 1bd: 5f pop %edi 1be: 5d pop %ebp 1bf: c3 ret break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1c0: 8b 45 08 mov 0x8(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1c3: 89 de mov %ebx,%esi break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1c5: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 1c9: 8d 65 f4 lea -0xc(%ebp),%esp 1cc: 5b pop %ebx 1cd: 5e pop %esi 1ce: 5f pop %edi 1cf: 5d pop %ebp 1d0: c3 ret 1d1: eb 0d jmp 1e0 <stat> 1d3: 90 nop 1d4: 90 nop 1d5: 90 nop 1d6: 90 nop 1d7: 90 nop 1d8: 90 nop 1d9: 90 nop 1da: 90 nop 1db: 90 nop 1dc: 90 nop 1dd: 90 nop 1de: 90 nop 1df: 90 nop 000001e0 <stat>: int stat(const char *n, struct stat *st) { 1e0: 55 push %ebp 1e1: 89 e5 mov %esp,%ebp 1e3: 56 push %esi 1e4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 1e5: 83 ec 08 sub $0x8,%esp 1e8: 6a 00 push $0x0 1ea: ff 75 08 pushl 0x8(%ebp) 1ed: e8 f0 00 00 00 call 2e2 <open> if(fd < 0) 1f2: 83 c4 10 add $0x10,%esp 1f5: 85 c0 test %eax,%eax 1f7: 78 27 js 220 <stat+0x40> return -1; r = fstat(fd, st); 1f9: 83 ec 08 sub $0x8,%esp 1fc: ff 75 0c pushl 0xc(%ebp) 1ff: 89 c3 mov %eax,%ebx 201: 50 push %eax 202: e8 f3 00 00 00 call 2fa <fstat> 207: 89 c6 mov %eax,%esi close(fd); 209: 89 1c 24 mov %ebx,(%esp) 20c: e8 b9 00 00 00 call 2ca <close> return r; 211: 83 c4 10 add $0x10,%esp 214: 89 f0 mov %esi,%eax } 216: 8d 65 f8 lea -0x8(%ebp),%esp 219: 5b pop %ebx 21a: 5e pop %esi 21b: 5d pop %ebp 21c: c3 ret 21d: 8d 76 00 lea 0x0(%esi),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 220: b8 ff ff ff ff mov $0xffffffff,%eax 225: eb ef jmp 216 <stat+0x36> 227: 89 f6 mov %esi,%esi 229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000230 <atoi>: return r; } int atoi(const char *s) { 230: 55 push %ebp 231: 89 e5 mov %esp,%ebp 233: 53 push %ebx 234: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 237: 0f be 11 movsbl (%ecx),%edx 23a: 8d 42 d0 lea -0x30(%edx),%eax 23d: 3c 09 cmp $0x9,%al 23f: b8 00 00 00 00 mov $0x0,%eax 244: 77 1f ja 265 <atoi+0x35> 246: 8d 76 00 lea 0x0(%esi),%esi 249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 250: 8d 04 80 lea (%eax,%eax,4),%eax 253: 83 c1 01 add $0x1,%ecx 256: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 25a: 0f be 11 movsbl (%ecx),%edx 25d: 8d 5a d0 lea -0x30(%edx),%ebx 260: 80 fb 09 cmp $0x9,%bl 263: 76 eb jbe 250 <atoi+0x20> n = n*10 + *s++ - '0'; return n; } 265: 5b pop %ebx 266: 5d pop %ebp 267: c3 ret 268: 90 nop 269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000270 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 270: 55 push %ebp 271: 89 e5 mov %esp,%ebp 273: 56 push %esi 274: 53 push %ebx 275: 8b 5d 10 mov 0x10(%ebp),%ebx 278: 8b 45 08 mov 0x8(%ebp),%eax 27b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 27e: 85 db test %ebx,%ebx 280: 7e 14 jle 296 <memmove+0x26> 282: 31 d2 xor %edx,%edx 284: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 288: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 28c: 88 0c 10 mov %cl,(%eax,%edx,1) 28f: 83 c2 01 add $0x1,%edx char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 292: 39 da cmp %ebx,%edx 294: 75 f2 jne 288 <memmove+0x18> *dst++ = *src++; return vdst; } 296: 5b pop %ebx 297: 5e pop %esi 298: 5d pop %ebp 299: c3 ret 0000029a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 29a: b8 01 00 00 00 mov $0x1,%eax 29f: cd 40 int $0x40 2a1: c3 ret 000002a2 <exit>: SYSCALL(exit) 2a2: b8 02 00 00 00 mov $0x2,%eax 2a7: cd 40 int $0x40 2a9: c3 ret 000002aa <wait>: SYSCALL(wait) 2aa: b8 03 00 00 00 mov $0x3,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <pipe>: SYSCALL(pipe) 2b2: b8 04 00 00 00 mov $0x4,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <read>: SYSCALL(read) 2ba: b8 05 00 00 00 mov $0x5,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <write>: SYSCALL(write) 2c2: b8 10 00 00 00 mov $0x10,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <close>: SYSCALL(close) 2ca: b8 15 00 00 00 mov $0x15,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <kill>: SYSCALL(kill) 2d2: b8 06 00 00 00 mov $0x6,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <exec>: SYSCALL(exec) 2da: b8 07 00 00 00 mov $0x7,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <open>: SYSCALL(open) 2e2: b8 0f 00 00 00 mov $0xf,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <mknod>: SYSCALL(mknod) 2ea: b8 11 00 00 00 mov $0x11,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <unlink>: SYSCALL(unlink) 2f2: b8 12 00 00 00 mov $0x12,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <fstat>: SYSCALL(fstat) 2fa: b8 08 00 00 00 mov $0x8,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <link>: SYSCALL(link) 302: b8 13 00 00 00 mov $0x13,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <mkdir>: SYSCALL(mkdir) 30a: b8 14 00 00 00 mov $0x14,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <chdir>: SYSCALL(chdir) 312: b8 09 00 00 00 mov $0x9,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <dup>: SYSCALL(dup) 31a: b8 0a 00 00 00 mov $0xa,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <getpid>: SYSCALL(getpid) 322: b8 0b 00 00 00 mov $0xb,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <sbrk>: SYSCALL(sbrk) 32a: b8 0c 00 00 00 mov $0xc,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <sleep>: SYSCALL(sleep) 332: b8 0d 00 00 00 mov $0xd,%eax 337: cd 40 int $0x40 339: c3 ret 0000033a <uptime>: SYSCALL(uptime) 33a: b8 0e 00 00 00 mov $0xe,%eax 33f: cd 40 int $0x40 341: c3 ret 342: 66 90 xchg %ax,%ax 344: 66 90 xchg %ax,%ax 346: 66 90 xchg %ax,%ax 348: 66 90 xchg %ax,%ax 34a: 66 90 xchg %ax,%ax 34c: 66 90 xchg %ax,%ax 34e: 66 90 xchg %ax,%ax 00000350 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 350: 55 push %ebp 351: 89 e5 mov %esp,%ebp 353: 57 push %edi 354: 56 push %esi 355: 53 push %ebx 356: 89 c6 mov %eax,%esi 358: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 35b: 8b 5d 08 mov 0x8(%ebp),%ebx 35e: 85 db test %ebx,%ebx 360: 74 7e je 3e0 <printint+0x90> 362: 89 d0 mov %edx,%eax 364: c1 e8 1f shr $0x1f,%eax 367: 84 c0 test %al,%al 369: 74 75 je 3e0 <printint+0x90> neg = 1; x = -xx; 36b: 89 d0 mov %edx,%eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 36d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) x = -xx; 374: f7 d8 neg %eax 376: 89 75 c0 mov %esi,-0x40(%ebp) } else { x = xx; } i = 0; 379: 31 ff xor %edi,%edi 37b: 8d 5d d7 lea -0x29(%ebp),%ebx 37e: 89 ce mov %ecx,%esi 380: eb 08 jmp 38a <printint+0x3a> 382: 8d b6 00 00 00 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 388: 89 cf mov %ecx,%edi 38a: 31 d2 xor %edx,%edx 38c: 8d 4f 01 lea 0x1(%edi),%ecx 38f: f7 f6 div %esi 391: 0f b6 92 40 07 00 00 movzbl 0x740(%edx),%edx }while((x /= base) != 0); 398: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 39a: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 39d: 75 e9 jne 388 <printint+0x38> if(neg) 39f: 8b 45 c4 mov -0x3c(%ebp),%eax 3a2: 8b 75 c0 mov -0x40(%ebp),%esi 3a5: 85 c0 test %eax,%eax 3a7: 74 08 je 3b1 <printint+0x61> buf[i++] = '-'; 3a9: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1) 3ae: 8d 4f 02 lea 0x2(%edi),%ecx 3b1: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi 3b5: 8d 76 00 lea 0x0(%esi),%esi 3b8: 0f b6 07 movzbl (%edi),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 3bb: 83 ec 04 sub $0x4,%esp 3be: 83 ef 01 sub $0x1,%edi 3c1: 6a 01 push $0x1 3c3: 53 push %ebx 3c4: 56 push %esi 3c5: 88 45 d7 mov %al,-0x29(%ebp) 3c8: e8 f5 fe ff ff call 2c2 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 3cd: 83 c4 10 add $0x10,%esp 3d0: 39 df cmp %ebx,%edi 3d2: 75 e4 jne 3b8 <printint+0x68> putc(fd, buf[i]); } 3d4: 8d 65 f4 lea -0xc(%ebp),%esp 3d7: 5b pop %ebx 3d8: 5e pop %esi 3d9: 5f pop %edi 3da: 5d pop %ebp 3db: c3 ret 3dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; } else { x = xx; 3e0: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 3e2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 3e9: eb 8b jmp 376 <printint+0x26> 3eb: 90 nop 3ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000003f0 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3f0: 55 push %ebp 3f1: 89 e5 mov %esp,%ebp 3f3: 57 push %edi 3f4: 56 push %esi 3f5: 53 push %ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3f6: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3f9: 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++){ 3fc: 8b 75 0c mov 0xc(%ebp),%esi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3ff: 8b 7d 08 mov 0x8(%ebp),%edi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 402: 89 45 d0 mov %eax,-0x30(%ebp) 405: 0f b6 1e movzbl (%esi),%ebx 408: 83 c6 01 add $0x1,%esi 40b: 84 db test %bl,%bl 40d: 0f 84 b0 00 00 00 je 4c3 <printf+0xd3> 413: 31 d2 xor %edx,%edx 415: eb 39 jmp 450 <printf+0x60> 417: 89 f6 mov %esi,%esi 419: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 420: 83 f8 25 cmp $0x25,%eax 423: 89 55 d4 mov %edx,-0x2c(%ebp) state = '%'; 426: ba 25 00 00 00 mov $0x25,%edx state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 42b: 74 18 je 445 <printf+0x55> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 42d: 8d 45 e2 lea -0x1e(%ebp),%eax 430: 83 ec 04 sub $0x4,%esp 433: 88 5d e2 mov %bl,-0x1e(%ebp) 436: 6a 01 push $0x1 438: 50 push %eax 439: 57 push %edi 43a: e8 83 fe ff ff call 2c2 <write> 43f: 8b 55 d4 mov -0x2c(%ebp),%edx 442: 83 c4 10 add $0x10,%esp 445: 83 c6 01 add $0x1,%esi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 448: 0f b6 5e ff movzbl -0x1(%esi),%ebx 44c: 84 db test %bl,%bl 44e: 74 73 je 4c3 <printf+0xd3> c = fmt[i] & 0xff; if(state == 0){ 450: 85 d2 test %edx,%edx uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 452: 0f be cb movsbl %bl,%ecx 455: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 458: 74 c6 je 420 <printf+0x30> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 45a: 83 fa 25 cmp $0x25,%edx 45d: 75 e6 jne 445 <printf+0x55> if(c == 'd'){ 45f: 83 f8 64 cmp $0x64,%eax 462: 0f 84 f8 00 00 00 je 560 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 468: 81 e1 f7 00 00 00 and $0xf7,%ecx 46e: 83 f9 70 cmp $0x70,%ecx 471: 74 5d je 4d0 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 473: 83 f8 73 cmp $0x73,%eax 476: 0f 84 84 00 00 00 je 500 <printf+0x110> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 47c: 83 f8 63 cmp $0x63,%eax 47f: 0f 84 ea 00 00 00 je 56f <printf+0x17f> putc(fd, *ap); ap++; } else if(c == '%'){ 485: 83 f8 25 cmp $0x25,%eax 488: 0f 84 c2 00 00 00 je 550 <printf+0x160> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 48e: 8d 45 e7 lea -0x19(%ebp),%eax 491: 83 ec 04 sub $0x4,%esp 494: c6 45 e7 25 movb $0x25,-0x19(%ebp) 498: 6a 01 push $0x1 49a: 50 push %eax 49b: 57 push %edi 49c: e8 21 fe ff ff call 2c2 <write> 4a1: 83 c4 0c add $0xc,%esp 4a4: 8d 45 e6 lea -0x1a(%ebp),%eax 4a7: 88 5d e6 mov %bl,-0x1a(%ebp) 4aa: 6a 01 push $0x1 4ac: 50 push %eax 4ad: 57 push %edi 4ae: 83 c6 01 add $0x1,%esi 4b1: e8 0c fe ff ff call 2c2 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4b6: 0f b6 5e ff movzbl -0x1(%esi),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4ba: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4bd: 31 d2 xor %edx,%edx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4bf: 84 db test %bl,%bl 4c1: 75 8d jne 450 <printf+0x60> putc(fd, c); } state = 0; } } } 4c3: 8d 65 f4 lea -0xc(%ebp),%esp 4c6: 5b pop %ebx 4c7: 5e pop %esi 4c8: 5f pop %edi 4c9: 5d pop %ebp 4ca: c3 ret 4cb: 90 nop 4cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 4d0: 83 ec 0c sub $0xc,%esp 4d3: b9 10 00 00 00 mov $0x10,%ecx 4d8: 6a 00 push $0x0 4da: 8b 5d d0 mov -0x30(%ebp),%ebx 4dd: 89 f8 mov %edi,%eax 4df: 8b 13 mov (%ebx),%edx 4e1: e8 6a fe ff ff call 350 <printint> ap++; 4e6: 89 d8 mov %ebx,%eax 4e8: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4eb: 31 d2 xor %edx,%edx if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; 4ed: 83 c0 04 add $0x4,%eax 4f0: 89 45 d0 mov %eax,-0x30(%ebp) 4f3: e9 4d ff ff ff jmp 445 <printf+0x55> 4f8: 90 nop 4f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 500: 8b 45 d0 mov -0x30(%ebp),%eax 503: 8b 18 mov (%eax),%ebx ap++; 505: 83 c0 04 add $0x4,%eax 508: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) s = "(null)"; 50b: b8 37 07 00 00 mov $0x737,%eax 510: 85 db test %ebx,%ebx 512: 0f 44 d8 cmove %eax,%ebx while(*s != 0){ 515: 0f b6 03 movzbl (%ebx),%eax 518: 84 c0 test %al,%al 51a: 74 23 je 53f <printf+0x14f> 51c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 520: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 523: 8d 45 e3 lea -0x1d(%ebp),%eax 526: 83 ec 04 sub $0x4,%esp 529: 6a 01 push $0x1 ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 52b: 83 c3 01 add $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 52e: 50 push %eax 52f: 57 push %edi 530: e8 8d fd ff ff call 2c2 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 535: 0f b6 03 movzbl (%ebx),%eax 538: 83 c4 10 add $0x10,%esp 53b: 84 c0 test %al,%al 53d: 75 e1 jne 520 <printf+0x130> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 53f: 31 d2 xor %edx,%edx 541: e9 ff fe ff ff jmp 445 <printf+0x55> 546: 8d 76 00 lea 0x0(%esi),%esi 549: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 550: 83 ec 04 sub $0x4,%esp 553: 88 5d e5 mov %bl,-0x1b(%ebp) 556: 8d 45 e5 lea -0x1b(%ebp),%eax 559: 6a 01 push $0x1 55b: e9 4c ff ff ff jmp 4ac <printf+0xbc> } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 560: 83 ec 0c sub $0xc,%esp 563: b9 0a 00 00 00 mov $0xa,%ecx 568: 6a 01 push $0x1 56a: e9 6b ff ff ff jmp 4da <printf+0xea> 56f: 8b 5d d0 mov -0x30(%ebp),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 572: 83 ec 04 sub $0x4,%esp 575: 8b 03 mov (%ebx),%eax 577: 6a 01 push $0x1 579: 88 45 e4 mov %al,-0x1c(%ebp) 57c: 8d 45 e4 lea -0x1c(%ebp),%eax 57f: 50 push %eax 580: 57 push %edi 581: e8 3c fd ff ff call 2c2 <write> 586: e9 5b ff ff ff jmp 4e6 <printf+0xf6> 58b: 66 90 xchg %ax,%ax 58d: 66 90 xchg %ax,%ax 58f: 90 nop 00000590 <free>: static Header base; static Header *freep; void free(void *ap) { 590: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 591: a1 dc 09 00 00 mov 0x9dc,%eax static Header base; static Header *freep; void free(void *ap) { 596: 89 e5 mov %esp,%ebp 598: 57 push %edi 599: 56 push %esi 59a: 53 push %ebx 59b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 59e: 8b 10 mov (%eax),%edx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 5a0: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5a3: 39 c8 cmp %ecx,%eax 5a5: 73 19 jae 5c0 <free+0x30> 5a7: 89 f6 mov %esi,%esi 5a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 5b0: 39 d1 cmp %edx,%ecx 5b2: 72 1c jb 5d0 <free+0x40> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5b4: 39 d0 cmp %edx,%eax 5b6: 73 18 jae 5d0 <free+0x40> static Header base; static Header *freep; void free(void *ap) { 5b8: 89 d0 mov %edx,%eax Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5ba: 39 c8 cmp %ecx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5bc: 8b 10 mov (%eax),%edx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5be: 72 f0 jb 5b0 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5c0: 39 d0 cmp %edx,%eax 5c2: 72 f4 jb 5b8 <free+0x28> 5c4: 39 d1 cmp %edx,%ecx 5c6: 73 f0 jae 5b8 <free+0x28> 5c8: 90 nop 5c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; if(bp + bp->s.size == p->s.ptr){ 5d0: 8b 73 fc mov -0x4(%ebx),%esi 5d3: 8d 3c f1 lea (%ecx,%esi,8),%edi 5d6: 39 d7 cmp %edx,%edi 5d8: 74 19 je 5f3 <free+0x63> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 5da: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 5dd: 8b 50 04 mov 0x4(%eax),%edx 5e0: 8d 34 d0 lea (%eax,%edx,8),%esi 5e3: 39 f1 cmp %esi,%ecx 5e5: 74 23 je 60a <free+0x7a> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 5e7: 89 08 mov %ecx,(%eax) freep = p; 5e9: a3 dc 09 00 00 mov %eax,0x9dc } 5ee: 5b pop %ebx 5ef: 5e pop %esi 5f0: 5f pop %edi 5f1: 5d pop %ebp 5f2: c3 ret bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 5f3: 03 72 04 add 0x4(%edx),%esi 5f6: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 5f9: 8b 10 mov (%eax),%edx 5fb: 8b 12 mov (%edx),%edx 5fd: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 600: 8b 50 04 mov 0x4(%eax),%edx 603: 8d 34 d0 lea (%eax,%edx,8),%esi 606: 39 f1 cmp %esi,%ecx 608: 75 dd jne 5e7 <free+0x57> p->s.size += bp->s.size; 60a: 03 53 fc add -0x4(%ebx),%edx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 60d: a3 dc 09 00 00 mov %eax,0x9dc bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 612: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 615: 8b 53 f8 mov -0x8(%ebx),%edx 618: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 61a: 5b pop %ebx 61b: 5e pop %esi 61c: 5f pop %edi 61d: 5d pop %ebp 61e: c3 ret 61f: 90 nop 00000620 <malloc>: return freep; } void* malloc(uint nbytes) { 620: 55 push %ebp 621: 89 e5 mov %esp,%ebp 623: 57 push %edi 624: 56 push %esi 625: 53 push %ebx 626: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 629: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 62c: 8b 15 dc 09 00 00 mov 0x9dc,%edx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 632: 8d 78 07 lea 0x7(%eax),%edi 635: c1 ef 03 shr $0x3,%edi 638: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 63b: 85 d2 test %edx,%edx 63d: 0f 84 a3 00 00 00 je 6e6 <malloc+0xc6> 643: 8b 02 mov (%edx),%eax 645: 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){ 648: 39 cf cmp %ecx,%edi 64a: 76 74 jbe 6c0 <malloc+0xa0> 64c: 81 ff 00 10 00 00 cmp $0x1000,%edi 652: be 00 10 00 00 mov $0x1000,%esi 657: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx 65e: 0f 43 f7 cmovae %edi,%esi 661: ba 00 80 00 00 mov $0x8000,%edx 666: 81 ff ff 0f 00 00 cmp $0xfff,%edi 66c: 0f 46 da cmovbe %edx,%ebx 66f: eb 10 jmp 681 <malloc+0x61> 671: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 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){ 678: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 67a: 8b 48 04 mov 0x4(%eax),%ecx 67d: 39 cf cmp %ecx,%edi 67f: 76 3f jbe 6c0 <malloc+0xa0> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 681: 39 05 dc 09 00 00 cmp %eax,0x9dc 687: 89 c2 mov %eax,%edx 689: 75 ed jne 678 <malloc+0x58> char *p; Header *hp; if(nu < 4096) nu = 4096; p = sbrk(nu * sizeof(Header)); 68b: 83 ec 0c sub $0xc,%esp 68e: 53 push %ebx 68f: e8 96 fc ff ff call 32a <sbrk> if(p == (char*)-1) 694: 83 c4 10 add $0x10,%esp 697: 83 f8 ff cmp $0xffffffff,%eax 69a: 74 1c je 6b8 <malloc+0x98> return 0; hp = (Header*)p; hp->s.size = nu; 69c: 89 70 04 mov %esi,0x4(%eax) free((void*)(hp + 1)); 69f: 83 ec 0c sub $0xc,%esp 6a2: 83 c0 08 add $0x8,%eax 6a5: 50 push %eax 6a6: e8 e5 fe ff ff call 590 <free> return freep; 6ab: 8b 15 dc 09 00 00 mov 0x9dc,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 6b1: 83 c4 10 add $0x10,%esp 6b4: 85 d2 test %edx,%edx 6b6: 75 c0 jne 678 <malloc+0x58> return 0; 6b8: 31 c0 xor %eax,%eax 6ba: eb 1c jmp 6d8 <malloc+0xb8> 6bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 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){ if(p->s.size == nunits) 6c0: 39 cf cmp %ecx,%edi 6c2: 74 1c je 6e0 <malloc+0xc0> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 6c4: 29 f9 sub %edi,%ecx 6c6: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 6c9: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 6cc: 89 78 04 mov %edi,0x4(%eax) } freep = prevp; 6cf: 89 15 dc 09 00 00 mov %edx,0x9dc return (void*)(p + 1); 6d5: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 6d8: 8d 65 f4 lea -0xc(%ebp),%esp 6db: 5b pop %ebx 6dc: 5e pop %esi 6dd: 5f pop %edi 6de: 5d pop %ebp 6df: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 6e0: 8b 08 mov (%eax),%ecx 6e2: 89 0a mov %ecx,(%edx) 6e4: eb e9 jmp 6cf <malloc+0xaf> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 6e6: c7 05 dc 09 00 00 e0 movl $0x9e0,0x9dc 6ed: 09 00 00 6f0: c7 05 e0 09 00 00 e0 movl $0x9e0,0x9e0 6f7: 09 00 00 base.s.size = 0; 6fa: b8 e0 09 00 00 mov $0x9e0,%eax 6ff: c7 05 e4 09 00 00 00 movl $0x0,0x9e4 706: 00 00 00 709: e9 3e ff ff ff jmp 64c <malloc+0x2c>
/* * Copyright Copyright 2012, System Insights, Inc. * * 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. */ #ifndef CHECKPOINT_HPP #define CHECKPOINT_HPP #include "component_event.hpp" #include <map> #include <string> #include <vector> #include <set> #include <dlib/array.h> class Checkpoint { public: Checkpoint(); Checkpoint(Checkpoint &aCheckpoint, std::set<std::string> *aFilter = NULL); ~Checkpoint(); void addComponentEvent(ComponentEvent *aEvent); void copy(Checkpoint &aCheckpoint, std::set<std::string> *aFilter = NULL); void clear(); void filter(std::set<std::string> &aFilter); std::map<std::string, ComponentEventPtr*> &getEvents() { return mEvents; } void getComponentEvents(ComponentEventPtrArray &list, std::set<std::string> *aFilter = NULL); ComponentEventPtr *getEventPtr(std::string anId) { return mEvents[anId]; } protected: std::map<std::string, ComponentEventPtr*> mEvents; std::set<std::string> mFilter; bool mHasFilter; }; #endif
; A316297: a(n) = n! times the denominator of the n-th harmonic number H(n). ; Submitted by Jon Maiga ; 1,4,36,288,7200,14400,705600,11289600,914457600,9144576000,1106493696000,13277924352000,2243969215488000,31415569016832000,471233535252480000,15079473128079360000,4357967734014935040000,26147806404089610240000 mov $1,1 lpb $0 mov $2,$0 add $3,$1 mul $3,$0 sub $0,1 add $2,1 mul $1,$2 lpe pow $1,2 gcd $3,$1 div $1,$3 mov $0,$1
include xlibproc.inc include Wintab.inc PROC_TEMPLATE WTMgrOpen, 2, Wintab, -, 100
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s namespace PR10622 { struct foo { const int first; foo(const foo&) = default; }; void find_or_insert(const foo& __obj) { foo x(__obj); } struct bar : foo { bar(const bar&) = default; }; void test_bar(const bar &obj) { bar obj2(obj); } } namespace PR11418 { template<typename T> T may_throw() { return T(); } template<typename T> T &&declval() noexcept; struct NonPOD { NonPOD(); NonPOD(const NonPOD &) noexcept; NonPOD(NonPOD &&) noexcept; }; struct X { NonPOD np = may_throw<NonPOD>(); }; static_assert(noexcept(declval<X>()), "noexcept isn't working at all"); static_assert(noexcept(X(declval<X&>())), "copy constructor can't throw"); static_assert(noexcept(X(declval<X>())), "move constructor can't throw"); }
db 0 ; species ID placeholder db 68, 65, 65, 80, 125, 115 ; hp atk def spd sat sdf db PSYCHIC, PSYCHIC ; type db 45 ; catch rate db 208 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 20 ; step cycles to hatch INCBIN "gfx/pokemon/gardevoir/front.dimensions" db GROWTH_SLOW ; growth rate dn EGG_INDETERMINATE, EGG_INDETERMINATE ; egg groups db 35 ; happiness ; tm/hm learnset tmhm CALM_MIND, TOXIC, HIDDEN_POWER, SUNNY_DAY, TAUNT, HYPER_BEAM, LIGHT_SCREEN, PROTECT, RAIN_DANCE, SAFEGUARD, FRUSTRATION, THUNDERBOLT, RETURN, PSYCHIC_M, SHADOW_BALL, DOUBLE_TEAM, REFLECT, SHOCK_WAVE, TORMENT, FACADE, SECRET_POWER, REST, ATTRACT, THIEF, SKILL_SWAP, SNATCH, FOCUS_BLAST, ENERGY_BALL, FLING, CHARGE_BEAM, ENDURE, RECYCLE, GIGA_IMPACT, FLASH, THUNDER_WAVE, PSYCH_UP, CAPTIVATE, SLEEP_TALK, NATURAL_GIFT, DREAM_EATER, GRASS_KNOT, SWAGGER, SUBSTITUTE, TRICK_ROOM, FIRE_PUNCH, HELPING_HAND, ICE_PUNCH, ICY_WIND, MUD_SLAP, SIGNAL_BEAM, SNORE, SWIFT, THUNDERPUNCH, TRICK, ZEN_HEADBUTT ; end
_zombie: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(void) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 04 sub $0x4,%esp if(fork() > 0) 11: e8 64 02 00 00 call 27a <fork> 16: 85 c0 test %eax,%eax 18: 7e 0d jle 27 <main+0x27> sleep(5); // Let child exit before parent. 1a: 83 ec 0c sub $0xc,%esp 1d: 6a 05 push $0x5 1f: e8 ee 02 00 00 call 312 <sleep> 24: 83 c4 10 add $0x10,%esp exit(); 27: e8 56 02 00 00 call 282 <exit> 2c: 66 90 xchg %ax,%ax 2e: 66 90 xchg %ax,%ax 00000030 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 30: 55 push %ebp 31: 89 e5 mov %esp,%ebp 33: 53 push %ebx 34: 8b 45 08 mov 0x8(%ebp),%eax 37: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 3a: 89 c2 mov %eax,%edx 3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 40: 83 c1 01 add $0x1,%ecx 43: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 47: 83 c2 01 add $0x1,%edx 4a: 84 db test %bl,%bl 4c: 88 5a ff mov %bl,-0x1(%edx) 4f: 75 ef jne 40 <strcpy+0x10> ; return os; } 51: 5b pop %ebx 52: 5d pop %ebp 53: c3 ret 54: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 5a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000060 <strcmp>: int strcmp(const char *p, const char *q) { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp 63: 53 push %ebx 64: 8b 55 08 mov 0x8(%ebp),%edx 67: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 6a: 0f b6 02 movzbl (%edx),%eax 6d: 0f b6 19 movzbl (%ecx),%ebx 70: 84 c0 test %al,%al 72: 75 1c jne 90 <strcmp+0x30> 74: eb 2a jmp a0 <strcmp+0x40> 76: 8d 76 00 lea 0x0(%esi),%esi 79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 80: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 83: 0f b6 02 movzbl (%edx),%eax p++, q++; 86: 83 c1 01 add $0x1,%ecx 89: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) 8c: 84 c0 test %al,%al 8e: 74 10 je a0 <strcmp+0x40> 90: 38 d8 cmp %bl,%al 92: 74 ec je 80 <strcmp+0x20> return (uchar)*p - (uchar)*q; 94: 29 d8 sub %ebx,%eax } 96: 5b pop %ebx 97: 5d pop %ebp 98: c3 ret 99: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi a0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; a2: 29 d8 sub %ebx,%eax } a4: 5b pop %ebx a5: 5d pop %ebp a6: c3 ret a7: 89 f6 mov %esi,%esi a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000000b0 <strlen>: uint strlen(const char *s) { b0: 55 push %ebp b1: 89 e5 mov %esp,%ebp b3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) b6: 80 39 00 cmpb $0x0,(%ecx) b9: 74 15 je d0 <strlen+0x20> bb: 31 d2 xor %edx,%edx bd: 8d 76 00 lea 0x0(%esi),%esi c0: 83 c2 01 add $0x1,%edx c3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) c7: 89 d0 mov %edx,%eax c9: 75 f5 jne c0 <strlen+0x10> ; return n; } cb: 5d pop %ebp cc: c3 ret cd: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) d0: 31 c0 xor %eax,%eax } d2: 5d pop %ebp d3: c3 ret d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000000e0 <memset>: void* memset(void *dst, int c, uint n) { e0: 55 push %ebp e1: 89 e5 mov %esp,%ebp e3: 57 push %edi e4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : e7: 8b 4d 10 mov 0x10(%ebp),%ecx ea: 8b 45 0c mov 0xc(%ebp),%eax ed: 89 d7 mov %edx,%edi ef: fc cld f0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } f2: 89 d0 mov %edx,%eax f4: 5f pop %edi f5: 5d pop %ebp f6: c3 ret f7: 89 f6 mov %esi,%esi f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000100 <strchr>: char* strchr(const char *s, char c) { 100: 55 push %ebp 101: 89 e5 mov %esp,%ebp 103: 53 push %ebx 104: 8b 45 08 mov 0x8(%ebp),%eax 107: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 10a: 0f b6 10 movzbl (%eax),%edx 10d: 84 d2 test %dl,%dl 10f: 74 1d je 12e <strchr+0x2e> if(*s == c) 111: 38 d3 cmp %dl,%bl 113: 89 d9 mov %ebx,%ecx 115: 75 0d jne 124 <strchr+0x24> 117: eb 17 jmp 130 <strchr+0x30> 119: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 120: 38 ca cmp %cl,%dl 122: 74 0c je 130 <strchr+0x30> for(; *s; s++) 124: 83 c0 01 add $0x1,%eax 127: 0f b6 10 movzbl (%eax),%edx 12a: 84 d2 test %dl,%dl 12c: 75 f2 jne 120 <strchr+0x20> return (char*)s; return 0; 12e: 31 c0 xor %eax,%eax } 130: 5b pop %ebx 131: 5d pop %ebp 132: c3 ret 133: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000140 <gets>: char* gets(char *buf, int max) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 57 push %edi 144: 56 push %esi 145: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 146: 31 f6 xor %esi,%esi 148: 89 f3 mov %esi,%ebx { 14a: 83 ec 1c sub $0x1c,%esp 14d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 150: eb 2f jmp 181 <gets+0x41> 152: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 158: 8d 45 e7 lea -0x19(%ebp),%eax 15b: 83 ec 04 sub $0x4,%esp 15e: 6a 01 push $0x1 160: 50 push %eax 161: 6a 00 push $0x0 163: e8 32 01 00 00 call 29a <read> if(cc < 1) 168: 83 c4 10 add $0x10,%esp 16b: 85 c0 test %eax,%eax 16d: 7e 1c jle 18b <gets+0x4b> break; buf[i++] = c; 16f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 173: 83 c7 01 add $0x1,%edi 176: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 179: 3c 0a cmp $0xa,%al 17b: 74 23 je 1a0 <gets+0x60> 17d: 3c 0d cmp $0xd,%al 17f: 74 1f je 1a0 <gets+0x60> for(i=0; i+1 < max; ){ 181: 83 c3 01 add $0x1,%ebx 184: 3b 5d 0c cmp 0xc(%ebp),%ebx 187: 89 fe mov %edi,%esi 189: 7c cd jl 158 <gets+0x18> 18b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 18d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 190: c6 03 00 movb $0x0,(%ebx) } 193: 8d 65 f4 lea -0xc(%ebp),%esp 196: 5b pop %ebx 197: 5e pop %esi 198: 5f pop %edi 199: 5d pop %ebp 19a: c3 ret 19b: 90 nop 19c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1a0: 8b 75 08 mov 0x8(%ebp),%esi 1a3: 8b 45 08 mov 0x8(%ebp),%eax 1a6: 01 de add %ebx,%esi 1a8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 1aa: c6 03 00 movb $0x0,(%ebx) } 1ad: 8d 65 f4 lea -0xc(%ebp),%esp 1b0: 5b pop %ebx 1b1: 5e pop %esi 1b2: 5f pop %edi 1b3: 5d pop %ebp 1b4: c3 ret 1b5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001c0 <stat>: int stat(const char *n, struct stat *st) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 56 push %esi 1c4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 1c5: 83 ec 08 sub $0x8,%esp 1c8: 6a 00 push $0x0 1ca: ff 75 08 pushl 0x8(%ebp) 1cd: e8 f0 00 00 00 call 2c2 <open> if(fd < 0) 1d2: 83 c4 10 add $0x10,%esp 1d5: 85 c0 test %eax,%eax 1d7: 78 27 js 200 <stat+0x40> return -1; r = fstat(fd, st); 1d9: 83 ec 08 sub $0x8,%esp 1dc: ff 75 0c pushl 0xc(%ebp) 1df: 89 c3 mov %eax,%ebx 1e1: 50 push %eax 1e2: e8 f3 00 00 00 call 2da <fstat> close(fd); 1e7: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 1ea: 89 c6 mov %eax,%esi close(fd); 1ec: e8 b9 00 00 00 call 2aa <close> return r; 1f1: 83 c4 10 add $0x10,%esp } 1f4: 8d 65 f8 lea -0x8(%ebp),%esp 1f7: 89 f0 mov %esi,%eax 1f9: 5b pop %ebx 1fa: 5e pop %esi 1fb: 5d pop %ebp 1fc: c3 ret 1fd: 8d 76 00 lea 0x0(%esi),%esi return -1; 200: be ff ff ff ff mov $0xffffffff,%esi 205: eb ed jmp 1f4 <stat+0x34> 207: 89 f6 mov %esi,%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000210 <atoi>: int atoi(const char *s) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 53 push %ebx 214: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 217: 0f be 11 movsbl (%ecx),%edx 21a: 8d 42 d0 lea -0x30(%edx),%eax 21d: 3c 09 cmp $0x9,%al n = 0; 21f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 224: 77 1f ja 245 <atoi+0x35> 226: 8d 76 00 lea 0x0(%esi),%esi 229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 230: 8d 04 80 lea (%eax,%eax,4),%eax 233: 83 c1 01 add $0x1,%ecx 236: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 23a: 0f be 11 movsbl (%ecx),%edx 23d: 8d 5a d0 lea -0x30(%edx),%ebx 240: 80 fb 09 cmp $0x9,%bl 243: 76 eb jbe 230 <atoi+0x20> return n; } 245: 5b pop %ebx 246: 5d pop %ebp 247: c3 ret 248: 90 nop 249: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000250 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 250: 55 push %ebp 251: 89 e5 mov %esp,%ebp 253: 56 push %esi 254: 53 push %ebx 255: 8b 5d 10 mov 0x10(%ebp),%ebx 258: 8b 45 08 mov 0x8(%ebp),%eax 25b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 25e: 85 db test %ebx,%ebx 260: 7e 14 jle 276 <memmove+0x26> 262: 31 d2 xor %edx,%edx 264: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 268: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 26c: 88 0c 10 mov %cl,(%eax,%edx,1) 26f: 83 c2 01 add $0x1,%edx while(n-- > 0) 272: 39 d3 cmp %edx,%ebx 274: 75 f2 jne 268 <memmove+0x18> return vdst; } 276: 5b pop %ebx 277: 5e pop %esi 278: 5d pop %ebp 279: c3 ret 0000027a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 27a: b8 01 00 00 00 mov $0x1,%eax 27f: cd 40 int $0x40 281: c3 ret 00000282 <exit>: SYSCALL(exit) 282: b8 02 00 00 00 mov $0x2,%eax 287: cd 40 int $0x40 289: c3 ret 0000028a <wait>: SYSCALL(wait) 28a: b8 03 00 00 00 mov $0x3,%eax 28f: cd 40 int $0x40 291: c3 ret 00000292 <pipe>: SYSCALL(pipe) 292: b8 04 00 00 00 mov $0x4,%eax 297: cd 40 int $0x40 299: c3 ret 0000029a <read>: SYSCALL(read) 29a: b8 05 00 00 00 mov $0x5,%eax 29f: cd 40 int $0x40 2a1: c3 ret 000002a2 <write>: SYSCALL(write) 2a2: b8 10 00 00 00 mov $0x10,%eax 2a7: cd 40 int $0x40 2a9: c3 ret 000002aa <close>: SYSCALL(close) 2aa: b8 15 00 00 00 mov $0x15,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <kill>: SYSCALL(kill) 2b2: b8 06 00 00 00 mov $0x6,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <exec>: SYSCALL(exec) 2ba: b8 07 00 00 00 mov $0x7,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <open>: SYSCALL(open) 2c2: b8 0f 00 00 00 mov $0xf,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <mknod>: SYSCALL(mknod) 2ca: b8 11 00 00 00 mov $0x11,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <unlink>: SYSCALL(unlink) 2d2: b8 12 00 00 00 mov $0x12,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <fstat>: SYSCALL(fstat) 2da: b8 08 00 00 00 mov $0x8,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <link>: SYSCALL(link) 2e2: b8 13 00 00 00 mov $0x13,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <mkdir>: SYSCALL(mkdir) 2ea: b8 14 00 00 00 mov $0x14,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <chdir>: SYSCALL(chdir) 2f2: b8 09 00 00 00 mov $0x9,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <dup>: SYSCALL(dup) 2fa: b8 0a 00 00 00 mov $0xa,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <getpid>: SYSCALL(getpid) 302: b8 0b 00 00 00 mov $0xb,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <sbrk>: SYSCALL(sbrk) 30a: b8 0c 00 00 00 mov $0xc,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <sleep>: SYSCALL(sleep) 312: b8 0d 00 00 00 mov $0xd,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <uptime>: SYSCALL(uptime) 31a: b8 0e 00 00 00 mov $0xe,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <waitx>: SYSCALL(waitx) 322: b8 16 00 00 00 mov $0x16,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <psimp>: SYSCALL(psimp) 32a: b8 17 00 00 00 mov $0x17,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <set_priority>: SYSCALL(set_priority) 332: b8 18 00 00 00 mov $0x18,%eax 337: cd 40 int $0x40 339: c3 ret 33a: 66 90 xchg %ax,%ax 33c: 66 90 xchg %ax,%ax 33e: 66 90 xchg %ax,%ax 00000340 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 340: 55 push %ebp 341: 89 e5 mov %esp,%ebp 343: 57 push %edi 344: 56 push %esi 345: 53 push %ebx 346: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 349: 85 d2 test %edx,%edx { 34b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 34e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 350: 79 76 jns 3c8 <printint+0x88> 352: f6 45 08 01 testb $0x1,0x8(%ebp) 356: 74 70 je 3c8 <printint+0x88> x = -xx; 358: f7 d8 neg %eax neg = 1; 35a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 361: 31 f6 xor %esi,%esi 363: 8d 5d d7 lea -0x29(%ebp),%ebx 366: eb 0a jmp 372 <printint+0x32> 368: 90 nop 369: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 370: 89 fe mov %edi,%esi 372: 31 d2 xor %edx,%edx 374: 8d 7e 01 lea 0x1(%esi),%edi 377: f7 f1 div %ecx 379: 0f b6 92 40 07 00 00 movzbl 0x740(%edx),%edx }while((x /= base) != 0); 380: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 382: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 385: 75 e9 jne 370 <printint+0x30> if(neg) 387: 8b 45 c4 mov -0x3c(%ebp),%eax 38a: 85 c0 test %eax,%eax 38c: 74 08 je 396 <printint+0x56> buf[i++] = '-'; 38e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 393: 8d 7e 02 lea 0x2(%esi),%edi 396: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 39a: 8b 7d c0 mov -0x40(%ebp),%edi 39d: 8d 76 00 lea 0x0(%esi),%esi 3a0: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 3a3: 83 ec 04 sub $0x4,%esp 3a6: 83 ee 01 sub $0x1,%esi 3a9: 6a 01 push $0x1 3ab: 53 push %ebx 3ac: 57 push %edi 3ad: 88 45 d7 mov %al,-0x29(%ebp) 3b0: e8 ed fe ff ff call 2a2 <write> while(--i >= 0) 3b5: 83 c4 10 add $0x10,%esp 3b8: 39 de cmp %ebx,%esi 3ba: 75 e4 jne 3a0 <printint+0x60> putc(fd, buf[i]); } 3bc: 8d 65 f4 lea -0xc(%ebp),%esp 3bf: 5b pop %ebx 3c0: 5e pop %esi 3c1: 5f pop %edi 3c2: 5d pop %ebp 3c3: c3 ret 3c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 3c8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 3cf: eb 90 jmp 361 <printint+0x21> 3d1: eb 0d jmp 3e0 <printf> 3d3: 90 nop 3d4: 90 nop 3d5: 90 nop 3d6: 90 nop 3d7: 90 nop 3d8: 90 nop 3d9: 90 nop 3da: 90 nop 3db: 90 nop 3dc: 90 nop 3dd: 90 nop 3de: 90 nop 3df: 90 nop 000003e0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3e0: 55 push %ebp 3e1: 89 e5 mov %esp,%ebp 3e3: 57 push %edi 3e4: 56 push %esi 3e5: 53 push %ebx 3e6: 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++){ 3e9: 8b 75 0c mov 0xc(%ebp),%esi 3ec: 0f b6 1e movzbl (%esi),%ebx 3ef: 84 db test %bl,%bl 3f1: 0f 84 b3 00 00 00 je 4aa <printf+0xca> ap = (uint*)(void*)&fmt + 1; 3f7: 8d 45 10 lea 0x10(%ebp),%eax 3fa: 83 c6 01 add $0x1,%esi state = 0; 3fd: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 3ff: 89 45 d4 mov %eax,-0x2c(%ebp) 402: eb 2f jmp 433 <printf+0x53> 404: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 408: 83 f8 25 cmp $0x25,%eax 40b: 0f 84 a7 00 00 00 je 4b8 <printf+0xd8> write(fd, &c, 1); 411: 8d 45 e2 lea -0x1e(%ebp),%eax 414: 83 ec 04 sub $0x4,%esp 417: 88 5d e2 mov %bl,-0x1e(%ebp) 41a: 6a 01 push $0x1 41c: 50 push %eax 41d: ff 75 08 pushl 0x8(%ebp) 420: e8 7d fe ff ff call 2a2 <write> 425: 83 c4 10 add $0x10,%esp 428: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 42b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 42f: 84 db test %bl,%bl 431: 74 77 je 4aa <printf+0xca> if(state == 0){ 433: 85 ff test %edi,%edi c = fmt[i] & 0xff; 435: 0f be cb movsbl %bl,%ecx 438: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 43b: 74 cb je 408 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 43d: 83 ff 25 cmp $0x25,%edi 440: 75 e6 jne 428 <printf+0x48> if(c == 'd'){ 442: 83 f8 64 cmp $0x64,%eax 445: 0f 84 05 01 00 00 je 550 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 44b: 81 e1 f7 00 00 00 and $0xf7,%ecx 451: 83 f9 70 cmp $0x70,%ecx 454: 74 72 je 4c8 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 456: 83 f8 73 cmp $0x73,%eax 459: 0f 84 99 00 00 00 je 4f8 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 45f: 83 f8 63 cmp $0x63,%eax 462: 0f 84 08 01 00 00 je 570 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 468: 83 f8 25 cmp $0x25,%eax 46b: 0f 84 ef 00 00 00 je 560 <printf+0x180> write(fd, &c, 1); 471: 8d 45 e7 lea -0x19(%ebp),%eax 474: 83 ec 04 sub $0x4,%esp 477: c6 45 e7 25 movb $0x25,-0x19(%ebp) 47b: 6a 01 push $0x1 47d: 50 push %eax 47e: ff 75 08 pushl 0x8(%ebp) 481: e8 1c fe ff ff call 2a2 <write> 486: 83 c4 0c add $0xc,%esp 489: 8d 45 e6 lea -0x1a(%ebp),%eax 48c: 88 5d e6 mov %bl,-0x1a(%ebp) 48f: 6a 01 push $0x1 491: 50 push %eax 492: ff 75 08 pushl 0x8(%ebp) 495: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 498: 31 ff xor %edi,%edi write(fd, &c, 1); 49a: e8 03 fe ff ff call 2a2 <write> for(i = 0; fmt[i]; i++){ 49f: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 4a3: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 4a6: 84 db test %bl,%bl 4a8: 75 89 jne 433 <printf+0x53> } } } 4aa: 8d 65 f4 lea -0xc(%ebp),%esp 4ad: 5b pop %ebx 4ae: 5e pop %esi 4af: 5f pop %edi 4b0: 5d pop %ebp 4b1: c3 ret 4b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 4b8: bf 25 00 00 00 mov $0x25,%edi 4bd: e9 66 ff ff ff jmp 428 <printf+0x48> 4c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 4c8: 83 ec 0c sub $0xc,%esp 4cb: b9 10 00 00 00 mov $0x10,%ecx 4d0: 6a 00 push $0x0 4d2: 8b 7d d4 mov -0x2c(%ebp),%edi 4d5: 8b 45 08 mov 0x8(%ebp),%eax 4d8: 8b 17 mov (%edi),%edx 4da: e8 61 fe ff ff call 340 <printint> ap++; 4df: 89 f8 mov %edi,%eax 4e1: 83 c4 10 add $0x10,%esp state = 0; 4e4: 31 ff xor %edi,%edi ap++; 4e6: 83 c0 04 add $0x4,%eax 4e9: 89 45 d4 mov %eax,-0x2c(%ebp) 4ec: e9 37 ff ff ff jmp 428 <printf+0x48> 4f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 4f8: 8b 45 d4 mov -0x2c(%ebp),%eax 4fb: 8b 08 mov (%eax),%ecx ap++; 4fd: 83 c0 04 add $0x4,%eax 500: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 503: 85 c9 test %ecx,%ecx 505: 0f 84 8e 00 00 00 je 599 <printf+0x1b9> while(*s != 0){ 50b: 0f b6 01 movzbl (%ecx),%eax state = 0; 50e: 31 ff xor %edi,%edi s = (char*)*ap; 510: 89 cb mov %ecx,%ebx while(*s != 0){ 512: 84 c0 test %al,%al 514: 0f 84 0e ff ff ff je 428 <printf+0x48> 51a: 89 75 d0 mov %esi,-0x30(%ebp) 51d: 89 de mov %ebx,%esi 51f: 8b 5d 08 mov 0x8(%ebp),%ebx 522: 8d 7d e3 lea -0x1d(%ebp),%edi 525: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 528: 83 ec 04 sub $0x4,%esp s++; 52b: 83 c6 01 add $0x1,%esi 52e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 531: 6a 01 push $0x1 533: 57 push %edi 534: 53 push %ebx 535: e8 68 fd ff ff call 2a2 <write> while(*s != 0){ 53a: 0f b6 06 movzbl (%esi),%eax 53d: 83 c4 10 add $0x10,%esp 540: 84 c0 test %al,%al 542: 75 e4 jne 528 <printf+0x148> 544: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 547: 31 ff xor %edi,%edi 549: e9 da fe ff ff jmp 428 <printf+0x48> 54e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 550: 83 ec 0c sub $0xc,%esp 553: b9 0a 00 00 00 mov $0xa,%ecx 558: 6a 01 push $0x1 55a: e9 73 ff ff ff jmp 4d2 <printf+0xf2> 55f: 90 nop write(fd, &c, 1); 560: 83 ec 04 sub $0x4,%esp 563: 88 5d e5 mov %bl,-0x1b(%ebp) 566: 8d 45 e5 lea -0x1b(%ebp),%eax 569: 6a 01 push $0x1 56b: e9 21 ff ff ff jmp 491 <printf+0xb1> putc(fd, *ap); 570: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 573: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 576: 8b 07 mov (%edi),%eax write(fd, &c, 1); 578: 6a 01 push $0x1 ap++; 57a: 83 c7 04 add $0x4,%edi putc(fd, *ap); 57d: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 580: 8d 45 e4 lea -0x1c(%ebp),%eax 583: 50 push %eax 584: ff 75 08 pushl 0x8(%ebp) 587: e8 16 fd ff ff call 2a2 <write> ap++; 58c: 89 7d d4 mov %edi,-0x2c(%ebp) 58f: 83 c4 10 add $0x10,%esp state = 0; 592: 31 ff xor %edi,%edi 594: e9 8f fe ff ff jmp 428 <printf+0x48> s = "(null)"; 599: bb 38 07 00 00 mov $0x738,%ebx while(*s != 0){ 59e: b8 28 00 00 00 mov $0x28,%eax 5a3: e9 72 ff ff ff jmp 51a <printf+0x13a> 5a8: 66 90 xchg %ax,%ax 5aa: 66 90 xchg %ax,%ax 5ac: 66 90 xchg %ax,%ax 5ae: 66 90 xchg %ax,%ax 000005b0 <free>: static Header base; static Header *freep; void free(void *ap) { 5b0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5b1: a1 e4 09 00 00 mov 0x9e4,%eax { 5b6: 89 e5 mov %esp,%ebp 5b8: 57 push %edi 5b9: 56 push %esi 5ba: 53 push %ebx 5bb: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 5be: 8d 4b f8 lea -0x8(%ebx),%ecx 5c1: 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) 5c8: 39 c8 cmp %ecx,%eax 5ca: 8b 10 mov (%eax),%edx 5cc: 73 32 jae 600 <free+0x50> 5ce: 39 d1 cmp %edx,%ecx 5d0: 72 04 jb 5d6 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5d2: 39 d0 cmp %edx,%eax 5d4: 72 32 jb 608 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 5d6: 8b 73 fc mov -0x4(%ebx),%esi 5d9: 8d 3c f1 lea (%ecx,%esi,8),%edi 5dc: 39 fa cmp %edi,%edx 5de: 74 30 je 610 <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; 5e0: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 5e3: 8b 50 04 mov 0x4(%eax),%edx 5e6: 8d 34 d0 lea (%eax,%edx,8),%esi 5e9: 39 f1 cmp %esi,%ecx 5eb: 74 3a je 627 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 5ed: 89 08 mov %ecx,(%eax) freep = p; 5ef: a3 e4 09 00 00 mov %eax,0x9e4 } 5f4: 5b pop %ebx 5f5: 5e pop %esi 5f6: 5f pop %edi 5f7: 5d pop %ebp 5f8: c3 ret 5f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 600: 39 d0 cmp %edx,%eax 602: 72 04 jb 608 <free+0x58> 604: 39 d1 cmp %edx,%ecx 606: 72 ce jb 5d6 <free+0x26> { 608: 89 d0 mov %edx,%eax 60a: eb bc jmp 5c8 <free+0x18> 60c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 610: 03 72 04 add 0x4(%edx),%esi 613: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 616: 8b 10 mov (%eax),%edx 618: 8b 12 mov (%edx),%edx 61a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 61d: 8b 50 04 mov 0x4(%eax),%edx 620: 8d 34 d0 lea (%eax,%edx,8),%esi 623: 39 f1 cmp %esi,%ecx 625: 75 c6 jne 5ed <free+0x3d> p->s.size += bp->s.size; 627: 03 53 fc add -0x4(%ebx),%edx freep = p; 62a: a3 e4 09 00 00 mov %eax,0x9e4 p->s.size += bp->s.size; 62f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 632: 8b 53 f8 mov -0x8(%ebx),%edx 635: 89 10 mov %edx,(%eax) } 637: 5b pop %ebx 638: 5e pop %esi 639: 5f pop %edi 63a: 5d pop %ebp 63b: c3 ret 63c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000640 <malloc>: return freep; } void* malloc(uint nbytes) { 640: 55 push %ebp 641: 89 e5 mov %esp,%ebp 643: 57 push %edi 644: 56 push %esi 645: 53 push %ebx 646: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 649: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 64c: 8b 15 e4 09 00 00 mov 0x9e4,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 652: 8d 78 07 lea 0x7(%eax),%edi 655: c1 ef 03 shr $0x3,%edi 658: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 65b: 85 d2 test %edx,%edx 65d: 0f 84 9d 00 00 00 je 700 <malloc+0xc0> 663: 8b 02 mov (%edx),%eax 665: 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){ 668: 39 cf cmp %ecx,%edi 66a: 76 6c jbe 6d8 <malloc+0x98> 66c: 81 ff 00 10 00 00 cmp $0x1000,%edi 672: bb 00 10 00 00 mov $0x1000,%ebx 677: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 67a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 681: eb 0e jmp 691 <malloc+0x51> 683: 90 nop 684: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 688: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 68a: 8b 48 04 mov 0x4(%eax),%ecx 68d: 39 f9 cmp %edi,%ecx 68f: 73 47 jae 6d8 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 691: 39 05 e4 09 00 00 cmp %eax,0x9e4 697: 89 c2 mov %eax,%edx 699: 75 ed jne 688 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 69b: 83 ec 0c sub $0xc,%esp 69e: 56 push %esi 69f: e8 66 fc ff ff call 30a <sbrk> if(p == (char*)-1) 6a4: 83 c4 10 add $0x10,%esp 6a7: 83 f8 ff cmp $0xffffffff,%eax 6aa: 74 1c je 6c8 <malloc+0x88> hp->s.size = nu; 6ac: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 6af: 83 ec 0c sub $0xc,%esp 6b2: 83 c0 08 add $0x8,%eax 6b5: 50 push %eax 6b6: e8 f5 fe ff ff call 5b0 <free> return freep; 6bb: 8b 15 e4 09 00 00 mov 0x9e4,%edx if((p = morecore(nunits)) == 0) 6c1: 83 c4 10 add $0x10,%esp 6c4: 85 d2 test %edx,%edx 6c6: 75 c0 jne 688 <malloc+0x48> return 0; } } 6c8: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 6cb: 31 c0 xor %eax,%eax } 6cd: 5b pop %ebx 6ce: 5e pop %esi 6cf: 5f pop %edi 6d0: 5d pop %ebp 6d1: c3 ret 6d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 6d8: 39 cf cmp %ecx,%edi 6da: 74 54 je 730 <malloc+0xf0> p->s.size -= nunits; 6dc: 29 f9 sub %edi,%ecx 6de: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 6e1: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 6e4: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 6e7: 89 15 e4 09 00 00 mov %edx,0x9e4 } 6ed: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 6f0: 83 c0 08 add $0x8,%eax } 6f3: 5b pop %ebx 6f4: 5e pop %esi 6f5: 5f pop %edi 6f6: 5d pop %ebp 6f7: c3 ret 6f8: 90 nop 6f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 700: c7 05 e4 09 00 00 e8 movl $0x9e8,0x9e4 707: 09 00 00 70a: c7 05 e8 09 00 00 e8 movl $0x9e8,0x9e8 711: 09 00 00 base.s.size = 0; 714: b8 e8 09 00 00 mov $0x9e8,%eax 719: c7 05 ec 09 00 00 00 movl $0x0,0x9ec 720: 00 00 00 723: e9 44 ff ff ff jmp 66c <malloc+0x2c> 728: 90 nop 729: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 730: 8b 08 mov (%eax),%ecx 732: 89 0a mov %ecx,(%edx) 734: eb b1 jmp 6e7 <malloc+0xa7>
; A079004: Least x>=3 such that F(x)==1 (mod 3^n) where F(x) denotes the x-th Fibonacci number (A000045). ; 7,10,10,34,106,322,970,2914,8746,26242,78730,236194,708586,2125762,6377290,19131874,57395626,172186882,516560650,1549681954,4649045866,13947137602,41841412810,125524238434,376572715306,1129718145922 mov $1,$0 min $0,1 add $0,3 trn $1,2 mov $2,3 pow $2,$1 mul $0,$2 mul $0,3 sub $0,2
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r15 push %r8 push %r9 push %rbp push %rcx push %rdi push %rsi lea addresses_A_ht+0x58ef, %rsi lea addresses_WT_ht+0x88ef, %rdi nop xor $27193, %r8 mov $67, %rcx rep movsw nop nop and %rbp, %rbp lea addresses_normal_ht+0x2fcf, %rdi clflush (%rdi) nop nop xor $3828, %r15 mov $0x6162636465666768, %rbp movq %rbp, %xmm2 movups %xmm2, (%rdi) nop nop nop nop cmp $22397, %rcx lea addresses_WT_ht+0x13eef, %r8 nop nop nop dec %r9 movups (%r8), %xmm6 vpextrq $1, %xmm6, %rcx nop nop cmp %r15, %r15 lea addresses_A_ht+0x1ab32, %rsi lea addresses_normal_ht+0xbe5f, %rdi nop nop nop nop xor $30482, %r11 mov $82, %rcx rep movsw nop nop nop nop nop xor $4486, %rsi lea addresses_normal_ht+0x1766f, %r11 xor %rcx, %rcx movb (%r11), %r9b nop nop nop lfence lea addresses_UC_ht+0x1d82f, %rbp and %r15, %r15 mov $0x6162636465666768, %r8 movq %r8, %xmm5 vmovups %ymm5, (%rbp) nop add %rcx, %rcx lea addresses_D_ht+0x188ef, %rsi lea addresses_A_ht+0x8af, %rdi xor %r8, %r8 mov $6, %rcx rep movsb nop nop nop nop nop add %r9, %r9 lea addresses_A_ht+0x8807, %r8 nop nop nop nop nop add $19646, %r9 movups (%r8), %xmm4 vpextrq $0, %xmm4, %r15 nop xor %r9, %r9 lea addresses_D_ht+0x1aeef, %rsi lea addresses_UC_ht+0xae0f, %rdi nop nop nop nop cmp $57854, %rbp mov $47, %rcx rep movsl nop nop nop nop cmp %r9, %r9 lea addresses_WT_ht+0xf4ef, %rsi lea addresses_WT_ht+0x1013f, %rdi nop sub $64615, %r15 mov $79, %rcx rep movsb sub $32669, %r9 lea addresses_A_ht+0xc06f, %r15 nop dec %rsi mov $0x6162636465666768, %rdi movq %rdi, %xmm3 and $0xffffffffffffffc0, %r15 movaps %xmm3, (%r15) nop nop add $32817, %r9 lea addresses_UC_ht+0x148ef, %rdi nop nop sub $49571, %r8 mov $0x6162636465666768, %r9 movq %r9, %xmm3 movups %xmm3, (%rdi) nop sub %r11, %r11 lea addresses_WC_ht+0x48ef, %rsi lea addresses_normal_ht+0x170ef, %rdi clflush (%rsi) nop add %r11, %r11 mov $97, %rcx rep movsb nop nop and $31046, %rdi pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r15 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r8 push %rcx push %rsi // Store lea addresses_normal+0x1442f, %r10 nop nop nop nop nop and $61050, %r8 mov $0x5152535455565758, %r11 movq %r11, (%r10) nop nop nop cmp $11807, %r8 // Store lea addresses_normal+0x1d8e5, %r8 nop nop nop nop nop add %rcx, %rcx mov $0x5152535455565758, %rsi movq %rsi, %xmm6 vmovups %ymm6, (%r8) nop nop sub $62798, %r12 // Faulty Load lea addresses_A+0x1c0ef, %r12 nop nop nop and $25762, %r8 mov (%r12), %rcx lea oracles, %r11 and $0xff, %rcx shlq $12, %rcx mov (%r11,%rcx,1), %rcx pop %rsi pop %rcx pop %r8 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_A', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 8, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_A', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 16, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': True}, 'OP': 'REPM'} {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 32, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 16, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 16, 'congruent': 2, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'} {'35': 21829} 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
TTL C:\Documents and Settings\administrator.HPT-OFFICE\Desktop\HPT Graphics\asm.asm EXPORT HPTMemCpyFastSARM EXPORT HPTMemCpyFastXSCALE EXPORT PageFlip EXPORT HPTPartialBlt EXPORT HPTPartialBltH EXPORT HPTPartialBltV EXPORT HPTPartialBltHV EXPORT HPTPartialBltO EXPORT HPTPartialBltHO EXPORT HPTPartialBltVO EXPORT HPTPartialBltHVO EXPORT HPTBlt16x16O EXPORT MemCpyFastLandscape AREA .code,CODE HPTMemCpyFastSARM PROC stmdb sp!,{r4-r11,r14} cmp r2,#0 beq SKIPLOOP BEGINLOOP2 mov r4,r1 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 ldrsb r5,[r4],#32 mov r3,#16 BEGINLOOP ldmia r1!,{r4-r11} ;stmia r0!,{r4-r11} subs r3,r3,#1 ;ldmia r1!,{r4-r11} stmia r0!,{r4-r11} bne BEGINLOOP subs r2,r2,#1 bne BEGINLOOP2 SKIPLOOP ldmia sp!,{r4-r11,r15} endp HPTMemCpyFastXSCALE PROC stmdb sp!,{r4-r11,r14} pld [r1] pld [r1,#32] pld [r1,#64] ;pld [r1,#96] cmp r2,#0 beq SKIPLOOP4 BEGINLOOP4 pld [r1,#96] ;ldmia r1!,{r4-r11} ;stmia r0!,{r4-r11} ldr r4,[r1] , #4 ldr r5,[r1] , #4 ldr r6,[r1] , #4 ldr r7,[r1] , #4 str r4,[r0] , #4 str r5,[r0] , #4 str r6,[r0] , #4 str r7,[r0] , #4 ldr r8,[r1] , #4 ldr r9,[r1] , #4 ldr r10,[r1] , #4 ldr r11,[r1] , #4 str r8,[r0] , #4 str r9,[r0] , #4 str r10,[r0] , #4 str r11,[r0] , #4 subs r2,r2,#1 pld [r1,#96] ;ldmia r1!,{r4-r11} ;stmia r0!,{r4-r11} ldr r4,[r1] , #4 ldr r5,[r1] , #4 ldr r6,[r1] , #4 ldr r7,[r1] , #4 str r4,[r0] , #4 str r5,[r0] , #4 str r6,[r0] , #4 str r7,[r0] , #4 ldr r8,[r1] , #4 ldr r9,[r1] , #4 ldr r10,[r1] , #4 ldr r11,[r1] , #4 str r8,[r0] , #4 str r9,[r0] , #4 str r10,[r0] , #4 str r11,[r0] , #4 bne BEGINLOOP4 SKIPLOOP4 ldmia sp!,{r4-r11,r15} endp PageFlip PROC stmdb sp!,{r4-r9,r14} pld [r1] pld [r1,#32] pld [r1,#64] ;pld [r1,#96] mov r8,#320 BEGINLOOPPFY mov r9,#15 BEGINLOOPPFX pld [r1,#96] ldr r4,[r1] , #4 ldr r5,[r1] , #4 ldr r6,[r1] , #4 ldr r7,[r1] , #4 str r4,[r0] , #4 str r5,[r0] , #4 str r6,[r0] , #4 str r7,[r0] , #4 subs r9,r9,#1 ldr r4,[r1] , #4 ldr r5,[r1] , #4 ldr r6,[r1] , #4 ldr r7,[r1] , #4 str r4,[r0] , #4 str r5,[r0] , #4 str r6,[r0] , #4 str r7,[r0] , #4 bne BEGINLOOPPFX subs r8,r8,#1 add r1,r1,r2 bne BEGINLOOPPFY ldmia sp!,{r4-r9,r15} endp HPTPartialBlt PROC ;r0 destination ;r1 source ;r2 x size ;r3 y size ;r4 color ;r5 ystep ;r6 current x size for current line ;r7 current pixel ;r8 amount to get to next line in back buffer ;r9 prefetch distance mov r12,sp stmdb sp!,{r4-r9,r14} ldmia r12!,{r4,r5} pld [r1] mov r2,r2, lsl #1 mov r5,r5, lsl #1 rsb r8,r2,#480 mov r9,r5 sub r5,r5,r2 BEGINY mov r6,r2 pld [r1,r9] BEGINX ldrh r7,[r1] , #2 cmp r7,r4 strneh r7,[r0] subs r6,r6,#2 add r0,r0,#2 bne BEGINX subs r3,r3,#1 add r0,r0,r8 add r1,r1,r5 bne BEGINY ldmia sp!,{r4-r9,r15} endp HPTPartialBltH PROC ;r0 destination ;r1 source ;r2 x size ;r3 y size ;r4 color ;r5 ystep ;r6 current x size for current line ;r7 current pixel ;r8 amount to get to next line in back buffer ;r9 prefetch distance mov r12,sp stmdb sp!,{r4-r9,r14} ldmia r12!,{r4,r5} pld [r1] ;pld [r1,#32] mov r2,r2, lsl #1 mov r5,r5, lsl #1 rsb r8,r2,#480 mov r9,r5 sub r9,r9,r2 add r5,r5,r2 BEGINYH mov r6,r2 pld [r1,r9] BEGINXH ldrh r7,[r1], #-2 cmp r7,r4 strneh r7,[r0] subs r6,r6,#2 add r0,r0,#2 ;sub r1,r1,#2 bne BEGINXH subs r3,r3,#1 add r0,r0,r8 add r1,r1,r5 bne BEGINYH ldmia sp!,{r4-r9,r15} endp HPTPartialBltV PROC ;r0 destination ;r1 source ;r2 x size ;r3 y size ;r4 color ;r5 ystep ;r6 current x size for current line ;r7 current pixel ;r8 amount to get to next line in back buffer ;r9 prefetch distance mov r12,sp stmdb sp!,{r4-r9,r14} ldmia r12!,{r4,r5} pld [r1] mov r2,r2, lsl #1 mov r5,r5, lsl #1 rsb r8,r2,#480 mov r9,r5 add r5,r5,r2 BEGINYV mov r6,r2 pld [r1,-r9] BEGINXV ldrh r7,[r1] , #2 cmp r7,r4 strneh r7,[r0] subs r6,r6,#2 add r0,r0,#2 bne BEGINXV subs r3,r3,#1 add r0,r0,r8 sub r1,r1,r5 bne BEGINYV ldmia sp!,{r4-r9,r15} endp HPTPartialBltHV PROC ;r0 destination ;r1 source ;r2 x size ;r3 y size ;r4 color ;r5 ystep ;r6 current x size for current line ;r7 current pixel ;r8 amount to get to next line in back buffer ;r9 prefetch distance mov r12,sp stmdb sp!,{r4-r9,r14} ldmia r12!,{r4,r5} pld [r1] mov r2,r2, lsl #1 mov r5,r5, lsl #1 rsb r8,r2,#480 add r9,r5,r2 sub r5,r5,r2 BEGINYHV mov r6,r2 pld [r1,-r9] BEGINXHV ldrh r7,[r1] , #-2 cmp r7,r4 strneh r7,[r0] subs r6,r6,#2 add r0,r0,#2 bne BEGINXHV subs r3,r3,#1 add r0,r0,r8 sub r1,r1,r5 bne BEGINYHV ldmia sp!,{r4-r9,r15} endp HPTPartialBltO PROC ;r0 destination ;r1 source ;r2 x size ;r3 y size ;r4 ystep ;r6 current x size for current line ;r7 current pixel ;r8 amount to get to next line in back buffer ;r9 prefetch distance mov r12,sp stmdb sp!,{r4-r9,r14} ldmia r12!,{r4,r5} pld [r1] mov r2,r2, lsl #1 mov r4,r4, lsl #1 rsb r8,r2,#480 mov r9,r4 sub r4,r4,r2 BEGINYO mov r6,r2 pld [r1,r9] BEGINXO ldrh r7,[r1] , #2 subs r6,r6,#2 ;cmp r7,r4 strh r7,[r0] add r0,r0,#2 bne BEGINXO subs r3,r3,#1 add r0,r0,r8 add r1,r1,r4 bne BEGINYO ldmia sp!,{r4-r9,r15} endp HPTPartialBltHO PROC ;r0 destination ;r1 source ;r2 x size ;r3 y size ;r4 ystep ;r6 current x size for current line ;r7 current pixel ;r8 amount to get to next line in back buffer ;r9 prefetch distance mov r12,sp stmdb sp!,{r4-r9,r14} ldmia r12!,{r4} pld [r1] mov r2,r2, lsl #1 mov r4,r4, lsl #1 rsb r8,r2,#480 sub r9,r4,r2 add r4,r4,r2 BEGINYHO mov r6,r2 pld [r1,r9] BEGINXHO ldrh r7,[r1] , #-2 subs r6,r6,#2 strh r7,[r0] add r0,r0,#2 bne BEGINXHO subs r3,r3,#1 add r0,r0,r8 add r1,r1,r4 bne BEGINYHO ldmia sp!,{r4-r9,r15} endp HPTPartialBltVO PROC ;r0 destination ;r1 source ;r2 x size ;r3 y size ;r4 ystep ;r6 current x size for current line ;r7 current pixel ;r8 amount to get to next line in back buffer ;r9 prefetch distance mov r12,sp stmdb sp!,{r4-r9,r14} ldmia r12!,{r4} pld [r1] mov r2,r2, lsl #1 mov r4,r4, lsl #1 rsb r8,r2,#480 mov r9,r4 add r4,r4,r2 BLITOBEGINYVO mov r6,r2 pld [r1,-r9] BLITOBEGINXVO ldrh r7,[r1] , #2 subs r6,r6,#2 strh r7,[r0] add r0,r0,#2 bne BLITOBEGINXVO subs r3,r3,#1 add r0,r0,r8 sub r1,r1,r4 bne BLITOBEGINYVO ldmia sp!,{r4-r9,r15} endp HPTPartialBltHVO PROC ;r0 destination ;r1 source ;r2 x size ;r3 y size ;r4 ystep ;r6 current x size for current line ;r7 current pixel ;r8 amount to get to next line in back buffer ;r9 prefetch distance mov r12,sp stmdb sp!,{r4-r9,r14} ldmia r12!,{r4} pld [r1] mov r2,r2, lsl #1 mov r4,r4, lsl #1 rsb r8,r2,#480 add r9,r4,r2 sub r4,r4,r2 BLITOBEGINYHVO mov r6,r2 pld [r1,-r9] BLITOBEGINXHVO ldrh r7,[r1] , #-2 subs r6,r6,#2 strh r7,[r0] add r0,r0,#2 bne BLITOBEGINXHVO subs r3,r3,#1 add r0,r0,r8 sub r1,r1,r4 bne BLITOBEGINYHVO ldmia sp!,{r4-r9,r15} endp HPTBlt16x16O PROC ;r0 destination ;r1 source ;r2 ystep ;r3 y size ;r4 color ;r5 ystep ;r6 current x size for current line ;r7 current pixel ;r8 amount to get to next line in back buffer ;r9 prefetch distance stmdb sp!,{r4-r11,r14} pld [r1] mov r3,#16 mov r2,r2 LSL #1 BEGIN16x16O pld [r1,#32] ldrh r4,[r1] ldrh r5,[r1,#2] strh r4,[r0] ldrh r6,[r1,#4] strh r5,[r0,#2] ldrh r7,[r1,#6] strh r6,[r0,#4] ldrh r8,[r1,#8] strh r7,[r0,#6] ldrh r9,[r1,#10] strh r8,[r0,#8] ldrh r10,[r1,#12] strh r9,[r0,#10] ldrh r11,[r1,#14] strh r10,[r0,#12] strh r11,[r0,#14] ldrh r4,[r1,#16] ldrh r5,[r1,#18] strh r4,[r0,#16] ldrh r6,[r1,#20] strh r5,[r0,#18] ldrh r7,[r1,#22] strh r6,[r0,#20] ldrh r8,[r1,#24] subs r3,r3,#1 strh r7,[r0,#22] ldrh r9,[r1,#26] strh r8,[r0,#24] ldrh r10,[r1,#28] strh r9,[r0,#26] ldrh r11,[r1,#30] strh r10,[r0,#28] strh r11,[r0,#30] add r1,r1,r2 add r0,r0,#480 bne BEGIN16x16O ldmia sp!,{r4-r11,r15} endp MemCpyFastLandscape PROC ;r0 destination ;r1 source ;r2 current destination ;r3 y count ;r4 x count ;r5-r8 registers to hold data ;r9-r11 registers to hold output offsets stmdb sp!,{r4-r11,r14} mov r3,#0 ;sub r3,r3,#2 mov r4,#60 ;mov r9,#640 add r9,r2,#640 mov r10,r9 LSL #1 add r11,r9,r10 ;mov r2,r0 BEGINLANDSCAPEY sub r2,r0,r3 add r3,r3,#2 pld [r1,#64] BEGINLANDSCAPEX ldrh r5,[r1] ldrh r6,[r1,#2] ldrh r7,[r1,#4] ldrh r8,[r1,#6] add r1,r1,#8 subs r4,r4,#1 strh r5,[r2] strh r6,[r2,r9] strh r7,[r2,r10] strh r8,[r2,r11] add r2,r2,r11 add r2,r2,r9 bne BEGINLANDSCAPEX cmp r3,#640 mov r4,#60 bne BEGINLANDSCAPEY ldmia sp!,{r4-r11,r15} endp END
/** * Copyright (c) 2020 Mobvoi Inc. (authors: Fangjun Kuang) * Xiaomi Corporation (authors: Haowen Qiu) * * See LICENSE for clarification regarding multiple authors */ #include "k2/csrc/host/fsa_renderer.h" #include <iomanip> #include <sstream> #include <string> namespace { std::string GeneratePrologue() { // TODO(fangjun): the following options can be passed from outside std::string header = R"header( digraph FSA { rankdir = LR; size = "8.5,11"; label = ""; center = 1; orientation = Portrait; ranksep = "0.4" nodesep = "0.25" )header"; return header; } std::string GenerateEpilogue() { return "}"; } using k2host::Arc; using k2host::Fsa; std::string ProcessState(const Fsa &fsa, int32_t state) { std::ostringstream os; os << " " << state << " [label = \"" << state << "\", shape = circle, style = bold, fontsize = 14]" << "\n"; int32_t arc_begin_index = fsa.indexes[0]; // it may be greater than 0 int32_t begin = fsa.indexes[state]; int32_t end = fsa.indexes[state + 1]; for (; begin != end; ++begin) { const auto &arc = fsa.data[begin]; int32_t src = arc.src_state; int32_t dest = arc.dest_state; int32_t label = arc.label; os << " " << src << " -> " << dest << " [label = \"" << label; if (arc.weight != 0.0) os << "/" << std::fixed << std::setprecision(1) << arc.weight; os << "\", fontsize = 14];" << "\n"; } return os.str(); } } // namespace namespace k2host { std::string FsaRenderer::Render() const { int32_t num_states = fsa_.NumStates(); if (num_states == 0) return ""; std::ostringstream os; os << GeneratePrologue(); int32_t final_state = fsa_.FinalState(); for (int32_t i = 0; i != final_state; ++i) { os << ProcessState(fsa_, i); } // now for the final state os << " " << final_state << " [label = \"" << final_state << "\", shape = doublecircle, style = solid, fontsize = 14]" << "\n"; os << GenerateEpilogue() << "\n"; return os.str(); } } // namespace k2host
; A315399: Coordination sequence Gal.4.43.4 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; Submitted by Simon Strandgaard ; 1,6,11,15,19,23,27,32,38,44,49,53,57,61,65,70,76,82,87,91,95,99,103,108,114,120,125,129,133,137,141,146,152,158,163,167,171,175,179,184,190,196,201,205,209,213,217,222,228,234 mov $5,$0 mul $0,2 add $0,6 mov $3,3 mov $4,3 lpb $0 mov $2,$0 sub $2,10 add $3,6 add $4,6 trn $2,$4 add $2,$3 mov $0,$2 lpe sub $0,6 trn $0,1 lpb $5 add $0,4 sub $5,1 lpe add $0,1
; A013698: a(n) = binomial(3*n+2, n-1). ; 1,8,55,364,2380,15504,100947,657800,4292145,28048800,183579396,1203322288,7898654920,51915526432,341643774795,2250829575120,14844575908435,97997533741800,647520696018735,4282083008118300,28339603908273840,187692294101632320,1243918491347262900,8249183865278257824,54737645114759121900,363413731121503794368,2414026679379329824344,16043346345066602651040,106671345686835109102032,709560230486400392024640,4721816312633418762600507,31433858882404362065762976,209337139656037681356273975,1394590469358810533224910040,9293758034873875526697094725,61954559354022542584456123044,413129206792931819052011244732,2755644326264809570170866867280,18385667002278359934079351723483,122701334246991636043707764706280,819082961281125889766557609987825,5469033289461647109060738370473600,36525229712715868611320663407578000,243989405684990009857757066044753600 mov $1,$0 add $1,5 add $1,$0 add $0,$1 bin $0,$1
; A067707: a(n) = 3*n^2 + 12*n. ; 15,36,63,96,135,180,231,288,351,420,495,576,663,756,855,960,1071,1188,1311,1440,1575,1716,1863,2016,2175,2340,2511,2688,2871,3060,3255,3456,3663,3876,4095,4320,4551,4788,5031,5280,5535,5796,6063,6336,6615,6900,7191,7488,7791,8100,8415,8736,9063,9396,9735,10080,10431,10788,11151,11520,11895,12276,12663,13056,13455,13860,14271,14688,15111,15540,15975,16416,16863,17316,17775,18240,18711,19188,19671,20160,20655,21156,21663,22176,22695,23220,23751,24288,24831,25380,25935,26496,27063,27636,28215,28800,29391,29988,30591,31200,31815,32436,33063,33696,34335,34980,35631,36288,36951,37620,38295,38976,39663,40356,41055,41760,42471,43188,43911,44640,45375,46116,46863,47616,48375,49140,49911,50688,51471,52260,53055,53856,54663,55476,56295,57120,57951,58788,59631,60480,61335,62196,63063,63936,64815,65700,66591,67488,68391,69300,70215,71136,72063,72996,73935,74880,75831,76788,77751,78720,79695,80676,81663,82656,83655,84660,85671,86688,87711,88740,89775,90816,91863,92916,93975,95040,96111,97188,98271,99360,100455,101556,102663,103776,104895,106020,107151,108288,109431,110580,111735,112896,114063,115236,116415,117600,118791,119988,121191,122400,123615,124836,126063,127296,128535,129780,131031,132288,133551,134820,136095,137376,138663,139956,141255,142560,143871,145188,146511,147840,149175,150516,151863,153216,154575,155940,157311,158688,160071,161460,162855,164256,165663,167076,168495,169920,171351,172788,174231,175680,177135,178596,180063,181536,183015,184500,185991,187488,188991,190500 mov $1,$0 add $1,6 mul $1,$0 mul $1,3 add $1,15
; A298252: Even integers n such that n-3 is prime. ; Submitted by Jon Maiga ; 6,8,10,14,16,20,22,26,32,34,40,44,46,50,56,62,64,70,74,76,82,86,92,100,104,106,110,112,116,130,134,140,142,152,154,160,166,170,176,182,184,194,196,200,202,214,226,230,232,236,242,244,254,260,266,272,274,280,284,286,296,310,314,316,320,334,340,350,352,356,362,370,376,382,386,392,400,404,412,422,424,434,436,442,446,452,460,464,466,470,482,490,494,502,506,512,524,526,544,550 mov $1,2 mov $2,$0 pow $2,2 lpb $2 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,2 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 sub $2,1 lpe mov $0,$1 add $0,4
; A022412: Expansion of 1/((1-x)(1-5x)(1-6x)(1-11x)). ; Submitted by Jon Maiga ; 1,23,356,4690,57015,663621,7538098,84446336,938561525,10384529155,114604142016,1262952525198,13906624731091,153059279644385,1684178151097070,18529154259093436,203840055167045073 add $0,2 lpb $0 sub $0,1 add $2,2 mul $2,5 sub $2,9 mul $3,11 add $3,$1 mul $1,6 add $1,$2 lpe mov $0,$3
// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see http://www.gnu.org/licenses/. // /* @file SSASFactory.cc * @author Johannes Pfannmüller, Christian Koch * @date * @version 1.0 * * @brief returns the desired SSAS * * @section DESCRIPTION */ #include "SSASFactory.h" #include "BasicSSAS.h" #include "LargestGhostListSSAS.h" #include "SmallestGhostListSSAS.h" #include "RelativeLargestGhostListSSAS.h" #include "RelativeSmallestGhostListSSAS.h" /* * @brief returns an instance of the SSASFactory * @return an instance of the SSASFactory */ SSASFactory::SSASFactory() { } /* * @brief returns an adpative Strategy based upon the type we want * @param probationaryCache the probationary cache * @param probationaryGhostList the probationary ghostlist * @param cacheSegmentVector the category cache vector * @param ghostListVector the ghostlists for the category caches * @param cacheSize the size of the cache * @param subCacheSize the subcache size * @param minSegSize the minimum subcache size * @param type the type of the adaption strategy we want * @return an adaptive Strategy */ BasicSSAS* SSASFactory:: createAdaptionStrategy( ARCProbationaryCache* probationaryCache, BasicGhostList* probationaryGhostList, std::vector<BasicCacheSegment*>* cacheSegmentVector, std::vector<BasicGhostList*>* ghostListVector, unsigned int cacheSize, int subCacheSize, double minSegSize, std::string type) { BasicSSAS* returnedSSAS = nullptr; if (type == "largestGhostList") { returnedSSAS = new LargestGhostListSSAS(probationaryCache, probationaryGhostList, cacheSegmentVector, ghostListVector, cacheSize, subCacheSize, minSegSize); } else if (type == "smallesGhostList") { returnedSSAS = new SmallestGhostListSSAS(probationaryCache, probationaryGhostList, cacheSegmentVector, ghostListVector, cacheSize, subCacheSize, minSegSize); } else if (type == "relativeLargestGhostList") { returnedSSAS = new RelativeLargestGhostListSSAS(probationaryCache, probationaryGhostList, cacheSegmentVector, ghostListVector, cacheSize, subCacheSize, minSegSize); } else if (type == "relativeSmallestGhostList") { returnedSSAS = new RelativeSmallestGhostListSSAS(probationaryCache, probationaryGhostList, cacheSegmentVector, ghostListVector, cacheSize, subCacheSize, minSegSize); } else throw "This type of adaption Strategy does not exist\n"; return returnedSSAS; }
;; ;; Copyright (c) 2017-2021, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; ;; In System V AMD64 ABI ;; callee saves: RBX, RBP, R12-R15 ;; Windows x64 ABI ;; callee saves: RBX, RBP, RDI, RSI, RSP, R12-R15 ;; ;; Registers: RAX RBX RCX RDX RBP RSI RDI R8 R9 R10 R11 R12 R13 R14 R15 ;; ----------------------------------------------------------- ;; Windows clobbers: RAX RCX RDX R8 R9 R10 R11 ;; Windows preserves: RBX RBP RSI RDI R12 R13 R14 R15 ;; ----------------------------------------------------------- ;; Linux clobbers: RAX RCX RDX RSI RDI R8 R9 R10 R11 ;; Linux preserves: RBX RBP R12 R13 R14 R15 ;; ----------------------------------------------------------- ;; Clobbers ZMM0-31 %include "include/os.asm" %include "include/imb_job.asm" %include "include/mb_mgr_datastruct.asm" %include "include/reg_sizes.asm" %include "include/cet.inc" ;; %define DO_DBGPRINT %include "include/dbgprint.asm" extern sha256_x16_avx512 mksection .rodata default rel align 16 byteswap: dq 0x0405060700010203, 0x0c0d0e0f08090a0b align 32 len_masks: dq 0x000000000000FFFF, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000 dq 0x00000000FFFF0000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000 dq 0x0000FFFF00000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000 dq 0xFFFF000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000 dq 0x0000000000000000, 0x000000000000FFFF, 0x0000000000000000, 0x0000000000000000 dq 0x0000000000000000, 0x00000000FFFF0000, 0x0000000000000000, 0x0000000000000000 dq 0x0000000000000000, 0x0000FFFF00000000, 0x0000000000000000, 0x0000000000000000 dq 0x0000000000000000, 0xFFFF000000000000, 0x0000000000000000, 0x0000000000000000 dq 0x0000000000000000, 0x0000000000000000, 0x000000000000FFFF, 0x0000000000000000 dq 0x0000000000000000, 0x0000000000000000, 0x00000000FFFF0000, 0x0000000000000000 dq 0x0000000000000000, 0x0000000000000000, 0x0000FFFF00000000, 0x0000000000000000 dq 0x0000000000000000, 0x0000000000000000, 0xFFFF000000000000, 0x0000000000000000 dq 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x000000000000FFFF dq 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x00000000FFFF0000 dq 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000FFFF00000000 dq 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0xFFFF000000000000 lane_1: dq 1 lane_2: dq 2 lane_3: dq 3 lane_4: dq 4 lane_5: dq 5 lane_6: dq 6 lane_7: dq 7 lane_8: dq 8 lane_9: dq 9 lane_10: dq 10 lane_11: dq 11 lane_12: dq 12 lane_13: dq 13 lane_14: dq 14 lane_15: dq 15 mksection .text %ifdef LINUX %define arg1 rdi %define arg2 rsi %define arg3 rdx %else %define arg1 rcx %define arg2 rdx %define arg3 rsi %endif %define state arg1 %define job arg2 %define len2 arg2 ; idx needs to be in rbp, r15 %define idx rbp %define unused_lanes r10 %define tmp5 r10 %define lane_data rbx %define tmp2 rbx %define job_rax rax %define tmp1 rax %define size_offset rax %define start_offset rax %define tmp3 arg1 %define extra_blocks arg2 %define p arg2 %define tmp4 arg3 %define tmp r9 %define len_upper r13 %define idx_upper r14 ; we clobber rsi, rbp; called routine also clobbers rax, r9 to r15 struc STACK _gpr_save: resq 8 _rsp_save: resq 1 endstruc %define APPEND(a,b) a %+ b ; JOB* flush_job_hmac_sha_224_avx512(MB_MGR_HMAC_SHA_256_OOO *state) ; JOB* flush_job_hmac_sha_256_avx512(MB_MGR_HMAC_SHA_256_OOO *state) ; arg 1 : state align 32 %ifdef SHA224 MKGLOBAL(flush_job_hmac_sha_224_avx512,function,internal) flush_job_hmac_sha_224_avx512: endbranch64 %else MKGLOBAL(flush_job_hmac_sha_256_avx512,function,internal) flush_job_hmac_sha_256_avx512: endbranch64 %endif mov rax, rsp sub rsp, STACK_size and rsp, -32 mov [rsp + _gpr_save + 8*0], rbx mov [rsp + _gpr_save + 8*1], rbp mov [rsp + _gpr_save + 8*2], r12 mov [rsp + _gpr_save + 8*3], r13 mov [rsp + _gpr_save + 8*4], r14 mov [rsp + _gpr_save + 8*5], r15 %ifndef LINUX mov [rsp + _gpr_save + 8*6], rsi mov [rsp + _gpr_save + 8*7], rdi %endif mov [rsp + _rsp_save], rax ; original SP ; if bit (32+3) is set, then all lanes are empty cmp dword [state + _num_lanes_inuse_sha256], 0 jz return_null ; find a lane with a non-null job xor idx, idx %assign I 1 %rep 15 cmp qword [state + _ldata_sha256 + (I * _HMAC_SHA1_LANE_DATA_size) + _job_in_lane], 0 cmovne idx, [rel APPEND(lane_,I)] %assign I (I+1) %endrep copy_lane_data: ; copy idx to empty lanes vmovdqa ymm0, [state + _lens_sha256] mov tmp, [state + _args_data_ptr_sha256 + PTR_SZ*idx] %assign I 0 %rep 16 cmp qword [state + _ldata_sha256 + I * _HMAC_SHA1_LANE_DATA_size + _job_in_lane], 0 jne APPEND(skip_,I) mov [state + _args_data_ptr_sha256 + PTR_SZ*I], tmp vpor ymm0, ymm0, [rel len_masks + 32*I] APPEND(skip_,I): %assign I (I+1) %endrep vmovdqa [state + _lens_sha256 ], ymm0 vphminposuw xmm1, xmm0 vpextrw DWORD(len2), xmm1, 0 ; min value vpextrw DWORD(idx), xmm1, 1 ; min index (0...7) vmovdqa xmm2, [state + _lens_sha256 + 8*2] vphminposuw xmm3, xmm2 vpextrw DWORD(len_upper), xmm3, 0 ; min value vpextrw DWORD(idx_upper), xmm3, 1 ; min index (8...F) cmp len2, len_upper jle use_min vmovdqa xmm1, xmm3 mov len2, len_upper mov idx, idx_upper ; idx would be in range 0..7 add idx, 8 ; to reflect that index is in 8..F range use_min: cmp len2, 0 je len_is_0 vpbroadcastw xmm1, xmm1 ; duplicate words across all lanes vpsubw xmm0, xmm0, xmm1 vmovdqa [state + _lens_sha256], xmm0 vpsubw xmm2, xmm2, xmm1 vmovdqa [state + _lens_sha256 + 8*2], xmm2 ; "state" and "args" are the same address, arg1 ; len is arg2 call sha256_x16_avx512 ; state and idx are intact len_is_0: ; process completed job "idx" imul lane_data, idx, _HMAC_SHA1_LANE_DATA_size lea lane_data, [state + _ldata_sha256 + lane_data] mov DWORD(extra_blocks), [lane_data + _extra_blocks] cmp extra_blocks, 0 jne proc_extra_blocks cmp dword [lane_data + _outer_done], 0 jne end_loop proc_outer: mov dword [lane_data + _outer_done], 1 mov DWORD(size_offset), [lane_data + _size_offset] mov qword [lane_data + _extra_block + size_offset], 0 mov word [state + _lens_sha256 + 2*idx], 1 lea tmp, [lane_data + _outer_block] mov [state + _args_data_ptr_sha256 + PTR_SZ*idx], tmp vmovd xmm0, [state + _args_digest_sha256 + 4*idx + 0*SHA256_DIGEST_ROW_SIZE] vpinsrd xmm0, xmm0, [state + _args_digest_sha256 + 4*idx + 1*SHA256_DIGEST_ROW_SIZE], 1 vpinsrd xmm0, xmm0, [state + _args_digest_sha256 + 4*idx + 2*SHA256_DIGEST_ROW_SIZE], 2 vpinsrd xmm0, xmm0, [state + _args_digest_sha256 + 4*idx + 3*SHA256_DIGEST_ROW_SIZE], 3 vpshufb xmm0, xmm0, [rel byteswap] vmovd xmm1, [state + _args_digest_sha256 + 4*idx + 4*SHA256_DIGEST_ROW_SIZE] vpinsrd xmm1, xmm1, [state + _args_digest_sha256 + 4*idx + 5*SHA256_DIGEST_ROW_SIZE], 1 vpinsrd xmm1, xmm1, [state + _args_digest_sha256 + 4*idx + 6*SHA256_DIGEST_ROW_SIZE], 2 %ifndef SHA224 vpinsrd xmm1, xmm1, [state + _args_digest_sha256 + 4*idx + 7*SHA256_DIGEST_ROW_SIZE], 3 %endif vpshufb xmm1, xmm1, [rel byteswap] vmovdqa [lane_data + _outer_block], xmm0 vmovdqa [lane_data + _outer_block + 4*4], xmm1 %ifdef SHA224 mov dword [lane_data + _outer_block + 7*4], 0x80 %endif mov job, [lane_data + _job_in_lane] mov tmp, [job + _auth_key_xor_opad] vmovdqu xmm0, [tmp] vmovdqu xmm1, [tmp + 4*4] vmovd [state + _args_digest_sha256 + 4*idx + 0*SHA256_DIGEST_ROW_SIZE], xmm0 vpextrd [state + _args_digest_sha256 + 4*idx + 1*SHA256_DIGEST_ROW_SIZE], xmm0, 1 vpextrd [state + _args_digest_sha256 + 4*idx + 2*SHA256_DIGEST_ROW_SIZE], xmm0, 2 vpextrd [state + _args_digest_sha256 + 4*idx + 3*SHA256_DIGEST_ROW_SIZE], xmm0, 3 vmovd [state + _args_digest_sha256 + 4*idx + 4*SHA256_DIGEST_ROW_SIZE], xmm1 vpextrd [state + _args_digest_sha256 + 4*idx + 5*SHA256_DIGEST_ROW_SIZE], xmm1, 1 vpextrd [state + _args_digest_sha256 + 4*idx + 6*SHA256_DIGEST_ROW_SIZE], xmm1, 2 vpextrd [state + _args_digest_sha256 + 4*idx + 7*SHA256_DIGEST_ROW_SIZE], xmm1, 3 jmp copy_lane_data align 16 proc_extra_blocks: mov DWORD(start_offset), [lane_data + _start_offset] mov [state + _lens_sha256 + 2*idx], WORD(extra_blocks) lea tmp, [lane_data + _extra_block + start_offset] mov [state + _args_data_ptr_sha256 + PTR_SZ*idx], tmp mov dword [lane_data + _extra_blocks], 0 jmp copy_lane_data return_null: xor job_rax, job_rax jmp return align 16 end_loop: mov job_rax, [lane_data + _job_in_lane] mov qword [lane_data + _job_in_lane], 0 or dword [job_rax + _status], IMB_STATUS_COMPLETED_AUTH mov unused_lanes, [state + _unused_lanes_sha256] shl unused_lanes, 4 or unused_lanes, idx mov [state + _unused_lanes_sha256], unused_lanes sub dword [state + _num_lanes_inuse_sha256], 1 mov p, [job_rax + _auth_tag_output] %ifdef SHA224 cmp qword [job_rax + _auth_tag_output_len_in_bytes], 14 jne copy_full_digest %else cmp qword [job_rax + _auth_tag_output_len_in_bytes], 16 jne copy_full_digest %endif ;; copy SHA224 14 bytes / SHA256 16 bytes mov DWORD(tmp), [state + _args_digest_sha256 + 4*idx + 0*SHA256_DIGEST_ROW_SIZE] mov DWORD(tmp2), [state + _args_digest_sha256 + 4*idx + 1*SHA256_DIGEST_ROW_SIZE] mov DWORD(tmp4), [state + _args_digest_sha256 + 4*idx + 2*SHA256_DIGEST_ROW_SIZE] mov DWORD(tmp5), [state + _args_digest_sha256 + 4*idx + 3*SHA256_DIGEST_ROW_SIZE] bswap DWORD(tmp) bswap DWORD(tmp2) bswap DWORD(tmp4) bswap DWORD(tmp5) mov [p + 0*4], DWORD(tmp) mov [p + 1*4], DWORD(tmp2) mov [p + 2*4], DWORD(tmp4) %ifdef SHA224 mov [p + 3*4], WORD(tmp5) %else mov [p + 3*4], DWORD(tmp5) %endif jmp clear_ret copy_full_digest: ;; copy SHA224 28 bytes / SHA256 32 bytes mov DWORD(tmp), [state + _args_digest_sha256 + 4*idx + 0*SHA256_DIGEST_ROW_SIZE] mov DWORD(tmp2), [state + _args_digest_sha256 + 4*idx + 1*SHA256_DIGEST_ROW_SIZE] mov DWORD(tmp4), [state + _args_digest_sha256 + 4*idx + 2*SHA256_DIGEST_ROW_SIZE] mov DWORD(tmp5), [state + _args_digest_sha256 + 4*idx + 3*SHA256_DIGEST_ROW_SIZE] bswap DWORD(tmp) bswap DWORD(tmp2) bswap DWORD(tmp4) bswap DWORD(tmp5) mov [p + 0*4], DWORD(tmp) mov [p + 1*4], DWORD(tmp2) mov [p + 2*4], DWORD(tmp4) mov [p + 3*4], DWORD(tmp5) mov DWORD(tmp), [state + _args_digest_sha256 + 4*idx + 4*SHA256_DIGEST_ROW_SIZE] mov DWORD(tmp2), [state + _args_digest_sha256 + 4*idx + 5*SHA256_DIGEST_ROW_SIZE] mov DWORD(tmp4), [state + _args_digest_sha256 + 4*idx + 6*SHA256_DIGEST_ROW_SIZE] %ifndef SHA224 mov DWORD(tmp5), [state + _args_digest_sha256 + 4*idx + 7*SHA256_DIGEST_ROW_SIZE] %endif bswap DWORD(tmp) bswap DWORD(tmp2) bswap DWORD(tmp4) %ifndef SHA224 bswap DWORD(tmp5) %endif mov [p + 4*4], DWORD(tmp) mov [p + 5*4], DWORD(tmp2) mov [p + 6*4], DWORD(tmp4) %ifndef SHA224 mov [p + 7*4], DWORD(tmp5) %endif clear_ret: %ifdef SAFE_DATA vpxorq zmm0, zmm0 ;; Clear digest (28B/32B), outer_block (28B/32B) and extra_block (64B) ;; of returned job and NULL jobs %assign I 0 %rep 16 cmp qword [state + _ldata_sha256 + (I*_HMAC_SHA1_LANE_DATA_size) + _job_in_lane], 0 jne APPEND(skip_clear_,I) ;; Clear digest (28 bytes for SHA-224, 32 bytes for SHA-256 bytes) %assign J 0 %rep 7 mov dword [state + _args_digest_sha256 + SHA256_DIGEST_WORD_SIZE*I + J*SHA256_DIGEST_ROW_SIZE], 0 %assign J (J+1) %endrep %ifndef SHA224 mov dword [state + _args_digest_sha256 + SHA256_DIGEST_WORD_SIZE*I + 7*SHA256_DIGEST_ROW_SIZE], 0 %endif lea lane_data, [state + _ldata_sha256 + (I*_HMAC_SHA1_LANE_DATA_size)] ;; Clear first 64 bytes of extra_block vmovdqu64 [lane_data + _extra_block], zmm0 ;; Clear first 28 bytes (SHA-224) or 32 bytes (SHA-256) of outer_block %ifdef SHA224 vmovdqa64 [lane_data + _outer_block], xmm0 mov qword [lane_data + _outer_block + 16], 0 mov dword [lane_data + _outer_block + 24], 0 %else vmovdqu64 [lane_data + _outer_block], ymm0 %endif APPEND(skip_clear_,I): %assign I (I+1) %endrep %endif ;; SAFE_DATA return: vzeroupper mov rbx, [rsp + _gpr_save + 8*0] mov rbp, [rsp + _gpr_save + 8*1] mov r12, [rsp + _gpr_save + 8*2] mov r13, [rsp + _gpr_save + 8*3] mov r14, [rsp + _gpr_save + 8*4] mov r15, [rsp + _gpr_save + 8*5] %ifndef LINUX mov rsi, [rsp + _gpr_save + 8*6] mov rdi, [rsp + _gpr_save + 8*7] %endif mov rsp, [rsp + _rsp_save] ; original SP ret mksection stack-noexec
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r15 push %rbp push %rcx push %rdi push %rsi lea addresses_UC_ht+0x8046, %rbp clflush (%rbp) nop nop nop nop inc %r13 mov (%rbp), %r15d nop nop nop nop nop and $53031, %r10 lea addresses_normal_ht+0x9446, %rsi lea addresses_D_ht+0x1b446, %rdi nop nop nop nop nop cmp $22760, %r10 mov $7, %rcx rep movsl nop nop nop nop nop add %r13, %r13 lea addresses_D_ht+0x1cd46, %r13 nop nop and %rcx, %rcx mov $0x6162636465666768, %r15 movq %r15, %xmm1 vmovups %ymm1, (%r13) nop nop nop nop sub $34960, %r13 lea addresses_D_ht+0x22a4, %r15 nop nop add %r10, %r10 movw $0x6162, (%r15) nop and %rbp, %rbp pop %rsi pop %rdi pop %rcx pop %rbp pop %r15 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r8 push %rdi push %rsi // Store lea addresses_PSE+0x10846, %r8 nop nop nop sub $9344, %rsi mov $0x5152535455565758, %r13 movq %r13, %xmm2 vmovups %ymm2, (%r8) nop nop add %rsi, %rsi // Faulty Load lea addresses_normal+0x18446, %r14 nop nop nop nop inc %r13 mov (%r14), %edi lea oracles, %rsi and $0xff, %rdi shlq $12, %rdi mov (%rsi,%rdi,1), %rdi pop %rsi pop %rdi pop %r8 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_PSE'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': False, 'same': True, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #include "stdafx.h" using namespace Common; using namespace std; using namespace ServiceModel; using namespace Management::ClusterManager; StringLiteral const TraceComponent("ApplicationContext"); RolloutContextType::Enum const ApplicationContextType(RolloutContextType::Application); ApplicationContext::ApplicationContext() : DeletableRolloutContext(ApplicationContextType) , applicationName_() , applicationId_() , globalInstanceCount_(0) , applicationVersion_(0) , appManifestId_() , packageInstance_(0) , appTypeName_() , appTypeVersion_() , appParameters_() , capacityDescription_() , isUpgrading_(false) , isCommitPending_(false) , pendingDefaultServicesLock_() , pendingDefaultServices_() , hasReportedHealthEntity_(false) , updateID_(0) , applicationDefinitionKind_(ApplicationDefinitionKind::Enum::ServiceFabricApplicationDescription) { } ApplicationContext::ApplicationContext( Common::NamingUri const & appName) : DeletableRolloutContext(ApplicationContextType) , applicationName_(appName) , applicationId_() , globalInstanceCount_(0) , applicationVersion_(0) , appManifestId_() , packageInstance_(0) , appTypeName_() , appTypeVersion_() , appParameters_() , capacityDescription_() , isUpgrading_(false) , isCommitPending_(false) , pendingDefaultServicesLock_() , pendingDefaultServices_() , hasReportedHealthEntity_(false) , updateID_(0) , applicationDefinitionKind_(ApplicationDefinitionKind::Enum::ServiceFabricApplicationDescription) { } ApplicationContext::ApplicationContext( Common::NamingUri const & appName, bool const isForceDelete) : DeletableRolloutContext(ApplicationContextType, isForceDelete) , applicationName_(appName) , applicationId_() , globalInstanceCount_(0) , applicationVersion_(0) , packageInstance_(0) , appTypeName_() , appTypeVersion_() , appManifestId_() , appParameters_() , capacityDescription_() , isUpgrading_(false) , isCommitPending_(false) , pendingDefaultServicesLock_() , pendingDefaultServices_() , hasReportedHealthEntity_(false) , updateID_(0) , applicationDefinitionKind_(ApplicationDefinitionKind::Enum::ServiceFabricApplicationDescription) { } ApplicationContext::ApplicationContext( ApplicationContext && other) : DeletableRolloutContext(move(other)) , applicationName_(move(other.applicationName_)) , applicationId_(move(other.applicationId_)) , globalInstanceCount_(move(other.globalInstanceCount_)) , applicationVersion_(move(other.applicationVersion_)) , packageInstance_(move(other.packageInstance_)) , appTypeName_(move(other.appTypeName_)) , appTypeVersion_(move(other.appTypeVersion_)) , appManifestId_(move(other.appManifestId_)) , appParameters_(move(other.appParameters_)) , capacityDescription_(move(other.capacityDescription_)) , isUpgrading_(move(other.isUpgrading_)) , isCommitPending_(move(other.isCommitPending_)) , pendingDefaultServicesLock_() , pendingDefaultServices_(move(other.pendingDefaultServices_)) , hasReportedHealthEntity_(move(other.hasReportedHealthEntity_)) , updateID_(other.updateID_) , applicationDefinitionKind_(other.ApplicationDefinitionKind) { } ApplicationContext & ApplicationContext::operator=( ApplicationContext && other) { if (this != &other) { __super::operator = (move(other)); applicationName_ = move(other.applicationName_); applicationId_ = move(other.applicationId_); globalInstanceCount_ = move(other.globalInstanceCount_); applicationVersion_ = move(other.applicationVersion_); packageInstance_ = move(other.packageInstance_); appTypeName_ = move(other.appTypeName_); appTypeVersion_ = move(other.appTypeVersion_); appManifestId_ = move(other.appManifestId_); appParameters_ = move(other.appParameters_); capacityDescription_ = move(other.capacityDescription_); isUpgrading_ = move(other.isUpgrading_); isCommitPending_ = move(other.isCommitPending_); applicationDefinitionKind_ = other.applicationDefinitionKind_; // don't move: pendingDefaultServicesLock_() pendingDefaultServices_ = move(other.pendingDefaultServices_); hasReportedHealthEntity_ = move(other.hasReportedHealthEntity_); updateID_ = other.updateID_; } return *this; } ApplicationContext::ApplicationContext( Common::ComponentRoot const & replica, ClientRequestSPtr const & clientRequest, Common::NamingUri const & appName, ServiceModelApplicationId const & appId, uint64 globalInstanceCount, ServiceModelTypeName const & typeName, ServiceModelVersion const & typeVersion, std::wstring const & appManifestId, std::map<std::wstring, std::wstring> const & appParameters) : DeletableRolloutContext(ApplicationContextType, replica, clientRequest) , applicationName_(appName) , applicationId_(appId) , globalInstanceCount_(globalInstanceCount) , applicationVersion_(0) , packageInstance_(DateTime::Now().Ticks) , appTypeName_(typeName) , appTypeVersion_(typeVersion) , appManifestId_(appManifestId) , appParameters_(appParameters) , capacityDescription_() , isUpgrading_(false) , isCommitPending_(false) , pendingDefaultServicesLock_() , pendingDefaultServices_() , hasReportedHealthEntity_(false) , updateID_(0) , applicationDefinitionKind_(ApplicationDefinitionKind::Enum::ServiceFabricApplicationDescription) { WriteNoise( TraceComponent, "{0} ctor({1}, {2}, Instance = {3}, {4}, {5}, {6})", this->TraceId, appName, appId, globalInstanceCount, typeName, typeVersion, applicationDefinitionKind_); } ApplicationContext::ApplicationContext( Store::ReplicaActivityId const &replicaActivityId, Common::NamingUri const & appName, ServiceModelApplicationId const & appId, uint64 globalInstanceCount, ServiceModelTypeName const & typeName, ServiceModelVersion const & typeVersion, std::wstring const & appManifestId, std::map<std::wstring, std::wstring> const & appParameters, ApplicationDefinitionKind::Enum const applicationDefinitionKind) : DeletableRolloutContext(ApplicationContextType, replicaActivityId) , applicationName_(appName) , applicationId_(appId) , globalInstanceCount_(globalInstanceCount) , applicationVersion_(0) , packageInstance_(DateTime::Now().Ticks) , appTypeName_(typeName) , appTypeVersion_(typeVersion) , appManifestId_(appManifestId) , appParameters_(appParameters) , capacityDescription_() , isUpgrading_(false) , isCommitPending_(false) , pendingDefaultServicesLock_() , pendingDefaultServices_() , hasReportedHealthEntity_(false) , updateID_(0) , applicationDefinitionKind_(applicationDefinitionKind) { WriteNoise( TraceComponent, "{0} ctor({1}, {2}, Instance = {3}, {4}, {5})", this->TraceId, appName, appId, globalInstanceCount, typeName, typeVersion); } ApplicationContext::~ApplicationContext() { if (replicaSPtr_) { WriteNoise( TraceComponent, "{0} ~dtor", this->TraceId); } } ApplicationQueryResult ApplicationContext::ToQueryResult(bool excludeApplicationParameters) const { ApplicationStatus::Enum applicationStatus; if (this->IsUpgrading) { applicationStatus = ApplicationStatus::Upgrading; } else if (this->IsPending) { applicationStatus = ApplicationStatus::Creating; } else if (this->IsDeleting) { applicationStatus = ApplicationStatus::Deleting; } else if (this->IsFailed) { applicationStatus = ApplicationStatus::Failed; } else { applicationStatus = ApplicationStatus::Ready; } return ApplicationQueryResult( this->ApplicationName, this->TypeName.Value, this->TypeVersion.Value, applicationStatus, excludeApplicationParameters ? map<wstring, wstring>() : this->Parameters, ApplicationDefinitionKind::ToPublicApi(applicationDefinitionKind_), L"", // deprecated field as of v2.2 map<wstring, wstring>()); // deprecated field as of v2.2 } std::wstring const & ApplicationContext::get_Type() const { return Constants::StoreType_ApplicationContext; } std::wstring ApplicationContext::ConstructKey() const { wstring temp; StringWriter writer(temp); writer.Write("{0}", applicationName_); return temp; } void ApplicationContext::WriteTo(Common::TextWriter & w, Common::FormatOptions const &) const { w.Write( "ApplicationContext({0})[{1}, {2}, {3} ({4}, {5}, {6}) ({7}, {8}) ({9}) ({10})]", this->Status, applicationName_, applicationId_, applicationDefinitionKind_, globalInstanceCount_, applicationVersion_, packageInstance_, appTypeName_, appTypeVersion_, capacityDescription_, appManifestId_); } bool ApplicationContext::CanAcceptUpgrade( ApplicationUpgradeDescription const & upgradeDescription, StoreDataApplicationManifest const & currentManifest) const { if (this->TypeVersion != ServiceModelVersion(upgradeDescription.TargetApplicationTypeVersion)) { return true; } auto currentMergedParameters = currentManifest.GetMergedApplicationParameters(this->Parameters); auto targetMergedParameters = currentManifest.GetMergedApplicationParameters(upgradeDescription.ApplicationParameters); // Don't expect count of parameters to change since the merge is based on the same manifest. // ImageBuilder will pick up on any validation errors due to extra (invalid) parameters that // may exist. // if (currentMergedParameters.size() != targetMergedParameters.size()) { return true; } // Even if type version doesn't change, allow upgrades in which only the // application parameters have changed // for (auto it=targetMergedParameters.begin(); it!=targetMergedParameters.end(); ++it) { auto find_it = currentMergedParameters.find(it->first); if (find_it == currentMergedParameters.end() || find_it->second != it->second) { return true; } } return false; } void ApplicationContext::SetApplicationVersion(uint64 applicationVersion) { applicationVersion_ = applicationVersion; } void ApplicationContext::SetApplicationAndTypeVersion(uint64 applicationVersion, ServiceModelVersion const & version) { applicationVersion_ = applicationVersion; appTypeVersion_ = version; } void ApplicationContext::SetApplicationParameters(std::map<std::wstring, std::wstring> const & applicationParameters) { appParameters_ = applicationParameters; } Common::ErrorCode ApplicationContext::SetApplicationCapacity(Reliability::ApplicationCapacityDescription const & applicationCapacity) { wstring errorMessage; if (!applicationCapacity.TryValidate(errorMessage)) { return ErrorCode(ErrorCodeValue::InvalidArgument, move(errorMessage)); } capacityDescription_ = applicationCapacity; return ErrorCodeValue::Success; } void ApplicationContext::SetHasReportedHealthEntity() { hasReportedHealthEntity_ = true; } wstring ApplicationContext::GetKeyPrefix(ServiceModelApplicationId const & appId) { wstring temp; StringWriter writer(temp); writer.Write("{0}{1}", appId, Constants::TokenDelimeter); return temp; } ErrorCode ApplicationContext::SetUpgradePending(Store::StoreTransaction const & storeTx, uint64 packageInstance) { isUpgrading_ = true; if (packageInstance > 0) { packageInstance_ = packageInstance; } return this->UpdateStatus(storeTx, RolloutStatus::Pending); } ErrorCode ApplicationContext::SetUpgradeComplete(Store::StoreTransaction const & storeTx, uint64 packageInstance) { isUpgrading_ = false; packageInstance_ = packageInstance; return this->Complete(storeTx); } void ApplicationContext::AddPendingDefaultService(ServiceModelServiceNameEx && names) { AcquireExclusiveLock lock(pendingDefaultServicesLock_); auto findIter = find(pendingDefaultServices_.begin(), pendingDefaultServices_.end(), names); if (findIter == pendingDefaultServices_.end()) { pendingDefaultServices_.push_back(move(names)); } } void ApplicationContext::ClearPendingDefaultServices() { AcquireExclusiveLock lock(pendingDefaultServicesLock_); pendingDefaultServices_.clear(); }
#ifndef __INVERTED_PENGUIN__EXCEPTIONS__INVERTEDPENGUINEXCEPTION_HPP__ #define __INVERTED_PENGUIN__EXCEPTIONS__INVERTEDPENGUINEXCEPTION_HPP__ #include <pistis/exceptions/PistisException.hpp> #include <string> namespace inverted_penguin { namespace exceptions { class InvertedPenguinException : public pistis::exceptions::PistisException { public: InvertedPenguinException(const std::string& details); InvertedPenguinException( const std::string& details, const pistis::exceptions::ExceptionOrigin& origin ); InvertedPenguinException(const InvertedPenguinException&) = default; InvertedPenguinException(InvertedPenguinException&&) = default; virtual ~InvertedPenguinException(); InvertedPenguinException& operator=(const InvertedPenguinException&) = default; InvertedPenguinException& operator=(InvertedPenguinException&) = default; private: std::string details_; }; } } #endif
.data linebrk: .asciiz "\n" .text main: li $s0, 1 # $s0 = loop counter li $s1, 10 # $s1 = upper bound of loop loop: move $a0, $s0 # print loop counter $s0 li $v0, 1 syscall li $v0, 4 # print new line la $a0, linebrk syscall addi $s0, $s0, 1 # increase counter by 1 ble $s0, $s1, loop # if ($s0 <= $s1) go to loop li $v0, 10 # exit syscall
; A218376: a(n) = 5^n*sum_{i=1..n} i^5/5^i. ; Submitted by Jamie Morken(s1) ; 0,1,37,428,3164,18945,102501,529312,2679328,13455689,67378445,337053276,1685515212,8427947353,42140274589,210702132320,1053511710176,5267559970737,26337801743253,131689011192364,658445059161820 mov $3,$0 mov $5,$0 lpb $3 mov $0,$5 sub $3,1 sub $0,$3 mul $1,$6 mov $2,$0 gcd $4,2 mov $6,3 add $6,$4 pow $2,$6 add $1,$2 lpe mov $0,$1
add x16, x15, x5
; Sony SMC-777 console ; SECTION code_clib PUBLIC generic_console_cls PUBLIC generic_console_vpeek PUBLIC generic_console_scrollup PUBLIC generic_console_printc PUBLIC generic_console_set_ink PUBLIC generic_console_set_paper PUBLIC generic_console_set_attribute EXTERN generic_console_flags EXTERN conio_map_colour EXTERN __smc777_mode EXTERN __smc777_attr EXTERN __smc777_ink16 EXTERN __smc777_paper16 EXTERN CONSOLE_COLUMNS EXTERN CONSOLE_ROWS generic_console_set_attribute: ld a,(generic_console_flags) rrca rrca and @00100000 ld c,a ld a,(__smc777_attr) and @11011111 set_attr: or c ld (__smc777_attr),a ret generic_console_set_ink: call conio_map_colour push af and 7 ld c,a ld a,(__smc777_attr) and @11111000 call set_attr pop af call nc,rotate ;attribute is in high nibble and 15 ld (__smc777_ink16),a ret generic_console_set_paper: call conio_map_colour call nc,rotate ;colour from table, is in high nibble and 15 ld (__smc777_paper16),a ret rotate: rrca rrca rrca rrca ret generic_console_cls: ld hl, +(CONSOLE_ROWS * CONSOLE_COLUMNS) ld bc, 0 continue: ld a,' ' out (c),a set 3,c ld a,(__smc777_attr) out (c),a res 3,c inc b jr nz,loop inc c loop: dec hl ld a,h or l jr nz,continue ld a,(__smc777_mode) and @00001100 ret z cp @00001000 jr z,get_bgattr_640 call get_bgattr_320 clg: ld bc,$0080 clg_1: out (c),l inc b jr nz,clg_1 inc c jr nz,clg_1 ret get_bgattr_320: ld a,(__smc777_paper16) and @00001111 ld l,a rlca rlca rlca rlca or l ld l,a ret get_bgattr_640: ld a,(__smc777_paper16) and @00000011 ld l,a rlca rlca or l rlca rlca or l rlca rlca or l ld l,a jr clg ; c = x ; b = y ; a = character to print ; e = raw generic_console_printc: call xypos out (c),a set 3,c ld a,(__smc777_attr) out (c),a ret ;Entry: c = x, ; b = y ;Exit: nc = success ; a = character, ; c = failure generic_console_vpeek: call xypos in a,(c) and a ret xypos: ld hl,-CONSOLE_COLUMNS ld de,CONSOLE_COLUMNS inc b generic_console_printc_1: add hl,de djnz generic_console_printc_1 generic_console_printc_3: add hl,bc ;hl now points to address in display ex af,af ld a,(__smc777_mode) and @00000011 jr z,is_80_col add hl,bc is_80_col: ex af,af ld c,h ;And swap round ld b,l ret generic_console_scrollup: push de push bc ld bc, +(CONSOLE_COLUMNS * 256) ld hl,+((CONSOLE_ROWS -1)* CONSOLE_COLUMNS) scroll_loop: push hl push bc in e,(c) set 3,c in d,(c) ld l,b ld h,c ld bc,-CONSOLE_COLUMNS add hl,bc ld c,h ld b,l out (c),d res 3,c out (c),e pop bc inc b jr nz,scroll_continue inc c scroll_continue: pop hl dec hl ld a,h or l jr nz,scroll_loop ld bc,$8007 ;Row 25, column 0 ld e,CONSOLE_COLUMNS ld d,' ' ld a,(__smc777_attr) scroll_loop_2: out (c),d set 3,c out (c),a res 3,c inc b jr nz,clear_continue inc c clear_continue: dec e jr nz,scroll_loop_2 pop bc pop de ret SECTION code_crt_init EXTERN asm_set_cursor_state EXTERN copy_font_8x8 EXTERN CRT_FONT ld l,$20 call asm_set_cursor_state ld bc,$1000 + (32 * 8) ld e,96 ld hl,CRT_FONT ld a,h or l call nz,copy_font_8x8
; A002063: a(n) = 9*4^n. ; 9,36,144,576,2304,9216,36864,147456,589824,2359296,9437184,37748736,150994944,603979776,2415919104,9663676416,38654705664,154618822656,618475290624,2473901162496,9895604649984,39582418599936,158329674399744,633318697598976,2533274790395904,10133099161583616,40532396646334464,162129586585337856,648518346341351424,2594073385365405696,10376293541461622784,41505174165846491136,166020696663385964544,664082786653543858176,2656331146614175432704,10625324586456701730816,42501298345826806923264 mov $1,4 pow $1,$0 mul $1,9 mov $0,$1
/*************************************************************************** Cisco Heat & F1 GrandPrix Star (c) 1990 & 1991 Jaleco driver by Luca Elia (eliavit@unina.it) Note: if MAME_DEBUG is defined, pressing Z with: Q,W,E shows scroll 0,1,2 R,T shows road 0,1 A,S,D,F shows sprites with priority 0,1,2,3 N shows sprites attribute M disables sprites zooming U toggles the display of some hardware registers' values ($80000/2/4/6) Keys can be used togheter! Additionally, layers can be disabled, writing to $82400 (fake video register): ---- ---- --54 ---- Enable Road 1,0 ---- ---- ---- 3--- Enable Sprites ---- ---- ---- -210 Enable Scroll 2,1,0 0 is the same as 0x3f ---------------------------------------------------------------------- Video Section Summary [ Cisco Heat ] [ F1 GP Star ] ---------------------------------------------------------------------- [ 3 Scrolling Layers ] see Megasys1.c Tile Format: Colour fedc b--- ---- ---- fedc ---- ---- ---- Code ---- -a98 7654 3210 ---- ba98 7654 3210 Layer Size: May be different from Megasys1? [ 2 Road Layers ] Each of the 256 (not all visible) lines of the screen can display any of the lines of gfx in ROM, which are larger than the sceen and can therefore be scrolled Line Width 1024 1024 Zoom No Yes [ 256 Sprites ] Each Sprite is up to 256x256 pixels (!) and can be zoomed in and out. See below. ***************************************************************************/ #include "driver.h" #include "drivers/megasys1.h" #include "vidhrdw/generic.h" /* Variables only used here: */ static int cischeat_ip_select; /* Variables that driver has access to: */ unsigned char *cischeat_roadram[2]; /* Variables defined in driver: */ /*************************************************************************** vh_start ***************************************************************************/ /************************************************************************** [ Cisco Heat ] **************************************************************************/ /* 32 colour codes for the tiles */ int cischeat_vh_start(void) { if (megasys1_vh_start() == 0) { megasys1_bits_per_color_code = 5; return 0; } else return 1; } /************************************************************************** [ F1 GrandPrix Star ] **************************************************************************/ /* 16 colour codes for the tiles */ int f1gpstar_vh_start(void) { if (megasys1_vh_start() == 0) { megasys1_bits_per_color_code = 4; return 0; } else return 1; } /*************************************************************************** Hardware registers access ***************************************************************************/ /* This function returns the status of the shift (ACTIVE_LOW): 1 - low shift 0 - high shift and allows the shift to be handled using two buttons */ static int read_shift(void) { static int ret = 1; /* start with low shift */ switch ( (readinputport(0) >> 2) & 3 ) { case 1 : ret = 1; break; // low shift: button 3 case 2 : ret = 0; break; // high shift: button 4 } return ret; } /* F1 GP Star has a real pedal, while Cisco Heat's is connected to a switch. The Former game stores, during boot, the value that corresponds to the pedal not pressed, and compares against it: The value returned must decrease when the pedal is pressed. We support just 2 values for now.. */ static int read_accelerator(void) { if (readinputport(0) & 1) return 0x00; // pedal pressed else return 0xff; } /************************************************************************** [ Cisco Heat ] **************************************************************************/ READ_HANDLER( cischeat_vregs_r ) { switch (offset) { case 0x0000 : return readinputport(1); // Coins case 0x0002 : return readinputport(2) + (read_shift()<<1); // Buttons case 0x0004 : return readinputport(3); // Motor Limit Switches case 0x0006 : return readinputport(4); // DSW 1 & 2 case 0x0010 : switch (cischeat_ip_select & 0x3) { case 0 : return readinputport(6); // Driving Wheel case 1 : return 0xFFFF; // Cockpit: Up / Down Position? case 2 : return 0xFFFF; // Cockpit: Left / Right Position? default: return 0xFFFF; } case 0x2200 : return readinputport(5); // DSW 3 (4 bits) case 0x2300 : return soundlatch2_r(0); // From sound cpu default: return READ_WORD(&megasys1_vregs[offset]); } } /************************************************************************** [ F1 GrandPrix Star ] **************************************************************************/ READ_HANDLER( f1gpstar_vregs_r ) { switch (offset) { case 0x0000 : // DSW 1&2: coinage changes with Country { int val = readinputport(1); if (val & 0x0200) return readinputport(6) | val; // JP, US else return readinputport(7) | val; // UK, FR } // case 0x0002 : return 0xFFFF; case 0x0004 : return readinputport(2) + (read_shift()<<5); // Buttons case 0x0006 : return readinputport(3); // ? Read at boot only case 0x0008 : return soundlatch2_r(0); // From sound cpu case 0x000c : return readinputport(4); // DSW 3 case 0x0010 : // Accel + Driving Wheel return (read_accelerator()&0xff) + ((readinputport(5)&0xff)<<8); default: return READ_WORD(&megasys1_vregs[offset]); } } /************************************************************************** [ Cisco Heat ] **************************************************************************/ WRITE_HANDLER( cischeat_vregs_w ) { int old_data, new_data; old_data = READ_WORD(&megasys1_vregs[offset]); COMBINE_WORD_MEM(&megasys1_vregs[offset],data); new_data = READ_WORD(&megasys1_vregs[offset]); switch (offset) { case 0x0000 : // leds osd_led_w(0, (new_data >> 4) & 1 ); osd_led_w(1, (new_data >> 5) & 1 ); break; case 0x0002 : // ?? 91/1/91/1 ... break; case 0x0004 : // motor (seat?) osd_led_w(2, (new_data != old_data) ? 1 : 0); break; case 0x0006 : // motor (wheel?) break; case 0x0010 : cischeat_ip_select = new_data; break; case 0x0012 : break; // value above + 1 case 0x2000+0 : MEGASYS1_VREG_SCROLL(0,x) break; case 0x2000+2 : MEGASYS1_VREG_SCROLL(0,y) break; case 0x2000+4 : MEGASYS1_VREG_FLAG(0) break; case 0x2008+0 : MEGASYS1_VREG_SCROLL(1,x) break; case 0x2008+2 : MEGASYS1_VREG_SCROLL(1,y) break; case 0x2008+4 : MEGASYS1_VREG_FLAG(1) break; case 0x2100+0 : MEGASYS1_VREG_SCROLL(2,x) break; case 0x2100+2 : MEGASYS1_VREG_SCROLL(2,y) break; case 0x2100+4 : MEGASYS1_VREG_FLAG(2) break; case 0x2108 : break; // ? written with 0 only case 0x2208 : break; // watchdog reset case 0x2300 : /* Sound CPU: reads latch during int 4, and stores command */ soundlatch_w(0,new_data); cpu_cause_interrupt(3,4); break; /* Not sure about this one.. */ case 0x2308 : cpu_set_reset_line(1, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE ); cpu_set_reset_line(2, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE ); cpu_set_reset_line(3, (new_data & 1) ? ASSERT_LINE : CLEAR_LINE ); break; } } /************************************************************************** [ F1 GrandPrix Star ] **************************************************************************/ WRITE_HANDLER( f1gpstar_vregs_w ) { int old_data, new_data; old_data = READ_WORD(&megasys1_vregs[offset]); COMBINE_WORD_MEM(&megasys1_vregs[offset],data); new_data = READ_WORD(&megasys1_vregs[offset]); switch (offset) { /* CPU #0 PC 00234A : Warning, vreg 0000 <- 0000 CPU #0 PC 002350 : Warning, vreg 0002 <- 0000 CPU #0 PC 00235C : Warning, vreg 0006 <- 0000 */ // "shudder" motors, leds case 0x0004 : case 0x0014 : osd_led_w(0, (new_data >> 2) & 1 ); // 1p start lamp osd_led_w(1, (new_data >> 5) & 1 ); // 2p start lamp? // wheel | seat motor osd_led_w(2, ((new_data >> 3) | (new_data >> 4)) & 1 ); break; /* Usually written in sequence, but not always */ case 0x0008 : soundlatch_w(0,new_data); break; case 0x0018 : cpu_cause_interrupt(3,4); break; case 0x0010 : break; case 0x2000+0 : MEGASYS1_VREG_SCROLL(0,x) break; case 0x2000+2 : MEGASYS1_VREG_SCROLL(0,y) break; case 0x2000+4 : MEGASYS1_VREG_FLAG(0) break; case 0x2008+0 : MEGASYS1_VREG_SCROLL(1,x) break; case 0x2008+2 : MEGASYS1_VREG_SCROLL(1,y) break; case 0x2008+4 : MEGASYS1_VREG_FLAG(1) break; case 0x2100+0 : MEGASYS1_VREG_SCROLL(2,x) break; case 0x2100+2 : MEGASYS1_VREG_SCROLL(2,y) break; case 0x2100+4 : MEGASYS1_VREG_FLAG(2) break; case 0x2108 : break; // ? written with 0 only case 0x2208 : break; // watchdog reset /* Not sure about this one. Values: $10 then 0, $7 then 0 */ case 0x2308 : cpu_set_reset_line(1, (new_data & 1) ? ASSERT_LINE : CLEAR_LINE ); cpu_set_reset_line(2, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE ); cpu_set_reset_line(3, (new_data & 4) ? ASSERT_LINE : CLEAR_LINE ); break; } } /*************************************************************************** Road Drawing ***************************************************************************/ #define ROAD_COLOR_CODES 64 #define ROAD_COLOR(_x_) ((_x_) & (ROAD_COLOR_CODES-1)) /* horizontal size of 1 line and 1 tile of the road */ #define X_SIZE (1024) #define TILE_SIZE (64) /************************************************************************** [ Cisco Heat ] **************************************************************************/ /* Road format: Offset Data 00.w Code 02.w X Scroll 04.w fedc ---- ---- ---- unused? ---- ba98 ---- ---- Priority ---- ---- 76-- ---- unused? ---- ---- --54 3210 Color 06.w Unused */ void cischeat_mark_road_colors(int road_num) { int i, color, colmask[ROAD_COLOR_CODES], sy; int gfx_num = (road_num & 1) ? 4 : 3; struct GfxDecodeInfo gfx = Machine->drv->gfxdecodeinfo[gfx_num]; int total_elements = Machine->gfx[gfx_num]->total_elements; unsigned int *pen_usage = Machine->gfx[gfx_num]->pen_usage; // int total_color_codes = gfx.total_color_codes; int color_codes_start = gfx.color_codes_start; unsigned char *roadram = cischeat_roadram[road_num & 1]; int min_y = Machine->visible_area. min_y; int max_y = Machine->visible_area. max_y; for (color = 0 ; color < ROAD_COLOR_CODES ; color++) colmask[color] = 0; /* Let's walk from the top to the bottom of the visible screen */ for (sy = min_y ; sy <= max_y ; sy ++) { int code = READ_WORD(&roadram[sy*8 + 0]); int attr = READ_WORD(&roadram[sy*8 + 4]); color = ROAD_COLOR(attr); /* line number converted to tile number (each tile is TILE_SIZE x 1) */ code = code * (X_SIZE/TILE_SIZE); for (i = 0; i < (X_SIZE/TILE_SIZE); i++) colmask[color] |= pen_usage[(code + i) % total_elements]; } for (color = 0; color < ROAD_COLOR_CODES; color++) for (i = 0; i < 16; i++) if (colmask[color] & (1 << i)) palette_used_colors[16 * color + i + color_codes_start] = PALETTE_COLOR_USED; } /* Draw road in the given bitmap. The priority1 and priority2 parameters specify the range of lines to draw */ void cischeat_draw_road(struct osd_bitmap *bitmap, int road_num, int priority1, int priority2, int transparency) { int curr_code,sx,sy; int min_priority, max_priority; struct rectangle rect = Machine->visible_area; unsigned char *roadram = cischeat_roadram[road_num & 1]; struct GfxElement *gfx = Machine->gfx[(road_num & 1)?4:3]; int min_y = rect.min_y; int max_y = rect.max_y; int max_x = rect.max_x; if (priority1 < priority2) { min_priority = priority1; max_priority = priority2; } else { min_priority = priority2; max_priority = priority1; } /* Move the priority values in place */ min_priority = (min_priority & 7) * 0x100; max_priority = (max_priority & 7) * 0x100; /* Let's draw from the top to the bottom of the visible screen */ for (sy = min_y ; sy <= max_y ; sy ++) { int code = READ_WORD(&roadram[sy*8 + 0]); int xscroll = READ_WORD(&roadram[sy*8 + 2]); int attr = READ_WORD(&roadram[sy*8 + 4]); /* high byte is a priority information */ if ( ((attr & 0x700) < min_priority) || ((attr & 0x700) > max_priority) ) continue; /* line number converted to tile number (each tile is TILE_SIZE x 1) */ code = code * (X_SIZE/TILE_SIZE); xscroll %= X_SIZE; curr_code = code + xscroll/TILE_SIZE; for (sx = -(xscroll%TILE_SIZE) ; sx <= max_x ; sx +=TILE_SIZE) { drawgfx(bitmap,gfx, curr_code++, ROAD_COLOR(attr), 0,0, sx,sy, &rect, transparency,15); /* wrap around */ if (curr_code%(X_SIZE/TILE_SIZE)==0) curr_code = code; } } } /************************************************************************** [ F1 GrandPrix Star ] **************************************************************************/ /* Road format: Offset Data 00.w fedc ---- ---- ---- Priority ---- ba98 7654 3210 X Scroll (After Zoom) 02.w fedc ba-- ---- ---- unused? ---- --98 7654 3210 X Zoom 04.w fe-- ---- ---- ---- unused? --dc ba98 ---- ---- Color ---- ---- 7654 3210 ? 06.w Code Imagine an "empty" line, 2 * X_SIZE wide, with the gfx from the ROM - whose original size is X_SIZE - in the middle. Zooming acts on this latter and can shrink it to 1 pixel or widen it to 2 * X_SIZE, while *keeping it centered* in the empty line. Scrolling acts on the resulting line. */ void f1gpstar_mark_road_colors(int road_num) { int i, color, colmask[ROAD_COLOR_CODES], sy; int gfx_num = (road_num & 1) ? 4 : 3; struct GfxDecodeInfo gfx = Machine->drv->gfxdecodeinfo[gfx_num]; int total_elements = Machine->gfx[gfx_num]->total_elements; unsigned int *pen_usage = Machine->gfx[gfx_num]->pen_usage; // int total_color_codes = gfx.total_color_codes; int color_codes_start = gfx.color_codes_start; unsigned char *roadram = cischeat_roadram[road_num & 1]; int min_y = Machine->visible_area.min_y; int max_y = Machine->visible_area.max_y; for (color = 0 ; color < ROAD_COLOR_CODES ; color++) colmask[color] = 0; /* Let's walk from the top to the bottom of the visible screen */ for (sy = min_y ; sy <= max_y ; sy ++) { int code = READ_WORD(&roadram[sy*8 + 6]); int attr = READ_WORD(&roadram[sy*8 + 4]); color = ROAD_COLOR(attr>>8); /* line number converted to tile number (each tile is TILE_SIZE x 1) */ code = code * (X_SIZE/TILE_SIZE); for (i = 0; i < (X_SIZE/TILE_SIZE); i++) colmask[color] |= pen_usage[(code + i) % total_elements]; } for (color = 0; color < ROAD_COLOR_CODES; color++) for (i = 0; i < 16; i++) if (colmask[color] & (1 << i)) palette_used_colors[16 * color + i + color_codes_start] = PALETTE_COLOR_USED; } /* Draw road in the given bitmap. The priority1 and priority2 parameters specify the range of lines to draw */ void f1gpstar_draw_road(struct osd_bitmap *bitmap, int road_num, int priority1, int priority2, int transparency) { int sx,sy; int xstart; int min_priority, max_priority; struct rectangle rect = Machine->visible_area; unsigned char *roadram = cischeat_roadram[road_num & 1]; struct GfxElement *gfx = Machine->gfx[(road_num & 1)?4:3]; int min_y = rect.min_y; int max_y = rect.max_y; int max_x = rect.max_x << 16; // use fixed point values (16.16), for accuracy if (priority1 < priority2) { min_priority = priority1; max_priority = priority2; } else { min_priority = priority2; max_priority = priority1; } /* Move the priority values in place */ min_priority = (min_priority & 7) * 0x1000; max_priority = (max_priority & 7) * 0x1000; /* Let's draw from the top to the bottom of the visible screen */ for (sy = min_y ; sy <= max_y ; sy ++) { int xscale, xdim; int xscroll = READ_WORD(&roadram[sy*8 + 0]); int xzoom = READ_WORD(&roadram[sy*8 + 2]); int attr = READ_WORD(&roadram[sy*8 + 4]); int code = READ_WORD(&roadram[sy*8 + 6]); /* highest nibble is a priority information */ if ( ((xscroll & 0x7000) < min_priority) || ((xscroll & 0x7000) > max_priority) ) continue; /* zoom code range: 000-3ff scale range: 0.0-2.0 */ xscale = ( ((xzoom & 0x3ff)+1) << (16+1) ) / 0x400; /* line number converted to tile number (each tile is TILE_SIZE x 1) */ code = code * (X_SIZE/TILE_SIZE); /* dimension of a tile after zoom */ xdim = TILE_SIZE * xscale; xscroll %= 2 * X_SIZE; xstart = (X_SIZE - xscroll) * 0x10000; xstart -= (X_SIZE * xscale) / 2; /* let's approximate to the nearest greater integer value to avoid holes in between tiles */ xscale += (1<<16)/TILE_SIZE; /* Draw the line */ for (sx = xstart ; sx <= max_x ; sx += xdim) { drawgfxzoom(bitmap,gfx, code++, ROAD_COLOR(attr>>8), 0,0, sx / 0x10000, sy, &rect, transparency,15, xscale, 1 << 16); /* stop when the end of the line of gfx is reached */ if ((code % (X_SIZE/TILE_SIZE)) == 0) break; } } } /*************************************************************************** Sprites Drawing ***************************************************************************/ #define SIGN_EXTEND_POS(_var_) {_var_ &= 0x3ff; if (_var_ > 0x1ff) _var_ -= 0x400;} #define SPRITE_COLOR_CODES (0x80) #define SPRITE_COLOR(_x_) ((_x_) & (SPRITE_COLOR_CODES - 1)) #define SHRINK(_org_,_fact_) ( ( (_org_) << 16 ) * (_fact_ & 0xff) / 0x80 ) /* Mark colors used by visible sprites */ static void cischeat_mark_sprite_colors(void) { int i, color, colmask[SPRITE_COLOR_CODES]; unsigned int *pen_usage = Machine->gfx[5]->pen_usage; int total_elements = Machine->gfx[5]->total_elements; int color_codes_start = Machine->drv->gfxdecodeinfo[5].color_codes_start; int xmin = Machine->visible_area.min_x; int xmax = Machine->visible_area.max_x; int ymin = Machine->visible_area.min_y; int ymax = Machine->visible_area.max_y; unsigned char *source = spriteram; const unsigned char *finish = source + 0x1000; for (color = 0 ; color < SPRITE_COLOR_CODES ; color++) colmask[color] = 0; for (; source < finish; source += 0x10 ) { int sx, sy, xzoom, yzoom; int xdim, ydim, xnum, ynum; int code, attr, size; size = READ_WORD(&source[0x00]); if (size & 0x1000) continue; /* number of tiles */ xnum = ( (size & 0x0f) >> 0 ) + 1; ynum = ( (size & 0xf0) >> 4 ) + 1; xzoom = READ_WORD(&source[0x02]); yzoom = READ_WORD(&source[0x04]); sx = READ_WORD(&source[0x06]); sy = READ_WORD(&source[0x08]); SIGN_EXTEND_POS(sx) SIGN_EXTEND_POS(sy) /* dimension of the sprite after zoom */ xdim = ( SHRINK(16 * xnum, xzoom) ) >> 16; ydim = ( SHRINK(16 * ynum, yzoom) ) >> 16; /* the y pos passed to the hardware is the that of the last line we need the y pos of the first line */ sy -= ydim; if ( ((sx+xdim-1) < xmin) || (sx > xmax) || ((sy+ydim-1) < ymin) || (sy > ymax) ) continue; code = READ_WORD(&source[0x0C]); attr = READ_WORD(&source[0x0E]); color = SPRITE_COLOR(attr); for (i = 0; i < xnum * ynum; i++) colmask[color] |= pen_usage[(code + i) % total_elements]; } for (color = 0; color < SPRITE_COLOR_CODES; color++) for (i = 0; i < (16-1); i++) // pen 15 is transparent if (colmask[color] & (1 << i)) palette_used_colors[16 * color + i + color_codes_start] = PALETTE_COLOR_USED; } /* Draw sprites, in the given priority range, to a bitmap. Priorities between 0 and 15 cover sprites whose priority nibble is between 0 and 15. Priorities between 0+16 and 15+16 cover sprites whose priority nibble is between 0 and 15 and whose colour code's high bit is set. Sprite Data: Offset Data 00 fed- ---- ---- ---- unused? ---c ---- ---- ---- Don't display this sprite ---- ba98 ---- ---- unused? ---- ---- 7654 ---- Number of tiles along Y, minus 1 (1-16) ---- ---- ---- 3210 Number of tiles along X, minus 1 (1-16) 02/04 fed- ---- ---- ---- unused? ---c ---- ---- ---- Flip X/Y ---- ba98 ---- ---- unused? ---- ---- 7654 3210 X/Y zoom 06/08 fedc ba-- ---- ---- unused? ---- --98 7654 3210 X/Y position 0A ? 0C Code 0E fed- ---- ---- ---- unused? ---c ---- ---- ---- used! ---- ba98 ---- ---- Priority ---- ---- 7--- ---- unused? ---- ---- -654 3210 Color */ static void cischeat_draw_sprites(struct osd_bitmap *bitmap , int priority1, int priority2) { int x, y, sx, sy; int xzoom, yzoom, xscale, yscale, flipx, flipy; int xdim, ydim, xnum, ynum; int xstart, ystart, xend, yend, xinc, yinc; int code, attr, color, size; int min_priority, max_priority, high_sprites; unsigned char *source = spriteram; const unsigned char *finish = source + 0x1000; /* Move the priority values in place */ high_sprites = (priority1 >= 16) | (priority2 >= 16); priority1 = (priority1 & 0x0f) * 0x100; priority2 = (priority2 & 0x0f) * 0x100; if (priority1 < priority2) { min_priority = priority1; max_priority = priority2; } else { min_priority = priority2; max_priority = priority1; } for (; source < finish; source += 0x10 ) { size = READ_WORD(&source[0x00]); if (size & 0x1000) continue; /* number of tiles */ xnum = ( (size & 0x0f) >> 0 ) + 1; ynum = ( (size & 0xf0) >> 4 ) + 1; xzoom = READ_WORD(&source[0x02]); yzoom = READ_WORD(&source[0x04]); flipx = xzoom & 0x1000; flipy = yzoom & 0x1000; sx = READ_WORD(&source[0x06]); sy = READ_WORD(&source[0x08]); SIGN_EXTEND_POS(sx) SIGN_EXTEND_POS(sy) /* use fixed point values (16.16), for accuracy */ sx <<= 16; sy <<= 16; /* dimension of a tile after zoom */ { xdim = SHRINK(16,xzoom); ydim = SHRINK(16,yzoom); } if ( ( (xdim / 0x10000) == 0 ) || ( (ydim / 0x10000) == 0) ) continue; /* the y pos passed to the hardware is the that of the last line we need the y pos of the first line */ sy -= (ydim * ynum); code = READ_WORD(&source[0x0C]); attr = READ_WORD(&source[0x0E]); color = SPRITE_COLOR(attr); /* high byte is a priority information */ if ( ((attr & 0x700) < min_priority) || ((attr & 0x700) > max_priority) ) continue; if ( high_sprites && (!(color & (SPRITE_COLOR_CODES/2))) ) continue; xscale = xdim / 16; yscale = ydim / 16; /* let's approximate to the nearest greater integer value to avoid holes in between tiles */ if (xscale & 0xffff) xscale += (1<<16)/16; if (yscale & 0xffff) yscale += (1<<16)/16; if (flipx) { xstart = xnum-1; xend = -1; xinc = -1; } else { xstart = 0; xend = xnum; xinc = +1; } if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } else { ystart = 0; yend = ynum; yinc = +1; } for (y = ystart; y != yend; y += yinc) { for (x = xstart; x != xend; x += xinc) { drawgfxzoom(bitmap,Machine->gfx[5], code++, color, flipx,flipy, (sx + x * xdim) / 0x10000, (sy + y * ydim) / 0x10000, &Machine->visible_area, TRANSPARENCY_PEN,15, xscale, yscale ); } } } /* end sprite loop */ } /*************************************************************************** Screen Drawing ***************************************************************************/ /************************************************************************** [ Cisco Heat ] **************************************************************************/ void cischeat_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh) { int megasys1_active_layers1, flag; megasys1_active_layers = 0x3f; megasys1_active_layers1 = megasys1_active_layers; MEGASYS1_TMAP_SET_SCROLL(0) MEGASYS1_TMAP_SET_SCROLL(1) MEGASYS1_TMAP_SET_SCROLL(2) MEGASYS1_TMAP_UPDATE(0) MEGASYS1_TMAP_UPDATE(1) MEGASYS1_TMAP_UPDATE(2) palette_init_used_colors(); if (megasys1_active_layers & 0x08) cischeat_mark_sprite_colors(); if (megasys1_active_layers & 0x10) cischeat_mark_road_colors(0); // road 0 if (megasys1_active_layers & 0x20) cischeat_mark_road_colors(1); // road 1 if (palette_recalc()) tilemap_mark_all_pixels_dirty(ALL_TILEMAPS); MEGASYS1_TMAP_RENDER(0) MEGASYS1_TMAP_RENDER(1) MEGASYS1_TMAP_RENDER(2) osd_clearbitmap(Machine->scrbitmap); /* bitmap, road, priority, transparency */ if (megasys1_active_layers & 0x10) cischeat_draw_road(bitmap,0,7,5,TRANSPARENCY_NONE); if (megasys1_active_layers & 0x20) cischeat_draw_road(bitmap,1,7,5,TRANSPARENCY_PEN); flag = 0; MEGASYS1_TMAP_DRAW(0) // else osd_clearbitmap(Machine->scrbitmap); MEGASYS1_TMAP_DRAW(1) if (megasys1_active_layers & 0x08) cischeat_draw_sprites(bitmap,15,3); if (megasys1_active_layers & 0x10) cischeat_draw_road(bitmap,0,4,1,TRANSPARENCY_PEN); if (megasys1_active_layers & 0x20) cischeat_draw_road(bitmap,1,4,1,TRANSPARENCY_PEN); if (megasys1_active_layers & 0x08) cischeat_draw_sprites(bitmap,2,2); if (megasys1_active_layers & 0x10) cischeat_draw_road(bitmap,0,0,0,TRANSPARENCY_PEN); if (megasys1_active_layers & 0x20) cischeat_draw_road(bitmap,1,0,0,TRANSPARENCY_PEN); if (megasys1_active_layers & 0x08) cischeat_draw_sprites(bitmap,1,0); MEGASYS1_TMAP_DRAW(2) /* for the map screen */ if (megasys1_active_layers & 0x08) cischeat_draw_sprites(bitmap,0+16,0+16); megasys1_active_layers = megasys1_active_layers1; } /************************************************************************** [ F1 GrandPrix Star ] **************************************************************************/ void f1gpstar_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh) { int megasys1_active_layers1, flag; megasys1_active_layers = 0x3f; megasys1_active_layers1 = megasys1_active_layers; MEGASYS1_TMAP_SET_SCROLL(0) MEGASYS1_TMAP_SET_SCROLL(1) MEGASYS1_TMAP_SET_SCROLL(2) MEGASYS1_TMAP_UPDATE(0) MEGASYS1_TMAP_UPDATE(1) MEGASYS1_TMAP_UPDATE(2) palette_init_used_colors(); if (megasys1_active_layers & 0x08) cischeat_mark_sprite_colors(); if (megasys1_active_layers & 0x10) f1gpstar_mark_road_colors(0); // road 0 if (megasys1_active_layers & 0x20) f1gpstar_mark_road_colors(1); // road 1 if (palette_recalc()) tilemap_mark_all_pixels_dirty(ALL_TILEMAPS); MEGASYS1_TMAP_RENDER(0) MEGASYS1_TMAP_RENDER(1) MEGASYS1_TMAP_RENDER(2) osd_clearbitmap(Machine->scrbitmap); /* 1: clouds 5, grad 7, road 0 2: clouds 5, grad 7, road 0, tunnel roof 0 */ /* NOTE: TRANSPARENCY_NONE isn't supported by drawgfxzoom */ /* (the function used in f1gpstar_drawroad to draw the road) */ /* road 1!! 0!! */ /* bitmap, road, min_priority, max_priority, transparency */ if (megasys1_active_layers & 0x20) f1gpstar_draw_road(bitmap,1,6,7,TRANSPARENCY_PEN); if (megasys1_active_layers & 0x10) f1gpstar_draw_road(bitmap,0,6,7,TRANSPARENCY_PEN); flag = 0; MEGASYS1_TMAP_DRAW(0) // else osd_clearbitmap(Machine->scrbitmap); MEGASYS1_TMAP_DRAW(1) /* road 1!! 0!! */ /* bitmap, road, min_priority, max_priority, transparency */ if (megasys1_active_layers & 0x20) f1gpstar_draw_road(bitmap,1,1,5,TRANSPARENCY_PEN); if (megasys1_active_layers & 0x10) f1gpstar_draw_road(bitmap,0,1,5,TRANSPARENCY_PEN); if (megasys1_active_layers & 0x08) cischeat_draw_sprites(bitmap,15,2); /* road 1!! 0!! */ /* bitmap, road, min_priority, max_priority, transparency */ if (megasys1_active_layers & 0x20) f1gpstar_draw_road(bitmap,1,0,0,TRANSPARENCY_PEN); if (megasys1_active_layers & 0x10) f1gpstar_draw_road(bitmap,0,0,0,TRANSPARENCY_PEN); if (megasys1_active_layers & 0x08) cischeat_draw_sprites(bitmap,1,1); MEGASYS1_TMAP_DRAW(2) if (megasys1_active_layers & 0x08) cischeat_draw_sprites(bitmap,0,0); megasys1_active_layers = megasys1_active_layers1; }
/* * File Tangram.cpp in project ThreeEngine * * Copyright (C) Ricardo Rodrigues 2017 - All Rights Reserved */ #include <cmath> #include "MyEngine.h" #include "../../../3Engine/src/Shapes/MeshLoader.h" #include "../../../3Engine/src/Shader/TextureLoader.h" #include "../../../3Engine/src/Camera/Perspective.h" #include "../../../3Engine/src/Utilities/Managers.h" #include "../../../3Engine/src/Utilities/Simulation.h" #include "../../../3Engine/src/Actors/SkySphere.h" using json = nlohmann::json; using namespace std; using namespace ThreeEngine; using namespace Executable; int main(int argc, char* argv[]) { srand(static_cast <unsigned> (time(0))); { MyEngine engine; engine.Init(argc, argv); engine.Run(); } exit(EXIT_SUCCESS); } namespace Executable { MyEngine::MyEngine() : Engine(), sceneGraph(new SceneGraph()), controller(this) { } MyEngine::~MyEngine() = default; void MyEngine::OnInit() { setupShaders(); setupMeshes(); setupTextures(); scene(); } void MyEngine::setupShaders() { auto skysphere = std::make_shared<ShaderProgram>( "shaders/SkySphere/program.json"); skysphere->Init(); ShaderProgramManager::instance()->Add("skysphere", skysphere); auto defaultProgram = std::make_shared<ShaderProgram>( "shaders/Default/program.json"); defaultProgram->Init(); ShaderProgramManager::instance()->Add("Default", defaultProgram); auto timeProgram = std::make_shared<ShaderProgram>( "shaders/TimeMovingTexture/program.json"); timeProgram->Init(); ShaderProgramManager::instance()->Add("Time", timeProgram); } void MyEngine::setupMeshes() { MeshManager::instance()->Add("Sphere", MeshLoader::instance()->LoadFileOBJ( "assets/Sphere.obj")); } void MyEngine::setupTextures() { TextureManager::instance()->Add("Stone", TextureLoader::instance()->LoadTexture( "assets/Stone.jpg")); TextureManager::instance()->Add("GGB3", TextureLoader::instance()->LoadCubemap( "assets/GoldenGateBridge3/negz.jpg", "assets/GoldenGateBridge3/posz.jpg", "assets/GoldenGateBridge3/posy.jpg", "assets/GoldenGateBridge3/negy.jpg", "assets/GoldenGateBridge3/negx.jpg", "assets/GoldenGateBridge3/posx.jpg" )); } void MyEngine::scene() { actors.push_back(reinterpret_cast<IDrawable*&&>(sceneGraph)); { // Camera handling number width = config["window"]["x"]; number height = config["window"]["y"]; number aspect = width / height; Camera* camera = new Camera( static_cast<GLuint>( ShaderProgramManager::instance()->Get( "Time")->GetUniformBlockBidingId( "SharedMatrices")), new Perspective(30, aspect, 1, 1000), new Matrix(Matrix::TranslationMatrix(Vector(0, 0, -100))) // new LookAt({5, 0.5f, 0}, {0, 0.5f, 0}, {0, 1, 0}) ); sceneGraph->SetCamera(camera); controller.camera = camera; } auto root = new Actor(); root->setShaderProgram( ShaderProgramManager::instance()->Get("Default")); sceneGraph->SetRoot(root); { auto object = new Actor(); auto program = ShaderProgramManager::instance()->Get("Time"); object->setShaderProgram(program); object->mesh = MeshManager::instance()->Get("Sphere"); object->textures.push_back( TextureManager::instance()->Get("Stone")); auto&& hTransform = object->transform; hTransform.scale = Vector(10); object->SetParent(root); object->preDraw = [program]() { glUniform1f(program->GetUniformLocationId("Time"), Time::Now()/1000.0f); }; } { auto skySphere = new SkySphere(); skySphere->setShaderProgram( ShaderProgramManager::instance()->Get("skysphere")); skySphere->mesh = MeshManager::instance()->Get("Sphere"); skySphere->textures.push_back( TextureManager::instance()->Get("GGB3")); auto&& hTransform = skySphere->transform; hTransform.scale = Vector(100); skySphere->SetParent(root); } // Initializes all the actors in it. sceneGraph->Init(); } void MyEngine::OnReshape(int, int) { // number aspect = (number) w / (number) h, // angle = Maths::ToRadians(30.0f / 2.0f), // d = 1.0f / tanf(angle); // camera->projection.M[0][0] = d / aspect; } void MyEngine::PreDraw() { controller.Update(); } void MyEngine::Update() { if (input.Click(27)) { // ESC Exit(); } Simulation::instance()->Update(); } void MyEngine::OnCleanup() { ShaderProgramManager::instance()->cleanup(); MeshManager::instance()->cleanup(); Simulation::instance()->cleanup(); } } /* namespace Divisaction */
/* Copyright (c) 2015 - 2022 Advanced Micro Devices, Inc. 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. */ #define _CRT_SECURE_NO_WARNINGS #include "vxImage.h" /////////////////////////////////////////////////////////////////////// // class CVxParamImage // CVxParamImage::CVxParamImage() { // vx configuration m_vxObjType = VX_TYPE_IMAGE; m_format = VX_DF_IMAGE_U8; m_width = 0; m_height = 0; m_planes = 0; // I/O configuration m_frameSize = 0; m_bufForCompare = nullptr; m_displayName = ""; m_repeatFrames = 0; m_countFrames = 0; m_useCheckSumForCompare = false; m_generateCheckSumForCompare = false; m_usingDisplay = false; m_usingWriter = false; m_countInitializeIO = 0; m_memory_type = VX_MEMORY_TYPE_NONE; m_active_handle = 0; memset(m_addr, 0, sizeof(m_addr)); memset(m_memory_handle, 0, sizeof(m_memory_handle)); m_swap_handles = false; #if ENABLE_OPENCV m_cvCapDev = NULL; m_cvCapMat = NULL; m_cvDispMat = NULL; m_cvImage = NULL; m_cvWriter = NULL; m_cvReadEofOccured = false; #endif m_cameraName[0] = 0; m_comparePixelErrorMin = 0; m_comparePixelErrorMax = 0; m_compareCountMatches = 0; m_compareCountMismatches = 0; // vx object m_image = nullptr; m_vxObjRef = nullptr; m_disableWaitForKeyPress = false; // reset video capture m_gotCaptureVideoSize = false; m_doNotResizeCapturedImages = false; m_captureWidth = 0; m_captureHeight = 0; m_colorIndexDefault = 0; m_radiusDefault = 2.0; } CVxParamImage::~CVxParamImage() { Shutdown(); } int CVxParamImage::Shutdown(void) { if (m_compareCountMatches > 0 && m_compareCountMismatches == 0) { printf("OK: image %s MATCHED for %d frame(s) of %s\n", m_useCheckSumForCompare ? "CHECKSUM" : "COMPARE", m_compareCountMatches, GetVxObjectName()); } if (m_image) { vxReleaseImage(&m_image); m_image = nullptr; } if (m_bufForCompare) { delete[] m_bufForCompare; m_bufForCompare = nullptr; } if (m_memory_type == VX_MEMORY_TYPE_HOST) { for (int active_handle = 0; active_handle < 2; active_handle++) { for (vx_size plane = 0; plane < m_planes; plane++) { if (m_memory_handle[active_handle][plane]) free(m_memory_handle[active_handle][plane]); m_memory_handle[active_handle][plane] = nullptr; } } } #if ENABLE_OPENCL else if (m_memory_type == VX_MEMORY_TYPE_OPENCL) { for (int active_handle = 0; active_handle < 2; active_handle++) { for (vx_size plane = 0; plane < m_planes; plane++) { if (m_memory_handle[active_handle][plane]) { int err = clReleaseMemObject((cl_mem)m_memory_handle[active_handle][plane]); if (err) ReportError("ERROR: clReleaseMemObject(*) failed (%d)\n", err); } m_memory_handle[active_handle][plane] = nullptr; } } } #elif ENABLE_HIP else if (m_memory_type == VX_MEMORY_TYPE_HIP) { for (int active_handle = 0; active_handle < 2; active_handle++) { for (vx_size plane = 0; plane < m_planes; plane++) { if (m_memory_handle[active_handle][plane]) { hipFree(m_memory_handle[active_handle][plane]); } m_memory_handle[active_handle][plane] = nullptr; } } } #endif m_memory_type = VX_MEMORY_TYPE_NONE; #if ENABLE_OPENCV bool changed_numCvUse = false; if (m_cvDispMat) { if (m_usingDisplay) { g_numCvUse--; changed_numCvUse = true; } delete (Mat *)m_cvDispMat; m_cvDispMat = NULL; } if (m_cvCapMat) { g_numCvUse--; changed_numCvUse = true; delete (Mat *)m_cvCapMat; m_cvCapMat = NULL; } if (m_cvCapDev) { delete (VideoCapture *)m_cvCapDev; m_cvCapDev = NULL; } if (m_cvImage) { g_numCvUse--; changed_numCvUse = true; delete (Mat *)m_cvImage; m_cvImage = NULL; } if (m_cvWriter) { delete (VideoWriter *)m_cvWriter; m_cvWriter = NULL; } if (changed_numCvUse && g_numCvUse == 0) { if (!m_disableWaitForKeyPress) { printf("Abort: Press any key to exit...\n"); fflush(stdout); waitKey(0); } } #endif return 0; } void CVxParamImage::DisableWaitForKeyPress() { m_disableWaitForKeyPress = true; } int CVxParamImage::Initialize(vx_context context, vx_graph graph, const char * desc) { // get object parameters and create object char objType[64]; const char * ioParams = ScanParameters(desc, "image|virtual-image|uniform-image|image-from-roi|image-from-handle|image-from-channel:", "s:", objType); if (!_stricmp(objType, "image") || !_stricmp(objType, "virtual-image") || !_stricmp(objType, "uniform-image") || !_stricmp(objType, "image-virtual") || !_stricmp(objType, "image-uniform")) { // syntax: [virtual-|uniform-]image:<width>,<height>,<format>[,<range>][,<space>][:<io-params>] ioParams = ScanParameters(ioParams, "<width>,<height>,<format>", "d,d,c", &m_width, &m_height, &m_format); if (!_stricmp(objType, "uniform-image") || !_stricmp(objType, "image-uniform")) { memset(&m_uniformValue, 0, sizeof(m_uniformValue)); if (*ioParams == ',') { ioParams++; if (*ioParams == '{') { // scan get 8-bit values for RGB/RGBX/YUV formats as {R;G;B}/{R;G;B;X}/{Y;U;V} const char * p = ioParams; for (int index = 0; index < 4 && (*p == '{' || *p == ';');) { int value = 0; p = ScanParameters(&p[1], "<byte>", "d", &value); m_uniformValue.reserved[index++] = (vx_uint8)value; } if (*p == '}') p++; ioParams = p; } else ioParams = ScanParameters(ioParams, "<uniform-pixel-value>", "D", m_uniformValue.reserved); } m_image = vxCreateUniformImage(context, m_width, m_height, m_format, &m_uniformValue); } else if (!_stricmp(objType, "image-virtual") || !_stricmp(objType, "virtual-image")) { m_image = vxCreateVirtualImage(graph, m_width, m_height, m_format); m_isVirtualObject = true; } else { m_image = vxCreateImage(context, m_width, m_height, m_format); } if (vxGetStatus((vx_reference)m_image) == VX_SUCCESS) { // process optional parameters: channel range and color space while (*ioParams == ',') { char enumName[64]; ioParams = ScanParameters(ioParams, ",<enum>", ",s", enumName); vx_enum enumValue = ovxName2Enum(enumName); if (enumValue == VX_CHANNEL_RANGE_FULL || enumValue == VX_CHANNEL_RANGE_RESTRICTED) { ERROR_CHECK(vxSetImageAttribute(m_image, VX_IMAGE_ATTRIBUTE_RANGE, &enumValue, sizeof(enumValue))); } else if (enumValue == VX_COLOR_SPACE_BT601_525 || enumValue == VX_COLOR_SPACE_BT601_625 || enumValue == VX_COLOR_SPACE_BT709) { ERROR_CHECK(vxSetImageAttribute(m_image, VX_IMAGE_ATTRIBUTE_SPACE, &enumValue, sizeof(enumValue))); } else { ReportError("ERROR: invalid enum specified: %s\n", enumName); } } } } else if (!_stricmp(objType, "image-from-roi") || !_stricmp(objType, "image-roi")) { // syntax: image-from-roi:<master-image>,rect{<start-x>;<start-y>;<end-x>;<end-y>}[:<io-params>] char roi[64]; ioParams = ScanParameters(ioParams, "<master-image>,rect{<start-x>;<start-y>;<end-x>;<end-y>}", "s,s", m_roiMasterName, roi); if (_strnicmp(roi, "rect{", 5) != 0) ReportError("ERROR: invalid image-from-roi syntax: %s\n", desc); ScanParameters(&roi[4], "{<start-x>;<start-y>;<end-x>;<end-y>}", "{d;d;d;d}", &m_roiRegion.start_x, &m_roiRegion.start_y, &m_roiRegion.end_x, &m_roiRegion.end_y); auto it = m_paramMap->find(m_roiMasterName); if (it == m_paramMap->end()) ReportError("ERROR: image [%s] doesn't exist for %s\n", m_roiMasterName, desc); vx_image masterImage = (vx_image)it->second->GetVxObject(); m_image = vxCreateImageFromROI(masterImage, &m_roiRegion); } else if (!_stricmp(objType, "image-from-channel")) { // syntax: image-from-channel:<master-image>,<channel>[:<io-params>] char roi[64]; ioParams = ScanParameters(ioParams, "<master-image>,<channel>", "s,s", m_roiMasterName, roi); vx_uint64 channel = 0; if (GetScalarValueFromString(VX_TYPE_ENUM, roi, &channel) < 0) ReportError("ERROR: invalid channel enum: %s\n", roi); auto it = m_paramMap->find(m_roiMasterName); if (it == m_paramMap->end()) ReportError("ERROR: image [%s] doesn't exist for %s\n", m_roiMasterName, desc); vx_image masterImage = (vx_image)it->second->GetVxObject(); m_image = vxCreateImageFromChannel(masterImage, (vx_enum)channel); } else if (!_stricmp(objType, "image-from-handle")) { // syntax: image-from-handle:<image-format>,{<dim-x>;<dim-y>;<stride-x>;<stride-y>}[+...],<memory-type>[:<io-params>] ioParams = ScanParameters(ioParams, "<format>,{<dim-x>;<dim-y>;<stride-x>;<stride-y>}", "c,{d;d;d;d}", &m_format, &m_addr[0].dim_x, &m_addr[0].dim_y, &m_addr[0].stride_x, &m_addr[0].stride_y); m_width = m_addr[0].dim_x; m_height = m_addr[0].dim_y; m_planes = 1; while (ioParams[0] == ';' && ioParams[1] == '{' && m_planes < 4) { ioParams = ScanParameters(ioParams, ",{<dim-x>;<dim-y>;<stride-x>;<stride-y>}", "+{d;d;d;d}", &m_format, &m_addr[m_planes].dim_x, &m_addr[m_planes].dim_y, &m_addr[m_planes].stride_x, &m_addr[m_planes].stride_y); m_planes++; } char type_str[64]; ioParams = ScanParameters(ioParams, "<memory-type>", ",s", type_str); vx_uint64 type_value = 0; if (GetScalarValueFromString(VX_TYPE_ENUM, type_str, &type_value) < 0) ReportError("ERROR: invalid channel enum: %s\n", type_str); int alloc_flags = 0; if (ioParams[0] == ',') { ioParams = ScanParameters(ioParams, "<alloc-flag>", ",d", &alloc_flags); } bool align_memory = false; m_memory_type = (vx_enum)type_value; if (m_memory_type == VX_MEMORY_TYPE_HOST) { if (alloc_flags == 1) { memset(m_memory_handle, 0, sizeof(m_memory_handle)); } else { // allocate all handles on host for (int active_handle = 0; active_handle < 2; active_handle++) { for (vx_size plane = 0; plane < m_planes; plane++) { vx_size size = (vx_size) m_addr[plane].dim_y * m_addr[plane].stride_y; m_memory_handle[active_handle][plane] = malloc(size); if (!m_memory_handle[active_handle][plane]) ReportError("ERROR: malloc(%d) failed\n", (int)size); } } } } #if ENABLE_OPENCL else if (m_memory_type == VX_MEMORY_TYPE_OPENCL) { if (alloc_flags == 1) { memset(m_memory_handle, 0, sizeof(m_memory_handle)); } else { // allocate all handles on opencl cl_context opencl_context = nullptr; vx_status status = vxQueryContext(context, VX_CONTEXT_ATTRIBUTE_AMD_OPENCL_CONTEXT, &opencl_context, sizeof(opencl_context)); if (status) ReportError("ERROR: vxQueryContext(*,VX_CONTEXT_ATTRIBUTE_AMD_OPENCL_CONTEXT,...) failed (%d)\n", status); for (int active_handle = 0; active_handle < 2; active_handle++) { for (vx_size plane = 0; plane < m_planes; plane++) { vx_size size = m_addr[plane].dim_y * m_addr[plane].stride_y; cl_int err = CL_SUCCESS; m_memory_handle[active_handle][plane] = clCreateBuffer(opencl_context, CL_MEM_READ_WRITE, size, NULL, &err); if (!m_memory_handle[active_handle][plane] || err) ReportError("ERROR: clCreateBuffer(*,CL_MEM_READ_WRITE,%d,NULL,*) failed (%d)\n", (int)size, err); } } } } #elif ENABLE_HIP else if (m_memory_type == VX_MEMORY_TYPE_HIP) { if (alloc_flags == 1) { memset(m_memory_handle, 0, sizeof(m_memory_handle)); } else { // allocate all handles on opencl int hip_device = -1; vx_status status = vxQueryContext(context, VX_CONTEXT_ATTRIBUTE_AMD_HIP_DEVICE, &hip_device, sizeof(hip_device)); if (status || hip_device<0 ) ReportError("ERROR: vxQueryContext(*,VX_CONTEXT_ATTRIBUTE_AMD_HIP_DEVICE,...) failed (%d, %d)\n", status, hip_device); for (int active_handle = 0; active_handle < 2; active_handle++) { for (vx_size plane = 0; plane < m_planes; plane++) { vx_size size = m_addr[plane].dim_y * m_addr[plane].stride_y; hipError_t err = hipMalloc(&m_memory_handle[active_handle][plane], size); if (!m_memory_handle[active_handle][plane] || err != hipSuccess) ReportError("ERROR: hipMalloc(%d) failed (%d)\n", (int)size, err); } } } } #endif else ReportError("ERROR: invalid memory-type enum: %s\n", type_str); m_active_handle = 0; m_image = vxCreateImageFromHandle(context, m_format, m_addr, m_memory_handle[m_active_handle], m_memory_type); } else ReportError("ERROR: unsupported image type: %s\n", desc); vx_status ovxStatus = vxGetStatus((vx_reference)m_image); if (ovxStatus != VX_SUCCESS) { printf("ERROR: image creation failed => %d (%s)\n", ovxStatus, ovxEnum2Name(ovxStatus)); if (m_image) vxReleaseImage(&m_image); throw - 1; } m_vxObjRef = (vx_reference)m_image; // io initialize return InitializeIO(context, graph, m_vxObjRef, ioParams); } int CVxParamImage::InitializeIO(vx_context context, vx_graph graph, vx_reference ref, const char * io_params) { // save reference object and get object attributes m_vxObjRef = ref; m_image = (vx_image)m_vxObjRef; ERROR_CHECK(vxQueryImage(m_image, VX_IMAGE_ATTRIBUTE_WIDTH, &m_width, sizeof(m_width))); ERROR_CHECK(vxQueryImage(m_image, VX_IMAGE_ATTRIBUTE_HEIGHT, &m_height, sizeof(m_height))); ERROR_CHECK(vxQueryImage(m_image, VX_IMAGE_ATTRIBUTE_FORMAT, &m_format, sizeof(m_format))); ERROR_CHECK(vxQueryImage(m_image, VX_IMAGE_ATTRIBUTE_PLANES, &m_planes, sizeof(m_planes))); // first-time initialization if (m_countInitializeIO == 0) { // initialize compare region to complete image m_rectCompare.start_x = 0; m_rectCompare.start_y = 0; m_rectCompare.end_x = m_width; m_rectCompare.end_y = m_height; } m_countInitializeIO++; // process I/O requests if (*io_params == ':') io_params++; while (*io_params) { char ioType[64], fileName[256]; io_params = ScanParameters(io_params, "<io-operation>,<parameter>", "s,S", ioType, fileName); // get file extension position in fileName int extpos = (int)strlen(fileName) - 1; while (extpos > 0 && fileName[extpos] != '.') extpos--; if (!_stricmp(ioType, "read") || !_stricmp(ioType, "camera")) { // read request syntax: read,<fileNameOrURL>[,frames{<start>[;<count>;repeat]}|no-resize] or camera,<deviceNumber> int cameraDevice = -1; if (!_stricmp(ioType, "camera")) cameraDevice = atoi(fileName); // get optional repeat frame count and starting frame m_repeatFrames = 0; while (*io_params == ',') { char option[64]; io_params = ScanParameters(io_params, ",frames{<start>[;<count>;repeat]}|no-resize", ",s", option); if (!_strnicmp(option, "frames{", 7)) { int startFrame = 0, count = 0; char repeat[64] = { 0 }; if (sscanf(&option[7], "%d;%d;%s", &startFrame, &count, repeat) >= 1) { repeat[6] = 0; // truncate since scanf will read all characters till the end of string into repeat m_captureFrameStart = startFrame; if (!_stricmp(repeat, "repeat") && (count > 0)) m_repeatFrames = count; } else ReportError("ERROR: invalid image read/camera option: %s\n", option); } else if (!_stricmp(option, "no-resize")) { m_doNotResizeCapturedImages = true; } else ReportError("ERROR: invalid image read/camera option: %s\n", option); } // check if openCV video capture need to be used if (!_stricmp(&fileName[extpos], ".mp4") || !_stricmp(&fileName[extpos], ".avi") || !_stricmp(&fileName[extpos], ".jpg") || !_stricmp(&fileName[extpos], ".jpeg") || !_stricmp(&fileName[extpos], ".jpe") || !_stricmp(&fileName[extpos], ".png") || !_stricmp(&fileName[extpos], ".bmp") || !_stricmp(&fileName[extpos], ".tif") || !_stricmp(&fileName[extpos], ".ppm") || !_stricmp(&fileName[extpos], ".tiff") || !_stricmp(&fileName[extpos], ".pgm") || !_stricmp(&fileName[extpos], ".pbm") || !_strnicmp(fileName, "file://", 7) || !_strnicmp(fileName, "http://", 7) || !_strnicmp(fileName, "https://", 8) || cameraDevice >= 0) { // need OpenCV to process these read I/O requests //////////////////// #if ENABLE_OPENCV if (m_format == VX_DF_IMAGE_RGB || m_format == VX_DF_IMAGE_U8) { // pen video capture device and mark multi-frame capture m_usingMultiFrameCapture = false; VideoCapture * pCap = nullptr; if (cameraDevice >= 0) { pCap = new VideoCapture(cameraDevice); } else { pCap = new VideoCapture(fileName); // if single .jpg are is specified, mark as single-frame capture if (strstr(fileName, "%") == NULL && (!_stricmp(&fileName[strlen(fileName) - 4], ".avi") || !_stricmp(&fileName[extpos], ".mp4"))) { m_usingMultiFrameCapture = true; } } m_cvCapDev = pCap; if (!pCap->isOpened()) { printf("ERROR: OpenCV device capture(%s) failed\n", fileName); throw - 1; } #if 0 // TBD: disabled the check to avoid errors with video files if (pCap->get(CV_CAP_PROP_FRAME_WIDTH) != m_width || pCap->get(CV_CAP_PROP_FRAME_HEIGHT) != m_height) { printf("ERROR: OpenCV capture(%s) device is %dx%d whereas requested image is %dx%d\n", fileName, pCap->get(CV_CAP_PROP_FRAME_WIDTH), pCap->get(CV_CAP_PROP_FRAME_HEIGHT), m_width, m_height); throw - 1; } #endif m_cvReadEofOccured = false; int cvMatType = (m_format == VX_DF_IMAGE_RGB) ? CV_8UC3 : CV_8U; m_cvCapMat = new Mat(m_height, m_width, cvMatType); //Mat(row, column, type) strcpy(m_cameraName, fileName); g_numCvUse++; // skip frames if requested if (m_captureFrameStart > 0) { printf("OK: skipping %d frames from %s\n", m_captureFrameStart, fileName); fflush(stdout); for (vx_uint32 i = 0; i < m_captureFrameStart; i++) { if (!m_cvReadEofOccured) { *(VideoCapture *)m_cvCapDev >> *(Mat *)m_cvCapMat; if (!((Mat *)m_cvCapMat)->data) { m_cvReadEofOccured = true; break; } } } } } #else printf("ERROR: This build doesn't support CAMERA option\n"); throw - 1; #endif } else { // raw frames reading ///////////////////////// if (m_fpRead) { fclose(m_fpRead); m_fpRead = nullptr; } m_fileNameRead.assign(RootDirUpdated(fileName)); m_fileNameForReadHasIndex = (m_fileNameRead.find("%") != m_fileNameRead.npos) ? true : false; // mark multi-frame capture enabled m_usingMultiFrameCapture = true; } } else if (!_stricmp(ioType, "init")) { if (fileName[0]) { // initialize image by reading from a file if (m_fpRead) { fclose(m_fpRead); m_fpRead = nullptr; } m_fileNameRead.assign(RootDirUpdated(fileName)); m_fileNameForReadHasIndex = (m_fileNameRead.find("%") != m_fileNameRead.npos) ? true : false; m_usingMultiFrameCapture = true; // read two images into handles m_rectFull.start_x = 0; m_rectFull.start_y = 0; m_rectFull.end_x = m_width; m_rectFull.end_y = m_height; m_fpRead = fopen(m_fileNameRead.c_str(), "rb"); if (!m_fpRead) ReportError("ERROR: unable to open: %s\n", m_fileNameRead.c_str()); if (ReadImage(m_image, &m_rectFull, m_fpRead)) ReportError("ERROR: unable to initialize image(%s) fully from %s\n", m_vxObjName, fileName); if (m_memory_type != VX_MEMORY_TYPE_NONE) { // need to read second image if image was created from handle m_active_handle = !m_active_handle; vx_status status = vxSwapImageHandle(m_image, m_memory_handle[m_active_handle], m_memory_handle[!m_active_handle], m_planes); if (status) ReportError("ERROR: vxSwapImageHandle(%s,*,*,%d) failed (%d)\n", m_vxObjName, (int)m_planes, status); if (ReadImage(m_image, &m_rectFull, m_fpRead)) ReportError("ERROR: unable to initialize second image(%s) fully from %s\n", m_vxObjName, fileName); } // close the file if (m_fpRead) { fclose(m_fpRead); m_fpRead = nullptr; } m_fileNameRead = ""; m_fileNameForReadHasIndex = false; } // mark that swap handles needs to be executed for images created from handle if (m_memory_type != VX_MEMORY_TYPE_NONE) m_swap_handles = true; } else if (!_stricmp(ioType, "view") || !_stricmp(ioType, "write")) { // write or view request syntax: write,<fileNameOrURL> OR view,<window-name>[,color-index{<#>}|,radius{<#>}] bool needDisplay = false; while (*io_params == ',') { char option[64]; io_params = ScanParameters(io_params, ",color-index{index}|radius{radius}", ",s", option); if (!_strnicmp(option, "color-index{", 12)) { int colorIndex = 0; if (sscanf(&option[12], "%d", &colorIndex) == 1) { m_colorIndexDefault = colorIndex; } else ReportError("ERROR: invalid image read/camera option: %s\n", option); } else if (!_strnicmp(option, "radius{", 7)) { float radius = 2.0; if (sscanf(&option[7], "%f", &radius) == 1) { m_radiusDefault = radius; } else ReportError("ERROR: invalid image read/camera option: %s\n", option); } } if (!_stricmp(ioType, "view") || !_stricmp(&fileName[extpos], ".mp4") || !_stricmp(&fileName[extpos], ".avi")) { // need OpenCV to process these write I/O requests //////////////////// #if ENABLE_OPENCV if (!_stricmp(ioType, "view")) { m_usingDisplay = true; m_displayName.assign(fileName); namedWindow(m_displayName, WINDOW_AUTOSIZE); g_numCvUse++; } else { if (m_fpWrite) { fclose(m_fpWrite); m_fpWrite = nullptr; } m_fileNameWrite.assign(RootDirUpdated(fileName)); VideoWriter * writer = new VideoWriter(m_fileNameWrite.c_str(), -1, 30, Size(m_width, m_height)); m_cvWriter = (void *)writer; m_usingWriter = true; } // create Mat object int cvMatType = CV_8UC1; if (m_format == VX_DF_IMAGE_U8 || m_format == VX_DF_IMAGE_U1_AMD) cvMatType = CV_8UC1; else if (m_format == VX_DF_IMAGE_S16) cvMatType = CV_16UC1; // CV_16SC1 is not supported else if (m_format == VX_DF_IMAGE_U16) cvMatType = CV_16UC1; else if (m_format == VX_DF_IMAGE_RGB) cvMatType = CV_8UC3; else if (m_format == VX_DF_IMAGE_RGBX) cvMatType = CV_8UC4; else if (m_format == VX_DF_IMAGE_F32_AMD) cvMatType = CV_32FC1; else { printf("ERROR: display of image type (%4.4s) is not support. Exiting.\n", (const char *)&m_format); throw - 1; } m_cvDispMat = new Mat(m_height, m_width, cvMatType); #else printf("ERROR: this feature requires OpenCV missing in this build\n"); throw - 1; #endif } else { m_fileNameWrite.assign(RootDirUpdated(fileName)); m_fileNameForWriteHasIndex = (m_fileNameWrite.find("%") != m_fileNameWrite.npos) ? true : false; } } else if (!_stricmp(ioType, "compare")) { // compare syntax: compare,fileName[,rect{<start-x>;<start-y>;<end-x>;<end-y>}][,err{<min>;<max>}][,checksum|checksum-save-instead-of-test] if (m_fpCompare) { fclose(m_fpCompare); m_fpCompare = nullptr; } // save the reference image fileName m_fileNameCompare.assign(RootDirUpdated(fileName)); m_fileNameForCompareHasIndex = (m_fileNameCompare.find("%") != m_fileNameCompare.npos) ? true : false; // initialize pixel error range to exact match m_comparePixelErrorMin = 0; m_comparePixelErrorMax = 0; // set the compare region m_rectCompare.start_x = 0; m_rectCompare.start_y = 0; m_rectCompare.end_x = m_width; m_rectCompare.end_y = m_height; while (*io_params == ',') { char option[64]; io_params = ScanParameters(io_params, ",rect{<start-x>;<start-y>;<end-x>;<end-y>}|err{<min>;<max>}|checksum|checksum-save-instead-of-test", ",s", option); if (!_strnicmp(option, "rect", 4)) { ScanParameters(option + 4, "{<start-x>;<start-y>;<end-x>;<end-y>}", "{d;d;d;d}", &m_rectCompare.start_x, &m_rectCompare.start_y, &m_rectCompare.end_x, &m_rectCompare.end_y); } else if (!_strnicmp(option, "err", 3)) { ScanParameters(option + 3, "{<min>;<max>}", "{f;f}", &m_comparePixelErrorMin, &m_comparePixelErrorMax); if (m_useCheckSumForCompare) ReportError("ERROR: can't support error range with checksum\n"); } else if (!_stricmp(option, "checksum")) { m_useCheckSumForCompare = true; if (m_comparePixelErrorMin != m_comparePixelErrorMax) ReportError("ERROR: can't support error range with checksum\n"); } else if (!_stricmp(option, "checksum-save-instead-of-test")) { m_generateCheckSumForCompare = true; } else ReportError("ERROR: invalid image compare option: %s\n", option); } } else if (!_stricmp(ioType, "directive") && (!_stricmp(fileName, "VX_DIRECTIVE_AMD_COPY_TO_OPENCL") || !_stricmp(fileName, "sync-cl-write"))) { m_useSyncOpenCLWriteDirective = true; } else ReportError("ERROR: invalid image operation: %s\n", ioType); if (*io_params == ':') io_params++; else if (*io_params) ReportError("ERROR: unexpected character sequence in parameter specification: %s\n", io_params); } return 0; } int CVxParamImage::Finalize() { // get object attributes ERROR_CHECK(vxQueryImage(m_image, VX_IMAGE_ATTRIBUTE_WIDTH, &m_width, sizeof(m_width))); ERROR_CHECK(vxQueryImage(m_image, VX_IMAGE_ATTRIBUTE_HEIGHT, &m_height, sizeof(m_height))); ERROR_CHECK(vxQueryImage(m_image, VX_IMAGE_ATTRIBUTE_FORMAT, &m_format, sizeof(m_format))); ERROR_CHECK(vxQueryImage(m_image, VX_IMAGE_ATTRIBUTE_PLANES, &m_planes, sizeof(m_planes))); // set m_rectFull to full image region m_rectFull.start_x = 0; m_rectFull.start_y = 0; m_rectFull.end_x = m_width; m_rectFull.end_y = m_height; // initialize other parameters m_compareCountMatches = 0; m_compareCountMismatches = 0; // Calculate image width for single plane image: vx_size width_in_bytes = (m_planes == 1) ? CalculateImageWidthInBytes(m_image) : 0; // compute frame size in bytes m_frameSize = 0; for (vx_uint32 plane = 0; plane < (vx_uint32)m_planes; plane++) { vx_rectangle_t rect = { 0, 0, m_width, m_height }; vx_imagepatch_addressing_t addr = { 0 }; vx_uint8 * dst = NULL; if (vxAccessImagePatch(m_image, &m_rectFull, plane, &addr, (void **)&dst, VX_READ_ONLY) == VX_SUCCESS) { vx_size width = (addr.dim_x * addr.scale_x) / VX_SCALE_UNITY; vx_size height = (addr.dim_y * addr.scale_y) / VX_SCALE_UNITY; if (addr.stride_x != 0) width_in_bytes = (width * addr.stride_x); m_frameSize += width_in_bytes * height; ERROR_CHECK(vxCommitImagePatch(m_image, &m_rectFull, plane, &addr, (void *)dst)); } } if (m_useSyncOpenCLWriteDirective) { // process user requested directives (required for uniform images) ERROR_CHECK_AND_WARN(vxDirective((vx_reference)m_image, VX_DIRECTIVE_AMD_COPY_TO_OPENCL), VX_ERROR_NOT_ALLOCATED); } return 0; } int CVxParamImage::SyncFrame(int frameNumber) { if (m_swap_handles) { // swap handles if requested for images created from handle m_active_handle = !m_active_handle; vx_status status = vxSwapImageHandle(m_image, m_memory_handle[m_active_handle], m_memory_handle[!m_active_handle], m_planes); if (status) ReportError("ERROR: vxSwapImageHandle(%s,*,*,%d) failed (%d)\n", m_vxObjName, (int)m_planes, status); } return 0; } int CVxParamImage::ReadFrame(int frameNumber) { #if ENABLE_OPENCV if (m_cvCapMat && m_cvCapDev) { // read image from camera if (m_cvReadEofOccured) { // no data available, report that no more frames available return 1; } VideoCapture * pCap = (VideoCapture *)m_cvCapDev; Mat * pMat = (Mat *)m_cvCapMat; //Get Mat type, bevor get a new frame from VideoCapture. int type = pMat->type(); int timeout = 0; *pCap >> *pMat; //change Mat type. if(type == CV_8U){ /*CV_8U convert to gray*/ cvtColor( *pMat, *pMat, CV_BGR2GRAY ); } if (!pMat->data) { // no data available, report that no more frames available m_cvReadEofOccured = true; return 1; } else if (!m_gotCaptureVideoSize) { m_captureWidth = pMat->cols; m_captureHeight = pMat->rows; m_gotCaptureVideoSize = true; bool doResize = !m_doNotResizeCapturedImages && (pMat->cols != m_width || pMat->rows != m_height); printf("OK: capturing %dx%d image(s) into %dx%d RGB image buffer%s\n", m_captureWidth, m_captureHeight, m_width, m_height, doResize ? " with resize" : ""); } // resize image using bicubic interpolation, if needed bool doResize = !m_doNotResizeCapturedImages && (pMat->cols != m_width || pMat->rows != m_height); if (doResize) { // resize the captured video to specifed buffer size resize(*pMat, *pMat, Size(m_width, m_height), 0, 0, INTER_CUBIC); } // copy Mat into image // NOTE: currently only supports U8, S16, RGB, RGBX image formats if (m_format == VX_DF_IMAGE_U8 || m_format == VX_DF_IMAGE_S16 || m_format == VX_DF_IMAGE_RGB || m_format == VX_DF_IMAGE_RGBX) { vx_rectangle_t rect = { 0, 0, min(m_width, (vx_uint32)pMat->cols), min(m_height, (vx_uint32)pMat->rows) }; vx_imagepatch_addressing_t addr = { 0 }; vx_uint8 * dst = NULL; ERROR_CHECK(vxAccessImagePatch(m_image, &rect, 0, &addr, (void **)&dst, VX_WRITE_ONLY)); vx_int32 rowSize = ((vx_int32)pMat->step < addr.stride_y) ? (vx_int32)pMat->step : addr.stride_y; for (vx_uint32 y = 0; y < rect.end_y; y++) { if (m_format == VX_DF_IMAGE_RGB) { // convert BGR to RGB vx_uint8 * pDst = (vx_uint8 *)dst + y * addr.stride_y; vx_uint8 * pSrc = (vx_uint8 *)pMat->data + y * pMat->step; for (vx_uint32 x = 0; x < m_width; x++) { pDst[0] = pSrc[2]; pDst[1] = pSrc[1]; pDst[2] = pSrc[0]; pDst += 3; pSrc += 3; } } else { memcpy(dst + y * addr.stride_y, pMat->data + y * pMat->step, rowSize); } } ERROR_CHECK(vxCommitImagePatch(m_image, &rect, 0, &addr, dst)); } } else if (m_cvImage) { // read image from camera VideoCapture * pCap = (VideoCapture *)m_cvCapDev; Mat * pMat = (Mat *)m_cvImage; int timeout = 0; *pCap >> *pMat; if (!pMat->data) { printf("ERROR: Can't read camera input. Camera is not supported.\n"); return -1; } vx_imagepatch_addressing_t addr = { 0 }; vx_uint8 * dst = NULL; ERROR_CHECK(vxAccessImagePatch(m_image, &m_rectFull, 0, &addr, (void **)&dst, VX_WRITE_ONLY)); vx_int32 rowSize = ((vx_int32)pMat->step < addr.stride_y) ? (vx_int32)pMat->step : addr.stride_y; for (vx_uint32 y = 0; y < m_height; y++) { memcpy(dst + y * addr.stride_y, pMat->data + y * pMat->step, rowSize); } ERROR_CHECK(vxCommitImagePatch(m_image, &m_rectFull, 0, &addr, dst)); } #endif // make sure that input file is open when OpenCV camera is not active and input filename is specified #if ENABLE_OPENCV if (!m_cvImage) #endif if (!m_fpRead) { if (m_fileNameRead.length() > 0) { char fileName[MAX_FILE_NAME_LENGTH]; sprintf(fileName, m_fileNameRead.c_str(), frameNumber, m_width, m_height); m_fpRead = fopen(fileName, "rb"); if (!m_fpRead) ReportError("ERROR: unable to open: %s\n", fileName); if (!m_fileNameForReadHasIndex && m_captureFrameStart > 0) { // skip to specified frame when starting frame is specified fseek(m_fpRead, m_captureFrameStart*(long)m_frameSize, SEEK_SET); } } } if (m_fpRead) { // update m_countFrames to be able to repeat after every m_repeatFrames if (m_repeatFrames != 0) { if (m_countFrames == m_repeatFrames) { // seek back to beginning after every m_repeatFrames frames fseek(m_fpRead, m_captureFrameStart*(long)m_frameSize, SEEK_SET); m_countFrames = 0; } else { m_countFrames++; } } // read all image planes into vx_image and check if EOF has occured while reading bool eofDetected = ReadImage(m_image, &m_rectFull, m_fpRead) ? true : false; // close file if file names has indices (i.e., only one frame per file requested) if (m_fileNameForReadHasIndex) { fclose(m_fpRead); m_fpRead = nullptr; } if (eofDetected) { // report the caller that end of file has been detected -- no frames available in input return 1; } } // process user requested directives if (m_useSyncOpenCLWriteDirective) { ERROR_CHECK_AND_WARN(vxDirective((vx_reference)m_image, VX_DIRECTIVE_AMD_COPY_TO_OPENCL), VX_ERROR_NOT_ALLOCATED); } return 0; } #if ENABLE_OPENCV int CVxParamImage::ViewFrame(int frameNumber) { if (m_cvDispMat) { // NOTE: supports only U8, S16, RGB, RGBX, F32 formats if (m_format == VX_DF_IMAGE_U8 || m_format == VX_DF_IMAGE_S16 || m_format == VX_DF_IMAGE_RGB || m_format == VX_DF_IMAGE_RGBX || m_format == VX_DF_IMAGE_F32_AMD || m_format == VX_DF_IMAGE_U1_AMD) { // copy image into Mat Mat * pMat = (Mat *)m_cvDispMat; vx_imagepatch_addressing_t addr = { 0 }; vx_uint8 * src = NULL; ERROR_CHECK(vxAccessImagePatch(m_image, &m_rectFull, 0, &addr, (void **)&src, VX_READ_ONLY)); if (m_format == VX_DF_IMAGE_U1_AMD) { for (vx_uint32 y = 0; y < m_height; y++) { vx_uint8 * pDst = (vx_uint8 *)pMat->data + y * pMat->step; vx_uint8 * pSrc = (vx_uint8 *)src + y * addr.stride_y; for (vx_uint32 x = 0; x < m_width; x++) { pDst[x] = (pSrc[x >> 3] & (1 << (x & 3))) ? 255u : 0; } } } else if (m_format == VX_DF_IMAGE_RGB) { for (vx_uint32 y = 0; y < m_height; y++) { vx_uint8 * pDst = (vx_uint8 *)pMat->data + y * pMat->step; vx_uint8 * pSrc = (vx_uint8 *)src + y * addr.stride_y; for (vx_uint32 x = 0; x < m_width; x++) { pDst[0] = pSrc[2]; pDst[1] = pSrc[1]; pDst[2] = pSrc[0]; pDst += 3; pSrc += 3; } } } else { vx_int32 rowSize = ((vx_int32)pMat->step < addr.stride_y) ? (vx_int32)pMat->step : addr.stride_y; for (vx_uint32 y = 0; y < m_height; y++) { memcpy(pMat->data + y * pMat->step, src + y * addr.stride_y, rowSize); } } ERROR_CHECK(vxCommitImagePatch(m_image, &m_rectFull, 0, &addr, src)); // convert grayscale Mat pMat to RGB Mat convertedToRGB: // this is done in order to be able to plot keypoints with different colors Mat convertedToRGB(pMat->rows, pMat->cols, CV_8UC3, Scalar(0, 0, 255)); Mat *pOutputImage = pMat; if (pMat->type() == CV_8UC1) { // TBD: need to support S16 images here cvtColor(*pMat, convertedToRGB, CV_GRAY2RGB); pOutputImage = &convertedToRGB; } // color table for key-points static int colorTable[][3] = { { 0, 255, 0 }, { 255, 0, 0 }, { 0, 255, 255 }, { 51, 51, 255 }, { 0, 0, 102 }, { 255, 255, 255 } }; int colorIndex = m_colorIndexDefault; // list of golbal list std::vector<ArrayItemForView> kpList; // process objects with same window name as the image int overlayOffsetX = 10, overlayOffsetY = 10; for (auto it = m_paramList.begin(); it != m_paramList.end(); it++) { if (*it != this && !m_displayName.compare((*it)->getDisplayName())) { // name of the window matched vx_delay delay = nullptr; vx_enum delayObjType = VX_TYPE_INVALID; if ((*it)->GetVxObjectType() == VX_TYPE_DELAY) { // display the slot[0] of delay object delay = (vx_delay)(*it)->GetVxObject(); ERROR_CHECK(vxQueryDelay(delay, VX_DELAY_ATTRIBUTE_TYPE, &delayObjType, sizeof(delayObjType))); } if ((*it)->GetVxObjectType() == VX_TYPE_ARRAY || (delay && delayObjType == VX_TYPE_ARRAY)) { // view the array data (processed in two steps) //////////////////////////// // get array and itemtype and numitems CVxParameter * paramArray = nullptr; vx_array arr = nullptr; if (delay && delayObjType == VX_TYPE_ARRAY) { // view the array from slot[0] arr = (vx_array)vxGetReferenceFromDelay(delay, 0); } else { paramArray = *it; arr = (vx_array)paramArray->GetVxObject(); } vx_enum itemtype = VX_TYPE_INVALID; vx_size arrayNumItems = 0; ERROR_CHECK(vxQueryArray(arr, VX_ARRAY_ATTRIBUTE_ITEMTYPE, &itemtype, sizeof(itemtype))); ERROR_CHECK(vxQueryArray(arr, VX_ARRAY_ATTRIBUTE_NUMITEMS, &arrayNumItems, sizeof(arrayNumItems))); if (itemtype != VX_TYPE_KEYPOINT && itemtype != VX_TYPE_RECTANGLE && itemtype != VX_TYPE_COORDINATES2D) ReportError("ERROR: doesn't support viewing of specified array type\n"); // add data items to the global kpList if (paramArray && paramArray->GetArrayListForViewCount() > 0) { // use data items from the shared list for view, if available size_t count = paramArray->GetArrayListForViewCount(); int colorIndexMax = colorIndex; for (auto index = 0; index < count; index++) { ArrayItemForView kpItem = *paramArray->GetArrayListForViewItemAt(index); // update kpItem.colorIndex and colorIndexMax int id = colorIndex + kpItem.colorIndex; if (id >= int(sizeof(colorTable) / sizeof(colorTable[0]))) id = int(sizeof(colorTable) / sizeof(colorTable[0]) - 1); colorIndexMax = max(id, colorIndexMax); kpItem.colorIndex = id; // add the item to global list kpList.push_back(kpItem); } // update colorIndex for next item colorIndex = colorIndexMax; if (colorIndex < int(sizeof(colorTable) / sizeof(colorTable[0]) - 1)) colorIndex++; // reset the list paramArray->ResetArrayListForView(); } else if (arrayNumItems > 0) { // use the data items from the vx_array object // initialize keypoint with colorIndex and update colorIndex for next keypoint set ArrayItemForView kpItem = { itemtype, colorIndex, 0, 0, 0.0f, 0, 0 }; if (colorIndex < int(sizeof(colorTable) / sizeof(colorTable[0]) - 1)) colorIndex++; // compute strength bounds and binSize for plotted point radius vx_size stride = 0; void *base = NULL; ERROR_CHECK(vxAccessArrayRange(arr, 0, arrayNumItems, &stride, &base, VX_READ_ONLY)); if (itemtype == VX_TYPE_KEYPOINT) { size_t arrayNumTracked = 0; for (size_t i = 0; i < arrayNumItems; i++) { vx_keypoint_t * kp = &vxArrayItem(vx_keypoint_t, base, i, stride); if (kp->tracking_status) { kpItem.strength = kp->strength; kpItem.x = kp->x; kpItem.y = kp->y; kpList.push_back(kpItem); arrayNumTracked++; } } char message[128]; sprintf(message, "%s [tracked %d/%d]", (*it)->GetVxObjectName(), (int)arrayNumTracked, (int)arrayNumItems); int H = 20; cv::putText(*pOutputImage, message, Point(overlayOffsetX + 0, overlayOffsetY + H - 6), CV_FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255, 0), 2, 8, false); cv::putText(*pOutputImage, message, Point(overlayOffsetX + 2, overlayOffsetY + H - 8), CV_FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 255, 255, 0), 1, 8, false); overlayOffsetY += H; } else if (itemtype == VX_TYPE_RECTANGLE) { for (size_t i = 0; i < arrayNumItems; i++) { vx_rectangle_t * kp = &vxArrayItem(vx_rectangle_t, base, i, stride); kpItem.x = kp->start_x; kpItem.y = kp->start_y; kpItem.w = kp->end_x - kp->start_x; kpItem.h = kp->end_y - kp->start_y; kpList.push_back(kpItem); } } else if (itemtype == VX_TYPE_COORDINATES2D) { for (size_t i = 0; i < arrayNumItems; i++) { vx_coordinates2d_t * kp = &vxArrayItem(vx_coordinates2d_t, base, i, stride); kpItem.x = kp->x; kpItem.y = kp->y; kpList.push_back(kpItem); } } ERROR_CHECK(vxCommitArrayRange(arr, 0, arrayNumItems, base)); } } else if ((*it)->GetVxObjectType() == VX_TYPE_DISTRIBUTION) { // view the distribution data //////////////////////////// vx_distribution dist = (vx_distribution)(*it)->GetVxObject(); vx_size numBins = 0; vx_uint32 * hist = nullptr; ERROR_CHECK(vxQueryDistribution(dist, VX_DISTRIBUTION_ATTRIBUTE_BINS, &numBins, sizeof(numBins))); ERROR_CHECK(vxAccessDistribution(dist, (void **)&hist, VX_READ_ONLY)); vx_uint32 maxValue = 0; for (size_t bin = 0; bin < numBins; bin++) { maxValue = max(maxValue, hist[bin]); } Rect box(overlayOffsetX, overlayOffsetY, 256, 100); overlayOffsetY += (box.height + 8); rectangle(*pOutputImage, Rect(box.x - 2, box.y - 2, box.width + 4, box.height + 4), Scalar(0, 0, 255), 1, 8); rectangle(*pOutputImage, Rect(box.x - 1, box.y - 1, box.width + 2, box.height + 2), Scalar(255, 0, 0), 1, 8); if (maxValue > 0) { int barWidth = box.width / (int)numBins; for (int bin = 0; bin < (int)numBins; bin++) { int barHeight = box.height * hist[bin] / maxValue; Rect bar(box.x + bin*barWidth, box.y + box.height - barHeight, barWidth, barHeight); rectangle(*pOutputImage, bar, Scalar(0, 255, 255), CV_FILLED, 8); } } ERROR_CHECK(vxCommitDistribution(dist, hist)); // show the name of the object to the right char message[128]; sprintf(message, "%s (distribution)", (*it)->GetVxObjectName()); int H = 20; cv::putText(*pOutputImage, message, Point(box.x + box.width + 10, box.y + H - 6), CV_FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255, 0), 2, 8, false); cv::putText(*pOutputImage, message, Point(box.x + box.width + 12, box.y + H - 8), CV_FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 255, 255, 0), 1, 8, false); } else if ((*it)->GetVxObjectType() == VX_TYPE_LUT) { // view the lut data //////////////////////////// vx_lut lut = (vx_lut)(*it)->GetVxObject(); vx_enum data_type; ERROR_CHECK(vxQueryLUT(lut, VX_LUT_ATTRIBUTE_TYPE, &data_type, sizeof(data_type))); if (data_type == VX_TYPE_UINT8) { // only supports 8-bit look-up tables vx_size count; vx_uint8 * data = nullptr; ERROR_CHECK(vxQueryLUT(lut, VX_LUT_ATTRIBUTE_COUNT, &count, sizeof(count))); ERROR_CHECK(vxAccessLUT(lut, (void **)&data, VX_READ_ONLY)); vx_uint32 maxValue = 255; Rect box(overlayOffsetX, overlayOffsetY, 256, 256); overlayOffsetY += (box.height + 8); rectangle(*pOutputImage, Rect(box.x - 2, box.y - 2, box.width + 4, box.height + 4), Scalar(255, 0, 255), 1, 8); rectangle(*pOutputImage, Rect(box.x - 1, box.y - 1, box.width + 2, box.height + 2), Scalar(255, 255, 0), 1, 8); int barWidth = box.width / (int)count; for (int bin = 0; bin < (int)count; bin++) { int barHeight = box.height * data[bin] / maxValue; Rect bar(box.x + bin*barWidth, box.y + box.height - barHeight, barWidth, barHeight); rectangle(*pOutputImage, bar, Scalar(0, 255, 255), CV_FILLED, 8); } ERROR_CHECK(vxCommitLUT(lut, data)); // show the name of the object to the right char message[128]; sprintf(message, "%s (lut)", (*it)->GetVxObjectName()); int H = 20; cv::putText(*pOutputImage, message, Point(box.x + box.width + 10, box.y + H - 6), CV_FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(255, 0, 0, 0), 2, 8, false); cv::putText(*pOutputImage, message, Point(box.x + box.width + 12, box.y + H - 8), CV_FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 255, 255, 0), 1, 8, false); } } else if ((*it)->GetVxObjectType() == VX_TYPE_SCALAR) { // view the scalar data //////////////////////////// char value[64]; vx_scalar scalar = (vx_scalar)(*it)->GetVxObject(); ReadScalarToString(scalar, value); char message[128]; sprintf(message, "%s = %s", (*it)->GetVxObjectName(), value); int H = 20; cv::putText(*pOutputImage, message, Point(overlayOffsetX+0, overlayOffsetY+H-6), CV_FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255, 0), 2, 8, false); cv::putText(*pOutputImage, message, Point(overlayOffsetX+2, overlayOffsetY+H-8), CV_FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 255, 255, 0), 1, 8, false); overlayOffsetY += H; } } } // add keypoints from user specified file(s) for (auto it = m_viewKeypointFilenameList.begin(); it != m_viewKeypointFilenameList.end(); it++) { // initialize keypoint with colorIndex and update colorIndex for next keypoint set ArrayItemForView kpItem = { VX_TYPE_KEYPOINT, colorIndex, 0, 0, 0.0f, 0, 0 }; if (colorIndex < int(sizeof(colorTable) / sizeof(colorTable[0]) - 1)) colorIndex++; // get list of keypoints from the user specified file char fileName[512]; sprintf(fileName, it->c_str(), frameNumber); FILE * fp = fopen(fileName, "r"); if (!fp) ReportError("ERROR: unable to open '%s'\n", fileName); char line[256]; while (fgets(line, sizeof(line), fp) != NULL) { if (sscanf(line, "%d%d%f", &kpItem.x, &kpItem.y, &kpItem.strength) == 3) { kpList.push_back(kpItem); } } fclose(fp); } // compute strength bounds and binSize for computing keypoint radius float minStrength = FLT_MAX, maxStrength = FLT_MIN; for (auto it = kpList.begin(); it != kpList.end(); it++) { if (it->itemtype == VX_TYPE_KEYPOINT) { float strength = it->strength; minStrength = min(strength, minStrength); maxStrength = max(strength, maxStrength); } } float binSize = (maxStrength - minStrength) / 5; // plot the points for (auto it = kpList.begin(); it != kpList.end(); it++) { Scalar color(colorTable[it->colorIndex][0], colorTable[it->colorIndex][1], colorTable[it->colorIndex][2]); if (it->itemtype == VX_TYPE_KEYPOINT) { // compute the radius of point using strength and binSize float strength = it->strength; double radius = m_radiusDefault; if (strength > minStrength) { radius += 2.0 * floor((strength - minStrength) / binSize); } // plot the points with key-point location as center of circle Point center(it->x, it->y); circle(*pOutputImage, center, (int)radius, Scalar(0, 0, 0), 1, 8); circle(*pOutputImage, center, (int)radius + 1, color, 1, 8); } else if (it->itemtype == VX_TYPE_RECTANGLE) { // plot the rectangle Rect rec(it->x, it->y, it->w, it->h); rectangle(*pOutputImage, rec, color, 1, 8); } else if (it->itemtype == VX_TYPE_COORDINATES2D) { // plot the points with small circle float radius = m_radiusDefault; Point center(it->x, it->y); circle(*pOutputImage, center, (int)radius, Scalar(0, 0, 0), 1, 8); circle(*pOutputImage, center, (int)radius + 1, color, 1, 8); } } // show the image and points (if requested) if (m_usingDisplay) { imshow(m_displayName, *pOutputImage); } if (m_usingWriter) { ((VideoWriter *)m_cvWriter)->write(*pOutputImage); } } } return 0; } #endif int CVxParamImage::WriteFrame(int frameNumber) { #if ENABLE_OPENCV if (ViewFrame(frameNumber) < 0) return -1; #endif if (!m_fpWrite) { if (m_fileNameWrite.length() > 0 && !m_usingWriter) { char fileName[MAX_FILE_NAME_LENGTH]; sprintf(fileName, m_fileNameWrite.c_str(), frameNumber, m_width, m_height); #if ENABLE_OPENCV // check if openCV imwrite need to be used int extpos = (int)strlen(fileName) - 1; while (extpos > 0 && fileName[extpos] != '.') extpos--; if (!_stricmp(&fileName[extpos], ".jpg") || !_stricmp(&fileName[extpos], ".jpeg") || !_stricmp(&fileName[extpos], ".jpe") || !_stricmp(&fileName[extpos], ".png") || !_stricmp(&fileName[extpos], ".bmp") || !_stricmp(&fileName[extpos], ".tif") || !_stricmp(&fileName[extpos], ".ppm") || !_stricmp(&fileName[extpos], ".tiff") || !_stricmp(&fileName[extpos], ".pgm") || !_stricmp(&fileName[extpos], ".pbm")) { WriteImageCompressed(m_image, &m_rectFull,fileName); return 0; } #endif m_fpWrite = fopen(fileName, "wb+"); if (!m_fpWrite) ReportError("ERROR: unable to create: %s\n", fileName); } } if (m_fpWrite) { // write vx_image into file WriteImage(m_image, &m_rectFull, m_fpWrite); // close the file if one frame gets written per file if (m_fileNameForWriteHasIndex && m_fpWrite) { fclose(m_fpWrite); m_fpWrite = nullptr; } } return 0; } int CVxParamImage::CompareFrame(int frameNumber) { // make sure that compare reference data is opened if (!m_fpCompare) { if (m_fileNameCompare.length() > 0) { sprintf(m_fileNameCompareCurrent, m_fileNameCompare.c_str(), frameNumber, m_width, m_height); if (m_generateCheckSumForCompare) { m_fpCompare = fopen(m_fileNameCompareCurrent, "w"); if (!m_fpCompare) ReportError("ERROR: unable to create: %s\n", m_fileNameCompareCurrent); } else { m_fpCompare = fopen(m_fileNameCompareCurrent, "rb"); if (!m_fpCompare) ReportError("ERROR: unable to open: %s\n", m_fileNameCompareCurrent); } } } if (!m_fpCompare) return 0; if (m_generateCheckSumForCompare) { // generate checksum ////////////////////////////////////////// char checkSumString[64]; ComputeChecksum(checkSumString, m_image, &m_rectCompare); fprintf(m_fpCompare, "%s\n", checkSumString); } else if (m_useCheckSumForCompare) { // compare checksum ////////////////////////////////////////// char checkSumStringRef[64] = { 0 }; if (fscanf(m_fpCompare, "%s", checkSumStringRef) != 1) { printf("ERROR: image checksum missing for frame#%d in %s\n", frameNumber, m_fileNameCompareCurrent); throw - 1; } char checkSumString[64]; ComputeChecksum(checkSumString, m_image, &m_rectCompare); if (!strcmp(checkSumString, checkSumStringRef)) { m_compareCountMatches++; if (m_verbose) printf("OK: image CHECKSUM MATCHED for %s with frame#%d of %s\n", GetVxObjectName(), frameNumber, m_fileNameCompareCurrent); } else { m_compareCountMismatches++; printf("ERROR: image CHECKSUM MISMATCHED for %s with frame#%d of %s [%s instead of %s]\n", GetVxObjectName(), frameNumber, m_fileNameCompareCurrent, checkSumString, checkSumStringRef); if (!m_discardCompareErrors) return -1; } } else { // compare raw frames ////////////////////////////////////////// // make sure buffer has been allocated if (!m_bufForCompare) { NULLPTR_CHECK(m_bufForCompare = new vx_uint8[m_frameSize]); } // read data from frame if (m_frameSize != fread(m_bufForCompare, 1, m_frameSize, m_fpCompare)) { // no more data to compare ReportError("ERROR: image data missing for frame#%d in %s\n", frameNumber, m_fileNameCompareCurrent); } // compare image to reference from file size_t errorPixelCountTotal = CompareImage(m_image, &m_rectCompare, m_bufForCompare, m_comparePixelErrorMin, m_comparePixelErrorMax, frameNumber, m_fileNameCompareCurrent); if (!errorPixelCountTotal) { m_compareCountMatches++; if (m_verbose) printf("OK: image COMPARE MATCHED for %s with frame#%d of %s\n", GetVxObjectName(), frameNumber, m_fileNameCompareCurrent); } else { m_compareCountMismatches++; if (!m_discardCompareErrors) return -1; } } // close the file if user requested separate file for each compare data if (m_fileNameForCompareHasIndex) { fclose(m_fpCompare); m_fpCompare = nullptr; } return 0; }
ori $ra,$ra,0xf div $6,$ra sll $1,$6,24 lb $5,5($0) srav $5,$1,$3 sll $6,$5,3 sll $4,$0,27 mult $1,$3 div $5,$ra sb $5,12($0) divu $2,$ra mflo $2 lb $6,15($0) lui $6,42828 mflo $2 mtlo $3 sll $1,$2,30 sll $1,$6,15 sb $2,6($0) mult $4,$2 mult $4,$5 addu $1,$1,$1 mtlo $2 multu $3,$5 mult $1,$2 multu $1,$2 mthi $4 ori $1,$1,52391 multu $5,$5 mtlo $5 divu $1,$ra divu $6,$ra addiu $3,$3,9212 sb $0,6($0) mfhi $0 mtlo $0 mult $4,$2 lui $0,32467 mtlo $4 mthi $2 addu $3,$1,$3 lui $3,63157 mflo $4 mflo $4 sll $4,$6,10 div $0,$ra addiu $1,$4,29514 addiu $1,$1,7611 srav $1,$4,$4 divu $2,$ra mfhi $6 multu $4,$5 mtlo $5 div $4,$ra srav $6,$6,$3 lui $1,61092 sll $2,$4,15 addiu $1,$5,-29704 mfhi $5 addiu $5,$6,31684 divu $4,$ra ori $1,$4,59217 sb $4,11($0) srav $6,$0,$6 mtlo $1 srav $1,$4,$3 srav $2,$2,$3 mtlo $5 div $6,$ra lui $6,6772 addu $0,$2,$2 ori $5,$2,46927 lui $1,35868 sb $1,5($0) divu $4,$ra sll $0,$0,4 addiu $3,$2,27404 lui $4,8084 divu $1,$ra sll $4,$3,5 addiu $4,$4,-3676 ori $4,$5,63853 addiu $4,$1,-30530 div $5,$ra mult $3,$1 mfhi $6 ori $1,$6,48419 div $5,$ra mult $2,$1 mfhi $4 mtlo $4 mfhi $3 lb $0,4($0) multu $3,$2 divu $5,$ra mflo $4 multu $5,$1 sb $2,1($0) sll $4,$5,16 mthi $5 addu $3,$4,$3 lui $0,12417 div $0,$ra mfhi $5 mflo $0 sll $4,$2,9 mfhi $4 multu $5,$5 mult $0,$1 div $0,$ra lb $6,8($0) addiu $5,$1,22044 sb $5,2($0) lb $5,1($0) ori $4,$1,48001 mthi $4 addiu $2,$2,29200 mtlo $0 ori $1,$1,9210 mult $1,$1 multu $0,$5 sb $5,13($0) sll $4,$1,4 addiu $4,$1,-18311 lb $5,3($0) addu $5,$5,$5 addu $4,$1,$0 mtlo $4 mflo $4 mult $1,$6 sll $6,$4,14 multu $6,$6 div $0,$ra lb $6,9($0) lb $4,0($0) lui $4,10940 addiu $5,$5,29942 lb $4,10($0) mflo $1 addiu $2,$2,-7225 mult $1,$0 sll $3,$3,24 mflo $1 lb $5,15($0) lui $5,47801 lui $4,7755 mtlo $4 mfhi $1 addiu $6,$6,-18287 divu $4,$ra mflo $4 ori $6,$2,64834 addiu $1,$6,-10461 sll $0,$4,7 lb $1,1($0) ori $5,$5,7263 mfhi $6 addu $5,$5,$4 mult $5,$6 srav $5,$0,$3 sb $4,6($0) mthi $4 divu $5,$ra mfhi $4 addiu $4,$1,-13051 lui $0,14179 addu $4,$0,$4 multu $4,$4 addiu $4,$4,-7629 addu $5,$4,$3 addiu $4,$2,8592 addu $1,$1,$6 multu $0,$0 multu $4,$4 mflo $2 srav $4,$6,$3 mthi $0 multu $1,$4 ori $0,$0,17028 sll $4,$2,18 lui $1,32129 div $5,$ra sb $5,14($0) sb $0,9($0) lui $2,63568 ori $6,$1,17929 addu $4,$4,$2 ori $1,$1,54606 lb $5,0($0) lui $5,58689 lui $4,36682 srav $4,$4,$4 sll $6,$1,24 mflo $4 addiu $4,$2,2379 sb $5,8($0) sb $6,1($0) addu $5,$0,$2 mthi $4 addiu $3,$3,30748 mfhi $5 addiu $6,$6,22227 mthi $4 mfhi $6 srav $1,$2,$3 mult $4,$2 sll $5,$4,18 sb $4,1($0) divu $5,$ra ori $4,$4,40522 mflo $6 addiu $0,$0,24040 mflo $6 mfhi $4 sb $0,2($0) mfhi $2 mtlo $4 lb $5,7($0) div $5,$ra sll $3,$1,25 lb $5,6($0) ori $0,$3,24626 sll $5,$5,26 mfhi $0 addu $4,$4,$5 mtlo $0 mflo $3 addu $4,$4,$4 mflo $1 sll $5,$5,12 addiu $5,$1,18408 addiu $4,$4,-19135 div $3,$ra lb $4,12($0) ori $1,$1,21095 mflo $5 mult $4,$2 addiu $1,$1,27844 mfhi $4 multu $4,$4 mthi $2 mthi $4 sll $4,$4,11 ori $0,$0,50356 mthi $4 addiu $6,$6,1878 sll $6,$3,1 div $4,$ra srav $4,$4,$4 mflo $4 sll $6,$6,23 mthi $4 ori $1,$1,30935 addu $5,$2,$5 mflo $6 sll $6,$2,15 sb $0,13($0) addiu $1,$2,-1896 ori $4,$5,50705 addiu $4,$4,-8265 addu $4,$4,$4 mthi $4 ori $4,$2,31561 sb $5,10($0) div $1,$ra sb $6,3($0) ori $1,$2,37042 multu $4,$2 mult $5,$4 mflo $5 lb $6,9($0) lb $3,8($0) lui $4,37186 addu $4,$0,$0 srav $4,$4,$2 addiu $0,$2,-204 multu $4,$4 srav $0,$0,$0 mthi $2 mtlo $0 sll $4,$2,22 lb $1,12($0) mult $4,$6 lui $4,22081 mfhi $4 mtlo $1 divu $2,$ra ori $4,$4,43151 divu $2,$ra addiu $1,$4,28430 mfhi $0 addu $2,$5,$2 lui $2,31823 mtlo $4 mfhi $4 addiu $1,$0,-5091 mult $1,$1 addu $1,$1,$5 srav $6,$4,$5 mult $1,$1 sll $1,$3,30 lb $5,12($0) srav $5,$3,$3 srav $1,$4,$4 ori $0,$0,34716 ori $1,$1,46163 mult $1,$3 lb $3,8($0) addu $4,$4,$3 mflo $4 mfhi $2 mtlo $2 ori $1,$2,26734 lui $5,4085 mthi $5 addu $1,$1,$3 sll $3,$3,30 mflo $5 addu $6,$6,$4 addu $4,$4,$5 sll $1,$2,27 addu $4,$4,$4 mthi $2 addu $2,$2,$2 lui $4,21449 sb $5,11($0) addu $0,$0,$1 mthi $5 addiu $4,$4,-6988 mthi $5 mtlo $4 mult $4,$5 lb $6,13($0) sll $5,$5,21 mthi $0 multu $6,$3 lui $2,65237 divu $2,$ra mtlo $5 addiu $0,$0,24884 lb $4,10($0) div $1,$ra multu $4,$2 srav $0,$2,$4 divu $1,$ra sb $5,2($0) ori $1,$5,29925 multu $1,$2 multu $4,$2 lb $3,12($0) mult $1,$4 lb $4,6($0) sll $5,$0,16 mult $1,$1 mthi $5 ori $2,$2,15652 addiu $4,$4,-25644 lui $6,51942 mthi $1 srav $5,$2,$6 sll $5,$5,22 mfhi $0 srav $4,$0,$4 addu $1,$1,$3 multu $4,$4 addu $4,$1,$1 mflo $5 lui $1,36671 addiu $5,$2,29676 mtlo $4 addiu $1,$1,15514 divu $6,$ra divu $4,$ra lui $3,52956 multu $3,$4 mflo $5 mthi $5 ori $4,$1,16055 sll $3,$3,6 mtlo $4 srav $4,$4,$3 lb $2,0($0) ori $1,$0,5178 mfhi $4 mflo $5 lui $2,42951 divu $4,$ra multu $3,$6 sll $4,$6,13 sll $4,$0,19 mflo $4 divu $3,$ra addiu $2,$0,-23722 mthi $4 mtlo $0 sb $6,13($0) ori $5,$1,55726 lb $4,11($0) addiu $5,$1,-4007 mthi $2 mult $2,$2 mult $5,$5 mthi $0 mflo $1 ori $0,$1,4172 mthi $4 sb $4,14($0) lui $1,19713 sll $4,$4,28 divu $4,$ra addu $5,$1,$2 mthi $0 lb $1,2($0) mfhi $4 multu $6,$4 srav $2,$4,$2 srav $0,$4,$4 mult $2,$5 srav $6,$4,$5 mfhi $1 multu $6,$5 divu $1,$ra divu $0,$ra div $4,$ra lui $6,21133 srav $2,$2,$5 addu $0,$1,$4 multu $1,$5 multu $0,$1 mult $5,$6 mflo $3 mult $1,$1 sll $4,$3,16 addiu $0,$6,22150 multu $4,$4 srav $4,$6,$6 mflo $4 divu $4,$ra addiu $5,$5,-13439 mthi $0 srav $3,$6,$3 mtlo $6 multu $1,$2 sll $6,$2,18 mflo $5 ori $1,$2,51887 ori $2,$2,37395 mult $5,$2 mthi $1 div $6,$ra addu $5,$4,$4 addiu $6,$5,20263 mult $0,$4 divu $4,$ra divu $4,$ra ori $0,$1,22217 sll $6,$5,18 divu $3,$ra sb $4,0($0) mthi $5 mult $5,$0 multu $4,$3 addiu $5,$4,28462 mfhi $6 lb $0,12($0) mflo $1 ori $2,$2,1972 mfhi $4 div $4,$ra srav $3,$2,$3 mflo $4 addiu $4,$4,29949 lui $6,64753 addiu $2,$2,-30220 srav $2,$2,$2 sb $6,4($0) lui $6,11706 divu $1,$ra mfhi $4 mult $4,$5 ori $6,$6,51213 mflo $3 ori $4,$2,21469 divu $4,$ra lb $1,7($0) sb $4,12($0) mult $4,$3 mtlo $4 divu $4,$ra mthi $5 div $4,$ra lb $6,7($0) srav $2,$2,$3 addiu $6,$3,-22031 multu $4,$0 mthi $6 addu $4,$5,$2 addiu $0,$2,-30258 ori $4,$4,13815 mfhi $3 addu $6,$4,$2 sll $6,$5,20 mfhi $1 mfhi $1 sb $2,4($0) div $2,$ra mtlo $0 addiu $1,$3,6260 lb $5,9($0) srav $5,$4,$4 div $1,$ra multu $2,$2 mthi $4 ori $0,$1,1219 ori $4,$2,31864 srav $3,$3,$3 div $4,$ra sb $5,12($0) lui $4,42766 mult $3,$3 ori $1,$4,18632 mthi $1 mflo $4 lb $1,6($0) mflo $5 mtlo $1 lui $0,33672 addiu $1,$6,-6951 srav $4,$4,$2 mfhi $4 sll $2,$2,4 addu $0,$0,$0 mflo $2 mflo $4 addiu $5,$1,17805 mfhi $0 divu $6,$ra lui $4,15399 mtlo $3 sll $5,$4,13 mtlo $1 srav $5,$5,$1 sll $2,$2,6 lb $5,10($0) ori $4,$2,53264 divu $4,$ra mfhi $1 mflo $4 mtlo $4 sb $4,4($0) addu $2,$1,$2 div $1,$ra lb $1,0($0) mflo $1 multu $2,$2 addu $2,$2,$0 divu $5,$ra lb $5,16($0) lui $4,30611 divu $3,$ra lb $2,8($0) mfhi $5 lb $4,13($0) addiu $4,$4,-13693 mult $2,$2 srav $6,$2,$6 mult $4,$4 multu $5,$5 lui $1,55659 mult $6,$0 srav $1,$2,$2 ori $1,$4,3677 mult $5,$1 mthi $5 mthi $1 mult $5,$4 mtlo $4 addiu $4,$2,16034 mthi $0 mtlo $4 addiu $3,$3,27330 mfhi $4 mtlo $1 lb $4,9($0) multu $1,$1 ori $6,$4,36199 divu $0,$ra mflo $5 sb $4,9($0) mflo $3 mthi $5 lui $1,32743 mfhi $1 mthi $1 addu $4,$1,$3 mflo $2 srav $4,$4,$4 mult $1,$1 div $5,$ra lb $5,14($0) div $5,$ra addu $4,$2,$1 mflo $4 sb $1,10($0) mflo $1 lui $0,55691 sb $5,0($0) addiu $5,$5,-23606 divu $4,$ra lb $1,15($0) divu $4,$ra mult $4,$2 lui $1,46716 ori $5,$1,24193 mtlo $4 ori $3,$3,63844 srav $4,$5,$5 multu $1,$2 multu $5,$5 addu $4,$6,$5 multu $5,$2 addu $0,$4,$6 mult $1,$1 sll $2,$2,30 multu $3,$2 addu $5,$5,$5 multu $2,$1 addiu $1,$1,14076 addiu $1,$0,-12179 multu $2,$2 lb $4,0($0) ori $0,$4,25497 mthi $3 srav $4,$2,$4 multu $4,$4 addu $2,$2,$4 mthi $0 sll $2,$2,5 div $1,$ra mtlo $0 addiu $4,$1,-15557 mthi $5 lb $6,6($0) ori $4,$6,39735 mfhi $0 divu $6,$ra lui $2,5770 lui $2,23316 mthi $4 lui $5,31893 div $6,$ra sll $0,$0,19 multu $4,$2 sll $1,$3,9 mult $5,$3 lb $0,8($0) mult $4,$2 mult $3,$3 lui $4,52393 mthi $4 divu $1,$ra mtlo $0 div $1,$ra srav $1,$5,$5 mfhi $4 addu $4,$2,$3 mult $2,$5 div $3,$ra mfhi $4 divu $4,$ra mthi $2 srav $1,$6,$2 lb $2,2($0) lui $3,56133 mult $5,$0 lui $5,45140 addiu $5,$2,-7825 mthi $4 sll $5,$2,12 divu $5,$ra sll $5,$3,22 lb $4,15($0) lui $3,8472 divu $5,$ra mult $6,$1 lui $2,42461 addu $0,$4,$4 mthi $3 sll $1,$5,25 sll $0,$4,10 sb $0,15($0) mult $5,$5 mflo $1 addiu $1,$2,-30774 div $5,$ra sll $5,$4,29 sb $3,13($0) mtlo $1 mfhi $4 div $1,$ra div $1,$ra divu $5,$ra addu $5,$2,$3 mtlo $5 sb $0,9($0) mthi $5 addu $0,$4,$3 mthi $5 mthi $0 mtlo $4 multu $5,$4 mfhi $4 divu $2,$ra addiu $3,$4,1837 multu $4,$5 lui $2,43140 lui $1,50169 mult $6,$5 sb $6,6($0) srav $4,$4,$4 sb $1,14($0) srav $1,$5,$5 mthi $4 multu $1,$4 mfhi $0 sb $5,12($0) mflo $5 mult $1,$5 addu $4,$4,$4 div $6,$ra mflo $4 mfhi $5 sll $4,$0,28 sll $5,$5,20 lui $3,55037 addiu $5,$4,-19022 mfhi $2 sb $5,2($0) lb $3,13($0) addu $4,$2,$4 mtlo $5 srav $4,$5,$5 ori $4,$6,48016 mfhi $5 mfhi $1 sll $5,$4,17 mult $1,$4 lui $1,63186 div $4,$ra sll $4,$4,18 addiu $4,$4,8797 lb $0,1($0) sll $5,$2,12 mtlo $4 divu $0,$ra mtlo $6 mtlo $5 sll $1,$0,13 multu $0,$6 multu $4,$6 divu $0,$ra addiu $6,$1,24207 addiu $4,$5,20953 lui $4,32551 multu $1,$4 addu $6,$6,$6 mult $1,$2 lb $1,11($0) sll $5,$0,7 lb $4,8($0) ori $5,$1,59768 lb $4,11($0) multu $2,$2 addiu $4,$4,-23253 multu $2,$2 addiu $2,$2,-29700 sll $4,$5,12 sb $5,10($0) mthi $4 sll $1,$6,22 mthi $0 addiu $4,$2,3104 mult $4,$2 mfhi $1 addu $6,$0,$0 addu $4,$6,$3 mfhi $0 lb $5,11($0) mult $4,$5 sb $4,4($0) lui $4,31703 mfhi $0 mflo $4 addu $1,$1,$3 mflo $6 lui $5,31453 mflo $3 sll $4,$2,17 addiu $4,$4,-26056 multu $2,$4 lui $3,50237 addiu $1,$4,3881 div $4,$ra addu $1,$1,$6 mfhi $2 divu $5,$ra div $3,$ra mthi $5 srav $5,$3,$3 sb $5,11($0) sll $0,$6,31 mthi $1 multu $1,$5 divu $1,$ra mult $0,$3 addu $6,$6,$3 sb $2,0($0) mfhi $0 lb $1,0($0) div $1,$ra addiu $5,$4,-9589 mthi $1 mult $4,$3 mult $4,$6 mtlo $1 divu $3,$ra sb $5,5($0) div $3,$ra mthi $5 lui $4,43652 srav $4,$4,$5 div $0,$ra lb $6,0($0) sb $0,13($0) addiu $3,$0,-8931 srav $6,$5,$4 addiu $1,$4,-27129 mfhi $4 div $1,$ra srav $2,$2,$1 addiu $4,$5,-31615 divu $5,$ra divu $4,$ra mthi $0 mult $5,$6 mtlo $5 mflo $2 mflo $4 srav $2,$2,$2 multu $5,$5 lb $3,14($0) ori $0,$4,62507 mult $4,$4 addu $0,$2,$2 srav $5,$1,$0 multu $5,$5 mult $0,$5 lb $3,0($0) sll $1,$1,4 ori $4,$2,2476 mult $4,$5 mult $4,$4 mthi $4 mult $1,$1 mult $0,$4 sll $4,$4,14 addiu $0,$5,1292 mflo $4 addu $4,$5,$5 lb $4,12($0) mfhi $6 div $5,$ra mult $3,$3 mtlo $1 lb $0,4($0) addu $4,$2,$1 multu $6,$6 mult $5,$1 multu $4,$1 multu $3,$1 divu $2,$ra sb $1,5($0) lui $2,53416 divu $1,$ra divu $4,$ra srav $4,$4,$3 lui $3,36166 mthi $3 addu $5,$2,$2
; Test to make sure moves do not happen if they will break jrs ld a, 1 jp label1 label2: jr nc,label4 jr label2 label4: jr label4 label6: REPT 128 nop ENDM label5: jr label5 label1: add a,b jr nc,label3 jp label2 label3: jr label3
; ; Comment ; ; === STACK SEGMENT === MyStack segment stack DB 64 dup('12345678') MyStack endS ; === DATA SEGMENT === MyData segment ; --- Declare your variables here --- printme DB "NATIONAL",0Ah,"COMPUTER",0Ah,"CAMP",13,10,07h,"$" MyData endS MyCode segment Assume CS:Mycode,DS:MyData ;Includes go here ;End of includes Main PROC Start: MOV AX, MYDATA MOV DS, AX ;Start of your code MOV AH,9 LEA DX,printme INT 21h ;End of your code. XOR AX,AX XOR BX,BX XOR CX,CX XOR DX,DX MOV AH, 4Ch XOR AL, AL INT 21h Main ENDP MyCode endS End Start
// Copyright (c) 2011-2019 Bitcoin Developers // Copyright (c) 2014-2019 Dash Developers // Copyright (c) 2015-2019 PIVX Developers // Copyright (c) 2018-2019 True Crypto OSS Community // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "openuridialog.h" #include "ui_openuridialog.h" #include "guiutil.h" #include "walletmodel.h" #include <QUrl> OpenURIDialog::OpenURIDialog(QWidget* parent) : QDialog(parent), ui(new Ui::OpenURIDialog) { ui->setupUi(this); #if QT_VERSION >= 0x040700 ui->uriEdit->setPlaceholderText("tdc:"); #endif } OpenURIDialog::~OpenURIDialog() { delete ui; } QString OpenURIDialog::getURI() { return ui->uriEdit->text(); } void OpenURIDialog::accept() { SendCoinsRecipient rcp; if (GUIUtil::parseBitcoinURI(getURI(), &rcp)) { /* Only accept value URIs */ QDialog::accept(); } else { ui->uriEdit->setValid(false); } } void OpenURIDialog::on_selectFileButton_clicked() { QString filename = GUIUtil::getOpenFileName(this, tr("Select payment request file to open"), "", "", NULL); if (filename.isEmpty()) return; QUrl fileUri = QUrl::fromLocalFile(filename); ui->uriEdit->setText("tdc:?r=" + QUrl::toPercentEncoding(fileUri.toString())); }
; Are data offsets relative to segment or group? ; The question only makes sense for a segment in a group. ; A difference will only be shown when another segment comes before it in the group. ; The problem is only relevant in EXE, not in COM where all is one segment anyway. ; data displacement [disp], [si+disp] ; data word DW fred, OFFSET fred ; immediate mov ax, OFFSET fred ; when the segment register that will address it is assumed to its segment ; when the segment register that will address it is assumed to its group ; (any other case is an error, outside the scope of this file) IDEAL ASSUME CS:_CODE SEGMENT _CODE start: int 20h ASSUME DS:_DATA mov dx, [disp1] ENDS _CODE SEGMENT _DATA1 DB 100H DUP (00) DB 100H DUP (01) DB 100H DUP (02) DB 100H DUP (03) ENDS _DATA1 SEGMENT _DATA2 disp1 DW 0 ENDS _DATA2 GROUP _DATA _DATA1, _DATA2 SEGMENT _STACK STACK DB 20H DUP (0) ENDS _STACK END start
; A039703: a(n) = n-th prime modulo 5. ; Submitted by Jon Maiga ; 2,3,0,2,1,3,2,4,3,4,1,2,1,3,2,3,4,1,2,1,3,4,3,4,2,1,3,2,4,3,2,1,2,4,4,1,2,3,2,3,4,1,1,3,2,4,1,3,2,4,3,4,1,1,2,3,4,1,2,1,3,3,2,1,3,2,1,2,2,4,3,4,2,3,4,3,4,2,1,4,4,1,1,3,4,3,4,2,1,3,2,4,2,1,4,3,4,1,3,1 mul $0,2 max $0,1 seq $0,173919 ; Numbers that are prime or one less than a prime. mod $0,5
; A201824: G.f.: Sum_{n>=0} log( 1/sqrt(1-2^n*x) )^n / n!. ; 1,1,3,20,330,15504,2324784,1198774720,2214919483920,14955617450039552,372282884729800002816,34307640086657221926620160,11737947382912650038702322439680 mov $1,2 mov $2,$0 sub $2,1 pow $1,$2 add $1,$2 bin $1,$0 mov $0,$1
;------------------------------------------------------------------------------ ; @file ; 16-bit initialization code ; ; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ;------------------------------------------------------------------------------ BITS 16 ; ; @param[out] DI 'BP' to indicate boot-strap processor ; EarlyBspInitReal16: mov di, 'BP' jmp short Main16 ; ; @param[out] DI 'AP' to indicate application processor ; EarlyApInitReal16: mov di, 'AP' jmp short Main16 ; ; Modified: EAX ; ; @param[in] EAX Initial value of the EAX register (BIST: Built-in Self Test) ; @param[out] ESP Initial value of the EAX register (BIST: Built-in Self Test) ; EarlyInit16: ; ; ESP - Initial value of the EAX register (BIST: Built-in Self Test) ; movd mm0, eax OneTimeCallRet EarlyInit16
// Copyright (c) 2012-2018 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <rpc/server.h> #include <rpc/client.h> #include <core_io.h> #include <key_io.h> #include <netbase.h> #include <test/test_bitcoinrand.h> #include <boost/algorithm/string.hpp> #include <boost/test/unit_test.hpp> #include <univalue.h> #include <rpc/blockchain.h> UniValue CallRPC(std::string args) { std::vector<std::string> vArgs; boost::split(vArgs, args, boost::is_any_of(" \t")); std::string strMethod = vArgs[0]; vArgs.erase(vArgs.begin()); JSONRPCRequest request; request.strMethod = strMethod; request.params = RPCConvertValues(strMethod, vArgs); request.fHelp = false; BOOST_CHECK(tableRPC[strMethod]); rpcfn_type method = tableRPC[strMethod]->actor; try { UniValue result = (*method)(request); return result; } catch (const UniValue& objError) { throw std::runtime_error(find_value(objError, "message").get_str()); } } BOOST_FIXTURE_TEST_SUITE(rpc_tests, TestingSetup) BOOST_AUTO_TEST_CASE(rpc_rawparams) { // Test raw transaction API argument handling UniValue r; BOOST_CHECK_THROW(CallRPC("getrawtransaction"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("getrawtransaction not_hex"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("getrawtransaction a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed not_int"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction null null"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction not_array"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction {} {}"), std::runtime_error); BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [] {}")); BOOST_CHECK_THROW(CallRPC("createrawtransaction [] {} extra"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("decoderawtransaction"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("decoderawtransaction null"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("decoderawtransaction DEADBEEF"), std::runtime_error); std::string rawtx = "0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000"; BOOST_CHECK_NO_THROW(r = CallRPC(std::string("decoderawtransaction ")+rawtx)); BOOST_CHECK_EQUAL(find_value(r.get_obj(), "size").get_int(), 193); BOOST_CHECK_EQUAL(find_value(r.get_obj(), "version").get_int(), 1); BOOST_CHECK_EQUAL(find_value(r.get_obj(), "locktime").get_int(), 0); BOOST_CHECK_THROW(CallRPC(std::string("decoderawtransaction ")+rawtx+" extra"), std::runtime_error); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("decoderawtransaction ")+rawtx+" false")); BOOST_CHECK_THROW(r = CallRPC(std::string("decoderawtransaction ")+rawtx+" false extra"), std::runtime_error); // Only check failure cases for sendrawtransaction, there's no network to send to... BOOST_CHECK_THROW(CallRPC("sendrawtransaction"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("sendrawtransaction null"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("sendrawtransaction DEADBEEF"), std::runtime_error); BOOST_CHECK_THROW(CallRPC(std::string("sendrawtransaction ")+rawtx+" extra"), std::runtime_error); } BOOST_AUTO_TEST_CASE(rpc_togglenetwork) { UniValue r; r = CallRPC("getnetworkinfo"); bool netState = find_value(r.get_obj(), "networkactive").get_bool(); BOOST_CHECK_EQUAL(netState, true); BOOST_CHECK_NO_THROW(CallRPC("setnetworkactive false")); r = CallRPC("getnetworkinfo"); int numConnection = find_value(r.get_obj(), "connections").get_int(); BOOST_CHECK_EQUAL(numConnection, 0); netState = find_value(r.get_obj(), "networkactive").get_bool(); BOOST_CHECK_EQUAL(netState, false); BOOST_CHECK_NO_THROW(CallRPC("setnetworkactive true")); r = CallRPC("getnetworkinfo"); netState = find_value(r.get_obj(), "networkactive").get_bool(); BOOST_CHECK_EQUAL(netState, true); } BOOST_AUTO_TEST_CASE(rpc_rawsign) { UniValue r; // input is a 1-of-2 multisig (so is output): std::string prevout = "[{\"txid\":\"b4cc287e58f87cdae59417329f710f3ecd75a4ee1d2872b7248f50977c8493f3\"," "\"vout\":1,\"scriptPubKey\":\"a914b10c9df5f7edf436c697f02f1efdba4cf399615187\"," "\"redeemScript\":\"512103debedc17b3df2badbcdd86d5feb4562b86fe182e5998abd8bcd4f122c6155b1b21027e940bb73ab8732bfdf7f9216ecefca5b94d6df834e77e108f68e66f126044c052ae\"}]"; r = CallRPC(std::string("createrawtransaction ")+prevout+" "+ "{\"3HqAe9LtNBjnsfM4CyYaWTnvCaUYT7v4oZ\":11}"); std::string notsigned = r.get_str(); std::string privkey1 = "\"KzsXybp9jX64P5ekX1KUxRQ79Jht9uzW7LorgwE65i5rWACL6LQe\""; std::string privkey2 = "\"Kyhdf5LuKTRx4ge69ybABsiUAWjVRK4XGxAKk2FQLp2HjGMy87Z4\""; r = CallRPC(std::string("signrawtransactionwithkey ")+notsigned+" [] "+prevout); BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == false); r = CallRPC(std::string("signrawtransactionwithkey ")+notsigned+" ["+privkey1+","+privkey2+"] "+prevout); BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == true); } BOOST_AUTO_TEST_CASE(rpc_createraw_op_return) { BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"data\":\"68656c6c6f776f726c64\"}")); // Allow more than one data transaction output BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"data\":\"68656c6c6f776f726c64\",\"data\":\"68656c6c6f776f726c64\"}")); // Key not "data" (bad address) BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"somedata\":\"68656c6c6f776f726c64\"}"), std::runtime_error); // Bad hex encoding of data output BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"data\":\"12345\"}"), std::runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"data\":\"12345g\"}"), std::runtime_error); // Data 81 bytes long BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"data\":\"010203040506070809101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081\"}")); } BOOST_AUTO_TEST_CASE(rpc_format_monetary_values) { BOOST_CHECK(ValueFromAmount(0LL).write() == "0.00000000"); BOOST_CHECK(ValueFromAmount(1LL).write() == "0.00000001"); BOOST_CHECK(ValueFromAmount(17622195LL).write() == "0.17622195"); BOOST_CHECK(ValueFromAmount(50000000LL).write() == "0.50000000"); BOOST_CHECK(ValueFromAmount(89898989LL).write() == "0.89898989"); BOOST_CHECK(ValueFromAmount(100000000LL).write() == "1.00000000"); BOOST_CHECK(ValueFromAmount(2099999999999990LL).write() == "20999999.99999990"); BOOST_CHECK(ValueFromAmount(2099999999999999LL).write() == "20999999.99999999"); BOOST_CHECK_EQUAL(ValueFromAmount(0).write(), "0.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount((COIN/10000)*123456789).write(), "12345.67890000"); BOOST_CHECK_EQUAL(ValueFromAmount(-COIN).write(), "-1.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(-COIN/10).write(), "-0.10000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*100000000).write(), "100000000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*10000000).write(), "10000000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*1000000).write(), "1000000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*100000).write(), "100000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*10000).write(), "10000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*1000).write(), "1000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*100).write(), "100.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*10).write(), "10.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN).write(), "1.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/10).write(), "0.10000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/100).write(), "0.01000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/1000).write(), "0.00100000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/10000).write(), "0.00010000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/100000).write(), "0.00001000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/1000000).write(), "0.00000100"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/10000000).write(), "0.00000010"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/100000000).write(), "0.00000001"); } static UniValue ValueFromString(const std::string &str) { UniValue value; BOOST_CHECK(value.setNumStr(str)); return value; } BOOST_AUTO_TEST_CASE(rpc_parse_monetary_values) { BOOST_CHECK_THROW(AmountFromValue(ValueFromString("-0.00000001")), UniValue); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0")), 0LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000000")), 0LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000001")), 1LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.17622195")), 17622195LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.5")), 50000000LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.50000000")), 50000000LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.89898989")), 89898989LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1.00000000")), 100000000LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.9999999")), 2099999999999990LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.99999999")), 2099999999999999LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1e-8")), COIN/100000000); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.1e-7")), COIN/100000000); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.01e-6")), COIN/100000000); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.0000000000000000000000000000000000000000000000000000000000000000000000000001e+68")), COIN/100000000); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("10000000000000000000000000000000000000000000000000000000000000000e-64")), COIN); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000e64")), COIN); BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e-9")), UniValue); //should fail BOOST_CHECK_THROW(AmountFromValue(ValueFromString("0.000000019")), UniValue); //should fail BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000001000000")), 1LL); //should pass, cut trailing 0 BOOST_CHECK_THROW(AmountFromValue(ValueFromString("19e-9")), UniValue); //should fail BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.19e-6")), 19); //should pass, leading 0 is present BOOST_CHECK_THROW(AmountFromValue(ValueFromString("92233720368.54775808")), UniValue); //overflow error BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e+11")), UniValue); //overflow error BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e11")), UniValue); //overflow error signless BOOST_CHECK_THROW(AmountFromValue(ValueFromString("93e+9")), UniValue); //overflow error } BOOST_AUTO_TEST_CASE(json_parse_errors) { // Valid BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("1.0").get_real(), 1.0); // Valid, with leading or trailing whitespace BOOST_CHECK_EQUAL(ParseNonRFCJSONValue(" 1.0").get_real(), 1.0); BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("1.0 ").get_real(), 1.0); BOOST_CHECK_THROW(AmountFromValue(ParseNonRFCJSONValue(".19e-6")), std::runtime_error); //should fail, missing leading 0, therefore invalid JSON BOOST_CHECK_EQUAL(AmountFromValue(ParseNonRFCJSONValue("0.00000000000000000000000000000000000001e+30 ")), 1); // Invalid, initial garbage BOOST_CHECK_THROW(ParseNonRFCJSONValue("[1.0"), std::runtime_error); BOOST_CHECK_THROW(ParseNonRFCJSONValue("a1.0"), std::runtime_error); // Invalid, trailing garbage BOOST_CHECK_THROW(ParseNonRFCJSONValue("1.0sds"), std::runtime_error); BOOST_CHECK_THROW(ParseNonRFCJSONValue("1.0]"), std::runtime_error); // BZAR addresses should fail parsing BOOST_CHECK_THROW(ParseNonRFCJSONValue("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"), std::runtime_error); BOOST_CHECK_THROW(ParseNonRFCJSONValue("3J98t1WpEZ73CNmQviecrnyiWrnqRhWNL"), std::runtime_error); } BOOST_AUTO_TEST_CASE(rpc_ban) { BOOST_CHECK_NO_THROW(CallRPC(std::string("clearbanned"))); UniValue r; BOOST_CHECK_NO_THROW(r = CallRPC(std::string("setban 127.0.0.0 add"))); BOOST_CHECK_THROW(r = CallRPC(std::string("setban 127.0.0.0:8334")), std::runtime_error); //portnumber for setban not allowed BOOST_CHECK_NO_THROW(r = CallRPC(std::string("listbanned"))); UniValue ar = r.get_array(); UniValue o1 = ar[0].get_obj(); UniValue adr = find_value(o1, "address"); BOOST_CHECK_EQUAL(adr.get_str(), "127.0.0.0/32"); BOOST_CHECK_NO_THROW(CallRPC(std::string("setban 127.0.0.0 remove"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("listbanned"))); ar = r.get_array(); BOOST_CHECK_EQUAL(ar.size(), 0U); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("setban 127.0.0.0/24 add 9907731200 true"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); adr = find_value(o1, "address"); UniValue banned_until = find_value(o1, "banned_until"); BOOST_CHECK_EQUAL(adr.get_str(), "127.0.0.0/24"); BOOST_CHECK_EQUAL(banned_until.get_int64(), 9907731200); // absolute time check BOOST_CHECK_NO_THROW(CallRPC(std::string("clearbanned"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("setban 127.0.0.0/24 add 200"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); adr = find_value(o1, "address"); banned_until = find_value(o1, "banned_until"); BOOST_CHECK_EQUAL(adr.get_str(), "127.0.0.0/24"); int64_t now = GetTime(); BOOST_CHECK(banned_until.get_int64() > now); BOOST_CHECK(banned_until.get_int64()-now <= 200); // must throw an exception because 127.0.0.1 is in already banned subnet range BOOST_CHECK_THROW(r = CallRPC(std::string("setban 127.0.0.1 add")), std::runtime_error); BOOST_CHECK_NO_THROW(CallRPC(std::string("setban 127.0.0.0/24 remove"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("listbanned"))); ar = r.get_array(); BOOST_CHECK_EQUAL(ar.size(), 0U); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("setban 127.0.0.0/255.255.0.0 add"))); BOOST_CHECK_THROW(r = CallRPC(std::string("setban 127.0.1.1 add")), std::runtime_error); BOOST_CHECK_NO_THROW(CallRPC(std::string("clearbanned"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("listbanned"))); ar = r.get_array(); BOOST_CHECK_EQUAL(ar.size(), 0U); BOOST_CHECK_THROW(r = CallRPC(std::string("setban test add")), std::runtime_error); //invalid IP //IPv6 tests BOOST_CHECK_NO_THROW(r = CallRPC(std::string("setban FE80:0000:0000:0000:0202:B3FF:FE1E:8329 add"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); adr = find_value(o1, "address"); BOOST_CHECK_EQUAL(adr.get_str(), "fe80::202:b3ff:fe1e:8329/128"); BOOST_CHECK_NO_THROW(CallRPC(std::string("clearbanned"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("setban 2001:db8::/ffff:fffc:0:0:0:0:0:0 add"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); adr = find_value(o1, "address"); BOOST_CHECK_EQUAL(adr.get_str(), "2001:db8::/30"); BOOST_CHECK_NO_THROW(CallRPC(std::string("clearbanned"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("setban 2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/128 add"))); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); adr = find_value(o1, "address"); BOOST_CHECK_EQUAL(adr.get_str(), "2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/128"); } BOOST_AUTO_TEST_CASE(rpc_convert_values_generatetoaddress) { UniValue result; BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", {"101", "mkESjLZW66TmHhiFX8MCaBjrhZ543PPh9a"})); BOOST_CHECK_EQUAL(result[0].get_int(), 101); BOOST_CHECK_EQUAL(result[1].get_str(), "mkESjLZW66TmHhiFX8MCaBjrhZ543PPh9a"); BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", {"101", "mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU"})); BOOST_CHECK_EQUAL(result[0].get_int(), 101); BOOST_CHECK_EQUAL(result[1].get_str(), "mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU"); BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", {"1", "mkESjLZW66TmHhiFX8MCaBjrhZ543PPh9a", "9"})); BOOST_CHECK_EQUAL(result[0].get_int(), 1); BOOST_CHECK_EQUAL(result[1].get_str(), "mkESjLZW66TmHhiFX8MCaBjrhZ543PPh9a"); BOOST_CHECK_EQUAL(result[2].get_int(), 9); BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", {"1", "mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU", "9"})); BOOST_CHECK_EQUAL(result[0].get_int(), 1); BOOST_CHECK_EQUAL(result[1].get_str(), "mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU"); BOOST_CHECK_EQUAL(result[2].get_int(), 9); } BOOST_AUTO_TEST_CASE(rpc_getblockstats_calculate_percentiles_by_weight) { int64_t total_weight = 200; std::vector<std::pair<CAmount, int64_t>> feerates; CAmount result[NUM_GETBLOCKSTATS_PERCENTILES] = { 0 }; for (int64_t i = 0; i < 100; i++) { feerates.emplace_back(std::make_pair(1 ,1)); } for (int64_t i = 0; i < 100; i++) { feerates.emplace_back(std::make_pair(2 ,1)); } CalculatePercentilesByWeight(result, feerates, total_weight); BOOST_CHECK_EQUAL(result[0], 1); BOOST_CHECK_EQUAL(result[1], 1); BOOST_CHECK_EQUAL(result[2], 1); BOOST_CHECK_EQUAL(result[3], 2); BOOST_CHECK_EQUAL(result[4], 2); // Test with more pairs, and two pairs overlapping 2 percentiles. total_weight = 100; CAmount result2[NUM_GETBLOCKSTATS_PERCENTILES] = { 0 }; feerates.clear(); feerates.emplace_back(std::make_pair(1, 9)); feerates.emplace_back(std::make_pair(2 , 16)); //10th + 25th percentile feerates.emplace_back(std::make_pair(4 ,50)); //50th + 75th percentile feerates.emplace_back(std::make_pair(5 ,10)); feerates.emplace_back(std::make_pair(9 ,15)); // 90th percentile CalculatePercentilesByWeight(result2, feerates, total_weight); BOOST_CHECK_EQUAL(result2[0], 2); BOOST_CHECK_EQUAL(result2[1], 2); BOOST_CHECK_EQUAL(result2[2], 4); BOOST_CHECK_EQUAL(result2[3], 4); BOOST_CHECK_EQUAL(result2[4], 9); // Same test as above, but one of the percentile-overlapping pairs is split in 2. total_weight = 100; CAmount result3[NUM_GETBLOCKSTATS_PERCENTILES] = { 0 }; feerates.clear(); feerates.emplace_back(std::make_pair(1, 9)); feerates.emplace_back(std::make_pair(2 , 11)); // 10th percentile feerates.emplace_back(std::make_pair(2 , 5)); // 25th percentile feerates.emplace_back(std::make_pair(4 ,50)); //50th + 75th percentile feerates.emplace_back(std::make_pair(5 ,10)); feerates.emplace_back(std::make_pair(9 ,15)); // 90th percentile CalculatePercentilesByWeight(result3, feerates, total_weight); BOOST_CHECK_EQUAL(result3[0], 2); BOOST_CHECK_EQUAL(result3[1], 2); BOOST_CHECK_EQUAL(result3[2], 4); BOOST_CHECK_EQUAL(result3[3], 4); BOOST_CHECK_EQUAL(result3[4], 9); // Test with one transaction spanning all percentiles. total_weight = 104; CAmount result4[NUM_GETBLOCKSTATS_PERCENTILES] = { 0 }; feerates.clear(); feerates.emplace_back(std::make_pair(1, 100)); feerates.emplace_back(std::make_pair(2, 1)); feerates.emplace_back(std::make_pair(3, 1)); feerates.emplace_back(std::make_pair(3, 1)); feerates.emplace_back(std::make_pair(999999, 1)); CalculatePercentilesByWeight(result4, feerates, total_weight); for (int64_t i = 0; i < NUM_GETBLOCKSTATS_PERCENTILES; i++) { BOOST_CHECK_EQUAL(result4[i], 1); } } BOOST_AUTO_TEST_SUITE_END()
BITS 16 ORG 0x7C00 %define STAGE2_LOCATION 0x60000 %define DECOMPRESSOR_LOCATION 0x70000 %define BOOT_FROM_CD 2 jmp skip_bpb nop ; El Torito Boot Information Table ; ↓ Set by mkisofs times 8-($-$$) db 0 boot_info: bi_PVD dd 0 bi_boot_LBA dd 0 bi_boot_len dd 0 bi_checksum dd 0 bi_reserved times 40 db 0 times 90-($-$$) db 0 skip_bpb: cli cld jmp 0x0000:.initialise_cs .initialise_cs: xor ax, ax mov ds, ax mov es, ax mov ss, ax mov sp, 0x7C00 sti ; int 13h? mov ah, 0x41 mov bx, 0x55AA int 0x13 jc err cmp bx, 0xAA55 jne err mov esp, 0x7C00 ; --- Load the decompressor --- mov eax, dword [bi_boot_LBA] add eax, DEC_LBA_OFFSET mov ecx, DEC_LBA_COUNT ; DECOMPRESSOR_LOCATION = 0x70000 = 0x7000:0x0000 mov si, 0x7000 xor di, di call read_2k_sectors jc err ; --- Load the stage2.bin.gz --- mov eax, dword [bi_boot_LBA] add eax, STAGE2_LBA_OFFSET mov ecx, STAGE2_LBA_COUNT ; STAGE2_LOCATION = 0x60000 = 0x6000:0x0000 mov si, 0x6000 xor di, di call read_2k_sectors jc err ; Enable GDT lgdt [gdt] cli mov eax, cr0 or al, 1 mov cr0, eax jmp 0x08:pmode err: hlt jmp err %include 'read_2k_sectors.asm' %include '../gdt.asm' BITS 32 pmode: mov eax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax ; Time to handle control over to the decompressor push BOOT_FROM_CD and edx, 0xFF push edx ; Boot drive push STAGE2_SIZE push STAGE2_LOCATION call DECOMPRESSOR_LOCATION hlt %define FILEPOS ($-$$) %define UPPER2K ((FILEPOS+2047) & ~2047) %define ALIGN2K times UPPER2K - FILEPOS db 0 ; Align stage2 to 2K ON DISK ALIGN2K DEC_LBA_OFFSET equ ($-$$)/2048 incbin '../../build/decompressor/decompressor.bin' ALIGN2K STAGE2_START equ $-$$ STAGE2_LBA_OFFSET equ STAGE2_START/2048 DEC_LBA_COUNT equ STAGE2_LBA_OFFSET - DEC_LBA_OFFSET incbin '../../build/stage23-bios/stage2.bin.gz' STAGE2_SIZE equ ($-$$) - STAGE2_START STAGE2_LBA_COUNT equ (2047 + $-$$)/2048
global long_mode_start extern kernel_main section .text bits 64 long_mode_start: mov ax, 0 mov ss, ax mov ds, ax mov es, ax mov fs, ax mov gs, ax ; print call kernel_main hlt
; A081106: 6th binomial transform of (1,1,0,0,0,0,...). ; 1,7,48,324,2160,14256,93312,606528,3919104,25194240,161243136,1027924992,6530347008,41358864384,261213880320,1645647446016,10344069660672,64885527871488,406239826673664,2538998916710400 mov $1,$0 lpb $0,1 sub $0,1 add $1,5 mul $1,6 lpe div $1,6 add $1,1
; ; USRROM TEMPLATE FOR A CUSTOM USER ROM ; #INCLUDE "std.asm" ; CR .EQU 0DH LF .EQU 0AH ; .ORG USR_LOC ; LD SP,USR_END ; LD HL,BOOTMSG ; INTRODUCTION CALL PRTSTR ; CALL CIN ; DO STUFF ; LD B,BF_SYSRESET ; SYSTEM RESTART LD C,BF_SYSRES_WARM ; WARM START CALL $FFF0 ; CALL HBIOS ; RET ; ; ; ; PRINT A STRING AT ADDRESS SPECIFIED IN HL ; STRING MUST BE TERMINATED BY '$' ; USAGE: ; LD HL,MYSTR ; CALL PRTSTR ; ... ; MYSTR: .DB "HELLO$" ; PRTSTR: LD A,(HL) INC HL CP '$' RET Z CALL COUT JR PRTSTR ; ; OUTPUT CHARACTER IN A TO CONSOLE DEVICE ; COUT: PUSH AF PUSH BC PUSH DE PUSH HL LD B,01H LD C,0 LD E,A RST 08 POP HL POP DE POP BC POP AF RET ; ; WAIT FOR A CHARACTER FROM THE CONSOLE DEVICE AND RETURN IT IN A ; CIN: PUSH BC PUSH DE PUSH HL LD B,00H LD C,00H RST 08 LD A,E POP HL POP DE POP BC RET ; BOOTMSG:.DB CR,LF,CR,LF .DB "No User ROM Installed." .DB CR,LF,CR,LF .DB "Press a key to return to Boot Loader.$" ; ; IT IS CRITICAL THAT THE FINAL BINARY BE EXACTLY USR_SIZ BYTES. ; THIS GENERATES FILLER AS NEEDED. ; SLACK .EQU (USR_END - $) .FILL SLACK,00 .ECHO "User ROM space remaining: " .ECHO SLACK .ECHO " bytes.\n" .END
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r15 push %r9 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_A_ht+0xc0f9, %r9 nop xor %r15, %r15 movb (%r9), %bl nop nop xor $44203, %rbp lea addresses_WT_ht+0x14ef9, %rcx nop nop add $51555, %r13 mov $0x6162636465666768, %r11 movq %r11, %xmm5 movups %xmm5, (%rcx) nop nop nop nop nop cmp %r11, %r11 lea addresses_WT_ht+0x8c73, %r15 nop nop nop nop nop and $20385, %rbx mov $0x6162636465666768, %r9 movq %r9, %xmm0 and $0xffffffffffffffc0, %r15 movntdq %xmm0, (%r15) nop nop nop nop nop add %r11, %r11 lea addresses_D_ht+0x1481d, %r15 xor $44693, %rcx movups (%r15), %xmm5 vpextrq $0, %xmm5, %rbx nop sub $10659, %rbp lea addresses_UC_ht+0x2909, %r11 nop nop sub %r13, %r13 mov $0x6162636465666768, %r9 movq %r9, %xmm4 vmovups %ymm4, (%r11) nop nop nop nop and $54594, %rcx lea addresses_A_ht+0x14c79, %rbp dec %r11 vmovups (%rbp), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %r13 nop nop nop nop cmp %rbx, %rbx lea addresses_D_ht+0x18d79, %rbp clflush (%rbp) nop nop nop xor %r13, %r13 vmovups (%rbp), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $1, %xmm0, %r9 nop and %r9, %r9 lea addresses_A_ht+0x1cf9, %r9 clflush (%r9) nop nop nop nop nop inc %rcx movups (%r9), %xmm5 vpextrq $0, %xmm5, %rbp nop inc %r13 lea addresses_WC_ht+0x1c179, %rsi lea addresses_WC_ht+0x11019, %rdi clflush (%rsi) and %rbp, %rbp mov $29, %rcx rep movsb nop nop nop nop sub %rdi, %rdi lea addresses_D_ht+0x1a4f9, %rsi lea addresses_normal_ht+0x177f9, %rdi clflush (%rdi) nop nop xor %r11, %r11 mov $19, %rcx rep movsq nop nop nop nop nop xor $5785, %rbp lea addresses_A_ht+0x12639, %rsi add $50675, %rbx mov (%rsi), %ebp nop nop nop nop nop add $24878, %rbx lea addresses_A_ht+0x3261, %rsi and $22642, %rdi movl $0x61626364, (%rsi) nop nop nop nop nop xor %r9, %r9 lea addresses_D_ht+0x8f9, %rsi lea addresses_normal_ht+0x19af9, %rdi nop nop nop nop dec %r11 mov $101, %rcx rep movsb sub %rbx, %rbx lea addresses_normal_ht+0x101b1, %rsi lea addresses_D_ht+0x1e6f9, %rdi nop nop sub $5122, %rbp mov $60, %rcx rep movsw nop nop nop add $8202, %r9 pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r15 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r15 push %r8 push %r9 push %rcx push %rdi push %rdx // Store lea addresses_D+0x32b5, %rcx nop nop nop nop cmp %r15, %r15 mov $0x5152535455565758, %r12 movq %r12, (%rcx) nop cmp %r12, %r12 // Load lea addresses_PSE+0xe739, %r8 nop nop nop nop add $42952, %r12 mov (%r8), %r15d nop nop nop cmp $25031, %r15 // Store mov $0xc91, %rdx nop inc %rdi mov $0x5152535455565758, %r8 movq %r8, %xmm4 movups %xmm4, (%rdx) nop nop nop dec %rdx // Store lea addresses_WT+0x127f9, %r9 nop sub %r15, %r15 movb $0x51, (%r9) nop nop xor %r15, %r15 // Store lea addresses_normal+0x124f9, %rcx nop nop nop nop nop xor $15115, %r15 mov $0x5152535455565758, %r8 movq %r8, %xmm7 vmovups %ymm7, (%rcx) nop nop nop nop nop add $6447, %rcx // Store lea addresses_A+0x1cb7d, %r8 nop nop nop nop nop and $7983, %r12 mov $0x5152535455565758, %rcx movq %rcx, %xmm2 movups %xmm2, (%r8) nop inc %r8 // Store lea addresses_US+0xf56f, %rdi nop nop nop nop nop cmp %r9, %r9 movb $0x51, (%rdi) nop nop xor %r15, %r15 // Store lea addresses_UC+0x1a199, %rdi nop add $60543, %rcx mov $0x5152535455565758, %rdx movq %rdx, %xmm7 movups %xmm7, (%rdi) nop nop nop nop inc %rdi // Store lea addresses_normal+0x124f9, %rdi nop nop nop nop nop xor $42281, %rdx mov $0x5152535455565758, %r15 movq %r15, (%rdi) and $18753, %rdx // Store lea addresses_normal+0x124f9, %r8 nop nop nop nop nop and $65071, %rdi movw $0x5152, (%r8) nop nop nop nop sub %r8, %r8 // Faulty Load lea addresses_normal+0x124f9, %rdx nop nop nop nop sub $28680, %rdi movb (%rdx), %r12b lea oracles, %r8 and $0xff, %r12 shlq $12, %r12 mov (%r8,%r12,1), %r12 pop %rdx pop %rdi pop %rcx pop %r9 pop %r8 pop %r15 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_D', 'size': 8, 'AVXalign': False}} {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_PSE', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_P', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_WT', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 32, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_A', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_US', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_UC', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 8, 'AVXalign': True}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 2, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': True, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False}} {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': True, 'congruent': 11, 'NT': False, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}} {'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': True, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}} {'52': 21829} 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 */
; *************************************************************************************** ; *************************************************************************************** ; ; Name : kernel.asm ; Author : Paul Robson (paul@robsons.org.uk) ; Date : 13th January 2019 ; Purpose : Machine Forth Kernel ; ; *************************************************************************************** ; *************************************************************************************** DictionaryPage = $20 ; dictionary page FirstCodePage = $22 ; first code page. ; ; Memory allocated from the Unused space in $4000-$7FFF ; StackTop = $7EFC ; -$7EFC Top of stack org $8000 ; $8000 boot. jr Boot org $8004 ; $8004 address of sysinfo dw SystemInformation Boot: ld sp,(StackDefault) ; reset Z80 Stack db $DD,$01 di ; disable interrupts db $ED,$91,7,2 ; set turbo port (7) to 2 (14Mhz speed) ld a,1 ; blue border out ($FE),a ld a,FirstCodePage ; get the page to start call PAGEInitialise ld a,(BootPage) ; switch to boot page. call PAGEInitialise ld hl,(BootAddress) ; start address jp (hl) StopDefault: jp StopDefault
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r15 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_WC_ht+0x1d702, %rsi lea addresses_WT_ht+0x858a, %rdi nop nop nop sub $8702, %r10 mov $84, %rcx rep movsb nop nop nop nop nop add %r15, %r15 lea addresses_UC_ht+0x1d262, %rsi lea addresses_WT_ht+0xba62, %rdi sub $53133, %r15 mov $77, %rcx rep movsb nop nop dec %rsi lea addresses_WC_ht+0x145e2, %rsi lea addresses_WC_ht+0x982, %rdi nop and $4417, %r10 mov $57, %rcx rep movsl and $50997, %rsi lea addresses_normal_ht+0x17e62, %rsi lea addresses_UC_ht+0x12952, %rdi nop nop nop nop and $18915, %r14 mov $26, %rcx rep movsl nop and %rcx, %rcx lea addresses_D_ht+0xfea2, %rsi nop nop nop nop nop xor %r9, %r9 mov $0x6162636465666768, %r15 movq %r15, %xmm5 vmovups %ymm5, (%rsi) nop nop nop nop nop inc %r14 lea addresses_D_ht+0xcc16, %rdi nop nop dec %r15 mov $0x6162636465666768, %r9 movq %r9, %xmm5 and $0xffffffffffffffc0, %rdi movntdq %xmm5, (%rdi) nop nop nop nop nop add $12657, %rdi lea addresses_D_ht+0x7662, %r10 nop nop nop and %r9, %r9 mov $0x6162636465666768, %rdi movq %rdi, %xmm1 movups %xmm1, (%r10) nop nop nop nop nop sub %r10, %r10 lea addresses_UC_ht+0xc2f6, %rsi nop nop cmp %rdi, %rdi movb $0x61, (%rsi) nop nop nop dec %r10 lea addresses_A_ht+0x12832, %r10 nop nop nop nop sub %rsi, %rsi movb $0x61, (%r10) nop nop nop nop nop cmp $55399, %r9 lea addresses_A_ht+0xd1fa, %r15 nop nop nop nop inc %r9 movups (%r15), %xmm2 vpextrq $1, %xmm2, %r10 nop nop nop and $2927, %rdi lea addresses_D_ht+0x11de2, %rsi lea addresses_normal_ht+0x10462, %rdi clflush (%rsi) nop nop nop nop nop sub %rax, %rax mov $69, %rcx rep movsb nop nop nop and $45616, %rsi lea addresses_normal_ht+0x19b0a, %rcx xor $8486, %rsi movb (%rcx), %r10b nop nop add $5659, %rsi lea addresses_UC_ht+0x15682, %rcx nop nop nop nop nop add $26706, %r10 movups (%rcx), %xmm7 vpextrq $0, %xmm7, %r9 nop nop nop cmp $16034, %rcx pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r15 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r8 push %rax push %rbx push %rcx push %rdi // Store mov $0xb6a, %r12 clflush (%r12) nop nop add %rbx, %rbx movw $0x5152, (%r12) nop nop dec %r12 // Store lea addresses_WC+0x1462, %rdi xor %rcx, %rcx mov $0x5152535455565758, %r12 movq %r12, %xmm2 vmovups %ymm2, (%rdi) nop nop and $9329, %rbx // Faulty Load lea addresses_D+0x17662, %rbx nop nop nop add $48673, %rax vmovups (%rbx), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %rcx lea oracles, %rdi and $0xff, %rcx shlq $12, %rcx mov (%rdi,%rcx,1), %rcx pop %rdi pop %rcx pop %rbx pop %rax pop %r8 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_P', 'size': 2, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_WC', 'size': 32, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}} {'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}} {'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': True, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': True}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False}} {'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}} {'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'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 */
dnl mpn_lshift dnl Copyright 2009 Jason Moxham dnl This file is part of the MPIR Library. dnl The MPIR Library is free software; you can redistribute it and/or modify dnl it under the terms of the GNU Lesser General Public License as published dnl by the Free Software Foundation; either version 2.1 of the License, or (at dnl your option) any later version. dnl The MPIR Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public dnl License for more details. dnl You should have received a copy of the GNU Lesser General Public License dnl along with the MPIR Library; see the file COPYING.LIB. If not, write dnl to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, dnl Boston, MA 02110-1301, USA. include(`../config.m4') C mpn_lshift(mp_ptr rdi,mp_ptr rsi,mp_size_t rdx,mp_limb_t rcx) C rax=carry ASM_START() PROLOGUE(mpn_lshift) C // odd and even n seem to have different runtimes push %rbx mov %rdx,%rbx lea 24(%rsi),%rsi lea 24(%rdi),%rdi mov -32(%rsi,%rbx,8),%rdx xor %rax,%rax shld %cl,%rdx,%rax sub $5,%rbx js skiplp ALIGN(16) lp: mov (%rsi,%rbx,8),%r8 mov -24(%rsi,%rbx,8),%r11 mov -8(%rsi,%rbx,8),%r9 shld %cl,%r8,%rdx mov %rdx,8(%rdi,%rbx,8) mov %r11,%rdx mov -16(%rsi,%rbx,8),%r10 shld %cl,%r9,%r8 shld %cl,%r10,%r9 mov %r8,(%rdi,%rbx,8) mov %r9,-8(%rdi,%rbx,8) shld %cl,%r11,%r10 sub $4,%rbx mov %r10,16(%rdi,%rbx,8) jns lp skiplp: cmp $-2,%rbx ja case3 je case2 jp case1 case0: shl %cl,%rdx mov %rdx,8(%rdi,%rbx,8) pop %rbx ret ALIGN(16) case3: mov (%rsi,%rbx,8),%r8 mov -8(%rsi,%rbx,8),%r9 shld %cl,%r8,%rdx mov %rdx,8(%rdi,%rbx,8) mov -16(%rsi,%rbx,8),%r10 shld %cl,%r9,%r8 shld %cl,%r10,%r9 mov %r8,(%rdi,%rbx,8) mov %r9,-8(%rdi,%rbx,8) shl %cl,%r10 mov %r10,16-32(%rdi,%rbx,8) pop %rbx ret ALIGN(16) case2: mov (%rsi,%rbx,8),%r8 mov -8(%rsi,%rbx,8),%r9 shld %cl,%r8,%rdx mov %rdx,8(%rdi,%rbx,8) shld %cl,%r9,%r8 shl %cl,%r9 mov %r8,(%rdi,%rbx,8) mov %r9,-8(%rdi,%rbx,8) pop %rbx ret ALIGN(16) case1: mov (%rsi,%rbx,8),%r8 shld %cl,%r8,%rdx mov %rdx,8(%rdi,%rbx,8) shl %cl,%r8 mov %r8,(%rdi,%rbx,8) pop %rbx ret EPILOGUE()
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: Video Drivers FILE: vga8Pointer.asm AUTHOR: Jim DeFrisco, Oct 8, 1992 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 10/ 8/92 Initial revision DESCRIPTION: These are a set of routines to support the use of a cursor for the pointing device. The cursor is limited to a 16x16 pixel bitmap (by the sizing of the holding buffers). The definition of a pointer allows for the specification of a "hot spot". This indicates where on the cursor shape the "current position" should be reported as. The way the mask and image are combined with the background are as follows: mask image -> screen pixel pixel pixel ----- ----- ------ 0 0 unchanged 0 1 xor 1 0 black 1 1 white For the 8-bit video drivers, we need to store the image in a buffer local to the video driver. Since there is no shifting required, we only need to establish the size of the transfer and the starting positions. (screen AND (not MASK)) XOR IMAGE We'll also use a local buffer to store the image the cursor sits on top of. $Id: vga8Pointer.asm,v 1.1 97/04/18 11:42:04 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidHidePtr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Erase the graphics pointer CALLED BY: EXTERNAL PASS: nothing RETURN: nothing DESTROYED: if (EraseCursor called) ax,bx,cx,dx,si,di,bp,es are destroyed else nothing destroyed PSEUDO CODE/STRATEGY: increment the visible count If the visible count is 1 erase the cursor KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 10/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidHidePtr proc near inc cs:[cursorCount] ; increment the nesting count cmp cs:[cursorCount],1 ; if the cursor wasn't showing jnz VHP_done ; then all done push es push ds mov cx, cs mov ds, cx call EraseCursor ; else erase it pop ds pop es VHP_done: ret VidHidePtr endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidShowPtr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw the graphics pointer CALLED BY: EXTERNAL PASS: nothing RETURN: nothing DESTROYED: if pointer is redrawn ax,bx,cx,dx,si,di,bp else cx, di destroyed PSEUDO CODE/STRATEGY: If the visible count is 0 draw the cursor else just decrement the count KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 10/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidShowPtr proc near dec cs:[cursorCount] ; set new value for nest count EC < ERROR_S VIDEO_HIDE_CURSOR_COUNT_UNDERFLOW > jnz VShP_done push es push ds mov cx, cs mov ds, cx call DrawCursor ; yes, draw it pop ds pop es VShP_done: ret VidShowPtr endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidMovePtr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Update the position of the pointer CALLED BY: INTERNAL PASS: ax - new x position bx - new y position RETURN: al - mask of save-under areas that pointer hot-spot overlaps with DESTROYED: ah,bx,cx,dx,si,di,bp PSEUDO CODE/STRATEGY: if (cursor is showing) erase it; translate position to account for hot point; update the position variables; if (cursor was showing) draw it; test for save-under overlaps; KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 10/92... Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidMovePtr proc near mov cx,cs mov ds,cx ; erase cursor if visible cmp cs:[cursorCount],0 jnz AfterCursorRedrawn push ax push bx call EraseCursor ; if moving XOR region with pointer then do special stuff cmp cs:[xorFlags], 0 jz noXOR pop bx pop ax push ax push bx sub ax, cs:[cursorX] sub bx, cs:[cursorY] call UpdateXORForPtr noXOR: ; store new position pop ds:[cursorY] pop ds:[cursorX] call DrawCursor jmp common AfterCursorRedrawn: ; store new position mov ds:[cursorX],ax mov ds:[cursorY],bx common: ; cmp cs:[suCount], 0 ; any active save under areas? ; jne CheckSUAreas clr al ret if (0) CheckSUAreas: mov ax, ds:[cursorX] ; Fetch location to check at mov bx, ds:[cursorY] mov cx, ax ; Pass rectangle = point mov dx, bx GOTO VidCheckUnder endif VidMovePtr endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidSetPtr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the picture data for the pointer cursor CALLED BY: EXTERNAL PASS: ds:si contains a far pointer to the following structure: PointerDef defined in cursor.def if si == -1, then the default pointer shape is used RETURN: nothing DESTROYED: (if pointer erased and redrawn) ax,bx,cx,dx,si,di,bp,ds else ax,bx,cx,si,di,bp,ds PSEUDO CODE/STRATEGY: pre-shift and store the correct mask and image data into some extra screen memory KNOWN BUGS/SIDE EFFECTS/IDEAS: Currently cursor size is fixed at 16x16 pixels. The pointer definition structure contains width and height fields anyway. REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 10/92... Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidSetPtr proc near push es cmp cs:[cursorCount], 0 ; see if it's currently on-screen jnz VSPnoshow ; no, safe to proceed push ds ; save passed params push si segmov ds, cs ; erase cursor wants ds -> cs call EraseCursor ; yes, restore screen before changing pop si pop ds VSPnoshow: cmp si, -1 ;custom pointer ? jne VSP_custom segmov ds,cs mov si, offset pBasic VSP_custom: ; ds:si = structure ; translate old current position to new one, based on new hotpoint EC < mov bl, ds:[si].PD_width > EC < and bl, mask PDW_WIDTH ; Get width portion of byte > EC < cmp bl, 16 ; only support these for now > EC < ERROR_NE VIDEO_ONLY_SUPPORTS_16x16_CURSORS > mov bx, {word}ds:[si][PD_hotX] ;bl = hotX, bh = hotY if ALLOW_BIG_MOUSE_POINTER cmp cs:[cursorSize], CUR_SIZE ;adjust hotX, hotY if double je bp0 ; sized mouse pointer add bx, bx ;bl = hotX, bh = hotY bp0: endif ; ALLOW_BIG_MOUSE_POINTER mov cs:[cursorHotX], bl ; store new x hot point mov cs:[cursorHotY], bh ; store new y hot point ; get pointer to cursor data. We're going to copy the data to the area ; just past the bottom of the screen. First the mask, with 8 copies ; (each 3 bytes) each shifted one more pixel to the right. This is ; followed by the same treatment for the data. add si, size PointerDef ; ds:si -> mask data ; set the destination to be the buffer we have to store the mask segmov es, cs mov di, offset ptrMaskBuffer mov cx, size ptrMaskBuffer ; clearing mask and picture mov al, 0xff ; so do words instead of bytes rep stosb ; clear the buffer, but do something mov cx, size ptrMaskBuffer ; different for the picture (we xor mov al, 0x0f ; the picy rep stosb if ALLOW_BIG_MOUSE_POINTER cmp cs:[cursorSize], CUR_SIZE jne setBigPointer endif ; ALLOW_BIG_MOUSE_POINTER ; first do the mask. mov di, offset ptrMaskBuffer mov dx, CUR_SIZE ; 16 scan lines maskLoop: lodsw ; get next word (scan) of mask data xchg al,ah mov bx, ax clr al mov cx, CUR_SIZE ; 16 pixels/scan mPixLoop: shl bx, 1 ; top bit into carry jnc mSkipOne mov es:[di], al mSkipOne: inc di loop mPixLoop ; do entire scan line dec dx jnz maskLoop ; do all of mask ; now do the picture data. mov di, offset ptrMaskBuffer + size ptrMaskBuffer mov dx, CUR_SIZE ; 16 scan lines pictureLoop: lodsw ; get next word (scan) of picture data xchg al,ah mov bx, ax clr al mov cx, CUR_SIZE ; 16 pixels/scan pPixLoop: shl bx, 1 ; top bit into carry jc pSkipOne mov es:[di], al pSkipOne: inc di loop pPixLoop ; do entire scan line dec dx jnz pictureLoop ; do all of mask drawCursor:: ; draw new cursor cmp cs:[cursorCount],0 jnz VSP_done push ds segmov ds, cs ;EraseCursor wants ds == cs call DrawCursor pop ds VSP_done: pop es ret if ALLOW_BIG_MOUSE_POINTER setBigPointer: ;; set big mouse pointer mov di, offset ptrMaskBuffer mov dx, CUR_SIZE ; 16 scan lines bpMaskLoop: lodsw ; get next word (scan) of mask data xchg al, ah mov bx, ax clr al mov cx, CUR_SIZE ; 16 pixels/scan bpmPixLoop: shl bx, 1 ; top bit into carry jnc bpmSkipOne mov es:[di], al mov es:[di+1], al ; do 2 pixels mov es:[di+CUR_SIZE*2], al mov es:[di+CUR_SIZE*2+1],al ; do 2 pixels on next scanline bpmSkipOne: add di, 2 ; skip 2 pixels loop bpmPixLoop ; do entire scan line add di, CUR_SIZE*2 ; skip to next scanline dec dx jnz bpMaskLoop ; do all of mask ; now do the picture data. mov dx, CUR_SIZE ; 16 scan lines bpPictureLoop: lodsw ; get next word (scan) of picture data xchg al, ah mov bx, ax clr al mov cx, CUR_SIZE ; 16 pixels/scan bppPixLoop: shl bx, 1 ; top bit into carry jc bppSkipOne mov es:[di], al mov es:[di+1], al ; do 2 pixels mov es:[di+CUR_SIZE*2], al mov es:[di+CUR_SIZE*2+1],al ; do 2 pixels on next scanline bppSkipOne: add di, 2 ; skip 2 pixelsk loop bppPixLoop ; do entire scan line add di, CUR_SIZE*2 ; skip to next scanline dec dx jnz bpPictureLoop ; do all of mask jmp drawCursor endif ; ALLOW_BIG_MOUSE_POINTER VidSetPtr endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CondHidePtr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Temporarily hide the pointer while in a drawing operation CALLED BY: INTERNAL CommonRectHigh PASS: RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 9/28/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CondHidePtr proc near cmp cs:[cursorCount],0 ;test for hidden jnz THP_ret cmp cs:[hiddenFlag],0 jnz THP_ret push ax, bx, cx, dx, si, di, bp, ds, es segmov ds,cs ;point at variables mov ds:[hiddenFlag],1 ;set hidden call EraseCursor pop ax, bx, cx, dx, si, di, bp, ds, es THP_ret: ret CondHidePtr endp public CondHidePtr CondShowPtrFar proc far push bp call CondShowPtr pop bp ret CondShowPtrFar endp CondShowPtr proc near push ds, es segmov ds,cs ;point at variables mov ds:[hiddenFlag],0 call DrawCursor pop ds, es ret CondShowPtr endp public CondShowPtr COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawCursor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw the cursor when the optimization variables might be incorrect CALLED BY: INTERNAL VidSetPtr, VidMovePtr PASS: cursorX, cursorY - cursor position cursorHotX, cursorHotY - cursor hot spot RETURN: DESTROYED: ax, bx, cx, dx, si, di, bp, ds, es PSEUDO CODE/STRATEGY: We have pre-shifted versions of the cursor mask and image. So we want to figure out which one to use (low three bits) and do the right transfer (on byte boundaries), taking into account any clipping (transfer fewer bytes if clipped). To effect the transfer, we use the bitblt hardware on the casio device. The BIOS calls are: SET_DMA_TRANSFER_OFFSET(mask) DO_DMA_TRANSFER(OR mode) SET_DMA_TRANSFER_OFFSET(picture) DO_DMA_TRANSFER(XOR mode) KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 9/28/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DrawCursor proc near uses ax, bx, cx, dx, si, di, bp .enter mov ax, cs:[cursorX] ; calc position to draw mov bx, cs:[cursorY] sub al, cs:[cursorHotX] sbb ah, 0 sub bl, cs:[cursorHotY] sbb bh, 0 ; ax,bx = cursor position ; we'll need to calc the width and the height of the ; transfer, so start out by assuming the full cursor size ; cl = width, ch = height, dl = left offset, dh = scan offset clr dx mov cl, {byte}cs:[cursorSize] mov ch, cl ; do different stuff if off left of screen tst ax ; check for neg coord LONG js offLeft ; OK, it may be entirely inside the screen. Check the right. mov si, cs:[DriverTable].VDI_pageW ; get right side coord sub si, cs:[cursorSize] cmp ax, si ; check right side LONG ja offRight ; else clip right side ; If we are off the screen on top, then we need to adjust ; the Y offset, else we are starting from scan line 320. checkHeight: tst bx ; see if off the top LONG js offTop ; take less-traveled road mov si, cs:[DriverTable].VDI_pageH sub si, cs:[cursorSize] cmp bx, si ; check off the bottom too LONG ja offBottom ; all ready to set the offsets, go for it. ; cl = width, ch = height, dl = left offset, dh = scan offset ; usage:ds:si -> pointer data ; es:di -> frame buffer ; bx = offset into scan line ; dx = offset from one scan line to the next ; bp = bytes left in this window ; ah = height calcIndex: mov cs:[cursorRegLeft], ax mov cs:[cursorRegTop], bx add al, cl adc ah, 0 dec ax mov cs:[cursorRegRight], ax inc ax sub al, cl sbb ah, 0 add bl, ch adc bh, 0 dec bx mov cs:[cursorRegBottom], bx inc bx sub bl, ch sbb bh, 0 mov cs:[backX], ax mov cs:[backY], bx mov cs:[backWidth], cl mov cs:[backHeight], ch push ax mov al, dh mul {byte}cs:[cursorSize] ; *cursorSize for scan index clr dh add dx, ax ; dx = byte offset into picture pop ax mov si, offset ptrMaskBuffer ; figure source address add si, dx ; segmov ds, cs ; ds:si -> maskBuffer (source) mov di, bx mov bx, ax CalcScanLineBoth di, bx, es, ds ; ds,es:[di] -> destination mov bp, cs:[curWinEnd] ; calc #bytes left sub bp, di ; bp = #bytes left mov ax, cs:[modeInfo].VMI_scanSize ; get bytes per scan mul cs:[cursorSize] cmp ax, bp ; going to overflow window ? mov ah, ch ; ah = height mov bx, offset cs:backBuffer ja careScanLoop ; finally, draw the sucker ; ds:di -> frame buffer (read window) ; es:di -> frame buffer (write window) ; cl - width loop counters ; ah - height loop counter ; al - scratch register ; cs:si - offset into cursor definition buffer ; cs:bx - offset into background save buffer drawLoop: mov ch, cl ; reload width pixLoop: mov al, ds:[di] ; get screen data mov cs:[bx], al ; store background and al, cs:[si] ; or in the mask xor al, cs:[si+(size ptrMaskBuffer)] ; xor the picture data stosb inc si inc bx dec ch jnz pixLoop sub di, cx add si, cs:[cursorSize] sub si, cx add di, cs:[modeInfo].VMI_scanSize dec ah jnz drawLoop done: .leave ret ; off the left side of the screen. This gets a bit complex. offLeft: neg ax ; that many bits over mov dl, al ; start in from the left sub cl, al ; that means fewer scans clr ax jmp checkHeight ; off the right side of the screen. This just means we ; transfer fewer bytes in width. offRight: sub si, ax ; assume one less xchg si, ax add cl, al ; cl = #bytes wide xchg si, ax jmp checkHeight ; the cursor is off the top of the screen. Adjust accordingly offTop: neg bx ; bl = #scans off top mov dh, bl ; dh = scan index sub ch, bl ; do that many less clr bx jmp calcIndex ; this is simple. We just need to reduce the number of scan ; lines to copy. offBottom: sub si, bx ; bx = -(#lines to shorten) xchg si, bx add ch, bl ; make it shorter xchg si, bx jmp calcIndex ; section of code to deal with drawing the cursor when we ; are getting close to the end of the memory window. careScanLoop: mov ch, cl ; reload width carePixLoop: mov al, ds:[di] ; get screen data mov cs:[bx], al ; store to background buffer and al, cs:[si] ; or in the mask xor al, cs:[si+(size ptrMaskBuffer)] ; xor the picture data stosb inc bx ; next background byte inc si ; next cursor picture byte dec ch jnz carePixLoop sub di, cx add si, cs:[cursorSize] sub si, cx dec ah jz done NextScanBoth di jnc careScanLoop cmp cx, cs:[pixelsLeft] ; if big enuf, just do it jbe careScanLoop mov ch, cs:[pixelsLeft].low splitScanLoop: mov al, ds:[di] ; get screen data mov cs:[bx], al ; store to background buffer and al, cs:[si] ; or in the mask xor al, cs:[si+(size ptrMaskBuffer)] ; xor the picture data stosb inc bx ; next background byte inc si ; next cursor picture byte dec ch jnz splitScanLoop call MidScanNextWinSrc call MidScanNextWin mov ch, cl sub ch, cs:[pixelsLeft].low splitScanLoop2: mov al, ds:[di] ; get screen data mov cs:[bx], al ; store to background buffer and al, cs:[si] ; or in the mask xor al, cs:[si+(size ptrMaskBuffer)] ; xor the picture data stosb inc bx ; next background byte inc si ; next cursor picture byte dec ch jnz splitScanLoop2 dec ah LONG jz done FirstWinScan jmp careScanLoop DrawCursor endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EraseCursor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Erase the cursor CALLED BY: INTERNAL VidSetPtr, VidMovePtr PASS: cursorByteX - cursor byte x position cursorScreenAddr - screen address to start at cursorLines - number of lines to draw cursorBuffer - data to recover ds - cs RETURN: DESTROYED: ax, bx, cx, dx, si, di, bp PSEUDO CODE/STRATEGY: This is much easier than drawing the cursor -- we just have to copy the corresponding area from VRAM to DDRAM. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 9/28/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EraseCursor proc near uses ax, si, ds, di, es, bx, cx .enter mov ax, cs:[backX] mov bx, cs:[backY] mov cl, cs:[backWidth] mov ch, cs:[backHeight] ; get ds:si -> frame buffer mov di, bx CalcScanLine di, ax, es ; es:di -> frame buffer segmov ds, cs, si mov si, offset backBuffer ; ds:si -> save area mov ax, cs:[modeInfo].VMI_scanSize mov bx, ax ; save another copy mul cs:[cursorSize] add ax, di jc partialWindow cmp ax, cs:[curWinEnd] ; calc #bytes left ja partialWindow ; the area is entirely inside the current memory window, ; DO IT FAST ! mov ax, bx ; restore scan size mov bh, ch ; scan line counter mov bl, cl ; save copy of pixel counter clr ch sub ax, cx ; distance to next scan scanLoop: mov cl, bl ; set up width rep movsb add di, ax ; onto next scan line dec bh jnz scanLoop done: .leave ret ; part of cursor is in the next window partialWindow: mov ax, bx ; restore scan size mov bh, ch mov bl, cl clr ch partLoop: mov cl, bl rep movsb mov cl, bl sub di, cx doneScan:: dec bh jz done NextScan di, ax jnc partLoop mov cl, bl cmp cx, cs:[pixelsLeft] jbe partLoop mov cx, cs:[pixelsLeft] rep movsb call MidScanNextWin mov cl, bl sub cx, cs:[pixelsLeft] rep movsb dec bh jz done FirstWinScan jmp partLoop EraseCursor endp
; A291358: The arithmetic function u(n,2,4). ; 5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2,5,2,5,2,3,2 mod $0,6 mov $1,4 gcd $1,$0 add $1,1 mov $0,$1
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 5, 0x90 .globl _h9_EncryptCFB_RIJ128_AES_NI _h9_EncryptCFB_RIJ128_AES_NI: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(144), %esp movl (32)(%ebp), %eax movdqu (%eax), %xmm4 movdqu %xmm4, (%esp) .Lblks_loopgas_1: movl (8)(%ebp), %esi movl (28)(%ebp), %edx lea (,%edx,4), %ebx movl (24)(%ebp), %edx cmp %ebx, %edx cmovl %edx, %ebx xor %ecx, %ecx .L__0000gas_1: movb (%esi,%ecx), %dl movb %dl, (80)(%esp,%ecx) add $(1), %ecx cmp %ebx, %ecx jl .L__0000gas_1 movl (20)(%ebp), %ecx movl (16)(%ebp), %edx lea (,%edx,4), %eax lea (-144)(%ecx,%eax,4), %eax xor %esi, %esi mov %ebx, %edi .Lsingle_blkgas_1: movdqu (%esp,%esi), %xmm0 pxor (%ecx), %xmm0 cmp $(12), %edx jl .Lkey_128_sgas_1 jz .Lkey_192_sgas_1 .Lkey_256_sgas_1: aesenc (-64)(%eax), %xmm0 aesenc (-48)(%eax), %xmm0 .Lkey_192_sgas_1: aesenc (-32)(%eax), %xmm0 aesenc (-16)(%eax), %xmm0 .Lkey_128_sgas_1: aesenc (%eax), %xmm0 aesenc (16)(%eax), %xmm0 aesenc (32)(%eax), %xmm0 aesenc (48)(%eax), %xmm0 aesenc (64)(%eax), %xmm0 aesenc (80)(%eax), %xmm0 aesenc (96)(%eax), %xmm0 aesenc (112)(%eax), %xmm0 aesenc (128)(%eax), %xmm0 aesenclast (144)(%eax), %xmm0 movdqu (80)(%esp,%esi), %xmm1 pxor %xmm1, %xmm0 movdqu %xmm0, (16)(%esp,%esi) addl (28)(%ebp), %esi subl (28)(%ebp), %edi jg .Lsingle_blkgas_1 movl (12)(%ebp), %edi xor %ecx, %ecx .L__0001gas_1: movb (16)(%esp,%ecx), %dl movb %dl, (%edi,%ecx) add $(1), %ecx cmp %ebx, %ecx jl .L__0001gas_1 movdqu (%esp,%ebx), %xmm0 movdqu %xmm0, (%esp) addl %ebx, (8)(%ebp) addl %ebx, (12)(%ebp) subl %ebx, (24)(%ebp) jg .Lblks_loopgas_1 add $(144), %esp pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_EncryptCFB32_RIJ128_AES_NI _h9_EncryptCFB32_RIJ128_AES_NI: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(144), %esp movl (32)(%ebp), %eax movdqu (%eax), %xmm4 movdqu %xmm4, (%esp) .Lblks_loopgas_2: movl (8)(%ebp), %esi movl (28)(%ebp), %edx lea (,%edx,4), %ebx movl (24)(%ebp), %edx cmp %ebx, %edx cmovl %edx, %ebx xor %ecx, %ecx .L__0002gas_2: movl (%esi,%ecx), %edx movl %edx, (80)(%esp,%ecx) add $(4), %ecx cmp %ebx, %ecx jl .L__0002gas_2 movl (20)(%ebp), %ecx movl (16)(%ebp), %edx lea (,%edx,4), %eax lea (-144)(%ecx,%eax,4), %eax xor %esi, %esi mov %ebx, %edi .Lsingle_blkgas_2: movdqu (%esp,%esi), %xmm0 pxor (%ecx), %xmm0 cmp $(12), %edx jl .Lkey_128_sgas_2 jz .Lkey_192_sgas_2 .Lkey_256_sgas_2: aesenc (-64)(%eax), %xmm0 aesenc (-48)(%eax), %xmm0 .Lkey_192_sgas_2: aesenc (-32)(%eax), %xmm0 aesenc (-16)(%eax), %xmm0 .Lkey_128_sgas_2: aesenc (%eax), %xmm0 aesenc (16)(%eax), %xmm0 aesenc (32)(%eax), %xmm0 aesenc (48)(%eax), %xmm0 aesenc (64)(%eax), %xmm0 aesenc (80)(%eax), %xmm0 aesenc (96)(%eax), %xmm0 aesenc (112)(%eax), %xmm0 aesenc (128)(%eax), %xmm0 aesenclast (144)(%eax), %xmm0 movdqu (80)(%esp,%esi), %xmm1 pxor %xmm1, %xmm0 movdqu %xmm0, (16)(%esp,%esi) addl (28)(%ebp), %esi subl (28)(%ebp), %edi jg .Lsingle_blkgas_2 movl (12)(%ebp), %edi xor %ecx, %ecx .L__0003gas_2: movl (16)(%esp,%ecx), %edx movl %edx, (%edi,%ecx) add $(4), %ecx cmp %ebx, %ecx jl .L__0003gas_2 movdqu (%esp,%ebx), %xmm0 movdqu %xmm0, (%esp) addl %ebx, (8)(%ebp) addl %ebx, (12)(%ebp) subl %ebx, (24)(%ebp) jg .Lblks_loopgas_2 add $(144), %esp pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_EncryptCFB128_RIJ128_AES_NI _h9_EncryptCFB128_RIJ128_AES_NI: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (28)(%ebp), %eax movdqu (%eax), %xmm0 movl (8)(%ebp), %esi movl (12)(%ebp), %edi movl (24)(%ebp), %ebx movl (20)(%ebp), %ecx movl (16)(%ebp), %edx lea (,%edx,4), %eax lea (-144)(%ecx,%eax,4), %eax .Lblks_loopgas_3: pxor (%ecx), %xmm0 movdqu (%esi), %xmm1 cmp $(12), %edx jl .Lkey_128_sgas_3 jz .Lkey_192_sgas_3 .Lkey_256_sgas_3: aesenc (-64)(%eax), %xmm0 aesenc (-48)(%eax), %xmm0 .Lkey_192_sgas_3: aesenc (-32)(%eax), %xmm0 aesenc (-16)(%eax), %xmm0 .Lkey_128_sgas_3: aesenc (%eax), %xmm0 aesenc (16)(%eax), %xmm0 aesenc (32)(%eax), %xmm0 aesenc (48)(%eax), %xmm0 aesenc (64)(%eax), %xmm0 aesenc (80)(%eax), %xmm0 aesenc (96)(%eax), %xmm0 aesenc (112)(%eax), %xmm0 aesenc (128)(%eax), %xmm0 aesenclast (144)(%eax), %xmm0 pxor %xmm1, %xmm0 movdqu %xmm0, (%edi) add $(16), %esi add $(16), %edi sub $(16), %ebx jg .Lblks_loopgas_3 pop %edi pop %esi pop %ebx pop %ebp ret
page ,132 title COMMAND2 - resident code for COMMAND.COM part II name COMMAND2 ;/* ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1991 ; * All Rights Reserved. ; */ ; ; Revision History ; ================ ; ; M038 SR 11/5/90 Changed stuff for Novell RPL. These guys cannot ; reserve memory by changing int 12h and then give it ; back to DOS by changing arenas in autoexec.bat. ; This makes command.com reload transient and this ; cannot be done at this stage. ; ; .xcref .xlist include dossym.inc include pdb.inc include syscall.inc include comsw.asm include comequ.asm include resmsg.equ include comseg.asm .list .cref DATARES segment public byte extrn Append_State:word extrn Append_Flag:byte extrn BMemMes:byte extrn ComBad:byte extrn ComDrv:byte extrn ComSpec:byte extrn EnvirSeg:word extrn ExtCom:byte extrn FRetMes:byte extrn HaltMes:byte extrn Handle01:word extrn InitFlag:BYTE extrn Int_2e_Ret:dword extrn Io_Save:word extrn Loading:byte extrn LTpa:word extrn MemSiz:word extrn NoHandMes:byte extrn OldTerm:dword extrn Parent:word extrn PermCom:byte extrn Prompt:byte extrn PutBackDrv:byte extrn PutBackMsg:byte extrn PutBackSubst:byte extrn Res_Tpa:word extrn RetCode:word extrn Save_Pdb:word extrn SingleCom:word extrn Sum:word extrn Trans:dword extrn TranVarEnd:byte extrn TranVars:byte extrn TrnSeg:word extrn VerVal:word extrn ResSize:word extrn OldDS:word extrn RStack:word extrn Ctrlc_Trap:near extrn CritErr_Trap:near extrn LodCom_Trap:near DATARES ends ;;ENVARENA segment public para ;;ENVARENA ends ;;ENVIRONMENT segment public para ; default COMMAND environment ;;ENVIRONMENT ends INIT segment public para extrn EnvSiz:word extrn OldEnv:word extrn ResetEnv:byte extrn UsedEnv:word extrn AllocedEnv:byte INIT ends TRANDATA segment public byte extrn trandataend:byte TRANDATA ends TRANSPACE segment public byte extrn transpaceend:byte extrn headcall:dword TRANSPACE ends CODERES segment public byte public BadMemErr public ChkSum ;; public EndInit public GetComDsk2 public Int_2e public LoadCom public LodCom public LodCom1 public RestHand public SavHand public SetVect public THeadFix public TRemCheck public TJmp assume cs:CODERES,ds:NOTHING,es:NOTHING,ss:NOTHING extrn ContC:near extrn DskErr:near extrn Alloc_error:near ;* If we cannot allocate enough memory for the transient or there ; was some other allocation error, we display a message and ; then die. ;SR; ; We will have to make sure that at this entry point and at FatalC, ;ds = DATARES. All jumps to these points are made from only within this file ;and so we should be able to do this assume ds:DATARES BadMemErr: mov dx,offset DATARES:BMemMes ; DX = ptr to msg FatalC: ;; push cs ;; pop ds ;; assume ds:ResGroup invoke RPrint ; If this is NOT a permanent (top-level) COMMAND, then we exit; ; we can't do anything else! cmp PermCom,0 je FatalRet ; We are a permanent command. If we are in the process of the ; magic interrupt (Singlecom) then exit too. cmp SingleCom,0 ; if permcom and singlecom jne FatalRet ; must take int_2e exit ; Permanent command. We can't do ANYthing except halt. mov dx,offset DATARES:HaltMes ; DX = ptr to msg invoke RPrint sti Stall: jmp Stall ; crash the system nicely FatalRet: mov dx,offset DATARES:FRetMes ; DX = ptr to msg invoke RPrint FatalRet2: cmp PermCom,0 ; if we get here and permcom, jne Ret_2e ; must be int_2e ; Bugbug: this is where we'd want to unhook int 2F, *if* we ; were a non-permanent COMMAND that had hooked it! (Just in ; case we decide to do that.) mov ax,Parent mov word ptr ds:Pdb_Parent_Pid,ax mov ax,word ptr OldTerm mov word ptr ds:Pdb_Exit,ax mov ax,word ptr OldTerm+2 mov word ptr ds:Pdb_Exit+2,ax mov ax,(EXIT shl 8) ; return to lower level int 21h Ret_2e: ;SR; ; We will ensure that ds = DATARES for all entries to this place ; ;; push cs ;; pop ds ;; assume ds:resgroup,es:nothing,ss:nothing assume ds:DATARES mov SingleCom,0 ; turn off singlecom mov es,Res_Tpa mov ah,DEALLOC int 21h ; free up space used by transient mov bx,Save_Pdb mov ah,SET_CURRENT_PDB int 21h ; current process is user mov ax,RetCode cmp ExtCom,0 jne GotECode xor ax,ax ; internals always return 0 GotECode: mov ExtCom,1 ; force external ;SR; This is actually returning to the caller. However, the old code had ;ds = RESGROUP so I guess we can keep ds = DATARES for us. ;Yes, int 2eh can corrupt all registers so we are ok. ; jmp Int_2e_Ret ;"iret" ;*** Int_2e, magic command executer Int_2e: assume ds:NOTHING,es:NOTHING,ss:NOTHING ;SR; ; We are going to come here from the stub with the old ds and DATARES value ;pushed on the stack in that order. Pick up this stuff off the stack ; pop ds ;ds = DATARES assume ds:DATARES pop ax ; pop ds:OldDS ;Save old value of ds pop word ptr Int_2e_Ret pop word ptr [Int_2e_Ret+2] ; store return address ;pop ax ; chuck flags add sp,2 ;; push cs ;; pop es push ds pop es ;es = DATARES ; mov ds,OldDS mov ds,ax assume ds:nothing ;ds = old value mov di,80h mov cx,64 ; Bugbug: cld rep movsw mov ah,GET_CURRENT_PDB int 21h ; get user's header mov es:Save_Pdb,bx mov ah,SET_CURRENT_PDB ;; mov bx,cs ;SR; ; Set ds = DATARES because BadMemErr expects this ; push es pop ds assume ds:DATARES mov bx,ds ;es = our PSP now int 21h ; current process is me mov SingleCom,81h mov ExtCom,1 ; make sure this case forced ;SR; ; We can enter LodCom directly after a command shell is terminated or we ;can fall thru from above. When we enter directly from the stub, the stack ;has the old ds value and the data seg value on the stack, so that ds can ;be properly set. To fake this, we push dummy values here. ; push ds ;old value of ds push ds ;data seg value, ds = DATARES LodCom: ; termination handler pop ds ;ds = DATARES assume ds:DATARES add sp,2 ; pop OldDS ;store old ds cmp ExtCom,0 jne @f ; internal cmd - memory allocated jmp LodCom1 @@: mov bx,0FFFFh mov ah,ALLOC int 21h call SetSize add ax,20h cmp bx,ax jnc MemOk ; > 512 byte buffer - good enough BadMemErrJ: jmp BadMemErr ; not enough memory ;*** SetSize - get transient size in paragraphs SetSize proc assume ds:NOTHING,es:NOTHING mov ax,offset TRANGROUP:TranSpaceEnd + 15 mov cl,4 shr ax,cl ret SetSize endp MemOk: assume ds:DATARES ;we have set ds = DATARES mov ah,ALLOC int 21h jc BadMemErrJ ; memory arenas probably trashed mov ExtCom,0 ; flag not to alloc again mov Res_Tpa,ax ; save current tpa segment and ax, 0F000h add ax, 01000h ; round up to next 64k boundary jc Bad_Tpa ; memory wrap if carry set ; Make sure that new boundary is within allocated range mov dx,Res_Tpa add dx,bx ; compute maximum address cmp dx,ax ; is 64k address out of range? jbe Bad_Tpa ; Must have 64K of usable space. sub dx,ax ; compute the usable space cmp dx,01000h ; is space >= 64k ? jae LTpaSet Bad_Tpa: mov ax,Res_Tpa LTpaSet: mov LTpa,ax ; usable tpa is 64k buffer aligned mov ax,Res_Tpa ; actual tpa is buffer allocated add bx,ax mov MemSiz,bx call SetSize sub bx,ax ; ;M038; Start of changes ; Changes for Novell RPL. These guys reserve memory for themselves by ;reducing int 12h size and add this memory to the system at autoexec time by ;running a program that changes arenas. This changes the largest block that ;command.com gets and so changes the transient segment. So, command.com does ;a checksum at the wrong address and thinks that the transient is destroyed ;and tries to reload it. At this point, no Comspec is defined and so the ;reload fails, hanging the system. To get around this we just copy the ;transient from the previous address to the new address(if changed) and ;then let command.com do the checksum. So, if the transient area is not ;corrupted, there will not be any reload. In Novell's case, the transient ;is not really corrupted and so this should work. ; cmp bx,TrnSeg ;Segment still the same? je LodCom1 ;yes, dont copy ; ;Check if the new segment is above or below the current move. If the new ;segment is above(i.e new block is larger than previous block), then we ;have to move in the reverse direction ; mov cx,offset TRANGROUP:TranSpaceEnd ;cx = length to move ja mov_down ;new seg > old seg, reverse move xor si,si ;normal move mov di,si cld jmp short copy_trans mov_down: mov si,cx ;reverse move, start from end dec si mov di,si std copy_trans: push ds push es mov es,bx ;dest segment mov ds,TrnSeg ;source segment assume ds:nothing rep movsb ;copy transient cld pop es pop ds assume ds:DATARES ; ;M038; End of changes ; mov TrnSeg,bx ;new location of transient LodCom1: ;; mov ax,cs ;; mov ss,ax ;SR; At this point ds = DATARES which is where the stack is located ; mov ax,ds mov ss,ax assume ss:DATARES mov sp,offset DATARES:RStack ;; mov ds,ax assume ds:DATARES call HeadFix ; close files, restore stdin, stdout xor bp,bp ; flag command ok mov ax,-1 xchg ax,VerVal cmp ax,-1 je NoSetVer mov ah,SET_VERIFY_ON_WRITE ; AL has correct value int 21h NoSetVer: cmp SingleCom,-1 jne NoSng jmp FatalRet2 ; we have finished the single command NoSng: call ChkSum ; check the transient cmp dx,Sum je HavCom ; transient ok Bogus_Com: mov Loading,1 ; flag DskErr routine call LoadCom ChkSame: call ChkSum cmp dx,Sum jz HavCom ; same command Also_Bogus: call WrongCom jmp short ChkSame HavCom: mov Loading,0 ; flag to DskErr mov si,offset DATARES:TranVars mov di,offset TRANGROUP:HeadCall mov es,TrnSeg cld mov cx,offset DATARES:TranVarEnd sub cx,si rep movsb ; transfer info to transient mov ax,MemSiz mov word ptr ds:Pdb_Block_Len,ax ; adjust my own header ;*** TJmp - jump-off to transient ; ; Public label so debugger can find this spot. TJmp: jmp Trans ;*** TRemCheck - far version of RemCheck for transient TRemCheck proc far pop ds ;ds = DATARES add sp,2 ;discard old value of ds call RemCheck ret TRemCheck endp ;*** RemCheck ; ; ENTRY AL = drive (0=default, 1=A, ...) ; ; EXIT ZR set if removeable media ; ZR clear if fixed media ; ; USED none RemCheck: savereg <ax,bx> mov bx,ax mov ax,(IOCTL shl 8) + 8 int 21h jnc rcCont ; If an error occurred, assume the media is non-removable. ; AX contains the non-zero error code from the int 21, so ; 'or ax,ax; sets non-zero. This behavior makes network drives ; appear to be non-removable. or ax,ax jmp short ResRegs rcCont: and ax,1 not ax ResRegs: restorereg <bx,ax> ret ;*** THeadFix ; ; Far version of HeadFix, called from transient. THeadFix proc far pop ds ;ds = DATARES add sp,2 ;discard old ds value on stack call HeadFix ret THeadFix endp ;*** HeadFix HeadFix: call SetVect ; set vectors to our values ; Clean up header ; Bugbug: optimize: ; mov word ptr ds:Pdb_Jfn_Table,cx instead of separate bytes xor bx,bx ; BX = handle = 0 mov cx,Io_Save ; CX = original stdin, stdout mov dx,word ptr ds:Pdb_Jfn_Table ; DX = current stdin, stdout cmp cl,dl je Chk1 ; stdin matches mov ah,CLOSE int 21h ; close stdin mov ds:Pdb_Jfn_Table,cl ; restore stdin Chk1: inc bx ; BX = handle = 1 cmp ch,dh je ChkOtherHand ; stdout matches mov ah,CLOSE int 21h ; close stdout mov ds:Pdb_Jfn_Table+1,ch ; restore stdout ChkOtherHand: add bx,4 ; skip handles 2,3,4 mov cx,FILPERPROC - 5 ; CX = # handles to close ; (handles 0-4 already done) CloseLoop: mov ah,CLOSE int 21h ; close each handle inc bx ; BX = next handle loop CloseLoop ; Bugbug: since this is for transient code, move it there ; M012: remove this CS -> DS. Must've been missed during ; purification. ;; push ds ; save data segment ;; push cs ; get local segment into DS ;; pop ds ; cmp Append_Flag,-1 ; do we need to reset APPEND? jne Append_Fix_End ; no - just exit mov ax,AppendSetState ; set the state of Append mov bx,Append_State ; back to the original state int 2Fh ; mov Append_Flag,0 ; set append flag to invalid Append_Fix_End: ; ;; pop ds ; get data segment back ret ;*** SavHand - save current program's stdin/out & set to our stderr ; ; ENTRY nothing ; ; EXIT nothing ; ; USED flags ; ; EFFECTS ; Handle01 = current program's stdin,stdout JFN entries ; current program's stdin,stdout set to our stderr ; ;SR; ; Changed ds = DATARES. We need it to access our JFN_Table ; Called from ContC ( ds = DATARES ) and DskErr ( ds = DATARES ). ; SavHand proc assume ds:DATARES,es:NOTHING,ss:NOTHING push bx ;preserve registers push ax push es push ds ; save DATARES value mov ah,GET_CURRENT_PDB int 21h ; BX = user's header seg addr mov ds,bx ; DS = user's header seg addr lds bx,ds:PDB_JFN_POINTER ; DS:BX = ptr to JFN table mov ax,word ptr ds:[bx] ; AX = stdin,stdout JFN's pop es ;es = DATARES push es ;save it back on stack mov es:Handle01,ax ; save user's stdin, stdout ;SR; ; Use es to address Handle01 & our JFN_Table ; mov al,es:[PDB_JFN_TABLE+2] ; AL = COMMAND stderr mov ah,al ; AH = COMMAND stderr mov word ptr ds:[bx],ax ; set user's stdin/out to our stderr pop ds ; restore registers pop es pop ax pop bx ret SavHand endp assume ds:DATARES GetComDsk2: call GetComDsk jmp LodCom1 ; memory already allocated RestHand: push ds push bx ; restore stdin, stdout to user push ax mov ah,GET_CURRENT_PDB int 21h ; point to user's header mov ax,Handle01 mov ds,bx assume ds:NOTHING lds bx,ds:Pdb_Jfn_Pointer ; DS:BX = ptr to jfn table mov word ptr ds:[bx],ax ; stuff his old 0 and 1 pop ax pop bx pop ds ret assume ds:DATARES,ss:DATARES Hopeless: mov dx,offset DATARES:ComBad jmp FatalC GetComDsk: mov al,ComDrv call RemCheck jnz Hopeless ; non-removable media GetComDsk3: cmp dx,offset DATARES:ComBad jnz GetComDsk4 mov dx,offset DATARES:ComBad ; DX = ptr to msg invoke RPrint ; say COMMAND is invalid GetComDsk4: ; Bugbug: there's always a drive here? No need to check? cmp PutBackDrv,0 ; is there a drive in the comspec? jnz Users_Drive ; yes - use it mov ah,GET_DEFAULT_DRIVE ; use default drive int 21h add al,"A" ; convert to ascii mov PutBackDrv,al ; put in message to print out Users_Drive: mov dx,offset DATARES:PutBackMsg ; prompt for diskette mov si,offset DATARES:PutBackSubst ; containing COMMAND invoke RPrint mov dx,offset DATARES:Prompt ; "Press any key" invoke RPrint call GetRawFlushedByte ret ;*** GetRawFlushedByte - flush world and get raw input GetRawFlushedByte: mov ax,(STD_CON_INPUT_FLUSH shl 8) or RAW_CON_INPUT int 21h ; get char without testing or echo mov ax,(STD_CON_INPUT_FLUSH shl 8) + 0 int 21h ; Bugbug: get rid of this return and the following retz. return ;*** LoadCom - load in transient LoadCom: assume ds:DATARES inc bp ; flag command read ifndef ROMDOS mov dx,offset DATARES:ComSpec mov ax,OPEN shl 8 int 21h ; open command.com jnc ReadCom cmp ax,ERROR_TOO_MANY_OPEN_FILES jnz TryDoOpen mov dx,offset DATARES:NoHandMes jmp FatalC ; will never find a handle TryDoOpen: call GetComDsk jmp LoadCom ReadCom: mov bx,ax ; BX = handle mov dx,offset RESGROUP:TranStart xor cx,cx ; CX:DX = seek loc mov ax,LSEEK shl 8 int 21h jc WrongCom1 mov cx,offset TRANGROUP:TranSpaceEnd - 100h push ds mov ds,TrnSeg assume ds:NOTHING mov dx,100h mov ah,READ int 21h pop ds assume ds:DATARES WrongCom1: pushf push ax mov ah,CLOSE int 21h ; close command.com pop ax popf jc WrongCom ; error on read cmp ax,cx retz ; size matched WrongCom: mov dx,offset DATARES:ComBad call GetComDsk jmp LoadCom ; try again else ;ROMDOS push si ; preserve registers push di push es mov si,offset RESGROUP:TranStart ; SI = offset in image mov es,TrnSeg mov di,100h ; ES:DI = ptr to destination mov cx,offset TRANGROUP:TranSpaceEnd-100h ; CX = size of transient image invoke LoadFromROM ; copy transient to RAM pop es ; restore registers pop di pop si ret ;; mov dx,80h ; DS:DX = ptr to desired DTA ;; ; Ok to use command tail buffer? ;; mov ah,SET_DMA ; AH = 'Set DTA Address' ;; int 21h ;; ;;; Bugbug: Are we screwing anybody up by setting DTA here? ;; ;; mov dx,offset RESGROUP:ComSpec ; DS:DX = ptr to "COMMAND",0 ;; mov ah,ROM_FIND_FIRST ; AH = 'ROM Find First' ;; int 21h ;; jc WrongCom ; couldn't find our image ;; ;;; Relevant DTA contents: ;;; Offset 15 = segment address of ROM header ;;; ;;; We're going to be stupid right now, and just know that ;;; the command.com image is at offset 30h in the ROM. ;; ;; push si ; save registers ;; push di ;; push ds ;; push es ;; ;; mov ds,ds:80h+15 ; DS = ROM seg addr ;; assume ds:NOTHING ;; mov si,30h+offset RESGROUP:TranStart ;; ; DS:SI = ptr to transient in ROM ;; mov es,TrnSeg ;; mov di,100h ; ES:DI = ptr to transient destination ;; ;; mov cx,offset TRANGROUP:TranSpaceEnd - 100h ;; ; CX = size of transient image ;; cld ;; rep movsb ; copy transient to RAM ;; ;; pop es ; restore registers ;; pop ds ;; assume ds:DATARES ;; pop di ;; pop si ;; ret WrongCom: mov dx,offset DATARES:ComBad ; DX = ptr to error message jmp FatalC ; print message and give up endif ;ROMDOS ;*** ChkSum - compute transient checksum ChkSum: push ds mov ds,TrnSeg mov si,100h mov cx,offset TRANGROUP:TranDataEnd - 100H Check_Sum: cld shr cx,1 xor dx,dx Chk: lodsw add dx,ax adc dx,0 loop Chk pop ds ret ;*** SetVect - set interrupt vectors SetVect: mov dx,offset DATARES:LodCom_Trap mov ax,(SET_INTERRUPT_VECTOR shl 8) or 22h mov word ptr ds:Pdb_Exit,dx mov word ptr ds:Pdb_Exit+2,ds int 21h mov dx,offset DATARES:Ctrlc_Trap inc al int 21h mov dx,offset DATARES:CritErr_Trap inc al int 21h ret ;SR; ; We have this to take care of the extra values pushed on the stack by ;the stub before jumping to LodCom1. We set up ds here and then jump to ;Lodcom1 ; public TrnLodCom1 TrnLodCom1: pop ds ;ds = DATARES add sp,2 ; pop ds:OldDS jmp LodCom1 ;*** EndInit - end up initialization sequence ; ; Move the environment to a newly allocated segment. ;;EndInit: ;; push ds ; save segments ;; push es ; ;; push cs ; get resident segment to DS ;; pop ds ; ;; assume ds:RESGROUP ;; mov cx,UsedEnv ; get number of bytes to move ;; mov es,EnvirSeg ; get target environment segment ;; assume es:NOTHING ;; ;; mov ds:Pdb_Environ,es ; put new environment in my header ;; mov ds,OldEnv ; source environment segment ;; assume ds:NOTHING ;; xor si,si ; set up offsets to start of segments ;; xor di,di ;; cld ;; rep movsb ; move it ;; xor ax,ax ;; stosb ; make sure it ends with double-null ;; ;; cmp ResetEnv,1 ; do we need to setblock to env end? ;; jne NoReset ; no - we already did it ;; mov bx,EnvSiz ; BX = size of environ in paragraphs ;; push es ; save environment - just to be sure ;; mov ah,SETBLOCK ; ;; int 21h ;; pop es ;; ;;NoReset: ;; mov InitFlag,FALSE ; turn off init flag ;; pop es ;; pop ds ;; jmp LodCom ; allocate transient ; ;The init code has been changed to take care of the new way in which the ;environment segment is allocated. ;NB: We can use all the init variables at this point because they are all in ;RESGROUP ;Bugbug: The above approach will not work for ROMDOS ; IF 0 EndInit: push ds push es ;save segments push cs pop ds assume ds:RESGROUP ; ; AllocedEnv flag signals whether it is a passed environment or not ; mov bx,ds mov es,bx ;es = RESGROUP ; ;ResSize is the actual size to be retained -- only data for HIMEM COMMAND, ; code + data for low COMMAND ; mov bx,ResSize ;Total size of resident mov ah,SETBLOCK int 21h ;Set block to resident size ; ;Allocate the correct size for the environment ; mov bx,EnvSiz ;bx = env size in paras mov ah,ALLOC int 21h ;get memory jc nomem_err ;out of memory,signal error mov EnvirSeg,ax ;Store new environment segment mov ds:PDB_Environ,ax ;Put new env seg in PSP mov es,ax ;es = address of allocated memory assume es:nothing ; ;Copy the environment to the newly allocated segment ; mov cx,UsedEnv ;number of bytes to move push ds mov ds,OldEnv ;ds = Old environment segment assume ds:nothing xor si,si mov di,si ;Start transfer from 0 cld rep movsb ;Do the copy xor ax,ax stosb ;Make it end with double-null pop ds ;ds = RESGROUP assume ds:RESGROUP ; ;We have to free the old environment block if it was allocated by INIT ; cmp AllocedEnv,0 ;has env been allocated by INIT? je no_free ;no, do not free it mov ax,OldEnv ;Get old environment mov es,ax mov ah,DEALLOC int 21h ;Free it no_free: mov InitFlag,FALSE ;indicate INIT is done pop es pop ds assume ds:nothing jmp LodCom ;allocate transient nomem_err: ; ;We call the error routine which will never return. It will either exit ;with an error ( if not the first COMMAND ) or just hang after an error ;message ( if first COMMAND ) ; call Alloc_error ENDIF CODERES ends ; This TAIL segment is used to produce a PARA aligned label in ; the resident group which is the location where the transient ; segments will be loaded initial. TAIL segment public para org 0 TranStart label word public TranStart TAIL ends ; This TAIL segment is used to produce a PARA aligned label in ; the transient group which is the location where the exec ; segments will be loaded initial. ; ; Bugbug: Is TRANTAIL used anymore? TRANTAIL segment public para org 0 ExecStart label word TRANTAIL ends end 
; A104473: a(n) = binomial(n+2,2)*binomial(n+6,2). ; 15,63,168,360,675,1155,1848,2808,4095,5775,7920,10608,13923,17955,22800,28560,35343,43263,52440,63000,75075,88803,104328,121800,141375,163215,187488,214368,244035,276675,312480,351648,394383,440895,491400,546120,605283,669123,737880,811800,891135,976143,1067088,1164240,1267875,1378275,1495728,1620528,1752975,1893375,2042040,2199288,2365443,2540835,2725800,2920680,3125823,3341583,3568320,3806400,4056195,4318083,4592448,4879680,5180175,5494335,5822568,6165288,6522915,6895875,7284600,7689528,8111103,8549775,9006000,9480240,9972963,10484643,11015760,11566800,12138255,12730623,13344408,13980120,14638275,15319395,16024008,16752648,17505855,18284175,19088160,19918368,20775363,21659715,22572000,23512800,24482703,25482303,26512200,27573000 add $0,4 bin $0,2 mov $1,$0 sub $0,1 sub $1,3 mul $1,$0 mov $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r14 push %r8 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x1d129, %rsi cmp %r12, %r12 mov (%rsi), %r8 nop add %rdx, %rdx lea addresses_WT_ht+0x13c09, %rbx nop nop nop nop nop add $17924, %rcx movw $0x6162, (%rbx) cmp %r14, %r14 lea addresses_WC_ht+0x91d1, %rcx nop nop nop nop nop sub $52422, %r14 mov (%rcx), %bx nop xor %r14, %r14 lea addresses_normal_ht+0xa9d1, %rsi lea addresses_A_ht+0x1a51, %rdi nop nop nop sub %r14, %r14 mov $67, %rcx rep movsq nop nop nop nop xor %rdi, %rdi lea addresses_WC_ht+0x1d209, %r14 add %rdi, %rdi mov (%r14), %r12 nop nop and %r8, %r8 lea addresses_WC_ht+0x1c409, %rsi lea addresses_D_ht+0xae09, %rdi nop nop nop nop nop and $58141, %rdx mov $87, %rcx rep movsl dec %r8 lea addresses_A_ht+0x6d09, %rsi lea addresses_WC_ht+0xae69, %rdi nop nop nop nop nop xor $42060, %r12 mov $24, %rcx rep movsw nop nop and $53007, %rsi lea addresses_UC_ht+0x1ca09, %rsi lea addresses_WC_ht+0x16d09, %rdi add %r8, %r8 mov $94, %rcx rep movsl nop nop nop nop nop cmp %rcx, %rcx lea addresses_WC_ht+0xc979, %rsi lea addresses_WC_ht+0x15409, %rdi add $11383, %r14 mov $124, %rcx rep movsw sub %rbx, %rbx lea addresses_normal_ht+0xa6a9, %rbx nop nop xor %rsi, %rsi mov $0x6162636465666768, %r8 movq %r8, %xmm3 movups %xmm3, (%rbx) nop nop xor $56392, %rdx lea addresses_A_ht+0xabf5, %rdi nop nop nop sub %rsi, %rsi movw $0x6162, (%rdi) nop nop nop nop sub $11533, %r12 lea addresses_UC_ht+0x8409, %rcx nop nop nop nop nop cmp $23878, %rdx movups (%rcx), %xmm1 vpextrq $1, %xmm1, %r8 xor %r12, %r12 lea addresses_WT_ht+0x158c9, %rdx and $27924, %rcx mov (%rdx), %r14w sub %rbx, %rbx lea addresses_normal_ht+0x1e809, %rsi lea addresses_normal_ht+0x131c6, %rdi nop nop add %rbx, %rbx mov $79, %rcx rep movsb sub $48178, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r8 pop %r14 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r8 push %r9 push %rax push %rbx push %rdi // Load lea addresses_WC+0x809, %r8 add %r11, %r11 mov (%r8), %rax nop nop add %rax, %rax // Store lea addresses_normal+0x1c59, %rdi clflush (%rdi) nop nop cmp %r9, %r9 movw $0x5152, (%rdi) nop nop nop nop dec %rax // Load lea addresses_WC+0x1545, %r10 nop nop nop nop nop and %r11, %r11 mov (%r10), %r8d nop nop nop nop xor $48785, %r11 // Store lea addresses_A+0x1c009, %r9 nop nop nop nop sub %r8, %r8 movb $0x51, (%r9) nop nop nop nop cmp $23251, %rax // Store mov $0xf09, %rdi nop nop nop nop nop cmp $2472, %r8 mov $0x5152535455565758, %rbx movq %rbx, (%rdi) nop nop nop xor $26055, %r10 // Store lea addresses_A+0x8009, %r8 nop nop nop and $55208, %r11 movw $0x5152, (%r8) nop nop dec %r9 // Store lea addresses_D+0x14209, %r10 nop sub %rax, %rax mov $0x5152535455565758, %rbx movq %rbx, %xmm7 vmovups %ymm7, (%r10) nop nop cmp $21064, %r8 // Faulty Load lea addresses_A+0x1bc09, %r8 and %rax, %rax mov (%r8), %ebx lea oracles, %r11 and $0xff, %rbx shlq $12, %rbx mov (%r11,%rbx,1), %rbx pop %rdi pop %rbx pop %rax pop %r9 pop %r8 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': True, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 5}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WC_ht', 'same': True, 'AVXalign': True, 'congruent': 9}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 10}, 'dst': {'same': True, 'type': 'addresses_D_ht', 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 9}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 0}} {'00': 2252} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
#include "top.h" void dnn_LeNet(in_t data_port[PORT_CFG::in_mem], ker_t kernel_port[PORT_CFG::ker_mem], res_t output_port[PORT_CFG::out_mem]) { interface intf; dnn_layers dnn; in_t L1_in [L1_CONV::lyr_in][L1_CONV::w_in][L1_CONV::w_in]; ker_t L1_ker [L1_CONV::lyr_out][L1_CONV::w2_ker]; ker_t L3_ker [L3_CONV::lyr_out][L3_CONV::w2_ker]; ker_t L6_ker [L5_FC::fc_ker]; ker_t L7_ker [L6_FC::fc_ker]; res_t L1_out [L1_CONV::lyr_out][L1_CONV::w_out][L1_CONV::w_out]; res_t L2_out [L2_POOL::lyr_out][L2_POOL::w_out][L2_POOL::w_out]; res_t L3_out [L3_CONV::lyr_out][L3_CONV::w_out][L3_CONV::w_out]; res_t L4_out [L4_POOL::lyr_out][L4_POOL::w_out][L4_POOL::w_out]; res_t L5_out [L4_POOL::lyr_out * L4_POOL::w_out * L4_POOL::w_out]; res_t L6_out [L5_FC::lyr_out]; res_t L7_out [L6_FC::lyr_out]; intf.read_input3D <in_t , PORT_CFG, L1_CONV> (data_port,L1_in); intf.read_kernel2D <ker_t, PORT_CFG, L1_CONV> (BASE_L1, kernel_port,L1_ker); intf.read_kernel2D <ker_t, PORT_CFG, L3_CONV> (BASE_L3, kernel_port,L3_ker); intf.read_kernel <ker_t, PORT_CFG, L5_FC> (BASE_L5, kernel_port,L6_ker); intf.read_kernel <ker_t, PORT_CFG, L6_FC> (BASE_L6, kernel_port,L7_ker); dnn.conv_3DT1 <in_t , ker_t , res_t, mid_t, L1_CONV> (1, L1_in , L1_ker , L1_out); dnn.ds_3DT1 <in_t , res_t, L2_POOL> (2, L1_out , L2_out); dnn.conv_3DT1 <in_t , ker_t , res_t, mid_t, L3_CONV> (3, L2_out , L3_ker , L3_out); dnn.ds_3DT1 <in_t , res_t, L4_POOL> (4, L3_out , L4_out); dnn.conv2fc <in_t, L4_POOL> (45, L4_out , L5_out); dnn.fc_T1 <in_t, ker_t,res_t, mid_t, L5_FC> (5, L5_out, L6_ker, L6_out); dnn.fc_T1 <in_t, ker_t,res_t, mid_t, L6_FC> (6, L6_out, L7_ker, L7_out); intf.write_result <res_t, PORT_CFG, L6_FC> (output_port,L7_out); //intf1.write_result2D <res_t, PORT_CFG, L4_POOL> (output_port,L4_out); } /* void dnn_topDual(in_t data_port[Pcfg_CONV::IN_MEM], ker_t kernel_port[Pcfg_CONV::KER_MEM], res_t output_port[Pcfg_CONV::OUT_MEM]) { #pragma HLS ARRAY_RESHAPE variable=data_port cyclic factor=2 dim=1 #pragma HLS ARRAY_RESHAPE variable=kernel_port cyclic factor=2 dim=1 #pragma HLS ARRAY_RESHAPE variable=output_port cyclic factor=2 dim=1 //#pragma HLS RESOURCE variable=data_port core=RAM_2P_BRAM //#pragma HLS RESOURCE variable=kernel_port core=RAM_2P_BRAM //#pragma HLS RESOURCE variable=output_port core=RAM_2P_BRAM #pragma HLS INTERFACE bram port=data_port #pragma HLS INTERFACE bram port=kernel_port #pragma HLS INTERFACE bram port=output_port interface intf1; dnn_layer dnn1; in_t input_array [L1_CONV::w_in][L1_CONV::w_in]; in_t input_array2 [L1_CONV::lyr_in][L1_CONV::w_in][L1_CONV::w_in]; ker_t L1_ker [L1_CONV::lyr_out][L1_CONV::w2_ker]; res_t conv2_out [L1_CONV::lyr_out][L1_CONV::w_out][L1_CONV::w_out]; //#pragma HLS ARRAY_RESHAPE variable=input_array cyclic factor=2 dim=1 //#pragma HLS ARRAY_RESHAPE variable=L1_ker cyclic factor=2 dim=1 #pragma HLS ARRAY_PARTITION variable=L1_ker complete dim=1 //#pragma HLS ARRAY_PARTITION variable=L1_ker complete dim=1 intf1.read_kernel2D <ker_t,Pcfg_CONV, L1_CONV> (kernel_port,L1_ker); intf1.read_input3D <in_t ,Pcfg_CONV, L1_CONV> (data_port,input_array2); dnn1.Conv_DualPortT2 <in_t ,ker_t , res_t, mid_t, L1_CONV> (input_array2 , L1_ker , conv2_out); intf1.write_result2D <res_t,Pcfg_CONV, L1_CONV> (output_port,conv2_out); //intf1.read_kernel2D <ker_t,Pcfg_CONV, L1_CONV> (kernel_port,L1_ker); //intf1.read_input3D <in_t ,Pcfg_CONV, L1_CONV> (data_port,input_array2); //dnn1.Conv_DualPortT2 <in_t ,ker_t , res_t, mid_t, L1_CONV> (input_array2 , L1_ker , conv2_out2); //intf1.write_result3D <res_t,Pcfg_CONV, L1_CONV> (output_port,conv2_out2); } */
lsr lsr
;+---------------------------------+ ;| SECTOR 2 - Secondary Bootloader | ;+---------------------------------+ [bits 16] [org 0x0500] ; ----- Main ----- ; Setup Segments and Stack cli mov ax, 0x0000 mov ds, ax mov es, ax mov ax, 0x9000 mov ss, ax mov sp, 0xFFFF sti mov si, Stg2Msg call Print call EnableA20_Keyboard_Out ; Check if we memory above 1Mb is wrapped around push ds mov ax, 0xFFFF mov ds, ax mov ax, [0x7E0E] pop ds mov bx, [0x7DFE] cmp ax, bx je A20Error ; Generate a memory map mov di, 0x8000 call GetMemoryMap ; Load kernel into memory mov si, FILENAME mov bx, 0x0000 ; Offset mov ax, 0x0300 ; Segment call Disk.GetFile ; Load GDT lgdt [gdt_pointer] ; Switch to protected mode cli mov eax, cr0 or eax, 1 mov cr0, eax jmp 0x8:Pmode ; Should just reference this from memory bpbBytesPerSector: DW 512 ; 11 Byte offset bpbSectorsPerCluster: DB 1 ; 13 bpbReservedSectors: DW 1 ; 14 bpbNumberOfFATs: DB 2 ; 16 bpbRootEntries: DW 224 ; 17 bpbTotalSectors: DW 2880 ; 19 bpbMedia: DB 0xF0 ; 21 bpbSectorsPerFAT: DW 9 ; 22 bpbSectorsPerTrack: DW 18 ; 24 bpbHeadsPerCylinder: DW 2 ; 26 bpbHiddenSectors: DD 0 ; 28 bpbTotalSectorsBig: DD 0 ; 32 bsDriveNumber: DB 0 ; 36 bsUnused: DB 0 ; 37 bsExtBootSignature: DB 0x29 ; 38 bsSerialNumber: DD 0xa0a1a2a3 ; 42 bsVolumeLabel: DB "EDOS " ; 43 bsFileSystem: DB "FAT12 " ; 44 ; ----- Routines ----- %include "src/disk.asm" %include "src/memory.asm" ; Prints a string ; SI = Start address of string Print: push ax .Loop: lodsb or al, al jz .Exit mov ah, 0x0e int 0x10 jmp .Loop .Exit: pop ax ret ; Prints AX as hex ; AX = Value to print Debug: push ax push cx mov cx, 4 .loop: rol ax, 4 call .LowALOut loop .loop mov ah, 0x0e mov al, 0x0A int 0x10 mov al, 0x0D int 0x10 pop cx pop ax ret .LowALOut: push ax and ax, 0x000F cmp al, 0x9 jg .abcdef add al, 0x30 jmp .skip .abcdef: add al, 0x37 .skip: mov ah, 0x0e int 0x10 pop ax ret ; ----- GDT ----- gdt_data: ; Null descriptor dd 0 ; null descriptor--just fill 8 bytes with zero dd 0 ; Code descriptor: ; code descriptor. Right after null descriptor dw 0FFFFh ; limit low dw 0 ; base low db 0 ; base middle db 10011010b ; access db 11001111b ; granularity db 0 ; base high ; Data descriptor: ; data descriptor dw 0FFFFh ; limit low (Same as code) dw 0 ; base low db 0 ; base middle db 10010010b ; access db 11001111b ; granularity db 0 ; base high end_of_gdt: gdt_pointer: dw end_of_gdt - gdt_data - 1 ; limit (Size of GDT) dd gdt_data ; base of GDT DISK EQU 0xF000 LBA EQU 0xF002 RD_START EQU 0xF004 RD_SIZE EQU 0xF006 FILENAME: db "KERNEL SYS" MEM_OFFSET: dw 0x1000 Stg2Msg: db "Second stage loaded!", 0x0A, 0x0D, 0 A20ErrorMsg: db "A20 error!", 0x0A, 0x0D, 0 [bits 32] %include "src/video.asm" Pmode: mov ax, 0x10 ; Set data segments to data selector (0x10) mov ds, ax mov ss, ax mov es, ax mov esp, 0x90000 call ClrScreen mov esi, Stg3Msg call PutS ; Copy kernel to 1MB (0x10000) mov eax, dword 2000 ; This should be the size of the kernel, temporarily hardcoded to 1MB movzx ebx, word [bpbBytesPerSector] mul ebx mov ebx, 4 div ebx cld mov esi, 0x3000 ; Initial location mov edi, 0x100000 ; Final location mov ecx, eax rep movsd mov esi, Stg4Msg call PutS cli jmp 0x100000 Stg3Msg: db "Now in protected mode!", 0x0A, 0x0D, 0 Stg4Msg: db "Jumping to kernel!", 0x0A, 0x0D, 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-2016 Intel Corporation All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; * Neither the name of Intel Corporation nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; code to compute 16 SHA1 using AVX ;; %include "reg_sizes.asm" default rel ;; Magic functions defined in FIPS 180-1 ;; ; macro MAGIC_F0 F,B,C,D,T ;; F = (D ^ (B & (C ^ D))) %macro MAGIC_F0 5 %define %%regF %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regT %5 vpxor %%regF, %%regC,%%regD vpand %%regF, %%regF,%%regB vpxor %%regF, %%regF,%%regD %endmacro ; macro MAGIC_F1 F,B,C,D,T ;; F = (B ^ C ^ D) %macro MAGIC_F1 5 %define %%regF %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regT %5 vpxor %%regF,%%regD,%%regC vpxor %%regF,%%regF,%%regB %endmacro ; macro MAGIC_F2 F,B,C,D,T ;; F = ((B & C) | (B & D) | (C & D)) %macro MAGIC_F2 5 %define %%regF %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regT %5 vpor %%regF,%%regB,%%regC vpand %%regT,%%regB,%%regC vpand %%regF,%%regF,%%regD vpor %%regF,%%regF,%%regT %endmacro ; macro MAGIC_F3 F,B,C,D,T ;; F = (B ^ C ^ D) %macro MAGIC_F3 5 %define %%regF %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regT %5 MAGIC_F1 %%regF,%%regB,%%regC,%%regD,%%regT %endmacro ; PROLD reg, imm, tmp %macro PROLD 3 %define %%reg %1 %define %%imm %2 %define %%tmp %3 vpsrld %%tmp, %%reg, (32-(%%imm)) vpslld %%reg, %%reg, %%imm vpor %%reg, %%reg, %%tmp %endmacro ; non-destructive ; PROLD_nd reg, imm, tmp, src %macro PROLD_nd 4 %define %%reg %1 %define %%imm %2 %define %%tmp %3 %define %%src %4 vpsrld %%tmp, %%src, (32-(%%imm)) vpslld %%reg, %%src, %%imm vpor %%reg, %%reg, %%tmp %endmacro %macro SHA1_STEP_00_15 11 %define %%regA %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regE %5 %define %%regT %6 %define %%regF %7 %define %%memW %8 %define %%immCNT %9 %define %%MAGIC %10 %define %%data %11 vpaddd %%regE, %%regE,%%immCNT vpaddd %%regE, %%regE,[%%data + (%%memW * 16)] PROLD_nd %%regT,5, %%regF,%%regA vpaddd %%regE, %%regE,%%regT %%MAGIC %%regF,%%regB,%%regC,%%regD,%%regT ;; FUN = MAGIC_Fi(B,C,D) PROLD %%regB,30, %%regT vpaddd %%regE, %%regE,%%regF %endmacro %macro SHA1_STEP_16_79 11 %define %%regA %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regE %5 %define %%regT %6 %define %%regF %7 %define %%memW %8 %define %%immCNT %9 %define %%MAGIC %10 %define %%data %11 vpaddd %%regE, %%regE,%%immCNT vmovdqa W14, [%%data + ((%%memW - 14) & 15) * 16] vpxor W16, W16, W14 vpxor W16, W16, [%%data + ((%%memW - 8) & 15) * 16] vpxor W16, W16, [%%data + ((%%memW - 3) & 15) * 16] vpsrld %%regF, W16, (32-1) vpslld W16, W16, 1 vpor %%regF, %%regF, W16 ROTATE_W vmovdqa [%%data + ((%%memW - 0) & 15) * 16],%%regF vpaddd %%regE, %%regE,%%regF PROLD_nd %%regT,5, %%regF, %%regA vpaddd %%regE, %%regE,%%regT %%MAGIC %%regF,%%regB,%%regC,%%regD,%%regT ;; FUN = MAGIC_Fi(B,C,D) PROLD %%regB,30, %%regT vpaddd %%regE,%%regE,%%regF %endmacro ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %ifidn __OUTPUT_FORMAT__, elf64 ; Linux %define arg0 rdi %define arg1 rsi %define arg2 rdx %define arg3 rcx %define arg4 r8 %define arg5 r9 %define tmp1 r10 %define tmp2 r11 %define tmp3 r12 ; must be saved and restored %define tmp4 r13 ; must be saved and restored %define tmp5 r14 ; must be saved and restored %define tmp6 r15 ; must be saved and restored %define return rax %define func(x) x: %macro FUNC_SAVE 0 push r12 push r13 push r14 push r15 %endmacro %macro FUNC_RESTORE 0 pop r15 pop r14 pop r13 pop r12 %endmacro %else ; Windows %define arg0 rcx %define arg1 rdx %define arg2 r8 %define arg3 r9 %define arg4 r10 %define arg5 r11 %define tmp1 r12 ; must be saved and restored %define tmp2 r13 ; must be saved and restored %define tmp3 r14 ; must be saved and restored %define tmp4 r15 ; must be saved and restored %define tmp5 rdi ; must be saved and restored %define tmp6 rsi ; must be saved and restored %define return rax %define stack_size 10*16 + 7*8 ; must be an odd multiple of 8 %define func(x) proc_frame x %macro FUNC_SAVE 0 alloc_stack stack_size save_xmm128 xmm6, 0*16 save_xmm128 xmm7, 1*16 save_xmm128 xmm8, 2*16 save_xmm128 xmm9, 3*16 save_xmm128 xmm10, 4*16 save_xmm128 xmm11, 5*16 save_xmm128 xmm12, 6*16 save_xmm128 xmm13, 7*16 save_xmm128 xmm14, 8*16 save_xmm128 xmm15, 9*16 save_reg r12, 10*16 + 0*8 save_reg r13, 10*16 + 1*8 save_reg r14, 10*16 + 2*8 save_reg r15, 10*16 + 3*8 save_reg rdi, 10*16 + 4*8 save_reg rsi, 10*16 + 5*8 end_prolog %endmacro %macro FUNC_RESTORE 0 movdqa xmm6, [rsp + 0*16] movdqa xmm7, [rsp + 1*16] movdqa xmm8, [rsp + 2*16] movdqa xmm9, [rsp + 3*16] movdqa xmm10, [rsp + 4*16] movdqa xmm11, [rsp + 5*16] movdqa xmm12, [rsp + 6*16] movdqa xmm13, [rsp + 7*16] movdqa xmm14, [rsp + 8*16] movdqa xmm15, [rsp + 9*16] mov r12, [rsp + 10*16 + 0*8] mov r13, [rsp + 10*16 + 1*8] mov r14, [rsp + 10*16 + 2*8] mov r15, [rsp + 10*16 + 3*8] mov rdi, [rsp + 10*16 + 4*8] mov rsi, [rsp + 10*16 + 5*8] add rsp, stack_size %endmacro %endif ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %define loops arg3 ;variables of mh_sha1 %define mh_in_p arg0 %define mh_digests_p arg1 %define mh_data_p arg2 %define mh_segs tmp1 ;variables used by storing segs_digests on stack %define RSP_SAVE tmp2 %define FRAMESZ 4*5*16 ;BYTES*DWORDS*SEGS %define pref tmp3 %macro PREFETCH_X 1 %define %%mem %1 prefetchnta %%mem %endmacro ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %define VMOVPS vmovups %define A xmm0 %define B xmm1 %define C xmm2 %define D xmm3 %define E xmm4 %define F xmm5 ; tmp %define G xmm6 ; tmp %define TMP G %define FUN F %define K xmm7 %define AA xmm8 %define BB xmm9 %define CC xmm10 %define DD xmm11 %define EE xmm12 %define T0 xmm6 %define T1 xmm7 %define T2 xmm8 %define T3 xmm9 %define T4 xmm10 %define T5 xmm11 %macro ROTATE_ARGS 0 %xdefine TMP_ E %xdefine E D %xdefine D C %xdefine C B %xdefine B A %xdefine A TMP_ %endm %define W14 xmm13 %define W15 xmm14 %define W16 xmm15 %macro ROTATE_W 0 %xdefine TMP_ W16 %xdefine W16 W15 %xdefine W15 W14 %xdefine W14 TMP_ %endm ;init hash digests ; segs_digests:low addr-> high_addr ; a | b | c | ...| p | (16) ; h0 | h0 | h0 | ...| h0 | | Aa| Ab | Ac |...| Ap | ; h1 | h1 | h1 | ...| h1 | | Ba| Bb | Bc |...| Bp | ; .... ; h4 | h4 | h4 | ...| h4 | | Ea| Eb | Ec |...| Ep | align 32 ;void mh_sha1_block_avx(const uint8_t * input_data, uint32_t digests[SHA1_DIGEST_WORDS][HASH_SEGS], ; uint8_t frame_buffer[MH_SHA1_BLOCK_SIZE], uint32_t num_blocks); ; arg 0 pointer to input data ; arg 1 pointer to digests, include segments digests(uint32_t digests[16][5]) ; arg 2 pointer to aligned_frame_buffer which is used to save the big_endian data. ; arg 3 number of 1KB blocks ; global mh_sha1_block_avx:function internal func(mh_sha1_block_avx) FUNC_SAVE ; save rsp mov RSP_SAVE, rsp cmp loops, 0 jle .return ; leave enough space to store segs_digests sub rsp, FRAMESZ ; align rsp to 16 Bytes needed by avx and rsp, ~0x0F %assign I 0 ; copy segs_digests into stack %rep 5 VMOVPS A, [mh_digests_p + I*64 + 16*0] VMOVPS B, [mh_digests_p + I*64 + 16*1] VMOVPS C, [mh_digests_p + I*64 + 16*2] VMOVPS D, [mh_digests_p + I*64 + 16*3] vmovdqa [rsp + I*64 + 16*0], A vmovdqa [rsp + I*64 + 16*1], B vmovdqa [rsp + I*64 + 16*2], C vmovdqa [rsp + I*64 + 16*3], D %assign I (I+1) %endrep .block_loop: ;transform to big-endian data and store on aligned_frame vmovdqa F, [PSHUFFLE_BYTE_FLIP_MASK] ;transform input data from DWORD*16_SEGS*5 to DWORD*4_SEGS*5*4 %assign I 0 %rep 16 VMOVPS T0,[mh_in_p + I*64+0*16] VMOVPS T1,[mh_in_p + I*64+1*16] VMOVPS T2,[mh_in_p + I*64+2*16] VMOVPS T3,[mh_in_p + I*64+3*16] vpshufb T0, F vmovdqa [mh_data_p +(I)*16 +0*256],T0 vpshufb T1, F vmovdqa [mh_data_p +(I)*16 +1*256],T1 vpshufb T2, F vmovdqa [mh_data_p +(I)*16 +2*256],T2 vpshufb T3, F vmovdqa [mh_data_p +(I)*16 +3*256],T3 %assign I (I+1) %endrep mov mh_segs, 0 ;start from the first 4 segments mov pref, 1024 ;avoid prefetch repeadtedly .segs_loop: ;; Initialize digests vmovdqa A, [rsp + 0*64 + mh_segs] vmovdqa B, [rsp + 1*64 + mh_segs] vmovdqa C, [rsp + 2*64 + mh_segs] vmovdqa D, [rsp + 3*64 + mh_segs] vmovdqa E, [rsp + 4*64 + mh_segs] vmovdqa AA, A vmovdqa BB, B vmovdqa CC, C vmovdqa DD, D vmovdqa EE, E ;; ;; perform 0-79 steps ;; vmovdqa K, [K00_19] ;; do rounds 0...15 %assign I 0 %rep 16 SHA1_STEP_00_15 A,B,C,D,E, TMP,FUN, I, K, MAGIC_F0, mh_data_p ROTATE_ARGS %assign I (I+1) %endrep ;; do rounds 16...19 vmovdqa W16, [mh_data_p + ((16 - 16) & 15) * 16] vmovdqa W15, [mh_data_p + ((16 - 15) & 15) * 16] %rep 4 SHA1_STEP_16_79 A,B,C,D,E, TMP,FUN, I, K, MAGIC_F0, mh_data_p ROTATE_ARGS %assign I (I+1) %endrep PREFETCH_X [mh_in_p + pref+128*0] ;; do rounds 20...39 vmovdqa K, [K20_39] %rep 20 SHA1_STEP_16_79 A,B,C,D,E, TMP,FUN, I, K, MAGIC_F1, mh_data_p ROTATE_ARGS %assign I (I+1) %endrep ;; do rounds 40...59 vmovdqa K, [K40_59] %rep 20 SHA1_STEP_16_79 A,B,C,D,E, TMP,FUN, I, K, MAGIC_F2, mh_data_p ROTATE_ARGS %assign I (I+1) %endrep PREFETCH_X [mh_in_p + pref+128*1] ;; do rounds 60...79 vmovdqa K, [K60_79] %rep 20 SHA1_STEP_16_79 A,B,C,D,E, TMP,FUN, I, K, MAGIC_F3, mh_data_p ROTATE_ARGS %assign I (I+1) %endrep vpaddd A, AA vpaddd B, BB vpaddd C, CC vpaddd D, DD vpaddd E, EE ; write out digests vmovdqa [rsp + 0*64 + mh_segs], A vmovdqa [rsp + 1*64 + mh_segs], B vmovdqa [rsp + 2*64 + mh_segs], C vmovdqa [rsp + 3*64 + mh_segs], D vmovdqa [rsp + 4*64 + mh_segs], E add pref, 256 add mh_data_p, 256 add mh_segs, 16 cmp mh_segs, 64 jc .segs_loop sub mh_data_p, (1024) add mh_in_p, (1024) sub loops, 1 jne .block_loop %assign I 0 ; copy segs_digests back to mh_digests_p %rep 5 vmovdqa A, [rsp + I*64 + 16*0] vmovdqa B, [rsp + I*64 + 16*1] vmovdqa C, [rsp + I*64 + 16*2] vmovdqa D, [rsp + I*64 + 16*3] VMOVPS [mh_digests_p + I*64 + 16*0], A VMOVPS [mh_digests_p + I*64 + 16*1], B VMOVPS [mh_digests_p + I*64 + 16*2], C VMOVPS [mh_digests_p + I*64 + 16*3], D %assign I (I+1) %endrep mov rsp, RSP_SAVE ; restore rsp .return: FUNC_RESTORE ret endproc_frame section .data align=16 align 16 PSHUFFLE_BYTE_FLIP_MASK: dq 0x0405060700010203, 0x0c0d0e0f08090a0b K00_19: dq 0x5A8279995A827999, 0x5A8279995A827999 K20_39: dq 0x6ED9EBA16ED9EBA1, 0x6ED9EBA16ED9EBA1 K40_59: dq 0x8F1BBCDC8F1BBCDC, 0x8F1BBCDC8F1BBCDC K60_79: dq 0xCA62C1D6CA62C1D6, 0xCA62C1D6CA62C1D6
/* * 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 (8|M0) acc0.0<1>:w 0x24060000:v add (8|M0) acc0.0<1>:w acc0.0<8;8,1>:w 0x1C:uw shl (4|M0) r22.4<1>:w acc0.4<4;4,1>:w 0x5:uw mov (1|M0) f0.0<1>:uw r24.0<0;1,0>:ub (W&~f0.0)jmpi L672 L80: mov (8|M0) r16.0<1>:ud r0.0<8;8,1>:ud 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 (1|M0) r16.2<1>:ud 0xE000:ud add (1|M0) a0.0<1>:ud r24.5<0;1,0>:ud 0x43EA100:ud (~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.1<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r9.4<0;1,0>:f send (1|M0) r28:uw r16:ub 0x2 a0.0 add (1|M0) a0.0<1>:ud r24.5<0;1,0>:ud 0x43EA102:ud send (1|M0) r30:uw r16:ub 0x2 a0.0 add (1|M0) a0.0<1>:ud r24.5<0;1,0>:ud 0x43EA100:ud (~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 (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) r37:uw r16:ub 0x2 a0.0 add (1|M0) a0.0<1>:ud r24.5<0;1,0>:ud 0x43EA102:ud send (1|M0) r39: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.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.1<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r9.4<0;1,0>:f send (1|M0) r32: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.7<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) r41:uw r16:ub 0x2 a0.0 mov (1|M0) a0.8<1>:uw 0x380:uw mov (1|M0) a0.11<1>:uw 0x3C0:uw mov (1|M0) a0.9<1>:uw 0x400:uw mov (1|M0) a0.10<1>:uw 0x440:uw add (4|M0) a0.12<1>:uw a0.8<4;4,1>:uw 0x120:uw L672: nop
; =============================================================== ; Jun 2007 ; =============================================================== ; ; void *zx_aaddrcup(void *aaddr) ; ; Modify attribute address to move up one character square. ; ; =============================================================== SECTION code_arch PUBLIC asm_zx_aaddrcup asm_zx_aaddrcup: ; enter : hl = attribute address ; ; exit : hl = attribute address up one character ; carry set if new attribute address is off screen ; ; uses : af, hl ld a,l sub $20 ld l,a ret nc dec h ld a,h cp $58 ret
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Stubs Written by D Morris - 30/9/98 ; ; ; $Id: drawto.asm,v 1.8 2016-07-02 09:01:35 dom Exp $ ; ;Usage: drawto(struct *pixels) SECTION code_clib PUBLIC drawto PUBLIC _drawto EXTERN swapgfxbk EXTERN __graphics_end EXTERN __gfx_coords EXTERN Line EXTERN plotpixel .drawto ._drawto push ix ld ix,2 add ix,sp ld hl,(__gfx_coords) ld e,(ix+2) ;y ld d,(ix+4) ;x call swapgfxbk ld ix,plotpixel call Line jp __graphics_end
CGROUP group code code segment dword 'CODE' assume cs:CGROUP,ds:CGROUP public pj_tnskip ;pj_tnskip(Pixel *s1,Pixel *s2,int bcount,int mustmatch); pj_tnskip proc near tnkp struc ;pj_tnskip parameter structure tnk_ebp dd ? tnk_ret dd ? ;return address for function tnk_s1 dd ? ;1st parameter tnk_s2 dd ? tnk_bcount dd ? tnk_mustmatch dd ? tnkp ends push ebp mov ebp,esp sub esp,4 ;space for local below difcount equ dword ptr[ebp-4] push ebx push ecx push edx push esi push edi mov difcount,0 ;zero out return value mov esi,[ebp].tnk_s1 mov edi,[ebp].tnk_s2 mov ebx,[ebp].tnk_bcount mov edx,[ebp].tnk_mustmatch tnsloop: ;calculate number of pixels different in s1 and s2 into ax mov ecx,ebx inc ecx repne cmpsb mov eax,ebx sub eax,ecx dec esi ;move source pointers just past this different run dec edi sub ebx,eax add difcount,eax ;and different count to return value cmp ebx,edx ;see if near the end... js endcheck ;see if enough in a row match to break out of this mov ecx,edx repe cmpsb jz ztnskip ;if all of them match between s1 and s2 go home inc ecx mov eax,edx ;calc ones that do match into ax sub eax,ecx add difcount,eax ;add it to difcount return value sub ebx,eax ;sub it from pixels left to examine dec esi ;update s1,s2 pointers dec edi jmp tnsloop endcheck: ;check last couple of pixels mov ecx,ebx inc ecx repe cmpsb jcxz ztnskip ;if all of them match between s1 and s2 go home add difcount,ebx ;otherwise assume no skip this time around ztnskip: mov eax,difcount pop edi pop esi pop edx pop ecx pop ebx mov esp,ebp pop ebp ret pj_tnskip endp public pj_tnsame ;pj_tnsame(Pixel *s2x,int bcount,int mustmatch); pj_tnsame proc near tnsp struc ;pj_tnskip parameter structure tns_edi dd ? tns_esi dd ? tns_edx dd ? tns_ecx dd ? tns_ebx dd ? tns_ret dd ? ;return address for function tns_s2x dd ? ;1st parameter tns_bcount dd ? tns_mustmatch dd ? tnsp ends push ebx push ecx push edx push esi push edi mov edi,[esp].tns_s2x ;get starting address in es:di mov edx,[esp].tns_bcount ;dx is 'dif_count' return value mov ebx,edx ;bx is # of pixels left mov esi,0 ;si is # of pixels examined alp: ;break out of loop if less than 4 pixels ;left to examine cmp ebx,[esp].tns_mustmatch js zalp ;same_count = pj_bsame(s2x,wcount) mov ecx,ebx mov al,[edi] rep scasb inc cx sub edi,2 mov eax,ebx sub eax,ecx cmp eax,[esp].tns_mustmatch ;if mustmatch or more jns gotsame ;go truncate dif_count add esi,eax add edi,eax sub ebx,eax jmp alp gotsame: mov edx,esi zalp: mov eax,edx ;return dif_count pop edi pop esi pop edx pop ecx pop ebx ret pj_tnsame endp code ends end
; A230929: Number of black-square subarrays of (n+2) X (2+2) 0..3 arrays x(i,j) with each element diagonally or antidiagonally next to at least one element with value (x(i,j)+1) mod 4, no adjacent elements equal, and upper left element zero. ; 2,6,16,48,146,438,1312,3936,11810,35430,106288,318864,956594,2869782,8609344,25828032,77484098,232452294,697356880,2092070640,6276211922,18828635766,56485907296,169457721888,508373165666,1525119496998,4575358490992,13726075472976,41178226418930,123534679256790,370604037770368,1111812113311104,3335436339933314 mov $1,9 mov $2,3 pow $2,$0 add $2,5 mul $1,$2 div $1,10 sub $1,4 mul $1,2
; A033648: Trajectory of 3 under map x->x + (x-with-digits-reversed). ; Submitted by Jon Maiga ; 3,6,12,33,66,132,363,726,1353,4884,9768,18447,92928,175857,934428,1758867,9447438,17794887,96644658,182289327,906271608,1712444217,8836886388,17673772776,85401510447,159803020905,668823329856,1327746658722,3606313135953,7201626272016,13304352533043,47337877873374,94675755746748,179440511504397,972845626549368,1836791253097647,9304694775074028,17509400550038067,93592406050528638,177274911110958177,949133922230430948,1798167954459762897,9780847499057381868,18462685009004862747 mov $2,$0 lpb $2 mov $0,$1 add $0,3 seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences). add $1,$0 sub $2,1 lpe mov $0,$1 add $0,3
; A176631: Triangle T(n, k) = 22^(k*(n-k)), read by rows. ; 1,1,1,1,22,1,1,484,484,1,1,10648,234256,10648,1,1,234256,113379904,113379904,234256,1,1,5153632,54875873536,1207269217792,54875873536,5153632,1,1,113379904,26559922791424,12855002631049216,12855002631049216,26559922791424,113379904,1 seq $0,4247 ; Multiplication table read by antidiagonals: T(i,j) = ij (i>=0, j>=0). mov $1,22 pow $1,$0 mov $0,$1
version https://git-lfs.github.com/spec/v1 oid sha256:b8e079e49b398b576190d3de4a497e00b2e15d1db8e7b244df7a9b2b943e8944 size 3907
global install_new_module global install_replace_module extern module_binary include "../include/spectranet.inc" include "../include/sysvars.inc" STR_install_message: defb "Installing Spectranet Search Index...\n", 0 STR_install_fail: defb "Failed!\n", 0 install_replace_module: ld (v_workspace), a and 0xFC ; mask out bottom two bits to find ld (v_workspace + 1), a ; the sector, store it for later call F_copysectortoram ; copy the flash sector ld a, (v_workspace) ; calculate the RAM page to use and 0x03 ; get position in the sector add a, 0xDC ; add RAM page number call SETPAGEA ld hl, module_binary ld de, 0x1000 ld bc, 0x1000 ldir ld a, (v_workspace + 1) ; retrieve sector page di call F_FlashEraseSector ld a, (v_workspace + 1) call F_writesector ; write the new contents of RAM ei ld hl, STR_install_message call PRINT42 ret ; F_copysectortoram ; Copies 4 pages of flash to RAM. ; Parameter: A = first page. F_copysectortoram: ex af, af' ; save ROM page ld a, 0xDC ; first RAM page ld b, 4 ; pages to copy copyloop14: push bc call SETPAGEB ; RAM into area B inc a ex af, af' ; ROM page into A call SETPAGEA ; page it in inc a ex af, af' ; for the next iteration. ld hl, 0x1000 ; copy the page ld de, 0x2000 ld bc, 0x1000 ldir pop bc djnz copyloop14 ret install_new_module: ld hl, STR_install_message call PRINT42 call F_findfirstfreepage jp c, install_module_failed call SETPAGEB ld hl, module_binary ld de, 0x2000 ld bc, 0x1000 call F_FlashWriteBlock jp c, install_module_failed ret install_module_failed: ld hl, STR_install_fail call PRINT42 ret F_findfirstfreepage: ld a, 0x04 loop3: call SETPAGEB ex af, af' ld a, (0x2000) cp 0xFF ; FF = free page jr z, found3 ex af, af' cp 0x1F ; Last page? jr z, nospace3 inc a jr loop3 nospace3: scf ret found3: ex af, af' and a ; make sure carry is reset ret ;--------------------------------------------------------------------------- ; F_FlashEraseSector ; Simple flash writer for the Am29F010 (and probably any 1 megabit flash ; with 16kbyte sectors) ; ; Parameters: A = page to erase (based on 4k Spectranet pages, but ; erases a 16k sector) ; Carry flag is set if an error occurs. F_FlashEraseSector: ; Page in the appropriate sector first 4k into page area B. ; Page to start the erase from is in A. call SETPAGEB ; page into page area B ld a, 0xAA ; unlock code 1 ld (0x555), a ; unlock addr 1 ld a, 0x55 ; unlock code 2 ld (0x2AA), a ; unlock addr 2 ld a, 0x80 ; erase cmd 1 ld (0x555), a ; erase cmd addr 1 ld a, 0xAA ; erase cmd 2 ld (0x555), a ; erase cmd addr 2 ld a, 0x55 ; erase cmd 3 ld (0x2AA), a ; erase cmd addr 3 ld a, 0x30 ; erase cmd 4 ld (0x2000), a ; erase sector address ld hl, 0x2000 wait1: bit 7, (hl) ; test DQ7 - should be 1 when complete jr nz, complete1 bit 5, (hl) ; test DQ5 - should be 1 to continue jr z, wait1 bit 7, (hl) ; test DQ7 again jr z, borked1 complete1: or 0 ; clear carry flag ret borked1: scf ; carry flag = error ret ;--------------------------------------------------------------------------- ; F_FlashWriteBlock ; Copies a block of memory to flash. The flash should be mapped into ; page area B. ; Parameters: HL = source start address ; DE = destination start address ; BC = number of bytes to copy ; On error, the carry flag is set. F_FlashWriteBlock: ld a, (hl) ; get byte to write call F_FlashWriteByte ret c ; on error, return immediately inc hl ; point at next source address inc de ; point at next destination address dec bc ; decrement byte count ld a, b or c ; is it zero? jr nz, F_FlashWriteBlock ret ;--------------------------------------------------------------------------- ; F_FlashWriteByte ; Writes a single byte to the flash memory. ; Parameters: DE = address to write ; A = byte to write ; On return, carry flag set = error ; Page the appropriate flash area into one of the paging areas to write to ; it, and the address should be in that address space. F_FlashWriteByte: push bc ld c, a ; save A ld a, 0xAA ; unlock 1 ld (0x555), a ; unlock address 1 ld a, 0x55 ; unlock 2 ld (0x2AA), a ; unlock address 2 ld a, 0xA0 ; Program ld (0x555), a ; Program address ld a, c ; retrieve A ld (de), a ; program it wait3: ld a, (de) ; read programmed address ld b, a ; save status xor c bit 7, a ; If bit 7 = 0 then bit 7 = data jr z, byteComplete3 bit 5, b ; test DQ5 jr z, wait3 ld a, (de) ; read programmed address xor c bit 7, a ; Does DQ7 = programmed data? 0 if true jr nz, borked3 byteComplete3: pop bc or 0 ; clear carry flag ret borked3: pop bc scf ; error = set carry flag ret ;--------------------------------------------------------------------------- ; F_writesector ; Writes 4 pages from the last 4 pages of RAM to flash, starting at the ; page specified in A F_writesector: ex af, af' ; swap with alternate set ld a, 0xDC ; RAM page 0xDC ld b, 4 ; number of pages loop4: push bc call SETPAGEA ; Page into area A inc a ; next page ex af, af' ; get flash page to program call SETPAGEB inc a ; next page ex af, af' ; back to ram page for next iteration ld hl, 0x1000 ld de, 0x2000 ld bc, 0x1000 push af call F_FlashWriteBlock jr c, failed4 ; restore stack and exit pop af pop bc djnz loop4 ; next page ret failed4: ; restore stack, set carry flag pop af pop bc scf ret
;============================================================================= ; @file loader.asm ; ; A second-stage boot loader suitable for an El Torito ISO 9660 cdrom image. ; ; This boot loader is executed after the first stage loader completes. Its ; responsibility is to load the kernel into memory, place the CPU into ; protected mode, then into 64-bit mode, and to start the kernel's execution. ; ; This loader allows for kernel images that are several megabytes in size. ; Making this possible was a bit tricky. 16-bit real mode is required to use ; the BIOS routines that load the kernel image from cdrom, but you can only ; use about 600KiB of memory while in real mode. So this loader switches ; between real mode and 32-bit protected mode while transferring chunks of the ; kernel image from lower to upper memory. ; ; Copyright 2016 Brett Vickers. ; Use of this source code is governed by a BSD-style license that can ; be found in the MonkOS LICENSE file. ;============================================================================= ; The second-stage boot loader starts in 16-bit real mode. bits 16 ; The second-stage loader is executed from code segment 0, starting at address ; 0x8000. org 0x8000 ; Produce a map file containing all symbols and sections. [map all ../build/boot/loader.map] ; Include constants, structures, and macros. %include "include/mem.inc" ; Memory layout constants %include "include/globals.inc" ; Global variable definitions %include "include/bios.inc" ; BIOS structures %include "include/iso9660.inc" ; ISO9660 structures %include "include/gdt.inc" ; Global descriptor table structures ;============================================================================= ; load ; ; This is the second stage loader's entry point. ; ; This code is launched by the first-stage loader and runs in 16-bit real mode ; starting at address 0:0x8000. ; ; Memory layout before this code starts running: ; ; 00000000 - 000003ff 1,024 bytes Real mode IVT ; 00000400 - 000004ff 256 bytes BIOS data area ; 00000500 - 000006ff 512 bytes Global variables ; 00000700 - 00007bff 29,952 bytes Free ; 00007c00 - 00007dff 512 bytes First-stage boot loader (MBR) ; 00007e00 - 00097fff 512 bytes Free ; 00008000 - 0000ffff 32,768 bytes Second-stage boot loader ; 00010000 - 0009fbff 588,800 bytes Free ; 0009fc00 - 0009ffff 1,024 bytes Extended BIOS data area (EBDA) ; 000a0000 - 000bffff 131,072 bytes BIOS video memory ; 000c0000 - 000fffff 262,144 bytes ROM ; ; [ See http://wiki.osdev.org/Memory_Map_(x86) ] ; ; Memory regions used or modified by this code: ; ; 00000800 - 00000fff 2,048 bytes Cdrom sector read buffer ; 00003000 - 000030ff 256 bytes Global Descriptor Table (GDT) ; 00003100 - 000031ff 256 bytes Task State Segment (TSS) ; 00003200 - 00003fff 3,584 bytes Global variables ; 00004000 - 00007bff 16,384 bytes Real mode stack ; 00010000 - 00017fff 32,768 bytes Page tables ; 0006f000 - 0006ffff 4,096 bytes 32-bit protected mode stack ; 00070000 - 0007ffff 65,536 bytes Kernel load buffer ; 00070000 - 00075fff 24,576 bytes Memory table (from BIOS) ; 0008a000 - 0008ffff 24,576 bytes Kernel special interrupt stacks ; 00100000 - 001fefff 1,044,480 bytes Kernel interrupt stack ; 00200000 - 002fffff 1,048,576 bytes Kernel stack ; 00300000 - (krnize) Kernel image ; ;============================================================================= load: .init: ; Disable interrupts while updating segment registers and stack ; pointer. cli ; Initialize all segment registers to zero. xor ax, ax mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax ; Initialize the stack pointer. mov sp, Mem.Stack.Top ; Clear all remaining general purpose registers. xor bx, bx xor cx, cx xor dx, dx xor si, si xor di, di xor bp, bp ;------------------------------------------------------------------------- ; Enable the A20 address line for upper memory access ;------------------------------------------------------------------------- .enableA20: ; Attempt to enable the A20 line if necessary. call EnableA20 jnc .error.A20 ; Display a status message. mov si, String.Status.A20Enabled call DisplayStatusString ;------------------------------------------------------------------------- ; Make sure we have a 64-bit CPU ;------------------------------------------------------------------------- .detect64BitMode: ; Detect if the cpuid instruction is available. call HasCPUID jnc .error.noCPUID ; Is the processor info function supported? mov eax, 0x80000000 ; Get Highest Extended Function Supported cpuid cmp eax, 0x80000001 jb .error.no64BitMode ; Use processor info function to see if 64-bit mode is supported. mov eax, 0x80000001 ; Extended Processor Info and Feature Bits cpuid test edx, (1 << 29) ; 64-bit mode bit jz .error.no64BitMode ; Clear 32-bit register values. xor eax, eax xor edx, edx ; Display a status message. mov si, String.Status.CPU64Detected call DisplayStatusString ;------------------------------------------------------------------------- ; Enable SSE on the CPU ;------------------------------------------------------------------------- .enableSSE: ; Load CPU feature flags into ecx and edx. mov eax, 1 cpuid ; Check for FXSAVE/FXRSTOR support. test edx, (1 << 24) jz .error.noFXinst ; Check for SSE1 support. test edx, (1 << 25) jz .error.noSSE ; Check for SSE2 support. test edx, (1 << 26) jz .error.noSSE2 ; Enable hardware FPU with monitoring. mov eax, cr0 and eax, ~(1 << 2) ; turn off CR0.EM bit (x87 FPU is present) or eax, (1 << 1) ; turn on CR0.MP bit (monitor FPU) mov cr0, eax ; Make sure FXSAVE/FXRSTOR instructions save the contents of the FPU ; MMX, XMM and MXCSR registers. Enable the use of SSE instructions. ; And indicate that the kernel is capable of handling SIMD floating- ; point exceptions. mov eax, cr4 or eax, (1 << 9) | (1 << 10) ; CR4.OFXSR, CR4.OSXMMEXCPT mov cr4, eax ; Display a status message. mov si, String.Status.SSEEnabled call DisplayStatusString ;------------------------------------------------------------------------- ; Load the kernel image into upper memory ;------------------------------------------------------------------------- .loadKernel: ; Enable interrupts while loading the kernel. sti ; Use a temporary GDT while loading the kernel, since we use 32-bit ; protected mode during the load. lgdt [GDT32.Table.Pointer] ; Find the first sector and size of the kernel, with results in bx and ; eax. call FindKernel jc .error.kernelNotFound ; Display a status message. mov si, String.Status.KernelFound call DisplayStatusString ; Start loading the kernel into memory. call LoadKernel jc .error.kernelLoadFailed ; Display a status message. mov si, String.Status.KernelLoaded call DisplayStatusString ; Disable interrupts and leave them disabled until the kernel ; launches. The kernel is responsible for setting up the interrupt ; controllers and tables before re-enabling interrupts. cli ;------------------------------------------------------------------------- ; Retrieve memory layout from the BIOS ;------------------------------------------------------------------------- .readLayout: ; Use the BIOS to collect an array of memory ranges available and in ; use. call ReadMemLayout ;------------------------------------------------------------------------- ; Wipe memory zones that the loaders used ;------------------------------------------------------------------------- .wipeMemory: cld push es ; Wipe the real mode BIOS IVT. xor ax, ax mov es, ax xor di, Mem.BIOS.IVT mov cx, Mem.BIOS.IVT.Size rep stosb ; Wipe the real mode BIOS data area. mov di, Mem.BIOS.Data mov cx, Mem.BIOS.Data.Size rep stosb ; Wipe the stage-1 boot loader. mov di, Mem.Loader1 mov cx, Mem.Loader1.Size rep stosb ; Wipe the temporary 32-bit protected mode stack. mov ax, Mem.Stack32.Temp.Bottom >> 4 mov es, ax xor ax, ax xor di, di mov cx, Mem.Stack32.Temp.Top - Mem.Stack32.Temp.Bottom rep stosb ; Restore original es register. pop es ;------------------------------------------------------------------------- ; Set up (but don't yet install) the 64-bit GDT ;------------------------------------------------------------------------- .setupGDT64: ; Copy the GDT to its memory layout location. mov si, GDT64.Table mov di, Mem.GDT mov cx, GDT64.Table.Size shr cx, 1 rep movsw ;------------------------------------------------------------------------- ; Set up (but don't yet install) the 64-bit task state segment ;------------------------------------------------------------------------- .setupTSS: ; Copy the TSS entry to its target memory location. mov si, TSS64.Entry mov di, Mem.TSS64 mov cx, TSS64.Entry.Size shr cx, 1 rep movsw ;------------------------------------------------------------------------- ; Set up page tables ;------------------------------------------------------------------------- .setupPageTables: ; Create page tables that identity-map the first 10MiB of memory. This ; should be more than enough to hold the kernel and its stacks. call SetupPageTables ; Enable PAE paging. mov eax, cr4 or eax, (1 << 5) ; CR4.PAE mov cr4, eax ;------------------------------------------------------------------------- ; Enable 64-bit protected mode and paging ;------------------------------------------------------------------------- .enable64BitMode: ; Enable 64-bit mode and syscall/sysret. mov ecx, 0xc0000080 ; Extended Feature Enable Register (EFER) rdmsr or eax, (1 << 8) | (1 << 0) wrmsr ; Enable paging and protected mode. mov eax, cr0 or eax, (1 << 31) | (1 << 0) ; CR0.PG, CR0.PE mov cr0, eax ; Enable global pages mov eax, cr4 or eax, (1 << 7) ; CR4.PGE mov cr4, eax ; Load the 64-bit GDT. lgdt [GDT64.Table.Pointer] ; Do a long jump using the new GDT, which forces the switch to 64-bit ; mode. jmp GDT64.Selector.Kernel.Code : .launch64 bits 64 ;------------------------------------------------------------------------- ; Launch the 64-bit kernel ;------------------------------------------------------------------------- .launch64: ; Save CPU feature bits into global memory block mov eax, 1 cpuid mov [Globals.CPUFeatureBitsECX], ecx mov [Globals.CPUFeatureBitsEDX], edx ; Wipe the real mode stack. xor eax, eax mov rdi, Mem.Stack.Bottom mov ecx, Mem.Stack.Top - Mem.Stack.Bottom rep stosb ; Load the mandatory 64-bit task state segment. mov ax, GDT64.Selector.TSS ltr ax ; Set up the data segment registers. Note that in 64-bit mode the CPU ; treats cs, ds, es, and ss as zero regardless of what we store there. ; (gs and fs are exceptions; they can be used as real segment ; registers.) mov ax, GDT64.Selector.Kernel.Data mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax ; Set the kernel stack pointer. mov rsp, Mem.Kernel.Stack.Top ; Initialize all general purpose registers. xor rax, rax xor rbx, rbx xor rcx, rcx xor rdx, rdx xor rdi, rdi xor rsi, rsi xor rbp, rbp xor r8, r8 xor r9, r9 xor r10, r10 xor r11, r11 xor r12, r12 xor r13, r13 xor r14, r14 xor r15, r15 ; Do a jump to the kernel's entry point. jmp Mem.Kernel.Code bits 16 ;------------------------------------------------------------------------- ; Error handlers ;------------------------------------------------------------------------- .error.A20: mov si, String.Error.A20 jmp .error .error.noCPUID: mov si, String.Error.NoCPUID jmp .error .error.no64BitMode: mov si, String.Error.No64BitMode jmp .error .error.kernelNotFound: mov si, String.Error.KernelNotFound jmp .error .error.kernelLoadFailed: mov si, String.Error.KernelLoadFailed jmp .error .error.noSSE: mov si, String.Error.NoSSE jmp .error .error.noSSE2: mov si, String.Error.NoSSE2 jmp .error .error.noFXinst: mov si, String.Error.NoFXinst jmp .error .error: call DisplayErrorString .hang: cli hlt jmp .hang ;============================================================================= ; EnableA20 ; ; Enable the A20 address line, so memory above 1MiB can be accessed. ; ; Returned flags: ; CF Set if enabled ; ; Killed registers: ; None ;============================================================================= EnableA20: ; Preserve ax register. push ax ; Check if the A20 line is already enabled. call TestA20 jc .done .attempt1: ; Attempt enabling with the BIOS. mov ax, 0x2401 int 0x15 ; Check if A20 line is now enabled. call TestA20 jc .done .attempt2: ; Attempt enabling with the keyboard controller. call .attempt2.wait1 ; Disable keyboard mov al, 0xad out 0x64, al call .attempt2.wait1 ; Read from input mov al, 0xd0 out 0x64, al call .attempt2.wait2 ; Get keyboard data in al, 0x60 push eax call .attempt2.wait1 ; Write to output mov al, 0xd1 out 0x64, al call .attempt2.wait1 ; Send data pop eax or al, 2 out 0x60, al call .attempt2.wait1 ; Enable keyboard mov al, 0xae out 0x64, al call .attempt2.wait1 ; Check if the A20 line is now enabled. call TestA20 jc .done jmp .attempt3 .attempt2.wait1: in al, 0x64 test al, 2 jnz .attempt2.wait1 ret .attempt2.wait2: in al, 0x64 test al, 1 jz .attempt2.wait2 ret .attempt3: ; Attempt enabling with the FAST A20 feature. in al, 0x92 or al, 2 out 0x92, al xor ax, ax ; Check if A20 line is now enabled. call TestA20 .done: ; Restore register. pop ax ret ;============================================================================= ; TestA20 ; ; Check to see if the A20 address line is enabled. ; ; Return flags: ; CF Set if enabled ; ; Killed registers: ; None ;============================================================================= TestA20: ; Preserve registers. push ds push es pusha ; Initialize return result to "not enabled". clc ; Set es segment register to 0x0000. xor ax, ax mov es, ax ; Set ds segment register to 0xffff. not ax mov ds, ax ; If the A20 line is disabled, then es:di and ds:si will point to the same ; physical memory location due to wrap-around at 1 MiB. ; ; es:di = 0000:0500 = 0x0000 * 16 + 0x0500 = 0x00500 = 0x0500 ; ds:si = ffff:0510 = 0xffff * 16 + 0x0510 = 0x10500 = 0x0500 mov di, 0x0500 mov si, 0x0510 ; Preserve the original values stored at es:di and ds:si. mov ax, [es:di] push ax mov ax, [ds:si] push ax ; Write different values to each logical address. mov byte [es:di], 0x00 mov byte [ds:si], 0xff ; If a store to ds:si changes the value at es:di, then memory wrapped and ; A20 is not enabled. cmp byte [es:di], 0xff ; Restore the original values stored at es:di and ds:si. pop ax mov [ds:si], ax pop ax mov [es:di], ax je .done .enabled: ; Set the carry flag to indicate the A20 line is enabled. stc .done: ; Restore registers. popa pop es pop ds ret ;============================================================================= ; HasCPUID ; ; Detect if the cpu supports the CPUID instruction. ; ; Bit 21 of the EFLAGS register can be modified only if the CPUID instruction ; is supported. ; ; Return flags: ; CF Set if CPUID is supported ; ; Killed registers: ; None ;============================================================================= HasCPUID: ; Preserve registers. push eax push ecx ; Copy flags to eax and ecx. pushfd pop eax mov ecx, eax ; Set flag 21 (the ID bit) xor eax, (1 << 21) push eax popfd ; Copy flags back to eax. If CPUID is supported, bit 21 will still be set. pushfd pop eax ; Restore the original flags from ecx. push ecx popfd ; Initialize the return flag (carry) to unsupported. clc ; If eax and ecx are equal, then flag 21 didn't remain set, and CPUID is ; not supported. xor eax, ecx jz .done ; CPUID is not supported .supported: ; CPUID is supported. stc .done: ; Restore registers. pop ecx pop eax ret ;============================================================================= ; ReadMemLayout ; ; Use the BIOS to read an array of memory regions. Each region is tagged as ; available or in use. ; ; After this procedure is complete, the memory layout will be stored as ; follows, starting at Mem.Table: ; ; <----- 64-bits -----> ; +----------------------+ ; | Zone count | ; +----------------------+ ; | Reserved | ; +----------------------+ ; | Zone #0 base address | ; +----------------------+ ; | Zone #0 size | ; +----------------------+ ; | Zone #0 type | ; +----------------------+ ; | Zone #1 base address | ; +----------------------+ ; | Zone #1 size | ; +----------------------+ ; | Zone #1 type | ; +----------------------+ ; | ... | ; +----------------------+ ; ; The table may be unsorted, and it could contain gaps. It's the ; responsibility of the kernel to clean up this data so that it's more usable. ; ; Killed registers: ; None ;============================================================================= ReadMemLayout: push eax push ebx push ecx push edx push esi push edi push es .init: ; Set the segment register for the location of the memory layout. mov ax, Mem.Table >> 4 mov es, ax xor esi, esi ; si = zone counter mov di, 0x10 ; di = target memory offset ; Initialize the ebx and edx registers for calls to the BIOS memory ; probe function. xor ebx, ebx ; ebx = BIOS call tracking data mov edx, 0x534d4150 ; edx = system map magic number 'SMAP' .readZone: ; Call the BIOS function. mov eax, 0xe820 ; eax = BIOS 15h function mov ecx, 24 ; ecx = Max size of target buffer int 0x15 ; Carry flag indicates error. jc .done ; If only 20 bytes were read (as is typical), pad up to 24 bytes. cmp ecx, 20 jne .nextZone ; Pad with zero. mov dword [es:di + 20], 0 .nextZone: ; Advance the zone counter and target pointer. inc si add di, 0x18 ; ebx will be zero when we're done. cmp ebx, 0 je .done ; Don't overflow the memory layout buffer. cmp si, (Mem.Table.Size - 0x10) / 0x18 jb .readZone .done: ; Store the zone count at the start of the layout. mov eax, esi xor di, di stosd xor eax, eax stosd stosd stosd ; Restore registers and flags. clc pop es pop edi pop esi pop edx pop ecx pop ebx pop eax ret ;============================================================================= ; FindKernel ; ; Scan the root directory of the cdrom for a file called "MONK.SYS". If found, ; return its start sector and file size. ; ; Return registers: ; EAX Kernel file size in bytes ; BX Start sector ; ; Return flags: ; CF Set on error ; ; Killed registers: ; None ;============================================================================= FindKernel: ; Save registers that would otherwise be killed. push cx push dx push si push di ; Obtain the drive number and root directory sector from global variables. ; These were set by the first-stage boot loader. mov dl, [Globals.DriveNumber] mov bx, [Globals.RootDirectorySector] .processSector: ; Load the current directory sector into the buffer. mov cx, 1 ; cx = 1 sector mov di, Mem.Sector.Buffer ; es:di = target buffer call ReadSectors jc .error .processDirEntry: ; Is the entry zero length? If so, we ran out of files in the ; directory. xor ax, ax mov al, [di + ISO.DirectoryEntry.RecordLength] cmp al, 0 je .error ; Is the entry a file (flags & 2 == 0)? test byte [di + ISO.DirectoryEntry.FileFlags], 0x02 jnz .nextDirEntry ; Is the file name the same length as "MONK.SYS;1"? cmp byte [di + ISO.DirectoryEntry.NameLength], \ Kernel.Filename.Length jne .nextDirEntry ; Is the file name "MONK.SYS;1"? push di mov cx, Kernel.Filename.Length mov si, Kernel.Filename add di, ISO.DirectoryEntry.Name cld rep cmpsb pop di je .kernelFound .nextDirEntry: ; Advance to the next directory entry. add di, ax cmp di, Mem.Sector.Buffer + Mem.Sector.Buffer.Size jb .processDirEntry .nextSector: ; Advance to the next directory sector. inc bx jmp .processSector .kernelFound: ; Return starting sector in bx. mov bx, [di + ISO.DirectoryEntry.LocationLBA] ; Return file size in eax. mov eax, [di + ISO.DirectoryEntry.Size] .success: ; Clear carry to indicate success. clc jmp .done .error: ; Set carry to indicate an error. stc .done: ; Restore registers. pop di pop si pop dx pop cx ret ;============================================================================= ; ReadSectors ; ; Read 1 or more 2048-byte sectors from the CDROM using int 13 function 42. ; ; Input registers: ; BX Starting sector LBA ; CX Number of sectors to read ; DL Drive number ; ES:DI Target buffer ; ; Return registers: ; AH Return code from int 13 (42h) BIOS call ; ; Flags: ; CF Set on error ; ; Killed registers: ; AX, SI ;============================================================================= ReadSectors: ; Fill the DAP buffer. mov word [BIOS.DAP.Buffer + BIOS.DAP.ReadSectors], cx mov word [BIOS.DAP.Buffer + BIOS.DAP.TargetBufferOffset], di mov word [BIOS.DAP.Buffer + BIOS.DAP.TargetBufferSegment], es mov word [BIOS.DAP.Buffer + BIOS.DAP.FirstSector], bx ; Load ds:si with the DAP buffer's address. lea si, [BIOS.DAP.Buffer] ; Call int13 BIOS function 42h (extended read sectors from drive). mov ax, 0x4200 int 0x13 ret ;============================================================================= ; LoadKernel ; ; Load the kernel into upper memory. ; ; There are two problems we need to solve: ; ; 1. In real mode, we have access to the BIOS but can only access the ; first megabyte of system memory. ; 2. In protected mode, we can access memory above the first megabyte but ; don't have access to the BIOS. ; ; Since we need the BIOS to read the kernel from the CDROM and we need to load ; it into upper memory, we'll have to switch back and forth between real mode ; and protected mode to do it. ; ; This code repeats the following steps until the kernel is fully copied into ; upper memory: ; ; 1. Use BIOS to read the next 64KiB of the kernel file into a lower ; memory buffer. ; 2. Switch to 32-bit protected mode. ; 3. Copy the 64KiB chunk from the lower memory buffer into the ; appropriate upper memory location. ; 4. Switch back to real mode. ; ; Input registers: ; EAX Size of the kernel file ; BX Start sector of the kernel file ; ; Return flags: ; CF Set on error ; ; Killed registers: ; None ;============================================================================= LoadKernel: ; Preserve registers. push es pusha ; Preserve the real mode stack pointer. mov [LoadKernel.StackPointer], sp ; Retrieve the cdrom disk number. mov dl, [Globals.DriveNumber] ; Save the kernel size. mov [Globals.KernelSize], eax ; Convert kernel size from bytes to sectors (after rounding up). add eax, Mem.Sector.Buffer.Size - 1 shr eax, 11 ; Store status in code memory, since it's hard to use the stack while ; switching between real and protected modes. mov [LoadKernel.CurrentSector], bx add ax, bx mov [LoadKernel.LastSector], ax .loadChunk: ; Set target buffer for the read. mov cx, Mem.Kernel.LoadBuffer >> 4 mov es, cx xor di, di ; Set the number of sectors to read (buffersize / 2048). mov cx, Mem.Kernel.LoadBuffer.Size >> 11 ; Calculate the number of remaining sectors. ; (ax = LastSector, bx = CurrentSector) sub ax, bx ; Are there fewer sectors to read than will fit in the buffer? cmp cx, ax jb .proceed ; Don't read more sectors than are left. mov cx, ax .proceed: ; Store the number of sectors being loaded, so we can access it in ; protected mode when we do the copy to upper memory. mov [LoadKernel.SectorsToCopy], cx ; Read a chunk of the kernel into the buffer. call ReadSectors jc .errorReal .prepareProtected32Mode: ; Disable interrupts until we're out of protected mode and back into ; real mode, since we're not setting up a new interrupt table. cli ; Enable protected mode. mov eax, cr0 or eax, (1 << 0) ; CR.PE mov cr0, eax ; Do a far jump to switch to 32-bit protected mode. jmp GDT32.Selector.Code32 : .switchToProtected32Mode bits 32 .switchToProtected32Mode: ; Initialize all data segment registers with the 32-bit protected mode ; data segment selector. mov ax, GDT32.Selector.Data32 mov ds, ax mov es, ax mov ss, ax ; Create a temporary stack used only while in protected mode. ; (probably not necessary since interrupts are disabled) mov esp, Mem.Stack32.Temp.Top .copyChunk: ; Set up a copy from lower memory to upper memory using the number of ; sectors. xor ecx, ecx xor esi, esi xor edi, edi mov bx, [LoadKernel.SectorsToCopy] mov cx, bx shl ecx, 11 ; multiply by sector size (2048) mov esi, Mem.Kernel.LoadBuffer mov edi, [LoadKernel.TargetPointer] ; Advance counters and pointers. add [LoadKernel.TargetPointer], ecx add [LoadKernel.CurrentSector], bx ; Copy the chunk. cld shr ecx, 2 ; divide by 4 since we're copying dwords. rep movsd .prepareProtected16Mode: ; Before we can switch back to real mode, we have to switch to ; 16-bit protected mode. jmp GDT32.Selector.Code16 : .switchToProtected16Mode bits 16 .switchToProtected16Mode: ; Initialize all data segment registers with the 16-bit protected mode ; data segment selector. mov ax, GDT32.Selector.Data16 mov ds, ax mov es, ax mov ss, ax .prepareRealMode: ; Disable protected mode. mov eax, cr0 and eax, ~(1 << 0) ; CR0.PE mov cr0, eax ; Do a far jump to switch back to real mode. jmp 0x0000 : .switchToRealMode .switchToRealMode: ; Restore real mode data segment registers. xor ax, ax mov ds, ax mov es, ax mov ss, ax ; Restore the real mode stack pointer. xor esp, esp mov sp, [LoadKernel.StackPointer] ; Enable interrupts again. sti .checkCompletion: ; Check if the copy is complete. mov ax, [LoadKernel.LastSector] mov bx, [LoadKernel.CurrentSector] cmp ax, bx je .success ; Proceed to the next chunk. jmp .loadChunk .errorReal: ; Set carry flag on error. stc jmp .done .success: ; Clear carry on success. clc .done: ; Wipe the sector load buffer. mov ax, Mem.Kernel.LoadBuffer >> 4 mov es, ax xor ax, ax xor di, di mov cx, Mem.Kernel.LoadBuffer.Size - 1 rep stosb inc cx stosb ; Clear upper word of 32-bit registers we used. xor eax, eax xor ecx, ecx xor esi, esi xor edi, edi ; Restore registers. popa pop es ret ;----------------------------------------------------------------------------- ; LoadKernel state variables ;----------------------------------------------------------------------------- align 4 LoadKernel.TargetPointer dd Mem.Kernel.Image LoadKernel.CurrentSector dw 0 LoadKernel.LastSector dw 0 LoadKernel.SectorsToCopy dw 0 LoadKernel.StackPointer dw 0 ;============================================================================= ; SetupPageTables ; ; Set up a page table for 64-bit mode. ; ; This procedure creates an identity-mapped page table for the first 10MiB of ; physical memory. ; ; Killed registers: ; None ;============================================================================= SetupPageTables: ; Constants for page table bits .Present equ 1 << 0 .ReadWrite equ 1 << 1 .WriteThru equ 1 << 3 .CacheDisable equ 1 << 4 .AttribTable equ 1 << 7 ; valid only on PT entries .LargePage equ 1 << 7 ; valid only on PDT entries .Guard equ 1 << 9 ; use a bit ignored by the CPU .StdBits equ .Present | .ReadWrite ; Preserve registers pusha push es ; Set segment to the root of the page table. mov ax, Mem.PageTable >> 4 mov es, ax .clearMemory: ; Clear all memory used to hold the page tables. cld xor eax, eax xor edi, edi mov ecx, (Mem.PageTable.End - Mem.PageTable) >> 2 rep stosd .makeTables: ; PML4T entry 0 points to the PDPT. mov di, Mem.PageTable.PML4T & 0xffff mov dword [es:di], Mem.PageTable.PDPT | .StdBits ; PDPT entry 0 points to the PDT. mov di, Mem.PageTable.PDPT & 0xffff mov dword [es:di], Mem.PageTable.PDT | .StdBits ; PDT entry 0 maps the first 2MiB using 4KiB pages. mov di, Mem.PageTable.PDT & 0xffff mov dword [es:di + 0x00], Mem.PageTable.PT | .StdBits ; PDT entries 1 through 5 map the next 8MiB using 2MiB pages. ; This memory holds the kernel image and its stack. mov dword [es:di + 0x08], 0x00200000 | .StdBits | .LargePage mov dword [es:di + 0x10], 0x00400000 | .StdBits | .LargePage mov dword [es:di + 0x18], 0x00600000 | .StdBits | .LargePage mov dword [es:di + 0x20], 0x00800000 | .StdBits | .LargePage ; Prepare to create 4K-page table entries for the first 2MiB. mov di, Mem.PageTable.PT & 0xffff mov eax, .StdBits mov cx, 512 ; 512 entries in first page covering 2MiB .makePage: ; Loop through each page table entry, incrementing the physical ; address by one page each time. mov [es:di], eax ; store physical address + .StdBits add eax, 0x1000 ; next physical address add di, 8 ; next page table entry loop .makePage .makeStackGuardPages: ; Create a 4KiB guard page just below the bottom of the kernel stack. ; This way, if the kernel overflows its stack, we'll get a page fault. ; (Note that this guard page resides within the first 2MiB of memory, ; which is necessary because we use 2MiB pages above 2MiB.) mov edi, Mem.Kernel.Stack.Bottom - 4096 call .makeGuard ; Create a guard page at the bottom of each interrupt stack. mov edi, Mem.Kernel.Stack.Interrupt.Bottom call .makeGuard mov edi, Mem.Kernel.Stack.NMI.Bottom call .makeGuard mov edi, Mem.Kernel.Stack.DF.Bottom call .makeGuard mov edi, Mem.Kernel.Stack.MC.Bottom call .makeGuard .markUncachedPages: ; Mark the 32 pages covering video and ROM memory (a0000..bffff) as ; uncacheable. mov edi, Mem.Video mov cx, 32 call .makeUncached .initPageRegister: ; CR3 is the page directory base register. mov edi, Mem.PageTable mov cr3, edi .done: ; Clear the upper bits of 32-bit registers we used. xor eax, eax xor ecx, ecx xor edi, edi ; Restore registers. pop es popa ret .makeGuard: ; Locate the page table entry for the physical address in edi. Clear ; its present bit, and set its guard bit. shr edi, 9 ; Divide by 4096, then mul by 8. add edi, Mem.PageTable.PT & 0xffff mov eax, [es:di] and eax, ~(.Present) ; clear the present bit. or eax, .Guard ; set the guard bit. mov [es:di], eax ret .makeUncached: ; Locate the page table entry for the physical address in edi. Set its ; cache-disable, write-through, and page-attribute-table bits. Repeat ; this process for a total of "cx" contiguous page entries. shr edi, 9 ; Divide by 4096, then mul by 8. add edi, Mem.PageTable.PT & 0xffff .makeUncached.next: mov eax, [es:di] or eax, .CacheDisable | .WriteThru | .AttribTable mov [es:di], eax add di, 8 loop .makeUncached.next ret ;============================================================================= ; DisplayStatusString ; ; Add an OS prefix and a CRLF suffix to a null-terminated string, then display ; it to the console using the BIOS. ; ; Input registers: ; SI String offset ; ; Killed registers: ; None ;============================================================================= DisplayStatusString: push si mov si, String.OS.Prefix call DisplayString pop si call DisplayString mov si, String.CRLF call DisplayString ret ;============================================================================= ; DisplayErrorString ; ; Add an OS+error prefix and a CRLF suffix to a null-terminated string, then ; display it to the console using the BIOS. ; ; Input registers: ; SI String offset ; ; Killed registers: ; None ;============================================================================= DisplayErrorString: push si mov si, String.OS.Prefix call DisplayString mov si, String.Error.Prefix call DisplayString pop si call DisplayString mov si, String.CRLF call DisplayString ret ;============================================================================= ; DisplayString ; ; Display a null-terminated string to the console using the BIOS int 10 ; function 0E. ; ; Input registers: ; SI String offset ; ; Killed registers: ; None ;============================================================================= DisplayString: push ax push bx mov ah, 0x0e ; int 10 AH=0x0e xor bx, bx ; page + color cld .loop: ; Read next string character into al register. lodsb ; Break when a null terminator is reached. cmp al, 0 je .done ; Call int 10 function 0eh (print character to teletype). int 0x10 jmp .loop .done: pop bx pop ax ret ;============================================================================= ; Global data ;============================================================================= ;----------------------------------------------------------------------------- ; Status and error strings ;----------------------------------------------------------------------------- String.CRLF db 0x0d, 0x0a, 0 String.OS.Prefix db "[Monk] ", 0 String.Status.A20Enabled db "A20 line enabled", 0 String.Status.CPU64Detected db "64-bit CPU detected", 0 String.Status.SSEEnabled db "SSE enabled", 0 String.Status.KernelFound db "Kernel found", 0 String.Status.KernelLoaded db "Kernel loaded", 0 String.Error.Prefix db "ERROR: ", 0 String.Error.A20 db "A20 line not enabled", 0 String.Error.NoCPUID db "CPUID not supported", 0 String.Error.No64BitMode db "CPU is not 64-bit", 0 String.Error.NoSSE db "No SSE support", 0 String.Error.NoSSE2 db "No SSE2 support", 0 String.Error.NoFXinst db "No FXSAVE/FXRSTOR", 0 String.Error.KernelNotFound db "Kernel not found", 0 String.Error.KernelLoadFailed db "Kernel load failed", 0 ;----------------------------------------------------------------------------- ; Filename strings ;----------------------------------------------------------------------------- Kernel.Filename db "MONK.SYS;1" Kernel.Filename.Length equ ($ - Kernel.Filename) ;----------------------------------------------------------------------------- ; DAP buffer used by ReadSectors ;----------------------------------------------------------------------------- align 4 BIOS.DAP.Buffer: istruc BIOS.DAP at BIOS.DAP.Bytes, db BIOS.DAP_size at BIOS.DAP.ReadSectors, dw 0 at BIOS.DAP.TargetBufferOffset, dw 0 at BIOS.DAP.TargetBufferSegment, dw 0 at BIOS.DAP.FirstSector, dq 0 iend ;----------------------------------------------------------------------------- ; Global Descriptor Table used (temporarily) in 32-bit protected mode ;----------------------------------------------------------------------------- align 4 GDT32.Table: ; Null descriptor istruc GDT.Descriptor at GDT.Descriptor.LimitLow, dw 0x0000 at GDT.Descriptor.BaseLow, dw 0x0000 at GDT.Descriptor.BaseMiddle, db 0x00 at GDT.Descriptor.Access, db 0x00 at GDT.Descriptor.LimitHighFlags, db 0x00 at GDT.Descriptor.BaseHigh, db 0x00 iend ; 32-bit protected mode - code segment descriptor (selector = 0x08) ; (Base=0, Limit=4GiB-1, RW=1, DC=0, EX=1, PR=1, Priv=0, SZ=1, GR=1) istruc GDT.Descriptor at GDT.Descriptor.LimitLow, dw 0xffff at GDT.Descriptor.BaseLow, dw 0x0000 at GDT.Descriptor.BaseMiddle, db 0x00 at GDT.Descriptor.Access, db 10011010b at GDT.Descriptor.LimitHighFlags, db 11001111b at GDT.Descriptor.BaseHigh, db 0x00 iend ; 32-bit protected mode - data segment descriptor (selector = 0x10) ; (Base=0, Limit=4GiB-1, RW=1, DC=0, EX=0, PR=1, Priv=0, SZ=1, GR=1) istruc GDT.Descriptor at GDT.Descriptor.LimitLow, dw 0xffff at GDT.Descriptor.BaseLow, dw 0x0000 at GDT.Descriptor.BaseMiddle, db 0x00 at GDT.Descriptor.Access, db 10010010b at GDT.Descriptor.LimitHighFlags, db 11001111b at GDT.Descriptor.BaseHigh, db 0x00 iend ; 16-bit protected mode - code segment descriptor (selector = 0x18) ; (Base=0, Limit=1MiB-1, RW=1, DC=0, EX=1, PR=1, Priv=0, SZ=0, GR=0) istruc GDT.Descriptor at GDT.Descriptor.LimitLow, dw 0xffff at GDT.Descriptor.BaseLow, dw 0x0000 at GDT.Descriptor.BaseMiddle, db 0x00 at GDT.Descriptor.Access, db 10011010b at GDT.Descriptor.LimitHighFlags, db 00000001b at GDT.Descriptor.BaseHigh, db 0x00 iend ; 16-bit protected mode - data segment descriptor (selector = 0x20) ; (Base=0, Limit=1MiB-1, RW=1, DC=0, EX=0, PR=1, Priv=0, SZ=0, GR=0) istruc GDT.Descriptor at GDT.Descriptor.LimitLow, dw 0xffff at GDT.Descriptor.BaseLow, dw 0x0000 at GDT.Descriptor.BaseMiddle, db 0x00 at GDT.Descriptor.Access, db 10010010b at GDT.Descriptor.LimitHighFlags, db 00000001b at GDT.Descriptor.BaseHigh, db 0x00 iend GDT32.Table.Size equ ($ - GDT32.Table) GDT32.Table.Pointer: dw GDT32.Table.Size - 1 ; Limit = offset of last byte in table dd GDT32.Table ;----------------------------------------------------------------------------- ; Global Descriptor Table used in 64-bit mode ;----------------------------------------------------------------------------- align 8 GDT64.Table: ; Null descriptor istruc GDT.Descriptor at GDT.Descriptor.LimitLow, dw 0x0000 at GDT.Descriptor.BaseLow, dw 0x0000 at GDT.Descriptor.BaseMiddle, db 0x00 at GDT.Descriptor.Access, db 0x00 at GDT.Descriptor.LimitHighFlags, db 0x00 at GDT.Descriptor.BaseHigh, db 0x00 iend ; kernel: data segment descriptor (selector = 0x08) istruc GDT.Descriptor at GDT.Descriptor.LimitLow, dw 0x0000 at GDT.Descriptor.BaseLow, dw 0x0000 at GDT.Descriptor.BaseMiddle, db 0x00 at GDT.Descriptor.Access, db 10010010b at GDT.Descriptor.LimitHighFlags, db 00000000b at GDT.Descriptor.BaseHigh, db 0x00 iend ; kernel: code segment descriptor (selector = 0x10) istruc GDT.Descriptor at GDT.Descriptor.LimitLow, dw 0x0000 at GDT.Descriptor.BaseLow, dw 0x0000 at GDT.Descriptor.BaseMiddle, db 0x00 at GDT.Descriptor.Access, db 10011010b at GDT.Descriptor.LimitHighFlags, db 00100000b at GDT.Descriptor.BaseHigh, db 0x00 iend ; user: data segment descriptor (selector = 0x18) istruc GDT.Descriptor at GDT.Descriptor.LimitLow, dw 0x0000 at GDT.Descriptor.BaseLow, dw 0x0000 at GDT.Descriptor.BaseMiddle, db 0x00 at GDT.Descriptor.Access, db 11110010b at GDT.Descriptor.LimitHighFlags, db 00000000b at GDT.Descriptor.BaseHigh, db 0x00 iend ; user: code segment descriptor (selector = 0x20) istruc GDT.Descriptor at GDT.Descriptor.LimitLow, dw 0x0000 at GDT.Descriptor.BaseLow, dw 0x0000 at GDT.Descriptor.BaseMiddle, db 0x00 at GDT.Descriptor.Access, db 11111010b at GDT.Descriptor.LimitHighFlags, db 00100000b at GDT.Descriptor.BaseHigh, db 0x00 iend ; 64-bit TSS descriptor (selector = 0x28) istruc TSS64.Descriptor at TSS64.Descriptor.LimitLow, dw TSS64_size - 1 at TSS64.Descriptor.BaseLow, dw Mem.TSS64 & 0xffff at TSS64.Descriptor.BaseMiddle, db (Mem.TSS64 >> 16) & 0xff at TSS64.Descriptor.Access, db 10001001b at TSS64.Descriptor.LimitHighFlags, db 00000000b at TSS64.Descriptor.BaseHigh, db (Mem.TSS64 >> 24) & 0xff at TSS64.Descriptor.BaseHighest, dd (Mem.TSS64 >> 32) at TSS64.Descriptor.Reserved, dd 0x00000000 iend GDT64.Table.Size equ ($ - GDT64.Table) ; GDT64 table pointer ; This pointer references Mem.GDT, not GDT64.Table, because that's where the ; 64-bit mode GDT will reside after we copy it. GDT64.Table.Pointer: dw GDT64.Table.Size - 1 ; Limit = offset of last byte in table dq Mem.GDT ; Address of table copy ;----------------------------------------------------------------------------- ; Task State Segment for 64-bit mode ;----------------------------------------------------------------------------- align 8 TSS64.Entry: ; Create a TSS that causes the CPU to use a special interrupt stack (RSP0) ; whenever an interrupt causes a privilege change from user mode to kernel ; mode. ; ; If a catastrophic exception occurs -- such as an NMI, double fault, or ; machine check -- use an exception-specific stack (IST1 .. IST3) that is ; guaranteed to be valid. ; ; See section 6.14.5 in volume 3 of the Intel 64 and IA-32 Architectures ; Software Developer’s Manual for more information. istruc TSS64 at TSS64.RSP0, dq Mem.Kernel.Stack.Interrupt.Top at TSS64.RSP1, dq 0 at TSS64.RSP2, dq 0 at TSS64.IST1, dq Mem.Kernel.Stack.NMI.Top at TSS64.IST2, dq Mem.Kernel.Stack.DF.Top at TSS64.IST3, dq Mem.Kernel.Stack.MC.Top at TSS64.IST4, dq 0 at TSS64.IST5, dq 0 at TSS64.IST6, dq 0 at TSS64.IST7, dq 0 at TSS64.IOPB, dw TSS64_size ; no IOPB iend TSS64.Entry.Size equ ($ - TSS64.Entry) ;============================================================================= ; Padding ;============================================================================= programEnd: ; Pad the boot record to 32 KiB times 0x8000 - ($ - $$) db 0
; A025768: Expansion of 1/((1-x)*(1-x^3)*(1-x^7)). ; 1,1,1,2,2,2,3,4,4,5,6,6,7,8,9,10,11,12,13,14,15,17,18,19,21,22,23,25,27,28,30,32,33,35,37,39,41,43,45,47,49,51,54,56,58,61,63,65,68,71,73,76,79,81,84,87,90,93,96 mov $3,$0 sub $3,1 mul $3,$0 mul $0,2 mov $1,$3 div $1,6 lpb $0 add $1,$0 mov $0,$2 div $1,7 lpe add $1,1
/* * File : interrupt.s34 * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2009, RT-Thread Development Team * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes * 2010-04-20 fify the first version * * For : Renesas M16C * Toolchain : IAR's EW for M16C v3.401 */ PUBLIC rt_hw_timer_handler PUBLIC rt_hw_uart0_receive_handler EXTERN rt_thread_switch_interrupt_flag EXTERN rt_interrupt_from_thread EXTERN rt_interrupt_to_thread EXTERN rt_interrupt_enter EXTERN rt_interrupt_leave EXTERN rt_tick_increase EXTERN u0rec_handler RSEG CSTACK RSEG ISTACK RSEG CODE:CODE:NOROOT(2) rt_hw_context_switch_interrupt_do MOV.B #0, rt_thread_switch_interrupt_flag MOV.W rt_interrupt_from_thread, A0 STC ISP, [A0] MOV.W rt_interrupt_to_thread, A0 LDC [A0], ISP POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore all processor registers from the new task's stack REIT .EVEN rt_hw_timer_handler: PUSHM R0,R1,R2,R3,A0,A1,SB,FB ; Save current task's registers JSR rt_interrupt_enter JSR rt_tick_increase JSR rt_interrupt_leave CMP.B #1, rt_thread_switch_interrupt_flag JEQ rt_hw_context_switch_interrupt_do POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers REIT ; Return from interrup .EVEN rt_hw_uart0_receive_handler: PUSHM R0,R1,R2,R3,A0,A1,SB,FB ; Save current task's registers JSR rt_interrupt_enter JSR u0rec_handler JSR rt_interrupt_leave CMP.B #1, rt_thread_switch_interrupt_flag JEQ rt_hw_context_switch_interrupt_do POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers REIT ; Return from interrup END
dw $0040 track_1D_08: db $FF, $18, $97, $DE, $63, $FE, $1A, $7E, $E6, $34 db $ED, $FC, $70, $30, $F5, $77, $87, $88, $F3, $5D db $DC, $0C, $0F, $FD, $E8, $E9, $C4, $BE, $EA, $A3 db $EE, $FD, $2F, $3F, $A8, $F6, $8C, $4B, $AC, $E1 db $D3, $48, $F3, $1E, $86, $BB, $B1, $E0, $EF, $3C db $76, $BB, $BA, $9C, $27, $8F, $F4, $7A, $E3, $F1 db $8F, $9A, $49, $63, $D5, $1E, $B8, $FF, $FC, $A6 db $3F, $18, $F9, $7E, $96, $3D, $7F, $29, $8F, $FD db $E8, $E9, $C4, $BE, $EA, $A3, $EE, $FD, $2F, $3F db $A8, $F6, $8C, $4B, $AC, $E1, $D3, $48, $F5, $77 db $87, $88, $F3, $5D, $DC, $0C, $00
; A109165: a(n) = 5*a(n-2) - 2*a(n-4), n >= 4; a(n) = (1/6)*(-1)^n + 4/3)*2^n - 1/2. ; Submitted by Jon Maiga ; 1,2,5,10,23,46,105,210,479,958,2185,4370,9967,19934,45465,90930,207391,414782,946025,1892050,4315343,8630686,19684665,39369330,89792639,179585278,409593865,819187730,1868384047,3736768094,8522732505 mov $1,1 mov $2,1 lpb $0 sub $0,2 mul $2,2 add $1,$2 add $2,$1 lpe lpb $0 bin $0,3 mul $2,2 lpe mov $0,$2
; A027937: a(n) = T(2*n, n+1), T given by A027935. ; 1,7,26,79,221,596,1581,4163,10926,28635,75001,196392,514201,1346239,3524546,9227431,24157781,63245948,165580101,433494395,1134903126,2971215027,7778742001,20365011024,53316291121,139583862391,365435296106,956722025983,2504730781901,6557470319780,17167680177501,44945570212787,117669030460926,308061521170059,806515533049321,2111485077977976,5527939700884681 lpb $0 sub $0,1 add $1,1 add $3,2 add $1,$3 add $2,$1 add $1,$2 lpe add $1,1
; A052939: Expansion of (1-x)*(1+x)/(1-3*x-x^2+2*x^3). ; Submitted by Jamie Morken(s1) ; 1,3,9,28,87,271,844,2629,8189,25508,79455,247495,770924,2401357,7480005,23299524,72575863,226067103,704178124,2193449749,6832393165,21282272996,66292312655,206494424631,643211040556,2003542920989,6240850954261,19439673702660,60552786220263,188616330454927,587522430179724,1830078048553573,5700523914930589,17756604932985892,55310182616781119,172286104953468071,536655287611213548,1671631602553546477,5206977885364916837,16219254683425869892,50521478730535433559,157369735104302336895 mul $0,2 mov $1,1 lpb $0 sub $0,2 add $2,$1 mul $1,2 add $1,$2 mov $4,$3 mov $3,$2 mov $2,$4 lpe mov $0,$1
; A332057: Partial sums (and absolute value of first differences) of A332056: if odd (resp. even) add (resp. subtract) the partial sum to get the next term. ; 1,3,2,3,7,4,5,11,6,7,15,8,9,19,10,11,23,12,13,27,14,15,31,16,17,35,18,19,39,20,21,43,22,23,47,24,25,51,26,27,55,28,29,59,30,31,63,32,33,67,34,35,71,36,37,75,38,39,79,40,41,83,42,43,87,44,45,91,46,47,95,48,49,99,50,51,103,52,53,107,54,55,111,56,57,115,58,59,119,60,61,123,62,63,127,64,65,131,66,67,135,68,69,139,70,71,143,72,73,147,74,75,151,76,77,155,78,79,159,80,81,163,82,83,167,84,85,171,86,87,175,88,89,179,90,91,183,92,93,187,94,95,191,96,97,195,98,99,199,100,101,203,102,103,207,104,105,211,106,107,215,108,109,219,110,111,223,112,113,227,114,115,231,116,117,235,118,119,239,120,121,243,122,123,247,124,125,251,126,127,255,128,129,259,130,131,263,132,133,267,134,135,271,136,137,275,138,139,279,140,141,283,142,143,287,144,145,291,146,147,295,148,149,299,150,151,303,152,153,307,154,155,311,156,157,315,158,159,319,160,161,323,162,163,327,164,165,331,166,167 mov $3,2 mov $4,$0 lpb $3 mov $0,$4 sub $3,1 add $0,$3 add $0,1 mov $2,$3 mov $5,$0 div $5,3 mov $6,0 add $6,$0 add $5,$6 pow $5,2 div $5,4 mov $6,$5 lpb $2 mov $1,$6 sub $2,1 lpe lpe lpb $4 sub $1,$6 mov $4,0 lpe
; A222470: Numerator sequence of the n-th convergent of the continued fraction 1/(1-2/(2-2/(3-2/(4-... ; Submitted by Jon Maiga ; 1,2,4,12,52,288,1912,14720,128656,1257120,13571008,160337856,2057250112,28480825856,423097887616,6712604550144,113268081577216,2025400259289600,38256068763347968,761070574748380160 mov $2,1 mov $3,1 lpb $0 sub $0,$2 mov $1,$4 mul $1,$0 mul $3,2 add $3,$1 add $4,$3 lpe mov $0,$3