text
stringlengths
1
1.05M
.data .text addi $s0, $zero, 100 # value to register without loading from ram addi $s1, $zero, 40 mul $t0, $s0, $s1 # only up to 32bits li $v0, 1 move $a0, $t0 syscall
.global s_prepare_buffers s_prepare_buffers: push %r10 push %rax push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x1063e, %rsi lea addresses_WT_ht+0x67fe, %rdi dec %r10 mov $36, %rcx rep movsl xor %rbp, %rbp lea addresses_WC_ht+0xd13e, %rax nop nop cmp %r10, %r10 mov $0x6162636465666768, %rdi movq %rdi, %xmm4 movups %xmm4, (%rax) nop nop nop sub $46561, %rax lea addresses_A_ht+0x1a83e, %rsi lea addresses_WC_ht+0x1563e, %rdi nop nop nop nop nop and $57399, %rdx mov $97, %rcx rep movsl nop nop nop nop nop inc %rbp lea addresses_A_ht+0xb1ae, %rbp clflush (%rbp) nop nop inc %rsi movb (%rbp), %dl nop and $4059, %rbp lea addresses_normal_ht+0x53f8, %r10 nop nop and %rsi, %rsi movb (%r10), %cl and %r10, %r10 lea addresses_D_ht+0x11a3e, %rbp nop dec %rdi movb $0x61, (%rbp) nop nop nop cmp $33537, %rsi lea addresses_WT_ht+0xe43e, %rcx clflush (%rcx) nop nop nop nop nop sub %rsi, %rsi movb $0x61, (%rcx) nop nop nop sub $28162, %rcx lea addresses_UC_ht+0xa73e, %rax nop nop nop nop dec %rbp mov $0x6162636465666768, %rcx movq %rcx, %xmm5 vmovups %ymm5, (%rax) nop and %rsi, %rsi lea addresses_WT_ht+0x4e3e, %rsi lea addresses_WC_ht+0x19c3e, %rdi nop cmp %rax, %rax mov $98, %rcx rep movsl nop nop nop nop dec %r10 lea addresses_normal_ht+0x217e, %rbp nop nop nop sub %rdx, %rdx movb (%rbp), %r10b nop nop nop nop nop xor %rax, %rax lea addresses_A_ht+0x19a3e, %rax nop dec %rsi mov (%rax), %rcx and %rdi, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r15 push %r8 push %rax push %rcx push %rdx // Store lea addresses_PSE+0x463e, %r14 nop and %r15, %r15 movw $0x5152, (%r14) // Exception!!! nop nop mov (0), %rax nop nop nop nop nop xor %r14, %r14 // Store lea addresses_PSE+0x1183e, %r10 nop and %r8, %r8 movl $0x51525354, (%r10) nop and $39082, %rcx // Faulty Load lea addresses_US+0x1a23e, %r8 add $50013, %rdx mov (%r8), %r10w lea oracles, %rdx and $0xff, %r10 shlq $12, %r10 mov (%rdx,%r10,1), %r10 pop %rdx pop %rcx pop %rax pop %r8 pop %r15 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': True, 'size': 8, 'type': 'addresses_US', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_PSE', 'congruent': 10}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_PSE', 'congruent': 6}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_US', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WC_ht', 'congruent': 8}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_A_ht', 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 1}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_D_ht', 'congruent': 11}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 1, 'type': 'addresses_WT_ht', 'congruent': 9}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC_ht', 'congruent': 8}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A_ht', 'congruent': 8}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A267810: Triangle read by rows giving successive states of cellular automaton generated by "Rule 217" initiated with a single ON (black) cell. ; 1,0,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1 mov $3,$0 lpb $3 mov $0,1 add $2,2 sub $3,$2 trn $0,$3 lpe pow $1,$0 mov $0,$1
<% from pwnlib.shellcraft.thumb.linux import syscall %> <%page args="mask"/> <%docstring> Invokes the syscall umask. See 'man 2 umask' for more information. Arguments: mask(mode_t): mask </%docstring> ${syscall('SYS_umask', mask)}
;; ;; Copyright (c) 2017-2022, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; ;; Stack must be aligned to 32 bytes before call ;; ;; Registers: RAX RBX RCX RDX RBP RSI RDI R8 R9 R10 R11 R12 R13 R14 R15 ;; ----------------------------------------------------------- ;; Windows clobbers: RAX RDX RDI R8 R9 R10 R11 R12 R13 R14 R15 ;; Windows preserves: RBX RCX RBP RSI ;; ----------------------------------------------------------- ;; Linux clobbers: RAX RDX RSI R8 R9 R10 R11 R12 R13 R14 R15 ;; Linux preserves: RBX RCX RBP RDI ;; ----------------------------------------------------------- ;; Clobbers ZMM0-31 ;; code to compute quad SHA512 using AVX512 %include "include/os.asm" ;%define DO_DBGPRINT %include "include/dbgprint.asm" %include "include/mb_mgr_datastruct.asm" %include "include/transpose_avx512.asm" %include "include/clear_regs.asm" %include "include/cet.inc" %define APPEND(a,b) a %+ b %ifdef LINUX ; Linux register definitions %define arg1 rdi %define arg2 rsi %define arg3 rcx %define arg4 rdx %else ; Windows definitions %define arg1 rcx %define arg2 rdx %define arg3 rsi %define arg4 rdi %endif %define STATE arg1 %define INP_SIZE arg2 %define IDX arg4 %define TBL r8 ;; retaining XMM_SAVE, because the top half of YMM registers no saving required, only bottom half, the XMM part %define NUM_LANES 8 %define XMM_SAVE (15-5)*16 %define SZ 8 %define SZ8 8 * SZ %define DIGEST_SZ 8 * SZ8 %define DIGEST_SAVE NUM_LANES * DIGEST_SZ %define RSP_SAVE 1*8 ; Define Stack Layout START_FIELDS ;;; name size align FIELD _DIGEST_SAVE, NUM_LANES*8*64, 64 FIELD _XMM_SAVE, XMM_SAVE, 16 FIELD _RSP, 8, 8 %assign STACK_SPACE _FIELD_OFFSET %define inp0 r9 %define inp1 r10 %define inp2 r11 %define inp3 r12 %define inp4 r13 %define inp5 r14 %define inp6 r15 %define inp7 rax %define A zmm0 %define B zmm1 %define C zmm2 %define D zmm3 %define E zmm4 %define F zmm5 %define G zmm6 %define H zmm7 %define T1 zmm8 %define TMP0 zmm9 %define TMP1 zmm10 %define TMP2 zmm11 %define TMP3 zmm12 %define TMP4 zmm13 %define TMP5 zmm14 %define TMP6 zmm15 %define W0 zmm16 %define W1 zmm17 %define W2 zmm18 %define W3 zmm19 %define W4 zmm20 %define W5 zmm21 %define W6 zmm22 %define W7 zmm23 %define W8 zmm24 %define W9 zmm25 %define W10 zmm26 %define W11 zmm27 %define W12 zmm28 %define W13 zmm29 %define W14 zmm30 %define W15 zmm31 ; from sha256_fips180-2.pdf ; define rotates for Sigma function for main loop steps %define BIG_SIGMA_0_0 28 ; Sigma0 %define BIG_SIGMA_0_1 34 %define BIG_SIGMA_0_2 39 %define BIG_SIGMA_1_0 14 ; Sigma1 %define BIG_SIGMA_1_1 18 %define BIG_SIGMA_1_2 41 ; define rotates for Sigma function for scheduling steps %define SMALL_SIGMA_0_0 1 ; sigma0 %define SMALL_SIGMA_0_1 8 %define SMALL_SIGMA_0_2 7 %define SMALL_SIGMA_1_0 19 ; sigma1 %define SMALL_SIGMA_1_1 61 %define SMALL_SIGMA_1_2 6 %define SHA_MAX_ROUNDS 80 %define SHA_ROUNDS_LESS_16 (SHA_MAX_ROUNDS - 16) %macro ROTATE_ARGS 0 %xdefine TMP_ H %xdefine H G %xdefine G F %xdefine F E %xdefine E D %xdefine D C %xdefine C B %xdefine B A %xdefine A TMP_ %endm ;; CH(A, B, C) = (A&B) ^ (~A&C) ;; MAJ(E, F, G) = (E&F) ^ (E&G) ^ (F&G) ;; SIGMA0 = ROR_28 ^ ROR_34 ^ ROR_39 ;; SIGMA1 = ROR_14 ^ ROR_18 ^ ROR_41 ;; sigma0 = ROR_1 ^ ROR_8 ^ SHR_7 ;; sigma1 = ROR_19 ^ ROR_61 ^ SHR_6 ;; Main processing loop per round ;; equivalent to %macro ROUND_00_15 2 %macro PROCESS_LOOP 2 %define %%WT %1 %define %%ROUND %2 ;; T1 = H + BIG_SIGMA_1(E) + CH(E, F, G) + Kt + Wt ;; T2 = BIG_SIGMA_0(A) + MAJ(A, B, C) ;; H=G, G=F, F=E, E=D+T1, D=C, C=B, B=A, A=T1+T2 ;; H becomes T2, then add T1 for A ;; D becomes D + T1 for E vpaddq T1, H, TMP3 ; T1 = H + Kt vmovdqa32 TMP0, E ;; compute BIG_SIGMA_1(E) vprorq TMP1, E, BIG_SIGMA_1_0 ; ROR_14(E) vprorq TMP2, E, BIG_SIGMA_1_1 ; ROR_18(E) vprorq TMP3, E, BIG_SIGMA_1_2 ; ROR_41(E) vpternlogq TMP1, TMP2, TMP3, 0x96 ; TMP1 = BIG_SIGMA_1(E) vpternlogq TMP0, F, G, 0xCA ; TMP0 = CH(E,F,G) vpaddq T1, T1, %%WT ; T1 = T1 + Wt vpaddq T1, T1, TMP0 ; T1 = T1 + CH(E,F,G) vpaddq T1, T1, TMP1 ; T1 = T1 + BIG_SIGMA_1(E) vpaddq D, D, T1 ; D = D + T1 vprorq H, A, BIG_SIGMA_0_0 ;ROR_28(A) vprorq TMP2, A, BIG_SIGMA_0_1 ;ROR_34(A) vprorq TMP3, A, BIG_SIGMA_0_2 ;ROR_39(A) vmovdqa32 TMP0, A vpternlogq TMP0, B, C, 0xE8 ; TMP0 = MAJ(A,B,C) vpternlogq H, TMP2, TMP3, 0x96 ; H(T2) = BIG_SIGMA_0(A) vpaddq H, H, TMP0 ; H(T2) = BIG_SIGMA_0(A) + MAJ(A,B,C) vpaddq H, H, T1 ; H(A) = H(T2) + T1 vmovdqa32 TMP3, [TBL + ((%%ROUND+1)*64)] ; Next Kt ;; Rotate the args A-H (rotation of names associated with regs) ROTATE_ARGS %endmacro %macro MSG_SCHED_ROUND_16_79 4 %define %%WT %1 %define %%WTp1 %2 %define %%WTp9 %3 %define %%WTp14 %4 vprorq TMP4, %%WTp14, SMALL_SIGMA_1_0 ; ROR_19(Wt-2) vprorq TMP5, %%WTp14, SMALL_SIGMA_1_1 ; ROR_61(Wt-2) vpsrlq TMP6, %%WTp14, SMALL_SIGMA_1_2 ; SHR_6(Wt-2) vpternlogq TMP4, TMP5, TMP6, 0x96 ; TMP4 = sigma_1(Wt-2) vpaddq %%WT, %%WT, TMP4 ; Wt = Wt-16 + sigma_1(Wt-2) vpaddq %%WT, %%WT, %%WTp9 ; Wt = Wt-16 + sigma_1(Wt-2) + Wt-7 vprorq TMP4, %%WTp1, SMALL_SIGMA_0_0 ; ROR_1(Wt-15) vprorq TMP5, %%WTp1, SMALL_SIGMA_0_1 ; ROR_8(Wt-15) vpsrlq TMP6, %%WTp1, SMALL_SIGMA_0_2 ; SHR_7(Wt-15) vpternlogq TMP4, TMP5, TMP6, 0x96 ; TMP4 = sigma_0(Wt-15) vpaddq %%WT, %%WT, TMP4 ; Wt = Wt-16 + sigma_1(Wt-2) + ; Wt-7 + sigma_0(Wt-15) + %endmacro mksection .rodata default rel align 64 ; 80 constants for SHA512 ; replicating for each lane, thus 8*80 ; to aid in SIMD .. space tradeoff for time! ; local to asm file, used nowhere else TABLE: dq 0x428a2f98d728ae22, 0x428a2f98d728ae22, 0x428a2f98d728ae22, 0x428a2f98d728ae22 dq 0x428a2f98d728ae22, 0x428a2f98d728ae22, 0x428a2f98d728ae22, 0x428a2f98d728ae22 dq 0x7137449123ef65cd, 0x7137449123ef65cd, 0x7137449123ef65cd, 0x7137449123ef65cd dq 0x7137449123ef65cd, 0x7137449123ef65cd, 0x7137449123ef65cd, 0x7137449123ef65cd dq 0xb5c0fbcfec4d3b2f, 0xb5c0fbcfec4d3b2f, 0xb5c0fbcfec4d3b2f, 0xb5c0fbcfec4d3b2f dq 0xb5c0fbcfec4d3b2f, 0xb5c0fbcfec4d3b2f, 0xb5c0fbcfec4d3b2f, 0xb5c0fbcfec4d3b2f dq 0xe9b5dba58189dbbc, 0xe9b5dba58189dbbc, 0xe9b5dba58189dbbc, 0xe9b5dba58189dbbc dq 0xe9b5dba58189dbbc, 0xe9b5dba58189dbbc, 0xe9b5dba58189dbbc, 0xe9b5dba58189dbbc dq 0x3956c25bf348b538, 0x3956c25bf348b538, 0x3956c25bf348b538, 0x3956c25bf348b538 dq 0x3956c25bf348b538, 0x3956c25bf348b538, 0x3956c25bf348b538, 0x3956c25bf348b538 dq 0x59f111f1b605d019, 0x59f111f1b605d019, 0x59f111f1b605d019, 0x59f111f1b605d019 dq 0x59f111f1b605d019, 0x59f111f1b605d019, 0x59f111f1b605d019, 0x59f111f1b605d019 dq 0x923f82a4af194f9b, 0x923f82a4af194f9b, 0x923f82a4af194f9b, 0x923f82a4af194f9b dq 0x923f82a4af194f9b, 0x923f82a4af194f9b, 0x923f82a4af194f9b, 0x923f82a4af194f9b dq 0xab1c5ed5da6d8118, 0xab1c5ed5da6d8118, 0xab1c5ed5da6d8118, 0xab1c5ed5da6d8118 dq 0xab1c5ed5da6d8118, 0xab1c5ed5da6d8118, 0xab1c5ed5da6d8118, 0xab1c5ed5da6d8118 dq 0xd807aa98a3030242, 0xd807aa98a3030242, 0xd807aa98a3030242, 0xd807aa98a3030242 dq 0xd807aa98a3030242, 0xd807aa98a3030242, 0xd807aa98a3030242, 0xd807aa98a3030242 dq 0x12835b0145706fbe, 0x12835b0145706fbe, 0x12835b0145706fbe, 0x12835b0145706fbe dq 0x12835b0145706fbe, 0x12835b0145706fbe, 0x12835b0145706fbe, 0x12835b0145706fbe dq 0x243185be4ee4b28c, 0x243185be4ee4b28c, 0x243185be4ee4b28c, 0x243185be4ee4b28c dq 0x243185be4ee4b28c, 0x243185be4ee4b28c, 0x243185be4ee4b28c, 0x243185be4ee4b28c dq 0x550c7dc3d5ffb4e2, 0x550c7dc3d5ffb4e2, 0x550c7dc3d5ffb4e2, 0x550c7dc3d5ffb4e2 dq 0x550c7dc3d5ffb4e2, 0x550c7dc3d5ffb4e2, 0x550c7dc3d5ffb4e2, 0x550c7dc3d5ffb4e2 dq 0x72be5d74f27b896f, 0x72be5d74f27b896f, 0x72be5d74f27b896f, 0x72be5d74f27b896f dq 0x72be5d74f27b896f, 0x72be5d74f27b896f, 0x72be5d74f27b896f, 0x72be5d74f27b896f dq 0x80deb1fe3b1696b1, 0x80deb1fe3b1696b1, 0x80deb1fe3b1696b1, 0x80deb1fe3b1696b1 dq 0x80deb1fe3b1696b1, 0x80deb1fe3b1696b1, 0x80deb1fe3b1696b1, 0x80deb1fe3b1696b1 dq 0x9bdc06a725c71235, 0x9bdc06a725c71235, 0x9bdc06a725c71235, 0x9bdc06a725c71235 dq 0x9bdc06a725c71235, 0x9bdc06a725c71235, 0x9bdc06a725c71235, 0x9bdc06a725c71235 dq 0xc19bf174cf692694, 0xc19bf174cf692694, 0xc19bf174cf692694, 0xc19bf174cf692694 dq 0xc19bf174cf692694, 0xc19bf174cf692694, 0xc19bf174cf692694, 0xc19bf174cf692694 dq 0xe49b69c19ef14ad2, 0xe49b69c19ef14ad2, 0xe49b69c19ef14ad2, 0xe49b69c19ef14ad2 dq 0xe49b69c19ef14ad2, 0xe49b69c19ef14ad2, 0xe49b69c19ef14ad2, 0xe49b69c19ef14ad2 dq 0xefbe4786384f25e3, 0xefbe4786384f25e3, 0xefbe4786384f25e3, 0xefbe4786384f25e3 dq 0xefbe4786384f25e3, 0xefbe4786384f25e3, 0xefbe4786384f25e3, 0xefbe4786384f25e3 dq 0x0fc19dc68b8cd5b5, 0x0fc19dc68b8cd5b5, 0x0fc19dc68b8cd5b5, 0x0fc19dc68b8cd5b5 dq 0x0fc19dc68b8cd5b5, 0x0fc19dc68b8cd5b5, 0x0fc19dc68b8cd5b5, 0x0fc19dc68b8cd5b5 dq 0x240ca1cc77ac9c65, 0x240ca1cc77ac9c65, 0x240ca1cc77ac9c65, 0x240ca1cc77ac9c65 dq 0x240ca1cc77ac9c65, 0x240ca1cc77ac9c65, 0x240ca1cc77ac9c65, 0x240ca1cc77ac9c65 dq 0x2de92c6f592b0275, 0x2de92c6f592b0275, 0x2de92c6f592b0275, 0x2de92c6f592b0275 dq 0x2de92c6f592b0275, 0x2de92c6f592b0275, 0x2de92c6f592b0275, 0x2de92c6f592b0275 dq 0x4a7484aa6ea6e483, 0x4a7484aa6ea6e483, 0x4a7484aa6ea6e483, 0x4a7484aa6ea6e483 dq 0x4a7484aa6ea6e483, 0x4a7484aa6ea6e483, 0x4a7484aa6ea6e483, 0x4a7484aa6ea6e483 dq 0x5cb0a9dcbd41fbd4, 0x5cb0a9dcbd41fbd4, 0x5cb0a9dcbd41fbd4, 0x5cb0a9dcbd41fbd4 dq 0x5cb0a9dcbd41fbd4, 0x5cb0a9dcbd41fbd4, 0x5cb0a9dcbd41fbd4, 0x5cb0a9dcbd41fbd4 dq 0x76f988da831153b5, 0x76f988da831153b5, 0x76f988da831153b5, 0x76f988da831153b5 dq 0x76f988da831153b5, 0x76f988da831153b5, 0x76f988da831153b5, 0x76f988da831153b5 dq 0x983e5152ee66dfab, 0x983e5152ee66dfab, 0x983e5152ee66dfab, 0x983e5152ee66dfab dq 0x983e5152ee66dfab, 0x983e5152ee66dfab, 0x983e5152ee66dfab, 0x983e5152ee66dfab dq 0xa831c66d2db43210, 0xa831c66d2db43210, 0xa831c66d2db43210, 0xa831c66d2db43210 dq 0xa831c66d2db43210, 0xa831c66d2db43210, 0xa831c66d2db43210, 0xa831c66d2db43210 dq 0xb00327c898fb213f, 0xb00327c898fb213f, 0xb00327c898fb213f, 0xb00327c898fb213f dq 0xb00327c898fb213f, 0xb00327c898fb213f, 0xb00327c898fb213f, 0xb00327c898fb213f dq 0xbf597fc7beef0ee4, 0xbf597fc7beef0ee4, 0xbf597fc7beef0ee4, 0xbf597fc7beef0ee4 dq 0xbf597fc7beef0ee4, 0xbf597fc7beef0ee4, 0xbf597fc7beef0ee4, 0xbf597fc7beef0ee4 dq 0xc6e00bf33da88fc2, 0xc6e00bf33da88fc2, 0xc6e00bf33da88fc2, 0xc6e00bf33da88fc2 dq 0xc6e00bf33da88fc2, 0xc6e00bf33da88fc2, 0xc6e00bf33da88fc2, 0xc6e00bf33da88fc2 dq 0xd5a79147930aa725, 0xd5a79147930aa725, 0xd5a79147930aa725, 0xd5a79147930aa725 dq 0xd5a79147930aa725, 0xd5a79147930aa725, 0xd5a79147930aa725, 0xd5a79147930aa725 dq 0x06ca6351e003826f, 0x06ca6351e003826f, 0x06ca6351e003826f, 0x06ca6351e003826f dq 0x06ca6351e003826f, 0x06ca6351e003826f, 0x06ca6351e003826f, 0x06ca6351e003826f dq 0x142929670a0e6e70, 0x142929670a0e6e70, 0x142929670a0e6e70, 0x142929670a0e6e70 dq 0x142929670a0e6e70, 0x142929670a0e6e70, 0x142929670a0e6e70, 0x142929670a0e6e70 dq 0x27b70a8546d22ffc, 0x27b70a8546d22ffc, 0x27b70a8546d22ffc, 0x27b70a8546d22ffc dq 0x27b70a8546d22ffc, 0x27b70a8546d22ffc, 0x27b70a8546d22ffc, 0x27b70a8546d22ffc dq 0x2e1b21385c26c926, 0x2e1b21385c26c926, 0x2e1b21385c26c926, 0x2e1b21385c26c926 dq 0x2e1b21385c26c926, 0x2e1b21385c26c926, 0x2e1b21385c26c926, 0x2e1b21385c26c926 dq 0x4d2c6dfc5ac42aed, 0x4d2c6dfc5ac42aed, 0x4d2c6dfc5ac42aed, 0x4d2c6dfc5ac42aed dq 0x4d2c6dfc5ac42aed, 0x4d2c6dfc5ac42aed, 0x4d2c6dfc5ac42aed, 0x4d2c6dfc5ac42aed dq 0x53380d139d95b3df, 0x53380d139d95b3df, 0x53380d139d95b3df, 0x53380d139d95b3df dq 0x53380d139d95b3df, 0x53380d139d95b3df, 0x53380d139d95b3df, 0x53380d139d95b3df dq 0x650a73548baf63de, 0x650a73548baf63de, 0x650a73548baf63de, 0x650a73548baf63de dq 0x650a73548baf63de, 0x650a73548baf63de, 0x650a73548baf63de, 0x650a73548baf63de dq 0x766a0abb3c77b2a8, 0x766a0abb3c77b2a8, 0x766a0abb3c77b2a8, 0x766a0abb3c77b2a8 dq 0x766a0abb3c77b2a8, 0x766a0abb3c77b2a8, 0x766a0abb3c77b2a8, 0x766a0abb3c77b2a8 dq 0x81c2c92e47edaee6, 0x81c2c92e47edaee6, 0x81c2c92e47edaee6, 0x81c2c92e47edaee6 dq 0x81c2c92e47edaee6, 0x81c2c92e47edaee6, 0x81c2c92e47edaee6, 0x81c2c92e47edaee6 dq 0x92722c851482353b, 0x92722c851482353b, 0x92722c851482353b, 0x92722c851482353b dq 0x92722c851482353b, 0x92722c851482353b, 0x92722c851482353b, 0x92722c851482353b dq 0xa2bfe8a14cf10364, 0xa2bfe8a14cf10364, 0xa2bfe8a14cf10364, 0xa2bfe8a14cf10364 dq 0xa2bfe8a14cf10364, 0xa2bfe8a14cf10364, 0xa2bfe8a14cf10364, 0xa2bfe8a14cf10364 dq 0xa81a664bbc423001, 0xa81a664bbc423001, 0xa81a664bbc423001, 0xa81a664bbc423001 dq 0xa81a664bbc423001, 0xa81a664bbc423001, 0xa81a664bbc423001, 0xa81a664bbc423001 dq 0xc24b8b70d0f89791, 0xc24b8b70d0f89791, 0xc24b8b70d0f89791, 0xc24b8b70d0f89791 dq 0xc24b8b70d0f89791, 0xc24b8b70d0f89791, 0xc24b8b70d0f89791, 0xc24b8b70d0f89791 dq 0xc76c51a30654be30, 0xc76c51a30654be30, 0xc76c51a30654be30, 0xc76c51a30654be30 dq 0xc76c51a30654be30, 0xc76c51a30654be30, 0xc76c51a30654be30, 0xc76c51a30654be30 dq 0xd192e819d6ef5218, 0xd192e819d6ef5218, 0xd192e819d6ef5218, 0xd192e819d6ef5218 dq 0xd192e819d6ef5218, 0xd192e819d6ef5218, 0xd192e819d6ef5218, 0xd192e819d6ef5218 dq 0xd69906245565a910, 0xd69906245565a910, 0xd69906245565a910, 0xd69906245565a910 dq 0xd69906245565a910, 0xd69906245565a910, 0xd69906245565a910, 0xd69906245565a910 dq 0xf40e35855771202a, 0xf40e35855771202a, 0xf40e35855771202a, 0xf40e35855771202a dq 0xf40e35855771202a, 0xf40e35855771202a, 0xf40e35855771202a, 0xf40e35855771202a dq 0x106aa07032bbd1b8, 0x106aa07032bbd1b8, 0x106aa07032bbd1b8, 0x106aa07032bbd1b8 dq 0x106aa07032bbd1b8, 0x106aa07032bbd1b8, 0x106aa07032bbd1b8, 0x106aa07032bbd1b8 dq 0x19a4c116b8d2d0c8, 0x19a4c116b8d2d0c8, 0x19a4c116b8d2d0c8, 0x19a4c116b8d2d0c8 dq 0x19a4c116b8d2d0c8, 0x19a4c116b8d2d0c8, 0x19a4c116b8d2d0c8, 0x19a4c116b8d2d0c8 dq 0x1e376c085141ab53, 0x1e376c085141ab53, 0x1e376c085141ab53, 0x1e376c085141ab53 dq 0x1e376c085141ab53, 0x1e376c085141ab53, 0x1e376c085141ab53, 0x1e376c085141ab53 dq 0x2748774cdf8eeb99, 0x2748774cdf8eeb99, 0x2748774cdf8eeb99, 0x2748774cdf8eeb99 dq 0x2748774cdf8eeb99, 0x2748774cdf8eeb99, 0x2748774cdf8eeb99, 0x2748774cdf8eeb99 dq 0x34b0bcb5e19b48a8, 0x34b0bcb5e19b48a8, 0x34b0bcb5e19b48a8, 0x34b0bcb5e19b48a8 dq 0x34b0bcb5e19b48a8, 0x34b0bcb5e19b48a8, 0x34b0bcb5e19b48a8, 0x34b0bcb5e19b48a8 dq 0x391c0cb3c5c95a63, 0x391c0cb3c5c95a63, 0x391c0cb3c5c95a63, 0x391c0cb3c5c95a63 dq 0x391c0cb3c5c95a63, 0x391c0cb3c5c95a63, 0x391c0cb3c5c95a63, 0x391c0cb3c5c95a63 dq 0x4ed8aa4ae3418acb, 0x4ed8aa4ae3418acb, 0x4ed8aa4ae3418acb, 0x4ed8aa4ae3418acb dq 0x4ed8aa4ae3418acb, 0x4ed8aa4ae3418acb, 0x4ed8aa4ae3418acb, 0x4ed8aa4ae3418acb dq 0x5b9cca4f7763e373, 0x5b9cca4f7763e373, 0x5b9cca4f7763e373, 0x5b9cca4f7763e373 dq 0x5b9cca4f7763e373, 0x5b9cca4f7763e373, 0x5b9cca4f7763e373, 0x5b9cca4f7763e373 dq 0x682e6ff3d6b2b8a3, 0x682e6ff3d6b2b8a3, 0x682e6ff3d6b2b8a3, 0x682e6ff3d6b2b8a3 dq 0x682e6ff3d6b2b8a3, 0x682e6ff3d6b2b8a3, 0x682e6ff3d6b2b8a3, 0x682e6ff3d6b2b8a3 dq 0x748f82ee5defb2fc, 0x748f82ee5defb2fc, 0x748f82ee5defb2fc, 0x748f82ee5defb2fc dq 0x748f82ee5defb2fc, 0x748f82ee5defb2fc, 0x748f82ee5defb2fc, 0x748f82ee5defb2fc dq 0x78a5636f43172f60, 0x78a5636f43172f60, 0x78a5636f43172f60, 0x78a5636f43172f60 dq 0x78a5636f43172f60, 0x78a5636f43172f60, 0x78a5636f43172f60, 0x78a5636f43172f60 dq 0x84c87814a1f0ab72, 0x84c87814a1f0ab72, 0x84c87814a1f0ab72, 0x84c87814a1f0ab72 dq 0x84c87814a1f0ab72, 0x84c87814a1f0ab72, 0x84c87814a1f0ab72, 0x84c87814a1f0ab72 dq 0x8cc702081a6439ec, 0x8cc702081a6439ec, 0x8cc702081a6439ec, 0x8cc702081a6439ec dq 0x8cc702081a6439ec, 0x8cc702081a6439ec, 0x8cc702081a6439ec, 0x8cc702081a6439ec dq 0x90befffa23631e28, 0x90befffa23631e28, 0x90befffa23631e28, 0x90befffa23631e28 dq 0x90befffa23631e28, 0x90befffa23631e28, 0x90befffa23631e28, 0x90befffa23631e28 dq 0xa4506cebde82bde9, 0xa4506cebde82bde9, 0xa4506cebde82bde9, 0xa4506cebde82bde9 dq 0xa4506cebde82bde9, 0xa4506cebde82bde9, 0xa4506cebde82bde9, 0xa4506cebde82bde9 dq 0xbef9a3f7b2c67915, 0xbef9a3f7b2c67915, 0xbef9a3f7b2c67915, 0xbef9a3f7b2c67915 dq 0xbef9a3f7b2c67915, 0xbef9a3f7b2c67915, 0xbef9a3f7b2c67915, 0xbef9a3f7b2c67915 dq 0xc67178f2e372532b, 0xc67178f2e372532b, 0xc67178f2e372532b, 0xc67178f2e372532b dq 0xc67178f2e372532b, 0xc67178f2e372532b, 0xc67178f2e372532b, 0xc67178f2e372532b dq 0xca273eceea26619c, 0xca273eceea26619c, 0xca273eceea26619c, 0xca273eceea26619c dq 0xca273eceea26619c, 0xca273eceea26619c, 0xca273eceea26619c, 0xca273eceea26619c dq 0xd186b8c721c0c207, 0xd186b8c721c0c207, 0xd186b8c721c0c207, 0xd186b8c721c0c207 dq 0xd186b8c721c0c207, 0xd186b8c721c0c207, 0xd186b8c721c0c207, 0xd186b8c721c0c207 dq 0xeada7dd6cde0eb1e, 0xeada7dd6cde0eb1e, 0xeada7dd6cde0eb1e, 0xeada7dd6cde0eb1e dq 0xeada7dd6cde0eb1e, 0xeada7dd6cde0eb1e, 0xeada7dd6cde0eb1e, 0xeada7dd6cde0eb1e dq 0xf57d4f7fee6ed178, 0xf57d4f7fee6ed178, 0xf57d4f7fee6ed178, 0xf57d4f7fee6ed178 dq 0xf57d4f7fee6ed178, 0xf57d4f7fee6ed178, 0xf57d4f7fee6ed178, 0xf57d4f7fee6ed178 dq 0x06f067aa72176fba, 0x06f067aa72176fba, 0x06f067aa72176fba, 0x06f067aa72176fba dq 0x06f067aa72176fba, 0x06f067aa72176fba, 0x06f067aa72176fba, 0x06f067aa72176fba dq 0x0a637dc5a2c898a6, 0x0a637dc5a2c898a6, 0x0a637dc5a2c898a6, 0x0a637dc5a2c898a6 dq 0x0a637dc5a2c898a6, 0x0a637dc5a2c898a6, 0x0a637dc5a2c898a6, 0x0a637dc5a2c898a6 dq 0x113f9804bef90dae, 0x113f9804bef90dae, 0x113f9804bef90dae, 0x113f9804bef90dae dq 0x113f9804bef90dae, 0x113f9804bef90dae, 0x113f9804bef90dae, 0x113f9804bef90dae dq 0x1b710b35131c471b, 0x1b710b35131c471b, 0x1b710b35131c471b, 0x1b710b35131c471b dq 0x1b710b35131c471b, 0x1b710b35131c471b, 0x1b710b35131c471b, 0x1b710b35131c471b dq 0x28db77f523047d84, 0x28db77f523047d84, 0x28db77f523047d84, 0x28db77f523047d84 dq 0x28db77f523047d84, 0x28db77f523047d84, 0x28db77f523047d84, 0x28db77f523047d84 dq 0x32caab7b40c72493, 0x32caab7b40c72493, 0x32caab7b40c72493, 0x32caab7b40c72493 dq 0x32caab7b40c72493, 0x32caab7b40c72493, 0x32caab7b40c72493, 0x32caab7b40c72493 dq 0x3c9ebe0a15c9bebc, 0x3c9ebe0a15c9bebc, 0x3c9ebe0a15c9bebc, 0x3c9ebe0a15c9bebc dq 0x3c9ebe0a15c9bebc, 0x3c9ebe0a15c9bebc, 0x3c9ebe0a15c9bebc, 0x3c9ebe0a15c9bebc dq 0x431d67c49c100d4c, 0x431d67c49c100d4c, 0x431d67c49c100d4c, 0x431d67c49c100d4c dq 0x431d67c49c100d4c, 0x431d67c49c100d4c, 0x431d67c49c100d4c, 0x431d67c49c100d4c dq 0x4cc5d4becb3e42b6, 0x4cc5d4becb3e42b6, 0x4cc5d4becb3e42b6, 0x4cc5d4becb3e42b6 dq 0x4cc5d4becb3e42b6, 0x4cc5d4becb3e42b6, 0x4cc5d4becb3e42b6, 0x4cc5d4becb3e42b6 dq 0x597f299cfc657e2a, 0x597f299cfc657e2a, 0x597f299cfc657e2a, 0x597f299cfc657e2a dq 0x597f299cfc657e2a, 0x597f299cfc657e2a, 0x597f299cfc657e2a, 0x597f299cfc657e2a dq 0x5fcb6fab3ad6faec, 0x5fcb6fab3ad6faec, 0x5fcb6fab3ad6faec, 0x5fcb6fab3ad6faec dq 0x5fcb6fab3ad6faec, 0x5fcb6fab3ad6faec, 0x5fcb6fab3ad6faec, 0x5fcb6fab3ad6faec dq 0x6c44198c4a475817, 0x6c44198c4a475817, 0x6c44198c4a475817, 0x6c44198c4a475817 dq 0x6c44198c4a475817, 0x6c44198c4a475817, 0x6c44198c4a475817, 0x6c44198c4a475817 align 64 ; this does the big endian to little endian conversion over a quad word .. ZMM ;; shuffle on ZMM is shuffle on 4 XMM size chunks, 128 bits PSHUFFLE_BYTE_FLIP_MASK: ;ddq 0x08090a0b0c0d0e0f0001020304050607 dq 0x0001020304050607, 0x08090a0b0c0d0e0f ;ddq 0x18191a1b1c1d1e1f1011121314151617 dq 0x1011121314151617, 0x18191a1b1c1d1e1f ;ddq 0x28292a2b2c2d2e2f2021222324252627 dq 0x2021222324252627, 0x28292a2b2c2d2e2f ;ddq 0x38393a3b3c3d3e3f3031323334353637 dq 0x3031323334353637, 0x38393a3b3c3d3e3f mksection .text ;; void sha512_x8_avx512(void *input_data, UINT64 *digest[NUM_LANES], const int size) ;; arg 1 : rcx : pointer to input data ;; arg 2 : rdx : pointer to UINT64 digest[8][num_lanes] ;; arg 3 : size in message block lengths (= 128 bytes) MKGLOBAL(sha512_x8_avx512,function,internal) align 64 sha512_x8_avx512: endbranch64 mov rax, rsp sub rsp, STACK_SPACE and rsp, ~63 ; align stack to multiple of 64 mov [rsp + _RSP], rax ;; Initialize digests ; organized uint64 digest[8][num_lanes]; no transpose required ;; Digest is an array of pointers to digests vmovdqu32 A, [STATE + 0*SHA512_DIGEST_ROW_SIZE] vmovdqu32 B, [STATE + 1*SHA512_DIGEST_ROW_SIZE] vmovdqu32 C, [STATE + 2*SHA512_DIGEST_ROW_SIZE] vmovdqu32 D, [STATE + 3*SHA512_DIGEST_ROW_SIZE] vmovdqu32 E, [STATE + 4*SHA512_DIGEST_ROW_SIZE] vmovdqu32 F, [STATE + 5*SHA512_DIGEST_ROW_SIZE] vmovdqu32 G, [STATE + 6*SHA512_DIGEST_ROW_SIZE] vmovdqu32 H, [STATE + 7*SHA512_DIGEST_ROW_SIZE] lea TBL,[rel TABLE] xor IDX, IDX ;; Read in input data address, saving them in registers because ;; they will serve as variables, which we shall keep incrementing mov inp0, [STATE + _data_ptr_sha512 + 0*PTR_SZ] mov inp1, [STATE + _data_ptr_sha512 + 1*PTR_SZ] mov inp2, [STATE + _data_ptr_sha512 + 2*PTR_SZ] mov inp3, [STATE + _data_ptr_sha512 + 3*PTR_SZ] mov inp4, [STATE + _data_ptr_sha512 + 4*PTR_SZ] mov inp5, [STATE + _data_ptr_sha512 + 5*PTR_SZ] mov inp6, [STATE + _data_ptr_sha512 + 6*PTR_SZ] mov inp7, [STATE + _data_ptr_sha512 + 7*PTR_SZ] jmp lloop align 32 lloop: ;; Load 64-byte blocks of data into ZMM registers before ;; performing a 8x8 64-bit transpose. ;; To speed up the transpose, data is loaded in chunks of 32 bytes, ;; interleaving data between lane X and lane X+4. ;; This way, final shuffles between top half and bottom half ;; of the matrix are avoided. TRANSPOSE8_U64_LOAD8 W0, W1, W2, W3, W4, W5, W6, W7, \ inp0, inp1, inp2, inp3, inp4, inp5, \ inp6, inp7, IDX TRANSPOSE8_U64 W0, W1, W2, W3, W4, W5, W6, W7, TMP0, TMP1, TMP2, TMP3 ;; Load next 512 bytes TRANSPOSE8_U64_LOAD8 W8, W9, W10, W11, W12, W13, W14, W15, \ inp0, inp1, inp2, inp3, inp4, inp5, \ inp6, inp7, IDX+SZ8 TRANSPOSE8_U64 W8, W9, W10, W11, W12, W13, W14, W15, TMP0, TMP1, TMP2, TMP3 vmovdqa32 TMP2, [rel PSHUFFLE_BYTE_FLIP_MASK] vmovdqa32 TMP3, [TBL] ; First K ; Save digests for later addition vmovdqa32 [rsp + _DIGEST_SAVE + 64*0], A vmovdqa32 [rsp + _DIGEST_SAVE + 64*1], B vmovdqa32 [rsp + _DIGEST_SAVE + 64*2], C vmovdqa32 [rsp + _DIGEST_SAVE + 64*3], D vmovdqa32 [rsp + _DIGEST_SAVE + 64*4], E vmovdqa32 [rsp + _DIGEST_SAVE + 64*5], F vmovdqa32 [rsp + _DIGEST_SAVE + 64*6], G vmovdqa32 [rsp + _DIGEST_SAVE + 64*7], H add IDX, 128 ; increment by message block length in bytes %assign I 0 %rep 16 ;;; little endian to big endian vpshufb APPEND(W,I), APPEND(W,I), TMP2 %assign I (I+1) %endrep ; MSG Schedule for W0-W15 is now complete in registers ; Process first (max-rounds -16) ; Calculate next Wt+16 after processing is complete and Wt is unneeded ; PROCESS_LOOP_00_79 APPEND(W,J), I, APPEND(W,K), APPEND(W,L), APPEND(W,M) %assign I 0 %assign J 0 %assign K 1 %assign L 9 %assign M 14 %rep SHA_ROUNDS_LESS_16 PROCESS_LOOP APPEND(W,J), I MSG_SCHED_ROUND_16_79 APPEND(W,J), APPEND(W,K), APPEND(W,L), APPEND(W,M) %assign I (I+1) %assign J ((J+1)% 16) %assign K ((K+1)% 16) %assign L ((L+1)% 16) %assign M ((M+1)% 16) %endrep ; Check is this is the last block sub INP_SIZE, 1 je lastLoop ; Process last 16 rounds ; Read in next block msg data for use in first 16 words of msg sched %assign I SHA_ROUNDS_LESS_16 %assign J 0 %rep 16 PROCESS_LOOP APPEND(W,J), I %assign I (I+1) %assign J (J+1) %endrep ; Add old digest vpaddq A, A, [rsp + _DIGEST_SAVE + 64*0] vpaddq B, B, [rsp + _DIGEST_SAVE + 64*1] vpaddq C, C, [rsp + _DIGEST_SAVE + 64*2] vpaddq D, D, [rsp + _DIGEST_SAVE + 64*3] vpaddq E, E, [rsp + _DIGEST_SAVE + 64*4] vpaddq F, F, [rsp + _DIGEST_SAVE + 64*5] vpaddq G, G, [rsp + _DIGEST_SAVE + 64*6] vpaddq H, H, [rsp + _DIGEST_SAVE + 64*7] jmp lloop align 32 lastLoop: ; Process last 16 rounds %assign I SHA_ROUNDS_LESS_16 %assign J 0 %rep 16 PROCESS_LOOP APPEND(W,J), I %assign I (I+1) %assign J (J+1) %endrep ; Add old digest vpaddq A, A, [rsp + _DIGEST_SAVE + 64*0] vpaddq B, B, [rsp + _DIGEST_SAVE + 64*1] vpaddq C, C, [rsp + _DIGEST_SAVE + 64*2] vpaddq D, D, [rsp + _DIGEST_SAVE + 64*3] vpaddq E, E, [rsp + _DIGEST_SAVE + 64*4] vpaddq F, F, [rsp + _DIGEST_SAVE + 64*5] vpaddq G, G, [rsp + _DIGEST_SAVE + 64*6] vpaddq H, H, [rsp + _DIGEST_SAVE + 64*7] ; Write out digest ;; results in A, B, C, D, E, F, G, H vmovdqu32 [STATE + 0*SHA512_DIGEST_ROW_SIZE], A vmovdqu32 [STATE + 1*SHA512_DIGEST_ROW_SIZE], B vmovdqu32 [STATE + 2*SHA512_DIGEST_ROW_SIZE], C vmovdqu32 [STATE + 3*SHA512_DIGEST_ROW_SIZE], D vmovdqu32 [STATE + 4*SHA512_DIGEST_ROW_SIZE], E vmovdqu32 [STATE + 5*SHA512_DIGEST_ROW_SIZE], F vmovdqu32 [STATE + 6*SHA512_DIGEST_ROW_SIZE], G vmovdqu32 [STATE + 7*SHA512_DIGEST_ROW_SIZE], H ; update input pointers %assign I 0 %rep 8 add [STATE + _data_ptr_sha512 + I*PTR_SZ], IDX %assign I (I+1) %endrep %ifdef SAFE_DATA ;; Clear stack frame ((NUM_LANES*8)*64 bytes) clear_all_zmms_asm %assign i 0 %rep (NUM_LANES*8) vmovdqa64 [rsp + i*64], zmm0 %assign i (i+1) %endrep %else vzeroupper %endif mov rsp, [rsp + _RSP] ;hash_done: ret mksection stack-noexec
copyright zengfr site:http://github.com/zengfr/romhack 003AF4 move.l ($2,A1), ($2a,A6) [1p+24, 1p+26, boss+24, boss+26, container+24, container+26, enemy+24, enemy+26, weapon+24, weapon+26] 003AFA move.w ($6,A1), ($30,A6) [1p+2A, 1p+2C, boss+2A, boss+2C, container+2A, container+2C, enemy+2A, enemy+2C, weapon+2A, weapon+2C] 003B2E move.l ($2,A1), ($2a,A6) [1p+24, 1p+26, boss+24, boss+26, container+24, container+26, enemy+24, enemy+26, weapon+24, weapon+26] 003B34 move.w ($6,A1), ($30,A6) [1p+2A, 1p+2C, boss+2A, boss+2C, container+2A, container+2C, enemy+2A, enemy+2C, weapon+2A, weapon+2C] 00A2C6 dbra D0, $a2c0 00A2E8 clr.b ($2a,A4) 00A2EC clr.b ($2b,A4) copyright zengfr site:http://github.com/zengfr/romhack
; --------------------------------------------------------------- ; ------- Copyright 2010 Daniel Valencia; All Rights Reserved. -- ; ------- -- ; ------- bs.asm -- ; ------- -- ; ------- A Boot Loader for FAT12 Filesystems -- ; --------------------------------------------------------------- [BITS 16] jmp short Start ; Go to the REAL entry point. nop OEM_Name db "ZoomZoom" Sector_Size dw 0 Cluster_Sectors db 0 Reserved_Sectors dw 0 FAT_Copies db 0 RD_Entries dw 0 Volume_Sectors dw 0 Medium_Type db 0 FAT_Sectors dw 0 Track_Sectors dw 0 Drive_Heads dw 0 Hidden_Sectors dw 0 ; Make sure there's enough room for _any_ size BPB. ;times 5ah-($-$$) db 0 ; 07dfeh ; --------------------------------------------------------- ; ------- Start: The REAL entry point. -- ; ------- -- ; ------- Purpose: -- ; ------- To set up the main registers -- ; ------- for the next steps. -- ; ------- -- ; ------- Registers Variables -- ; ------- -- ; ------- Input: DL = bootdrive None -- ; ------- -- ; ------- Output: None None -- ; --------------------------------------------------------- Start: xor ax, ax mov ds, ax mov es, ax mov ss, ax mov sp, 4000h mov esi, 7c00h mov edi, BS_ADDRESS mov ecx, 80h rep movsd jmp 0:Start_1 [ORG BS_ADDRESS] Start_1: call Enable_A20 mov eax, [ds:bx] call Print_DWORD_16 call Space mov ax, 0ffffh mov ds, ax mov bx, 10h mov eax, [ds:bx] call Print_DWORD_16 call CrLf mov eax, 0 mov bx, 0 mov [ds:bx], eax mov eax, [ds:bx] call Print_DWORD_16 call Space mov ax, 0ffffh mov ds, ax mov bx, 10h mov ax, [ds:bx] call Print_DWORD_16 call CrLf jmp Error ; mov [bootdrive], dl ; call Enable_A20 ; call Read_Stuff ; lea esi, [Image] ; mov bx, START_ADDRESS / 10h ; call Get_File ; ;Leap: ; call Dot ; . (6) ; push dword Get_File ; Publish Service ; push dword START_ADDRESS ; Inform of starting address ; jmp 0:START_ADDRESS ; ; --------------------------------------------------------- ; ------- Enable_A20: -- ; ------- Disables the masking of A20 that was put -- ; ------- as a backwards-compatibility hack. -- ; --------------------------------------------------------- Enable_A20: call Enable_A20.Wait ; Spin mov al, 0xd1 out 0x64, al call Enable_A20.Wait ; Spin mov al, 0xdf out 0x60, al call Enable_A20.Wait ; Spin ret Enable_A20.Wait: bts ecx, 16 rep nop in al, 0x64 test al, 2 jnz Enable_A20.Wait ret ;; --------------------------------------------------------- ;; ------- Read_Stuff: -- ;; ------- Compute_Stuff -- ;; ------- Read_FAT -- ;; ------- Read_Root -- ;; --------------------------------------------------------- ; ;Read_Stuff: ;Compute_Stuff: ; ; Compute Cylinder_Sectors ; mov ax, word [Track_Sectors] ; mul word [Drive_Heads] ; mov byte [Cylinder_Sectors], al ; Should fit in 8 bits. ; ; ; Compute Cluster_Paras ; mov ax, word [Sector_Size] ; Max. sector size = 2 KiB. ; shr ax, 4 ; AX = Paragraphs per sector. ; mul byte [Cluster_Sectors] ; AX = paragraphs per cluster. ; mov word [Cluster_Paras], ax ; ; ; Compute Root_Start ; mov ax, word [FAT_Sectors] ; Retrieve FAT sectors. ; mov cx, [Reserved_Sectors] ; Retrieve Start of FAT. ; mul byte [FAT_Copies] ; There are FAT copies. ; add ax, cx ; RD starting sector. ; mov word [Root_Start], ax ; Save. ; ; ; Compute Root_Sectors ; movzx eax, word [RD_Entries] ; shl ax, 5 ; 32 bytes per RD entry. ; div word [Sector_Size] ; AX=Sectors in RootDir. ; mov word [Root_Sectors], ax ; Save. ; ; ; Compute Data_Start ; add ax, word [Root_Start] ; AX=Root_Start+Root_Sectors ; mov word [Data_Start], ax ; Save. ; call Dot ; . (2) ; ;Read_FAT: ; mov ax, [Reserved_Sectors] ; First FAT starts here. ; push ax ; mov cx, [FAT_Sectors] ; Sectors in each FAT. ; mov bx, FAT_ADDRESS / 10h ; Load the destination-> ; mov es, bx ; -> segment into ES. ; call Read_Sectors ; call Dot ; . (3) ; ;Read_Root: ; mov ax, word [Root_Start] ; [Root_Start] ; pop cx ; [Root_Sectors] ; mov bx, ROOT_ADDRESS / 10h ; mov es, bx ; call Read_Sectors ; call Dot ; . (4) ; ret ; ; ; ;; --------------------------------------------------------- ;; ------- Get_File: -- ;; ------- Locates a file by name inside -- ;; ------- the Root Directory, and then reads -- ;; ------- its contents. -- ;; ------- -- ;; ------- Input: ES:0=Pointer to root directory. -- ;; ------- BX:0=Pointer to destination. -- ;; ------- -- ;; ------- Output: AX=Number of first cluster. -- ;; ------- CX=File size in bytes. -- ;; ------- -- ;; ------- On Error: Hang. -- ;; --------------------------------------------------------- ; ;Get_File: ; mov ax, ROOT_ADDRESS / 10h ; mov es, ax ; mov eax, esi ;Find_File: ; mov esi, eax ; xor edi, edi ; cmp byte [edi], 0 ; If Empty ; je Error ; Error ; mov ecx, 11 ; Else ; repe cmpsb ; Compare 11 Bytes ; je Find_File.Found ; If Not Found ; mov dx, es ; inc dx ; inc dx ; mov es, dx ; Move To Next Entry ; jmp Find_File ; Repeat ; ;Find_File.Found: ; mov ax, es ; mov ax, word [es:1ah] ; Initial Cluster ; mov cx, word [es:1ch] ; File size in byres. ; ;Read_File: ; push cx ; call Dot ; call Read_Cluster ; pop cx ; cmp ax, 0ff0h ; jnb Read_File.Done ; mov bx, es ; add bx, [Cluster_Paras] ; jmp Read_File ; ;Read_File.Done: ; call Dot ; . (5) ; ret ; ; ;; --------------------------------------------------------- ;; ------- Read_Cluster: -- ;; ------- Reads the contents of a cluster into memory. -- ;; ------- -- ;; ------- Input: AX = Cluster number. -- ;; ------- BX:0 = Pointer to destination. -- ;; ------- -- ;; ------- Output: AX will contain the next -- ;; ------- Cluster's number. -- ;; --------------------------------------------------------- ; ;Read_Cluster: ; ; Starting sector = (Cluster - 2) * Cluster_Sectors ; ; + Data_Start ; push ax ;; push ax ;; call Print_WORD_16 ;; pop ax ; mov es, bx ; sub ax, 2 ; movzx bx, byte [Cluster_Sectors] ; push bx ; mul bx ; DX:AX = AX * BX ; add ax, [Data_Start] ; pop cx ; [Cluster_Sectors] ; call Read_Sectors ; ;Next_Cluster: ; ; BX = (Last_Cluster * 3) / 2 ; pop ax ; mov bx, ax ; shl bx, 1 ; add bx, ax ; mov cx, cs ; shr bx, 1 ; ; ; CX = CF (is Last_Cluster odd?) ; adc cx, cx ; mov ax, [bx+FAT_ADDRESS] ; Read Little-Endian Word. ; shr cx, 1 ; jc Next_Cluster.Odd ; If Even Cluster ; and ax, 0fffh ; Chop last nibble. ; jmp Next_Cluster.Done ; ;Next_Cluster.Odd: ; Else ; shr ax, 4 ; Chop first nibble. ; ;Next_Cluster.Done: ; ret ; ; ; ;; --------------------------------------------------------- ;; ------- Read_Sectors: -- ;; ------- Reads a number of consecutive sectors from -- ;; ------- disk into memory. -- ;; ------- -- ;; ------- Input: CL=Number of sectors to read. -- ;; ------- AX=Number of starting sector. -- ;; ------- -- ;; ------- Output: ES:0=pointer to contents in memory. -- ;; --------------------------------------------------------- ; ;Read_Sectors: ; mov ch, 2 ; Function Number, will end up in ah ; push cx ; Save FN and Number of Sectors ; ; ; Convert LBA to CHS ; mov bl, [Cylinder_Sectors] ; div bl ; mov ch, al ; Save Cylinder Number in CH ; shr ax, 8 ; Shift AH into AL so that AX has the reminder ; mov bl, byte [Track_Sectors] ; div bl ; mov dh, al ; Save Head Number in DH ; mov cl, ah ; Save Sector Number in CL ; inc cl ; ;; pop ax ;; push ax ;; pusha ;; push dx ;; push cx ;; push bx ;; push ax ;; call Dot ;; pop ax ;; call Print_WORD_16 ;; call Dot ;; mov ax, es ;; call Print_WORD_16 ;; call Dot ;; pop ax ;; call Print_WORD_16 ;; call Dot ;; pop ax ;; call Print_WORD_16 ;; call Dot ;; pop ax ;; call Print_WORD_16 ;; popa ; ; ; ; Make the call ; mov bx, cs ; Clear destination offset ; mov dl, [bootdrive] ; Set source drive ; pop ax ; Retrieve FN and NoS ; int 13h ;ret ; ; ; ;; --------------------------------------------------------- ;; ------- Dot: -- ;; ------- Prints a happy dot symbol(2E) in the screen. -- ;; --------------------------------------------------------- ; ;Dot: ; pusha ; mov al, 2eh ; jmp putchar.do ; ;;Comma: ;; pusha ;; mov al, 2ch ;; jmp putchar.do Space: pusha mov al, 20h jmp putchar.do CrLf: pusha mov al, 13h jmp putchar.do putchar: pusha putchar.do: mov ah, 0eh int 10h popa ret Error: mov ah, 'X' call putchar Error.Loop: hlt jmp Error ; --------------------------------------------------------- ; ------- Print_16: -- ; --------------------------------------------------------- Print_16: lodsb cmp al, 0 je Print_16.done call putchar jmp Print_16 Print_16.done: ret Print_DWORD_16: push eax shr eax, 16 call Print_WORD_16 pop eax call Print_WORD_16 ret Print_WORD_16: mov ecx, 4 shl eax, 16 jmp Print_WORD_16.Loop Print_WORD_16.Loop: rol eax, 4 call Print_Digit_16 loop Print_WORD_16.Loop ret Print_Digit_16: pushad and al, 0fh cmp al, 9 ja Print_Digit_16.Alpha or al, 30h Print_Digit_16.PutChar: call putchar popad ret Print_Digit_16.Alpha: add al, 40h - 9 jmp Print_Digit_16.PutChar ; --------------------------------------------------------- ; ------- D a t a -- ; --------------------------------------------------------- NULL_SEGMENT EQU 0000h PM_CODE_SEGMENT EQU 0008h LM_CODE_SEGMENT EQU 0010h DATA_SEGMENT EQU 0018h BS_ADDRESS EQu 0600h FAT_ADDRESS EQU 2000h ROOT_ADDRESS EQU 4000h START_ADDRESS EQU 6000h Image db "START " Cylinder_Sectors db 0 Cluster_Paras dw 0 Root_Sectors dw 0 Root_Start dw 0 Data_Start dw 0 bootdrive db 0 ;fwd dd 0 ;bwd dd 0 ; --------------------------------------------------------- ; ------- M a g i c -- ; --------------------------------------------------------- times 1feh-($-$$) db 0 ; 07dfeh db 055h, 0aah
; ///////////////////////////////////////////////////////////////////////////// ; Znake (ZX Spectrum 48K) ; ----------------------------------------------------------------------------- ; 2_game_init.asm ; ----------------------------------------------------------------------------- ; Copyright (C) 2016, Chris Wyatt ; All rights reserved ; Distributed under the Apache 2 license (see LICENSE) ; ///////////////////////////////////////////////////////////////////////////// init: ; Clear screen ld hl,0x4000 ld de,0x4001 ld bc,0x17ff ld (hl),0 ldir ld iy,draw_line ; Push col/row and memory locations of graphics to stack, ready to draw ; later ; Push top border ld b,16 ; Column/row ld de,0x0803 ; Location of border top ld hl,0x8180 push_top_border_next: push hl push de inc d djnz push_top_border_next ; Push right border ld b,16 ; Location of border right ld hl,0x8188 ; Column/row ld de,0x1804 push_right_border_next: push hl push de inc e djnz push_right_border_next ; Push bottom border ld b,16 ; Location of border top ld hl,0x8190 ; Column/row ld de,0x0814 push_bottom_border_next: push hl push de inc d djnz push_bottom_border_next ; Push left border ld b,16 ; Location of border right ld hl,0x8198 ; Column/row ld de,0x0704 push_left_border_next: push hl push de inc e djnz push_left_border_next ; Push border corners ; Location of border top-right ld hl,0x81a0 ; Column/row ld de,0x1803 push hl push de ; Location of border bottom-right ld hl,0x81a8 ; Column/row ld de,0x1814 push hl push de ; Location of border bottom-left ld hl,0x81b0 ; Column/row ld de,0x0714 push hl push de ; Location of border top-left ld hl,0x81b8 ; Column/row ld de,0x0703 push hl push de ld c,16 + 16 + 16 + 16 + 4 halt draw_border_char: pop de pop hl call draw_char dec c jr nz,draw_border_char ; Initialise snake xor a ; a = 0x00 ld (last_input),a ld (snake_direction_queue),a ld (snake_history_tail_offset),a inc a ; a = 0x01 ld (snake_history_head_offset),a inc a ; a = 0x02 ld (snake_direction_current),a ld a,0x87 ld (TBL_SNAKE_HISTORY),a ld a,0x67 ld (TBL_SNAKE_HISTORY + 1),a ld de,DIFFICULTIES_ROW_LENGTH ld ix,difficulties - DIFFICULTIES_ROW_LENGTH ld a,(difficulty) inc a ld b,a inc_difficulty: add ix,de djnz inc_difficulty ; Set snake speed ld a,(ix + 4) ld (no_of_frames_per_update),a ; Set high score string from value in difficulties table push ix pop hl ld de,5 add hl,de ld de,str_hi_score call gen_score_str ld a,3 ld (snake_length),a ; Reset score ld hl,0x0000 ld (score),hl ; Reset score string ld hl,0x3030 ; '00' ld (str_score),hl ld (str_score + 2),hl ; Score label ld de,0x0802 ld hl,str_score_lbl call print ; High score label ld de,0x1102 ld hl,str_hi_score_lbl call print ; High score ld de,0x1402 ld hl,str_hi_score call print ld a,(flags) ; Set food eaten flag set 0,a ; Invalidate all free squares tables or 0xf0 ld (flags),a ; Initialise previous frame count ld a,(23672) ld (previous_frame_count),a ; Draw initial snake graphics ; Location of snake head left ld hl,0x8120 ; Column/row ld de,0x0e0b ; 6 + 8, 7 + 4 call draw_char ; Location of snake body left/right ld hl,0x8130 ; Column/row ld de,0x0f0b ; 7 + 8, 7 + 4 call draw_char ; Location of snake tail right ld hl,0x8160 ; Column/row ld de,0x100b ; 8 + 8, 7 + 4 call draw_char
Music_DefeatedGymLeader_Ch1:: tempo 112 volume 7, 7 duty_cycle 3 vibrato 18, 3, 1 toggle_perfect_pitch tempo 112 note_type 12, 10, 6 octave 4 note D_, 6 octave 3 note A_, 1 octave 4 note D_, 1 note F#, 6 note D_, 1 note F#, 1 note_type 12, 10, 0 note A_, 8 note_type 12, 10, 7 note A_, 8 Music_DefeatedGymLeader_branch_23ccc:: note_type 12, 11, 2 octave 3 note A_, 2 note A_, 2 note F#, 4 note G_, 2 note G_, 2 note E_, 4 note D_, 2 note E_, 2 note D_, 2 note E_, 2 note D_, 4 note D_, 4 note A_, 2 note A_, 2 note F#, 4 note G_, 2 note G_, 2 note E_, 4 note D_, 2 note E_, 2 note D_, 2 note C#, 2 note_type 12, 11, 1 octave 2 note B_, 8 note_type 12, 11, 2 octave 3 note A_, 2 note A_, 2 note F#, 4 note G_, 2 note G_, 2 note E_, 4 note D_, 2 note E_, 2 note D_, 2 note E_, 2 note D_, 4 note D_, 4 note A_, 2 note A_, 2 note F#, 4 note G_, 2 note G_, 2 note E_, 4 note D_, 2 note E_, 2 note D_, 2 note C#, 2 note_type 12, 11, 1 octave 2 note B_, 8 note_type 12, 9, 7 octave 3 note D_, 6 octave 2 note A_, 1 octave 3 note D_, 1 note F#, 8 note_type 12, 11, 0 note F#, 6 note E_, 1 note F#, 1 note A_, 8 note_type 12, 9, 7 note E_, 6 note C#, 1 note E_, 1 note G#, 8 note_type 12, 11, 0 note G#, 6 note E_, 1 note G#, 1 note B_, 8 note_type 12, 9, 7 note C#, 6 octave 2 note A_, 1 octave 3 note C#, 1 note E_, 8 note_type 12, 11, 0 note E_, 6 note C#, 1 note E_, 1 note E_, 4 note G_, 4 note_type 12, 9, 0 note F#, 8 note E_, 8 note D_, 8 note C#, 8 note_type 12, 9, 7 note D_, 6 octave 2 note A_, 1 octave 3 note D_, 1 note F#, 8 note_type 12, 11, 0 note F#, 6 note E_, 1 note F#, 1 note A_, 8 note_type 12, 9, 7 note E_, 6 note C#, 1 note E_, 1 note G#, 8 note_type 12, 11, 0 note G#, 6 note E_, 1 note G#, 1 note B_, 8 note_type 12, 9, 7 note C#, 6 octave 2 note A_, 1 octave 3 note C#, 1 note E_, 8 note_type 12, 11, 0 note E_, 6 note C#, 1 note E_, 1 note E_, 4 note G_, 4 note_type 12, 9, 7 note F#, 6 note E_, 1 note F#, 1 note A_, 8 note_type 12, 10, 7 note G_, 8 note E_, 8 sound_loop 0, Music_DefeatedGymLeader_branch_23ccc Music_DefeatedGymLeader_Ch2:: duty_cycle 2 vibrato 24, 2, 4 note_type 12, 12, 4 octave 4 note A_, 6 note F#, 1 note A_, 1 octave 5 note D_, 6 octave 4 note A_, 1 octave 5 note D_, 1 note_type 12, 11, 0 note F#, 8 note_type 12, 11, 7 note F#, 8 Music_DefeatedGymLeader_branch_23d84:: note_type 12, 12, 2 octave 4 note D_, 2 note C#, 2 octave 3 note B_, 4 octave 4 note C#, 2 octave 3 note B_, 2 note A_, 4 note B_, 2 note A_, 2 note G_, 2 note F#, 2 note_type 12, 12, 4 note A_, 4 note A_, 4 note_type 12, 12, 2 octave 4 note D_, 2 note C#, 2 octave 3 note B_, 4 octave 4 note C#, 2 octave 3 note B_, 2 note A_, 4 note B_, 2 note A_, 2 note G_, 2 note F#, 2 note_type 12, 12, 1 note D_, 6 note_type 6, 12, 2 note G_, 1 note A_, 1 note B_, 1 octave 4 note C#, 1 note_type 12, 12, 2 note D_, 2 note C#, 2 octave 3 note B_, 4 octave 4 note C#, 2 octave 3 note B_, 2 note A_, 4 note B_, 2 note A_, 2 note G_, 2 note F#, 2 note_type 12, 12, 4 note A_, 4 note A_, 3 note_type 6, 12, 2 note B_, 1 octave 4 note C#, 1 note_type 12, 12, 2 note D_, 2 note C#, 2 octave 3 note B_, 4 octave 4 note C#, 2 octave 3 note B_, 2 note A_, 4 note B_, 2 note A_, 2 note G_, 2 note F#, 2 note_type 12, 12, 1 note D_, 8 note_type 12, 12, 7 note A_, 6 note F#, 1 note A_, 1 note_type 12, 11, 0 octave 4 note D_, 8 note_type 12, 10, 0 note D_, 8 note_type 12, 9, 7 note D_, 8 note_type 12, 12, 7 octave 3 note B_, 6 note G#, 1 note B_, 1 note_type 12, 8, 0 octave 4 note E_, 8 note_type 12, 10, 0 note E_, 8 note_type 12, 12, 7 note E_, 8 octave 3 note G_, 6 note E_, 1 note G_, 1 note_type 12, 6, -7 octave 4 note C#, 8 note_type 12, 12, 7 note C#, 8 note F#, 4 note E_, 4 note_type 12, 11, 0 note D_, 14 octave 3 note B_, 2 note_type 12, 10, 0 note A_, 8 note_type 12, 11, 7 note A_, 8 note_type 12, 12, 7 note A_, 6 note F#, 1 note A_, 1 note_type 12, 11, 0 octave 4 note D_, 8 note_type 12, 10, 0 note D_, 8 note_type 12, 9, 7 note D_, 8 note_type 12, 12, 7 octave 3 note B_, 6 note G#, 1 note B_, 1 note_type 12, 4, -7 octave 4 note E_, 8 note_type 12, 11, 0 note E_, 8 note_type 12, 12, 7 note E_, 8 octave 3 note G_, 6 note E_, 1 note G_, 1 note_type 12, 11, 0 octave 4 note C#, 8 note_type 12, 11, 7 note C#, 8 octave 3 note A_, 4 octave 4 note C#, 4 note_type 12, 11, 0 note D_, 14 note E_, 2 note D_, 12 note_type 12, 12, 2 octave 3 note G_, 1 note A_, 1 note B_, 1 octave 4 note C#, 1 sound_loop 0, Music_DefeatedGymLeader_branch_23d84 Music_DefeatedGymLeader_Ch3:: note_type 12, 1, 0 vibrato 16, 1, 2 octave 4 note F#, 6 note D_, 1 note F#, 1 note A_, 6 note F#, 1 note A_, 1 octave 5 note D_, 6 octave 4 note A_, 1 octave 5 note D_, 1 note F#, 8 Music_DefeatedGymLeader_branch_23e65:: octave 4 note F#, 1 rest 1 note F#, 1 rest 1 note F#, 1 rest 3 note G_, 1 rest 1 note G_, 1 rest 1 note G_, 1 rest 3 note A_, 1 rest 1 note A_, 1 rest 1 note A_, 1 rest 1 note G_, 1 rest 1 note F#, 3 rest 1 note F#, 3 rest 1 note F#, 1 rest 1 note F#, 1 rest 1 note F#, 1 rest 3 note G_, 1 rest 1 note G_, 1 rest 1 note E_, 1 rest 1 note E_, 1 rest 1 note F#, 1 rest 1 note F#, 1 rest 1 note E_, 1 rest 1 note E_, 1 rest 1 note D_, 1 rest 5 note D_, 1 rest 1 note F#, 1 rest 1 note D_, 1 rest 1 note F#, 1 rest 1 note D_, 1 rest 1 note G_, 1 rest 1 note D_, 1 rest 1 note G_, 1 rest 1 note D_, 1 rest 1 note A_, 1 rest 1 note D_, 1 rest 1 note A_, 1 rest 1 note D_, 1 rest 1 note G_, 3 rest 1 note D_, 3 rest 1 note F#, 1 rest 1 note D_, 1 rest 1 note F#, 1 rest 1 note D_, 1 rest 1 note G_, 1 rest 1 note D_, 1 rest 1 note G_, 1 rest 1 note D_, 1 rest 1 note A_, 1 rest 1 note D_, 1 rest 1 note G_, 1 rest 1 note D_, 1 rest 1 note F#, 1 rest 7 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note G#, 2 note F#, 2 note E_, 2 note D#, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note C#, 2 note D_, 2 note E_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note G#, 2 note F#, 2 note E_, 2 note D#, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note E_, 2 note B_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note C#, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note D_, 2 note A_, 2 note G_, 2 note A_, 2 note G_, 2 note E_, 2 sound_loop 0, Music_DefeatedGymLeader_branch_23e65
#include <bgapidef.hpp> #include "bgapi.hpp" #include "bgapi_init.h" /* * Initialize cameras * @return Returns True if the camera systems and at least one camera was correctly initialized */ bool baumer_startup(std::vector<BGAPI::System*>& ppSystem, std::vector<BGAPI::System*>::iterator& systemIter, BGAPI_RESULT& res, std::vector<BGAPI::Camera*>& cameraPointers, std::vector<BGAPI::Image*>& imagePointers, int& camera_num, int& system_count, BGAPI::Image* pImage) { int currSystem = 0; int i = 0; //try to initialize baumer system res = init_systems( &system_count, &ppSystem ); if( res != BGAPI_RESULT_OK ) { printf("init_systems Errorcode: %d\n", res); } ROS_INFO("Baumer Camera init_systems OK. %d systems found\n", system_count); //init all cameras in all systems res = init_cameras( system_count, &ppSystem, &currSystem, camera_num, cameraPointers ); if( res != BGAPI_RESULT_OK ) { ROS_INFO("init_camera Errorcode: %d\n", res); return false; } if (camera_num > 0) { ROS_INFO("init_cameras OK. Found %d Baumer cameras\n", camera_num); } else { ROS_INFO("No cameras detected, finalizing..."); return false; } //set all cameras to BayerRGB8 to save ethernet bandwidth if(!setup_cameras(cameraPointers, "BayerRG8")) { ROS_INFO("Could not setup cameras for capture. Finalizing..."); return false; } //create an image res = BGAPI::createImage( &pImage ); if( res != BGAPI_RESULT_OK ) { ROS_INFO( "Error %d while creating an image.\n", res ); return false; } res = cameraPointers[i]->setImage( pImage ); if( res != BGAPI_RESULT_OK ) { ROS_INFO( "Error %d while setting an image to the camera.\n", res ); return false; } if (!start_cameras(cameraPointers)) { ROS_INFO("Could not create images for capture. Finalizing..."); return false; } return true; } /*! * brightness in this program is defined as the ratio between the pixels with higher values over the lowest ones. * Ratio is calculated splitting the histogram in half, and dividing the number of pixels in the seconf (higher) part * of the histogram (brightness higher than 128) over the total number of pixels. * @param in_image * @return */ float get_image_brightness_percent(cv::Mat& in_image) { cv::Mat histogram; int histSize = 16; float range[] = { 0, 16 } ; const float* histRange = { range }; bool uniform = true; bool accumulate = false; cv::calcHist( &in_image, 1, 0, cv::Mat(), histogram, 1, &histSize, &histRange, uniform, accumulate ); float high_half_samples = 0; float total_samples = 0; for (int k =0; k <= histSize; k++) { if (k >= histSize/2) high_half_samples+=histogram.at<float>(k); total_samples+=histogram.at<float>(k); } float brightness; if(high_half_samples == 0) brightness = 0.0; else brightness = high_half_samples/total_samples; #ifdef VLG22_DEBUG int hist_w = 512; int hist_h = 400; int bin_w = cvRound( (double) hist_w/histSize ); cv::Mat histImage( hist_h, hist_w, CV_8UC3, cv::Scalar( 0,0,0) ); /// Normalize the result to [ 0, histImage.rows ] cv::normalize(histogram, histogram, 0, histImage.rows, cv::NORM_MINMAX, -1, cv::Mat() ); for( int j = 1; j < histSize; j++ ) { total_samples+=histogram.at<float>(j); cv::line( histImage, cv::Point( bin_w*(j-1), hist_h - cvRound(histogram.at<float>(j-1)) ), cv::Point( bin_w*(j), hist_h - cvRound(histogram.at<float>(j)) ), cv::Scalar( 255, 255, 255), 2, 8, 0 ); } std::cout << high_half_samples << "/" << total_samples << "==>" << brightness << std::endl; /// Display cv::imshow("Histogram", histImage ); cv::waitKey(1); #endif return brightness; } /*! * Changes, if possible, the camera time exposure. * @param camera_pointer Valid pointer of the camera to change. * @param exposure New exposure */ void baumer_change_exposure(BGAPI::Camera* camera_pointer, int exposure) { if (camera_pointer == NULL) return; BGAPI_FeatureState state; state.cbSize = sizeof( BGAPI_FeatureState ); BGAPI_RESULT res = BGAPI_RESULT_FAIL; BGAPIX_TypeRangeINT rangedint; rangedint.cbSize = sizeof( BGAPIX_TypeRangeINT ); res = camera_pointer->getExposure( &state, &rangedint ); if( res != BGAPI_RESULT_OK ) { ROS_INFO("BGAPI::Camera::getExposure Errorcode: %d", res); } if (exposure > rangedint.maximum) exposure = rangedint.maximum; if (exposure < rangedint.minimum) exposure = rangedint.minimum; res = camera_pointer->setExposure( exposure ); if( res != BGAPI_RESULT_OK ) { ROS_INFO("BGAPI::Camera::setExposure Errorcode: %d", res); } /*res = camera_pointer->setGain( 2.0 ); if( res != BGAPI_RESULT_OK ) { printf("BGAPI::Camera::setGain Errorcode: %d\n", res); }*/ } void get_ros_params(ros::NodeHandle& node_handle, int& fps, double& scale, double& brightness) { if (node_handle.getParam("fps", fps)) { ROS_INFO("fps set to %d", fps); } else { fps = 20; ROS_INFO("No param received, defaulting fps to %df", fps); } if (node_handle.getParam("scale", scale)) { if (scale > 1.0 || scale < 0.01) { scale = 1.0; } ROS_INFO("scale set to %.2f", scale); } else { scale = 0.5; ROS_INFO("No param received, defaulting scale to %.2f", scale); } if (node_handle.getParam("brightness", brightness)) { if (brightness > 1.0 || brightness < 0.01) { brightness = 0.7; } ROS_INFO("brightness set to %.2f", brightness); } else { brightness = 0.7; ROS_INFO("No param received, defaulting brightness to %.2f", brightness); } } void ros_init_publishers(ros::NodeHandle node_handle, ros::Publisher publishers[], int camera_num) { for (int i = 0; i < camera_num; i++) { std::string topic(std::string("image_raw")); if (camera_num > 1) { topic = "camera" + std::to_string(i) + "/" + topic; } publishers[i] = node_handle.advertise<sensor_msgs::Image>(topic, 100); ROS_INFO("Publishing.. %s", topic.c_str()); } } sensor_msgs::Image ros_prepare_image(int count, cv::Mat image, size_t camera_id) { //ROS publish******************* sensor_msgs::Image msg; msg.header.seq = count; std::string frame = "camera" + std::to_string(camera_id); msg.header.frame_id = frame; msg.header.stamp.sec = ros::Time::now().sec; msg.header.stamp.nsec = ros::Time::now().nsec; msg.height = image.size().height; msg.width = image.size().width; msg.encoding = "rgb8"; msg.step = image.cols * image.elemSize(); size_t image_size = image.rows * image.cols * image.elemSize(); msg.data.resize(image_size); memcpy(msg.data.data(), image.data, image_size); return msg; } void adjust_exposure(BGAPI::Camera* camera_pointer, cv::Mat& bayer_image, float& current_brightness, float threshold_brightness, int& prev_exposure, int& exposure, int exposure_delta) { current_brightness = get_image_brightness_percent(bayer_image); if (current_brightness < threshold_brightness) { if (exposure <= VLG22_MAX_EXPOSURE) { exposure = prev_exposure + exposure_delta; ROS_INFO("Increasing exposure"); baumer_change_exposure(camera_pointer, exposure); } } if (current_brightness == 1.0) { if (exposure >= VLG22_MIN_EXPOSURE) { exposure = prev_exposure - exposure_delta; ROS_INFO("Reducing exposure"); baumer_change_exposure(camera_pointer, exposure); } } prev_exposure = exposure; } int main(int argc, char **argv) { ros::init(argc, argv, "baumer_vlg22"); ros::NodeHandle n; ros::NodeHandle private_nh("~"); ros::Publisher camera_info_pub; int system_count = 0; int camera_num = 0; int fps; double brightness; double scale; get_ros_params(private_nh, fps, scale, brightness); std::vector<BGAPI::System*> ppSystem; std::vector<BGAPI::System*>::iterator systemIter; BGAPI_RESULT res = BGAPI_RESULT_FAIL; std::vector<BGAPI::Camera*> cameraPointers; std::vector<BGAPI::Image*> imagePointers; BGAPI::Image* pImage = NULL; if(!baumer_startup(ppSystem, systemIter, res, cameraPointers, imagePointers, camera_num, system_count, pImage)) { return -1; } //create ros camera publishers ros::Publisher pub[camera_num]; ros_init_publishers(n, pub, camera_num); int receiveTimeout = 1000; int count = 0; ros::Rate loop_rate(fps); // Hz float current_brightness = 0.0; int prev_exposure = VLG22_DEFAULT_EXPOSURE; const int exposure_delta = 1000; while (ros::ok()) { unsigned char* imagebuffer = NULL; int swc = 0; int hwc = 0; int width = 0; int height = 0; int exposure = VLG22_DEFAULT_EXPOSURE; for (unsigned int i = 0; i < cameraPointers.size(); i++) { res = cameraPointers[i]->getImage( &pImage, receiveTimeout ); if( res != BGAPI_RESULT_OK ) { ROS_INFO("BGAPI_Camera_getImage returned with errorcode %d\n", res ); } else { free(imagebuffer); (pImage)->get( &imagebuffer ); (pImage)->getNumber( &swc, &hwc ); res = (pImage)->getSize(&width, &height); if( res != BGAPI_RESULT_OK ) { ROS_INFO("BGAPI::Image::getSize Errorcode: %d", res); } cv::Mat bayer_image(cv::Size(width, height), CV_8UC1, imagebuffer); cv::Mat color_image(cv::Size(width, height), CV_8UC3); cv::cvtColor(bayer_image, color_image, CV_BayerBG2RGB); cv::Mat resized_color_image; cv::resize(color_image, resized_color_image, cv::Size(), scale, scale); adjust_exposure(cameraPointers[i], bayer_image, current_brightness, brightness, prev_exposure, exposure, exposure_delta); sensor_msgs::Image msg = ros_prepare_image(count, resized_color_image, i); pub[i].publish(msg); res = cameraPointers[i]->setImage( pImage ); if( res != BGAPI_RESULT_OK ) { ROS_INFO( "setImage failed with %d\n", res ); } } } ros::spinOnce(); loop_rate.sleep(); count++; } //stop acquisition stop_cameras(cameraPointers); //release the system res = release_systems( &ppSystem ); if( res != BGAPI_RESULT_OK ) { ROS_INFO("release_systems Errorcode: %d\n", res); } //release image memory release_images(&imagePointers); return 0; }
// Copyright (c) 2010-2020, Lawrence Livermore National Security, LLC. Produced // at the Lawrence Livermore National Laboratory. All Rights reserved. See files // LICENSE and NOTICE for details. LLNL-CODE-806117. // // This file is part of the MFEM library. For more information and source code // availability visit https://mfem.org. // // MFEM is free software; you can redistribute it and/or modify it under the // terms of the BSD-3 license. We welcome feedback and contributions, see file // CONTRIBUTING.md for details. #ifndef MFEM_TEXT #define MFEM_TEXT #include <istream> #include <iomanip> #include <sstream> #include <string> #include <limits> #include <algorithm> namespace mfem { // Utilities for text parsing inline void skip_comment_lines(std::istream &is, const char comment_char) { while (1) { is >> std::ws; if (is.peek() != comment_char) { break; } is.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } } // Check for, and remove, a trailing '\r'. inline void filter_dos(std::string &line) { if (!line.empty() && *line.rbegin() == '\r') { line.resize(line.size()-1); } } // Convert an integer to a string inline std::string to_string(int i) { std::stringstream ss; ss << i; // trim leading spaces std::string out_str = ss.str(); out_str = out_str.substr(out_str.find_first_not_of(" \t")); return out_str; } // Convert an integer to a 0-padded string with the given number of 'digits' inline std::string to_padded_string(int i, int digits) { std::ostringstream oss; oss << std::setw(digits) << std::setfill('0') << i; return oss.str(); } // Convert a string to an int inline int to_int(const std::string& str) { int i; std::stringstream(str) >> i; return i; } } #endif
Music_PalletTown:: audio Music_PalletTown, Ch0, Ch1, Ch2 Music_Pokecenter:: audio Music_Pokecenter, Ch0, Ch1, Ch2 Music_Gym:: audio Music_Gym, Ch0, Ch1, Ch2 ; Viridian City, Pewter City, Saffron City Music_Cities1:: audio Music_Cities1, Ch0, Ch1, Ch2, Ch3 ; Cerulean City, Fuchsia City Music_Cities2:: audio Music_Cities2, Ch0, Ch1, Ch2 Music_Celadon:: audio Music_Celadon, Ch0, Ch1, Ch2 Music_Cinnabar:: audio Music_Cinnabar, Ch0, Ch1, Ch2 Music_Vermilion:: audio Music_Vermilion, Ch0, Ch1, Ch2, Ch3 Music_Lavender:: audio Music_Lavender, Ch0, Ch1, Ch2, Ch3 Music_SSAnne:: audio Music_SSAnne, Ch0, Ch1, Ch2 Music_MeetProfOak:: audio Music_MeetProfOak, Ch0, Ch1, Ch2 Music_MeetRival:: audio Music_MeetRival, Ch0, Ch1, Ch2 Music_MuseumGuy:: audio Music_MuseumGuy, Ch0, Ch1, Ch2, Ch3 Music_SafariZone:: audio Music_SafariZone, Ch0, Ch1, Ch2 Music_PkmnHealed:: audio Music_PkmnHealed, Ch0, Ch1, Ch2 ; Routes 1 and 2 Music_Routes1:: audio Music_Routes1, Ch0, Ch1, Ch2, Ch3 ; Routes 24 and 25 Music_Routes2:: audio Music_Routes2, Ch0, Ch1, Ch2, Ch3 ; Routes 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22 Music_Routes3:: audio Music_Routes3, Ch0, Ch1, Ch2, Ch3 ; Routes 11, 12, 13, 14, 15 Music_Routes4:: audio Music_Routes4, Ch0, Ch1, Ch2, Ch3 ; Route 23, Indigo Plateau Music_IndigoPlateau:: audio Music_IndigoPlateau, Ch0, Ch1, Ch2, Ch3
; Sets cursor offset from the cursor offset in cx set_cursor_offset: xor ax, ax ; Clear out a register to get/set I/O bus data shr cx, 1 ; Video buffer has text and attribute data, so multiply offset by 2 mov eax, 14 ; 14 - High byte of cursor offset mov dx, 0x3d4 ; Register Screen Control Address out dx, al ; Query high byte of cursor offset mov al, ch ; High byte of new cursor offset mov dx, 0x3d5 ; Register Screen Data Address out dx, al ; Write high byte of new cursor offset mov eax, 15 ; 15 - Low byte of cursor offset mov dx, 0x3d4 ; Register Screen Control Address out dx, al ; Query low byte of cursor offset mov al, cl ; Low byte of new cursor offset mov dx, 0x3d5 ; Register Screen Data Address out dx, al ; Write low byte of new cursor offset ret ; Stores cursor offset in cx get_cursor_offset: xor ecx, ecx ; Place to store cursor offset xor ax, ax ; Clear out a register to get/set I/O bus data mov eax, 14 ; 14 - High byte of cursor position mov dx, 0x3d4 ; Register Screen Control Address out dx, al ; Query high byte of cursor offset mov dx, 0x3d5 ; Register Screen Data Address in al, dx ; Get high byte of cursor offset mov ch, al ; Store high byte mov eax, 15 ; 15 - Low byte of cursor position mov dx, 0x3d4 ; Register Screen Control Address out dx, al ; Query low byte of cursor offset mov dx, 0x3d5 ; Register Screen Data Address in al, dx ; Get low byte of cursor offset add cl, al ; Add low byte to c register shl cx, 1 ; Double the offset to get the VIDEO_BUFFER offset ret ; Returns with row[eax] and col[edx] get_cursor_position: call get_cursor_offset ; Get cursor offset shr ecx, 1 ; Divide by 2 to get text offset mov eax, ecx ; Move the text offset to eax - to be multiplied mov edx, 0 ; Clear d register to hold remainder mov ecx, 0x50 ; Divide eax by MAX_COLS(0x50) div ecx ; eax/ecx => eax:edx (eax=quotient, edx=remainder) ret ; With row[eax] and col[edx] returns computed offset in[ecx] get_offset: mov ecx, edx ; Store column xor edx, edx ; Clear edx for multiplication mov edx, 0x50 ; Multiply by MAX_COL mul edx ; eax*edx => edx:eax - converts row to offset add ecx, eax ; Add row offset shl ecx, 1 ; Double result since VIDEO_BUFFEER includes attributes ret advance_cursor_offset: push eax push ecx push edx call get_cursor_offset ; Get the offset add ecx, 2 ; Move to the next character call set_cursor_offset ; Move to the next character call _check_bounds ; Ensure we haven't gone past the VIDEO_BUFFER pop edx pop ecx pop eax ret
;;============================================================= ;; vhd_footer: ;; VHD FOOTER. ;; ;VHD_FEATURES EQU 0 ;features ;VHD_FILE_FORMAT_VERSION EQU 0x00001000 ;file format version ;VHD_CREATOR_APP EQU 0x61766D6A ;;0x6A,0x6D,0x76,0x61 ;creator app ;VHD_PLATFORM_VERSION EQU 0x0A000400 ;VHD_PLATFORM_CODE_WI2R EQU 0x57693272 ;WI2R ;VHD_PLATFORM_CODE_WI2K EQU 0x5769326B ;WI2K ;VHD_PLATFORM_CODE_W2RU EQU 0x57327275 ;W2RU ;VHD_PLATFORM_CODE_W2KU EQU 0x57326B75 ;W2KU ;VHD_PLATFORM_CODE_NONE EQU 0 ;NONE ;VHD_PLATFORM_CODE_MAC EQU 0x4D163220 ;MAC ;VHD_PLATFORM_CODE_MACX EQU 0x4D163258 ;MACX ;VHD_PLATFORM_TEST EQU 0x6B326957 ;jรก funcionou. ;VHD_PLATFORM EQU VHD_PLATFORM_TEST ;VHD_ORIGINAL_SIZE_PART1 EQU 0 ;VHD_ORIGINAL_SIZE_PART2 EQU 0x00000001 ;16MB ;VHD_ORIGINAL_SIZE_PART2 EQU 0x00000002 ;32MB ;VHD_CURRENT_SIZE_PART1 EQU 0 ;VHD_CURRENT_SIZE_PART2 EQU 0x00000001 ;16MB ;VHD_CURRENT_SIZE_PART2 EQU 0x00000002 ;32MB ;VHD_FOOTER_DISK_GEOMETRY_CYLINDER EQU 0xC303 ;*49923 ;VHD_FOOTER_DISK_GEOMETRY_HEADS EQU 4 ;*4 ;VHD_FOOTER_DISK_GEOMETRY_SECTORS EQU 0x11 ;*17 ;VHD_FOOTER_DISK_TYPE EQU 2 ;FIXED 0x02000000 ;VHD_FOOTER_DISK_TYPE EQU 3 ;DYNAMIC ;VHD_FOOTER_DISK_TYPE EQU 4 ;DIFFERENCING ;VHD_FOOTER_CHECKSUM EQU 0xDBE6FFFF ;vhdSize=32MB partitionSize=8 ;VHD_FOOTER_CHECKSUM EQU 0xDBE6FFFF ;vhdSize=32MB partitionSize=16 ;VHD_FOOTER_CHECKSUM EQU 0xD0E8FFFF ;vhdSize=32MB partitionSize=16 ;VHD_FOOTER_CHECKSUM EQU 0xC2E7FFFF ;funcionou com vhdsize=32MB patitionSize=32MB. ;;... ;; History: ;; 2016 - Created by Fred Nora. vhd_footer: ;; .cookie: db 'conectix' .features: dd 0 .version: dd 0x00001000 .dataOffset: dd 0xFFFFFFFF, 0xFFFFFFFF .timeStamp: dd 0x5868091E .creatorApp: db 0x6A, 0x6D, 0x76, 0x61 .creatorVersion: dd 0x0A000400 .creatorOS: dd 0x6B326957 .originalSyze: dd 0, 0x00000002 ;bytes. .currentSyze: dd 0, 0x00000002 ;bytes. .diskGeometry: dw 0xC303 ;# Cylinders. db 4 ;# Heads. db 0x11 ;# Sectors. .diskType: dd 0x02000000 ;fixed. .chechsum: dd 0xC2E7FFFF .uniqueID: db 0x11, 0x80, 0xF2, 0x62 db 0xD4, 0x95, 0x65, 0x44 db 0x88, 0x88, 0x88, 0x88 db 0x88, 0x88, 0x88, 0x88 .savedState: db 0 .reserved: times 427 db 0
; A141597: Triangle T(n,k) = 2*binomial(n,k)^2-1, read by rows, 0<=k<=n. ; 1,1,1,1,7,1,1,17,17,1,1,31,71,31,1,1,49,199,199,49,1,1,71,449,799,449,71,1,1,97,881,2449,2449,881,97,1,1,127,1567,6271,9799,6271,1567,127,1,1,161,2591,14111,31751,31751,14111,2591,161,1,1,199,4049,28799,88199 seq $0,7318 ; Pascal's triangle read by rows: C(n,k) = binomial(n,k) = n!/(k!*(n-k)!), 0 <= k <= n. pow $0,2 mul $0,2 sub $0,1
db "TADPOLE@" ; species name dw 200, 270 ; height, weight db "The swirl on its" next "belly is its" next "insides showing" page "through the skin." next "It looks clearer" next "after it eats.@"
; A047447: Numbers that are congruent to {2, 3, 5, 6} mod 8. ; 2,3,5,6,10,11,13,14,18,19,21,22,26,27,29,30,34,35,37,38,42,43,45,46,50,51,53,54,58,59,61,62,66,67,69,70,74,75,77,78,82,83,85,86,90,91,93,94,98,99,101,102,106,107,109,110,114,115,117,118,122,123 mov $1,$0 div $0,2 mov $2,$0 mul $0,2 gcd $2,2 add $0,$2 add $1,$0
; void *tshr_py2saddr(uchar y) SECTION code_clib SECTION code_arch PUBLIC tshr_py2saddr EXTERN zx_py2saddr defc tshr_py2saddr = zx_py2saddr
// coding: utf-8 // ---------------------------------------------------------------------------- /* Copyright (c) 2009, Roboterclub Aachen e.V. * 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 the Roboterclub Aachen e.V. 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 ROBOTERCLUB AACHEN E.V. ''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 ROBOTERCLUB AACHEN E.V. 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. */ // ---------------------------------------------------------------------------- #ifndef FAKE_POSTMAN_HPP #define FAKE_POSTMAN_HPP #include <xpcc/communication/postman/postman.hpp> #include <xpcc/container/linked_list.hpp> #include "testing_component_1.hpp" #include "testing_component_2.hpp" #include "message.hpp" /** * * * \see DispatcherTest */ class FakePostman : public xpcc::Postman { public: virtual DeliverInfo deliverPacket(const xpcc::Header& header, const xpcc::SmartPointer& payload); virtual bool isComponentAvaliable(uint8_t component) const; public: xpcc::LinkedList<Message> messagesToDeliver; TestingComponent1 *component1; ///< must be created external! TestingComponent2 *component2; ///< must be created external! }; #endif // FAKE_POSTMAN_HPP
* Network server driver V0.0  1985 Tony Tebby QJUMP * section nd * xdef ns_io IO entry xdef ns_open open entry * xref nd_read0 read a packet xref nd_send0 send a packet * include dev8_dd_qlnd_keys * * Open nsv channel * ns_open sub.l a3,a3 point to parameters!! move.w io.name,a2 and decode the name jsr (a2) bra.s nso_exit ... oops bra.s nso_exit ... oops bra.s nso_do ... NET recognised * dc.w 3,'NSV' name is nsv dc.w 0 no parameters * nso_do move.l #nd_fend,d1 allocate large net block move.w mm.alchp,a2 allocate in common heap jsr (a2) bne.s nso_rts * moveq #$ffffff80,d5 set msb of station or.b sv_netnr(a6),d5 move.b d5,nd_self(a0) set myself nso_exit nso_rts rts * * Network IO * ns_io lea nd_data(a0),a1 set block pointer subq.b #io.fstrg,d0 fetch? beq.s ns_read ... yes, read packet move.l a2,d1 find length of packet sub.l a1,d1 move.b d2,nd_type(a0) set type addq.b #-nf.sblk,d2 is it send block? bne.s ns_send ... no addq.w #3,d1 ... yes, length in long words lsr.w #2,d1 ns_send move.b d1,nd_nbyt(a0) set length bra.l nd_send0 then send packet * ns_read move.b nd_self(a0),nd_dest(a0) read from anybody bsr.l nd_read0 read packet move.b nd_type(a0),d1 set type rts end
; A047358: Numbers that are congruent to {2, 3} mod 7. ; 2,3,9,10,16,17,23,24,30,31,37,38,44,45,51,52,58,59,65,66,72,73,79,80,86,87,93,94,100,101,107,108,114,115,121,122,128,129,135,136,142,143,149,150,156,157,163,164,170,171,177,178,184,185,191,192,198,199,205,206,212,213,219,220,226,227,233,234,240,241,247,248,254,255,261,262,268,269,275,276,282,283,289,290,296,297,303,304,310,311,317,318,324,325,331,332,338,339,345,346,352,353,359,360,366,367,373,374,380,381,387,388,394,395,401,402,408,409,415,416,422,423,429,430,436,437,443,444,450,451,457,458,464,465,471,472,478,479,485,486,492,493,499,500,506,507,513,514,520,521,527,528,534,535,541,542,548,549,555,556,562,563,569,570,576,577,583,584,590,591,597,598,604,605,611,612,618,619,625,626,632,633,639,640,646,647,653,654,660,661,667,668,674,675,681,682,688,689,695,696,702,703,709,710,716,717,723,724,730,731,737,738,744,745,751,752,758,759,765,766,772,773,779,780,786,787,793,794,800,801,807,808,814,815,821,822,828,829,835,836,842,843,849,850,856,857,863,864,870,871 mov $1,$0 div $0,2 mul $0,5 add $1,$0 add $1,2
SECTION smc_clib SECTION smc_sound_bit PUBLIC _bitfx_12 INCLUDE "config_private.inc" EXTERN asm_bit_open _bitfx_12: ; TSpace 2 ld a,230 ld (ts_FR_1 + 1),a xor a ld (ts_FR_2 + 1),a call asm_bit_open ld b,200 t2_loop: dec h jr nz, t2_jump xor __SOUND_BIT_TOGGLE INCLUDE "sound/bit/z80/output_bit_device_2.inc" push bc ld b,250 wait1: djnz wait1 pop bc xor __SOUND_BIT_TOGGLE INCLUDE "sound/bit/z80/output_bit_device_2.inc" ts_FR_1: ld h,230 t2_jump: inc l jr nz, t2_loop push af ld a,(ts_FR_2 + 1) inc a ld (ts_FR_2 + 1),a pop af xor __SOUND_BIT_TOGGLE INCLUDE "sound/bit/z80/output_bit_device_2.inc" push bc ld b,200 wait2: djnz wait2 pop bc xor __SOUND_BIT_TOGGLE INCLUDE "sound/bit/z80/output_bit_device_2.inc" ts_FR_2: ld l,0 djnz t2_loop ret
; A134015: Expansion of (1 - phi(-q) * phi(q^4)) / 2 in powers of q where phi() is a Ramanujan theta function. ; Submitted by Jon Maiga ; 1,0,0,-2,2,0,0,-2,1,0,0,0,2,0,0,-2,2,0,0,-4,0,0,0,0,3,0,0,0,2,0,0,-2,0,0,0,-2,2,0,0,-4,2,0,0,0,2,0,0,0,1,0,0,-4,2,0,0,0,0,0,0,0,2,0,0,-2,4,0,0,-4,0,0,0,-2,2,0,0,0,0,0,0,-4,1,0,0,0,4,0,0,0,2,0,0,0,0,0,0,0,2,0,0,-6 mov $1,$0 mod $0,4 seq $1,105673 ; One-half of theta series of square lattice (or half the number of ways of writing n > 0 as a sum of 2 squares), without the constant term, which is 1/2. mul $0,$1 sub $1,$0 mov $0,$1 div $0,2
;-------------------------------------------------------- ; File Created by SDCC : free open source ANSI-C Compiler ; Version 4.1.6 #12419 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- EXTERN __divschar EXTERN __divschar_callee EXTERN __divsint EXTERN __divsint_callee EXTERN __divslong EXTERN __divslong_callee EXTERN __divslonglong EXTERN __divslonglong_callee EXTERN __divsuchar EXTERN __divsuchar_callee EXTERN __divuchar EXTERN __divuchar_callee EXTERN __divuint EXTERN __divuint_callee EXTERN __divulong EXTERN __divulong_callee EXTERN __divulonglong EXTERN __divulonglong_callee EXTERN __divuschar EXTERN __divuschar_callee EXTERN __modschar EXTERN __modschar_callee EXTERN __modsint EXTERN __modsint_callee EXTERN __modslong EXTERN __modslong_callee EXTERN __modslonglong EXTERN __modslonglong_callee EXTERN __modsuchar EXTERN __modsuchar_callee EXTERN __moduchar EXTERN __moduchar_callee EXTERN __moduint EXTERN __moduint_callee EXTERN __modulong EXTERN __modulong_callee EXTERN __modulonglong EXTERN __modulonglong_callee EXTERN __moduschar EXTERN __moduschar_callee EXTERN __mulint EXTERN __mulint_callee EXTERN __mullong EXTERN __mullong_callee EXTERN __mullonglong EXTERN __mullonglong_callee EXTERN __mulschar EXTERN __mulschar_callee EXTERN __mulsuchar EXTERN __mulsuchar_callee EXTERN __muluchar EXTERN __muluchar_callee EXTERN __muluschar EXTERN __muluschar_callee EXTERN __rlslonglong EXTERN __rlslonglong_callee EXTERN __rlulonglong EXTERN __rlulonglong_callee EXTERN __rrslonglong EXTERN __rrslonglong_callee EXTERN __rrulonglong EXTERN __rrulonglong_callee EXTERN ___sdcc_call_hl EXTERN ___sdcc_call_iy EXTERN ___sdcc_enter_ix EXTERN banked_call EXTERN _banked_ret EXTERN ___fs2schar EXTERN ___fs2schar_callee EXTERN ___fs2sint EXTERN ___fs2sint_callee EXTERN ___fs2slong EXTERN ___fs2slong_callee EXTERN ___fs2slonglong EXTERN ___fs2slonglong_callee EXTERN ___fs2uchar EXTERN ___fs2uchar_callee EXTERN ___fs2uint EXTERN ___fs2uint_callee EXTERN ___fs2ulong EXTERN ___fs2ulong_callee EXTERN ___fs2ulonglong EXTERN ___fs2ulonglong_callee EXTERN ___fsadd EXTERN ___fsadd_callee EXTERN ___fsdiv EXTERN ___fsdiv_callee EXTERN ___fseq EXTERN ___fseq_callee EXTERN ___fsgt EXTERN ___fsgt_callee EXTERN ___fslt EXTERN ___fslt_callee EXTERN ___fsmul EXTERN ___fsmul_callee EXTERN ___fsneq EXTERN ___fsneq_callee EXTERN ___fssub EXTERN ___fssub_callee EXTERN ___schar2fs EXTERN ___schar2fs_callee EXTERN ___sint2fs EXTERN ___sint2fs_callee EXTERN ___slong2fs EXTERN ___slong2fs_callee EXTERN ___slonglong2fs EXTERN ___slonglong2fs_callee EXTERN ___uchar2fs EXTERN ___uchar2fs_callee EXTERN ___uint2fs EXTERN ___uint2fs_callee EXTERN ___ulong2fs EXTERN ___ulong2fs_callee EXTERN ___ulonglong2fs EXTERN ___ulonglong2fs_callee EXTERN ____sdcc_2_copy_src_mhl_dst_deix EXTERN ____sdcc_2_copy_src_mhl_dst_bcix EXTERN ____sdcc_4_copy_src_mhl_dst_deix EXTERN ____sdcc_4_copy_src_mhl_dst_bcix EXTERN ____sdcc_4_copy_src_mhl_dst_mbc EXTERN ____sdcc_4_ldi_nosave_bc EXTERN ____sdcc_4_ldi_save_bc EXTERN ____sdcc_4_push_hlix EXTERN ____sdcc_4_push_mhl EXTERN ____sdcc_lib_setmem_hl EXTERN ____sdcc_ll_add_de_bc_hl EXTERN ____sdcc_ll_add_de_bc_hlix EXTERN ____sdcc_ll_add_de_hlix_bc EXTERN ____sdcc_ll_add_de_hlix_bcix EXTERN ____sdcc_ll_add_deix_bc_hl EXTERN ____sdcc_ll_add_deix_hlix EXTERN ____sdcc_ll_add_hlix_bc_deix EXTERN ____sdcc_ll_add_hlix_deix_bc EXTERN ____sdcc_ll_add_hlix_deix_bcix EXTERN ____sdcc_ll_asr_hlix_a EXTERN ____sdcc_ll_asr_mbc_a EXTERN ____sdcc_ll_copy_src_de_dst_hlix EXTERN ____sdcc_ll_copy_src_de_dst_hlsp EXTERN ____sdcc_ll_copy_src_deix_dst_hl EXTERN ____sdcc_ll_copy_src_deix_dst_hlix EXTERN ____sdcc_ll_copy_src_deixm_dst_hlsp EXTERN ____sdcc_ll_copy_src_desp_dst_hlsp EXTERN ____sdcc_ll_copy_src_hl_dst_de EXTERN ____sdcc_ll_copy_src_hlsp_dst_de EXTERN ____sdcc_ll_copy_src_hlsp_dst_deixm EXTERN ____sdcc_ll_lsl_hlix_a EXTERN ____sdcc_ll_lsl_mbc_a EXTERN ____sdcc_ll_lsr_hlix_a EXTERN ____sdcc_ll_lsr_mbc_a EXTERN ____sdcc_ll_push_hlix EXTERN ____sdcc_ll_push_mhl EXTERN ____sdcc_ll_sub_de_bc_hl EXTERN ____sdcc_ll_sub_de_bc_hlix EXTERN ____sdcc_ll_sub_de_hlix_bc EXTERN ____sdcc_ll_sub_de_hlix_bcix EXTERN ____sdcc_ll_sub_deix_bc_hl EXTERN ____sdcc_ll_sub_deix_hlix EXTERN ____sdcc_ll_sub_hlix_bc_deix EXTERN ____sdcc_ll_sub_hlix_deix_bc EXTERN ____sdcc_ll_sub_hlix_deix_bcix EXTERN ____sdcc_load_debc_deix EXTERN ____sdcc_load_dehl_deix EXTERN ____sdcc_load_debc_mhl EXTERN ____sdcc_load_hlde_mhl EXTERN ____sdcc_store_dehl_bcix EXTERN ____sdcc_store_debc_hlix EXTERN ____sdcc_store_debc_mhl EXTERN ____sdcc_cpu_pop_ei EXTERN ____sdcc_cpu_pop_ei_jp EXTERN ____sdcc_cpu_push_di EXTERN ____sdcc_outi EXTERN ____sdcc_outi_128 EXTERN ____sdcc_outi_256 EXTERN ____sdcc_ldi EXTERN ____sdcc_ldi_128 EXTERN ____sdcc_ldi_256 EXTERN ____sdcc_4_copy_srcd_hlix_dst_deix EXTERN ____sdcc_4_and_src_mbc_mhl_dst_deix EXTERN ____sdcc_4_or_src_mbc_mhl_dst_deix EXTERN ____sdcc_4_xor_src_mbc_mhl_dst_deix EXTERN ____sdcc_4_or_src_dehl_dst_bcix EXTERN ____sdcc_4_xor_src_dehl_dst_bcix EXTERN ____sdcc_4_and_src_dehl_dst_bcix EXTERN ____sdcc_4_xor_src_mbc_mhl_dst_debc EXTERN ____sdcc_4_or_src_mbc_mhl_dst_debc EXTERN ____sdcc_4_and_src_mbc_mhl_dst_debc EXTERN ____sdcc_4_cpl_src_mhl_dst_debc EXTERN ____sdcc_4_xor_src_debc_mhl_dst_debc EXTERN ____sdcc_4_or_src_debc_mhl_dst_debc EXTERN ____sdcc_4_and_src_debc_mhl_dst_debc EXTERN ____sdcc_4_and_src_debc_hlix_dst_debc EXTERN ____sdcc_4_or_src_debc_hlix_dst_debc EXTERN ____sdcc_4_xor_src_debc_hlix_dst_debc ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- GLOBAL _m32_logf ;-------------------------------------------------------- ; Externals used ;-------------------------------------------------------- GLOBAL _m32_polyf GLOBAL _m32_hypotf GLOBAL _m32_ldexpf GLOBAL _m32_frexpf GLOBAL _m32_invsqrtf GLOBAL _m32_sqrtf GLOBAL _m32_invf GLOBAL _m32_sqrf GLOBAL _m32_div2f GLOBAL _m32_mul2f GLOBAL _m32_modff GLOBAL _m32_fmodf GLOBAL _m32_roundf GLOBAL _m32_floorf GLOBAL _m32_fabsf GLOBAL _m32_ceilf GLOBAL _m32_powf GLOBAL _m32_log10f GLOBAL _m32_log2f GLOBAL _m32_exp10f GLOBAL _m32_exp2f GLOBAL _m32_expf GLOBAL _m32_atanhf GLOBAL _m32_acoshf GLOBAL _m32_asinhf GLOBAL _m32_tanhf GLOBAL _m32_coshf GLOBAL _m32_sinhf GLOBAL _m32_atan2f GLOBAL _m32_atanf GLOBAL _m32_acosf GLOBAL _m32_asinf GLOBAL _m32_tanf GLOBAL _m32_cosf GLOBAL _m32_sinf GLOBAL _poly_callee GLOBAL _poly GLOBAL _exp10_fastcall GLOBAL _exp10 GLOBAL _mul10u_fastcall GLOBAL _mul10u GLOBAL _mul2_fastcall GLOBAL _mul2 GLOBAL _div2_fastcall GLOBAL _div2 GLOBAL _invsqrt_fastcall GLOBAL _invsqrt GLOBAL _inv_fastcall GLOBAL _inv GLOBAL _sqr_fastcall GLOBAL _sqr GLOBAL _isunordered_callee GLOBAL _isunordered GLOBAL _islessgreater_callee GLOBAL _islessgreater GLOBAL _islessequal_callee GLOBAL _islessequal GLOBAL _isless_callee GLOBAL _isless GLOBAL _isgreaterequal_callee GLOBAL _isgreaterequal GLOBAL _isgreater_callee GLOBAL _isgreater GLOBAL _fma_callee GLOBAL _fma GLOBAL _fmin_callee GLOBAL _fmin GLOBAL _fmax_callee GLOBAL _fmax GLOBAL _fdim_callee GLOBAL _fdim GLOBAL _nexttoward_callee GLOBAL _nexttoward GLOBAL _nextafter_callee GLOBAL _nextafter GLOBAL _nan_fastcall GLOBAL _nan GLOBAL _copysign_callee GLOBAL _copysign GLOBAL _remquo_callee GLOBAL _remquo GLOBAL _remainder_callee GLOBAL _remainder GLOBAL _fmod_callee GLOBAL _fmod GLOBAL _modf_callee GLOBAL _modf GLOBAL _trunc_fastcall GLOBAL _trunc GLOBAL _lround_fastcall GLOBAL _lround GLOBAL _round_fastcall GLOBAL _round GLOBAL _lrint_fastcall GLOBAL _lrint GLOBAL _rint_fastcall GLOBAL _rint GLOBAL _nearbyint_fastcall GLOBAL _nearbyint GLOBAL _floor_fastcall GLOBAL _floor GLOBAL _ceil_fastcall GLOBAL _ceil GLOBAL _tgamma_fastcall GLOBAL _tgamma GLOBAL _lgamma_fastcall GLOBAL _lgamma GLOBAL _erfc_fastcall GLOBAL _erfc GLOBAL _erf_fastcall GLOBAL _erf GLOBAL _cbrt_fastcall GLOBAL _cbrt GLOBAL _sqrt_fastcall GLOBAL _sqrt GLOBAL _pow_callee GLOBAL _pow GLOBAL _hypot_callee GLOBAL _hypot GLOBAL _fabs_fastcall GLOBAL _fabs GLOBAL _logb_fastcall GLOBAL _logb GLOBAL _log2_fastcall GLOBAL _log2 GLOBAL _log1p_fastcall GLOBAL _log1p GLOBAL _log10_fastcall GLOBAL _log10 GLOBAL _log_fastcall GLOBAL _log GLOBAL _scalbln_callee GLOBAL _scalbln GLOBAL _scalbn_callee GLOBAL _scalbn GLOBAL _ldexp_callee GLOBAL _ldexp GLOBAL _ilogb_fastcall GLOBAL _ilogb GLOBAL _frexp_callee GLOBAL _frexp GLOBAL _expm1_fastcall GLOBAL _expm1 GLOBAL _exp2_fastcall GLOBAL _exp2 GLOBAL _exp_fastcall GLOBAL _exp GLOBAL _tanh_fastcall GLOBAL _tanh GLOBAL _sinh_fastcall GLOBAL _sinh GLOBAL _cosh_fastcall GLOBAL _cosh GLOBAL _atanh_fastcall GLOBAL _atanh GLOBAL _asinh_fastcall GLOBAL _asinh GLOBAL _acosh_fastcall GLOBAL _acosh GLOBAL _tan_fastcall GLOBAL _tan GLOBAL _sin_fastcall GLOBAL _sin GLOBAL _cos_fastcall GLOBAL _cos GLOBAL _atan2_callee GLOBAL _atan2 GLOBAL _atan_fastcall GLOBAL _atan GLOBAL _asin_fastcall GLOBAL _asin GLOBAL _acos_fastcall GLOBAL _acos GLOBAL _m32_coeff_logf ;-------------------------------------------------------- ; special function registers ;-------------------------------------------------------- ;-------------------------------------------------------- ; ram data ;-------------------------------------------------------- SECTION bss_compiler ;-------------------------------------------------------- ; ram data ;-------------------------------------------------------- IF 0 ; .area _INITIALIZED removed by z88dk ENDIF ;-------------------------------------------------------- ; absolute external ram data ;-------------------------------------------------------- SECTION IGNORE ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- SECTION code_crt_init ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- SECTION IGNORE ;-------------------------------------------------------- ; code ;-------------------------------------------------------- SECTION code_compiler ; --------------------------------- ; Function m32_logf ; --------------------------------- _m32_logf: push ix ld ix,0 add ix,sp ld c, l ld b, h ld hl, -18 add hl, sp ld sp, hl ld (ix-6),c ld (ix-5),b ld (ix-4),e ld l, e ld (ix-3),d ld h,d push hl ld l,(ix-6) ld h,(ix-5) push hl ld hl,0x0000 push hl push hl call ___fslt_callee bit 0,l jr NZ,l_m32_logf_00102 ld de,0xff00 ld hl,0x0000 jp l_m32_logf_00106 l_m32_logf_00102: ld hl,16 add hl, sp push hl ld l,(ix-4) ld h,(ix-3) push hl ld l,(ix-6) ld h,(ix-5) push hl call _m32_frexpf push hl ld c,l ld b,h push de ld hl,0x3f35 push hl ld hl,0x04f3 push hl push de push bc call ___fslt_callee ld (ix-3),l pop de pop bc ld a,(ix-3) or a, a jr Z,l_m32_logf_00104 ld l,(ix-2) ld h,(ix-1) dec hl ld (ix-2),l ld (ix-1),h ld l, c ld h, b call _m32_mul2f ld bc,0x3f80 push bc ld bc,0x0000 push bc push de push hl call ___fssub_callee ex (sp), hl ld (ix-16),e ld (ix-15),d jr l_m32_logf_00105 l_m32_logf_00104: ld hl,0x3f80 push hl ld hl,0x0000 push hl push de push bc call ___fssub_callee ex (sp), hl ld (ix-16),e ld (ix-15),d l_m32_logf_00105: pop hl push hl ld e,(ix-16) ld d,(ix-15) call _m32_sqrf ld (ix-14),l ld (ix-13),h ld (ix-12),e ld (ix-11),d ld hl,0x0009 push hl ld hl,_m32_coeff_logf push hl ld l,(ix-16) ld h,(ix-15) push hl ld l,(ix-18) ld h,(ix-17) push hl call _m32_polyf ld c,(ix-12) ld b,(ix-11) push bc ld c,(ix-14) ld b,(ix-13) push bc push de push hl call ___fsmul_callee ld (ix-6),l ld (ix-5),h ld (ix-4),e ld (ix-3),d ld l,(ix-2) ld h,(ix-1) push hl call ___sint2fs_callee ld (ix-10),l ld (ix-9),h ld (ix-8),e ld (ix-7),d push de push hl ld hl,0xb95e push hl ld hl,0x8083 push hl call ___fsmul_callee push de push hl ld l,(ix-4) ld h,(ix-3) push hl ld l,(ix-6) ld h,(ix-5) push hl call ___fsadd_callee ld (ix-6),l ld (ix-5),h ld (ix-4),e ld (ix-3),d ld l,(ix-14) ld h,(ix-13) ld e,(ix-12) ld d,(ix-11) call _m32_div2f push de push hl ld l,(ix-4) ld h,(ix-3) push hl ld l,(ix-6) ld h,(ix-5) push hl call ___fssub_callee push de push hl ld l,(ix-16) ld h,(ix-15) push hl ld l,(ix-18) ld h,(ix-17) push hl call ___fsadd_callee ld (ix-6),l ld (ix-5),h ld (ix-4),e ld (ix-3),d ld l,(ix-8) ld h,(ix-7) push hl ld l,(ix-10) ld h,(ix-9) push hl ld hl,0x3f31 push hl ld hl,0x8000 push hl call ___fsmul_callee push de push hl ld l,(ix-4) ld h,(ix-3) push hl ld l,(ix-6) ld h,(ix-5) push hl call ___fsadd_callee l_m32_logf_00106: ld sp, ix pop ix ret SECTION IGNORE
; A135293: Differences between successive numbers whose sum of digits in base 3 is 2. ; Submitted by Jon Maiga ; 2,2,2,4,2,6,10,2,6,18,28,2,6,18,54,82,2,6,18,54,162,244,2,6,18,54,162,486,730,2,6,18,54,162,486,1458,2188,2,6,18,54,162,486,1458,4374,6562,2,6,18,54,162,486,1458,4374,13122,19684,2,6,18,54,162,486,1458,4374,13122,39366,59050,2,6,18,54,162,486,1458,4374,13122,39366,118098,177148,2,6,18,54,162,486,1458,4374,13122,39366,118098,354294,531442,2,6,18,54,162,486,1458,4374 mov $3,2 mov $5,$0 lpb $3 mov $0,$5 sub $3,1 add $0,$3 trn $0,1 seq $0,55235 ; Sums of two powers of 3. mov $2,$3 mul $2,$0 add $4,$2 lpe min $5,1 mul $5,$0 mov $0,$4 sub $0,$5
/* MIT License Copyright (c) 2021 Edgar Malagรณn Calderรณn 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 "Plugin.hpp" #include <iostream> Plugin::Factory* Plugin::factory = nullptr; Plugin* Plugin::newPlugin() { if(Plugin::factory) { // If a factory is available then return whatever it returns return Plugin::factory->newPlugin(); } else { // Instead of throwing an exception a default implementation // can be returned throw std::runtime_error("Plugin not available"); } } Plugin::Factory::Factory() { // Register this as default factory factory = this; } Plugin::Factory::~Factory() { // Deregister this factory factory = nullptr; }
; A058310: (1/2)*(n^2+n+2)*(n^2+3*n+1). ; 1,10,44,133,319,656,1210,2059,3293,5014,7336,10385,14299,19228,25334,32791,41785,52514,65188,80029,97271,117160,139954,165923,195349,228526,265760,307369,353683,405044,461806,524335,593009,668218,750364,839861,937135 mov $1,$0 add $0,1 pow $0,4 mul $1,3 add $1,$0 div $1,2 add $1,1
#include <iostream> using namespace std; float fun() { return 2.34f; } int main() { auto x = 2 * 5.7 + 'a'; auto b = fun(); cout << x << endl << b << endl; return 0; }
#include "filesystem.h" #include <glib.h> int main() { { auto home_path=filesystem::get_home_path(); g_assert(!home_path.empty()); } { auto original="test () '\""; auto escaped=filesystem::escape_argument(original); g_assert_cmpstr(escaped.c_str(), ==, "test\\ \\(\\)\\ \\'\\\""); auto unescaped=filesystem::unescape_argument(escaped); g_assert_cmpstr(unescaped.c_str(), ==, original); } { auto unescaped=filesystem::unescape_argument("'test \\()\"\\''"); g_assert_cmpstr(unescaped.c_str(), ==, "test \\()\"'"); } { auto unescaped=filesystem::unescape_argument("\"test \\'()\\\"\""); g_assert_cmpstr(unescaped.c_str(), ==, "test \\'()\""); } { auto unescaped=filesystem::unescape_argument("\\\\"); g_assert_cmpstr(unescaped.c_str(), ==, "\\"); } { auto unescaped=filesystem::unescape_argument("\\\\\\ "); g_assert_cmpstr(unescaped.c_str(), ==, "\\ "); } { auto unescaped=filesystem::unescape_argument("\\\\\\ \\ \\ \\\\"); g_assert_cmpstr(unescaped.c_str(), ==, "\\ \\"); } { auto unescaped=filesystem::unescape_argument("c:\\a\\ b\\c"); g_assert_cmpstr(unescaped.c_str(), ==, "c:\\a b\\c"); } { auto unescaped=filesystem::unescape_argument("\"\\\\\\\"\""); g_assert_cmpstr(unescaped.c_str(), ==, "\\\""); } { auto unescaped=filesystem::unescape_argument("\"\\\"\""); g_assert_cmpstr(unescaped.c_str(), ==, "\""); } { auto unescaped=filesystem::unescape_argument("\"a\\b\""); g_assert_cmpstr(unescaped.c_str(), ==, "a\\b"); } auto tests_path=boost::filesystem::canonical(JUCI_TESTS_PATH); { g_assert(filesystem::file_in_path(tests_path/"filesystem_test.cc", tests_path)); g_assert(!filesystem::file_in_path(boost::filesystem::canonical(tests_path/".."/"CMakeLists.txt"), tests_path)); } auto license_file=boost::filesystem::canonical(tests_path/".."/"LICENSE"); { g_assert(filesystem::find_file_in_path_parents("LICENSE", tests_path)==license_file); } { g_assert(filesystem::get_normal_path(tests_path/".."/"LICENSE")==license_file); g_assert(filesystem::get_normal_path("/foo")=="/foo"); g_assert(filesystem::get_normal_path("/foo/")=="/foo"); g_assert(filesystem::get_normal_path("/foo/.")=="/foo"); g_assert(filesystem::get_normal_path("/foo/./bar/..////")=="/foo"); g_assert(filesystem::get_normal_path("/foo/.///bar/../")=="/foo"); g_assert(filesystem::get_normal_path("../foo")=="../foo"); g_assert(filesystem::get_normal_path("../../foo")=="../../foo"); g_assert(filesystem::get_normal_path("../././foo")=="../foo"); g_assert(filesystem::get_normal_path("/../foo")=="/../foo"); } { boost::filesystem::path relative_path="filesystem_test.cc"; g_assert(filesystem::get_relative_path(tests_path/relative_path, tests_path)==relative_path); } }
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r8 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x14bb6, %rsi lea addresses_normal_ht+0xafb6, %rdi nop cmp $24584, %r11 mov $104, %rcx rep movsw nop nop nop nop nop xor $55679, %rbx lea addresses_A_ht+0x188ce, %r8 and $39366, %rsi movl $0x61626364, (%r8) nop lfence lea addresses_WC_ht+0x3336, %r8 nop nop nop dec %rdx mov (%r8), %rsi nop xor %r11, %r11 lea addresses_WT_ht+0x39b6, %rcx nop nop sub %rdx, %rdx movl $0x61626364, (%rcx) nop nop nop nop nop add %rdi, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r8 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %rax push %rcx push %rdi push %rdx push %rsi // REPMOV lea addresses_UC+0x99b6, %rsi lea addresses_D+0x18cf6, %rdi clflush (%rsi) clflush (%rdi) nop nop nop cmp $4843, %rdx mov $125, %rcx rep movsb nop nop nop lfence // Load lea addresses_A+0xf5b6, %r10 nop and $5363, %rdi mov (%r10), %ax nop nop nop nop nop sub %rcx, %rcx // Store lea addresses_WT+0x142b6, %rsi clflush (%rsi) and $20699, %r10 mov $0x5152535455565758, %rdi movq %rdi, %xmm0 vmovups %ymm0, (%rsi) // Exception!!! nop nop mov (0), %r10 nop nop nop add %rcx, %rcx // Store lea addresses_WT+0x148b6, %rdi cmp %r10, %r10 movl $0x51525354, (%rdi) nop nop nop nop xor $50071, %rdi // Store lea addresses_normal+0xb1b6, %rax nop nop nop nop add $13320, %rsi mov $0x5152535455565758, %rdi movq %rdi, %xmm3 movups %xmm3, (%rax) nop nop nop nop sub %r10, %r10 // Faulty Load lea addresses_normal+0x51b6, %rcx clflush (%rcx) nop and %r14, %r14 movups (%rcx), %xmm1 vpextrq $0, %xmm1, %rdx lea oracles, %r10 and $0xff, %rdx shlq $12, %rdx mov (%r10,%rdx,1), %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D', 'congruent': 6, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 11, 'same': False}} {'34': 2268} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
; A189573: Positions of 0 in A189572; complement of A080652 (conjectured). ; 1,3,4,6,8,10,11,13,15,16,18,20,21,23,25,27,28,30,32,33,35,37,39,40,42,44,45,47,49,51,52,54,56,57,59,61,62,64,66,68,69,71,73,74,76,78,80,81,83,85,86,88,90,91,93,95,97,98,100,102,103,105,107,109,110,112,114,115,117 mov $1,$0 mov $2,$0 mov $5,$0 lpb $2,1 lpb $0,1 sub $0,1 add $4,$5 lpe lpb $4,1 add $1,1 mov $2,$0 add $3,4 trn $4,$3 lpe lpe add $1,1
#include "epiphansdk_video_source.h" #include <iostream> namespace gg { VideoSourceEpiphanSDK::VideoSourceEpiphanSDK( const std::string device_id, V2U_INT32 colour_space) : IVideoSource() , _frame_grabber(nullptr) , _flags(0) , _daemon(nullptr) { FrmGrab_Init(); _frame_grabber = FrmGrabLocal_OpenSN(device_id.c_str()); if (not _frame_grabber) { // TODO - exception GiftGrab#42 std::cerr << "Could not open " << device_id << std::endl; return; } if (colour_space != V2U_GRABFRAME_FORMAT_I420 and colour_space != V2U_GRABFRAME_FORMAT_BGR24) { // TODO - exception GiftGrab#42 std::cerr << "Colour space " << colour_space << " not supported" << std::endl; return; } else if (colour_space == V2U_GRABFRAME_FORMAT_I420) _colour = I420; else _colour = BGRA; _flags |= colour_space; VideoFrame frame(_colour); _full.x = 0; _full.y = 0; /* TODO - e.g. EpiphanSDK_MAX_RES_X and * EpiphanSDK_MAX_RES_Y after * EpiphanSDK#6 */ _full.width = 1920; _full.height = 1080; get_full_frame(); // TODO - exception GiftGrab#42 if (not get_frame(frame)) return; _daemon = new gg::BroadcastDaemon(this); _daemon->start(get_frame_rate()); } VideoSourceEpiphanSDK::~VideoSourceEpiphanSDK() { delete _daemon; if (_frame_grabber) FrmGrab_Close(_frame_grabber); FrmGrab_Deinit(); } bool VideoSourceEpiphanSDK::get_frame_dimensions(int & width, int & height) { width = _roi.width; height = _roi.height; return true; } bool VideoSourceEpiphanSDK::get_frame(VideoFrame & frame) { if (frame.colour() != _colour) // TODO - exception GiftGrab#42 return false; _buffer = FrmGrab_Frame(_frame_grabber, _flags, &_roi); if (_buffer) { frame.init_from_specs( static_cast<unsigned char*>(_buffer->pixbuf), _buffer->imagelen, /* TODO #54 specified _roi not always * respected by FrmGrab_Frame, hence * constructing with _buffer->crop * instead of _roi to avoid alignment * problems when saving to video files */ _buffer->crop.width, _buffer->crop.height ); FrmGrab_Release(_frame_grabber, _buffer); return true; } else return false; } double VideoSourceEpiphanSDK::get_frame_rate() { if (_frame_grabber) { #if defined(Epiphan_DVI2PCIeDuo_DVI) and \ defined(Epiphan_DVI2PCIeDuo_SDI) and \ defined(Epiphan_DVI2PCIeDuo_DVI_MAX_FRAME_RATE) and \ defined(Epiphan_DVI2PCIeDuo_SDI_MAX_FRAME_RATE) std::string port_id = FrmGrab_GetId(_frame_grabber); if (port_id == Epiphan_DVI2PCIeDuo_DVI) return Epiphan_DVI2PCIeDuo_DVI_MAX_FRAME_RATE; else if (port_id == Epiphan_DVI2PCIeDuo_SDI) return Epiphan_DVI2PCIeDuo_SDI_MAX_FRAME_RATE; #endif } // TODO - exception GiftGrab#42 return 0; } void VideoSourceEpiphanSDK::set_sub_frame(int x, int y, int width, int height) { if (x >= _full.x and x + width <= _full.x + _full.width and y >= _full.y and y + height <= _full.y + _full.height) { _roi.x = x; _roi.y = y; _roi.width = width; _roi.height = height; } // TODO - exception GiftGrab#42 // else // throw VideoSourceError("ROI " + std::to_string(x) + ", " + // std::to_string(y) + ", " + // std::to_string(width) + ", " + // std::to_string(height) + ", " + // "not within full frame"); } void VideoSourceEpiphanSDK::get_full_frame() { _roi.x = _full.x; _roi.y = _full.y; _roi.width = _full.width; _roi.height = _full.height; } }
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld a, 00 ldff(ff), a ld a, 30 ldff(00), a ld a, 01 ldff(4d), a stop, 00 ld c, 41 ld b, 03 ld d, 03 lbegin_waitm3: ldff a, (c) and a, d cmp a, b jrnz lbegin_waitm3 ld a, 20 ldff(c), a ld a, 02 ldff(ff), a ei xor a, a ldff(68), a ld c, 69 lbegin_clearbgp0: xor a, a ldff(c), a ldff a, (c) or a, a jrnz lbegin_clearbgp0 inc a ld a, 05 ldff(43), a xor a, a inc a .text@1000 lstatint: nop .text@1079 ldff(c), a ldff a, (c) and a, 07 jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
; A047331: Numbers that are congruent to {2, 3, 5, 6} mod 7. ; 2,3,5,6,9,10,12,13,16,17,19,20,23,24,26,27,30,31,33,34,37,38,40,41,44,45,47,48,51,52,54,55,58,59,61,62,65,66,68,69,72,73,75,76,79,80,82,83,86,87,89,90,93,94,96,97,100,101,103,104,107,108,110,111 mul $0,7 mov $1,$0 gcd $1,4 add $0,$1 div $0,4 add $0,1
Name: z00_rmdt.asm Type: file Size: 372202 Last-Modified: '2016-05-13T04:36:32Z' SHA-1: 2F857236155238AA442956D6F87C0EE7F294550E Description: null
; stdio_error_eacces_mc ; 06.2008 aralbrec PUBLIC stdio_error_eacces_mc EXTERN stdio_errno_mc INCLUDE "../stdio.def" .stdio_error_eacces_mc ld hl,EACCES jp stdio_errno_mc
copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 004B78 move.w D1, -(A0) 004B7A dbra D0, $4b78 004B8C move.w A6, -(A4) [base+6AFE] 004B8E move.w A4, ($6afe,A5) [base+6B22, base+6B24, base+6B26, base+6B28, base+6B2A, base+6B2C, base+6B2E] 0AAACA move.l (A0), D2 0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAACE move.w D0, ($2,A0) 0AAAD2 cmp.l (A0), D0 0AAAD4 bne $aaafc 0AAAD8 move.l D2, (A0)+ 0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAE6 move.l (A0), D2 0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAF4 move.l D2, (A0)+ 0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] copyright zengfr site:http://github.com/zengfr/romhack
; A040247: Continued fraction for sqrt(264). ; 16,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32,4,32 sub $0,1 mod $0,2 mul $0,10 add $0,2 pow $0,2 mov $1,$0 div $1,20 mul $1,4 add $1,4
;_ minit.asm ; Module initialization support. ; ; Copyright: Copyright Digital Mars 2000 - 2010. ; License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). ; Authors: Walter Bright ; ; Copyright Digital Mars 2000 - 2010. ; Distributed under the Boost Software License, Version 1.0. ; (See accompanying file LICENSE or copy at ; http://www.boost.org/LICENSE_1_0.txt) ; ; With VC installed, build with: ; ml /omf minit.asm .model FLAT ifdef _WIN32 DATAGRP EQU FLAT else DATAGRP EQU DGROUP endif ; Provide a default resolution for weak extern records, no way in C ; to define an omf symbol with a specific value public __nullext __nullext equ 0 extrn __moduleinfo_array:near ; This bit of assembler is needed because, from C or D, one cannot ; specify the names of data segments. Why does this matter? ; All the ModuleInfo pointers are placed into a segment named 'FM'. ; The order in which they are placed in 'FM' is arbitrarily up to the linker. ; In order to walk all the pointers, we need to be able to find the ; beginning and the end of the 'FM' segment. ; This is done by bracketing the 'FM' segment with two other, empty, ; segments named 'FMB' and 'FME'. Since this module is the only one that ; ever refers to 'FMB' and 'FME', we get to control the order in which ; these segments appear relative to 'FM' by using a GROUP statement. ; So, we have in memory: ; FMB empty segment ; FM contains all the pointers ; FME empty segment ; and finding the limits of FM is as easy as taking the address of FMB ; and the address of FME. ; These segments bracket FM, which contains the list of ModuleInfo pointers FMB segment dword use32 public 'DATA' FMB ends FM segment dword use32 public 'DATA' FM ends FME segment dword use32 public 'DATA' FME ends ; This leaves room in the _fatexit() list for _moduleDtor() XOB segment dword use32 public 'BSS' XOB ends XO segment dword use32 public 'BSS' dd ? XO ends XOE segment dword use32 public 'BSS' XOE ends DGROUP group FMB,FM,FME ; These segments bracket DP, which contains the _DATA pointer references public __DPbegin, __DPend DPB segment dword use32 public 'CODE' __DPbegin: DPB ends DP segment dword use32 public 'CODE' DP ends DPE segment dword use32 public 'CODE' __DPend: DPE ends CGROUP group DPB,DP,DPE ; These segments bracket TP, which contains the TLS pointer references public __TPbegin, __TPend TPB segment dword use32 public 'CODE' __TPbegin: TPB ends TP segment dword use32 public 'CODE' TP ends TPE segment dword use32 public 'CODE' __TPend: TPE ends CGROUP group TPB,TP,TPE _TEXT segment para use32 public 'CODE' assume CS:_TEXT ; extern (C) void _minit(); ; Converts array of ModuleInfo pointers to a D dynamic array of them, ; so they can be accessed via D. ; Result is written to: ; extern (C) ModuleInfo[] _moduleinfo_array; public __minit __minit: mov EDX,offset DATAGRP:FMB mov EAX,offset DATAGRP:FME mov dword ptr __moduleinfo_array+4,EDX sub EAX,EDX ; size in bytes of FM segment shr EAX,2 ; convert to array length mov dword ptr __moduleinfo_array,EAX ret _TEXT ends end
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r15 push %r8 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_D_ht+0xe714, %rcx nop nop nop nop nop add %r8, %r8 movb $0x61, (%rcx) nop nop add $20175, %rdi lea addresses_UC_ht+0x87f2, %rsi lea addresses_normal_ht+0x9b72, %rdi nop nop nop xor %r15, %r15 mov $44, %rcx rep movsw cmp %r12, %r12 lea addresses_D_ht+0x12c72, %rdi nop cmp $41504, %r8 movb (%rdi), %r15b nop nop and $36461, %r12 lea addresses_D_ht+0x472, %r12 nop nop and %r9, %r9 mov $0x6162636465666768, %rcx movq %rcx, %xmm5 movups %xmm5, (%r12) nop nop nop nop cmp %r12, %r12 lea addresses_A_ht+0xd772, %r12 nop nop nop add $30579, %rdi movb (%r12), %r8b nop nop nop nop nop add %r12, %r12 lea addresses_UC_ht+0xa072, %r12 cmp %rcx, %rcx and $0xffffffffffffffc0, %r12 movntdqa (%r12), %xmm5 vpextrq $1, %xmm5, %rdi sub %r15, %r15 lea addresses_UC_ht+0x1a016, %rsi lea addresses_D_ht+0x14c72, %rdi nop nop nop nop nop and %rax, %rax mov $72, %rcx rep movsl nop add %r9, %r9 lea addresses_WT_ht+0xeb6e, %r8 nop nop sub %rax, %rax movw $0x6162, (%r8) nop nop cmp %r15, %r15 pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r15 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r15 push %r9 push %rax push %rcx // Load lea addresses_US+0x27c6, %r15 and %rax, %rax vmovups (%r15), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $0, %xmm0, %r9 nop nop and $58001, %r9 // Faulty Load lea addresses_US+0x15472, %rax nop sub $39344, %rcx mov (%rax), %r13 lea oracles, %rcx and $0xff, %r13 shlq $12, %r13 mov (%rcx,%r13,1), %r13 pop %rcx pop %rax pop %r9 pop %r15 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_US', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_US', 'same': False, 'size': 32, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_US', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 10, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': True}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
public rand section CODE_2 ; ; Xorshift PRNG ; ; https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Random ; ; Input: ; None ; ; Output: ; hl - PRN ; ; Corrupts: ; a ; rand: ld hl, 1 ; seed must not be 0 ld a, h rra ld a, l rra xor h ld h, a ld a, l rra ld a, h rra xor l ld l, a xor h ld h, a ld (rand+1), hl ret
#ifndef BSDFDISPLAY_HPP_ #define BSDFDISPLAY_HPP_ #include <QLabel> #include <memory> class QImage; namespace Tungsten { class TraceableScene; class Primitive; class Scene; class Bsdf; class BsdfDisplay : public QLabel { Q_OBJECT enum PrimitiveMode { PRIMITIVE_SPHERE, PRIMITIVE_CUBE, PRIMITIVE_PLANE, }; int _w, _h; QImage _image; int _spp; PrimitiveMode _mode; std::unique_ptr<Scene> _scene; std::vector<std::shared_ptr<Primitive>> _prims; std::unique_ptr<TraceableScene> _flattenedScene; std::shared_ptr<Bsdf> _bsdf; void rebuildImage(); private slots: void finishRender(); public: BsdfDisplay(int w, int h, QWidget *parent = nullptr); ~BsdfDisplay(); public slots: void changeBsdf(std::shared_ptr<Bsdf> &bsdf); signals: void rendererFinished(); }; } #endif /* BSDFDISPLAY_HPP_ */
; 04.2006 aralbrec ; 01.2014 stefano ; void __FASTCALL__ zx_border(uchar colour) PUBLIC zx_border zx_border: in a,(254) and $40 rra rra or l out (254),a and 7 rla rla rla ld e,a ld a,(23624) and $c7 or e ld (23624),a ret
class Solution { bool dp[1004][1004], vis[1004][1004]; bool call(int i, int j, string &s, string &p) { if (i == s.size() && j == p.size()) return 1; if (j >= p.size()) return 0; bool &ret = dp[i][j]; if (vis[i][j]) return ret; vis[i][j] = 1; if (i < s.size() && s[i] == p[j]) { ret = ret || call(i + 1, j + 1, s, p); } if (i < s.size() && p[j] == '.') { ret = ret || call(i + 1, j + 1, s, p); } if (p[j] == '*') { ret = call(i, j + 1, s, p); if (i < s.size() && (p[j - 1] == s[i] || p[j - 1] == '.')) { ret = ret || call(i + 1, j, s, p); ret = ret || call(i + 1, j + 1, s, p); } } if (j < p.size() && p[j + 1] == '*') ret = ret || call(i, j + 2, s, p); return ret; } public: bool isMatch(string s, string p) { memset(vis, 0, sizeof vis); return call(0, 0, s, p); } };
SFX_Muted_Snare1_2_Ch7: unknownnoise0x20 0, 161, 24 unknownnoise0x20 0, 49, 51 endchannel
; ; ANSI Video handling for the ABC80 ; ; set it up with: ; .text_cols = max columns ; .text_rows = max rows ; ; Display a char in location (ansi_ROW),(ansi_COLUMN) ; A=char to display ; ; A slower (but working) method it commented out ; ; ; $Id: f_ansi_char.asm,v 1.5 2016-06-12 16:06:42 dom Exp $ ; SECTION code_clib PUBLIC ansi_CHAR EXTERN ansi_ROW EXTERN ansi_COLUMN PUBLIC text_cols PUBLIC text_rows .text_cols defb 40 .text_rows defb 24 .ansi_CHAR push af ld a,(ansi_ROW) ld hl,884 ; ROW table in ROM ld d,0 rla ld e,a add hl,de ld a,(hl) inc hl ld h,(hl) ld l,a ; ld hl,31744 ; OLD method (non ROM dependent) ; cp 8 ; jr c,jpvdu ; ld hl,31784 ; sub 8 ; cp 8 ; jr c,jpvdu ; ld hl,31824 ; sub 8 ;.jpvdu ; and a ; jr z,r_zero ; ld b,a ; ld de,128 ;.r_loop ; add hl,de ; djnz r_loop .r_zero ld a,(ansi_COLUMN) ; ld d,0 ld e,a add hl,de pop af ld (hl),a ret
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r15 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x1e4e6, %rbx sub %r15, %r15 mov $0x6162636465666768, %rbp movq %rbp, %xmm7 vmovups %ymm7, (%rbx) nop nop xor %r12, %r12 lea addresses_WC_ht+0x49f6, %r11 nop nop inc %rbp mov (%r11), %di nop sub %rbx, %rbx lea addresses_normal_ht+0x267a, %rsi lea addresses_WC_ht+0xbbee, %rdi nop nop sub %rbx, %rbx mov $87, %rcx rep movsb nop nop nop xor %rsi, %rsi lea addresses_D_ht+0x5c56, %rbx nop sub $44703, %r15 movl $0x61626364, (%rbx) sub $37178, %rsi lea addresses_UC_ht+0x33a6, %rsi nop nop nop nop sub $34567, %rdi mov (%rsi), %r11w nop nop xor %rcx, %rcx lea addresses_UC_ht+0x17726, %rsi lea addresses_UC_ht+0x14ba6, %rdi nop nop nop cmp $44604, %rbp mov $70, %rcx rep movsb nop dec %rsi lea addresses_A_ht+0x77a6, %rsi nop nop nop nop cmp %rdi, %rdi and $0xffffffffffffffc0, %rsi movntdqa (%rsi), %xmm4 vpextrq $0, %xmm4, %r12 nop sub $30109, %rcx lea addresses_normal_ht+0x16cdb, %r12 nop add %rbp, %rbp mov $0x6162636465666768, %r15 movq %r15, %xmm2 and $0xffffffffffffffc0, %r12 movntdq %xmm2, (%r12) nop nop nop add %rcx, %rcx lea addresses_WC_ht+0xca6, %rsi lea addresses_WC_ht+0x165a6, %rdi nop nop nop nop cmp $52225, %r15 mov $35, %rcx rep movsb nop nop nop nop inc %r12 lea addresses_A_ht+0x1c3a6, %r12 nop nop nop and $59814, %rsi mov $0x6162636465666768, %rbp movq %rbp, (%r12) nop nop nop nop inc %r12 lea addresses_WT_ht+0x4fb6, %rsi lea addresses_WT_ht+0x19eeb, %rdi xor %r12, %r12 mov $34, %rcx rep movsw nop nop nop add $40096, %rdi lea addresses_WC_ht+0x170c6, %rbx add %r12, %r12 mov (%rbx), %bp nop nop nop inc %rsi lea addresses_UC_ht+0x2e6, %rbp nop nop nop nop sub %r12, %r12 movw $0x6162, (%rbp) add %r11, %r11 lea addresses_normal_ht+0x104a6, %rbp clflush (%rbp) nop nop and %r12, %r12 and $0xffffffffffffffc0, %rbp movntdqa (%rbp), %xmm0 vpextrq $0, %xmm0, %rsi nop nop nop nop nop sub %rbp, %rbp pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r15 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r8 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi // Store lea addresses_A+0x10d63, %rbp nop xor %r10, %r10 movb $0x51, (%rbp) nop nop nop and %rdx, %rdx // Store lea addresses_normal+0x1eaa6, %r8 nop nop nop nop sub %rbx, %rbx movl $0x51525354, (%r8) nop nop nop sub %rbx, %rbx // REPMOV lea addresses_PSE+0x17e26, %rsi lea addresses_WC+0x193a6, %rdi clflush (%rdi) nop nop nop nop and $33685, %rdx mov $29, %rcx rep movsw nop nop nop nop sub $28990, %rdx // Faulty Load lea addresses_WC+0x193a6, %r10 nop nop nop nop nop add $49171, %rcx mov (%r10), %rdi lea oracles, %rbp and $0xff, %rdi shlq $12, %rdi mov (%rbp,%rdi,1), %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_WC', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_normal', 'size': 4, 'AVXalign': False}} {'src': {'type': 'addresses_PSE', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC', 'congruent': 0, 'same': True}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_WC', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False}} {'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False}} {'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}} {'src': {'same': False, 'congruent': 10, 'NT': True, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': True, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}} {'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': True}} {'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False}} {'src': {'same': False, 'congruent': 8, 'NT': True, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
// SID music located in another bank being played in a raster IRQ using memory mapping on the MEGA65 // Music is Cybernoid II by Jeroen Tel released in 1988 by Hewson https://csdb.dk/sid/?id=28140 // SID relocated using http://www.linusakesson.net/software/sidreloc/index.php .cpu _45gs02 // MEGA65 platform PRG executable with banked code and data starting in MEGA65 mode. .file [name="banked-music.prg", type="prg", segments="Program"] .segmentdef Program [segments="Basic, Code, Data"] .segmentdef Basic [start=$2001] .segmentdef Code [start=$2017] .segmentdef Data [startAfter="Code"] .segmentdef Banked [segments="CodeBanked, DataBanked"] .segmentdef CodeBanked [start=$4000] .segmentdef DataBanked [startAfter="CodeBanked"] .segment Basic .byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0 .byte $15, $20, $14, $00, $9e, $20 // 20 SYS .text toIntString(main) // NNNN .byte $00, $00, $00 // /// Value that disables all CIA interrupts when stored to the CIA Interrupt registers .const CIA_INTERRUPT_CLEAR = $7f /// VICII IRQ Status/Enable Raster // @see #IRQ_ENABLE #IRQ_STATUS /// 0 | RST| Reaching a certain raster line. The line is specified by writing /// | | to register 0xd012 and bit 7 of $d011 and internally stored by /// | | the VIC for the raster compare. The test for reaching the /// | | interrupt raster line is done in cycle 0 of every line (for line /// | | 0, in cycle 1). .const IRQ_RASTER = 1 /// DMA command copy .const DMA_COMMAND_COPY = 0 /// Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written .const PROCPORT_DDR_MEMORY_MASK = 7 /// RAM in 0xA000, 0xE000 I/O in 0xD000 .const PROCPORT_RAM_IO = 5 .const OFFSET_STRUCT_F018_DMAGIC_EN018B = 3 .const OFFSET_STRUCT_DMA_LIST_F018B_COUNT = 1 .const OFFSET_STRUCT_DMA_LIST_F018B_SRC = 3 .const OFFSET_STRUCT_DMA_LIST_F018B_DEST = 6 .const OFFSET_STRUCT_F018_DMAGIC_ADDRMB = 4 .const OFFSET_STRUCT_F018_DMAGIC_ADDRBANK = 2 .const OFFSET_STRUCT_F018_DMAGIC_ADDRMSB = 1 .const OFFSET_STRUCT_DMA_LIST_F018B_SRC_BANK = 5 .const OFFSET_STRUCT_DMA_LIST_F018B_DEST_BANK = 8 .const OFFSET_STRUCT_MOS4569_VICIII_KEY = $2f .const OFFSET_STRUCT_MEGA65_VICIV_CONTROLB = $31 .const OFFSET_STRUCT_MEGA65_VICIV_CONTROLC = $54 .const OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO = $5c .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12 .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11 .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19 .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20 /// Processor port data direction register .label PROCPORT_DDR = 0 /// Processor Port Register controlling RAM/ROM configuration and the datasette .label PROCPORT = 1 /// The VIC-II MOS 6567/6569 .label VICII = $d000 /// The VIC III MOS 4567/4569 .label VICIII = $d000 /// The VIC IV .label VICIV = $d000 /// DMAgic F018 Controller .label DMA = $d700 /// Default address of screen character matrix .label DEFAULT_SCREEN = $800 /// The CIA#1: keyboard matrix, joystick #1/#2 .label CIA1 = $dc00 /// The vector used when the HARDWARE serves IRQ interrupts .label HARDWARE_IRQ = $fffe // Address after the end of the music .label MUSIC_END = $5200 // Pointer to the music init routine .label musicInit = MUSIC // Pointer to the music play routine .label musicPlay = MUSIC+3 .segment Code // Raster IRQ routine irq: { pha phx phy phz // VICII->IRQ_STATUS = IRQ_RASTER // Acknowledge the IRQ ldz #IRQ_RASTER stz VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS // (VICII->BORDER_COLOR)++; inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR // memoryRemapBlock(0x40, 0x100) // Remap memory to put music at $4000 jsr memoryRemapBlock // (*musicPlay)() // Play remapped SID jsr musicPlay // memoryRemap(0,0,0) // Reset memory mapping lda #<0 sta.z memoryRemap.upperPageOffset sta.z memoryRemap.upperPageOffset+1 taz sta.z memoryRemap.lowerPageOffset sta.z memoryRemap.lowerPageOffset+1 jsr memoryRemap // char raster = VICII->RASTER // Wait for the next raster line lda VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER __b2: // while(VICII->RASTER==raster) cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER beq __b2 // (VICII->BORDER_COLOR)--; dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR // } plz ply plx pla rti } main: { // asm // Stop IRQ's sei // memoryRemap(0,0,0) // Map memory to BANK 0 : 0x00XXXX - giving access to I/O lda #<0 sta.z memoryRemap.upperPageOffset sta.z memoryRemap.upperPageOffset+1 taz sta.z memoryRemap.lowerPageOffset sta.z memoryRemap.lowerPageOffset+1 jsr memoryRemap // VICIII->KEY = 0x47 // Enable MEGA65 features ldz #$47 stz VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY // VICIII->KEY = 0x53 ldz #$53 stz VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY // VICIV->CONTROLB |= 0x40 // Enable 48MHz fast mode lda #$40 ora VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB // VICIV->CONTROLC |= 0x40 lda #$40 ora VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC // *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK // no kernal or BASIC rom visible ldz #PROCPORT_DDR_MEMORY_MASK stz.z PROCPORT_DDR // *PROCPORT = PROCPORT_RAM_IO ldz #PROCPORT_RAM_IO stz.z PROCPORT // VICIV->SIDBDRWD_LO = 1 // open sideborder ldz #1 stz VICIV+OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO // memcpy_dma4(1, (void*)0x0000, 0, upperCodeData, MUSIC_END-MUSIC) // Transfer banked code/data to upper memory ($10000) jsr memcpy_dma4 // memoryRemapBlock(0x40, 0x100) // Remap [$4000-$5fff] to point to [$10000-$11fff] jsr memoryRemapBlock // asm // Initialize SID lda #0 // (*musicInit)() jsr musicInit // memoryRemap(0,0,0) // Reset memory mapping lda #<0 sta.z memoryRemap.upperPageOffset sta.z memoryRemap.upperPageOffset+1 taz sta.z memoryRemap.lowerPageOffset sta.z memoryRemap.lowerPageOffset+1 jsr memoryRemap // CIA1->INTERRUPT = CIA_INTERRUPT_CLEAR // Set up raster interrupts C64 style // Disable CIA 1 Timer IRQ ldz #CIA_INTERRUPT_CLEAR stz CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT // VICII->RASTER = 0xff // Set raster line to 0xff ldz #$ff stz VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER // VICII->CONTROL1 &= 0x7f lda #$7f and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 // VICII->IRQ_ENABLE = IRQ_RASTER // Enable Raster Interrupt ldz #IRQ_RASTER stz VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE // *HARDWARE_IRQ = &irq // Set the IRQ routine lda #<irq sta HARDWARE_IRQ lda #>irq sta HARDWARE_IRQ+1 // asm // Enable IRQ cli ldx #0 __b2: // MUSIC[mem_destroy_i++]++; inc MUSIC,x inx ldy #0 // Show unmapped MUSIC memory __b3: // for(char i=0;i<240;i++) cpy #$f0 bcc __b4 jmp __b2 __b4: // DEFAULT_SCREEN[i] = MUSIC[i] lda MUSIC,y sta DEFAULT_SCREEN,y // for(char i=0;i<240;i++) iny jmp __b3 } // Remap a single 8K memory block in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. // All the other 8K memory blocks will not be mapped and will point to their own address in the lowest 64K of the MEGA65 memory. // blockPage: Page address of the 8K memory block to remap (ie. the block that is remapped is $100 * the passed page address.) // memoryPage: Page address of the memory that the block should point to in the 1MB memory space of the MEGA65. // Ie. the memory that will be pointed to is $100 * the passed page address. Only the lower 12bits of the passed value is used. // void memoryRemapBlock(char blockPage, unsigned int memoryPage) memoryRemapBlock: { // Find the page offset (the number of pages to offset the block) .const pageOffset = $100-$40 // Which block is being remapped? (0-7) .const block = $40>>5 .const blockBits = 1<<block // memoryRemap(blockBits, pageOffset, pageOffset) lda #<pageOffset sta.z memoryRemap.upperPageOffset lda #>pageOffset sta.z memoryRemap.upperPageOffset+1 ldz #blockBits lda #<pageOffset sta.z memoryRemap.lowerPageOffset lda #>pageOffset sta.z memoryRemap.lowerPageOffset+1 jsr memoryRemap // } rts } // Remap some of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. // After the remapping the CPU will access the mapped memory whenever it uses instructions that access a remapped block. // See section 2.3.4 in http://www.zimmers.net/cbmpics/cbm/c65/c65manual.txt for a description of the CPU memory remapper of the C65. // remapBlocks: Indicates which 8K blocks of the 6502 address space to remap. Each bit represents one 8K block // - bit 0 Memory block $0000-$1fff. Use constant MEMORYBLOCK_0000. // - bit 1 Memory block $2000-$3fff. Use constant MEMORYBLOCK_2000. // - bit 2 Memory block $4000-$5fff. Use constant MEMORYBLOCK_4000. // - bit 3 Memory block $6000-$7fff. Use constant MEMORYBLOCK_6000. // - bit 4 Memory block $8000-$9fff. Use constant MEMORYBLOCK_8000. // - bit 5 Memory block $a000-$bfff. Use constant MEMORYBLOCK_A000. // - bit 6 Memory block $c000-$dfff. Use constant MEMORYBLOCK_C000. // - bit 7 Memory block $e000-$ffff. Use constant MEMORYBLOCK_E000. // lowerPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3). // The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used. // - If block 0 ($0000-$1fff) is remapped it will point to lowerPageOffset*$100. // - If block 1 ($2000-$3fff) is remapped it will point to lowerPageOffset*$100 + $2000. // - If block 2 ($4000-$5fff) is remapped it will point to lowerPageOffset*$100 + $4000. // - If block 3 ($6000-$7fff) is remapped it will point to lowerPageOffset*$100 + $6000. // upperPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7). // The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used. // - If block 4 ($8000-$9fff) is remapped it will point to upperPageOffset*$100 + $8000 // - If block 5 ($a000-$bfff) is remapped it will point to upperPageOffset*$100 + $a000. // - If block 6 ($c000-$dfff) is remapped it will point to upperPageOffset*$100 + $c000. // - If block 7 ($e000-$ffff) is remapped it will point to upperPageOffset*$100 + $e000. // void memoryRemap(__register(Z) char remapBlocks, __zp(3) unsigned int lowerPageOffset, __zp(7) unsigned int upperPageOffset) memoryRemap: { .label aVal = $b .label xVal = $a .label __1 = 5 .label yVal = 9 .label zVal = 2 .label __6 = 6 .label lowerPageOffset = 3 .label upperPageOffset = 7 // char aVal = BYTE0(lowerPageOffset) // lower blocks offset page low lda.z lowerPageOffset sta.z aVal // remapBlocks << 4 tza asl asl asl asl sta.z __1 // BYTE1(lowerPageOffset) lda.z lowerPageOffset+1 // BYTE1(lowerPageOffset) & 0xf and #$f // char xVal = (remapBlocks << 4) | (BYTE1(lowerPageOffset) & 0xf) // lower blocks to map + lower blocks offset high nibble ora.z __1 sta.z xVal // char yVal = BYTE0(upperPageOffset) // upper blocks offset page lda.z upperPageOffset sta.z yVal // remapBlocks & 0xf0 tza and #$f0 sta.z __6 // BYTE1(upperPageOffset) lda.z upperPageOffset+1 // BYTE1(upperPageOffset) & 0xf and #$f // char zVal = (remapBlocks & 0xf0) | (BYTE1(upperPageOffset) & 0xf) // upper blocks to map + upper blocks offset page high nibble ora.z __6 sta.z zVal // asm lda aVal ldx xVal ldy yVal ldz zVal map eom // } rts } // Copy a memory block anywhere in first 4MB memory space using MEGA65 DMagic DMA // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination. // - dest_bank The 64KB bank for the destination (0-127) // - dest The destination address (within the MB and bank) // - src_bank The 64KB bank for the source (0-127) // - src The source address (within the MB and bank) // - num The number of bytes to copy // void memcpy_dma4(char dest_bank, void *dest, char src_bank, void *src, unsigned int num) memcpy_dma4: { .const num = MUSIC_END-MUSIC .const dest_bank = 1 .const src_bank = 0 .label dest = 0 .label src = upperCodeData // char dmaMode = DMA->EN018B // Remember current F018 A/B mode ldx DMA+OFFSET_STRUCT_F018_DMAGIC_EN018B // memcpy_dma_command4.count = num // Set up command lda #<num sta memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_COUNT lda #>num sta memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_COUNT+1 // memcpy_dma_command4.src_bank = src_bank ldz #src_bank stz memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_SRC_BANK // memcpy_dma_command4.src = src lda #<src sta memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_SRC lda #>src sta memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_SRC+1 // memcpy_dma_command4.dest_bank = dest_bank ldz #dest_bank stz memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_DEST_BANK // memcpy_dma_command4.dest = dest lda #<dest sta memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_DEST lda #>dest sta memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_DEST+1 // DMA->EN018B = 1 // Set F018B mode ldz #1 stz DMA+OFFSET_STRUCT_F018_DMAGIC_EN018B // DMA->ADDRMB = 0 // Set address of DMA list ldz #0 stz DMA+OFFSET_STRUCT_F018_DMAGIC_ADDRMB // DMA->ADDRBANK = 0 stz DMA+OFFSET_STRUCT_F018_DMAGIC_ADDRBANK // DMA-> ADDRMSB = BYTE1(&memcpy_dma_command4) ldz #>memcpy_dma_command4 stz DMA+OFFSET_STRUCT_F018_DMAGIC_ADDRMSB // DMA-> ADDRLSBTRIG = BYTE0(&memcpy_dma_command4) // Trigger the DMA (without option lists) ldz #<memcpy_dma_command4 stz DMA // DMA->EN018B = dmaMode // Re-enable F018A mode stx DMA+OFFSET_STRUCT_F018_DMAGIC_EN018B // } rts } .segment Data // Array containing the banked upper memory code/data to be transferred to upper memory before execution upperCodeData: .segmentout [segments="Banked"] // DMA list entry for copying data in the 1MB memory space memcpy_dma_command4: .byte DMA_COMMAND_COPY .word 0, 0 .byte 0 .word 0 .byte 0, 0 .word 0 .segment DataBanked .pc = $4000 "MUSIC" // SID tune at an absolute address MUSIC: .const music = LoadSid("Cybernoid_II_4000.sid") .fill music.size, music.getData(i)
; A282701: a(n) = maximal number of real roots of any of the polynomials c_0 + c_1*x + c_2*x^2 + ... + c_n*x^n where the coefficients c_i are -1, 0, or 1, c_0 != 0, and c_n != 0. ; 0,1,2,3,2,3,4,5,4,5,4,5,6,7,6,7,6 mov $2,1 add $2,$0 lpb $2 gcd $0,2 add $1,2 trn $2,$1 lpe sub $1,$0 mov $0,$1
; --------------------------------------------------------------------------- ; Sprite mappings - Robotnik on the "TRY AGAIN" and "END" screens ; --------------------------------------------------------------------------- Map_EEgg_internal: dc.w M_EEgg_Try1-Map_EEgg_internal dc.w M_EEgg_Try2-Map_EEgg_internal dc.w M_EEgg_Try3-Map_EEgg_internal dc.w M_EEgg_Try4-Map_EEgg_internal dc.w M_EEgg_End1-Map_EEgg_internal dc.w M_EEgg_End2-Map_EEgg_internal dc.w M_EEgg_End3-Map_EEgg_internal dc.w M_EEgg_End4-Map_EEgg_internal M_EEgg_Try1: dc.b 8 dc.b $E9, 5, 0, 0, $F0 dc.b $F9, $C, 0, 4, $E0 dc.b $E9, 4, 0, 8, 0 dc.b $F1, $D, 0, $A, 0 dc.b 1, 6, 0, $23, $F0 dc.b 1, 6, 8, $23, 0 dc.b $18, 4, 0, $29, $EC dc.b $18, 4, 8, $29, 4 M_EEgg_Try2: dc.b 8 dc.b $E8, $D, 0, $12, $E0 dc.b $F8, 8, 0, $1A, $E8 dc.b $E8, 5, 8, 0, 0 dc.b $F8, $C, 8, 4, 0 dc.b 0, 6, 0, $1D, $F0 dc.b 0, 6, 8, $1D, 0 dc.b $18, 4, 0, $29, $EC dc.b $18, 4, 8, $29, 4 M_EEgg_Try3: dc.b 8 dc.b $E9, 4, 8, 8, $F0 dc.b $F1, $D, 8, $A, $E0 dc.b $E9, 5, 8, 0, 0 dc.b $F9, $C, 8, 4, 0 dc.b 1, 6, 0, $23, $F0 dc.b 1, 6, 8, $23, 0 dc.b $18, 4, 0, $29, $EC dc.b $18, 4, 8, $29, 4 M_EEgg_Try4: dc.b 8 dc.b $E8, 5, 0, 0, $F0 dc.b $F8, $C, 0, 4, $E0 dc.b $E8, $D, 8, $12, 0 dc.b $F8, 8, 8, $1A, 0 dc.b 0, 6, 0, $1D, $F0 dc.b 0, 6, 8, $1D, 0 dc.b $18, 4, 0, $29, $EC dc.b $18, 4, 8, $29, 4 M_EEgg_End1: dc.b $C dc.b $ED, $A, 0, $2B, $E8 dc.b $F5, 0, 0, $34, $E0 dc.b 5, 4, 0, $35, $F0 dc.b $D, 8, 0, $37, $E8 dc.b $ED, $A, 8, $2B, 0 dc.b $F5, 0, 8, $34, $18 dc.b 5, 4, 8, $35, 0 dc.b $D, 8, 8, $37, 0 dc.b $10, $D, 0, $73, $E0 dc.b $10, $D, 0, $7B, 0 dc.b $1C, $C, 0, $5B, $E0 dc.b $1C, $C, 8, $5B, 0 M_EEgg_End2: dc.b $A dc.b $D2, 7, 0, $3A, $F0 dc.b $DA, 0, 0, $42, $E8 dc.b $F2, 7, 0, $43, $F0 dc.b $D2, 7, 8, $3A, 0 dc.b $DA, 0, 8, $42, $10 dc.b $F2, 7, 8, $43, 0 dc.b $10, $D, 0, $67, $E8 dc.b $10, 5, 0, $6F, 8 dc.b $1C, $C, 0, $5F, $E0 dc.b $1C, $C, 8, $5F, 0 M_EEgg_End3: dc.b $A dc.b $C4, $B, 0, $4B, $E8 dc.b $E4, 8, 0, $57, $E8 dc.b $EC, 0, 0, $5A, $F0 dc.b $C4, $B, 8, $4B, 0 dc.b $E4, 8, 8, $57, 0 dc.b $EC, 0, 8, $5A, 8 dc.b $10, $D, 0, $67, $E8 dc.b $10, 5, 0, $6F, 8 dc.b $1C, $C, 0, $63, $E0 dc.b $1C, $C, 8, $63, 0 M_EEgg_End4: dc.b $C dc.b $F4, $A, 0, $2B, $E8 dc.b $FC, 0, 0, $34, $E0 dc.b $C, 4, 0, $35, $F0 dc.b $14, 8, 0, $37, $E8 dc.b $F4, $A, 8, $2B, 0 dc.b $FC, 0, 8, $34, $18 dc.b $C, 4, 8, $35, 0 dc.b $14, 8, 8, $37, 0 dc.b $18, $C, 0, $83, $E0 dc.b $18, $C, 0, $87, 0 dc.b $1C, $C, 0, $5B, $E0 dc.b $1C, $C, 8, $5B, 0 even
; A005654: Number of bracelets (turn over necklaces) with n red, 1 pink and n-1 blue beads; also reversible strings with n red and n-1 blue beads; also next-to-central column in Losanitsch's triangle A034851. ; Submitted by Jon Maiga ; 1,2,6,19,66,236,868,3235,12190,46252,176484,676270,2600612,10030008,38781096,150273315,583407990,2268795980,8836340260,34461678394,134564560988,526024917288,2058358034616,8061901596814,31602652961516,123979635837176,486734861612328,1912172660219260,7516816644943560,29566145429994736,116357088391374032,458156035385917731,1804857108804606630,7113260369393545740,28046569455332514468,110628135071477978626,436532641088444120108,1723155162182151654600,6804253717317430635800,26876802183368505747610 mov $1,$0 mov $2,1 add $2,$0 add $0,$2 bin $0,$1 div $2,2 bin $1,$2 add $0,$1 div $0,2
.cseg .org 0x10 rjmp ac_completed_handler ; Analog Comparator Handler
; A186544: a(n) = floor((Pi-2)*n/(Pi-3)); complement of A187320. ; 8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,129,137,145,153,161,169,177,185,193,201,209,217,225,233,241,249,258,266,274,282,290,298,306,314,322,330,338,346,354,362,370,378,387,395,403,411,419,427,435,443,451,459,467,475,483,491,499,507,516,524,532,540,548,556,564,572,580,588,596,604,612,620,628,636,645 mov $1,1 add $1,$0 div $1,16 add $1,8 mov $2,$0 mul $2,8 add $1,$2 mov $0,$1
MOV AX, 100h MOV DS, AX MOV DS:[1000h], 34h MOV DS:[2000h], 34h ret
; A263449: Permutation of the natural numbers: [4k+1, 4k+4, 4k+3, 4k+2, ...]. ; 1,4,3,2,5,8,7,6,9,12,11,10,13,16,15,14,17,20,19,18,21,24,23,22,25,28,27,26,29,32,31,30,33,36,35,34,37,40,39,38,41,44,43,42,45,48,47,46,49,52,51,50,53,56,55,54,57,60,59,58,61,64,63,62,65,68,67,66,69,72,71,70,73,76,75,74,77,80,79,78,81,84,83,82,85,88,87,86,89,92,91,90,93,96,95,94,97,100,99,98 mov $1,3 lpb $1 add $0,2 add $1,$0 gcd $1,4 lpe sub $0,1
.file "aes-x86_64.asm" .text /* Takes the key in eax, applies the sbox to it, and rotates */ /* the result right by 8 bits, storing the result in edx. */ /* Uses registers rax, rbx, rcx, rdx, rbp, rsi, rdi, and r13. */ /* Also reads from r12, but does not write to it. */ .macro AES128_SET_KEY_SUBROTR8 movzbl %al, %ebp movzbl %ah, %esi shrl $16, %eax movzbl %al, %r13d movzbl %ah, %edi movzbl (%r12,%rbp), %eax movzbl (%r12,%rsi), %ebx movzbl (%r12,%r13), %ecx movzbl (%r12,%rdi), %edx movb %cl, %bh movb %al, %dh shll $16, %ebx orl %ebx, %edx .endm .align 16 .globl _crypto_aes128_set_key_x86_64 .def _crypto_aes128_set_key_x86_64; .scl 2; .type 32; .endef /* void _aes128_set_key_x86_64(uint32_t* subkeys [%rdi], */ /* const uint8_t* key [%rsi]) */ _crypto_aes128_set_key_x86_64: /* Clobber Registers */ pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx /* Offset and store output pointer */ leaq 0x30(%rdi), %r14 /* Store sbox pointer */ movq .refptr._crypto_aes_sbox(%rip), %r12 /* Copy first 4 keys */ movl 0x0(%rsi), %r8d movl 0x4(%rsi), %r9d movl 0x8(%rsi), %r10d movl 0xC(%rsi), %r11d movl %r8d, -0x30(%r14) movl %r9d, -0x2C(%r14) movl %r10d, -0x28(%r14) movl %r11d, -0x24(%r14) /* Key Set 1 */ /* Combined Substitute and Rotate */ movl %r11d, %eax AES128_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x01, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, -0x20(%r14) movl %r9d, -0x1C(%r14) movl %r10d, -0x18(%r14) movl %r11d, -0x14(%r14) /* Key Set 2 */ /* Combined Substitute and Rotate */ movl %r11d, %eax AES128_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x02, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, -0x10(%r14) movl %r9d, -0x0C(%r14) movl %r10d, -0x08(%r14) movl %r11d, -0x04(%r14) /* Key Set 3 */ /* Combined Substitute and Rotate */ movl %r11d, %eax AES128_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x04, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, 0x00(%r14) movl %r9d, 0x04(%r14) movl %r10d, 0x08(%r14) movl %r11d, 0x0C(%r14) /* Key Set 4 */ /* Combined Substitute and Rotate */ movl %r11d, %eax AES128_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x08, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, 0x10(%r14) movl %r9d, 0x14(%r14) movl %r10d, 0x18(%r14) movl %r11d, 0x1C(%r14) /* Key Set 5 */ /* Combined Substitute and Rotate */ movl %r11d, %eax AES128_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x10, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, 0x20(%r14) movl %r9d, 0x24(%r14) movl %r10d, 0x28(%r14) movl %r11d, 0x2C(%r14) /* Key Set 6 */ /* Combined Substitute and Rotate */ movl %r11d, %eax AES128_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x20, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, 0x30(%r14) movl %r9d, 0x34(%r14) movl %r10d, 0x38(%r14) movl %r11d, 0x3C(%r14) /* Key Set 7 */ /* Combined Substitute and Rotate */ movl %r11d, %eax AES128_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x40, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, 0x40(%r14) movl %r9d, 0x44(%r14) movl %r10d, 0x48(%r14) movl %r11d, 0x4C(%r14) /* Key Set 8 */ /* Combined Substitute and Rotate */ movl %r11d, %eax AES128_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x80, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, 0x50(%r14) movl %r9d, 0x54(%r14) movl %r10d, 0x58(%r14) movl %r11d, 0x5C(%r14) /* Key Set 9 */ /* Combined Substitute and Rotate */ movl %r11d, %eax AES128_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x1B, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, 0x60(%r14) movl %r9d, 0x64(%r14) movl %r10d, 0x68(%r14) movl %r11d, 0x6C(%r14) /* Key Set 10 */ /* Combined Substitute and Rotate */ movl %r11d, %eax AES128_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x36, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, 0x70(%r14) movl %r9d, 0x74(%r14) movl %r10d, 0x78(%r14) movl %r11d, 0x7C(%r14) /* Restore clobbered registers and return */ popq %rbx popq %rbp popq %r12 popq %r13 popq %r14 ret /* Takes the key in eax, applies the sbox to it, and rotates */ /* the result right by 8 bits, storing the result in ebx. */ /* Uses registers rax, rbx, rcx, rdx, rbp, rsi, and rdi. */ /* Also reads from r14, but does not write to it. */ .macro AES192_SET_KEY_SUBROTR8 movzbl %al, %ebp movzbl %ah, %esi shrl $16, %eax movzbl %ah, %edi movzbl %al, %eax movzbl (%r14,%rbp), %edx movzbl (%r14,%rsi), %ecx movzbl (%r14,%rdi), %ebx movzbl (%r14,%rax), %eax movb %al, %ch movb %dl, %bh shll $16, %ecx orl %ecx, %ebx .endm .align 16 .globl _crypto_aes192_set_key_x86_64 .def _crypto_aes192_set_key_x86_64; .scl 2; .type 32; .endef /* void _aes192_set_key_x86_64(uint32_t* subkeys [%rdi], */ /* const uint8_t* key [%rsi]) */ _crypto_aes192_set_key_x86_64: /* Clobber Registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx /* Offset and store output pointer */ leaq 0x50(%rdi), %r15 /* Store sbox pointer */ movq .refptr._crypto_aes_sbox(%rip), %r14 /* Copy first 6 keys */ movl 0x00(%rsi), %r8d movl 0x04(%rsi), %r9d movl 0x08(%rsi), %r10d movl 0x0C(%rsi), %r11d movl 0x10(%rsi), %r12d movl 0x14(%rsi), %r13d movl %r8d, -0x50(%r15) movl %r9d, -0x4C(%r15) movl %r10d, -0x48(%r15) movl %r11d, -0x44(%r15) movl %r12d, -0x40(%r15) movl %r13d, -0x3C(%r15) /* Key Set 1 */ /* Combined Substitute and Rotate */ movl %r13d, %eax AES192_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x01, %r8d xorl %ebx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d xorl %r11d, %r12d xorl %r12d, %r13d /* Store keys */ movl %r8d, -0x38(%r15) movl %r9d, -0x34(%r15) movl %r10d, -0x30(%r15) movl %r11d, -0x2C(%r15) movl %r12d, -0x28(%r15) movl %r13d, -0x24(%r15) /* Key Set 2 */ /* Combined Substitute and Rotate */ movl %r13d, %eax AES192_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x02, %r8d xorl %ebx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d xorl %r11d, %r12d xorl %r12d, %r13d /* Store keys */ movl %r8d, -0x20(%r15) movl %r9d, -0x1C(%r15) movl %r10d, -0x18(%r15) movl %r11d, -0x14(%r15) movl %r12d, -0x10(%r15) movl %r13d, -0x0C(%r15) /* Key Set 3 */ /* Combined Substitute and Rotate */ movl %r13d, %eax AES192_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x04, %r8d xorl %ebx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d xorl %r11d, %r12d xorl %r12d, %r13d /* Store keys */ movl %r8d, -0x08(%r15) movl %r9d, -0x04(%r15) movl %r10d, -0x00(%r15) movl %r11d, 0x04(%r15) movl %r12d, 0x08(%r15) movl %r13d, 0x0C(%r15) /* Key Set 4 */ /* Combined Substitute and Rotate */ movl %r13d, %eax AES192_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x08, %r8d xorl %ebx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d xorl %r11d, %r12d xorl %r12d, %r13d /* Store keys */ movl %r8d, 0x10(%r15) movl %r9d, 0x14(%r15) movl %r10d, 0x18(%r15) movl %r11d, 0x1C(%r15) movl %r12d, 0x20(%r15) movl %r13d, 0x24(%r15) /* Key Set 5 */ /* Combined Substitute and Rotate */ movl %r13d, %eax AES192_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x10, %r8d xorl %ebx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d xorl %r11d, %r12d xorl %r12d, %r13d /* Store keys */ movl %r8d, 0x28(%r15) movl %r9d, 0x2C(%r15) movl %r10d, 0x30(%r15) movl %r11d, 0x34(%r15) movl %r12d, 0x38(%r15) movl %r13d, 0x3C(%r15) /* Key Set 6 */ /* Combined Substitute and Rotate */ movl %r13d, %eax AES192_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x20, %r8d xorl %ebx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d xorl %r11d, %r12d xorl %r12d, %r13d /* Store keys */ movl %r8d, 0x40(%r15) movl %r9d, 0x44(%r15) movl %r10d, 0x48(%r15) movl %r11d, 0x4C(%r15) movl %r12d, 0x50(%r15) movl %r13d, 0x54(%r15) /* Key Set 7 */ /* Combined Substitute and Rotate */ movl %r13d, %eax AES192_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x40, %r8d xorl %ebx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d xorl %r11d, %r12d xorl %r12d, %r13d /* Store keys */ movl %r8d, 0x58(%r15) movl %r9d, 0x5C(%r15) movl %r10d, 0x60(%r15) movl %r11d, 0x64(%r15) movl %r12d, 0x68(%r15) movl %r13d, 0x6C(%r15) /* Key Set 8 */ /* Combined Substitute and Rota */ AES192_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x40, %r8d xorl %ebx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, 0x70(%r15) movl %r9d, 0x74(%r15) movl %r10d, 0x78(%r15) movl %r11d, 0x7C(%r15) /* Restore clobbered registers and return */ popq %rbx popq %rbp popq %r12 popq %r13 popq %r14 popq %r15 ret /* Takes the key in edx, applies the sbox to it, and rotates */ /* the result right by 8 bits, storing the result in edx. */ /* Uses registers rax, rbx, rcx, and rdx. */ /* Also reads from rsi, but does not write to it. */ .macro AES256_SET_KEY_SUBROTR8 movzbl %dl, %eax movzbl %dh, %ebx shll $16, %edx movzbl %dl, %ecx movzbl %dh, %edx movzbl (%rsi,%rax), %eax movzbl (%rsi,%rbx), %ebx movzbl (%rsi,%rcx), %ecx movzbl (%rsi,%rdx), %edx movb %cl, %bh movb %al, %dh shll $16, %ebx orl %ebx, %edx .endm /* Takes the key in edx and applies the sbox to it, */ /* storing the result in eax. */ /* Uses registers rax, rbx, rcx, and rdx. */ /* Also reads from rsi, but does not write to it. */ .macro AES256_SET_KEY_SUB movzbl %dl, %eax movzbl %dh, %ebx shll $16, %edx movzbl %dl, %ecx movzbl %dh, %edx movzbl (%rsi,%rax), %eax movzbl (%rsi,%rbx), %ebx movzbl (%rsi,%rcx), %ecx movzbl (%rsi,%rdx), %edx movb %bl, %ah movb %dl, %ch shll $16, %ecx orl %ecx, %eax .endm .align 16 .globl _crypto_aes256_set_key_x86_64 .def _crypto_aes256_set_key_x86_64; .scl 2; .type 32; .endef /* void _aes256_set_key_x86_64(uint32_t* subkeys [%rdi], */ /* const uint8_t* key [%rsi]) */ _crypto_aes256_set_key_x86_64: /* Clobber Registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbx /* Offset output pointer */ addq $0x70, %rdi /* Copy first 8 keys */ movl 0x00(%rsi), %r8d movl 0x04(%rsi), %r9d movl 0x08(%rsi), %r10d movl 0x0C(%rsi), %r11d movl 0x10(%rsi), %r12d movl 0x14(%rsi), %r13d movl 0x18(%rsi), %r14d movl 0x1C(%rsi), %r15d movl %r8d, -0x70(%rdi) movl %r9d, -0x6C(%rdi) movl %r10d, -0x68(%rdi) movl %r11d, -0x64(%rdi) movl %r12d, -0x60(%rdi) movl %r13d, -0x5C(%rdi) movl %r14d, -0x58(%rdi) movl %r15d, -0x54(%rdi) /* Store sbox pointer */ movq .refptr._crypto_aes_sbox(%rip), %rsi /* Key Set 1 */ /* Combined Substitute and Rotate */ movl %r15d, %edx AES256_SET_KEY_SUBROTR8 /* Compute first 4 keys of set */ xorl $0x01, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Substitute */ movl %r11d, %edx AES256_SET_KEY_SUB /* Compute last 4 keys of set */ xorl %eax, %r12d xorl %r12d, %r13d xorl %r13d, %r14d xorl %r14d, %r15d /* Store keys */ movl %r8d, -0x50(%rdi) movl %r9d, -0x4C(%rdi) movl %r10d, -0x48(%rdi) movl %r11d, -0x44(%rdi) movl %r12d, -0x40(%rdi) movl %r13d, -0x3C(%rdi) movl %r14d, -0x38(%rdi) movl %r15d, -0x34(%rdi) /* Key Set 2 */ /* Combined Substitute and Rotate */ movl %r15d, %edx AES256_SET_KEY_SUBROTR8 /* Compute first 4 keys of set */ xorl $0x02, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Substitute */ movl %r11d, %edx AES256_SET_KEY_SUB /* Compute last 4 keys of set */ xorl %eax, %r12d xorl %r12d, %r13d xorl %r13d, %r14d xorl %r14d, %r15d /* Store keys */ movl %r8d, -0x30(%rdi) movl %r9d, -0x2C(%rdi) movl %r10d, -0x28(%rdi) movl %r11d, -0x24(%rdi) movl %r12d, -0x20(%rdi) movl %r13d, -0x1C(%rdi) movl %r14d, -0x18(%rdi) movl %r15d, -0x14(%rdi) /* Key Set 3 */ /* Combined Substitute and Rotate */ movl %r15d, %edx AES256_SET_KEY_SUBROTR8 /* Compute first 4 keys of set */ xorl $0x04, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Substitute */ movl %r11d, %edx AES256_SET_KEY_SUB /* Compute last 4 keys of set */ xorl %eax, %r12d xorl %r12d, %r13d xorl %r13d, %r14d xorl %r14d, %r15d /* Store keys */ movl %r8d, -0x10(%rdi) movl %r9d, -0x0C(%rdi) movl %r10d, -0x08(%rdi) movl %r11d, -0x04(%rdi) movl %r12d, 0x00(%rdi) movl %r13d, 0x04(%rdi) movl %r14d, 0x08(%rdi) movl %r15d, 0x0C(%rdi) /* Key Set 4 */ /* Combined Substitute and Rotate */ movl %r15d, %edx AES256_SET_KEY_SUBROTR8 /* Compute first 4 keys of set */ xorl $0x08, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Substitute */ movl %r11d, %edx AES256_SET_KEY_SUB /* Compute last 4 keys of set */ xorl %eax, %r12d xorl %r12d, %r13d xorl %r13d, %r14d xorl %r14d, %r15d /* Store keys */ movl %r8d, 0x10(%rdi) movl %r9d, 0x14(%rdi) movl %r10d, 0x18(%rdi) movl %r11d, 0x1C(%rdi) movl %r12d, 0x20(%rdi) movl %r13d, 0x24(%rdi) movl %r14d, 0x28(%rdi) movl %r15d, 0x2C(%rdi) /* Key Set 5 */ /* Combined Substitute and Rotate */ movl %r15d, %edx AES256_SET_KEY_SUBROTR8 /* Compute first 4 keys of set */ xorl $0x10, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Substitute */ movl %r11d, %edx AES256_SET_KEY_SUB /* Compute last 4 keys of set */ xorl %eax, %r12d xorl %r12d, %r13d xorl %r13d, %r14d xorl %r14d, %r15d /* Store keys */ movl %r8d, 0x30(%rdi) movl %r9d, 0x34(%rdi) movl %r10d, 0x38(%rdi) movl %r11d, 0x3C(%rdi) movl %r12d, 0x40(%rdi) movl %r13d, 0x44(%rdi) movl %r14d, 0x48(%rdi) movl %r15d, 0x4C(%rdi) /* Key Set 6 */ /* Combined Substitute and Rotate */ movl %r15d, %edx AES256_SET_KEY_SUBROTR8 /* Compute first 4 keys of set */ xorl $0x20, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Substitute */ movl %r11d, %edx AES256_SET_KEY_SUB /* Compute last 4 keys of set */ xorl %eax, %r12d xorl %r12d, %r13d xorl %r13d, %r14d xorl %r14d, %r15d /* Store keys */ movl %r8d, 0x50(%rdi) movl %r9d, 0x54(%rdi) movl %r10d, 0x58(%rdi) movl %r11d, 0x5C(%rdi) movl %r12d, 0x60(%rdi) movl %r13d, 0x64(%rdi) movl %r14d, 0x68(%rdi) movl %r15d, 0x6C(%rdi) /* Key Set 7 */ /* Combined Substitute and Rotate */ movl %r15d, %edx AES256_SET_KEY_SUBROTR8 /* Compute keys */ xorl $0x40, %r8d xorl %edx, %r8d xorl %r8d, %r9d xorl %r9d, %r10d xorl %r10d, %r11d /* Store keys */ movl %r8d, 0x70(%rdi) movl %r9d, 0x74(%rdi) movl %r10d, 0x78(%rdi) movl %r11d, 0x7C(%rdi) /* Restore clobbered registers and return */ popq %rbx popq %r12 popq %r13 popq %r14 popq %r15 ret /* Invert the 4 keys in eax, ebx, ecx, and edx, storing */ /* the results in r8d, r9d, r10d, and r11d, respectively. */ /* Uses registers rax, rbx, rcx, rdx, r8, r9, r10, r11, r12, r13, r14, and r15. */ /* Also reads from rbp, but does not write to it. */ .macro AES_INVERT4 movzbl %al, %r12d movzbl %bl, %r13d movzbl %cl, %r14d movzbl %dl, %r15d movl 0x000(%rbp,%r12,4), %r8d movl 0x000(%rbp,%r13,4), %r9d movl 0x000(%rbp,%r14,4), %r10d movl 0x000(%rbp,%r15,4), %r11d movzbl %ah, %r12d movzbl %bh, %r13d movzbl %ch, %r14d movzbl %dh, %r15d xorl 0x400(%rbp,%r12,4), %r8d xorl 0x400(%rbp,%r13,4), %r9d xorl 0x400(%rbp,%r14,4), %r10d xorl 0x400(%rbp,%r15,4), %r11d shrl $16, %eax shrl $16, %ebx shrl $16, %ecx shrl $16, %edx movzbl %al, %r12d movzbl %bl, %r13d movzbl %cl, %r14d movzbl %dl, %r15d movl 0x800(%rbp,%r12,4), %r8d movl 0x800(%rbp,%r13,4), %r9d movl 0x800(%rbp,%r14,4), %r10d movl 0x800(%rbp,%r15,4), %r11d movzbl %ah, %r12d movzbl %bh, %r13d movzbl %ch, %r14d movzbl %dh, %r15d xorl 0xC00(%rbp,%r12,4), %r8d xorl 0xC00(%rbp,%r13,4), %r9d xorl 0xC00(%rbp,%r14,4), %r10d xorl 0xC00(%rbp,%r15,4), %r11d .endm .align 16 .globl _crypto_aes128_invert_x86_64 .def _crypto_aes128_invert_x86_64; .scl 2; .type 32; .endef /* void _aes128_invert_x86_64(uint32_t* dst [%rdi], */ /* const uint32_t* src [%rsi]) */ _crypto_aes128_invert_x86_64: /* Clobber registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx addq $0x30, %rdi /* Offset dst pointer (to allow for 1-byte offsets) */ addq $0x30, %rsi /* Offset src pointer (to allow for 1-byte offsets) */ movq .refptr._crypto_aes_mtable(%rip), %rbp /* Load mtable pointer into rbp */ cmpq %rdi, %rsi jne .Linvert128 /* Copy first 4 and last 4 keys without inverting */ /* Round Key 0 */ movl -0x30(%rsi), %eax movl -0x2C(%rsi), %ebx movl -0x28(%rsi), %ecx movl -0x24(%rsi), %edx /* Round Key 10 */ movl 0x70(%rsi), %r12d movl 0x74(%rsi), %r13d movl 0x78(%rsi), %r14d movl 0x7C(%rsi), %r15d /* Round Key 0 */ movl %eax, -0x30(%rdi) movl %ebx, -0x2C(%rdi) movl %ecx, -0x28(%rdi) movl %edx, -0x24(%rdi) /* Round Key 10 */ movl %r12d, 0x70(%rdi) movl %r13d, 0x74(%rdi) movl %r14d, 0x78(%rdi) movl %r15d, 0x7C(%rdi) .align 16 .Linvert128: /* Round Key 1 */ movl -0x20(%rsi), %eax movl -0x1C(%rsi), %ebx movl -0x18(%rsi), %ecx movl -0x14(%rsi), %edx AES_INVERT4 movl %r8d, -0x20(%rdi) movl %r9d, -0x1C(%rdi) movl %r10d, -0x18(%rdi) movl %r11d, -0x14(%rdi) /* Round Key 2 */ movl -0x10(%rsi), %eax movl -0x0C(%rsi), %ebx movl -0x08(%rsi), %ecx movl -0x04(%rsi), %edx AES_INVERT4 movl %r8d, -0x10(%rdi) movl %r9d, -0x0C(%rdi) movl %r10d, -0x08(%rdi) movl %r11d, -0x04(%rdi) /* Round Key 3 */ movl 0x00(%rsi), %eax movl 0x04(%rsi), %ebx movl 0x08(%rsi), %ecx movl 0x0C(%rsi), %edx AES_INVERT4 movl %r8d, 0x00(%rdi) movl %r9d, 0x04(%rdi) movl %r10d, 0x08(%rdi) movl %r11d, 0x0C(%rdi) /* Round Key 4 */ movl 0x10(%rsi), %eax movl 0x14(%rsi), %ebx movl 0x18(%rsi), %ecx movl 0x1C(%rsi), %edx AES_INVERT4 movl %r8d, 0x10(%rdi) movl %r9d, 0x14(%rdi) movl %r10d, 0x18(%rdi) movl %r11d, 0x1C(%rdi) /* Round Key 5 */ movl 0x20(%rsi), %eax movl 0x24(%rsi), %ebx movl 0x28(%rsi), %ecx movl 0x2C(%rsi), %edx AES_INVERT4 movl %r8d, 0x20(%rdi) movl %r9d, 0x24(%rdi) movl %r10d, 0x28(%rdi) movl %r11d, 0x2C(%rdi) /* Round Key 6 */ movl 0x30(%rsi), %eax movl 0x34(%rsi), %ebx movl 0x38(%rsi), %ecx movl 0x3C(%rsi), %edx AES_INVERT4 movl %r8d, 0x30(%rdi) movl %r9d, 0x34(%rdi) movl %r10d, 0x38(%rdi) movl %r11d, 0x3C(%rdi) /* Round Key 7 */ movl 0x40(%rsi), %eax movl 0x44(%rsi), %ebx movl 0x48(%rsi), %ecx movl 0x4C(%rsi), %edx AES_INVERT4 movl %r8d, 0x40(%rdi) movl %r9d, 0x44(%rdi) movl %r10d, 0x48(%rdi) movl %r11d, 0x4C(%rdi) /* Round Key 8 */ movl 0x50(%rsi), %eax movl 0x54(%rsi), %ebx movl 0x58(%rsi), %ecx movl 0x5C(%rsi), %edx AES_INVERT4 movl %r8d, 0x50(%rdi) movl %r9d, 0x54(%rdi) movl %r10d, 0x58(%rdi) movl %r11d, 0x5C(%rdi) /* Round Key 9 */ movl 0x60(%rsi), %eax movl 0x64(%rsi), %ebx movl 0x68(%rsi), %ecx movl 0x6C(%rsi), %edx AES_INVERT4 movl %r8d, 0x60(%rdi) movl %r9d, 0x64(%rdi) movl %r10d, 0x68(%rdi) movl %r11d, 0x6C(%rdi) /* Restore clobbered registers and return */ popq %rbx popq %r12 popq %r13 popq %r14 popq %r15 ret .align 16 .globl _crypto_aes192_invert_x86_64 .def _crypto_aes192_invert_x86_64; .scl 2; .type 32; .endef /* void _aes192_invert_x86_64(uint32_t* dst [%rdi], */ /* const uint32_t* src [%rsi]) */ _crypto_aes192_invert_x86_64: /* Clobber registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx addq $0x50, %rdi /* Offset dst pointer (to allow for 1-byte offsets) */ addq $0x50, %rsi /* Offset src pointer (to allow for 1-byte offsets) */ movq .refptr._crypto_aes_mtable(%rip), %rbp /* Load mtable pointer into rbp */ cmpq %rdi, %rsi jne .Linvert192 /* Copy first 4 and last 4 keys without inverting */ /* Round Key 0 */ movl -0x50(%rsi), %eax movl -0x4C(%rsi), %ebx movl -0x48(%rsi), %ecx movl -0x44(%rsi), %edx /* Round Key 12 */ movl 0x70(%rsi), %r12d movl 0x74(%rsi), %r13d movl 0x78(%rsi), %r14d movl 0x7C(%rsi), %r15d /* Round Key 0 */ movl %eax, -0x50(%rdi) movl %ebx, -0x4C(%rdi) movl %ecx, -0x48(%rdi) movl %edx, -0x44(%rdi) /* Round Key 12 */ movl %r12d, 0x70(%rdi) movl %r13d, 0x74(%rdi) movl %r14d, 0x78(%rdi) movl %r15d, 0x7C(%rdi) .Linvert192: /* Round Key 1 */ movl -0x40(%rsi), %eax movl -0x3C(%rsi), %ebx movl -0x38(%rsi), %ecx movl -0x34(%rsi), %edx AES_INVERT4 movl %r8d, -0x40(%rdi) movl %r9d, -0x3C(%rdi) movl %r10d, -0x38(%rdi) movl %r11d, -0x34(%rdi) /* Round Key 2 */ movl -0x30(%rsi), %eax movl -0x2C(%rsi), %ebx movl -0x28(%rsi), %ecx movl -0x24(%rsi), %edx AES_INVERT4 movl %r8d, -0x30(%rdi) movl %r9d, -0x2C(%rdi) movl %r10d, -0x28(%rdi) movl %r11d, -0x24(%rdi) /* Recycle 128-bit invert code for remaining 9 round keys */ jmp .Linvert128 .globl _crypto_aes256_invert_x86_64 .def _crypto_aes256_invert_x86_64; .scl 2; .type 32; .endef /* void _aes256_invert_x86_64(uint32_t* dst [%rdi], */ /* const uint32_t* src [%rsi]) */ _crypto_aes256_invert_x86_64: /* Clobber registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx addq $0x70, %rdi /* Offset dst pointer (to allow for 1-byte offsets) */ addq $0x70, %rsi /* Offset src pointer (to allow for 1-byte offsets) */ movq .refptr._crypto_aes_mtable(%rip), %rbp /* Load mtable pointer into rbp */ cmpq %rdi, %rsi jne .Linvert256 /* Copy first 4 and last 4 keys without inverting */ /* Round Key 0 */ movl -0x70(%rsi), %eax movl -0x6C(%rsi), %ebx movl -0x68(%rsi), %ecx movl -0x64(%rsi), %edx /* Round Key 14 */ movl 0x70(%rsi), %r12d movl 0x74(%rsi), %r13d movl 0x78(%rsi), %r14d movl 0x7C(%rsi), %r15d /* Round Key 0 */ movl %eax, -0x70(%rdi) movl %ebx, -0x6C(%rdi) movl %ecx, -0x68(%rdi) movl %edx, -0x64(%rdi) /* Round Key 14 */ movl %r12d, 0x70(%rdi) movl %r13d, 0x74(%rdi) movl %r14d, 0x78(%rdi) movl %r15d, 0x7C(%rdi) .Linvert256: /* Round Key 1 */ movl -0x60(%rsi), %eax movl -0x5C(%rsi), %ebx movl -0x58(%rsi), %ecx movl -0x54(%rsi), %edx AES_INVERT4 movl %r8d, -0x60(%rdi) movl %r9d, -0x5C(%rdi) movl %r10d, -0x58(%rdi) movl %r11d, -0x54(%rdi) /* Round Key 2 */ movl -0x50(%rsi), %eax movl -0x4C(%rsi), %ebx movl -0x48(%rsi), %ecx movl -0x44(%rsi), %edx AES_INVERT4 movl %r8d, -0x50(%rdi) movl %r9d, -0x4C(%rdi) movl %r10d, -0x48(%rdi) movl %r11d, -0x44(%rdi) /* Round Key 3 */ movl -0x40(%rsi), %eax movl -0x3C(%rsi), %ebx movl -0x38(%rsi), %ecx movl -0x34(%rsi), %edx AES_INVERT4 movl %r8d, -0x40(%rdi) movl %r9d, -0x3C(%rdi) movl %r10d, -0x38(%rdi) movl %r11d, -0x34(%rdi) /* Round Key 4 */ movl -0x30(%rsi), %eax movl -0x2C(%rsi), %ebx movl -0x28(%rsi), %ecx movl -0x24(%rsi), %edx AES_INVERT4 movl %r8d, -0x30(%rdi) movl %r9d, -0x2C(%rdi) movl %r10d, -0x28(%rdi) movl %r11d, -0x24(%rdi) /* Recycle 128-bit invert code for remaining 9 round keys */ jmp .Linvert128 .macro AES_ENCRYPT_ROUND movzbl %al, %ebp movzbl %bl, %esi movzbl %cl, %edi movzbl %dl, %r12d movl 0x000(%r13,%rbp,4), %r8d movl 0x000(%r13,%rsi,4), %r9d movl 0x000(%r13,%rdi,4), %r10d movl 0x000(%r13,%r12,4), %r11d movzbl %ah, %ebp movzbl %bh, %esi movzbl %ch, %edi movzbl %dh, %r12d xorl 0x400(%r13,%rbp,4), %r11d xorl 0x400(%r13,%rsi,4), %r8d xorl 0x400(%r13,%rdi,4), %r9d xorl 0x400(%r13,%r12,4), %r10d shrl $16, %eax shrl $16, %ebx shrl $16, %ecx shrl $16, %edx movzbl %al, %ebp movzbl %bl, %esi movzbl %cl, %edi movzbl %dl, %r12d xorl 0x800(%r13,%rbp,4), %r10d xorl 0x800(%r13,%rsi,4), %r11d xorl 0x800(%r13,%rdi,4), %r8d xorl 0x800(%r13,%r12,4), %r9d movzbl %ah, %ebp movzbl %bh, %esi movzbl %ch, %edi movzbl %dh, %r12d xorl 0xC00(%r13,%rbp,4), %r9d xorl 0xC00(%r13,%rsi,4), %r10d xorl 0xC00(%r13,%rdi,4), %r11d xorl 0xC00(%r13,%r12,4), %r8d .endm .macro AES_ENCRYPT_ROUND_FINAL movzbl %al, %ebp movzbl %bl, %esi movzbl %cl, %edi movzbl %dl, %r12d movzbl (%r13,%rbp), %r8d movzbl (%r13,%rsi), %r9d movzbl (%r13,%rdi), %r10d movzbl (%r13,%r12), %r11d rorl $8, %r8d rorl $8, %r9d rorl $8, %r10d rorl $8, %r11d movzbl %ah, %ebp movzbl %bh, %esi movzbl %ch, %edi movzbl %dh, %r12d movb (%r13,%rbp), %r11b movb (%r13,%rsi), %r8b movb (%r13,%rdi), %r9b movb (%r13,%r12), %r10b rorl $8, %r11d rorl $8, %r8d rorl $8, %r9d rorl $8, %r10d shrl $16, %eax shrl $16, %ebx shrl $16, %ecx shrl $16, %edx movzbl %al, %ebp movzbl %bl, %esi movzbl %cl, %edi movzbl %dl, %r12d movb (%r13,%rbp), %r10b movb (%r13,%rsi), %r11b movb (%r13,%rdi), %r8b movb (%r13,%r12), %r9b rorl $8, %r10d rorl $8, %r11d rorl $8, %r8d rorl $8, %r9d movzbl %ah, %ebp movzbl %bh, %esi movzbl %ch, %edi movzbl %dh, %r12d movb (%r13,%rbp), %r9b movb (%r13,%rsi), %r10b movb (%r13,%rdi), %r11b movb (%r13,%r12), %r8b rorl $8, %r9d rorl $8, %r10d rorl $8, %r11d rorl $8, %r8d .endm .align 16 .globl _crypto_aes128_encrypt_x86_64 .def _crypto_aes128_encrypt_x86_64; .scl 2; .type 32; .endef /* void _aes128_encrypt_x86_64(const uint32_t* key [%rdi], */ /* uint8_t* dst [%rsi], */ /* const uint8_t* src [%rdx], */ /* size_t length [%rcx]) */ _crypto_aes128_encrypt_x86_64: /* Clobber Registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx subq $16, %rsp /* Allocate 16 bytes on stack for loop counter and src pointer */ cmpq $16, %rcx jb .Lencrypt128_end /* skip to return if there is less than 16 bytes to process */ shrq $4, %rcx /* divide length by 16 */ movq %rsi, %r15 /* Move output pointer */ leaq 0x30(%rdi), %r14 /* Offset and store key pointer */ movq %rcx, 0(%rsp) /* store loop counter on stack */ movq %rdx, 8(%rsp) /* store src pointer on stack */ .align 16 .Lencrypt128_loop: movq 8(%rsp), %rdx /* Load src pointer */ /* Store dtable pointer */ movq .refptr._crypto_aes_dtable(%rip), %r13 /* Load state */ movl 0x0(%rdx), %eax movl 0x4(%rdx), %ebx movl 0x8(%rdx), %ecx movl 0xC(%rdx), %edx addq $16, 8(%rsp) /* Offset src pointer */ /* Add first round key */ xorl -0x30(%r14), %eax xorl -0x2C(%r14), %ebx xorl -0x28(%r14), %ecx xorl -0x24(%r14), %edx /* Round 1 */ AES_ENCRYPT_ROUND movl -0x20(%r14), %eax movl -0x1C(%r14), %ebx movl -0x18(%r14), %ecx movl -0x14(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 2 */ AES_ENCRYPT_ROUND movl -0x10(%r14), %eax movl -0x0C(%r14), %ebx movl -0x08(%r14), %ecx movl -0x04(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 3 */ AES_ENCRYPT_ROUND movl 0x00(%r14), %eax movl 0x04(%r14), %ebx movl 0x08(%r14), %ecx movl 0x0C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 4 */ AES_ENCRYPT_ROUND movl 0x10(%r14), %eax movl 0x14(%r14), %ebx movl 0x18(%r14), %ecx movl 0x1C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 5 */ AES_ENCRYPT_ROUND movl 0x20(%r14), %eax movl 0x24(%r14), %ebx movl 0x28(%r14), %ecx movl 0x2C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 6 */ AES_ENCRYPT_ROUND movl 0x30(%r14), %eax movl 0x34(%r14), %ebx movl 0x38(%r14), %ecx movl 0x3C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 7 */ AES_ENCRYPT_ROUND movl 0x40(%r14), %eax movl 0x44(%r14), %ebx movl 0x48(%r14), %ecx movl 0x4C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 8 */ AES_ENCRYPT_ROUND movl 0x50(%r14), %eax movl 0x54(%r14), %ebx movl 0x58(%r14), %ecx movl 0x5C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 9 */ AES_ENCRYPT_ROUND movl 0x60(%r14), %eax movl 0x64(%r14), %ebx movl 0x68(%r14), %ecx movl 0x6C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 10, Final Round */ /* Store sbox pointer */ movq .refptr._crypto_aes_sbox(%rip), %r13 AES_ENCRYPT_ROUND_FINAL xorl 0x70(%r14), %r8d xorl 0x74(%r14), %r9d xorl 0x78(%r14), %r10d xorl 0x7C(%r14), %r11d /* Store output */ movl %r8d, 0x0(%r15) movl %r9d, 0x4(%r15) movl %r10d, 0x8(%r15) movl %r11d, 0xC(%r15) addq $16, %r15 /* Increment dst pointer */ /* Decrement loop counter and check loop condition */ decq (%rsp) jnz .Lencrypt128_loop .align 16 .Lencrypt128_end: /* Free allocated stack space, restore clobbered registers, and return */ addq $16, %rsp /* Free allocated stack space */ popq %rbx popq %rbp popq %r12 popq %r13 popq %r14 popq %r15 ret .align 16 .globl _crypto_aes192_encrypt_x86_64 .def _crypto_aes192_encrypt_x86_64; .scl 2; .type 32; .endef /* void _aes192_encrypt_x86_64(const uint32_t* key [%rdi], */ /* uint8_t* dst [%rsi], */ /* const uint8_t* src [%rdx], */ /* size_t length [%rcx]) */ _crypto_aes192_encrypt_x86_64: /* Clobber Registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx subq $16, %rsp /* Allocate 16 bytes on stack for loop counter and src pointer */ cmpq $16, %rcx jb .Lencrypt192_end /* skip to return if there is less than 16 bytes to process */ shrq $4, %rcx /* divide length by 16 */ movq %rsi, %r15 /* Move output pointer */ leaq 0x50(%rdi), %r14 /* Offset and store key pointer */ movq %rcx, 0(%rsp) /* store loop counter on stack */ movq %rdx, 8(%rsp) /* store src pointer on stack */ .align 16 .Lencrypt192_loop: movq 8(%rsp), %rdx /* Load src pointer */ /* Store dtable pointer */ movq .refptr._crypto_aes_dtable(%rip), %r13 /* Load state */ movl 0x0(%rdx), %eax movl 0x4(%rdx), %ebx movl 0x8(%rdx), %ecx movl 0xC(%rdx), %edx addq $16, 8(%rsp) /* Offset src pointer */ /* Add first round key */ xorl -0x50(%r14), %eax xorl -0x4C(%r14), %ebx xorl -0x48(%r14), %ecx xorl -0x44(%r14), %edx /* Round 1 */ AES_ENCRYPT_ROUND movl -0x40(%r14), %eax movl -0x3C(%r14), %ebx movl -0x38(%r14), %ecx movl -0x34(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 2 */ AES_ENCRYPT_ROUND movl -0x30(%r14), %eax movl -0x2C(%r14), %ebx movl -0x28(%r14), %ecx movl -0x24(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 3 */ AES_ENCRYPT_ROUND movl -0x20(%r14), %eax movl -0x1C(%r14), %ebx movl -0x18(%r14), %ecx movl -0x14(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 4 */ AES_ENCRYPT_ROUND movl -0x10(%r14), %eax movl -0x0C(%r14), %ebx movl -0x08(%r14), %ecx movl -0x04(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 5 */ AES_ENCRYPT_ROUND movl 0x00(%r14), %eax movl 0x04(%r14), %ebx movl 0x08(%r14), %ecx movl 0x0C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 6 */ AES_ENCRYPT_ROUND movl 0x10(%r14), %eax movl 0x14(%r14), %ebx movl 0x18(%r14), %ecx movl 0x1C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 7 */ AES_ENCRYPT_ROUND movl 0x20(%r14), %eax movl 0x24(%r14), %ebx movl 0x28(%r14), %ecx movl 0x2C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 8 */ AES_ENCRYPT_ROUND movl 0x30(%r14), %eax movl 0x34(%r14), %ebx movl 0x38(%r14), %ecx movl 0x3C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 9 */ AES_ENCRYPT_ROUND movl 0x40(%r14), %eax movl 0x44(%r14), %ebx movl 0x48(%r14), %ecx movl 0x4C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 10 */ AES_ENCRYPT_ROUND movl 0x50(%r14), %eax movl 0x54(%r14), %ebx movl 0x58(%r14), %ecx movl 0x5C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 11 */ AES_ENCRYPT_ROUND movl 0x60(%r14), %eax movl 0x64(%r14), %ebx movl 0x68(%r14), %ecx movl 0x6C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 12, Final Round */ /* Store sbox pointer */ movq .refptr._crypto_aes_sbox(%rip), %r13 AES_ENCRYPT_ROUND_FINAL xorl 0x70(%r14), %r8d xorl 0x74(%r14), %r9d xorl 0x78(%r14), %r10d xorl 0x7C(%r14), %r11d /* Store output */ movl %r8d, 0x0(%r15) movl %r9d, 0x4(%r15) movl %r10d, 0x8(%r15) movl %r11d, 0xC(%r15) addq $16, %r15 /* Increment dst pointer */ /* Decrement loop counter and check loop condition */ decq (%rsp) jnz .Lencrypt192_loop .align 16 .Lencrypt192_end: /* Free allocated stack space, restore clobbered registers, and return */ addq $16, %rsp /* Free allocated stack space */ popq %rbx popq %rbp popq %r12 popq %r13 popq %r14 popq %r15 ret .align 16 .globl _crypto_aes256_encrypt_x86_64 .def _crypto_aes256_encrypt_x86_64; .scl 2; .type 32; .endef /* void _aes256_encrypt_x86_64(const uint32_t* key [%rdi], */ /* uint8_t* dst [%rsi], */ /* const uint8_t* src [%rdx], */ /* size_t length [%rcx]) */ _crypto_aes256_encrypt_x86_64: /* Clobber Registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx subq $16, %rsp /* Allocate 16 bytes on stack for loop counter and src pointer */ cmpq $16, %rcx jb .Lencrypt256_end /* skip to return if there is less than 16 bytes to process */ shrq $4, %rcx /* divide length by 16 */ movq %rsi, %r15 /* Move output pointer */ leaq 0x70(%rdi), %r14 /* Offset and store key pointer */ movq %rcx, 0(%rsp) /* store loop counter on stack */ movq %rdx, 8(%rsp) /* store src pointer on stack */ .align 16 .Lencrypt256_loop: movq 8(%rsp), %rdx /* Load src pointer */ /* Store dtable pointer */ movq .refptr._crypto_aes_dtable(%rip), %r13 /* Load state */ movl 0x0(%rdx), %eax movl 0x4(%rdx), %ebx movl 0x8(%rdx), %ecx movl 0xC(%rdx), %edx addq $16, 8(%rsp) /* Offset src pointer */ /* Add first round key */ xorl -0x70(%r14), %eax xorl -0x6C(%r14), %ebx xorl -0x68(%r14), %ecx xorl -0x64(%r14), %edx /* Round 1 */ AES_ENCRYPT_ROUND movl -0x60(%r14), %eax movl -0x5C(%r14), %ebx movl -0x58(%r14), %ecx movl -0x54(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 2 */ AES_ENCRYPT_ROUND movl -0x50(%r14), %eax movl -0x4C(%r14), %ebx movl -0x48(%r14), %ecx movl -0x44(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 3 */ AES_ENCRYPT_ROUND movl -0x40(%r14), %eax movl -0x3C(%r14), %ebx movl -0x38(%r14), %ecx movl -0x34(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 4 */ AES_ENCRYPT_ROUND movl -0x30(%r14), %eax movl -0x2C(%r14), %ebx movl -0x28(%r14), %ecx movl -0x24(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 5 */ AES_ENCRYPT_ROUND movl -0x20(%r14), %eax movl -0x1C(%r14), %ebx movl -0x18(%r14), %ecx movl -0x14(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 6 */ AES_ENCRYPT_ROUND movl -0x10(%r14), %eax movl -0x0C(%r14), %ebx movl -0x08(%r14), %ecx movl -0x04(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 7 */ AES_ENCRYPT_ROUND movl 0x00(%r14), %eax movl 0x04(%r14), %ebx movl 0x08(%r14), %ecx movl 0x0C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 8 */ AES_ENCRYPT_ROUND movl 0x10(%r14), %eax movl 0x14(%r14), %ebx movl 0x18(%r14), %ecx movl 0x1C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 9 */ AES_ENCRYPT_ROUND movl 0x20(%r14), %eax movl 0x24(%r14), %ebx movl 0x28(%r14), %ecx movl 0x2C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 10 */ AES_ENCRYPT_ROUND movl 0x30(%r14), %eax movl 0x34(%r14), %ebx movl 0x38(%r14), %ecx movl 0x3C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 11 */ AES_ENCRYPT_ROUND movl 0x40(%r14), %eax movl 0x44(%r14), %ebx movl 0x48(%r14), %ecx movl 0x4C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 12 */ AES_ENCRYPT_ROUND movl 0x50(%r14), %eax movl 0x54(%r14), %ebx movl 0x58(%r14), %ecx movl 0x5C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 13 */ AES_ENCRYPT_ROUND movl 0x60(%r14), %eax movl 0x64(%r14), %ebx movl 0x68(%r14), %ecx movl 0x6C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 14, Final Round */ /* Store sbox pointer */ movq .refptr._crypto_aes_sbox(%rip), %r13 AES_ENCRYPT_ROUND_FINAL xorl 0x70(%r14), %r8d xorl 0x74(%r14), %r9d xorl 0x78(%r14), %r10d xorl 0x7C(%r14), %r11d /* Store output */ movl %r8d, 0x0(%r15) movl %r9d, 0x4(%r15) movl %r10d, 0x8(%r15) movl %r11d, 0xC(%r15) addq $16, %r15 /* Increment dst pointer */ /* Decrement loop counter and check loop condition */ decq (%rsp) jnz .Lencrypt256_loop .align 16 .Lencrypt256_end: /* Free allocated stack space, restore clobbered registers, and return */ addq $16, %rsp /* Free allocated stack space */ popq %rbx popq %rbp popq %r12 popq %r13 popq %r14 popq %r15 ret .macro AES_DECRYPT_ROUND movzbl %al, %ebp movzbl %bl, %esi movzbl %cl, %edi movzbl %dl, %r12d movl 0x000(%r13,%rbp,4), %r8d movl 0x000(%r13,%rsi,4), %r9d movl 0x000(%r13,%rdi,4), %r10d movl 0x000(%r13,%r12,4), %r11d movzbl %ah, %ebp movzbl %bh, %esi movzbl %ch, %edi movzbl %dh, %r12d xorl 0x400(%r13,%rbp,4), %r9d xorl 0x400(%r13,%rsi,4), %r10d xorl 0x400(%r13,%rdi,4), %r11d xorl 0x400(%r13,%r12,4), %r8d shrl $16, %eax shrl $16, %ebx shrl $16, %ecx shrl $16, %edx movzbl %al, %ebp movzbl %bl, %esi movzbl %cl, %edi movzbl %dl, %r12d xorl 0x800(%r13,%rbp,4), %r10d xorl 0x800(%r13,%rsi,4), %r11d xorl 0x800(%r13,%rdi,4), %r8d xorl 0x800(%r13,%r12,4), %r9d movzbl %ah, %ebp movzbl %bh, %esi movzbl %ch, %edi movzbl %dh, %r12d xorl 0xC00(%r13,%rbp,4), %r11d xorl 0xC00(%r13,%rsi,4), %r8d xorl 0xC00(%r13,%rdi,4), %r9d xorl 0xC00(%r13,%r12,4), %r10d .endm .macro AES_DECRYPT_ROUND_FINAL movzbl %al, %ebp movzbl %bl, %esi movzbl %cl, %edi movzbl %dl, %r12d movzbl (%r13,%rbp), %r8d movzbl (%r13,%rsi), %r9d movzbl (%r13,%rdi), %r10d movzbl (%r13,%r12), %r11d rorl $8, %r8d rorl $8, %r9d rorl $8, %r10d rorl $8, %r11d movzbl %ah, %ebp movzbl %bh, %esi movzbl %ch, %edi movzbl %dh, %r12d movb (%r13,%rbp), %r9b movb (%r13,%rsi), %r10b movb (%r13,%rdi), %r11b movb (%r13,%r12), %r8b rorl $8, %r9d rorl $8, %r10d rorl $8, %r11d rorl $8, %r8d shrl $16, %eax shrl $16, %ebx shrl $16, %ecx shrl $16, %edx movzbl %al, %ebp movzbl %bl, %esi movzbl %cl, %edi movzbl %dl, %r12d movb (%r13,%rbp), %r10b movb (%r13,%rsi), %r11b movb (%r13,%rdi), %r8b movb (%r13,%r12), %r9b rorl $8, %r10d rorl $8, %r11d rorl $8, %r8d rorl $8, %r9d movzbl %ah, %ebp movzbl %bh, %esi movzbl %ch, %edi movzbl %dh, %r12d movb (%r13,%rbp), %r11b movb (%r13,%rsi), %r8b movb (%r13,%rdi), %r9b movb (%r13,%r12), %r10b rorl $8, %r11d rorl $8, %r8d rorl $8, %r9d rorl $8, %r10d .endm .align 16 .globl _crypto_aes128_decrypt_x86_64 .def _crypto_aes128_decrypt_x86_64; .scl 2; .type 32; .endef /* void _aes128_decrypt_x86_64(const uint32_t* key [%rdi], */ /* uint8_t* dst [%rsi], */ /* const uint8_t* src [%rdx], */ /* size_t length [%rcx]) */ _crypto_aes128_decrypt_x86_64: /* Clobber Registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx subq $16, %rsp /* Allocate 16 bytes on stack for loop counter and src pointer */ cmpq $16, %rcx jb .Ldecrypt128_end /* skip to return if there is less than 16 bytes to process */ shrq $4, %rcx /* divide length by 16 */ movq %rsi, %r15 /* Move output pointer */ leaq 0x30(%rdi), %r14 /* Offset and store key pointer */ movq %rcx, 0(%rsp) /* store loop counter on stack */ movq %rdx, 8(%rsp) /* store src pointer on stack */ .align 16 .Ldecrypt128_loop: movq 8(%rsp), %rdx /* Load src pointer */ /* Store itable pointer */ movq .refptr._crypto_aes_itable(%rip), %r13 /* Load state */ movl 0x0(%rdx), %eax movl 0x4(%rdx), %ebx movl 0x8(%rdx), %ecx movl 0xC(%rdx), %edx addq $16, 8(%rsp) /* Offset src pointer */ /* Add last round key */ xorl 0x70(%r14), %eax xorl 0x74(%r14), %ebx xorl 0x78(%r14), %ecx xorl 0x7C(%r14), %edx /* Round 9 */ AES_DECRYPT_ROUND movl 0x60(%r14), %eax movl 0x64(%r14), %ebx movl 0x68(%r14), %ecx movl 0x6C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 8 */ AES_DECRYPT_ROUND movl 0x50(%r14), %eax movl 0x54(%r14), %ebx movl 0x58(%r14), %ecx movl 0x5C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 7 */ AES_DECRYPT_ROUND movl 0x40(%r14), %eax movl 0x44(%r14), %ebx movl 0x48(%r14), %ecx movl 0x4C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 6 */ AES_DECRYPT_ROUND movl 0x30(%r14), %eax movl 0x34(%r14), %ebx movl 0x38(%r14), %ecx movl 0x3C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 5 */ AES_DECRYPT_ROUND movl 0x20(%r14), %eax movl 0x24(%r14), %ebx movl 0x28(%r14), %ecx movl 0x2C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 4 */ AES_DECRYPT_ROUND movl 0x10(%r14), %eax movl 0x14(%r14), %ebx movl 0x18(%r14), %ecx movl 0x1C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 3 */ AES_DECRYPT_ROUND movl 0x00(%r14), %eax movl 0x04(%r14), %ebx movl 0x08(%r14), %ecx movl 0x0C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 2 */ AES_DECRYPT_ROUND movl -0x10(%r14), %eax movl -0x0C(%r14), %ebx movl -0x08(%r14), %ecx movl -0x04(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 1 */ AES_DECRYPT_ROUND movl -0x20(%r14), %eax movl -0x1C(%r14), %ebx movl -0x18(%r14), %ecx movl -0x14(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 0, Final Round */ /* Store ibox pointer */ movq .refptr._crypto_aes_ibox(%rip), %r13 AES_DECRYPT_ROUND_FINAL xorl -0x30(%r14), %r8d xorl -0x2C(%r14), %r9d xorl -0x28(%r14), %r10d xorl -0x24(%r14), %r11d /* Store output */ movl %r8d, 0x0(%r15) movl %r9d, 0x4(%r15) movl %r10d, 0x8(%r15) movl %r11d, 0xC(%r15) addq $16, %r15 /* Increment dst pointer */ /* Decrement loop counter and check loop condition */ decq (%rsp) jnz .Ldecrypt128_loop .align 16 .Ldecrypt128_end: /* Free allocated stack space, restore clobbered registers, and return */ addq $16, %rsp /* Free allocated stack space */ popq %rbx popq %rbp popq %r12 popq %r13 popq %r14 popq %r15 ret .align 16 .globl _crypto_aes192_decrypt_x86_64 .def _crypto_aes192_decrypt_x86_64; .scl 2; .type 32; .endef /* void _aes192_decrypt_x86_64(const uint32_t* key [%rdi], */ /* uint8_t* dst [%rsi], */ /* const uint8_t* src [%rdx], */ /* size_t length [%rcx]) */ _crypto_aes192_decrypt_x86_64: /* Clobber Registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx subq $16, %rsp /* Allocate 16 bytes on stack for loop counter and src pointer */ cmpq $16, %rcx jb .Ldecrypt192_end /* skip to return if there is less than 16 bytes to process */ shrq $4, %rcx /* divide length by 16 */ movq %rsi, %r15 /* Move output pointer */ leaq 0x50(%rdi), %r14 /* Offset and store key pointer */ movq %rcx, 0(%rsp) /* store loop counter on stack */ movq %rdx, 8(%rsp) /* store src pointer on stack */ .align 16 .Ldecrypt192_loop: movq 8(%rsp), %rdx /* Load src pointer */ /* Store itable pointer */ movq .refptr._crypto_aes_itable(%rip), %r13 /* Load state */ movl 0x0(%rdx), %eax movl 0x4(%rdx), %ebx movl 0x8(%rdx), %ecx movl 0xC(%rdx), %edx addq $16, 8(%rsp) /* Offset src pointer */ /* Add last round key */ xorl 0x70(%r14), %eax xorl 0x74(%r14), %ebx xorl 0x78(%r14), %ecx xorl 0x7C(%r14), %edx /* Round 11 */ AES_DECRYPT_ROUND movl 0x60(%r14), %eax movl 0x64(%r14), %ebx movl 0x68(%r14), %ecx movl 0x6C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 10 */ AES_DECRYPT_ROUND movl 0x50(%r14), %eax movl 0x54(%r14), %ebx movl 0x58(%r14), %ecx movl 0x5C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 9 */ AES_DECRYPT_ROUND movl 0x40(%r14), %eax movl 0x44(%r14), %ebx movl 0x48(%r14), %ecx movl 0x4C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 8 */ AES_DECRYPT_ROUND movl 0x30(%r14), %eax movl 0x34(%r14), %ebx movl 0x38(%r14), %ecx movl 0x3C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 7 */ AES_DECRYPT_ROUND movl 0x20(%r14), %eax movl 0x24(%r14), %ebx movl 0x28(%r14), %ecx movl 0x2C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 6 */ AES_DECRYPT_ROUND movl 0x10(%r14), %eax movl 0x14(%r14), %ebx movl 0x18(%r14), %ecx movl 0x1C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 5 */ AES_DECRYPT_ROUND movl 0x00(%r14), %eax movl 0x04(%r14), %ebx movl 0x08(%r14), %ecx movl 0x0C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 4 */ AES_DECRYPT_ROUND movl -0x10(%r14), %eax movl -0x0C(%r14), %ebx movl -0x08(%r14), %ecx movl -0x04(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 3 */ AES_DECRYPT_ROUND movl -0x20(%r14), %eax movl -0x1C(%r14), %ebx movl -0x18(%r14), %ecx movl -0x14(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 2 */ AES_DECRYPT_ROUND movl -0x30(%r14), %eax movl -0x2C(%r14), %ebx movl -0x28(%r14), %ecx movl -0x24(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 1 */ AES_DECRYPT_ROUND movl -0x40(%r14), %eax movl -0x3C(%r14), %ebx movl -0x38(%r14), %ecx movl -0x34(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 0, Final Round */ /* Store ibox pointer */ movq .refptr._crypto_aes_ibox(%rip), %r13 AES_DECRYPT_ROUND_FINAL xorl -0x50(%r14), %r8d xorl -0x4C(%r14), %r9d xorl -0x48(%r14), %r10d xorl -0x44(%r14), %r11d /* Store output */ movl %r8d, 0x0(%r15) movl %r9d, 0x4(%r15) movl %r10d, 0x8(%r15) movl %r11d, 0xC(%r15) addq $16, %r15 /* Increment dst pointer */ /* Decrement loop counter and check loop condition */ decq (%rsp) jnz .Ldecrypt192_loop .align 16 .Ldecrypt192_end: /* Free allocated stack space, restore clobbered registers, and return */ addq $16, %rsp /* Free allocated stack space */ popq %rbx popq %rbp popq %r12 popq %r13 popq %r14 popq %r15 ret .align 16 .globl _crypto_aes256_decrypt_x86_64 .def _crypto_aes256_decrypt_x86_64; .scl 2; .type 32; .endef /* void _aes256_decrypt_x86_64(const uint32_t* key [%rdi], */ /* uint8_t* dst [%rsi], */ /* const uint8_t* src [%rdx], */ /* size_t length [%rcx]) */ _crypto_aes256_decrypt_x86_64: /* Clobber Registers */ pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbp pushq %rbx subq $16, %rsp /* Allocate 16 bytes on stack for loop counter and src pointer */ cmpq $16, %rcx jb .Ldecrypt256_end /* skip to return if there is less than 16 bytes to process */ shrq $4, %rcx /* divide length by 16 */ movq %rsi, %r15 /* Move output pointer */ leaq 0x70(%rdi), %r14 /* Offset and store key pointer */ movq %rcx, 0(%rsp) /* store loop counter on stack */ movq %rdx, 8(%rsp) /* store src pointer on stack */ .align 16 .Ldecrypt256_loop: movq 8(%rsp), %rdx /* Load src pointer */ /* Store itable pointer */ movq .refptr._crypto_aes_itable(%rip), %r13 /* Load state */ movl 0x0(%rdx), %eax movl 0x4(%rdx), %ebx movl 0x8(%rdx), %ecx movl 0xC(%rdx), %edx addq $16, 8(%rsp) /* Offset src pointer */ /* Add last round key */ xorl 0x70(%r14), %eax xorl 0x74(%r14), %ebx xorl 0x78(%r14), %ecx xorl 0x7C(%r14), %edx /* Round 13 */ AES_DECRYPT_ROUND movl 0x60(%r14), %eax movl 0x64(%r14), %ebx movl 0x68(%r14), %ecx movl 0x6C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 12 */ AES_DECRYPT_ROUND movl 0x50(%r14), %eax movl 0x54(%r14), %ebx movl 0x58(%r14), %ecx movl 0x5C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 11 */ AES_DECRYPT_ROUND movl 0x40(%r14), %eax movl 0x44(%r14), %ebx movl 0x48(%r14), %ecx movl 0x4C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 10 */ AES_DECRYPT_ROUND movl 0x30(%r14), %eax movl 0x34(%r14), %ebx movl 0x38(%r14), %ecx movl 0x3C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 9 */ AES_DECRYPT_ROUND movl 0x20(%r14), %eax movl 0x24(%r14), %ebx movl 0x28(%r14), %ecx movl 0x2C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 8 */ AES_DECRYPT_ROUND movl 0x10(%r14), %eax movl 0x14(%r14), %ebx movl 0x18(%r14), %ecx movl 0x1C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 7 */ AES_DECRYPT_ROUND movl 0x00(%r14), %eax movl 0x04(%r14), %ebx movl 0x08(%r14), %ecx movl 0x0C(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 6 */ AES_DECRYPT_ROUND movl -0x10(%r14), %eax movl -0x0C(%r14), %ebx movl -0x08(%r14), %ecx movl -0x04(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 5 */ AES_DECRYPT_ROUND movl -0x20(%r14), %eax movl -0x1C(%r14), %ebx movl -0x18(%r14), %ecx movl -0x14(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 4 */ AES_DECRYPT_ROUND movl -0x30(%r14), %eax movl -0x2C(%r14), %ebx movl -0x28(%r14), %ecx movl -0x24(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 3 */ AES_DECRYPT_ROUND movl -0x40(%r14), %eax movl -0x3C(%r14), %ebx movl -0x38(%r14), %ecx movl -0x34(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 2 */ AES_DECRYPT_ROUND movl -0x50(%r14), %eax movl -0x4C(%r14), %ebx movl -0x48(%r14), %ecx movl -0x44(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 1 */ AES_DECRYPT_ROUND movl -0x60(%r14), %eax movl -0x5C(%r14), %ebx movl -0x58(%r14), %ecx movl -0x54(%r14), %edx xorl %r8d, %eax xorl %r9d, %ebx xorl %r10d, %ecx xorl %r11d, %edx /* Round 0, Final Round */ /* Store ibox pointer */ movq .refptr._crypto_aes_ibox(%rip), %r13 AES_DECRYPT_ROUND_FINAL xorl -0x70(%r14), %r8d xorl -0x6C(%r14), %r9d xorl -0x68(%r14), %r10d xorl -0x64(%r14), %r11d /* Store output */ movl %r8d, 0x0(%r15) movl %r9d, 0x4(%r15) movl %r10d, 0x8(%r15) movl %r11d, 0xC(%r15) addq $16, %r15 /* Increment dst pointer */ /* Decrement loop counter and check loop condition */ decq (%rsp) jnz .Ldecrypt256_loop .align 16 .Ldecrypt256_end: /* Free allocated stack space, restore clobbered registers, and return */ addq $16, %rsp /* Free allocated stack space */ popq %rbx popq %rbp popq %r12 popq %r13 popq %r14 popq %r15 ret .ident "GCC: (GNU) 7.3.0" .section .rdata$.refptr._crypto_aes_sbox, "dr" .globl .refptr._crypto_aes_sbox .linkonce discard .refptr._crypto_aes_sbox: .quad _crypto_aes_sbox .section .rdata$.refptr._crypto_aes_ibox, "dr" .globl .refptr._crypto_aes_ibox .linkonce discard .refptr._crypto_aes_ibox: .quad _crypto_aes_ibox .section .rdata$.refptr._crypto_aes_dtable, "dr" .globl .refptr._crypto_aes_dtable .linkonce discard .refptr._crypto_aes_dtable: .quad _crypto_aes_dtable .section .rdata$.refptr._crypto_aes_itable, "dr" .globl .refptr._crypto_aes_itable .linkonce discard .refptr._crypto_aes_itable: .quad _crypto_aes_itable .section .rdata$.refptr._crypto_aes_mtable, "dr" .globl .refptr._crypto_aes_mtable .linkonce discard .refptr._crypto_aes_mtable: .quad _crypto_aes_mtable
; $Id: patch_beeper.asm $ ; ; Generic 1 bit sound functions ; IF !__CPU_GBZ80__ && !__CPU_INTEL__ ;SECTION code_clib SECTION smc_clib PUBLIC patch_beeper PUBLIC _patch_beeper INCLUDE "games/games.inc" ;EXTERN bit_open_di ;EXTERN bit_close_ei EXTERN __snd_tick ; ; Pattern controlled buzzer, approx. timing ; by Stefano Bodrato, Jan/2021 ; .patch_beeper ._patch_beeper push ix push bc ; bit pattern pop ix push ix IF sndbit_port >= 256 exx ld bc,sndbit_port exx ENDIF ld a,l srl l srl l cpl and 3 ld c,a ld b,0 ;ld ix,beixp3 ;add ix,bc ;call bit_open_di ;ld a,(__snd_tick) .beixp3 ;nop ;nop ;nop inc b inc c .behllp dec c jr nz,behllp ld c,$3F dec b jp nz,behllp ld a,e and 7 jr nz,no_pattern_loop inc ix ld a,(ix+0) and a jr nz,no_pattern_loop pop ix ; back to the beginning of bit pattern push ix ; 14T ; jr compensate .no_pattern_loop ; push ix ; 14T ; pop ix ; back to the beginning of bit pattern ;.compensate rlc (ix+0) sbc a,a ; 0 or FF and sndbit_mask ld c,a ld a,(__snd_tick) xor c IF sndbit_port >= 256 exx out (c),a ;9 T slower exx ELSE out (sndbit_port),a ENDIF ld b,h ld c,a ;bit sndbit_bit,a ;if o/p go again! ;jr nz,be_again ld a,d or e jr z,be_end ld a,c ld c,l dec de ;jp (ix) jp beixp3 ;.be_again ; ld c,l ; inc c ; jp (ix) .be_end pop ix pop ix ;call bit_close_ei ret ENDIF
#pragma warning(push, 3) #include <lua.hpp> #include <luabind/luabind.hpp> #include <base/lua/luabind.h> #pragma warning(pop) #include <slk/ObjectManager.hpp> #include <slk/table/SlkTable.hpp> #include <slk/table/IniTable.hpp> #include <slk/reader/SlkReader.hpp> #include <slk/reader/TxtReader.hpp> #include <slk/reader/IniReader.hpp> #include "InterfaceStormLib.h" namespace NLua { namespace TableWrap { template <class TTable> struct Iterator { Iterator(TTable &table) : cur_(table.begin()) , end_(table.end()) { } bool valid() const { return !(cur_ == end_); } typename TTable::iterator cur_; typename TTable::iterator end_; }; template <class TTable> Iterator<TTable> begin(TTable &table) { return Iterator<TTable>(table); } } namespace SlkObjectWrap { void next(lua_State* pState, TableWrap::Iterator<slk::SlkSingle>& it) { luabind::object(pState, it.cur_->first).push(pState); luabind::object(pState, it.cur_->second.to_string()).push(pState); ++it.cur_; } void get(lua_State* pState, slk::SlkSingle const &table, std::string const &key) { auto const& It = table.find(key); if (It == table.end()) { lua_pushnil(pState); } else { luabind::object(pState, It->second.to_string()).push(pState); } } void set(slk::SlkSingle &table, std::string const &key, std::string const &val) { table[key] = slk::SlkValue(val); } } namespace SlkTableWrap { void next(lua_State* pState, TableWrap::Iterator<slk::SlkTable>& it) { luabind::object(pState, it.cur_->first.to_string()).push(pState); luabind::object(pState, it.cur_->second).push(pState); ++it.cur_; } void get(lua_State* pState, slk::SlkTable const &table, std::string const &key) { auto const& It = table.find(key); if (It == table.end()) { lua_pushnil(pState); } else { luabind::object(pState, It->second).push(pState); } } void set(slk::SlkTable &table, std::string const &key, slk::SlkSingle const &val) { table[key] = val; } } namespace IniObjectWrap { void next(lua_State* pState, TableWrap::Iterator<slk::IniSingle>& it) { luabind::object(pState, it.cur_->first).push(pState); luabind::object(pState, it.cur_->second).push(pState); ++it.cur_; } void get(lua_State* pState, slk::IniSingle const &table, std::string const &key) { auto const& It = table.find(key); if (It == table.end()) { lua_pushnil(pState); } else { luabind::object(pState, It->second).push(pState); } } void set(slk::IniSingle &table, std::string const &key, std::string const &val) { table[key] = val; } } namespace IniTableWrap { void next(lua_State* pState, TableWrap::Iterator<slk::IniTable>& it) { luabind::object(pState, it.cur_->first).push(pState); luabind::object(pState, it.cur_->second).push(pState); ++it.cur_; } void get(lua_State* pState, slk::IniTable const &table, std::string const &key) { auto const& It = table.find(key); if (It == table.end()) { lua_pushnil(pState); } else { luabind::object(pState, It->second).push(pState); } } void set(slk::IniTable &table, std::string const &key, slk::IniSingle const &val) { table[key] = val; } } struct InterfaceStormWrap : slk::InterfaceStorm, luabind::wrap_base { bool has(std::string const& path) { return luabind::call_member<bool>(this, "has", path); } std::string load(std::string const& path, error_code& ec) { std::string ret = luabind::call_member<std::string>(this, "load", path); if (ret.empty()) { ec = ERROR_FILE_NOT_FOUND; } return std::move(ret); } }; } // namespace NLua int luaopen_mapanalyzer(lua_State *pState) { using namespace luabind; module(pState, "mapanalyzer") [ class_<slk::InterfaceStorm, NLua::InterfaceStormWrap>("interface_storm") .def(constructor<>()) .def("has", &slk::InterfaceStorm::has) .def("load", &slk::InterfaceStorm::load) , class_<slk::ROBJECT_TYPE::ENUM>("OBJECT_TYPE") .enum_("constants") [ value("UNIT", slk::ROBJECT_TYPE::UNIT), value("ITEM", slk::ROBJECT_TYPE::ITEM), value("DESTRUCTABLE", slk::ROBJECT_TYPE::DESTRUCTABLE), value("BUFF", slk::ROBJECT_TYPE::BUFF), value("DOODAD", slk::ROBJECT_TYPE::DOODAD), value("ABILITY", slk::ROBJECT_TYPE::ABILITY), value("UPGRADE", slk::ROBJECT_TYPE::UPGRADE) ] , class_<NLua::TableWrap::Iterator<slk::SlkSingle>>("slk_object_iterator") .def(constructor<slk::SlkSingle &>()) .def("valid", &NLua::TableWrap::Iterator<slk::SlkSingle>::valid) .def("next", &NLua::SlkObjectWrap::next) , class_<slk::SlkSingle>("slk_object") .def(constructor<>()) .def("get", &NLua::SlkObjectWrap::get) .def("set", &NLua::SlkObjectWrap::set) .def("begin", &NLua::TableWrap::begin<slk::SlkSingle>) , class_<NLua::TableWrap::Iterator<slk::SlkTable>>("slk_table_iterator") .def(constructor<slk::SlkTable &>()) .def("valid", &NLua::TableWrap::Iterator<slk::SlkTable>::valid) .def("next", &NLua::SlkTableWrap::next) , class_<slk::SlkTable>("slk_table") .def(constructor<>()) .def("get", &NLua::SlkTableWrap::get) .def("set", &NLua::SlkTableWrap::set) .def("begin", &NLua::TableWrap::begin<slk::SlkTable>) , class_<NLua::TableWrap::Iterator<slk::IniSingle>>("ini_object_iterator") .def(constructor<slk::IniSingle &>()) .def("valid", &NLua::TableWrap::Iterator<slk::IniSingle>::valid) .def("next", &NLua::IniObjectWrap::next) , class_<slk::IniSingle>("ini_object") .def(constructor<>()) .def("get", &NLua::IniObjectWrap::get) .def("set", &NLua::IniObjectWrap::set) .def("begin", &NLua::TableWrap::begin<slk::IniSingle>) , class_<NLua::TableWrap::Iterator<slk::IniTable>>("ini_table_iterator") .def(constructor<slk::IniTable &>()) .def("valid", &NLua::TableWrap::Iterator<slk::IniTable>::valid) .def("next", &NLua::IniTableWrap::next) , class_<slk::IniTable>("ini_table") .def(constructor<>()) .def("get", &NLua::IniTableWrap::get) .def("set", &NLua::IniTableWrap::set) .def("begin", &NLua::TableWrap::begin<slk::IniTable>) , class_<slk::ObjectManager>("manager2") .def(constructor<slk::InterfaceStorm&>()) .def("load", &slk::ObjectManager::load_singleton<slk::ROBJECT_TYPE::ENUM, slk::SlkTable>) .def("load_file", &slk::ObjectManager::load<slk::IniTable>) .def("convert", &slk::ObjectManager::convert_string) ]; return 0; }
; A066375: a(n) = 6*binomial(n,4) + 3*binomial(n,3) + 4*binomial(n,2) - n + 2. ; 1,4,14,40,97,206,394,694,1145,1792,2686,3884,5449,7450,9962,13066,16849,21404,26830,33232,40721,49414,59434,70910,83977,98776,115454,134164,155065,178322,204106,232594,263969,298420,336142,377336,422209,470974,523850,581062,642841,709424,781054,857980,940457,1028746,1123114,1223834,1331185,1445452,1566926,1695904,1832689,1977590,2130922,2293006,2464169,2644744,2835070,3035492,3246361,3468034,3700874,3945250,4201537,4470116,4751374,5045704,5353505,5675182,6011146,6361814,6727609,7108960,7506302,7920076,8350729,8798714,9264490,9748522,10251281,10773244,11314894,11876720,12459217,13062886,13688234,14335774,15006025,15699512,16416766,17158324,17924729,18716530,19534282,20378546,21249889,22148884,23076110,24032152,25017601,26033054,27079114,28156390,29265497,30407056,31581694,32790044,34032745,35310442,36623786,37973434,39360049,40784300,42246862,43748416,45289649,46871254,48493930,50158382,51865321,53615464,55409534,57248260,59132377,61062626,63039754,65064514,67137665,69259972,71432206,73655144,75929569,78256270,80636042,83069686,85558009,88101824,90701950,93359212,96074441,98848474,101682154,104576330,107531857,110549596,113630414,116775184,119984785,123260102,126602026,130011454,133489289,137036440,140653822,144342356,148102969,151936594,155844170,159826642,163884961,168020084,172232974,176524600,180895937,185347966,189881674,194498054,199198105,203982832,208853246,213810364,218855209,223988810,229212202,234526426,239932529,245431564,251024590,256712672,262496881,268378294,274357994,280437070,286616617,292897736,299281534,305769124,312361625,319060162,325865866,332779874,339803329,346937380,354183182,361541896,369014689,376602734,384307210,392129302,400070201,408131104,416313214,424617740,433045897,441598906,450277994,459084394,468019345,477084092,486279886,495607984,505069649,514666150,524398762,534268766,544277449,554426104,564716030,575148532,585724921,596446514,607314634,618330610,629495777,640811476,652279054,663899864,675675265,687606622,699695306,711942694,724350169,736919120,749650942,762547036,775608809,788837674,802235050,815802362,829541041,843452524,857538254,871799680,886238257,900855446,915652714,930631534,945793385,961139752 mul $0,2 mov $1,2 lpb $0 sub $0,1 add $2,$1 add $1,$0 sub $0,1 add $3,$2 lpe add $0,3 add $1,$0 sub $1,1 add $1,$3 sub $1,3
// Copyright (c) 2021 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <map> #include <string> #include "gtest/gtest.h" #include "../../include/conf.hpp" #include "../../include/common.hpp" #include "../../include/operators/strided_slice.hpp" using executor::Tensor; using executor::OperatorConfig; using executor::TensorConfig; using executor::AttrConfig; using executor::MemoryAllocator; struct OpArgs { std::vector<Tensor*> input; std::vector<Tensor*> output; OperatorConfig conf; }; struct TestParams { std::pair<OpArgs, OpArgs> args; bool expect_to_fail; }; bool CheckResult(const TestParams& t) { const auto& p = t.args.first; const auto& q = t.args.second; executor::StridedSliceOperator strided_slice_op(p.conf); strided_slice_op.Reshape(p.input, p.output); strided_slice_op.Forward(p.input, p.output); // Should compare buffer with different addresses EXPECT_NE(p.output[0]->data(), q.output[0]->data()); return executor::CompareData<float>(p.output[0]->data(), p.output[0]->size(), q.output[0]->data(), q.output[0]->size()); } class StridedSliceOpTest : public testing::TestWithParam<TestParams> { protected: StridedSliceOpTest() {} ~StridedSliceOpTest() {} void SetUp() override {} void TearDown() override {} }; TEST_P(StridedSliceOpTest, TestPostfix) { TestParams t = testing::TestWithParam<TestParams>::GetParam(); EXPECT_TRUE(CheckResult(t)); } std::pair<OpArgs, OpArgs> GenerateFp32Case(const std::vector<std::vector<int64_t> >& input_shape, std::string append_op = "") { // Step 1: Construct Tensor config ptr const auto& src_shape = input_shape[0]; TensorConfig* src_config = new TensorConfig("src", src_shape); std::vector<TensorConfig*> input_config_vec = {src_config}; std::vector<int64_t> dst_shape = {src_shape[0], 1, src_shape[2]}; TensorConfig* dst_config = new TensorConfig("dst", dst_shape); std::vector<TensorConfig*> output_config_vec = {dst_config}; // Step 1.1: Construct Operator config obj std::map<std::string, std::string> attr_map; attr_map["begin_mask"] = "5"; attr_map["ellipsis_mask"] = "0"; attr_map["end_mask"] = "5"; attr_map["new_axis_mask"] = "0"; attr_map["shrink_axis_mask"] = "0"; attr_map["begin"] = "0,0,0"; attr_map["end"] = "0,1,0"; attr_map["strides"] = "1,1,1"; AttrConfig* op_attr = new AttrConfig(attr_map); OperatorConfig op_config = OperatorConfig("strided_slice", "fp32", input_config_vec, output_config_vec, op_attr); // Step 2: Construct Tensor ptr auto make_tensor_obj = [&](const TensorConfig* a_tensor_config, int life_num = 1) { // step1: set shape Tensor* a_tensor = new Tensor(*a_tensor_config); // step2: set tensor life a_tensor->add_tensor_life(life_num); // step3: library buffer can only be obtained afterwards auto tensor_data = a_tensor->mutable_data(); executor::InitVector(static_cast<float*>(tensor_data), a_tensor->size()); Tensor* a_tensor_copy = new Tensor(*a_tensor_config); a_tensor_copy->add_tensor_life(life_num); auto tensor_data_copy = a_tensor_copy->mutable_data(); memcpy(tensor_data_copy, tensor_data, a_tensor_copy->size() * sizeof(float)); return std::pair<Tensor*, Tensor*>{a_tensor, a_tensor_copy}; }; auto src_tensors = make_tensor_obj(src_config, 2); Tensor* dst_tensor = new Tensor(*dst_config); dst_tensor->add_tensor_life(1); Tensor* dst_tensor_copy = new Tensor(*dst_config); dst_tensor_copy->add_tensor_life(1); auto dst_data_copy = static_cast<float*>(dst_tensor_copy->mutable_data()); auto src_data_copy = static_cast<const float*>(src_tensors.second->data()); for (int i = 0; i < dst_shape[0]; ++i) { #pragma omp parallel for for (int j = 0; j < dst_shape[1]; ++j) { #pragma omp simd for (int k = 0; k < dst_shape[2]; ++k) { dst_data_copy[i * dst_shape[1] * dst_shape[2] + j * dst_shape[2] + k] = src_data_copy[i * src_shape[1] * src_shape[2] + j * src_shape[2] + k]; } } } OpArgs op_args = {{src_tensors.first}, {dst_tensor}, op_config}; OpArgs op_args_copy = {{src_tensors.second}, {dst_tensor_copy}, op_config}; return {op_args, op_args_copy}; } static auto CasesFp32 = []() { std::string memory_strategy = getenv("DIRECT_BUFFER") == NULL ? "cycle_buffer" : "direct_buffer"; MemoryAllocator::SetStrategy(memory_strategy); std::vector<TestParams> cases; // Config std::vector<int64_t> src_shape; // case: simple src_shape = {64, 128, 768}; // dst = (64, 1, 768) cases.push_back({GenerateFp32Case({src_shape}), false}); return ::testing::ValuesIn(cases); }; INSTANTIATE_TEST_SUITE_P(Prefix, StridedSliceOpTest, CasesFp32());
; THIS IS AN AUTOGENERATED FILE ; WARNING: FOR MACOS ONLY ; nasm -f macho64 prc4.asm -o prc4.o && ld -o prc4.macho -macosx_version_min 10.7 -e start prc4.o && ./prc4.macho BITS 64 section .text global start start: push rbp mov rbp, rsp ; PRINT OUTPUT push 0xa203a mov DWORD [rsp+0x4],0x0 push 0x76207965 mov DWORD [rsp+0x4],0x65756c61 push 0x7475706e mov DWORD [rsp+0x4],0x6b206120 push 0x61656c50 mov DWORD [rsp+0x4],0x69206573 mov rax,0x2000004 mov rdi,0x1 mov rsi,rsp mov edx,0x1b syscall pop rax pop rax pop rax pop rax ; GET INPUT mov rax, 0x2000003 mov rdi, 0 lea rsi, [rel key] mov edx, 0x10 syscall ; CHECK 4 BYTES OF KEY mov rdx, QWORD [rel key] shr rdx, 32 cmp edx, 0x36395477 jne fail ; GENERATE SBOX lea rcx, [rel key] ; key: rcx mov rdx, strict qword 8 ; L: rdx lea r8, [rel sbox] ; sbox: r8 call rc4init lea rcx, [rel encrypted] ; bufin mov rdx, strict qword 48 ; len lea r8, [rel encrypted] ; bufout lea r9, [rel sbox] ; sbox call rc4run mov eax, 0x2000004 ; write mov rdi, 1 ; std out lea rsi, [rel encrypted] add rsi, 8 mov edx, 40 syscall mov rax, qword [rel encrypted] xor rbx, rbx xor rcx, rcx xor rdx, rdx xor rdi, rdi pop rbp ret ; PRINT FAIL WHALE fail: mov eax, 0x2000004 ; write mov rdi, 1 ; std out lea rsi, [rel msg2] mov edx, 230 syscall xor eax, eax mov rax, 0x2000001 ; exit mov rdi, 0 syscall rc4init: push rbp mov rbp, rsp xor rax, rax mov r11, 0x20 mov r9, 0x808080808080808 mov r10, 0x706050403020100 loop1_s: cmp rax,r11 je loop1_e mov QWORD [r8+rax*8], r10 add r10, r9 inc rax jmp loop1_s loop1_e: xor rax,rax xor r9,r9 xor r10,r10 loop2_s: movzx r11, BYTE [r8+rax*1] add r9, r11 movq xmm0,r11 movzx r11,BYTE [rcx+r10*1] add r9, r11 xor r11, r11 mov r11b, r9b xchg r9, r11 movzx r11, BYTE [r8+r9*1] mov BYTE [r8+rax*1], r11b movq r11, xmm0 mov BYTE [r8+r9*1], r11b inc r10 xor r11, r11 cmp rdx, r10 cmove r10, r11 inc rax test al, al jne loop2_s pop rbp ret rc4run: push rbp mov rbp, rsp xor rax, rax xor r10, r10 movq xmm0, r10 movq xmm1, r10 rc4run_loop1_s: cmp rdx, rax je rc4run_loop1_e movq r10, xmm0 inc r10 xor r11, r11 mov r11b, r10b movq xmm0, r11 movzx r10, BYTE [r9+r11*1] movq r11, xmm1 movq xmm2, r10 add r10, r11 xor r11, r11 mov r11b, r10b movq xmm1, r11 movzx r10, BYTE [r9+r11*1] movq xmm3, r10 movq r11, xmm0 mov BYTE [r9+r11*1], r10b movq r11, xmm1 movq r10, xmm2 mov BYTE [r9+r11*1], r10b movq r11, xmm3 add r10, r11 xor r11, r11 mov r11b, r10b movzx r10, BYTE [r9+r11*1] movzx r11, BYTE [rcx+rax*1] xor r10, r11 mov BYTE [r8+rax*1],r10b inc rax jmp rc4run_loop1_s rc4run_loop1_e: pop rbp ret section .data encrypted: db 0x42 db 0x86 db 0xD2 db 0xBF db 0xA5 db 0x19 db 0xB8 db 0xB6 db 0xBD db 0x90 db 0xE9 db 0x68 db 0xD0 db 0x69 db 0x37 db 0x29 db 0xF8 db 0x12 db 0xF4 db 0xE5 db 0xD0 db 0xFB db 0xF3 db 0x7E db 0x72 db 0x61 db 0x79 db 0x19 db 0xED db 0x44 db 0x12 db 0x52 db 0xF5 db 0xF9 db 0xAA db 0x14 db 0x36 db 0x0D db 0x1F db 0xB2 db 0x52 db 0x6B db 0xF2 db 0x6A db 0xDA db 0x9D db 0xEC db 0x3C key: times 0x10 db 0 sbox: times 0x100 db 0 msg2: db 32,32,32,32,32,70,65,73,76,32,87,72,65,76,69,33,10,10,87,32,32,32,32,32,87,32,32,32,32,32,32,87,32,32,32,32,32,32,32,32,10,87,32,32,32,32,32,32,32,32,87,32,32,87,32,32,32,32,32,87,32,32,32,32,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,39,46,32,32,87,32,32,32,32,32,32,10,32,32,46,45,34,34,45,46,95,32,32,32,32,32,92,32,92,46,45,45,124,32,32,10,32,47,32,32,32,32,32,32,32,34,45,46,46,95,95,41,32,46,45,39,32,32,32,10,124,32,32,32,32,32,95,32,32,32,32,32,32,32,32,32,47,32,32,32,32,32,32,10,92,39,45,46,95,95,44,32,32,32,46,95,95,46,44,39,32,32,32,32,32,32,32,10,32,96,39,45,45,45,45,39,46,95,92,45,45,39,32,32,32,32,32,32,10,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86, 10
//===--- SemanticHighlighting.cpp - ------------------------- ---*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "SemanticHighlighting.h" #include "FindTarget.h" #include "ParsedAST.h" #include "Protocol.h" #include "SourceCode.h" #include "support/Logger.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/Type.h" #include "clang/AST/TypeLoc.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "clang/Tooling/Syntax/Tokens.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Base64.h" #include "llvm/Support/Casting.h" #include <algorithm> namespace clang { namespace clangd { namespace { /// Some names are not written in the source code and cannot be highlighted, /// e.g. anonymous classes. This function detects those cases. bool canHighlightName(DeclarationName Name) { switch (Name.getNameKind()) { case DeclarationName::Identifier: { auto *II = Name.getAsIdentifierInfo(); return II && !II->getName().empty(); } case DeclarationName::CXXConstructorName: case DeclarationName::CXXDestructorName: return true; case DeclarationName::ObjCZeroArgSelector: case DeclarationName::ObjCOneArgSelector: case DeclarationName::ObjCMultiArgSelector: // Multi-arg selectors need special handling, and we handle 0/1 arg // selectors there too. return false; case DeclarationName::CXXConversionFunctionName: case DeclarationName::CXXOperatorName: case DeclarationName::CXXDeductionGuideName: case DeclarationName::CXXLiteralOperatorName: case DeclarationName::CXXUsingDirective: return false; } llvm_unreachable("invalid name kind"); } llvm::Optional<HighlightingKind> kindForType(const Type *TP, const HeuristicResolver *Resolver); llvm::Optional<HighlightingKind> kindForDecl(const NamedDecl *D, const HeuristicResolver *Resolver) { if (auto *USD = dyn_cast<UsingShadowDecl>(D)) { if (auto *Target = USD->getTargetDecl()) D = Target; } if (auto *TD = dyn_cast<TemplateDecl>(D)) { if (auto *Templated = TD->getTemplatedDecl()) D = Templated; } if (auto *TD = dyn_cast<TypedefNameDecl>(D)) { // We try to highlight typedefs as their underlying type. if (auto K = kindForType(TD->getUnderlyingType().getTypePtrOrNull(), Resolver)) return K; // And fallback to a generic kind if this fails. return HighlightingKind::Typedef; } // We highlight class decls, constructor decls and destructor decls as // `Class` type. The destructor decls are handled in `VisitTagTypeLoc` (we // will visit a TypeLoc where the underlying Type is a CXXRecordDecl). if (auto *RD = llvm::dyn_cast<RecordDecl>(D)) { // We don't want to highlight lambdas like classes. if (RD->isLambda()) return llvm::None; return HighlightingKind::Class; } if (isa<ClassTemplateDecl, RecordDecl, CXXConstructorDecl, ObjCInterfaceDecl, ObjCImplementationDecl>(D)) return HighlightingKind::Class; if (isa<ObjCProtocolDecl>(D)) return HighlightingKind::Interface; if (isa<ObjCCategoryDecl>(D)) return HighlightingKind::Namespace; if (auto *MD = dyn_cast<CXXMethodDecl>(D)) return MD->isStatic() ? HighlightingKind::StaticMethod : HighlightingKind::Method; if (auto *OMD = dyn_cast<ObjCMethodDecl>(D)) return OMD->isClassMethod() ? HighlightingKind::StaticMethod : HighlightingKind::Method; if (isa<FieldDecl, ObjCPropertyDecl>(D)) return HighlightingKind::Field; if (isa<EnumDecl>(D)) return HighlightingKind::Enum; if (isa<EnumConstantDecl>(D)) return HighlightingKind::EnumConstant; if (isa<ParmVarDecl>(D)) return HighlightingKind::Parameter; if (auto *VD = dyn_cast<VarDecl>(D)) { if (isa<ImplicitParamDecl>(VD)) // e.g. ObjC Self return llvm::None; return VD->isStaticDataMember() ? HighlightingKind::StaticField : VD->isLocalVarDecl() ? HighlightingKind::LocalVariable : HighlightingKind::Variable; } if (const auto *BD = dyn_cast<BindingDecl>(D)) return BD->getDeclContext()->isFunctionOrMethod() ? HighlightingKind::LocalVariable : HighlightingKind::Variable; if (isa<FunctionDecl>(D)) return HighlightingKind::Function; if (isa<NamespaceDecl>(D) || isa<NamespaceAliasDecl>(D) || isa<UsingDirectiveDecl>(D)) return HighlightingKind::Namespace; if (isa<TemplateTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) || isa<NonTypeTemplateParmDecl>(D)) return HighlightingKind::TemplateParameter; if (isa<ConceptDecl>(D)) return HighlightingKind::Concept; if (const auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(D)) { auto Targets = Resolver->resolveUsingValueDecl(UUVD); if (!Targets.empty()) { return kindForDecl(Targets[0], Resolver); } return HighlightingKind::Unknown; } return llvm::None; } llvm::Optional<HighlightingKind> kindForType(const Type *TP, const HeuristicResolver *Resolver) { if (!TP) return llvm::None; if (TP->isBuiltinType()) // Builtins are special, they do not have decls. return HighlightingKind::Primitive; if (auto *TD = dyn_cast<TemplateTypeParmType>(TP)) return kindForDecl(TD->getDecl(), Resolver); if (isa<ObjCObjectPointerType>(TP)) return HighlightingKind::Class; if (auto *TD = TP->getAsTagDecl()) return kindForDecl(TD, Resolver); return llvm::None; } // Whether T is const in a loose sense - is a variable with this type readonly? bool isConst(QualType T) { if (T.isNull() || T->isDependentType()) return false; T = T.getNonReferenceType(); if (T.isConstQualified()) return true; if (const auto *AT = T->getAsArrayTypeUnsafe()) return isConst(AT->getElementType()); if (isConst(T->getPointeeType())) return true; return false; } // Whether D is const in a loose sense (should it be highlighted as such?) // FIXME: This is separate from whether *a particular usage* can mutate D. // We may want V in V.size() to be readonly even if V is mutable. bool isConst(const Decl *D) { if (llvm::isa<EnumConstantDecl>(D) || llvm::isa<NonTypeTemplateParmDecl>(D)) return true; if (llvm::isa<FieldDecl>(D) || llvm::isa<VarDecl>(D) || llvm::isa<MSPropertyDecl>(D) || llvm::isa<BindingDecl>(D)) { if (isConst(llvm::cast<ValueDecl>(D)->getType())) return true; } if (const auto *OCPD = llvm::dyn_cast<ObjCPropertyDecl>(D)) { if (OCPD->isReadOnly()) return true; } if (const auto *MPD = llvm::dyn_cast<MSPropertyDecl>(D)) { if (!MPD->hasSetter()) return true; } if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D)) { if (CMD->isConst()) return true; } return false; } // "Static" means many things in C++, only some get the "static" modifier. // // Meanings that do: // - Members associated with the class rather than the instance. // This is what 'static' most often means across languages. // - static local variables // These are similarly "detached from their context" by the static keyword. // In practice, these are rarely used inside classes, reducing confusion. // // Meanings that don't: // - Namespace-scoped variables, which have static storage class. // This is implicit, so the keyword "static" isn't so strongly associated. // If we want a modifier for these, "global scope" is probably the concept. // - Namespace-scoped variables/functions explicitly marked "static". // There the keyword changes *linkage* , which is a totally different concept. // If we want to model this, "file scope" would be a nice modifier. // // This is confusing, and maybe we should use another name, but because "static" // is a standard LSP modifier, having one with that name has advantages. bool isStatic(const Decl *D) { if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D)) return CMD->isStatic(); if (const VarDecl *VD = llvm::dyn_cast<VarDecl>(D)) return VD->isStaticDataMember() || VD->isStaticLocal(); if (const auto *OPD = llvm::dyn_cast<ObjCPropertyDecl>(D)) return OPD->isClassProperty(); if (const auto *OMD = llvm::dyn_cast<ObjCMethodDecl>(D)) return OMD->isClassMethod(); return false; } bool isAbstract(const Decl *D) { if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D)) return CMD->isPure(); if (const auto *CRD = llvm::dyn_cast<CXXRecordDecl>(D)) return CRD->hasDefinition() && CRD->isAbstract(); return false; } bool isDependent(const Decl *D) { if (isa<UnresolvedUsingValueDecl>(D)) return true; return false; } // For a macro usage `DUMP(foo)`, we want: // - DUMP --> "macro" // - foo --> "variable". SourceLocation getHighlightableSpellingToken(SourceLocation L, const SourceManager &SM) { if (L.isFileID()) return SM.isWrittenInMainFile(L) ? L : SourceLocation{}; // Tokens expanded from the macro body contribute no highlightings. if (!SM.isMacroArgExpansion(L)) return {}; // Tokens expanded from macro args are potentially highlightable. return getHighlightableSpellingToken(SM.getImmediateSpellingLoc(L), SM); } unsigned evaluateHighlightPriority(const HighlightingToken &Tok) { enum HighlightPriority { Dependent = 0, Resolved = 1 }; return (Tok.Modifiers & (1 << uint32_t(HighlightingModifier::DependentName))) ? Dependent : Resolved; } // Sometimes we get multiple tokens at the same location: // // - findExplicitReferences() returns a heuristic result for a dependent name // (e.g. Method) and CollectExtraHighlighting returning a fallback dependent // highlighting (e.g. Unknown+Dependent). // - macro arguments are expanded multiple times and have different roles // - broken code recovery produces several AST nodes at the same location // // We should either resolve these to a single token, or drop them all. // Our heuristics are: // // - token kinds that come with "dependent-name" modifiers are less reliable // (these tend to be vague, like Type or Unknown) // - if we have multiple equally reliable kinds, drop token rather than guess // - take the union of modifiers from all tokens // // In particular, heuristically resolved dependent names get their heuristic // kind, plus the dependent modifier. llvm::Optional<HighlightingToken> resolveConflict(ArrayRef<HighlightingToken> Tokens) { if (Tokens.size() == 1) return Tokens[0]; if (Tokens.size() != 2) return llvm::None; unsigned Priority1 = evaluateHighlightPriority(Tokens[0]); unsigned Priority2 = evaluateHighlightPriority(Tokens[1]); if (Priority1 == Priority2 && Tokens[0].Kind != Tokens[1].Kind) return llvm::None; auto Result = Priority1 > Priority2 ? Tokens[0] : Tokens[1]; Result.Modifiers = Tokens[0].Modifiers | Tokens[1].Modifiers; return Result; } /// Consumes source locations and maps them to text ranges for highlightings. class HighlightingsBuilder { public: HighlightingsBuilder(const ParsedAST &AST) : TB(AST.getTokens()), SourceMgr(AST.getSourceManager()), LangOpts(AST.getLangOpts()) {} HighlightingToken &addToken(SourceLocation Loc, HighlightingKind Kind) { Loc = getHighlightableSpellingToken(Loc, SourceMgr); if (Loc.isInvalid()) return InvalidHighlightingToken; const auto *Tok = TB.spelledTokenAt(Loc); assert(Tok); return addToken( halfOpenToRange(SourceMgr, Tok->range(SourceMgr).toCharRange(SourceMgr)), Kind); } HighlightingToken &addToken(Range R, HighlightingKind Kind) { HighlightingToken HT; HT.R = std::move(R); HT.Kind = Kind; Tokens.push_back(std::move(HT)); return Tokens.back(); } std::vector<HighlightingToken> collect(ParsedAST &AST) && { // Initializer lists can give duplicates of tokens, therefore all tokens // must be deduplicated. llvm::sort(Tokens); auto Last = std::unique(Tokens.begin(), Tokens.end()); Tokens.erase(Last, Tokens.end()); // Macros can give tokens that have the same source range but conflicting // kinds. In this case all tokens sharing this source range should be // removed. std::vector<HighlightingToken> NonConflicting; NonConflicting.reserve(Tokens.size()); for (ArrayRef<HighlightingToken> TokRef = Tokens; !TokRef.empty();) { ArrayRef<HighlightingToken> Conflicting = TokRef.take_while([&](const HighlightingToken &T) { // TokRef is guaranteed at least one element here because otherwise // this predicate would never fire. return T.R == TokRef.front().R; }); if (auto Resolved = resolveConflict(Conflicting)) NonConflicting.push_back(*Resolved); // TokRef[Conflicting.size()] is the next token with a different range (or // the end of the Tokens). TokRef = TokRef.drop_front(Conflicting.size()); } const auto &SM = AST.getSourceManager(); StringRef MainCode = SM.getBufferOrFake(SM.getMainFileID()).getBuffer(); // Merge token stream with "inactive line" markers. std::vector<HighlightingToken> WithInactiveLines; auto SortedSkippedRanges = AST.getMacros().SkippedRanges; llvm::sort(SortedSkippedRanges); auto It = NonConflicting.begin(); for (const Range &R : SortedSkippedRanges) { // Create one token for each line in the skipped range, so it works // with line-based diffing. assert(R.start.line <= R.end.line); for (int Line = R.start.line; Line <= R.end.line; ++Line) { // If the end of the inactive range is at the beginning // of a line, that line is not inactive. if (Line == R.end.line && R.end.character == 0) continue; // Copy tokens before the inactive line for (; It != NonConflicting.end() && It->R.start.line < Line; ++It) WithInactiveLines.push_back(std::move(*It)); // Add a token for the inactive line itself. auto StartOfLine = positionToOffset(MainCode, Position{Line, 0}); if (StartOfLine) { StringRef LineText = MainCode.drop_front(*StartOfLine).take_until([](char C) { return C == '\n'; }); HighlightingToken HT; WithInactiveLines.emplace_back(); WithInactiveLines.back().Kind = HighlightingKind::InactiveCode; WithInactiveLines.back().R.start.line = Line; WithInactiveLines.back().R.end.line = Line; WithInactiveLines.back().R.end.character = static_cast<int>(lspLength(LineText)); } else { elog("Failed to convert position to offset: {0}", StartOfLine.takeError()); } // Skip any other tokens on the inactive line. e.g. // `#ifndef Foo` is considered as part of an inactive region when Foo is // defined, and there is a Foo macro token. // FIXME: we should reduce the scope of the inactive region to not // include the directive itself. while (It != NonConflicting.end() && It->R.start.line == Line) ++It; } } // Copy tokens after the last inactive line for (; It != NonConflicting.end(); ++It) WithInactiveLines.push_back(std::move(*It)); return WithInactiveLines; } const HeuristicResolver *getResolver() const { return Resolver; } private: const syntax::TokenBuffer &TB; const SourceManager &SourceMgr; const LangOptions &LangOpts; std::vector<HighlightingToken> Tokens; const HeuristicResolver *Resolver; // returned from addToken(InvalidLoc) HighlightingToken InvalidHighlightingToken; }; llvm::Optional<HighlightingModifier> scopeModifier(const NamedDecl *D) { const DeclContext *DC = D->getDeclContext(); // Injected "Foo" within the class "Foo" has file scope, not class scope. if (auto *R = dyn_cast_or_null<RecordDecl>(D)) if (R->isInjectedClassName()) DC = DC->getParent(); // Lambda captures are considered function scope, not class scope. if (llvm::isa<FieldDecl>(D)) if (const auto *RD = llvm::dyn_cast<RecordDecl>(DC)) if (RD->isLambda()) return HighlightingModifier::FunctionScope; // Walk up the DeclContext hierarchy until we find something interesting. for (; !DC->isFileContext(); DC = DC->getParent()) { if (DC->isFunctionOrMethod()) return HighlightingModifier::FunctionScope; if (DC->isRecord()) return HighlightingModifier::ClassScope; } // Some template parameters (e.g. those for variable templates) don't have // meaningful DeclContexts. That doesn't mean they're global! if (DC->isTranslationUnit() && D->isTemplateParameter()) return llvm::None; // ExternalLinkage threshold could be tweaked, e.g. module-visible as global. if (D->getLinkageInternal() < ExternalLinkage) return HighlightingModifier::FileScope; return HighlightingModifier::GlobalScope; } llvm::Optional<HighlightingModifier> scopeModifier(const Type *T) { if (!T) return llvm::None; if (T->isBuiltinType()) return HighlightingModifier::GlobalScope; if (auto *TD = dyn_cast<TemplateTypeParmType>(T)) return scopeModifier(TD->getDecl()); if (auto *TD = T->getAsTagDecl()) return scopeModifier(TD); return llvm::None; } /// Produces highlightings, which are not captured by findExplicitReferences, /// e.g. highlights dependent names and 'auto' as the underlying type. class CollectExtraHighlightings : public RecursiveASTVisitor<CollectExtraHighlightings> { public: CollectExtraHighlightings(HighlightingsBuilder &H) : H(H) {} bool VisitDecltypeTypeLoc(DecltypeTypeLoc L) { if (auto K = kindForType(L.getTypePtr(), H.getResolver())) { auto &Tok = H.addToken(L.getBeginLoc(), *K) .addModifier(HighlightingModifier::Deduced); if (auto Mod = scopeModifier(L.getTypePtr())) Tok.addModifier(*Mod); } return true; } bool VisitDeclaratorDecl(DeclaratorDecl *D) { auto *AT = D->getType()->getContainedAutoType(); if (!AT) return true; if (auto K = kindForType(AT->getDeducedType().getTypePtrOrNull(), H.getResolver())) { auto &Tok = H.addToken(D->getTypeSpecStartLoc(), *K) .addModifier(HighlightingModifier::Deduced); if (auto Mod = scopeModifier(AT->getDeducedType().getTypePtrOrNull())) Tok.addModifier(*Mod); } return true; } // We handle objective-C selectors specially, because one reference can // cover several non-contiguous tokens. void highlightObjCSelector(const ArrayRef<SourceLocation> &Locs, bool Decl, bool Class) { HighlightingKind Kind = Class ? HighlightingKind::StaticMethod : HighlightingKind::Method; for (SourceLocation Part : Locs) { auto &Tok = H.addToken(Part, Kind).addModifier(HighlightingModifier::ClassScope); if (Decl) Tok.addModifier(HighlightingModifier::Declaration); if (Class) Tok.addModifier(HighlightingModifier::Static); } } bool VisitObjCMethodDecl(ObjCMethodDecl *OMD) { llvm::SmallVector<SourceLocation> Locs; OMD->getSelectorLocs(Locs); highlightObjCSelector(Locs, /*Decl=*/true, OMD->isClassMethod()); return true; } bool VisitObjCMessageExpr(ObjCMessageExpr *OME) { llvm::SmallVector<SourceLocation> Locs; OME->getSelectorLocs(Locs); highlightObjCSelector(Locs, /*Decl=*/false, OME->isClassMessage()); return true; } bool VisitOverloadExpr(OverloadExpr *E) { if (!E->decls().empty()) return true; // handled by findExplicitReferences. auto &Tok = H.addToken(E->getNameLoc(), HighlightingKind::Unknown) .addModifier(HighlightingModifier::DependentName); if (llvm::isa<UnresolvedMemberExpr>(E)) Tok.addModifier(HighlightingModifier::ClassScope); // other case is UnresolvedLookupExpr, scope is unknown. return true; } bool VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E) { H.addToken(E->getMemberNameInfo().getLoc(), HighlightingKind::Unknown) .addModifier(HighlightingModifier::DependentName) .addModifier(HighlightingModifier::ClassScope); return true; } bool VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) { H.addToken(E->getNameInfo().getLoc(), HighlightingKind::Unknown) .addModifier(HighlightingModifier::DependentName) .addModifier(HighlightingModifier::ClassScope); return true; } bool VisitDependentNameTypeLoc(DependentNameTypeLoc L) { H.addToken(L.getNameLoc(), HighlightingKind::Type) .addModifier(HighlightingModifier::DependentName) .addModifier(HighlightingModifier::ClassScope); return true; } bool VisitDependentTemplateSpecializationTypeLoc( DependentTemplateSpecializationTypeLoc L) { H.addToken(L.getTemplateNameLoc(), HighlightingKind::Type) .addModifier(HighlightingModifier::DependentName) .addModifier(HighlightingModifier::ClassScope); return true; } bool TraverseTemplateArgumentLoc(TemplateArgumentLoc L) { // Handle template template arguments only (other arguments are handled by // their Expr, TypeLoc etc values). if (L.getArgument().getKind() != TemplateArgument::Template && L.getArgument().getKind() != TemplateArgument::TemplateExpansion) return RecursiveASTVisitor::TraverseTemplateArgumentLoc(L); TemplateName N = L.getArgument().getAsTemplateOrTemplatePattern(); switch (N.getKind()) { case TemplateName::OverloadedTemplate: // Template template params must always be class templates. // Don't bother to try to work out the scope here. H.addToken(L.getTemplateNameLoc(), HighlightingKind::Class); break; case TemplateName::DependentTemplate: case TemplateName::AssumedTemplate: H.addToken(L.getTemplateNameLoc(), HighlightingKind::Class) .addModifier(HighlightingModifier::DependentName); break; case TemplateName::Template: case TemplateName::QualifiedTemplate: case TemplateName::SubstTemplateTemplateParm: case TemplateName::SubstTemplateTemplateParmPack: // Names that could be resolved to a TemplateDecl are handled elsewhere. break; } return RecursiveASTVisitor::TraverseTemplateArgumentLoc(L); } // findExplicitReferences will walk nested-name-specifiers and // find anything that can be resolved to a Decl. However, non-leaf // components of nested-name-specifiers which are dependent names // (kind "Identifier") cannot be resolved to a decl, so we visit // them here. bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc Q) { if (NestedNameSpecifier *NNS = Q.getNestedNameSpecifier()) { if (NNS->getKind() == NestedNameSpecifier::Identifier) H.addToken(Q.getLocalBeginLoc(), HighlightingKind::Type) .addModifier(HighlightingModifier::DependentName) .addModifier(HighlightingModifier::ClassScope); } return RecursiveASTVisitor::TraverseNestedNameSpecifierLoc(Q); } private: HighlightingsBuilder &H; }; } // namespace std::vector<HighlightingToken> getSemanticHighlightings(ParsedAST &AST) { auto &C = AST.getASTContext(); // Add highlightings for AST nodes. HighlightingsBuilder Builder(AST); // Highlight 'decltype' and 'auto' as their underlying types. CollectExtraHighlightings(Builder).TraverseAST(C); // Highlight all decls and references coming from the AST. findExplicitReferences( C, [&](ReferenceLoc R) { for (const NamedDecl *Decl : R.Targets) { if (!canHighlightName(Decl->getDeclName())) continue; auto Kind = kindForDecl(Decl, AST.getHeuristicResolver()); if (!Kind) continue; auto &Tok = Builder.addToken(R.NameLoc, *Kind); // The attribute tests don't want to look at the template. if (auto *TD = dyn_cast<TemplateDecl>(Decl)) { if (auto *Templated = TD->getTemplatedDecl()) Decl = Templated; } if (auto Mod = scopeModifier(Decl)) Tok.addModifier(*Mod); if (isConst(Decl)) Tok.addModifier(HighlightingModifier::Readonly); if (isStatic(Decl)) Tok.addModifier(HighlightingModifier::Static); if (isAbstract(Decl)) Tok.addModifier(HighlightingModifier::Abstract); if (isDependent(Decl)) Tok.addModifier(HighlightingModifier::DependentName); if (Decl->isDeprecated()) Tok.addModifier(HighlightingModifier::Deprecated); // Do not treat an UnresolvedUsingValueDecl as a declaration. // It's more common to think of it as a reference to the // underlying declaration. if (R.IsDecl && !isa<UnresolvedUsingValueDecl>(Decl)) Tok.addModifier(HighlightingModifier::Declaration); } }, AST.getHeuristicResolver()); // Add highlightings for macro references. auto AddMacro = [&](const MacroOccurrence &M) { auto &T = Builder.addToken(M.Rng, HighlightingKind::Macro); T.addModifier(HighlightingModifier::GlobalScope); if (M.IsDefinition) T.addModifier(HighlightingModifier::Declaration); }; for (const auto &SIDToRefs : AST.getMacros().MacroRefs) for (const auto &M : SIDToRefs.second) AddMacro(M); for (const auto &M : AST.getMacros().UnknownMacros) AddMacro(M); return std::move(Builder).collect(AST); } llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, HighlightingKind K) { switch (K) { case HighlightingKind::Variable: return OS << "Variable"; case HighlightingKind::LocalVariable: return OS << "LocalVariable"; case HighlightingKind::Parameter: return OS << "Parameter"; case HighlightingKind::Function: return OS << "Function"; case HighlightingKind::Method: return OS << "Method"; case HighlightingKind::StaticMethod: return OS << "StaticMethod"; case HighlightingKind::Field: return OS << "Field"; case HighlightingKind::StaticField: return OS << "StaticField"; case HighlightingKind::Class: return OS << "Class"; case HighlightingKind::Interface: return OS << "Interface"; case HighlightingKind::Enum: return OS << "Enum"; case HighlightingKind::EnumConstant: return OS << "EnumConstant"; case HighlightingKind::Typedef: return OS << "Typedef"; case HighlightingKind::Type: return OS << "Type"; case HighlightingKind::Unknown: return OS << "Unknown"; case HighlightingKind::Namespace: return OS << "Namespace"; case HighlightingKind::TemplateParameter: return OS << "TemplateParameter"; case HighlightingKind::Concept: return OS << "Concept"; case HighlightingKind::Primitive: return OS << "Primitive"; case HighlightingKind::Macro: return OS << "Macro"; case HighlightingKind::InactiveCode: return OS << "InactiveCode"; } llvm_unreachable("invalid HighlightingKind"); } llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, HighlightingModifier K) { switch (K) { case HighlightingModifier::Declaration: return OS << "decl"; // abbrevation for common case default: return OS << toSemanticTokenModifier(K); } } bool operator==(const HighlightingToken &L, const HighlightingToken &R) { return std::tie(L.R, L.Kind, L.Modifiers) == std::tie(R.R, R.Kind, R.Modifiers); } bool operator<(const HighlightingToken &L, const HighlightingToken &R) { return std::tie(L.R, L.Kind, R.Modifiers) < std::tie(R.R, R.Kind, R.Modifiers); } std::vector<SemanticToken> toSemanticTokens(llvm::ArrayRef<HighlightingToken> Tokens) { assert(std::is_sorted(Tokens.begin(), Tokens.end())); std::vector<SemanticToken> Result; const HighlightingToken *Last = nullptr; for (const HighlightingToken &Tok : Tokens) { Result.emplace_back(); SemanticToken &Out = Result.back(); // deltaStart/deltaLine are relative if possible. if (Last) { assert(Tok.R.start.line >= Last->R.start.line); Out.deltaLine = Tok.R.start.line - Last->R.start.line; if (Out.deltaLine == 0) { assert(Tok.R.start.character >= Last->R.start.character); Out.deltaStart = Tok.R.start.character - Last->R.start.character; } else { Out.deltaStart = Tok.R.start.character; } } else { Out.deltaLine = Tok.R.start.line; Out.deltaStart = Tok.R.start.character; } assert(Tok.R.end.line == Tok.R.start.line); Out.length = Tok.R.end.character - Tok.R.start.character; Out.tokenType = static_cast<unsigned>(Tok.Kind); Out.tokenModifiers = Tok.Modifiers; Last = &Tok; } return Result; } llvm::StringRef toSemanticTokenType(HighlightingKind Kind) { switch (Kind) { case HighlightingKind::Variable: case HighlightingKind::LocalVariable: case HighlightingKind::StaticField: return "variable"; case HighlightingKind::Parameter: return "parameter"; case HighlightingKind::Function: return "function"; case HighlightingKind::Method: return "method"; case HighlightingKind::StaticMethod: // FIXME: better method with static modifier? return "function"; case HighlightingKind::Field: return "property"; case HighlightingKind::Class: return "class"; case HighlightingKind::Interface: return "interface"; case HighlightingKind::Enum: return "enum"; case HighlightingKind::EnumConstant: return "enumMember"; case HighlightingKind::Typedef: case HighlightingKind::Type: return "type"; case HighlightingKind::Unknown: return "unknown"; // nonstandard case HighlightingKind::Namespace: return "namespace"; case HighlightingKind::TemplateParameter: return "typeParameter"; case HighlightingKind::Concept: return "concept"; // nonstandard case HighlightingKind::Primitive: return "type"; case HighlightingKind::Macro: return "macro"; case HighlightingKind::InactiveCode: return "comment"; } llvm_unreachable("unhandled HighlightingKind"); } llvm::StringRef toSemanticTokenModifier(HighlightingModifier Modifier) { switch (Modifier) { case HighlightingModifier::Declaration: return "declaration"; case HighlightingModifier::Deprecated: return "deprecated"; case HighlightingModifier::Readonly: return "readonly"; case HighlightingModifier::Static: return "static"; case HighlightingModifier::Deduced: return "deduced"; // nonstandard case HighlightingModifier::Abstract: return "abstract"; case HighlightingModifier::DependentName: return "dependentName"; // nonstandard case HighlightingModifier::FunctionScope: return "functionScope"; // nonstandard case HighlightingModifier::ClassScope: return "classScope"; // nonstandard case HighlightingModifier::FileScope: return "fileScope"; // nonstandard case HighlightingModifier::GlobalScope: return "globalScope"; // nonstandard } llvm_unreachable("unhandled HighlightingModifier"); } std::vector<SemanticTokensEdit> diffTokens(llvm::ArrayRef<SemanticToken> Old, llvm::ArrayRef<SemanticToken> New) { // For now, just replace everything from the first-last modification. // FIXME: use a real diff instead, this is bad with include-insertion. unsigned Offset = 0; while (!Old.empty() && !New.empty() && Old.front() == New.front()) { ++Offset; Old = Old.drop_front(); New = New.drop_front(); } while (!Old.empty() && !New.empty() && Old.back() == New.back()) { Old = Old.drop_back(); New = New.drop_back(); } if (Old.empty() && New.empty()) return {}; SemanticTokensEdit Edit; Edit.startToken = Offset; Edit.deleteTokens = Old.size(); Edit.tokens = New; return {std::move(Edit)}; } } // namespace clangd } // namespace clang
#include "pch.h" #include "hwnd_data_cache.h" HWNDDataCache hwnd_cache; WindowAndProcPath HWNDDataCache::get_window_and_path(HWND hwnd) { std::unique_lock lock(mutex); auto ptr = get_internal(hwnd); return ptr ? *ptr : WindowAndProcPath{}; } HWND HWNDDataCache::get_window(HWND hwnd) { std::unique_lock lock(mutex); auto ptr = get_internal(hwnd); return ptr ? ptr->hwnd : nullptr; } WindowAndProcPath* HWNDDataCache::get_internal(HWND hwnd) { auto root = GetAncestor(hwnd, GA_ROOT); // Filter the fast and easy cases if (!IsWindowVisible(root) || is_invalid_hwnd(root) || is_invalid_class(root) || is_invalid_style(root)) { return nullptr; } // Get the HWND process path from the cache DWORD pid = GetWindowThreadProcessId(root, nullptr); auto cache_ptr = get_from_cache(root, pid); if (cache_ptr == nullptr) { cache_ptr = put_in_cache(root, pid); } // If the app is a UWP app, check if it isnt banned if (is_uwp_app(root) && is_invalid_uwp_app(cache_ptr->process_path)) { // cache the HWND of the invalid app so we wont search for it again invalid_hwnds.push_back(root); return nullptr; } return cache_ptr; } WindowAndProcPath* HWNDDataCache::get_from_cache(HWND root, DWORD pid) { auto next = next_timestamp(); auto it = std::find_if(begin(cache), end(cache), [&](const auto& entry) { return root == entry.data.hwnd && pid == entry.pid; }); if (it != end(cache)) { it->atime = next; return &(it->data); } else { return nullptr; } } WindowAndProcPath* HWNDDataCache::put_in_cache(HWND root, DWORD pid) { auto next = next_timestamp(); auto it = std::min_element(begin(cache), end(cache), [](const auto& lhs, const auto& rhs) { return lhs.atime < rhs.atime; }); it->atime = next; it->pid = pid; it->data.hwnd = root; it->data.process_path = get_process_path(root); return &(it->data); } bool HWNDDataCache::is_invalid_hwnd(HWND hwnd) const { return std::find(begin(invalid_hwnds), end(invalid_hwnds), hwnd) != end(invalid_hwnds); } bool HWNDDataCache::is_invalid_class(HWND hwnd) const { std::array<char, 256> class_name; GetClassNameA(hwnd, class_name.data(), static_cast<int>(class_name.size())); for (auto invalid : invalid_classes) { if (strcmp(invalid, class_name.data()) == 0) return true; } return false; } bool HWNDDataCache::is_invalid_style(HWND hwnd) const { auto style = GetWindowLong(hwnd, GWL_STYLE); for (auto invalid : invalid_basic_styles) { if ((invalid & style) != 0) { return true; } } style = GetWindowLong(hwnd, GWL_EXSTYLE); for (auto invalid : invalid_ext_styles) { if ((invalid & style) != 0) { return true; } } return false; } bool HWNDDataCache::is_uwp_app(HWND hwnd) const { std::array<char, 256> class_name; GetClassNameA(hwnd, class_name.data(), static_cast<int>(class_name.size())); return strcmp(class_name.data(), "Windows.UI.Core.CoreWindow") == 0; } bool HWNDDataCache::is_invalid_uwp_app(const std::wstring& process_path) const { for (const auto& invalid : invalid_uwp_apps) { // check if process_path ends in "invalid" if (process_path.length() >= invalid.length() && process_path.compare(process_path.length() - invalid.length(), invalid.length(), invalid) == 0) { return true; } } return false; } unsigned HWNDDataCache::next_timestamp() { auto next = ++current_timestamp; if (next == 0) { // Handle overflow by invalidating the cache for (auto& entry : cache) { entry.data.hwnd = nullptr; } } return next; }
[list -] %include "swos.inc" %include "swsmenu.inc" [list +] section .text bits 32 global CheckForFastReplay CheckForFastReplay: %ifdef DEBUG extern DumpVariables call DumpVariables ; write out debug variables %endif test byte [replayStatus], 1 jz .out test byte [replayStatus], 4 jz .out xor byte [rplFrameSkip], 1 test byte [rplFrameSkip], 1 jz .out pop eax ; get rid of return address .out: cmp word [EGA_graphics], -1 retn global MyHilPtrIncrement MyHilPtrIncrement: mov eax, [nextGoalPtr] cmp [A1], eax jnz .out mov bx, [rplHandle] test bx, bx jz .reset_ptr mov cx, 19000 mov edx, [goalBasePtr] mov ah, 0x40 int 0x21 jc .set_error cmp ax, 19000 jz .reset_ptr .set_error: mov byte [saveErrors], 1 .reset_ptr: mov eax, [goalBasePtr] mov [A1], eax .out: retn global MyHilPtrAdd MyHilPtrAdd: mov eax, [nextGoalPtr] cmp [A0], eax jnz .out test byte [replayStatus], 1 jz .reset_ptr mov bx, [rplHandle] mov cx, 19000 mov edx, [goalBasePtr] mov ah, 0x3f int 0x21 .reset_ptr: mov eax, [goalBasePtr] mov [A0], eax .out: retn global OpenReplayFile OpenReplayFile: mov word [rplHandle], 0 ; rplHandle will be zero in case of an error mov byte [saveErrors], 0 mov edx, tmp_filename xor ecx, ecx mov ah, 0x3c int 0x21 ; try to open file for writing jc .out mov [rplHandle], ax mov bx, ax xor cx, cx mov dx, 3626 ; leave room for header (3626 bytes) mov ax, 0x4200 int 0x21 jc .close_file or byte [replayStatus], 2 ; set recording flag jmp .out .close_file: mov ah, 0x3e ; if can't seek, close file int 0x21 mov word [rplHandle], 0 ; set rplHandle to zero to indicate error .out: mov dword [A0], g_currentMenu retn ; CloseReplayFile ; ; in: ; eax - if true it's normal call, just retn, otherwise called from SWOS ; global CloseReplayFile CloseReplayFile: push eax sub esp, byte 4 mov esi, rplHandle mov bx, [esi] test bx, bx jz near .out ; if file wasn't opened, nothing to do inc byte [saveErrors] ; anticipate error mov eax, [currentHilPtr] cmp eax, [nextGoalPtr] jz .nothing_left mov ecx, eax mov edx, [goalBasePtr] sub ecx, edx mov ah, 0x40 int 0x21 ; save remaining stuff jc .close_file .nothing_left: xor cx, cx xor dx, dx mov ax, 0x4201 int 0x21 ; get current position jc .close_file mov [esp], ax ; save current position mov [esp + 2], dx xor dx, dx xor cx, cx mov ax, 0x4200 ; seek to beginning int 0x21 jc .close_file push word [hilNumGoals] ; save number of goals for normal hils mov word [hilNumGoals], 1 ; important - this will look just like one highlight mov ah, 0x40 mov ecx, 3626 mov edx, hilFileBuffer int 0x21 ; write hil header pop word [hilNumGoals] ; restore original number of goals jc .close_file mov dx, [esp] ; restore previous position mov cx, [esp + 2] mov ax, 0x4200 int 0x21 mov dword [esi], -1 push byte 4 mov ah, 0x40 mov edx, esi pop ecx int 0x21 ; save replay terminator (-1) jc .close_file or byte [replayStatus], 8 ; all OK, we have a replay - set flag mov esi, tmp_filename mov edi, selectedFile push byte 13 pop ecx rep movsb dec byte [saveErrors] ; restore errors as it was .close_file: mov ah, 0x3e int 0x21 ; close file mov word [rplHandle], 0 ; clear handle .out: and byte [replayStatus], ~2 ; clear recording flag add esp, byte 4 pop eax test eax, eax jnz .retn mov ax, [isGameFriendly] ; recreate the test or ax, ax .retn: retn global ShowReplaysMenu ShowReplaysMenu: mov dword [A6], replaysMenu calla ShowMenu retn InitReplays: xor ebx, ebx mov al, [replayStatus] and al, 8 cmp bl, al ; al greater than zero? sbb ebx, ebx ; ebx = al > 0 ? -1 : 0 neg ebx ; ebx = al > 0 ? 1 : 0 mov ecx, ebx mov edx, ebx shl ecx, 2 add ecx, edx ; ecx = al > 0 ? 5 : 0 add cl, 9 ; ecx = al > 0 ? 14 : 9 neg ebx ; ebx = al > 0 ? -1 : 0 not ebx ; ebx = al > 0 ? 0 : -1 neg ebx ; ebx = al > 0 ? 0 : 1 mov edi, ebx ; CalcMenuEntryAddress trashes bx mov [D0], word 2 calla CalcMenuEntryAddress mov esi, [A0] mov [esi + MenuEntry.isDisabled], di ; disable or enable view/save replay buttons mov [esi + MenuEntry.backAndFrameColor], cx ; set color - green or gray for disabled entry mov [D0], word 4 calla CalcMenuEntryAddress mov esi, [A0] mov [esi + MenuEntry.isDisabled], di mov [esi + MenuEntry.backAndFrameColor], cx mov al, [saveErrors] ; check rpl file errors test al, al jz .out mov dword [A0], err_msg calla ShowErrorMenu .out: retn ViewReplay: mov edx, selectedFile mov ax, 0x3d00 int 0x21 jnc play_it .cant_open: mov dword [A0], cant_open_str calla ShowErrorMenu retn play_it: mov [rplHandle], ax mov bx, ax mov ecx, 19000 + 3626 mov edx, hilFileBuffer mov ah, 0x3f int 0x21 jc read_error test eax, eax jz read_error ; check for zero-sized file cmp eax, ecx jnz read_error ; check for too small filesize mov edi, hilFilename mov esi, selectedFile push byte 13 pop ecx rep movsb and byte [replayStatus], ~4 ; turn off fast replay or byte [replayStatus], 1 ; set playing flag calla ShowHighlights and byte [replayStatus], ~1 mov bx, [rplHandle] ; close file mov ah, 0x3e int 0x21 mov word [hilNumGoals], 0 ; reset highlights retn read_error: mov ah, 0x3e int 0x21 mov dword [A0], err_reading calla ShowErrorMenu retn LoadReplay: mov eax, load_replay_str mov [A0], eax mov [A1], eax mov dword [D0], 'LPR.' calla GetFilenameAndExtension jnz .out mov esi, [A0] mov edi, selectedFile push byte 13 pop ecx rep movsb ; copy selected name to our buffer or byte [replayStatus], 8 .out: jmp InitReplays SaveReplay: mov eax, saveFilename ; zero out default save name mov byte [eax], 0 mov [A0], eax mov dword [A1], save_replay_str mov dword [D0], 'LPR.' calla SelectFileToSaveDialog jnz near .out mov esi, [A0] mov edi, selectedFile push byte 13 pop ecx rep cmpsb ; compare selected file with destination jne .copy mov dword [A0], cant_copy_to_itself calla ShowErrorMenu jmp short SaveReplay .copy: mov edx, selectedFile mov ax, 0x3d00 int 0x21 jc ViewReplay.cant_open mov esi, eax mov edx, [A0] xor ecx, ecx mov ah, 0x3c int 0x21 jc ViewReplay.cant_open mov edi, eax mov edx, foundFilenamesBuffer .copy_loop: mov ebx, esi mov cx, 0x4000 mov ah, 0x3f int 0x21 jc read_error test eax, eax jz .copy_over mov ecx, eax mov ah, 0x40 mov ebx, edi int 0x21 jnc .copy_loop mov dword [A0], err_writing calla ShowErrorMenu .copy_over: mov ebx, esi mov ah, 0x3e int 0x21 mov ebx, edi int 0x21 .out: retn section .bss rplHandle: resd 1 selectedFile: resb 13 saveFilename: resb 13 saveErrors: resb 1 ; bit 0 set = playing (1) ; bit 1 set = recording (2) ; bit 2 set = fast replay (4) ; bit 3 set = we have replay to show (8) ; global replayStatus replayStatus: resb 1 global rplFrameSkip rplFrameSkip: resb 1 section .rdata load_replay_str: db "LOAD REPLAY", 0 save_replay_str: db "SAVE REPLAY", 0 tmp_filename: db "LASTGAME.RPL", 0 err_msg: db "WARNING: FILE MAY BE CORRUPTED", 0 cant_open_str: db "FILE COULD NOT BE OPENED", 0 err_reading: db "ERROR READING FILE", 0 err_writing: db "ERROR WRITING FILE", 0 cant_copy_to_itself: db "CANT COPY FILE TO ITSELF", 0 error_copying: db "ERROR COPYING FILE", 0 section .data StartMenu replaysMenu, InitReplays, 0, 0, 3 StartEntry 92, 0, 120, 15 EntryColor 0x17 EntryString 0, "REPLAYS" EndEntry StartEntry 102, 185, 100, 15 NextEntries -1, -1, 4, -1 EntryColor 12 EntryString 0, aExit OnSelect SetExitMenuFlag EndEntry StartEntry 82, 60, 140, 15 NextEntries -1, -1, -1, 3 EntryColor 14 EntryString 0, "VIEW REPLAY" OnSelect ViewReplay EndEntry StartEntry 82, 90, 140, 15 NextEntries -1, -1, 2, 4 EntryColor 14 EntryString 0, "LOAD REPLAY" OnSelect LoadReplay EndEntry StartEntry 82, 120, 140, 15 NextEntries -1, -1, 3, 1 EntryColor 14 EntryString 0, "SAVE REPLAY" OnSelect SaveReplay EndEntry EndMenu
#include "bcpch.h" #include <glm/gtc/matrix_transform.hpp> #include "byteCat/app/Application.h" #include "byteCat/entity-system/cameras/PerspectiveCamera.h" namespace BC { PerspectiveCamera::PerspectiveCamera(float fov, float nearPlane, float farPlane) { int width = Application::GetInstance().getWindow().getWidth(); int height = Application::GetInstance().getWindow().getHeight(); projectionMatrix = glm::perspective(glm::radians(fov), ((width * 1.0f) / (height * 1.0f)), nearPlane, farPlane); this->fov = fov; this->nearPlane = nearPlane; this->farPlane = farPlane; } void PerspectiveCamera::setPerspective(float fov, float nearPlane, float farPlane) { int width = Application::GetInstance().getWindow().getWidth(); int height = Application::GetInstance().getWindow().getHeight(); projectionMatrix = glm::perspective(glm::radians(fov), ((width * 1.0f) / (height * 1.0f)), nearPlane, farPlane); this->fov = fov; this->nearPlane = nearPlane; this->farPlane = farPlane; } void PerspectiveCamera::onWindowResize(unsigned width, unsigned height) { projectionMatrix = glm::perspective(glm::radians(fov), ((width * 1.0f) / (height * 1.0f)), nearPlane, farPlane); } }
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r15 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x1b2b3, %rsi lea addresses_UC_ht+0x1d633, %rdi nop nop inc %r13 mov $55, %rcx rep movsq nop nop nop xor $39105, %r14 lea addresses_A_ht+0xd544, %rsi lea addresses_UC_ht+0x1c7ab, %rdi clflush (%rdi) sub %rbx, %rbx mov $34, %rcx rep movsb nop nop nop add %rbx, %rbx lea addresses_A_ht+0x13d82, %rdi nop xor %rax, %rax movb $0x61, (%rdi) nop nop nop nop cmp $21378, %rbx lea addresses_UC_ht+0x172e3, %rdi nop nop nop nop and %r13, %r13 mov $0x6162636465666768, %rbx movq %rbx, %xmm3 movups %xmm3, (%rdi) nop nop add $57034, %rcx lea addresses_UC_ht+0xc9b3, %rsi lea addresses_normal_ht+0xcd3, %rdi nop sub %r15, %r15 mov $82, %rcx rep movsq nop nop nop sub $17258, %r14 lea addresses_WT_ht+0xcab3, %rsi lea addresses_normal_ht+0xa433, %rdi nop xor $1306, %r13 mov $45, %rcx rep movsw nop nop sub %rcx, %rcx lea addresses_D_ht+0x4ef3, %rcx nop cmp %r15, %r15 vmovups (%rcx), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $1, %xmm4, %rdi xor $54481, %rcx lea addresses_WT_ht+0x21b3, %r14 nop nop nop nop nop dec %r13 movw $0x6162, (%r14) nop inc %r15 lea addresses_WC_ht+0xbbb3, %rsi lea addresses_normal_ht+0x10ab3, %rdi clflush (%rdi) nop nop nop add $19806, %r13 mov $78, %rcx rep movsq sub %r15, %r15 lea addresses_WC_ht+0x15f97, %rcx nop nop nop nop nop inc %rax movb (%rcx), %r14b nop add $56561, %rdi lea addresses_D_ht+0x139b3, %rdi nop nop nop nop nop sub %rsi, %rsi movb $0x61, (%rdi) nop xor %rax, %rax lea addresses_A_ht+0x5273, %rsi lea addresses_WT_ht+0x1cdb3, %rdi nop nop nop nop nop add %r14, %r14 mov $10, %rcx rep movsb nop nop nop nop nop add $2610, %rcx lea addresses_A_ht+0x8573, %rax clflush (%rax) nop nop nop nop nop add %rbx, %rbx and $0xffffffffffffffc0, %rax movaps (%rax), %xmm7 vpextrq $0, %xmm7, %r14 nop nop nop nop xor %r13, %r13 lea addresses_WC_ht+0x1c955, %rsi lea addresses_WC_ht+0x16c33, %rdi clflush (%rsi) nop nop and %r14, %r14 mov $74, %rcx rep movsw nop nop nop nop nop cmp $17701, %rax lea addresses_D_ht+0x1953, %r14 nop nop nop nop nop inc %rsi mov (%r14), %edi nop nop nop nop nop xor $32819, %rax pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r15 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r15 push %r8 push %rbp push %rbx push %rsi // Store lea addresses_RW+0x1efb3, %r12 clflush (%r12) cmp $44011, %rbp movl $0x51525354, (%r12) nop nop nop nop nop sub $62754, %r15 // Store mov $0x4491d800000001b3, %r10 sub %rbx, %rbx movl $0x51525354, (%r10) nop nop dec %rbp // Faulty Load mov $0x4491d800000001b3, %r15 nop nop and %r8, %r8 mov (%r15), %r10 lea oracles, %r15 and $0xff, %r10 shlq $12, %r10 mov (%r15,%r10,1), %r10 pop %rsi pop %rbx pop %rbp pop %r8 pop %r15 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_RW', 'AVXalign': False, 'size': 4}} {'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 4}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_UC_ht'}} {'src': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16}} {'src': {'same': False, 'congruent': 9, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_normal_ht'}} {'src': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_normal_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 7, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 2}} {'src': {'same': True, 'congruent': 8, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 1}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 1}} {'src': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_A_ht', 'AVXalign': True, 'size': 16}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 1, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_WC_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'54': 1264, '00': 20565} 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 54 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 54 00 00 00 54 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 54 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 54 54 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 54 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 54 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 54 00 00 00 00 00 00 00 00 54 */
; A192831: Molecular topological indices of the hypercube graphs. ; Submitted by Jamie Morken(s3) ; 4,48,360,2304,13600,76032,407680,2113536,10658304,52531200,254003200,1208549376,5672083456,26309885952,120803328000,549772591104,2482528976896,11132640165888,49615651471360,219902744985600,969770180542464,4257311052791808,18612537272565760,81064802956345344,351843741859840000,1522216719416819712,6566248354550906880,28246577073321148416,121200873623303225344,518814678039448780800,2215915133918091673600,9444732970137336938496,40177008601893842190336,170595489213525862121472 mov $1,2 pow $1,$0 add $0,1 mul $1,$0 add $0,$1 mul $1,$0 mul $1,2 mov $0,$1
; A186148: Rank of (1/4)n^3 when {(1/4)i^3: i>=1} and {j^2>: j>=1} are jointly ranked with (1/4)i^3 before j^2 when (1/4)i^3=j^2. Complement of A186149. ; 1,3,5,7,10,13,16,19,22,25,29,32,36,40,44,47,52,56,60,64,69,73,78,82,87,92,97,102,107,112,117,122,127,133,138,143,149,155,160,166,172,178,183,189,195,201,208,214,220,226,233,239,245,252,258,265,272,278,285,292,299,306,313,319,327,334,341,348,355,362,370,377,384,392,399,407,414,422,430,437,445,453,461,468,476,484,492,500 mov $2,$0 mov $3,$0 seq $0,186147 ; Rank of n^3 when {i^2: i>=1} and {j^3: j>=1} are jointly ranked with i^2 after j^3 when i^2=j^3. Complement of A135674. mov $1,2 sub $3,$0 add $3,3 sub $1,$3 div $1,2 add $1,1 add $1,$2 mov $0,$1
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 80 .text@150 lbegin: ld b, 90 call lwaitly_b ld hl, fe00 ld(hl), 00 ld c, 41 ld b, 03 lbegin_waitm3: ldff a, (c) and a, b cmp a, b jrnz lbegin_waitm3 ld a, 20 ldff(c), a xor a, a ldff(0f), a ld a, 02 ldff(ff), a ei .text@1000 lstatint: nop .text@1066 ld(hl), 01 .text@10c0 ld a, (hl--) and a, b jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r8 push %r9 push %rbp push %rcx push %rdi push %rsi lea addresses_WT_ht+0x1ea6a, %rsi lea addresses_UC_ht+0x55ea, %rdi nop nop nop nop nop xor %r8, %r8 mov $87, %rcx rep movsw nop nop nop sub $51219, %rdi lea addresses_WT_ht+0x1bd6a, %r14 nop nop nop nop nop add $20542, %rcx movl $0x61626364, (%r14) nop sub %r8, %r8 lea addresses_WC_ht+0x32b7, %rcx clflush (%rcx) sub $16948, %r9 mov $0x6162636465666768, %r8 movq %r8, (%rcx) nop nop nop nop cmp %rdi, %rdi lea addresses_normal_ht+0xc16a, %rdi nop nop nop nop nop add $19053, %rcx mov $0x6162636465666768, %rsi movq %rsi, %xmm3 movups %xmm3, (%rdi) nop nop nop nop nop add %rsi, %rsi lea addresses_UC_ht+0x153ea, %rsi lea addresses_A_ht+0x185ea, %rdi nop nop nop nop nop and $63350, %r10 mov $98, %rcx rep movsw xor %r8, %r8 lea addresses_WC_ht+0xa482, %rsi lea addresses_WC_ht+0x1ddea, %rdi clflush (%rdi) nop nop nop nop nop add %r14, %r14 mov $42, %rcx rep movsb nop nop nop nop nop sub $62077, %r8 lea addresses_A_ht+0x8a4a, %rsi lea addresses_D_ht+0x63e, %rdi nop nop add $5097, %r8 mov $64, %rcx rep movsq nop nop nop nop nop add $17749, %r8 lea addresses_D_ht+0xb682, %r10 nop xor $29800, %rsi mov $0x6162636465666768, %r8 movq %r8, %xmm4 vmovups %ymm4, (%r10) nop nop sub %rdi, %rdi lea addresses_WT_ht+0x1c58a, %r9 nop nop and %rcx, %rcx mov (%r9), %si nop nop cmp $21963, %r10 lea addresses_A_ht+0x2bea, %r10 nop nop and %r9, %r9 movl $0x61626364, (%r10) nop nop nop cmp %rsi, %rsi lea addresses_WT_ht+0xd1ea, %rbp nop nop nop nop inc %rsi mov $0x6162636465666768, %rcx movq %rcx, (%rbp) nop nop nop nop nop sub $17226, %rdi pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r14 push %r8 push %rax push %rbp // Store lea addresses_RW+0x1f416, %r8 dec %r11 movl $0x51525354, (%r8) nop nop nop cmp %r8, %r8 // Load lea addresses_WT+0x1056a, %rbp nop nop nop xor $53473, %rax mov (%rbp), %r11d nop nop nop nop nop dec %r11 // Store lea addresses_PSE+0x1b1ea, %rbp nop nop sub $52471, %r10 movl $0x51525354, (%rbp) nop nop nop nop xor $16551, %r10 // Faulty Load lea addresses_WT+0x1edea, %r10 xor $61049, %rbp mov (%r10), %ax lea oracles, %r10 and $0xff, %rax shlq $12, %rax mov (%r10,%rax,1), %rax pop %rbp pop %rax pop %r8 pop %r14 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 1, 'same': False, 'type': 'addresses_RW'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7, 'same': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'dst': {'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 10, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': True, 'type': 'addresses_WT'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 5, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'} {'src': {'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'} {'src': {'congruent': 3, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 4, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 6, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'39': 21829} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
include stdiolib.i CGROUP group code code segment dword 'CODE' assume cs:CGROUP,ds:CGROUP STDIOLIB_JUMP fputs siol_fputs code ends end
%include "include/u7bg-all-includes.asm" %assign ItemType_LOCKED_CHEST 522 %assign ItemType_SEALED_BOX 798 %macro isAxLockedItemType 0 cmp ax, ItemType_LOCKED_CHEST jz %%isLocked cmp ax, ItemType_SEALED_BOX jz %%isLocked xor ax, ax jmp %%end %%isLocked: mov ax, 1 %%end: %endmacro %include "../u7-common/patch-eop-shapeBarkForContent.asm"
extern m7_ippsHashMethod_SHA224:function extern n8_ippsHashMethod_SHA224:function extern y8_ippsHashMethod_SHA224:function extern e9_ippsHashMethod_SHA224:function extern l9_ippsHashMethod_SHA224:function extern n0_ippsHashMethod_SHA224:function extern k0_ippsHashMethod_SHA224:function extern ippcpJumpIndexForMergedLibs extern ippcpSafeInit:function segment .data align 8 dq .Lin_ippsHashMethod_SHA224 .Larraddr_ippsHashMethod_SHA224: dq m7_ippsHashMethod_SHA224 dq n8_ippsHashMethod_SHA224 dq y8_ippsHashMethod_SHA224 dq e9_ippsHashMethod_SHA224 dq l9_ippsHashMethod_SHA224 dq n0_ippsHashMethod_SHA224 dq k0_ippsHashMethod_SHA224 segment .text global ippsHashMethod_SHA224:function (ippsHashMethod_SHA224.LEndippsHashMethod_SHA224 - ippsHashMethod_SHA224) .Lin_ippsHashMethod_SHA224: db 0xf3, 0x0f, 0x1e, 0xfa call ippcpSafeInit wrt ..plt align 16 ippsHashMethod_SHA224: db 0xf3, 0x0f, 0x1e, 0xfa mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc] movsxd rax, dword [rax] lea r11, [rel .Larraddr_ippsHashMethod_SHA224] mov r11, qword [r11+rax*8] jmp r11 .LEndippsHashMethod_SHA224:
; A095808: Number of ways to write n in the form m + (m+1) + ... + (m+k-1) + (m+k) + (m+k-1) + ... + (m+1) + m with integers m>= 1, k>=1. Or, number of divisors a of 4n-1 with 0 < (a-1)^2 < 4n. ; 0,0,0,1,0,0,1,0,1,1,0,0,1,1,0,2,0,0,2,0,0,1,1,1,2,0,0,1,1,1,1,0,0,3,0,1,2,0,1,1,0,0,2,2,0,1,1,0,3,0,1,2,0,1,1,0,0,3,1,0,2,1,0,3,1,0,1,0,2,2,0,1,1,1,1,1,0,0,5,1,1,1,0,1,1,1,0,3,1,0,2,0,1,3,0,0,2,1,1,3 mul $0,4 add $0,2 cal $0,1227 ; Number of odd divisors of n. mov $1,$0 sub $1,2 div $1,2
#pragma once #include "catch2.hpp" #include "multisolver_interface/Solver.h" TEST_CASE("InvalidStatusException", "[exceptions][invalid_status]") { SolverFactory factory; for (auto const& solver_name : factory.get_solvers_list()) { //======================================================================================== // solver declaration SolverAbstract::Ptr solver = factory.create_solver(solver_name); try { solver->zero_status_check(-1, "test exception"); } catch(InvalidStatusException& ex) { REQUIRE(std::string(ex.what()) == "Failed to test exception: invalid status -1 (0 expected)"); } } } TEST_CASE("InvalidRowSizeException", "[exceptions][invalid_row_size]") { SolverFactory factory; std::string solver_name = "CBC"; //======================================================================================== // solver declaration SolverAbstract::Ptr solver = factory.create_solver(solver_name); solver->init(); try{ std::vector<std::string> names = solver->get_row_names(0,9); }catch(InvalidRowSizeException& ex) { REQUIRE(std::string(ex.what()) == "Invalid row size for solver. 0 rows available (10 expected)"); } } TEST_CASE("InvalidColSizeException", "[exceptions][invalid_col_size]") { SolverFactory factory; std::string solver_name = "CBC"; //======================================================================================== // solver declaration SolverAbstract::Ptr solver = factory.create_solver(solver_name); solver->init(); try{ std::vector<std::string> names = solver->get_col_names(0,9); }catch(InvalidColSizeException& ex) { REQUIRE(std::string(ex.what()) == "Invalid col size for solver. 0 cols available (10 expected)"); } } SolverAbstract::Ptr createSimpleProblem(const std::string& solver_name) { SolverFactory factory; SolverAbstract::Ptr solver = factory.create_solver(solver_name); solver->init(); // 2 Colunms with no obj std::vector<int> matind(0); std::vector<double> matval(0); std::vector<int> matstart = std::vector<int>(2, 0); std::vector<double> obj = std::vector<double>(2, 0.0); std::vector<double> lb = std::vector<double>(2, 0.0); std::vector<double> ub = std::vector<double>(2, 100.0); solver->add_cols(2, 0, obj.data(), matstart.data(), matind.data(), matval.data(), lb.data(), ub.data()); //======================================================================================== // Add a row to problem : creating row structure int newRows = 2; int newElems = 3; std::vector<double> matvalRow = { 5.0, -3.2, 10 }; std::vector<int> mind = { 0, 1 , 1 }; std::vector<int> mstart = { 0, 2 , 3 }; std::vector<char> ntype = { 'L', 'G' }; std::vector<double> rhs = { 5.0 , 2}; //======================================================================================== // Add rows to solver solver->add_rows(newRows, newElems, ntype.data(), rhs.data(), NULL, mstart.data(), mind.data(), matvalRow.data()); return solver; } TEST_CASE("InvalidColTypeException", "[exceptions][invalid_col_type]") { for (auto const& solver_name : {"CBC", "CLP"}) { SolverAbstract::Ptr solver = createSimpleProblem(solver_name); try { solver->chg_col_type(std::vector<int>(1, 0), std::vector<char>(1, 'P')); } catch (InvalidColTypeException &ex) { REQUIRE(std::string(ex.what()) == "Invalid col type P for solver."); } } } TEST_CASE("InvalidBoundTypeException", "[exceptions][invalid_bound_type]") { for (auto const& solver_name : {"CBC", "CLP"}) { SolverAbstract::Ptr solver = createSimpleProblem(solver_name); try { solver->chg_bounds(std::vector<int>(1, 0), std::vector<char>(1, 'P'), std::vector<double>(1, 0)); } catch (InvalidBoundTypeException &ex) { REQUIRE(std::string(ex.what()) == "Invalid bound type P for solver."); } } } TEST_CASE("InvalidSetAlgorithm", "[exceptions][invalid_set_algorithm]") { for (auto const& solver_name : {"CBC", "CLP"}) { SolverFactory factory; SolverAbstract::Ptr solver = factory.create_solver(solver_name); solver->init(); try { solver->set_algorithm("BARRIER"); } catch (InvalidSolverOptionException &ex) { REQUIRE(std::string(ex.what()) == "Invalid option 'set_algorithm : BARRIER' for solver."); } } } TEST_CASE("InvalidSetSimpleIter", "[exceptions][set_simplex_iter]") { for (auto const& solver_name : {"CBC"}) { SolverFactory factory; SolverAbstract::Ptr solver = factory.create_solver(solver_name); solver->init(); try { solver->set_simplex_iter(10); } catch (InvalidSolverOptionException &ex) { REQUIRE(std::string(ex.what()) == "Invalid option 'set_simplex_iter : 10' for solver."); } } } TEST_CASE("InvalidSetOptimatilityGap", "[exceptions][set_optimality_gap]") { for (auto const& solver_name : {"CBC", "CLP"}) { SolverFactory factory; SolverAbstract::Ptr solver = factory.create_solver(solver_name); solver->init(); try { solver->set_optimality_gap(10); } catch (InvalidSolverOptionException &ex) { REQUIRE(std::string(ex.what()) == "Invalid option 'set_optimality_gap : 10.000000' for solver."); } } } TEST_CASE("InvalidSolverNameException", "[exceptions][invalid_solver_name]") { for (std::string const& solver_name : {"SIRIUS", "GUROBI"}) { SolverFactory factory; try { SolverAbstract::Ptr solver = factory.create_solver(solver_name); } catch (InvalidSolverNameException &ex) { REQUIRE(std::string(ex.what()) == std::string("Solver '"+ solver_name + "' not supported")); } } }
############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .section .note.GNU-stack,"",%progbits .text p521r1_data: _prime521r1: .long 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF .long 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF .long 0x1FF .p2align 5, 0x90 .globl add_521 .type add_521, @function add_521: movl (%esi), %eax addl (%ebx), %eax movl %eax, (%edi) movl (4)(%esi), %eax adcl (4)(%ebx), %eax movl %eax, (4)(%edi) movl (8)(%esi), %eax adcl (8)(%ebx), %eax movl %eax, (8)(%edi) movl (12)(%esi), %eax adcl (12)(%ebx), %eax movl %eax, (12)(%edi) movl (16)(%esi), %eax adcl (16)(%ebx), %eax movl %eax, (16)(%edi) movl (20)(%esi), %eax adcl (20)(%ebx), %eax movl %eax, (20)(%edi) movl (24)(%esi), %eax adcl (24)(%ebx), %eax movl %eax, (24)(%edi) movl (28)(%esi), %eax adcl (28)(%ebx), %eax movl %eax, (28)(%edi) movl (32)(%esi), %eax adcl (32)(%ebx), %eax movl %eax, (32)(%edi) movl (36)(%esi), %eax adcl (36)(%ebx), %eax movl %eax, (36)(%edi) movl (40)(%esi), %eax adcl (40)(%ebx), %eax movl %eax, (40)(%edi) movl (44)(%esi), %eax adcl (44)(%ebx), %eax movl %eax, (44)(%edi) movl (48)(%esi), %eax adcl (48)(%ebx), %eax movl %eax, (48)(%edi) movl (52)(%esi), %eax adcl (52)(%ebx), %eax movl %eax, (52)(%edi) movl (56)(%esi), %eax adcl (56)(%ebx), %eax movl %eax, (56)(%edi) movl (60)(%esi), %eax adcl (60)(%ebx), %eax movl %eax, (60)(%edi) movl (64)(%esi), %eax adcl (64)(%ebx), %eax movl %eax, (64)(%edi) mov $(0), %eax adc $(0), %eax ret .Lfe1: .size add_521, .Lfe1-(add_521) .p2align 5, 0x90 .globl sub_521 .type sub_521, @function sub_521: movl (%esi), %eax subl (%ebx), %eax movl %eax, (%edi) movl (4)(%esi), %eax sbbl (4)(%ebx), %eax movl %eax, (4)(%edi) movl (8)(%esi), %eax sbbl (8)(%ebx), %eax movl %eax, (8)(%edi) movl (12)(%esi), %eax sbbl (12)(%ebx), %eax movl %eax, (12)(%edi) movl (16)(%esi), %eax sbbl (16)(%ebx), %eax movl %eax, (16)(%edi) movl (20)(%esi), %eax sbbl (20)(%ebx), %eax movl %eax, (20)(%edi) movl (24)(%esi), %eax sbbl (24)(%ebx), %eax movl %eax, (24)(%edi) movl (28)(%esi), %eax sbbl (28)(%ebx), %eax movl %eax, (28)(%edi) movl (32)(%esi), %eax sbbl (32)(%ebx), %eax movl %eax, (32)(%edi) movl (36)(%esi), %eax sbbl (36)(%ebx), %eax movl %eax, (36)(%edi) movl (40)(%esi), %eax sbbl (40)(%ebx), %eax movl %eax, (40)(%edi) movl (44)(%esi), %eax sbbl (44)(%ebx), %eax movl %eax, (44)(%edi) movl (48)(%esi), %eax sbbl (48)(%ebx), %eax movl %eax, (48)(%edi) movl (52)(%esi), %eax sbbl (52)(%ebx), %eax movl %eax, (52)(%edi) movl (56)(%esi), %eax sbbl (56)(%ebx), %eax movl %eax, (56)(%edi) movl (60)(%esi), %eax sbbl (60)(%ebx), %eax movl %eax, (60)(%edi) movl (64)(%esi), %eax sbbl (64)(%ebx), %eax movl %eax, (64)(%edi) mov $(0), %eax adc $(0), %eax ret .Lfe2: .size sub_521, .Lfe2-(sub_521) .p2align 5, 0x90 .globl shl_521 .type shl_521, @function shl_521: push %ecx mov $(13), %ecx pxor %xmm1, %xmm1 .Lshl_loopgas_3: movdqu (%esi), %xmm0 movdqa %xmm0, %xmm2 add $(16), %esi palignr $(8), %xmm1, %xmm2 movdqa %xmm0, %xmm1 psllq $(1), %xmm0 psrlq $(63), %xmm2 por %xmm2, %xmm0 movdqu %xmm0, (%edi) add $(16), %edi sub $(4), %ecx jg .Lshl_loopgas_3 movd (%esi), %xmm0 palignr $(12), %xmm1, %xmm0 psllq $(1), %xmm0 psrldq $(4), %xmm0 movd %xmm0, (%edi) sub $(64), %esi sub $(64), %edi pop %ecx xor %eax, %eax ret .Lfe3: .size shl_521, .Lfe3-(shl_521) .p2align 5, 0x90 .globl shr_521 .type shr_521, @function shr_521: movl (64)(%esi), %eax push %ecx mov $(9), %ecx .Lshr_loopgas_4: movdqu (%esi), %xmm0 movdqu (16)(%esi), %xmm1 palignr $(8), %xmm0, %xmm1 add $(16), %esi psrlq $(1), %xmm0 psllq $(63), %xmm1 por %xmm1, %xmm0 movdqu %xmm0, (%edi) add $(16), %edi sub $(4), %ecx jg .Lshr_loopgas_4 pop %ecx movdqu (%esi), %xmm0 movd %eax, %xmm1 palignr $(8), %xmm0, %xmm1 psrlq $(1), %xmm0 psllq $(63), %xmm1 por %xmm1, %xmm0 movdqu %xmm0, (%edi) shr $(1), %eax movl %eax, (16)(%edi) sub $(24), %esi sub $(24), %esi ret .Lfe4: .size shr_521, .Lfe4-(shr_521) .p2align 5, 0x90 .globl p521r1_add .type p521r1_add, @function p521r1_add: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(72), %esp and $(-16), %esp movl %eax, (68)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebx call add_521 mov %eax, %edx lea (%esp), %edi movl (8)(%ebp), %esi lea p521r1_data, %ebx lea ((_prime521r1-p521r1_data))(%ebx), %ebx call sub_521 lea (%esp), %esi movl (8)(%ebp), %edi sub %eax, %edx cmovne %edi, %esi movdqu (%esi), %xmm0 movdqu (16)(%esi), %xmm1 movdqu (32)(%esi), %xmm2 movdqu (48)(%esi), %xmm3 movl (64)(%esi), %eax movdqu %xmm0, (%edi) movdqu %xmm1, (16)(%edi) movdqu %xmm2, (32)(%edi) movdqu %xmm3, (48)(%edi) movl %eax, (64)(%edi) mov (68)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe5: .size p521r1_add, .Lfe5-(p521r1_add) .p2align 5, 0x90 .globl p521r1_sub .type p521r1_sub, @function p521r1_sub: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(72), %esp and $(-16), %esp movl %eax, (68)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebx call sub_521 mov %eax, %edx lea (%esp), %edi movl (8)(%ebp), %esi lea p521r1_data, %ebx lea ((_prime521r1-p521r1_data))(%ebx), %ebx call add_521 lea (%esp), %esi movl (8)(%ebp), %edi test %edx, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movdqu (16)(%esi), %xmm1 movdqu (32)(%esi), %xmm2 movdqu (48)(%esi), %xmm3 movl (64)(%esi), %eax movdqu %xmm0, (%edi) movdqu %xmm1, (16)(%edi) movdqu %xmm2, (32)(%edi) movdqu %xmm3, (48)(%edi) movl %eax, (64)(%edi) mov (68)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe6: .size p521r1_sub, .Lfe6-(p521r1_sub) .p2align 5, 0x90 .globl p521r1_neg .type p521r1_neg, @function p521r1_neg: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(72), %esp and $(-16), %esp movl %eax, (68)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi mov $(0), %eax subl (%esi), %eax movl %eax, (%edi) mov $(0), %eax sbbl (4)(%esi), %eax movl %eax, (4)(%edi) mov $(0), %eax sbbl (8)(%esi), %eax movl %eax, (8)(%edi) mov $(0), %eax sbbl (12)(%esi), %eax movl %eax, (12)(%edi) mov $(0), %eax sbbl (16)(%esi), %eax movl %eax, (16)(%edi) mov $(0), %eax sbbl (20)(%esi), %eax movl %eax, (20)(%edi) mov $(0), %eax sbbl (24)(%esi), %eax movl %eax, (24)(%edi) mov $(0), %eax sbbl (28)(%esi), %eax movl %eax, (28)(%edi) mov $(0), %eax sbbl (32)(%esi), %eax movl %eax, (32)(%edi) mov $(0), %eax sbbl (36)(%esi), %eax movl %eax, (36)(%edi) mov $(0), %eax sbbl (40)(%esi), %eax movl %eax, (40)(%edi) mov $(0), %eax sbbl (44)(%esi), %eax movl %eax, (44)(%edi) mov $(0), %eax sbbl (48)(%esi), %eax movl %eax, (48)(%edi) mov $(0), %eax sbbl (52)(%esi), %eax movl %eax, (52)(%edi) mov $(0), %eax sbbl (56)(%esi), %eax movl %eax, (56)(%edi) mov $(0), %eax sbbl (60)(%esi), %eax movl %eax, (60)(%edi) mov $(0), %eax sbbl (64)(%esi), %eax movl %eax, (64)(%edi) sbb %edx, %edx lea (%esp), %edi movl (8)(%ebp), %esi lea p521r1_data, %ebx lea ((_prime521r1-p521r1_data))(%ebx), %ebx call add_521 lea (%esp), %esi movl (8)(%ebp), %edi test %edx, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movdqu (16)(%esi), %xmm1 movdqu (32)(%esi), %xmm2 movdqu (48)(%esi), %xmm3 movl (64)(%esi), %eax movdqu %xmm0, (%edi) movdqu %xmm1, (16)(%edi) movdqu %xmm2, (32)(%edi) movdqu %xmm3, (48)(%edi) movl %eax, (64)(%edi) mov (68)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe7: .size p521r1_neg, .Lfe7-(p521r1_neg) .p2align 5, 0x90 .globl p521r1_mul_by_2 .type p521r1_mul_by_2, @function p521r1_mul_by_2: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(72), %esp and $(-16), %esp movl %eax, (68)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi call shl_521 mov %eax, %edx mov %edi, %esi movl (8)(%ebp), %edi lea p521r1_data, %ebx lea ((_prime521r1-p521r1_data))(%ebx), %ebx call sub_521 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movdqu (16)(%esi), %xmm1 movdqu (32)(%esi), %xmm2 movdqu (48)(%esi), %xmm3 movl (64)(%esi), %eax movdqu %xmm0, (%edi) movdqu %xmm1, (16)(%edi) movdqu %xmm2, (32)(%edi) movdqu %xmm3, (48)(%edi) movl %eax, (64)(%edi) mov (68)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe8: .size p521r1_mul_by_2, .Lfe8-(p521r1_mul_by_2) .p2align 5, 0x90 .globl p521r1_mul_by_3 .type p521r1_mul_by_3, @function p521r1_mul_by_3: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(144), %esp and $(-16), %esp movl %eax, (140)(%esp) lea p521r1_data, %eax lea ((_prime521r1-p521r1_data))(%eax), %eax movl %eax, (136)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi call shl_521 mov %eax, %edx mov %edi, %esi lea (68)(%esp), %edi mov (136)(%esp), %ebx call sub_521 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movdqu (16)(%esi), %xmm1 movdqu (32)(%esi), %xmm2 movdqu (48)(%esi), %xmm3 movl (64)(%esi), %eax movdqu %xmm0, (%edi) movdqu %xmm1, (16)(%edi) movdqu %xmm2, (32)(%edi) movdqu %xmm3, (48)(%edi) movl %eax, (64)(%edi) mov %edi, %esi movl (12)(%ebp), %ebx call add_521 mov %eax, %edx movl (8)(%ebp), %edi mov (136)(%esp), %ebx call sub_521 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movdqu (16)(%esi), %xmm1 movdqu (32)(%esi), %xmm2 movdqu (48)(%esi), %xmm3 movl (64)(%esi), %eax movdqu %xmm0, (%edi) movdqu %xmm1, (16)(%edi) movdqu %xmm2, (32)(%edi) movdqu %xmm3, (48)(%edi) movl %eax, (64)(%edi) mov (140)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe9: .size p521r1_mul_by_3, .Lfe9-(p521r1_mul_by_3) .p2align 5, 0x90 .globl p521r1_div_by_2 .type p521r1_div_by_2, @function p521r1_div_by_2: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(72), %esp and $(-16), %esp movl %eax, (68)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi lea p521r1_data, %ebx lea ((_prime521r1-p521r1_data))(%ebx), %ebx call add_521 mov $(0), %edx movl (%esi), %ecx and $(1), %ecx cmovne %edi, %esi cmove %edx, %eax movl (8)(%ebp), %edi call shr_521 mov (68)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe10: .size p521r1_div_by_2, .Lfe10-(p521r1_div_by_2) .p2align 5, 0x90 .globl p521r1_mul_mont_slm .type p521r1_mul_mont_slm, @function p521r1_mul_mont_slm: push %ebp mov %esp, %ebp push %ebx push %esi push %edi push %ebp mov %esp, %eax sub $(88), %esp and $(-16), %esp movl %eax, (84)(%esp) pxor %xmm0, %xmm0 movdqa %xmm0, (%esp) movdqa %xmm0, (16)(%esp) movdqa %xmm0, (32)(%esp) movdqa %xmm0, (48)(%esp) movq %xmm0, (64)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebp movl %edi, (72)(%esp) movl %esi, (76)(%esp) movl %ebp, (80)(%esp) mov $(17), %ebx movd (4)(%esi), %mm1 movd (8)(%esi), %mm2 movd (12)(%esi), %mm3 movd (16)(%esi), %mm4 .p2align 5, 0x90 .Lmmul_loopgas_11: movd %ebx, %mm7 movl (%ebp), %edx movl (%esi), %eax movd %edx, %mm0 add $(4), %ebp movl %ebp, (80)(%esp) pmuludq %mm0, %mm1 pmuludq %mm0, %mm2 mul %edx addl (%esp), %eax adc $(0), %edx pmuludq %mm0, %mm3 pmuludq %mm0, %mm4 movd %mm1, %ecx psrlq $(32), %mm1 add %edx, %ecx movd %mm1, %edx adc $(0), %edx addl (4)(%esp), %ecx movd (20)(%esi), %mm1 movl %ecx, (%esp) adc $(0), %edx movd %mm2, %ebx psrlq $(32), %mm2 add %edx, %ebx movd %mm2, %edx adc $(0), %edx addl (8)(%esp), %ebx movd (24)(%esi), %mm2 movl %ebx, (4)(%esp) adc $(0), %edx pmuludq %mm0, %mm1 pmuludq %mm0, %mm2 movd %mm3, %ebp psrlq $(32), %mm3 add %edx, %ebp movd %mm3, %edx adc $(0), %edx addl (12)(%esp), %ebp movd (28)(%esi), %mm3 movl %ebp, (8)(%esp) adc $(0), %edx movd %mm4, %edi psrlq $(32), %mm4 add %edx, %edi movd %mm4, %edx adc $(0), %edx addl (16)(%esp), %edi movd (32)(%esi), %mm4 movl %edi, (12)(%esp) adc $(0), %edx pmuludq %mm0, %mm3 pmuludq %mm0, %mm4 movd %mm1, %ecx psrlq $(32), %mm1 add %edx, %ecx movd %mm1, %edx adc $(0), %edx addl (20)(%esp), %ecx movd (36)(%esi), %mm1 movl %ecx, (16)(%esp) adc $(0), %edx movd %mm2, %ebx psrlq $(32), %mm2 add %edx, %ebx movd %mm2, %edx adc $(0), %edx addl (24)(%esp), %ebx movd (40)(%esi), %mm2 movl %ebx, (20)(%esp) adc $(0), %edx pmuludq %mm0, %mm1 pmuludq %mm0, %mm2 movd %mm3, %ebp psrlq $(32), %mm3 add %edx, %ebp movd %mm3, %edx adc $(0), %edx addl (28)(%esp), %ebp movd (44)(%esi), %mm3 movl %ebp, (24)(%esp) adc $(0), %edx movd %mm4, %edi psrlq $(32), %mm4 add %edx, %edi movd %mm4, %edx adc $(0), %edx addl (32)(%esp), %edi movd (48)(%esi), %mm4 movl %edi, (28)(%esp) adc $(0), %edx pmuludq %mm0, %mm3 pmuludq %mm0, %mm4 movd %mm1, %ecx psrlq $(32), %mm1 add %edx, %ecx movd %mm1, %edx adc $(0), %edx addl (36)(%esp), %ecx movd (52)(%esi), %mm1 movl %ecx, (32)(%esp) adc $(0), %edx movd %mm2, %ebx psrlq $(32), %mm2 add %edx, %ebx movd %mm2, %edx adc $(0), %edx addl (40)(%esp), %ebx movd (56)(%esi), %mm2 movl %ebx, (36)(%esp) adc $(0), %edx pmuludq %mm0, %mm1 pmuludq %mm0, %mm2 movd %mm3, %ebp psrlq $(32), %mm3 add %edx, %ebp movd %mm3, %edx adc $(0), %edx addl (44)(%esp), %ebp movd (60)(%esi), %mm3 movl %ebp, (40)(%esp) adc $(0), %edx movd %mm4, %edi psrlq $(32), %mm4 add %edx, %edi movd %mm4, %edx adc $(0), %edx addl (48)(%esp), %edi movd (64)(%esi), %mm4 movl %edi, (44)(%esp) adc $(0), %edx pmuludq %mm0, %mm3 pmuludq %mm0, %mm4 movd %mm1, %ecx psrlq $(32), %mm1 add %edx, %ecx movd %mm1, %edx adc $(0), %edx addl (52)(%esp), %ecx movl %ecx, (48)(%esp) adc $(0), %edx movd %mm2, %ebx psrlq $(32), %mm2 add %edx, %ebx movd %mm2, %edx adc $(0), %edx addl (56)(%esp), %ebx movl %ebx, (52)(%esp) adc $(0), %edx movd %mm3, %ebp psrlq $(32), %mm3 add %edx, %ebp movd %mm3, %edx adc $(0), %edx addl (60)(%esp), %ebp movl %ebp, (56)(%esp) adc $(0), %edx movd %mm4, %edi psrlq $(32), %mm4 add %edx, %edi movd %mm4, %edx adc $(0), %edx addl (64)(%esp), %edi adc $(0), %edx movd %mm7, %ebx mov %eax, %ecx shl $(9), %eax shr $(23), %ecx add %eax, %edi movl %edi, (60)(%esp) adc %ecx, %edx movl %edx, (64)(%esp) sub $(1), %ebx movd (4)(%esi), %mm1 movd (8)(%esi), %mm2 movd (12)(%esi), %mm3 movd (16)(%esi), %mm4 jz .Lexit_mmul_loopgas_11 movl (80)(%esp), %ebp jmp .Lmmul_loopgas_11 .Lexit_mmul_loopgas_11: emms mov (72)(%esp), %edi lea (%esp), %esi lea p521r1_data, %ebx lea ((_prime521r1-p521r1_data))(%ebx), %ebx call sub_521 movl (68)(%esp), %edx cmove %edi, %esi movdqu (%esi), %xmm0 movdqu (16)(%esi), %xmm1 movdqu (32)(%esi), %xmm2 movdqu (48)(%esi), %xmm3 movl (64)(%esi), %eax movdqu %xmm0, (%edi) movdqu %xmm1, (16)(%edi) movdqu %xmm2, (32)(%edi) movdqu %xmm3, (48)(%edi) movl %eax, (64)(%edi) mov (84)(%esp), %esp pop %ebp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe11: .size p521r1_mul_mont_slm, .Lfe11-(p521r1_mul_mont_slm) .p2align 5, 0x90 .globl p521r1_sqr_mont_slm .type p521r1_sqr_mont_slm, @function p521r1_sqr_mont_slm: push %ebp mov %esp, %ebp push %esi push %edi movl (12)(%ebp), %esi movl (8)(%ebp), %edi push %esi push %esi push %edi call p521r1_mul_mont_slm add $(12), %esp pop %edi pop %esi pop %ebp ret .Lfe12: .size p521r1_sqr_mont_slm, .Lfe12-(p521r1_sqr_mont_slm) .p2align 5, 0x90 .globl p521r1_mred .type p521r1_mred, @function p521r1_mred: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (12)(%ebp), %esi mov $(17), %ecx xor %edx, %edx .p2align 5, 0x90 .Lmred_loopgas_13: movl (%esi), %ebx movl (%esi), %eax shr $(23), %ebx shl $(9), %eax add %edx, %ebx addl (64)(%esi), %eax movl (68)(%esi), %edx adc %edx, %ebx mov $(0), %edx movl %eax, (64)(%esi) movl %ebx, (68)(%esi) adc $(0), %edx lea (4)(%esi), %esi sub $(1), %ecx jnz .Lmred_loopgas_13 movl (8)(%ebp), %edi lea p521r1_data, %ebx lea ((_prime521r1-p521r1_data))(%ebx), %ebx call sub_521 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movdqu (16)(%esi), %xmm1 movdqu (32)(%esi), %xmm2 movdqu (48)(%esi), %xmm3 movl (64)(%esi), %eax movdqu %xmm0, (%edi) movdqu %xmm1, (16)(%edi) movdqu %xmm2, (32)(%edi) movdqu %xmm3, (48)(%edi) movl %eax, (64)(%edi) pop %edi pop %esi pop %ebx pop %ebp ret pop %edi pop %esi pop %ebx pop %ebp ret .Lfe13: .size p521r1_mred, .Lfe13-(p521r1_mred) .p2align 5, 0x90 .globl p521r1_select_pp_w5 .type p521r1_select_pp_w5, @function p521r1_select_pp_w5: push %ebp mov %esp, %ebp push %esi push %edi pxor %xmm0, %xmm0 movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %eax movd %eax, %xmm7 pshufd $(0), %xmm7, %xmm7 mov $(1), %edx movd %edx, %xmm6 pshufd $(0), %xmm6, %xmm6 movdqa %xmm0, (%edi) movdqa %xmm0, (16)(%edi) movdqa %xmm0, (32)(%edi) movdqa %xmm0, (48)(%edi) movdqa %xmm0, (64)(%edi) movdqa %xmm0, (80)(%edi) movdqa %xmm0, (96)(%edi) movdqa %xmm0, (112)(%edi) movdqa %xmm0, (128)(%edi) movdqa %xmm0, (144)(%edi) movdqa %xmm0, (160)(%edi) movdqa %xmm0, (176)(%edi) pxor %xmm3, %xmm3 movdqa %xmm6, %xmm5 mov $(16), %ecx .p2align 5, 0x90 .Lselect_loopgas_14: movdqa %xmm5, %xmm4 pcmpeqd %xmm7, %xmm4 movdqu (%esi), %xmm0 pand %xmm4, %xmm0 por (%edi), %xmm0 movdqa %xmm0, (%edi) movdqu (16)(%esi), %xmm1 pand %xmm4, %xmm1 por (16)(%edi), %xmm1 movdqa %xmm1, (16)(%edi) movdqu (32)(%esi), %xmm0 pand %xmm4, %xmm0 por (32)(%edi), %xmm0 movdqa %xmm0, (32)(%edi) movdqu (48)(%esi), %xmm1 pand %xmm4, %xmm1 por (48)(%edi), %xmm1 movdqa %xmm1, (48)(%edi) movdqu (64)(%esi), %xmm0 pand %xmm4, %xmm0 por (64)(%edi), %xmm0 movdqa %xmm0, (64)(%edi) movdqu (80)(%esi), %xmm1 pand %xmm4, %xmm1 por (80)(%edi), %xmm1 movdqa %xmm1, (80)(%edi) movdqu (96)(%esi), %xmm0 pand %xmm4, %xmm0 por (96)(%edi), %xmm0 movdqa %xmm0, (96)(%edi) movdqu (112)(%esi), %xmm1 pand %xmm4, %xmm1 por (112)(%edi), %xmm1 movdqa %xmm1, (112)(%edi) movdqu (128)(%esi), %xmm0 pand %xmm4, %xmm0 por (128)(%edi), %xmm0 movdqa %xmm0, (128)(%edi) movdqu (144)(%esi), %xmm1 pand %xmm4, %xmm1 por (144)(%edi), %xmm1 movdqa %xmm1, (144)(%edi) movdqu (160)(%esi), %xmm0 pand %xmm4, %xmm0 por (160)(%edi), %xmm0 movdqa %xmm0, (160)(%edi) movdqu (176)(%esi), %xmm1 pand %xmm4, %xmm1 por (176)(%edi), %xmm1 movdqa %xmm1, (176)(%edi) movdqu (192)(%esi), %xmm0 pand %xmm4, %xmm0 por %xmm0, %xmm3 paddd %xmm6, %xmm5 add $(204), %esi sub $(1), %ecx jnz .Lselect_loopgas_14 movq %xmm3, (192)(%edi) psrldq $(8), %xmm3 movd %xmm3, (200)(%edi) pop %edi pop %esi pop %ebp ret .Lfe14: .size p521r1_select_pp_w5, .Lfe14-(p521r1_select_pp_w5)
//================================================================================================= /*! // \file src/mathtest/dvecdvecouter/VDaVDb.cpp // \brief Source file for the VDaVDb dense vector/dense vector outer product math test // // Copyright (C) 2012-2018 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/DynamicVector.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/dvecdvecouter/OperationTest.h> #include <blazetest/system/MathTest.h> //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'VDaVDb'..." << std::endl; using blazetest::mathtest::TypeA; using blazetest::mathtest::TypeB; try { // Vector type definitions typedef blaze::DynamicVector<TypeA> VDa; typedef blaze::DynamicVector<TypeB> VDb; // Creator type definitions typedef blazetest::Creator<VDa> CVDa; typedef blazetest::Creator<VDb> CVDb; // Running tests with small vectors for( size_t i=0UL; i<=6UL; ++i ) { for( size_t j=0UL; j<=6UL; ++j ) { RUN_DVECDVECOUTER_OPERATION_TEST( CVDa( i ), CVDb( j ) ); } } // Running tests with large vectors RUN_DVECDVECOUTER_OPERATION_TEST( CVDa( 67UL ), CVDb( 67UL ) ); RUN_DVECDVECOUTER_OPERATION_TEST( CVDa( 67UL ), CVDb( 127UL ) ); RUN_DVECDVECOUTER_OPERATION_TEST( CVDa( 127UL ), CVDb( 67UL ) ); RUN_DVECDVECOUTER_OPERATION_TEST( CVDa( 127UL ), CVDb( 127UL ) ); RUN_DVECDVECOUTER_OPERATION_TEST( CVDa( 64UL ), CVDb( 64UL ) ); RUN_DVECDVECOUTER_OPERATION_TEST( CVDa( 64UL ), CVDb( 128UL ) ); RUN_DVECDVECOUTER_OPERATION_TEST( CVDa( 128UL ), CVDb( 64UL ) ); RUN_DVECDVECOUTER_OPERATION_TEST( CVDa( 128UL ), CVDb( 128UL ) ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during dense vector/dense vector outer product:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
_usertests: file format elf32-i386 Disassembly of section .text: 00000000 <iputtest>: int stdout = 1; // does chdir() call iput(p->cwd) in a transaction? void iputtest(void) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 18 sub $0x18,%esp printf(stdout, "iput test\n"); 6: a1 d4 62 00 00 mov 0x62d4,%eax b: c7 44 24 04 2a 44 00 movl $0x442a,0x4(%esp) 12: 00 13: 89 04 24 mov %eax,(%esp) 16: e8 2a 40 00 00 call 4045 <printf> if(mkdir("iputdir") < 0){ 1b: c7 04 24 35 44 00 00 movl $0x4435,(%esp) 22: e8 f6 3e 00 00 call 3f1d <mkdir> 27: 85 c0 test %eax,%eax 29: 79 1a jns 45 <iputtest+0x45> printf(stdout, "mkdir failed\n"); 2b: a1 d4 62 00 00 mov 0x62d4,%eax 30: c7 44 24 04 3d 44 00 movl $0x443d,0x4(%esp) 37: 00 38: 89 04 24 mov %eax,(%esp) 3b: e8 05 40 00 00 call 4045 <printf> exit(); 40: e8 70 3e 00 00 call 3eb5 <exit> } if(chdir("iputdir") < 0){ 45: c7 04 24 35 44 00 00 movl $0x4435,(%esp) 4c: e8 d4 3e 00 00 call 3f25 <chdir> 51: 85 c0 test %eax,%eax 53: 79 1a jns 6f <iputtest+0x6f> printf(stdout, "chdir iputdir failed\n"); 55: a1 d4 62 00 00 mov 0x62d4,%eax 5a: c7 44 24 04 4b 44 00 movl $0x444b,0x4(%esp) 61: 00 62: 89 04 24 mov %eax,(%esp) 65: e8 db 3f 00 00 call 4045 <printf> exit(); 6a: e8 46 3e 00 00 call 3eb5 <exit> } if(unlink("../iputdir") < 0){ 6f: c7 04 24 61 44 00 00 movl $0x4461,(%esp) 76: e8 8a 3e 00 00 call 3f05 <unlink> 7b: 85 c0 test %eax,%eax 7d: 79 1a jns 99 <iputtest+0x99> printf(stdout, "unlink ../iputdir failed\n"); 7f: a1 d4 62 00 00 mov 0x62d4,%eax 84: c7 44 24 04 6c 44 00 movl $0x446c,0x4(%esp) 8b: 00 8c: 89 04 24 mov %eax,(%esp) 8f: e8 b1 3f 00 00 call 4045 <printf> exit(); 94: e8 1c 3e 00 00 call 3eb5 <exit> } if(chdir("/") < 0){ 99: c7 04 24 86 44 00 00 movl $0x4486,(%esp) a0: e8 80 3e 00 00 call 3f25 <chdir> a5: 85 c0 test %eax,%eax a7: 79 1a jns c3 <iputtest+0xc3> printf(stdout, "chdir / failed\n"); a9: a1 d4 62 00 00 mov 0x62d4,%eax ae: c7 44 24 04 88 44 00 movl $0x4488,0x4(%esp) b5: 00 b6: 89 04 24 mov %eax,(%esp) b9: e8 87 3f 00 00 call 4045 <printf> exit(); be: e8 f2 3d 00 00 call 3eb5 <exit> } printf(stdout, "iput test ok\n"); c3: a1 d4 62 00 00 mov 0x62d4,%eax c8: c7 44 24 04 98 44 00 movl $0x4498,0x4(%esp) cf: 00 d0: 89 04 24 mov %eax,(%esp) d3: e8 6d 3f 00 00 call 4045 <printf> } d8: c9 leave d9: c3 ret 000000da <exitiputtest>: // does exit() call iput(p->cwd) in a transaction? void exitiputtest(void) { da: 55 push %ebp db: 89 e5 mov %esp,%ebp dd: 83 ec 28 sub $0x28,%esp int pid; printf(stdout, "exitiput test\n"); e0: a1 d4 62 00 00 mov 0x62d4,%eax e5: c7 44 24 04 a6 44 00 movl $0x44a6,0x4(%esp) ec: 00 ed: 89 04 24 mov %eax,(%esp) f0: e8 50 3f 00 00 call 4045 <printf> pid = fork(); f5: e8 b3 3d 00 00 call 3ead <fork> fa: 89 45 f4 mov %eax,-0xc(%ebp) if(pid < 0){ fd: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 101: 79 1a jns 11d <exitiputtest+0x43> printf(stdout, "fork failed\n"); 103: a1 d4 62 00 00 mov 0x62d4,%eax 108: c7 44 24 04 b5 44 00 movl $0x44b5,0x4(%esp) 10f: 00 110: 89 04 24 mov %eax,(%esp) 113: e8 2d 3f 00 00 call 4045 <printf> exit(); 118: e8 98 3d 00 00 call 3eb5 <exit> } if(pid == 0){ 11d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 121: 0f 85 83 00 00 00 jne 1aa <exitiputtest+0xd0> if(mkdir("iputdir") < 0){ 127: c7 04 24 35 44 00 00 movl $0x4435,(%esp) 12e: e8 ea 3d 00 00 call 3f1d <mkdir> 133: 85 c0 test %eax,%eax 135: 79 1a jns 151 <exitiputtest+0x77> printf(stdout, "mkdir failed\n"); 137: a1 d4 62 00 00 mov 0x62d4,%eax 13c: c7 44 24 04 3d 44 00 movl $0x443d,0x4(%esp) 143: 00 144: 89 04 24 mov %eax,(%esp) 147: e8 f9 3e 00 00 call 4045 <printf> exit(); 14c: e8 64 3d 00 00 call 3eb5 <exit> } if(chdir("iputdir") < 0){ 151: c7 04 24 35 44 00 00 movl $0x4435,(%esp) 158: e8 c8 3d 00 00 call 3f25 <chdir> 15d: 85 c0 test %eax,%eax 15f: 79 1a jns 17b <exitiputtest+0xa1> printf(stdout, "child chdir failed\n"); 161: a1 d4 62 00 00 mov 0x62d4,%eax 166: c7 44 24 04 c2 44 00 movl $0x44c2,0x4(%esp) 16d: 00 16e: 89 04 24 mov %eax,(%esp) 171: e8 cf 3e 00 00 call 4045 <printf> exit(); 176: e8 3a 3d 00 00 call 3eb5 <exit> } if(unlink("../iputdir") < 0){ 17b: c7 04 24 61 44 00 00 movl $0x4461,(%esp) 182: e8 7e 3d 00 00 call 3f05 <unlink> 187: 85 c0 test %eax,%eax 189: 79 1a jns 1a5 <exitiputtest+0xcb> printf(stdout, "unlink ../iputdir failed\n"); 18b: a1 d4 62 00 00 mov 0x62d4,%eax 190: c7 44 24 04 6c 44 00 movl $0x446c,0x4(%esp) 197: 00 198: 89 04 24 mov %eax,(%esp) 19b: e8 a5 3e 00 00 call 4045 <printf> exit(); 1a0: e8 10 3d 00 00 call 3eb5 <exit> } exit(); 1a5: e8 0b 3d 00 00 call 3eb5 <exit> } wait(); 1aa: e8 0e 3d 00 00 call 3ebd <wait> printf(stdout, "exitiput test ok\n"); 1af: a1 d4 62 00 00 mov 0x62d4,%eax 1b4: c7 44 24 04 d6 44 00 movl $0x44d6,0x4(%esp) 1bb: 00 1bc: 89 04 24 mov %eax,(%esp) 1bf: e8 81 3e 00 00 call 4045 <printf> } 1c4: c9 leave 1c5: c3 ret 000001c6 <openiputtest>: // for(i = 0; i < 10000; i++) // yield(); // } void openiputtest(void) { 1c6: 55 push %ebp 1c7: 89 e5 mov %esp,%ebp 1c9: 83 ec 28 sub $0x28,%esp int pid; printf(stdout, "openiput test\n"); 1cc: a1 d4 62 00 00 mov 0x62d4,%eax 1d1: c7 44 24 04 e8 44 00 movl $0x44e8,0x4(%esp) 1d8: 00 1d9: 89 04 24 mov %eax,(%esp) 1dc: e8 64 3e 00 00 call 4045 <printf> if(mkdir("oidir") < 0){ 1e1: c7 04 24 f7 44 00 00 movl $0x44f7,(%esp) 1e8: e8 30 3d 00 00 call 3f1d <mkdir> 1ed: 85 c0 test %eax,%eax 1ef: 79 1a jns 20b <openiputtest+0x45> printf(stdout, "mkdir oidir failed\n"); 1f1: a1 d4 62 00 00 mov 0x62d4,%eax 1f6: c7 44 24 04 fd 44 00 movl $0x44fd,0x4(%esp) 1fd: 00 1fe: 89 04 24 mov %eax,(%esp) 201: e8 3f 3e 00 00 call 4045 <printf> exit(); 206: e8 aa 3c 00 00 call 3eb5 <exit> } pid = fork(); 20b: e8 9d 3c 00 00 call 3ead <fork> 210: 89 45 f4 mov %eax,-0xc(%ebp) if(pid < 0){ 213: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 217: 79 1a jns 233 <openiputtest+0x6d> printf(stdout, "fork failed\n"); 219: a1 d4 62 00 00 mov 0x62d4,%eax 21e: c7 44 24 04 b5 44 00 movl $0x44b5,0x4(%esp) 225: 00 226: 89 04 24 mov %eax,(%esp) 229: e8 17 3e 00 00 call 4045 <printf> exit(); 22e: e8 82 3c 00 00 call 3eb5 <exit> } if(pid == 0){ 233: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 237: 75 3c jne 275 <openiputtest+0xaf> int fd = open("oidir", O_RDWR); 239: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) 240: 00 241: c7 04 24 f7 44 00 00 movl $0x44f7,(%esp) 248: e8 a8 3c 00 00 call 3ef5 <open> 24d: 89 45 f0 mov %eax,-0x10(%ebp) if(fd >= 0){ 250: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 254: 78 1a js 270 <openiputtest+0xaa> printf(stdout, "open directory for write succeeded\n"); 256: a1 d4 62 00 00 mov 0x62d4,%eax 25b: c7 44 24 04 14 45 00 movl $0x4514,0x4(%esp) 262: 00 263: 89 04 24 mov %eax,(%esp) 266: e8 da 3d 00 00 call 4045 <printf> exit(); 26b: e8 45 3c 00 00 call 3eb5 <exit> } exit(); 270: e8 40 3c 00 00 call 3eb5 <exit> } sleep(1); 275: c7 04 24 01 00 00 00 movl $0x1,(%esp) 27c: e8 c4 3c 00 00 call 3f45 <sleep> if(unlink("oidir") != 0){ 281: c7 04 24 f7 44 00 00 movl $0x44f7,(%esp) 288: e8 78 3c 00 00 call 3f05 <unlink> 28d: 85 c0 test %eax,%eax 28f: 74 1a je 2ab <openiputtest+0xe5> printf(stdout, "unlink failed\n"); 291: a1 d4 62 00 00 mov 0x62d4,%eax 296: c7 44 24 04 38 45 00 movl $0x4538,0x4(%esp) 29d: 00 29e: 89 04 24 mov %eax,(%esp) 2a1: e8 9f 3d 00 00 call 4045 <printf> exit(); 2a6: e8 0a 3c 00 00 call 3eb5 <exit> } wait(); 2ab: e8 0d 3c 00 00 call 3ebd <wait> printf(stdout, "openiput test ok\n"); 2b0: a1 d4 62 00 00 mov 0x62d4,%eax 2b5: c7 44 24 04 47 45 00 movl $0x4547,0x4(%esp) 2bc: 00 2bd: 89 04 24 mov %eax,(%esp) 2c0: e8 80 3d 00 00 call 4045 <printf> } 2c5: c9 leave 2c6: c3 ret 000002c7 <opentest>: // simple file system tests void opentest(void) { 2c7: 55 push %ebp 2c8: 89 e5 mov %esp,%ebp 2ca: 83 ec 28 sub $0x28,%esp int fd; printf(stdout, "open test\n"); 2cd: a1 d4 62 00 00 mov 0x62d4,%eax 2d2: c7 44 24 04 59 45 00 movl $0x4559,0x4(%esp) 2d9: 00 2da: 89 04 24 mov %eax,(%esp) 2dd: e8 63 3d 00 00 call 4045 <printf> fd = open("echo", 0); 2e2: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 2e9: 00 2ea: c7 04 24 14 44 00 00 movl $0x4414,(%esp) 2f1: e8 ff 3b 00 00 call 3ef5 <open> 2f6: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 2f9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2fd: 79 1a jns 319 <opentest+0x52> printf(stdout, "open echo failed!\n"); 2ff: a1 d4 62 00 00 mov 0x62d4,%eax 304: c7 44 24 04 64 45 00 movl $0x4564,0x4(%esp) 30b: 00 30c: 89 04 24 mov %eax,(%esp) 30f: e8 31 3d 00 00 call 4045 <printf> exit(); 314: e8 9c 3b 00 00 call 3eb5 <exit> } close(fd); 319: 8b 45 f4 mov -0xc(%ebp),%eax 31c: 89 04 24 mov %eax,(%esp) 31f: e8 b9 3b 00 00 call 3edd <close> fd = open("doesnotexist", 0); 324: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 32b: 00 32c: c7 04 24 77 45 00 00 movl $0x4577,(%esp) 333: e8 bd 3b 00 00 call 3ef5 <open> 338: 89 45 f4 mov %eax,-0xc(%ebp) if(fd >= 0){ 33b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 33f: 78 1a js 35b <opentest+0x94> printf(stdout, "open doesnotexist succeeded!\n"); 341: a1 d4 62 00 00 mov 0x62d4,%eax 346: c7 44 24 04 84 45 00 movl $0x4584,0x4(%esp) 34d: 00 34e: 89 04 24 mov %eax,(%esp) 351: e8 ef 3c 00 00 call 4045 <printf> exit(); 356: e8 5a 3b 00 00 call 3eb5 <exit> } printf(stdout, "open test ok\n"); 35b: a1 d4 62 00 00 mov 0x62d4,%eax 360: c7 44 24 04 a2 45 00 movl $0x45a2,0x4(%esp) 367: 00 368: 89 04 24 mov %eax,(%esp) 36b: e8 d5 3c 00 00 call 4045 <printf> } 370: c9 leave 371: c3 ret 00000372 <writetest>: void writetest(void) { 372: 55 push %ebp 373: 89 e5 mov %esp,%ebp 375: 83 ec 28 sub $0x28,%esp int fd; int i; printf(stdout, "small file test\n"); 378: a1 d4 62 00 00 mov 0x62d4,%eax 37d: c7 44 24 04 b0 45 00 movl $0x45b0,0x4(%esp) 384: 00 385: 89 04 24 mov %eax,(%esp) 388: e8 b8 3c 00 00 call 4045 <printf> fd = open("small", O_CREATE|O_RDWR); 38d: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 394: 00 395: c7 04 24 c1 45 00 00 movl $0x45c1,(%esp) 39c: e8 54 3b 00 00 call 3ef5 <open> 3a1: 89 45 f0 mov %eax,-0x10(%ebp) if(fd >= 0){ 3a4: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 3a8: 78 21 js 3cb <writetest+0x59> printf(stdout, "creat small succeeded; ok\n"); 3aa: a1 d4 62 00 00 mov 0x62d4,%eax 3af: c7 44 24 04 c7 45 00 movl $0x45c7,0x4(%esp) 3b6: 00 3b7: 89 04 24 mov %eax,(%esp) 3ba: e8 86 3c 00 00 call 4045 <printf> } else { printf(stdout, "error: creat small failed!\n"); exit(); } for(i = 0; i < 100; i++){ 3bf: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 3c6: e9 a0 00 00 00 jmp 46b <writetest+0xf9> printf(stdout, "small file test\n"); fd = open("small", O_CREATE|O_RDWR); if(fd >= 0){ printf(stdout, "creat small succeeded; ok\n"); } else { printf(stdout, "error: creat small failed!\n"); 3cb: a1 d4 62 00 00 mov 0x62d4,%eax 3d0: c7 44 24 04 e2 45 00 movl $0x45e2,0x4(%esp) 3d7: 00 3d8: 89 04 24 mov %eax,(%esp) 3db: e8 65 3c 00 00 call 4045 <printf> exit(); 3e0: e8 d0 3a 00 00 call 3eb5 <exit> } for(i = 0; i < 100; i++){ if(write(fd, "aaaaaaaaaa", 10) != 10){ 3e5: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 3ec: 00 3ed: c7 44 24 04 fe 45 00 movl $0x45fe,0x4(%esp) 3f4: 00 3f5: 8b 45 f0 mov -0x10(%ebp),%eax 3f8: 89 04 24 mov %eax,(%esp) 3fb: e8 d5 3a 00 00 call 3ed5 <write> 400: 83 f8 0a cmp $0xa,%eax 403: 74 21 je 426 <writetest+0xb4> printf(stdout, "error: write aa %d new file failed\n", i); 405: a1 d4 62 00 00 mov 0x62d4,%eax 40a: 8b 55 f4 mov -0xc(%ebp),%edx 40d: 89 54 24 08 mov %edx,0x8(%esp) 411: c7 44 24 04 0c 46 00 movl $0x460c,0x4(%esp) 418: 00 419: 89 04 24 mov %eax,(%esp) 41c: e8 24 3c 00 00 call 4045 <printf> exit(); 421: e8 8f 3a 00 00 call 3eb5 <exit> } if(write(fd, "bbbbbbbbbb", 10) != 10){ 426: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 42d: 00 42e: c7 44 24 04 30 46 00 movl $0x4630,0x4(%esp) 435: 00 436: 8b 45 f0 mov -0x10(%ebp),%eax 439: 89 04 24 mov %eax,(%esp) 43c: e8 94 3a 00 00 call 3ed5 <write> 441: 83 f8 0a cmp $0xa,%eax 444: 74 21 je 467 <writetest+0xf5> printf(stdout, "error: write bb %d new file failed\n", i); 446: a1 d4 62 00 00 mov 0x62d4,%eax 44b: 8b 55 f4 mov -0xc(%ebp),%edx 44e: 89 54 24 08 mov %edx,0x8(%esp) 452: c7 44 24 04 3c 46 00 movl $0x463c,0x4(%esp) 459: 00 45a: 89 04 24 mov %eax,(%esp) 45d: e8 e3 3b 00 00 call 4045 <printf> exit(); 462: e8 4e 3a 00 00 call 3eb5 <exit> printf(stdout, "creat small succeeded; ok\n"); } else { printf(stdout, "error: creat small failed!\n"); exit(); } for(i = 0; i < 100; i++){ 467: 83 45 f4 01 addl $0x1,-0xc(%ebp) 46b: 83 7d f4 63 cmpl $0x63,-0xc(%ebp) 46f: 0f 8e 70 ff ff ff jle 3e5 <writetest+0x73> if(write(fd, "bbbbbbbbbb", 10) != 10){ printf(stdout, "error: write bb %d new file failed\n", i); exit(); } } printf(stdout, "writes ok\n"); 475: a1 d4 62 00 00 mov 0x62d4,%eax 47a: c7 44 24 04 60 46 00 movl $0x4660,0x4(%esp) 481: 00 482: 89 04 24 mov %eax,(%esp) 485: e8 bb 3b 00 00 call 4045 <printf> close(fd); 48a: 8b 45 f0 mov -0x10(%ebp),%eax 48d: 89 04 24 mov %eax,(%esp) 490: e8 48 3a 00 00 call 3edd <close> fd = open("small", O_RDONLY); 495: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 49c: 00 49d: c7 04 24 c1 45 00 00 movl $0x45c1,(%esp) 4a4: e8 4c 3a 00 00 call 3ef5 <open> 4a9: 89 45 f0 mov %eax,-0x10(%ebp) if(fd >= 0){ 4ac: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 4b0: 78 3e js 4f0 <writetest+0x17e> printf(stdout, "open small succeeded ok\n"); 4b2: a1 d4 62 00 00 mov 0x62d4,%eax 4b7: c7 44 24 04 6b 46 00 movl $0x466b,0x4(%esp) 4be: 00 4bf: 89 04 24 mov %eax,(%esp) 4c2: e8 7e 3b 00 00 call 4045 <printf> } else { printf(stdout, "error: open small failed!\n"); exit(); } i = read(fd, buf, 2000); 4c7: c7 44 24 08 d0 07 00 movl $0x7d0,0x8(%esp) 4ce: 00 4cf: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 4d6: 00 4d7: 8b 45 f0 mov -0x10(%ebp),%eax 4da: 89 04 24 mov %eax,(%esp) 4dd: e8 eb 39 00 00 call 3ecd <read> 4e2: 89 45 f4 mov %eax,-0xc(%ebp) if(i == 2000){ 4e5: 81 7d f4 d0 07 00 00 cmpl $0x7d0,-0xc(%ebp) 4ec: 75 4e jne 53c <writetest+0x1ca> 4ee: eb 1a jmp 50a <writetest+0x198> close(fd); fd = open("small", O_RDONLY); if(fd >= 0){ printf(stdout, "open small succeeded ok\n"); } else { printf(stdout, "error: open small failed!\n"); 4f0: a1 d4 62 00 00 mov 0x62d4,%eax 4f5: c7 44 24 04 84 46 00 movl $0x4684,0x4(%esp) 4fc: 00 4fd: 89 04 24 mov %eax,(%esp) 500: e8 40 3b 00 00 call 4045 <printf> exit(); 505: e8 ab 39 00 00 call 3eb5 <exit> } i = read(fd, buf, 2000); if(i == 2000){ printf(stdout, "read succeeded ok\n"); 50a: a1 d4 62 00 00 mov 0x62d4,%eax 50f: c7 44 24 04 9f 46 00 movl $0x469f,0x4(%esp) 516: 00 517: 89 04 24 mov %eax,(%esp) 51a: e8 26 3b 00 00 call 4045 <printf> } else { printf(stdout, "read failed\n"); exit(); } close(fd); 51f: 8b 45 f0 mov -0x10(%ebp),%eax 522: 89 04 24 mov %eax,(%esp) 525: e8 b3 39 00 00 call 3edd <close> if(unlink("small") < 0){ 52a: c7 04 24 c1 45 00 00 movl $0x45c1,(%esp) 531: e8 cf 39 00 00 call 3f05 <unlink> 536: 85 c0 test %eax,%eax 538: 79 36 jns 570 <writetest+0x1fe> 53a: eb 1a jmp 556 <writetest+0x1e4> } i = read(fd, buf, 2000); if(i == 2000){ printf(stdout, "read succeeded ok\n"); } else { printf(stdout, "read failed\n"); 53c: a1 d4 62 00 00 mov 0x62d4,%eax 541: c7 44 24 04 b2 46 00 movl $0x46b2,0x4(%esp) 548: 00 549: 89 04 24 mov %eax,(%esp) 54c: e8 f4 3a 00 00 call 4045 <printf> exit(); 551: e8 5f 39 00 00 call 3eb5 <exit> } close(fd); if(unlink("small") < 0){ printf(stdout, "unlink small failed\n"); 556: a1 d4 62 00 00 mov 0x62d4,%eax 55b: c7 44 24 04 bf 46 00 movl $0x46bf,0x4(%esp) 562: 00 563: 89 04 24 mov %eax,(%esp) 566: e8 da 3a 00 00 call 4045 <printf> exit(); 56b: e8 45 39 00 00 call 3eb5 <exit> } printf(stdout, "small file test ok\n"); 570: a1 d4 62 00 00 mov 0x62d4,%eax 575: c7 44 24 04 d4 46 00 movl $0x46d4,0x4(%esp) 57c: 00 57d: 89 04 24 mov %eax,(%esp) 580: e8 c0 3a 00 00 call 4045 <printf> } 585: c9 leave 586: c3 ret 00000587 <writetest1>: void writetest1(void) { 587: 55 push %ebp 588: 89 e5 mov %esp,%ebp 58a: 83 ec 28 sub $0x28,%esp int i, fd, n; printf(stdout, "big files test\n"); 58d: a1 d4 62 00 00 mov 0x62d4,%eax 592: c7 44 24 04 e8 46 00 movl $0x46e8,0x4(%esp) 599: 00 59a: 89 04 24 mov %eax,(%esp) 59d: e8 a3 3a 00 00 call 4045 <printf> fd = open("big", O_CREATE|O_RDWR); 5a2: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 5a9: 00 5aa: c7 04 24 f8 46 00 00 movl $0x46f8,(%esp) 5b1: e8 3f 39 00 00 call 3ef5 <open> 5b6: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 5b9: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 5bd: 79 1a jns 5d9 <writetest1+0x52> printf(stdout, "error: creat big failed!\n"); 5bf: a1 d4 62 00 00 mov 0x62d4,%eax 5c4: c7 44 24 04 fc 46 00 movl $0x46fc,0x4(%esp) 5cb: 00 5cc: 89 04 24 mov %eax,(%esp) 5cf: e8 71 3a 00 00 call 4045 <printf> exit(); 5d4: e8 dc 38 00 00 call 3eb5 <exit> } for(i = 0; i < MAXFILE; i++){ 5d9: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 5e0: eb 51 jmp 633 <writetest1+0xac> ((int*)buf)[0] = i; 5e2: b8 c0 8a 00 00 mov $0x8ac0,%eax 5e7: 8b 55 f4 mov -0xc(%ebp),%edx 5ea: 89 10 mov %edx,(%eax) if(write(fd, buf, 512) != 512){ 5ec: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 5f3: 00 5f4: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 5fb: 00 5fc: 8b 45 ec mov -0x14(%ebp),%eax 5ff: 89 04 24 mov %eax,(%esp) 602: e8 ce 38 00 00 call 3ed5 <write> 607: 3d 00 02 00 00 cmp $0x200,%eax 60c: 74 21 je 62f <writetest1+0xa8> printf(stdout, "error: write big file failed\n", i); 60e: a1 d4 62 00 00 mov 0x62d4,%eax 613: 8b 55 f4 mov -0xc(%ebp),%edx 616: 89 54 24 08 mov %edx,0x8(%esp) 61a: c7 44 24 04 16 47 00 movl $0x4716,0x4(%esp) 621: 00 622: 89 04 24 mov %eax,(%esp) 625: e8 1b 3a 00 00 call 4045 <printf> exit(); 62a: e8 86 38 00 00 call 3eb5 <exit> if(fd < 0){ printf(stdout, "error: creat big failed!\n"); exit(); } for(i = 0; i < MAXFILE; i++){ 62f: 83 45 f4 01 addl $0x1,-0xc(%ebp) 633: 8b 45 f4 mov -0xc(%ebp),%eax 636: 3d 8b 00 00 00 cmp $0x8b,%eax 63b: 76 a5 jbe 5e2 <writetest1+0x5b> printf(stdout, "error: write big file failed\n", i); exit(); } } close(fd); 63d: 8b 45 ec mov -0x14(%ebp),%eax 640: 89 04 24 mov %eax,(%esp) 643: e8 95 38 00 00 call 3edd <close> fd = open("big", O_RDONLY); 648: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 64f: 00 650: c7 04 24 f8 46 00 00 movl $0x46f8,(%esp) 657: e8 99 38 00 00 call 3ef5 <open> 65c: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 65f: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 663: 79 1a jns 67f <writetest1+0xf8> printf(stdout, "error: open big failed!\n"); 665: a1 d4 62 00 00 mov 0x62d4,%eax 66a: c7 44 24 04 34 47 00 movl $0x4734,0x4(%esp) 671: 00 672: 89 04 24 mov %eax,(%esp) 675: e8 cb 39 00 00 call 4045 <printf> exit(); 67a: e8 36 38 00 00 call 3eb5 <exit> } n = 0; 67f: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) for(;;){ i = read(fd, buf, 512); 686: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 68d: 00 68e: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 695: 00 696: 8b 45 ec mov -0x14(%ebp),%eax 699: 89 04 24 mov %eax,(%esp) 69c: e8 2c 38 00 00 call 3ecd <read> 6a1: 89 45 f4 mov %eax,-0xc(%ebp) if(i == 0){ 6a4: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 6a8: 75 4c jne 6f6 <writetest1+0x16f> if(n == MAXFILE - 1){ 6aa: 81 7d f0 8b 00 00 00 cmpl $0x8b,-0x10(%ebp) 6b1: 75 21 jne 6d4 <writetest1+0x14d> printf(stdout, "read only %d blocks from big", n); 6b3: a1 d4 62 00 00 mov 0x62d4,%eax 6b8: 8b 55 f0 mov -0x10(%ebp),%edx 6bb: 89 54 24 08 mov %edx,0x8(%esp) 6bf: c7 44 24 04 4d 47 00 movl $0x474d,0x4(%esp) 6c6: 00 6c7: 89 04 24 mov %eax,(%esp) 6ca: e8 76 39 00 00 call 4045 <printf> exit(); 6cf: e8 e1 37 00 00 call 3eb5 <exit> } break; 6d4: 90 nop n, ((int*)buf)[0]); exit(); } n++; } close(fd); 6d5: 8b 45 ec mov -0x14(%ebp),%eax 6d8: 89 04 24 mov %eax,(%esp) 6db: e8 fd 37 00 00 call 3edd <close> if(unlink("big") < 0){ 6e0: c7 04 24 f8 46 00 00 movl $0x46f8,(%esp) 6e7: e8 19 38 00 00 call 3f05 <unlink> 6ec: 85 c0 test %eax,%eax 6ee: 0f 89 87 00 00 00 jns 77b <writetest1+0x1f4> 6f4: eb 6b jmp 761 <writetest1+0x1da> if(n == MAXFILE - 1){ printf(stdout, "read only %d blocks from big", n); exit(); } break; } else if(i != 512){ 6f6: 81 7d f4 00 02 00 00 cmpl $0x200,-0xc(%ebp) 6fd: 74 21 je 720 <writetest1+0x199> printf(stdout, "read failed %d\n", i); 6ff: a1 d4 62 00 00 mov 0x62d4,%eax 704: 8b 55 f4 mov -0xc(%ebp),%edx 707: 89 54 24 08 mov %edx,0x8(%esp) 70b: c7 44 24 04 6a 47 00 movl $0x476a,0x4(%esp) 712: 00 713: 89 04 24 mov %eax,(%esp) 716: e8 2a 39 00 00 call 4045 <printf> exit(); 71b: e8 95 37 00 00 call 3eb5 <exit> } if(((int*)buf)[0] != n){ 720: b8 c0 8a 00 00 mov $0x8ac0,%eax 725: 8b 00 mov (%eax),%eax 727: 3b 45 f0 cmp -0x10(%ebp),%eax 72a: 74 2c je 758 <writetest1+0x1d1> printf(stdout, "read content of block %d is %d\n", n, ((int*)buf)[0]); 72c: b8 c0 8a 00 00 mov $0x8ac0,%eax } else if(i != 512){ printf(stdout, "read failed %d\n", i); exit(); } if(((int*)buf)[0] != n){ printf(stdout, "read content of block %d is %d\n", 731: 8b 10 mov (%eax),%edx 733: a1 d4 62 00 00 mov 0x62d4,%eax 738: 89 54 24 0c mov %edx,0xc(%esp) 73c: 8b 55 f0 mov -0x10(%ebp),%edx 73f: 89 54 24 08 mov %edx,0x8(%esp) 743: c7 44 24 04 7c 47 00 movl $0x477c,0x4(%esp) 74a: 00 74b: 89 04 24 mov %eax,(%esp) 74e: e8 f2 38 00 00 call 4045 <printf> n, ((int*)buf)[0]); exit(); 753: e8 5d 37 00 00 call 3eb5 <exit> } n++; 758: 83 45 f0 01 addl $0x1,-0x10(%ebp) } 75c: e9 25 ff ff ff jmp 686 <writetest1+0xff> close(fd); if(unlink("big") < 0){ printf(stdout, "unlink big failed\n"); 761: a1 d4 62 00 00 mov 0x62d4,%eax 766: c7 44 24 04 9c 47 00 movl $0x479c,0x4(%esp) 76d: 00 76e: 89 04 24 mov %eax,(%esp) 771: e8 cf 38 00 00 call 4045 <printf> exit(); 776: e8 3a 37 00 00 call 3eb5 <exit> } printf(stdout, "big files ok\n"); 77b: a1 d4 62 00 00 mov 0x62d4,%eax 780: c7 44 24 04 af 47 00 movl $0x47af,0x4(%esp) 787: 00 788: 89 04 24 mov %eax,(%esp) 78b: e8 b5 38 00 00 call 4045 <printf> } 790: c9 leave 791: c3 ret 00000792 <createtest>: void createtest(void) { 792: 55 push %ebp 793: 89 e5 mov %esp,%ebp 795: 83 ec 28 sub $0x28,%esp int i, fd; printf(stdout, "many creates, followed by unlink test\n"); 798: a1 d4 62 00 00 mov 0x62d4,%eax 79d: c7 44 24 04 c0 47 00 movl $0x47c0,0x4(%esp) 7a4: 00 7a5: 89 04 24 mov %eax,(%esp) 7a8: e8 98 38 00 00 call 4045 <printf> name[0] = 'a'; 7ad: c6 05 c0 aa 00 00 61 movb $0x61,0xaac0 name[2] = '\0'; 7b4: c6 05 c2 aa 00 00 00 movb $0x0,0xaac2 for(i = 0; i < 52; i++){ 7bb: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 7c2: eb 31 jmp 7f5 <createtest+0x63> name[1] = '0' + i; 7c4: 8b 45 f4 mov -0xc(%ebp),%eax 7c7: 83 c0 30 add $0x30,%eax 7ca: a2 c1 aa 00 00 mov %al,0xaac1 fd = open(name, O_CREATE|O_RDWR); 7cf: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 7d6: 00 7d7: c7 04 24 c0 aa 00 00 movl $0xaac0,(%esp) 7de: e8 12 37 00 00 call 3ef5 <open> 7e3: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 7e6: 8b 45 f0 mov -0x10(%ebp),%eax 7e9: 89 04 24 mov %eax,(%esp) 7ec: e8 ec 36 00 00 call 3edd <close> printf(stdout, "many creates, followed by unlink test\n"); name[0] = 'a'; name[2] = '\0'; for(i = 0; i < 52; i++){ 7f1: 83 45 f4 01 addl $0x1,-0xc(%ebp) 7f5: 83 7d f4 33 cmpl $0x33,-0xc(%ebp) 7f9: 7e c9 jle 7c4 <createtest+0x32> name[1] = '0' + i; fd = open(name, O_CREATE|O_RDWR); close(fd); } name[0] = 'a'; 7fb: c6 05 c0 aa 00 00 61 movb $0x61,0xaac0 name[2] = '\0'; 802: c6 05 c2 aa 00 00 00 movb $0x0,0xaac2 for(i = 0; i < 52; i++){ 809: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 810: eb 1b jmp 82d <createtest+0x9b> name[1] = '0' + i; 812: 8b 45 f4 mov -0xc(%ebp),%eax 815: 83 c0 30 add $0x30,%eax 818: a2 c1 aa 00 00 mov %al,0xaac1 unlink(name); 81d: c7 04 24 c0 aa 00 00 movl $0xaac0,(%esp) 824: e8 dc 36 00 00 call 3f05 <unlink> fd = open(name, O_CREATE|O_RDWR); close(fd); } name[0] = 'a'; name[2] = '\0'; for(i = 0; i < 52; i++){ 829: 83 45 f4 01 addl $0x1,-0xc(%ebp) 82d: 83 7d f4 33 cmpl $0x33,-0xc(%ebp) 831: 7e df jle 812 <createtest+0x80> name[1] = '0' + i; unlink(name); } printf(stdout, "many creates, followed by unlink; ok\n"); 833: a1 d4 62 00 00 mov 0x62d4,%eax 838: c7 44 24 04 e8 47 00 movl $0x47e8,0x4(%esp) 83f: 00 840: 89 04 24 mov %eax,(%esp) 843: e8 fd 37 00 00 call 4045 <printf> } 848: c9 leave 849: c3 ret 0000084a <dirtest>: void dirtest(void) { 84a: 55 push %ebp 84b: 89 e5 mov %esp,%ebp 84d: 83 ec 18 sub $0x18,%esp printf(stdout, "mkdir test\n"); 850: a1 d4 62 00 00 mov 0x62d4,%eax 855: c7 44 24 04 0e 48 00 movl $0x480e,0x4(%esp) 85c: 00 85d: 89 04 24 mov %eax,(%esp) 860: e8 e0 37 00 00 call 4045 <printf> if(mkdir("dir0") < 0){ 865: c7 04 24 1a 48 00 00 movl $0x481a,(%esp) 86c: e8 ac 36 00 00 call 3f1d <mkdir> 871: 85 c0 test %eax,%eax 873: 79 1a jns 88f <dirtest+0x45> printf(stdout, "mkdir failed\n"); 875: a1 d4 62 00 00 mov 0x62d4,%eax 87a: c7 44 24 04 3d 44 00 movl $0x443d,0x4(%esp) 881: 00 882: 89 04 24 mov %eax,(%esp) 885: e8 bb 37 00 00 call 4045 <printf> exit(); 88a: e8 26 36 00 00 call 3eb5 <exit> } if(chdir("dir0") < 0){ 88f: c7 04 24 1a 48 00 00 movl $0x481a,(%esp) 896: e8 8a 36 00 00 call 3f25 <chdir> 89b: 85 c0 test %eax,%eax 89d: 79 1a jns 8b9 <dirtest+0x6f> printf(stdout, "chdir dir0 failed\n"); 89f: a1 d4 62 00 00 mov 0x62d4,%eax 8a4: c7 44 24 04 1f 48 00 movl $0x481f,0x4(%esp) 8ab: 00 8ac: 89 04 24 mov %eax,(%esp) 8af: e8 91 37 00 00 call 4045 <printf> exit(); 8b4: e8 fc 35 00 00 call 3eb5 <exit> } if(chdir("..") < 0){ 8b9: c7 04 24 32 48 00 00 movl $0x4832,(%esp) 8c0: e8 60 36 00 00 call 3f25 <chdir> 8c5: 85 c0 test %eax,%eax 8c7: 79 1a jns 8e3 <dirtest+0x99> printf(stdout, "chdir .. failed\n"); 8c9: a1 d4 62 00 00 mov 0x62d4,%eax 8ce: c7 44 24 04 35 48 00 movl $0x4835,0x4(%esp) 8d5: 00 8d6: 89 04 24 mov %eax,(%esp) 8d9: e8 67 37 00 00 call 4045 <printf> exit(); 8de: e8 d2 35 00 00 call 3eb5 <exit> } if(unlink("dir0") < 0){ 8e3: c7 04 24 1a 48 00 00 movl $0x481a,(%esp) 8ea: e8 16 36 00 00 call 3f05 <unlink> 8ef: 85 c0 test %eax,%eax 8f1: 79 1a jns 90d <dirtest+0xc3> printf(stdout, "unlink dir0 failed\n"); 8f3: a1 d4 62 00 00 mov 0x62d4,%eax 8f8: c7 44 24 04 46 48 00 movl $0x4846,0x4(%esp) 8ff: 00 900: 89 04 24 mov %eax,(%esp) 903: e8 3d 37 00 00 call 4045 <printf> exit(); 908: e8 a8 35 00 00 call 3eb5 <exit> } printf(stdout, "mkdir test ok\n"); 90d: a1 d4 62 00 00 mov 0x62d4,%eax 912: c7 44 24 04 5a 48 00 movl $0x485a,0x4(%esp) 919: 00 91a: 89 04 24 mov %eax,(%esp) 91d: e8 23 37 00 00 call 4045 <printf> } 922: c9 leave 923: c3 ret 00000924 <exectest>: void exectest(void) { 924: 55 push %ebp 925: 89 e5 mov %esp,%ebp 927: 83 ec 18 sub $0x18,%esp printf(stdout, "exec test\n"); 92a: a1 d4 62 00 00 mov 0x62d4,%eax 92f: c7 44 24 04 69 48 00 movl $0x4869,0x4(%esp) 936: 00 937: 89 04 24 mov %eax,(%esp) 93a: e8 06 37 00 00 call 4045 <printf> if(exec("echo", echoargv) < 0){ 93f: c7 44 24 04 c0 62 00 movl $0x62c0,0x4(%esp) 946: 00 947: c7 04 24 14 44 00 00 movl $0x4414,(%esp) 94e: e8 9a 35 00 00 call 3eed <exec> 953: 85 c0 test %eax,%eax 955: 79 1a jns 971 <exectest+0x4d> printf(stdout, "exec echo failed\n"); 957: a1 d4 62 00 00 mov 0x62d4,%eax 95c: c7 44 24 04 74 48 00 movl $0x4874,0x4(%esp) 963: 00 964: 89 04 24 mov %eax,(%esp) 967: e8 d9 36 00 00 call 4045 <printf> exit(); 96c: e8 44 35 00 00 call 3eb5 <exit> } } 971: c9 leave 972: c3 ret 00000973 <pipe1>: // simple fork and pipe read/write void pipe1(void) { 973: 55 push %ebp 974: 89 e5 mov %esp,%ebp 976: 83 ec 38 sub $0x38,%esp int fds[2], pid; int seq, i, n, cc, total; if(pipe(fds) != 0){ 979: 8d 45 d8 lea -0x28(%ebp),%eax 97c: 89 04 24 mov %eax,(%esp) 97f: e8 41 35 00 00 call 3ec5 <pipe> 984: 85 c0 test %eax,%eax 986: 74 19 je 9a1 <pipe1+0x2e> printf(1, "pipe() failed\n"); 988: c7 44 24 04 86 48 00 movl $0x4886,0x4(%esp) 98f: 00 990: c7 04 24 01 00 00 00 movl $0x1,(%esp) 997: e8 a9 36 00 00 call 4045 <printf> exit(); 99c: e8 14 35 00 00 call 3eb5 <exit> } pid = fork(); 9a1: e8 07 35 00 00 call 3ead <fork> 9a6: 89 45 e0 mov %eax,-0x20(%ebp) seq = 0; 9a9: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) if(pid == 0){ 9b0: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) 9b4: 0f 85 88 00 00 00 jne a42 <pipe1+0xcf> close(fds[0]); 9ba: 8b 45 d8 mov -0x28(%ebp),%eax 9bd: 89 04 24 mov %eax,(%esp) 9c0: e8 18 35 00 00 call 3edd <close> for(n = 0; n < 5; n++){ 9c5: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) 9cc: eb 69 jmp a37 <pipe1+0xc4> for(i = 0; i < 1033; i++) 9ce: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 9d5: eb 18 jmp 9ef <pipe1+0x7c> buf[i] = seq++; 9d7: 8b 45 f4 mov -0xc(%ebp),%eax 9da: 8d 50 01 lea 0x1(%eax),%edx 9dd: 89 55 f4 mov %edx,-0xc(%ebp) 9e0: 8b 55 f0 mov -0x10(%ebp),%edx 9e3: 81 c2 c0 8a 00 00 add $0x8ac0,%edx 9e9: 88 02 mov %al,(%edx) pid = fork(); seq = 0; if(pid == 0){ close(fds[0]); for(n = 0; n < 5; n++){ for(i = 0; i < 1033; i++) 9eb: 83 45 f0 01 addl $0x1,-0x10(%ebp) 9ef: 81 7d f0 08 04 00 00 cmpl $0x408,-0x10(%ebp) 9f6: 7e df jle 9d7 <pipe1+0x64> buf[i] = seq++; if(write(fds[1], buf, 1033) != 1033){ 9f8: 8b 45 dc mov -0x24(%ebp),%eax 9fb: c7 44 24 08 09 04 00 movl $0x409,0x8(%esp) a02: 00 a03: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) a0a: 00 a0b: 89 04 24 mov %eax,(%esp) a0e: e8 c2 34 00 00 call 3ed5 <write> a13: 3d 09 04 00 00 cmp $0x409,%eax a18: 74 19 je a33 <pipe1+0xc0> printf(1, "pipe1 oops 1\n"); a1a: c7 44 24 04 95 48 00 movl $0x4895,0x4(%esp) a21: 00 a22: c7 04 24 01 00 00 00 movl $0x1,(%esp) a29: e8 17 36 00 00 call 4045 <printf> exit(); a2e: e8 82 34 00 00 call 3eb5 <exit> } pid = fork(); seq = 0; if(pid == 0){ close(fds[0]); for(n = 0; n < 5; n++){ a33: 83 45 ec 01 addl $0x1,-0x14(%ebp) a37: 83 7d ec 04 cmpl $0x4,-0x14(%ebp) a3b: 7e 91 jle 9ce <pipe1+0x5b> if(write(fds[1], buf, 1033) != 1033){ printf(1, "pipe1 oops 1\n"); exit(); } } exit(); a3d: e8 73 34 00 00 call 3eb5 <exit> } else if(pid > 0){ a42: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) a46: 0f 8e f9 00 00 00 jle b45 <pipe1+0x1d2> close(fds[1]); a4c: 8b 45 dc mov -0x24(%ebp),%eax a4f: 89 04 24 mov %eax,(%esp) a52: e8 86 34 00 00 call 3edd <close> total = 0; a57: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) cc = 1; a5e: c7 45 e8 01 00 00 00 movl $0x1,-0x18(%ebp) while((n = read(fds[0], buf, cc)) > 0){ a65: eb 68 jmp acf <pipe1+0x15c> for(i = 0; i < n; i++){ a67: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) a6e: eb 3d jmp aad <pipe1+0x13a> if((buf[i] & 0xff) != (seq++ & 0xff)){ a70: 8b 45 f0 mov -0x10(%ebp),%eax a73: 05 c0 8a 00 00 add $0x8ac0,%eax a78: 0f b6 00 movzbl (%eax),%eax a7b: 0f be c8 movsbl %al,%ecx a7e: 8b 45 f4 mov -0xc(%ebp),%eax a81: 8d 50 01 lea 0x1(%eax),%edx a84: 89 55 f4 mov %edx,-0xc(%ebp) a87: 31 c8 xor %ecx,%eax a89: 0f b6 c0 movzbl %al,%eax a8c: 85 c0 test %eax,%eax a8e: 74 19 je aa9 <pipe1+0x136> printf(1, "pipe1 oops 2\n"); a90: c7 44 24 04 a3 48 00 movl $0x48a3,0x4(%esp) a97: 00 a98: c7 04 24 01 00 00 00 movl $0x1,(%esp) a9f: e8 a1 35 00 00 call 4045 <printf> aa4: e9 b5 00 00 00 jmp b5e <pipe1+0x1eb> } else if(pid > 0){ close(fds[1]); total = 0; cc = 1; while((n = read(fds[0], buf, cc)) > 0){ for(i = 0; i < n; i++){ aa9: 83 45 f0 01 addl $0x1,-0x10(%ebp) aad: 8b 45 f0 mov -0x10(%ebp),%eax ab0: 3b 45 ec cmp -0x14(%ebp),%eax ab3: 7c bb jl a70 <pipe1+0xfd> if((buf[i] & 0xff) != (seq++ & 0xff)){ printf(1, "pipe1 oops 2\n"); return; } } total += n; ab5: 8b 45 ec mov -0x14(%ebp),%eax ab8: 01 45 e4 add %eax,-0x1c(%ebp) cc = cc * 2; abb: d1 65 e8 shll -0x18(%ebp) if(cc > sizeof(buf)) abe: 8b 45 e8 mov -0x18(%ebp),%eax ac1: 3d 00 20 00 00 cmp $0x2000,%eax ac6: 76 07 jbe acf <pipe1+0x15c> cc = sizeof(buf); ac8: c7 45 e8 00 20 00 00 movl $0x2000,-0x18(%ebp) exit(); } else if(pid > 0){ close(fds[1]); total = 0; cc = 1; while((n = read(fds[0], buf, cc)) > 0){ acf: 8b 45 d8 mov -0x28(%ebp),%eax ad2: 8b 55 e8 mov -0x18(%ebp),%edx ad5: 89 54 24 08 mov %edx,0x8(%esp) ad9: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) ae0: 00 ae1: 89 04 24 mov %eax,(%esp) ae4: e8 e4 33 00 00 call 3ecd <read> ae9: 89 45 ec mov %eax,-0x14(%ebp) aec: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) af0: 0f 8f 71 ff ff ff jg a67 <pipe1+0xf4> total += n; cc = cc * 2; if(cc > sizeof(buf)) cc = sizeof(buf); } if(total != 5 * 1033){ af6: 81 7d e4 2d 14 00 00 cmpl $0x142d,-0x1c(%ebp) afd: 74 20 je b1f <pipe1+0x1ac> printf(1, "pipe1 oops 3 total %d\n", total); aff: 8b 45 e4 mov -0x1c(%ebp),%eax b02: 89 44 24 08 mov %eax,0x8(%esp) b06: c7 44 24 04 b1 48 00 movl $0x48b1,0x4(%esp) b0d: 00 b0e: c7 04 24 01 00 00 00 movl $0x1,(%esp) b15: e8 2b 35 00 00 call 4045 <printf> exit(); b1a: e8 96 33 00 00 call 3eb5 <exit> } close(fds[0]); b1f: 8b 45 d8 mov -0x28(%ebp),%eax b22: 89 04 24 mov %eax,(%esp) b25: e8 b3 33 00 00 call 3edd <close> wait(); b2a: e8 8e 33 00 00 call 3ebd <wait> } else { printf(1, "fork() failed\n"); exit(); } printf(1, "pipe1 ok\n"); b2f: c7 44 24 04 d7 48 00 movl $0x48d7,0x4(%esp) b36: 00 b37: c7 04 24 01 00 00 00 movl $0x1,(%esp) b3e: e8 02 35 00 00 call 4045 <printf> b43: eb 19 jmp b5e <pipe1+0x1eb> exit(); } close(fds[0]); wait(); } else { printf(1, "fork() failed\n"); b45: c7 44 24 04 c8 48 00 movl $0x48c8,0x4(%esp) b4c: 00 b4d: c7 04 24 01 00 00 00 movl $0x1,(%esp) b54: e8 ec 34 00 00 call 4045 <printf> exit(); b59: e8 57 33 00 00 call 3eb5 <exit> } printf(1, "pipe1 ok\n"); } b5e: c9 leave b5f: c3 ret 00000b60 <preempt>: // meant to be run w/ at most two CPUs void preempt(void) { b60: 55 push %ebp b61: 89 e5 mov %esp,%ebp b63: 83 ec 38 sub $0x38,%esp int pid1, pid2, pid3; int pfds[2]; printf(1, "preempt: "); b66: c7 44 24 04 e1 48 00 movl $0x48e1,0x4(%esp) b6d: 00 b6e: c7 04 24 01 00 00 00 movl $0x1,(%esp) b75: e8 cb 34 00 00 call 4045 <printf> pid1 = fork(); b7a: e8 2e 33 00 00 call 3ead <fork> b7f: 89 45 f4 mov %eax,-0xc(%ebp) if(pid1 == 0) b82: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) b86: 75 02 jne b8a <preempt+0x2a> for(;;) ; b88: eb fe jmp b88 <preempt+0x28> pid2 = fork(); b8a: e8 1e 33 00 00 call 3ead <fork> b8f: 89 45 f0 mov %eax,-0x10(%ebp) if(pid2 == 0) b92: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) b96: 75 02 jne b9a <preempt+0x3a> for(;;) ; b98: eb fe jmp b98 <preempt+0x38> pipe(pfds); b9a: 8d 45 e4 lea -0x1c(%ebp),%eax b9d: 89 04 24 mov %eax,(%esp) ba0: e8 20 33 00 00 call 3ec5 <pipe> pid3 = fork(); ba5: e8 03 33 00 00 call 3ead <fork> baa: 89 45 ec mov %eax,-0x14(%ebp) if(pid3 == 0){ bad: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) bb1: 75 4c jne bff <preempt+0x9f> close(pfds[0]); bb3: 8b 45 e4 mov -0x1c(%ebp),%eax bb6: 89 04 24 mov %eax,(%esp) bb9: e8 1f 33 00 00 call 3edd <close> if(write(pfds[1], "x", 1) != 1) bbe: 8b 45 e8 mov -0x18(%ebp),%eax bc1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) bc8: 00 bc9: c7 44 24 04 eb 48 00 movl $0x48eb,0x4(%esp) bd0: 00 bd1: 89 04 24 mov %eax,(%esp) bd4: e8 fc 32 00 00 call 3ed5 <write> bd9: 83 f8 01 cmp $0x1,%eax bdc: 74 14 je bf2 <preempt+0x92> printf(1, "preempt write error"); bde: c7 44 24 04 ed 48 00 movl $0x48ed,0x4(%esp) be5: 00 be6: c7 04 24 01 00 00 00 movl $0x1,(%esp) bed: e8 53 34 00 00 call 4045 <printf> close(pfds[1]); bf2: 8b 45 e8 mov -0x18(%ebp),%eax bf5: 89 04 24 mov %eax,(%esp) bf8: e8 e0 32 00 00 call 3edd <close> for(;;) ; bfd: eb fe jmp bfd <preempt+0x9d> } close(pfds[1]); bff: 8b 45 e8 mov -0x18(%ebp),%eax c02: 89 04 24 mov %eax,(%esp) c05: e8 d3 32 00 00 call 3edd <close> if(read(pfds[0], buf, sizeof(buf)) != 1){ c0a: 8b 45 e4 mov -0x1c(%ebp),%eax c0d: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) c14: 00 c15: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) c1c: 00 c1d: 89 04 24 mov %eax,(%esp) c20: e8 a8 32 00 00 call 3ecd <read> c25: 83 f8 01 cmp $0x1,%eax c28: 74 16 je c40 <preempt+0xe0> printf(1, "preempt read error"); c2a: c7 44 24 04 01 49 00 movl $0x4901,0x4(%esp) c31: 00 c32: c7 04 24 01 00 00 00 movl $0x1,(%esp) c39: e8 07 34 00 00 call 4045 <printf> c3e: eb 77 jmp cb7 <preempt+0x157> return; } close(pfds[0]); c40: 8b 45 e4 mov -0x1c(%ebp),%eax c43: 89 04 24 mov %eax,(%esp) c46: e8 92 32 00 00 call 3edd <close> printf(1, "kill... "); c4b: c7 44 24 04 14 49 00 movl $0x4914,0x4(%esp) c52: 00 c53: c7 04 24 01 00 00 00 movl $0x1,(%esp) c5a: e8 e6 33 00 00 call 4045 <printf> kill(pid1); c5f: 8b 45 f4 mov -0xc(%ebp),%eax c62: 89 04 24 mov %eax,(%esp) c65: e8 7b 32 00 00 call 3ee5 <kill> kill(pid2); c6a: 8b 45 f0 mov -0x10(%ebp),%eax c6d: 89 04 24 mov %eax,(%esp) c70: e8 70 32 00 00 call 3ee5 <kill> kill(pid3); c75: 8b 45 ec mov -0x14(%ebp),%eax c78: 89 04 24 mov %eax,(%esp) c7b: e8 65 32 00 00 call 3ee5 <kill> printf(1, "wait... "); c80: c7 44 24 04 1d 49 00 movl $0x491d,0x4(%esp) c87: 00 c88: c7 04 24 01 00 00 00 movl $0x1,(%esp) c8f: e8 b1 33 00 00 call 4045 <printf> wait(); c94: e8 24 32 00 00 call 3ebd <wait> wait(); c99: e8 1f 32 00 00 call 3ebd <wait> wait(); c9e: e8 1a 32 00 00 call 3ebd <wait> printf(1, "preempt ok\n"); ca3: c7 44 24 04 26 49 00 movl $0x4926,0x4(%esp) caa: 00 cab: c7 04 24 01 00 00 00 movl $0x1,(%esp) cb2: e8 8e 33 00 00 call 4045 <printf> } cb7: c9 leave cb8: c3 ret 00000cb9 <exitwait>: // try to find any races between exit and wait void exitwait(void) { cb9: 55 push %ebp cba: 89 e5 mov %esp,%ebp cbc: 83 ec 28 sub $0x28,%esp int i, pid; for(i = 0; i < 100; i++){ cbf: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) cc6: eb 53 jmp d1b <exitwait+0x62> pid = fork(); cc8: e8 e0 31 00 00 call 3ead <fork> ccd: 89 45 f0 mov %eax,-0x10(%ebp) if(pid < 0){ cd0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) cd4: 79 16 jns cec <exitwait+0x33> printf(1, "fork failed\n"); cd6: c7 44 24 04 b5 44 00 movl $0x44b5,0x4(%esp) cdd: 00 cde: c7 04 24 01 00 00 00 movl $0x1,(%esp) ce5: e8 5b 33 00 00 call 4045 <printf> return; cea: eb 49 jmp d35 <exitwait+0x7c> } if(pid){ cec: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) cf0: 74 20 je d12 <exitwait+0x59> if(wait() != pid){ cf2: e8 c6 31 00 00 call 3ebd <wait> cf7: 3b 45 f0 cmp -0x10(%ebp),%eax cfa: 74 1b je d17 <exitwait+0x5e> printf(1, "wait wrong pid\n"); cfc: c7 44 24 04 32 49 00 movl $0x4932,0x4(%esp) d03: 00 d04: c7 04 24 01 00 00 00 movl $0x1,(%esp) d0b: e8 35 33 00 00 call 4045 <printf> return; d10: eb 23 jmp d35 <exitwait+0x7c> } } else { exit(); d12: e8 9e 31 00 00 call 3eb5 <exit> void exitwait(void) { int i, pid; for(i = 0; i < 100; i++){ d17: 83 45 f4 01 addl $0x1,-0xc(%ebp) d1b: 83 7d f4 63 cmpl $0x63,-0xc(%ebp) d1f: 7e a7 jle cc8 <exitwait+0xf> } } else { exit(); } } printf(1, "exitwait ok\n"); d21: c7 44 24 04 42 49 00 movl $0x4942,0x4(%esp) d28: 00 d29: c7 04 24 01 00 00 00 movl $0x1,(%esp) d30: e8 10 33 00 00 call 4045 <printf> } d35: c9 leave d36: c3 ret 00000d37 <mem>: void mem(void) { d37: 55 push %ebp d38: 89 e5 mov %esp,%ebp d3a: 83 ec 28 sub $0x28,%esp void *m1, *m2; int pid, ppid; printf(1, "mem test\n"); d3d: c7 44 24 04 4f 49 00 movl $0x494f,0x4(%esp) d44: 00 d45: c7 04 24 01 00 00 00 movl $0x1,(%esp) d4c: e8 f4 32 00 00 call 4045 <printf> ppid = getpid(); d51: e8 df 31 00 00 call 3f35 <getpid> d56: 89 45 f0 mov %eax,-0x10(%ebp) if((pid = fork()) == 0){ d59: e8 4f 31 00 00 call 3ead <fork> d5e: 89 45 ec mov %eax,-0x14(%ebp) d61: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) d65: 0f 85 aa 00 00 00 jne e15 <mem+0xde> m1 = 0; d6b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) while((m2 = malloc(10001)) != 0){ d72: eb 0e jmp d82 <mem+0x4b> *(char**)m2 = m1; d74: 8b 45 e8 mov -0x18(%ebp),%eax d77: 8b 55 f4 mov -0xc(%ebp),%edx d7a: 89 10 mov %edx,(%eax) m1 = m2; d7c: 8b 45 e8 mov -0x18(%ebp),%eax d7f: 89 45 f4 mov %eax,-0xc(%ebp) printf(1, "mem test\n"); ppid = getpid(); if((pid = fork()) == 0){ m1 = 0; while((m2 = malloc(10001)) != 0){ d82: c7 04 24 11 27 00 00 movl $0x2711,(%esp) d89: e8 a3 35 00 00 call 4331 <malloc> d8e: 89 45 e8 mov %eax,-0x18(%ebp) d91: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) d95: 75 dd jne d74 <mem+0x3d> *(char**)m2 = m1; m1 = m2; } while(m1){ d97: eb 19 jmp db2 <mem+0x7b> m2 = *(char**)m1; d99: 8b 45 f4 mov -0xc(%ebp),%eax d9c: 8b 00 mov (%eax),%eax d9e: 89 45 e8 mov %eax,-0x18(%ebp) free(m1); da1: 8b 45 f4 mov -0xc(%ebp),%eax da4: 89 04 24 mov %eax,(%esp) da7: e8 4c 34 00 00 call 41f8 <free> m1 = m2; dac: 8b 45 e8 mov -0x18(%ebp),%eax daf: 89 45 f4 mov %eax,-0xc(%ebp) m1 = 0; while((m2 = malloc(10001)) != 0){ *(char**)m2 = m1; m1 = m2; } while(m1){ db2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) db6: 75 e1 jne d99 <mem+0x62> m2 = *(char**)m1; free(m1); m1 = m2; } m1 = malloc(1024*20); db8: c7 04 24 00 50 00 00 movl $0x5000,(%esp) dbf: e8 6d 35 00 00 call 4331 <malloc> dc4: 89 45 f4 mov %eax,-0xc(%ebp) if(m1 == 0){ dc7: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) dcb: 75 24 jne df1 <mem+0xba> printf(1, "couldn't allocate mem?!!\n"); dcd: c7 44 24 04 59 49 00 movl $0x4959,0x4(%esp) dd4: 00 dd5: c7 04 24 01 00 00 00 movl $0x1,(%esp) ddc: e8 64 32 00 00 call 4045 <printf> kill(ppid); de1: 8b 45 f0 mov -0x10(%ebp),%eax de4: 89 04 24 mov %eax,(%esp) de7: e8 f9 30 00 00 call 3ee5 <kill> exit(); dec: e8 c4 30 00 00 call 3eb5 <exit> } free(m1); df1: 8b 45 f4 mov -0xc(%ebp),%eax df4: 89 04 24 mov %eax,(%esp) df7: e8 fc 33 00 00 call 41f8 <free> printf(1, "mem ok\n"); dfc: c7 44 24 04 73 49 00 movl $0x4973,0x4(%esp) e03: 00 e04: c7 04 24 01 00 00 00 movl $0x1,(%esp) e0b: e8 35 32 00 00 call 4045 <printf> exit(); e10: e8 a0 30 00 00 call 3eb5 <exit> } else { wait(); e15: e8 a3 30 00 00 call 3ebd <wait> } } e1a: c9 leave e1b: c3 ret 00000e1c <sharedfd>: // two processes write to the same file descriptor // is the offset shared? does inode locking work? void sharedfd(void) { e1c: 55 push %ebp e1d: 89 e5 mov %esp,%ebp e1f: 83 ec 48 sub $0x48,%esp int fd, pid, i, n, nc, np; char buf[10]; printf(1, "sharedfd test\n"); e22: c7 44 24 04 7b 49 00 movl $0x497b,0x4(%esp) e29: 00 e2a: c7 04 24 01 00 00 00 movl $0x1,(%esp) e31: e8 0f 32 00 00 call 4045 <printf> unlink("sharedfd"); e36: c7 04 24 8a 49 00 00 movl $0x498a,(%esp) e3d: e8 c3 30 00 00 call 3f05 <unlink> fd = open("sharedfd", O_CREATE|O_RDWR); e42: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) e49: 00 e4a: c7 04 24 8a 49 00 00 movl $0x498a,(%esp) e51: e8 9f 30 00 00 call 3ef5 <open> e56: 89 45 e8 mov %eax,-0x18(%ebp) if(fd < 0){ e59: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) e5d: 79 19 jns e78 <sharedfd+0x5c> printf(1, "fstests: cannot open sharedfd for writing"); e5f: c7 44 24 04 94 49 00 movl $0x4994,0x4(%esp) e66: 00 e67: c7 04 24 01 00 00 00 movl $0x1,(%esp) e6e: e8 d2 31 00 00 call 4045 <printf> return; e73: e9 a0 01 00 00 jmp 1018 <sharedfd+0x1fc> } pid = fork(); e78: e8 30 30 00 00 call 3ead <fork> e7d: 89 45 e4 mov %eax,-0x1c(%ebp) memset(buf, pid==0?'c':'p', sizeof(buf)); e80: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) e84: 75 07 jne e8d <sharedfd+0x71> e86: b8 63 00 00 00 mov $0x63,%eax e8b: eb 05 jmp e92 <sharedfd+0x76> e8d: b8 70 00 00 00 mov $0x70,%eax e92: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) e99: 00 e9a: 89 44 24 04 mov %eax,0x4(%esp) e9e: 8d 45 d6 lea -0x2a(%ebp),%eax ea1: 89 04 24 mov %eax,(%esp) ea4: e8 5f 2e 00 00 call 3d08 <memset> for(i = 0; i < 1000; i++){ ea9: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) eb0: eb 39 jmp eeb <sharedfd+0xcf> if(write(fd, buf, sizeof(buf)) != sizeof(buf)){ eb2: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) eb9: 00 eba: 8d 45 d6 lea -0x2a(%ebp),%eax ebd: 89 44 24 04 mov %eax,0x4(%esp) ec1: 8b 45 e8 mov -0x18(%ebp),%eax ec4: 89 04 24 mov %eax,(%esp) ec7: e8 09 30 00 00 call 3ed5 <write> ecc: 83 f8 0a cmp $0xa,%eax ecf: 74 16 je ee7 <sharedfd+0xcb> printf(1, "fstests: write sharedfd failed\n"); ed1: c7 44 24 04 c0 49 00 movl $0x49c0,0x4(%esp) ed8: 00 ed9: c7 04 24 01 00 00 00 movl $0x1,(%esp) ee0: e8 60 31 00 00 call 4045 <printf> break; ee5: eb 0d jmp ef4 <sharedfd+0xd8> printf(1, "fstests: cannot open sharedfd for writing"); return; } pid = fork(); memset(buf, pid==0?'c':'p', sizeof(buf)); for(i = 0; i < 1000; i++){ ee7: 83 45 f4 01 addl $0x1,-0xc(%ebp) eeb: 81 7d f4 e7 03 00 00 cmpl $0x3e7,-0xc(%ebp) ef2: 7e be jle eb2 <sharedfd+0x96> if(write(fd, buf, sizeof(buf)) != sizeof(buf)){ printf(1, "fstests: write sharedfd failed\n"); break; } } if(pid == 0) ef4: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) ef8: 75 05 jne eff <sharedfd+0xe3> exit(); efa: e8 b6 2f 00 00 call 3eb5 <exit> else wait(); eff: e8 b9 2f 00 00 call 3ebd <wait> close(fd); f04: 8b 45 e8 mov -0x18(%ebp),%eax f07: 89 04 24 mov %eax,(%esp) f0a: e8 ce 2f 00 00 call 3edd <close> fd = open("sharedfd", 0); f0f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) f16: 00 f17: c7 04 24 8a 49 00 00 movl $0x498a,(%esp) f1e: e8 d2 2f 00 00 call 3ef5 <open> f23: 89 45 e8 mov %eax,-0x18(%ebp) if(fd < 0){ f26: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) f2a: 79 19 jns f45 <sharedfd+0x129> printf(1, "fstests: cannot open sharedfd for reading\n"); f2c: c7 44 24 04 e0 49 00 movl $0x49e0,0x4(%esp) f33: 00 f34: c7 04 24 01 00 00 00 movl $0x1,(%esp) f3b: e8 05 31 00 00 call 4045 <printf> return; f40: e9 d3 00 00 00 jmp 1018 <sharedfd+0x1fc> } nc = np = 0; f45: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) f4c: 8b 45 ec mov -0x14(%ebp),%eax f4f: 89 45 f0 mov %eax,-0x10(%ebp) while((n = read(fd, buf, sizeof(buf))) > 0){ f52: eb 3b jmp f8f <sharedfd+0x173> for(i = 0; i < sizeof(buf); i++){ f54: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) f5b: eb 2a jmp f87 <sharedfd+0x16b> if(buf[i] == 'c') f5d: 8d 55 d6 lea -0x2a(%ebp),%edx f60: 8b 45 f4 mov -0xc(%ebp),%eax f63: 01 d0 add %edx,%eax f65: 0f b6 00 movzbl (%eax),%eax f68: 3c 63 cmp $0x63,%al f6a: 75 04 jne f70 <sharedfd+0x154> nc++; f6c: 83 45 f0 01 addl $0x1,-0x10(%ebp) if(buf[i] == 'p') f70: 8d 55 d6 lea -0x2a(%ebp),%edx f73: 8b 45 f4 mov -0xc(%ebp),%eax f76: 01 d0 add %edx,%eax f78: 0f b6 00 movzbl (%eax),%eax f7b: 3c 70 cmp $0x70,%al f7d: 75 04 jne f83 <sharedfd+0x167> np++; f7f: 83 45 ec 01 addl $0x1,-0x14(%ebp) printf(1, "fstests: cannot open sharedfd for reading\n"); return; } nc = np = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i = 0; i < sizeof(buf); i++){ f83: 83 45 f4 01 addl $0x1,-0xc(%ebp) f87: 8b 45 f4 mov -0xc(%ebp),%eax f8a: 83 f8 09 cmp $0x9,%eax f8d: 76 ce jbe f5d <sharedfd+0x141> if(fd < 0){ printf(1, "fstests: cannot open sharedfd for reading\n"); return; } nc = np = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ f8f: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) f96: 00 f97: 8d 45 d6 lea -0x2a(%ebp),%eax f9a: 89 44 24 04 mov %eax,0x4(%esp) f9e: 8b 45 e8 mov -0x18(%ebp),%eax fa1: 89 04 24 mov %eax,(%esp) fa4: e8 24 2f 00 00 call 3ecd <read> fa9: 89 45 e0 mov %eax,-0x20(%ebp) fac: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) fb0: 7f a2 jg f54 <sharedfd+0x138> nc++; if(buf[i] == 'p') np++; } } close(fd); fb2: 8b 45 e8 mov -0x18(%ebp),%eax fb5: 89 04 24 mov %eax,(%esp) fb8: e8 20 2f 00 00 call 3edd <close> unlink("sharedfd"); fbd: c7 04 24 8a 49 00 00 movl $0x498a,(%esp) fc4: e8 3c 2f 00 00 call 3f05 <unlink> if(nc == 10000 && np == 10000){ fc9: 81 7d f0 10 27 00 00 cmpl $0x2710,-0x10(%ebp) fd0: 75 1f jne ff1 <sharedfd+0x1d5> fd2: 81 7d ec 10 27 00 00 cmpl $0x2710,-0x14(%ebp) fd9: 75 16 jne ff1 <sharedfd+0x1d5> printf(1, "sharedfd ok\n"); fdb: c7 44 24 04 0b 4a 00 movl $0x4a0b,0x4(%esp) fe2: 00 fe3: c7 04 24 01 00 00 00 movl $0x1,(%esp) fea: e8 56 30 00 00 call 4045 <printf> fef: eb 27 jmp 1018 <sharedfd+0x1fc> } else { printf(1, "sharedfd oops %d %d\n", nc, np); ff1: 8b 45 ec mov -0x14(%ebp),%eax ff4: 89 44 24 0c mov %eax,0xc(%esp) ff8: 8b 45 f0 mov -0x10(%ebp),%eax ffb: 89 44 24 08 mov %eax,0x8(%esp) fff: c7 44 24 04 18 4a 00 movl $0x4a18,0x4(%esp) 1006: 00 1007: c7 04 24 01 00 00 00 movl $0x1,(%esp) 100e: e8 32 30 00 00 call 4045 <printf> exit(); 1013: e8 9d 2e 00 00 call 3eb5 <exit> } } 1018: c9 leave 1019: c3 ret 0000101a <fourfiles>: // four processes write different files at the same // time, to test block allocation. void fourfiles(void) { 101a: 55 push %ebp 101b: 89 e5 mov %esp,%ebp 101d: 83 ec 48 sub $0x48,%esp int fd, pid, i, j, n, total, pi; char *names[] = { "f0", "f1", "f2", "f3" }; 1020: c7 45 c8 2d 4a 00 00 movl $0x4a2d,-0x38(%ebp) 1027: c7 45 cc 30 4a 00 00 movl $0x4a30,-0x34(%ebp) 102e: c7 45 d0 33 4a 00 00 movl $0x4a33,-0x30(%ebp) 1035: c7 45 d4 36 4a 00 00 movl $0x4a36,-0x2c(%ebp) char *fname; printf(1, "fourfiles test\n"); 103c: c7 44 24 04 39 4a 00 movl $0x4a39,0x4(%esp) 1043: 00 1044: c7 04 24 01 00 00 00 movl $0x1,(%esp) 104b: e8 f5 2f 00 00 call 4045 <printf> for(pi = 0; pi < 4; pi++){ 1050: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp) 1057: e9 fc 00 00 00 jmp 1158 <fourfiles+0x13e> fname = names[pi]; 105c: 8b 45 e8 mov -0x18(%ebp),%eax 105f: 8b 44 85 c8 mov -0x38(%ebp,%eax,4),%eax 1063: 89 45 e4 mov %eax,-0x1c(%ebp) unlink(fname); 1066: 8b 45 e4 mov -0x1c(%ebp),%eax 1069: 89 04 24 mov %eax,(%esp) 106c: e8 94 2e 00 00 call 3f05 <unlink> pid = fork(); 1071: e8 37 2e 00 00 call 3ead <fork> 1076: 89 45 e0 mov %eax,-0x20(%ebp) if(pid < 0){ 1079: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) 107d: 79 19 jns 1098 <fourfiles+0x7e> printf(1, "fork failed\n"); 107f: c7 44 24 04 b5 44 00 movl $0x44b5,0x4(%esp) 1086: 00 1087: c7 04 24 01 00 00 00 movl $0x1,(%esp) 108e: e8 b2 2f 00 00 call 4045 <printf> exit(); 1093: e8 1d 2e 00 00 call 3eb5 <exit> } if(pid == 0){ 1098: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) 109c: 0f 85 b2 00 00 00 jne 1154 <fourfiles+0x13a> fd = open(fname, O_CREATE | O_RDWR); 10a2: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 10a9: 00 10aa: 8b 45 e4 mov -0x1c(%ebp),%eax 10ad: 89 04 24 mov %eax,(%esp) 10b0: e8 40 2e 00 00 call 3ef5 <open> 10b5: 89 45 dc mov %eax,-0x24(%ebp) if(fd < 0){ 10b8: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) 10bc: 79 19 jns 10d7 <fourfiles+0xbd> printf(1, "create failed\n"); 10be: c7 44 24 04 49 4a 00 movl $0x4a49,0x4(%esp) 10c5: 00 10c6: c7 04 24 01 00 00 00 movl $0x1,(%esp) 10cd: e8 73 2f 00 00 call 4045 <printf> exit(); 10d2: e8 de 2d 00 00 call 3eb5 <exit> } memset(buf, '0'+pi, 512); 10d7: 8b 45 e8 mov -0x18(%ebp),%eax 10da: 83 c0 30 add $0x30,%eax 10dd: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 10e4: 00 10e5: 89 44 24 04 mov %eax,0x4(%esp) 10e9: c7 04 24 c0 8a 00 00 movl $0x8ac0,(%esp) 10f0: e8 13 2c 00 00 call 3d08 <memset> for(i = 0; i < 12; i++){ 10f5: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 10fc: eb 4b jmp 1149 <fourfiles+0x12f> if((n = write(fd, buf, 500)) != 500){ 10fe: c7 44 24 08 f4 01 00 movl $0x1f4,0x8(%esp) 1105: 00 1106: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 110d: 00 110e: 8b 45 dc mov -0x24(%ebp),%eax 1111: 89 04 24 mov %eax,(%esp) 1114: e8 bc 2d 00 00 call 3ed5 <write> 1119: 89 45 d8 mov %eax,-0x28(%ebp) 111c: 81 7d d8 f4 01 00 00 cmpl $0x1f4,-0x28(%ebp) 1123: 74 20 je 1145 <fourfiles+0x12b> printf(1, "write failed %d\n", n); 1125: 8b 45 d8 mov -0x28(%ebp),%eax 1128: 89 44 24 08 mov %eax,0x8(%esp) 112c: c7 44 24 04 58 4a 00 movl $0x4a58,0x4(%esp) 1133: 00 1134: c7 04 24 01 00 00 00 movl $0x1,(%esp) 113b: e8 05 2f 00 00 call 4045 <printf> exit(); 1140: e8 70 2d 00 00 call 3eb5 <exit> printf(1, "create failed\n"); exit(); } memset(buf, '0'+pi, 512); for(i = 0; i < 12; i++){ 1145: 83 45 f4 01 addl $0x1,-0xc(%ebp) 1149: 83 7d f4 0b cmpl $0xb,-0xc(%ebp) 114d: 7e af jle 10fe <fourfiles+0xe4> if((n = write(fd, buf, 500)) != 500){ printf(1, "write failed %d\n", n); exit(); } } exit(); 114f: e8 61 2d 00 00 call 3eb5 <exit> char *names[] = { "f0", "f1", "f2", "f3" }; char *fname; printf(1, "fourfiles test\n"); for(pi = 0; pi < 4; pi++){ 1154: 83 45 e8 01 addl $0x1,-0x18(%ebp) 1158: 83 7d e8 03 cmpl $0x3,-0x18(%ebp) 115c: 0f 8e fa fe ff ff jle 105c <fourfiles+0x42> } exit(); } } for(pi = 0; pi < 4; pi++){ 1162: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp) 1169: eb 09 jmp 1174 <fourfiles+0x15a> wait(); 116b: e8 4d 2d 00 00 call 3ebd <wait> } exit(); } } for(pi = 0; pi < 4; pi++){ 1170: 83 45 e8 01 addl $0x1,-0x18(%ebp) 1174: 83 7d e8 03 cmpl $0x3,-0x18(%ebp) 1178: 7e f1 jle 116b <fourfiles+0x151> wait(); } for(i = 0; i < 2; i++){ 117a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1181: e9 dc 00 00 00 jmp 1262 <fourfiles+0x248> fname = names[i]; 1186: 8b 45 f4 mov -0xc(%ebp),%eax 1189: 8b 44 85 c8 mov -0x38(%ebp,%eax,4),%eax 118d: 89 45 e4 mov %eax,-0x1c(%ebp) fd = open(fname, 0); 1190: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1197: 00 1198: 8b 45 e4 mov -0x1c(%ebp),%eax 119b: 89 04 24 mov %eax,(%esp) 119e: e8 52 2d 00 00 call 3ef5 <open> 11a3: 89 45 dc mov %eax,-0x24(%ebp) total = 0; 11a6: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) while((n = read(fd, buf, sizeof(buf))) > 0){ 11ad: eb 4c jmp 11fb <fourfiles+0x1e1> for(j = 0; j < n; j++){ 11af: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 11b6: eb 35 jmp 11ed <fourfiles+0x1d3> if(buf[j] != '0'+i){ 11b8: 8b 45 f0 mov -0x10(%ebp),%eax 11bb: 05 c0 8a 00 00 add $0x8ac0,%eax 11c0: 0f b6 00 movzbl (%eax),%eax 11c3: 0f be c0 movsbl %al,%eax 11c6: 8b 55 f4 mov -0xc(%ebp),%edx 11c9: 83 c2 30 add $0x30,%edx 11cc: 39 d0 cmp %edx,%eax 11ce: 74 19 je 11e9 <fourfiles+0x1cf> printf(1, "wrong char\n"); 11d0: c7 44 24 04 69 4a 00 movl $0x4a69,0x4(%esp) 11d7: 00 11d8: c7 04 24 01 00 00 00 movl $0x1,(%esp) 11df: e8 61 2e 00 00 call 4045 <printf> exit(); 11e4: e8 cc 2c 00 00 call 3eb5 <exit> for(i = 0; i < 2; i++){ fname = names[i]; fd = open(fname, 0); total = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(j = 0; j < n; j++){ 11e9: 83 45 f0 01 addl $0x1,-0x10(%ebp) 11ed: 8b 45 f0 mov -0x10(%ebp),%eax 11f0: 3b 45 d8 cmp -0x28(%ebp),%eax 11f3: 7c c3 jl 11b8 <fourfiles+0x19e> if(buf[j] != '0'+i){ printf(1, "wrong char\n"); exit(); } } total += n; 11f5: 8b 45 d8 mov -0x28(%ebp),%eax 11f8: 01 45 ec add %eax,-0x14(%ebp) for(i = 0; i < 2; i++){ fname = names[i]; fd = open(fname, 0); total = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ 11fb: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) 1202: 00 1203: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 120a: 00 120b: 8b 45 dc mov -0x24(%ebp),%eax 120e: 89 04 24 mov %eax,(%esp) 1211: e8 b7 2c 00 00 call 3ecd <read> 1216: 89 45 d8 mov %eax,-0x28(%ebp) 1219: 83 7d d8 00 cmpl $0x0,-0x28(%ebp) 121d: 7f 90 jg 11af <fourfiles+0x195> exit(); } } total += n; } close(fd); 121f: 8b 45 dc mov -0x24(%ebp),%eax 1222: 89 04 24 mov %eax,(%esp) 1225: e8 b3 2c 00 00 call 3edd <close> if(total != 12*500){ 122a: 81 7d ec 70 17 00 00 cmpl $0x1770,-0x14(%ebp) 1231: 74 20 je 1253 <fourfiles+0x239> printf(1, "wrong length %d\n", total); 1233: 8b 45 ec mov -0x14(%ebp),%eax 1236: 89 44 24 08 mov %eax,0x8(%esp) 123a: c7 44 24 04 75 4a 00 movl $0x4a75,0x4(%esp) 1241: 00 1242: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1249: e8 f7 2d 00 00 call 4045 <printf> exit(); 124e: e8 62 2c 00 00 call 3eb5 <exit> } unlink(fname); 1253: 8b 45 e4 mov -0x1c(%ebp),%eax 1256: 89 04 24 mov %eax,(%esp) 1259: e8 a7 2c 00 00 call 3f05 <unlink> for(pi = 0; pi < 4; pi++){ wait(); } for(i = 0; i < 2; i++){ 125e: 83 45 f4 01 addl $0x1,-0xc(%ebp) 1262: 83 7d f4 01 cmpl $0x1,-0xc(%ebp) 1266: 0f 8e 1a ff ff ff jle 1186 <fourfiles+0x16c> exit(); } unlink(fname); } printf(1, "fourfiles ok\n"); 126c: c7 44 24 04 86 4a 00 movl $0x4a86,0x4(%esp) 1273: 00 1274: c7 04 24 01 00 00 00 movl $0x1,(%esp) 127b: e8 c5 2d 00 00 call 4045 <printf> } 1280: c9 leave 1281: c3 ret 00001282 <createdelete>: // four processes create and delete different files in same directory void createdelete(void) { 1282: 55 push %ebp 1283: 89 e5 mov %esp,%ebp 1285: 83 ec 48 sub $0x48,%esp enum { N = 20 }; int pid, i, fd, pi; char name[32]; printf(1, "createdelete test\n"); 1288: c7 44 24 04 94 4a 00 movl $0x4a94,0x4(%esp) 128f: 00 1290: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1297: e8 a9 2d 00 00 call 4045 <printf> for(pi = 0; pi < 4; pi++){ 129c: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 12a3: e9 f4 00 00 00 jmp 139c <createdelete+0x11a> pid = fork(); 12a8: e8 00 2c 00 00 call 3ead <fork> 12ad: 89 45 ec mov %eax,-0x14(%ebp) if(pid < 0){ 12b0: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 12b4: 79 19 jns 12cf <createdelete+0x4d> printf(1, "fork failed\n"); 12b6: c7 44 24 04 b5 44 00 movl $0x44b5,0x4(%esp) 12bd: 00 12be: c7 04 24 01 00 00 00 movl $0x1,(%esp) 12c5: e8 7b 2d 00 00 call 4045 <printf> exit(); 12ca: e8 e6 2b 00 00 call 3eb5 <exit> } if(pid == 0){ 12cf: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 12d3: 0f 85 bf 00 00 00 jne 1398 <createdelete+0x116> name[0] = 'p' + pi; 12d9: 8b 45 f0 mov -0x10(%ebp),%eax 12dc: 83 c0 70 add $0x70,%eax 12df: 88 45 c8 mov %al,-0x38(%ebp) name[2] = '\0'; 12e2: c6 45 ca 00 movb $0x0,-0x36(%ebp) for(i = 0; i < N; i++){ 12e6: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 12ed: e9 97 00 00 00 jmp 1389 <createdelete+0x107> name[1] = '0' + i; 12f2: 8b 45 f4 mov -0xc(%ebp),%eax 12f5: 83 c0 30 add $0x30,%eax 12f8: 88 45 c9 mov %al,-0x37(%ebp) fd = open(name, O_CREATE | O_RDWR); 12fb: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1302: 00 1303: 8d 45 c8 lea -0x38(%ebp),%eax 1306: 89 04 24 mov %eax,(%esp) 1309: e8 e7 2b 00 00 call 3ef5 <open> 130e: 89 45 e8 mov %eax,-0x18(%ebp) if(fd < 0){ 1311: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 1315: 79 19 jns 1330 <createdelete+0xae> printf(1, "create failed\n"); 1317: c7 44 24 04 49 4a 00 movl $0x4a49,0x4(%esp) 131e: 00 131f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1326: e8 1a 2d 00 00 call 4045 <printf> exit(); 132b: e8 85 2b 00 00 call 3eb5 <exit> } close(fd); 1330: 8b 45 e8 mov -0x18(%ebp),%eax 1333: 89 04 24 mov %eax,(%esp) 1336: e8 a2 2b 00 00 call 3edd <close> if(i > 0 && (i % 2 ) == 0){ 133b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 133f: 7e 44 jle 1385 <createdelete+0x103> 1341: 8b 45 f4 mov -0xc(%ebp),%eax 1344: 83 e0 01 and $0x1,%eax 1347: 85 c0 test %eax,%eax 1349: 75 3a jne 1385 <createdelete+0x103> name[1] = '0' + (i / 2); 134b: 8b 45 f4 mov -0xc(%ebp),%eax 134e: 89 c2 mov %eax,%edx 1350: c1 ea 1f shr $0x1f,%edx 1353: 01 d0 add %edx,%eax 1355: d1 f8 sar %eax 1357: 83 c0 30 add $0x30,%eax 135a: 88 45 c9 mov %al,-0x37(%ebp) if(unlink(name) < 0){ 135d: 8d 45 c8 lea -0x38(%ebp),%eax 1360: 89 04 24 mov %eax,(%esp) 1363: e8 9d 2b 00 00 call 3f05 <unlink> 1368: 85 c0 test %eax,%eax 136a: 79 19 jns 1385 <createdelete+0x103> printf(1, "unlink failed\n"); 136c: c7 44 24 04 38 45 00 movl $0x4538,0x4(%esp) 1373: 00 1374: c7 04 24 01 00 00 00 movl $0x1,(%esp) 137b: e8 c5 2c 00 00 call 4045 <printf> exit(); 1380: e8 30 2b 00 00 call 3eb5 <exit> } if(pid == 0){ name[0] = 'p' + pi; name[2] = '\0'; for(i = 0; i < N; i++){ 1385: 83 45 f4 01 addl $0x1,-0xc(%ebp) 1389: 83 7d f4 13 cmpl $0x13,-0xc(%ebp) 138d: 0f 8e 5f ff ff ff jle 12f2 <createdelete+0x70> printf(1, "unlink failed\n"); exit(); } } } exit(); 1393: e8 1d 2b 00 00 call 3eb5 <exit> int pid, i, fd, pi; char name[32]; printf(1, "createdelete test\n"); for(pi = 0; pi < 4; pi++){ 1398: 83 45 f0 01 addl $0x1,-0x10(%ebp) 139c: 83 7d f0 03 cmpl $0x3,-0x10(%ebp) 13a0: 0f 8e 02 ff ff ff jle 12a8 <createdelete+0x26> } exit(); } } for(pi = 0; pi < 4; pi++){ 13a6: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 13ad: eb 09 jmp 13b8 <createdelete+0x136> wait(); 13af: e8 09 2b 00 00 call 3ebd <wait> } exit(); } } for(pi = 0; pi < 4; pi++){ 13b4: 83 45 f0 01 addl $0x1,-0x10(%ebp) 13b8: 83 7d f0 03 cmpl $0x3,-0x10(%ebp) 13bc: 7e f1 jle 13af <createdelete+0x12d> wait(); } name[0] = name[1] = name[2] = 0; 13be: c6 45 ca 00 movb $0x0,-0x36(%ebp) 13c2: 0f b6 45 ca movzbl -0x36(%ebp),%eax 13c6: 88 45 c9 mov %al,-0x37(%ebp) 13c9: 0f b6 45 c9 movzbl -0x37(%ebp),%eax 13cd: 88 45 c8 mov %al,-0x38(%ebp) for(i = 0; i < N; i++){ 13d0: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 13d7: e9 bb 00 00 00 jmp 1497 <createdelete+0x215> for(pi = 0; pi < 4; pi++){ 13dc: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 13e3: e9 a1 00 00 00 jmp 1489 <createdelete+0x207> name[0] = 'p' + pi; 13e8: 8b 45 f0 mov -0x10(%ebp),%eax 13eb: 83 c0 70 add $0x70,%eax 13ee: 88 45 c8 mov %al,-0x38(%ebp) name[1] = '0' + i; 13f1: 8b 45 f4 mov -0xc(%ebp),%eax 13f4: 83 c0 30 add $0x30,%eax 13f7: 88 45 c9 mov %al,-0x37(%ebp) fd = open(name, 0); 13fa: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1401: 00 1402: 8d 45 c8 lea -0x38(%ebp),%eax 1405: 89 04 24 mov %eax,(%esp) 1408: e8 e8 2a 00 00 call 3ef5 <open> 140d: 89 45 e8 mov %eax,-0x18(%ebp) if((i == 0 || i >= N/2) && fd < 0){ 1410: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1414: 74 06 je 141c <createdelete+0x19a> 1416: 83 7d f4 09 cmpl $0x9,-0xc(%ebp) 141a: 7e 26 jle 1442 <createdelete+0x1c0> 141c: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 1420: 79 20 jns 1442 <createdelete+0x1c0> printf(1, "oops createdelete %s didn't exist\n", name); 1422: 8d 45 c8 lea -0x38(%ebp),%eax 1425: 89 44 24 08 mov %eax,0x8(%esp) 1429: c7 44 24 04 a8 4a 00 movl $0x4aa8,0x4(%esp) 1430: 00 1431: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1438: e8 08 2c 00 00 call 4045 <printf> exit(); 143d: e8 73 2a 00 00 call 3eb5 <exit> } else if((i >= 1 && i < N/2) && fd >= 0){ 1442: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1446: 7e 2c jle 1474 <createdelete+0x1f2> 1448: 83 7d f4 09 cmpl $0x9,-0xc(%ebp) 144c: 7f 26 jg 1474 <createdelete+0x1f2> 144e: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 1452: 78 20 js 1474 <createdelete+0x1f2> printf(1, "oops createdelete %s did exist\n", name); 1454: 8d 45 c8 lea -0x38(%ebp),%eax 1457: 89 44 24 08 mov %eax,0x8(%esp) 145b: c7 44 24 04 cc 4a 00 movl $0x4acc,0x4(%esp) 1462: 00 1463: c7 04 24 01 00 00 00 movl $0x1,(%esp) 146a: e8 d6 2b 00 00 call 4045 <printf> exit(); 146f: e8 41 2a 00 00 call 3eb5 <exit> } if(fd >= 0) 1474: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 1478: 78 0b js 1485 <createdelete+0x203> close(fd); 147a: 8b 45 e8 mov -0x18(%ebp),%eax 147d: 89 04 24 mov %eax,(%esp) 1480: e8 58 2a 00 00 call 3edd <close> wait(); } name[0] = name[1] = name[2] = 0; for(i = 0; i < N; i++){ for(pi = 0; pi < 4; pi++){ 1485: 83 45 f0 01 addl $0x1,-0x10(%ebp) 1489: 83 7d f0 03 cmpl $0x3,-0x10(%ebp) 148d: 0f 8e 55 ff ff ff jle 13e8 <createdelete+0x166> for(pi = 0; pi < 4; pi++){ wait(); } name[0] = name[1] = name[2] = 0; for(i = 0; i < N; i++){ 1493: 83 45 f4 01 addl $0x1,-0xc(%ebp) 1497: 83 7d f4 13 cmpl $0x13,-0xc(%ebp) 149b: 0f 8e 3b ff ff ff jle 13dc <createdelete+0x15a> if(fd >= 0) close(fd); } } for(i = 0; i < N; i++){ 14a1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 14a8: eb 34 jmp 14de <createdelete+0x25c> for(pi = 0; pi < 4; pi++){ 14aa: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 14b1: eb 21 jmp 14d4 <createdelete+0x252> name[0] = 'p' + i; 14b3: 8b 45 f4 mov -0xc(%ebp),%eax 14b6: 83 c0 70 add $0x70,%eax 14b9: 88 45 c8 mov %al,-0x38(%ebp) name[1] = '0' + i; 14bc: 8b 45 f4 mov -0xc(%ebp),%eax 14bf: 83 c0 30 add $0x30,%eax 14c2: 88 45 c9 mov %al,-0x37(%ebp) unlink(name); 14c5: 8d 45 c8 lea -0x38(%ebp),%eax 14c8: 89 04 24 mov %eax,(%esp) 14cb: e8 35 2a 00 00 call 3f05 <unlink> close(fd); } } for(i = 0; i < N; i++){ for(pi = 0; pi < 4; pi++){ 14d0: 83 45 f0 01 addl $0x1,-0x10(%ebp) 14d4: 83 7d f0 03 cmpl $0x3,-0x10(%ebp) 14d8: 7e d9 jle 14b3 <createdelete+0x231> if(fd >= 0) close(fd); } } for(i = 0; i < N; i++){ 14da: 83 45 f4 01 addl $0x1,-0xc(%ebp) 14de: 83 7d f4 13 cmpl $0x13,-0xc(%ebp) 14e2: 7e c6 jle 14aa <createdelete+0x228> name[1] = '0' + i; unlink(name); } } printf(1, "createdelete ok\n"); 14e4: c7 44 24 04 ec 4a 00 movl $0x4aec,0x4(%esp) 14eb: 00 14ec: c7 04 24 01 00 00 00 movl $0x1,(%esp) 14f3: e8 4d 2b 00 00 call 4045 <printf> } 14f8: c9 leave 14f9: c3 ret 000014fa <unlinkread>: // can I unlink a file and still read it? void unlinkread(void) { 14fa: 55 push %ebp 14fb: 89 e5 mov %esp,%ebp 14fd: 83 ec 28 sub $0x28,%esp int fd, fd1; printf(1, "unlinkread test\n"); 1500: c7 44 24 04 fd 4a 00 movl $0x4afd,0x4(%esp) 1507: 00 1508: c7 04 24 01 00 00 00 movl $0x1,(%esp) 150f: e8 31 2b 00 00 call 4045 <printf> fd = open("unlinkread", O_CREATE | O_RDWR); 1514: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 151b: 00 151c: c7 04 24 0e 4b 00 00 movl $0x4b0e,(%esp) 1523: e8 cd 29 00 00 call 3ef5 <open> 1528: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 152b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 152f: 79 19 jns 154a <unlinkread+0x50> printf(1, "create unlinkread failed\n"); 1531: c7 44 24 04 19 4b 00 movl $0x4b19,0x4(%esp) 1538: 00 1539: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1540: e8 00 2b 00 00 call 4045 <printf> exit(); 1545: e8 6b 29 00 00 call 3eb5 <exit> } write(fd, "hello", 5); 154a: c7 44 24 08 05 00 00 movl $0x5,0x8(%esp) 1551: 00 1552: c7 44 24 04 33 4b 00 movl $0x4b33,0x4(%esp) 1559: 00 155a: 8b 45 f4 mov -0xc(%ebp),%eax 155d: 89 04 24 mov %eax,(%esp) 1560: e8 70 29 00 00 call 3ed5 <write> close(fd); 1565: 8b 45 f4 mov -0xc(%ebp),%eax 1568: 89 04 24 mov %eax,(%esp) 156b: e8 6d 29 00 00 call 3edd <close> fd = open("unlinkread", O_RDWR); 1570: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) 1577: 00 1578: c7 04 24 0e 4b 00 00 movl $0x4b0e,(%esp) 157f: e8 71 29 00 00 call 3ef5 <open> 1584: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 1587: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 158b: 79 19 jns 15a6 <unlinkread+0xac> printf(1, "open unlinkread failed\n"); 158d: c7 44 24 04 39 4b 00 movl $0x4b39,0x4(%esp) 1594: 00 1595: c7 04 24 01 00 00 00 movl $0x1,(%esp) 159c: e8 a4 2a 00 00 call 4045 <printf> exit(); 15a1: e8 0f 29 00 00 call 3eb5 <exit> } if(unlink("unlinkread") != 0){ 15a6: c7 04 24 0e 4b 00 00 movl $0x4b0e,(%esp) 15ad: e8 53 29 00 00 call 3f05 <unlink> 15b2: 85 c0 test %eax,%eax 15b4: 74 19 je 15cf <unlinkread+0xd5> printf(1, "unlink unlinkread failed\n"); 15b6: c7 44 24 04 51 4b 00 movl $0x4b51,0x4(%esp) 15bd: 00 15be: c7 04 24 01 00 00 00 movl $0x1,(%esp) 15c5: e8 7b 2a 00 00 call 4045 <printf> exit(); 15ca: e8 e6 28 00 00 call 3eb5 <exit> } fd1 = open("unlinkread", O_CREATE | O_RDWR); 15cf: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 15d6: 00 15d7: c7 04 24 0e 4b 00 00 movl $0x4b0e,(%esp) 15de: e8 12 29 00 00 call 3ef5 <open> 15e3: 89 45 f0 mov %eax,-0x10(%ebp) write(fd1, "yyy", 3); 15e6: c7 44 24 08 03 00 00 movl $0x3,0x8(%esp) 15ed: 00 15ee: c7 44 24 04 6b 4b 00 movl $0x4b6b,0x4(%esp) 15f5: 00 15f6: 8b 45 f0 mov -0x10(%ebp),%eax 15f9: 89 04 24 mov %eax,(%esp) 15fc: e8 d4 28 00 00 call 3ed5 <write> close(fd1); 1601: 8b 45 f0 mov -0x10(%ebp),%eax 1604: 89 04 24 mov %eax,(%esp) 1607: e8 d1 28 00 00 call 3edd <close> if(read(fd, buf, sizeof(buf)) != 5){ 160c: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) 1613: 00 1614: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 161b: 00 161c: 8b 45 f4 mov -0xc(%ebp),%eax 161f: 89 04 24 mov %eax,(%esp) 1622: e8 a6 28 00 00 call 3ecd <read> 1627: 83 f8 05 cmp $0x5,%eax 162a: 74 19 je 1645 <unlinkread+0x14b> printf(1, "unlinkread read failed"); 162c: c7 44 24 04 6f 4b 00 movl $0x4b6f,0x4(%esp) 1633: 00 1634: c7 04 24 01 00 00 00 movl $0x1,(%esp) 163b: e8 05 2a 00 00 call 4045 <printf> exit(); 1640: e8 70 28 00 00 call 3eb5 <exit> } if(buf[0] != 'h'){ 1645: 0f b6 05 c0 8a 00 00 movzbl 0x8ac0,%eax 164c: 3c 68 cmp $0x68,%al 164e: 74 19 je 1669 <unlinkread+0x16f> printf(1, "unlinkread wrong data\n"); 1650: c7 44 24 04 86 4b 00 movl $0x4b86,0x4(%esp) 1657: 00 1658: c7 04 24 01 00 00 00 movl $0x1,(%esp) 165f: e8 e1 29 00 00 call 4045 <printf> exit(); 1664: e8 4c 28 00 00 call 3eb5 <exit> } if(write(fd, buf, 10) != 10){ 1669: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 1670: 00 1671: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 1678: 00 1679: 8b 45 f4 mov -0xc(%ebp),%eax 167c: 89 04 24 mov %eax,(%esp) 167f: e8 51 28 00 00 call 3ed5 <write> 1684: 83 f8 0a cmp $0xa,%eax 1687: 74 19 je 16a2 <unlinkread+0x1a8> printf(1, "unlinkread write failed\n"); 1689: c7 44 24 04 9d 4b 00 movl $0x4b9d,0x4(%esp) 1690: 00 1691: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1698: e8 a8 29 00 00 call 4045 <printf> exit(); 169d: e8 13 28 00 00 call 3eb5 <exit> } close(fd); 16a2: 8b 45 f4 mov -0xc(%ebp),%eax 16a5: 89 04 24 mov %eax,(%esp) 16a8: e8 30 28 00 00 call 3edd <close> unlink("unlinkread"); 16ad: c7 04 24 0e 4b 00 00 movl $0x4b0e,(%esp) 16b4: e8 4c 28 00 00 call 3f05 <unlink> printf(1, "unlinkread ok\n"); 16b9: c7 44 24 04 b6 4b 00 movl $0x4bb6,0x4(%esp) 16c0: 00 16c1: c7 04 24 01 00 00 00 movl $0x1,(%esp) 16c8: e8 78 29 00 00 call 4045 <printf> } 16cd: c9 leave 16ce: c3 ret 000016cf <linktest>: void linktest(void) { 16cf: 55 push %ebp 16d0: 89 e5 mov %esp,%ebp 16d2: 83 ec 28 sub $0x28,%esp int fd; printf(1, "linktest\n"); 16d5: c7 44 24 04 c5 4b 00 movl $0x4bc5,0x4(%esp) 16dc: 00 16dd: c7 04 24 01 00 00 00 movl $0x1,(%esp) 16e4: e8 5c 29 00 00 call 4045 <printf> unlink("lf1"); 16e9: c7 04 24 cf 4b 00 00 movl $0x4bcf,(%esp) 16f0: e8 10 28 00 00 call 3f05 <unlink> unlink("lf2"); 16f5: c7 04 24 d3 4b 00 00 movl $0x4bd3,(%esp) 16fc: e8 04 28 00 00 call 3f05 <unlink> fd = open("lf1", O_CREATE|O_RDWR); 1701: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1708: 00 1709: c7 04 24 cf 4b 00 00 movl $0x4bcf,(%esp) 1710: e8 e0 27 00 00 call 3ef5 <open> 1715: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 1718: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 171c: 79 19 jns 1737 <linktest+0x68> printf(1, "create lf1 failed\n"); 171e: c7 44 24 04 d7 4b 00 movl $0x4bd7,0x4(%esp) 1725: 00 1726: c7 04 24 01 00 00 00 movl $0x1,(%esp) 172d: e8 13 29 00 00 call 4045 <printf> exit(); 1732: e8 7e 27 00 00 call 3eb5 <exit> } if(write(fd, "hello", 5) != 5){ 1737: c7 44 24 08 05 00 00 movl $0x5,0x8(%esp) 173e: 00 173f: c7 44 24 04 33 4b 00 movl $0x4b33,0x4(%esp) 1746: 00 1747: 8b 45 f4 mov -0xc(%ebp),%eax 174a: 89 04 24 mov %eax,(%esp) 174d: e8 83 27 00 00 call 3ed5 <write> 1752: 83 f8 05 cmp $0x5,%eax 1755: 74 19 je 1770 <linktest+0xa1> printf(1, "write lf1 failed\n"); 1757: c7 44 24 04 ea 4b 00 movl $0x4bea,0x4(%esp) 175e: 00 175f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1766: e8 da 28 00 00 call 4045 <printf> exit(); 176b: e8 45 27 00 00 call 3eb5 <exit> } close(fd); 1770: 8b 45 f4 mov -0xc(%ebp),%eax 1773: 89 04 24 mov %eax,(%esp) 1776: e8 62 27 00 00 call 3edd <close> if(link("lf1", "lf2") < 0){ 177b: c7 44 24 04 d3 4b 00 movl $0x4bd3,0x4(%esp) 1782: 00 1783: c7 04 24 cf 4b 00 00 movl $0x4bcf,(%esp) 178a: e8 86 27 00 00 call 3f15 <link> 178f: 85 c0 test %eax,%eax 1791: 79 19 jns 17ac <linktest+0xdd> printf(1, "link lf1 lf2 failed\n"); 1793: c7 44 24 04 fc 4b 00 movl $0x4bfc,0x4(%esp) 179a: 00 179b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 17a2: e8 9e 28 00 00 call 4045 <printf> exit(); 17a7: e8 09 27 00 00 call 3eb5 <exit> } unlink("lf1"); 17ac: c7 04 24 cf 4b 00 00 movl $0x4bcf,(%esp) 17b3: e8 4d 27 00 00 call 3f05 <unlink> if(open("lf1", 0) >= 0){ 17b8: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 17bf: 00 17c0: c7 04 24 cf 4b 00 00 movl $0x4bcf,(%esp) 17c7: e8 29 27 00 00 call 3ef5 <open> 17cc: 85 c0 test %eax,%eax 17ce: 78 19 js 17e9 <linktest+0x11a> printf(1, "unlinked lf1 but it is still there!\n"); 17d0: c7 44 24 04 14 4c 00 movl $0x4c14,0x4(%esp) 17d7: 00 17d8: c7 04 24 01 00 00 00 movl $0x1,(%esp) 17df: e8 61 28 00 00 call 4045 <printf> exit(); 17e4: e8 cc 26 00 00 call 3eb5 <exit> } fd = open("lf2", 0); 17e9: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 17f0: 00 17f1: c7 04 24 d3 4b 00 00 movl $0x4bd3,(%esp) 17f8: e8 f8 26 00 00 call 3ef5 <open> 17fd: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 1800: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1804: 79 19 jns 181f <linktest+0x150> printf(1, "open lf2 failed\n"); 1806: c7 44 24 04 39 4c 00 movl $0x4c39,0x4(%esp) 180d: 00 180e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1815: e8 2b 28 00 00 call 4045 <printf> exit(); 181a: e8 96 26 00 00 call 3eb5 <exit> } if(read(fd, buf, sizeof(buf)) != 5){ 181f: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) 1826: 00 1827: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 182e: 00 182f: 8b 45 f4 mov -0xc(%ebp),%eax 1832: 89 04 24 mov %eax,(%esp) 1835: e8 93 26 00 00 call 3ecd <read> 183a: 83 f8 05 cmp $0x5,%eax 183d: 74 19 je 1858 <linktest+0x189> printf(1, "read lf2 failed\n"); 183f: c7 44 24 04 4a 4c 00 movl $0x4c4a,0x4(%esp) 1846: 00 1847: c7 04 24 01 00 00 00 movl $0x1,(%esp) 184e: e8 f2 27 00 00 call 4045 <printf> exit(); 1853: e8 5d 26 00 00 call 3eb5 <exit> } close(fd); 1858: 8b 45 f4 mov -0xc(%ebp),%eax 185b: 89 04 24 mov %eax,(%esp) 185e: e8 7a 26 00 00 call 3edd <close> if(link("lf2", "lf2") >= 0){ 1863: c7 44 24 04 d3 4b 00 movl $0x4bd3,0x4(%esp) 186a: 00 186b: c7 04 24 d3 4b 00 00 movl $0x4bd3,(%esp) 1872: e8 9e 26 00 00 call 3f15 <link> 1877: 85 c0 test %eax,%eax 1879: 78 19 js 1894 <linktest+0x1c5> printf(1, "link lf2 lf2 succeeded! oops\n"); 187b: c7 44 24 04 5b 4c 00 movl $0x4c5b,0x4(%esp) 1882: 00 1883: c7 04 24 01 00 00 00 movl $0x1,(%esp) 188a: e8 b6 27 00 00 call 4045 <printf> exit(); 188f: e8 21 26 00 00 call 3eb5 <exit> } unlink("lf2"); 1894: c7 04 24 d3 4b 00 00 movl $0x4bd3,(%esp) 189b: e8 65 26 00 00 call 3f05 <unlink> if(link("lf2", "lf1") >= 0){ 18a0: c7 44 24 04 cf 4b 00 movl $0x4bcf,0x4(%esp) 18a7: 00 18a8: c7 04 24 d3 4b 00 00 movl $0x4bd3,(%esp) 18af: e8 61 26 00 00 call 3f15 <link> 18b4: 85 c0 test %eax,%eax 18b6: 78 19 js 18d1 <linktest+0x202> printf(1, "link non-existant succeeded! oops\n"); 18b8: c7 44 24 04 7c 4c 00 movl $0x4c7c,0x4(%esp) 18bf: 00 18c0: c7 04 24 01 00 00 00 movl $0x1,(%esp) 18c7: e8 79 27 00 00 call 4045 <printf> exit(); 18cc: e8 e4 25 00 00 call 3eb5 <exit> } if(link(".", "lf1") >= 0){ 18d1: c7 44 24 04 cf 4b 00 movl $0x4bcf,0x4(%esp) 18d8: 00 18d9: c7 04 24 9f 4c 00 00 movl $0x4c9f,(%esp) 18e0: e8 30 26 00 00 call 3f15 <link> 18e5: 85 c0 test %eax,%eax 18e7: 78 19 js 1902 <linktest+0x233> printf(1, "link . lf1 succeeded! oops\n"); 18e9: c7 44 24 04 a1 4c 00 movl $0x4ca1,0x4(%esp) 18f0: 00 18f1: c7 04 24 01 00 00 00 movl $0x1,(%esp) 18f8: e8 48 27 00 00 call 4045 <printf> exit(); 18fd: e8 b3 25 00 00 call 3eb5 <exit> } printf(1, "linktest ok\n"); 1902: c7 44 24 04 bd 4c 00 movl $0x4cbd,0x4(%esp) 1909: 00 190a: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1911: e8 2f 27 00 00 call 4045 <printf> } 1916: c9 leave 1917: c3 ret 00001918 <concreate>: // test concurrent create/link/unlink of the same file void concreate(void) { 1918: 55 push %ebp 1919: 89 e5 mov %esp,%ebp 191b: 83 ec 68 sub $0x68,%esp struct { ushort inum; char name[14]; } de; printf(1, "concreate test\n"); 191e: c7 44 24 04 ca 4c 00 movl $0x4cca,0x4(%esp) 1925: 00 1926: c7 04 24 01 00 00 00 movl $0x1,(%esp) 192d: e8 13 27 00 00 call 4045 <printf> file[0] = 'C'; 1932: c6 45 e5 43 movb $0x43,-0x1b(%ebp) file[2] = '\0'; 1936: c6 45 e7 00 movb $0x0,-0x19(%ebp) for(i = 0; i < 40; i++){ 193a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1941: e9 f7 00 00 00 jmp 1a3d <concreate+0x125> file[1] = '0' + i; 1946: 8b 45 f4 mov -0xc(%ebp),%eax 1949: 83 c0 30 add $0x30,%eax 194c: 88 45 e6 mov %al,-0x1a(%ebp) unlink(file); 194f: 8d 45 e5 lea -0x1b(%ebp),%eax 1952: 89 04 24 mov %eax,(%esp) 1955: e8 ab 25 00 00 call 3f05 <unlink> pid = fork(); 195a: e8 4e 25 00 00 call 3ead <fork> 195f: 89 45 ec mov %eax,-0x14(%ebp) if(pid && (i % 3) == 1){ 1962: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1966: 74 3a je 19a2 <concreate+0x8a> 1968: 8b 4d f4 mov -0xc(%ebp),%ecx 196b: ba 56 55 55 55 mov $0x55555556,%edx 1970: 89 c8 mov %ecx,%eax 1972: f7 ea imul %edx 1974: 89 c8 mov %ecx,%eax 1976: c1 f8 1f sar $0x1f,%eax 1979: 29 c2 sub %eax,%edx 197b: 89 d0 mov %edx,%eax 197d: 01 c0 add %eax,%eax 197f: 01 d0 add %edx,%eax 1981: 29 c1 sub %eax,%ecx 1983: 89 ca mov %ecx,%edx 1985: 83 fa 01 cmp $0x1,%edx 1988: 75 18 jne 19a2 <concreate+0x8a> link("C0", file); 198a: 8d 45 e5 lea -0x1b(%ebp),%eax 198d: 89 44 24 04 mov %eax,0x4(%esp) 1991: c7 04 24 da 4c 00 00 movl $0x4cda,(%esp) 1998: e8 78 25 00 00 call 3f15 <link> 199d: e9 87 00 00 00 jmp 1a29 <concreate+0x111> } else if(pid == 0 && (i % 5) == 1){ 19a2: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 19a6: 75 3a jne 19e2 <concreate+0xca> 19a8: 8b 4d f4 mov -0xc(%ebp),%ecx 19ab: ba 67 66 66 66 mov $0x66666667,%edx 19b0: 89 c8 mov %ecx,%eax 19b2: f7 ea imul %edx 19b4: d1 fa sar %edx 19b6: 89 c8 mov %ecx,%eax 19b8: c1 f8 1f sar $0x1f,%eax 19bb: 29 c2 sub %eax,%edx 19bd: 89 d0 mov %edx,%eax 19bf: c1 e0 02 shl $0x2,%eax 19c2: 01 d0 add %edx,%eax 19c4: 29 c1 sub %eax,%ecx 19c6: 89 ca mov %ecx,%edx 19c8: 83 fa 01 cmp $0x1,%edx 19cb: 75 15 jne 19e2 <concreate+0xca> link("C0", file); 19cd: 8d 45 e5 lea -0x1b(%ebp),%eax 19d0: 89 44 24 04 mov %eax,0x4(%esp) 19d4: c7 04 24 da 4c 00 00 movl $0x4cda,(%esp) 19db: e8 35 25 00 00 call 3f15 <link> 19e0: eb 47 jmp 1a29 <concreate+0x111> } else { fd = open(file, O_CREATE | O_RDWR); 19e2: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 19e9: 00 19ea: 8d 45 e5 lea -0x1b(%ebp),%eax 19ed: 89 04 24 mov %eax,(%esp) 19f0: e8 00 25 00 00 call 3ef5 <open> 19f5: 89 45 e8 mov %eax,-0x18(%ebp) if(fd < 0){ 19f8: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 19fc: 79 20 jns 1a1e <concreate+0x106> printf(1, "concreate create %s failed\n", file); 19fe: 8d 45 e5 lea -0x1b(%ebp),%eax 1a01: 89 44 24 08 mov %eax,0x8(%esp) 1a05: c7 44 24 04 dd 4c 00 movl $0x4cdd,0x4(%esp) 1a0c: 00 1a0d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1a14: e8 2c 26 00 00 call 4045 <printf> exit(); 1a19: e8 97 24 00 00 call 3eb5 <exit> } close(fd); 1a1e: 8b 45 e8 mov -0x18(%ebp),%eax 1a21: 89 04 24 mov %eax,(%esp) 1a24: e8 b4 24 00 00 call 3edd <close> } if(pid == 0) 1a29: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1a2d: 75 05 jne 1a34 <concreate+0x11c> exit(); 1a2f: e8 81 24 00 00 call 3eb5 <exit> else wait(); 1a34: e8 84 24 00 00 call 3ebd <wait> } de; printf(1, "concreate test\n"); file[0] = 'C'; file[2] = '\0'; for(i = 0; i < 40; i++){ 1a39: 83 45 f4 01 addl $0x1,-0xc(%ebp) 1a3d: 83 7d f4 27 cmpl $0x27,-0xc(%ebp) 1a41: 0f 8e ff fe ff ff jle 1946 <concreate+0x2e> exit(); else wait(); } memset(fa, 0, sizeof(fa)); 1a47: c7 44 24 08 28 00 00 movl $0x28,0x8(%esp) 1a4e: 00 1a4f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1a56: 00 1a57: 8d 45 bd lea -0x43(%ebp),%eax 1a5a: 89 04 24 mov %eax,(%esp) 1a5d: e8 a6 22 00 00 call 3d08 <memset> fd = open(".", 0); 1a62: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1a69: 00 1a6a: c7 04 24 9f 4c 00 00 movl $0x4c9f,(%esp) 1a71: e8 7f 24 00 00 call 3ef5 <open> 1a76: 89 45 e8 mov %eax,-0x18(%ebp) n = 0; 1a79: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) while(read(fd, &de, sizeof(de)) > 0){ 1a80: e9 a1 00 00 00 jmp 1b26 <concreate+0x20e> if(de.inum == 0) 1a85: 0f b7 45 ac movzwl -0x54(%ebp),%eax 1a89: 66 85 c0 test %ax,%ax 1a8c: 75 05 jne 1a93 <concreate+0x17b> continue; 1a8e: e9 93 00 00 00 jmp 1b26 <concreate+0x20e> if(de.name[0] == 'C' && de.name[2] == '\0'){ 1a93: 0f b6 45 ae movzbl -0x52(%ebp),%eax 1a97: 3c 43 cmp $0x43,%al 1a99: 0f 85 87 00 00 00 jne 1b26 <concreate+0x20e> 1a9f: 0f b6 45 b0 movzbl -0x50(%ebp),%eax 1aa3: 84 c0 test %al,%al 1aa5: 75 7f jne 1b26 <concreate+0x20e> i = de.name[1] - '0'; 1aa7: 0f b6 45 af movzbl -0x51(%ebp),%eax 1aab: 0f be c0 movsbl %al,%eax 1aae: 83 e8 30 sub $0x30,%eax 1ab1: 89 45 f4 mov %eax,-0xc(%ebp) if(i < 0 || i >= sizeof(fa)){ 1ab4: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1ab8: 78 08 js 1ac2 <concreate+0x1aa> 1aba: 8b 45 f4 mov -0xc(%ebp),%eax 1abd: 83 f8 27 cmp $0x27,%eax 1ac0: 76 23 jbe 1ae5 <concreate+0x1cd> printf(1, "concreate weird file %s\n", de.name); 1ac2: 8d 45 ac lea -0x54(%ebp),%eax 1ac5: 83 c0 02 add $0x2,%eax 1ac8: 89 44 24 08 mov %eax,0x8(%esp) 1acc: c7 44 24 04 f9 4c 00 movl $0x4cf9,0x4(%esp) 1ad3: 00 1ad4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1adb: e8 65 25 00 00 call 4045 <printf> exit(); 1ae0: e8 d0 23 00 00 call 3eb5 <exit> } if(fa[i]){ 1ae5: 8d 55 bd lea -0x43(%ebp),%edx 1ae8: 8b 45 f4 mov -0xc(%ebp),%eax 1aeb: 01 d0 add %edx,%eax 1aed: 0f b6 00 movzbl (%eax),%eax 1af0: 84 c0 test %al,%al 1af2: 74 23 je 1b17 <concreate+0x1ff> printf(1, "concreate duplicate file %s\n", de.name); 1af4: 8d 45 ac lea -0x54(%ebp),%eax 1af7: 83 c0 02 add $0x2,%eax 1afa: 89 44 24 08 mov %eax,0x8(%esp) 1afe: c7 44 24 04 12 4d 00 movl $0x4d12,0x4(%esp) 1b05: 00 1b06: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1b0d: e8 33 25 00 00 call 4045 <printf> exit(); 1b12: e8 9e 23 00 00 call 3eb5 <exit> } fa[i] = 1; 1b17: 8d 55 bd lea -0x43(%ebp),%edx 1b1a: 8b 45 f4 mov -0xc(%ebp),%eax 1b1d: 01 d0 add %edx,%eax 1b1f: c6 00 01 movb $0x1,(%eax) n++; 1b22: 83 45 f0 01 addl $0x1,-0x10(%ebp) } memset(fa, 0, sizeof(fa)); fd = open(".", 0); n = 0; while(read(fd, &de, sizeof(de)) > 0){ 1b26: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 1b2d: 00 1b2e: 8d 45 ac lea -0x54(%ebp),%eax 1b31: 89 44 24 04 mov %eax,0x4(%esp) 1b35: 8b 45 e8 mov -0x18(%ebp),%eax 1b38: 89 04 24 mov %eax,(%esp) 1b3b: e8 8d 23 00 00 call 3ecd <read> 1b40: 85 c0 test %eax,%eax 1b42: 0f 8f 3d ff ff ff jg 1a85 <concreate+0x16d> } fa[i] = 1; n++; } } close(fd); 1b48: 8b 45 e8 mov -0x18(%ebp),%eax 1b4b: 89 04 24 mov %eax,(%esp) 1b4e: e8 8a 23 00 00 call 3edd <close> if(n != 40){ 1b53: 83 7d f0 28 cmpl $0x28,-0x10(%ebp) 1b57: 74 19 je 1b72 <concreate+0x25a> printf(1, "concreate not enough files in directory listing\n"); 1b59: c7 44 24 04 30 4d 00 movl $0x4d30,0x4(%esp) 1b60: 00 1b61: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1b68: e8 d8 24 00 00 call 4045 <printf> exit(); 1b6d: e8 43 23 00 00 call 3eb5 <exit> } for(i = 0; i < 40; i++){ 1b72: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1b79: e9 2d 01 00 00 jmp 1cab <concreate+0x393> file[1] = '0' + i; 1b7e: 8b 45 f4 mov -0xc(%ebp),%eax 1b81: 83 c0 30 add $0x30,%eax 1b84: 88 45 e6 mov %al,-0x1a(%ebp) pid = fork(); 1b87: e8 21 23 00 00 call 3ead <fork> 1b8c: 89 45 ec mov %eax,-0x14(%ebp) if(pid < 0){ 1b8f: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1b93: 79 19 jns 1bae <concreate+0x296> printf(1, "fork failed\n"); 1b95: c7 44 24 04 b5 44 00 movl $0x44b5,0x4(%esp) 1b9c: 00 1b9d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1ba4: e8 9c 24 00 00 call 4045 <printf> exit(); 1ba9: e8 07 23 00 00 call 3eb5 <exit> } if(((i % 3) == 0 && pid == 0) || 1bae: 8b 4d f4 mov -0xc(%ebp),%ecx 1bb1: ba 56 55 55 55 mov $0x55555556,%edx 1bb6: 89 c8 mov %ecx,%eax 1bb8: f7 ea imul %edx 1bba: 89 c8 mov %ecx,%eax 1bbc: c1 f8 1f sar $0x1f,%eax 1bbf: 29 c2 sub %eax,%edx 1bc1: 89 d0 mov %edx,%eax 1bc3: 01 c0 add %eax,%eax 1bc5: 01 d0 add %edx,%eax 1bc7: 29 c1 sub %eax,%ecx 1bc9: 89 ca mov %ecx,%edx 1bcb: 85 d2 test %edx,%edx 1bcd: 75 06 jne 1bd5 <concreate+0x2bd> 1bcf: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1bd3: 74 28 je 1bfd <concreate+0x2e5> ((i % 3) == 1 && pid != 0)){ 1bd5: 8b 4d f4 mov -0xc(%ebp),%ecx 1bd8: ba 56 55 55 55 mov $0x55555556,%edx 1bdd: 89 c8 mov %ecx,%eax 1bdf: f7 ea imul %edx 1be1: 89 c8 mov %ecx,%eax 1be3: c1 f8 1f sar $0x1f,%eax 1be6: 29 c2 sub %eax,%edx 1be8: 89 d0 mov %edx,%eax 1bea: 01 c0 add %eax,%eax 1bec: 01 d0 add %edx,%eax 1bee: 29 c1 sub %eax,%ecx 1bf0: 89 ca mov %ecx,%edx pid = fork(); if(pid < 0){ printf(1, "fork failed\n"); exit(); } if(((i % 3) == 0 && pid == 0) || 1bf2: 83 fa 01 cmp $0x1,%edx 1bf5: 75 74 jne 1c6b <concreate+0x353> ((i % 3) == 1 && pid != 0)){ 1bf7: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1bfb: 74 6e je 1c6b <concreate+0x353> close(open(file, 0)); 1bfd: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1c04: 00 1c05: 8d 45 e5 lea -0x1b(%ebp),%eax 1c08: 89 04 24 mov %eax,(%esp) 1c0b: e8 e5 22 00 00 call 3ef5 <open> 1c10: 89 04 24 mov %eax,(%esp) 1c13: e8 c5 22 00 00 call 3edd <close> close(open(file, 0)); 1c18: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1c1f: 00 1c20: 8d 45 e5 lea -0x1b(%ebp),%eax 1c23: 89 04 24 mov %eax,(%esp) 1c26: e8 ca 22 00 00 call 3ef5 <open> 1c2b: 89 04 24 mov %eax,(%esp) 1c2e: e8 aa 22 00 00 call 3edd <close> close(open(file, 0)); 1c33: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1c3a: 00 1c3b: 8d 45 e5 lea -0x1b(%ebp),%eax 1c3e: 89 04 24 mov %eax,(%esp) 1c41: e8 af 22 00 00 call 3ef5 <open> 1c46: 89 04 24 mov %eax,(%esp) 1c49: e8 8f 22 00 00 call 3edd <close> close(open(file, 0)); 1c4e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1c55: 00 1c56: 8d 45 e5 lea -0x1b(%ebp),%eax 1c59: 89 04 24 mov %eax,(%esp) 1c5c: e8 94 22 00 00 call 3ef5 <open> 1c61: 89 04 24 mov %eax,(%esp) 1c64: e8 74 22 00 00 call 3edd <close> 1c69: eb 2c jmp 1c97 <concreate+0x37f> } else { unlink(file); 1c6b: 8d 45 e5 lea -0x1b(%ebp),%eax 1c6e: 89 04 24 mov %eax,(%esp) 1c71: e8 8f 22 00 00 call 3f05 <unlink> unlink(file); 1c76: 8d 45 e5 lea -0x1b(%ebp),%eax 1c79: 89 04 24 mov %eax,(%esp) 1c7c: e8 84 22 00 00 call 3f05 <unlink> unlink(file); 1c81: 8d 45 e5 lea -0x1b(%ebp),%eax 1c84: 89 04 24 mov %eax,(%esp) 1c87: e8 79 22 00 00 call 3f05 <unlink> unlink(file); 1c8c: 8d 45 e5 lea -0x1b(%ebp),%eax 1c8f: 89 04 24 mov %eax,(%esp) 1c92: e8 6e 22 00 00 call 3f05 <unlink> } if(pid == 0) 1c97: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1c9b: 75 05 jne 1ca2 <concreate+0x38a> exit(); 1c9d: e8 13 22 00 00 call 3eb5 <exit> else wait(); 1ca2: e8 16 22 00 00 call 3ebd <wait> if(n != 40){ printf(1, "concreate not enough files in directory listing\n"); exit(); } for(i = 0; i < 40; i++){ 1ca7: 83 45 f4 01 addl $0x1,-0xc(%ebp) 1cab: 83 7d f4 27 cmpl $0x27,-0xc(%ebp) 1caf: 0f 8e c9 fe ff ff jle 1b7e <concreate+0x266> exit(); else wait(); } printf(1, "concreate ok\n"); 1cb5: c7 44 24 04 61 4d 00 movl $0x4d61,0x4(%esp) 1cbc: 00 1cbd: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1cc4: e8 7c 23 00 00 call 4045 <printf> } 1cc9: c9 leave 1cca: c3 ret 00001ccb <linkunlink>: // another concurrent link/unlink/create test, // to look for deadlocks. void linkunlink() { 1ccb: 55 push %ebp 1ccc: 89 e5 mov %esp,%ebp 1cce: 83 ec 28 sub $0x28,%esp int pid, i; printf(1, "linkunlink test\n"); 1cd1: c7 44 24 04 6f 4d 00 movl $0x4d6f,0x4(%esp) 1cd8: 00 1cd9: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1ce0: e8 60 23 00 00 call 4045 <printf> unlink("x"); 1ce5: c7 04 24 eb 48 00 00 movl $0x48eb,(%esp) 1cec: e8 14 22 00 00 call 3f05 <unlink> pid = fork(); 1cf1: e8 b7 21 00 00 call 3ead <fork> 1cf6: 89 45 ec mov %eax,-0x14(%ebp) if(pid < 0){ 1cf9: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1cfd: 79 19 jns 1d18 <linkunlink+0x4d> printf(1, "fork failed\n"); 1cff: c7 44 24 04 b5 44 00 movl $0x44b5,0x4(%esp) 1d06: 00 1d07: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1d0e: e8 32 23 00 00 call 4045 <printf> exit(); 1d13: e8 9d 21 00 00 call 3eb5 <exit> } unsigned int x = (pid ? 1 : 97); 1d18: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1d1c: 74 07 je 1d25 <linkunlink+0x5a> 1d1e: b8 01 00 00 00 mov $0x1,%eax 1d23: eb 05 jmp 1d2a <linkunlink+0x5f> 1d25: b8 61 00 00 00 mov $0x61,%eax 1d2a: 89 45 f0 mov %eax,-0x10(%ebp) for(i = 0; i < 100; i++){ 1d2d: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1d34: e9 8e 00 00 00 jmp 1dc7 <linkunlink+0xfc> x = x * 1103515245 + 12345; 1d39: 8b 45 f0 mov -0x10(%ebp),%eax 1d3c: 69 c0 6d 4e c6 41 imul $0x41c64e6d,%eax,%eax 1d42: 05 39 30 00 00 add $0x3039,%eax 1d47: 89 45 f0 mov %eax,-0x10(%ebp) if((x % 3) == 0){ 1d4a: 8b 4d f0 mov -0x10(%ebp),%ecx 1d4d: ba ab aa aa aa mov $0xaaaaaaab,%edx 1d52: 89 c8 mov %ecx,%eax 1d54: f7 e2 mul %edx 1d56: d1 ea shr %edx 1d58: 89 d0 mov %edx,%eax 1d5a: 01 c0 add %eax,%eax 1d5c: 01 d0 add %edx,%eax 1d5e: 29 c1 sub %eax,%ecx 1d60: 89 ca mov %ecx,%edx 1d62: 85 d2 test %edx,%edx 1d64: 75 1e jne 1d84 <linkunlink+0xb9> close(open("x", O_RDWR | O_CREATE)); 1d66: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1d6d: 00 1d6e: c7 04 24 eb 48 00 00 movl $0x48eb,(%esp) 1d75: e8 7b 21 00 00 call 3ef5 <open> 1d7a: 89 04 24 mov %eax,(%esp) 1d7d: e8 5b 21 00 00 call 3edd <close> 1d82: eb 3f jmp 1dc3 <linkunlink+0xf8> } else if((x % 3) == 1){ 1d84: 8b 4d f0 mov -0x10(%ebp),%ecx 1d87: ba ab aa aa aa mov $0xaaaaaaab,%edx 1d8c: 89 c8 mov %ecx,%eax 1d8e: f7 e2 mul %edx 1d90: d1 ea shr %edx 1d92: 89 d0 mov %edx,%eax 1d94: 01 c0 add %eax,%eax 1d96: 01 d0 add %edx,%eax 1d98: 29 c1 sub %eax,%ecx 1d9a: 89 ca mov %ecx,%edx 1d9c: 83 fa 01 cmp $0x1,%edx 1d9f: 75 16 jne 1db7 <linkunlink+0xec> link("cat", "x"); 1da1: c7 44 24 04 eb 48 00 movl $0x48eb,0x4(%esp) 1da8: 00 1da9: c7 04 24 80 4d 00 00 movl $0x4d80,(%esp) 1db0: e8 60 21 00 00 call 3f15 <link> 1db5: eb 0c jmp 1dc3 <linkunlink+0xf8> } else { unlink("x"); 1db7: c7 04 24 eb 48 00 00 movl $0x48eb,(%esp) 1dbe: e8 42 21 00 00 call 3f05 <unlink> printf(1, "fork failed\n"); exit(); } unsigned int x = (pid ? 1 : 97); for(i = 0; i < 100; i++){ 1dc3: 83 45 f4 01 addl $0x1,-0xc(%ebp) 1dc7: 83 7d f4 63 cmpl $0x63,-0xc(%ebp) 1dcb: 0f 8e 68 ff ff ff jle 1d39 <linkunlink+0x6e> } else { unlink("x"); } } if(pid) 1dd1: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1dd5: 74 07 je 1dde <linkunlink+0x113> wait(); 1dd7: e8 e1 20 00 00 call 3ebd <wait> 1ddc: eb 05 jmp 1de3 <linkunlink+0x118> else exit(); 1dde: e8 d2 20 00 00 call 3eb5 <exit> printf(1, "linkunlink ok\n"); 1de3: c7 44 24 04 84 4d 00 movl $0x4d84,0x4(%esp) 1dea: 00 1deb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1df2: e8 4e 22 00 00 call 4045 <printf> } 1df7: c9 leave 1df8: c3 ret 00001df9 <bigdir>: // directory that uses indirect blocks void bigdir(void) { 1df9: 55 push %ebp 1dfa: 89 e5 mov %esp,%ebp 1dfc: 83 ec 38 sub $0x38,%esp int i, fd; char name[10]; printf(1, "bigdir test\n"); 1dff: c7 44 24 04 93 4d 00 movl $0x4d93,0x4(%esp) 1e06: 00 1e07: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1e0e: e8 32 22 00 00 call 4045 <printf> unlink("bd"); 1e13: c7 04 24 a0 4d 00 00 movl $0x4da0,(%esp) 1e1a: e8 e6 20 00 00 call 3f05 <unlink> fd = open("bd", O_CREATE); 1e1f: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 1e26: 00 1e27: c7 04 24 a0 4d 00 00 movl $0x4da0,(%esp) 1e2e: e8 c2 20 00 00 call 3ef5 <open> 1e33: 89 45 f0 mov %eax,-0x10(%ebp) if(fd < 0){ 1e36: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 1e3a: 79 19 jns 1e55 <bigdir+0x5c> printf(1, "bigdir create failed\n"); 1e3c: c7 44 24 04 a3 4d 00 movl $0x4da3,0x4(%esp) 1e43: 00 1e44: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1e4b: e8 f5 21 00 00 call 4045 <printf> exit(); 1e50: e8 60 20 00 00 call 3eb5 <exit> } close(fd); 1e55: 8b 45 f0 mov -0x10(%ebp),%eax 1e58: 89 04 24 mov %eax,(%esp) 1e5b: e8 7d 20 00 00 call 3edd <close> for(i = 0; i < 500; i++){ 1e60: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1e67: eb 64 jmp 1ecd <bigdir+0xd4> name[0] = 'x'; 1e69: c6 45 e6 78 movb $0x78,-0x1a(%ebp) name[1] = '0' + (i / 64); 1e6d: 8b 45 f4 mov -0xc(%ebp),%eax 1e70: 8d 50 3f lea 0x3f(%eax),%edx 1e73: 85 c0 test %eax,%eax 1e75: 0f 48 c2 cmovs %edx,%eax 1e78: c1 f8 06 sar $0x6,%eax 1e7b: 83 c0 30 add $0x30,%eax 1e7e: 88 45 e7 mov %al,-0x19(%ebp) name[2] = '0' + (i % 64); 1e81: 8b 45 f4 mov -0xc(%ebp),%eax 1e84: 99 cltd 1e85: c1 ea 1a shr $0x1a,%edx 1e88: 01 d0 add %edx,%eax 1e8a: 83 e0 3f and $0x3f,%eax 1e8d: 29 d0 sub %edx,%eax 1e8f: 83 c0 30 add $0x30,%eax 1e92: 88 45 e8 mov %al,-0x18(%ebp) name[3] = '\0'; 1e95: c6 45 e9 00 movb $0x0,-0x17(%ebp) if(link("bd", name) != 0){ 1e99: 8d 45 e6 lea -0x1a(%ebp),%eax 1e9c: 89 44 24 04 mov %eax,0x4(%esp) 1ea0: c7 04 24 a0 4d 00 00 movl $0x4da0,(%esp) 1ea7: e8 69 20 00 00 call 3f15 <link> 1eac: 85 c0 test %eax,%eax 1eae: 74 19 je 1ec9 <bigdir+0xd0> printf(1, "bigdir link failed\n"); 1eb0: c7 44 24 04 b9 4d 00 movl $0x4db9,0x4(%esp) 1eb7: 00 1eb8: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1ebf: e8 81 21 00 00 call 4045 <printf> exit(); 1ec4: e8 ec 1f 00 00 call 3eb5 <exit> printf(1, "bigdir create failed\n"); exit(); } close(fd); for(i = 0; i < 500; i++){ 1ec9: 83 45 f4 01 addl $0x1,-0xc(%ebp) 1ecd: 81 7d f4 f3 01 00 00 cmpl $0x1f3,-0xc(%ebp) 1ed4: 7e 93 jle 1e69 <bigdir+0x70> printf(1, "bigdir link failed\n"); exit(); } } unlink("bd"); 1ed6: c7 04 24 a0 4d 00 00 movl $0x4da0,(%esp) 1edd: e8 23 20 00 00 call 3f05 <unlink> for(i = 0; i < 500; i++){ 1ee2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1ee9: eb 5c jmp 1f47 <bigdir+0x14e> name[0] = 'x'; 1eeb: c6 45 e6 78 movb $0x78,-0x1a(%ebp) name[1] = '0' + (i / 64); 1eef: 8b 45 f4 mov -0xc(%ebp),%eax 1ef2: 8d 50 3f lea 0x3f(%eax),%edx 1ef5: 85 c0 test %eax,%eax 1ef7: 0f 48 c2 cmovs %edx,%eax 1efa: c1 f8 06 sar $0x6,%eax 1efd: 83 c0 30 add $0x30,%eax 1f00: 88 45 e7 mov %al,-0x19(%ebp) name[2] = '0' + (i % 64); 1f03: 8b 45 f4 mov -0xc(%ebp),%eax 1f06: 99 cltd 1f07: c1 ea 1a shr $0x1a,%edx 1f0a: 01 d0 add %edx,%eax 1f0c: 83 e0 3f and $0x3f,%eax 1f0f: 29 d0 sub %edx,%eax 1f11: 83 c0 30 add $0x30,%eax 1f14: 88 45 e8 mov %al,-0x18(%ebp) name[3] = '\0'; 1f17: c6 45 e9 00 movb $0x0,-0x17(%ebp) if(unlink(name) != 0){ 1f1b: 8d 45 e6 lea -0x1a(%ebp),%eax 1f1e: 89 04 24 mov %eax,(%esp) 1f21: e8 df 1f 00 00 call 3f05 <unlink> 1f26: 85 c0 test %eax,%eax 1f28: 74 19 je 1f43 <bigdir+0x14a> printf(1, "bigdir unlink failed"); 1f2a: c7 44 24 04 cd 4d 00 movl $0x4dcd,0x4(%esp) 1f31: 00 1f32: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1f39: e8 07 21 00 00 call 4045 <printf> exit(); 1f3e: e8 72 1f 00 00 call 3eb5 <exit> exit(); } } unlink("bd"); for(i = 0; i < 500; i++){ 1f43: 83 45 f4 01 addl $0x1,-0xc(%ebp) 1f47: 81 7d f4 f3 01 00 00 cmpl $0x1f3,-0xc(%ebp) 1f4e: 7e 9b jle 1eeb <bigdir+0xf2> printf(1, "bigdir unlink failed"); exit(); } } printf(1, "bigdir ok\n"); 1f50: c7 44 24 04 e2 4d 00 movl $0x4de2,0x4(%esp) 1f57: 00 1f58: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1f5f: e8 e1 20 00 00 call 4045 <printf> } 1f64: c9 leave 1f65: c3 ret 00001f66 <subdir>: void subdir(void) { 1f66: 55 push %ebp 1f67: 89 e5 mov %esp,%ebp 1f69: 83 ec 28 sub $0x28,%esp int fd, cc; printf(1, "subdir test\n"); 1f6c: c7 44 24 04 ed 4d 00 movl $0x4ded,0x4(%esp) 1f73: 00 1f74: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1f7b: e8 c5 20 00 00 call 4045 <printf> unlink("ff"); 1f80: c7 04 24 fa 4d 00 00 movl $0x4dfa,(%esp) 1f87: e8 79 1f 00 00 call 3f05 <unlink> if(mkdir("dd") != 0){ 1f8c: c7 04 24 fd 4d 00 00 movl $0x4dfd,(%esp) 1f93: e8 85 1f 00 00 call 3f1d <mkdir> 1f98: 85 c0 test %eax,%eax 1f9a: 74 19 je 1fb5 <subdir+0x4f> printf(1, "subdir mkdir dd failed\n"); 1f9c: c7 44 24 04 00 4e 00 movl $0x4e00,0x4(%esp) 1fa3: 00 1fa4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1fab: e8 95 20 00 00 call 4045 <printf> exit(); 1fb0: e8 00 1f 00 00 call 3eb5 <exit> } fd = open("dd/ff", O_CREATE | O_RDWR); 1fb5: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1fbc: 00 1fbd: c7 04 24 18 4e 00 00 movl $0x4e18,(%esp) 1fc4: e8 2c 1f 00 00 call 3ef5 <open> 1fc9: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 1fcc: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1fd0: 79 19 jns 1feb <subdir+0x85> printf(1, "create dd/ff failed\n"); 1fd2: c7 44 24 04 1e 4e 00 movl $0x4e1e,0x4(%esp) 1fd9: 00 1fda: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1fe1: e8 5f 20 00 00 call 4045 <printf> exit(); 1fe6: e8 ca 1e 00 00 call 3eb5 <exit> } write(fd, "ff", 2); 1feb: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp) 1ff2: 00 1ff3: c7 44 24 04 fa 4d 00 movl $0x4dfa,0x4(%esp) 1ffa: 00 1ffb: 8b 45 f4 mov -0xc(%ebp),%eax 1ffe: 89 04 24 mov %eax,(%esp) 2001: e8 cf 1e 00 00 call 3ed5 <write> close(fd); 2006: 8b 45 f4 mov -0xc(%ebp),%eax 2009: 89 04 24 mov %eax,(%esp) 200c: e8 cc 1e 00 00 call 3edd <close> if(unlink("dd") >= 0){ 2011: c7 04 24 fd 4d 00 00 movl $0x4dfd,(%esp) 2018: e8 e8 1e 00 00 call 3f05 <unlink> 201d: 85 c0 test %eax,%eax 201f: 78 19 js 203a <subdir+0xd4> printf(1, "unlink dd (non-empty dir) succeeded!\n"); 2021: c7 44 24 04 34 4e 00 movl $0x4e34,0x4(%esp) 2028: 00 2029: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2030: e8 10 20 00 00 call 4045 <printf> exit(); 2035: e8 7b 1e 00 00 call 3eb5 <exit> } if(mkdir("/dd/dd") != 0){ 203a: c7 04 24 5a 4e 00 00 movl $0x4e5a,(%esp) 2041: e8 d7 1e 00 00 call 3f1d <mkdir> 2046: 85 c0 test %eax,%eax 2048: 74 19 je 2063 <subdir+0xfd> printf(1, "subdir mkdir dd/dd failed\n"); 204a: c7 44 24 04 61 4e 00 movl $0x4e61,0x4(%esp) 2051: 00 2052: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2059: e8 e7 1f 00 00 call 4045 <printf> exit(); 205e: e8 52 1e 00 00 call 3eb5 <exit> } fd = open("dd/dd/ff", O_CREATE | O_RDWR); 2063: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 206a: 00 206b: c7 04 24 7c 4e 00 00 movl $0x4e7c,(%esp) 2072: e8 7e 1e 00 00 call 3ef5 <open> 2077: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 207a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 207e: 79 19 jns 2099 <subdir+0x133> printf(1, "create dd/dd/ff failed\n"); 2080: c7 44 24 04 85 4e 00 movl $0x4e85,0x4(%esp) 2087: 00 2088: c7 04 24 01 00 00 00 movl $0x1,(%esp) 208f: e8 b1 1f 00 00 call 4045 <printf> exit(); 2094: e8 1c 1e 00 00 call 3eb5 <exit> } write(fd, "FF", 2); 2099: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp) 20a0: 00 20a1: c7 44 24 04 9d 4e 00 movl $0x4e9d,0x4(%esp) 20a8: 00 20a9: 8b 45 f4 mov -0xc(%ebp),%eax 20ac: 89 04 24 mov %eax,(%esp) 20af: e8 21 1e 00 00 call 3ed5 <write> close(fd); 20b4: 8b 45 f4 mov -0xc(%ebp),%eax 20b7: 89 04 24 mov %eax,(%esp) 20ba: e8 1e 1e 00 00 call 3edd <close> fd = open("dd/dd/../ff", 0); 20bf: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 20c6: 00 20c7: c7 04 24 a0 4e 00 00 movl $0x4ea0,(%esp) 20ce: e8 22 1e 00 00 call 3ef5 <open> 20d3: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 20d6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 20da: 79 19 jns 20f5 <subdir+0x18f> printf(1, "open dd/dd/../ff failed\n"); 20dc: c7 44 24 04 ac 4e 00 movl $0x4eac,0x4(%esp) 20e3: 00 20e4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 20eb: e8 55 1f 00 00 call 4045 <printf> exit(); 20f0: e8 c0 1d 00 00 call 3eb5 <exit> } cc = read(fd, buf, sizeof(buf)); 20f5: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) 20fc: 00 20fd: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 2104: 00 2105: 8b 45 f4 mov -0xc(%ebp),%eax 2108: 89 04 24 mov %eax,(%esp) 210b: e8 bd 1d 00 00 call 3ecd <read> 2110: 89 45 f0 mov %eax,-0x10(%ebp) if(cc != 2 || buf[0] != 'f'){ 2113: 83 7d f0 02 cmpl $0x2,-0x10(%ebp) 2117: 75 0b jne 2124 <subdir+0x1be> 2119: 0f b6 05 c0 8a 00 00 movzbl 0x8ac0,%eax 2120: 3c 66 cmp $0x66,%al 2122: 74 19 je 213d <subdir+0x1d7> printf(1, "dd/dd/../ff wrong content\n"); 2124: c7 44 24 04 c5 4e 00 movl $0x4ec5,0x4(%esp) 212b: 00 212c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2133: e8 0d 1f 00 00 call 4045 <printf> exit(); 2138: e8 78 1d 00 00 call 3eb5 <exit> } close(fd); 213d: 8b 45 f4 mov -0xc(%ebp),%eax 2140: 89 04 24 mov %eax,(%esp) 2143: e8 95 1d 00 00 call 3edd <close> if(link("dd/dd/ff", "dd/dd/ffff") != 0){ 2148: c7 44 24 04 e0 4e 00 movl $0x4ee0,0x4(%esp) 214f: 00 2150: c7 04 24 7c 4e 00 00 movl $0x4e7c,(%esp) 2157: e8 b9 1d 00 00 call 3f15 <link> 215c: 85 c0 test %eax,%eax 215e: 74 19 je 2179 <subdir+0x213> printf(1, "link dd/dd/ff dd/dd/ffff failed\n"); 2160: c7 44 24 04 ec 4e 00 movl $0x4eec,0x4(%esp) 2167: 00 2168: c7 04 24 01 00 00 00 movl $0x1,(%esp) 216f: e8 d1 1e 00 00 call 4045 <printf> exit(); 2174: e8 3c 1d 00 00 call 3eb5 <exit> } if(unlink("dd/dd/ff") != 0){ 2179: c7 04 24 7c 4e 00 00 movl $0x4e7c,(%esp) 2180: e8 80 1d 00 00 call 3f05 <unlink> 2185: 85 c0 test %eax,%eax 2187: 74 19 je 21a2 <subdir+0x23c> printf(1, "unlink dd/dd/ff failed\n"); 2189: c7 44 24 04 0d 4f 00 movl $0x4f0d,0x4(%esp) 2190: 00 2191: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2198: e8 a8 1e 00 00 call 4045 <printf> exit(); 219d: e8 13 1d 00 00 call 3eb5 <exit> } if(open("dd/dd/ff", O_RDONLY) >= 0){ 21a2: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 21a9: 00 21aa: c7 04 24 7c 4e 00 00 movl $0x4e7c,(%esp) 21b1: e8 3f 1d 00 00 call 3ef5 <open> 21b6: 85 c0 test %eax,%eax 21b8: 78 19 js 21d3 <subdir+0x26d> printf(1, "open (unlinked) dd/dd/ff succeeded\n"); 21ba: c7 44 24 04 28 4f 00 movl $0x4f28,0x4(%esp) 21c1: 00 21c2: c7 04 24 01 00 00 00 movl $0x1,(%esp) 21c9: e8 77 1e 00 00 call 4045 <printf> exit(); 21ce: e8 e2 1c 00 00 call 3eb5 <exit> } if(chdir("dd") != 0){ 21d3: c7 04 24 fd 4d 00 00 movl $0x4dfd,(%esp) 21da: e8 46 1d 00 00 call 3f25 <chdir> 21df: 85 c0 test %eax,%eax 21e1: 74 19 je 21fc <subdir+0x296> printf(1, "chdir dd failed\n"); 21e3: c7 44 24 04 4c 4f 00 movl $0x4f4c,0x4(%esp) 21ea: 00 21eb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 21f2: e8 4e 1e 00 00 call 4045 <printf> exit(); 21f7: e8 b9 1c 00 00 call 3eb5 <exit> } if(chdir("dd/../../dd") != 0){ 21fc: c7 04 24 5d 4f 00 00 movl $0x4f5d,(%esp) 2203: e8 1d 1d 00 00 call 3f25 <chdir> 2208: 85 c0 test %eax,%eax 220a: 74 19 je 2225 <subdir+0x2bf> printf(1, "chdir dd/../../dd failed\n"); 220c: c7 44 24 04 69 4f 00 movl $0x4f69,0x4(%esp) 2213: 00 2214: c7 04 24 01 00 00 00 movl $0x1,(%esp) 221b: e8 25 1e 00 00 call 4045 <printf> exit(); 2220: e8 90 1c 00 00 call 3eb5 <exit> } if(chdir("dd/../../../dd") != 0){ 2225: c7 04 24 83 4f 00 00 movl $0x4f83,(%esp) 222c: e8 f4 1c 00 00 call 3f25 <chdir> 2231: 85 c0 test %eax,%eax 2233: 74 19 je 224e <subdir+0x2e8> printf(1, "chdir dd/../../dd failed\n"); 2235: c7 44 24 04 69 4f 00 movl $0x4f69,0x4(%esp) 223c: 00 223d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2244: e8 fc 1d 00 00 call 4045 <printf> exit(); 2249: e8 67 1c 00 00 call 3eb5 <exit> } if(chdir("./..") != 0){ 224e: c7 04 24 92 4f 00 00 movl $0x4f92,(%esp) 2255: e8 cb 1c 00 00 call 3f25 <chdir> 225a: 85 c0 test %eax,%eax 225c: 74 19 je 2277 <subdir+0x311> printf(1, "chdir ./.. failed\n"); 225e: c7 44 24 04 97 4f 00 movl $0x4f97,0x4(%esp) 2265: 00 2266: c7 04 24 01 00 00 00 movl $0x1,(%esp) 226d: e8 d3 1d 00 00 call 4045 <printf> exit(); 2272: e8 3e 1c 00 00 call 3eb5 <exit> } fd = open("dd/dd/ffff", 0); 2277: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 227e: 00 227f: c7 04 24 e0 4e 00 00 movl $0x4ee0,(%esp) 2286: e8 6a 1c 00 00 call 3ef5 <open> 228b: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 228e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2292: 79 19 jns 22ad <subdir+0x347> printf(1, "open dd/dd/ffff failed\n"); 2294: c7 44 24 04 aa 4f 00 movl $0x4faa,0x4(%esp) 229b: 00 229c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 22a3: e8 9d 1d 00 00 call 4045 <printf> exit(); 22a8: e8 08 1c 00 00 call 3eb5 <exit> } if(read(fd, buf, sizeof(buf)) != 2){ 22ad: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) 22b4: 00 22b5: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 22bc: 00 22bd: 8b 45 f4 mov -0xc(%ebp),%eax 22c0: 89 04 24 mov %eax,(%esp) 22c3: e8 05 1c 00 00 call 3ecd <read> 22c8: 83 f8 02 cmp $0x2,%eax 22cb: 74 19 je 22e6 <subdir+0x380> printf(1, "read dd/dd/ffff wrong len\n"); 22cd: c7 44 24 04 c2 4f 00 movl $0x4fc2,0x4(%esp) 22d4: 00 22d5: c7 04 24 01 00 00 00 movl $0x1,(%esp) 22dc: e8 64 1d 00 00 call 4045 <printf> exit(); 22e1: e8 cf 1b 00 00 call 3eb5 <exit> } close(fd); 22e6: 8b 45 f4 mov -0xc(%ebp),%eax 22e9: 89 04 24 mov %eax,(%esp) 22ec: e8 ec 1b 00 00 call 3edd <close> if(open("dd/dd/ff", O_RDONLY) >= 0){ 22f1: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 22f8: 00 22f9: c7 04 24 7c 4e 00 00 movl $0x4e7c,(%esp) 2300: e8 f0 1b 00 00 call 3ef5 <open> 2305: 85 c0 test %eax,%eax 2307: 78 19 js 2322 <subdir+0x3bc> printf(1, "open (unlinked) dd/dd/ff succeeded!\n"); 2309: c7 44 24 04 e0 4f 00 movl $0x4fe0,0x4(%esp) 2310: 00 2311: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2318: e8 28 1d 00 00 call 4045 <printf> exit(); 231d: e8 93 1b 00 00 call 3eb5 <exit> } if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){ 2322: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 2329: 00 232a: c7 04 24 05 50 00 00 movl $0x5005,(%esp) 2331: e8 bf 1b 00 00 call 3ef5 <open> 2336: 85 c0 test %eax,%eax 2338: 78 19 js 2353 <subdir+0x3ed> printf(1, "create dd/ff/ff succeeded!\n"); 233a: c7 44 24 04 0e 50 00 movl $0x500e,0x4(%esp) 2341: 00 2342: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2349: e8 f7 1c 00 00 call 4045 <printf> exit(); 234e: e8 62 1b 00 00 call 3eb5 <exit> } if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){ 2353: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 235a: 00 235b: c7 04 24 2a 50 00 00 movl $0x502a,(%esp) 2362: e8 8e 1b 00 00 call 3ef5 <open> 2367: 85 c0 test %eax,%eax 2369: 78 19 js 2384 <subdir+0x41e> printf(1, "create dd/xx/ff succeeded!\n"); 236b: c7 44 24 04 33 50 00 movl $0x5033,0x4(%esp) 2372: 00 2373: c7 04 24 01 00 00 00 movl $0x1,(%esp) 237a: e8 c6 1c 00 00 call 4045 <printf> exit(); 237f: e8 31 1b 00 00 call 3eb5 <exit> } if(open("dd", O_CREATE) >= 0){ 2384: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 238b: 00 238c: c7 04 24 fd 4d 00 00 movl $0x4dfd,(%esp) 2393: e8 5d 1b 00 00 call 3ef5 <open> 2398: 85 c0 test %eax,%eax 239a: 78 19 js 23b5 <subdir+0x44f> printf(1, "create dd succeeded!\n"); 239c: c7 44 24 04 4f 50 00 movl $0x504f,0x4(%esp) 23a3: 00 23a4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 23ab: e8 95 1c 00 00 call 4045 <printf> exit(); 23b0: e8 00 1b 00 00 call 3eb5 <exit> } if(open("dd", O_RDWR) >= 0){ 23b5: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) 23bc: 00 23bd: c7 04 24 fd 4d 00 00 movl $0x4dfd,(%esp) 23c4: e8 2c 1b 00 00 call 3ef5 <open> 23c9: 85 c0 test %eax,%eax 23cb: 78 19 js 23e6 <subdir+0x480> printf(1, "open dd rdwr succeeded!\n"); 23cd: c7 44 24 04 65 50 00 movl $0x5065,0x4(%esp) 23d4: 00 23d5: c7 04 24 01 00 00 00 movl $0x1,(%esp) 23dc: e8 64 1c 00 00 call 4045 <printf> exit(); 23e1: e8 cf 1a 00 00 call 3eb5 <exit> } if(open("dd", O_WRONLY) >= 0){ 23e6: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 23ed: 00 23ee: c7 04 24 fd 4d 00 00 movl $0x4dfd,(%esp) 23f5: e8 fb 1a 00 00 call 3ef5 <open> 23fa: 85 c0 test %eax,%eax 23fc: 78 19 js 2417 <subdir+0x4b1> printf(1, "open dd wronly succeeded!\n"); 23fe: c7 44 24 04 7e 50 00 movl $0x507e,0x4(%esp) 2405: 00 2406: c7 04 24 01 00 00 00 movl $0x1,(%esp) 240d: e8 33 1c 00 00 call 4045 <printf> exit(); 2412: e8 9e 1a 00 00 call 3eb5 <exit> } if(link("dd/ff/ff", "dd/dd/xx") == 0){ 2417: c7 44 24 04 99 50 00 movl $0x5099,0x4(%esp) 241e: 00 241f: c7 04 24 05 50 00 00 movl $0x5005,(%esp) 2426: e8 ea 1a 00 00 call 3f15 <link> 242b: 85 c0 test %eax,%eax 242d: 75 19 jne 2448 <subdir+0x4e2> printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n"); 242f: c7 44 24 04 a4 50 00 movl $0x50a4,0x4(%esp) 2436: 00 2437: c7 04 24 01 00 00 00 movl $0x1,(%esp) 243e: e8 02 1c 00 00 call 4045 <printf> exit(); 2443: e8 6d 1a 00 00 call 3eb5 <exit> } if(link("dd/xx/ff", "dd/dd/xx") == 0){ 2448: c7 44 24 04 99 50 00 movl $0x5099,0x4(%esp) 244f: 00 2450: c7 04 24 2a 50 00 00 movl $0x502a,(%esp) 2457: e8 b9 1a 00 00 call 3f15 <link> 245c: 85 c0 test %eax,%eax 245e: 75 19 jne 2479 <subdir+0x513> printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n"); 2460: c7 44 24 04 c8 50 00 movl $0x50c8,0x4(%esp) 2467: 00 2468: c7 04 24 01 00 00 00 movl $0x1,(%esp) 246f: e8 d1 1b 00 00 call 4045 <printf> exit(); 2474: e8 3c 1a 00 00 call 3eb5 <exit> } if(link("dd/ff", "dd/dd/ffff") == 0){ 2479: c7 44 24 04 e0 4e 00 movl $0x4ee0,0x4(%esp) 2480: 00 2481: c7 04 24 18 4e 00 00 movl $0x4e18,(%esp) 2488: e8 88 1a 00 00 call 3f15 <link> 248d: 85 c0 test %eax,%eax 248f: 75 19 jne 24aa <subdir+0x544> printf(1, "link dd/ff dd/dd/ffff succeeded!\n"); 2491: c7 44 24 04 ec 50 00 movl $0x50ec,0x4(%esp) 2498: 00 2499: c7 04 24 01 00 00 00 movl $0x1,(%esp) 24a0: e8 a0 1b 00 00 call 4045 <printf> exit(); 24a5: e8 0b 1a 00 00 call 3eb5 <exit> } if(mkdir("dd/ff/ff") == 0){ 24aa: c7 04 24 05 50 00 00 movl $0x5005,(%esp) 24b1: e8 67 1a 00 00 call 3f1d <mkdir> 24b6: 85 c0 test %eax,%eax 24b8: 75 19 jne 24d3 <subdir+0x56d> printf(1, "mkdir dd/ff/ff succeeded!\n"); 24ba: c7 44 24 04 0e 51 00 movl $0x510e,0x4(%esp) 24c1: 00 24c2: c7 04 24 01 00 00 00 movl $0x1,(%esp) 24c9: e8 77 1b 00 00 call 4045 <printf> exit(); 24ce: e8 e2 19 00 00 call 3eb5 <exit> } if(mkdir("dd/xx/ff") == 0){ 24d3: c7 04 24 2a 50 00 00 movl $0x502a,(%esp) 24da: e8 3e 1a 00 00 call 3f1d <mkdir> 24df: 85 c0 test %eax,%eax 24e1: 75 19 jne 24fc <subdir+0x596> printf(1, "mkdir dd/xx/ff succeeded!\n"); 24e3: c7 44 24 04 29 51 00 movl $0x5129,0x4(%esp) 24ea: 00 24eb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 24f2: e8 4e 1b 00 00 call 4045 <printf> exit(); 24f7: e8 b9 19 00 00 call 3eb5 <exit> } if(mkdir("dd/dd/ffff") == 0){ 24fc: c7 04 24 e0 4e 00 00 movl $0x4ee0,(%esp) 2503: e8 15 1a 00 00 call 3f1d <mkdir> 2508: 85 c0 test %eax,%eax 250a: 75 19 jne 2525 <subdir+0x5bf> printf(1, "mkdir dd/dd/ffff succeeded!\n"); 250c: c7 44 24 04 44 51 00 movl $0x5144,0x4(%esp) 2513: 00 2514: c7 04 24 01 00 00 00 movl $0x1,(%esp) 251b: e8 25 1b 00 00 call 4045 <printf> exit(); 2520: e8 90 19 00 00 call 3eb5 <exit> } if(unlink("dd/xx/ff") == 0){ 2525: c7 04 24 2a 50 00 00 movl $0x502a,(%esp) 252c: e8 d4 19 00 00 call 3f05 <unlink> 2531: 85 c0 test %eax,%eax 2533: 75 19 jne 254e <subdir+0x5e8> printf(1, "unlink dd/xx/ff succeeded!\n"); 2535: c7 44 24 04 61 51 00 movl $0x5161,0x4(%esp) 253c: 00 253d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2544: e8 fc 1a 00 00 call 4045 <printf> exit(); 2549: e8 67 19 00 00 call 3eb5 <exit> } if(unlink("dd/ff/ff") == 0){ 254e: c7 04 24 05 50 00 00 movl $0x5005,(%esp) 2555: e8 ab 19 00 00 call 3f05 <unlink> 255a: 85 c0 test %eax,%eax 255c: 75 19 jne 2577 <subdir+0x611> printf(1, "unlink dd/ff/ff succeeded!\n"); 255e: c7 44 24 04 7d 51 00 movl $0x517d,0x4(%esp) 2565: 00 2566: c7 04 24 01 00 00 00 movl $0x1,(%esp) 256d: e8 d3 1a 00 00 call 4045 <printf> exit(); 2572: e8 3e 19 00 00 call 3eb5 <exit> } if(chdir("dd/ff") == 0){ 2577: c7 04 24 18 4e 00 00 movl $0x4e18,(%esp) 257e: e8 a2 19 00 00 call 3f25 <chdir> 2583: 85 c0 test %eax,%eax 2585: 75 19 jne 25a0 <subdir+0x63a> printf(1, "chdir dd/ff succeeded!\n"); 2587: c7 44 24 04 99 51 00 movl $0x5199,0x4(%esp) 258e: 00 258f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2596: e8 aa 1a 00 00 call 4045 <printf> exit(); 259b: e8 15 19 00 00 call 3eb5 <exit> } if(chdir("dd/xx") == 0){ 25a0: c7 04 24 b1 51 00 00 movl $0x51b1,(%esp) 25a7: e8 79 19 00 00 call 3f25 <chdir> 25ac: 85 c0 test %eax,%eax 25ae: 75 19 jne 25c9 <subdir+0x663> printf(1, "chdir dd/xx succeeded!\n"); 25b0: c7 44 24 04 b7 51 00 movl $0x51b7,0x4(%esp) 25b7: 00 25b8: c7 04 24 01 00 00 00 movl $0x1,(%esp) 25bf: e8 81 1a 00 00 call 4045 <printf> exit(); 25c4: e8 ec 18 00 00 call 3eb5 <exit> } if(unlink("dd/dd/ffff") != 0){ 25c9: c7 04 24 e0 4e 00 00 movl $0x4ee0,(%esp) 25d0: e8 30 19 00 00 call 3f05 <unlink> 25d5: 85 c0 test %eax,%eax 25d7: 74 19 je 25f2 <subdir+0x68c> printf(1, "unlink dd/dd/ff failed\n"); 25d9: c7 44 24 04 0d 4f 00 movl $0x4f0d,0x4(%esp) 25e0: 00 25e1: c7 04 24 01 00 00 00 movl $0x1,(%esp) 25e8: e8 58 1a 00 00 call 4045 <printf> exit(); 25ed: e8 c3 18 00 00 call 3eb5 <exit> } if(unlink("dd/ff") != 0){ 25f2: c7 04 24 18 4e 00 00 movl $0x4e18,(%esp) 25f9: e8 07 19 00 00 call 3f05 <unlink> 25fe: 85 c0 test %eax,%eax 2600: 74 19 je 261b <subdir+0x6b5> printf(1, "unlink dd/ff failed\n"); 2602: c7 44 24 04 cf 51 00 movl $0x51cf,0x4(%esp) 2609: 00 260a: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2611: e8 2f 1a 00 00 call 4045 <printf> exit(); 2616: e8 9a 18 00 00 call 3eb5 <exit> } if(unlink("dd") == 0){ 261b: c7 04 24 fd 4d 00 00 movl $0x4dfd,(%esp) 2622: e8 de 18 00 00 call 3f05 <unlink> 2627: 85 c0 test %eax,%eax 2629: 75 19 jne 2644 <subdir+0x6de> printf(1, "unlink non-empty dd succeeded!\n"); 262b: c7 44 24 04 e4 51 00 movl $0x51e4,0x4(%esp) 2632: 00 2633: c7 04 24 01 00 00 00 movl $0x1,(%esp) 263a: e8 06 1a 00 00 call 4045 <printf> exit(); 263f: e8 71 18 00 00 call 3eb5 <exit> } if(unlink("dd/dd") < 0){ 2644: c7 04 24 04 52 00 00 movl $0x5204,(%esp) 264b: e8 b5 18 00 00 call 3f05 <unlink> 2650: 85 c0 test %eax,%eax 2652: 79 19 jns 266d <subdir+0x707> printf(1, "unlink dd/dd failed\n"); 2654: c7 44 24 04 0a 52 00 movl $0x520a,0x4(%esp) 265b: 00 265c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2663: e8 dd 19 00 00 call 4045 <printf> exit(); 2668: e8 48 18 00 00 call 3eb5 <exit> } if(unlink("dd") < 0){ 266d: c7 04 24 fd 4d 00 00 movl $0x4dfd,(%esp) 2674: e8 8c 18 00 00 call 3f05 <unlink> 2679: 85 c0 test %eax,%eax 267b: 79 19 jns 2696 <subdir+0x730> printf(1, "unlink dd failed\n"); 267d: c7 44 24 04 1f 52 00 movl $0x521f,0x4(%esp) 2684: 00 2685: c7 04 24 01 00 00 00 movl $0x1,(%esp) 268c: e8 b4 19 00 00 call 4045 <printf> exit(); 2691: e8 1f 18 00 00 call 3eb5 <exit> } printf(1, "subdir ok\n"); 2696: c7 44 24 04 31 52 00 movl $0x5231,0x4(%esp) 269d: 00 269e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 26a5: e8 9b 19 00 00 call 4045 <printf> } 26aa: c9 leave 26ab: c3 ret 000026ac <bigwrite>: // test writes that are larger than the log. void bigwrite(void) { 26ac: 55 push %ebp 26ad: 89 e5 mov %esp,%ebp 26af: 83 ec 28 sub $0x28,%esp int fd, sz; printf(1, "bigwrite test\n"); 26b2: c7 44 24 04 3c 52 00 movl $0x523c,0x4(%esp) 26b9: 00 26ba: c7 04 24 01 00 00 00 movl $0x1,(%esp) 26c1: e8 7f 19 00 00 call 4045 <printf> unlink("bigwrite"); 26c6: c7 04 24 4b 52 00 00 movl $0x524b,(%esp) 26cd: e8 33 18 00 00 call 3f05 <unlink> for(sz = 499; sz < 12*512; sz += 471){ 26d2: c7 45 f4 f3 01 00 00 movl $0x1f3,-0xc(%ebp) 26d9: e9 b3 00 00 00 jmp 2791 <bigwrite+0xe5> fd = open("bigwrite", O_CREATE | O_RDWR); 26de: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 26e5: 00 26e6: c7 04 24 4b 52 00 00 movl $0x524b,(%esp) 26ed: e8 03 18 00 00 call 3ef5 <open> 26f2: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 26f5: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 26f9: 79 19 jns 2714 <bigwrite+0x68> printf(1, "cannot create bigwrite\n"); 26fb: c7 44 24 04 54 52 00 movl $0x5254,0x4(%esp) 2702: 00 2703: c7 04 24 01 00 00 00 movl $0x1,(%esp) 270a: e8 36 19 00 00 call 4045 <printf> exit(); 270f: e8 a1 17 00 00 call 3eb5 <exit> } int i; for(i = 0; i < 2; i++){ 2714: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 271b: eb 50 jmp 276d <bigwrite+0xc1> int cc = write(fd, buf, sz); 271d: 8b 45 f4 mov -0xc(%ebp),%eax 2720: 89 44 24 08 mov %eax,0x8(%esp) 2724: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 272b: 00 272c: 8b 45 ec mov -0x14(%ebp),%eax 272f: 89 04 24 mov %eax,(%esp) 2732: e8 9e 17 00 00 call 3ed5 <write> 2737: 89 45 e8 mov %eax,-0x18(%ebp) if(cc != sz){ 273a: 8b 45 e8 mov -0x18(%ebp),%eax 273d: 3b 45 f4 cmp -0xc(%ebp),%eax 2740: 74 27 je 2769 <bigwrite+0xbd> printf(1, "write(%d) ret %d\n", sz, cc); 2742: 8b 45 e8 mov -0x18(%ebp),%eax 2745: 89 44 24 0c mov %eax,0xc(%esp) 2749: 8b 45 f4 mov -0xc(%ebp),%eax 274c: 89 44 24 08 mov %eax,0x8(%esp) 2750: c7 44 24 04 6c 52 00 movl $0x526c,0x4(%esp) 2757: 00 2758: c7 04 24 01 00 00 00 movl $0x1,(%esp) 275f: e8 e1 18 00 00 call 4045 <printf> exit(); 2764: e8 4c 17 00 00 call 3eb5 <exit> if(fd < 0){ printf(1, "cannot create bigwrite\n"); exit(); } int i; for(i = 0; i < 2; i++){ 2769: 83 45 f0 01 addl $0x1,-0x10(%ebp) 276d: 83 7d f0 01 cmpl $0x1,-0x10(%ebp) 2771: 7e aa jle 271d <bigwrite+0x71> if(cc != sz){ printf(1, "write(%d) ret %d\n", sz, cc); exit(); } } close(fd); 2773: 8b 45 ec mov -0x14(%ebp),%eax 2776: 89 04 24 mov %eax,(%esp) 2779: e8 5f 17 00 00 call 3edd <close> unlink("bigwrite"); 277e: c7 04 24 4b 52 00 00 movl $0x524b,(%esp) 2785: e8 7b 17 00 00 call 3f05 <unlink> int fd, sz; printf(1, "bigwrite test\n"); unlink("bigwrite"); for(sz = 499; sz < 12*512; sz += 471){ 278a: 81 45 f4 d7 01 00 00 addl $0x1d7,-0xc(%ebp) 2791: 81 7d f4 ff 17 00 00 cmpl $0x17ff,-0xc(%ebp) 2798: 0f 8e 40 ff ff ff jle 26de <bigwrite+0x32> } close(fd); unlink("bigwrite"); } printf(1, "bigwrite ok\n"); 279e: c7 44 24 04 7e 52 00 movl $0x527e,0x4(%esp) 27a5: 00 27a6: c7 04 24 01 00 00 00 movl $0x1,(%esp) 27ad: e8 93 18 00 00 call 4045 <printf> } 27b2: c9 leave 27b3: c3 ret 000027b4 <bigfile>: void bigfile(void) { 27b4: 55 push %ebp 27b5: 89 e5 mov %esp,%ebp 27b7: 83 ec 28 sub $0x28,%esp int fd, i, total, cc; printf(1, "bigfile test\n"); 27ba: c7 44 24 04 8b 52 00 movl $0x528b,0x4(%esp) 27c1: 00 27c2: c7 04 24 01 00 00 00 movl $0x1,(%esp) 27c9: e8 77 18 00 00 call 4045 <printf> unlink("bigfile"); 27ce: c7 04 24 99 52 00 00 movl $0x5299,(%esp) 27d5: e8 2b 17 00 00 call 3f05 <unlink> fd = open("bigfile", O_CREATE | O_RDWR); 27da: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 27e1: 00 27e2: c7 04 24 99 52 00 00 movl $0x5299,(%esp) 27e9: e8 07 17 00 00 call 3ef5 <open> 27ee: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 27f1: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 27f5: 79 19 jns 2810 <bigfile+0x5c> printf(1, "cannot create bigfile"); 27f7: c7 44 24 04 a1 52 00 movl $0x52a1,0x4(%esp) 27fe: 00 27ff: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2806: e8 3a 18 00 00 call 4045 <printf> exit(); 280b: e8 a5 16 00 00 call 3eb5 <exit> } for(i = 0; i < 20; i++){ 2810: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 2817: eb 5a jmp 2873 <bigfile+0xbf> memset(buf, i, 600); 2819: c7 44 24 08 58 02 00 movl $0x258,0x8(%esp) 2820: 00 2821: 8b 45 f4 mov -0xc(%ebp),%eax 2824: 89 44 24 04 mov %eax,0x4(%esp) 2828: c7 04 24 c0 8a 00 00 movl $0x8ac0,(%esp) 282f: e8 d4 14 00 00 call 3d08 <memset> if(write(fd, buf, 600) != 600){ 2834: c7 44 24 08 58 02 00 movl $0x258,0x8(%esp) 283b: 00 283c: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 2843: 00 2844: 8b 45 ec mov -0x14(%ebp),%eax 2847: 89 04 24 mov %eax,(%esp) 284a: e8 86 16 00 00 call 3ed5 <write> 284f: 3d 58 02 00 00 cmp $0x258,%eax 2854: 74 19 je 286f <bigfile+0xbb> printf(1, "write bigfile failed\n"); 2856: c7 44 24 04 b7 52 00 movl $0x52b7,0x4(%esp) 285d: 00 285e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2865: e8 db 17 00 00 call 4045 <printf> exit(); 286a: e8 46 16 00 00 call 3eb5 <exit> fd = open("bigfile", O_CREATE | O_RDWR); if(fd < 0){ printf(1, "cannot create bigfile"); exit(); } for(i = 0; i < 20; i++){ 286f: 83 45 f4 01 addl $0x1,-0xc(%ebp) 2873: 83 7d f4 13 cmpl $0x13,-0xc(%ebp) 2877: 7e a0 jle 2819 <bigfile+0x65> if(write(fd, buf, 600) != 600){ printf(1, "write bigfile failed\n"); exit(); } } close(fd); 2879: 8b 45 ec mov -0x14(%ebp),%eax 287c: 89 04 24 mov %eax,(%esp) 287f: e8 59 16 00 00 call 3edd <close> fd = open("bigfile", 0); 2884: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 288b: 00 288c: c7 04 24 99 52 00 00 movl $0x5299,(%esp) 2893: e8 5d 16 00 00 call 3ef5 <open> 2898: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 289b: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 289f: 79 19 jns 28ba <bigfile+0x106> printf(1, "cannot open bigfile\n"); 28a1: c7 44 24 04 cd 52 00 movl $0x52cd,0x4(%esp) 28a8: 00 28a9: c7 04 24 01 00 00 00 movl $0x1,(%esp) 28b0: e8 90 17 00 00 call 4045 <printf> exit(); 28b5: e8 fb 15 00 00 call 3eb5 <exit> } total = 0; 28ba: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) for(i = 0; ; i++){ 28c1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) cc = read(fd, buf, 300); 28c8: c7 44 24 08 2c 01 00 movl $0x12c,0x8(%esp) 28cf: 00 28d0: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 28d7: 00 28d8: 8b 45 ec mov -0x14(%ebp),%eax 28db: 89 04 24 mov %eax,(%esp) 28de: e8 ea 15 00 00 call 3ecd <read> 28e3: 89 45 e8 mov %eax,-0x18(%ebp) if(cc < 0){ 28e6: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 28ea: 79 19 jns 2905 <bigfile+0x151> printf(1, "read bigfile failed\n"); 28ec: c7 44 24 04 e2 52 00 movl $0x52e2,0x4(%esp) 28f3: 00 28f4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 28fb: e8 45 17 00 00 call 4045 <printf> exit(); 2900: e8 b0 15 00 00 call 3eb5 <exit> } if(cc == 0) 2905: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 2909: 75 1b jne 2926 <bigfile+0x172> break; 290b: 90 nop printf(1, "read bigfile wrong data\n"); exit(); } total += cc; } close(fd); 290c: 8b 45 ec mov -0x14(%ebp),%eax 290f: 89 04 24 mov %eax,(%esp) 2912: e8 c6 15 00 00 call 3edd <close> if(total != 20*600){ 2917: 81 7d f0 e0 2e 00 00 cmpl $0x2ee0,-0x10(%ebp) 291e: 0f 84 99 00 00 00 je 29bd <bigfile+0x209> 2924: eb 7e jmp 29a4 <bigfile+0x1f0> printf(1, "read bigfile failed\n"); exit(); } if(cc == 0) break; if(cc != 300){ 2926: 81 7d e8 2c 01 00 00 cmpl $0x12c,-0x18(%ebp) 292d: 74 19 je 2948 <bigfile+0x194> printf(1, "short read bigfile\n"); 292f: c7 44 24 04 f7 52 00 movl $0x52f7,0x4(%esp) 2936: 00 2937: c7 04 24 01 00 00 00 movl $0x1,(%esp) 293e: e8 02 17 00 00 call 4045 <printf> exit(); 2943: e8 6d 15 00 00 call 3eb5 <exit> } if(buf[0] != i/2 || buf[299] != i/2){ 2948: 0f b6 05 c0 8a 00 00 movzbl 0x8ac0,%eax 294f: 0f be d0 movsbl %al,%edx 2952: 8b 45 f4 mov -0xc(%ebp),%eax 2955: 89 c1 mov %eax,%ecx 2957: c1 e9 1f shr $0x1f,%ecx 295a: 01 c8 add %ecx,%eax 295c: d1 f8 sar %eax 295e: 39 c2 cmp %eax,%edx 2960: 75 1a jne 297c <bigfile+0x1c8> 2962: 0f b6 05 eb 8b 00 00 movzbl 0x8beb,%eax 2969: 0f be d0 movsbl %al,%edx 296c: 8b 45 f4 mov -0xc(%ebp),%eax 296f: 89 c1 mov %eax,%ecx 2971: c1 e9 1f shr $0x1f,%ecx 2974: 01 c8 add %ecx,%eax 2976: d1 f8 sar %eax 2978: 39 c2 cmp %eax,%edx 297a: 74 19 je 2995 <bigfile+0x1e1> printf(1, "read bigfile wrong data\n"); 297c: c7 44 24 04 0b 53 00 movl $0x530b,0x4(%esp) 2983: 00 2984: c7 04 24 01 00 00 00 movl $0x1,(%esp) 298b: e8 b5 16 00 00 call 4045 <printf> exit(); 2990: e8 20 15 00 00 call 3eb5 <exit> } total += cc; 2995: 8b 45 e8 mov -0x18(%ebp),%eax 2998: 01 45 f0 add %eax,-0x10(%ebp) if(fd < 0){ printf(1, "cannot open bigfile\n"); exit(); } total = 0; for(i = 0; ; i++){ 299b: 83 45 f4 01 addl $0x1,-0xc(%ebp) if(buf[0] != i/2 || buf[299] != i/2){ printf(1, "read bigfile wrong data\n"); exit(); } total += cc; } 299f: e9 24 ff ff ff jmp 28c8 <bigfile+0x114> close(fd); if(total != 20*600){ printf(1, "read bigfile wrong total\n"); 29a4: c7 44 24 04 24 53 00 movl $0x5324,0x4(%esp) 29ab: 00 29ac: c7 04 24 01 00 00 00 movl $0x1,(%esp) 29b3: e8 8d 16 00 00 call 4045 <printf> exit(); 29b8: e8 f8 14 00 00 call 3eb5 <exit> } unlink("bigfile"); 29bd: c7 04 24 99 52 00 00 movl $0x5299,(%esp) 29c4: e8 3c 15 00 00 call 3f05 <unlink> printf(1, "bigfile test ok\n"); 29c9: c7 44 24 04 3e 53 00 movl $0x533e,0x4(%esp) 29d0: 00 29d1: c7 04 24 01 00 00 00 movl $0x1,(%esp) 29d8: e8 68 16 00 00 call 4045 <printf> } 29dd: c9 leave 29de: c3 ret 000029df <fourteen>: void fourteen(void) { 29df: 55 push %ebp 29e0: 89 e5 mov %esp,%ebp 29e2: 83 ec 28 sub $0x28,%esp int fd; // DIRSIZ is 14. printf(1, "fourteen test\n"); 29e5: c7 44 24 04 4f 53 00 movl $0x534f,0x4(%esp) 29ec: 00 29ed: c7 04 24 01 00 00 00 movl $0x1,(%esp) 29f4: e8 4c 16 00 00 call 4045 <printf> if(mkdir("12345678901234") != 0){ 29f9: c7 04 24 5e 53 00 00 movl $0x535e,(%esp) 2a00: e8 18 15 00 00 call 3f1d <mkdir> 2a05: 85 c0 test %eax,%eax 2a07: 74 19 je 2a22 <fourteen+0x43> printf(1, "mkdir 12345678901234 failed\n"); 2a09: c7 44 24 04 6d 53 00 movl $0x536d,0x4(%esp) 2a10: 00 2a11: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2a18: e8 28 16 00 00 call 4045 <printf> exit(); 2a1d: e8 93 14 00 00 call 3eb5 <exit> } if(mkdir("12345678901234/123456789012345") != 0){ 2a22: c7 04 24 8c 53 00 00 movl $0x538c,(%esp) 2a29: e8 ef 14 00 00 call 3f1d <mkdir> 2a2e: 85 c0 test %eax,%eax 2a30: 74 19 je 2a4b <fourteen+0x6c> printf(1, "mkdir 12345678901234/123456789012345 failed\n"); 2a32: c7 44 24 04 ac 53 00 movl $0x53ac,0x4(%esp) 2a39: 00 2a3a: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2a41: e8 ff 15 00 00 call 4045 <printf> exit(); 2a46: e8 6a 14 00 00 call 3eb5 <exit> } fd = open("123456789012345/123456789012345/123456789012345", O_CREATE); 2a4b: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 2a52: 00 2a53: c7 04 24 dc 53 00 00 movl $0x53dc,(%esp) 2a5a: e8 96 14 00 00 call 3ef5 <open> 2a5f: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 2a62: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2a66: 79 19 jns 2a81 <fourteen+0xa2> printf(1, "create 123456789012345/123456789012345/123456789012345 failed\n"); 2a68: c7 44 24 04 0c 54 00 movl $0x540c,0x4(%esp) 2a6f: 00 2a70: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2a77: e8 c9 15 00 00 call 4045 <printf> exit(); 2a7c: e8 34 14 00 00 call 3eb5 <exit> } close(fd); 2a81: 8b 45 f4 mov -0xc(%ebp),%eax 2a84: 89 04 24 mov %eax,(%esp) 2a87: e8 51 14 00 00 call 3edd <close> fd = open("12345678901234/12345678901234/12345678901234", 0); 2a8c: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 2a93: 00 2a94: c7 04 24 4c 54 00 00 movl $0x544c,(%esp) 2a9b: e8 55 14 00 00 call 3ef5 <open> 2aa0: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 2aa3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2aa7: 79 19 jns 2ac2 <fourteen+0xe3> printf(1, "open 12345678901234/12345678901234/12345678901234 failed\n"); 2aa9: c7 44 24 04 7c 54 00 movl $0x547c,0x4(%esp) 2ab0: 00 2ab1: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2ab8: e8 88 15 00 00 call 4045 <printf> exit(); 2abd: e8 f3 13 00 00 call 3eb5 <exit> } close(fd); 2ac2: 8b 45 f4 mov -0xc(%ebp),%eax 2ac5: 89 04 24 mov %eax,(%esp) 2ac8: e8 10 14 00 00 call 3edd <close> if(mkdir("12345678901234/12345678901234") == 0){ 2acd: c7 04 24 b6 54 00 00 movl $0x54b6,(%esp) 2ad4: e8 44 14 00 00 call 3f1d <mkdir> 2ad9: 85 c0 test %eax,%eax 2adb: 75 19 jne 2af6 <fourteen+0x117> printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n"); 2add: c7 44 24 04 d4 54 00 movl $0x54d4,0x4(%esp) 2ae4: 00 2ae5: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2aec: e8 54 15 00 00 call 4045 <printf> exit(); 2af1: e8 bf 13 00 00 call 3eb5 <exit> } if(mkdir("123456789012345/12345678901234") == 0){ 2af6: c7 04 24 04 55 00 00 movl $0x5504,(%esp) 2afd: e8 1b 14 00 00 call 3f1d <mkdir> 2b02: 85 c0 test %eax,%eax 2b04: 75 19 jne 2b1f <fourteen+0x140> printf(1, "mkdir 12345678901234/123456789012345 succeeded!\n"); 2b06: c7 44 24 04 24 55 00 movl $0x5524,0x4(%esp) 2b0d: 00 2b0e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2b15: e8 2b 15 00 00 call 4045 <printf> exit(); 2b1a: e8 96 13 00 00 call 3eb5 <exit> } printf(1, "fourteen ok\n"); 2b1f: c7 44 24 04 55 55 00 movl $0x5555,0x4(%esp) 2b26: 00 2b27: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2b2e: e8 12 15 00 00 call 4045 <printf> } 2b33: c9 leave 2b34: c3 ret 00002b35 <rmdot>: void rmdot(void) { 2b35: 55 push %ebp 2b36: 89 e5 mov %esp,%ebp 2b38: 83 ec 18 sub $0x18,%esp printf(1, "rmdot test\n"); 2b3b: c7 44 24 04 62 55 00 movl $0x5562,0x4(%esp) 2b42: 00 2b43: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2b4a: e8 f6 14 00 00 call 4045 <printf> if(mkdir("dots") != 0){ 2b4f: c7 04 24 6e 55 00 00 movl $0x556e,(%esp) 2b56: e8 c2 13 00 00 call 3f1d <mkdir> 2b5b: 85 c0 test %eax,%eax 2b5d: 74 19 je 2b78 <rmdot+0x43> printf(1, "mkdir dots failed\n"); 2b5f: c7 44 24 04 73 55 00 movl $0x5573,0x4(%esp) 2b66: 00 2b67: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2b6e: e8 d2 14 00 00 call 4045 <printf> exit(); 2b73: e8 3d 13 00 00 call 3eb5 <exit> } if(chdir("dots") != 0){ 2b78: c7 04 24 6e 55 00 00 movl $0x556e,(%esp) 2b7f: e8 a1 13 00 00 call 3f25 <chdir> 2b84: 85 c0 test %eax,%eax 2b86: 74 19 je 2ba1 <rmdot+0x6c> printf(1, "chdir dots failed\n"); 2b88: c7 44 24 04 86 55 00 movl $0x5586,0x4(%esp) 2b8f: 00 2b90: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2b97: e8 a9 14 00 00 call 4045 <printf> exit(); 2b9c: e8 14 13 00 00 call 3eb5 <exit> } if(unlink(".") == 0){ 2ba1: c7 04 24 9f 4c 00 00 movl $0x4c9f,(%esp) 2ba8: e8 58 13 00 00 call 3f05 <unlink> 2bad: 85 c0 test %eax,%eax 2baf: 75 19 jne 2bca <rmdot+0x95> printf(1, "rm . worked!\n"); 2bb1: c7 44 24 04 99 55 00 movl $0x5599,0x4(%esp) 2bb8: 00 2bb9: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2bc0: e8 80 14 00 00 call 4045 <printf> exit(); 2bc5: e8 eb 12 00 00 call 3eb5 <exit> } if(unlink("..") == 0){ 2bca: c7 04 24 32 48 00 00 movl $0x4832,(%esp) 2bd1: e8 2f 13 00 00 call 3f05 <unlink> 2bd6: 85 c0 test %eax,%eax 2bd8: 75 19 jne 2bf3 <rmdot+0xbe> printf(1, "rm .. worked!\n"); 2bda: c7 44 24 04 a7 55 00 movl $0x55a7,0x4(%esp) 2be1: 00 2be2: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2be9: e8 57 14 00 00 call 4045 <printf> exit(); 2bee: e8 c2 12 00 00 call 3eb5 <exit> } if(chdir("/") != 0){ 2bf3: c7 04 24 86 44 00 00 movl $0x4486,(%esp) 2bfa: e8 26 13 00 00 call 3f25 <chdir> 2bff: 85 c0 test %eax,%eax 2c01: 74 19 je 2c1c <rmdot+0xe7> printf(1, "chdir / failed\n"); 2c03: c7 44 24 04 88 44 00 movl $0x4488,0x4(%esp) 2c0a: 00 2c0b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2c12: e8 2e 14 00 00 call 4045 <printf> exit(); 2c17: e8 99 12 00 00 call 3eb5 <exit> } if(unlink("dots/.") == 0){ 2c1c: c7 04 24 b6 55 00 00 movl $0x55b6,(%esp) 2c23: e8 dd 12 00 00 call 3f05 <unlink> 2c28: 85 c0 test %eax,%eax 2c2a: 75 19 jne 2c45 <rmdot+0x110> printf(1, "unlink dots/. worked!\n"); 2c2c: c7 44 24 04 bd 55 00 movl $0x55bd,0x4(%esp) 2c33: 00 2c34: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2c3b: e8 05 14 00 00 call 4045 <printf> exit(); 2c40: e8 70 12 00 00 call 3eb5 <exit> } if(unlink("dots/..") == 0){ 2c45: c7 04 24 d4 55 00 00 movl $0x55d4,(%esp) 2c4c: e8 b4 12 00 00 call 3f05 <unlink> 2c51: 85 c0 test %eax,%eax 2c53: 75 19 jne 2c6e <rmdot+0x139> printf(1, "unlink dots/.. worked!\n"); 2c55: c7 44 24 04 dc 55 00 movl $0x55dc,0x4(%esp) 2c5c: 00 2c5d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2c64: e8 dc 13 00 00 call 4045 <printf> exit(); 2c69: e8 47 12 00 00 call 3eb5 <exit> } if(unlink("dots") != 0){ 2c6e: c7 04 24 6e 55 00 00 movl $0x556e,(%esp) 2c75: e8 8b 12 00 00 call 3f05 <unlink> 2c7a: 85 c0 test %eax,%eax 2c7c: 74 19 je 2c97 <rmdot+0x162> printf(1, "unlink dots failed!\n"); 2c7e: c7 44 24 04 f4 55 00 movl $0x55f4,0x4(%esp) 2c85: 00 2c86: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2c8d: e8 b3 13 00 00 call 4045 <printf> exit(); 2c92: e8 1e 12 00 00 call 3eb5 <exit> } printf(1, "rmdot ok\n"); 2c97: c7 44 24 04 09 56 00 movl $0x5609,0x4(%esp) 2c9e: 00 2c9f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2ca6: e8 9a 13 00 00 call 4045 <printf> } 2cab: c9 leave 2cac: c3 ret 00002cad <dirfile>: void dirfile(void) { 2cad: 55 push %ebp 2cae: 89 e5 mov %esp,%ebp 2cb0: 83 ec 28 sub $0x28,%esp int fd; printf(1, "dir vs file\n"); 2cb3: c7 44 24 04 13 56 00 movl $0x5613,0x4(%esp) 2cba: 00 2cbb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2cc2: e8 7e 13 00 00 call 4045 <printf> fd = open("dirfile", O_CREATE); 2cc7: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 2cce: 00 2ccf: c7 04 24 20 56 00 00 movl $0x5620,(%esp) 2cd6: e8 1a 12 00 00 call 3ef5 <open> 2cdb: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 2cde: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2ce2: 79 19 jns 2cfd <dirfile+0x50> printf(1, "create dirfile failed\n"); 2ce4: c7 44 24 04 28 56 00 movl $0x5628,0x4(%esp) 2ceb: 00 2cec: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2cf3: e8 4d 13 00 00 call 4045 <printf> exit(); 2cf8: e8 b8 11 00 00 call 3eb5 <exit> } close(fd); 2cfd: 8b 45 f4 mov -0xc(%ebp),%eax 2d00: 89 04 24 mov %eax,(%esp) 2d03: e8 d5 11 00 00 call 3edd <close> if(chdir("dirfile") == 0){ 2d08: c7 04 24 20 56 00 00 movl $0x5620,(%esp) 2d0f: e8 11 12 00 00 call 3f25 <chdir> 2d14: 85 c0 test %eax,%eax 2d16: 75 19 jne 2d31 <dirfile+0x84> printf(1, "chdir dirfile succeeded!\n"); 2d18: c7 44 24 04 3f 56 00 movl $0x563f,0x4(%esp) 2d1f: 00 2d20: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2d27: e8 19 13 00 00 call 4045 <printf> exit(); 2d2c: e8 84 11 00 00 call 3eb5 <exit> } fd = open("dirfile/xx", 0); 2d31: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 2d38: 00 2d39: c7 04 24 59 56 00 00 movl $0x5659,(%esp) 2d40: e8 b0 11 00 00 call 3ef5 <open> 2d45: 89 45 f4 mov %eax,-0xc(%ebp) if(fd >= 0){ 2d48: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2d4c: 78 19 js 2d67 <dirfile+0xba> printf(1, "create dirfile/xx succeeded!\n"); 2d4e: c7 44 24 04 64 56 00 movl $0x5664,0x4(%esp) 2d55: 00 2d56: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2d5d: e8 e3 12 00 00 call 4045 <printf> exit(); 2d62: e8 4e 11 00 00 call 3eb5 <exit> } fd = open("dirfile/xx", O_CREATE); 2d67: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 2d6e: 00 2d6f: c7 04 24 59 56 00 00 movl $0x5659,(%esp) 2d76: e8 7a 11 00 00 call 3ef5 <open> 2d7b: 89 45 f4 mov %eax,-0xc(%ebp) if(fd >= 0){ 2d7e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2d82: 78 19 js 2d9d <dirfile+0xf0> printf(1, "create dirfile/xx succeeded!\n"); 2d84: c7 44 24 04 64 56 00 movl $0x5664,0x4(%esp) 2d8b: 00 2d8c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2d93: e8 ad 12 00 00 call 4045 <printf> exit(); 2d98: e8 18 11 00 00 call 3eb5 <exit> } if(mkdir("dirfile/xx") == 0){ 2d9d: c7 04 24 59 56 00 00 movl $0x5659,(%esp) 2da4: e8 74 11 00 00 call 3f1d <mkdir> 2da9: 85 c0 test %eax,%eax 2dab: 75 19 jne 2dc6 <dirfile+0x119> printf(1, "mkdir dirfile/xx succeeded!\n"); 2dad: c7 44 24 04 82 56 00 movl $0x5682,0x4(%esp) 2db4: 00 2db5: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2dbc: e8 84 12 00 00 call 4045 <printf> exit(); 2dc1: e8 ef 10 00 00 call 3eb5 <exit> } if(unlink("dirfile/xx") == 0){ 2dc6: c7 04 24 59 56 00 00 movl $0x5659,(%esp) 2dcd: e8 33 11 00 00 call 3f05 <unlink> 2dd2: 85 c0 test %eax,%eax 2dd4: 75 19 jne 2def <dirfile+0x142> printf(1, "unlink dirfile/xx succeeded!\n"); 2dd6: c7 44 24 04 9f 56 00 movl $0x569f,0x4(%esp) 2ddd: 00 2dde: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2de5: e8 5b 12 00 00 call 4045 <printf> exit(); 2dea: e8 c6 10 00 00 call 3eb5 <exit> } if(link("README", "dirfile/xx") == 0){ 2def: c7 44 24 04 59 56 00 movl $0x5659,0x4(%esp) 2df6: 00 2df7: c7 04 24 bd 56 00 00 movl $0x56bd,(%esp) 2dfe: e8 12 11 00 00 call 3f15 <link> 2e03: 85 c0 test %eax,%eax 2e05: 75 19 jne 2e20 <dirfile+0x173> printf(1, "link to dirfile/xx succeeded!\n"); 2e07: c7 44 24 04 c4 56 00 movl $0x56c4,0x4(%esp) 2e0e: 00 2e0f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2e16: e8 2a 12 00 00 call 4045 <printf> exit(); 2e1b: e8 95 10 00 00 call 3eb5 <exit> } if(unlink("dirfile") != 0){ 2e20: c7 04 24 20 56 00 00 movl $0x5620,(%esp) 2e27: e8 d9 10 00 00 call 3f05 <unlink> 2e2c: 85 c0 test %eax,%eax 2e2e: 74 19 je 2e49 <dirfile+0x19c> printf(1, "unlink dirfile failed!\n"); 2e30: c7 44 24 04 e3 56 00 movl $0x56e3,0x4(%esp) 2e37: 00 2e38: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2e3f: e8 01 12 00 00 call 4045 <printf> exit(); 2e44: e8 6c 10 00 00 call 3eb5 <exit> } fd = open(".", O_RDWR); 2e49: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) 2e50: 00 2e51: c7 04 24 9f 4c 00 00 movl $0x4c9f,(%esp) 2e58: e8 98 10 00 00 call 3ef5 <open> 2e5d: 89 45 f4 mov %eax,-0xc(%ebp) if(fd >= 0){ 2e60: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2e64: 78 19 js 2e7f <dirfile+0x1d2> printf(1, "open . for writing succeeded!\n"); 2e66: c7 44 24 04 fc 56 00 movl $0x56fc,0x4(%esp) 2e6d: 00 2e6e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2e75: e8 cb 11 00 00 call 4045 <printf> exit(); 2e7a: e8 36 10 00 00 call 3eb5 <exit> } fd = open(".", 0); 2e7f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 2e86: 00 2e87: c7 04 24 9f 4c 00 00 movl $0x4c9f,(%esp) 2e8e: e8 62 10 00 00 call 3ef5 <open> 2e93: 89 45 f4 mov %eax,-0xc(%ebp) if(write(fd, "x", 1) > 0){ 2e96: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 2e9d: 00 2e9e: c7 44 24 04 eb 48 00 movl $0x48eb,0x4(%esp) 2ea5: 00 2ea6: 8b 45 f4 mov -0xc(%ebp),%eax 2ea9: 89 04 24 mov %eax,(%esp) 2eac: e8 24 10 00 00 call 3ed5 <write> 2eb1: 85 c0 test %eax,%eax 2eb3: 7e 19 jle 2ece <dirfile+0x221> printf(1, "write . succeeded!\n"); 2eb5: c7 44 24 04 1b 57 00 movl $0x571b,0x4(%esp) 2ebc: 00 2ebd: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2ec4: e8 7c 11 00 00 call 4045 <printf> exit(); 2ec9: e8 e7 0f 00 00 call 3eb5 <exit> } close(fd); 2ece: 8b 45 f4 mov -0xc(%ebp),%eax 2ed1: 89 04 24 mov %eax,(%esp) 2ed4: e8 04 10 00 00 call 3edd <close> printf(1, "dir vs file OK\n"); 2ed9: c7 44 24 04 2f 57 00 movl $0x572f,0x4(%esp) 2ee0: 00 2ee1: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2ee8: e8 58 11 00 00 call 4045 <printf> } 2eed: c9 leave 2eee: c3 ret 00002eef <iref>: // test that iput() is called at the end of _namei() void iref(void) { 2eef: 55 push %ebp 2ef0: 89 e5 mov %esp,%ebp 2ef2: 83 ec 28 sub $0x28,%esp int i, fd; printf(1, "empty file name\n"); 2ef5: c7 44 24 04 3f 57 00 movl $0x573f,0x4(%esp) 2efc: 00 2efd: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2f04: e8 3c 11 00 00 call 4045 <printf> // the 50 is NINODE for(i = 0; i < 50 + 1; i++){ 2f09: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 2f10: e9 d2 00 00 00 jmp 2fe7 <iref+0xf8> if(mkdir("irefd") != 0){ 2f15: c7 04 24 50 57 00 00 movl $0x5750,(%esp) 2f1c: e8 fc 0f 00 00 call 3f1d <mkdir> 2f21: 85 c0 test %eax,%eax 2f23: 74 19 je 2f3e <iref+0x4f> printf(1, "mkdir irefd failed\n"); 2f25: c7 44 24 04 56 57 00 movl $0x5756,0x4(%esp) 2f2c: 00 2f2d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2f34: e8 0c 11 00 00 call 4045 <printf> exit(); 2f39: e8 77 0f 00 00 call 3eb5 <exit> } if(chdir("irefd") != 0){ 2f3e: c7 04 24 50 57 00 00 movl $0x5750,(%esp) 2f45: e8 db 0f 00 00 call 3f25 <chdir> 2f4a: 85 c0 test %eax,%eax 2f4c: 74 19 je 2f67 <iref+0x78> printf(1, "chdir irefd failed\n"); 2f4e: c7 44 24 04 6a 57 00 movl $0x576a,0x4(%esp) 2f55: 00 2f56: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2f5d: e8 e3 10 00 00 call 4045 <printf> exit(); 2f62: e8 4e 0f 00 00 call 3eb5 <exit> } mkdir(""); 2f67: c7 04 24 7e 57 00 00 movl $0x577e,(%esp) 2f6e: e8 aa 0f 00 00 call 3f1d <mkdir> link("README", ""); 2f73: c7 44 24 04 7e 57 00 movl $0x577e,0x4(%esp) 2f7a: 00 2f7b: c7 04 24 bd 56 00 00 movl $0x56bd,(%esp) 2f82: e8 8e 0f 00 00 call 3f15 <link> fd = open("", O_CREATE); 2f87: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 2f8e: 00 2f8f: c7 04 24 7e 57 00 00 movl $0x577e,(%esp) 2f96: e8 5a 0f 00 00 call 3ef5 <open> 2f9b: 89 45 f0 mov %eax,-0x10(%ebp) if(fd >= 0) 2f9e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 2fa2: 78 0b js 2faf <iref+0xc0> close(fd); 2fa4: 8b 45 f0 mov -0x10(%ebp),%eax 2fa7: 89 04 24 mov %eax,(%esp) 2faa: e8 2e 0f 00 00 call 3edd <close> fd = open("xx", O_CREATE); 2faf: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 2fb6: 00 2fb7: c7 04 24 7f 57 00 00 movl $0x577f,(%esp) 2fbe: e8 32 0f 00 00 call 3ef5 <open> 2fc3: 89 45 f0 mov %eax,-0x10(%ebp) if(fd >= 0) 2fc6: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 2fca: 78 0b js 2fd7 <iref+0xe8> close(fd); 2fcc: 8b 45 f0 mov -0x10(%ebp),%eax 2fcf: 89 04 24 mov %eax,(%esp) 2fd2: e8 06 0f 00 00 call 3edd <close> unlink("xx"); 2fd7: c7 04 24 7f 57 00 00 movl $0x577f,(%esp) 2fde: e8 22 0f 00 00 call 3f05 <unlink> int i, fd; printf(1, "empty file name\n"); // the 50 is NINODE for(i = 0; i < 50 + 1; i++){ 2fe3: 83 45 f4 01 addl $0x1,-0xc(%ebp) 2fe7: 83 7d f4 32 cmpl $0x32,-0xc(%ebp) 2feb: 0f 8e 24 ff ff ff jle 2f15 <iref+0x26> if(fd >= 0) close(fd); unlink("xx"); } chdir("/"); 2ff1: c7 04 24 86 44 00 00 movl $0x4486,(%esp) 2ff8: e8 28 0f 00 00 call 3f25 <chdir> printf(1, "empty file name OK\n"); 2ffd: c7 44 24 04 82 57 00 movl $0x5782,0x4(%esp) 3004: 00 3005: c7 04 24 01 00 00 00 movl $0x1,(%esp) 300c: e8 34 10 00 00 call 4045 <printf> } 3011: c9 leave 3012: c3 ret 00003013 <forktest>: // test that fork fails gracefully // the forktest binary also does this, but it runs out of proc entries first. // inside the bigger usertests binary, we run out of memory first. void forktest(void) { 3013: 55 push %ebp 3014: 89 e5 mov %esp,%ebp 3016: 83 ec 28 sub $0x28,%esp int n, pid; printf(1, "fork test\n"); 3019: c7 44 24 04 96 57 00 movl $0x5796,0x4(%esp) 3020: 00 3021: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3028: e8 18 10 00 00 call 4045 <printf> for(n=0; n<1000; n++){ 302d: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 3034: eb 1f jmp 3055 <forktest+0x42> pid = fork(); 3036: e8 72 0e 00 00 call 3ead <fork> 303b: 89 45 f0 mov %eax,-0x10(%ebp) if(pid < 0) 303e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 3042: 79 02 jns 3046 <forktest+0x33> break; 3044: eb 18 jmp 305e <forktest+0x4b> if(pid == 0) 3046: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 304a: 75 05 jne 3051 <forktest+0x3e> exit(); 304c: e8 64 0e 00 00 call 3eb5 <exit> { int n, pid; printf(1, "fork test\n"); for(n=0; n<1000; n++){ 3051: 83 45 f4 01 addl $0x1,-0xc(%ebp) 3055: 81 7d f4 e7 03 00 00 cmpl $0x3e7,-0xc(%ebp) 305c: 7e d8 jle 3036 <forktest+0x23> break; if(pid == 0) exit(); } if(n == 1000){ 305e: 81 7d f4 e8 03 00 00 cmpl $0x3e8,-0xc(%ebp) 3065: 75 19 jne 3080 <forktest+0x6d> printf(1, "fork claimed to work 1000 times!\n"); 3067: c7 44 24 04 a4 57 00 movl $0x57a4,0x4(%esp) 306e: 00 306f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3076: e8 ca 0f 00 00 call 4045 <printf> exit(); 307b: e8 35 0e 00 00 call 3eb5 <exit> } for(; n > 0; n--){ 3080: eb 26 jmp 30a8 <forktest+0x95> if(wait() < 0){ 3082: e8 36 0e 00 00 call 3ebd <wait> 3087: 85 c0 test %eax,%eax 3089: 79 19 jns 30a4 <forktest+0x91> printf(1, "wait stopped early\n"); 308b: c7 44 24 04 c6 57 00 movl $0x57c6,0x4(%esp) 3092: 00 3093: c7 04 24 01 00 00 00 movl $0x1,(%esp) 309a: e8 a6 0f 00 00 call 4045 <printf> exit(); 309f: e8 11 0e 00 00 call 3eb5 <exit> if(n == 1000){ printf(1, "fork claimed to work 1000 times!\n"); exit(); } for(; n > 0; n--){ 30a4: 83 6d f4 01 subl $0x1,-0xc(%ebp) 30a8: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 30ac: 7f d4 jg 3082 <forktest+0x6f> printf(1, "wait stopped early\n"); exit(); } } if(wait() != -1){ 30ae: e8 0a 0e 00 00 call 3ebd <wait> 30b3: 83 f8 ff cmp $0xffffffff,%eax 30b6: 74 19 je 30d1 <forktest+0xbe> printf(1, "wait got too many\n"); 30b8: c7 44 24 04 da 57 00 movl $0x57da,0x4(%esp) 30bf: 00 30c0: c7 04 24 01 00 00 00 movl $0x1,(%esp) 30c7: e8 79 0f 00 00 call 4045 <printf> exit(); 30cc: e8 e4 0d 00 00 call 3eb5 <exit> } printf(1, "fork test OK\n"); 30d1: c7 44 24 04 ed 57 00 movl $0x57ed,0x4(%esp) 30d8: 00 30d9: c7 04 24 01 00 00 00 movl $0x1,(%esp) 30e0: e8 60 0f 00 00 call 4045 <printf> } 30e5: c9 leave 30e6: c3 ret 000030e7 <sbrktest>: void sbrktest(void) { 30e7: 55 push %ebp 30e8: 89 e5 mov %esp,%ebp 30ea: 53 push %ebx 30eb: 81 ec 84 00 00 00 sub $0x84,%esp int fds[2], pid, pids[10], ppid; char *a, *b, *c, *lastaddr, *oldbrk, *p, scratch; uint amt; printf(stdout, "sbrk test\n"); 30f1: a1 d4 62 00 00 mov 0x62d4,%eax 30f6: c7 44 24 04 fb 57 00 movl $0x57fb,0x4(%esp) 30fd: 00 30fe: 89 04 24 mov %eax,(%esp) 3101: e8 3f 0f 00 00 call 4045 <printf> oldbrk = sbrk(0); 3106: c7 04 24 00 00 00 00 movl $0x0,(%esp) 310d: e8 2b 0e 00 00 call 3f3d <sbrk> 3112: 89 45 ec mov %eax,-0x14(%ebp) // can one sbrk() less than a page? a = sbrk(0); 3115: c7 04 24 00 00 00 00 movl $0x0,(%esp) 311c: e8 1c 0e 00 00 call 3f3d <sbrk> 3121: 89 45 f4 mov %eax,-0xc(%ebp) int i; for(i = 0; i < 5000; i++){ 3124: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 312b: eb 59 jmp 3186 <sbrktest+0x9f> b = sbrk(1); 312d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3134: e8 04 0e 00 00 call 3f3d <sbrk> 3139: 89 45 e8 mov %eax,-0x18(%ebp) if(b != a){ 313c: 8b 45 e8 mov -0x18(%ebp),%eax 313f: 3b 45 f4 cmp -0xc(%ebp),%eax 3142: 74 2f je 3173 <sbrktest+0x8c> printf(stdout, "sbrk test failed %d %x %x\n", i, a, b); 3144: a1 d4 62 00 00 mov 0x62d4,%eax 3149: 8b 55 e8 mov -0x18(%ebp),%edx 314c: 89 54 24 10 mov %edx,0x10(%esp) 3150: 8b 55 f4 mov -0xc(%ebp),%edx 3153: 89 54 24 0c mov %edx,0xc(%esp) 3157: 8b 55 f0 mov -0x10(%ebp),%edx 315a: 89 54 24 08 mov %edx,0x8(%esp) 315e: c7 44 24 04 06 58 00 movl $0x5806,0x4(%esp) 3165: 00 3166: 89 04 24 mov %eax,(%esp) 3169: e8 d7 0e 00 00 call 4045 <printf> exit(); 316e: e8 42 0d 00 00 call 3eb5 <exit> } *b = 1; 3173: 8b 45 e8 mov -0x18(%ebp),%eax 3176: c6 00 01 movb $0x1,(%eax) a = b + 1; 3179: 8b 45 e8 mov -0x18(%ebp),%eax 317c: 83 c0 01 add $0x1,%eax 317f: 89 45 f4 mov %eax,-0xc(%ebp) oldbrk = sbrk(0); // can one sbrk() less than a page? a = sbrk(0); int i; for(i = 0; i < 5000; i++){ 3182: 83 45 f0 01 addl $0x1,-0x10(%ebp) 3186: 81 7d f0 87 13 00 00 cmpl $0x1387,-0x10(%ebp) 318d: 7e 9e jle 312d <sbrktest+0x46> exit(); } *b = 1; a = b + 1; } pid = fork(); 318f: e8 19 0d 00 00 call 3ead <fork> 3194: 89 45 e4 mov %eax,-0x1c(%ebp) if(pid < 0){ 3197: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 319b: 79 1a jns 31b7 <sbrktest+0xd0> printf(stdout, "sbrk test fork failed\n"); 319d: a1 d4 62 00 00 mov 0x62d4,%eax 31a2: c7 44 24 04 21 58 00 movl $0x5821,0x4(%esp) 31a9: 00 31aa: 89 04 24 mov %eax,(%esp) 31ad: e8 93 0e 00 00 call 4045 <printf> exit(); 31b2: e8 fe 0c 00 00 call 3eb5 <exit> } c = sbrk(1); 31b7: c7 04 24 01 00 00 00 movl $0x1,(%esp) 31be: e8 7a 0d 00 00 call 3f3d <sbrk> 31c3: 89 45 e0 mov %eax,-0x20(%ebp) c = sbrk(1); 31c6: c7 04 24 01 00 00 00 movl $0x1,(%esp) 31cd: e8 6b 0d 00 00 call 3f3d <sbrk> 31d2: 89 45 e0 mov %eax,-0x20(%ebp) if(c != a + 1){ 31d5: 8b 45 f4 mov -0xc(%ebp),%eax 31d8: 83 c0 01 add $0x1,%eax 31db: 3b 45 e0 cmp -0x20(%ebp),%eax 31de: 74 1a je 31fa <sbrktest+0x113> printf(stdout, "sbrk test failed post-fork\n"); 31e0: a1 d4 62 00 00 mov 0x62d4,%eax 31e5: c7 44 24 04 38 58 00 movl $0x5838,0x4(%esp) 31ec: 00 31ed: 89 04 24 mov %eax,(%esp) 31f0: e8 50 0e 00 00 call 4045 <printf> exit(); 31f5: e8 bb 0c 00 00 call 3eb5 <exit> } if(pid == 0) 31fa: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 31fe: 75 05 jne 3205 <sbrktest+0x11e> exit(); 3200: e8 b0 0c 00 00 call 3eb5 <exit> wait(); 3205: e8 b3 0c 00 00 call 3ebd <wait> // can one grow address space to something big? #define BIG (100*1024*1024) a = sbrk(0); 320a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3211: e8 27 0d 00 00 call 3f3d <sbrk> 3216: 89 45 f4 mov %eax,-0xc(%ebp) amt = (BIG) - (uint)a; 3219: 8b 45 f4 mov -0xc(%ebp),%eax 321c: ba 00 00 40 06 mov $0x6400000,%edx 3221: 29 c2 sub %eax,%edx 3223: 89 d0 mov %edx,%eax 3225: 89 45 dc mov %eax,-0x24(%ebp) p = sbrk(amt); 3228: 8b 45 dc mov -0x24(%ebp),%eax 322b: 89 04 24 mov %eax,(%esp) 322e: e8 0a 0d 00 00 call 3f3d <sbrk> 3233: 89 45 d8 mov %eax,-0x28(%ebp) if (p != a) { 3236: 8b 45 d8 mov -0x28(%ebp),%eax 3239: 3b 45 f4 cmp -0xc(%ebp),%eax 323c: 74 1a je 3258 <sbrktest+0x171> printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n"); 323e: a1 d4 62 00 00 mov 0x62d4,%eax 3243: c7 44 24 04 54 58 00 movl $0x5854,0x4(%esp) 324a: 00 324b: 89 04 24 mov %eax,(%esp) 324e: e8 f2 0d 00 00 call 4045 <printf> exit(); 3253: e8 5d 0c 00 00 call 3eb5 <exit> } lastaddr = (char*) (BIG-1); 3258: c7 45 d4 ff ff 3f 06 movl $0x63fffff,-0x2c(%ebp) *lastaddr = 99; 325f: 8b 45 d4 mov -0x2c(%ebp),%eax 3262: c6 00 63 movb $0x63,(%eax) // can one de-allocate? a = sbrk(0); 3265: c7 04 24 00 00 00 00 movl $0x0,(%esp) 326c: e8 cc 0c 00 00 call 3f3d <sbrk> 3271: 89 45 f4 mov %eax,-0xc(%ebp) c = sbrk(-4096); 3274: c7 04 24 00 f0 ff ff movl $0xfffff000,(%esp) 327b: e8 bd 0c 00 00 call 3f3d <sbrk> 3280: 89 45 e0 mov %eax,-0x20(%ebp) if(c == (char*)0xffffffff){ 3283: 83 7d e0 ff cmpl $0xffffffff,-0x20(%ebp) 3287: 75 1a jne 32a3 <sbrktest+0x1bc> printf(stdout, "sbrk could not deallocate\n"); 3289: a1 d4 62 00 00 mov 0x62d4,%eax 328e: c7 44 24 04 92 58 00 movl $0x5892,0x4(%esp) 3295: 00 3296: 89 04 24 mov %eax,(%esp) 3299: e8 a7 0d 00 00 call 4045 <printf> exit(); 329e: e8 12 0c 00 00 call 3eb5 <exit> } c = sbrk(0); 32a3: c7 04 24 00 00 00 00 movl $0x0,(%esp) 32aa: e8 8e 0c 00 00 call 3f3d <sbrk> 32af: 89 45 e0 mov %eax,-0x20(%ebp) if(c != a - 4096){ 32b2: 8b 45 f4 mov -0xc(%ebp),%eax 32b5: 2d 00 10 00 00 sub $0x1000,%eax 32ba: 3b 45 e0 cmp -0x20(%ebp),%eax 32bd: 74 28 je 32e7 <sbrktest+0x200> printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c); 32bf: a1 d4 62 00 00 mov 0x62d4,%eax 32c4: 8b 55 e0 mov -0x20(%ebp),%edx 32c7: 89 54 24 0c mov %edx,0xc(%esp) 32cb: 8b 55 f4 mov -0xc(%ebp),%edx 32ce: 89 54 24 08 mov %edx,0x8(%esp) 32d2: c7 44 24 04 b0 58 00 movl $0x58b0,0x4(%esp) 32d9: 00 32da: 89 04 24 mov %eax,(%esp) 32dd: e8 63 0d 00 00 call 4045 <printf> exit(); 32e2: e8 ce 0b 00 00 call 3eb5 <exit> } // can one re-allocate that page? a = sbrk(0); 32e7: c7 04 24 00 00 00 00 movl $0x0,(%esp) 32ee: e8 4a 0c 00 00 call 3f3d <sbrk> 32f3: 89 45 f4 mov %eax,-0xc(%ebp) c = sbrk(4096); 32f6: c7 04 24 00 10 00 00 movl $0x1000,(%esp) 32fd: e8 3b 0c 00 00 call 3f3d <sbrk> 3302: 89 45 e0 mov %eax,-0x20(%ebp) if(c != a || sbrk(0) != a + 4096){ 3305: 8b 45 e0 mov -0x20(%ebp),%eax 3308: 3b 45 f4 cmp -0xc(%ebp),%eax 330b: 75 19 jne 3326 <sbrktest+0x23f> 330d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3314: e8 24 0c 00 00 call 3f3d <sbrk> 3319: 8b 55 f4 mov -0xc(%ebp),%edx 331c: 81 c2 00 10 00 00 add $0x1000,%edx 3322: 39 d0 cmp %edx,%eax 3324: 74 28 je 334e <sbrktest+0x267> printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c); 3326: a1 d4 62 00 00 mov 0x62d4,%eax 332b: 8b 55 e0 mov -0x20(%ebp),%edx 332e: 89 54 24 0c mov %edx,0xc(%esp) 3332: 8b 55 f4 mov -0xc(%ebp),%edx 3335: 89 54 24 08 mov %edx,0x8(%esp) 3339: c7 44 24 04 e8 58 00 movl $0x58e8,0x4(%esp) 3340: 00 3341: 89 04 24 mov %eax,(%esp) 3344: e8 fc 0c 00 00 call 4045 <printf> exit(); 3349: e8 67 0b 00 00 call 3eb5 <exit> } if(*lastaddr == 99){ 334e: 8b 45 d4 mov -0x2c(%ebp),%eax 3351: 0f b6 00 movzbl (%eax),%eax 3354: 3c 63 cmp $0x63,%al 3356: 75 1a jne 3372 <sbrktest+0x28b> // should be zero printf(stdout, "sbrk de-allocation didn't really deallocate\n"); 3358: a1 d4 62 00 00 mov 0x62d4,%eax 335d: c7 44 24 04 10 59 00 movl $0x5910,0x4(%esp) 3364: 00 3365: 89 04 24 mov %eax,(%esp) 3368: e8 d8 0c 00 00 call 4045 <printf> exit(); 336d: e8 43 0b 00 00 call 3eb5 <exit> } a = sbrk(0); 3372: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3379: e8 bf 0b 00 00 call 3f3d <sbrk> 337e: 89 45 f4 mov %eax,-0xc(%ebp) c = sbrk(-(sbrk(0) - oldbrk)); 3381: 8b 5d ec mov -0x14(%ebp),%ebx 3384: c7 04 24 00 00 00 00 movl $0x0,(%esp) 338b: e8 ad 0b 00 00 call 3f3d <sbrk> 3390: 29 c3 sub %eax,%ebx 3392: 89 d8 mov %ebx,%eax 3394: 89 04 24 mov %eax,(%esp) 3397: e8 a1 0b 00 00 call 3f3d <sbrk> 339c: 89 45 e0 mov %eax,-0x20(%ebp) if(c != a){ 339f: 8b 45 e0 mov -0x20(%ebp),%eax 33a2: 3b 45 f4 cmp -0xc(%ebp),%eax 33a5: 74 28 je 33cf <sbrktest+0x2e8> printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c); 33a7: a1 d4 62 00 00 mov 0x62d4,%eax 33ac: 8b 55 e0 mov -0x20(%ebp),%edx 33af: 89 54 24 0c mov %edx,0xc(%esp) 33b3: 8b 55 f4 mov -0xc(%ebp),%edx 33b6: 89 54 24 08 mov %edx,0x8(%esp) 33ba: c7 44 24 04 40 59 00 movl $0x5940,0x4(%esp) 33c1: 00 33c2: 89 04 24 mov %eax,(%esp) 33c5: e8 7b 0c 00 00 call 4045 <printf> exit(); 33ca: e8 e6 0a 00 00 call 3eb5 <exit> } // can we read the kernel's memory? for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 33cf: c7 45 f4 00 00 00 80 movl $0x80000000,-0xc(%ebp) 33d6: eb 7b jmp 3453 <sbrktest+0x36c> ppid = getpid(); 33d8: e8 58 0b 00 00 call 3f35 <getpid> 33dd: 89 45 d0 mov %eax,-0x30(%ebp) pid = fork(); 33e0: e8 c8 0a 00 00 call 3ead <fork> 33e5: 89 45 e4 mov %eax,-0x1c(%ebp) if(pid < 0){ 33e8: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 33ec: 79 1a jns 3408 <sbrktest+0x321> printf(stdout, "fork failed\n"); 33ee: a1 d4 62 00 00 mov 0x62d4,%eax 33f3: c7 44 24 04 b5 44 00 movl $0x44b5,0x4(%esp) 33fa: 00 33fb: 89 04 24 mov %eax,(%esp) 33fe: e8 42 0c 00 00 call 4045 <printf> exit(); 3403: e8 ad 0a 00 00 call 3eb5 <exit> } if(pid == 0){ 3408: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 340c: 75 39 jne 3447 <sbrktest+0x360> printf(stdout, "oops could read %x = %x\n", a, *a); 340e: 8b 45 f4 mov -0xc(%ebp),%eax 3411: 0f b6 00 movzbl (%eax),%eax 3414: 0f be d0 movsbl %al,%edx 3417: a1 d4 62 00 00 mov 0x62d4,%eax 341c: 89 54 24 0c mov %edx,0xc(%esp) 3420: 8b 55 f4 mov -0xc(%ebp),%edx 3423: 89 54 24 08 mov %edx,0x8(%esp) 3427: c7 44 24 04 61 59 00 movl $0x5961,0x4(%esp) 342e: 00 342f: 89 04 24 mov %eax,(%esp) 3432: e8 0e 0c 00 00 call 4045 <printf> kill(ppid); 3437: 8b 45 d0 mov -0x30(%ebp),%eax 343a: 89 04 24 mov %eax,(%esp) 343d: e8 a3 0a 00 00 call 3ee5 <kill> exit(); 3442: e8 6e 0a 00 00 call 3eb5 <exit> } wait(); 3447: e8 71 0a 00 00 call 3ebd <wait> printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c); exit(); } // can we read the kernel's memory? for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 344c: 81 45 f4 50 c3 00 00 addl $0xc350,-0xc(%ebp) 3453: 81 7d f4 7f 84 1e 80 cmpl $0x801e847f,-0xc(%ebp) 345a: 0f 86 78 ff ff ff jbe 33d8 <sbrktest+0x2f1> wait(); } // if we run the system out of memory, does it clean up the last // failed allocation? if(pipe(fds) != 0){ 3460: 8d 45 c8 lea -0x38(%ebp),%eax 3463: 89 04 24 mov %eax,(%esp) 3466: e8 5a 0a 00 00 call 3ec5 <pipe> 346b: 85 c0 test %eax,%eax 346d: 74 19 je 3488 <sbrktest+0x3a1> printf(1, "pipe() failed\n"); 346f: c7 44 24 04 86 48 00 movl $0x4886,0x4(%esp) 3476: 00 3477: c7 04 24 01 00 00 00 movl $0x1,(%esp) 347e: e8 c2 0b 00 00 call 4045 <printf> exit(); 3483: e8 2d 0a 00 00 call 3eb5 <exit> } for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 3488: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 348f: e9 87 00 00 00 jmp 351b <sbrktest+0x434> if((pids[i] = fork()) == 0){ 3494: e8 14 0a 00 00 call 3ead <fork> 3499: 8b 55 f0 mov -0x10(%ebp),%edx 349c: 89 44 95 a0 mov %eax,-0x60(%ebp,%edx,4) 34a0: 8b 45 f0 mov -0x10(%ebp),%eax 34a3: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax 34a7: 85 c0 test %eax,%eax 34a9: 75 46 jne 34f1 <sbrktest+0x40a> // allocate a lot of memory sbrk(BIG - (uint)sbrk(0)); 34ab: c7 04 24 00 00 00 00 movl $0x0,(%esp) 34b2: e8 86 0a 00 00 call 3f3d <sbrk> 34b7: ba 00 00 40 06 mov $0x6400000,%edx 34bc: 29 c2 sub %eax,%edx 34be: 89 d0 mov %edx,%eax 34c0: 89 04 24 mov %eax,(%esp) 34c3: e8 75 0a 00 00 call 3f3d <sbrk> write(fds[1], "x", 1); 34c8: 8b 45 cc mov -0x34(%ebp),%eax 34cb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 34d2: 00 34d3: c7 44 24 04 eb 48 00 movl $0x48eb,0x4(%esp) 34da: 00 34db: 89 04 24 mov %eax,(%esp) 34de: e8 f2 09 00 00 call 3ed5 <write> // sit around until killed for(;;) sleep(1000); 34e3: c7 04 24 e8 03 00 00 movl $0x3e8,(%esp) 34ea: e8 56 0a 00 00 call 3f45 <sleep> 34ef: eb f2 jmp 34e3 <sbrktest+0x3fc> } if(pids[i] != -1) 34f1: 8b 45 f0 mov -0x10(%ebp),%eax 34f4: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax 34f8: 83 f8 ff cmp $0xffffffff,%eax 34fb: 74 1a je 3517 <sbrktest+0x430> read(fds[0], &scratch, 1); 34fd: 8b 45 c8 mov -0x38(%ebp),%eax 3500: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 3507: 00 3508: 8d 55 9f lea -0x61(%ebp),%edx 350b: 89 54 24 04 mov %edx,0x4(%esp) 350f: 89 04 24 mov %eax,(%esp) 3512: e8 b6 09 00 00 call 3ecd <read> // failed allocation? if(pipe(fds) != 0){ printf(1, "pipe() failed\n"); exit(); } for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 3517: 83 45 f0 01 addl $0x1,-0x10(%ebp) 351b: 8b 45 f0 mov -0x10(%ebp),%eax 351e: 83 f8 09 cmp $0x9,%eax 3521: 0f 86 6d ff ff ff jbe 3494 <sbrktest+0x3ad> if(pids[i] != -1) read(fds[0], &scratch, 1); } // if those failed allocations freed up the pages they did allocate, // we'll be able to allocate here c = sbrk(4096); 3527: c7 04 24 00 10 00 00 movl $0x1000,(%esp) 352e: e8 0a 0a 00 00 call 3f3d <sbrk> 3533: 89 45 e0 mov %eax,-0x20(%ebp) for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 3536: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 353d: eb 26 jmp 3565 <sbrktest+0x47e> if(pids[i] == -1) 353f: 8b 45 f0 mov -0x10(%ebp),%eax 3542: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax 3546: 83 f8 ff cmp $0xffffffff,%eax 3549: 75 02 jne 354d <sbrktest+0x466> continue; 354b: eb 14 jmp 3561 <sbrktest+0x47a> kill(pids[i]); 354d: 8b 45 f0 mov -0x10(%ebp),%eax 3550: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax 3554: 89 04 24 mov %eax,(%esp) 3557: e8 89 09 00 00 call 3ee5 <kill> wait(); 355c: e8 5c 09 00 00 call 3ebd <wait> read(fds[0], &scratch, 1); } // if those failed allocations freed up the pages they did allocate, // we'll be able to allocate here c = sbrk(4096); for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 3561: 83 45 f0 01 addl $0x1,-0x10(%ebp) 3565: 8b 45 f0 mov -0x10(%ebp),%eax 3568: 83 f8 09 cmp $0x9,%eax 356b: 76 d2 jbe 353f <sbrktest+0x458> if(pids[i] == -1) continue; kill(pids[i]); wait(); } if(c == (char*)0xffffffff){ 356d: 83 7d e0 ff cmpl $0xffffffff,-0x20(%ebp) 3571: 75 1a jne 358d <sbrktest+0x4a6> printf(stdout, "failed sbrk leaked memory\n"); 3573: a1 d4 62 00 00 mov 0x62d4,%eax 3578: c7 44 24 04 7a 59 00 movl $0x597a,0x4(%esp) 357f: 00 3580: 89 04 24 mov %eax,(%esp) 3583: e8 bd 0a 00 00 call 4045 <printf> exit(); 3588: e8 28 09 00 00 call 3eb5 <exit> } if(sbrk(0) > oldbrk) 358d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3594: e8 a4 09 00 00 call 3f3d <sbrk> 3599: 3b 45 ec cmp -0x14(%ebp),%eax 359c: 76 1b jbe 35b9 <sbrktest+0x4d2> sbrk(-(sbrk(0) - oldbrk)); 359e: 8b 5d ec mov -0x14(%ebp),%ebx 35a1: c7 04 24 00 00 00 00 movl $0x0,(%esp) 35a8: e8 90 09 00 00 call 3f3d <sbrk> 35ad: 29 c3 sub %eax,%ebx 35af: 89 d8 mov %ebx,%eax 35b1: 89 04 24 mov %eax,(%esp) 35b4: e8 84 09 00 00 call 3f3d <sbrk> printf(stdout, "sbrk test OK\n"); 35b9: a1 d4 62 00 00 mov 0x62d4,%eax 35be: c7 44 24 04 95 59 00 movl $0x5995,0x4(%esp) 35c5: 00 35c6: 89 04 24 mov %eax,(%esp) 35c9: e8 77 0a 00 00 call 4045 <printf> } 35ce: 81 c4 84 00 00 00 add $0x84,%esp 35d4: 5b pop %ebx 35d5: 5d pop %ebp 35d6: c3 ret 000035d7 <validateint>: void validateint(int *p) { 35d7: 55 push %ebp 35d8: 89 e5 mov %esp,%ebp 35da: 53 push %ebx 35db: 83 ec 10 sub $0x10,%esp int res; asm("mov %%esp, %%ebx\n\t" 35de: b8 0d 00 00 00 mov $0xd,%eax 35e3: 8b 55 08 mov 0x8(%ebp),%edx 35e6: 89 d1 mov %edx,%ecx 35e8: 89 e3 mov %esp,%ebx 35ea: 89 cc mov %ecx,%esp 35ec: cd 40 int $0x40 35ee: 89 dc mov %ebx,%esp 35f0: 89 45 f8 mov %eax,-0x8(%ebp) "int %2\n\t" "mov %%ebx, %%esp" : "=a" (res) : "a" (SYS_sleep), "n" (T_SYSCALL), "c" (p) : "ebx"); } 35f3: 83 c4 10 add $0x10,%esp 35f6: 5b pop %ebx 35f7: 5d pop %ebp 35f8: c3 ret 000035f9 <validatetest>: void validatetest(void) { 35f9: 55 push %ebp 35fa: 89 e5 mov %esp,%ebp 35fc: 83 ec 28 sub $0x28,%esp int hi, pid; uint p; printf(stdout, "validate test\n"); 35ff: a1 d4 62 00 00 mov 0x62d4,%eax 3604: c7 44 24 04 a3 59 00 movl $0x59a3,0x4(%esp) 360b: 00 360c: 89 04 24 mov %eax,(%esp) 360f: e8 31 0a 00 00 call 4045 <printf> hi = 1100*1024; 3614: c7 45 f0 00 30 11 00 movl $0x113000,-0x10(%ebp) for(p = 0; p <= (uint)hi; p += 4096){ 361b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 3622: eb 7f jmp 36a3 <validatetest+0xaa> if((pid = fork()) == 0){ 3624: e8 84 08 00 00 call 3ead <fork> 3629: 89 45 ec mov %eax,-0x14(%ebp) 362c: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 3630: 75 10 jne 3642 <validatetest+0x49> // try to crash the kernel by passing in a badly placed integer validateint((int*)p); 3632: 8b 45 f4 mov -0xc(%ebp),%eax 3635: 89 04 24 mov %eax,(%esp) 3638: e8 9a ff ff ff call 35d7 <validateint> exit(); 363d: e8 73 08 00 00 call 3eb5 <exit> } sleep(0); 3642: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3649: e8 f7 08 00 00 call 3f45 <sleep> sleep(0); 364e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3655: e8 eb 08 00 00 call 3f45 <sleep> kill(pid); 365a: 8b 45 ec mov -0x14(%ebp),%eax 365d: 89 04 24 mov %eax,(%esp) 3660: e8 80 08 00 00 call 3ee5 <kill> wait(); 3665: e8 53 08 00 00 call 3ebd <wait> // try to crash the kernel by passing in a bad string pointer if(link("nosuchfile", (char*)p) != -1){ 366a: 8b 45 f4 mov -0xc(%ebp),%eax 366d: 89 44 24 04 mov %eax,0x4(%esp) 3671: c7 04 24 b2 59 00 00 movl $0x59b2,(%esp) 3678: e8 98 08 00 00 call 3f15 <link> 367d: 83 f8 ff cmp $0xffffffff,%eax 3680: 74 1a je 369c <validatetest+0xa3> printf(stdout, "link should not succeed\n"); 3682: a1 d4 62 00 00 mov 0x62d4,%eax 3687: c7 44 24 04 bd 59 00 movl $0x59bd,0x4(%esp) 368e: 00 368f: 89 04 24 mov %eax,(%esp) 3692: e8 ae 09 00 00 call 4045 <printf> exit(); 3697: e8 19 08 00 00 call 3eb5 <exit> uint p; printf(stdout, "validate test\n"); hi = 1100*1024; for(p = 0; p <= (uint)hi; p += 4096){ 369c: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) 36a3: 8b 45 f0 mov -0x10(%ebp),%eax 36a6: 3b 45 f4 cmp -0xc(%ebp),%eax 36a9: 0f 83 75 ff ff ff jae 3624 <validatetest+0x2b> printf(stdout, "link should not succeed\n"); exit(); } } printf(stdout, "validate ok\n"); 36af: a1 d4 62 00 00 mov 0x62d4,%eax 36b4: c7 44 24 04 d6 59 00 movl $0x59d6,0x4(%esp) 36bb: 00 36bc: 89 04 24 mov %eax,(%esp) 36bf: e8 81 09 00 00 call 4045 <printf> } 36c4: c9 leave 36c5: c3 ret 000036c6 <bsstest>: // does unintialized data start out zero? char uninit[10000]; void bsstest(void) { 36c6: 55 push %ebp 36c7: 89 e5 mov %esp,%ebp 36c9: 83 ec 28 sub $0x28,%esp int i; printf(stdout, "bss test\n"); 36cc: a1 d4 62 00 00 mov 0x62d4,%eax 36d1: c7 44 24 04 e3 59 00 movl $0x59e3,0x4(%esp) 36d8: 00 36d9: 89 04 24 mov %eax,(%esp) 36dc: e8 64 09 00 00 call 4045 <printf> for(i = 0; i < sizeof(uninit); i++){ 36e1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 36e8: eb 2d jmp 3717 <bsstest+0x51> if(uninit[i] != '\0'){ 36ea: 8b 45 f4 mov -0xc(%ebp),%eax 36ed: 05 a0 63 00 00 add $0x63a0,%eax 36f2: 0f b6 00 movzbl (%eax),%eax 36f5: 84 c0 test %al,%al 36f7: 74 1a je 3713 <bsstest+0x4d> printf(stdout, "bss test failed\n"); 36f9: a1 d4 62 00 00 mov 0x62d4,%eax 36fe: c7 44 24 04 ed 59 00 movl $0x59ed,0x4(%esp) 3705: 00 3706: 89 04 24 mov %eax,(%esp) 3709: e8 37 09 00 00 call 4045 <printf> exit(); 370e: e8 a2 07 00 00 call 3eb5 <exit> bsstest(void) { int i; printf(stdout, "bss test\n"); for(i = 0; i < sizeof(uninit); i++){ 3713: 83 45 f4 01 addl $0x1,-0xc(%ebp) 3717: 8b 45 f4 mov -0xc(%ebp),%eax 371a: 3d 0f 27 00 00 cmp $0x270f,%eax 371f: 76 c9 jbe 36ea <bsstest+0x24> if(uninit[i] != '\0'){ printf(stdout, "bss test failed\n"); exit(); } } printf(stdout, "bss test ok\n"); 3721: a1 d4 62 00 00 mov 0x62d4,%eax 3726: c7 44 24 04 fe 59 00 movl $0x59fe,0x4(%esp) 372d: 00 372e: 89 04 24 mov %eax,(%esp) 3731: e8 0f 09 00 00 call 4045 <printf> } 3736: c9 leave 3737: c3 ret 00003738 <bigargtest>: // does exec return an error if the arguments // are larger than a page? or does it write // below the stack and wreck the instructions/data? void bigargtest(void) { 3738: 55 push %ebp 3739: 89 e5 mov %esp,%ebp 373b: 83 ec 28 sub $0x28,%esp int pid, fd; unlink("bigarg-ok"); 373e: c7 04 24 0b 5a 00 00 movl $0x5a0b,(%esp) 3745: e8 bb 07 00 00 call 3f05 <unlink> pid = fork(); 374a: e8 5e 07 00 00 call 3ead <fork> 374f: 89 45 f0 mov %eax,-0x10(%ebp) if(pid == 0){ 3752: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 3756: 0f 85 90 00 00 00 jne 37ec <bigargtest+0xb4> static char *args[MAXARG]; int i; for(i = 0; i < MAXARG-1; i++) 375c: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 3763: eb 12 jmp 3777 <bigargtest+0x3f> args[i] = "bigargs test: failed\n "; 3765: 8b 45 f4 mov -0xc(%ebp),%eax 3768: c7 04 85 00 63 00 00 movl $0x5a18,0x6300(,%eax,4) 376f: 18 5a 00 00 unlink("bigarg-ok"); pid = fork(); if(pid == 0){ static char *args[MAXARG]; int i; for(i = 0; i < MAXARG-1; i++) 3773: 83 45 f4 01 addl $0x1,-0xc(%ebp) 3777: 83 7d f4 1e cmpl $0x1e,-0xc(%ebp) 377b: 7e e8 jle 3765 <bigargtest+0x2d> args[i] = "bigargs test: failed\n "; args[MAXARG-1] = 0; 377d: c7 05 7c 63 00 00 00 movl $0x0,0x637c 3784: 00 00 00 printf(stdout, "bigarg test\n"); 3787: a1 d4 62 00 00 mov 0x62d4,%eax 378c: c7 44 24 04 f5 5a 00 movl $0x5af5,0x4(%esp) 3793: 00 3794: 89 04 24 mov %eax,(%esp) 3797: e8 a9 08 00 00 call 4045 <printf> exec("echo", args); 379c: c7 44 24 04 00 63 00 movl $0x6300,0x4(%esp) 37a3: 00 37a4: c7 04 24 14 44 00 00 movl $0x4414,(%esp) 37ab: e8 3d 07 00 00 call 3eed <exec> printf(stdout, "bigarg test ok\n"); 37b0: a1 d4 62 00 00 mov 0x62d4,%eax 37b5: c7 44 24 04 02 5b 00 movl $0x5b02,0x4(%esp) 37bc: 00 37bd: 89 04 24 mov %eax,(%esp) 37c0: e8 80 08 00 00 call 4045 <printf> fd = open("bigarg-ok", O_CREATE); 37c5: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 37cc: 00 37cd: c7 04 24 0b 5a 00 00 movl $0x5a0b,(%esp) 37d4: e8 1c 07 00 00 call 3ef5 <open> 37d9: 89 45 ec mov %eax,-0x14(%ebp) close(fd); 37dc: 8b 45 ec mov -0x14(%ebp),%eax 37df: 89 04 24 mov %eax,(%esp) 37e2: e8 f6 06 00 00 call 3edd <close> exit(); 37e7: e8 c9 06 00 00 call 3eb5 <exit> } else if(pid < 0){ 37ec: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 37f0: 79 1a jns 380c <bigargtest+0xd4> printf(stdout, "bigargtest: fork failed\n"); 37f2: a1 d4 62 00 00 mov 0x62d4,%eax 37f7: c7 44 24 04 12 5b 00 movl $0x5b12,0x4(%esp) 37fe: 00 37ff: 89 04 24 mov %eax,(%esp) 3802: e8 3e 08 00 00 call 4045 <printf> exit(); 3807: e8 a9 06 00 00 call 3eb5 <exit> } wait(); 380c: e8 ac 06 00 00 call 3ebd <wait> fd = open("bigarg-ok", 0); 3811: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 3818: 00 3819: c7 04 24 0b 5a 00 00 movl $0x5a0b,(%esp) 3820: e8 d0 06 00 00 call 3ef5 <open> 3825: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 3828: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 382c: 79 1a jns 3848 <bigargtest+0x110> printf(stdout, "bigarg test failed!\n"); 382e: a1 d4 62 00 00 mov 0x62d4,%eax 3833: c7 44 24 04 2b 5b 00 movl $0x5b2b,0x4(%esp) 383a: 00 383b: 89 04 24 mov %eax,(%esp) 383e: e8 02 08 00 00 call 4045 <printf> exit(); 3843: e8 6d 06 00 00 call 3eb5 <exit> } close(fd); 3848: 8b 45 ec mov -0x14(%ebp),%eax 384b: 89 04 24 mov %eax,(%esp) 384e: e8 8a 06 00 00 call 3edd <close> unlink("bigarg-ok"); 3853: c7 04 24 0b 5a 00 00 movl $0x5a0b,(%esp) 385a: e8 a6 06 00 00 call 3f05 <unlink> } 385f: c9 leave 3860: c3 ret 00003861 <fsfull>: // what happens when the file system runs out of blocks? // answer: balloc panics, so this test is not useful. void fsfull() { 3861: 55 push %ebp 3862: 89 e5 mov %esp,%ebp 3864: 53 push %ebx 3865: 83 ec 74 sub $0x74,%esp int nfiles; int fsblocks = 0; 3868: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) printf(1, "fsfull test\n"); 386f: c7 44 24 04 40 5b 00 movl $0x5b40,0x4(%esp) 3876: 00 3877: c7 04 24 01 00 00 00 movl $0x1,(%esp) 387e: e8 c2 07 00 00 call 4045 <printf> for(nfiles = 0; ; nfiles++){ 3883: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) char name[64]; name[0] = 'f'; 388a: c6 45 a4 66 movb $0x66,-0x5c(%ebp) name[1] = '0' + nfiles / 1000; 388e: 8b 4d f4 mov -0xc(%ebp),%ecx 3891: ba d3 4d 62 10 mov $0x10624dd3,%edx 3896: 89 c8 mov %ecx,%eax 3898: f7 ea imul %edx 389a: c1 fa 06 sar $0x6,%edx 389d: 89 c8 mov %ecx,%eax 389f: c1 f8 1f sar $0x1f,%eax 38a2: 29 c2 sub %eax,%edx 38a4: 89 d0 mov %edx,%eax 38a6: 83 c0 30 add $0x30,%eax 38a9: 88 45 a5 mov %al,-0x5b(%ebp) name[2] = '0' + (nfiles % 1000) / 100; 38ac: 8b 5d f4 mov -0xc(%ebp),%ebx 38af: ba d3 4d 62 10 mov $0x10624dd3,%edx 38b4: 89 d8 mov %ebx,%eax 38b6: f7 ea imul %edx 38b8: c1 fa 06 sar $0x6,%edx 38bb: 89 d8 mov %ebx,%eax 38bd: c1 f8 1f sar $0x1f,%eax 38c0: 89 d1 mov %edx,%ecx 38c2: 29 c1 sub %eax,%ecx 38c4: 69 c1 e8 03 00 00 imul $0x3e8,%ecx,%eax 38ca: 29 c3 sub %eax,%ebx 38cc: 89 d9 mov %ebx,%ecx 38ce: ba 1f 85 eb 51 mov $0x51eb851f,%edx 38d3: 89 c8 mov %ecx,%eax 38d5: f7 ea imul %edx 38d7: c1 fa 05 sar $0x5,%edx 38da: 89 c8 mov %ecx,%eax 38dc: c1 f8 1f sar $0x1f,%eax 38df: 29 c2 sub %eax,%edx 38e1: 89 d0 mov %edx,%eax 38e3: 83 c0 30 add $0x30,%eax 38e6: 88 45 a6 mov %al,-0x5a(%ebp) name[3] = '0' + (nfiles % 100) / 10; 38e9: 8b 5d f4 mov -0xc(%ebp),%ebx 38ec: ba 1f 85 eb 51 mov $0x51eb851f,%edx 38f1: 89 d8 mov %ebx,%eax 38f3: f7 ea imul %edx 38f5: c1 fa 05 sar $0x5,%edx 38f8: 89 d8 mov %ebx,%eax 38fa: c1 f8 1f sar $0x1f,%eax 38fd: 89 d1 mov %edx,%ecx 38ff: 29 c1 sub %eax,%ecx 3901: 6b c1 64 imul $0x64,%ecx,%eax 3904: 29 c3 sub %eax,%ebx 3906: 89 d9 mov %ebx,%ecx 3908: ba 67 66 66 66 mov $0x66666667,%edx 390d: 89 c8 mov %ecx,%eax 390f: f7 ea imul %edx 3911: c1 fa 02 sar $0x2,%edx 3914: 89 c8 mov %ecx,%eax 3916: c1 f8 1f sar $0x1f,%eax 3919: 29 c2 sub %eax,%edx 391b: 89 d0 mov %edx,%eax 391d: 83 c0 30 add $0x30,%eax 3920: 88 45 a7 mov %al,-0x59(%ebp) name[4] = '0' + (nfiles % 10); 3923: 8b 4d f4 mov -0xc(%ebp),%ecx 3926: ba 67 66 66 66 mov $0x66666667,%edx 392b: 89 c8 mov %ecx,%eax 392d: f7 ea imul %edx 392f: c1 fa 02 sar $0x2,%edx 3932: 89 c8 mov %ecx,%eax 3934: c1 f8 1f sar $0x1f,%eax 3937: 29 c2 sub %eax,%edx 3939: 89 d0 mov %edx,%eax 393b: c1 e0 02 shl $0x2,%eax 393e: 01 d0 add %edx,%eax 3940: 01 c0 add %eax,%eax 3942: 29 c1 sub %eax,%ecx 3944: 89 ca mov %ecx,%edx 3946: 89 d0 mov %edx,%eax 3948: 83 c0 30 add $0x30,%eax 394b: 88 45 a8 mov %al,-0x58(%ebp) name[5] = '\0'; 394e: c6 45 a9 00 movb $0x0,-0x57(%ebp) printf(1, "writing %s\n", name); 3952: 8d 45 a4 lea -0x5c(%ebp),%eax 3955: 89 44 24 08 mov %eax,0x8(%esp) 3959: c7 44 24 04 4d 5b 00 movl $0x5b4d,0x4(%esp) 3960: 00 3961: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3968: e8 d8 06 00 00 call 4045 <printf> int fd = open(name, O_CREATE|O_RDWR); 396d: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 3974: 00 3975: 8d 45 a4 lea -0x5c(%ebp),%eax 3978: 89 04 24 mov %eax,(%esp) 397b: e8 75 05 00 00 call 3ef5 <open> 3980: 89 45 e8 mov %eax,-0x18(%ebp) if(fd < 0){ 3983: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 3987: 79 1d jns 39a6 <fsfull+0x145> printf(1, "open %s failed\n", name); 3989: 8d 45 a4 lea -0x5c(%ebp),%eax 398c: 89 44 24 08 mov %eax,0x8(%esp) 3990: c7 44 24 04 59 5b 00 movl $0x5b59,0x4(%esp) 3997: 00 3998: c7 04 24 01 00 00 00 movl $0x1,(%esp) 399f: e8 a1 06 00 00 call 4045 <printf> break; 39a4: eb 74 jmp 3a1a <fsfull+0x1b9> } int total = 0; 39a6: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) while(1){ int cc = write(fd, buf, 512); 39ad: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 39b4: 00 39b5: c7 44 24 04 c0 8a 00 movl $0x8ac0,0x4(%esp) 39bc: 00 39bd: 8b 45 e8 mov -0x18(%ebp),%eax 39c0: 89 04 24 mov %eax,(%esp) 39c3: e8 0d 05 00 00 call 3ed5 <write> 39c8: 89 45 e4 mov %eax,-0x1c(%ebp) if(cc < 512) 39cb: 81 7d e4 ff 01 00 00 cmpl $0x1ff,-0x1c(%ebp) 39d2: 7f 2f jg 3a03 <fsfull+0x1a2> break; 39d4: 90 nop total += cc; fsblocks++; } printf(1, "wrote %d bytes\n", total); 39d5: 8b 45 ec mov -0x14(%ebp),%eax 39d8: 89 44 24 08 mov %eax,0x8(%esp) 39dc: c7 44 24 04 69 5b 00 movl $0x5b69,0x4(%esp) 39e3: 00 39e4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 39eb: e8 55 06 00 00 call 4045 <printf> close(fd); 39f0: 8b 45 e8 mov -0x18(%ebp),%eax 39f3: 89 04 24 mov %eax,(%esp) 39f6: e8 e2 04 00 00 call 3edd <close> if(total == 0) 39fb: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 39ff: 75 10 jne 3a11 <fsfull+0x1b0> 3a01: eb 0c jmp 3a0f <fsfull+0x1ae> int total = 0; while(1){ int cc = write(fd, buf, 512); if(cc < 512) break; total += cc; 3a03: 8b 45 e4 mov -0x1c(%ebp),%eax 3a06: 01 45 ec add %eax,-0x14(%ebp) fsblocks++; 3a09: 83 45 f0 01 addl $0x1,-0x10(%ebp) } 3a0d: eb 9e jmp 39ad <fsfull+0x14c> printf(1, "wrote %d bytes\n", total); close(fd); if(total == 0) break; 3a0f: eb 09 jmp 3a1a <fsfull+0x1b9> int nfiles; int fsblocks = 0; printf(1, "fsfull test\n"); for(nfiles = 0; ; nfiles++){ 3a11: 83 45 f4 01 addl $0x1,-0xc(%ebp) } printf(1, "wrote %d bytes\n", total); close(fd); if(total == 0) break; } 3a15: e9 70 fe ff ff jmp 388a <fsfull+0x29> while(nfiles >= 0){ 3a1a: e9 d7 00 00 00 jmp 3af6 <fsfull+0x295> char name[64]; name[0] = 'f'; 3a1f: c6 45 a4 66 movb $0x66,-0x5c(%ebp) name[1] = '0' + nfiles / 1000; 3a23: 8b 4d f4 mov -0xc(%ebp),%ecx 3a26: ba d3 4d 62 10 mov $0x10624dd3,%edx 3a2b: 89 c8 mov %ecx,%eax 3a2d: f7 ea imul %edx 3a2f: c1 fa 06 sar $0x6,%edx 3a32: 89 c8 mov %ecx,%eax 3a34: c1 f8 1f sar $0x1f,%eax 3a37: 29 c2 sub %eax,%edx 3a39: 89 d0 mov %edx,%eax 3a3b: 83 c0 30 add $0x30,%eax 3a3e: 88 45 a5 mov %al,-0x5b(%ebp) name[2] = '0' + (nfiles % 1000) / 100; 3a41: 8b 5d f4 mov -0xc(%ebp),%ebx 3a44: ba d3 4d 62 10 mov $0x10624dd3,%edx 3a49: 89 d8 mov %ebx,%eax 3a4b: f7 ea imul %edx 3a4d: c1 fa 06 sar $0x6,%edx 3a50: 89 d8 mov %ebx,%eax 3a52: c1 f8 1f sar $0x1f,%eax 3a55: 89 d1 mov %edx,%ecx 3a57: 29 c1 sub %eax,%ecx 3a59: 69 c1 e8 03 00 00 imul $0x3e8,%ecx,%eax 3a5f: 29 c3 sub %eax,%ebx 3a61: 89 d9 mov %ebx,%ecx 3a63: ba 1f 85 eb 51 mov $0x51eb851f,%edx 3a68: 89 c8 mov %ecx,%eax 3a6a: f7 ea imul %edx 3a6c: c1 fa 05 sar $0x5,%edx 3a6f: 89 c8 mov %ecx,%eax 3a71: c1 f8 1f sar $0x1f,%eax 3a74: 29 c2 sub %eax,%edx 3a76: 89 d0 mov %edx,%eax 3a78: 83 c0 30 add $0x30,%eax 3a7b: 88 45 a6 mov %al,-0x5a(%ebp) name[3] = '0' + (nfiles % 100) / 10; 3a7e: 8b 5d f4 mov -0xc(%ebp),%ebx 3a81: ba 1f 85 eb 51 mov $0x51eb851f,%edx 3a86: 89 d8 mov %ebx,%eax 3a88: f7 ea imul %edx 3a8a: c1 fa 05 sar $0x5,%edx 3a8d: 89 d8 mov %ebx,%eax 3a8f: c1 f8 1f sar $0x1f,%eax 3a92: 89 d1 mov %edx,%ecx 3a94: 29 c1 sub %eax,%ecx 3a96: 6b c1 64 imul $0x64,%ecx,%eax 3a99: 29 c3 sub %eax,%ebx 3a9b: 89 d9 mov %ebx,%ecx 3a9d: ba 67 66 66 66 mov $0x66666667,%edx 3aa2: 89 c8 mov %ecx,%eax 3aa4: f7 ea imul %edx 3aa6: c1 fa 02 sar $0x2,%edx 3aa9: 89 c8 mov %ecx,%eax 3aab: c1 f8 1f sar $0x1f,%eax 3aae: 29 c2 sub %eax,%edx 3ab0: 89 d0 mov %edx,%eax 3ab2: 83 c0 30 add $0x30,%eax 3ab5: 88 45 a7 mov %al,-0x59(%ebp) name[4] = '0' + (nfiles % 10); 3ab8: 8b 4d f4 mov -0xc(%ebp),%ecx 3abb: ba 67 66 66 66 mov $0x66666667,%edx 3ac0: 89 c8 mov %ecx,%eax 3ac2: f7 ea imul %edx 3ac4: c1 fa 02 sar $0x2,%edx 3ac7: 89 c8 mov %ecx,%eax 3ac9: c1 f8 1f sar $0x1f,%eax 3acc: 29 c2 sub %eax,%edx 3ace: 89 d0 mov %edx,%eax 3ad0: c1 e0 02 shl $0x2,%eax 3ad3: 01 d0 add %edx,%eax 3ad5: 01 c0 add %eax,%eax 3ad7: 29 c1 sub %eax,%ecx 3ad9: 89 ca mov %ecx,%edx 3adb: 89 d0 mov %edx,%eax 3add: 83 c0 30 add $0x30,%eax 3ae0: 88 45 a8 mov %al,-0x58(%ebp) name[5] = '\0'; 3ae3: c6 45 a9 00 movb $0x0,-0x57(%ebp) unlink(name); 3ae7: 8d 45 a4 lea -0x5c(%ebp),%eax 3aea: 89 04 24 mov %eax,(%esp) 3aed: e8 13 04 00 00 call 3f05 <unlink> nfiles--; 3af2: 83 6d f4 01 subl $0x1,-0xc(%ebp) close(fd); if(total == 0) break; } while(nfiles >= 0){ 3af6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 3afa: 0f 89 1f ff ff ff jns 3a1f <fsfull+0x1be> name[5] = '\0'; unlink(name); nfiles--; } printf(1, "fsfull test finished\n"); 3b00: c7 44 24 04 79 5b 00 movl $0x5b79,0x4(%esp) 3b07: 00 3b08: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3b0f: e8 31 05 00 00 call 4045 <printf> } 3b14: 83 c4 74 add $0x74,%esp 3b17: 5b pop %ebx 3b18: 5d pop %ebp 3b19: c3 ret 00003b1a <rand>: unsigned long randstate = 1; unsigned int rand() { 3b1a: 55 push %ebp 3b1b: 89 e5 mov %esp,%ebp randstate = randstate * 1664525 + 1013904223; 3b1d: a1 d8 62 00 00 mov 0x62d8,%eax 3b22: 69 c0 0d 66 19 00 imul $0x19660d,%eax,%eax 3b28: 05 5f f3 6e 3c add $0x3c6ef35f,%eax 3b2d: a3 d8 62 00 00 mov %eax,0x62d8 return randstate; 3b32: a1 d8 62 00 00 mov 0x62d8,%eax } 3b37: 5d pop %ebp 3b38: c3 ret 00003b39 <main>: int main(int argc, char *argv[]) { 3b39: 55 push %ebp 3b3a: 89 e5 mov %esp,%ebp 3b3c: 83 e4 f0 and $0xfffffff0,%esp 3b3f: 83 ec 10 sub $0x10,%esp printf(1, "usertests starting\n"); 3b42: c7 44 24 04 8f 5b 00 movl $0x5b8f,0x4(%esp) 3b49: 00 3b4a: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3b51: e8 ef 04 00 00 call 4045 <printf> if(open("usertests.ran", 0) >= 0){ 3b56: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 3b5d: 00 3b5e: c7 04 24 a3 5b 00 00 movl $0x5ba3,(%esp) 3b65: e8 8b 03 00 00 call 3ef5 <open> 3b6a: 85 c0 test %eax,%eax 3b6c: 78 19 js 3b87 <main+0x4e> printf(1, "already ran user tests -- rebuild fs.img\n"); 3b6e: c7 44 24 04 b4 5b 00 movl $0x5bb4,0x4(%esp) 3b75: 00 3b76: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3b7d: e8 c3 04 00 00 call 4045 <printf> exit(); 3b82: e8 2e 03 00 00 call 3eb5 <exit> } close(open("usertests.ran", O_CREATE)); 3b87: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 3b8e: 00 3b8f: c7 04 24 a3 5b 00 00 movl $0x5ba3,(%esp) 3b96: e8 5a 03 00 00 call 3ef5 <open> 3b9b: 89 04 24 mov %eax,(%esp) 3b9e: e8 3a 03 00 00 call 3edd <close> createdelete(); 3ba3: e8 da d6 ff ff call 1282 <createdelete> linkunlink(); 3ba8: e8 1e e1 ff ff call 1ccb <linkunlink> concreate(); 3bad: e8 66 dd ff ff call 1918 <concreate> fourfiles(); 3bb2: e8 63 d4 ff ff call 101a <fourfiles> sharedfd(); 3bb7: e8 60 d2 ff ff call e1c <sharedfd> bigargtest(); 3bbc: e8 77 fb ff ff call 3738 <bigargtest> bigwrite(); 3bc1: e8 e6 ea ff ff call 26ac <bigwrite> bigargtest(); 3bc6: e8 6d fb ff ff call 3738 <bigargtest> bsstest(); 3bcb: e8 f6 fa ff ff call 36c6 <bsstest> sbrktest(); 3bd0: e8 12 f5 ff ff call 30e7 <sbrktest> validatetest(); 3bd5: e8 1f fa ff ff call 35f9 <validatetest> opentest(); 3bda: e8 e8 c6 ff ff call 2c7 <opentest> writetest(); 3bdf: e8 8e c7 ff ff call 372 <writetest> writetest1(); 3be4: e8 9e c9 ff ff call 587 <writetest1> createtest(); 3be9: e8 a4 cb ff ff call 792 <createtest> openiputtest(); 3bee: e8 d3 c5 ff ff call 1c6 <openiputtest> exitiputtest(); 3bf3: e8 e2 c4 ff ff call da <exitiputtest> iputtest(); 3bf8: e8 03 c4 ff ff call 0 <iputtest> mem(); 3bfd: e8 35 d1 ff ff call d37 <mem> pipe1(); 3c02: e8 6c cd ff ff call 973 <pipe1> preempt(); 3c07: e8 54 cf ff ff call b60 <preempt> exitwait(); 3c0c: e8 a8 d0 ff ff call cb9 <exitwait> rmdot(); 3c11: e8 1f ef ff ff call 2b35 <rmdot> fourteen(); 3c16: e8 c4 ed ff ff call 29df <fourteen> bigfile(); 3c1b: e8 94 eb ff ff call 27b4 <bigfile> subdir(); 3c20: e8 41 e3 ff ff call 1f66 <subdir> linktest(); 3c25: e8 a5 da ff ff call 16cf <linktest> unlinkread(); 3c2a: e8 cb d8 ff ff call 14fa <unlinkread> dirfile(); 3c2f: e8 79 f0 ff ff call 2cad <dirfile> iref(); 3c34: e8 b6 f2 ff ff call 2eef <iref> forktest(); 3c39: e8 d5 f3 ff ff call 3013 <forktest> bigdir(); // slow 3c3e: e8 b6 e1 ff ff call 1df9 <bigdir> exectest(); 3c43: e8 dc cc ff ff call 924 <exectest> exit(); 3c48: e8 68 02 00 00 call 3eb5 <exit> 00003c4d <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 3c4d: 55 push %ebp 3c4e: 89 e5 mov %esp,%ebp 3c50: 57 push %edi 3c51: 53 push %ebx asm volatile("cld; rep stosb" : 3c52: 8b 4d 08 mov 0x8(%ebp),%ecx 3c55: 8b 55 10 mov 0x10(%ebp),%edx 3c58: 8b 45 0c mov 0xc(%ebp),%eax 3c5b: 89 cb mov %ecx,%ebx 3c5d: 89 df mov %ebx,%edi 3c5f: 89 d1 mov %edx,%ecx 3c61: fc cld 3c62: f3 aa rep stos %al,%es:(%edi) 3c64: 89 ca mov %ecx,%edx 3c66: 89 fb mov %edi,%ebx 3c68: 89 5d 08 mov %ebx,0x8(%ebp) 3c6b: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 3c6e: 5b pop %ebx 3c6f: 5f pop %edi 3c70: 5d pop %ebp 3c71: c3 ret 00003c72 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 3c72: 55 push %ebp 3c73: 89 e5 mov %esp,%ebp 3c75: 83 ec 10 sub $0x10,%esp char *os; os = s; 3c78: 8b 45 08 mov 0x8(%ebp),%eax 3c7b: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 3c7e: 90 nop 3c7f: 8b 45 08 mov 0x8(%ebp),%eax 3c82: 8d 50 01 lea 0x1(%eax),%edx 3c85: 89 55 08 mov %edx,0x8(%ebp) 3c88: 8b 55 0c mov 0xc(%ebp),%edx 3c8b: 8d 4a 01 lea 0x1(%edx),%ecx 3c8e: 89 4d 0c mov %ecx,0xc(%ebp) 3c91: 0f b6 12 movzbl (%edx),%edx 3c94: 88 10 mov %dl,(%eax) 3c96: 0f b6 00 movzbl (%eax),%eax 3c99: 84 c0 test %al,%al 3c9b: 75 e2 jne 3c7f <strcpy+0xd> ; return os; 3c9d: 8b 45 fc mov -0x4(%ebp),%eax } 3ca0: c9 leave 3ca1: c3 ret 00003ca2 <strcmp>: int strcmp(const char *p, const char *q) { 3ca2: 55 push %ebp 3ca3: 89 e5 mov %esp,%ebp while(*p && *p == *q) 3ca5: eb 08 jmp 3caf <strcmp+0xd> p++, q++; 3ca7: 83 45 08 01 addl $0x1,0x8(%ebp) 3cab: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 3caf: 8b 45 08 mov 0x8(%ebp),%eax 3cb2: 0f b6 00 movzbl (%eax),%eax 3cb5: 84 c0 test %al,%al 3cb7: 74 10 je 3cc9 <strcmp+0x27> 3cb9: 8b 45 08 mov 0x8(%ebp),%eax 3cbc: 0f b6 10 movzbl (%eax),%edx 3cbf: 8b 45 0c mov 0xc(%ebp),%eax 3cc2: 0f b6 00 movzbl (%eax),%eax 3cc5: 38 c2 cmp %al,%dl 3cc7: 74 de je 3ca7 <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 3cc9: 8b 45 08 mov 0x8(%ebp),%eax 3ccc: 0f b6 00 movzbl (%eax),%eax 3ccf: 0f b6 d0 movzbl %al,%edx 3cd2: 8b 45 0c mov 0xc(%ebp),%eax 3cd5: 0f b6 00 movzbl (%eax),%eax 3cd8: 0f b6 c0 movzbl %al,%eax 3cdb: 29 c2 sub %eax,%edx 3cdd: 89 d0 mov %edx,%eax } 3cdf: 5d pop %ebp 3ce0: c3 ret 00003ce1 <strlen>: uint strlen(char *s) { 3ce1: 55 push %ebp 3ce2: 89 e5 mov %esp,%ebp 3ce4: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 3ce7: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 3cee: eb 04 jmp 3cf4 <strlen+0x13> 3cf0: 83 45 fc 01 addl $0x1,-0x4(%ebp) 3cf4: 8b 55 fc mov -0x4(%ebp),%edx 3cf7: 8b 45 08 mov 0x8(%ebp),%eax 3cfa: 01 d0 add %edx,%eax 3cfc: 0f b6 00 movzbl (%eax),%eax 3cff: 84 c0 test %al,%al 3d01: 75 ed jne 3cf0 <strlen+0xf> ; return n; 3d03: 8b 45 fc mov -0x4(%ebp),%eax } 3d06: c9 leave 3d07: c3 ret 00003d08 <memset>: void* memset(void *dst, int c, uint n) { 3d08: 55 push %ebp 3d09: 89 e5 mov %esp,%ebp 3d0b: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 3d0e: 8b 45 10 mov 0x10(%ebp),%eax 3d11: 89 44 24 08 mov %eax,0x8(%esp) 3d15: 8b 45 0c mov 0xc(%ebp),%eax 3d18: 89 44 24 04 mov %eax,0x4(%esp) 3d1c: 8b 45 08 mov 0x8(%ebp),%eax 3d1f: 89 04 24 mov %eax,(%esp) 3d22: e8 26 ff ff ff call 3c4d <stosb> return dst; 3d27: 8b 45 08 mov 0x8(%ebp),%eax } 3d2a: c9 leave 3d2b: c3 ret 00003d2c <strchr>: char* strchr(const char *s, char c) { 3d2c: 55 push %ebp 3d2d: 89 e5 mov %esp,%ebp 3d2f: 83 ec 04 sub $0x4,%esp 3d32: 8b 45 0c mov 0xc(%ebp),%eax 3d35: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 3d38: eb 14 jmp 3d4e <strchr+0x22> if(*s == c) 3d3a: 8b 45 08 mov 0x8(%ebp),%eax 3d3d: 0f b6 00 movzbl (%eax),%eax 3d40: 3a 45 fc cmp -0x4(%ebp),%al 3d43: 75 05 jne 3d4a <strchr+0x1e> return (char*)s; 3d45: 8b 45 08 mov 0x8(%ebp),%eax 3d48: eb 13 jmp 3d5d <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 3d4a: 83 45 08 01 addl $0x1,0x8(%ebp) 3d4e: 8b 45 08 mov 0x8(%ebp),%eax 3d51: 0f b6 00 movzbl (%eax),%eax 3d54: 84 c0 test %al,%al 3d56: 75 e2 jne 3d3a <strchr+0xe> if(*s == c) return (char*)s; return 0; 3d58: b8 00 00 00 00 mov $0x0,%eax } 3d5d: c9 leave 3d5e: c3 ret 00003d5f <gets>: char* gets(char *buf, int max) { 3d5f: 55 push %ebp 3d60: 89 e5 mov %esp,%ebp 3d62: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 3d65: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 3d6c: eb 4c jmp 3dba <gets+0x5b> cc = read(0, &c, 1); 3d6e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 3d75: 00 3d76: 8d 45 ef lea -0x11(%ebp),%eax 3d79: 89 44 24 04 mov %eax,0x4(%esp) 3d7d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3d84: e8 44 01 00 00 call 3ecd <read> 3d89: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 3d8c: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 3d90: 7f 02 jg 3d94 <gets+0x35> break; 3d92: eb 31 jmp 3dc5 <gets+0x66> buf[i++] = c; 3d94: 8b 45 f4 mov -0xc(%ebp),%eax 3d97: 8d 50 01 lea 0x1(%eax),%edx 3d9a: 89 55 f4 mov %edx,-0xc(%ebp) 3d9d: 89 c2 mov %eax,%edx 3d9f: 8b 45 08 mov 0x8(%ebp),%eax 3da2: 01 c2 add %eax,%edx 3da4: 0f b6 45 ef movzbl -0x11(%ebp),%eax 3da8: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 3daa: 0f b6 45 ef movzbl -0x11(%ebp),%eax 3dae: 3c 0a cmp $0xa,%al 3db0: 74 13 je 3dc5 <gets+0x66> 3db2: 0f b6 45 ef movzbl -0x11(%ebp),%eax 3db6: 3c 0d cmp $0xd,%al 3db8: 74 0b je 3dc5 <gets+0x66> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 3dba: 8b 45 f4 mov -0xc(%ebp),%eax 3dbd: 83 c0 01 add $0x1,%eax 3dc0: 3b 45 0c cmp 0xc(%ebp),%eax 3dc3: 7c a9 jl 3d6e <gets+0xf> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 3dc5: 8b 55 f4 mov -0xc(%ebp),%edx 3dc8: 8b 45 08 mov 0x8(%ebp),%eax 3dcb: 01 d0 add %edx,%eax 3dcd: c6 00 00 movb $0x0,(%eax) return buf; 3dd0: 8b 45 08 mov 0x8(%ebp),%eax } 3dd3: c9 leave 3dd4: c3 ret 00003dd5 <stat>: int stat(char *n, struct stat *st) { 3dd5: 55 push %ebp 3dd6: 89 e5 mov %esp,%ebp 3dd8: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 3ddb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 3de2: 00 3de3: 8b 45 08 mov 0x8(%ebp),%eax 3de6: 89 04 24 mov %eax,(%esp) 3de9: e8 07 01 00 00 call 3ef5 <open> 3dee: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 3df1: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 3df5: 79 07 jns 3dfe <stat+0x29> return -1; 3df7: b8 ff ff ff ff mov $0xffffffff,%eax 3dfc: eb 23 jmp 3e21 <stat+0x4c> r = fstat(fd, st); 3dfe: 8b 45 0c mov 0xc(%ebp),%eax 3e01: 89 44 24 04 mov %eax,0x4(%esp) 3e05: 8b 45 f4 mov -0xc(%ebp),%eax 3e08: 89 04 24 mov %eax,(%esp) 3e0b: e8 fd 00 00 00 call 3f0d <fstat> 3e10: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 3e13: 8b 45 f4 mov -0xc(%ebp),%eax 3e16: 89 04 24 mov %eax,(%esp) 3e19: e8 bf 00 00 00 call 3edd <close> return r; 3e1e: 8b 45 f0 mov -0x10(%ebp),%eax } 3e21: c9 leave 3e22: c3 ret 00003e23 <atoi>: int atoi(const char *s) { 3e23: 55 push %ebp 3e24: 89 e5 mov %esp,%ebp 3e26: 83 ec 10 sub $0x10,%esp int n; n = 0; 3e29: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 3e30: eb 25 jmp 3e57 <atoi+0x34> n = n*10 + *s++ - '0'; 3e32: 8b 55 fc mov -0x4(%ebp),%edx 3e35: 89 d0 mov %edx,%eax 3e37: c1 e0 02 shl $0x2,%eax 3e3a: 01 d0 add %edx,%eax 3e3c: 01 c0 add %eax,%eax 3e3e: 89 c1 mov %eax,%ecx 3e40: 8b 45 08 mov 0x8(%ebp),%eax 3e43: 8d 50 01 lea 0x1(%eax),%edx 3e46: 89 55 08 mov %edx,0x8(%ebp) 3e49: 0f b6 00 movzbl (%eax),%eax 3e4c: 0f be c0 movsbl %al,%eax 3e4f: 01 c8 add %ecx,%eax 3e51: 83 e8 30 sub $0x30,%eax 3e54: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 3e57: 8b 45 08 mov 0x8(%ebp),%eax 3e5a: 0f b6 00 movzbl (%eax),%eax 3e5d: 3c 2f cmp $0x2f,%al 3e5f: 7e 0a jle 3e6b <atoi+0x48> 3e61: 8b 45 08 mov 0x8(%ebp),%eax 3e64: 0f b6 00 movzbl (%eax),%eax 3e67: 3c 39 cmp $0x39,%al 3e69: 7e c7 jle 3e32 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 3e6b: 8b 45 fc mov -0x4(%ebp),%eax } 3e6e: c9 leave 3e6f: c3 ret 00003e70 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 3e70: 55 push %ebp 3e71: 89 e5 mov %esp,%ebp 3e73: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 3e76: 8b 45 08 mov 0x8(%ebp),%eax 3e79: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 3e7c: 8b 45 0c mov 0xc(%ebp),%eax 3e7f: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 3e82: eb 17 jmp 3e9b <memmove+0x2b> *dst++ = *src++; 3e84: 8b 45 fc mov -0x4(%ebp),%eax 3e87: 8d 50 01 lea 0x1(%eax),%edx 3e8a: 89 55 fc mov %edx,-0x4(%ebp) 3e8d: 8b 55 f8 mov -0x8(%ebp),%edx 3e90: 8d 4a 01 lea 0x1(%edx),%ecx 3e93: 89 4d f8 mov %ecx,-0x8(%ebp) 3e96: 0f b6 12 movzbl (%edx),%edx 3e99: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 3e9b: 8b 45 10 mov 0x10(%ebp),%eax 3e9e: 8d 50 ff lea -0x1(%eax),%edx 3ea1: 89 55 10 mov %edx,0x10(%ebp) 3ea4: 85 c0 test %eax,%eax 3ea6: 7f dc jg 3e84 <memmove+0x14> *dst++ = *src++; return vdst; 3ea8: 8b 45 08 mov 0x8(%ebp),%eax } 3eab: c9 leave 3eac: c3 ret 00003ead <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 3ead: b8 01 00 00 00 mov $0x1,%eax 3eb2: cd 40 int $0x40 3eb4: c3 ret 00003eb5 <exit>: SYSCALL(exit) 3eb5: b8 02 00 00 00 mov $0x2,%eax 3eba: cd 40 int $0x40 3ebc: c3 ret 00003ebd <wait>: SYSCALL(wait) 3ebd: b8 03 00 00 00 mov $0x3,%eax 3ec2: cd 40 int $0x40 3ec4: c3 ret 00003ec5 <pipe>: SYSCALL(pipe) 3ec5: b8 04 00 00 00 mov $0x4,%eax 3eca: cd 40 int $0x40 3ecc: c3 ret 00003ecd <read>: SYSCALL(read) 3ecd: b8 05 00 00 00 mov $0x5,%eax 3ed2: cd 40 int $0x40 3ed4: c3 ret 00003ed5 <write>: SYSCALL(write) 3ed5: b8 10 00 00 00 mov $0x10,%eax 3eda: cd 40 int $0x40 3edc: c3 ret 00003edd <close>: SYSCALL(close) 3edd: b8 15 00 00 00 mov $0x15,%eax 3ee2: cd 40 int $0x40 3ee4: c3 ret 00003ee5 <kill>: SYSCALL(kill) 3ee5: b8 06 00 00 00 mov $0x6,%eax 3eea: cd 40 int $0x40 3eec: c3 ret 00003eed <exec>: SYSCALL(exec) 3eed: b8 07 00 00 00 mov $0x7,%eax 3ef2: cd 40 int $0x40 3ef4: c3 ret 00003ef5 <open>: SYSCALL(open) 3ef5: b8 0f 00 00 00 mov $0xf,%eax 3efa: cd 40 int $0x40 3efc: c3 ret 00003efd <mknod>: SYSCALL(mknod) 3efd: b8 11 00 00 00 mov $0x11,%eax 3f02: cd 40 int $0x40 3f04: c3 ret 00003f05 <unlink>: SYSCALL(unlink) 3f05: b8 12 00 00 00 mov $0x12,%eax 3f0a: cd 40 int $0x40 3f0c: c3 ret 00003f0d <fstat>: SYSCALL(fstat) 3f0d: b8 08 00 00 00 mov $0x8,%eax 3f12: cd 40 int $0x40 3f14: c3 ret 00003f15 <link>: SYSCALL(link) 3f15: b8 13 00 00 00 mov $0x13,%eax 3f1a: cd 40 int $0x40 3f1c: c3 ret 00003f1d <mkdir>: SYSCALL(mkdir) 3f1d: b8 14 00 00 00 mov $0x14,%eax 3f22: cd 40 int $0x40 3f24: c3 ret 00003f25 <chdir>: SYSCALL(chdir) 3f25: b8 09 00 00 00 mov $0x9,%eax 3f2a: cd 40 int $0x40 3f2c: c3 ret 00003f2d <dup>: SYSCALL(dup) 3f2d: b8 0a 00 00 00 mov $0xa,%eax 3f32: cd 40 int $0x40 3f34: c3 ret 00003f35 <getpid>: SYSCALL(getpid) 3f35: b8 0b 00 00 00 mov $0xb,%eax 3f3a: cd 40 int $0x40 3f3c: c3 ret 00003f3d <sbrk>: SYSCALL(sbrk) 3f3d: b8 0c 00 00 00 mov $0xc,%eax 3f42: cd 40 int $0x40 3f44: c3 ret 00003f45 <sleep>: SYSCALL(sleep) 3f45: b8 0d 00 00 00 mov $0xd,%eax 3f4a: cd 40 int $0x40 3f4c: c3 ret 00003f4d <uptime>: SYSCALL(uptime) 3f4d: b8 0e 00 00 00 mov $0xe,%eax 3f52: cd 40 int $0x40 3f54: c3 ret 00003f55 <history>: SYSCALL(history) 3f55: b8 16 00 00 00 mov $0x16,%eax 3f5a: cd 40 int $0x40 3f5c: c3 ret 00003f5d <wait2>: SYSCALL(wait2) 3f5d: b8 17 00 00 00 mov $0x17,%eax 3f62: cd 40 int $0x40 3f64: c3 ret 00003f65 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 3f65: 55 push %ebp 3f66: 89 e5 mov %esp,%ebp 3f68: 83 ec 18 sub $0x18,%esp 3f6b: 8b 45 0c mov 0xc(%ebp),%eax 3f6e: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 3f71: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 3f78: 00 3f79: 8d 45 f4 lea -0xc(%ebp),%eax 3f7c: 89 44 24 04 mov %eax,0x4(%esp) 3f80: 8b 45 08 mov 0x8(%ebp),%eax 3f83: 89 04 24 mov %eax,(%esp) 3f86: e8 4a ff ff ff call 3ed5 <write> } 3f8b: c9 leave 3f8c: c3 ret 00003f8d <printint>: static void printint(int fd, int xx, int base, int sgn) { 3f8d: 55 push %ebp 3f8e: 89 e5 mov %esp,%ebp 3f90: 56 push %esi 3f91: 53 push %ebx 3f92: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 3f95: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 3f9c: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 3fa0: 74 17 je 3fb9 <printint+0x2c> 3fa2: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 3fa6: 79 11 jns 3fb9 <printint+0x2c> neg = 1; 3fa8: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 3faf: 8b 45 0c mov 0xc(%ebp),%eax 3fb2: f7 d8 neg %eax 3fb4: 89 45 ec mov %eax,-0x14(%ebp) 3fb7: eb 06 jmp 3fbf <printint+0x32> } else { x = xx; 3fb9: 8b 45 0c mov 0xc(%ebp),%eax 3fbc: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 3fbf: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 3fc6: 8b 4d f4 mov -0xc(%ebp),%ecx 3fc9: 8d 41 01 lea 0x1(%ecx),%eax 3fcc: 89 45 f4 mov %eax,-0xc(%ebp) 3fcf: 8b 5d 10 mov 0x10(%ebp),%ebx 3fd2: 8b 45 ec mov -0x14(%ebp),%eax 3fd5: ba 00 00 00 00 mov $0x0,%edx 3fda: f7 f3 div %ebx 3fdc: 89 d0 mov %edx,%eax 3fde: 0f b6 80 dc 62 00 00 movzbl 0x62dc(%eax),%eax 3fe5: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 3fe9: 8b 75 10 mov 0x10(%ebp),%esi 3fec: 8b 45 ec mov -0x14(%ebp),%eax 3fef: ba 00 00 00 00 mov $0x0,%edx 3ff4: f7 f6 div %esi 3ff6: 89 45 ec mov %eax,-0x14(%ebp) 3ff9: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 3ffd: 75 c7 jne 3fc6 <printint+0x39> if(neg) 3fff: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 4003: 74 10 je 4015 <printint+0x88> buf[i++] = '-'; 4005: 8b 45 f4 mov -0xc(%ebp),%eax 4008: 8d 50 01 lea 0x1(%eax),%edx 400b: 89 55 f4 mov %edx,-0xc(%ebp) 400e: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 4013: eb 1f jmp 4034 <printint+0xa7> 4015: eb 1d jmp 4034 <printint+0xa7> putc(fd, buf[i]); 4017: 8d 55 dc lea -0x24(%ebp),%edx 401a: 8b 45 f4 mov -0xc(%ebp),%eax 401d: 01 d0 add %edx,%eax 401f: 0f b6 00 movzbl (%eax),%eax 4022: 0f be c0 movsbl %al,%eax 4025: 89 44 24 04 mov %eax,0x4(%esp) 4029: 8b 45 08 mov 0x8(%ebp),%eax 402c: 89 04 24 mov %eax,(%esp) 402f: e8 31 ff ff ff call 3f65 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 4034: 83 6d f4 01 subl $0x1,-0xc(%ebp) 4038: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 403c: 79 d9 jns 4017 <printint+0x8a> putc(fd, buf[i]); } 403e: 83 c4 30 add $0x30,%esp 4041: 5b pop %ebx 4042: 5e pop %esi 4043: 5d pop %ebp 4044: c3 ret 00004045 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 4045: 55 push %ebp 4046: 89 e5 mov %esp,%ebp 4048: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 404b: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 4052: 8d 45 0c lea 0xc(%ebp),%eax 4055: 83 c0 04 add $0x4,%eax 4058: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 405b: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 4062: e9 7c 01 00 00 jmp 41e3 <printf+0x19e> c = fmt[i] & 0xff; 4067: 8b 55 0c mov 0xc(%ebp),%edx 406a: 8b 45 f0 mov -0x10(%ebp),%eax 406d: 01 d0 add %edx,%eax 406f: 0f b6 00 movzbl (%eax),%eax 4072: 0f be c0 movsbl %al,%eax 4075: 25 ff 00 00 00 and $0xff,%eax 407a: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 407d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 4081: 75 2c jne 40af <printf+0x6a> if(c == '%'){ 4083: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 4087: 75 0c jne 4095 <printf+0x50> state = '%'; 4089: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 4090: e9 4a 01 00 00 jmp 41df <printf+0x19a> } else { putc(fd, c); 4095: 8b 45 e4 mov -0x1c(%ebp),%eax 4098: 0f be c0 movsbl %al,%eax 409b: 89 44 24 04 mov %eax,0x4(%esp) 409f: 8b 45 08 mov 0x8(%ebp),%eax 40a2: 89 04 24 mov %eax,(%esp) 40a5: e8 bb fe ff ff call 3f65 <putc> 40aa: e9 30 01 00 00 jmp 41df <printf+0x19a> } } else if(state == '%'){ 40af: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 40b3: 0f 85 26 01 00 00 jne 41df <printf+0x19a> if(c == 'd'){ 40b9: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 40bd: 75 2d jne 40ec <printf+0xa7> printint(fd, *ap, 10, 1); 40bf: 8b 45 e8 mov -0x18(%ebp),%eax 40c2: 8b 00 mov (%eax),%eax 40c4: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 40cb: 00 40cc: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 40d3: 00 40d4: 89 44 24 04 mov %eax,0x4(%esp) 40d8: 8b 45 08 mov 0x8(%ebp),%eax 40db: 89 04 24 mov %eax,(%esp) 40de: e8 aa fe ff ff call 3f8d <printint> ap++; 40e3: 83 45 e8 04 addl $0x4,-0x18(%ebp) 40e7: e9 ec 00 00 00 jmp 41d8 <printf+0x193> } else if(c == 'x' || c == 'p'){ 40ec: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 40f0: 74 06 je 40f8 <printf+0xb3> 40f2: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 40f6: 75 2d jne 4125 <printf+0xe0> printint(fd, *ap, 16, 0); 40f8: 8b 45 e8 mov -0x18(%ebp),%eax 40fb: 8b 00 mov (%eax),%eax 40fd: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 4104: 00 4105: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 410c: 00 410d: 89 44 24 04 mov %eax,0x4(%esp) 4111: 8b 45 08 mov 0x8(%ebp),%eax 4114: 89 04 24 mov %eax,(%esp) 4117: e8 71 fe ff ff call 3f8d <printint> ap++; 411c: 83 45 e8 04 addl $0x4,-0x18(%ebp) 4120: e9 b3 00 00 00 jmp 41d8 <printf+0x193> } else if(c == 's'){ 4125: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 4129: 75 45 jne 4170 <printf+0x12b> s = (char*)*ap; 412b: 8b 45 e8 mov -0x18(%ebp),%eax 412e: 8b 00 mov (%eax),%eax 4130: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 4133: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 4137: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 413b: 75 09 jne 4146 <printf+0x101> s = "(null)"; 413d: c7 45 f4 de 5b 00 00 movl $0x5bde,-0xc(%ebp) while(*s != 0){ 4144: eb 1e jmp 4164 <printf+0x11f> 4146: eb 1c jmp 4164 <printf+0x11f> putc(fd, *s); 4148: 8b 45 f4 mov -0xc(%ebp),%eax 414b: 0f b6 00 movzbl (%eax),%eax 414e: 0f be c0 movsbl %al,%eax 4151: 89 44 24 04 mov %eax,0x4(%esp) 4155: 8b 45 08 mov 0x8(%ebp),%eax 4158: 89 04 24 mov %eax,(%esp) 415b: e8 05 fe ff ff call 3f65 <putc> s++; 4160: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 4164: 8b 45 f4 mov -0xc(%ebp),%eax 4167: 0f b6 00 movzbl (%eax),%eax 416a: 84 c0 test %al,%al 416c: 75 da jne 4148 <printf+0x103> 416e: eb 68 jmp 41d8 <printf+0x193> putc(fd, *s); s++; } } else if(c == 'c'){ 4170: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 4174: 75 1d jne 4193 <printf+0x14e> putc(fd, *ap); 4176: 8b 45 e8 mov -0x18(%ebp),%eax 4179: 8b 00 mov (%eax),%eax 417b: 0f be c0 movsbl %al,%eax 417e: 89 44 24 04 mov %eax,0x4(%esp) 4182: 8b 45 08 mov 0x8(%ebp),%eax 4185: 89 04 24 mov %eax,(%esp) 4188: e8 d8 fd ff ff call 3f65 <putc> ap++; 418d: 83 45 e8 04 addl $0x4,-0x18(%ebp) 4191: eb 45 jmp 41d8 <printf+0x193> } else if(c == '%'){ 4193: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 4197: 75 17 jne 41b0 <printf+0x16b> putc(fd, c); 4199: 8b 45 e4 mov -0x1c(%ebp),%eax 419c: 0f be c0 movsbl %al,%eax 419f: 89 44 24 04 mov %eax,0x4(%esp) 41a3: 8b 45 08 mov 0x8(%ebp),%eax 41a6: 89 04 24 mov %eax,(%esp) 41a9: e8 b7 fd ff ff call 3f65 <putc> 41ae: eb 28 jmp 41d8 <printf+0x193> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 41b0: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 41b7: 00 41b8: 8b 45 08 mov 0x8(%ebp),%eax 41bb: 89 04 24 mov %eax,(%esp) 41be: e8 a2 fd ff ff call 3f65 <putc> putc(fd, c); 41c3: 8b 45 e4 mov -0x1c(%ebp),%eax 41c6: 0f be c0 movsbl %al,%eax 41c9: 89 44 24 04 mov %eax,0x4(%esp) 41cd: 8b 45 08 mov 0x8(%ebp),%eax 41d0: 89 04 24 mov %eax,(%esp) 41d3: e8 8d fd ff ff call 3f65 <putc> } state = 0; 41d8: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 41df: 83 45 f0 01 addl $0x1,-0x10(%ebp) 41e3: 8b 55 0c mov 0xc(%ebp),%edx 41e6: 8b 45 f0 mov -0x10(%ebp),%eax 41e9: 01 d0 add %edx,%eax 41eb: 0f b6 00 movzbl (%eax),%eax 41ee: 84 c0 test %al,%al 41f0: 0f 85 71 fe ff ff jne 4067 <printf+0x22> putc(fd, c); } state = 0; } } } 41f6: c9 leave 41f7: c3 ret 000041f8 <free>: static Header base; static Header *freep; void free(void *ap) { 41f8: 55 push %ebp 41f9: 89 e5 mov %esp,%ebp 41fb: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 41fe: 8b 45 08 mov 0x8(%ebp),%eax 4201: 83 e8 08 sub $0x8,%eax 4204: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 4207: a1 88 63 00 00 mov 0x6388,%eax 420c: 89 45 fc mov %eax,-0x4(%ebp) 420f: eb 24 jmp 4235 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 4211: 8b 45 fc mov -0x4(%ebp),%eax 4214: 8b 00 mov (%eax),%eax 4216: 3b 45 fc cmp -0x4(%ebp),%eax 4219: 77 12 ja 422d <free+0x35> 421b: 8b 45 f8 mov -0x8(%ebp),%eax 421e: 3b 45 fc cmp -0x4(%ebp),%eax 4221: 77 24 ja 4247 <free+0x4f> 4223: 8b 45 fc mov -0x4(%ebp),%eax 4226: 8b 00 mov (%eax),%eax 4228: 3b 45 f8 cmp -0x8(%ebp),%eax 422b: 77 1a ja 4247 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 422d: 8b 45 fc mov -0x4(%ebp),%eax 4230: 8b 00 mov (%eax),%eax 4232: 89 45 fc mov %eax,-0x4(%ebp) 4235: 8b 45 f8 mov -0x8(%ebp),%eax 4238: 3b 45 fc cmp -0x4(%ebp),%eax 423b: 76 d4 jbe 4211 <free+0x19> 423d: 8b 45 fc mov -0x4(%ebp),%eax 4240: 8b 00 mov (%eax),%eax 4242: 3b 45 f8 cmp -0x8(%ebp),%eax 4245: 76 ca jbe 4211 <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 4247: 8b 45 f8 mov -0x8(%ebp),%eax 424a: 8b 40 04 mov 0x4(%eax),%eax 424d: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 4254: 8b 45 f8 mov -0x8(%ebp),%eax 4257: 01 c2 add %eax,%edx 4259: 8b 45 fc mov -0x4(%ebp),%eax 425c: 8b 00 mov (%eax),%eax 425e: 39 c2 cmp %eax,%edx 4260: 75 24 jne 4286 <free+0x8e> bp->s.size += p->s.ptr->s.size; 4262: 8b 45 f8 mov -0x8(%ebp),%eax 4265: 8b 50 04 mov 0x4(%eax),%edx 4268: 8b 45 fc mov -0x4(%ebp),%eax 426b: 8b 00 mov (%eax),%eax 426d: 8b 40 04 mov 0x4(%eax),%eax 4270: 01 c2 add %eax,%edx 4272: 8b 45 f8 mov -0x8(%ebp),%eax 4275: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 4278: 8b 45 fc mov -0x4(%ebp),%eax 427b: 8b 00 mov (%eax),%eax 427d: 8b 10 mov (%eax),%edx 427f: 8b 45 f8 mov -0x8(%ebp),%eax 4282: 89 10 mov %edx,(%eax) 4284: eb 0a jmp 4290 <free+0x98> } else bp->s.ptr = p->s.ptr; 4286: 8b 45 fc mov -0x4(%ebp),%eax 4289: 8b 10 mov (%eax),%edx 428b: 8b 45 f8 mov -0x8(%ebp),%eax 428e: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 4290: 8b 45 fc mov -0x4(%ebp),%eax 4293: 8b 40 04 mov 0x4(%eax),%eax 4296: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 429d: 8b 45 fc mov -0x4(%ebp),%eax 42a0: 01 d0 add %edx,%eax 42a2: 3b 45 f8 cmp -0x8(%ebp),%eax 42a5: 75 20 jne 42c7 <free+0xcf> p->s.size += bp->s.size; 42a7: 8b 45 fc mov -0x4(%ebp),%eax 42aa: 8b 50 04 mov 0x4(%eax),%edx 42ad: 8b 45 f8 mov -0x8(%ebp),%eax 42b0: 8b 40 04 mov 0x4(%eax),%eax 42b3: 01 c2 add %eax,%edx 42b5: 8b 45 fc mov -0x4(%ebp),%eax 42b8: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 42bb: 8b 45 f8 mov -0x8(%ebp),%eax 42be: 8b 10 mov (%eax),%edx 42c0: 8b 45 fc mov -0x4(%ebp),%eax 42c3: 89 10 mov %edx,(%eax) 42c5: eb 08 jmp 42cf <free+0xd7> } else p->s.ptr = bp; 42c7: 8b 45 fc mov -0x4(%ebp),%eax 42ca: 8b 55 f8 mov -0x8(%ebp),%edx 42cd: 89 10 mov %edx,(%eax) freep = p; 42cf: 8b 45 fc mov -0x4(%ebp),%eax 42d2: a3 88 63 00 00 mov %eax,0x6388 } 42d7: c9 leave 42d8: c3 ret 000042d9 <morecore>: static Header* morecore(uint nu) { 42d9: 55 push %ebp 42da: 89 e5 mov %esp,%ebp 42dc: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 42df: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 42e6: 77 07 ja 42ef <morecore+0x16> nu = 4096; 42e8: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 42ef: 8b 45 08 mov 0x8(%ebp),%eax 42f2: c1 e0 03 shl $0x3,%eax 42f5: 89 04 24 mov %eax,(%esp) 42f8: e8 40 fc ff ff call 3f3d <sbrk> 42fd: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 4300: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 4304: 75 07 jne 430d <morecore+0x34> return 0; 4306: b8 00 00 00 00 mov $0x0,%eax 430b: eb 22 jmp 432f <morecore+0x56> hp = (Header*)p; 430d: 8b 45 f4 mov -0xc(%ebp),%eax 4310: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 4313: 8b 45 f0 mov -0x10(%ebp),%eax 4316: 8b 55 08 mov 0x8(%ebp),%edx 4319: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 431c: 8b 45 f0 mov -0x10(%ebp),%eax 431f: 83 c0 08 add $0x8,%eax 4322: 89 04 24 mov %eax,(%esp) 4325: e8 ce fe ff ff call 41f8 <free> return freep; 432a: a1 88 63 00 00 mov 0x6388,%eax } 432f: c9 leave 4330: c3 ret 00004331 <malloc>: void* malloc(uint nbytes) { 4331: 55 push %ebp 4332: 89 e5 mov %esp,%ebp 4334: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 4337: 8b 45 08 mov 0x8(%ebp),%eax 433a: 83 c0 07 add $0x7,%eax 433d: c1 e8 03 shr $0x3,%eax 4340: 83 c0 01 add $0x1,%eax 4343: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 4346: a1 88 63 00 00 mov 0x6388,%eax 434b: 89 45 f0 mov %eax,-0x10(%ebp) 434e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 4352: 75 23 jne 4377 <malloc+0x46> base.s.ptr = freep = prevp = &base; 4354: c7 45 f0 80 63 00 00 movl $0x6380,-0x10(%ebp) 435b: 8b 45 f0 mov -0x10(%ebp),%eax 435e: a3 88 63 00 00 mov %eax,0x6388 4363: a1 88 63 00 00 mov 0x6388,%eax 4368: a3 80 63 00 00 mov %eax,0x6380 base.s.size = 0; 436d: c7 05 84 63 00 00 00 movl $0x0,0x6384 4374: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 4377: 8b 45 f0 mov -0x10(%ebp),%eax 437a: 8b 00 mov (%eax),%eax 437c: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 437f: 8b 45 f4 mov -0xc(%ebp),%eax 4382: 8b 40 04 mov 0x4(%eax),%eax 4385: 3b 45 ec cmp -0x14(%ebp),%eax 4388: 72 4d jb 43d7 <malloc+0xa6> if(p->s.size == nunits) 438a: 8b 45 f4 mov -0xc(%ebp),%eax 438d: 8b 40 04 mov 0x4(%eax),%eax 4390: 3b 45 ec cmp -0x14(%ebp),%eax 4393: 75 0c jne 43a1 <malloc+0x70> prevp->s.ptr = p->s.ptr; 4395: 8b 45 f4 mov -0xc(%ebp),%eax 4398: 8b 10 mov (%eax),%edx 439a: 8b 45 f0 mov -0x10(%ebp),%eax 439d: 89 10 mov %edx,(%eax) 439f: eb 26 jmp 43c7 <malloc+0x96> else { p->s.size -= nunits; 43a1: 8b 45 f4 mov -0xc(%ebp),%eax 43a4: 8b 40 04 mov 0x4(%eax),%eax 43a7: 2b 45 ec sub -0x14(%ebp),%eax 43aa: 89 c2 mov %eax,%edx 43ac: 8b 45 f4 mov -0xc(%ebp),%eax 43af: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 43b2: 8b 45 f4 mov -0xc(%ebp),%eax 43b5: 8b 40 04 mov 0x4(%eax),%eax 43b8: c1 e0 03 shl $0x3,%eax 43bb: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 43be: 8b 45 f4 mov -0xc(%ebp),%eax 43c1: 8b 55 ec mov -0x14(%ebp),%edx 43c4: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 43c7: 8b 45 f0 mov -0x10(%ebp),%eax 43ca: a3 88 63 00 00 mov %eax,0x6388 return (void*)(p + 1); 43cf: 8b 45 f4 mov -0xc(%ebp),%eax 43d2: 83 c0 08 add $0x8,%eax 43d5: eb 38 jmp 440f <malloc+0xde> } if(p == freep) 43d7: a1 88 63 00 00 mov 0x6388,%eax 43dc: 39 45 f4 cmp %eax,-0xc(%ebp) 43df: 75 1b jne 43fc <malloc+0xcb> if((p = morecore(nunits)) == 0) 43e1: 8b 45 ec mov -0x14(%ebp),%eax 43e4: 89 04 24 mov %eax,(%esp) 43e7: e8 ed fe ff ff call 42d9 <morecore> 43ec: 89 45 f4 mov %eax,-0xc(%ebp) 43ef: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 43f3: 75 07 jne 43fc <malloc+0xcb> return 0; 43f5: b8 00 00 00 00 mov $0x0,%eax 43fa: eb 13 jmp 440f <malloc+0xde> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 43fc: 8b 45 f4 mov -0xc(%ebp),%eax 43ff: 89 45 f0 mov %eax,-0x10(%ebp) 4402: 8b 45 f4 mov -0xc(%ebp),%eax 4405: 8b 00 mov (%eax),%eax 4407: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 440a: e9 70 ff ff ff jmp 437f <malloc+0x4e> } 440f: c9 leave 4410: c3 ret
/* * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) * * This file is part of Orfeo Toolbox * * https://www.orfeo-toolbox.org/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <complex> #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbExtractROI.h" #include "otbMacro.h" int otbWritingComplexDataWithComplexImageTest(int itkNotUsed(argc), char * argv[]) { typedef double RealType; typedef std::complex<RealType> PixelType; typedef otb::Image<PixelType, 2> ImageType; typedef otb::ImageFileReader<ImageType> ReaderType; typedef otb::ImageFileWriter<ImageType> WriterType; typedef otb::ExtractROI<PixelType, PixelType> ExtractROIFilterType; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(argv[1]); ExtractROIFilterType::Pointer extract = ExtractROIFilterType::New(); extract->SetInput(reader->GetOutput()); extract->SetStartX(atoi(argv[3])); extract->SetStartY(atoi(argv[4])); extract->SetSizeX(atoi(argv[5])); extract->SetSizeY(atoi(argv[6])); WriterType::Pointer writer = WriterType::New(); writer->SetInput(extract->GetOutput()); writer->SetFileName(argv[2]); writer->Update(); return EXIT_SUCCESS; }
[section .text] [bits 32] ;lock ้”ๅฎš็š„ๆ˜ฏๅ†…ๅญ˜ๅœฐๅ€๏ผŒๆ‰€ไปฅๆ“ไฝœๅฏน่ฑกๅ€ผๅฟ…้กปๆ—ถๅ†…ๅญ˜ๆ‰่กŒ ; void __atomic_add(int *a, int b); global __atomic_add __atomic_add: mov eax, [esp + 4] ; a mov ebx, [esp + 8] ; b ; ้€š่ฟ‡lockๅ‰็ผ€๏ผŒ่ฎฉ่ฟ็ฎ—ๆ—ถๅŽŸๅญ่ฟ็ฎ— lock add [eax], ebx ; *a += b ret ; void __atomic_sub(int *a, int b); global __atomic_sub __atomic_sub: mov eax, [esp + 4] ; a mov ebx, [esp + 8] ; b ; ้€š่ฟ‡lockๅ‰็ผ€๏ผŒ่ฎฉ่ฟ็ฎ—ๆ—ถๅŽŸๅญ่ฟ็ฎ— lock sub [eax], ebx ; *a -= b ret ; void __atomic_inc(int *a); global __atomic_inc __atomic_inc: mov eax, [esp + 4] ; a ; ้€š่ฟ‡lockๅ‰็ผ€๏ผŒ่ฎฉ่ฟ็ฎ—ๆ—ถๅŽŸๅญ่ฟ็ฎ— lock inc dword [eax] ; ++*a ret ; void __atomic_dec(int *a); global __atomic_dec __atomic_dec: mov eax, [esp + 4] ; a ; ้€š่ฟ‡lockๅ‰็ผ€๏ผŒ่ฎฉ่ฟ็ฎ—ๆ—ถๅŽŸๅญ่ฟ็ฎ— lock dec dword [eax] ; --*a ret ; void __atomic_or(int *a, int b); global __atomic_or __atomic_or: mov eax, [esp + 4] ; a mov ebx, [esp + 8] ; b ; ้€š่ฟ‡lockๅ‰็ผ€๏ผŒ่ฎฉ่ฟ็ฎ—ๆ—ถๅŽŸๅญ่ฟ็ฎ— lock or [eax], ebx ; *a |= b ret ; void __atomic_and(int *a, int b); global __atomic_and __atomic_and: mov eax, [esp + 4] ; a mov ebx, [esp + 8] ; b ; ้€š่ฟ‡lockๅ‰็ผ€๏ผŒ่ฎฉ่ฟ็ฎ—ๆ—ถๅŽŸๅญ่ฟ็ฎ— lock and [eax], ebx ; *a &= b ret
; --------------------------------------------- ; Hello World for Win64 Intel x64 Assembly ; ; by fruel (https://github.com/fruel) ; 13 June 2016 ; --------------------------------------------- GetStdHandle PROTO ExitProcess PROTO WriteConsoleA PROTO .data msg BYTE "Hello World!",0 bytesWritten DWORD ? .code main PROC sub rsp, 5 * 8 ; reserve shadow space mov rcx, -11 ; nStdHandle (STD_OUTPUT_HANDLE) call GetStdHandle mov rcx, rax ; hConsoleOutput lea rdx, msg ; *lpBuffer mov r8, LENGTHOF msg - 1 ; nNumberOfCharsToWrite lea r9, bytesWritten ; lpNumberOfCharsWritten mov QWORD PTR [rsp + 4 * SIZEOF QWORD], 0 ; lpReserved call WriteConsoleA mov rcx, 0 ; uExitCode call ExitProcess main ENDP END
; A167548: The fifth row of the ED1 array A167546 ; 24,240,960,2688,6144,12264,22200,37320,59208,89664,130704,184560,253680,340728,448584,580344,739320,929040,1153248,1415904,1721184,2073480,2477400,2937768,3459624,4048224,4709040,5447760,6270288,7182744,8191464,9303000,10524120,11861808,13323264,14915904,16647360,18525480,20558328,22754184,25121544,27669120,30405840,33340848,36483504,39843384,43430280,47254200,51325368,55654224,60251424,65127840,70294560,75762888,81544344,87650664,94093800,100885920,108039408,115566864,123481104,131795160,140522280,149675928,159269784,169317744,179833920,190832640,202328448,214336104,226870584,239947080,253581000,267787968,282583824,297984624,314006640,330666360,347980488,365965944,384639864,404019600,424122720,444967008,466570464,488951304,512127960,536119080,560943528,586620384,613168944,640608720,668959440,698241048,728473704,759677784,791873880,825082800,859325568,894623424,930997824,968470440,1007063160,1046798088,1087697544,1129784064,1173080400,1217609520,1263394608,1310459064,1358826504,1408520760,1459565880,1511986128,1565805984,1621050144,1677743520,1735911240,1795578648,1856771304,1919514984,1983835680,2049759600,2117313168,2186523024,2257416024,2330019240,2404359960,2480465688,2558364144,2638083264,2719651200,2803096320,2888447208,2975732664,3064981704,3156223560,3249487680,3344803728,3442201584,3541711344,3643363320,3747188040,3853216248,3961478904,4072007184,4184832480,4299986400,4417500768,4537407624,4659739224,4784528040,4911806760,5041608288,5173965744,5308912464,5446482000,5586708120,5729624808,5875266264,6023666904,6174861360,6328884480,6485771328,6645557184,6808277544,6973968120,7142664840,7314403848,7489221504,7667154384,7848239280,8032513200,8220013368,8410777224,8604842424,8802246840,9003028560,9207225888,9414877344,9626021664,9840697800,10058944920,10280802408,10506309864,10735507104,10968434160,11205131280,11445638928,11689997784,11938248744,12190432920,12446591640,12706766448,12970999104,13239331584,13511806080,13788465000,14069350968,14354506824,14643975624,14937800640,15236025360,15538693488,15845848944,16157535864,16473798600,16794681720,17120230008,17450488464,17785502304,18125316960,18469978080,18819531528,19174023384,19533499944,19898007720,20267593440,20642304048,21022186704,21407288784,21797657880,22193341800,22594388568,23000846424,23412763824,23830189440,24253172160,24681761088,25116005544,25555955064,26001659400,26453168520,26910532608,27373802064,27843027504,28318259760,28799549880,29286949128,29780508984,30280281144,30786317520,31298670240,31817391648,32342534304,32874150984,33412294680,33957018600,34508376168,35066421024 mov $1,$0 mov $3,$0 lpb $0 add $1,$0 sub $0,1 lpe mul $1,2 add $1,24 mov $2,75 mov $4,$3 lpb $2 add $1,$4 sub $2,1 lpe mov $6,$3 lpb $6 add $5,$4 sub $6,1 lpe mov $2,98 mov $4,$5 lpb $2 add $1,$4 sub $2,1 lpe mov $5,0 mov $6,$3 lpb $6 add $5,$4 sub $6,1 lpe mov $2,30 mov $4,$5 lpb $2 add $1,$4 sub $2,1 lpe mov $5,0 mov $6,$3 lpb $6 add $5,$4 sub $6,1 lpe mov $2,9 mov $4,$5 lpb $2 add $1,$4 sub $2,1 lpe
#include "BaseUI2DLayer.h" #include "Timer.h" #include "ModuleInput.h" #include "MouseDevice.h" #include "LayerMouseInfo.h" #include "MultiTouchDevice.h" #include "MultiTouchPinch.h" #include "MouseVelocityComputer.h" #include "NotificationCenter.h" #include "RenderingScreen.h" #include "ModuleRenderer.h" #include "Module2DLayers.h" #include "UI/UIItem.h" #include "TouchInputEventManager.h" #include <algorithm> IMPLEMENT_CLASS_INFO(BaseUI2DLayer); #include "Platform/2DLayers/BaseUI2DLayer.inl.h" /////////////////////////////////////////// // // BaseUI2DLayer // /////////////////////////////////////////// IMPLEMENT_CONSTRUCTOR(BaseUI2DLayer) , mInput(0) , mRootItem(0) { } void BaseUI2DLayer::InitModifiable() { Abstract2DLayer::InitModifiable(); if (IsInit()) { kstl::vector<CMSP> instances; GetSonInstancesByType("UIItem", instances); KIGS_ASSERT(instances.size() < 2); // only one UIItem child if (instances.empty()) { // add the root UIItem mRootItem = KigsCore::GetInstanceOf(getName(), "UIItem"); // set the root size to the screen size kfloat X, Y; GetRenderingScreen()->GetDesignSize(X, Y); mRootItem->setValue("Size", v2f(X,Y)); addItem(mRootItem); mRootItem->Init(); } else { mRootItem = instances[0]; } instances.clear(); instances = GetInstances("ModuleInput"); // KIGS_ASSERT(instances.size() == 1); if(instances.size()==1) mInput = (ModuleInput*)(instances[0].get()); ModuleSpecificRenderer* renderer = (ModuleSpecificRenderer*)((ModuleRenderer*)KigsCore::Instance()->GetMainModuleInList(RendererModuleCoreIndex))->GetSpecificRenderer(); if (renderer->getDefaultUiShader()) { addItem(renderer->getDefaultUiShader()); } } else { UninitModifiable(); } } void BaseUI2DLayer::Update(const Timer& a_Timer, void* addParam) { if (!IsInit()) { Init(); } if ((!IsRenderable()) || (!IsInit())) { return; } // if not interactive, don't do update (but still draw) if (!mIsInteractive) { return; } UpdateChildrens(a_Timer, mRootItem.get(), addParam); } void BaseUI2DLayer::UpdateChildrens(const Timer& a_timer, UIItem* current, void* addParam) { current->CallUpdate(a_timer, addParam); // recursif Call const kstl::set<Node2D*, Node2D::PriorityCompare>& sons = current->GetSons(); kstl::set<Node2D*, Node2D::PriorityCompare>::const_reverse_iterator it = sons.rbegin(); kstl::set<Node2D*, Node2D::PriorityCompare>::const_reverse_iterator end = sons.rend(); for (; it != end; ++it) { UpdateChildrens(a_timer, (UIItem*)(*it), addParam); } } /////////////////////////////////////////// bool NodeToDraw::Sorter::operator()(NodeToDraw& a, NodeToDraw& b) const { auto orderA = std::make_tuple(a.prio, a.depth, a.parent, a.node); auto orderB = std::make_tuple(b.prio, b.depth, b.parent, b.node); return orderA < orderB; } void BaseUI2DLayer::SortItemsFrontToBack(SortItemsFrontToBackParam& param) { kstl::vector<NodeToDraw> nodes; nodes.reserve(param.toSort.size()); for (auto cm : param.toSort) { Node2D* node = aggregate_cast<Node2D>(cm); if (node) { int depth = 0; auto father = node->getFather(); while (father) { ++depth; father = father->getFather(); } nodes.push_back(NodeToDraw{ node, node->GetFinalPriority(), node->getFather(), depth, 0, cm }); } else { nodes.push_back(NodeToDraw{ 0, 0, cm, 0, 0, cm }); } } std::sort(nodes.begin(), nodes.end(), NodeToDraw::Sorter{}); param.sorted.resize(param.toSort.size()); for (u32 i = 0; i < nodes.size(); ++i) { param.sorted[i] = std::make_tuple(nodes[nodes.size() - 1 - i].root, Hit{}); } } void BaseUI2DLayer::AccumulateToDraw(TravState* state, kstl::vector<NodeToDraw>& todraw, CoreModifiable* current, int depth, u32 clip_count) { if (current->isSubType(Node2D::mClassID)) { if (static_cast<Node2D*>(current)->GetNodeFlag(Node2D::Node2D_ClipSons)) { ++clip_count; } } for (auto& item_struct : current->getItems()) { bool continue_down = true; auto item = item_struct.mItem; if (item->isSubType(Node2D::mClassID)) { auto node = static_cast<Node2D*>(item.get()); if (node->Draw(state)) { node->SetUpNodeIfNeeded(); todraw.push_back(NodeToDraw{ node, node->GetFinalPriority(), current, depth, clip_count }); } else { continue_down = false; } } if(continue_down) AccumulateToDraw(state, todraw, item.get(), depth+1, clip_count); } } //! Do drawing here if any void BaseUI2DLayer::TravDraw(TravState* state) { if ((!IsInit())) { return; } // first thing to do (activate rendering screen) if (!StartDrawing(state)) return; auto holo_before = state->GetHolographicMode(); state->SetHolographicMode(GetRenderingScreen()->IsHolographic()); state->mHolographicUseStackMatrix = true; // call predraw (activate the shader)! PreDrawDrawable(state); ModuleSpecificRenderer* renderer = (ModuleSpecificRenderer*)state->GetRenderer(); int lShaderMask = ModuleRenderer::VERTEX_ARRAY_MASK | ModuleRenderer::TEXCOORD_ARRAY_MASK | ModuleRenderer::NO_LIGHT_MASK; // create shader if none renderer->GetActiveShader()->ChooseShader(state, lShaderMask); renderer->ActiveTextureChannel(0); renderer->PushState(); renderer->SetCullMode(RENDERER_CULL_NONE); renderer->SetLightMode(RENDERER_LIGHT_OFF); state->mCurrentMaterial = 0; state->SetAllVisible(false); renderer->SetDepthMaskMode(RENDERER_DEPTH_MASK_OFF); renderer->SetAlphaTestMode(RENDERER_ALPHA_TEST_ON); renderer->SetAlphaMode(RENDERER_ALPHA_GREATER, 0.01f); renderer->SetBlendMode(RENDERER_BLEND_ON); renderer->SetBlendFuncMode(RENDERER_BLEND_SRC_ALPHA, RENDERER_BLEND_ONE_MINUS_SRC_ALPHA); renderer->SetDepthTestMode(false); // get rendering screen size kfloat rendersx, rendersy; GetRenderingScreen()->GetSize(rendersx, rendersy); kfloat drendersx, drendersy; GetRenderingScreen()->GetDesignSize(drendersx, drendersy); // do drawing here if (Module2DLayers::getRotate180()) { renderer->Ortho(MATRIX_MODE_PROJECTION,(float)drendersx, 0.0f, 0.0f, (float)drendersy, -1.0f, 1.0f); } else { renderer->Ortho(MATRIX_MODE_PROJECTION,0.0f, (float)drendersx, (float)drendersy, 0.0f, -1.0f, 1.0f); } renderer->Viewport(0, 0, (int)rendersx, (int)rendersy); renderer->SetScissorTestMode(RENDERER_SCISSOR_TEST_ON); renderer->SetScissorValue(0, 0, (int)rendersx, (int)rendersy); renderer->LoadIdentity(MATRIX_MODE_MODEL); renderer->LoadIdentity(MATRIX_MODE_VIEW); renderer->LoadIdentity(MATRIX_MODE_UV); //renderer->FlushMatrix(); //renderer->FlushState(); if (mClearColorBuffer) { renderer->SetClearColorValue(mClearColor[0], mClearColor[1], mClearColor[2], mClearColor[3]); renderer->ClearView(RENDERER_CLEAR_COLOR); } if (IsRenderable()) { kstl::vector<NodeToDraw> todraw; todraw.push_back(NodeToDraw{ mRootItem.get(), 0 }); if (mRootItem->Draw(state)) { mRootItem->SetUpNodeIfNeeded(); AccumulateToDraw(state, todraw, mRootItem.get()); } std::sort(todraw.begin(), todraw.end(), NodeToDraw::Sorter{}); renderer->SetStencilTest(true); kstl::vector<Node2D*> current_stencil_stack; kstl::vector<Node2D*> cache_stencil_stack; auto compare_stencil_stacks = [&]() { if (current_stencil_stack.size() != cache_stencil_stack.size()) return false; for (u32 i = 0; i < current_stencil_stack.size(); ++i) { if (current_stencil_stack[i] != cache_stencil_stack[i]) return false; } return true; }; ShaderBase* current_custom_shader = nullptr; for (auto item : todraw) { if (item.clip_count > 0) { current_stencil_stack.clear(); Node2D* father = item.node->getFather(); while (father && current_stencil_stack.size() < item.clip_count) { if (father->GetNodeFlag(Node2D::Node2D_ClipSons)) { current_stencil_stack.push_back(father); } father = father->getFather(); } if (compare_stencil_stacks()) { renderer->SetStencilMode(RendererCullMode::RENDERER_CULL_FRONT_AND_BACK, RENDERER_STENCIL_EQUAL, (int)cache_stencil_stack.size(), 0xFFFFFFFF); } else { renderer->SetColorMask(false, false, false, false); renderer->ClearView(RendererClearMode::RENDERER_CLEAR_STENCIL); renderer->SetStencilOp(RendererCullMode::RENDERER_CULL_FRONT_AND_BACK, RENDERER_STENCIL_OP_ZERO, RENDERER_STENCIL_OP_ZERO, RENDERER_STENCIL_OP_INCR); if (current_custom_shader) { current_custom_shader->DoPostDraw(state); //renderer->popShader(current_custom_shader, state); } int current_clip = 0; for (auto node : current_stencil_stack) { renderer->SetStencilMode(RendererCullMode::RENDERER_CULL_FRONT_AND_BACK, RENDERER_STENCIL_EQUAL, current_clip, 0xFFFFFFFF); float op = 0.0f; node->getValue("Opacity", op); node->setValue("Opacity", 1); node->ProtectedDraw(state); node->setValue("Opacity", op); ++current_clip; } renderer->SetColorMask(true, true, true, true); renderer->SetStencilMode(RendererCullMode::RENDERER_CULL_FRONT_AND_BACK, RENDERER_STENCIL_EQUAL, current_clip, 0xFFFFFFFF); std::swap(current_stencil_stack, cache_stencil_stack); if (current_custom_shader) { current_custom_shader->DoPreDraw(state); //renderer->pushShader(current_custom_shader, state); } } } else renderer->SetStencilMode(RendererCullMode::RENDERER_CULL_FRONT_AND_BACK, RENDERER_STENCIL_ALWAYS, 0, 0xFFFFFFFF); renderer->SetStencilOp(RendererCullMode::RENDERER_CULL_FRONT_AND_BACK, RENDERER_STENCIL_OP_KEEP, RENDERER_STENCIL_OP_KEEP, RENDERER_STENCIL_OP_KEEP); ShaderBase* shader = nullptr; if (item.node->GetNodeFlag(Node2D::Node2D_UseCustomShader)) { shader = item.node->getValue<CoreModifiable*>("CustomShader")->as<ShaderBase>(); } if (shader != current_custom_shader) { if (current_custom_shader) { current_custom_shader->DoPostDraw(state); //renderer->popShader(current_custom_shader, state); } if (shader) { shader->DoPreDraw(state); //renderer->pushShader(shader, state); } current_custom_shader = shader; } item.node->ProtectedDraw(state); } if (current_custom_shader) { current_custom_shader->DoPostDraw(state); //renderer->popShader(current_custom_shader, state); } renderer->SetStencilTest(false); } state->mHolographicUseStackMatrix = false; state->SetHolographicMode(holo_before); renderer->PopState(); // call postdraw (deactivate the shader) PostDrawDrawable(state); // last thing to do EndDrawing(state); //renderer->PopUIShader(); }
SFX_Cry17_3_Ch1: dutycycle 15 unknownsfx0x20 15, 247, 0, 5 unknownsfx0x20 15, 231, 8, 5 unknownsfx0x20 8, 180, 128, 4 unknownsfx0x20 15, 162, 96, 4 endchannel SFX_Cry17_3_Ch2: dutycycle 68 unknownsfx0x20 14, 215, 129, 4 unknownsfx0x20 14, 199, 137, 4 unknownsfx0x20 10, 180, 1, 4 unknownsfx0x20 15, 194, 225, 3 endchannel SFX_Cry17_3_Ch3: unknownnoise0x20 14, 247, 124 unknownnoise0x20 12, 246, 108 unknownnoise0x20 9, 228, 124 unknownnoise0x20 15, 226, 108 endchannel
; A081408: a(n) = (n+1)*a(n-5), with a(0)=a(1)=a(2)=a(3)=a(4)=1. ; 1,1,1,1,1,6,7,8,9,10,66,84,104,126,150,1056,1428,1872,2394,3000,22176,31416,43056,57456,75000,576576,848232,1205568,1666224,2250000,17873856,27143424,39783744,56651616,78750000,643458816,1004306688,1511782272,2209413024,3150000000,26381811456,42180880896,65006637696,97214173056,141750000000,1213563326976,1982501402112,3120318609408,4763494479744,7087500000000,61891729675776,103090072909824,165376886298624,257228701906176,389812500000000,3465936861843456,5876134155859968,9591859405320192 add $0,1 mov $1,1 lpb $0 mul $1,$0 trn $0,10 add $0,5 lpe mov $0,$1
<% from pwnlib.shellcraft.aarch64.linux import syscall %> <%page args="from_, tofd, to"/> <%docstring> Invokes the syscall symlinkat. See 'man 2 symlinkat' for more information. Arguments: from(char): from tofd(int): tofd to(char): to </%docstring> ${syscall('SYS_symlinkat', from_, tofd, to)}
; This program test assertions of read-only and write-only memory ; KLC3 is expected to detect and give warning about data r/w overflow ; 2020.07.11 by liuzikai ; KLC3: INPUT_FILE .ORIG x3000 ; CHECK: ================ REPORT ================ LD R1, READ_ONLY_MEM ; this is OK ; CHECK-NOT: LD R1, READ_ONLY_MEM LD R2, UNINITIALIZED_MEM ; this is BAD ; CHECK: WARN_READ_UNINITIALIZED_MEMORY ; CHECK-SAME: LD R2, UNINITIALIZED_MEM ST R1, UNINITIALIZED_MEM ; this is OK ; CHECK-NOT: ST R1, UNINITIALIZED_MEM ST R2, READ_ONLY_MEM ; this is BAD ; CHECK: WARN_WRITE_READ_ONLY_DATA ; CHECK-SAME: ST R2, READ_ONLY_MEM LD R3, READ_ONLY_SYM ; this is OK ; CHECK-NOT: LD R3, READ_ONLY_SYM LD R4, WRITE_ONLY_SYM ; this is BAD ; CHECK: WARN_READ_UNINITIALIZED_MEMORY ; CHECK-SAME: LD R4, WRITE_ONLY_SYM ST R3, WRITE_ONLY_SYM ; this is OK ; CHECK-NOT: ST R3, WRITE_ONLY_SYM ST R4, READ_ONLY_SYM ; this is BAD ; CHECK: WARN_WRITE_READ_ONLY_DATA ; CHECK-SAME: ST R4, READ_ONLY_SYM ; CHECK: ================ END OF REPORT ================ HALT READ_ONLY_MEM .FILL #42 ; KLC3: READ_ONLY UNINITIALIZED_MEM .BLKW #1 ; KLC3: UNINITIALIZED READ_ONLY_SYM .FILL #0 ; KLC3: SYMBOLIC as NUM1 READ_ONLY WRITE_ONLY_SYM .BLKW #1 ; KLC3: SYMBOLIC as NUM2 UNINITIALIZED .END ; RUN: %klc3 %s --use-forked-solver=false --output-dir=none --report-to-terminal=true 2>&1 | FileCheck %s
#ifndef _DDSINVENTORY_ #define _DDSINVENTORY_ #include "DDGlobal.hpp" DD_BEGIN template <typename T> class DDSInventory; template <typename T> class DDSInventory { public: DDSInventory(); DDSInventory(int new_length); DDSInventory(int new_length, const T& initial_value); ~DDSInventory(); int get_capacity() const; int get_length() const; bool is_full() const; bool is_empty() const; T& at(int index); DDSInventory<T>& expand(int extra_capacity); DDSInventory<T>& set_capacity(int new_capacity); DDSInventory<T>& lengthen(int extra_length); DDSInventory<T>& lengthen(int extra_length, const T& initial_value); DDSInventory<T>& set_length(int new_length); DDSInventory<T>& set_length(int new_length, const T& initial_value); DDSInventory<T>& append(const T& element); T& operator [](int index); const T& operator [](int index) const;//Unlike DDInventory, operator of DDSInventory does not check index. use member at for index check. protected: int& check_index(int& index) const; DDSInventory<T>& destruct(); int capacity = 0; int m_length = 0; T** m_content = nullptr; }; DD_END DD_BEGIN #define DDSINVENTORY_MEMBER(...) template <typename T> __VA_ARGS__ DDSInventory<T> DDSINVENTORY_MEMBER()::DDSInventory() : capacity(0), m_length(0), m_content(nullptr) { } DDSINVENTORY_MEMBER()::DDSInventory(int new_length) : capacity(2 * new_length), m_length(new_length), m_content(nullptr) { if (m_length < 0) throw DDError(DDErrorType::INVALID_ARGUMENT, "Invalid initial m_length of sinventory. "); DDALLOCATE(m_content = new T*[capacity], "Failed to allocate sinventory. ", capacity = 0; m_length = 0;) for (int i = 0; i < m_length; ++i) DDALLOCATE(m_content[i] = new T, "Failed to allocate element. ", lengthen(i - m_length);); } DDSINVENTORY_MEMBER()::DDSInventory(int new_length, const T& initial_value) : capacity(2 * new_length), m_length(new_length), m_content(nullptr) { if (m_length < 0) throw DDError(DDErrorType::INVALID_ARGUMENT, "Invalid initial m_length of sinventory. "); DDALLOCATE(m_content = new T*[capacity], "Failed to allocate sinventory. ", capacity = 0; m_length = 0;) for (int i = 0; i < m_length; ++i) DDALLOCATE(m_content[i] = new T(initial_value), "Failed to allocate element. ", lengthen(i - m_length);) } DDSINVENTORY_MEMBER()::~DDSInventory() { destruct(); } DDSINVENTORY_MEMBER(inline int)::get_capacity() const { return capacity; } DDSINVENTORY_MEMBER(inline int)::get_length() const { return m_length; } DDSINVENTORY_MEMBER(inline bool)::is_full() const { return capacity <= m_length; } DDSINVENTORY_MEMBER(inline bool)::is_empty() const { return m_length == 0; } DDSINVENTORY_MEMBER(T&)::at(int index) { return *m_content[check_index(index)]; } DDSINVENTORY_MEMBER(DDSInventory<T>&)::expand(int extra_capacity) { capacity += extra_capacity; if (capacity < 0) throw DDError(DDErrorType::INVALID_ARGUMENT, "Invalid new capacity of sinventory. "); if (extra_capacity) { T** tmp_content; DDALLOCATE(tmp_content = new T*[capacity], "Failed to allocate new sinventory. ", capacity -= extra_capacity;) for (int i = 0; i < m_length && i < capacity; ++i) tmp_content[i] = m_content[i]; while (m_length > capacity) delete m_content[--m_length]; delete[] m_content; m_content = tmp_content; } return *this; } DDSINVENTORY_MEMBER(inline DDSInventory<T>&)::set_capacity(int new_capacity) { return expand(new_capacity - capacity); } DDSINVENTORY_MEMBER(DDSInventory<T>&)::lengthen(int extra_length) { m_length += extra_length;// Maybe not very safe. I'll keep my eye on it. if (m_length < 0) throw DDError(DDErrorType::INVALID_ARGUMENT, "Invalid new m_length of sinventory. "); if (extra_length) { if (m_length > capacity) { DDERROR_MONITOR set_capacity(2 * m_length); DDERROR_SOLVE m_length -= extra_length; DDERROR_SUBMIT } for (int i = extra_length + 1; i <= 0; ++i) { delete m_content [m_length - i]; } for (int i = 1; i <= extra_length; ++i) DDALLOCATE(m_content[m_length - i] = new T, "Failed to allocate element. ", destruct();); } return *this; } DDSINVENTORY_MEMBER(DDSInventory<T>&)::lengthen(int extra_length, const T& initial_value) { m_length += extra_length;// Maybe not very safe. I'll keep my eye on it. if (m_length < 0) throw DDError(DDErrorType::INVALID_ARGUMENT, "Invalid new m_length of sinventory. "); if (extra_length) { if (m_length > capacity) { DDERROR_MONITOR set_capacity(2 * m_length); DDERROR_SOLVE m_length -= extra_length; DDERROR_SUBMIT } for (int i = extra_length + 1; i <= 0; ++i) { delete m_content [m_length - i]; } for (int i = 1; i <= extra_length; ++i) DDALLOCATE(m_content[m_length - i] = new T(initial_value), "Failed to allocate element. ", destruct();); } return *this; } DDSINVENTORY_MEMBER(inline DDSInventory<T>&)::set_length(int new_length) { return lengthen(new_length - m_length); } DDSINVENTORY_MEMBER(inline DDSInventory<T>&)::set_length(int new_length, const T& initial_value) { return lengthen(new_length - m_length, initial_value); } DDSINVENTORY_MEMBER(inline DDSInventory<T>&)::append(const T& element) { return lengthen(1, element); } DDSINVENTORY_MEMBER(inline T&)::operator [](int index) { return *m_content[index]; } DDSINVENTORY_MEMBER(inline const T&)::operator [](int index) const { return *m_content[index]; } DDSINVENTORY_MEMBER(inline int&)::check_index(int& index) const { if (index < 0 || index >= m_length) throw DDError(DDErrorType::ACCESS_DENIED, "Invalid index of DDSInventory called. "); return index; } DDSINVENTORY_MEMBER(DDSInventory<T>&)::destruct() { while (m_length) delete m_content[--m_length]; delete[] m_content; m_content = nullptr; return *this; } #undef DDSINVENTORY_MEMBER DD_END #endif
//===--- Sema.cpp - AST Builder and Semantic Analysis Implementation ------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements the actions class which performs semantic analysis and // builds an AST out of a parse stream. // //===----------------------------------------------------------------------===// #include "UsedDeclVisitor.h" #include "clang/AST/ASTContext.h" #include "clang/AST/ASTDiagnostic.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/PrettyDeclStackTrace.h" #include "clang/AST/StmtCXX.h" #include "clang/Basic/DarwinSDKInfo.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/Stack.h" #include "clang/Basic/TargetInfo.h" #include "clang/Lex/HeaderSearch.h" #include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/Preprocessor.h" #include "clang/Sema/CXXFieldCollector.h" #include "clang/Sema/DelayedDiagnostic.h" #include "clang/Sema/ExternalSemaSource.h" #include "clang/Sema/Initialization.h" #include "clang/Sema/MultiplexExternalSemaSource.h" #include "clang/Sema/ObjCMethodList.h" #include "clang/Sema/Scope.h" #include "clang/Sema/ScopeInfo.h" #include "clang/Sema/SemaConsumer.h" #include "clang/Sema/SemaInternal.h" #include "clang/Sema/TemplateDeduction.h" #include "clang/Sema/TemplateInstCallback.h" #include "clang/Sema/TypoCorrection.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/TimeProfiler.h" using namespace clang; using namespace sema; SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); } ModuleLoader &Sema::getModuleLoader() const { return PP.getModuleLoader(); } DarwinSDKInfo * Sema::getDarwinSDKInfoForAvailabilityChecking(SourceLocation Loc, StringRef Platform) { if (CachedDarwinSDKInfo) return CachedDarwinSDKInfo->get(); auto SDKInfo = parseDarwinSDKInfo( PP.getFileManager().getVirtualFileSystem(), PP.getHeaderSearchInfo().getHeaderSearchOpts().Sysroot); if (SDKInfo && *SDKInfo) { CachedDarwinSDKInfo = std::make_unique<DarwinSDKInfo>(std::move(**SDKInfo)); return CachedDarwinSDKInfo->get(); } if (!SDKInfo) llvm::consumeError(SDKInfo.takeError()); Diag(Loc, diag::warn_missing_sdksettings_for_availability_checking) << Platform; CachedDarwinSDKInfo = std::unique_ptr<DarwinSDKInfo>(); return nullptr; } IdentifierInfo * Sema::InventAbbreviatedTemplateParameterTypeName(IdentifierInfo *ParamName, unsigned int Index) { std::string InventedName; llvm::raw_string_ostream OS(InventedName); if (!ParamName) OS << "auto:" << Index + 1; else OS << ParamName->getName() << ":auto"; OS.flush(); return &Context.Idents.get(OS.str()); } PrintingPolicy Sema::getPrintingPolicy(const ASTContext &Context, const Preprocessor &PP) { PrintingPolicy Policy = Context.getPrintingPolicy(); // In diagnostics, we print _Bool as bool if the latter is defined as the // former. Policy.Bool = Context.getLangOpts().Bool; if (!Policy.Bool) { if (const MacroInfo *BoolMacro = PP.getMacroInfo(Context.getBoolName())) { Policy.Bool = BoolMacro->isObjectLike() && BoolMacro->getNumTokens() == 1 && BoolMacro->getReplacementToken(0).is(tok::kw__Bool); } } return Policy; } void Sema::ActOnTranslationUnitScope(Scope *S) { TUScope = S; PushDeclContext(S, Context.getTranslationUnitDecl()); } namespace clang { namespace sema { class SemaPPCallbacks : public PPCallbacks { Sema *S = nullptr; llvm::SmallVector<SourceLocation, 8> IncludeStack; public: void set(Sema &S) { this->S = &S; } void reset() { S = nullptr; } virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID) override { if (!S) return; switch (Reason) { case EnterFile: { SourceManager &SM = S->getSourceManager(); SourceLocation IncludeLoc = SM.getIncludeLoc(SM.getFileID(Loc)); if (IncludeLoc.isValid()) { if (llvm::timeTraceProfilerEnabled()) { const FileEntry *FE = SM.getFileEntryForID(SM.getFileID(Loc)); llvm::timeTraceProfilerBegin( "Source", FE != nullptr ? FE->getName() : StringRef("<unknown>")); } IncludeStack.push_back(IncludeLoc); S->DiagnoseNonDefaultPragmaAlignPack( Sema::PragmaAlignPackDiagnoseKind::NonDefaultStateAtInclude, IncludeLoc); } break; } case ExitFile: if (!IncludeStack.empty()) { if (llvm::timeTraceProfilerEnabled()) llvm::timeTraceProfilerEnd(); S->DiagnoseNonDefaultPragmaAlignPack( Sema::PragmaAlignPackDiagnoseKind::ChangedStateAtExit, IncludeStack.pop_back_val()); } break; default: break; } } }; } // end namespace sema } // end namespace clang const unsigned Sema::MaxAlignmentExponent; const uint64_t Sema::MaximumAlignment; Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind, CodeCompleteConsumer *CodeCompleter) : ExternalSource(nullptr), isMultiplexExternalSource(false), CurFPFeatures(pp.getLangOpts()), LangOpts(pp.getLangOpts()), PP(pp), Context(ctxt), Consumer(consumer), Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()), CollectStats(false), CodeCompleter(CodeCompleter), CurContext(nullptr), OriginalLexicalContext(nullptr), MSStructPragmaOn(false), MSPointerToMemberRepresentationMethod( LangOpts.getMSPointerToMemberRepresentationMethod()), VtorDispStack(LangOpts.getVtorDispMode()), AlignPackStack(AlignPackInfo(getLangOpts().XLPragmaPack)), DataSegStack(nullptr), BSSSegStack(nullptr), ConstSegStack(nullptr), CodeSegStack(nullptr), FpPragmaStack(FPOptionsOverride()), CurInitSeg(nullptr), VisContext(nullptr), PragmaAttributeCurrentTargetDecl(nullptr), IsBuildingRecoveryCallExpr(false), Cleanup{}, LateTemplateParser(nullptr), LateTemplateParserCleanup(nullptr), OpaqueParser(nullptr), IdResolver(pp), StdExperimentalNamespaceCache(nullptr), StdInitializerList(nullptr), StdCoroutineTraitsCache(nullptr), CXXTypeInfoDecl(nullptr), MSVCGuidDecl(nullptr), NSNumberDecl(nullptr), NSValueDecl(nullptr), NSStringDecl(nullptr), StringWithUTF8StringMethod(nullptr), ValueWithBytesObjCTypeMethod(nullptr), NSArrayDecl(nullptr), ArrayWithObjectsMethod(nullptr), NSDictionaryDecl(nullptr), DictionaryWithObjectsMethod(nullptr), GlobalNewDeleteDeclared(false), TUKind(TUKind), NumSFINAEErrors(0), FullyCheckedComparisonCategories( static_cast<unsigned>(ComparisonCategoryType::Last) + 1), SatisfactionCache(Context), AccessCheckingSFINAE(false), InNonInstantiationSFINAEContext(false), NonInstantiationEntries(0), ArgumentPackSubstitutionIndex(-1), CurrentInstantiationScope(nullptr), DisableTypoCorrection(false), TyposCorrected(0), AnalysisWarnings(*this), ThreadSafetyDeclCache(nullptr), VarDataSharingAttributesStack(nullptr), CurScope(nullptr), Ident_super(nullptr), Ident___float128(nullptr), SyclIntHeader(nullptr), SyclIntFooter(nullptr) { assert(pp.TUKind == TUKind); TUScope = nullptr; isConstantEvaluatedOverride = false; LoadedExternalKnownNamespaces = false; for (unsigned I = 0; I != NSAPI::NumNSNumberLiteralMethods; ++I) NSNumberLiteralMethods[I] = nullptr; if (getLangOpts().ObjC) NSAPIObj.reset(new NSAPI(Context)); if (getLangOpts().CPlusPlus) FieldCollector.reset(new CXXFieldCollector()); // Tell diagnostics how to render things from the AST library. Diags.SetArgToStringFn(&FormatASTNodeDiagnosticArgument, &Context); ExprEvalContexts.emplace_back( ExpressionEvaluationContext::PotentiallyEvaluated, 0, CleanupInfo{}, nullptr, ExpressionEvaluationContextRecord::EK_Other); // Initialization of data sharing attributes stack for OpenMP InitDataSharingAttributesStack(); std::unique_ptr<sema::SemaPPCallbacks> Callbacks = std::make_unique<sema::SemaPPCallbacks>(); SemaPPCallbackHandler = Callbacks.get(); PP.addPPCallbacks(std::move(Callbacks)); SemaPPCallbackHandler->set(*this); } // Anchor Sema's type info to this TU. void Sema::anchor() {} void Sema::addImplicitTypedef(StringRef Name, QualType T) { DeclarationName DN = &Context.Idents.get(Name); if (IdResolver.begin(DN) == IdResolver.end()) PushOnScopeChains(Context.buildImplicitTypedef(T, Name), TUScope); } void Sema::Initialize() { if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer)) SC->InitializeSema(*this); // Tell the external Sema source about this Sema object. if (ExternalSemaSource *ExternalSema = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource())) ExternalSema->InitializeSema(*this); // This needs to happen after ExternalSemaSource::InitializeSema(this) or we // will not be able to merge any duplicate __va_list_tag decls correctly. VAListTagName = PP.getIdentifierInfo("__va_list_tag"); if (!TUScope) return; // Initialize predefined 128-bit integer types, if needed. if (Context.getTargetInfo().hasInt128Type() || (Context.getAuxTargetInfo() && Context.getAuxTargetInfo()->hasInt128Type())) { // If either of the 128-bit integer types are unavailable to name lookup, // define them now. DeclarationName Int128 = &Context.Idents.get("__int128_t"); if (IdResolver.begin(Int128) == IdResolver.end()) PushOnScopeChains(Context.getInt128Decl(), TUScope); DeclarationName UInt128 = &Context.Idents.get("__uint128_t"); if (IdResolver.begin(UInt128) == IdResolver.end()) PushOnScopeChains(Context.getUInt128Decl(), TUScope); } // Initialize predefined Objective-C types: if (getLangOpts().ObjC) { // If 'SEL' does not yet refer to any declarations, make it refer to the // predefined 'SEL'. DeclarationName SEL = &Context.Idents.get("SEL"); if (IdResolver.begin(SEL) == IdResolver.end()) PushOnScopeChains(Context.getObjCSelDecl(), TUScope); // If 'id' does not yet refer to any declarations, make it refer to the // predefined 'id'. DeclarationName Id = &Context.Idents.get("id"); if (IdResolver.begin(Id) == IdResolver.end()) PushOnScopeChains(Context.getObjCIdDecl(), TUScope); // Create the built-in typedef for 'Class'. DeclarationName Class = &Context.Idents.get("Class"); if (IdResolver.begin(Class) == IdResolver.end()) PushOnScopeChains(Context.getObjCClassDecl(), TUScope); // Create the built-in forward declaratino for 'Protocol'. DeclarationName Protocol = &Context.Idents.get("Protocol"); if (IdResolver.begin(Protocol) == IdResolver.end()) PushOnScopeChains(Context.getObjCProtocolDecl(), TUScope); } // Create the internal type for the *StringMakeConstantString builtins. DeclarationName ConstantString = &Context.Idents.get("__NSConstantString"); if (IdResolver.begin(ConstantString) == IdResolver.end()) PushOnScopeChains(Context.getCFConstantStringDecl(), TUScope); // Initialize Microsoft "predefined C++ types". if (getLangOpts().MSVCCompat) { if (getLangOpts().CPlusPlus && IdResolver.begin(&Context.Idents.get("type_info")) == IdResolver.end()) PushOnScopeChains(Context.buildImplicitRecord("type_info", TTK_Class), TUScope); addImplicitTypedef("size_t", Context.getSizeType()); } if (getLangOpts().SYCLIsDevice) { addImplicitTypedef("__ocl_event_t", Context.OCLEventTy); addImplicitTypedef("__ocl_sampler_t", Context.OCLSamplerTy); #ifdef SEMA_STRINGIZE #error "Undefine SEMA_STRINGIZE macro." #endif #define SEMA_STRINGIZE(s) #s #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ addImplicitTypedef(SEMA_STRINGIZE(__ocl_##ImgType##_##Suffix##_t), \ Context.SingletonId); #include "clang/Basic/OpenCLImageTypes.def" #undef SEMA_STRINGIZE } if (getLangOpts().SYCLIsDevice || getLangOpts().OpenCL) { #ifdef SEMA_STRINGIZE #error "Undefine SEMA_STRINGIZE macro." #endif #define SEMA_STRINGIZE(s) #s #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ addImplicitTypedef(SEMA_STRINGIZE(__ocl_sampled_##ImgType##_##Suffix##_t), \ Context.Sampled##SingletonId); #define IMAGE_WRITE_TYPE(Type, Id, Ext) #define IMAGE_READ_WRITE_TYPE(Type, Id, Ext) #include "clang/Basic/OpenCLImageTypes.def" #undef SEMA_STRINGIZE } // Initialize predefined OpenCL types and supported extensions and (optional) // core features. if (getLangOpts().OpenCL) { getOpenCLOptions().addSupport( Context.getTargetInfo().getSupportedOpenCLOpts(), getLangOpts()); addImplicitTypedef("sampler_t", Context.OCLSamplerTy); addImplicitTypedef("event_t", Context.OCLEventTy); if (getLangOpts().getOpenCLCompatibleVersion() >= 200) { addImplicitTypedef("clk_event_t", Context.OCLClkEventTy); addImplicitTypedef("queue_t", Context.OCLQueueTy); if (getLangOpts().OpenCLPipes) addImplicitTypedef("reserve_id_t", Context.OCLReserveIDTy); addImplicitTypedef("atomic_int", Context.getAtomicType(Context.IntTy)); addImplicitTypedef("atomic_uint", Context.getAtomicType(Context.UnsignedIntTy)); addImplicitTypedef("atomic_float", Context.getAtomicType(Context.FloatTy)); // OpenCLC v2.0, s6.13.11.6 requires that atomic_flag is implemented as // 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide. addImplicitTypedef("atomic_flag", Context.getAtomicType(Context.IntTy)); // OpenCL v2.0 s6.13.11.6: // - The atomic_long and atomic_ulong types are supported if the // cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics // extensions are supported. // - The atomic_double type is only supported if double precision // is supported and the cl_khr_int64_base_atomics and // cl_khr_int64_extended_atomics extensions are supported. // - If the device address space is 64-bits, the data types // atomic_intptr_t, atomic_uintptr_t, atomic_size_t and // atomic_ptrdiff_t are supported if the cl_khr_int64_base_atomics and // cl_khr_int64_extended_atomics extensions are supported. auto AddPointerSizeDependentTypes = [&]() { auto AtomicSizeT = Context.getAtomicType(Context.getSizeType()); auto AtomicIntPtrT = Context.getAtomicType(Context.getIntPtrType()); auto AtomicUIntPtrT = Context.getAtomicType(Context.getUIntPtrType()); auto AtomicPtrDiffT = Context.getAtomicType(Context.getPointerDiffType()); addImplicitTypedef("atomic_size_t", AtomicSizeT); addImplicitTypedef("atomic_intptr_t", AtomicIntPtrT); addImplicitTypedef("atomic_uintptr_t", AtomicUIntPtrT); addImplicitTypedef("atomic_ptrdiff_t", AtomicPtrDiffT); }; if (Context.getTypeSize(Context.getSizeType()) == 32) { AddPointerSizeDependentTypes(); } if (getOpenCLOptions().isSupported("cl_khr_fp16", getLangOpts())) { auto AtomicHalfT = Context.getAtomicType(Context.HalfTy); addImplicitTypedef("atomic_half", AtomicHalfT); } std::vector<QualType> Atomic64BitTypes; if (getOpenCLOptions().isSupported("cl_khr_int64_base_atomics", getLangOpts()) && getOpenCLOptions().isSupported("cl_khr_int64_extended_atomics", getLangOpts())) { if (getOpenCLOptions().isSupported("cl_khr_fp64", getLangOpts())) { auto AtomicDoubleT = Context.getAtomicType(Context.DoubleTy); addImplicitTypedef("atomic_double", AtomicDoubleT); Atomic64BitTypes.push_back(AtomicDoubleT); } auto AtomicLongT = Context.getAtomicType(Context.LongTy); auto AtomicULongT = Context.getAtomicType(Context.UnsignedLongTy); addImplicitTypedef("atomic_long", AtomicLongT); addImplicitTypedef("atomic_ulong", AtomicULongT); if (Context.getTypeSize(Context.getSizeType()) == 64) { AddPointerSizeDependentTypes(); } } } #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ if (getOpenCLOptions().isSupported(#Ext, getLangOpts())) { \ addImplicitTypedef(#ExtType, Context.Id##Ty); \ } #include "clang/Basic/OpenCLExtensionTypes.def" } if (Context.getTargetInfo().hasAArch64SVETypes()) { #define SVE_TYPE(Name, Id, SingletonId) \ addImplicitTypedef(Name, Context.SingletonId); #include "clang/Basic/AArch64SVEACLETypes.def" } if (Context.getTargetInfo().getTriple().isPPC64()) { #define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \ addImplicitTypedef(#Name, Context.Id##Ty); #include "clang/Basic/PPCTypes.def" #define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \ addImplicitTypedef(#Name, Context.Id##Ty); #include "clang/Basic/PPCTypes.def" } if (Context.getTargetInfo().hasRISCVVTypes()) { #define RVV_TYPE(Name, Id, SingletonId) \ addImplicitTypedef(Name, Context.SingletonId); #include "clang/Basic/RISCVVTypes.def" } if (Context.getTargetInfo().hasBuiltinMSVaList()) { DeclarationName MSVaList = &Context.Idents.get("__builtin_ms_va_list"); if (IdResolver.begin(MSVaList) == IdResolver.end()) PushOnScopeChains(Context.getBuiltinMSVaListDecl(), TUScope); } DeclarationName BuiltinVaList = &Context.Idents.get("__builtin_va_list"); if (IdResolver.begin(BuiltinVaList) == IdResolver.end()) PushOnScopeChains(Context.getBuiltinVaListDecl(), TUScope); } Sema::~Sema() { assert(InstantiatingSpecializations.empty() && "failed to clean up an InstantiatingTemplate?"); if (VisContext) FreeVisContext(); // Kill all the active scopes. for (sema::FunctionScopeInfo *FSI : FunctionScopes) delete FSI; // Tell the SemaConsumer to forget about us; we're going out of scope. if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer)) SC->ForgetSema(); // Detach from the external Sema source. if (ExternalSemaSource *ExternalSema = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource())) ExternalSema->ForgetSema(); // If Sema's ExternalSource is the multiplexer - we own it. if (isMultiplexExternalSource) delete ExternalSource; // Delete cached satisfactions. std::vector<ConstraintSatisfaction *> Satisfactions; Satisfactions.reserve(Satisfactions.size()); for (auto &Node : SatisfactionCache) Satisfactions.push_back(&Node); for (auto *Node : Satisfactions) delete Node; threadSafety::threadSafetyCleanup(ThreadSafetyDeclCache); // Destroys data sharing attributes stack for OpenMP DestroyDataSharingAttributesStack(); // Detach from the PP callback handler which outlives Sema since it's owned // by the preprocessor. SemaPPCallbackHandler->reset(); } void Sema::warnStackExhausted(SourceLocation Loc) { // Only warn about this once. if (!WarnedStackExhausted) { Diag(Loc, diag::warn_stack_exhausted); WarnedStackExhausted = true; } } void Sema::runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref<void()> Fn) { clang::runWithSufficientStackSpace([&] { warnStackExhausted(Loc); }, Fn); } /// makeUnavailableInSystemHeader - There is an error in the current /// context. If we're still in a system header, and we can plausibly /// make the relevant declaration unavailable instead of erroring, do /// so and return true. bool Sema::makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason) { // If we're not in a function, it's an error. FunctionDecl *fn = dyn_cast<FunctionDecl>(CurContext); if (!fn) return false; // If we're in template instantiation, it's an error. if (inTemplateInstantiation()) return false; // If that function's not in a system header, it's an error. if (!Context.getSourceManager().isInSystemHeader(loc)) return false; // If the function is already unavailable, it's not an error. if (fn->hasAttr<UnavailableAttr>()) return true; fn->addAttr(UnavailableAttr::CreateImplicit(Context, "", reason, loc)); return true; } ASTMutationListener *Sema::getASTMutationListener() const { return getASTConsumer().GetASTMutationListener(); } ///Registers an external source. If an external source already exists, /// creates a multiplex external source and appends to it. /// ///\param[in] E - A non-null external sema source. /// void Sema::addExternalSource(ExternalSemaSource *E) { assert(E && "Cannot use with NULL ptr"); if (!ExternalSource) { ExternalSource = E; return; } if (isMultiplexExternalSource) static_cast<MultiplexExternalSemaSource*>(ExternalSource)->addSource(*E); else { ExternalSource = new MultiplexExternalSemaSource(*ExternalSource, *E); isMultiplexExternalSource = true; } } /// Print out statistics about the semantic analysis. void Sema::PrintStats() const { llvm::errs() << "\n*** Semantic Analysis Stats:\n"; llvm::errs() << NumSFINAEErrors << " SFINAE diagnostics trapped.\n"; BumpAlloc.PrintStats(); AnalysisWarnings.PrintStats(); } void Sema::diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc) { Optional<NullabilityKind> ExprNullability = SrcType->getNullability(Context); if (!ExprNullability || (*ExprNullability != NullabilityKind::Nullable && *ExprNullability != NullabilityKind::NullableResult)) return; Optional<NullabilityKind> TypeNullability = DstType->getNullability(Context); if (!TypeNullability || *TypeNullability != NullabilityKind::NonNull) return; Diag(Loc, diag::warn_nullability_lost) << SrcType << DstType; } void Sema::diagnoseZeroToNullptrConversion(CastKind Kind, const Expr* E) { if (Diags.isIgnored(diag::warn_zero_as_null_pointer_constant, E->getBeginLoc())) return; // nullptr only exists from C++11 on, so don't warn on its absence earlier. if (!getLangOpts().CPlusPlus11) return; if (Kind != CK_NullToPointer && Kind != CK_NullToMemberPointer) return; if (E->IgnoreParenImpCasts()->getType()->isNullPtrType()) return; // Don't diagnose the conversion from a 0 literal to a null pointer argument // in a synthesized call to operator<=>. if (!CodeSynthesisContexts.empty() && CodeSynthesisContexts.back().Kind == CodeSynthesisContext::RewritingOperatorAsSpaceship) return; // If it is a macro from system header, and if the macro name is not "NULL", // do not warn. SourceLocation MaybeMacroLoc = E->getBeginLoc(); if (Diags.getSuppressSystemWarnings() && SourceMgr.isInSystemMacro(MaybeMacroLoc) && !findMacroSpelling(MaybeMacroLoc, "NULL")) return; Diag(E->getBeginLoc(), diag::warn_zero_as_null_pointer_constant) << FixItHint::CreateReplacement(E->getSourceRange(), "nullptr"); } /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast. /// If there is already an implicit cast, merge into the existing one. /// The result is of the given category. ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty, CastKind Kind, ExprValueKind VK, const CXXCastPath *BasePath, CheckedConversionKind CCK) { #ifndef NDEBUG if (VK == VK_PRValue && !E->isPRValue()) { switch (Kind) { default: llvm_unreachable( ("can't implicitly cast glvalue to prvalue with this cast " "kind: " + std::string(CastExpr::getCastKindName(Kind))) .c_str()); case CK_Dependent: case CK_LValueToRValue: case CK_ArrayToPointerDecay: case CK_FunctionToPointerDecay: case CK_ToVoid: case CK_NonAtomicToAtomic: break; } } assert((VK == VK_PRValue || Kind == CK_Dependent || !E->isPRValue()) && "can't cast prvalue to glvalue"); #endif diagnoseNullableToNonnullConversion(Ty, E->getType(), E->getBeginLoc()); diagnoseZeroToNullptrConversion(Kind, E); QualType ExprTy = Context.getCanonicalType(E->getType()); QualType TypeTy = Context.getCanonicalType(Ty); if (ExprTy == TypeTy) return E; if (Kind == CK_ArrayToPointerDecay) { // C++1z [conv.array]: The temporary materialization conversion is applied. // We also use this to fuel C++ DR1213, which applies to C++11 onwards. if (getLangOpts().CPlusPlus && E->isPRValue()) { // The temporary is an lvalue in C++98 and an xvalue otherwise. ExprResult Materialized = CreateMaterializeTemporaryExpr( E->getType(), E, !getLangOpts().CPlusPlus11); if (Materialized.isInvalid()) return ExprError(); E = Materialized.get(); } // C17 6.7.1p6 footnote 124: The implementation can treat any register // declaration simply as an auto declaration. However, whether or not // addressable storage is actually used, the address of any part of an // object declared with storage-class specifier register cannot be // computed, either explicitly(by use of the unary & operator as discussed // in 6.5.3.2) or implicitly(by converting an array name to a pointer as // discussed in 6.3.2.1).Thus, the only operator that can be applied to an // array declared with storage-class specifier register is sizeof. if (VK == VK_PRValue && !getLangOpts().CPlusPlus && !E->isPRValue()) { if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) { if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) { if (VD->getStorageClass() == SC_Register) { Diag(E->getExprLoc(), diag::err_typecheck_address_of) << /*register variable*/ 3 << E->getSourceRange(); return ExprError(); } } } } } if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(E)) { if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) { ImpCast->setType(Ty); ImpCast->setValueKind(VK); return E; } } return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK, CurFPFeatureOverrides()); } /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding /// to the conversion from scalar type ScalarTy to the Boolean type. CastKind Sema::ScalarTypeToBooleanCastKind(QualType ScalarTy) { switch (ScalarTy->getScalarTypeKind()) { case Type::STK_Bool: return CK_NoOp; case Type::STK_CPointer: return CK_PointerToBoolean; case Type::STK_BlockPointer: return CK_PointerToBoolean; case Type::STK_ObjCObjectPointer: return CK_PointerToBoolean; case Type::STK_MemberPointer: return CK_MemberPointerToBoolean; case Type::STK_Integral: return CK_IntegralToBoolean; case Type::STK_Floating: return CK_FloatingToBoolean; case Type::STK_IntegralComplex: return CK_IntegralComplexToBoolean; case Type::STK_FloatingComplex: return CK_FloatingComplexToBoolean; case Type::STK_FixedPoint: return CK_FixedPointToBoolean; } llvm_unreachable("unknown scalar type kind"); } /// Used to prune the decls of Sema's UnusedFileScopedDecls vector. static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) { if (D->getMostRecentDecl()->isUsed()) return true; if (D->isExternallyVisible()) return true; if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { // If this is a function template and none of its specializations is used, // we should warn. if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate()) for (const auto *Spec : Template->specializations()) if (ShouldRemoveFromUnused(SemaRef, Spec)) return true; // UnusedFileScopedDecls stores the first declaration. // The declaration may have become definition so check again. const FunctionDecl *DeclToCheck; if (FD->hasBody(DeclToCheck)) return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck); // Later redecls may add new information resulting in not having to warn, // so check again. DeclToCheck = FD->getMostRecentDecl(); if (DeclToCheck != FD) return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck); } if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { // If a variable usable in constant expressions is referenced, // don't warn if it isn't used: if the value of a variable is required // for the computation of a constant expression, it doesn't make sense to // warn even if the variable isn't odr-used. (isReferenced doesn't // precisely reflect that, but it's a decent approximation.) if (VD->isReferenced() && VD->mightBeUsableInConstantExpressions(SemaRef->Context)) return true; if (VarTemplateDecl *Template = VD->getDescribedVarTemplate()) // If this is a variable template and none of its specializations is used, // we should warn. for (const auto *Spec : Template->specializations()) if (ShouldRemoveFromUnused(SemaRef, Spec)) return true; // UnusedFileScopedDecls stores the first declaration. // The declaration may have become definition so check again. const VarDecl *DeclToCheck = VD->getDefinition(); if (DeclToCheck) return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck); // Later redecls may add new information resulting in not having to warn, // so check again. DeclToCheck = VD->getMostRecentDecl(); if (DeclToCheck != VD) return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck); } return false; } static bool isFunctionOrVarDeclExternC(NamedDecl *ND) { if (auto *FD = dyn_cast<FunctionDecl>(ND)) return FD->isExternC(); return cast<VarDecl>(ND)->isExternC(); } /// Determine whether ND is an external-linkage function or variable whose /// type has no linkage. bool Sema::isExternalWithNoLinkageType(ValueDecl *VD) { // Note: it's not quite enough to check whether VD has UniqueExternalLinkage, // because we also want to catch the case where its type has VisibleNoLinkage, // which does not affect the linkage of VD. return getLangOpts().CPlusPlus && VD->hasExternalFormalLinkage() && !isExternalFormalLinkage(VD->getType()->getLinkage()) && !isFunctionOrVarDeclExternC(VD); } /// Obtains a sorted list of functions and variables that are undefined but /// ODR-used. void Sema::getUndefinedButUsed( SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> > &Undefined) { for (const auto &UndefinedUse : UndefinedButUsed) { NamedDecl *ND = UndefinedUse.first; // Ignore attributes that have become invalid. if (ND->isInvalidDecl()) continue; // __attribute__((weakref)) is basically a definition. if (ND->hasAttr<WeakRefAttr>()) continue; if (isa<CXXDeductionGuideDecl>(ND)) continue; if (ND->hasAttr<DLLImportAttr>() || ND->hasAttr<DLLExportAttr>()) { // An exported function will always be emitted when defined, so even if // the function is inline, it doesn't have to be emitted in this TU. An // imported function implies that it has been exported somewhere else. continue; } if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) { if (FD->isDefined()) continue; if (FD->isExternallyVisible() && !isExternalWithNoLinkageType(FD) && !FD->getMostRecentDecl()->isInlined() && !FD->hasAttr<ExcludeFromExplicitInstantiationAttr>()) continue; if (FD->getBuiltinID()) continue; } else { auto *VD = cast<VarDecl>(ND); if (VD->hasDefinition() != VarDecl::DeclarationOnly) continue; if (VD->isExternallyVisible() && !isExternalWithNoLinkageType(VD) && !VD->getMostRecentDecl()->isInline() && !VD->hasAttr<ExcludeFromExplicitInstantiationAttr>()) continue; // Skip VarDecls that lack formal definitions but which we know are in // fact defined somewhere. if (VD->isKnownToBeDefined()) continue; } Undefined.push_back(std::make_pair(ND, UndefinedUse.second)); } } /// checkUndefinedButUsed - Check for undefined objects with internal linkage /// or that are inline. static void checkUndefinedButUsed(Sema &S) { if (S.UndefinedButUsed.empty()) return; // Collect all the still-undefined entities with internal linkage. SmallVector<std::pair<NamedDecl *, SourceLocation>, 16> Undefined; S.getUndefinedButUsed(Undefined); if (Undefined.empty()) return; for (auto Undef : Undefined) { ValueDecl *VD = cast<ValueDecl>(Undef.first); SourceLocation UseLoc = Undef.second; if (S.isExternalWithNoLinkageType(VD)) { // C++ [basic.link]p8: // A type without linkage shall not be used as the type of a variable // or function with external linkage unless // -- the entity has C language linkage // -- the entity is not odr-used or is defined in the same TU // // As an extension, accept this in cases where the type is externally // visible, since the function or variable actually can be defined in // another translation unit in that case. S.Diag(VD->getLocation(), isExternallyVisible(VD->getType()->getLinkage()) ? diag::ext_undefined_internal_type : diag::err_undefined_internal_type) << isa<VarDecl>(VD) << VD; } else if (!VD->isExternallyVisible()) { // FIXME: We can promote this to an error. The function or variable can't // be defined anywhere else, so the program must necessarily violate the // one definition rule. bool IsImplicitBase = false; if (const auto *BaseD = dyn_cast<FunctionDecl>(VD)) { auto *DVAttr = BaseD->getAttr<OMPDeclareVariantAttr>(); if (DVAttr && !DVAttr->getTraitInfo().isExtensionActive( llvm::omp::TraitProperty:: implementation_extension_disable_implicit_base)) { const auto *Func = cast<FunctionDecl>( cast<DeclRefExpr>(DVAttr->getVariantFuncRef())->getDecl()); IsImplicitBase = BaseD->isImplicit() && Func->getIdentifier()->isMangledOpenMPVariantName(); } } if (!S.getLangOpts().OpenMP || !IsImplicitBase) S.Diag(VD->getLocation(), diag::warn_undefined_internal) << isa<VarDecl>(VD) << VD; } else if (auto *FD = dyn_cast<FunctionDecl>(VD)) { (void)FD; assert(FD->getMostRecentDecl()->isInlined() && "used object requires definition but isn't inline or internal?"); // FIXME: This is ill-formed; we should reject. S.Diag(VD->getLocation(), diag::warn_undefined_inline) << VD; } else { assert(cast<VarDecl>(VD)->getMostRecentDecl()->isInline() && "used var requires definition but isn't inline or internal?"); S.Diag(VD->getLocation(), diag::err_undefined_inline_var) << VD; } if (UseLoc.isValid()) S.Diag(UseLoc, diag::note_used_here); } S.UndefinedButUsed.clear(); } void Sema::LoadExternalWeakUndeclaredIdentifiers() { if (!ExternalSource) return; SmallVector<std::pair<IdentifierInfo *, WeakInfo>, 4> WeakIDs; ExternalSource->ReadWeakUndeclaredIdentifiers(WeakIDs); for (auto &WeakID : WeakIDs) WeakUndeclaredIdentifiers.insert(WeakID); } typedef llvm::DenseMap<const CXXRecordDecl*, bool> RecordCompleteMap; /// Returns true, if all methods and nested classes of the given /// CXXRecordDecl are defined in this translation unit. /// /// Should only be called from ActOnEndOfTranslationUnit so that all /// definitions are actually read. static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD, RecordCompleteMap &MNCComplete) { RecordCompleteMap::iterator Cache = MNCComplete.find(RD); if (Cache != MNCComplete.end()) return Cache->second; if (!RD->isCompleteDefinition()) return false; bool Complete = true; for (DeclContext::decl_iterator I = RD->decls_begin(), E = RD->decls_end(); I != E && Complete; ++I) { if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I)) Complete = M->isDefined() || M->isDefaulted() || (M->isPure() && !isa<CXXDestructorDecl>(M)); else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I)) // If the template function is marked as late template parsed at this // point, it has not been instantiated and therefore we have not // performed semantic analysis on it yet, so we cannot know if the type // can be considered complete. Complete = !F->getTemplatedDecl()->isLateTemplateParsed() && F->getTemplatedDecl()->isDefined(); else if (const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) { if (R->isInjectedClassName()) continue; if (R->hasDefinition()) Complete = MethodsAndNestedClassesComplete(R->getDefinition(), MNCComplete); else Complete = false; } } MNCComplete[RD] = Complete; return Complete; } /// Returns true, if the given CXXRecordDecl is fully defined in this /// translation unit, i.e. all methods are defined or pure virtual and all /// friends, friend functions and nested classes are fully defined in this /// translation unit. /// /// Should only be called from ActOnEndOfTranslationUnit so that all /// definitions are actually read. static bool IsRecordFullyDefined(const CXXRecordDecl *RD, RecordCompleteMap &RecordsComplete, RecordCompleteMap &MNCComplete) { RecordCompleteMap::iterator Cache = RecordsComplete.find(RD); if (Cache != RecordsComplete.end()) return Cache->second; bool Complete = MethodsAndNestedClassesComplete(RD, MNCComplete); for (CXXRecordDecl::friend_iterator I = RD->friend_begin(), E = RD->friend_end(); I != E && Complete; ++I) { // Check if friend classes and methods are complete. if (TypeSourceInfo *TSI = (*I)->getFriendType()) { // Friend classes are available as the TypeSourceInfo of the FriendDecl. if (CXXRecordDecl *FriendD = TSI->getType()->getAsCXXRecordDecl()) Complete = MethodsAndNestedClassesComplete(FriendD, MNCComplete); else Complete = false; } else { // Friend functions are available through the NamedDecl of FriendDecl. if (const FunctionDecl *FD = dyn_cast<FunctionDecl>((*I)->getFriendDecl())) Complete = FD->isDefined(); else // This is a template friend, give up. Complete = false; } } RecordsComplete[RD] = Complete; return Complete; } void Sema::emitAndClearUnusedLocalTypedefWarnings() { if (ExternalSource) ExternalSource->ReadUnusedLocalTypedefNameCandidates( UnusedLocalTypedefNameCandidates); for (const TypedefNameDecl *TD : UnusedLocalTypedefNameCandidates) { if (TD->isReferenced()) continue; Diag(TD->getLocation(), diag::warn_unused_local_typedef) << isa<TypeAliasDecl>(TD) << TD->getDeclName(); } UnusedLocalTypedefNameCandidates.clear(); } /// This is called before the very first declaration in the translation unit /// is parsed. Note that the ASTContext may have already injected some /// declarations. void Sema::ActOnStartOfTranslationUnit() { if (getLangOpts().ModulesTS && (getLangOpts().getCompilingModule() == LangOptions::CMK_ModuleInterface || getLangOpts().getCompilingModule() == LangOptions::CMK_None)) { // We start in an implied global module fragment. SourceLocation StartOfTU = SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID()); ActOnGlobalModuleFragmentDecl(StartOfTU); ModuleScopes.back().ImplicitGlobalModuleFragment = true; } } void Sema::ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind) { // No explicit actions are required at the end of the global module fragment. if (Kind == TUFragmentKind::Global) return; // Transfer late parsed template instantiations over to the pending template // instantiation list. During normal compilation, the late template parser // will be installed and instantiating these templates will succeed. // // If we are building a TU prefix for serialization, it is also safe to // transfer these over, even though they are not parsed. The end of the TU // should be outside of any eager template instantiation scope, so when this // AST is deserialized, these templates will not be parsed until the end of // the combined TU. PendingInstantiations.insert(PendingInstantiations.end(), LateParsedInstantiations.begin(), LateParsedInstantiations.end()); LateParsedInstantiations.clear(); // If DefinedUsedVTables ends up marking any virtual member functions it // might lead to more pending template instantiations, which we then need // to instantiate. DefineUsedVTables(); // C++: Perform implicit template instantiations. // // FIXME: When we perform these implicit instantiations, we do not // carefully keep track of the point of instantiation (C++ [temp.point]). // This means that name lookup that occurs within the template // instantiation will always happen at the end of the translation unit, // so it will find some names that are not required to be found. This is // valid, but we could do better by diagnosing if an instantiation uses a // name that was not visible at its first point of instantiation. if (ExternalSource) { // Load pending instantiations from the external source. SmallVector<PendingImplicitInstantiation, 4> Pending; ExternalSource->ReadPendingInstantiations(Pending); for (auto PII : Pending) if (auto Func = dyn_cast<FunctionDecl>(PII.first)) Func->setInstantiationIsPending(true); PendingInstantiations.insert(PendingInstantiations.begin(), Pending.begin(), Pending.end()); } { llvm::TimeTraceScope TimeScope("PerformPendingInstantiations"); PerformPendingInstantiations(); } if (getLangOpts().SYCLIsDevice) { // Set the names of the kernels, now that the names have settled down. This // needs to happen before we generate the integration headers. SetSYCLKernelNames(); // Emit SYCL integration header for current translation unit if needed if (SyclIntHeader != nullptr) SyclIntHeader->emit(getLangOpts().SYCLIntHeader); if (SyclIntFooter != nullptr) SyclIntFooter->emit(getLangOpts().SYCLIntFooter); MarkDevices(); } emitDeferredDiags(); assert(LateParsedInstantiations.empty() && "end of TU template instantiation should not create more " "late-parsed templates"); // Report diagnostics for uncorrected delayed typos. Ideally all of them // should have been corrected by that time, but it is very hard to cover all // cases in practice. for (const auto &Typo : DelayedTypos) { // We pass an empty TypoCorrection to indicate no correction was performed. Typo.second.DiagHandler(TypoCorrection()); } DelayedTypos.clear(); } /// ActOnEndOfTranslationUnit - This is called at the very end of the /// translation unit when EOF is reached and all but the top-level scope is /// popped. void Sema::ActOnEndOfTranslationUnit() { assert(DelayedDiagnostics.getCurrentPool() == nullptr && "reached end of translation unit with a pool attached?"); // If code completion is enabled, don't perform any end-of-translation-unit // work. if (PP.isCodeCompletionEnabled()) return; // Complete translation units and modules define vtables and perform implicit // instantiations. PCH files do not. if (TUKind != TU_Prefix) { DiagnoseUseOfUnimplementedSelectors(); ActOnEndOfTranslationUnitFragment( !ModuleScopes.empty() && ModuleScopes.back().Module->Kind == Module::PrivateModuleFragment ? TUFragmentKind::Private : TUFragmentKind::Normal); if (LateTemplateParserCleanup) LateTemplateParserCleanup(OpaqueParser); CheckDelayedMemberExceptionSpecs(); } else { // If we are building a TU prefix for serialization, it is safe to transfer // these over, even though they are not parsed. The end of the TU should be // outside of any eager template instantiation scope, so when this AST is // deserialized, these templates will not be parsed until the end of the // combined TU. PendingInstantiations.insert(PendingInstantiations.end(), LateParsedInstantiations.begin(), LateParsedInstantiations.end()); LateParsedInstantiations.clear(); if (LangOpts.PCHInstantiateTemplates) { llvm::TimeTraceScope TimeScope("PerformPendingInstantiations"); PerformPendingInstantiations(); } } DiagnoseUnterminatedPragmaAlignPack(); DiagnoseUnterminatedPragmaAttribute(); // All delayed member exception specs should be checked or we end up accepting // incompatible declarations. assert(DelayedOverridingExceptionSpecChecks.empty()); assert(DelayedEquivalentExceptionSpecChecks.empty()); // All dllexport classes should have been processed already. assert(DelayedDllExportClasses.empty()); assert(DelayedDllExportMemberFunctions.empty()); // Remove file scoped decls that turned out to be used. UnusedFileScopedDecls.erase( std::remove_if(UnusedFileScopedDecls.begin(nullptr, true), UnusedFileScopedDecls.end(), [this](const DeclaratorDecl *DD) { return ShouldRemoveFromUnused(this, DD); }), UnusedFileScopedDecls.end()); if (TUKind == TU_Prefix) { // Translation unit prefixes don't need any of the checking below. if (!PP.isIncrementalProcessingEnabled()) TUScope = nullptr; return; } // Check for #pragma weak identifiers that were never declared LoadExternalWeakUndeclaredIdentifiers(); for (auto WeakID : WeakUndeclaredIdentifiers) { if (WeakID.second.getUsed()) continue; Decl *PrevDecl = LookupSingleName(TUScope, WeakID.first, SourceLocation(), LookupOrdinaryName); if (PrevDecl != nullptr && !(isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) Diag(WeakID.second.getLocation(), diag::warn_attribute_wrong_decl_type) << "'weak'" << ExpectedVariableOrFunction; else Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared) << WeakID.first; } if (LangOpts.CPlusPlus11 && !Diags.isIgnored(diag::warn_delegating_ctor_cycle, SourceLocation())) CheckDelegatingCtorCycles(); if (!Diags.hasErrorOccurred()) { if (ExternalSource) ExternalSource->ReadUndefinedButUsed(UndefinedButUsed); checkUndefinedButUsed(*this); } // A global-module-fragment is only permitted within a module unit. bool DiagnosedMissingModuleDeclaration = false; if (!ModuleScopes.empty() && ModuleScopes.back().Module->Kind == Module::GlobalModuleFragment && !ModuleScopes.back().ImplicitGlobalModuleFragment) { Diag(ModuleScopes.back().BeginLoc, diag::err_module_declaration_missing_after_global_module_introducer); DiagnosedMissingModuleDeclaration = true; } if (TUKind == TU_Module) { // If we are building a module interface unit, we need to have seen the // module declaration by now. if (getLangOpts().getCompilingModule() == LangOptions::CMK_ModuleInterface && (ModuleScopes.empty() || !ModuleScopes.back().Module->isModulePurview()) && !DiagnosedMissingModuleDeclaration) { // FIXME: Make a better guess as to where to put the module declaration. Diag(getSourceManager().getLocForStartOfFile( getSourceManager().getMainFileID()), diag::err_module_declaration_missing); } // If we are building a module, resolve all of the exported declarations // now. if (Module *CurrentModule = PP.getCurrentModule()) { ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap(); SmallVector<Module *, 2> Stack; Stack.push_back(CurrentModule); while (!Stack.empty()) { Module *Mod = Stack.pop_back_val(); // Resolve the exported declarations and conflicts. // FIXME: Actually complain, once we figure out how to teach the // diagnostic client to deal with complaints in the module map at this // point. ModMap.resolveExports(Mod, /*Complain=*/false); ModMap.resolveUses(Mod, /*Complain=*/false); ModMap.resolveConflicts(Mod, /*Complain=*/false); // Queue the submodules, so their exports will also be resolved. Stack.append(Mod->submodule_begin(), Mod->submodule_end()); } } // Warnings emitted in ActOnEndOfTranslationUnit() should be emitted for // modules when they are built, not every time they are used. emitAndClearUnusedLocalTypedefWarnings(); } // C99 6.9.2p2: // A declaration of an identifier for an object that has file // scope without an initializer, and without a storage-class // specifier or with the storage-class specifier static, // constitutes a tentative definition. If a translation unit // contains one or more tentative definitions for an identifier, // and the translation unit contains no external definition for // that identifier, then the behavior is exactly as if the // translation unit contains a file scope declaration of that // identifier, with the composite type as of the end of the // translation unit, with an initializer equal to 0. llvm::SmallSet<VarDecl *, 32> Seen; for (TentativeDefinitionsType::iterator T = TentativeDefinitions.begin(ExternalSource), TEnd = TentativeDefinitions.end(); T != TEnd; ++T) { VarDecl *VD = (*T)->getActingDefinition(); // If the tentative definition was completed, getActingDefinition() returns // null. If we've already seen this variable before, insert()'s second // return value is false. if (!VD || VD->isInvalidDecl() || !Seen.insert(VD).second) continue; if (const IncompleteArrayType *ArrayT = Context.getAsIncompleteArrayType(VD->getType())) { // Set the length of the array to 1 (C99 6.9.2p5). Diag(VD->getLocation(), diag::warn_tentative_incomplete_array); llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true); QualType T = Context.getConstantArrayType(ArrayT->getElementType(), One, nullptr, ArrayType::Normal, 0); VD->setType(T); } else if (RequireCompleteType(VD->getLocation(), VD->getType(), diag::err_tentative_def_incomplete_type)) VD->setInvalidDecl(); // No initialization is performed for a tentative definition. CheckCompleteVariableDeclaration(VD); // Notify the consumer that we've completed a tentative definition. if (!VD->isInvalidDecl()) Consumer.CompleteTentativeDefinition(VD); } for (auto D : ExternalDeclarations) { if (!D || D->isInvalidDecl() || D->getPreviousDecl() || !D->isUsed()) continue; Consumer.CompleteExternalDeclaration(D); } // If there were errors, disable 'unused' warnings since they will mostly be // noise. Don't warn for a use from a module: either we should warn on all // file-scope declarations in modules or not at all, but whether the // declaration is used is immaterial. if (!Diags.hasErrorOccurred() && TUKind != TU_Module) { // Output warning for unused file scoped decls. for (UnusedFileScopedDeclsType::iterator I = UnusedFileScopedDecls.begin(ExternalSource), E = UnusedFileScopedDecls.end(); I != E; ++I) { if (ShouldRemoveFromUnused(this, *I)) continue; if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) { const FunctionDecl *DiagD; if (!FD->hasBody(DiagD)) DiagD = FD; if (DiagD->isDeleted()) continue; // Deleted functions are supposed to be unused. if (DiagD->isReferenced()) { if (isa<CXXMethodDecl>(DiagD)) Diag(DiagD->getLocation(), diag::warn_unneeded_member_function) << DiagD; else { if (FD->getStorageClass() == SC_Static && !FD->isInlineSpecified() && !SourceMgr.isInMainFile( SourceMgr.getExpansionLoc(FD->getLocation()))) Diag(DiagD->getLocation(), diag::warn_unneeded_static_internal_decl) << DiagD; else Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl) << /*function*/ 0 << DiagD; } } else { if (FD->getDescribedFunctionTemplate()) Diag(DiagD->getLocation(), diag::warn_unused_template) << /*function*/ 0 << DiagD; else Diag(DiagD->getLocation(), isa<CXXMethodDecl>(DiagD) ? diag::warn_unused_member_function : diag::warn_unused_function) << DiagD; } } else { const VarDecl *DiagD = cast<VarDecl>(*I)->getDefinition(); if (!DiagD) DiagD = cast<VarDecl>(*I); if (DiagD->isReferenced()) { Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl) << /*variable*/ 1 << DiagD; } else if (DiagD->getType().isConstQualified()) { const SourceManager &SM = SourceMgr; if (SM.getMainFileID() != SM.getFileID(DiagD->getLocation()) || !PP.getLangOpts().IsHeaderFile) Diag(DiagD->getLocation(), diag::warn_unused_const_variable) << DiagD; } else { if (DiagD->getDescribedVarTemplate()) Diag(DiagD->getLocation(), diag::warn_unused_template) << /*variable*/ 1 << DiagD; else Diag(DiagD->getLocation(), diag::warn_unused_variable) << DiagD; } } } emitAndClearUnusedLocalTypedefWarnings(); } if (!Diags.isIgnored(diag::warn_unused_private_field, SourceLocation())) { // FIXME: Load additional unused private field candidates from the external // source. RecordCompleteMap RecordsComplete; RecordCompleteMap MNCComplete; for (NamedDeclSetType::iterator I = UnusedPrivateFields.begin(), E = UnusedPrivateFields.end(); I != E; ++I) { const NamedDecl *D = *I; const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D->getDeclContext()); if (RD && !RD->isUnion() && IsRecordFullyDefined(RD, RecordsComplete, MNCComplete)) { Diag(D->getLocation(), diag::warn_unused_private_field) << D->getDeclName(); } } } if (!Diags.isIgnored(diag::warn_mismatched_delete_new, SourceLocation())) { if (ExternalSource) ExternalSource->ReadMismatchingDeleteExpressions(DeleteExprs); for (const auto &DeletedFieldInfo : DeleteExprs) { for (const auto &DeleteExprLoc : DeletedFieldInfo.second) { AnalyzeDeleteExprMismatch(DeletedFieldInfo.first, DeleteExprLoc.first, DeleteExprLoc.second); } } } // Check we've noticed that we're no longer parsing the initializer for every // variable. If we miss cases, then at best we have a performance issue and // at worst a rejects-valid bug. assert(ParsingInitForAutoVars.empty() && "Didn't unmark var as having its initializer parsed"); if (!PP.isIncrementalProcessingEnabled()) TUScope = nullptr; } //===----------------------------------------------------------------------===// // Helper functions. //===----------------------------------------------------------------------===// DeclContext *Sema::getFunctionLevelDeclContext() { DeclContext *DC = CurContext; while (true) { if (isa<BlockDecl>(DC) || isa<EnumDecl>(DC) || isa<CapturedDecl>(DC) || isa<RequiresExprBodyDecl>(DC)) { DC = DC->getParent(); } else if (isa<CXXMethodDecl>(DC) && cast<CXXMethodDecl>(DC)->getOverloadedOperator() == OO_Call && cast<CXXRecordDecl>(DC->getParent())->isLambda()) { DC = DC->getParent()->getParent(); } else break; } return DC; } /// getCurFunctionDecl - If inside of a function body, this returns a pointer /// to the function decl for the function being parsed. If we're currently /// in a 'block', this returns the containing context. FunctionDecl *Sema::getCurFunctionDecl() { DeclContext *DC = getFunctionLevelDeclContext(); return dyn_cast<FunctionDecl>(DC); } ObjCMethodDecl *Sema::getCurMethodDecl() { DeclContext *DC = getFunctionLevelDeclContext(); while (isa<RecordDecl>(DC)) DC = DC->getParent(); return dyn_cast<ObjCMethodDecl>(DC); } NamedDecl *Sema::getCurFunctionOrMethodDecl() { DeclContext *DC = getFunctionLevelDeclContext(); if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC)) return cast<NamedDecl>(DC); return nullptr; } LangAS Sema::getDefaultCXXMethodAddrSpace() const { if (getLangOpts().OpenCL) return getASTContext().getDefaultOpenCLPointeeAddrSpace(); return LangAS::Default; } void Sema::EmitCurrentDiagnostic(unsigned DiagID) { // FIXME: It doesn't make sense to me that DiagID is an incoming argument here // and yet we also use the current diag ID on the DiagnosticsEngine. This has // been made more painfully obvious by the refactor that introduced this // function, but it is possible that the incoming argument can be // eliminated. If it truly cannot be (for example, there is some reentrancy // issue I am not seeing yet), then there should at least be a clarifying // comment somewhere. if (Optional<TemplateDeductionInfo*> Info = isSFINAEContext()) { switch (DiagnosticIDs::getDiagnosticSFINAEResponse( Diags.getCurrentDiagID())) { case DiagnosticIDs::SFINAE_Report: // We'll report the diagnostic below. break; case DiagnosticIDs::SFINAE_SubstitutionFailure: // Count this failure so that we know that template argument deduction // has failed. ++NumSFINAEErrors; // Make a copy of this suppressed diagnostic and store it with the // template-deduction information. if (*Info && !(*Info)->hasSFINAEDiagnostic()) { Diagnostic DiagInfo(&Diags); (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(), PartialDiagnostic(DiagInfo, Context.getDiagAllocator())); } Diags.setLastDiagnosticIgnored(true); Diags.Clear(); return; case DiagnosticIDs::SFINAE_AccessControl: { // Per C++ Core Issue 1170, access control is part of SFINAE. // Additionally, the AccessCheckingSFINAE flag can be used to temporarily // make access control a part of SFINAE for the purposes of checking // type traits. if (!AccessCheckingSFINAE && !getLangOpts().CPlusPlus11) break; SourceLocation Loc = Diags.getCurrentDiagLoc(); // Suppress this diagnostic. ++NumSFINAEErrors; // Make a copy of this suppressed diagnostic and store it with the // template-deduction information. if (*Info && !(*Info)->hasSFINAEDiagnostic()) { Diagnostic DiagInfo(&Diags); (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(), PartialDiagnostic(DiagInfo, Context.getDiagAllocator())); } Diags.setLastDiagnosticIgnored(true); Diags.Clear(); // Now the diagnostic state is clear, produce a C++98 compatibility // warning. Diag(Loc, diag::warn_cxx98_compat_sfinae_access_control); // The last diagnostic which Sema produced was ignored. Suppress any // notes attached to it. Diags.setLastDiagnosticIgnored(true); return; } case DiagnosticIDs::SFINAE_Suppress: // Make a copy of this suppressed diagnostic and store it with the // template-deduction information; if (*Info) { Diagnostic DiagInfo(&Diags); (*Info)->addSuppressedDiagnostic(DiagInfo.getLocation(), PartialDiagnostic(DiagInfo, Context.getDiagAllocator())); } // Suppress this diagnostic. Diags.setLastDiagnosticIgnored(true); Diags.Clear(); return; } } // Copy the diagnostic printing policy over the ASTContext printing policy. // TODO: Stop doing that. See: https://reviews.llvm.org/D45093#1090292 Context.setPrintingPolicy(getPrintingPolicy()); // Emit the diagnostic. if (!Diags.EmitCurrentDiagnostic()) return; // If this is not a note, and we're in a template instantiation // that is different from the last template instantiation where // we emitted an error, print a template instantiation // backtrace. if (!DiagnosticIDs::isBuiltinNote(DiagID)) PrintContextStack(); } Sema::SemaDiagnosticBuilder Sema::Diag(SourceLocation Loc, const PartialDiagnostic &PD, bool DeferHint) { return Diag(Loc, PD.getDiagID(), DeferHint) << PD; } bool Sema::hasUncompilableErrorOccurred() const { if (getDiagnostics().hasUncompilableErrorOccurred()) return true; auto *FD = dyn_cast<FunctionDecl>(CurContext); if (!FD) return false; auto Loc = DeviceDeferredDiags.find(FD); if (Loc == DeviceDeferredDiags.end()) return false; for (auto PDAt : Loc->second) { if (DiagnosticIDs::isDefaultMappingAsError( PDAt.getDiag().second.getDiagID())) return true; } return false; } // Print notes showing how we can reach FD starting from an a priori // known-callable function. static void emitCallStackNotes(Sema &S, FunctionDecl *FD) { auto FnIt = S.DeviceKnownEmittedFns.find(FD); while (FnIt != S.DeviceKnownEmittedFns.end()) { // Respect error limit. if (S.Diags.hasFatalErrorOccurred()) return; DiagnosticBuilder Builder( S.Diags.Report(FnIt->second.Loc, diag::note_called_by)); Builder << FnIt->second.FD; FnIt = S.DeviceKnownEmittedFns.find(FnIt->second.FD); } } namespace { /// Helper class that emits deferred diagnostic messages if an entity directly /// or indirectly using the function that causes the deferred diagnostic /// messages is known to be emitted. /// /// During parsing of AST, certain diagnostic messages are recorded as deferred /// diagnostics since it is unknown whether the functions containing such /// diagnostics will be emitted. A list of potentially emitted functions and /// variables that may potentially trigger emission of functions are also /// recorded. DeferredDiagnosticsEmitter recursively visits used functions /// by each function to emit deferred diagnostics. /// /// During the visit, certain OpenMP directives or initializer of variables /// with certain OpenMP attributes will cause subsequent visiting of any /// functions enter a state which is called OpenMP device context in this /// implementation. The state is exited when the directive or initializer is /// exited. This state can change the emission states of subsequent uses /// of functions. /// /// Conceptually the functions or variables to be visited form a use graph /// where the parent node uses the child node. At any point of the visit, /// the tree nodes traversed from the tree root to the current node form a use /// stack. The emission state of the current node depends on two factors: /// 1. the emission state of the root node /// 2. whether the current node is in OpenMP device context /// If the function is decided to be emitted, its contained deferred diagnostics /// are emitted, together with the information about the use stack. /// class DeferredDiagnosticsEmitter : public UsedDeclVisitor<DeferredDiagnosticsEmitter> { public: typedef UsedDeclVisitor<DeferredDiagnosticsEmitter> Inherited; // Whether the function is already in the current use-path. llvm::SmallPtrSet<CanonicalDeclPtr<Decl>, 4> InUsePath; // The current use-path. llvm::SmallVector<CanonicalDeclPtr<FunctionDecl>, 4> UsePath; // Whether the visiting of the function has been done. Done[0] is for the // case not in OpenMP device context. Done[1] is for the case in OpenMP // device context. We need two sets because diagnostics emission may be // different depending on whether it is in OpenMP device context. llvm::SmallPtrSet<CanonicalDeclPtr<Decl>, 4> DoneMap[2]; // Emission state of the root node of the current use graph. bool ShouldEmitRootNode; Sema::DeviceDiagnosticReason RootReason = Sema::DeviceDiagnosticReason::All; // Current OpenMP device context level. It is initialized to 0 and each // entering of device context increases it by 1 and each exit decreases // it by 1. Non-zero value indicates it is currently in device context. unsigned InOMPDeviceContext; DeferredDiagnosticsEmitter(Sema &S) : Inherited(S), ShouldEmitRootNode(false), InOMPDeviceContext(0) {} bool shouldVisitDiscardedStmt() const { return false; } void VisitOMPTargetDirective(OMPTargetDirective *Node) { ++InOMPDeviceContext; Inherited::VisitOMPTargetDirective(Node); --InOMPDeviceContext; } void visitUsedDecl(SourceLocation Loc, Decl *D) { if (S.LangOpts.SYCLIsDevice && ShouldEmitRootNode) { if (auto *VD = dyn_cast<VarDecl>(D)) { if (!S.checkAllowedSYCLInitializer(VD)) { S.Diag(Loc, diag::err_sycl_restrict) << Sema::KernelConstStaticVariable; return; } } } if (isa<VarDecl>(D)) return; if (auto *FD = dyn_cast<FunctionDecl>(D)) { Sema::DeviceDiagnosticReason SaveReason = RootReason; // Allow switching context from SYCL to ESIMD. Switching back is not // allowed. I.e., once we entered ESIMD code we stay there until we exit // the subgraph. if ((RootReason == Sema::DeviceDiagnosticReason::Sycl) && (S.getEmissionReason(FD) == Sema::DeviceDiagnosticReason::Esimd)) RootReason = Sema::DeviceDiagnosticReason::Esimd; checkFunc(Loc, FD); // Restore the context RootReason = SaveReason; } else { Inherited::visitUsedDecl(Loc, D); } } void checkVar(VarDecl *VD) { assert(VD->isFileVarDecl() && "Should only check file-scope variables"); if (auto *Init = VD->getInit()) { auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD); bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost || *DevTy == OMPDeclareTargetDeclAttr::DT_Any); if (IsDev) ++InOMPDeviceContext; this->Visit(Init); if (IsDev) --InOMPDeviceContext; } } void checkFunc(SourceLocation Loc, FunctionDecl *FD) { auto &Done = DoneMap[InOMPDeviceContext > 0 ? 1 : 0]; FunctionDecl *Caller = UsePath.empty() ? nullptr : UsePath.back(); if ((!ShouldEmitRootNode && !S.getLangOpts().OpenMP && !Caller) || S.shouldIgnoreInHostDeviceCheck(FD) || InUsePath.count(FD)) return; // Finalize analysis of OpenMP-specific constructs. if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1 && (ShouldEmitRootNode || InOMPDeviceContext)) S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc); // Finalize analysis of SYCL-specific constructs. if (Caller && S.LangOpts.SYCLIsDevice) S.finalizeSYCLDelayedAnalysis(Caller, FD, Loc, RootReason); if (Caller) S.DeviceKnownEmittedFns[FD] = {Caller, Loc}; // Always emit deferred diagnostics for the direct users. This does not // lead to explosion of diagnostics since each user is visited at most // twice. if (ShouldEmitRootNode || InOMPDeviceContext) emitDeferredDiags(FD, Caller); // Do not revisit a function if the function body has been completely // visited before. if (!Done.insert(FD).second) return; InUsePath.insert(FD); UsePath.push_back(FD); if (auto *S = FD->getBody()) { this->Visit(S); } UsePath.pop_back(); InUsePath.erase(FD); } void checkRecordedDecl(Decl *D) { if (auto *FD = dyn_cast<FunctionDecl>(D)) { ShouldEmitRootNode = S.getEmissionStatus(FD, /*Final=*/true) == Sema::FunctionEmissionStatus::Emitted; RootReason = S.getEmissionReason(FD); checkFunc(SourceLocation(), FD); } else { // Global VarDecls don't really have a reason, so set this to 'ALL'. RootReason = Sema::DeviceDiagnosticReason::All; checkVar(cast<VarDecl>(D)); } } // Emit any deferred diagnostics for FD void emitDeferredDiags(FunctionDecl *FD, bool ShowCallStack) { auto It = S.DeviceDeferredDiags.find(FD); if (It == S.DeviceDeferredDiags.end()) return; bool HasWarningOrError = false; bool FirstDiag = true; for (Sema::DeviceDeferredDiagnostic &D : It->second) { // Respect error limit. if (S.Diags.hasFatalErrorOccurred()) return; const SourceLocation &Loc = D.getDiag().first; const PartialDiagnostic &PD = D.getDiag().second; Sema::DeviceDiagnosticReason Reason = D.getReason(); HasWarningOrError |= S.getDiagnostics().getDiagnosticLevel(PD.getDiagID(), Loc) >= DiagnosticsEngine::Warning; // If the diagnostic doesn't apply to this call graph, skip this // diagnostic. if ((RootReason & Reason) == Sema::DeviceDiagnosticReason::None) continue; { DiagnosticBuilder Builder(S.Diags.Report(Loc, PD.getDiagID())); PD.Emit(Builder); } // Emit the note on the first diagnostic in case too many diagnostics // cause the note not emitted. if (FirstDiag && HasWarningOrError && ShowCallStack) { emitCallStackNotes(S, FD); FirstDiag = false; } } } }; } // namespace void Sema::emitDeferredDiags() { if (ExternalSource) ExternalSource->ReadDeclsToCheckForDeferredDiags( DeclsToCheckForDeferredDiags); if ((DeviceDeferredDiags.empty() && !LangOpts.OpenMP && !LangOpts.SYCLIsDevice) || DeclsToCheckForDeferredDiags.empty()) return; DeferredDiagnosticsEmitter DDE(*this); for (auto D : DeclsToCheckForDeferredDiags) DDE.checkRecordedDecl(D); } // In CUDA, there are some constructs which may appear in semantically-valid // code, but trigger errors if we ever generate code for the function in which // they appear. Essentially every construct you're not allowed to use on the // device falls into this category, because you are allowed to use these // constructs in a __host__ __device__ function, but only if that function is // never codegen'ed on the device. // // To handle semantic checking for these constructs, we keep track of the set of // functions we know will be emitted, either because we could tell a priori that // they would be emitted, or because they were transitively called by a // known-emitted function. // // We also keep a partial call graph of which not-known-emitted functions call // which other not-known-emitted functions. // // When we see something which is illegal if the current function is emitted // (usually by way of CUDADiagIfDeviceCode, CUDADiagIfHostCode, or // CheckCUDACall), we first check if the current function is known-emitted. If // so, we immediately output the diagnostic. // // Otherwise, we "defer" the diagnostic. It sits in Sema::DeviceDeferredDiags // until we discover that the function is known-emitted, at which point we take // it out of this map and emit the diagnostic. Sema::SemaDiagnosticBuilder::SemaDiagnosticBuilder(Kind K, SourceLocation Loc, unsigned DiagID, FunctionDecl *Fn, Sema &S, DeviceDiagnosticReason R) : S(S), Loc(Loc), DiagID(DiagID), Fn(Fn), ShowCallStack(K == K_ImmediateWithCallStack || K == K_Deferred) { switch (K) { case K_Nop: break; case K_Immediate: case K_ImmediateWithCallStack: ImmediateDiag.emplace( ImmediateDiagBuilder(S.Diags.Report(Loc, DiagID), S, DiagID)); break; case K_Deferred: assert(Fn && "Must have a function to attach the deferred diag to."); auto &Diags = S.DeviceDeferredDiags[Fn]; PartialDiagId.emplace(Diags.size()); Diags.emplace_back(Loc, S.PDiag(DiagID), R); break; } } Sema::SemaDiagnosticBuilder::SemaDiagnosticBuilder(SemaDiagnosticBuilder &&D) : S(D.S), Loc(D.Loc), DiagID(D.DiagID), Fn(D.Fn), ShowCallStack(D.ShowCallStack), ImmediateDiag(D.ImmediateDiag), PartialDiagId(D.PartialDiagId) { // Clean the previous diagnostics. D.ShowCallStack = false; D.ImmediateDiag.reset(); D.PartialDiagId.reset(); } Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() { if (ImmediateDiag) { // Emit our diagnostic and, if it was a warning or error, output a callstack // if Fn isn't a priori known-emitted. bool IsWarningOrError = S.getDiagnostics().getDiagnosticLevel( DiagID, Loc) >= DiagnosticsEngine::Warning; ImmediateDiag.reset(); // Emit the immediate diag. if (IsWarningOrError && ShowCallStack) emitCallStackNotes(S, Fn); } else { assert((!PartialDiagId || ShowCallStack) && "Must always show call stack for deferred diags."); } } Sema::SemaDiagnosticBuilder Sema::targetDiag(SourceLocation Loc, unsigned DiagID, FunctionDecl *FD) { FD = FD ? FD : getCurFunctionDecl(); if (LangOpts.OpenMP) return LangOpts.OpenMPIsDevice ? diagIfOpenMPDeviceCode(Loc, DiagID, FD) : diagIfOpenMPHostCode(Loc, DiagID, FD); if (getLangOpts().CUDA) return getLangOpts().CUDAIsDevice ? CUDADiagIfDeviceCode(Loc, DiagID) : CUDADiagIfHostCode(Loc, DiagID); if (getLangOpts().SYCLIsDevice) return SYCLDiagIfDeviceCode(Loc, DiagID); return SemaDiagnosticBuilder(SemaDiagnosticBuilder::K_Immediate, Loc, DiagID, FD, *this, DeviceDiagnosticReason::All); } Sema::SemaDiagnosticBuilder Sema::Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint) { bool IsError = Diags.getDiagnosticIDs()->isDefaultMappingAsError(DiagID); bool ShouldDefer = getLangOpts().CUDA && LangOpts.GPUDeferDiag && DiagnosticIDs::isDeferrable(DiagID) && (DeferHint || DeferDiags || !IsError); auto SetIsLastErrorImmediate = [&](bool Flag) { if (IsError) IsLastErrorImmediate = Flag; }; if (!ShouldDefer) { SetIsLastErrorImmediate(true); return SemaDiagnosticBuilder(SemaDiagnosticBuilder::K_Immediate, Loc, DiagID, getCurFunctionDecl(), *this, DeviceDiagnosticReason::All); } SemaDiagnosticBuilder DB = getLangOpts().CUDAIsDevice ? CUDADiagIfDeviceCode(Loc, DiagID) : CUDADiagIfHostCode(Loc, DiagID); SetIsLastErrorImmediate(DB.isImmediate()); return DB; } void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) { if (isUnevaluatedContext() || Ty.isNull()) return; Decl *C = cast<Decl>(getCurLexicalContext()); // Memcpy operations for structs containing a member with unsupported type // are ok, though. if (const auto *MD = dyn_cast<CXXMethodDecl>(C)) { if ((MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) && MD->isTrivial()) return; if (const auto *Ctor = dyn_cast<CXXConstructorDecl>(MD)) if (Ctor->isCopyOrMoveConstructor() && Ctor->isTrivial()) return; } // Try to associate errors with the lexical context, if that is a function, or // the value declaration otherwise. FunctionDecl *FD = isa<FunctionDecl>(C) ? cast<FunctionDecl>(C) : dyn_cast_or_null<FunctionDecl>(D); auto CheckDeviceType = [&](QualType Ty) { if (Ty->isDependentType()) return; if (Ty->isBitIntType()) { if (!Context.getTargetInfo().hasBitIntType()) { PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type); if (D) PD << D; else PD << "expression"; targetDiag(Loc, PD, FD) << false /*show bit size*/ << 0 /*bitsize*/ << false /*return*/ << Ty << Context.getTargetInfo().getTriple().str(); } return; } // Check if we are dealing with two 'long double' but with different // semantics. bool LongDoubleMismatched = false; if (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128) { const llvm::fltSemantics &Sem = Context.getFloatTypeSemantics(Ty); if ((&Sem != &llvm::APFloat::PPCDoubleDouble() && !Context.getTargetInfo().hasFloat128Type()) || (&Sem == &llvm::APFloat::PPCDoubleDouble() && !Context.getTargetInfo().hasIbm128Type())) LongDoubleMismatched = true; } if ((Ty->isFloat16Type() && !Context.getTargetInfo().hasFloat16Type()) || ((Ty->isFloat128Type() || (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128)) && !Context.getTargetInfo().hasFloat128Type()) || (Ty->isIbm128Type() && !Context.getTargetInfo().hasIbm128Type()) || (Ty->isIntegerType() && Context.getTypeSize(Ty) == 128 && !Context.getTargetInfo().hasInt128Type()) || LongDoubleMismatched) { PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type); if (D) PD << D; else PD << "expression"; if (targetDiag(Loc, PD, FD) << true /*show bit size*/ << static_cast<unsigned>(Context.getTypeSize(Ty)) << Ty << false /*return*/ << Context.getTargetInfo().getTriple().str()) { if (D) D->setInvalidDecl(); } if (D) targetDiag(D->getLocation(), diag::note_defined_here, FD) << D; } }; auto CheckType = [&](QualType Ty, bool IsRetTy = false) { if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)) CheckDeviceType(Ty); QualType UnqualTy = Ty.getCanonicalType().getUnqualifiedType(); const TargetInfo &TI = Context.getTargetInfo(); if (!TI.hasLongDoubleType() && UnqualTy == Context.LongDoubleTy) { PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type); if (D) PD << D; else PD << "expression"; if (Diag(Loc, PD, FD) << false /*show bit size*/ << 0 << Ty << false /*return*/ << Context.getTargetInfo().getTriple().str()) { if (D) D->setInvalidDecl(); } if (D) targetDiag(D->getLocation(), diag::note_defined_here, FD) << D; } bool IsDouble = UnqualTy == Context.DoubleTy; bool IsFloat = UnqualTy == Context.FloatTy; if (IsRetTy && !TI.hasFPReturn() && (IsDouble || IsFloat)) { PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type); if (D) PD << D; else PD << "expression"; if (Diag(Loc, PD, FD) << false /*show bit size*/ << 0 << Ty << true /*return*/ << Context.getTargetInfo().getTriple().str()) { if (D) D->setInvalidDecl(); } if (D) targetDiag(D->getLocation(), diag::note_defined_here, FD) << D; } }; CheckType(Ty); if (const auto *FPTy = dyn_cast<FunctionProtoType>(Ty)) { for (const auto &ParamTy : FPTy->param_types()) CheckType(ParamTy); CheckType(FPTy->getReturnType(), /*IsRetTy=*/true); } if (const auto *FNPTy = dyn_cast<FunctionNoProtoType>(Ty)) CheckType(FNPTy->getReturnType(), /*IsRetTy=*/true); } /// Looks through the macro-expansion chain for the given /// location, looking for a macro expansion with the given name. /// If one is found, returns true and sets the location to that /// expansion loc. bool Sema::findMacroSpelling(SourceLocation &locref, StringRef name) { SourceLocation loc = locref; if (!loc.isMacroID()) return false; // There's no good way right now to look at the intermediate // expansions, so just jump to the expansion location. loc = getSourceManager().getExpansionLoc(loc); // If that's written with the name, stop here. SmallString<16> buffer; if (getPreprocessor().getSpelling(loc, buffer) == name) { locref = loc; return true; } return false; } /// Determines the active Scope associated with the given declaration /// context. /// /// This routine maps a declaration context to the active Scope object that /// represents that declaration context in the parser. It is typically used /// from "scope-less" code (e.g., template instantiation, lazy creation of /// declarations) that injects a name for name-lookup purposes and, therefore, /// must update the Scope. /// /// \returns The scope corresponding to the given declaraion context, or NULL /// if no such scope is open. Scope *Sema::getScopeForContext(DeclContext *Ctx) { if (!Ctx) return nullptr; Ctx = Ctx->getPrimaryContext(); for (Scope *S = getCurScope(); S; S = S->getParent()) { // Ignore scopes that cannot have declarations. This is important for // out-of-line definitions of static class members. if (S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope)) if (DeclContext *Entity = S->getEntity()) if (Ctx == Entity->getPrimaryContext()) return S; } return nullptr; } /// Enter a new function scope void Sema::PushFunctionScope() { if (FunctionScopes.empty() && CachedFunctionScope) { // Use CachedFunctionScope to avoid allocating memory when possible. CachedFunctionScope->Clear(); FunctionScopes.push_back(CachedFunctionScope.release()); } else { FunctionScopes.push_back(new FunctionScopeInfo(getDiagnostics())); } if (LangOpts.OpenMP) pushOpenMPFunctionRegion(); } void Sema::PushBlockScope(Scope *BlockScope, BlockDecl *Block) { FunctionScopes.push_back(new BlockScopeInfo(getDiagnostics(), BlockScope, Block)); } LambdaScopeInfo *Sema::PushLambdaScope() { LambdaScopeInfo *const LSI = new LambdaScopeInfo(getDiagnostics()); FunctionScopes.push_back(LSI); return LSI; } void Sema::RecordParsingTemplateParameterDepth(unsigned Depth) { if (LambdaScopeInfo *const LSI = getCurLambda()) { LSI->AutoTemplateParameterDepth = Depth; return; } llvm_unreachable( "Remove assertion if intentionally called in a non-lambda context."); } // Check that the type of the VarDecl has an accessible copy constructor and // resolve its destructor's exception specification. // This also performs initialization of block variables when they are moved // to the heap. It uses the same rules as applicable for implicit moves // according to the C++ standard in effect ([class.copy.elision]p3). static void checkEscapingByref(VarDecl *VD, Sema &S) { QualType T = VD->getType(); EnterExpressionEvaluationContext scope( S, Sema::ExpressionEvaluationContext::PotentiallyEvaluated); SourceLocation Loc = VD->getLocation(); Expr *VarRef = new (S.Context) DeclRefExpr(S.Context, VD, false, T, VK_LValue, Loc); ExprResult Result; auto IE = InitializedEntity::InitializeBlock(Loc, T); if (S.getLangOpts().CPlusPlus2b) { auto *E = ImplicitCastExpr::Create(S.Context, T, CK_NoOp, VarRef, nullptr, VK_XValue, FPOptionsOverride()); Result = S.PerformCopyInitialization(IE, SourceLocation(), E); } else { Result = S.PerformMoveOrCopyInitialization( IE, Sema::NamedReturnInfo{VD, Sema::NamedReturnInfo::MoveEligible}, VarRef); } if (!Result.isInvalid()) { Result = S.MaybeCreateExprWithCleanups(Result); Expr *Init = Result.getAs<Expr>(); S.Context.setBlockVarCopyInit(VD, Init, S.canThrow(Init)); } // The destructor's exception specification is needed when IRGen generates // block copy/destroy functions. Resolve it here. if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl()) if (CXXDestructorDecl *DD = RD->getDestructor()) { auto *FPT = DD->getType()->getAs<FunctionProtoType>(); S.ResolveExceptionSpec(Loc, FPT); } } static void markEscapingByrefs(const FunctionScopeInfo &FSI, Sema &S) { // Set the EscapingByref flag of __block variables captured by // escaping blocks. for (const BlockDecl *BD : FSI.Blocks) { for (const BlockDecl::Capture &BC : BD->captures()) { VarDecl *VD = BC.getVariable(); if (VD->hasAttr<BlocksAttr>()) { // Nothing to do if this is a __block variable captured by a // non-escaping block. if (BD->doesNotEscape()) continue; VD->setEscapingByref(); } // Check whether the captured variable is or contains an object of // non-trivial C union type. QualType CapType = BC.getVariable()->getType(); if (CapType.hasNonTrivialToPrimitiveDestructCUnion() || CapType.hasNonTrivialToPrimitiveCopyCUnion()) S.checkNonTrivialCUnion(BC.getVariable()->getType(), BD->getCaretLocation(), Sema::NTCUC_BlockCapture, Sema::NTCUK_Destruct|Sema::NTCUK_Copy); } } for (VarDecl *VD : FSI.ByrefBlockVars) { // __block variables might require us to capture a copy-initializer. if (!VD->isEscapingByref()) continue; // It's currently invalid to ever have a __block variable with an // array type; should we diagnose that here? // Regardless, we don't want to ignore array nesting when // constructing this copy. if (VD->getType()->isStructureOrClassType()) checkEscapingByref(VD, S); } } /// Pop a function (or block or lambda or captured region) scope from the stack. /// /// \param WP The warning policy to use for CFG-based warnings, or null if such /// warnings should not be produced. /// \param D The declaration corresponding to this function scope, if producing /// CFG-based warnings. /// \param BlockType The type of the block expression, if D is a BlockDecl. Sema::PoppedFunctionScopePtr Sema::PopFunctionScopeInfo(const AnalysisBasedWarnings::Policy *WP, const Decl *D, QualType BlockType) { assert(!FunctionScopes.empty() && "mismatched push/pop!"); markEscapingByrefs(*FunctionScopes.back(), *this); PoppedFunctionScopePtr Scope(FunctionScopes.pop_back_val(), PoppedFunctionScopeDeleter(this)); if (LangOpts.OpenMP) popOpenMPFunctionRegion(Scope.get()); // Issue any analysis-based warnings. if (WP && D) AnalysisWarnings.IssueWarnings(*WP, Scope.get(), D, BlockType); else for (const auto &PUD : Scope->PossiblyUnreachableDiags) Diag(PUD.Loc, PUD.PD); return Scope; } void Sema::PoppedFunctionScopeDeleter:: operator()(sema::FunctionScopeInfo *Scope) const { // Stash the function scope for later reuse if it's for a normal function. if (Scope->isPlainFunction() && !Self->CachedFunctionScope) Self->CachedFunctionScope.reset(Scope); else delete Scope; } void Sema::PushCompoundScope(bool IsStmtExpr) { getCurFunction()->CompoundScopes.push_back(CompoundScopeInfo(IsStmtExpr)); } void Sema::PopCompoundScope() { FunctionScopeInfo *CurFunction = getCurFunction(); assert(!CurFunction->CompoundScopes.empty() && "mismatched push/pop"); CurFunction->CompoundScopes.pop_back(); } /// Determine whether any errors occurred within this function/method/ /// block. bool Sema::hasAnyUnrecoverableErrorsInThisFunction() const { return getCurFunction()->hasUnrecoverableErrorOccurred(); } void Sema::setFunctionHasBranchIntoScope() { if (!FunctionScopes.empty()) FunctionScopes.back()->setHasBranchIntoScope(); } void Sema::setFunctionHasBranchProtectedScope() { if (!FunctionScopes.empty()) FunctionScopes.back()->setHasBranchProtectedScope(); } void Sema::setFunctionHasIndirectGoto() { if (!FunctionScopes.empty()) FunctionScopes.back()->setHasIndirectGoto(); } void Sema::setFunctionHasMustTail() { if (!FunctionScopes.empty()) FunctionScopes.back()->setHasMustTail(); } BlockScopeInfo *Sema::getCurBlock() { if (FunctionScopes.empty()) return nullptr; auto CurBSI = dyn_cast<BlockScopeInfo>(FunctionScopes.back()); if (CurBSI && CurBSI->TheDecl && !CurBSI->TheDecl->Encloses(CurContext)) { // We have switched contexts due to template instantiation. assert(!CodeSynthesisContexts.empty()); return nullptr; } return CurBSI; } FunctionScopeInfo *Sema::getEnclosingFunction() const { if (FunctionScopes.empty()) return nullptr; for (int e = FunctionScopes.size() - 1; e >= 0; --e) { if (isa<sema::BlockScopeInfo>(FunctionScopes[e])) continue; return FunctionScopes[e]; } return nullptr; } LambdaScopeInfo *Sema::getEnclosingLambda() const { for (auto *Scope : llvm::reverse(FunctionScopes)) { if (auto *LSI = dyn_cast<sema::LambdaScopeInfo>(Scope)) { if (LSI->Lambda && !LSI->Lambda->Encloses(CurContext)) { // We have switched contexts due to template instantiation. // FIXME: We should swap out the FunctionScopes during code synthesis // so that we don't need to check for this. assert(!CodeSynthesisContexts.empty()); return nullptr; } return LSI; } } return nullptr; } LambdaScopeInfo *Sema::getCurLambda(bool IgnoreNonLambdaCapturingScope) { if (FunctionScopes.empty()) return nullptr; auto I = FunctionScopes.rbegin(); if (IgnoreNonLambdaCapturingScope) { auto E = FunctionScopes.rend(); while (I != E && isa<CapturingScopeInfo>(*I) && !isa<LambdaScopeInfo>(*I)) ++I; if (I == E) return nullptr; } auto *CurLSI = dyn_cast<LambdaScopeInfo>(*I); if (CurLSI && CurLSI->Lambda && !CurLSI->Lambda->Encloses(CurContext)) { // We have switched contexts due to template instantiation. assert(!CodeSynthesisContexts.empty()); return nullptr; } return CurLSI; } // We have a generic lambda if we parsed auto parameters, or we have // an associated template parameter list. LambdaScopeInfo *Sema::getCurGenericLambda() { if (LambdaScopeInfo *LSI = getCurLambda()) { return (LSI->TemplateParams.size() || LSI->GLTemplateParameterList) ? LSI : nullptr; } return nullptr; } void Sema::ActOnComment(SourceRange Comment) { if (!LangOpts.RetainCommentsFromSystemHeaders && SourceMgr.isInSystemHeader(Comment.getBegin())) return; RawComment RC(SourceMgr, Comment, LangOpts.CommentOpts, false); if (RC.isAlmostTrailingComment()) { SourceRange MagicMarkerRange(Comment.getBegin(), Comment.getBegin().getLocWithOffset(3)); StringRef MagicMarkerText; switch (RC.getKind()) { case RawComment::RCK_OrdinaryBCPL: MagicMarkerText = "///<"; break; case RawComment::RCK_OrdinaryC: MagicMarkerText = "/**<"; break; default: llvm_unreachable("if this is an almost Doxygen comment, " "it should be ordinary"); } Diag(Comment.getBegin(), diag::warn_not_a_doxygen_trailing_member_comment) << FixItHint::CreateReplacement(MagicMarkerRange, MagicMarkerText); } Context.addComment(RC); } // Pin this vtable to this file. ExternalSemaSource::~ExternalSemaSource() {} char ExternalSemaSource::ID; void ExternalSemaSource::ReadMethodPool(Selector Sel) { } void ExternalSemaSource::updateOutOfDateSelector(Selector Sel) { } void ExternalSemaSource::ReadKnownNamespaces( SmallVectorImpl<NamespaceDecl *> &Namespaces) { } void ExternalSemaSource::ReadUndefinedButUsed( llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {} void ExternalSemaSource::ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &) {} /// Figure out if an expression could be turned into a call. /// /// Use this when trying to recover from an error where the programmer may have /// written just the name of a function instead of actually calling it. /// /// \param E - The expression to examine. /// \param ZeroArgCallReturnTy - If the expression can be turned into a call /// with no arguments, this parameter is set to the type returned by such a /// call; otherwise, it is set to an empty QualType. /// \param OverloadSet - If the expression is an overloaded function /// name, this parameter is populated with the decls of the various overloads. bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &OverloadSet) { ZeroArgCallReturnTy = QualType(); OverloadSet.clear(); const OverloadExpr *Overloads = nullptr; bool IsMemExpr = false; if (E.getType() == Context.OverloadTy) { OverloadExpr::FindResult FR = OverloadExpr::find(const_cast<Expr*>(&E)); // Ignore overloads that are pointer-to-member constants. if (FR.HasFormOfMemberPointer) return false; Overloads = FR.Expression; } else if (E.getType() == Context.BoundMemberTy) { Overloads = dyn_cast<UnresolvedMemberExpr>(E.IgnoreParens()); IsMemExpr = true; } bool Ambiguous = false; bool IsMV = false; if (Overloads) { for (OverloadExpr::decls_iterator it = Overloads->decls_begin(), DeclsEnd = Overloads->decls_end(); it != DeclsEnd; ++it) { OverloadSet.addDecl(*it); // Check whether the function is a non-template, non-member which takes no // arguments. if (IsMemExpr) continue; if (const FunctionDecl *OverloadDecl = dyn_cast<FunctionDecl>((*it)->getUnderlyingDecl())) { if (OverloadDecl->getMinRequiredArguments() == 0) { if (!ZeroArgCallReturnTy.isNull() && !Ambiguous && (!IsMV || !(OverloadDecl->isCPUDispatchMultiVersion() || OverloadDecl->isCPUSpecificMultiVersion()))) { ZeroArgCallReturnTy = QualType(); Ambiguous = true; } else { ZeroArgCallReturnTy = OverloadDecl->getReturnType(); IsMV = OverloadDecl->isCPUDispatchMultiVersion() || OverloadDecl->isCPUSpecificMultiVersion(); } } } } // If it's not a member, use better machinery to try to resolve the call if (!IsMemExpr) return !ZeroArgCallReturnTy.isNull(); } // Attempt to call the member with no arguments - this will correctly handle // member templates with defaults/deduction of template arguments, overloads // with default arguments, etc. if (IsMemExpr && !E.isTypeDependent()) { Sema::TentativeAnalysisScope Trap(*this); ExprResult R = BuildCallToMemberFunction(nullptr, &E, SourceLocation(), None, SourceLocation()); if (R.isUsable()) { ZeroArgCallReturnTy = R.get()->getType(); return true; } return false; } if (const DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E.IgnoreParens())) { if (const FunctionDecl *Fun = dyn_cast<FunctionDecl>(DeclRef->getDecl())) { if (Fun->getMinRequiredArguments() == 0) ZeroArgCallReturnTy = Fun->getReturnType(); return true; } } // We don't have an expression that's convenient to get a FunctionDecl from, // but we can at least check if the type is "function of 0 arguments". QualType ExprTy = E.getType(); const FunctionType *FunTy = nullptr; QualType PointeeTy = ExprTy->getPointeeType(); if (!PointeeTy.isNull()) FunTy = PointeeTy->getAs<FunctionType>(); if (!FunTy) FunTy = ExprTy->getAs<FunctionType>(); if (const FunctionProtoType *FPT = dyn_cast_or_null<FunctionProtoType>(FunTy)) { if (FPT->getNumParams() == 0) ZeroArgCallReturnTy = FunTy->getReturnType(); return true; } return false; } /// Give notes for a set of overloads. /// /// A companion to tryExprAsCall. In cases when the name that the programmer /// wrote was an overloaded function, we may be able to make some guesses about /// plausible overloads based on their return types; such guesses can be handed /// off to this method to be emitted as notes. /// /// \param Overloads - The overloads to note. /// \param FinalNoteLoc - If we've suppressed printing some overloads due to /// -fshow-overloads=best, this is the location to attach to the note about too /// many candidates. Typically this will be the location of the original /// ill-formed expression. static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads, const SourceLocation FinalNoteLoc) { unsigned ShownOverloads = 0; unsigned SuppressedOverloads = 0; for (UnresolvedSetImpl::iterator It = Overloads.begin(), DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) { if (ShownOverloads >= S.Diags.getNumOverloadCandidatesToShow()) { ++SuppressedOverloads; continue; } NamedDecl *Fn = (*It)->getUnderlyingDecl(); // Don't print overloads for non-default multiversioned functions. if (const auto *FD = Fn->getAsFunction()) { if (FD->isMultiVersion() && FD->hasAttr<TargetAttr>() && !FD->getAttr<TargetAttr>()->isDefaultVersion()) continue; } S.Diag(Fn->getLocation(), diag::note_possible_target_of_call); ++ShownOverloads; } S.Diags.overloadCandidatesShown(ShownOverloads); if (SuppressedOverloads) S.Diag(FinalNoteLoc, diag::note_ovl_too_many_candidates) << SuppressedOverloads; } static void notePlausibleOverloads(Sema &S, SourceLocation Loc, const UnresolvedSetImpl &Overloads, bool (*IsPlausibleResult)(QualType)) { if (!IsPlausibleResult) return noteOverloads(S, Overloads, Loc); UnresolvedSet<2> PlausibleOverloads; for (OverloadExpr::decls_iterator It = Overloads.begin(), DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) { const FunctionDecl *OverloadDecl = cast<FunctionDecl>(*It); QualType OverloadResultTy = OverloadDecl->getReturnType(); if (IsPlausibleResult(OverloadResultTy)) PlausibleOverloads.addDecl(It.getDecl()); } noteOverloads(S, PlausibleOverloads, Loc); } /// Determine whether the given expression can be called by just /// putting parentheses after it. Notably, expressions with unary /// operators can't be because the unary operator will start parsing /// outside the call. static bool IsCallableWithAppend(Expr *E) { E = E->IgnoreImplicit(); return (!isa<CStyleCastExpr>(E) && !isa<UnaryOperator>(E) && !isa<BinaryOperator>(E) && !isa<CXXOperatorCallExpr>(E)); } static bool IsCPUDispatchCPUSpecificMultiVersion(const Expr *E) { if (const auto *UO = dyn_cast<UnaryOperator>(E)) E = UO->getSubExpr(); if (const auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) { if (ULE->getNumDecls() == 0) return false; const NamedDecl *ND = *ULE->decls_begin(); if (const auto *FD = dyn_cast<FunctionDecl>(ND)) return FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion(); } return false; } bool Sema::tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain, bool (*IsPlausibleResult)(QualType)) { SourceLocation Loc = E.get()->getExprLoc(); SourceRange Range = E.get()->getSourceRange(); QualType ZeroArgCallTy; UnresolvedSet<4> Overloads; if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) && !ZeroArgCallTy.isNull() && (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) { // At this point, we know E is potentially callable with 0 // arguments and that it returns something of a reasonable type, // so we can emit a fixit and carry on pretending that E was // actually a CallExpr. SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd()); bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get()); Diag(Loc, PD) << /*zero-arg*/ 1 << IsMV << Range << (IsCallableWithAppend(E.get()) ? FixItHint::CreateInsertion(ParenInsertionLoc, "()") : FixItHint()); if (!IsMV) notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult); // FIXME: Try this before emitting the fixit, and suppress diagnostics // while doing so. E = BuildCallExpr(nullptr, E.get(), Range.getEnd(), None, Range.getEnd().getLocWithOffset(1)); return true; } if (!ForceComplain) return false; bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get()); Diag(Loc, PD) << /*not zero-arg*/ 0 << IsMV << Range; if (!IsMV) notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult); E = ExprError(); return true; } IdentifierInfo *Sema::getSuperIdentifier() const { if (!Ident_super) Ident_super = &Context.Idents.get("super"); return Ident_super; } IdentifierInfo *Sema::getFloat128Identifier() const { if (!Ident___float128) Ident___float128 = &Context.Idents.get("__float128"); return Ident___float128; } void Sema::PushCapturedRegionScope(Scope *S, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel) { auto *CSI = new CapturedRegionScopeInfo( getDiagnostics(), S, CD, RD, CD->getContextParam(), K, (getLangOpts().OpenMP && K == CR_OpenMP) ? getOpenMPNestingLevel() : 0, OpenMPCaptureLevel); CSI->ReturnType = Context.VoidTy; FunctionScopes.push_back(CSI); } CapturedRegionScopeInfo *Sema::getCurCapturedRegion() { if (FunctionScopes.empty()) return nullptr; return dyn_cast<CapturedRegionScopeInfo>(FunctionScopes.back()); } const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> & Sema::getMismatchingDeleteExpressions() const { return DeleteExprs; }
; ------------------------------------------------------------------ ; Geography-based hangman game for MikeOS ; ; At the end of this file you'll see a list of 256 cities (in ; lower-case to make the game code simpler). We get one city at ; random from the list and store it in a string. ; ; Next, we create another string of the same size, but with underscore ; characters instead of the real ones. We display this 'work' string to ; the player, who tries to guess characters. If s/he gets a char right, ; it is revealed in the work string. ; ; If s/he gets gets a char wrong, we add it to a list of misses, and ; draw more of the hanging man. Poor bloke. ; ------------------------------------------------------------------ BITS 16 %INCLUDE "mikedev.inc" ORG 32768 start: call os_hide_cursor ; First, reset values in case user is playing multiple games mov di, real_string ; Full city name mov al, 0 mov cx, 50 rep stosb mov di, work_string ; String that starts as '_' characters mov al, 0 mov cx, 50 rep stosb mov di, tried_chars ; Chars the user has tried, but aren't in the real string mov al, 0 mov cx, 255 rep stosb mov byte [tried_chars_pos], 0 mov byte [misses], 1 ; First miss is to show the platform mov ax, title_msg ; Set up the screen mov bx, footer_msg mov cx, 01100000b call os_draw_background mov ax, 0 mov bx, 255 call os_get_random ; Get a random number mov bl, cl ; Store in BL mov si, cities ; Skip number of lines stored in BL skip_loop: cmp bl, 0 je skip_finished dec bl .inner: lodsb ; Find a zero to denote end of line cmp al, 0 jne .inner jmp skip_loop skip_finished: mov di, real_string ; Store the string from the city list call os_string_copy mov ax, si call os_string_length mov dx, ax ; DX = number of '_' characters to show call add_underscores cmp dx, 5 ; Give first char if it's a short string ja no_hint mov ax, hint_msg_1 ; Tell player about the hint mov bx, hint_msg_2 mov cx, 0 mov dx, 0 call os_dialog_box call os_hide_cursor mov ax, title_msg ; Redraw screen mov bx, footer_msg mov cx, 01100000b call os_draw_background mov byte al, [real_string] ; Copy first letter over mov byte [work_string], al no_hint: call fix_spaces ; Add spaces to working string if necessary main_loop: call show_tried_chars ; Update screen areas call show_hangman call show_main_box cmp byte [misses], 11 ; See if the player has lost je lost_game call os_wait_for_key ; Get input cmp al, KEY_ESC je finish cmp al, 122 ; Work with just "a" to "z" keys ja main_loop cmp al, 97 jb main_loop mov bl, al ; Store character temporarily mov cx, 0 ; Counter into string mov dl, 0 ; Flag whether char was found mov si, real_string find_loop: lodsb cmp al, 0 ; End of string? je done_find cmp al, bl ; Find char entered in string je found_char inc cx ; Move on to next character jmp find_loop found_char: inc dl ; Note that at least one char match was found mov di, work_string add di, cx ; Update our underscore string with char found mov byte [di], bl inc cx jmp find_loop done_find: mov si, real_string ; If the strings match, the player has won! mov di, work_string call os_string_compare jc won_game cmp dl, 0 ; If char was found, skip next bit jne main_loop call update_tried_chars ; Otherwise add char to list of misses jmp main_loop won_game: call show_win_msg .loop: call os_wait_for_key ; Wait for keypress cmp al, KEY_ESC je finish cmp al, KEY_ENTER jne .loop jmp start lost_game: ; After too many misses... call show_lose_msg .loop: ; Wait for keypress call os_wait_for_key cmp al, KEY_ESC je finish cmp al, KEY_ENTER jne .loop jmp start finish: call os_show_cursor call os_clear_screen ret add_underscores: ; Create string of underscores mov di, work_string mov al, '_' mov cx, dx ; Size of string rep stosb ret ; Copy any spaces from the real string into the work string fix_spaces: mov si, real_string mov di, work_string .loop: lodsb cmp al, 0 je .done cmp al, ' ' jne .no_space mov byte [di], ' ' .no_space: inc di jmp .loop .done: ret ; Here we check the list of wrong chars that the player entered previously, ; and see if the latest addition is already in there... update_tried_chars: mov si, tried_chars mov al, bl call os_find_char_in_string cmp ax, 0 jne .nothing_to_add ; Skip next bit if char was already in list mov si, tried_chars mov ax, 0 mov byte al, [tried_chars_pos] ; Move into the list add si, ax mov byte [si], bl inc byte [tried_chars_pos] inc byte [misses] ; Knock up the score .nothing_to_add: ret show_main_box: pusha mov bl, BLACK_ON_WHITE mov dh, 5 mov dl, 2 mov si, 36 mov di, 21 call os_draw_block mov dh, 7 mov dl, 4 call os_move_cursor mov si, help_msg_1 call os_print_string mov dh, 8 mov dl, 4 call os_move_cursor mov si, help_msg_2 call os_print_string mov dh, 17 mov dl, 4 call os_move_cursor mov si, help_msg_3 call os_print_string mov dh, 18 mov dl, 4 call os_move_cursor mov si, help_msg_4 call os_print_string mov dh, 12 mov dl, 6 call os_move_cursor mov si, work_string call os_print_string popa ret show_tried_chars: pusha mov bl, BLACK_ON_WHITE mov dh, 18 mov dl, 40 mov si, 39 mov di, 23 call os_draw_block mov dh, 19 mov dl, 41 call os_move_cursor mov si, tried_chars_msg call os_print_string mov dh, 21 mov dl, 41 call os_move_cursor mov si, tried_chars call os_print_string popa ret show_win_msg: mov bl, WHITE_ON_GREEN mov dh, 14 mov dl, 5 mov si, 30 mov di, 15 call os_draw_block mov dh, 14 mov dl, 6 call os_move_cursor mov si, .win_msg call os_print_string mov dh, 12 mov dl, 6 call os_move_cursor mov si, real_string call os_print_string ret .win_msg db 'Yay! Hit enter to play again', 0 show_lose_msg: mov bl, WHITE_ON_LIGHT_RED mov dh, 14 mov dl, 5 mov si, 30 mov di, 15 call os_draw_block mov dh, 14 mov dl, 6 call os_move_cursor mov si, .lose_msg call os_print_string mov dh, 12 mov dl, 6 call os_move_cursor mov si, real_string call os_print_string ret .lose_msg db 'Doh! Hit enter to play again', 0 ; Draw the hangman box and appropriate bits depending on the number of misses show_hangman: pusha mov bl, BLACK_ON_WHITE mov dh, 2 mov dl, 42 mov si, 35 mov di, 17 call os_draw_block cmp byte [misses], 0 je near .0 cmp byte [misses], 1 je near .1 cmp byte [misses], 2 je near .2 cmp byte [misses], 3 je near .3 cmp byte [misses], 4 je near .4 cmp byte [misses], 5 je near .5 cmp byte [misses], 6 je near .6 cmp byte [misses], 7 je near .7 cmp byte [misses], 8 je near .8 cmp byte [misses], 9 je near .9 cmp byte [misses], 10 je near .10 cmp byte [misses], 11 je near .11 .11: ; Right leg mov dh, 10 mov dl, 64 call os_move_cursor mov si, .11_t call os_print_string .10: ; Left leg mov dh, 10 mov dl, 62 call os_move_cursor mov si, .10_t call os_print_string .9: ; Torso mov dh, 9 mov dl, 63 call os_move_cursor mov si, .9_t call os_print_string .8: ; Arms mov dh, 8 mov dl, 62 call os_move_cursor mov si, .8_t call os_print_string .7: ; Head mov dh, 7 mov dl, 63 call os_move_cursor mov si, .7_t call os_print_string .6: ; Rope mov dh, 6 mov dl, 63 call os_move_cursor mov si, .6_t call os_print_string .5: ; Beam mov dh, 5 mov dl, 56 call os_move_cursor mov si, .5_t call os_print_string .4: ; Support for beam mov dh, 6 mov dl, 57 call os_move_cursor mov si, .4_t call os_print_string .3: ; Pole mov dh, 12 mov dl, 56 call os_move_cursor mov si, .3_t call os_print_string mov dh, 11 mov dl, 56 call os_move_cursor call os_print_string mov dh, 10 mov dl, 56 call os_move_cursor call os_print_string mov dh, 9 mov dl, 56 call os_move_cursor call os_print_string mov dh, 8 mov dl, 56 call os_move_cursor call os_print_string mov dh, 7 mov dl, 56 call os_move_cursor call os_print_string mov dh, 6 mov dl, 56 call os_move_cursor call os_print_string .2: ; Support for pole mov dh, 13 mov dl, 55 call os_move_cursor mov si, .2_t call os_print_string .1: ; Ground mov dh, 14 mov dl, 53 call os_move_cursor mov si, .1_t call os_print_string .0: popa ret .1_t db '-------------', 0 .2_t db '/|\', 0 .3_t db '|', 0 .4_t db '/', 0 .5_t db '________', 0 .6_t db '|', 0 .7_t db 'O', 0 .8_t db '---', 0 .9_t db '|', 0 .10_t db '/', 0 .11_t db '\', 0 title_msg db 'MikeOS Hangman', 0 footer_msg db 'Press Esc to exit', 0 hint_msg_1 db 'Short word this time, so you', 0 hint_msg_2 db 'get the first letter for free!', 0 help_msg_1 db 'Can you guess the city name', 0 help_msg_2 db 'that fits the spaces beneath?', 0 help_msg_3 db 'Press keys to guess letters,', 0 help_msg_4 db 'but you only have 10 chances!', 0 real_string times 50 db 0 work_string times 50 db 0 tried_chars_msg db 'Tried characters...', 0 tried_chars_pos db 0 tried_chars times 255 db 0 misses db 1 cities: db 'kabul', 0 db 'tirane', 0 db 'algiers', 0 db 'andorra la vella', 0 db 'luanda', 0 db 'saint johns', 0 db 'buenos aires', 0 db 'yerevan', 0 db 'canberra', 0 db 'adelaide', 0 db 'melbourne', 0 db 'vienna', 0 db 'baku', 0 db 'nassau', 0 db 'manama', 0 db 'dhaka', 0 db 'bridgetown', 0 db 'minsk', 0 db 'brussels', 0 db 'belmopan', 0 db 'porto novo', 0 db 'thimpu', 0 db 'sucre', 0 db 'sarajevo', 0 db 'gaborone', 0 db 'brasilia', 0 db 'bandar seri begawan', 0 db 'sofia', 0 db 'ouagadougou', 0 db 'bujumbura', 0 db 'phnom penh', 0 db 'yaounde', 0 db 'ottawa', 0 db 'praia', 0 db 'bangui', 0 db 'ndjamema', 0 db 'santiago', 0 db 'beijing', 0 db 'bogota', 0 db 'moroni', 0 db 'brazzaville', 0 db 'kinshasa', 0 db 'san jose', 0 db 'yamoussoukro', 0 db 'zagreb', 0 db 'havana', 0 db 'nicosia', 0 db 'prague', 0 db 'copenhagen', 0 db 'djibouti', 0 db 'roseau', 0 db 'santo domingo', 0 db 'dili', 0 db 'quito', 0 db 'cairo', 0 db 'san salvador', 0 db 'malabo', 0 db 'asmara', 0 db 'tallinn', 0 db 'addis ababa', 0 db 'suva', 0 db 'helsinki', 0 db 'paris', 0 db 'libreville', 0 db 'banjul', 0 db 'tbilisi', 0 db 'berlin', 0 db 'accra', 0 db 'athens', 0 db 'saint georges', 0 db 'guatemala city', 0 db 'conakry', 0 db 'bissau', 0 db 'georgetown', 0 db 'port au prince', 0 db 'tegucigalpa', 0 db 'budapest', 0 db 'reykjavik', 0 db 'new delhi', 0 db 'jakarta', 0 db 'baghdad', 0 db 'dublin', 0 db 'jerusalem', 0 db 'rome', 0 db 'kingston', 0 db 'tokyo', 0 db 'amman', 0 db 'astana', 0 db 'nairobi', 0 db 'tarawa atoll', 0 db 'pyongyang', 0 db 'seoul', 0 db 'pristina', 0 db 'kuwait city', 0 db 'bishkek', 0 db 'vientiane', 0 db 'riga', 0 db 'beirut', 0 db 'maseru', 0 db 'monrovia', 0 db 'tripoli', 0 db 'vaduz', 0 db 'vilnius', 0 db 'luxembourg', 0 db 'skopje', 0 db 'antananarivo', 0 db 'lilongwe', 0 db 'kuala lumpur', 0 db 'male', 0 db 'bamako', 0 db 'valletta', 0 db 'majuro', 0 db 'nouakchott', 0 db 'port louis', 0 db 'mexico city', 0 db 'palikir', 0 db 'chisinau', 0 db 'monaco', 0 db 'ulaanbaatar', 0 db 'podgorica', 0 db 'rabat', 0 db 'maputo', 0 db 'rangoon', 0 db 'windhoek', 0 db 'yaren district', 0 db 'kathmandu', 0 db 'amsterdam', 0 db 'the hague', 0 db 'wellington', 0 db 'managua', 0 db 'niamey', 0 db 'abuja', 0 db 'lagos', 0 db 'oslo', 0 db 'bergen', 0 db 'stavanger', 0 db 'muscat', 0 db 'islamabad', 0 db 'karachi', 0 db 'melekeok', 0 db 'panama city', 0 db 'port moresby', 0 db 'asuncion', 0 db 'lima', 0 db 'manila', 0 db 'warsaw', 0 db 'lisbon', 0 db 'doha', 0 db 'bucharest', 0 db 'moscow', 0 db 'kigali', 0 db 'basseterre', 0 db 'castries', 0 db 'kingstown', 0 db 'apia', 0 db 'san marino', 0 db 'sao tome', 0 db 'riyadh', 0 db 'dakar', 0 db 'belgrade', 0 db 'victoria', 0 db 'freetown', 0 db 'singapore', 0 db 'bratislava', 0 db 'ljubljana', 0 db 'honiara', 0 db 'mogadishu', 0 db 'pretoria', 0 db 'bloemfontein', 0 db 'madrid', 0 db 'colombo', 0 db 'khartoum', 0 db 'paramaribo', 0 db 'mbabane', 0 db 'stockholm', 0 db 'bern', 0 db 'geneva', 0 db 'zurich', 0 db 'damascus', 0 db 'taipei', 0 db 'dushanbe', 0 db 'dar es salaam', 0 db 'bangkok', 0 db 'lome', 0 db 'nukualofa', 0 db 'port of spain', 0 db 'tunis', 0 db 'ankara', 0 db 'ashgabat', 0 db 'funafuti', 0 db 'kampala', 0 db 'kiev', 0 db 'abu dhabi', 0 db 'dubai', 0 db 'london', 0 db 'washington', 0 db 'montevideo', 0 db 'tashkent', 0 db 'port vila', 0 db 'vatican city', 0 db 'caracas', 0 db 'hanoi', 0 db 'sanaa', 0 db 'lusaka', 0 db 'harare', 0 db 'st petersburg', 0 db 'odessa', 0 db 'manchester', 0 db 'liverpool', 0 db 'birmingham', 0 db 'frankfurt', 0 db 'munich', 0 db 'dortmund', 0 db 'new york', 0 db 'chicago', 0 db 'san francisco', 0 db 'los angeles', 0 db 'las vegas', 0 db 'boston', 0 db 'new jersey', 0 db 'dallas', 0 db 'atlanta', 0 db 'miami', 0 db 'vancouver', 0 db 'toronto', 0 db 'saopaulo', 0 db 'rio de janeiro', 0 db 'vladivostok', 0 db 'glasgow', 0 db 'edinburgh', 0 db 'lyon', 0 db 'venice', 0 db 'torshavn', 0 db 'nuuk', 0 db 'bristol', 0 db 'york', 0 db 'tel aviv', 0 db 'seattle', 0 db 'stuttgart', 0 db 'osaka', 0 db 'kyoto', 0 db 'sapporo', 0 db 'kagoshima', 0 db 'shanghai', 0 db 'chongqing', 0 db 'hong kong', 0 db 'macao', 0 db 'xian', 0 db 'lhasa', 0 db 'warrington', 0 db 'leeds', 0 db 'luxor', 0 db 'timbuktu', 0 db 'honolulu', 0 db 'bordeaux', 0 db 'cupertino', 0 ; ------------------------------------------------------------------
default rel %define XMMWORD %define YMMWORD %define ZMMWORD section .text code align=64 EXTERN OPENSSL_ia32cap_P global sha256_block_data_order ALIGN 16 sha256_block_data_order: mov QWORD[8+rsp],rdi ;WIN64 prologue mov QWORD[16+rsp],rsi mov rax,rsp $L$SEH_begin_sha256_block_data_order: mov rdi,rcx mov rsi,rdx mov rdx,r8 lea r11,[OPENSSL_ia32cap_P] mov r9d,DWORD[r11] mov r10d,DWORD[4+r11] mov r11d,DWORD[8+r11] and r9d,1073741824 and r10d,268435968 or r10d,r9d cmp r10d,1342177792 je NEAR $L$avx_shortcut test r10d,512 jnz NEAR $L$ssse3_shortcut mov rax,rsp push rbx push rbp push r12 push r13 push r14 push r15 shl rdx,4 sub rsp,16*4+4*8 lea rdx,[rdx*4+rsi] and rsp,-64 mov QWORD[((64+0))+rsp],rdi mov QWORD[((64+8))+rsp],rsi mov QWORD[((64+16))+rsp],rdx mov QWORD[88+rsp],rax $L$prologue: mov eax,DWORD[rdi] mov ebx,DWORD[4+rdi] mov ecx,DWORD[8+rdi] mov edx,DWORD[12+rdi] mov r8d,DWORD[16+rdi] mov r9d,DWORD[20+rdi] mov r10d,DWORD[24+rdi] mov r11d,DWORD[28+rdi] jmp NEAR $L$loop ALIGN 16 $L$loop: mov edi,ebx lea rbp,[K256] xor edi,ecx mov r12d,DWORD[rsi] mov r13d,r8d mov r14d,eax bswap r12d ror r13d,14 mov r15d,r9d xor r13d,r8d ror r14d,9 xor r15d,r10d mov DWORD[rsp],r12d xor r14d,eax and r15d,r8d ror r13d,5 add r12d,r11d xor r15d,r10d ror r14d,11 xor r13d,r8d add r12d,r15d mov r15d,eax add r12d,DWORD[rbp] xor r14d,eax xor r15d,ebx ror r13d,6 mov r11d,ebx and edi,r15d ror r14d,2 add r12d,r13d xor r11d,edi add edx,r12d add r11d,r12d lea rbp,[4+rbp] add r11d,r14d mov r12d,DWORD[4+rsi] mov r13d,edx mov r14d,r11d bswap r12d ror r13d,14 mov edi,r8d xor r13d,edx ror r14d,9 xor edi,r9d mov DWORD[4+rsp],r12d xor r14d,r11d and edi,edx ror r13d,5 add r12d,r10d xor edi,r9d ror r14d,11 xor r13d,edx add r12d,edi mov edi,r11d add r12d,DWORD[rbp] xor r14d,r11d xor edi,eax ror r13d,6 mov r10d,eax and r15d,edi ror r14d,2 add r12d,r13d xor r10d,r15d add ecx,r12d add r10d,r12d lea rbp,[4+rbp] add r10d,r14d mov r12d,DWORD[8+rsi] mov r13d,ecx mov r14d,r10d bswap r12d ror r13d,14 mov r15d,edx xor r13d,ecx ror r14d,9 xor r15d,r8d mov DWORD[8+rsp],r12d xor r14d,r10d and r15d,ecx ror r13d,5 add r12d,r9d xor r15d,r8d ror r14d,11 xor r13d,ecx add r12d,r15d mov r15d,r10d add r12d,DWORD[rbp] xor r14d,r10d xor r15d,r11d ror r13d,6 mov r9d,r11d and edi,r15d ror r14d,2 add r12d,r13d xor r9d,edi add ebx,r12d add r9d,r12d lea rbp,[4+rbp] add r9d,r14d mov r12d,DWORD[12+rsi] mov r13d,ebx mov r14d,r9d bswap r12d ror r13d,14 mov edi,ecx xor r13d,ebx ror r14d,9 xor edi,edx mov DWORD[12+rsp],r12d xor r14d,r9d and edi,ebx ror r13d,5 add r12d,r8d xor edi,edx ror r14d,11 xor r13d,ebx add r12d,edi mov edi,r9d add r12d,DWORD[rbp] xor r14d,r9d xor edi,r10d ror r13d,6 mov r8d,r10d and r15d,edi ror r14d,2 add r12d,r13d xor r8d,r15d add eax,r12d add r8d,r12d lea rbp,[20+rbp] add r8d,r14d mov r12d,DWORD[16+rsi] mov r13d,eax mov r14d,r8d bswap r12d ror r13d,14 mov r15d,ebx xor r13d,eax ror r14d,9 xor r15d,ecx mov DWORD[16+rsp],r12d xor r14d,r8d and r15d,eax ror r13d,5 add r12d,edx xor r15d,ecx ror r14d,11 xor r13d,eax add r12d,r15d mov r15d,r8d add r12d,DWORD[rbp] xor r14d,r8d xor r15d,r9d ror r13d,6 mov edx,r9d and edi,r15d ror r14d,2 add r12d,r13d xor edx,edi add r11d,r12d add edx,r12d lea rbp,[4+rbp] add edx,r14d mov r12d,DWORD[20+rsi] mov r13d,r11d mov r14d,edx bswap r12d ror r13d,14 mov edi,eax xor r13d,r11d ror r14d,9 xor edi,ebx mov DWORD[20+rsp],r12d xor r14d,edx and edi,r11d ror r13d,5 add r12d,ecx xor edi,ebx ror r14d,11 xor r13d,r11d add r12d,edi mov edi,edx add r12d,DWORD[rbp] xor r14d,edx xor edi,r8d ror r13d,6 mov ecx,r8d and r15d,edi ror r14d,2 add r12d,r13d xor ecx,r15d add r10d,r12d add ecx,r12d lea rbp,[4+rbp] add ecx,r14d mov r12d,DWORD[24+rsi] mov r13d,r10d mov r14d,ecx bswap r12d ror r13d,14 mov r15d,r11d xor r13d,r10d ror r14d,9 xor r15d,eax mov DWORD[24+rsp],r12d xor r14d,ecx and r15d,r10d ror r13d,5 add r12d,ebx xor r15d,eax ror r14d,11 xor r13d,r10d add r12d,r15d mov r15d,ecx add r12d,DWORD[rbp] xor r14d,ecx xor r15d,edx ror r13d,6 mov ebx,edx and edi,r15d ror r14d,2 add r12d,r13d xor ebx,edi add r9d,r12d add ebx,r12d lea rbp,[4+rbp] add ebx,r14d mov r12d,DWORD[28+rsi] mov r13d,r9d mov r14d,ebx bswap r12d ror r13d,14 mov edi,r10d xor r13d,r9d ror r14d,9 xor edi,r11d mov DWORD[28+rsp],r12d xor r14d,ebx and edi,r9d ror r13d,5 add r12d,eax xor edi,r11d ror r14d,11 xor r13d,r9d add r12d,edi mov edi,ebx add r12d,DWORD[rbp] xor r14d,ebx xor edi,ecx ror r13d,6 mov eax,ecx and r15d,edi ror r14d,2 add r12d,r13d xor eax,r15d add r8d,r12d add eax,r12d lea rbp,[20+rbp] add eax,r14d mov r12d,DWORD[32+rsi] mov r13d,r8d mov r14d,eax bswap r12d ror r13d,14 mov r15d,r9d xor r13d,r8d ror r14d,9 xor r15d,r10d mov DWORD[32+rsp],r12d xor r14d,eax and r15d,r8d ror r13d,5 add r12d,r11d xor r15d,r10d ror r14d,11 xor r13d,r8d add r12d,r15d mov r15d,eax add r12d,DWORD[rbp] xor r14d,eax xor r15d,ebx ror r13d,6 mov r11d,ebx and edi,r15d ror r14d,2 add r12d,r13d xor r11d,edi add edx,r12d add r11d,r12d lea rbp,[4+rbp] add r11d,r14d mov r12d,DWORD[36+rsi] mov r13d,edx mov r14d,r11d bswap r12d ror r13d,14 mov edi,r8d xor r13d,edx ror r14d,9 xor edi,r9d mov DWORD[36+rsp],r12d xor r14d,r11d and edi,edx ror r13d,5 add r12d,r10d xor edi,r9d ror r14d,11 xor r13d,edx add r12d,edi mov edi,r11d add r12d,DWORD[rbp] xor r14d,r11d xor edi,eax ror r13d,6 mov r10d,eax and r15d,edi ror r14d,2 add r12d,r13d xor r10d,r15d add ecx,r12d add r10d,r12d lea rbp,[4+rbp] add r10d,r14d mov r12d,DWORD[40+rsi] mov r13d,ecx mov r14d,r10d bswap r12d ror r13d,14 mov r15d,edx xor r13d,ecx ror r14d,9 xor r15d,r8d mov DWORD[40+rsp],r12d xor r14d,r10d and r15d,ecx ror r13d,5 add r12d,r9d xor r15d,r8d ror r14d,11 xor r13d,ecx add r12d,r15d mov r15d,r10d add r12d,DWORD[rbp] xor r14d,r10d xor r15d,r11d ror r13d,6 mov r9d,r11d and edi,r15d ror r14d,2 add r12d,r13d xor r9d,edi add ebx,r12d add r9d,r12d lea rbp,[4+rbp] add r9d,r14d mov r12d,DWORD[44+rsi] mov r13d,ebx mov r14d,r9d bswap r12d ror r13d,14 mov edi,ecx xor r13d,ebx ror r14d,9 xor edi,edx mov DWORD[44+rsp],r12d xor r14d,r9d and edi,ebx ror r13d,5 add r12d,r8d xor edi,edx ror r14d,11 xor r13d,ebx add r12d,edi mov edi,r9d add r12d,DWORD[rbp] xor r14d,r9d xor edi,r10d ror r13d,6 mov r8d,r10d and r15d,edi ror r14d,2 add r12d,r13d xor r8d,r15d add eax,r12d add r8d,r12d lea rbp,[20+rbp] add r8d,r14d mov r12d,DWORD[48+rsi] mov r13d,eax mov r14d,r8d bswap r12d ror r13d,14 mov r15d,ebx xor r13d,eax ror r14d,9 xor r15d,ecx mov DWORD[48+rsp],r12d xor r14d,r8d and r15d,eax ror r13d,5 add r12d,edx xor r15d,ecx ror r14d,11 xor r13d,eax add r12d,r15d mov r15d,r8d add r12d,DWORD[rbp] xor r14d,r8d xor r15d,r9d ror r13d,6 mov edx,r9d and edi,r15d ror r14d,2 add r12d,r13d xor edx,edi add r11d,r12d add edx,r12d lea rbp,[4+rbp] add edx,r14d mov r12d,DWORD[52+rsi] mov r13d,r11d mov r14d,edx bswap r12d ror r13d,14 mov edi,eax xor r13d,r11d ror r14d,9 xor edi,ebx mov DWORD[52+rsp],r12d xor r14d,edx and edi,r11d ror r13d,5 add r12d,ecx xor edi,ebx ror r14d,11 xor r13d,r11d add r12d,edi mov edi,edx add r12d,DWORD[rbp] xor r14d,edx xor edi,r8d ror r13d,6 mov ecx,r8d and r15d,edi ror r14d,2 add r12d,r13d xor ecx,r15d add r10d,r12d add ecx,r12d lea rbp,[4+rbp] add ecx,r14d mov r12d,DWORD[56+rsi] mov r13d,r10d mov r14d,ecx bswap r12d ror r13d,14 mov r15d,r11d xor r13d,r10d ror r14d,9 xor r15d,eax mov DWORD[56+rsp],r12d xor r14d,ecx and r15d,r10d ror r13d,5 add r12d,ebx xor r15d,eax ror r14d,11 xor r13d,r10d add r12d,r15d mov r15d,ecx add r12d,DWORD[rbp] xor r14d,ecx xor r15d,edx ror r13d,6 mov ebx,edx and edi,r15d ror r14d,2 add r12d,r13d xor ebx,edi add r9d,r12d add ebx,r12d lea rbp,[4+rbp] add ebx,r14d mov r12d,DWORD[60+rsi] mov r13d,r9d mov r14d,ebx bswap r12d ror r13d,14 mov edi,r10d xor r13d,r9d ror r14d,9 xor edi,r11d mov DWORD[60+rsp],r12d xor r14d,ebx and edi,r9d ror r13d,5 add r12d,eax xor edi,r11d ror r14d,11 xor r13d,r9d add r12d,edi mov edi,ebx add r12d,DWORD[rbp] xor r14d,ebx xor edi,ecx ror r13d,6 mov eax,ecx and r15d,edi ror r14d,2 add r12d,r13d xor eax,r15d add r8d,r12d add eax,r12d lea rbp,[20+rbp] jmp NEAR $L$rounds_16_xx ALIGN 16 $L$rounds_16_xx: mov r13d,DWORD[4+rsp] mov r15d,DWORD[56+rsp] mov r12d,r13d ror r13d,11 add eax,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD[36+rsp] add r12d,DWORD[rsp] mov r13d,r8d add r12d,r15d mov r14d,eax ror r13d,14 mov r15d,r9d xor r13d,r8d ror r14d,9 xor r15d,r10d mov DWORD[rsp],r12d xor r14d,eax and r15d,r8d ror r13d,5 add r12d,r11d xor r15d,r10d ror r14d,11 xor r13d,r8d add r12d,r15d mov r15d,eax add r12d,DWORD[rbp] xor r14d,eax xor r15d,ebx ror r13d,6 mov r11d,ebx and edi,r15d ror r14d,2 add r12d,r13d xor r11d,edi add edx,r12d add r11d,r12d lea rbp,[4+rbp] mov r13d,DWORD[8+rsp] mov edi,DWORD[60+rsp] mov r12d,r13d ror r13d,11 add r11d,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD[40+rsp] add r12d,DWORD[4+rsp] mov r13d,edx add r12d,edi mov r14d,r11d ror r13d,14 mov edi,r8d xor r13d,edx ror r14d,9 xor edi,r9d mov DWORD[4+rsp],r12d xor r14d,r11d and edi,edx ror r13d,5 add r12d,r10d xor edi,r9d ror r14d,11 xor r13d,edx add r12d,edi mov edi,r11d add r12d,DWORD[rbp] xor r14d,r11d xor edi,eax ror r13d,6 mov r10d,eax and r15d,edi ror r14d,2 add r12d,r13d xor r10d,r15d add ecx,r12d add r10d,r12d lea rbp,[4+rbp] mov r13d,DWORD[12+rsp] mov r15d,DWORD[rsp] mov r12d,r13d ror r13d,11 add r10d,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD[44+rsp] add r12d,DWORD[8+rsp] mov r13d,ecx add r12d,r15d mov r14d,r10d ror r13d,14 mov r15d,edx xor r13d,ecx ror r14d,9 xor r15d,r8d mov DWORD[8+rsp],r12d xor r14d,r10d and r15d,ecx ror r13d,5 add r12d,r9d xor r15d,r8d ror r14d,11 xor r13d,ecx add r12d,r15d mov r15d,r10d add r12d,DWORD[rbp] xor r14d,r10d xor r15d,r11d ror r13d,6 mov r9d,r11d and edi,r15d ror r14d,2 add r12d,r13d xor r9d,edi add ebx,r12d add r9d,r12d lea rbp,[4+rbp] mov r13d,DWORD[16+rsp] mov edi,DWORD[4+rsp] mov r12d,r13d ror r13d,11 add r9d,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD[48+rsp] add r12d,DWORD[12+rsp] mov r13d,ebx add r12d,edi mov r14d,r9d ror r13d,14 mov edi,ecx xor r13d,ebx ror r14d,9 xor edi,edx mov DWORD[12+rsp],r12d xor r14d,r9d and edi,ebx ror r13d,5 add r12d,r8d xor edi,edx ror r14d,11 xor r13d,ebx add r12d,edi mov edi,r9d add r12d,DWORD[rbp] xor r14d,r9d xor edi,r10d ror r13d,6 mov r8d,r10d and r15d,edi ror r14d,2 add r12d,r13d xor r8d,r15d add eax,r12d add r8d,r12d lea rbp,[20+rbp] mov r13d,DWORD[20+rsp] mov r15d,DWORD[8+rsp] mov r12d,r13d ror r13d,11 add r8d,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD[52+rsp] add r12d,DWORD[16+rsp] mov r13d,eax add r12d,r15d mov r14d,r8d ror r13d,14 mov r15d,ebx xor r13d,eax ror r14d,9 xor r15d,ecx mov DWORD[16+rsp],r12d xor r14d,r8d and r15d,eax ror r13d,5 add r12d,edx xor r15d,ecx ror r14d,11 xor r13d,eax add r12d,r15d mov r15d,r8d add r12d,DWORD[rbp] xor r14d,r8d xor r15d,r9d ror r13d,6 mov edx,r9d and edi,r15d ror r14d,2 add r12d,r13d xor edx,edi add r11d,r12d add edx,r12d lea rbp,[4+rbp] mov r13d,DWORD[24+rsp] mov edi,DWORD[12+rsp] mov r12d,r13d ror r13d,11 add edx,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD[56+rsp] add r12d,DWORD[20+rsp] mov r13d,r11d add r12d,edi mov r14d,edx ror r13d,14 mov edi,eax xor r13d,r11d ror r14d,9 xor edi,ebx mov DWORD[20+rsp],r12d xor r14d,edx and edi,r11d ror r13d,5 add r12d,ecx xor edi,ebx ror r14d,11 xor r13d,r11d add r12d,edi mov edi,edx add r12d,DWORD[rbp] xor r14d,edx xor edi,r8d ror r13d,6 mov ecx,r8d and r15d,edi ror r14d,2 add r12d,r13d xor ecx,r15d add r10d,r12d add ecx,r12d lea rbp,[4+rbp] mov r13d,DWORD[28+rsp] mov r15d,DWORD[16+rsp] mov r12d,r13d ror r13d,11 add ecx,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD[60+rsp] add r12d,DWORD[24+rsp] mov r13d,r10d add r12d,r15d mov r14d,ecx ror r13d,14 mov r15d,r11d xor r13d,r10d ror r14d,9 xor r15d,eax mov DWORD[24+rsp],r12d xor r14d,ecx and r15d,r10d ror r13d,5 add r12d,ebx xor r15d,eax ror r14d,11 xor r13d,r10d add r12d,r15d mov r15d,ecx add r12d,DWORD[rbp] xor r14d,ecx xor r15d,edx ror r13d,6 mov ebx,edx and edi,r15d ror r14d,2 add r12d,r13d xor ebx,edi add r9d,r12d add ebx,r12d lea rbp,[4+rbp] mov r13d,DWORD[32+rsp] mov edi,DWORD[20+rsp] mov r12d,r13d ror r13d,11 add ebx,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD[rsp] add r12d,DWORD[28+rsp] mov r13d,r9d add r12d,edi mov r14d,ebx ror r13d,14 mov edi,r10d xor r13d,r9d ror r14d,9 xor edi,r11d mov DWORD[28+rsp],r12d xor r14d,ebx and edi,r9d ror r13d,5 add r12d,eax xor edi,r11d ror r14d,11 xor r13d,r9d add r12d,edi mov edi,ebx add r12d,DWORD[rbp] xor r14d,ebx xor edi,ecx ror r13d,6 mov eax,ecx and r15d,edi ror r14d,2 add r12d,r13d xor eax,r15d add r8d,r12d add eax,r12d lea rbp,[20+rbp] mov r13d,DWORD[36+rsp] mov r15d,DWORD[24+rsp] mov r12d,r13d ror r13d,11 add eax,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD[4+rsp] add r12d,DWORD[32+rsp] mov r13d,r8d add r12d,r15d mov r14d,eax ror r13d,14 mov r15d,r9d xor r13d,r8d ror r14d,9 xor r15d,r10d mov DWORD[32+rsp],r12d xor r14d,eax and r15d,r8d ror r13d,5 add r12d,r11d xor r15d,r10d ror r14d,11 xor r13d,r8d add r12d,r15d mov r15d,eax add r12d,DWORD[rbp] xor r14d,eax xor r15d,ebx ror r13d,6 mov r11d,ebx and edi,r15d ror r14d,2 add r12d,r13d xor r11d,edi add edx,r12d add r11d,r12d lea rbp,[4+rbp] mov r13d,DWORD[40+rsp] mov edi,DWORD[28+rsp] mov r12d,r13d ror r13d,11 add r11d,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD[8+rsp] add r12d,DWORD[36+rsp] mov r13d,edx add r12d,edi mov r14d,r11d ror r13d,14 mov edi,r8d xor r13d,edx ror r14d,9 xor edi,r9d mov DWORD[36+rsp],r12d xor r14d,r11d and edi,edx ror r13d,5 add r12d,r10d xor edi,r9d ror r14d,11 xor r13d,edx add r12d,edi mov edi,r11d add r12d,DWORD[rbp] xor r14d,r11d xor edi,eax ror r13d,6 mov r10d,eax and r15d,edi ror r14d,2 add r12d,r13d xor r10d,r15d add ecx,r12d add r10d,r12d lea rbp,[4+rbp] mov r13d,DWORD[44+rsp] mov r15d,DWORD[32+rsp] mov r12d,r13d ror r13d,11 add r10d,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD[12+rsp] add r12d,DWORD[40+rsp] mov r13d,ecx add r12d,r15d mov r14d,r10d ror r13d,14 mov r15d,edx xor r13d,ecx ror r14d,9 xor r15d,r8d mov DWORD[40+rsp],r12d xor r14d,r10d and r15d,ecx ror r13d,5 add r12d,r9d xor r15d,r8d ror r14d,11 xor r13d,ecx add r12d,r15d mov r15d,r10d add r12d,DWORD[rbp] xor r14d,r10d xor r15d,r11d ror r13d,6 mov r9d,r11d and edi,r15d ror r14d,2 add r12d,r13d xor r9d,edi add ebx,r12d add r9d,r12d lea rbp,[4+rbp] mov r13d,DWORD[48+rsp] mov edi,DWORD[36+rsp] mov r12d,r13d ror r13d,11 add r9d,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD[16+rsp] add r12d,DWORD[44+rsp] mov r13d,ebx add r12d,edi mov r14d,r9d ror r13d,14 mov edi,ecx xor r13d,ebx ror r14d,9 xor edi,edx mov DWORD[44+rsp],r12d xor r14d,r9d and edi,ebx ror r13d,5 add r12d,r8d xor edi,edx ror r14d,11 xor r13d,ebx add r12d,edi mov edi,r9d add r12d,DWORD[rbp] xor r14d,r9d xor edi,r10d ror r13d,6 mov r8d,r10d and r15d,edi ror r14d,2 add r12d,r13d xor r8d,r15d add eax,r12d add r8d,r12d lea rbp,[20+rbp] mov r13d,DWORD[52+rsp] mov r15d,DWORD[40+rsp] mov r12d,r13d ror r13d,11 add r8d,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD[20+rsp] add r12d,DWORD[48+rsp] mov r13d,eax add r12d,r15d mov r14d,r8d ror r13d,14 mov r15d,ebx xor r13d,eax ror r14d,9 xor r15d,ecx mov DWORD[48+rsp],r12d xor r14d,r8d and r15d,eax ror r13d,5 add r12d,edx xor r15d,ecx ror r14d,11 xor r13d,eax add r12d,r15d mov r15d,r8d add r12d,DWORD[rbp] xor r14d,r8d xor r15d,r9d ror r13d,6 mov edx,r9d and edi,r15d ror r14d,2 add r12d,r13d xor edx,edi add r11d,r12d add edx,r12d lea rbp,[4+rbp] mov r13d,DWORD[56+rsp] mov edi,DWORD[44+rsp] mov r12d,r13d ror r13d,11 add edx,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD[24+rsp] add r12d,DWORD[52+rsp] mov r13d,r11d add r12d,edi mov r14d,edx ror r13d,14 mov edi,eax xor r13d,r11d ror r14d,9 xor edi,ebx mov DWORD[52+rsp],r12d xor r14d,edx and edi,r11d ror r13d,5 add r12d,ecx xor edi,ebx ror r14d,11 xor r13d,r11d add r12d,edi mov edi,edx add r12d,DWORD[rbp] xor r14d,edx xor edi,r8d ror r13d,6 mov ecx,r8d and r15d,edi ror r14d,2 add r12d,r13d xor ecx,r15d add r10d,r12d add ecx,r12d lea rbp,[4+rbp] mov r13d,DWORD[60+rsp] mov r15d,DWORD[48+rsp] mov r12d,r13d ror r13d,11 add ecx,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD[28+rsp] add r12d,DWORD[56+rsp] mov r13d,r10d add r12d,r15d mov r14d,ecx ror r13d,14 mov r15d,r11d xor r13d,r10d ror r14d,9 xor r15d,eax mov DWORD[56+rsp],r12d xor r14d,ecx and r15d,r10d ror r13d,5 add r12d,ebx xor r15d,eax ror r14d,11 xor r13d,r10d add r12d,r15d mov r15d,ecx add r12d,DWORD[rbp] xor r14d,ecx xor r15d,edx ror r13d,6 mov ebx,edx and edi,r15d ror r14d,2 add r12d,r13d xor ebx,edi add r9d,r12d add ebx,r12d lea rbp,[4+rbp] mov r13d,DWORD[rsp] mov edi,DWORD[52+rsp] mov r12d,r13d ror r13d,11 add ebx,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD[32+rsp] add r12d,DWORD[60+rsp] mov r13d,r9d add r12d,edi mov r14d,ebx ror r13d,14 mov edi,r10d xor r13d,r9d ror r14d,9 xor edi,r11d mov DWORD[60+rsp],r12d xor r14d,ebx and edi,r9d ror r13d,5 add r12d,eax xor edi,r11d ror r14d,11 xor r13d,r9d add r12d,edi mov edi,ebx add r12d,DWORD[rbp] xor r14d,ebx xor edi,ecx ror r13d,6 mov eax,ecx and r15d,edi ror r14d,2 add r12d,r13d xor eax,r15d add r8d,r12d add eax,r12d lea rbp,[20+rbp] cmp BYTE[3+rbp],0 jnz NEAR $L$rounds_16_xx mov rdi,QWORD[((64+0))+rsp] add eax,r14d lea rsi,[64+rsi] add eax,DWORD[rdi] add ebx,DWORD[4+rdi] add ecx,DWORD[8+rdi] add edx,DWORD[12+rdi] add r8d,DWORD[16+rdi] add r9d,DWORD[20+rdi] add r10d,DWORD[24+rdi] add r11d,DWORD[28+rdi] cmp rsi,QWORD[((64+16))+rsp] mov DWORD[rdi],eax mov DWORD[4+rdi],ebx mov DWORD[8+rdi],ecx mov DWORD[12+rdi],edx mov DWORD[16+rdi],r8d mov DWORD[20+rdi],r9d mov DWORD[24+rdi],r10d mov DWORD[28+rdi],r11d jb NEAR $L$loop mov rsi,QWORD[88+rsp] mov r15,QWORD[((-48))+rsi] mov r14,QWORD[((-40))+rsi] mov r13,QWORD[((-32))+rsi] mov r12,QWORD[((-24))+rsi] mov rbp,QWORD[((-16))+rsi] mov rbx,QWORD[((-8))+rsi] lea rsp,[rsi] $L$epilogue: mov rdi,QWORD[8+rsp] ;WIN64 epilogue mov rsi,QWORD[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_sha256_block_data_order: ALIGN 64 K256: DD 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 DD 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 DD 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 DD 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 DD 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 DD 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 DD 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 DD 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 DD 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc DD 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc DD 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da DD 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da DD 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 DD 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 DD 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 DD 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 DD 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 DD 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 DD 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 DD 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 DD 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 DD 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 DD 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 DD 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 DD 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 DD 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 DD 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 DD 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 DD 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 DD 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 DD 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 DD 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 DD 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f DD 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f DD 0x03020100,0x0b0a0908,0xffffffff,0xffffffff DD 0x03020100,0x0b0a0908,0xffffffff,0xffffffff DD 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 DD 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 DB 83,72,65,50,53,54,32,98,108,111,99,107,32,116,114,97 DB 110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54 DB 52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121 DB 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46 DB 111,114,103,62,0 ALIGN 64 sha256_block_data_order_ssse3: mov QWORD[8+rsp],rdi ;WIN64 prologue mov QWORD[16+rsp],rsi mov rax,rsp $L$SEH_begin_sha256_block_data_order_ssse3: mov rdi,rcx mov rsi,rdx mov rdx,r8 $L$ssse3_shortcut: mov rax,rsp push rbx push rbp push r12 push r13 push r14 push r15 shl rdx,4 sub rsp,160 lea rdx,[rdx*4+rsi] and rsp,-64 mov QWORD[((64+0))+rsp],rdi mov QWORD[((64+8))+rsp],rsi mov QWORD[((64+16))+rsp],rdx mov QWORD[88+rsp],rax movaps XMMWORD[(64+32)+rsp],xmm6 movaps XMMWORD[(64+48)+rsp],xmm7 movaps XMMWORD[(64+64)+rsp],xmm8 movaps XMMWORD[(64+80)+rsp],xmm9 $L$prologue_ssse3: mov eax,DWORD[rdi] mov ebx,DWORD[4+rdi] mov ecx,DWORD[8+rdi] mov edx,DWORD[12+rdi] mov r8d,DWORD[16+rdi] mov r9d,DWORD[20+rdi] mov r10d,DWORD[24+rdi] mov r11d,DWORD[28+rdi] jmp NEAR $L$loop_ssse3 ALIGN 16 $L$loop_ssse3: movdqa xmm7,XMMWORD[((K256+512))] movdqu xmm0,XMMWORD[rsi] movdqu xmm1,XMMWORD[16+rsi] movdqu xmm2,XMMWORD[32+rsi] DB 102,15,56,0,199 movdqu xmm3,XMMWORD[48+rsi] lea rbp,[K256] DB 102,15,56,0,207 movdqa xmm4,XMMWORD[rbp] movdqa xmm5,XMMWORD[32+rbp] DB 102,15,56,0,215 paddd xmm4,xmm0 movdqa xmm6,XMMWORD[64+rbp] DB 102,15,56,0,223 movdqa xmm7,XMMWORD[96+rbp] paddd xmm5,xmm1 paddd xmm6,xmm2 paddd xmm7,xmm3 movdqa XMMWORD[rsp],xmm4 mov r14d,eax movdqa XMMWORD[16+rsp],xmm5 mov edi,ebx movdqa XMMWORD[32+rsp],xmm6 xor edi,ecx movdqa XMMWORD[48+rsp],xmm7 mov r13d,r8d jmp NEAR $L$ssse3_00_47 ALIGN 16 $L$ssse3_00_47: sub rbp,-128 ror r13d,14 movdqa xmm4,xmm1 mov eax,r14d mov r12d,r9d movdqa xmm7,xmm3 ror r14d,9 xor r13d,r8d xor r12d,r10d ror r13d,5 xor r14d,eax DB 102,15,58,15,224,4 and r12d,r8d xor r13d,r8d DB 102,15,58,15,250,4 add r11d,DWORD[rsp] mov r15d,eax xor r12d,r10d ror r14d,11 movdqa xmm5,xmm4 xor r15d,ebx add r11d,r12d movdqa xmm6,xmm4 ror r13d,6 and edi,r15d psrld xmm4,3 xor r14d,eax add r11d,r13d xor edi,ebx paddd xmm0,xmm7 ror r14d,2 add edx,r11d psrld xmm6,7 add r11d,edi mov r13d,edx pshufd xmm7,xmm3,250 add r14d,r11d ror r13d,14 pslld xmm5,14 mov r11d,r14d mov r12d,r8d pxor xmm4,xmm6 ror r14d,9 xor r13d,edx xor r12d,r9d ror r13d,5 psrld xmm6,11 xor r14d,r11d pxor xmm4,xmm5 and r12d,edx xor r13d,edx pslld xmm5,11 add r10d,DWORD[4+rsp] mov edi,r11d pxor xmm4,xmm6 xor r12d,r9d ror r14d,11 movdqa xmm6,xmm7 xor edi,eax add r10d,r12d pxor xmm4,xmm5 ror r13d,6 and r15d,edi xor r14d,r11d psrld xmm7,10 add r10d,r13d xor r15d,eax paddd xmm0,xmm4 ror r14d,2 add ecx,r10d psrlq xmm6,17 add r10d,r15d mov r13d,ecx add r14d,r10d pxor xmm7,xmm6 ror r13d,14 mov r10d,r14d mov r12d,edx ror r14d,9 psrlq xmm6,2 xor r13d,ecx xor r12d,r8d pxor xmm7,xmm6 ror r13d,5 xor r14d,r10d and r12d,ecx pshufd xmm7,xmm7,128 xor r13d,ecx add r9d,DWORD[8+rsp] mov r15d,r10d psrldq xmm7,8 xor r12d,r8d ror r14d,11 xor r15d,r11d add r9d,r12d ror r13d,6 paddd xmm0,xmm7 and edi,r15d xor r14d,r10d add r9d,r13d pshufd xmm7,xmm0,80 xor edi,r11d ror r14d,2 add ebx,r9d movdqa xmm6,xmm7 add r9d,edi mov r13d,ebx psrld xmm7,10 add r14d,r9d ror r13d,14 psrlq xmm6,17 mov r9d,r14d mov r12d,ecx pxor xmm7,xmm6 ror r14d,9 xor r13d,ebx xor r12d,edx ror r13d,5 xor r14d,r9d psrlq xmm6,2 and r12d,ebx xor r13d,ebx add r8d,DWORD[12+rsp] pxor xmm7,xmm6 mov edi,r9d xor r12d,edx ror r14d,11 pshufd xmm7,xmm7,8 xor edi,r10d add r8d,r12d movdqa xmm6,XMMWORD[rbp] ror r13d,6 and r15d,edi pslldq xmm7,8 xor r14d,r9d add r8d,r13d xor r15d,r10d paddd xmm0,xmm7 ror r14d,2 add eax,r8d add r8d,r15d paddd xmm6,xmm0 mov r13d,eax add r14d,r8d movdqa XMMWORD[rsp],xmm6 ror r13d,14 movdqa xmm4,xmm2 mov r8d,r14d mov r12d,ebx movdqa xmm7,xmm0 ror r14d,9 xor r13d,eax xor r12d,ecx ror r13d,5 xor r14d,r8d DB 102,15,58,15,225,4 and r12d,eax xor r13d,eax DB 102,15,58,15,251,4 add edx,DWORD[16+rsp] mov r15d,r8d xor r12d,ecx ror r14d,11 movdqa xmm5,xmm4 xor r15d,r9d add edx,r12d movdqa xmm6,xmm4 ror r13d,6 and edi,r15d psrld xmm4,3 xor r14d,r8d add edx,r13d xor edi,r9d paddd xmm1,xmm7 ror r14d,2 add r11d,edx psrld xmm6,7 add edx,edi mov r13d,r11d pshufd xmm7,xmm0,250 add r14d,edx ror r13d,14 pslld xmm5,14 mov edx,r14d mov r12d,eax pxor xmm4,xmm6 ror r14d,9 xor r13d,r11d xor r12d,ebx ror r13d,5 psrld xmm6,11 xor r14d,edx pxor xmm4,xmm5 and r12d,r11d xor r13d,r11d pslld xmm5,11 add ecx,DWORD[20+rsp] mov edi,edx pxor xmm4,xmm6 xor r12d,ebx ror r14d,11 movdqa xmm6,xmm7 xor edi,r8d add ecx,r12d pxor xmm4,xmm5 ror r13d,6 and r15d,edi xor r14d,edx psrld xmm7,10 add ecx,r13d xor r15d,r8d paddd xmm1,xmm4 ror r14d,2 add r10d,ecx psrlq xmm6,17 add ecx,r15d mov r13d,r10d add r14d,ecx pxor xmm7,xmm6 ror r13d,14 mov ecx,r14d mov r12d,r11d ror r14d,9 psrlq xmm6,2 xor r13d,r10d xor r12d,eax pxor xmm7,xmm6 ror r13d,5 xor r14d,ecx and r12d,r10d pshufd xmm7,xmm7,128 xor r13d,r10d add ebx,DWORD[24+rsp] mov r15d,ecx psrldq xmm7,8 xor r12d,eax ror r14d,11 xor r15d,edx add ebx,r12d ror r13d,6 paddd xmm1,xmm7 and edi,r15d xor r14d,ecx add ebx,r13d pshufd xmm7,xmm1,80 xor edi,edx ror r14d,2 add r9d,ebx movdqa xmm6,xmm7 add ebx,edi mov r13d,r9d psrld xmm7,10 add r14d,ebx ror r13d,14 psrlq xmm6,17 mov ebx,r14d mov r12d,r10d pxor xmm7,xmm6 ror r14d,9 xor r13d,r9d xor r12d,r11d ror r13d,5 xor r14d,ebx psrlq xmm6,2 and r12d,r9d xor r13d,r9d add eax,DWORD[28+rsp] pxor xmm7,xmm6 mov edi,ebx xor r12d,r11d ror r14d,11 pshufd xmm7,xmm7,8 xor edi,ecx add eax,r12d movdqa xmm6,XMMWORD[32+rbp] ror r13d,6 and r15d,edi pslldq xmm7,8 xor r14d,ebx add eax,r13d xor r15d,ecx paddd xmm1,xmm7 ror r14d,2 add r8d,eax add eax,r15d paddd xmm6,xmm1 mov r13d,r8d add r14d,eax movdqa XMMWORD[16+rsp],xmm6 ror r13d,14 movdqa xmm4,xmm3 mov eax,r14d mov r12d,r9d movdqa xmm7,xmm1 ror r14d,9 xor r13d,r8d xor r12d,r10d ror r13d,5 xor r14d,eax DB 102,15,58,15,226,4 and r12d,r8d xor r13d,r8d DB 102,15,58,15,248,4 add r11d,DWORD[32+rsp] mov r15d,eax xor r12d,r10d ror r14d,11 movdqa xmm5,xmm4 xor r15d,ebx add r11d,r12d movdqa xmm6,xmm4 ror r13d,6 and edi,r15d psrld xmm4,3 xor r14d,eax add r11d,r13d xor edi,ebx paddd xmm2,xmm7 ror r14d,2 add edx,r11d psrld xmm6,7 add r11d,edi mov r13d,edx pshufd xmm7,xmm1,250 add r14d,r11d ror r13d,14 pslld xmm5,14 mov r11d,r14d mov r12d,r8d pxor xmm4,xmm6 ror r14d,9 xor r13d,edx xor r12d,r9d ror r13d,5 psrld xmm6,11 xor r14d,r11d pxor xmm4,xmm5 and r12d,edx xor r13d,edx pslld xmm5,11 add r10d,DWORD[36+rsp] mov edi,r11d pxor xmm4,xmm6 xor r12d,r9d ror r14d,11 movdqa xmm6,xmm7 xor edi,eax add r10d,r12d pxor xmm4,xmm5 ror r13d,6 and r15d,edi xor r14d,r11d psrld xmm7,10 add r10d,r13d xor r15d,eax paddd xmm2,xmm4 ror r14d,2 add ecx,r10d psrlq xmm6,17 add r10d,r15d mov r13d,ecx add r14d,r10d pxor xmm7,xmm6 ror r13d,14 mov r10d,r14d mov r12d,edx ror r14d,9 psrlq xmm6,2 xor r13d,ecx xor r12d,r8d pxor xmm7,xmm6 ror r13d,5 xor r14d,r10d and r12d,ecx pshufd xmm7,xmm7,128 xor r13d,ecx add r9d,DWORD[40+rsp] mov r15d,r10d psrldq xmm7,8 xor r12d,r8d ror r14d,11 xor r15d,r11d add r9d,r12d ror r13d,6 paddd xmm2,xmm7 and edi,r15d xor r14d,r10d add r9d,r13d pshufd xmm7,xmm2,80 xor edi,r11d ror r14d,2 add ebx,r9d movdqa xmm6,xmm7 add r9d,edi mov r13d,ebx psrld xmm7,10 add r14d,r9d ror r13d,14 psrlq xmm6,17 mov r9d,r14d mov r12d,ecx pxor xmm7,xmm6 ror r14d,9 xor r13d,ebx xor r12d,edx ror r13d,5 xor r14d,r9d psrlq xmm6,2 and r12d,ebx xor r13d,ebx add r8d,DWORD[44+rsp] pxor xmm7,xmm6 mov edi,r9d xor r12d,edx ror r14d,11 pshufd xmm7,xmm7,8 xor edi,r10d add r8d,r12d movdqa xmm6,XMMWORD[64+rbp] ror r13d,6 and r15d,edi pslldq xmm7,8 xor r14d,r9d add r8d,r13d xor r15d,r10d paddd xmm2,xmm7 ror r14d,2 add eax,r8d add r8d,r15d paddd xmm6,xmm2 mov r13d,eax add r14d,r8d movdqa XMMWORD[32+rsp],xmm6 ror r13d,14 movdqa xmm4,xmm0 mov r8d,r14d mov r12d,ebx movdqa xmm7,xmm2 ror r14d,9 xor r13d,eax xor r12d,ecx ror r13d,5 xor r14d,r8d DB 102,15,58,15,227,4 and r12d,eax xor r13d,eax DB 102,15,58,15,249,4 add edx,DWORD[48+rsp] mov r15d,r8d xor r12d,ecx ror r14d,11 movdqa xmm5,xmm4 xor r15d,r9d add edx,r12d movdqa xmm6,xmm4 ror r13d,6 and edi,r15d psrld xmm4,3 xor r14d,r8d add edx,r13d xor edi,r9d paddd xmm3,xmm7 ror r14d,2 add r11d,edx psrld xmm6,7 add edx,edi mov r13d,r11d pshufd xmm7,xmm2,250 add r14d,edx ror r13d,14 pslld xmm5,14 mov edx,r14d mov r12d,eax pxor xmm4,xmm6 ror r14d,9 xor r13d,r11d xor r12d,ebx ror r13d,5 psrld xmm6,11 xor r14d,edx pxor xmm4,xmm5 and r12d,r11d xor r13d,r11d pslld xmm5,11 add ecx,DWORD[52+rsp] mov edi,edx pxor xmm4,xmm6 xor r12d,ebx ror r14d,11 movdqa xmm6,xmm7 xor edi,r8d add ecx,r12d pxor xmm4,xmm5 ror r13d,6 and r15d,edi xor r14d,edx psrld xmm7,10 add ecx,r13d xor r15d,r8d paddd xmm3,xmm4 ror r14d,2 add r10d,ecx psrlq xmm6,17 add ecx,r15d mov r13d,r10d add r14d,ecx pxor xmm7,xmm6 ror r13d,14 mov ecx,r14d mov r12d,r11d ror r14d,9 psrlq xmm6,2 xor r13d,r10d xor r12d,eax pxor xmm7,xmm6 ror r13d,5 xor r14d,ecx and r12d,r10d pshufd xmm7,xmm7,128 xor r13d,r10d add ebx,DWORD[56+rsp] mov r15d,ecx psrldq xmm7,8 xor r12d,eax ror r14d,11 xor r15d,edx add ebx,r12d ror r13d,6 paddd xmm3,xmm7 and edi,r15d xor r14d,ecx add ebx,r13d pshufd xmm7,xmm3,80 xor edi,edx ror r14d,2 add r9d,ebx movdqa xmm6,xmm7 add ebx,edi mov r13d,r9d psrld xmm7,10 add r14d,ebx ror r13d,14 psrlq xmm6,17 mov ebx,r14d mov r12d,r10d pxor xmm7,xmm6 ror r14d,9 xor r13d,r9d xor r12d,r11d ror r13d,5 xor r14d,ebx psrlq xmm6,2 and r12d,r9d xor r13d,r9d add eax,DWORD[60+rsp] pxor xmm7,xmm6 mov edi,ebx xor r12d,r11d ror r14d,11 pshufd xmm7,xmm7,8 xor edi,ecx add eax,r12d movdqa xmm6,XMMWORD[96+rbp] ror r13d,6 and r15d,edi pslldq xmm7,8 xor r14d,ebx add eax,r13d xor r15d,ecx paddd xmm3,xmm7 ror r14d,2 add r8d,eax add eax,r15d paddd xmm6,xmm3 mov r13d,r8d add r14d,eax movdqa XMMWORD[48+rsp],xmm6 cmp BYTE[131+rbp],0 jne NEAR $L$ssse3_00_47 ror r13d,14 mov eax,r14d mov r12d,r9d ror r14d,9 xor r13d,r8d xor r12d,r10d ror r13d,5 xor r14d,eax and r12d,r8d xor r13d,r8d add r11d,DWORD[rsp] mov r15d,eax xor r12d,r10d ror r14d,11 xor r15d,ebx add r11d,r12d ror r13d,6 and edi,r15d xor r14d,eax add r11d,r13d xor edi,ebx ror r14d,2 add edx,r11d add r11d,edi mov r13d,edx add r14d,r11d ror r13d,14 mov r11d,r14d mov r12d,r8d ror r14d,9 xor r13d,edx xor r12d,r9d ror r13d,5 xor r14d,r11d and r12d,edx xor r13d,edx add r10d,DWORD[4+rsp] mov edi,r11d xor r12d,r9d ror r14d,11 xor edi,eax add r10d,r12d ror r13d,6 and r15d,edi xor r14d,r11d add r10d,r13d xor r15d,eax ror r14d,2 add ecx,r10d add r10d,r15d mov r13d,ecx add r14d,r10d ror r13d,14 mov r10d,r14d mov r12d,edx ror r14d,9 xor r13d,ecx xor r12d,r8d ror r13d,5 xor r14d,r10d and r12d,ecx xor r13d,ecx add r9d,DWORD[8+rsp] mov r15d,r10d xor r12d,r8d ror r14d,11 xor r15d,r11d add r9d,r12d ror r13d,6 and edi,r15d xor r14d,r10d add r9d,r13d xor edi,r11d ror r14d,2 add ebx,r9d add r9d,edi mov r13d,ebx add r14d,r9d ror r13d,14 mov r9d,r14d mov r12d,ecx ror r14d,9 xor r13d,ebx xor r12d,edx ror r13d,5 xor r14d,r9d and r12d,ebx xor r13d,ebx add r8d,DWORD[12+rsp] mov edi,r9d xor r12d,edx ror r14d,11 xor edi,r10d add r8d,r12d ror r13d,6 and r15d,edi xor r14d,r9d add r8d,r13d xor r15d,r10d ror r14d,2 add eax,r8d add r8d,r15d mov r13d,eax add r14d,r8d ror r13d,14 mov r8d,r14d mov r12d,ebx ror r14d,9 xor r13d,eax xor r12d,ecx ror r13d,5 xor r14d,r8d and r12d,eax xor r13d,eax add edx,DWORD[16+rsp] mov r15d,r8d xor r12d,ecx ror r14d,11 xor r15d,r9d add edx,r12d ror r13d,6 and edi,r15d xor r14d,r8d add edx,r13d xor edi,r9d ror r14d,2 add r11d,edx add edx,edi mov r13d,r11d add r14d,edx ror r13d,14 mov edx,r14d mov r12d,eax ror r14d,9 xor r13d,r11d xor r12d,ebx ror r13d,5 xor r14d,edx and r12d,r11d xor r13d,r11d add ecx,DWORD[20+rsp] mov edi,edx xor r12d,ebx ror r14d,11 xor edi,r8d add ecx,r12d ror r13d,6 and r15d,edi xor r14d,edx add ecx,r13d xor r15d,r8d ror r14d,2 add r10d,ecx add ecx,r15d mov r13d,r10d add r14d,ecx ror r13d,14 mov ecx,r14d mov r12d,r11d ror r14d,9 xor r13d,r10d xor r12d,eax ror r13d,5 xor r14d,ecx and r12d,r10d xor r13d,r10d add ebx,DWORD[24+rsp] mov r15d,ecx xor r12d,eax ror r14d,11 xor r15d,edx add ebx,r12d ror r13d,6 and edi,r15d xor r14d,ecx add ebx,r13d xor edi,edx ror r14d,2 add r9d,ebx add ebx,edi mov r13d,r9d add r14d,ebx ror r13d,14 mov ebx,r14d mov r12d,r10d ror r14d,9 xor r13d,r9d xor r12d,r11d ror r13d,5 xor r14d,ebx and r12d,r9d xor r13d,r9d add eax,DWORD[28+rsp] mov edi,ebx xor r12d,r11d ror r14d,11 xor edi,ecx add eax,r12d ror r13d,6 and r15d,edi xor r14d,ebx add eax,r13d xor r15d,ecx ror r14d,2 add r8d,eax add eax,r15d mov r13d,r8d add r14d,eax ror r13d,14 mov eax,r14d mov r12d,r9d ror r14d,9 xor r13d,r8d xor r12d,r10d ror r13d,5 xor r14d,eax and r12d,r8d xor r13d,r8d add r11d,DWORD[32+rsp] mov r15d,eax xor r12d,r10d ror r14d,11 xor r15d,ebx add r11d,r12d ror r13d,6 and edi,r15d xor r14d,eax add r11d,r13d xor edi,ebx ror r14d,2 add edx,r11d add r11d,edi mov r13d,edx add r14d,r11d ror r13d,14 mov r11d,r14d mov r12d,r8d ror r14d,9 xor r13d,edx xor r12d,r9d ror r13d,5 xor r14d,r11d and r12d,edx xor r13d,edx add r10d,DWORD[36+rsp] mov edi,r11d xor r12d,r9d ror r14d,11 xor edi,eax add r10d,r12d ror r13d,6 and r15d,edi xor r14d,r11d add r10d,r13d xor r15d,eax ror r14d,2 add ecx,r10d add r10d,r15d mov r13d,ecx add r14d,r10d ror r13d,14 mov r10d,r14d mov r12d,edx ror r14d,9 xor r13d,ecx xor r12d,r8d ror r13d,5 xor r14d,r10d and r12d,ecx xor r13d,ecx add r9d,DWORD[40+rsp] mov r15d,r10d xor r12d,r8d ror r14d,11 xor r15d,r11d add r9d,r12d ror r13d,6 and edi,r15d xor r14d,r10d add r9d,r13d xor edi,r11d ror r14d,2 add ebx,r9d add r9d,edi mov r13d,ebx add r14d,r9d ror r13d,14 mov r9d,r14d mov r12d,ecx ror r14d,9 xor r13d,ebx xor r12d,edx ror r13d,5 xor r14d,r9d and r12d,ebx xor r13d,ebx add r8d,DWORD[44+rsp] mov edi,r9d xor r12d,edx ror r14d,11 xor edi,r10d add r8d,r12d ror r13d,6 and r15d,edi xor r14d,r9d add r8d,r13d xor r15d,r10d ror r14d,2 add eax,r8d add r8d,r15d mov r13d,eax add r14d,r8d ror r13d,14 mov r8d,r14d mov r12d,ebx ror r14d,9 xor r13d,eax xor r12d,ecx ror r13d,5 xor r14d,r8d and r12d,eax xor r13d,eax add edx,DWORD[48+rsp] mov r15d,r8d xor r12d,ecx ror r14d,11 xor r15d,r9d add edx,r12d ror r13d,6 and edi,r15d xor r14d,r8d add edx,r13d xor edi,r9d ror r14d,2 add r11d,edx add edx,edi mov r13d,r11d add r14d,edx ror r13d,14 mov edx,r14d mov r12d,eax ror r14d,9 xor r13d,r11d xor r12d,ebx ror r13d,5 xor r14d,edx and r12d,r11d xor r13d,r11d add ecx,DWORD[52+rsp] mov edi,edx xor r12d,ebx ror r14d,11 xor edi,r8d add ecx,r12d ror r13d,6 and r15d,edi xor r14d,edx add ecx,r13d xor r15d,r8d ror r14d,2 add r10d,ecx add ecx,r15d mov r13d,r10d add r14d,ecx ror r13d,14 mov ecx,r14d mov r12d,r11d ror r14d,9 xor r13d,r10d xor r12d,eax ror r13d,5 xor r14d,ecx and r12d,r10d xor r13d,r10d add ebx,DWORD[56+rsp] mov r15d,ecx xor r12d,eax ror r14d,11 xor r15d,edx add ebx,r12d ror r13d,6 and edi,r15d xor r14d,ecx add ebx,r13d xor edi,edx ror r14d,2 add r9d,ebx add ebx,edi mov r13d,r9d add r14d,ebx ror r13d,14 mov ebx,r14d mov r12d,r10d ror r14d,9 xor r13d,r9d xor r12d,r11d ror r13d,5 xor r14d,ebx and r12d,r9d xor r13d,r9d add eax,DWORD[60+rsp] mov edi,ebx xor r12d,r11d ror r14d,11 xor edi,ecx add eax,r12d ror r13d,6 and r15d,edi xor r14d,ebx add eax,r13d xor r15d,ecx ror r14d,2 add r8d,eax add eax,r15d mov r13d,r8d add r14d,eax mov rdi,QWORD[((64+0))+rsp] mov eax,r14d add eax,DWORD[rdi] lea rsi,[64+rsi] add ebx,DWORD[4+rdi] add ecx,DWORD[8+rdi] add edx,DWORD[12+rdi] add r8d,DWORD[16+rdi] add r9d,DWORD[20+rdi] add r10d,DWORD[24+rdi] add r11d,DWORD[28+rdi] cmp rsi,QWORD[((64+16))+rsp] mov DWORD[rdi],eax mov DWORD[4+rdi],ebx mov DWORD[8+rdi],ecx mov DWORD[12+rdi],edx mov DWORD[16+rdi],r8d mov DWORD[20+rdi],r9d mov DWORD[24+rdi],r10d mov DWORD[28+rdi],r11d jb NEAR $L$loop_ssse3 mov rsi,QWORD[88+rsp] movaps xmm6,XMMWORD[((64+32))+rsp] movaps xmm7,XMMWORD[((64+48))+rsp] movaps xmm8,XMMWORD[((64+64))+rsp] movaps xmm9,XMMWORD[((64+80))+rsp] mov r15,QWORD[((-48))+rsi] mov r14,QWORD[((-40))+rsi] mov r13,QWORD[((-32))+rsi] mov r12,QWORD[((-24))+rsi] mov rbp,QWORD[((-16))+rsi] mov rbx,QWORD[((-8))+rsi] lea rsp,[rsi] $L$epilogue_ssse3: mov rdi,QWORD[8+rsp] ;WIN64 epilogue mov rsi,QWORD[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_sha256_block_data_order_ssse3: ALIGN 64 sha256_block_data_order_avx: mov QWORD[8+rsp],rdi ;WIN64 prologue mov QWORD[16+rsp],rsi mov rax,rsp $L$SEH_begin_sha256_block_data_order_avx: mov rdi,rcx mov rsi,rdx mov rdx,r8 $L$avx_shortcut: mov rax,rsp push rbx push rbp push r12 push r13 push r14 push r15 shl rdx,4 sub rsp,160 lea rdx,[rdx*4+rsi] and rsp,-64 mov QWORD[((64+0))+rsp],rdi mov QWORD[((64+8))+rsp],rsi mov QWORD[((64+16))+rsp],rdx mov QWORD[88+rsp],rax movaps XMMWORD[(64+32)+rsp],xmm6 movaps XMMWORD[(64+48)+rsp],xmm7 movaps XMMWORD[(64+64)+rsp],xmm8 movaps XMMWORD[(64+80)+rsp],xmm9 $L$prologue_avx: vzeroupper mov eax,DWORD[rdi] mov ebx,DWORD[4+rdi] mov ecx,DWORD[8+rdi] mov edx,DWORD[12+rdi] mov r8d,DWORD[16+rdi] mov r9d,DWORD[20+rdi] mov r10d,DWORD[24+rdi] mov r11d,DWORD[28+rdi] vmovdqa xmm8,XMMWORD[((K256+512+32))] vmovdqa xmm9,XMMWORD[((K256+512+64))] jmp NEAR $L$loop_avx ALIGN 16 $L$loop_avx: vmovdqa xmm7,XMMWORD[((K256+512))] vmovdqu xmm0,XMMWORD[rsi] vmovdqu xmm1,XMMWORD[16+rsi] vmovdqu xmm2,XMMWORD[32+rsi] vmovdqu xmm3,XMMWORD[48+rsi] vpshufb xmm0,xmm0,xmm7 lea rbp,[K256] vpshufb xmm1,xmm1,xmm7 vpshufb xmm2,xmm2,xmm7 vpaddd xmm4,xmm0,XMMWORD[rbp] vpshufb xmm3,xmm3,xmm7 vpaddd xmm5,xmm1,XMMWORD[32+rbp] vpaddd xmm6,xmm2,XMMWORD[64+rbp] vpaddd xmm7,xmm3,XMMWORD[96+rbp] vmovdqa XMMWORD[rsp],xmm4 mov r14d,eax vmovdqa XMMWORD[16+rsp],xmm5 mov edi,ebx vmovdqa XMMWORD[32+rsp],xmm6 xor edi,ecx vmovdqa XMMWORD[48+rsp],xmm7 mov r13d,r8d jmp NEAR $L$avx_00_47 ALIGN 16 $L$avx_00_47: sub rbp,-128 vpalignr xmm4,xmm1,xmm0,4 shrd r13d,r13d,14 mov eax,r14d mov r12d,r9d vpalignr xmm7,xmm3,xmm2,4 shrd r14d,r14d,9 xor r13d,r8d xor r12d,r10d vpsrld xmm6,xmm4,7 shrd r13d,r13d,5 xor r14d,eax and r12d,r8d vpaddd xmm0,xmm0,xmm7 xor r13d,r8d add r11d,DWORD[rsp] mov r15d,eax vpsrld xmm7,xmm4,3 xor r12d,r10d shrd r14d,r14d,11 xor r15d,ebx vpslld xmm5,xmm4,14 add r11d,r12d shrd r13d,r13d,6 and edi,r15d vpxor xmm4,xmm7,xmm6 xor r14d,eax add r11d,r13d xor edi,ebx vpshufd xmm7,xmm3,250 shrd r14d,r14d,2 add edx,r11d add r11d,edi vpsrld xmm6,xmm6,11 mov r13d,edx add r14d,r11d shrd r13d,r13d,14 vpxor xmm4,xmm4,xmm5 mov r11d,r14d mov r12d,r8d shrd r14d,r14d,9 vpslld xmm5,xmm5,11 xor r13d,edx xor r12d,r9d shrd r13d,r13d,5 vpxor xmm4,xmm4,xmm6 xor r14d,r11d and r12d,edx xor r13d,edx vpsrld xmm6,xmm7,10 add r10d,DWORD[4+rsp] mov edi,r11d xor r12d,r9d vpxor xmm4,xmm4,xmm5 shrd r14d,r14d,11 xor edi,eax add r10d,r12d vpsrlq xmm7,xmm7,17 shrd r13d,r13d,6 and r15d,edi xor r14d,r11d vpaddd xmm0,xmm0,xmm4 add r10d,r13d xor r15d,eax shrd r14d,r14d,2 vpxor xmm6,xmm6,xmm7 add ecx,r10d add r10d,r15d mov r13d,ecx vpsrlq xmm7,xmm7,2 add r14d,r10d shrd r13d,r13d,14 mov r10d,r14d vpxor xmm6,xmm6,xmm7 mov r12d,edx shrd r14d,r14d,9 xor r13d,ecx vpshufb xmm6,xmm6,xmm8 xor r12d,r8d shrd r13d,r13d,5 xor r14d,r10d vpaddd xmm0,xmm0,xmm6 and r12d,ecx xor r13d,ecx add r9d,DWORD[8+rsp] vpshufd xmm7,xmm0,80 mov r15d,r10d xor r12d,r8d shrd r14d,r14d,11 vpsrld xmm6,xmm7,10 xor r15d,r11d add r9d,r12d shrd r13d,r13d,6 vpsrlq xmm7,xmm7,17 and edi,r15d xor r14d,r10d add r9d,r13d vpxor xmm6,xmm6,xmm7 xor edi,r11d shrd r14d,r14d,2 add ebx,r9d vpsrlq xmm7,xmm7,2 add r9d,edi mov r13d,ebx add r14d,r9d vpxor xmm6,xmm6,xmm7 shrd r13d,r13d,14 mov r9d,r14d mov r12d,ecx vpshufb xmm6,xmm6,xmm9 shrd r14d,r14d,9 xor r13d,ebx xor r12d,edx vpaddd xmm0,xmm0,xmm6 shrd r13d,r13d,5 xor r14d,r9d and r12d,ebx vpaddd xmm6,xmm0,XMMWORD[rbp] xor r13d,ebx add r8d,DWORD[12+rsp] mov edi,r9d xor r12d,edx shrd r14d,r14d,11 xor edi,r10d add r8d,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,r9d add r8d,r13d xor r15d,r10d shrd r14d,r14d,2 add eax,r8d add r8d,r15d mov r13d,eax add r14d,r8d vmovdqa XMMWORD[rsp],xmm6 vpalignr xmm4,xmm2,xmm1,4 shrd r13d,r13d,14 mov r8d,r14d mov r12d,ebx vpalignr xmm7,xmm0,xmm3,4 shrd r14d,r14d,9 xor r13d,eax xor r12d,ecx vpsrld xmm6,xmm4,7 shrd r13d,r13d,5 xor r14d,r8d and r12d,eax vpaddd xmm1,xmm1,xmm7 xor r13d,eax add edx,DWORD[16+rsp] mov r15d,r8d vpsrld xmm7,xmm4,3 xor r12d,ecx shrd r14d,r14d,11 xor r15d,r9d vpslld xmm5,xmm4,14 add edx,r12d shrd r13d,r13d,6 and edi,r15d vpxor xmm4,xmm7,xmm6 xor r14d,r8d add edx,r13d xor edi,r9d vpshufd xmm7,xmm0,250 shrd r14d,r14d,2 add r11d,edx add edx,edi vpsrld xmm6,xmm6,11 mov r13d,r11d add r14d,edx shrd r13d,r13d,14 vpxor xmm4,xmm4,xmm5 mov edx,r14d mov r12d,eax shrd r14d,r14d,9 vpslld xmm5,xmm5,11 xor r13d,r11d xor r12d,ebx shrd r13d,r13d,5 vpxor xmm4,xmm4,xmm6 xor r14d,edx and r12d,r11d xor r13d,r11d vpsrld xmm6,xmm7,10 add ecx,DWORD[20+rsp] mov edi,edx xor r12d,ebx vpxor xmm4,xmm4,xmm5 shrd r14d,r14d,11 xor edi,r8d add ecx,r12d vpsrlq xmm7,xmm7,17 shrd r13d,r13d,6 and r15d,edi xor r14d,edx vpaddd xmm1,xmm1,xmm4 add ecx,r13d xor r15d,r8d shrd r14d,r14d,2 vpxor xmm6,xmm6,xmm7 add r10d,ecx add ecx,r15d mov r13d,r10d vpsrlq xmm7,xmm7,2 add r14d,ecx shrd r13d,r13d,14 mov ecx,r14d vpxor xmm6,xmm6,xmm7 mov r12d,r11d shrd r14d,r14d,9 xor r13d,r10d vpshufb xmm6,xmm6,xmm8 xor r12d,eax shrd r13d,r13d,5 xor r14d,ecx vpaddd xmm1,xmm1,xmm6 and r12d,r10d xor r13d,r10d add ebx,DWORD[24+rsp] vpshufd xmm7,xmm1,80 mov r15d,ecx xor r12d,eax shrd r14d,r14d,11 vpsrld xmm6,xmm7,10 xor r15d,edx add ebx,r12d shrd r13d,r13d,6 vpsrlq xmm7,xmm7,17 and edi,r15d xor r14d,ecx add ebx,r13d vpxor xmm6,xmm6,xmm7 xor edi,edx shrd r14d,r14d,2 add r9d,ebx vpsrlq xmm7,xmm7,2 add ebx,edi mov r13d,r9d add r14d,ebx vpxor xmm6,xmm6,xmm7 shrd r13d,r13d,14 mov ebx,r14d mov r12d,r10d vpshufb xmm6,xmm6,xmm9 shrd r14d,r14d,9 xor r13d,r9d xor r12d,r11d vpaddd xmm1,xmm1,xmm6 shrd r13d,r13d,5 xor r14d,ebx and r12d,r9d vpaddd xmm6,xmm1,XMMWORD[32+rbp] xor r13d,r9d add eax,DWORD[28+rsp] mov edi,ebx xor r12d,r11d shrd r14d,r14d,11 xor edi,ecx add eax,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,ebx add eax,r13d xor r15d,ecx shrd r14d,r14d,2 add r8d,eax add eax,r15d mov r13d,r8d add r14d,eax vmovdqa XMMWORD[16+rsp],xmm6 vpalignr xmm4,xmm3,xmm2,4 shrd r13d,r13d,14 mov eax,r14d mov r12d,r9d vpalignr xmm7,xmm1,xmm0,4 shrd r14d,r14d,9 xor r13d,r8d xor r12d,r10d vpsrld xmm6,xmm4,7 shrd r13d,r13d,5 xor r14d,eax and r12d,r8d vpaddd xmm2,xmm2,xmm7 xor r13d,r8d add r11d,DWORD[32+rsp] mov r15d,eax vpsrld xmm7,xmm4,3 xor r12d,r10d shrd r14d,r14d,11 xor r15d,ebx vpslld xmm5,xmm4,14 add r11d,r12d shrd r13d,r13d,6 and edi,r15d vpxor xmm4,xmm7,xmm6 xor r14d,eax add r11d,r13d xor edi,ebx vpshufd xmm7,xmm1,250 shrd r14d,r14d,2 add edx,r11d add r11d,edi vpsrld xmm6,xmm6,11 mov r13d,edx add r14d,r11d shrd r13d,r13d,14 vpxor xmm4,xmm4,xmm5 mov r11d,r14d mov r12d,r8d shrd r14d,r14d,9 vpslld xmm5,xmm5,11 xor r13d,edx xor r12d,r9d shrd r13d,r13d,5 vpxor xmm4,xmm4,xmm6 xor r14d,r11d and r12d,edx xor r13d,edx vpsrld xmm6,xmm7,10 add r10d,DWORD[36+rsp] mov edi,r11d xor r12d,r9d vpxor xmm4,xmm4,xmm5 shrd r14d,r14d,11 xor edi,eax add r10d,r12d vpsrlq xmm7,xmm7,17 shrd r13d,r13d,6 and r15d,edi xor r14d,r11d vpaddd xmm2,xmm2,xmm4 add r10d,r13d xor r15d,eax shrd r14d,r14d,2 vpxor xmm6,xmm6,xmm7 add ecx,r10d add r10d,r15d mov r13d,ecx vpsrlq xmm7,xmm7,2 add r14d,r10d shrd r13d,r13d,14 mov r10d,r14d vpxor xmm6,xmm6,xmm7 mov r12d,edx shrd r14d,r14d,9 xor r13d,ecx vpshufb xmm6,xmm6,xmm8 xor r12d,r8d shrd r13d,r13d,5 xor r14d,r10d vpaddd xmm2,xmm2,xmm6 and r12d,ecx xor r13d,ecx add r9d,DWORD[40+rsp] vpshufd xmm7,xmm2,80 mov r15d,r10d xor r12d,r8d shrd r14d,r14d,11 vpsrld xmm6,xmm7,10 xor r15d,r11d add r9d,r12d shrd r13d,r13d,6 vpsrlq xmm7,xmm7,17 and edi,r15d xor r14d,r10d add r9d,r13d vpxor xmm6,xmm6,xmm7 xor edi,r11d shrd r14d,r14d,2 add ebx,r9d vpsrlq xmm7,xmm7,2 add r9d,edi mov r13d,ebx add r14d,r9d vpxor xmm6,xmm6,xmm7 shrd r13d,r13d,14 mov r9d,r14d mov r12d,ecx vpshufb xmm6,xmm6,xmm9 shrd r14d,r14d,9 xor r13d,ebx xor r12d,edx vpaddd xmm2,xmm2,xmm6 shrd r13d,r13d,5 xor r14d,r9d and r12d,ebx vpaddd xmm6,xmm2,XMMWORD[64+rbp] xor r13d,ebx add r8d,DWORD[44+rsp] mov edi,r9d xor r12d,edx shrd r14d,r14d,11 xor edi,r10d add r8d,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,r9d add r8d,r13d xor r15d,r10d shrd r14d,r14d,2 add eax,r8d add r8d,r15d mov r13d,eax add r14d,r8d vmovdqa XMMWORD[32+rsp],xmm6 vpalignr xmm4,xmm0,xmm3,4 shrd r13d,r13d,14 mov r8d,r14d mov r12d,ebx vpalignr xmm7,xmm2,xmm1,4 shrd r14d,r14d,9 xor r13d,eax xor r12d,ecx vpsrld xmm6,xmm4,7 shrd r13d,r13d,5 xor r14d,r8d and r12d,eax vpaddd xmm3,xmm3,xmm7 xor r13d,eax add edx,DWORD[48+rsp] mov r15d,r8d vpsrld xmm7,xmm4,3 xor r12d,ecx shrd r14d,r14d,11 xor r15d,r9d vpslld xmm5,xmm4,14 add edx,r12d shrd r13d,r13d,6 and edi,r15d vpxor xmm4,xmm7,xmm6 xor r14d,r8d add edx,r13d xor edi,r9d vpshufd xmm7,xmm2,250 shrd r14d,r14d,2 add r11d,edx add edx,edi vpsrld xmm6,xmm6,11 mov r13d,r11d add r14d,edx shrd r13d,r13d,14 vpxor xmm4,xmm4,xmm5 mov edx,r14d mov r12d,eax shrd r14d,r14d,9 vpslld xmm5,xmm5,11 xor r13d,r11d xor r12d,ebx shrd r13d,r13d,5 vpxor xmm4,xmm4,xmm6 xor r14d,edx and r12d,r11d xor r13d,r11d vpsrld xmm6,xmm7,10 add ecx,DWORD[52+rsp] mov edi,edx xor r12d,ebx vpxor xmm4,xmm4,xmm5 shrd r14d,r14d,11 xor edi,r8d add ecx,r12d vpsrlq xmm7,xmm7,17 shrd r13d,r13d,6 and r15d,edi xor r14d,edx vpaddd xmm3,xmm3,xmm4 add ecx,r13d xor r15d,r8d shrd r14d,r14d,2 vpxor xmm6,xmm6,xmm7 add r10d,ecx add ecx,r15d mov r13d,r10d vpsrlq xmm7,xmm7,2 add r14d,ecx shrd r13d,r13d,14 mov ecx,r14d vpxor xmm6,xmm6,xmm7 mov r12d,r11d shrd r14d,r14d,9 xor r13d,r10d vpshufb xmm6,xmm6,xmm8 xor r12d,eax shrd r13d,r13d,5 xor r14d,ecx vpaddd xmm3,xmm3,xmm6 and r12d,r10d xor r13d,r10d add ebx,DWORD[56+rsp] vpshufd xmm7,xmm3,80 mov r15d,ecx xor r12d,eax shrd r14d,r14d,11 vpsrld xmm6,xmm7,10 xor r15d,edx add ebx,r12d shrd r13d,r13d,6 vpsrlq xmm7,xmm7,17 and edi,r15d xor r14d,ecx add ebx,r13d vpxor xmm6,xmm6,xmm7 xor edi,edx shrd r14d,r14d,2 add r9d,ebx vpsrlq xmm7,xmm7,2 add ebx,edi mov r13d,r9d add r14d,ebx vpxor xmm6,xmm6,xmm7 shrd r13d,r13d,14 mov ebx,r14d mov r12d,r10d vpshufb xmm6,xmm6,xmm9 shrd r14d,r14d,9 xor r13d,r9d xor r12d,r11d vpaddd xmm3,xmm3,xmm6 shrd r13d,r13d,5 xor r14d,ebx and r12d,r9d vpaddd xmm6,xmm3,XMMWORD[96+rbp] xor r13d,r9d add eax,DWORD[60+rsp] mov edi,ebx xor r12d,r11d shrd r14d,r14d,11 xor edi,ecx add eax,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,ebx add eax,r13d xor r15d,ecx shrd r14d,r14d,2 add r8d,eax add eax,r15d mov r13d,r8d add r14d,eax vmovdqa XMMWORD[48+rsp],xmm6 cmp BYTE[131+rbp],0 jne NEAR $L$avx_00_47 shrd r13d,r13d,14 mov eax,r14d mov r12d,r9d shrd r14d,r14d,9 xor r13d,r8d xor r12d,r10d shrd r13d,r13d,5 xor r14d,eax and r12d,r8d xor r13d,r8d add r11d,DWORD[rsp] mov r15d,eax xor r12d,r10d shrd r14d,r14d,11 xor r15d,ebx add r11d,r12d shrd r13d,r13d,6 and edi,r15d xor r14d,eax add r11d,r13d xor edi,ebx shrd r14d,r14d,2 add edx,r11d add r11d,edi mov r13d,edx add r14d,r11d shrd r13d,r13d,14 mov r11d,r14d mov r12d,r8d shrd r14d,r14d,9 xor r13d,edx xor r12d,r9d shrd r13d,r13d,5 xor r14d,r11d and r12d,edx xor r13d,edx add r10d,DWORD[4+rsp] mov edi,r11d xor r12d,r9d shrd r14d,r14d,11 xor edi,eax add r10d,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,r11d add r10d,r13d xor r15d,eax shrd r14d,r14d,2 add ecx,r10d add r10d,r15d mov r13d,ecx add r14d,r10d shrd r13d,r13d,14 mov r10d,r14d mov r12d,edx shrd r14d,r14d,9 xor r13d,ecx xor r12d,r8d shrd r13d,r13d,5 xor r14d,r10d and r12d,ecx xor r13d,ecx add r9d,DWORD[8+rsp] mov r15d,r10d xor r12d,r8d shrd r14d,r14d,11 xor r15d,r11d add r9d,r12d shrd r13d,r13d,6 and edi,r15d xor r14d,r10d add r9d,r13d xor edi,r11d shrd r14d,r14d,2 add ebx,r9d add r9d,edi mov r13d,ebx add r14d,r9d shrd r13d,r13d,14 mov r9d,r14d mov r12d,ecx shrd r14d,r14d,9 xor r13d,ebx xor r12d,edx shrd r13d,r13d,5 xor r14d,r9d and r12d,ebx xor r13d,ebx add r8d,DWORD[12+rsp] mov edi,r9d xor r12d,edx shrd r14d,r14d,11 xor edi,r10d add r8d,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,r9d add r8d,r13d xor r15d,r10d shrd r14d,r14d,2 add eax,r8d add r8d,r15d mov r13d,eax add r14d,r8d shrd r13d,r13d,14 mov r8d,r14d mov r12d,ebx shrd r14d,r14d,9 xor r13d,eax xor r12d,ecx shrd r13d,r13d,5 xor r14d,r8d and r12d,eax xor r13d,eax add edx,DWORD[16+rsp] mov r15d,r8d xor r12d,ecx shrd r14d,r14d,11 xor r15d,r9d add edx,r12d shrd r13d,r13d,6 and edi,r15d xor r14d,r8d add edx,r13d xor edi,r9d shrd r14d,r14d,2 add r11d,edx add edx,edi mov r13d,r11d add r14d,edx shrd r13d,r13d,14 mov edx,r14d mov r12d,eax shrd r14d,r14d,9 xor r13d,r11d xor r12d,ebx shrd r13d,r13d,5 xor r14d,edx and r12d,r11d xor r13d,r11d add ecx,DWORD[20+rsp] mov edi,edx xor r12d,ebx shrd r14d,r14d,11 xor edi,r8d add ecx,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,edx add ecx,r13d xor r15d,r8d shrd r14d,r14d,2 add r10d,ecx add ecx,r15d mov r13d,r10d add r14d,ecx shrd r13d,r13d,14 mov ecx,r14d mov r12d,r11d shrd r14d,r14d,9 xor r13d,r10d xor r12d,eax shrd r13d,r13d,5 xor r14d,ecx and r12d,r10d xor r13d,r10d add ebx,DWORD[24+rsp] mov r15d,ecx xor r12d,eax shrd r14d,r14d,11 xor r15d,edx add ebx,r12d shrd r13d,r13d,6 and edi,r15d xor r14d,ecx add ebx,r13d xor edi,edx shrd r14d,r14d,2 add r9d,ebx add ebx,edi mov r13d,r9d add r14d,ebx shrd r13d,r13d,14 mov ebx,r14d mov r12d,r10d shrd r14d,r14d,9 xor r13d,r9d xor r12d,r11d shrd r13d,r13d,5 xor r14d,ebx and r12d,r9d xor r13d,r9d add eax,DWORD[28+rsp] mov edi,ebx xor r12d,r11d shrd r14d,r14d,11 xor edi,ecx add eax,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,ebx add eax,r13d xor r15d,ecx shrd r14d,r14d,2 add r8d,eax add eax,r15d mov r13d,r8d add r14d,eax shrd r13d,r13d,14 mov eax,r14d mov r12d,r9d shrd r14d,r14d,9 xor r13d,r8d xor r12d,r10d shrd r13d,r13d,5 xor r14d,eax and r12d,r8d xor r13d,r8d add r11d,DWORD[32+rsp] mov r15d,eax xor r12d,r10d shrd r14d,r14d,11 xor r15d,ebx add r11d,r12d shrd r13d,r13d,6 and edi,r15d xor r14d,eax add r11d,r13d xor edi,ebx shrd r14d,r14d,2 add edx,r11d add r11d,edi mov r13d,edx add r14d,r11d shrd r13d,r13d,14 mov r11d,r14d mov r12d,r8d shrd r14d,r14d,9 xor r13d,edx xor r12d,r9d shrd r13d,r13d,5 xor r14d,r11d and r12d,edx xor r13d,edx add r10d,DWORD[36+rsp] mov edi,r11d xor r12d,r9d shrd r14d,r14d,11 xor edi,eax add r10d,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,r11d add r10d,r13d xor r15d,eax shrd r14d,r14d,2 add ecx,r10d add r10d,r15d mov r13d,ecx add r14d,r10d shrd r13d,r13d,14 mov r10d,r14d mov r12d,edx shrd r14d,r14d,9 xor r13d,ecx xor r12d,r8d shrd r13d,r13d,5 xor r14d,r10d and r12d,ecx xor r13d,ecx add r9d,DWORD[40+rsp] mov r15d,r10d xor r12d,r8d shrd r14d,r14d,11 xor r15d,r11d add r9d,r12d shrd r13d,r13d,6 and edi,r15d xor r14d,r10d add r9d,r13d xor edi,r11d shrd r14d,r14d,2 add ebx,r9d add r9d,edi mov r13d,ebx add r14d,r9d shrd r13d,r13d,14 mov r9d,r14d mov r12d,ecx shrd r14d,r14d,9 xor r13d,ebx xor r12d,edx shrd r13d,r13d,5 xor r14d,r9d and r12d,ebx xor r13d,ebx add r8d,DWORD[44+rsp] mov edi,r9d xor r12d,edx shrd r14d,r14d,11 xor edi,r10d add r8d,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,r9d add r8d,r13d xor r15d,r10d shrd r14d,r14d,2 add eax,r8d add r8d,r15d mov r13d,eax add r14d,r8d shrd r13d,r13d,14 mov r8d,r14d mov r12d,ebx shrd r14d,r14d,9 xor r13d,eax xor r12d,ecx shrd r13d,r13d,5 xor r14d,r8d and r12d,eax xor r13d,eax add edx,DWORD[48+rsp] mov r15d,r8d xor r12d,ecx shrd r14d,r14d,11 xor r15d,r9d add edx,r12d shrd r13d,r13d,6 and edi,r15d xor r14d,r8d add edx,r13d xor edi,r9d shrd r14d,r14d,2 add r11d,edx add edx,edi mov r13d,r11d add r14d,edx shrd r13d,r13d,14 mov edx,r14d mov r12d,eax shrd r14d,r14d,9 xor r13d,r11d xor r12d,ebx shrd r13d,r13d,5 xor r14d,edx and r12d,r11d xor r13d,r11d add ecx,DWORD[52+rsp] mov edi,edx xor r12d,ebx shrd r14d,r14d,11 xor edi,r8d add ecx,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,edx add ecx,r13d xor r15d,r8d shrd r14d,r14d,2 add r10d,ecx add ecx,r15d mov r13d,r10d add r14d,ecx shrd r13d,r13d,14 mov ecx,r14d mov r12d,r11d shrd r14d,r14d,9 xor r13d,r10d xor r12d,eax shrd r13d,r13d,5 xor r14d,ecx and r12d,r10d xor r13d,r10d add ebx,DWORD[56+rsp] mov r15d,ecx xor r12d,eax shrd r14d,r14d,11 xor r15d,edx add ebx,r12d shrd r13d,r13d,6 and edi,r15d xor r14d,ecx add ebx,r13d xor edi,edx shrd r14d,r14d,2 add r9d,ebx add ebx,edi mov r13d,r9d add r14d,ebx shrd r13d,r13d,14 mov ebx,r14d mov r12d,r10d shrd r14d,r14d,9 xor r13d,r9d xor r12d,r11d shrd r13d,r13d,5 xor r14d,ebx and r12d,r9d xor r13d,r9d add eax,DWORD[60+rsp] mov edi,ebx xor r12d,r11d shrd r14d,r14d,11 xor edi,ecx add eax,r12d shrd r13d,r13d,6 and r15d,edi xor r14d,ebx add eax,r13d xor r15d,ecx shrd r14d,r14d,2 add r8d,eax add eax,r15d mov r13d,r8d add r14d,eax mov rdi,QWORD[((64+0))+rsp] mov eax,r14d add eax,DWORD[rdi] lea rsi,[64+rsi] add ebx,DWORD[4+rdi] add ecx,DWORD[8+rdi] add edx,DWORD[12+rdi] add r8d,DWORD[16+rdi] add r9d,DWORD[20+rdi] add r10d,DWORD[24+rdi] add r11d,DWORD[28+rdi] cmp rsi,QWORD[((64+16))+rsp] mov DWORD[rdi],eax mov DWORD[4+rdi],ebx mov DWORD[8+rdi],ecx mov DWORD[12+rdi],edx mov DWORD[16+rdi],r8d mov DWORD[20+rdi],r9d mov DWORD[24+rdi],r10d mov DWORD[28+rdi],r11d jb NEAR $L$loop_avx mov rsi,QWORD[88+rsp] vzeroupper movaps xmm6,XMMWORD[((64+32))+rsp] movaps xmm7,XMMWORD[((64+48))+rsp] movaps xmm8,XMMWORD[((64+64))+rsp] movaps xmm9,XMMWORD[((64+80))+rsp] mov r15,QWORD[((-48))+rsi] mov r14,QWORD[((-40))+rsi] mov r13,QWORD[((-32))+rsi] mov r12,QWORD[((-24))+rsi] mov rbp,QWORD[((-16))+rsi] mov rbx,QWORD[((-8))+rsi] lea rsp,[rsi] $L$epilogue_avx: mov rdi,QWORD[8+rsp] ;WIN64 epilogue mov rsi,QWORD[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_sha256_block_data_order_avx: EXTERN __imp_RtlVirtualUnwind ALIGN 16 se_handler: push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD[120+r8] mov rbx,QWORD[248+r8] mov rsi,QWORD[8+r9] mov r11,QWORD[56+r9] mov r10d,DWORD[r11] lea r10,[r10*1+rsi] cmp rbx,r10 jb NEAR $L$in_prologue mov rax,QWORD[152+r8] mov r10d,DWORD[4+r11] lea r10,[r10*1+rsi] cmp rbx,r10 jae NEAR $L$in_prologue mov rsi,rax mov rax,QWORD[((64+24))+rax] mov rbx,QWORD[((-8))+rax] mov rbp,QWORD[((-16))+rax] mov r12,QWORD[((-24))+rax] mov r13,QWORD[((-32))+rax] mov r14,QWORD[((-40))+rax] mov r15,QWORD[((-48))+rax] mov QWORD[144+r8],rbx mov QWORD[160+r8],rbp mov QWORD[216+r8],r12 mov QWORD[224+r8],r13 mov QWORD[232+r8],r14 mov QWORD[240+r8],r15 lea r10,[$L$epilogue] cmp rbx,r10 jb NEAR $L$in_prologue lea rsi,[((64+32))+rsi] lea rdi,[512+r8] mov ecx,8 DD 0xa548f3fc $L$in_prologue: mov rdi,QWORD[8+rax] mov rsi,QWORD[16+rax] mov QWORD[152+r8],rax mov QWORD[168+r8],rsi mov QWORD[176+r8],rdi mov rdi,QWORD[40+r9] mov rsi,r8 mov ecx,154 DD 0xa548f3fc mov rsi,r9 xor rcx,rcx mov rdx,QWORD[8+rsi] mov r8,QWORD[rsi] mov r9,QWORD[16+rsi] mov r10,QWORD[40+rsi] lea r11,[56+rsi] lea r12,[24+rsi] mov QWORD[32+rsp],r10 mov QWORD[40+rsp],r11 mov QWORD[48+rsp],r12 mov QWORD[56+rsp],rcx call QWORD[__imp_RtlVirtualUnwind] mov eax,1 add rsp,64 popfq pop r15 pop r14 pop r13 pop r12 pop rbp pop rbx pop rdi pop rsi DB 0F3h,0C3h ;repret section .pdata rdata align=4 ALIGN 4 DD $L$SEH_begin_sha256_block_data_order wrt ..imagebase DD $L$SEH_end_sha256_block_data_order wrt ..imagebase DD $L$SEH_info_sha256_block_data_order wrt ..imagebase DD $L$SEH_begin_sha256_block_data_order_ssse3 wrt ..imagebase DD $L$SEH_end_sha256_block_data_order_ssse3 wrt ..imagebase DD $L$SEH_info_sha256_block_data_order_ssse3 wrt ..imagebase DD $L$SEH_begin_sha256_block_data_order_avx wrt ..imagebase DD $L$SEH_end_sha256_block_data_order_avx wrt ..imagebase DD $L$SEH_info_sha256_block_data_order_avx wrt ..imagebase section .xdata rdata align=8 ALIGN 8 $L$SEH_info_sha256_block_data_order: DB 9,0,0,0 DD se_handler wrt ..imagebase DD $L$prologue wrt ..imagebase,$L$epilogue wrt ..imagebase $L$SEH_info_sha256_block_data_order_ssse3: DB 9,0,0,0 DD se_handler wrt ..imagebase DD $L$prologue_ssse3 wrt ..imagebase,$L$epilogue_ssse3 wrt ..imagebase $L$SEH_info_sha256_block_data_order_avx: DB 9,0,0,0 DD se_handler wrt ..imagebase DD $L$prologue_avx wrt ..imagebase,$L$epilogue_avx wrt ..imagebase
; RisitOS / based on mikeOS / BSD Licence ; os_print_string -- Displays text ; IN: SI = message location (zero-terminated string) ; OUT: Nothing (registers preserved) os_print_string: pusha mov ah, 0Eh ; int 10h teletype function .repeat: lodsb ; Get char from string cmp al, 0 je .done ; If char is zero, end of string int 10h ; Otherwise, print it jmp .repeat ; And move on to next char .done: popa ret ; ------------------------------------------------------------------ ; os_clear_screen -- Clears the screen to background ; IN/OUT: Nothing (registers preserved) os_clear_screen: pusha mov dx, 0 ; Position cursor at top-left call os_move_cursor mov ah, 6 ; Scroll full-screen mov bh, 1Eh ; Normal white on black mov bh, 7 ; mov cx, 0 ; Top-left mov dh, 24 ; Bottom-right mov dl, 79 int 10h popa ret ; ------------------------------------------------------------------ ; os_move_cursor -- Moves cursor in text mode ; IN: DH, DL = row, column; OUT: Nothing (registers preserved) os_move_cursor: pusha mov bh, 0 mov ah, 2 int 10h ; BIOS interrupt to move cursor popa ret ; ------------------------------------------------------------------ ; os_get_cursor_pos -- Return position of text cursor ; OUT: DH, DL = row, column os_get_cursor_pos: pusha mov bh, 0 mov ah, 3 int 10h ; BIOS interrupt to get cursor position mov [.tmp], dx popa mov dx, [.tmp] ret .tmp dw 0 ; ------------------------------------------------------------------ ; os_print_horiz_line -- Draw a horizontal line on the screen ; IN: AX = line type (1 for double (-), otherwise single (=)) ; OUT: Nothing (registers preserved) os_print_horiz_line: pusha mov cx, ax ; Store line type param mov al, 196 ; Default is single-line code cmp cx, 1 ; Was double-line specified in AX? jne .ready mov al, 205 ; If so, here's the code .ready: mov cx, 0 ; Counter mov ah, 0Eh ; BIOS output char routine .restart: int 10h inc cx cmp cx, 80 ; Drawn 80 chars yet? je .done jmp .restart .done: popa ret ; ------------------------------------------------------------------ ; os_show_cursor -- Turns on cursor in text mode ; IN/OUT: Nothing os_show_cursor: pusha mov ch, 6 mov cl, 7 mov ah, 1 mov al, 3 int 10h popa ret ; ------------------------------------------------------------------ ; os_hide_cursor -- Turns off cursor in text mode ; IN/OUT: Nothing os_hide_cursor: pusha mov ch, 32 mov ah, 1 mov al, 3 ; Must be video mode for buggy BIOSes! int 10h popa ret ; ------------------------------------------------------------------ ; os_draw_block -- Render block of specified colour ; IN: BL/DL/DH/SI/DI = colour/start X pos/start Y pos/width/finish Y pos os_draw_block: pusha .more: call os_move_cursor ; Move to block starting position mov ah, 09h ; Draw colour section mov bh, 0 mov cx, si mov al, ' ' int 10h inc dh ; Get ready for next line mov ax, 0 mov al, dh ; Get current Y position into DL cmp ax, di ; Reached finishing point (DI)? jne .more ; If not, keep drawing popa ret ; ------------------------------------------------------------------ ; os_file_selector -- Show a file selection dialog ; IN: Nothing; OUT: AX = location of filename string (or carry set if Esc pressed) os_file_selector: pusha mov word [.filename], 0 ; Terminate string in case user leaves without choosing mov ax, .buffer ; Get comma-separated list of filenames call os_get_file_list mov ax, .buffer ; Show those filenames in a list dialog box mov bx, .help_msg1 mov cx, .help_msg2 call os_list_dialog jc .esc_pressed dec ax ; Result from os_list_box starts from 1, but ; for our file list offset we want to start from 0 mov cx, ax mov bx, 0 mov si, .buffer ; Get our filename from the list .loop1: cmp bx, cx je .got_our_filename lodsb cmp al, ',' je .comma_found jmp .loop1 .comma_found: inc bx jmp .loop1 .got_our_filename: ; Now copy the filename string mov di, .filename .loop2: lodsb cmp al, ',' je .finished_copying cmp al, 0 je .finished_copying stosb jmp .loop2 .finished_copying: mov byte [di], 0 ; Zero terminate the filename string popa mov ax, .filename clc ret .esc_pressed: ; Set carry flag if Escape was pressed popa stc ret .buffer times 1024 db 0 .help_msg1 db 'Please select a file using the cursor', 0 .help_msg2 db 'keys from the list below...', 0 .filename times 13 db 0 ; ------------------------------------------------------------------ ; os_list_dialog -- Show a dialog with a list of options ; IN: AX = comma-separated list of strings to show (zero-terminated), ; BX = first help string, CX = second help string ; OUT: AX = number (starts from 1) of entry selected; carry set if Esc pressed os_list_dialog: pusha push ax ; Store string list for now push cx ; And help strings push bx call os_hide_cursor mov cl, 0 ; Count the number of entries in the list mov si, ax .count_loop: lodsb cmp al, 0 je .done_count cmp al, ',' jne .count_loop inc cl jmp .count_loop .done_count: inc cl mov byte [.num_of_entries], cl mov bl, 1Eh ; White on red mov dl, 20 ; Start X position mov dh, 2 ; Start Y position mov si, 40 ; Width mov di, 23 ; Finish Y position call os_draw_block ; Draw option selector window mov dl, 21 ; Show first line of help text... mov dh, 3 call os_move_cursor pop si ; Get back first string call os_print_string inc dh ; ...and the second call os_move_cursor pop si call os_print_string pop si ; SI = location of option list string (pushed earlier) mov word [.list_string], si ; Now that we've drawn the list, highlight the currently selected ; entry and let the user move up and down using the cursor keys mov byte [.skip_num], 0 ; Not skipping any lines at first showing mov dl, 25 ; Set up starting position for selector mov dh, 7 call os_move_cursor .more_select: pusha mov bl, 11110000b ; Black on white for option list box mov dl, 21 mov dh, 6 mov si, 38 mov di, 22 call os_draw_block popa call .draw_black_bar mov word si, [.list_string] call .draw_list .another_key: call os_wait_for_key ; Move / select option cmp ah, 48h ; Up pressed? je .go_up cmp ah, 50h ; Down pressed? je .go_down cmp al, 13 ; Enter pressed? je .option_selected cmp al, 27 ; Esc pressed? je .esc_pressed jmp .more_select ; If not, wait for another key .go_up: cmp dh, 7 ; Already at top? jle .hit_top call .draw_white_bar mov dl, 25 call os_move_cursor dec dh ; Row to select (increasing down) jmp .more_select .go_down: ; Already at bottom of list? cmp dh, 20 je .hit_bottom mov cx, 0 mov byte cl, dh sub cl, 7 inc cl add byte cl, [.skip_num] mov byte al, [.num_of_entries] cmp cl, al je .another_key call .draw_white_bar mov dl, 25 call os_move_cursor inc dh jmp .more_select .hit_top: mov byte cl, [.skip_num] ; Any lines to scroll up? cmp cl, 0 je .another_key ; If not, wait for another key dec byte [.skip_num] ; If so, decrement lines to skip jmp .more_select .hit_bottom: ; See if there's more to scroll mov cx, 0 mov byte cl, dh sub cl, 7 inc cl add byte cl, [.skip_num] mov byte al, [.num_of_entries] cmp cl, al je .another_key inc byte [.skip_num] ; If so, increment lines to skip jmp .more_select .option_selected: call os_show_cursor sub dh, 7 mov ax, 0 mov al, dh inc al ; Options start from 1 add byte al, [.skip_num] ; Add any lines skipped from scrolling mov word [.tmp], ax ; Store option number before restoring all other regs popa mov word ax, [.tmp] clc ; Clear carry as Esc wasn't pressed ret .esc_pressed: call os_show_cursor popa stc ; Set carry for Esc ret .draw_list: pusha mov dl, 23 ; Get into position for option list text mov dh, 7 call os_move_cursor mov cx, 0 ; Skip lines scrolled off the top of the dialog mov byte cl, [.skip_num] .skip_loop: cmp cx, 0 je .skip_loop_finished .more_lodsb: lodsb cmp al, ',' jne .more_lodsb dec cx jmp .skip_loop .skip_loop_finished: mov bx, 0 ; Counter for total number of options .more: lodsb ; Get next character in file name, increment pointer cmp al, 0 ; End of string? je .done_list cmp al, ',' ; Next option? (String is comma-separated) je .newline mov ah, 0Eh int 10h jmp .more .newline: mov dl, 23 ; Go back to starting X position inc dh ; But jump down a line call os_move_cursor inc bx ; Update the number-of-options counter cmp bx, 14 ; Limit to one screen of options jl .more .done_list: popa call os_move_cursor ret .draw_black_bar: pusha mov dl, 22 call os_move_cursor mov ah, 09h ; Draw white bar at top mov bh, 0 mov cx, 36 mov bl, 4 ; White text on black background mov al, '' int 10h popa ret .draw_white_bar: pusha mov dl, 22 call os_move_cursor mov ah, 09h ; Draw white bar at top mov bh, 0 mov cx, 36 mov bl, 4 ; Black text on white background mov al, '' int 10h popa ret .tmp dw 0 .num_of_entries db 0 .skip_num db 0 .list_string dw 0 ; ------------------------------------------------------------------ ; os_draw_background -- Clear screen with white top and bottom bars ; containing text, and a coloured middle section. ; IN: AX/BX = top/bottom string locations, CX = colour os_draw_background: pusha push ax ; Store params to pop out later push bx push cx mov dl, 0 mov dh, 0 call os_move_cursor mov ah, 09h ; Draw colour section mov cx, 1840 pop bx ; Get colour param (originally in CX) mov bh, 0 mov al, ' ' int 10h mov dh, 24 mov dl, 0 call os_move_cursor mov ah, 09h ; Draw white bar at bottom mov bh, 0 mov cx, 80 mov bl, 01110000b mov al, ' ' int 10h mov dh, 24 mov dl, 1 call os_move_cursor pop bx ; Get bottom string param mov si, bx call os_print_string mov dh, 0 mov dl, 1 call os_move_cursor pop ax ; Get top string param mov si, ax call os_print_string mov dh, 1 ; Ready for app text mov dl, 0 call os_move_cursor popa ret ; ------------------------------------------------------------------ ; os_print_newline -- Reset cursor to start of next line ; IN/OUT: Nothing (registers preserved) os_print_newline: pusha mov ah, 0Eh ; BIOS output char code mov al, 13 int 10h mov al, 10 int 10h popa ret ; ------------------------------------------------------------------ ; os_dump_registers -- Displays register contents in hex on the screen ; IN/OUT: AX/BX/CX/DX = registers to show os_dump_registers: pusha call os_print_newline push di push si push dx push cx push bx mov si, .ax_string call os_print_string call os_print_4hex pop ax mov si, .bx_string call os_print_string call os_print_4hex pop ax mov si, .cx_string call os_print_string call os_print_4hex pop ax mov si, .dx_string call os_print_string call os_print_4hex pop ax mov si, .si_string call os_print_string call os_print_4hex pop ax mov si, .di_string call os_print_string call os_print_4hex call os_print_newline popa ret .ax_string db 'AX:', 0 .bx_string db ' BX:', 0 .cx_string db ' CX:', 0 .dx_string db ' DX:', 0 .si_string db ' SI:', 0 .di_string db ' DI:', 0 ; ------------------------------------------------------------------ ; os_input_dialog -- Get text string from user via a dialog box ; IN: AX = string location, BX = message to show; OUT: AX = string location os_input_dialog: pusha push ax ; Save string location push bx ; Save message to show mov dh, 1Eh ; First, draw red background box mov dl, 12 .redbox: ; Loop to draw all lines of box call os_move_cursor pusha mov ah, 09h mov bh, 0 mov cx, 55 mov bl, 1Eh ; White on red mov al, ' ' int 10h popa inc dh cmp dh, 16 je .boxdone jmp .redbox .boxdone: mov dl, 14 mov dh, 11 call os_move_cursor pop bx ; Get message back and display it mov si, bx call os_print_string mov dl, 14 mov dh, 13 call os_move_cursor pop ax ; Get input string back mov bx, 50 call os_input_string popa ret ; ------------------------------------------------------------------ ; os_dialog_box -- Print dialog box in middle of screen, with button(s) ; IN: AX, BX, CX = string locations (set registers to 0 for no display) ; IN: DX = 0 for single 'OK' dialog, 1 for two-button 'OK' and 'Cancel' ; OUT: If two-button mode, AX = 0 for OK and 1 for cancel ; NOTE: Each string is limited to 40 characters os_dialog_box: pusha mov [.tmp], dx call os_hide_cursor mov dh, 2 ; First, draw red background box mov dl, 19 .redbox: ; Loop to draw all lines of box call os_move_cursor pusha mov ah, 09h mov bh, 0 mov cx, 42 mov bl, 1Eh ; White on red mov al, ' ' int 10h popa inc dh cmp dh, 16 je .boxdone jmp .redbox .boxdone: cmp ax, 0 ; Skip string params if zero je .no_first_string mov dl, 20 mov dh, 10 call os_move_cursor mov si, ax ; First string call os_print_string .no_first_string: cmp bx, 0 je .no_second_string mov dl, 20 mov dh, 11 call os_move_cursor mov si, bx ; Second string call os_print_string .no_second_string: cmp cx, 0 je .no_third_string mov dl, 20 mov dh, 12 call os_move_cursor mov si, cx ; Third string call os_print_string .no_third_string: mov dx, [.tmp] cmp dx, 0 je .one_button cmp dx, 1 je .two_button .one_button: mov bl, 11110000b ; Black on white mov dh, 14 mov dl, 35 mov si, 8 mov di, 15 call os_draw_block mov dl, 38 ; OK button, centred at bottom of box mov dh, 14 call os_move_cursor mov si, .ok_button_string call os_print_string jmp .one_button_wait .two_button: mov bl, 11110000b ; Black on white mov dh, 14 mov dl, 27 mov si, 8 mov di, 15 call os_draw_block mov dl, 30 ; OK button mov dh, 14 call os_move_cursor mov si, .ok_button_string call os_print_string mov dl, 44 ; Cancel button mov dh, 14 call os_move_cursor mov si, .cancel_button_string call os_print_string mov cx, 0 ; Default button = 0 jmp .two_button_wait .one_button_wait: call os_wait_for_key cmp al, 13 ; Wait for enter key (13) to be pressed jne .one_button_wait call os_show_cursor popa ret .two_button_wait: call os_wait_for_key cmp ah, 75 ; Left cursor key pressed? jne .noleft mov bl, 11110000b ; Black on white mov dh, 14 mov dl, 27 mov si, 8 mov di, 15 call os_draw_block mov dl, 30 ; OK button mov dh, 14 call os_move_cursor mov si, .ok_button_string call os_print_string mov bl, 01001111b ; White on red for cancel button mov dh, 14 mov dl, 42 mov si, 9 mov di, 15 call os_draw_block mov dl, 44 ; Cancel button mov dh, 14 call os_move_cursor mov si, .cancel_button_string call os_print_string mov cx, 0 ; And update result we'll return jmp .two_button_wait .noleft: cmp ah, 77 ; Right cursor key pressed? jne .noright mov bl, 01001111b ; Black on white mov dh, 14 mov dl, 27 mov si, 8 mov di, 15 call os_draw_block mov dl, 30 ; OK button mov dh, 14 call os_move_cursor mov si, .ok_button_string call os_print_string mov bl, 11110000b ; White on red for cancel button mov dh, 14 mov dl, 43 mov si, 8 mov di, 15 call os_draw_block mov dl, 44 ; Cancel button mov dh, 14 call os_move_cursor mov si, .cancel_button_string call os_print_string mov cx, 1 ; And update result we'll return jmp .two_button_wait .noright: cmp al, 13 ; Wait for enter key (13) to be pressed jne .two_button_wait call os_show_cursor mov [.tmp], cx ; Keep result after restoring all regs popa mov ax, [.tmp] ret .ok_button_string db 'OK', 0 .cancel_button_string db 'Cancel', 0 .ok_button_noselect db ' OK ', 0 .cancel_button_noselect db ' Cancel ', 0 .tmp dw 0 ; ------------------------------------------------------------------ ; os_print_space -- Print a space to the screen ; IN/OUT: Nothing os_print_space: pusha mov ah, 0Eh ; BIOS teletype function mov al, 20h ; Space is character 20h int 10h popa ret ; ------------------------------------------------------------------ ; os_dump_string -- Dump string as hex bytes and printable characters ; IN: SI = points to string to dump os_dump_string: pusha mov bx, si ; Save for final print .line: mov di, si ; Save current pointer mov cx, 0 ; Byte counter .more_hex: lodsb cmp al, 0 je .chr_print call os_print_2hex call os_print_space ; Single space most bytes inc cx cmp cx, 8 jne .q_next_line call os_print_space ; Double space centre of line jmp .more_hex .q_next_line: cmp cx, 16 jne .more_hex .chr_print: cmp cx, 16 ; full line? jae .chr_cont mov ax, 16 ; no, partial line, pad hex display with spaces sub ax, cx mov cx, ax mov dx, ax shl ax, 1 add cx, ax cmp dx, 8 ; less than 1/2 line? jbe .chr_c1 inc cx ; yes, add space .chr_c1: call os_print_space loop .chr_c1 .chr_cont: call os_print_space mov ah, 0Eh ; BIOS teletype function mov al, '|' ; Break between hex and character int 10h call os_print_space mov si, di ; Go back to beginning of this line mov cx, 0 .more_chr: lodsb cmp al, 0 je .done cmp al, ' ' jae .tst_high jmp short .not_printable .tst_high: cmp al, '~' jbe .output .not_printable: mov al, '.' .output: mov ah, 0Eh int 10h inc cx cmp cx, 16 jl .more_chr call os_print_newline ; Go to next line jmp .line .done: call os_print_newline ; Go to next line popa ret ; ------------------------------------------------------------------ ; os_print_digit -- Displays contents of AX as a single digit ; Works up to base 37, ie digits 0-Z ; IN: AX = "digit" to format and print os_print_digit: pusha cmp ax, 9 ; There is a break in ASCII table between 9 and A jle .digit_format add ax, 'A'-'9'-1 ; Correct for the skipped punctuation .digit_format: add ax, '0' ; 0 will display as '0', etc. mov ah, 0Eh ; May modify other registers int 10h popa ret ; ------------------------------------------------------------------ ; os_print_1hex -- Displays low nibble of AL in hex format ; IN: AL = number to format and print os_print_1hex: pusha and ax, 0Fh ; Mask off data to display call os_print_digit popa ret ; ------------------------------------------------------------------ ; os_print_2hex -- Displays AL in hex format ; IN: AL = number to format and print os_print_2hex: pusha push ax ; Output high nibble shr ax, 4 call os_print_1hex pop ax ; Output low nibble call os_print_1hex popa ret ; ------------------------------------------------------------------ ; os_print_4hex -- Displays AX in hex format ; IN: AX = number to format and print os_print_4hex: pusha push ax ; Output high byte mov al, ah call os_print_2hex pop ax ; Output low byte call os_print_2hex popa ret ; ------------------------------------------------------------------ ; os_input_string --- Get a string from keyboard input ; IN: AX = output address, BX = maximum bytes of output string ; OUT: nothing os_input_string: pusha ; If the character count is zero, don't do anything. cmp bx, 0 je .done mov di, ax ; DI = Current position in buffer dec bx ; BX = Maximum characters in string mov cx, bx ; CX = Remaining character count .get_char: call os_wait_for_key cmp al, 8 je .backspace cmp al, 13 ; The ENTER key ends the prompt je .end_string ; Do not add any characters if the maximum size has been reached. jcxz .get_char ; Only add printable characters (ASCII Values 32-126) cmp al, ' ' jb .get_char cmp al, 126 ja .get_char call .add_char dec cx jmp .get_char .end_string: mov al, 0 stosb .done: popa ret .backspace: ; Check if there are any characters to backspace cmp cx, bx jae .get_char inc cx ; Increase characters remaining call .reverse_cursor ; Move back to the previous character mov al, ' ' ; Print a space on the character call .add_char call .reverse_cursor ; Now move the cursor back again jmp .get_char .reverse_cursor: dec di ; Move the output pointer backwards call os_get_cursor_pos cmp dl, 0 ; Is the cursor at the start of line? je .back_line dec dl ; If not, just decrease the column call os_move_cursor ret .back_line: dec dh ; Otherwise, move the cursor to the end mov dl, 79 ; of the previous line. call os_move_cursor ret .add_char: stosb mov ah, 0x0E ; Teletype Function mov bh, 0 ; Video Page 0 push bp ; Some BIOS's may mess up BP int 0x10 pop bp ret ; ==================================================================
; A302576: Numbers k such that k/10 + 1 is a square. ; -10,0,30,80,150,240,350,480,630,800,990,1200,1430,1680,1950,2240,2550,2880,3230,3600,3990,4400,4830,5280,5750,6240,6750,7280,7830,8400,8990,9600,10230,10880,11550,12240,12950,13680,14430,15200,15990,16800,17630,18480,19350,20240,21150,22080,23030,24000,24990,26000,27030,28080,29150,30240,31350,32480,33630,34800,35990,37200,38430,39680,40950,42240,43550,44880,46230,47600,48990,50400,51830,53280,54750,56240,57750,59280,60830,62400,63990,65600,67230,68880,70550,72240,73950,75680,77430,79200,80990 pow $0,2 sub $0,1 mul $0,10
;Program to add two numbers .model small .stack 100h .data .code main proc mov dx,24 add dx,42 mov ah,4ch int 21h main endp end main
lc r4, 0xfffff90a lc r5, 0xffff8000 gts r6, r4, r5 halt #@expected values #r4 = 0xfffff90a #r5 = 0xffff8000 #r6 = 0x00000001 #pc = -2147483632 #e0 = 0 #e1 = 0 #e2 = 0 #e3 = 0
<% from pwnlib.shellcraft.amd64.linux import syscall %> <%page args="addr, length"/> <%docstring> Invokes the syscall munmap. See 'man 2 munmap' for more information. Arguments: addr(void): addr len(size_t): len </%docstring> ${syscall('SYS_munmap', addr, length)}
; A266977: Number of ON (black) cells in the n-th iteration of the "Rule 78" elementary cellular automaton starting with a single ON (black) cell. ; 1,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30,31,31,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40,41,41,42,42,43,43,44,44,45,45,46,46,47,47,48,48,49,49,50,50,51,51,52,52,53,53,54,54,55,55,56,56,57,57,58,58,59,59,60,60,61,61,62,62,63,63,64,64,65,65,66,66,67,67,68,68,69,69,70,70,71,71,72,72,73,73,74,74,75,75,76,76,77,77,78,78,79,79,80,80,81,81,82,82,83,83,84,84,85,85,86,86,87,87,88,88,89,89,90,90,91,91,92,92,93,93,94,94,95,95,96,96,97,97,98,98,99,99,100,100,101,101,102,102,103,103,104,104,105,105,106,106,107,107,108,108,109,109,110,110,111,111,112,112,113,113,114,114,115,115,116,116,117,117,118,118,119,119,120,120,121,121,122,122,123,123,124,124,125,125,126,126 pow $2,$0 div $0,2 pow $1,$2 add $1,$0 add $1,1
; A094835: a(n) = 2702*a(n-1) - a(n-2); a(-1) = a(0) = 26. ; Submitted by Jon Maiga ; 26,26,70226,189750626,512706121226,1385331749802026,3743165875258953026,10114032809617941274226,27328112908421802064005626,73840550964522899559001927226,199517141378027966186621143359026 trn $0,1 mul $0,3 add $0,1 seq $0,82841 ; a(n) = 4*a(n-1) - a(n-2) for n>1, a(0)=3, a(1)=9. pow $0,2 div $0,72 mul $0,24 add $0,2
; pasmo -I ../bfloat -d test_fln.asm 24576.bin > test.asm ; grep "BREAKPOINT" test.asm ; randomize usr 57344 INCLUDE "finit.asm" color_flow_warning EQU 1 carry_flow_warning EQU 1 fix_ln EQU 1 DATA_ADR EQU $6000 ; 24576 TEXT_ADR EQU $E000 ; 57344 ORG DATA_ADR ; red dw $7e7b, $79a2 ; ln(+9.805e-01) = -1.972e-02 dw $7e4b, $7cee ; ln(+7.930e-01) = -2.320e-01 dw $7e6b, $7baf ; ln(+9.180e-01) = -8.559e-02 dw $7e7b, $79a2 ; ln(+9.805e-01) = -1.972e-02 dw $7e6e, $7b95 ; ln(+9.297e-01) = -7.291e-02 dw $7e72, $7ae6 ; ln(+9.453e-01) = -5.624e-02 dw $7e7a, $79c2 ; ln(+9.766e-01) = -2.372e-02 dw $7e4e, $7cdf ; ln(+8.047e-01) = -2.173e-01 dw $7e63, $7bf6 ; ln(+8.867e-01) = -1.202e-01 ; yellow dw $7e47, $7d81 ; ln(+7.773e-01) = -2.519e-01 dw $7e69, $7bc1 ; ln(+9.102e-01) = -9.414e-02 dw $7e1f, $7df4 ; ln(+6.211e-01) = -4.763e-01 dw $7e28, $7dd8 ; ln(+6.562e-01) = -4.212e-01 dw $7e13, $7e8e ; ln(+5.742e-01) = -5.547e-01 dw $7e07, $7ea4 ; ln(+5.273e-01) = -6.399e-01 dw $7e15, $7e8b ; ln(+5.820e-01) = -5.412e-01 dw $7e20, $7df1 ; ln(+6.250e-01) = -4.700e-01 dw $7e04, $7eaa ; ln(+5.156e-01) = -6.624e-01 dw $7e7d, $78c1 ; ln(+9.883e-01) = -1.179e-02 dw $7e2a, $7dd2 ; ln(+6.641e-01) = -4.094e-01 dw $7e08, $7ea2 ; ln(+5.312e-01) = -6.325e-01 dw $7e38, $7da9 ; ln(+7.188e-01) = -3.302e-01 dw $7e54, $7cc1 ; ln(+8.281e-01) = -1.886e-01 dw $7e52, $7ccb ; ln(+8.203e-01) = -1.981e-01 dw $7e1f, $7df4 ; ln(+6.211e-01) = -4.763e-01 dw $7e11, $7e92 ; ln(+5.664e-01) = -5.684e-01 dw $7e7d, $78c1 ; ln(+9.883e-01) = -1.179e-02 dw $7e15, $7e8b ; ln(+5.820e-01) = -5.412e-01 dw $7e36, $7daf ; ln(+7.109e-01) = -3.412e-01 dw $7e52, $7ccb ; ln(+8.203e-01) = -1.981e-01 dw $7e54, $7cc1 ; ln(+8.281e-01) = -1.886e-01 ; green dw $7e1a, $7e82 ; ln(+6.016e-01) = -5.082e-01 dw $7e0a, $7e9e ; ln(+5.391e-01) = -6.179e-01 dw FP1, FPMIN dw FP2, $7E31 dw $7f33, $7d2c ; ln(+1.398e+00) = +3.354e-01 dw $7f77, $7e28 ; ln(+1.930e+00) = +6.574e-01 dw $7f4a, $7d6a ; ln(+1.578e+00) = +4.562e-01 dw $7f4d, $7d71 ; ln(+1.602e+00) = +4.710e-01 INCLUDE "test_fln.dat" dw $BABE, $DEAD ; Stop MARK ; Subroutines INCLUDE "fln.asm" INCLUDE "fequals.asm" INCLUDE "print_txt.asm" INCLUDE "print_hex.asm" ; Lookup tables INCLUDE "fln.tab" if ( $ > TEXT_ADR ) .ERROR "Prilis dlouha data!" endif ORG TEXT_ADR LD HL, DATA_ADR PUSH HL READ_DATA: POP HL LD BC, $0004 LD DE, OP1 LDIR PUSH HL ; HL = HL + DE ; HL = HL - DE ; HL = BC * DE ; HL = BC % HL ; HL = BC / HL ; HL = HL * HL ; HL = HL % 1 ; HL = HL^0.5 LD HL, (OP1) BREAKPOINT: ; FUSE Debugger ; br 0xE011 PUSH HL CALL FLN ; HL = ln(HL) POP BC ; kontrola LD BC, (RESULT) IGNORE EQU $+1 LD A, $00 OR A LD A, $00 LD (IGNORE), A JR nz, READ_DATA CALL FEQUALS if 1 JR nc, READ_DATA JR z, PRINT_OK else JR z, PRINT_OK endif CALL PRINT_DATA if 1 OR A LD HL, $DEAD SBC HL, BC JR nz, READ_DATA endif POP HL RET ; exit PRINT_OK: CALL PRINT_DATA JR READ_DATA OP1: defs 2 RESULT: defs 2 ; BC = kontrolni ; HL = spocitana PRINT_DATA: LD (DATA_COL), A LD DE, DATA_4 CALL WRITE_HEX LD HL, (OP1) LD DE, DATA_1 CALL WRITE_HEX LD H, B LD L, C LD DE, DATA_3 CALL WRITE_HEX CALL PRINT_TXT defb INK, COL_WHITE, 'ln($' DATA_1: defs 4 defb ') = $' DATA_3: defs 4 defb ' ? ', INK DATA_COL: defb COL_WHITE, '$' DATA_4: defs 4 defb NEW_LINE defb STOP_MARK
String_89116: db "-----@" String_8911c: db "ใงใ‚“ใ‚ใฐใ‚“ใ”ใ†ใŒใ€€ใŸใ ใ—ใ" ; Phone number is not next "ใฏใ„ใฃใฆใ€€ใ„ใพใ›ใ‚“๏ผ@" ; entered correctly! String_89135: db "ใƒ‡ใƒผใ‚ฟใŒใ€€ใ‹ใ‚ใฃใฆใ€€ใ„ใพใ™ใŒ" ; The data has changed. next "ใ‹ใใ‹ใˆใชใ„ใงใ€€ใ‚„ใ‚ใพใ™ใ‹๏ผŸ@" ; Quit anyway? String_89153: db "ใƒกใƒƒใ‚ปใƒผใ‚ธใฏใ€€ใ‚ใ‚Šใพใ›ใ‚“@" ; No message OpenSRAMBank4: push af ld a, $4 call GetSRAMBank pop af ret Function89168: ld hl, wGameTimerPause set GAMETIMERPAUSE_MOBILE_7_F, [hl] ret Function8916e: ld hl, wGameTimerPause res GAMETIMERPAUSE_MOBILE_7_F, [hl] ret Function89174: ld hl, wGameTimerPause bit GAMETIMERPAUSE_MOBILE_7_F, [hl] ret Function8917a: ld hl, wd002 ld bc, $32 xor a call ByteFill ret Function89185: ; strcmp(hl, de, c) ; Compares c bytes starting at de and hl and incrementing together until a mismatch is found. ; Preserves hl and de. push de push hl .loop ld a, [de] inc de cp [hl] jr nz, .done inc hl dec c jr nz, .loop .done pop hl pop de ret Function89193: ; copy(hl, de, 4) ; Copies c bytes from hl to de. ; Preserves hl and de. push de push hl .loop ld a, [hli] ld [de], a inc de dec c jr nz, .loop pop hl pop de ret Function8919e: ; Searches for the c'th string starting at de. Returns the pointer in de. ld a, c and a ret z .loop ld a, [de] inc de cp "@" jr nz, .loop dec c jr nz, .loop ret Function891ab: call Mobile22_SetBGMapMode1 farcall ReloadMapPart call Mobile22_SetBGMapMode0 ret Function891b8: call Mobile22_SetBGMapMode0 hlcoord 0, 0 ld a, " " ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill call DelayFrame ret Function891ca: push bc call Function891b8 call WaitBGMap pop bc ret Function891d3: push bc call Function891ca ld c, $10 call DelayFrames pop bc ret Function891de: call Mobile22_SetBGMapMode0 call ClearPalettes hlcoord 0, 0, wAttrMap ld a, $7 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill hlcoord 0, 0 ld a, " " ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill call Function891ab ret Function891fe: push bc call Function891de ld c, $10 call DelayFrames pop bc ret Function89209: ld a, 1 ld [wSpriteUpdatesEnabled], a ret Function8920f: ld a, 0 ld [wSpriteUpdatesEnabled], a ret Function89215: push hl push bc ld bc, wAttrMap - wTileMap add hl, bc ld [hl], a pop bc pop hl ret Function8921f: push de ld de, SCREEN_WIDTH add hl, de inc hl ld a, $7f .loop push bc push hl .asm_89229 ld [hli], a dec c jr nz, .asm_89229 pop hl add hl, de pop bc dec b jr nz, .loop pop de ret Mobile22_ButtonSound: call JoyWaitAorB call PlayClickSFX ret Mobile22_SetBGMapMode0: xor a ldh [hBGMapMode], a ret Mobile22_SetBGMapMode1: ld a, $1 ldh [hBGMapMode], a ret Function89245: farcall TryLoadSaveFile ret c farcall _LoadData and a ret Function89254: ld bc, $d07 jr Function89261 Function89259: ld bc, $0e07 jr Function89261 Function8925e: ld bc, $0e0c Function89261: push af push bc ld hl, MenuHeader_0x892a3 call CopyMenuHeader pop bc ld hl, wMenuBorderTopCoord ld a, c ld [hli], a ld a, b ld [hli], a ld a, c add $4 ld [hli], a ld a, b add $5 ld [hl], a pop af ld [wMenuCursorBuffer], a call PushWindow call Mobile22_SetBGMapMode0 call Function89209 call VerticalMenu push af ld c, $a call DelayFrames call CloseWindow call Function8920f pop af jr c, .done ld a, [wMenuCursorY] cp $2 jr z, .done and a ret .done scf ret MenuHeader_0x892a3: db MENU_BACKUP_TILES ; flags menu_coords 10, 5, 15, 9 dw MenuData_0x892ab db 1 ; default option MenuData_0x892ab: db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 2 ; items db "ใฏใ„@" db "ใ„ใ„ใˆ@" Function892b4: call Function8931b Function892b7: ld d, b ld e, c ld hl, 0 add hl, bc ld a, "@" ld bc, 6 call ByteFill ld b, d ld c, e ld hl, 6 add hl, bc ld a, "@" ld bc, 6 call ByteFill ld b, d ld c, e ld hl, 12 add hl, bc xor a ld [hli], a ld [hl], a ld hl, 14 add hl, bc ld [hli], a ld [hl], a ld hl, 16 add hl, bc ld [hl], a ld hl, 17 add hl, bc ld a, -1 ld bc, 8 call ByteFill ld b, d ld c, e ld e, 6 ld hl, 25 add hl, bc .loop ld a, -1 ld [hli], a ld a, -1 ld [hli], a dec e jr nz, .loop ret Function89305: xor a ld [wMenuSelection], a ld c, 40 .loop ld a, [wMenuSelection] inc a ld [wMenuSelection], a push bc call Function892b4 pop bc dec c jr nz, .loop ret Function8931b: push hl ld hl, $a03b ; 4:a03b ld a, [wMenuSelection] dec a ld bc, 37 call AddNTimes ld b, h ld c, l pop hl ret Function8932d: ld hl, 0 add hl, bc Function89331: ; Scans up to 5 characters starting at hl, looking for a nonspace character up to the next terminator. ; Sets carry if it does not find a nonspace character. ; Returns the location of the following character in hl. push bc ld c, NAME_LENGTH_JAPANESE - 1 .loop ld a, [hli] cp "@" jr z, .terminator cp " " jr nz, .nonspace dec c jr nz, .loop .terminator scf jr .done .nonspace and a .done pop bc ret Function89346: ld h, b ld l, c jr _incave Function8934a: ld hl, NAME_LENGTH_JAPANESE add hl, bc _incave: ; Scans up to 5 characters starting at hl, looking for a nonspace character up to the next terminator. Sets carry if it does not find a nonspace character. Returns the location of the following character in hl. push bc ld c, NAME_LENGTH_JAPANESE - 1 .loop ld a, [hli] cp "@" jr z, .terminator cp " " jr nz, .nonspace dec c jr nz, .loop .terminator scf jr .done .nonspace and a .done pop bc ret Function89363: ; Scans six byte pairs starting at bc to find $ff. Sets carry if it does not find a $ff. Returns the location of the byte after the first $ff found in hl. ld h, b ld l, c jr ._incave ld hl, 25 add hl, bc ._incave push de ld e, NAME_LENGTH_JAPANESE .loop ld a, [hli] cp -1 jr nz, .ok ld a, [hli] cp -1 jr nz, .ok dec e jr nz, .loop scf jr .done .ok and a .done pop de ret Function89381: push bc push de call Function89b45 jr c, .ok push hl ld a, -1 ld bc, 8 call ByteFill pop hl .ok pop de ld c, 8 call Function89193 pop bc ret Function8939a: push bc ld hl, 0 add hl, bc ld de, wd002 ld c, 6 call Function89193 pop bc ld hl, 17 add hl, bc ld de, wd008 call Function89381 ret Function893b3: call DisableLCD call ClearSprites call LoadStandardFont call LoadFontsExtra call Function893ef call Function8942b call Function89455 call EnableLCD ret Function893cc: call DisableLCD call ClearSprites call LoadStandardFont call LoadFontsExtra call Function893ef call Function89464 call EnableLCD ret Function893e2: call Function89b1e call Function893b3 call Function8a5b6 call Function8949c ret Function893ef: ld de, vTiles0 ld hl, GFX_8940b ld bc, $20 ld a, BANK(GFX_8940b) call FarCopyBytes ret Function893fe: call DisableLCD call Function893ef call EnableLCD call DelayFrame ret GFX_8940b: INCBIN "gfx/unknown/08940b.2bpp" Function8942b: ld de, vTiles0 tile $02 ld hl, MobileAdapterGFX + $7d tiles ld bc, 8 tiles ld a, BANK(MobileAdapterGFX) call FarCopyBytes ld de, vTiles0 tile $0a ld hl, MobileAdapterGFX + $c6 tiles ld bc, 4 tiles ld a, BANK(MobileAdapterGFX) call FarCopyBytes ret Function89448: ; Clears the sprite array push af ld hl, wVirtualOAM ld d, 24 * SPRITEOAMSTRUCT_LENGTH xor a .loop ld [hli], a dec d jr nz, .loop pop af ret Function89455: ld hl, MobileAdapterGFX + $7d tiles ld de, vTiles2 tile $0c ld bc, $49 tiles ld a, BANK(MobileAdapterGFX) call FarCopyBytes ret Function89464: ld hl, MobileAdapterGFX ld de, vTiles2 ld bc, $20 tiles ld a, BANK(MobileAdapterGFX) call FarCopyBytes ld hl, MobileAdapterGFX + $66 tiles ld de, vTiles2 tile $20 ld bc, $17 tiles ld a, BANK(MobileAdapterGFX) call FarCopyBytes ret Function89481: ld d, 2 call Function8934a ret c ld d, 0 ld hl, 16 add hl, bc bit 0, [hl] ret z inc d ret Function89492: ld d, 0 ld a, [wPlayerGender] bit PLAYERGENDER_FEMALE_F, a ret z inc d ret Function8949c: ldh a, [rSVBK] push af ld a, 5 ldh [rSVBK], a ld hl, Palette_894b3 ld de, wBGPals1 palette 7 ld bc, 1 palettes call CopyBytes pop af ldh [rSVBK], a ret Palette_894b3: RGB 31, 31, 31 RGB 31, 31, 31 RGB 31, 31, 31 RGB 00, 00, 00 Function894bb: call Function894dc push bc call Function8956f call Function8949c call Function8a60d pop bc ret Function894ca: push bc call Function894dc call Function895c7 call Function8949c call Function8a60d call SetPalettes pop bc ret Function894dc: push bc ldh a, [rSVBK] push af ld a, 5 ldh [rSVBK], a ld c, d ld b, 0 ld hl, .PalettePointers add hl, bc add hl, bc ld a, [hli] ld h, [hl] ld l, a ld de, wBGPals1 ld bc, 3 palettes call CopyBytes ld hl, .Pals345 ld de, wBGPals1 + 3 palettes ld bc, 3 palettes call CopyBytes pop af ldh [rSVBK], a pop bc ret .PalettePointers: dw .Pals012a dw .Pals012b dw .Pals012c .Pals012a: RGB 31, 31, 31 RGB 10, 17, 13 RGB 10, 08, 22 RGB 00, 00, 00 RGB 31, 31, 31 RGB 16, 20, 31 RGB 10, 08, 22 RGB 00, 00, 00 RGB 31, 31, 31 RGB 16, 20, 31 RGB 10, 17, 13 RGB 00, 00, 00 .Pals012b: RGB 31, 31, 31 RGB 30, 22, 11 RGB 31, 08, 15 RGB 00, 00, 00 RGB 31, 31, 31 RGB 16, 20, 31 RGB 31, 08, 15 RGB 00, 00, 00 RGB 31, 31, 31 RGB 16, 20, 31 RGB 30, 22, 11 RGB 00, 00, 00 .Pals012c: RGB 31, 31, 31 RGB 15, 20, 26 RGB 25, 07, 20 RGB 00, 00, 00 RGB 31, 31, 31 RGB 16, 20, 31 RGB 25, 07, 20 RGB 00, 00, 00 RGB 31, 31, 31 RGB 16, 20, 31 RGB 15, 20, 26 RGB 00, 00, 00 .Pals345: RGB 31, 31, 31 RGB 31, 31, 31 RGB 31, 13, 00 RGB 14, 08, 00 RGB 31, 31, 31 RGB 16, 16, 31 RGB 00, 00, 31 RGB 00, 00, 00 RGB 19, 31, 11 RGB 00, 00, 00 RGB 00, 00, 00 RGB 00, 00, 00 Function8956f: push bc ld hl, 16 add hl, bc ld d, h ld e, l ld hl, $000c add hl, bc ld b, h ld c, l farcall GetMobileOTTrainerClass ld a, c ld [wTrainerClass], a ldh a, [rSVBK] push af ld a, 5 ldh [rSVBK], a ld hl, wd030 ld a, -1 ld [hli], a ld a, " " ld [hl], a pop af ldh [rSVBK], a ld a, [wTrainerClass] ld h, 0 ld l, a add hl, hl add hl, hl ld de, TrainerPalettes add hl, de ldh a, [rSVBK] push af ld a, $5 ldh [rSVBK], a ld de, wd032 ld c, 4 .loop ld a, BANK(TrainerPalettes) call GetFarByte ld [de], a inc de inc hl dec c jr nz, .loop ld hl, wd036 xor a ld [hli], a ld [hl], a pop af ldh [rSVBK], a pop bc ret Function895c7: ldh a, [rSVBK] push af ld a, 5 ldh [rSVBK], a ld hl, Palette_895de ld de, wd030 ld bc, 8 call CopyBytes pop af ldh [rSVBK], a ret Palette_895de: RGB 31, 31, 31 RGB 07, 07, 06 RGB 07, 07, 06 RGB 00, 00, 00 Function895e6: ld a, 7 hlcoord 0, 0, wAttrMap ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill ret Function895f2: push bc xor a hlcoord 0, 0, wAttrMap ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill call Function89605 call Function89655 pop bc ret Function89605: hlcoord 19, 2, wAttrMap ld a, 1 ld de, SCREEN_WIDTH ld c, 14 .loop ld [hl], a dec c jr z, .done add hl, de inc a ld [hl], a dec a add hl, de dec c jr nz, .loop .done hlcoord 0, 16, wAttrMap ld c, 10 ld a, 2 .loop2 ld [hli], a dec a ld [hli], a inc a dec c jr nz, .loop2 hlcoord 1, 11, wAttrMap ld a, 4 ld bc, 4 call ByteFill ld a, 5 ld bc, 14 call ByteFill ret Function8963d: hlcoord 12, 3, wAttrMap ld a, 6 ld de, SCREEN_WIDTH lb bc, 7, 7 .loop push hl ld c, 7 .next ld [hli], a dec c jr nz, .next pop hl add hl, de dec b jr nz, .loop ret Function89655: hlcoord 1, 12, wAttrMap ld de, SCREEN_WIDTH ld a, 5 ld b, 4 .loop ld c, 18 push hl .next ld [hli], a dec c jr nz, .next pop hl add hl, de dec b jr nz, .loop ret Function8966c: push bc call Function89688 hlcoord 4, 0 ld c, 8 call Function896f5 pop bc ret Function8967a: push bc call Function89688 hlcoord 2, 0 ld c, 12 call Function896f5 pop bc ret Function89688: hlcoord 0, 0 ld a, 1 ld e, SCREEN_WIDTH call Function896e1 ld a, 2 ld e, SCREEN_WIDTH call Function896eb ld a, 3 ld [hli], a ld a, 4 ld e, SCREEN_HEIGHT call Function896e1 ld a, 6 ld [hli], a push bc ld c, 13 .loop call Function896cb dec c jr z, .done call Function896d6 dec c jr nz, .loop .done pop bc ld a, 25 ld [hli], a ld a, 26 ld e, SCREEN_HEIGHT call Function896e1 ld a, 28 ld [hli], a ld a, 2 ld e, SCREEN_WIDTH call Function896eb ret Function896cb: ld de, SCREEN_WIDTH - 1 ld a, 7 ld [hl], a add hl, de ld a, 9 ld [hli], a ret Function896d6: ld de, SCREEN_WIDTH - 1 ld a, 10 ld [hl], a add hl, de ld a, 11 ld [hli], a ret Function896e1: .loop ld [hli], a inc a dec e ret z ld [hli], a dec a dec e jr nz, .loop ret Function896eb: .loop ld [hli], a dec a dec e ret z ld [hli], a inc a dec e jr nz, .loop ret Function896f5: call Function8971f call Function89736 inc hl inc hl ld b, 2 ClearScreenArea: ; clears an area of the screen ; INPUT: ; hl = address of upper left corner of the area ; b = height ; c = width ld a, " " ; blank tile ld de, 20 ; screen width .loop push bc push hl .innerLoop ld [hli], a dec c jr nz, .innerLoop pop hl pop bc add hl, de dec b jr nz, .loop dec hl inc c inc c .asm_89713 ld a, $36 ld [hli], a dec c ret z ld a, $18 ld [hli], a dec c jr nz, .asm_89713 ret Function8971f: ld a, $2c ld [hli], a ld a, $2d ld [hld], a push hl ld de, SCREEN_WIDTH add hl, de ld a, $31 ld [hli], a ld a, $32 ld [hld], a add hl, de ld a, $35 ld [hl], a pop hl ret Function89736: push hl inc hl inc hl ld e, c ld d, $0 add hl, de ld a, $2f ld [hli], a ld a, $30 ld [hld], a ld de, SCREEN_WIDTH add hl, de ld a, $33 ld [hli], a ld a, $34 ld [hl], a add hl, de ld a, $1f ld [hl], a pop hl ret Function89753: ld a, $c ld [hl], a xor a call Function89215 ret Function8975b: ld a, $1d ld [hli], a inc a ld [hli], a ld a, $d ld [hl], a dec hl dec hl ld a, $4 ld e, $3 .asm_89769 call Function89215 inc hl dec e jr nz, .asm_89769 ret Function89771: ld a, $12 ld [hl], a ld a, $3 call Function89215 ret Function8977a: ld e, $4 ld d, $13 .asm_8977e ld a, d ld [hl], a ld a, $4 call Function89215 inc hl inc d dec e jr nz, .asm_8977e ld e, $e .asm_8978c ld a, d ld [hl], a xor a call Function89215 inc hl dec e jr nz, .asm_8978c ret Function89797: push bc ld a, $e ld [hl], a ld bc, SCREEN_WIDTH add hl, bc ld a, $11 ld [hli], a ld a, $10 ld c, $8 .asm_897a6 ld [hli], a dec c jr nz, .asm_897a6 ld a, $f ld [hl], a pop bc ret Function897af: push bc ld hl, $0010 add hl, bc ld d, h ld e, l ld hl, $000c add hl, bc ld b, h ld c, l farcall GetMobileOTTrainerClass ld a, c ld [wTrainerClass], a xor a ld [wCurPartySpecies], a ld de, vTiles2 tile $37 farcall GetTrainerPic pop bc ret Function897d5: push bc call Function8934a jr nc, .asm_897f3 hlcoord 12, 3, wAttrMap xor a ld de, SCREEN_WIDTH lb bc, 7, 7 .asm_897e5 push hl ld c, $7 .asm_897e8 ld [hli], a dec c jr nz, .asm_897e8 pop hl add hl, de dec b jr nz, .asm_897e5 pop bc ret .asm_897f3 ld a, $37 ldh [hGraphicStartTile], a hlcoord 12, 3 lb bc, 7, 7 predef PlaceGraphic call Function8963d pop bc ret Function89807: ld hl, MobileAdapterGFX + $20 tiles ld a, [wPlayerGender] bit PLAYERGENDER_FEMALE_F, a jr z, .asm_89814 ld hl, MobileAdapterGFX + $43 tiles .asm_89814 call DisableLCD ld de, vTiles2 tile $37 ld bc, $23 tiles ld a, BANK(MobileAdapterGFX) call FarCopyBytes call EnableLCD call DelayFrame ret Function89829: push bc ld bc, $705 ld de, $14 ld a, $37 .asm_89832 push bc push hl .asm_89834 ld [hli], a inc a dec c jr nz, .asm_89834 pop hl add hl, de pop bc dec b jr nz, .asm_89832 call Function8963d pop bc ret Function89844: call Function89481 call Function894bb call Function897af push bc call WaitBGMap2 call SetPalettes pop bc ret Function89856: push bc call Function891b8 pop bc call Function895f2 call Function8966c call Function899d3 call Function898aa call Function898be call Function898dc call Function898f3 push bc ld bc, wd008 hlcoord 2, 10 call Function89975 pop bc call Function897d5 ret Function8987f: call Function891b8 call Function895f2 call Function8967a call Function899d3 hlcoord 5, 1 call Function8999c hlcoord 13, 3 call Function89829 call Function899b2 hlcoord 5, 5 call Function899c9 ld bc, wd008 hlcoord 2, 10 call Function89975 ret Function898aa: ld a, [wMenuSelection] and a ret z push bc hlcoord 6, 1 ld de, wMenuSelection lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum pop bc ret Function898be: push bc ld de, wd002 ld hl, wd002 call Function89331 jr nc, .asm_898cd ld de, String_89116 .asm_898cd hlcoord 9, 1 ld a, [wMenuSelection] and a jr nz, .asm_898d7 dec hl .asm_898d7 call PlaceString pop bc ret Function898dc: ld hl, $0006 add hl, bc push bc ld d, h ld e, l call Function8934a jr nc, .asm_898eb ld de, String_89116 .asm_898eb hlcoord 6, 4 call PlaceString pop bc ret Function898f3: push bc ld hl, $000c add hl, bc ld d, h ld e, l call Function8934a jr c, .asm_8990a hlcoord 5, 5 lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum jr .asm_89913 .asm_8990a hlcoord 5, 5 ld de, String_89116 call PlaceString .asm_89913 pop bc ret Function89915: push bc push hl ld de, Unknown_89942 ld c, $8 .asm_8991c ld a, [de] ld [hl], a ld a, $4 call Function89215 inc hl inc de dec c jr nz, .asm_8991c pop hl ld b, $4 ld c, $2b ld a, $8 ld de, Unknown_8994a .asm_89932 push af ld a, [de] cp [hl] jr nz, .asm_8993b call Function8994e inc de .asm_8993b inc hl pop af dec a jr nz, .asm_89932 pop bc ret Unknown_89942: db $24, $25, $26, " ", $27, $28, $29, $2a Unknown_8994a: db $24, $27, $29, $ff Function8994e: push hl push de ld de, SCREEN_WIDTH ld a, l sub e ld l, a ld a, h sbc d ld h, a ld a, c ld [hl], a ld a, b call Function89215 pop de pop hl ret Function89962: push bc ld c, $4 ld b, $20 .asm_89967 ld a, b ld [hl], a ld a, $4 call Function89215 inc hl inc b dec c jr nz, .asm_89967 pop bc ret Function89975: push bc ld e, $8 .asm_89978 ld a, [bc] ld d, a call Function8998b swap d inc hl ld a, d call Function8998b inc bc inc hl dec e jr nz, .asm_89978 pop bc ret Function8998b: push bc and $f cp $a jr nc, .asm_89997 ld c, $f6 add c jr .asm_89999 .asm_89997 ld a, $7f .asm_89999 ld [hl], a pop bc ret Function8999c: ld de, wPlayerName call PlaceString inc bc ld h, b ld l, c ld de, String_899ac call PlaceString ret String_899ac: db "ใฎใ€€ใ‚ใ„ใ—@" Function899b2: ld bc, wPlayerName call Function89346 jr c, .asm_899bf ld de, wPlayerName jr .asm_899c2 .asm_899bf ld de, String_89116 .asm_899c2 hlcoord 6, 4 call PlaceString ret Function899c9: ld de, wPlayerID lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum ret Function899d3: hlcoord 1, 4 call Function89753 hlcoord 2, 5 call Function8975b hlcoord 1, 9 call Function89771 hlcoord 1, 11 call Function8977a hlcoord 1, 5 call Function89797 hlcoord 2, 4 call Function89962 hlcoord 2, 9 call Function89915 ret Function899fe: push bc push hl ld hl, $0019 add hl, bc ld b, h ld c, l pop hl call Function89a0c pop bc ret Function89a0c: push hl call Function89363 pop hl jr c, .asm_89a1c ld d, h ld e, l farcall Function11c08f ret .asm_89a1c ld de, String_89153 call PlaceString ret Function89a23: hlcoord 0, 11 ld b, $4 ld c, $12 call Function8921f ret Function89a2e: hlcoord 11, 12 ld b, $2 ld c, $6 call Textbox hlcoord 13, 13 ld de, String_89a4e call PlaceString hlcoord 13, 14 ld de, String_89a53 call PlaceString call Function89655 ret String_89a4e: db "ใ‘ใฃใฆใ„@" String_89a53: db "ใ‚„ใ‚ใ‚‹@" Function89a57: call JoyTextDelay_ForcehJoyDown ; joypad bit D_UP_F, c jr nz, .d_up bit D_DOWN_F, c jr nz, .d_down bit A_BUTTON_F, c jr nz, .a_b_button bit B_BUTTON_F, c jr nz, .a_b_button bit START_F, c jr nz, .start_button scf ret .a_b_button ld a, $1 and a ret .start_button ld a, $2 and a ret .d_up call .MoveCursorUp call nc, .PlayPocketSwitchSFX ld a, $0 ret .d_down call .MoveCursorDown call nc, .PlayPocketSwitchSFX ld a, $0 ret .PlayPocketSwitchSFX: push af ld de, SFX_SWITCH_POCKETS call PlaySFX pop af ret .MoveCursorDown: ld d, 40 ld e, 1 call .ApplyCursorMovement ret .MoveCursorUp: ld d, 1 ld e, -1 call .ApplyCursorMovement ret .ApplyCursorMovement: ld a, [wMenuSelection] ld c, a push bc .loop ld a, [wMenuSelection] cp d jr z, .equal_to_d add e jr nz, .not_zero inc a .not_zero ld [wMenuSelection], a call .Function89ac7 ; BCD conversion of data in SRAM? jr nc, .loop call .Function89ae6 ; split [wMenuSelection] into [wd030] + [wd031] where [wd030] <= 5 pop bc and a ret .equal_to_d pop bc ld a, c ld [wMenuSelection], a scf ret .Function89ac7: call OpenSRAMBank4 call Function8931b call .Function89ad4 call CloseSRAM ret .Function89ad4: push de call Function8932d ; find a non-space character within 5 bytes of bc jr c, .no_nonspace_character ld hl, 17 add hl, bc call Function89b45 jr c, .finish_decode .no_nonspace_character and a .finish_decode pop de ret .Function89ae6: ld hl, wd031 xor a ld [hl], a ld a, [wMenuSelection] .loop2 cp 6 jr c, .load_and_ret sub 5 ld c, a ld a, [hl] add 5 ld [hl], a ld a, c jr .loop2 .load_and_ret ld [wd030], a ret Function89b00: farcall MG_Mobile_Layout_LoadPals ret Function89b07: call Mobile22_SetBGMapMode0 call DelayFrame farcall Function4a3a7 ret Function89b14: call ClearBGPalettes call Function89b07 call Function89b00 ret Function89b1e: farcall Function4a485 call Function89b00 ret Function89b28: call Function891de call ClearBGPalettes call Function893e2 call ExitMenu call Function891ab call SetPalettes ret Function89b3b: call Mobile22_SetBGMapMode0 farcall Function48cda ret Function89b45: ; some sort of decoder? ; BCD? push hl push bc ld c, $10 ld e, $0 .loop ld a, [hli] ld b, a and $f cp 10 jr c, .low_nybble_less_than_10 ld a, c cp $b jr nc, .clear_carry jr .set_carry .low_nybble_less_than_10 dec c swap b inc e ld a, b and $f cp 10 jr c, .high_nybble_less_than_10 ld a, c cp $b jr nc, .clear_carry jr .set_carry .high_nybble_less_than_10 inc e dec c jr nz, .loop dec e .set_carry scf jr .finish .clear_carry and a .finish pop bc pop hl ret Function89b78: push bc ld a, [wd010] cp $10 jr c, .asm_89b8c ld a, e and a jr z, .asm_89b89 ld c, e .asm_89b85 inc hl dec c jr nz, .asm_89b85 .asm_89b89 ld a, $7f ld [hl], a .asm_89b8c ld a, [wd010] inc a and $1f ld [wd010], a pop bc ret Function89b97: call Function89c34 jr c, .asm_89ba0 call Function89448 ret .asm_89ba0 ld a, [wd011] ld hl, Unknown_89bd8 and a jr z, .asm_89bae .asm_89ba9 inc hl inc hl dec a jr nz, .asm_89ba9 .asm_89bae ld a, [hli] ld h, [hl] ld l, a ld de, wVirtualOAMSprite00 .asm_89bb4 ld a, [hli] cp $ff ret z ld c, a ld b, $0 .asm_89bbb push hl ld a, [hli] ld [de], a ; y inc de ld a, [hli] add b ld [de], a ; x inc de ld a, $08 add b ld b, a ld a, [hli] ; tile id ld [de], a inc de ld a, [hli] ; attributes ld [de], a inc de pop hl dec c jr nz, .asm_89bbb ld b, $0 ld c, $4 add hl, bc jr .asm_89bb4 Unknown_89bd8: dw Unknown_89be0 dw Unknown_89bf5 dw Unknown_89c0a dw Unknown_89c1f Unknown_89be0: db $01, $12, $4e, $01, 0 db $01, $19, $4e, $01, 0 | Y_FLIP db $01, $12, $72, $01, 0 | X_FLIP db $01, $19, $72, $01, 0 | X_FLIP | Y_FLIP db -1 ; end Unknown_89bf5: db $01, $60, $16, $01, 0 db $01, $62, $16, $01, 0 | Y_FLIP db $01, $60, $92, $01, 0 | X_FLIP db $01, $62, $92, $01, 0 | X_FLIP | Y_FLIP db -1 ; end Unknown_89c0a: db $01, $78, $66, $01, 0 db $01, $78, $66, $01, 0 | Y_FLIP db $01, $78, $92, $01, 0 | X_FLIP db $01, $78, $92, $01, 0 | X_FLIP | Y_FLIP db -1 ; end Unknown_89c1f: db $01, $80, $66, $01, 0 db $01, $80, $66, $01, 0 | Y_FLIP db $01, $80, $92, $01, 0 | X_FLIP db $01, $80, $92, $01, 0 | X_FLIP | Y_FLIP db -1 ; end Function89c34: push bc ld a, [wd012] ld c, a inc a and $f ld [wd012], a ld a, c cp $8 pop bc ret Function89c44: call Function89c34 jr c, .asm_89c4f push de call Function89448 pop de ret .asm_89c4f ld hl, wVirtualOAMSprite00 push de ld a, b ld [hli], a ; y ld d, $8 ld a, e and a ld a, c jr z, .asm_89c60 .asm_89c5c add d dec e jr nz, .asm_89c5c .asm_89c60 pop de ld [hli], a ; x ld a, d ld [hli], a ; tile id xor a ld [hli], a ; attributes ret Function89c67: ; menu scrolling? call JoyTextDelay_ForcehJoyDown ; joypad ld b, $0 bit A_BUTTON_F, c jr z, .not_a_button ld b, $1 and a ret .not_a_button bit B_BUTTON_F, c jr z, .not_b_button scf ret .not_b_button xor a bit D_UP_F, c jr z, .not_d_up ld a, $1 .not_d_up bit D_DOWN_F, c jr z, .not_d_down ld a, $2 .not_d_down bit D_LEFT_F, c jr z, .not_d_left ld a, $3 .not_d_left bit D_RIGHT_F, c jr z, .not_d_right ld a, $4 .not_d_right and a ret z ; no dpad pressed dec a ld c, a ld d, $0 ld hl, .ScrollData0 ld a, [wd02f] and a jr z, .got_data ld hl, .ScrollData1 .got_data ld a, [wd011] and a jr z, .got_row ld e, $4 .add_n_times add hl, de dec a jr nz, .add_n_times .got_row ld e, c add hl, de ld a, [hl] and a ret z dec a ld [wd011], a xor a ld [wd012], a ret .ScrollData0: db 0, 2, 0, 0 db 1, 3, 0, 0 db 2, 4, 0, 0 db 3, 0, 0, 0 .ScrollData1: db 0, 0, 0, 0 db 0, 3, 0, 0 db 2, 4, 0, 0 db 3, 0, 0, 0 Function89cdf: ld a, $10 add b ld b, a ld a, $8 add c ld c, a ld e, $2 ld a, $2 ld hl, wVirtualOAMSprite00 .asm_89cee push af push bc ld d, $4 .asm_89cf2 ld a, b ld [hli], a ; y ld a, c ld [hli], a ; x ld a, e ld [hli], a ; tile id ld a, $1 ld [hli], a ; attributes ld a, $8 add c ld c, a inc e dec d jr nz, .asm_89cf2 pop bc ld a, $8 add b ld b, a pop af dec a jr nz, .asm_89cee ret Function89d0d: call Mobile22_SetBGMapMode0 ldh a, [rSVBK] push af ld a, $5 ldh [rSVBK], a ld c, 8 ld de, wBGPals1 .loop push bc ld hl, .Palette1 ld bc, 1 palettes call CopyBytes pop bc dec c jr nz, .loop ld hl, .Palette2 ld de, wBGPals1 + 2 palettes ld bc, 1 palettes call CopyBytes pop af ldh [rSVBK], a call SetPalettes farcall PrintMail call Mobile22_SetBGMapMode1 ld c, 24 call DelayFrames call RestartMapMusic ret .Palette1: RGB 31, 31, 31 RGB 19, 19, 19 RGB 15, 15, 15 RGB 00, 00, 00 .Palette2: RGB 31, 31, 31 RGB 19, 19, 19 RGB 19, 19, 19 RGB 00, 00, 00 Function89d5e: push af call CopyMenuHeader pop af ld [wMenuCursorBuffer], a call Mobile22_SetBGMapMode0 call PlaceVerticalMenuItems call InitVerticalMenuCursor ld hl, w2DMenuFlags1 set 7, [hl] ret Function89d75: push hl call Mobile22_SetBGMapMode0 call _hl_ farcall Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap pop hl jr asm_89d90 Function89d85: push hl call Mobile22_SetBGMapMode0 call _hl_ call CGBOnly_CopyTilemapAtOnce pop hl asm_89d90: call Mobile22_SetBGMapMode0 push hl call _hl_ call Function89dab ld a, [wMenuCursorY] push af call Function891ab pop af pop hl jr c, .asm_89da9 jr z, asm_89d90 scf ret .asm_89da9 and a ret Function89dab: call Mobile22_SetBGMapMode0 farcall MobileMenuJoypad call Mobile22_SetBGMapMode0 ld a, c ld hl, wMenuJoypadFilter and [hl] ret z bit 0, a jr nz, .asm_89dc7 bit 1, a jr nz, .asm_89dd9 xor a ret .asm_89dc7 call PlayClickSFX ld a, [w2DMenuNumRows] ld c, a ld a, [wMenuCursorY] cp c jr z, .asm_89dd9 call PlaceHollowCursor scf ret .asm_89dd9 call PlayClickSFX ld a, $1 and a ret Function89de0: call ClearSprites call Function89e0a jr c, .asm_89e00 ld c, $1 .asm_89dea call Function8a31c jr z, .asm_89dfd ld a, [wMenuCursorY] ld c, a push bc ld hl, Jumptable_89e04 ld a, e dec a rst JumpTable pop bc jr .asm_89dea .asm_89dfd call Function891fe .asm_89e00 call Function8917a ret Jumptable_89e04: dw Function8a62c dw Function8a999 dw Function8ab93 Function89e0a: call OpenSRAMBank4 call Function8b3b0 call CloseSRAM ld hl, Jumptable_89e18 rst JumpTable ret Jumptable_89e18: dw Function89e1e dw Function8a116 dw Function8a2aa Function89e1e: call OpenSRAMBank4 ld bc, $a037 call Function8b36c call CloseSRAM xor a ld [wd02d], a asm_89e2e: ld a, [wd02d] ld hl, Jumptable_89e3c rst JumpTable ret Function89e36: ld hl, wd02d inc [hl] jr asm_89e2e Jumptable_89e3c: dw Function89e6f dw Function89fed dw Function89ff6 dw Function8a03d dw Function89eb9 dw Function89efd dw Function89fce dw Function8a04c dw Function8a055 dw Function8a0e6 dw Function8a0ec dw Function8a0f5 dw Function89e58 dw Function89e68 Function89e58: ld a, $1 call Function8a2fe call Function891fe call Function893e2 call Function89168 and a ret Function89e68: call Function891fe ld a, $1 scf ret Function89e6f: call Function891de call Function89245 call Function89ee1 call Function89e9a hlcoord 7, 4 call Function8a58d ld a, $5 hlcoord 7, 4, wAttrMap call Function8a5a3 ld a, $6 hlcoord 10, 4, wAttrMap call Function8a5a3 call Function891ab call SetPalettes jp Function89e36 Function89e9a: ldh a, [rSVBK] push af ld a, $5 ldh [rSVBK], a ld hl, Palette_89eb1 ld de, wBGPals1 palette 5 ld bc, 1 palettes call CopyBytes pop af ldh [rSVBK], a ret Palette_89eb1: RGB 31, 31, 31 RGB 31, 31, 31 RGB 27, 19, 00 RGB 00, 00, 00 Function89eb9: call Function891fe call Function89ee1 call Function89e9a hlcoord 7, 4 call Function8a58d ld a, $5 hlcoord 7, 4, wAttrMap call Function8a5a3 ld a, $6 hlcoord 10, 4, wAttrMap call Function8a5a3 call Function891ab call SetPalettes jp Function89e36 Function89ee1: call ClearBGPalettes call Function893e2 call Mobile22_SetBGMapMode0 farcall Function4a3a7 farcall MG_Mobile_Layout_CreatePalBoxes hlcoord 1, 0 call Function8a53d ret Function89efd: ld hl, wd012 ld a, $ff ld [hli], a xor a rept 4 ld [hli], a endr ld [hl], a .asm_89f09 ld hl, wd012 inc [hl] ld a, [hli] and $3 jr nz, .asm_89f2e ld a, [hl] cp $4 jr nc, .asm_89f2e ld b, $32 inc [hl] ld a, [hl] dec a jr z, .asm_89f26 ld c, a .asm_89f1f ld a, $b add b ld b, a dec c jr nz, .asm_89f1f .asm_89f26 ld c, $e8 ld a, [wd013] call Function89fa5 .asm_89f2e ld a, [wd013] and a jr z, .asm_89f58 .asm_89f34 call Function89f6a ld e, a ld a, c cp $a8 jr nc, .asm_89f4d cp $46 jr c, .asm_89f4d ld d, $0 dec e ld hl, wd014 add hl, de set 0, [hl] inc e jr .asm_89f51 .asm_89f4d ld a, $2 add c ld c, a .asm_89f51 ld a, e call Function89f77 dec a jr nz, .asm_89f34 .asm_89f58 call DelayFrame ld hl, wd014 ld c, $4 .asm_89f60 ld a, [hli] and a jr z, .asm_89f09 dec c jr nz, .asm_89f60 jp Function89e36 Function89f6a: push af ld de, $10 call Function89f9a ld a, [hli] ld b, a ld a, [hl] ld c, a pop af ret Function89f77: push af ld de, $10 call Function89f9a ld d, $2 .asm_89f80 push bc ld e, $2 .asm_89f83 ld a, b ld [hli], a ld a, c ld [hli], a inc hl inc hl ld a, $8 add c ld c, a dec e jr nz, .asm_89f83 pop bc ld a, $8 add b ld b, a dec d jr nz, .asm_89f80 pop af ret Function89f9a: dec a ld hl, wVirtualOAM and a ret z .asm_89fa0 add hl, de dec a jr nz, .asm_89fa0 ret Function89fa5: ld de, $10 call Function89f9a ld e, $2 ld d, $a .asm_89faf push bc ld a, $2 .asm_89fb2 push af ld a, b ld [hli], a ld a, c ld [hli], a ld a, d inc d ld [hli], a ld a, $1 ld [hli], a ld a, $8 add c ld c, a pop af dec a jr nz, .asm_89fb2 pop bc ld a, $8 add b ld b, a dec e jr nz, .asm_89faf ret Function89fce: call Function8a5b6 ld a, $5 hlcoord 7, 4, wAttrMap call Function8a5a3 ld a, $6 hlcoord 10, 4, wAttrMap call Function8a5a3 call Function89448 call SetPalettes call Function891ab jp Function89e36 Function89fed: ld hl, UnknownText_0x8a102 call PrintText jp Function89e36 Function89ff6: call Function891fe call ClearBGPalettes call Function893cc call Function89807 call Function89492 call Function894ca call OpenSRAMBank4 ld hl, $a603 ld a, -1 ld bc, 8 call ByteFill ld hl, $a603 ld de, wd008 call Function89381 call CloseSRAM call Function8987f call OpenSRAMBank4 hlcoord 1, 13 ld bc, $a007 call Function89a0c call CloseSRAM call Function891ab call Mobile22_ButtonSound jp Function89e36 Function8a03d: ld hl, UnknownText_0x8a107 call Function89209 call PrintText call Function8920f jp Function89e36 Function8a04c: ld hl, UnknownText_0x8a10c call PrintText jp Function89e36 Function8a055: ld c, $7 ld b, $4 .asm_8a059 call Function8a0a1 inc c call Function8a0c9 push bc call Function8a58d pop bc call Function8a0de push bc push hl ld a, $5 call Function8a5a3 pop hl inc hl inc hl inc hl ld a, $6 call Function8a5a3 call CGBOnly_CopyTilemapAtOnce pop bc ld a, c cp $b jr nz, .asm_8a059 call Function8a0a1 hlcoord 12, 4 call Function8a58d ld a, $5 hlcoord 12, 4, wAttrMap call Function8a5a3 pop hl ld a, $6 hlcoord 15, 4, wAttrMap call Function8a5a3 call CGBOnly_CopyTilemapAtOnce jp Function89e36 Function8a0a1: call Mobile22_SetBGMapMode0 push bc call Function8a0c9 ld e, $6 .asm_8a0aa push hl ld bc, $6 add hl, bc ld d, [hl] call Function8a0c1 pop hl ld [hl], d call Function89215 ld bc, $14 add hl, bc dec e jr nz, .asm_8a0aa pop bc ret Function8a0c1: push hl ld bc, wAttrMap - wTileMap add hl, bc ld a, [hl] pop hl ret Function8a0c9: push bc hlcoord 0, 0 ld de, $14 ld a, b and a jr z, .asm_8a0d8 .asm_8a0d4 add hl, de dec b jr nz, .asm_8a0d4 .asm_8a0d8 ld d, $0 ld e, c add hl, de pop bc ret Function8a0de: call Function8a0c9 ld de, wAttrMap - wTileMap add hl, de ret Function8a0e6: call Function8b539 jp Function89e36 Function8a0ec: ld hl, UnknownText_0x8a111 call PrintText jp Function89e36 Function8a0f5: call Function8b555 jp nc, Function8a0ff ld hl, wd02d inc [hl] Function8a0ff: jp Function89e36 UnknownText_0x8a102: ; The CARD FOLDER stores your and your friends' CARDS. A CARD contains information like the person's name, phone number and profile. text_far UnknownText_0x1c5238 text_end UnknownText_0x8a107: ; This is your CARD. Once you've entered your phone number, you can trade CARDS with your friends. text_far UnknownText_0x1c52bc text_end UnknownText_0x8a10c: ; If you have your friend's CARD, you can use it to make a call from a mobile phone on the 2nd floor of a #MON CENTER. text_far UnknownText_0x1c531e text_end UnknownText_0x8a111: ; To safely store your collection of CARDS, you must set a PASSCODE for your CARD FOLDER. text_far UnknownText_0x1c5394 text_end Function8a116: ld a, $1 ld [wd030], a ld hl, MenuHeader_0x8a176 call LoadMenuHeader .asm_8a121 call Mobile22_SetBGMapMode0 call Function8a17b jr c, .asm_8a16b ld a, [wMenuCursorY] ld [wd030], a dec d jr z, .asm_8a140 call Function8a20d jr c, .asm_8a121 xor a call Function8a2fe call Function8916e jr .asm_8a16b .asm_8a140 call Function89174 jr nz, .asm_8a14c call Function8a241 jr c, .asm_8a121 jr .asm_8a15a .asm_8a14c call WaitSFX ld de, SFX_TWINKLE call PlaySFX ld c, $10 call DelayFrames .asm_8a15a call ExitMenu call Function891de call Function893e2 call Function89245 call Function89168 and a ret .asm_8a16b call Function89209 call CloseWindow call Function8920f scf ret MenuHeader_0x8a176: db MENU_BACKUP_TILES ; flags menu_coords 14, 0, SCREEN_WIDTH - 1, 6 Function8a17b: decoord 14, 0 ld b, $5 ld c, $4 call Function89b3b ld hl, MenuHeader_0x8a19a ld a, [wd030] call Function89d5e ld hl, Function8a1b0 call Function89d75 jr nc, .asm_8a198 ld a, $0 .asm_8a198 ld d, a ret MenuHeader_0x8a19a: db MENU_BACKUP_TILES ; flags menu_coords 14, 0, SCREEN_WIDTH - 1, 6 dw MenuData_0x8a1a2 db 1 ; default option MenuData_0x8a1a2: db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING | STATICMENU_WRAP ; flags db 3 ; items db "ใฒใ‚‰ใ@" db "ใ™ใฆใ‚‹@" db "ใ‚‚ใฉใ‚‹@" Function8a1b0: hlcoord 0, 12 ld b, $4 ld c, $12 call Textbox hlcoord 1, 14 ld a, [wMenuCursorY] ld de, Strings_8a1cc dec a ld c, a call Function8919e call PlaceString ret Strings_8a1cc: db "ใ‚ใ„ใ—<NO>ใ›ใ„ใ‚Šใจใ€€ใธใ‚“ใ—ใ‚…ใ†ใ‚’" next "ใŠใ“ใชใ„ใพใ™" db "@" db "ใ‚ใ„ใ—ใƒ•ใ‚ฉใƒซใƒ€ใƒผ<NO>ใ‚ใ„ใ—ใจ" next "ใ‚ใ‚“ใ—ใ‚‡ใ†ใฐใ‚“ใ”ใ†<WO>ใ‘ใ—ใพใ™" db "@" db "ใพใˆ<NO>ใŒใ‚ใ‚“<NI>ใ‚‚ใฉใ‚Šใพใ™" db "@" Function8a20d: ld hl, UnknownText_0x8a232 call PrintText ld a, $2 call Function89259 ret c ld hl, UnknownText_0x8a237 call PrintText ld a, $2 call Function89259 ret c xor a call Function8a2fe ld hl, UnknownText_0x8a23c call PrintText xor a and a ret UnknownText_0x8a232: ; If the CARD FOLDER is deleted, all its CARDS and the PASSCODE will also be deleted. Beware--a deleted CARD FOLDER can't be restored. Want to delete your CARD FOLDER? text_far UnknownText_0x1c53ee text_end UnknownText_0x8a237: ; Are you sure you want to delete it? text_far UnknownText_0x1c5494 text_end UnknownText_0x8a23c: ; The CARD FOLDER has been deleted. text_far UnknownText_0x1c54b9 text_end Function8a241: call LoadStandardMenuHeader call Function891fe call Function8a262 jr nc, .asm_8a254 call Function891fe call Function89b28 scf ret .asm_8a254 call Function891de call ClearBGPalettes call ExitMenu call Function891de and a ret Function8a262: call ClearBGPalettes call Function893e2 call Mobile22_SetBGMapMode0 farcall Function4a3a7 farcall MG_Mobile_Layout_CreatePalBoxes hlcoord 1, 0 call Function8a53d hlcoord 12, 4 call Function8a58d ld a, $5 hlcoord 12, 4, wAttrMap call Function8a5a3 ld a, $6 hlcoord 15, 4, wAttrMap call Function8a5a3 xor a ld [wd02e], a ld bc, wd013 call Function8b36c call Function8b493 call Function891ab call SetPalettes call Function8b5e7 ret Function8a2aa: ld hl, MenuHeader_0x8a2ef call LoadMenuHeader ld hl, UnknownText_0x8a2f4 call PrintText ld a, $1 call Function89259 jr nc, .asm_8a2cf ld hl, UnknownText_0x8a2f9 call PrintText ld a, $2 call Function89259 jr c, .asm_8a2ea call Function8a20d jr .asm_8a2ea .asm_8a2cf call ExitMenu call Function8a241 jr c, .asm_8a2ed ld a, $1 call Function8a313 call CloseSRAM call Function891de call Function89245 call Function89168 and a ret .asm_8a2ea call CloseWindow .asm_8a2ed scf ret MenuHeader_0x8a2ef: db MENU_BACKUP_TILES ; flags menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 UnknownText_0x8a2f4: ; There is an older CARD FOLDER from a previous journey. Do you want to open it? text_far UnknownText_0x1c54dd text_end UnknownText_0x8a2f9: ; Delete the old CARD FOLDER? text_far UnknownText_0x1c552d text_end Function8a2fe: call Function8a313 call Function89305 ld hl, $a603 ld bc, $8 ld a, -1 call ByteFill call CloseSRAM ret Function8a313: ld c, a call OpenSRAMBank4 ld a, c ld [$a60b], a ret Function8a31c: push bc call Mobile22_SetBGMapMode0 farcall Function4a3a7 farcall MG_Mobile_Layout_CreatePalBoxes hlcoord 1, 0 call Function8a53d hlcoord 12, 4 call Function8a58d call Function8a3b2 pop bc ld a, c ld [wMenuCursorBuffer], a ld [wMenuSelection], a call PlaceVerticalMenuItems call InitVerticalMenuCursor ld hl, w2DMenuFlags1 set 7, [hl] .asm_8a34e call Function8a3a2 call Mobile22_SetBGMapMode0 call Function8a453 call Function8a4d3 call Function8a4fc call Function891ab call SetPalettes call Function8a383 jr c, .asm_8a370 jr z, .asm_8a34e .asm_8a36a call Function89448 xor a ld e, a ret .asm_8a370 call Function89448 call PlaceHollowCursor call Function8a3a2 ld a, [wMenuSelection] cp $ff jr z, .asm_8a36a ld e, a and a ret Function8a383: farcall MobileMenuJoypad ld a, c ld hl, wMenuJoypadFilter and [hl] ret z bit 0, a jr nz, .asm_8a399 bit 1, a jr nz, .asm_8a39e xor a ret .asm_8a399 call PlayClickSFX scf ret .asm_8a39e call PlayClickSFX ret Function8a3a2: ld a, [wMenuCursorY] dec a ld hl, wd002 ld e, a ld d, $0 add hl, de ld a, [hl] ld [wMenuSelection], a ret Function8a3b2: ld a, $1 ld [wMenuSelection], a call Function8a4fc call Function8a3df jr nc, .asm_8a3ce decoord 0, 2 ld b, $6 ld c, $9 call Function89b3b ld hl, MenuHeader_0x8a435 jr .asm_8a3db .asm_8a3ce decoord 0, 2 ld b, $8 ld c, $9 call Function89b3b ld hl, MenuHeader_0x8a40f .asm_8a3db call CopyMenuHeader ret Function8a3df: call OpenSRAMBank4 ld hl, $a603 call Function89b45 call CloseSRAM ld hl, wd002 jr c, .asm_8a3f8 ld de, Unknown_8a408 call Function8a400 scf ret .asm_8a3f8 ld de, Unknown_8a40b call Function8a400 and a ret Function8a400: ld a, [de] inc de ld [hli], a cp $ff jr nz, Function8a400 ret Unknown_8a408: db 1, 2, -1 Unknown_8a40b: db 1, 2, 3, -1 MenuHeader_0x8a40f: db MENU_BACKUP_TILES ; flags menu_coords 0, 2, 10, TEXTBOX_Y - 1 dw MenuData_0x8a417 db 1 ; default option MenuData_0x8a417: db STATICMENU_CURSOR | STATICMENU_WRAP ; flags db 4 ; items db "ใ‚ใ„ใ—ใ‚Šใ‚นใƒˆ@" db "ใ˜ใถใ‚“ใฎใ€€ใ‚ใ„ใ—@" db "ใ‚ใ„ใ—ใ“ใ†ใ‹ใ‚“@" db "ใ‚„ใ‚ใ‚‹@" MenuHeader_0x8a435: db MENU_BACKUP_TILES ; flags menu_coords 0, 2, 10, 9 dw MenuData_0x8a43d db 1 ; default option MenuData_0x8a43d: db STATICMENU_CURSOR | STATICMENU_WRAP ; flags db 3 ; items db "ใ‚ใ„ใ—ใ‚Šใ‚นใƒˆ@" db "ใ˜ใถใ‚“ใฎใ€€ใ‚ใ„ใ—@" db "ใ‚„ใ‚ใ‚‹@" Function8a453: hlcoord 0, 12 ld b, $4 ld c, $12 call Textbox hlcoord 1, 14 ld de, String_8a476 ld a, [wMenuSelection] cp $ff jr z, .asm_8a472 ld de, Strings_8a483 dec a ld c, a call Function8919e .asm_8a472 call PlaceString ret String_8a476: db "ใพใˆ<NO>ใŒใ‚ใ‚“<NI>ใ‚‚ใฉใ‚Šใพใ™@" Strings_8a483: db "ใŠใจใ‚‚ใ ใก<NO>ใ‚ใ„ใ—ใฏ" next "ใ“ใ“<NI>ใ„ใ‚ŒใฆใŠใใพใ™@" db "ใงใ‚“ใ‚ใฐใ‚“ใ”ใ†<WO>ใ„ใ‚Œใ‚‹ใจ" next "ใ‚ใ„ใ—ใ“ใ†ใ‹ใ‚“<GA>ใงใใพใ™@" db "ใจใ‚‚ใ ใกใจใ€€ใ˜ใถใ‚“<NO>ใ‚ใ„ใ—ใ‚’" next "ใ›ใใŒใ„ใ›ใ‚“ใงใ€€ใ“ใ†ใ‹ใ‚“ใ€€ใ—ใพใ™@" Function8a4d3: ld a, [wMenuSelection] cp $1 jr nz, .asm_8a4eb ld a, $5 hlcoord 12, 4, wAttrMap call Function8a5a3 ld a, $7 hlcoord 15, 4, wAttrMap call Function8a5a3 ret .asm_8a4eb ld a, $7 hlcoord 12, 4, wAttrMap call Function8a5a3 ld a, $6 hlcoord 15, 4, wAttrMap call Function8a5a3 ret Function8a4fc: ld a, [wMenuSelection] cp $3 jr nz, asm_8a529 ld hl, wd012 ld a, [hli] ld b, a ld a, [hld] add b ld [hl], a ld b, a ld c, $80 call Function89cdf call Function8a515 ret Function8a515: ld hl, wd012 ld a, [hl] cp $38 jr c, .asm_8a520 cp $3c ret c .asm_8a520 ld a, [wd013] cpl inc a ld [wd013], a ret asm_8a529: ld hl, wd012 ld a, $3c ld [hli], a ld a, $ff ld [hli], a ld hl, wVirtualOAM xor a ld bc, 8 * SPRITEOAMSTRUCT_LENGTH call ByteFill ret Function8a53d: push hl ld a, $15 ld c, $8 ld de, $14 call Function8a573 ld a, $1d ld c, $9 call Function8a57c inc a ld [hl], a call Function8a584 pop hl add hl, de ld a, $1f ld c, $8 call Function8a573 dec hl ld a, $51 ld [hli], a ld a, $26 ld c, $1 call Function8a57c ld a, $52 ld c, $3 call Function8a573 ld a, $27 ld c, $6 Function8a573: ld [hl], a call Function8a584 inc a dec c jr nz, Function8a573 ret Function8a57c: ld [hl], a call Function8a584 dec c jr nz, Function8a57c ret Function8a584: push af ld a, $4 call Function89215 inc hl pop af ret Function8a58d: ld a, $2d ld bc, $606 ld de, $14 .asm_8a595 push bc push hl .asm_8a597 ld [hli], a inc a dec c jr nz, .asm_8a597 pop hl add hl, de pop bc dec b jr nz, .asm_8a595 ret Function8a5a3: ld bc, $603 ld de, $14 .asm_8a5a9 push bc push hl .asm_8a5ab ld [hli], a dec c jr nz, .asm_8a5ab pop hl add hl, de pop bc dec b jr nz, .asm_8a5a9 ret Function8a5b6: ldh a, [rSVBK] push af ld a, $5 ldh [rSVBK], a ld hl, Palette_8a5e5 ld de, wBGPals1 + 4 palettes ld bc, 3 palettes call CopyBytes ld hl, Palette_8a5fd ld de, wOBPals1 ld bc, 1 palettes call CopyBytes ld hl, Palette_8a605 ld de, wOBPals1 + 1 palettes ld bc, 1 palettes call CopyBytes pop af ldh [rSVBK], a ret Palette_8a5e5: RGB 31, 31, 31 RGB 27, 19, 00 RGB 07, 11, 22 RGB 00, 00, 00 RGB 31, 31, 31 RGB 16, 16, 31 RGB 27, 19, 00 RGB 00, 00, 00 RGB 31, 31, 31 RGB 31, 00, 00 RGB 27, 19, 00 RGB 00, 00, 00 Palette_8a5fd: RGB 00, 00, 00 RGB 00, 00, 00 RGB 00, 00, 00 RGB 31, 31, 31 Palette_8a605: RGB 00, 00, 00 RGB 14, 18, 31 RGB 16, 16, 31 RGB 31, 31, 31 Function8a60d: ldh a, [rSVBK] push af ld a, $5 ldh [rSVBK], a ld hl, Palette_8a624 ld de, wOBPals1 ld bc, 1 palettes call CopyBytes pop af ldh [rSVBK], a ret Palette_8a624: RGB 31, 31, 31 RGB 31, 31, 31 RGB 31, 31, 31 RGB 00, 00, 00 Function8a62c: call LoadStandardMenuHeader call Function891fe xor a call Function8b94a call Function8b677 .asm_8a639 xor a ld [wd033], a ld [wd032], a ld [wd0e3], a call Function8b7bd ld a, c and a jr z, .asm_8a66a ld [wMenuSelection], a ld b, a ld a, [wScrollingMenuCursorPosition] inc a ld [wd034], a push bc call Function8b960 ld a, c pop bc jr z, .asm_8a639 ld c, a ld hl, Jumptable_8a671 ld a, b ld [wMenuSelection], a ld a, c dec a rst JumpTable jr .asm_8a639 .asm_8a66a call Function891fe call Function89b28 ret Jumptable_8a671: dw Function8a679 dw Function8a6cd dw Function8a8c3 dw Function8a930 Function8a679: call Function891de call ClearBGPalettes call Function893cc call OpenSRAMBank4 call Function8931b call Function89844 call CloseSRAM call OpenSRAMBank4 call Function8939a call Function89856 hlcoord 1, 13 call Function899fe call Function891ab call CloseSRAM .asm_8a6a3 call Function89a57 jr c, .asm_8a6a3 and a jr z, Function8a679 ld hl, Jumptable_8a6bc dec a rst JumpTable jr c, Function8a679 call Function891fe call Function8b677 call Function89448 ret Jumptable_8a6bc: dw Function8a6c0 dw Function8a6c5 Function8a6c0: call PlayClickSFX and a ret Function8a6c5: call PlayClickSFX call Function89d0d scf ret Function8a6cd: call Function891de call ClearBGPalettes call Function893cc call OpenSRAMBank4 call Function8931b call Function89844 call Function8a757 call CloseSRAM .asm_8a6e5 call OpenSRAMBank4 call Function8931b call Function89856 call Function89a2e call Function891ab xor a ld [wd02f], a call CloseSRAM .asm_8a6fb call Function89b97 call Function89c67 jr c, .asm_8a718 ld a, b and a jr z, .asm_8a6fb call PlayClickSFX call Function89448 ld a, [wd011] ld hl, Jumptable_8a74f rst JumpTable jr nc, .asm_8a6e5 jr .asm_8a742 .asm_8a718 call OpenSRAMBank4 call Function8a765 call CloseSRAM jr nc, .asm_8a73f call Mobile22_SetBGMapMode0 call Function89448 call Function89a23 hlcoord 1, 13 ld de, String_89135 call PlaceString call WaitBGMap ld a, $2 call Function89254 jr c, .asm_8a6e5 .asm_8a73f call CloseSRAM .asm_8a742 call ClearBGPalettes call Function89448 call Function891d3 call Function8b677 ret Jumptable_8a74f: dw Function8a78c dw Function8a7cb dw Function8a818 dw Function8a8a1 Function8a757: call Function8939a xor a ld [wd010], a ld [wd011], a ld [wd012], a ret Function8a765: call Function8931b push bc ld hl, $0 add hl, bc ld de, wd002 ld c, $6 call Function89185 pop bc jr nz, .asm_8a78a push bc ld hl, $11 add hl, bc ld de, wd008 ld c, $8 call Function89185 pop bc jr nz, .asm_8a78a and a ret .asm_8a78a scf ret Function8a78c: call Function891fe ld de, wd002 ld b, NAME_FRIEND farcall NamingScreen call OpenSRAMBank4 call Function8931b push bc ld hl, $0 add hl, bc ld d, h ld e, l ld hl, wd002 call InitName call CloseSRAM call DelayFrame call JoyTextDelay call Function891de call ClearBGPalettes call Function893cc call OpenSRAMBank4 pop bc call Function89844 call CloseSRAM and a ret Function8a7cb: ld a, [wMenuSelection] push af call Function891de ld de, wd008 ld c, $0 farcall Function17a68f jr c, .asm_8a7f4 ld hl, wd008 ld a, $ff ld bc, $8 call ByteFill ld h, d ld l, e ld de, wd008 ld c, $8 call Function89193 .asm_8a7f4 pop af ld [wMenuSelection], a call Function891de call ClearBGPalettes call Function893cc call OpenSRAMBank4 call Function8931b call Function89844 call Function89856 call Function89a2e call Function891ab call CloseSRAM and a ret Function8a818: call Function89a23 ld hl, wd002 call Function89331 jr c, .asm_8a875 ld hl, wd008 call Function89b45 jr nc, .asm_8a87a call OpenSRAMBank4 call Function8a765 jr nc, .asm_8a863 call Function8931b push bc ld hl, $0 add hl, bc ld d, h ld e, l ld hl, wd002 ld c, $6 call Function89193 pop bc ld hl, $11 add hl, bc ld d, h ld e, l ld hl, wd008 ld c, $8 call Function89193 hlcoord 1, 13 ld de, .string_8a868 call PlaceString call WaitBGMap call JoyWaitAorB .asm_8a863 call CloseSRAM scf ret .string_8a868 db "ใ‚ใ„ใ—<WO>ใ‹ใใ‹ใˆใ€€ใพใ—<TA!>@" .asm_8a875 ld de, String_8a88b jr .asm_8a87d .asm_8a87a ld de, String_8911c .asm_8a87d hlcoord 1, 13 call PlaceString call WaitBGMap call JoyWaitAorB and a ret String_8a88b: db "ใŠใจใ‚‚ใ ใก<NO>ใชใพใˆใŒ" next "ใ‹ใ‹ใ‚Œใฆใ€€ใ„ใพใ›ใ‚“๏ผ@" Function8a8a1: call OpenSRAMBank4 call Function8a765 call CloseSRAM jr nc, .asm_8a8bf call Function89a23 hlcoord 1, 13 ld de, String_89135 call PlaceString ld a, $2 call Function89254 jr c, .asm_8a8c1 .asm_8a8bf scf ret .asm_8a8c1 and a ret Function8a8c3: call Function891de call ClearBGPalettes call Function893cc call OpenSRAMBank4 call Function8931b call Function89844 call Function8939a call Function89856 call CloseSRAM call Function891ab hlcoord 1, 13 ld de, String_8a919 call PlaceString ld a, $2 call Function89254 jr c, .asm_8a90f call OpenSRAMBank4 call Function892b4 call CloseSRAM call Function89a23 call Mobile22_SetBGMapMode0 hlcoord 1, 13 ld de, String_8a926 call PlaceString call WaitBGMap call JoyWaitAorB .asm_8a90f call Function89448 call Function891fe call Function8b677 ret String_8a919: db "ใ“ใฎใƒ‡ใƒผใ‚ฟ<WO>ใ‘ใ—ใพใ™ใ‹๏ผŸ@" String_8a926: db "ใƒ‡ใƒผใ‚ฟ<WO>ใ‘ใ—ใพใ—<TA!>@" Function8a930: ld a, [wMenuSelection] push af xor a ld [wd032], a ld a, $1 ld [wd033], a ld a, [wd034] ld [wd0e3], a .asm_8a943 call Function8b7bd ld a, [wMenuJoypad] and $1 jr nz, .asm_8a953 ld a, c and a jr nz, .asm_8a943 pop af ret .asm_8a953 call OpenSRAMBank4 pop af cp c jr z, .asm_8a995 push bc ld [wMenuSelection], a call Function8931b push bc ld h, b ld l, c ld de, wd002 ld bc, $25 call CopyBytes pop de pop bc ld a, c ld [wMenuSelection], a call Function8931b push bc ld h, b ld l, c ld bc, $25 call CopyBytes pop de ld hl, wd002 ld bc, $25 call CopyBytes ld de, SFX_SWITCH_POKEMON call WaitPlaySFX ld de, SFX_SWITCH_POKEMON call WaitPlaySFX .asm_8a995 call CloseSRAM ret Function8a999: ld hl, MenuHeader_0x8a9c9 call LoadMenuHeader ld c, $1 .asm_8a9a1 call Function8a9ce jr c, .asm_8a9bb push bc push de call LoadStandardMenuHeader pop de dec e ld a, e ld hl, Jumptable_8a9c5 rst JumpTable call Function891fe call Function89b28 pop bc jr .asm_8a9a1 .asm_8a9bb call Function89209 call CloseWindow call Function8920f ret Jumptable_8a9c5: dw Function8aa0a dw Function8ab3b MenuHeader_0x8a9c9: db MENU_BACKUP_TILES ; flags menu_coords 11, 4, 18, TEXTBOX_Y - 1 Function8a9ce: push bc decoord 11, 4 ld b, $6 ld c, $6 call Function89b3b pop bc ld a, c ld hl, MenuHeader_0x8a9f2 call Function89d5e ld hl, Function8aa09 call Function89d85 jr c, .asm_8a9ed ld c, a ld e, a and a ret .asm_8a9ed ld c, a ld e, $0 scf ret MenuHeader_0x8a9f2: db MENU_BACKUP_TILES ; flags menu_coords 11, 4, 18, TEXTBOX_Y - 1 dw MenuData_0x8a9fa db 1 ; default option MenuData_0x8a9fa: db STATICMENU_CURSOR | STATICMENU_WRAP ; flags db 3 ; items db "ใธใ‚“ใ—ใ‚…ใ†@" db "ใฟใ‚‹@" db "ใ‚„ใ‚ใ‚‹@" Function8aa09: ret Function8aa0a: ld a, $1 ld [wd02f], a ld [wd011], a xor a ld [wd010], a ld [wd012], a call OpenSRAMBank4 ld hl, $a603 ld de, wd008 call Function89381 call CloseSRAM call Function891fe call ClearBGPalettes call Function893cc call Function89807 call Function89492 call Function894ca .asm_8aa3a call Function8987f call Function89a2e call Function891ab .asm_8aa43 call Function89b97 call Function89c67 jr c, .asm_8aa61 ld a, b and a jr z, .asm_8aa43 call PlayClickSFX call Function89448 ld a, [wd011] dec a ld hl, Jumptable_8aa6d rst JumpTable jr nc, .asm_8aa3a jr .asm_8aa69 .asm_8aa61 call Function89448 call Function8ab11 jr nc, .asm_8aa3a .asm_8aa69 call Function89448 ret Jumptable_8aa6d: dw Function8aa73 dw Function8aab6 dw Function8ab11 Function8aa73: ld a, [wMenuSelection] ld e, a push de call Function891de ld de, wd008 ld c, $0 farcall Function17a68f jr c, .asm_8aa9d ld hl, wd008 ld a, $ff ld bc, $8 call ByteFill ld h, d ld l, e ld de, wd008 ld c, $8 call Function89193 .asm_8aa9d call Function891fe call ClearBGPalettes call Function893cc call Function89807 call Function89492 call Function894ca pop de ld a, e ld [wMenuSelection], a and a ret Function8aab6: call Function89a23 ld hl, wd008 call Function89b45 jr nc, Function8ab00 call OpenSRAMBank4 ld de, wd008 ld hl, $a603 ld c, $8 call Function89185 jr z, .asm_8aaeb ld hl, wd008 ld de, $a603 ld c, $8 call Function89193 hlcoord 1, 13 ld de, String_8aaf0 call PlaceString call WaitBGMap call JoyWaitAorB .asm_8aaeb call CloseSRAM scf ret String_8aaf0: db "ใ‚ใŸใ‚‰ใ—ใ„ใ€€ใ‚ใ„ใ—<PKMN>ใงใใพใ—<LF>@" Function8ab00: ld de, String_8911c hlcoord 1, 13 call PlaceString call WaitBGMap call Mobile22_ButtonSound and a ret Function8ab11: call OpenSRAMBank4 ld hl, $a603 ld de, wd008 ld c, $8 call Function89185 call CloseSRAM jr z, .asm_8ab37 call Function89a23 hlcoord 1, 13 ld de, String_89135 call PlaceString ld a, $2 call Function89254 jr c, .asm_8ab39 .asm_8ab37 scf ret .asm_8ab39 and a ret Function8ab3b: .pressed_start call Function891fe call ClearBGPalettes call Function893cc call Function89807 call Function89492 call Function894ca call OpenSRAMBank4 ld hl, $a603 ld de, wd008 call Function89381 call CloseSRAM call Function8987f call OpenSRAMBank4 hlcoord 1, 13 ld bc, $a007 call Function89a0c call CloseSRAM call Function891ab call .JoypadLoop jr c, .pressed_start ret .JoypadLoop: call JoyTextDelay_ForcehJoyDown bit A_BUTTON_F, c jr nz, .a_b_button bit B_BUTTON_F, c jr nz, .a_b_button bit START_F, c jr z, .JoypadLoop call PlayClickSFX call Function89d0d scf ret .a_b_button call PlayClickSFX and a ret Function8ab93: call ClearBGPalettes call LoadStandardMenuHeader farcall Function105688 call ClearSprites call Function891fe call Function89b28 ret Function8aba9: ld a, $2 call Function8b94a ld a, $1 ld [wd032], a .asm_8abb3 call Function891fe call Function8b677 .asm_8abb9 call Function8b7bd jr z, .asm_8abdf ld a, c ld [wMenuSelection], a call OpenSRAMBank4 call Function8931b ld hl, $0011 add hl, bc call Function89b45 call CloseSRAM jr c, .asm_8abe2 ld de, SFX_WRONG call WaitPlaySFX call CloseSRAM jr .asm_8abb9 .asm_8abdf xor a ld c, a ret .asm_8abe2 call PlayClickSFX .asm_8abe5 call Function891de call ClearBGPalettes call Function893cc call OpenSRAMBank4 call Function8931b call Function89844 call CloseSRAM call OpenSRAMBank4 call Function8939a call Function89856 hlcoord 1, 13 call Function899fe call CloseSRAM call Function891ab .asm_8ac0f call Function89a57 jr c, .asm_8ac0f and a jr z, .asm_8abe5 cp $2 jr z, .asm_8ac0f hlcoord 0, 12 ld b, $4 ld c, $12 call Textbox hlcoord 1, 14 ld de, String_8ac3b call PlaceString ld a, $1 call Function8925e jp c, .asm_8abb3 ld a, [wMenuSelection] ld c, a ret String_8ac3b: db "ใ“<NO>ใจใ‚‚ใ ใก<NI>ใงใ‚“ใ‚ใ‚’" next "ใ‹ใ‘ใพใ™ใ‹๏ผŸ@" Function8ac4e: xor a ld [wMenuSelection], a push de call Function891de call ClearBGPalettes call Function893cc pop bc call Function89844 call Function8939a call Function89856 hlcoord 1, 13 call Function899fe call Function891ab ret Function8ac70: push de ld a, $3 call Function8b94a Function8ac76: call Function891fe call Function8b677 Function8ac7c: call Function8b7bd jr z, .asm_8acf0 ld a, c ld [wd02f], a ld [wMenuSelection], a call OpenSRAMBank4 call Function8931b call Function8932d call CloseSRAM jr nc, .asm_8acb0 call OpenSRAMBank4 ld hl, $0011 add hl, bc call Function89b45 call CloseSRAM jr nc, .asm_8accc call OpenSRAMBank4 call Function892b7 call CloseSRAM jr .asm_8accc .asm_8acb0 call Function8ad0b jr c, Function8ac76 and a jr nz, .asm_8accc call OpenSRAMBank4 ld h, b ld l, c ld d, $0 ld e, $6 add hl, de ld d, h ld e, l pop hl ld c, $1f call Function89193 jr .asm_8ace4 .asm_8accc pop hl call OpenSRAMBank4 ld d, b ld e, c ld c, $6 call Function89193 ld a, $6 add e ld e, a ld a, $0 adc d ld d, a ld c, $1f call Function89193 .asm_8ace4 call CloseSRAM call LoadStandardFont ld a, [wd02f] ld c, a and a ret .asm_8acf0 ld hl, UnknownText_0x8ad06 call PrintText ld a, $2 call Function89259 jp c, Function8ac7c call LoadStandardFont pop de ld c, $0 scf ret UnknownText_0x8ad06: ; Finish registering CARDS? text_far UnknownText_0x1c554a text_end Function8ad0b: .asm_8ad0b ld a, [wMenuSelection] ld [wd02f], a call Function891de call ClearBGPalettes call Function893cc call OpenSRAMBank4 call Function8931b push bc call Function89844 call Function8939a call Function89856 hlcoord 1, 13 call Function899fe call CloseSRAM call Function891ab pop bc .asm_8ad37 push bc call Function89a57 pop bc jr c, .asm_8ad37 and a jr z, .asm_8ad0b cp $2 jr z, .asm_8ad37 call Mobile22_SetBGMapMode0 push bc hlcoord 0, 12 ld b, $4 ld c, $12 call Textbox ld de, String_8ad89 hlcoord 1, 14 call PlaceString ld a, $2 call Function8925e jr c, .asm_8ad87 call Mobile22_SetBGMapMode0 hlcoord 0, 12 ld b, $4 ld c, $12 call Textbox ld de, String_8ad9c hlcoord 1, 14 call PlaceString ld a, $1 call Function8925e jr c, .asm_8ad84 ld a, $0 jr .asm_8ad86 .asm_8ad84 ld a, $1 .asm_8ad86 and a .asm_8ad87 pop bc ret String_8ad89: db "ใ“<NO>ใ‚ใ„ใ—<WO>ใ‘ใ—ใฆ" next "ใ„ใ‚Œใ‹ใˆใพใ™ใ‹๏ผŸ@" String_8ad9c: db "ใŠใจใ‚‚ใ ใก<NO>ใชใพใˆใ‚’" next "ใฎใ“ใ—ใฆใ€€ใŠใใพใ™ใ‹๏ผŸ@" Function8adb3: call Function891de call Function8a262 push af call Function891de pop af ret Function8adbf: call OpenSRAMBank4 ld hl, $a603 call Function89b45 call CloseSRAM ret Function8adcc: call OpenSRAMBank4 call Function8b3b0 call CloseSRAM ret nc cp $2 ret z scf ret