text stringlengths 1 1.05M |
|---|
page ,132
;---------------------------Module-Header-------------------------------;
; Module Name: MATH.ASM
;
; Contains FIXED point math routines.
;
; Created: Sun 30-Aug-1987 19:28:30
; Author: Charles Whitmer [chuckwh]
;
; Copyright (c) 1987 Microsoft Corporation
;-----------------------------------------------------------------------;
?WIN = 0
?PLM = 1
?NODATA = 0
.286
.xlist
include cmacros.inc
include windows.inc
.list
externA __WinFlags
UQUAD struc
uq0 dw ?
uq1 dw ?
uq2 dw ?
uq3 dw ?
UQUAD ends
; The following two equates are just used as shorthand
; for the "word ptr" and "byte ptr" overrides.
wptr equ word ptr
bptr equ byte ptr
; The following structure should be used to access high and low
; words of a DWORD. This means that "word ptr foo[2]" -> "foo.hi".
LONG struc
lo dw ?
hi dw ?
LONG ends
EAXtoDXAX macro
shld edx,eax,16 ; move HIWORD(eax) to dx
endm
DXAXtoEAX macro
ror eax,16 ; xchg HIWORD(eax) and LOWORD(eax)
shrd eax,edx,16 ; move LOWORD(edx) to HIWORD(eax)
endm
neg32 macro hi, lo
neg lo
adc hi,0 ; carry set unless lo zero
neg hi
endm
ifndef SEGNAME
SEGNAME equ <_TEXT>
endif
createSeg %SEGNAME, CodeSeg, word, public, CODE
sBegin CodeSeg
assumes cs,CodeSeg
assumes ds,nothing
assumes es,nothing
;---------------------------Public-Routine------------------------------;
; long muldiv32(long, long, long)
;
; multiples two 32 bit values and then divides the result by a third
; 32 bit value with full 64 bit presision
;
; lResult = (lNumber * lNumerator) / lDenominator with correct rounding
;
; Entry:
; lNumber = number to multiply by nNumerator
; lNumerator = number to multiply by nNumber
; lDenominator = number to divide the multiplication result by.
;
; Returns:
; DX:AX = result of multiplication and division.
;
; Error Returns:
; none
; Registers Preserved:
; DS,ES,SI,DI
; History:
; Fri 05-Oct-1990 -by- Rob Williams [Robwi]
; Behavior consistent with MulDiv16 routine (signed, no int 0 on overflow)
; Stole muldiv16 psuedocode
;
; Wed 14-June-1990 -by- Todd Laney [ToddLa]
; converted it to 386/286 code. (by checking __WinFlags)
;
; Tue 08-May-1990 -by- Rob Williams [Robwi]
; Wrote it.
;
;----------------------------Pseudo-Code--------------------------------;
; long FAR PASCAL muldiv32(long, long, long)
; long l;
; long Numer;
; long Denom;
; {
;
; Sign = sign of Denom; // Sign will keep track of final sign //
;
;
; if (Denom < 0)
; {
; negate Denom; // make sure Denom is positive //
; }
;
; if (l < 0)
; {
; negate l; // make sure l is positive //
; }
;
; make Sign reflect any sign change;
;
;
; if (Numer < 0)
; {
; negate Numer; // make sure Numer is positive //
; }
;
; make Sign reflect any sign change;
;
; Numer *= l;
; Numer += (Denom/2); // adjust for rounding //
;
; if (overflow) // check for overflow, and handle divide by zero //
; {
; jump to md5;
; }
;
; result = Numer/Denom;
;
; if (overflow) // check again to see if overflow occured //
; {
; jump to md5;
; }
;
; if (Sign is negative) // put sign on the result //
; {
; negate result;
; }
;
;md6:
; return(result);
;
;md5:
; DX = 7FFF; // indicate overflow by //
; AX = 0xFFFF // return largest integer //
; if (Sign is negative)
; {
; DX = 0x8000; // with correct sign //
; AX = 0x0000;
; }
;
; jump to md6;
; }
;-----------------------------------------------------------------------;
assumes ds,nothing
assumes es,nothing
cProc muldiv32,<PUBLIC,FAR,NODATA,NONWIN>,<>
; ParmD lNumber
; ParmD lNumerator
; ParmD lDenominator
cBegin <nogen>
mov ax,__WinFlags
test ax,WF_CPU286+WF_CPU086+WF_CPU186
jz md32_1
jmp NEAR PTR muldiv32_286
md32_1:
errn$ muldiv32_386
cEnd <nogen>
cProc muldiv32_386,<PUBLIC,FAR,NODATA,NONWIN>,<>
ParmD lNumber
ParmD lNumerator
ParmD lDenominator
cBegin
.386
mov ebx,lDenominator ; get the demoninator
mov ecx,ebx ; ECX holds the final sign in hiword
or ebx,ebx ; ensure the denominator is positive
jns md386_1
neg ebx
md386_1:
mov eax,lNumber ; get the long we are multiplying
xor ecx,eax ; make ECX reflect any sign change
or eax,eax ; ensure the long is positive
jns md386_2
neg eax
md386_2:
mov edx,lNumerator ; get the numerator
xor ecx,edx ; make ECX reflect any sign change
or edx,edx ; ensure the numerator is positive
jns md386_3
neg edx
md386_3:
mul edx ; multiply
mov cx,bx ; get half of the demoninator to adjust for rounding
sar ebx,1
add eax,ebx ; adjust for possible rounding error
adc edx,0 ; this is really a long addition
sal ebx,1 ; restore the demoninator
or bx,cx ; fix bottom bit
cmp edx,ebx ; check for overflow
jae md386_5 ; (ae handles /0 case)
div ebx ; divide
or eax,eax ; If sign is set, then overflow occured
js md386_5 ; Overflow.
or ecx,ecx ; put the sign on the result
jns md386_6
neg eax
md386_6:
EAXtoDXAX ; convert eax to dx:ax for 16 bit programs
.286
cEnd
.386
md386_5:
mov eax,7FFFFFFFh ; return the largest integer
or ecx,ecx ; with the correct sign
jns md386_6
not eax
jmp md386_6
.286
cProc muldiv32_286,<PUBLIC,FAR,NODATA,NONWIN>,<di,si>
ParmD lNumber
ParmD lNumerator
ParmD lDenominator
LocalW wSign
cBegin
mov dx,lDenominator.hi ; get the demoninator
mov si,dx ; SI holds the final sign
or dx,dx ; ensure the denominator is positive
jns md286_1
neg32 dx, lDenominator.lo
mov lDenominator.hi, dx
md286_1:
mov ax,lNumber.lo ; get the long we are multiplying
mov dx,lNumber.hi
xor si,dx ; make ECX reflect any sign change
or dx,dx ; ensure the long is positive
jns md286_2
neg32 dx, ax
md286_2:
mov bx,lNumerator.lo ; get the numerator
mov cx,lNumerator.hi ; get the numerator
xor si,cx ; make ECX reflect any sign change
or cx,cx ; ensure the numerator is positive
jns md286_3
neg32 cx, bx
md286_3:
mov wSign, si ; save sign
call dmul ; multiply (result in dx:cx:bx:ax)
mov si, lDenominator.hi
mov di, lDenominator.lo
sar si, 1 ; get half of the demoninator
rcr di, 1 ; to adjust for rounding
add ax, di ; adjust for possible rounding error
adc bx, si
adc cx, 0
adc dx, 0 ; this is really a long addition
sal di, 1 ; restore the demoninator
rcl si, 1
or di, lDenominator.lo ; fix bottom bit
cmp dx, si ; begin overflow check (unsigned for div 0 check)
ja md286_5 ; overflow
jb md286_7 ; no overflow
cmp cx, di
jae md286_5 ; overflow
md286_7:
call qdiv ; DX:AX is quotient
or dx,dx ; If sign is set, then overflow occured
js md286_5 ; Overflow.
mov cx, wSign
or cx,cx ; put the sign on the result
jns md286_6
neg32 dx,ax
md286_6:
cEnd
md286_5:
mov cx, wSign
mov ax, 0FFFFh ; return the largest integer
mov dx, 7FFFh
or cx, cx ; with the correct sign
jns md286_6
not dx
not ax
jmp md286_6
cProc muldivru32,<PUBLIC,FAR,NODATA,NONWIN>,<>
; ParmD lNumber
; ParmD lNumerator
; ParmD lDenominator
cBegin <nogen>
mov ax,__WinFlags
test ax,WF_CPU286+WF_CPU086+WF_CPU186
jz mdru32_1
jmp NEAR PTR muldivru32_286
mdru32_1:
errn$ muldivru32_386
cEnd <nogen>
cProc muldivru32_386,<PUBLIC,FAR,NODATA,NONWIN>,<>
ParmD lNumber
ParmD lNumerator
ParmD lDenominator
cBegin
.386
mov ebx,lDenominator ; get the demoninator
mov ecx,ebx ; ECX holds the final sign in hiword
or ebx,ebx ; ensure the denominator is positive
jns mdru386_1
neg ebx
mdru386_1:
mov eax,lNumber ; get the long we are multiplying
xor ecx,eax ; make ECX reflect any sign change
or eax,eax ; ensure the long is positive
jns mdru386_2
neg eax
mdru386_2:
mov edx,lNumerator ; get the numerator
xor ecx,edx ; make ECX reflect any sign change
or edx,edx ; ensure the numerator is positive
jns mdru386_3
neg edx
mdru386_3:
mul edx ; multiply
mov cx,bx ; get demoninator - 1 to adjust for rounding
sub ebx,1
add eax,ebx ; adjust for possible rounding error
adc edx,0 ; this is really a long addition
add ebx,1 ; restore the demoninator
cmp edx,ebx ; check for overflow
jae mdru386_5 ; (ae handles /0 case)
div ebx ; divide
or eax,eax ; If sign is set, then overflow occured
js mdru386_5 ; Overflow.
or ecx,ecx ; put the sign on the result
jns mdru386_6
neg eax
mdru386_6:
EAXtoDXAX ; convert eax to dx:ax for 16 bit programs
.286
cEnd
.386
mdru386_5:
mov eax,7FFFFFFFh ; return the largest integer
or ecx,ecx ; with the correct sign
jns mdru386_6
not eax
jmp mdru386_6
.286
cProc muldivru32_286,<PUBLIC,FAR,NODATA,NONWIN>,<di,si>
ParmD lNumber
ParmD lNumerator
ParmD lDenominator
LocalW wSign
cBegin
mov dx,lDenominator.hi ; get the demoninator
mov si,dx ; SI holds the final sign
or dx,dx ; ensure the denominator is positive
jns mdru286_1
neg32 dx, lDenominator.lo
mov lDenominator.hi, dx
mdru286_1:
mov ax,lNumber.lo ; get the long we are multiplying
mov dx,lNumber.hi
xor si,dx ; make ECX reflect any sign change
or dx,dx ; ensure the long is positive
jns mdru286_2
neg32 dx, ax
mdru286_2:
mov bx,lNumerator.lo ; get the numerator
mov cx,lNumerator.hi ; get the numerator
xor si,cx ; make ECX reflect any sign change
or cx,cx ; ensure the numerator is positive
jns mdru286_3
neg32 cx, bx
mdru286_3:
mov wSign, si ; save sign
call dmul ; multiply (result in dx:cx:bx:ax)
mov si, lDenominator.hi
mov di, lDenominator.lo
sub di, 1 ; get demoninator - 1
sbb si, 0 ; to adjust for rounding
add ax, di ; adjust for possible rounding error
adc bx, si
adc cx, 0
adc dx, 0 ; this is really a long addition
add di, 1 ; restore the demoninator
adc si, 0
cmp dx, si ; begin overflow check (unsigned for div 0 check)
ja mdru286_5 ; overflow
jb mdru286_7 ; no overflow
cmp cx, di
jae mdru286_5 ; overflow
mdru286_7:
call qdiv ; DX:AX is quotient
or dx,dx ; If sign is set, then overflow occured
js mdru286_5 ; Overflow.
mov cx, wSign
or cx,cx ; put the sign on the result
jns mdru286_6
neg32 dx,ax
mdru286_6:
cEnd
mdru286_5:
mov cx, wSign
mov ax, 0FFFFh ; return the largest integer
mov dx, 7FFFh
or cx, cx ; with the correct sign
jns mdru286_6
not dx
not ax
jmp mdru286_6
cProc muldivrd32,<PUBLIC,FAR,NODATA,NONWIN>,<>
; ParmD lNumber
; ParmD lNumerator
; ParmD lDenominator
cBegin <nogen>
mov ax,__WinFlags
test ax,WF_CPU286+WF_CPU086+WF_CPU186
jz mdrd32_1
jmp NEAR PTR muldivrd32_286
mdrd32_1:
errn$ muldivrd32_386
cEnd <nogen>
cProc muldivrd32_386,<PUBLIC,FAR,NODATA,NONWIN>,<>
ParmD lNumber
ParmD lNumerator
ParmD lDenominator
cBegin
.386
mov ebx,lDenominator ; get the demoninator
mov ecx,ebx ; ECX holds the final sign in hiword
or ebx,ebx ; ensure the denominator is positive
jns mdrd386_1
neg ebx
mdrd386_1:
mov eax,lNumber ; get the long we are multiplying
xor ecx,eax ; make ECX reflect any sign change
or eax,eax ; ensure the long is positive
jns mdrd386_2
neg eax
mdrd386_2:
mov edx,lNumerator ; get the numerator
xor ecx,edx ; make ECX reflect any sign change
or edx,edx ; ensure the numerator is positive
jns mdrd386_3
neg edx
mdrd386_3:
mul edx ; multiply
div ebx ; divide
or eax,eax ; If sign is set, then overflow occured
js mdrd386_5 ; Overflow.
or ecx,ecx ; put the sign on the result
jns mdrd386_6
neg eax
mdrd386_6:
EAXtoDXAX ; convert eax to dx:ax for 16 bit programs
.286
cEnd
.386
mdrd386_5:
mov eax,7FFFFFFFh ; return the largest integer
or ecx,ecx ; with the correct sign
jns mdrd386_6
not eax
jmp mdrd386_6
.286
cProc muldivrd32_286,<PUBLIC,FAR,NODATA,NONWIN>,<di,si>
ParmD lNumber
ParmD lNumerator
ParmD lDenominator
LocalW wSign
cBegin
mov dx,lDenominator.hi ; get the demoninator
mov si,dx ; SI holds the final sign
or dx,dx ; ensure the denominator is positive
jns mdrd286_1
neg32 dx, lDenominator.lo
mov lDenominator.hi, dx
mdrd286_1:
mov ax,lNumber.lo ; get the long we are multiplying
mov dx,lNumber.hi
xor si,dx ; make ECX reflect any sign change
or dx,dx ; ensure the long is positive
jns mdrd286_2
neg32 dx, ax
mdrd286_2:
mov bx,lNumerator.lo ; get the numerator
mov cx,lNumerator.hi ; get the numerator
xor si,cx ; make ECX reflect any sign change
or cx,cx ; ensure the numerator is positive
jns mdrd286_3
neg32 cx, bx
mdrd286_3:
mov wSign, si ; save sign
call dmul ; multiply (result in dx:cx:bx:ax)
mov si, lDenominator.hi
mov di, lDenominator.lo
cmp dx, si ; begin overflow check (unsigned for div 0 check)
ja mdrd286_5 ; overflow
jb mdrd286_7 ; no overflow
cmp cx, di
jae mdrd286_5 ; overflow
mdrd286_7:
call qdiv ; DX:AX is quotient
or dx,dx ; If sign is set, then overflow occured
js mdrd286_5 ; Overflow.
mov cx, wSign
or cx,cx ; put the sign on the result
jns mdrd286_6
neg32 dx,ax
mdrd286_6:
cEnd
mdrd286_5:
mov cx, wSign
mov ax, 0FFFFh ; return the largest integer
mov dx, 7FFFh
or cx, cx ; with the correct sign
jns mdrd286_6
not dx
not ax
jmp mdrd286_6
;---------------------------Public-Routine------------------------------;
; idmul
;
; This is an extended precision multiply routine, intended to emulate
; 80386 imul instruction.
;
; Entry:
; DX:AX = LONG
; CX:BX = LONG
; Returns:
; DX:CX:BX:AX = QUAD product
; Registers Destroyed:
; none
; History:
; Tue 26-Jan-1988 23:47:02 -by- Charles Whitmer [chuckwh]
; Wrote it.
;-----------------------------------------------------------------------;
assumes ds,nothing
assumes es,nothing
cProc idmul,<PUBLIC,NEAR>,<si,di>
localQ qTemp
cBegin
; put one argument in safe registers
mov si,dx
mov di,ax
; do the low order unsigned product
mul bx
mov qTemp.uq0,ax
mov qTemp.uq1,dx
; do the high order signed product
mov ax,si
imul cx
mov qTemp.uq2,ax
mov qTemp.uq3,dx
; do a mixed product
mov ax,si
cwd
and dx,bx
sub qTemp.uq2,dx ; adjust for sign bit
sbb qTemp.uq3,0
mul bx
add qTemp.uq1,ax
adc qTemp.uq2,dx
adc qTemp.uq3,0
; do the other mixed product
mov ax,cx
cwd
and dx,di
sub qTemp.uq2,dx
sbb qTemp.uq3,0
mul di
; pick up the answer
mov bx,ax
mov cx,dx
xor dx,dx
mov ax,qTemp.uq0
add bx,qTemp.uq1
adc cx,qTemp.uq2
adc dx,qTemp.uq3
cEnd
;---------------------------Public-Routine------------------------------;
; dmul
;
; This is an extended precision multiply routine, intended to emulate
; 80386 mul instruction.
;
; Entry:
; DX:AX = LONG
; CX:BX = LONG
; Returns:
; DX:CX:BX:AX = QUAD product
; Registers Destroyed:
; none
; History:
; Tue 02-Feb-1988 10:50:44 -by- Charles Whitmer [chuckwh]
; Copied from idmul and modified.
;-----------------------------------------------------------------------;
assumes ds,nothing
assumes es,nothing
cProc dmul,<PUBLIC,NEAR>,<si,di>
localQ qTemp
cBegin
; put one argument in safe registers
mov si,dx
mov di,ax
; do the low order product
mul bx
mov qTemp.uq0,ax
mov qTemp.uq1,dx
; do the high order product
mov ax,si
mul cx
mov qTemp.uq2,ax
mov qTemp.uq3,dx
; do a mixed product
mov ax,si
mul bx
add qTemp.uq1,ax
adc qTemp.uq2,dx
adc qTemp.uq3,0
; do the other mixed product
mov ax,cx
mul di
; pick up the answer
mov bx,ax
mov cx,dx
xor dx,dx
mov ax,qTemp.uq0
add bx,qTemp.uq1
adc cx,qTemp.uq2
adc dx,qTemp.uq3
cEnd
;---------------------------Public-Routine------------------------------;
; iqdiv
;
; This is an extended precision divide routine which is intended to
; emulate the 80386 64 bit/32 bit IDIV instruction. We don't have the
; 32 bit registers to work with, but we pack the arguments and results
; into what registers we do have. We will divide two signed numbers
; and return the quotient and remainder. We will do INT 0 for overflow,
; just like the 80386 microcode. This should ease conversion later.
;
; This routine just keeps track of the signs and calls qdiv to do the
; real work.
;
; Entry:
; DX:CX:BX:AX = QUAD Numerator
; SI:DI = LONG Denominator
; Returns:
; DX:AX = quotient
; CX:BX = remainder
; Registers Destroyed:
; DI,SI
; History:
; Tue 26-Jan-1988 02:49:19 -by- Charles Whitmer [chuckwh]
; Wrote it.
;-----------------------------------------------------------------------;
WIMP equ 1
IQDIV_RESULT_SIGN equ 1
IQDIV_REM_SIGN equ 2
assumes ds,nothing
assumes es,nothing
cProc iqdiv,<PUBLIC,NEAR>
localB flags
cBegin
mov flags,0
; take the absolute value of the denominator
or si,si
jns denominator_is_cool
xor flags,IQDIV_RESULT_SIGN
neg di
adc si,0
neg si
denominator_is_cool:
; take the absolute value of the denominator
or dx,dx
jns numerator_is_cool
xor flags,IQDIV_RESULT_SIGN + IQDIV_REM_SIGN
not ax
not bx
not cx
not dx
add ax,1
adc bx,0
adc cx,0
adc dx,0
numerator_is_cool:
; do the unsigned division
call qdiv
ifdef WIMP
jo iqdiv_exit
endif
; check for overflow
or dx,dx
jns have_a_bit_to_spare
ifdef WIMP
mov ax,8000h
dec ah
jmp short iqdiv_exit
else
int 0 ; You're toast, Jack!
endif
have_a_bit_to_spare:
; negate the result, if required
test flags,IQDIV_RESULT_SIGN
jz result_is_done
neg ax
adc dx,0
neg dx
result_is_done:
; negate the remainder, if required
test flags,IQDIV_REM_SIGN
jz remainder_is_done
neg bx
adc cx,0
neg cx
remainder_is_done:
iqdiv_exit:
cEnd
;---------------------------Public-Routine------------------------------;
; qdiv
;
; This is an extended precision divide routine which is intended to
; emulate the 80386 64 bit/32 bit DIV instruction. We don't have the
; 32 bit registers to work with, but we pack the arguments and results
; into what registers we do have. We will divide two unsigned numbers
; and return the quotient and remainder. We will do INT 0 for overflow,
; just like the 80386 microcode. This should ease conversion later.
;
; Entry:
; DX:CX:BX:AX = UQUAD Numerator
; SI:DI = ULONG Denominator
; Returns:
; DX:AX = quotient
; CX:BX = remainder
; Registers Destroyed:
; none
; History:
; Tue 26-Jan-1988 00:02:09 -by- Charles Whitmer [chuckwh]
; Wrote it.
;-----------------------------------------------------------------------;
assumes ds,nothing
assumes es,nothing
cProc qdiv,<PUBLIC,NEAR>,<si,di>
localQ uqNumerator
localD ulDenominator
localD ulQuotient
localW cShift
cBegin
; stuff the quad word into local memory
mov uqNumerator.uq0,ax
mov uqNumerator.uq1,bx
mov uqNumerator.uq2,cx
mov uqNumerator.uq3,dx
; check for overflow
qdiv_restart:
cmp si,dx
ja qdiv_no_overflow
jb qdiv_overflow
cmp di,cx
ja qdiv_no_overflow
qdiv_overflow:
ifdef WIMP
mov ax,8000h
dec ah
jmp qdiv_exit
else
int 0 ; You're toast, Jack!
jmp qdiv_restart
endif
qdiv_no_overflow:
; check for a zero Numerator
or ax,bx
or ax,cx
or ax,dx
jz qdiv_exit_relay ; quotient = remainder = 0
; handle the special case when the denominator lives in the low word
or si,si
jnz not_that_special
; calculate (DX=0):CX:BX:uqNumerator.uq0 / (SI=0):DI
cmp di,1 ; separate out the trivial case
jz div_by_one
xchg dx,cx ; CX = remainder.hi = 0
mov ax,bx
div di
mov bx,ax ; BX = quotient.hi
mov ax,uqNumerator.uq0
div di ; AX = quotient.lo
xchg bx,dx ; DX = quotient.hi, BX = remainder.lo
ifdef WIMP
or ax,ax ; clear OF
endif
qdiv_exit_relay:
jmp qdiv_exit
; calculate (DX=0):(CX=0):BX:uqNumerator.uq0 / (SI=0):(DI=1)
div_by_one:
xchg dx,bx ; DX = quotient.hi, BX = remainder.lo = 0
mov ax,uqNumerator.uq0 ; AX = quotient.lo
jmp qdiv_exit
not_that_special:
; handle the special case when the denominator lives in the high word
or di,di
jnz not_this_special_either
; calculate DX:CX:BX:uqNumerator.uq0 / SI:(DI=0)
cmp si,1 ; separate out the trivial case
jz div_by_10000h
mov ax,cx
div si
mov cx,ax ; CX = quotient.hi
mov ax,bx
div si ; AX = quotient.lo
xchg cx,dx ; DX = quotient.hi, CX = remainder.hi
mov bx,uqNumerator.uq0 ; BX = remainder.lo
ifdef WIMP
or ax,ax ; clear OF
endif
jmp qdiv_exit
; calculate (DX=0):CX:BX:uqNumerator.uq0 / (SI=1):(DI=0)
div_by_10000h:
xchg cx,dx ; DX = quotient.hi, CX = remainder.hi = 0
mov ax,bx ; AX = quotient.lo
mov bx,uqNumerator.uq0 ; BX = remainder.lo
jmp qdiv_exit
not_this_special_either:
; normalize the denominator
mov dx,si
mov ax,di
call ulNormalize ; DX:AX = normalized denominator
mov cShift,cx ; CX < 16
mov ulDenominator.lo,ax
mov ulDenominator.hi,dx
; shift the Numerator by the same amount
jcxz numerator_is_shifted
mov si,-1
shl si,cl
not si ; SI = mask
mov bx,uqNumerator.uq3
shl bx,cl
mov ax,uqNumerator.uq2
rol ax,cl
mov di,si
and di,ax
or bx,di
mov uqNumerator.uq3,bx
xor ax,di
mov bx,uqNumerator.uq1
rol bx,cl
mov di,si
and di,bx
or ax,di
mov uqNumerator.uq2,ax
xor bx,di
mov ax,uqNumerator.uq0
rol ax,cl
mov di,si
and di,ax
or bx,di
mov uqNumerator.uq1,bx
xor ax,di
mov uqNumerator.uq0,ax
numerator_is_shifted:
; set up registers for division
mov dx,uqNumerator.uq3
mov ax,uqNumerator.uq2
mov di,uqNumerator.uq1
mov cx,ulDenominator.hi
mov bx,ulDenominator.lo
; check for case when Denominator has only 16 bits
or bx,bx
jnz must_do_long_division
div cx
mov si,ax
mov ax,uqNumerator.uq1
div cx
xchg si,dx ; DX:AX = quotient
mov di,uqNumerator.uq0 ; SI:DI = remainder (shifted)
jmp short unshift_remainder
must_do_long_division:
; do the long division, part IZ@NL@%
cmp dx,cx ; we only know that DX:AX < CX:BX!
jb first_division_is_safe
mov ulQuotient.hi,0 ; i.e. 10000h, our guess is too big
mov si,ax
sub si,bx ; ... remainder is negative
jmp short first_adjuster
first_division_is_safe:
div cx
mov ulQuotient.hi,ax
mov si,dx
mul bx ; fix remainder for low order term
sub di,ax
sbb si,dx
jnc first_adjuster_done ; The remainder is UNSIGNED! We have
first_adjuster: ; to use the carry flag to keep track
dec ulQuotient.hi ; of the sign. The adjuster loop
add di,bx ; watches for a change to the carry
adc si,cx ; flag which would indicate a sign
jnc first_adjuster ; change IF we had more bits to keep
first_adjuster_done: ; a sign in.
; do the long division, part II
mov dx,si
mov ax,di
mov di,uqNumerator.uq0
cmp dx,cx ; we only know that DX:AX < CX:BX!
jb second_division_is_safe
mov ulQuotient.lo,0 ; i.e. 10000h, our guess is too big
mov si,ax
sub si,bx ; ... remainder is negative
jmp short second_adjuster
second_division_is_safe:
div cx
mov ulQuotient.lo,ax
mov si,dx
mul bx ; fix remainder for low order term
sub di,ax
sbb si,dx
jnc second_adjuster_done
second_adjuster:
dec ulQuotient.lo
add di,bx
adc si,cx
jnc second_adjuster
second_adjuster_done:
mov ax,ulQuotient.lo
mov dx,ulQuotient.hi
; unshift the remainder in SI:DI
unshift_remainder:
mov cx,cShift
jcxz remainder_unshifted
mov bx,-1
shr bx,cl
not bx
shr di,cl
ror si,cl
and bx,si
or di,bx
xor si,bx
remainder_unshifted:
mov cx,si
mov bx,di
ifdef WIMP
or ax,ax ; clear OF
endif
qdiv_exit:
cEnd
;---------------------------Public-Routine------------------------------;
; ulNormalize
;
; Normalizes a ULONG so that the highest order bit is 1. Returns the
; number of shifts done. Also returns ZF=1 if the ULONG was zero.
;
; Entry:
; DX:AX = ULONG
; Returns:
; DX:AX = normalized ULONG
; CX = shift count
; ZF = 1 if the ULONG is zero, 0 otherwise
; Registers Destroyed:
; none
; History:
; Mon 25-Jan-1988 22:07:03 -by- Charles Whitmer [chuckwh]
; Wrote it.
;-----------------------------------------------------------------------;
assumes ds,nothing
assumes es,nothing
cProc ulNormalize,<PUBLIC,NEAR>
cBegin
; shift by words
xor cx,cx
or dx,dx
js ulNormalize_exit
jnz top_word_ok
xchg ax,dx
or dx,dx
jz ulNormalize_exit ; the zero exit
mov cl,16
js ulNormalize_exit
top_word_ok:
; shift by bytes
or dh,dh
jnz top_byte_ok
xchg dh,dl
xchg dl,ah
xchg ah,al
add cl,8
or dh,dh
js ulNormalize_exit
top_byte_ok:
; do the rest by bits
inc cx
add ax,ax
adc dx,dx
js ulNormalize_exit
inc cx
add ax,ax
adc dx,dx
js ulNormalize_exit
inc cx
add ax,ax
adc dx,dx
js ulNormalize_exit
inc cx
add ax,ax
adc dx,dx
js ulNormalize_exit
inc cx
add ax,ax
adc dx,dx
js ulNormalize_exit
inc cx
add ax,ax
adc dx,dx
js ulNormalize_exit
inc cx
add ax,ax
adc dx,dx
ulNormalize_exit:
cEnd
sEnd CodeSeg
end
|
; A017187: a(n) = (9*n + 2)^3.
; 8,1331,8000,24389,54872,103823,175616,274625,405224,571787,778688,1030301,1331000,1685159,2097152,2571353,3112136,3723875,4410944,5177717,6028568,6967871,8000000,9129329,10360232,11697083,13144256,14706125,16387064,18191447,20123648,22188041,24389000,26730899,29218112,31855013,34645976,37595375,40707584,43986977,47437928,51064811,54872000,58863869,63044792,67419143,71991296,76765625,81746504,86938307,92345408,97972181,103823000,109902239,116214272,122763473,129554216,136590875,143877824,151419437,159220088,167284151,175616000,184220009,193100552,202262003,211708736,221445125,231475544,241804367,252435968,263374721,274625000,286191179,298077632,310288733,322828856,335702375,348913664,362467097,376367048,390617891,405224000,420189749,435519512,451217663,467288576,483736625,500566184,517781627,535387328,553387661,571787000,590589719,609800192,629422793,649461896,669921875,690807104,712121957
mul $0,9
add $0,2
pow $0,3
|
; A147837: a(n)=7*a(n-1)-5*a(n-2), a(0)=1, a(1)=5 .
; 1,5,30,185,1145,7090,43905,271885,1683670,10426265,64565505,399827210,2475962945,15332604565,94948417230,587975897785,3641089198345,22547744899490,139628768304705,864662653635485,5354494733924870
mov $1,1
mov $2,3
lpb $0,1
sub $0,1
add $2,$1
add $1,$2
mul $2,5
lpe
|
; A218737: a(n) = (34^n-1)/33.
; 0,1,35,1191,40495,1376831,46812255,1591616671,54114966815,1839908871711,62556901638175,2126934655697951,72315778293730335,2458736461986831391,83597039707552267295,2842299350056777088031,96638177901930420993055,3285698048665634313763871,111713733654631566667971615,3798266944257473266711034911,129141076104754091068175186975,4390796587561639096317956357151,149287083977095729274810516143135,5075760855221254795343557548866591,172575869077522663041680956661464095,5867579548635770543417152526489779231
mov $1,34
pow $1,$0
div $1,33
mov $0,$1
|
; A141943: Primes congruent to 21 mod 25.
; Submitted by Jon Maiga
; 71,271,421,521,571,821,971,1021,1171,1321,1471,1571,1621,1721,1871,2221,2371,2521,2621,2671,2971,3121,3221,3271,3371,3571,3671,3821,4021,4271,4421,4621,4721,4871,5021,5171,5471,5521,5821,6121,6221,6271,6421,6521,6571,6871,6971,7121,7321,7621,8171,8221,8521,8821,8971,9221,9371,9421,9521,9721,9871,10271,10321,10771,11071,11171,11321,11471,11621,11821,11971,12071,12421,12671,12721,12821,13121,13171,13421,13721,13921,14071,14221,14321,14621,14771,14821,15121,15271,15671,15971,16421,16871,16921
mov $2,$0
add $2,6
pow $2,2
lpb $2
mov $3,$4
add $3,20
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $1,$0
max $1,0
cmp $1,$0
mul $2,$1
sub $2,1
add $4,50
lpe
mov $0,$4
add $0,21
|
; A007979: Expansion of (1+x^2)(1+x^4)/((1-x)^2*(1-x^2)*(1-x^3)).
; Submitted by Jamie Morken(s2)
; 1,2,5,9,16,25,39,56,79,107,142,183,233,290,357,433,520,617,727,848,983,1131,1294,1471,1665,1874,2101,2345,2608,2889,3191,3512,3855,4219,4606,5015,5449,5906,6389,6897,7432,7993,8583,9200,9847,10523,11230,11967,12737,13538,14373,15241,16144,17081,18055,19064,20111,21195,22318,23479,24681,25922,27205,28529,29896,31305,32759,34256,35799,37387,39022,40703,42433,44210,46037,47913,49840,51817,53847,55928,58063,60251,62494,64791,67145,69554,72021,74545,77128,79769,82471,85232,88055,90939,93886,96895
mov $2,$0
mov $3,$0
pow $0,3
mul $0,2
div $0,3
add $3,1
pow $3,2
add $0,$3
div $0,6
add $0,$2
add $0,1
|
*=$1337
loop: lda $fe ; A=rnd
sta $00 ; ZP(0)=A
lda $fe
and #$3 ; A=A&3
clc ; Clear carry
adc #$2 ; A+=2
sta $01 ; ZP(1)=A
lda $fe ; A=rnd
ldy #$0 ; Y=0
sta ($00),y ; ZP(0),ZP(1)=y
inc $fd ;wait for sync
jmp loop
|
#note: r40 (the exception handler) and r46 (the start of usermode code) must
#be specified in hex (0xwhatever)
#I just don't see any reason not to, and it makes programming the script
#much nicer to deal with...
#load exception handler
lc r40, 0x80000050
leh r40
#enable exceptions
cle
#load TLB entries
#virtual page 0 is for instructions
#virtual page 1 is for data
lc r46, 0x0000005c #usermode start address
lc r47, 1 #interrupts off
lc r48, 1 #in user mode
lc r42, 0x00000000 #denotes VPN 0
lc r43, 0x0000000d #denotes VPN 0 maps to physical page 0
#and is fetchable, readable, and valid
tlbse r0, r42 #load into entry 0
lc r42, 0x00001000 #denotes VPN 1
lc r43, 0x0000101e #denotes VPN 1 maps to physical page 1
#and is readable, writable, valid, and dirty
#(dirty to prevent taking a
#read-only exception)
tlbse r48, r42 #load into entry 1
#this last tlb entry is designed to produce a bus error
lc r44, 2 #load into TLB entry 2
lc r42, 0x3fffe000 #denotes VPN 0x3fffe
lc r43, 0x3fffe01f #map VPN 0x3fffe to page 0x3fffe
#and is readable, writable, valid, and dirty
#(dirty to prevent taking a
#read-only exception)
tlbse r44, r42
#warp to user mode
rfe r46, r47, r48
#handle exceptions
lc r49, 0xdeadbeef
halt #or rather don't =)
lc r30, 1
bnzi k2, 1
trap
#@expected values
#e3 = 0x000000a0
#mode = S
#interrupts = off
#exceptions = off
#r40 = 0x80000050
#r46 = 0x0000005c
#r47 = 1
#r48 = 1
#r42 = 0x3fffe000
#r43 = 0x3fffe01f
#r44 = 2
#r49 = 0xdeadbeef
#pc = 0x8000005c
#e0 = 0x00000060
#e2 = 0x00000060
#e1 = 0x00000001
#tlb 0:
# vpn = 0x00000
# os = 0x000
# ppn = 0x00000
# at = 0x00d
#tlb 1:
# vpn = 0x00001
# os = 0x000
# ppn = 0x00001
# at = 0x01e
#tlb 2:
# vpn = 0x3fffe
# os = 0x000
# ppn = 0x3fffe
# at = 0x01f
|
// Copyright 2021 The IREE Authors
//
// Licensed 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
//===- BufferAllocViewCleanUpPass.cpp -------------------------------------===//
//
// This pass performs canonicalizations/cleanups related to HAL interface/buffer
// allocations and views. We need a dedicated pass because patterns here involve
// multiple dialects.
//
//===----------------------------------------------------------------------===//
#include "iree/compiler/Codegen/PassDetail.h"
#include "iree/compiler/Codegen/Passes.h"
#include "iree/compiler/Dialect/Flow/IR/FlowOps.h"
#include "iree/compiler/Dialect/HAL/IR/HALOps.h"
#include "mlir/Dialect/Linalg/IR/LinalgOps.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
namespace mlir {
namespace iree_compiler {
namespace {
/// Folds linalg.tensor_reshape into the source hal.interface.binding.subspan.
///
/// For example, this matches the following pattern:
///
/// %subspan = hal.interface.binding.subspan @... :
/// !flow.dispatch.tensor<readonly:3x3x1x96xf32>
/// %tensor = flow.dispatch.tensor.load %subspan :
/// !flow.dispatch.tensor<readonly:3x3x1x96xf32> -> tensor<3x3x1x96xf32>
/// %0 = linalg.tensor_reshape %tensor [
/// affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
/// ] : tensor<3x3x1x96xf32> into tensor<864xf32>
///
/// And turns it into:
///
/// %subspan = hal.interface.binding.subspan @... :
/// !flow.dispatch.tensor<readonly:864xf32>
/// %0 = flow.dispatch.tensor.load %subspan :
/// !flow.dispatch.tensor<readonly:864xf32> -> tensor<864xf32>
template <typename TensorReshapeOp>
struct FoldReshapeIntoInterfaceTensorLoad : OpRewritePattern<TensorReshapeOp> {
using OpRewritePattern<TensorReshapeOp>::OpRewritePattern;
LogicalResult matchAndRewrite(TensorReshapeOp reshapeOp,
PatternRewriter &rewriter) const override {
auto loadOp =
reshapeOp.src()
.template getDefiningOp<IREE::Flow::DispatchTensorLoadOp>();
if (!loadOp) return failure();
// Make sure we are loading the full incoming subspan. Otherwise we cannot
// simply adjust the subspan's resultant type later.
if (!loadOp.offsets().empty() || !loadOp.sizes().empty() ||
!loadOp.strides().empty())
return failure();
auto subspanOp =
loadOp.source()
.template getDefiningOp<IREE::HAL::InterfaceBindingSubspanOp>();
if (!subspanOp) return failure();
auto newSubspanType = IREE::Flow::DispatchTensorType::get(
subspanOp.getType()
.template cast<IREE::Flow::DispatchTensorType>()
.getAccess(),
reshapeOp.getResultType());
Value newSubspanOp = rewriter.create<IREE::HAL::InterfaceBindingSubspanOp>(
subspanOp.getLoc(), newSubspanType, subspanOp.binding(),
subspanOp.byte_offset(), subspanOp.byte_length());
rewriter.replaceOpWithNewOp<IREE::Flow::DispatchTensorLoadOp>(
reshapeOp, reshapeOp.getResultType(), newSubspanOp);
return success();
}
};
// Removes operations with Allocate MemoryEffects but no uses.
struct RemoveDeadMemAllocs : RewritePattern {
RemoveDeadMemAllocs(MLIRContext *context, PatternBenefit benefit = 1)
: RewritePattern(MatchAnyOpTypeTag(), benefit, context) {}
LogicalResult matchAndRewrite(Operation *op,
PatternRewriter &rewriter) const override {
auto memEffect = dyn_cast<MemoryEffectOpInterface>(op);
if (!memEffect || !memEffect.hasEffect<MemoryEffects::Allocate>()) {
return failure();
}
if (!op->use_empty()) return failure();
rewriter.eraseOp(op);
return success();
}
};
/// Runs canonicalization patterns on interface load/store ops.
struct CleanupBufferAllocViewPass
: public CleanupBufferAllocViewBase<CleanupBufferAllocViewPass> {
void runOnOperation() override {
OwningRewritePatternList patterns(&getContext());
patterns.insert<
FoldReshapeIntoInterfaceTensorLoad<linalg::TensorCollapseShapeOp>,
FoldReshapeIntoInterfaceTensorLoad<linalg::TensorExpandShapeOp>,
RemoveDeadMemAllocs>(&getContext());
(void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
}
};
} // namespace
std::unique_ptr<OperationPass<FuncOp>> createCleanupBufferAllocViewPass() {
return std::make_unique<CleanupBufferAllocViewPass>();
}
} // namespace iree_compiler
} // namespace mlir
|
/* $Id: AbcSimplex.hpp 2070 2014-11-18 11:12:54Z forrest $ */
// Copyright (C) 2002, International Business Machines
// Corporation and others, Copyright (C) 2012, FasterCoin. All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).
/*
Authors
John Forrest
*/
#ifndef AbcSimplex_H
#define AbcSimplex_H
#include <iostream>
#include <cfloat>
#include "ClpModel.hpp"
#include "ClpMatrixBase.hpp"
#include "CoinIndexedVector.hpp"
#include "AbcCommon.hpp"
class AbcSimplex;
#include "ClpSolve.hpp"
#include "CoinAbcCommon.hpp"
#include "ClpSimplex.hpp"
class AbcDualRowPivot;
class AbcPrimalColumnPivot;
class AbcSimplexFactorization;
class AbcNonLinearCost;
class OsiAbcSolverInterface;
class CoinWarmStartBasis;
class ClpDisasterHandler;
class AbcSimplexProgress;
class AbcMatrix;
class AbcTolerancesEtc;
/** This solves LPs using the simplex method
It inherits from ClpModel and all its arrays are created at
algorithm time. Originally I tried to work with model arrays
but for simplicity of coding I changed to single arrays with
structural variables then row variables. Some coding is still
based on old style and needs cleaning up.
For a description of algorithms:
for dual see AbcSimplexDual.hpp and at top of AbcSimplexDual.cpp
for primal see AbcSimplexPrimal.hpp and at top of AbcSimplexPrimal.cpp
There is an algorithm data member. + for primal variations
and - for dual variations
*/
#define PAN
#if ABC_NORMAL_DEBUG>0
#define PRINT_PAN 1
#endif
#define TRY_ABC_GUS
#define HEAVY_PERTURBATION 57
#if ABC_PARALLEL==1
// Use pthreads
#include <pthread.h>
#endif
class AbcSimplex : public ClpSimplex {
friend void AbcSimplexUnitTest(const std::string & mpsDir);
public:
/** enums for status of various sorts.
ClpModel order (and warmstart) is
isFree = 0x00,
basic = 0x01,
atUpperBound = 0x02,
atLowerBound = 0x03,
isFixed means fixed at lower bound and out of basis
*/
enum Status {
atLowerBound = 0x00, // so we can use bottom two bits to sort and swap signs
atUpperBound = 0x01,
isFree = 0x04,
superBasic = 0x05,
basic = 0x06,
isFixed = 0x07
};
// For Dual
enum FakeBound {
noFake = 0x00,
lowerFake = 0x01,
upperFake = 0x02,
bothFake = 0x03
};
/**@name Constructors and destructor and copy */
//@{
/// Default constructor
AbcSimplex (bool emptyMessages = false );
/** Copy constructor.
*/
AbcSimplex(const AbcSimplex & rhs);
/** Copy constructor from model.
*/
AbcSimplex(const ClpSimplex & rhs);
/** Subproblem constructor. A subset of whole model is created from the
row and column lists given. The new order is given by list order and
duplicates are allowed. Name and integer information can be dropped
Can optionally modify rhs to take into account variables NOT in list
in this case duplicates are not allowed (also see getbackSolution)
*/
AbcSimplex (const ClpSimplex * wholeModel,
int numberRows, const int * whichRows,
int numberColumns, const int * whichColumns,
bool dropNames = true, bool dropIntegers = true,
bool fixOthers = false);
/** Subproblem constructor. A subset of whole model is created from the
row and column lists given. The new order is given by list order and
duplicates are allowed. Name and integer information can be dropped
Can optionally modify rhs to take into account variables NOT in list
in this case duplicates are not allowed (also see getbackSolution)
*/
AbcSimplex (const AbcSimplex * wholeModel,
int numberRows, const int * whichRows,
int numberColumns, const int * whichColumns,
bool dropNames = true, bool dropIntegers = true,
bool fixOthers = false);
/** This constructor modifies original AbcSimplex and stores
original stuff in created AbcSimplex. It is only to be used in
conjunction with originalModel */
AbcSimplex (AbcSimplex * wholeModel,
int numberColumns, const int * whichColumns);
/** This copies back stuff from miniModel and then deletes miniModel.
Only to be used with mini constructor */
void originalModel(AbcSimplex * miniModel);
/** This constructor copies from ClpSimplex */
AbcSimplex (const ClpSimplex * clpSimplex);
/// Put back solution into ClpSimplex
void putBackSolution(ClpSimplex * simplex);
/** Array persistence flag
If 0 then as now (delete/new)
1 then only do arrays if bigger needed
2 as 1 but give a bit extra if bigger needed
*/
//void setPersistenceFlag(int value);
/// Save a copy of model with certain state - normally without cuts
void makeBaseModel();
/// Switch off base model
void deleteBaseModel();
/// See if we have base model
inline AbcSimplex * baseModel() const {
return abcBaseModel_;
}
/** Reset to base model (just size and arrays needed)
If model NULL use internal copy
*/
void setToBaseModel(AbcSimplex * model = NULL);
/// Assignment operator. This copies the data
AbcSimplex & operator=(const AbcSimplex & rhs);
/// Destructor
~AbcSimplex ( );
//@}
/**@name Functions most useful to user */
//@{
/** Dual algorithm - see AbcSimplexDual.hpp for method.
*/
int dual();
int doAbcDual();
/** Primal algorithm - see AbcSimplexPrimal.hpp for method.
*/
int primal(int ifValuesPass);
int doAbcPrimal(int ifValuesPass);
/// Returns a basis (to be deleted by user)
CoinWarmStartBasis * getBasis() const;
/// Passes in factorization
void setFactorization( AbcSimplexFactorization & factorization);
/// Swaps factorization
AbcSimplexFactorization * swapFactorization( AbcSimplexFactorization * factorization);
/// Gets clean and emptyish factorization
AbcSimplexFactorization * getEmptyFactorization();
/** Tightens primal bounds to make dual faster. Unless
fixed or doTight>10, bounds are slightly looser than they could be.
This is to make dual go faster and is probably not needed
with a presolve. Returns non-zero if problem infeasible.
Fudge for branch and bound - put bounds on columns of factor *
largest value (at continuous) - should improve stability
in branch and bound on infeasible branches (0.0 is off)
*/
int tightenPrimalBounds();
/// Sets row pivot choice algorithm in dual
void setDualRowPivotAlgorithm(AbcDualRowPivot & choice);
/// Sets column pivot choice algorithm in primal
void setPrimalColumnPivotAlgorithm(AbcPrimalColumnPivot & choice);
//@}
/// If user left factorization frequency then compute
void defaultFactorizationFrequency();
//@}
/**@name most useful gets and sets */
//@{
/// factorization
inline AbcSimplexFactorization * factorization() const {
return reinterpret_cast<AbcSimplexFactorization *>(abcFactorization_);
}
#ifdef EARLY_FACTORIZE
/// Early factorization
inline AbcSimplexFactorization * earlyFactorization() const {
return reinterpret_cast<AbcSimplexFactorization *>(abcEarlyFactorization_);
}
#endif
/// Factorization frequency
int factorizationFrequency() const;
void setFactorizationFrequency(int value);
/// Maximum rows
inline int maximumAbcNumberRows() const
{ return maximumAbcNumberRows_;}
/// Maximum Total
inline int maximumNumberTotal() const
{ return maximumNumberTotal_;}
inline int maximumTotal() const
{ return maximumNumberTotal_;}
/// Return true if the objective limit test can be relied upon
bool isObjectiveLimitTestValid() const ;
/// Number of variables (includes spare rows)
inline int numberTotal() const
{ return numberTotal_;}
/// Number of variables without fixed to zero (includes spare rows)
inline int numberTotalWithoutFixed() const
{ return numberTotalWithoutFixed_;}
/// Useful arrays (0,1,2,3,4,5,6,7)
inline CoinPartitionedVector * usefulArray(int index) {
return & usefulArray_[index];
}
inline CoinPartitionedVector * usefulArray(int index) const {
return const_cast<CoinPartitionedVector *>(&usefulArray_[index]);
}
//@}
/******************** End of most useful part **************/
/**@name Functions less likely to be useful to casual user */
//@{
/** Given an existing factorization computes and checks
primal and dual solutions. Uses current problem arrays for
bounds. Returns feasibility states */
int getSolution ();
/// Sets objectiveValue_ from rawObjectiveValue_
void setClpSimplexObjectiveValue();
/** Sets dual values pass djs using unscaled duals
type 1 - values pass
type 2 - just use as infeasibility weights
type 3 - as 2 but crash
*/
void setupDualValuesPass(const double * fakeDuals,
const double * fakePrimals,
int type);
/// Gets objective value with all offsets but as for minimization
inline double minimizationObjectiveValue() const
{ return objectiveValue_-dblParam_[ClpObjOffset];}
/// Current dualTolerance (will end up as dualTolerance_)
inline double currentDualTolerance() const
{ return currentDualTolerance_;}
inline void setCurrentDualTolerance(double value) {
currentDualTolerance_ = value;
}
/// Return pointer to details of costs
inline AbcNonLinearCost * abcNonLinearCost() const {
return abcNonLinearCost_;
}
/// Perturbation (fixed) - is just scaled random numbers
double * perturbationSaved() const
{ return perturbationSaved_;}
/// Acceptable pivot for this iteration
inline double acceptablePivot() const
{ return acceptablePivot_;}
/// Set to 1 if no free or super basic
inline int ordinaryVariables() const
{ return ordinaryVariables_;}
/// Number of ordinary (lo/up) in tableau row
inline int numberOrdinary() const
{ return numberOrdinary_;}
/// Set number of ordinary (lo/up) in tableau row
inline void setNumberOrdinary(int number)
{ numberOrdinary_=number;}
/// Current dualBound (will end up as dualBound_)
inline double currentDualBound() const
{ return currentDualBound_;}
/// dual row pivot choice
inline AbcDualRowPivot * dualRowPivot() const {
return abcDualRowPivot_;
}
/// primal column pivot choice
inline AbcPrimalColumnPivot * primalColumnPivot() const {
return abcPrimalColumnPivot_;
}
/// Abc Matrix
inline AbcMatrix * abcMatrix() const {
return abcMatrix_;
}
/** Factorizes using current basis.
solveType - 1 iterating, 0 initial, -1 external
If 10 added then in primal values pass
Return codes are as from AbcSimplexFactorization unless initial factorization
when total number of singularities is returned.
Special case is numberRows_+1 -> all slack basis.
if initial should be before permute in
pivotVariable may be same as toExternal
*/
int internalFactorize(int solveType);
/**
Permutes in from ClpModel data - assumes scale factors done
and AbcMatrix exists but is in original order (including slacks)
For now just add basicArray at end
==
But could partition into
normal (i.e. reasonable lower/upper)
abnormal - free, odd bounds
fixed
==
sets a valid pivotVariable
Slacks always shifted by offset
Fixed variables always shifted by offset
Recode to allow row objective so can use pi from idiot etc
*/
void permuteIn();
/// deals with new basis and puts in abcPivotVariable_
void permuteBasis();
/// Permutes out - bit settings same as stateOfProblem
void permuteOut(int whatsWanted);
/// Save data
ClpDataSave saveData() ;
/// Restore data
void restoreData(ClpDataSave saved);
/// Clean up status - make sure no superbasic etc
void cleanStatus(bool valuesPass=false);
/** Computes duals from scratch. If givenDjs then
allows for nonzero basic djs. Returns number of refinements */
int computeDuals(double * givenDjs, CoinIndexedVector * array1, CoinIndexedVector * array2);
/// Computes primals from scratch. Returns number of refinements
int computePrimals (CoinIndexedVector * array1, CoinIndexedVector * array2);
/// Computes nonbasic cost and total cost
void computeObjective ();
/// set multiple sequence in
void setMultipleSequenceIn(int sequenceIn[4]);
/**
Unpacks one column of the matrix into indexed array
Uses sequenceIn_
*/
inline void unpack(CoinIndexedVector & rowArray) const
{unpack(rowArray,sequenceIn_);}
/**
Unpacks one column of the matrix into indexed array
*/
void unpack(CoinIndexedVector & rowArray, int sequence) const;
/**
This does basis housekeeping and does values for in/out variables.
Can also decide to re-factorize
*/
int housekeeping(/*double objectiveChange*/);
/** This sets largest infeasibility and most infeasible and sum
and number of infeasibilities (Primal) */
void checkPrimalSolution(bool justBasic);
/** This sets largest infeasibility and most infeasible and sum
and number of infeasibilities (Dual) */
void checkDualSolution();
/** This sets largest infeasibility and most infeasible and sum
and number of infeasibilities AND sumFakeInfeasibilites_ (Dual) */
void checkDualSolutionPlusFake();
/** This sets sum and number of infeasibilities (Dual and Primal) */
void checkBothSolutions();
/// Computes solutions - 1 do duals, 2 do primals, 3 both (returns number of refinements)
int gutsOfSolution(int type);
/// Computes solutions - 1 do duals, 2 do primals, 3 both (returns number of refinements)
int gutsOfPrimalSolution(int type);
/// Saves good status etc
void saveGoodStatus();
/// Restores previous good status and says trouble
void restoreGoodStatus(int type);
#define rowUseScale_ scaleFromExternal_
#define inverseRowUseScale_ scaleToExternal_
/// After modifying first copy refreshes second copy and marks as updated
void refreshCosts();
void refreshLower(unsigned int type=~(ROW_LOWER_SAME|COLUMN_UPPER_SAME));
void refreshUpper(unsigned int type=~(ROW_LOWER_SAME|COLUMN_LOWER_SAME));
/// Sets up all extra pointers
void setupPointers(int maxRows,int maxColumns);
/// Copies all saved versions to working versions and may do something for perturbation
void copyFromSaved(int type=31);
/// fills in perturbationSaved_ from start with 0.5+random
void fillPerturbation(int start, int number);
/// For debug - prints summary of arrays which are out of kilter
void checkArrays(int ignoreEmpty=0) const;
/// For debug - summarizes dj situation (1 recomputes duals first, 2 checks duals as well)
void checkDjs(int type=1) const;
/// For debug - checks solutionBasic
void checkSolutionBasic() const;
/// For debug - moves solution back to external and computes stuff (always checks djs)
void checkMoveBack(bool checkDuals);
public:
/** For advanced use. When doing iterative solves things can get
nasty so on values pass if incoming solution has largest
infeasibility < incomingInfeasibility throw out variables
from basis until largest infeasibility < allowedInfeasibility
or incoming largest infeasibility.
If allowedInfeasibility>= incomingInfeasibility this is
always possible altough you may end up with an all slack basis.
Defaults are 1.0,10.0
*/
void setValuesPassAction(double incomingInfeasibility,
double allowedInfeasibility);
/** Get a clean factorization - i.e. throw out singularities
may do more later */
int cleanFactorization(int ifValuesPass);
/// Move status and solution to ClpSimplex
void moveStatusToClp(ClpSimplex * clpModel);
/// Move status and solution from ClpSimplex
void moveStatusFromClp(ClpSimplex * clpModel);
//@}
/**@name most useful gets and sets */
//@{
public:
/// Objective value
inline double clpObjectiveValue() const {
return (objectiveValue_+objectiveOffset_-bestPossibleImprovement_)*optimizationDirection_ - dblParam_[ClpObjOffset];
}
/** Basic variables pivoting on which rows
may be same as toExternal but may be as at invert */
inline int * pivotVariable() const {
return abcPivotVariable_;
}
/// State of problem
inline int stateOfProblem() const
{ return stateOfProblem_;}
/// State of problem
inline void setStateOfProblem(int value)
{ stateOfProblem_=value;}
/// Points from external to internal
//inline int * fromExternal() const
//{ return fromExternal_;}
/// Points from internal to external
//inline int * toExternal() const
//{return toExternal_;}
/** Scale from primal external to internal (in external order) Or other way for dual
*/
inline double * scaleFromExternal() const
{return scaleFromExternal_;}
/** Scale from primal internal to external (in external order) Or other way for dual
*/
inline double * scaleToExternal() const
{return scaleToExternal_;}
/// corresponds to rowScale etc
inline double * rowScale2() const
{return rowUseScale_;}
inline double * inverseRowScale2() const
{return inverseRowUseScale_;}
inline double * inverseColumnScale2() const
{return inverseColumnUseScale_;}
inline double * columnScale2() const
{return columnUseScale_;}
inline int arrayForDualColumn() const
{return arrayForDualColumn_;}
/// upper theta from dual column
inline double upperTheta() const
{return upperTheta_;}
inline int arrayForReplaceColumn() const
{ return arrayForReplaceColumn_;}
inline int arrayForFlipBounds() const
{ return arrayForFlipBounds_;}
inline int arrayForFlipRhs() const
{ return arrayForFlipRhs_;}
inline int arrayForBtran() const
{ return arrayForBtran_;}
inline int arrayForFtran() const
{ return arrayForFtran_;}
inline int arrayForTableauRow() const
{ return arrayForTableauRow_;}
/// value of incoming variable (in Dual)
double valueIncomingDual() const;
/// Get pointer to array[getNumCols()] of primal solution vector
const double * getColSolution() const;
/// Get pointer to array[getNumRows()] of dual prices
const double * getRowPrice() const;
/// Get a pointer to array[getNumCols()] of reduced costs
const double * getReducedCost() const;
/** Get pointer to array[getNumRows()] of row activity levels (constraint
matrix times the solution vector */
const double * getRowActivity() const;
//@}
/**@name protected methods */
//@{
/** May change basis and then returns number changed.
Computation of solutions may be overriden by given pi and solution
*/
int gutsOfSolution ( double * givenDuals,
const double * givenPrimals,
bool valuesPass = false);
/// Does most of deletion for arrays etc(0 just null arrays, 1 delete first)
void gutsOfDelete(int type);
/// Does most of copying
void gutsOfCopy(const AbcSimplex & rhs);
/// Initializes arrays
void gutsOfInitialize(int numberRows,int numberColumns,bool doMore);
/// resizes arrays
void gutsOfResize(int numberRows,int numberColumns);
/** Translates ClpModel to AbcSimplex
See DO_ bits in stateOfProblem_ for type e.g. DO_BASIS_AND_ORDER
*/
void translate(int type);
/// Moves basic stuff to basic area
void moveToBasic(int which=15);
//@}
public:
/**@name public methods */
//@{
/// Return region
inline double * solutionRegion() const {
return abcSolution_;
}
inline double * djRegion() const {
return abcDj_;
}
inline double * lowerRegion() const {
return abcLower_;
}
inline double * upperRegion() const {
return abcUpper_;
}
inline double * costRegion() const {
return abcCost_;
}
/// Return region
inline double * solutionRegion(int which) const {
return abcSolution_+which*maximumAbcNumberRows_;
}
inline double * djRegion(int which) const {
return abcDj_+which*maximumAbcNumberRows_;
}
inline double * lowerRegion(int which) const {
return abcLower_+which*maximumAbcNumberRows_;
}
inline double * upperRegion(int which) const {
return abcUpper_+which*maximumAbcNumberRows_;
}
inline double * costRegion(int which) const {
return abcCost_+which*maximumAbcNumberRows_;
}
/// Return region
inline double * solutionBasic() const {
return solutionBasic_;
}
inline double * djBasic() const {
return djBasic_;
}
inline double * lowerBasic() const {
return lowerBasic_;
}
inline double * upperBasic() const {
return upperBasic_;
}
inline double * costBasic() const {
return costBasic_;
}
/// Perturbation
inline double * abcPerturbation() const
{ return abcPerturbation_;}
/// Fake djs
inline double * fakeDjs() const
{ return djSaved_;}
inline unsigned char * internalStatus() const
{ return internalStatus_;}
inline AbcSimplex::Status getInternalStatus(int sequence) const {
return static_cast<Status> (internalStatus_[sequence] & 7);
}
inline AbcSimplex::Status getInternalColumnStatus(int sequence) const {
return static_cast<Status> (internalStatus_[sequence+maximumAbcNumberRows_] & 7);
}
inline void setInternalStatus(int sequence, AbcSimplex::Status newstatus) {
unsigned char & st_byte = internalStatus_[sequence];
st_byte = static_cast<unsigned char>(st_byte & ~7);
st_byte = static_cast<unsigned char>(st_byte | newstatus);
}
inline void setInternalColumnStatus(int sequence, AbcSimplex::Status newstatus) {
unsigned char & st_byte = internalStatus_[sequence+maximumAbcNumberRows_];
st_byte = static_cast<unsigned char>(st_byte & ~7);
st_byte = static_cast<unsigned char>(st_byte | newstatus);
}
/** Normally the first factorization does sparse coding because
the factorization could be singular. This allows initial dense
factorization when it is known to be safe
*/
void setInitialDenseFactorization(bool onOff);
bool initialDenseFactorization() const;
/** Return sequence In or Out */
inline int sequenceIn() const {
return sequenceIn_;
}
inline int sequenceOut() const {
return sequenceOut_;
}
/** Set sequenceIn or Out */
inline void setSequenceIn(int sequence) {
sequenceIn_ = sequence;
}
inline void setSequenceOut(int sequence) {
sequenceOut_ = sequence;
}
#if 0
/** Return sequenceInternal In or Out */
inline int sequenceInternalIn() const {
return sequenceInternalIn_;
}
inline int sequenceInternalOut() const {
return sequenceInternalOut_;
}
/** Set sequenceInternalIn or Out */
inline void setSequenceInternalIn(int sequence) {
sequenceInternalIn_ = sequence;
}
inline void setSequenceInternalOut(int sequence) {
sequenceInternalOut_ = sequence;
}
#endif
/// Returns 1 if sequence indicates column
inline int isColumn(int sequence) const {
return sequence >= maximumAbcNumberRows_ ? 1 : 0;
}
/// Returns sequence number within section
inline int sequenceWithin(int sequence) const {
return sequence < maximumAbcNumberRows_ ? sequence : sequence - maximumAbcNumberRows_;
}
/// Current/last pivot row (set after END of choosing pivot row in dual)
inline int lastPivotRow() const
{ return lastPivotRow_;}
/// First Free_
inline int firstFree() const
{ return firstFree_;}
/// Last firstFree_
inline int lastFirstFree() const
{ return lastFirstFree_;}
/// Free chosen vector
inline int freeSequenceIn() const
{ return freeSequenceIn_;}
/// Acceptable pivot for this iteration
inline double currentAcceptablePivot() const
{ return currentAcceptablePivot_;}
#ifdef PAN
/** Returns
1 if fake superbasic
0 if free or true superbasic
-1 if was fake but has cleaned itself up (sets status)
-2 if wasn't fake
*/
inline int fakeSuperBasic(int iSequence) {
if ((internalStatus_[iSequence]&7)==4)
return 0; // free
if ((internalStatus_[iSequence]&7)!=5)
return -2;
double value=abcSolution_[iSequence];
if (value<abcLower_[iSequence]+primalTolerance_) {
if(abcDj_[iSequence]>=-currentDualTolerance_) {
setInternalStatus(iSequence,atLowerBound);
#if PRINT_PAN>1
printf("Pansetting %d to lb\n",iSequence);
#endif
return -1;
} else {
return 1;
}
} else if (value>abcUpper_[iSequence]-primalTolerance_) {
if (abcDj_[iSequence]<=currentDualTolerance_) {
setInternalStatus(iSequence,atUpperBound);
#if PRINT_PAN>1
printf("Pansetting %d to ub\n",iSequence);
#endif
return -1;
} else {
return 1;
}
} else {
return 0;
}
}
#endif
/// Return row or column values
inline double solution(int sequence) {
return abcSolution_[sequence];
}
/// Return address of row or column values
inline double & solutionAddress(int sequence) {
return abcSolution_[sequence];
}
inline double reducedCost(int sequence) {
return abcDj_[sequence];
}
inline double & reducedCostAddress(int sequence) {
return abcDj_[sequence];
}
inline double lower(int sequence) {
return abcLower_[sequence];
}
/// Return address of row or column lower bound
inline double & lowerAddress(int sequence) {
return abcLower_[sequence];
}
inline double upper(int sequence) {
return abcUpper_[sequence];
}
/// Return address of row or column upper bound
inline double & upperAddress(int sequence) {
return abcUpper_[sequence];
}
inline double cost(int sequence) {
return abcCost_[sequence];
}
/// Return address of row or column cost
inline double & costAddress(int sequence) {
return abcCost_[sequence];
}
/// Return original lower bound
inline double originalLower(int iSequence) const {
if (iSequence < numberColumns_) return columnLower_[iSequence];
else
return rowLower_[iSequence-numberColumns_];
}
/// Return original lower bound
inline double originalUpper(int iSequence) const {
if (iSequence < numberColumns_) return columnUpper_[iSequence];
else
return rowUpper_[iSequence-numberColumns_];
}
/// For dealing with all issues of cycling etc
inline AbcSimplexProgress * abcProgress()
{ return &abcProgress_;}
#ifdef ABC_SPRINT
/// Overwrite to create sub problem (just internal arrays) - save full stuff
AbcSimplex * createSubProblem(int numberColumns,const int * whichColumn);
/// Restore stuff from sub problem (and delete sub problem)
void restoreFromSubProblem(AbcSimplex * fullProblem, const int * whichColumn);
#endif
public:
/** Clears an array and says available (-1 does all)
when no possibility of going parallel */
inline void clearArraysPublic(int which)
{ clearArrays(which);}
/** Returns first available empty array (and sets flag)
when no possibility of going parallel */
inline int getAvailableArrayPublic() const
{ return getAvailableArray();}
#if ABC_PARALLEL
/// get parallel mode
inline int parallelMode() const
{ return parallelMode_;}
/// set parallel mode
inline void setParallelMode(int value)
{ parallelMode_=value;}
/// Number of cpus
inline int numberCpus() const
{ return parallelMode_+1;}
#if ABC_PARALLEL==1
/// set stop start
inline void setStopStart(int value)
{ stopStart_=value;}
#endif
#endif
//protected:
/// Clears an array and says available (-1 does all)
void clearArrays(int which);
/// Clears an array and says available
void clearArrays(CoinPartitionedVector * which);
/// Returns first available empty array (and sets flag)
int getAvailableArray() const;
/// Say array going to be used
inline void setUsedArray(int which) const
{int check=1<<which;assert ((stateOfProblem_&check)==0);stateOfProblem_|=check;}
/// Say array going available
inline void setAvailableArray(int which) const
{int check=1<<which;assert ((stateOfProblem_&check)!=0);
assert (!usefulArray_[which].getNumElements());stateOfProblem_&=~check;}
/// Swaps primal stuff
void swapPrimalStuff();
/// Swaps dual stuff
void swapDualStuff(int lastSequenceOut,int lastDirectionOut);
protected:
//@}
/**@name status methods */
//@{
/// Swaps two variables and does status
void swap(int pivotRow,int nonBasicPosition,Status newStatus);
inline void setFakeBound(int sequence, FakeBound fakeBound) {
unsigned char & st_byte = internalStatus_[sequence];
st_byte = static_cast<unsigned char>(st_byte & ~24);
st_byte = static_cast<unsigned char>(st_byte | (fakeBound << 3));
}
inline FakeBound getFakeBound(int sequence) const {
return static_cast<FakeBound> ((internalStatus_[sequence] >> 3) & 3);
}
bool atFakeBound(int sequence) const;
inline void setPivoted( int sequence) {
internalStatus_[sequence] = static_cast<unsigned char>(internalStatus_[sequence] | 32);
}
inline void clearPivoted( int sequence) {
internalStatus_[sequence] = static_cast<unsigned char>(internalStatus_[sequence] & ~32);
}
inline bool pivoted(int sequence) const {
return (((internalStatus_[sequence] >> 5) & 1) != 0);
}
public:
/// Swaps two variables
void swap(int pivotRow,int nonBasicPosition);
/// To flag a variable
void setFlagged( int sequence);
inline void clearFlagged( int sequence) {
internalStatus_[sequence] = static_cast<unsigned char>(internalStatus_[sequence] & ~64);
}
inline bool flagged(int sequence) const {
return ((internalStatus_[sequence] & 64) != 0);
}
protected:
/// To say row active in primal pivot row choice
inline void setActive( int iRow) {
internalStatus_[iRow] = static_cast<unsigned char>(internalStatus_[iRow] | 128);
}
inline void clearActive( int iRow) {
internalStatus_[iRow] = static_cast<unsigned char>(internalStatus_[iRow] & ~128);
}
inline bool active(int iRow) const {
return ((internalStatus_[iRow] & 128) != 0);
}
public:
/** Set up status array (can be used by OsiAbc).
Also can be used to set up all slack basis */
void createStatus() ;
/// Does sort of crash
void crash(int type);
/** Puts more stuff in basis
1 bit set - do even if basis exists
2 bit set - don't bother staying triangular
*/
void putStuffInBasis(int type);
/** Sets up all slack basis and resets solution to
as it was after initial load or readMps */
void allSlackBasis();
/// For debug - check pivotVariable consistent
void checkConsistentPivots() const;
/// Print stuff
void printStuff() const;
/// Common bits of coding for dual and primal
int startup(int ifValuesPass);
/// Raw objective value (so always minimize in primal)
inline double rawObjectiveValue() const {
return objectiveValue_;
}
/// Compute objective value from solution and put in objectiveValue_
void computeObjectiveValue(bool useWorkingSolution = false);
/// Compute minimization objective value from internal solution without perturbation
double computeInternalObjectiveValue();
/// Move status and solution across
void moveInfo(const AbcSimplex & rhs, bool justStatus = false);
#ifndef NUMBER_THREADS
#define NUMBER_THREADS 3
#endif
#if ABC_PARALLEL==1
// For waking up thread
inline pthread_mutex_t * mutexPointer(int which,int thread=0)
{ return mutex_+which+3*thread;}
inline pthread_barrier_t * barrierPointer()
{ return &barrier_;}
inline int whichLocked(int thread=0) const
{ return locked_[thread];}
inline CoinThreadInfo * threadInfoPointer(int thread=0)
{ return threadInfo_+thread;}
void startParallelStuff(int type);
int stopParallelStuff(int type);
/// so thread can find out which one it is
int whichThread() const;
#elif ABC_PARALLEL==2
//inline CoinThreadInfo * threadInfoPointer(int thread=0)
//{ return threadInfo_+thread;}
#endif
//@}
//-------------------------------------------------------------------------
/**@name Changing bounds on variables and constraints */
//@{
/** Set an objective function coefficient */
void setObjectiveCoefficient( int elementIndex, double elementValue );
/** Set an objective function coefficient */
inline void setObjCoeff( int elementIndex, double elementValue ) {
setObjectiveCoefficient( elementIndex, elementValue);
}
/** Set a single column lower bound<br>
Use -DBL_MAX for -infinity. */
void setColumnLower( int elementIndex, double elementValue );
/** Set a single column upper bound<br>
Use DBL_MAX for infinity. */
void setColumnUpper( int elementIndex, double elementValue );
/** Set a single column lower and upper bound */
void setColumnBounds( int elementIndex,
double lower, double upper );
/** Set the bounds on a number of columns simultaneously<br>
The default implementation just invokes setColLower() and
setColUpper() over and over again.
@param indexFirst,indexLast pointers to the beginning and after the
end of the array of the indices of the variables whose
<em>either</em> bound changes
@param boundList the new lower/upper bound pairs for the variables
*/
void setColumnSetBounds(const int* indexFirst,
const int* indexLast,
const double* boundList);
/** Set a single column lower bound<br>
Use -DBL_MAX for -infinity. */
inline void setColLower( int elementIndex, double elementValue ) {
setColumnLower(elementIndex, elementValue);
}
/** Set a single column upper bound<br>
Use DBL_MAX for infinity. */
inline void setColUpper( int elementIndex, double elementValue ) {
setColumnUpper(elementIndex, elementValue);
}
/** Set a single column lower and upper bound */
inline void setColBounds( int elementIndex,
double newlower, double newupper ) {
setColumnBounds(elementIndex, newlower, newupper);
}
/** Set the bounds on a number of columns simultaneously<br>
@param indexFirst,indexLast pointers to the beginning and after the
end of the array of the indices of the variables whose
<em>either</em> bound changes
@param boundList the new lower/upper bound pairs for the variables
*/
inline void setColSetBounds(const int* indexFirst,
const int* indexLast,
const double* boundList) {
setColumnSetBounds(indexFirst, indexLast, boundList);
}
/** Set a single row lower bound<br>
Use -DBL_MAX for -infinity. */
void setRowLower( int elementIndex, double elementValue );
/** Set a single row upper bound<br>
Use DBL_MAX for infinity. */
void setRowUpper( int elementIndex, double elementValue ) ;
/** Set a single row lower and upper bound */
void setRowBounds( int elementIndex,
double lower, double upper ) ;
/** Set the bounds on a number of rows simultaneously<br>
@param indexFirst,indexLast pointers to the beginning and after the
end of the array of the indices of the constraints whose
<em>either</em> bound changes
@param boundList the new lower/upper bound pairs for the constraints
*/
void setRowSetBounds(const int* indexFirst,
const int* indexLast,
const double* boundList);
/// Resizes rim part of model
void resize (int newNumberRows, int newNumberColumns);
//@}
////////////////// data //////////////////
protected:
/**@name data. Many arrays have a row part and a column part.
There is a single array with both - columns then rows and
then normally two arrays pointing to rows and columns. The
single array is the owner of memory
*/
//@{
/// Sum of nonbasic costs
double sumNonBasicCosts_;
/// Sum of costs (raw objective value)
double rawObjectiveValue_;
/// Objective offset (from offset_)
double objectiveOffset_;
/** Perturbation factor
If <0.0 then virtual
if 0.0 none
if >0.0 use this as factor */
double perturbationFactor_;
/// Current dualTolerance (will end up as dualTolerance_)
double currentDualTolerance_;
/// Current dualBound (will end up as dualBound_)
double currentDualBound_;
/// Largest gap
double largestGap_;
/// Last dual bound
double lastDualBound_;
/// Sum of infeasibilities when using fake perturbation tolerance
double sumFakeInfeasibilities_;
/// Last primal error
double lastPrimalError_;
/// Last dual error
double lastDualError_;
/// Acceptable pivot for this iteration
double currentAcceptablePivot_;
/// Movement of variable
double movement_;
/// Objective change
double objectiveChange_;
/// Btran alpha
double btranAlpha_;
/// FT alpha
#ifdef ABC_LONG_FACTORIZATION
long
#endif
double ftAlpha_;
/// Minimum theta movement
double minimumThetaMovement_;
/// Initial sum of infeasibilities
double initialSumInfeasibilities_;
public:
/// Where we are in iteration
int stateOfIteration_;
protected:
/// Last firstFree_
int lastFirstFree_;
/// Free chosen vector
int freeSequenceIn_;
/// Maximum number rows
int maximumAbcNumberRows_;
/// Maximum number columns
int maximumAbcNumberColumns_;
/// Maximum numberTotal
int maximumNumberTotal_;
/// Current number of variables flagged
int numberFlagged_;
/// Iteration at which to do relaxed dualColumn
int normalDualColumnIteration_;
/** State of dual waffle
-2 - in initial large tolerance phase
-1 - in medium tolerance phase
n - in correct tolerance phase and thought optimal n times
*/
int stateDualColumn_;
/*
May want to put some arrays into struct
Two arrays point to/from external
Order is basic,unused basic, at lower, at upper, superbasic, free, fixed with starts
*/
/// Number of variables (includes spare rows)
int numberTotal_;
/// Number of variables without fixed to zero (includes spare rows)
int numberTotalWithoutFixed_;
/// Start of variables at lower bound with no upper
#define startAtLowerNoOther_ maximumAbcNumberRows_
/// Start of variables at lower bound with upper
int startAtLowerOther_;
/// Start of variables at upper bound with no lower
int startAtUpperNoOther_;
/// Start of variables at upper bound with lower
int startAtUpperOther_;
/// Start of superBasic, free or awkward bounds variables
int startOther_;
/// Start of fixed variables
int startFixed_;
#ifdef EARLY_FACTORIZE
/// Number of iterations to try factorizing early
int numberEarly_;
#endif
/**
State of problem
State of external arrays
2048 - status OK
4096 - row primal solution OK
8192 - row dual solution OK
16384 - column primal solution OK
32768 - column dual solution OK
65536 - Everything not going smoothly (when smooth we forget about tiny bad djs)
131072 - when increasing rows add a bit
262144 - scale matrix and create new one
524288 - do basis and order
1048576 - just status (and check if order needed)
2097152 - just solution
4194304 - just redo bounds (and offset)
Bottom bits say if usefulArray in use
*/
#define ALL_STATUS_OK 2048
#define ROW_PRIMAL_OK 4096
#define ROW_DUAL_OK 8192
#define COLUMN_PRIMAL_OK 16384
#define COLUMN_DUAL_OK 32768
#define PESSIMISTIC 65536
#define ADD_A_BIT 131072
#define DO_SCALE_AND_MATRIX 262144
#define DO_BASIS_AND_ORDER 524288
#define DO_STATUS 1048576
#define DO_SOLUTION 2097152
#define DO_JUST_BOUNDS 0x400000
#define NEED_BASIS_SORT 0x800000
#define FAKE_SUPERBASIC 0x1000000
#define VALUES_PASS 0x2000000
#define VALUES_PASS2 0x4000000
mutable int stateOfProblem_;
#if ABC_PARALLEL
public:
/// parallel mode
int parallelMode_;
protected:
#endif
/// Number of ordinary (lo/up) in tableau row
int numberOrdinary_;
/// Set to 1 if no free or super basic
int ordinaryVariables_;
/// Number of free nonbasic variables
int numberFreeNonBasic_;
/// Last time cleaned up
int lastCleaned_;
/// Current/last pivot row (set after END of choosing pivot row in dual)
int lastPivotRow_;
/// Nonzero (probably 10) if swapped algorithms
int swappedAlgorithm_;
/// Initial number of infeasibilities
int initialNumberInfeasibilities_;
/// Points from external to internal
//int * fromExternal_;
/// Points from internal to external
//int * toExternal_;
/** Scale from primal external to internal (in external order) Or other way for dual
*/
double * scaleFromExternal_;
/** Scale from primal internal to external (in external order) Or other way for dual
*/
double * scaleToExternal_;
/// use this instead of columnScale
double * columnUseScale_;
/// use this instead of inverseColumnScale
double * inverseColumnUseScale_;
/** Primal offset (in external order)
So internal value is (external-offset)*scaleFromExternal
*/
double * offset_;
/// Offset for accumulated offsets*matrix
double * offsetRhs_;
/// Useful array of numberTotal length
double * tempArray_;
/** Working status
? may be signed
? link pi_ to an indexed array?
may have saved from last factorization at end */
unsigned char * internalStatus_;
/// Saved status
unsigned char * internalStatusSaved_;
/** Perturbation (fixed) - is just scaled random numbers
If perturbationFactor_<0 then virtual perturbation */
double * abcPerturbation_;
/// saved perturbation
double * perturbationSaved_;
/// basic perturbation
double * perturbationBasic_;
/// Working matrix
AbcMatrix * abcMatrix_;
/** Working scaled copy of lower bounds
has original scaled copy at end */
double * abcLower_;
/** Working scaled copy of upper bounds
has original scaled copy at end */
double * abcUpper_;
/** Working scaled copy of objective
? where perturbed copy or can we
always work with perturbed copy (in B&B) if we adjust increments/cutoffs
? should we save a fixed perturbation offset array
has original scaled copy at end */
double * abcCost_;
/** Working scaled primal solution
may have saved from last factorization at end */
double * abcSolution_;
/** Working scaled dual solution
may have saved from last factorization at end */
double * abcDj_;
/// Saved scaled copy of lower bounds
double * lowerSaved_;
/// Saved scaled copy of upper bounds
double * upperSaved_;
/// Saved scaled copy of objective
double * costSaved_;
/// Saved scaled primal solution
double * solutionSaved_;
/// Saved scaled dual solution
double * djSaved_;
/// Working scaled copy of basic lower bounds
double * lowerBasic_;
/// Working scaled copy of basic upper bounds
double * upperBasic_;
/// Working scaled copy of basic objective
double * costBasic_;
/// Working scaled basic primal solution
double * solutionBasic_;
/// Working scaled basic dual solution (want it to be zero)
double * djBasic_;
/// dual row pivot choice
AbcDualRowPivot * abcDualRowPivot_;
/// primal column pivot choice
AbcPrimalColumnPivot * abcPrimalColumnPivot_;
/** Basic variables pivoting on which rows
followed by atLo/atUp then free/superbasic then fixed
*/
int * abcPivotVariable_;
/// Reverse abcPivotVariable_ for moving around
int * reversePivotVariable_;
/// factorization
AbcSimplexFactorization * abcFactorization_;
#ifdef EARLY_FACTORIZE
/// Alternative factorization
AbcSimplexFactorization * abcEarlyFactorization_;
#endif
#ifdef TEMPORARY_FACTORIZATION
/// Alternative factorization
AbcSimplexFactorization * abcOtherFactorization_;
#endif
/// Saved version of solution
//double * savedSolution_;
/// A copy of model with certain state - normally without cuts
AbcSimplex * abcBaseModel_;
/// A copy of model as ClpSimplex with certain state
ClpSimplex * clpModel_;
/** Very wasteful way of dealing with infeasibilities in primal.
However it will allow non-linearities and use of dual
analysis. If it doesn't work it can easily be replaced.
*/
AbcNonLinearCost * abcNonLinearCost_;
/// Useful arrays (all of row+column+2 length)
/* has secondary offset and counts so row goes first then column
Probably back to CoinPartitionedVector as AbcMatrix has slacks
also says if in use - so we can just get next available one */
#define ABC_NUMBER_USEFUL 8
mutable CoinPartitionedVector usefulArray_[ABC_NUMBER_USEFUL];
/// For dealing with all issues of cycling etc
AbcSimplexProgress abcProgress_;
/// For saving stuff at beginning
ClpDataSave saveData_;
/// upper theta from dual column
double upperTheta_;
/// Multiple sequence in
int multipleSequenceIn_[4];
public:
int arrayForDualColumn_;
int arrayForReplaceColumn_;
int arrayForFlipBounds_; //2
int arrayForFlipRhs_; // if sequential can re-use
int arrayForBtran_; // 0
int arrayForFtran_; // 1
int arrayForTableauRow_; //3
protected:
int numberFlipped_;
int numberDisasters_;
//int nextCleanNonBasicIteration_;
#if ABC_PARALLEL==1
// For waking up thread
pthread_mutex_t mutex_[3*NUMBER_THREADS];
pthread_barrier_t barrier_;
CoinThreadInfo threadInfo_[NUMBER_THREADS];
pthread_t abcThread_[NUMBER_THREADS];
int locked_[NUMBER_THREADS];
int stopStart_;
#elif ABC_PARALLEL==2
//CoinThreadInfo threadInfo_[NUMBER_THREADS];
#endif
//@}
};
//#############################################################################
/** A function that tests the methods in the AbcSimplex class. The
only reason for it not to be a member method is that this way it doesn't
have to be compiled into the library. And that's a gain, because the
library should be compiled with optimization on, but this method should be
compiled with debugging.
It also does some testing of AbcSimplexFactorization class
*/
void
AbcSimplexUnitTest(const std::string & mpsDir);
#endif
|
// -----------------------------------------------------------------------------------------------------
// Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
// Copyright (c) 2016-2019, Knut Reinert & MPI für molekulare Genetik
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
// -----------------------------------------------------------------------------------------------------
#pragma once
#include <vector>
#include "alignment_fixture.hpp"
#include "semi_global_edit_distance_unbanded.hpp"
#include <seqan3/alignment/configuration/align_config_aligned_ends.hpp>
#include <seqan3/alignment/configuration/align_config_edit.hpp>
#include <seqan3/alignment/configuration/align_config_max_error.hpp>
#include <seqan3/alphabet/aminoacid/aa27.hpp>
#include <seqan3/alphabet/nucleotide/dna4.hpp>
namespace seqan3::test::alignment::fixture::semi_global::edit_distance::max_errors::unbanded
{
using namespace seqan3::test::alignment::fixture::semi_global::edit_distance::unbanded;
using detail::column_index_type;
using detail::row_index_type;
static auto dna4_01_e255 = []()
{
return alignment_fixture
{
"AACCGGTTAACCGGTT"_dna4,
"ACGTACGTA"_dna4,
align_cfg::edit | align_cfg::max_error{255} | align_cfg::aligned_ends{free_ends_first},
-5,
"AC---CGGTT",
"ACGTACG-TA",
dna4_01.front_coordinate,
dna4_01.back_coordinate,
dna4_01.score_vector,
dna4_01.trace_vector
};
}();
static auto dna4_01_e5 = []()
{
std::vector<bool> masking_matrix
{
// e, A, A, C, C, G, G, T, T, A, A, C, C, G, G, T, T
/*e*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*A*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*C*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*G*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*T*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*A*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*C*/ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*G*/ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*T*/ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
/*A*/ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1
};
return alignment_fixture
{
"AACCGGTTAACCGGTT"_dna4,
"ACGTACGTA"_dna4,
align_cfg::edit | align_cfg::max_error{5} | align_cfg::aligned_ends{free_ends_first},
-5,
"AC---CGGTT",
"ACGTACG-TA",
dna4_01.front_coordinate,
dna4_01.back_coordinate,
dna4_01.score_matrix().mask_matrix(masking_matrix),
dna4_01.trace_matrix().mask_matrix(masking_matrix)
};
}();
static auto dna4_01_e2 = []()
{
std::vector<bool> masking_matrix
{
// e, A, A, C, C, G, G, T, T, A, A, C, C, G, G, T, T
/*e*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*A*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*C*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/*G*/ 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0,
/*T*/ 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0,
/*A*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*C*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*G*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*T*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*A*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
return alignment_fixture
{
"AACCGGTTAACCGGTT"_dna4,
"ACGTACGTA"_dna4,
align_cfg::edit | align_cfg::max_error{2} | align_cfg::aligned_ends{free_ends_first},
INF,
"",
"",
alignment_coordinate{column_index_type{16u}, row_index_type{9u}},
alignment_coordinate{column_index_type{16u}, row_index_type{9u}},
dna4_01.score_matrix().mask_matrix(masking_matrix),
dna4_01.trace_matrix().mask_matrix(masking_matrix)
};
}();
static auto dna4_01T_e255 = []()
{
return alignment_fixture
{
"ACGTACGTA"_dna4,
"AACCGGTTAACCGGTT"_dna4,
align_cfg::edit | align_cfg::max_error{255} | align_cfg::aligned_ends{free_ends_first},
-8,
"A-C-G-T-A-C-G-TA",
"AACCGGTTAACCGGTT",
dna4_01T.front_coordinate,
dna4_01T.back_coordinate,
dna4_01T.score_vector,
dna4_01T.trace_vector
};
}();
static auto dna4_02_e255 = []()
{
return alignment_fixture
{
"AACCGGTAAACCGGTT"_dna4,
"ACGTACGTA"_dna4,
align_cfg::edit | align_cfg::max_error{255} | align_cfg::aligned_ends{free_ends_first},
-4,
"AC---CGGTA",
"ACGTACG-TA",
dna4_02.front_coordinate,
dna4_02.back_coordinate,
dna4_02.score_vector,
dna4_02.trace_vector
};
}();
static auto aa27_01_e255 = []()
{
return alignment_fixture
{
"UUWWRRIIUUWWRRII"_aa27,
"UWRIUWRIU"_aa27,
align_cfg::edit | align_cfg::max_error{255} | align_cfg::aligned_ends{free_ends_first},
-5,
"UW---WRRII",
"UWRIUWR-IU",
aa27_01.front_coordinate,
aa27_01.back_coordinate,
aa27_01.score_vector,
aa27_01.trace_vector
};
}();
static auto aa27_01T_e255 = []()
{
return alignment_fixture
{
"UWRIUWRIU"_aa27,
"UUWWRRIIUUWWRRII"_aa27,
align_cfg::edit | align_cfg::max_error{255} | align_cfg::aligned_ends{free_ends_first},
-8,
"U-W-R-I-U-W-R-IU",
"UUWWRRIIUUWWRRII",
aa27_01T.front_coordinate,
aa27_01T.back_coordinate,
aa27_01T.score_vector,
aa27_01T.trace_vector
};
}();
} // namespace seqan3::test::alignment::fixture::global::edit_distance::unbanded
|
; A077446: Numbers n such that 2*n^2 + 14 is a square.
; 1,5,11,31,65,181,379,1055,2209,6149,12875,35839,75041,208885,437371,1217471,2549185,7095941,14857739,41358175,86597249,241053109,504725755,1404960479,2941757281,8188709765,17145817931,47727298111,99933150305,278175078901,582453083899,1621323175295,3394785353089,9449763972869,19786259034635,55077260661919,115322768854721,321013799998645,672150354093691,1871005539329951,3917579355707425,10905019435981061,22833325780150859,63559111076556415,133082375325197729,370449647023357429,775660926171035515,2159138771063588159,4520883181701015361,12584382979358171525,26349638164035056651,73347159105085440991,153576945802509324545,427498571651154474421,895112036651020890619,2491644270801841405535,5217095274103616019169,14522367053159893958789,30407459607970675224395,84642558048157522347199,177227662373720435327201,493332981235785240124405,1032958514634351936738811,2875355329366553918399231,6020523425432391185105665,16758798994963538270270981,35090182037959995173895179,97677438640414675703226655,204520568802327579858265409,569305832847524515949088949,1192033230776005483975697275,3318157558444732419991307039,6947678815853705323995918241,19339639517820870003998753285,40494039664346226459999812171,112719679548480487604001212671,236016559170223653436002954785,656978437773062055620008522741,1375605315356995694156017916539,3829150947089891846116049923775,8017615332971750511500104544449,22317927244766289021076291019909,46730086682473507374844609350155,130078412521507842280341696195679,272362904761869293737567551556481,758152547884280764660973886154165,1587447341888742255050560699988731,4418836874784176745685501620729311,9252321146570584236565796648375905,25754868700820779709452035838221701,53926479537534763164344219190266699,150110375330140501511026713408600895,314306556078637994749499518493224289,874907383280022229356708244613383669
lpb $0
sub $0,1
mov $2,$0
max $2,0
seq $2,143609 ; Numerators of the upper principal and intermediate convergents to 2^(1/2).
add $1,$2
lpe
mul $1,2
add $1,1
mov $0,$1
|
; double expm1(double x)
SECTION code_fp_math48
PUBLIC am48_expm1
EXTERN am48_exp, am48_dconst_1, am48_dsub, am48_dpopret
am48_expm1:
; compute exp(AC')-1
;
; enter : AC' = double x
;
; exit : success
;
; AC' = exp(x) - 1
; carry reset
;
; fail if overflow
;
; AC' = +inf
; carry set, errno set
;
; uses : af, af', bc', de', hl'
call am48_exp
ret c ; if overflow
push bc ; save AC
push de
push hl
call am48_dconst_1
call am48_dsub
jp am48_dpopret
|
; A269895: Number of n X 1 0..6 arrays with some element plus some horizontally or vertically adjacent neighbor totalling six exactly once.
; 0,7,84,756,6048,45360,326592,2286144,15676416,105815808,705438720,4655895552,30474952704,198087192576,1279948013568,8228237230080,52660718272512,335712078987264,2132759090036736,13507474236899328,85310363601469440,537455290689257472,3378290398618189824,21191094318605008896,132674677473005273088,829216734206282956800,5174312421447205650432,32239946625940281360384,200604112339183972909056,1246611269536357545934848,7737587190225667526492160,47973040579399138664251392,297123348104665633017298944,1838450716397618604294537216,11364968065003460462911684608,70195390989727255800336875520,433205841536602492939221860352,2671436022809048706458534805504,16461821978390894731690430693376,101370166919564983347777915322368,623816411812707589832479478906880,3836470932648151677469748795277312,23580260366520346895667724302680064,144850170822910702359101735002177536,889312676680195940065182745129648128
mov $1,6
pow $1,$0
mul $1,$0
div $1,6
mul $1,7
mov $0,$1
|
%ifdef CONFIG
{
"RegData": {
"RCX": "0x10000"
},
"Mode": "32BIT"
}
%endif
mov ecx, 0x10
.loop:
dec ecx
jecxz .end
jmp .loop
.end:
mov ecx, 0x1FFFF
.loop2:
dec cx
jcxz .end2
jmp .loop2
.end2:
hlt
|
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <stdio.h>
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "JVMTITools.h"
extern "C" {
#define PASSED 0
#define STATUS_FAILED 2
static jvmtiEnv *jvmti = NULL;
static jvmtiEventCallbacks callbacks;
static jint result = PASSED;
static jboolean printdump = JNI_FALSE;
static int eventsCount = 0;
static int eventsExpected = 0;
static const char *prefix = NULL;
void JNICALL ThreadEnd(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
jvmtiError err;
jvmtiThreadInfo inf;
char name[32];
err = jvmti_env->GetThreadInfo(thread, &inf);
if (err != JVMTI_ERROR_NONE) {
printf("(GetThreadInfo#%d) unexpected error: %s (%d)\n",
eventsCount, TranslateError(err), err);
result = STATUS_FAILED;
}
if (printdump == JNI_TRUE) {
printf(">>> %s\n", inf.name);
}
if (inf.name != NULL && strstr(inf.name, prefix) == inf.name) {
eventsCount++;
sprintf(name, "%s%d", prefix, eventsCount);
if (inf.name == NULL || strcmp(name, inf.name) != 0) {
printf("(#%d) wrong thread name: \"%s\"",
eventsCount, inf.name);
printf(", expected: \"%s\"\n", name);
result = STATUS_FAILED;
}
}
}
#ifdef STATIC_BUILD
JNIEXPORT jint JNICALL Agent_OnLoad_threadend001(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNICALL Agent_OnAttach_threadend001(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNI_OnLoad_threadend001(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiError err;
jint res;
if (options != NULL && strcmp(options, "printdump") == 0) {
printdump = JNI_TRUE;
}
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK || jvmti == NULL) {
printf("Wrong result of a valid call to GetEnv!\n");
return JNI_ERR;
}
callbacks.ThreadEnd = &ThreadEnd;
err = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks));
if (err != JVMTI_ERROR_NONE) {
printf("(SetEventCallbacks) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;
}
return JNI_OK;
}
JNIEXPORT void JNICALL
Java_nsk_jvmti_ThreadEnd_threadend001_getReady(JNIEnv *env,
jclass cls, jint i, jstring name) {
jvmtiError err;
if (jvmti == NULL) {
printf("JVMTI client was not properly loaded!\n");
return;
}
prefix = env->GetStringUTFChars(name, NULL);
if (prefix == NULL) {
printf("Failed to copy UTF-8 string!\n");
result = STATUS_FAILED;
return;
}
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
JVMTI_EVENT_THREAD_END, NULL);
if (err == JVMTI_ERROR_NONE) {
eventsExpected = i;
} else {
printf("Failed to enable JVMTI_EVENT_THREAD_END: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
}
}
JNIEXPORT jint JNICALL
Java_nsk_jvmti_ThreadEnd_threadend001_check(JNIEnv *env, jclass cls) {
jvmtiError err;
if (jvmti == NULL) {
printf("JVMTI client was not properly loaded!\n");
return STATUS_FAILED;
}
err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,
JVMTI_EVENT_THREAD_END, NULL);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to disable JVMTI_EVENT_THREAD_END: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
}
if (eventsCount != eventsExpected) {
printf("Wrong number of thread end events: %d, expected: %d\n",
eventsCount, eventsExpected);
result = STATUS_FAILED;
}
return result;
}
}
|
; A064758: a(n) = n*12^n - 1.
; 11,287,5183,82943,1244159,17915903,250822655,3439853567,46438023167,619173642239,8173092077567,106993205379071,1390911669927935,17974858503684095,231105323618795519,2958148142320582655,37716388814587428863,479219999055934390271,6070119988041835610111,76675199848949502443519,966107518096763730788351,12145351656073601187053567,152368957139832451255762943,1907924332881380259202596863,23849054161017253240032460799,297636195929495320435605110783,3709004903121403223889848303615
add $0,1
mov $2,12
pow $2,$0
mul $0,$2
sub $0,1
|
; A070825: One half of product of first n+1 Lucas numbers A000032.
; Submitted by Christian Krause
; 1,1,3,12,84,924,16632,482328,22669416,1722875616,211913700768,42170826452832,13579006117811904,7074662187380001984,5963940223961341672512,8134814465483270041306368,17953535525321576981163154176,64112075360923351399733623562496,370439571435415124387660876944101888,3463239553349695997900241538550408550912,52388424723520851360236953753652030149645824,1282259083532896357893159680074387089942731188224,50781306485153294461642802809985951923001983247235072
mov $1,1
mov $2,2
mov $3,1
lpb $0
sub $0,1
add $4,$3
mul $1,$4
mov $3,$2
mov $2,$4
lpe
mov $0,$1
|
INCLUDE "hardware.inc"
INCLUDE "macros.inc"
SECTION "GameVars", WRAM0
ShadowScrollX:: DS 1
IsGamePaused:: DS 1 ; 0 = unpaused, nonzero = paused
IsGameOver:: DS 1 ; 0 = in play, nonzero = game over
SECTION "MainGameCode", ROM0
StartGame::
call disableLCD
; Initialize sprite buffer to 0
ld hl, STARTOF("SpriteBuffer")
ld c, SIZEOF("SpriteBuffer")
ld d, 0
rst memsetFast
; Copy tileset into VRAM
rom_bank_switch BANK("RoadTiles1")
ld hl, RoadTiles1VRAM
ld de, STARTOF("RoadTiles1")
ld bc, SIZEOF("RoadTiles1")
call memcpy
rom_bank_switch BANK("RoadTiles2")
ld hl, RoadTiles2VRAM
ld de, STARTOF("RoadTiles2")
ld bc, SIZEOF("RoadTiles2")
call memcpy
rom_bank_switch BANK("RoadTiles3")
ld hl, RoadTiles3VRAM
ld de, STARTOF("RoadTiles3")
ld bc, SIZEOF("RoadTiles3")
call memcpy
rom_bank_switch BANK("RoadTiles4")
ld hl, RoadTiles4VRAM
ld de, STARTOF("RoadTiles4")
ld bc, SIZEOF("RoadTiles4")
call memcpy
rom_bank_switch BANK("RoadObjectTiles")
ld hl, RoadObjectTilesVRAM
ld de, STARTOF("RoadObjectTiles")
ld bc, SIZEOF("RoadObjectTiles")
call memcpy
rom_bank_switch BANK("PoliceCarTiles")
ld hl, PoliceCarTilesVRAM
ld de, STARTOF("PoliceCarTiles")
ld bc, SIZEOF("PoliceCarTiles")
call memcpy
rom_bank_switch BANK("PoliceHeavyTiles")
ld hl, PoliceHeavyTilesVRAM
ld de, STARTOF("PoliceHeavyTiles")
ld bc, SIZEOF("PoliceHeavyTiles")
call memcpy
rom_bank_switch BANK("HelicopterTiles")
ld hl, HelicopterTilesVRAM
ld de, STARTOF("HelicopterTiles")
ld bc, SIZEOF("HelicopterTiles")
call memcpy
rom_bank_switch BANK("HelicopterExplosionTiles")
ld hl, HelicopterExplosionTilesVRAM
ld de, STARTOF("HelicopterExplosionTiles")
ld bc, SIZEOF("HelicopterExplosionTiles")
call memcpy
rom_bank_switch BANK("MissileTiles")
ld hl, MissileTilesVRAM
ld de, STARTOF("MissileTiles")
ld bc, SIZEOF("MissileTiles")
call memcpy
rom_bank_switch BANK("Explosion1Tiles")
ld hl, Explosion1TilesVRAM
ld de, STARTOF("Explosion1Tiles")
ld bc, SIZEOF("Explosion1Tiles")
call memcpy
rom_bank_switch BANK("WarningTiles")
ld hl, WarningTilesVRAM
ld de, STARTOF("WarningTiles")
ld bc, SIZEOF("WarningTiles")
call memcpy
rom_bank_switch BANK("StatusBar")
ld hl, StatusBarVRAM
ld de, STARTOF("StatusBar")
ld bc, SIZEOF("StatusBar")
call memcpy
rom_bank_switch BANK("MenuBarTiles")
ld hl, MenuBarTilesVRAM
ld de, STARTOF("MenuBarTiles")
ld bc, SIZEOF("MenuBarTiles")
call memcpy
rom_bank_switch BANK("FontTiles")
ld hl, MenuBarNumbersVRAM
ld de, STARTOF("FontTiles") + 53 * 16
ld bc, 10 * 16
call memcpy
ld a, %11100100 ; Init background palette
ldh [rBGP], a
ldh [rOBP0], a ; Init sprite palettes
ldh [rOBP1], a
; Init menu bar tilemaps
call genMenuBarTilemaps
; Initialise variables
call initDistance
call initCollision
call initGameUI
call initRoadGen
call initPlayer
call initEnemyCars
call initHelicopter
call initMissiles
call initRoadObject
call initSpecial
call initScreenShake
xor a
ld [IsGamePaused], a
ld [IsGameOver], a
ld a, 16 ; Init X scroll
ld [ShadowScrollX], a
;ld a, 19 ; Generate enough road for the whole screen, plus 1 extra line
ld a, 24 ; Generate enough road for the whole screen, plus several extra lines
.pregenRoadLp:
push af
call GenRoadRow
call CopyRoadBuffer
pop af
dec a
jr nz, .pregenRoadLp
; Init VBlank vector
ld hl, VblankVectorRAM
ld a, LOW(InGameVBlank)
ld [hli], a
ld a, HIGH(InGameVBlank)
ld [hl], a
; Enable screen and initialise screen settings
ld a, LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 \
| LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON
ldh [rLCDC], a
; Enable LY=LYC as LCD STAT interrupt source
ld a, STATF_LYC
ldh [rSTAT], a
; Make sure no erroneous LYC interrupts happen before it's set up
ld a, $FF
ldh [rLYC], a
; Disable all interrupts except VBlank and LCD
ld a, IEF_VBLANK | IEF_STAT
ldh [rIE], a
xor a
ldh [rIF], a ; Discard all pending interrupts (there would normally be a VBlank pending)
ei
GameLoop:
call readInput
ld a, [IsGamePaused]
ld b, a
ld a, [IsGameOver]
or b
jr z, .notPaused
call updateMenuBar
jr .paused
.notPaused:
ld a, [newButtons] ; Pause if start button is pressed
and PADF_START
jr z, .pauseNotPressed
ld a, $FF
ld [IsGamePaused], a
xor a ; open pause menu
call startMenuBarAnim
play_sound_effect FX_Pause
.pauseNotPressed:
call updateRoad
call updatePlayer
call updateEnemyCars
call updateHelicopter
call updateMissiles
call updateRoadObject
call updateSpecial
call updateStatusBar
call updateScreenShake
.paused:
call updateAudio
.doneGameLoop:
call waitVblank
jr GameLoop
; Update road scroll, and generate new line of road if needed
updateRoad:
ld a, [CurrentRoadScrollSpeed + 1] ; Load subpixel portion of road speed
ld b, a ; put that into B
ld hl, CurrentRoadScrollPos + 1
ld a, [hl] ; Load current subpixel into A
sub b ; Apply subpixel speed to current subpixel position
ld [hl], a ; Save back current subpixel pos
ld a, [CurrentRoadScrollSpeed] ; Load pixel portion of road speed
adc 0 ; If subpixels overflowed, apply a full pixel to road speed
ld b, a ; ; A and B now contains the number of pixels to scroll this frame
ld hl, CurrentRoadScrollPos
ld a, [hl] ; \
sub b ; | Update the road scroll pixel
ld [hl], a ; /
; Update RoadScrollCtr, and generate new road line if needed
ld hl, RoadScrollCtr
ld a, [hl]
add b ; B is still the number of lines scrolled this frame
ld [hl], a
cp 8 - 1 ; 8 pixels per line, minus 1 so carry can be used as <
ret nc ; if RoadScrollCtr <= 7 (i.e. < 8), no new line is needed
sub 8
ld [hl], a ; hl = RoadScrollCtr
call GenRoadRow
call incrementDistance
ret
InGameVBlank:
; Copy new road line onto the background tilemap if one is ready
ld a, [RoadLineReady]
and a ; update zero flag
call nz, CopyRoadBuffer
; Copy status bar tilemap
call copyStatusBarBuffer
; Update Scroll
ld a, [CurrentRoadScrollPos]
ldh [rSCY], a
ld a, [ShadowScrollX]
ldh [rSCX], a
ldh a, [rLCDC]
or LCDCF_OBJON ; Enable sprites (status bar / ui disables them)
and ~LCDCF_BG9C00 ; Switch background tilemap
ldh [rLCDC], a
; Copy sprite buffer into OAM
call DMARoutineHRAM
ld a, [IsGamePaused]
ld b, a
ld a, [IsGameOver]
or b
jr nz, .menuBarActive
call setupStatusBarInterrupt ; If menu bar isn't present, go straight to status bar
jr .doneLCDIntSetup
.menuBarActive:
call setupMenuBarInterrupt ; If game is paused, setup menu bar interrupt instead of status bar
.doneLCDIntSetup:
jp VblankEnd
; Setup LY interrupt for top of status bar
setupStatusBarInterrupt::
ld hl, LCDIntVectorRAM
ld a, LOW(statusBarTopLine)
ld [hli], a
ld a, HIGH(statusBarTopLine)
ld [hl], a
ld a, 129 - 1 ; runs on line before
ld [rLYC], a
ret |
/*
Copyright (c) 2002-2009 Tampere University.
This file is part of TTA-Based Codesign Environment (TCE).
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.
*/
/**
* @file BEMSerializerTest.hh
*
* A test suite for BEMSerializer.
*
* @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
* @note rating: red
*/
#ifndef BEMSerializerTest_HH
#define BEMSerializerTest_HH
#include <string>
#include <TestSuite.h>
#include "BEMSerializer.hh"
#include "BinaryEncoding.hh"
#include "MoveSlot.hh"
#include "ImmediateControlField.hh"
#include "LImmDstRegisterField.hh"
#include "GuardField.hh"
#include "GPRGuardEncoding.hh"
#include "FUGuardEncoding.hh"
#include "BridgeEncoding.hh"
#include "ImmediateEncoding.hh"
#include "SocketEncoding.hh"
#include "NOPEncoding.hh"
#include "SourceField.hh"
#include "DestinationField.hh"
#include "SocketCodeTable.hh"
#include "FUPortCode.hh"
#include "RFPortCode.hh"
#include "IUPortCode.hh"
using std::string;
const string DST_FILE = "./data/testbem.bem";
/**
* Test suite for testing BEMSerializer class.
*/
class BEMSerializerTest : public CxxTest::TestSuite {
public:
void setUp();
void tearDown();
void testWriteAndRead();
private:
BinaryEncoding* bem_;
};
/**
* Called before each test.
*/
void
BEMSerializerTest::setUp() {
bem_ = new BinaryEncoding();
}
/**
* Called after each test.
*/
void
BEMSerializerTest::tearDown() {
delete bem_;
}
/**
* Tests writing a binary encoding map to a file and reading it.
*/
void
BEMSerializerTest::testWriteAndRead() {
const string bus1 = "bus1";
const string bus2 = "bus2";
const string bus3 = "bus3";
const string rf1 = "rf1";
const string fu1 = "fu1";
const string iu1 = "iu1";
const string iu2 = "iu2";
const string port1 = "port1";
const string port2 = "port2";
const string bridge1 = "br1";
const string bridge2 = "br2";
const string socket1 = "socket1";
const string socket2 = "socket2";
const string scTableName = "table1";
const string add = "add";
const string iTemp1 = "iTemp1";
MoveSlot* slot1 = new MoveSlot(bus1, *bem_);
MoveSlot* slot2 = new MoveSlot(bus2, *bem_);
MoveSlot* slot3 = new MoveSlot(bus3, *bem_);
LImmDstRegisterField* dstRegField1 = new LImmDstRegisterField(3, *bem_);
LImmDstRegisterField* dstRegField2 = new LImmDstRegisterField(2, *bem_);
ImmediateControlField* icField = new ImmediateControlField(*bem_);
GuardField* gField1 = new GuardField(*slot1);
new GPRGuardEncoding(rf1, 0, false, 0, *gField1);
new FUGuardEncoding(fu1, port1, true, 1, *gField1);
SourceField* srcField1 = new SourceField(BinaryEncoding::LEFT, *slot1);
new BridgeEncoding(bridge1, 0, 3, *srcField1);
new BridgeEncoding(bridge2, 1, 2, *srcField1);
SocketEncoding* sEnc1 = new SocketEncoding(socket1, 2, 1, *srcField1);
new SocketEncoding(socket2, 3, 1, *srcField1);
new ImmediateEncoding(2, 0, 8, *srcField1);
new NOPEncoding(3, 0, *srcField1);
SocketCodeTable* table = new SocketCodeTable(scTableName, *bem_);
new FUPortCode(fu1, port1, 24, 0, *table);
new FUPortCode(fu1, port2, add, 25, 0, *table);
new RFPortCode(rf1, 2, 0, 3, *table);
new IUPortCode(iu1, 0, 1, 4, *table);
sEnc1->setSocketCodes(*table);
DestinationField* dstField1 = new DestinationField(
BinaryEncoding::LEFT, *slot1);
new NOPEncoding(0, 0, *dstField1);
SourceField* srcField2 = new SourceField(BinaryEncoding::LEFT, *slot2);
new SocketEncoding(socket1, 0, 1, *srcField2);
SourceField* srcField3 = new SourceField(BinaryEncoding::LEFT, *slot3);
new SocketEncoding(socket2, 1, 0, *srcField3);
dstRegField1->addDestination(iTemp1, iu1);
dstRegField2->addDestination(iTemp1, iu2);
icField->addTemplateEncoding(iTemp1, 1);
BEMSerializer serializer;
serializer.setDestinationFile(DST_FILE);
serializer.writeBinaryEncoding(*bem_);
serializer.setSourceFile(DST_FILE);
BinaryEncoding* readBEM = serializer.readBinaryEncoding();
TS_ASSERT(readBEM->hasMoveSlot(bus1));
TS_ASSERT(readBEM->hasMoveSlot(bus2));
TS_ASSERT(readBEM->hasMoveSlot(bus3));
TS_ASSERT(readBEM->longImmDstRegisterFieldCount() == 2);
TS_ASSERT(readBEM->hasImmediateControlField());
MoveSlot& readSlot1 = readBEM->moveSlot(bus1);
MoveSlot& readSlot2 = readBEM->moveSlot(bus2);
MoveSlot& readSlot3 = readBEM->moveSlot(bus3);
LImmDstRegisterField& readDstRegField1 =
readBEM->longImmDstRegisterField(0);
ImmediateControlField& readICField = readBEM->immediateControlField();
TS_ASSERT(readSlot1.relativePosition() == 0);
TS_ASSERT(readSlot2.relativePosition() == 1);
TS_ASSERT(readSlot3.relativePosition() == 2);
TS_ASSERT(readDstRegField1.relativePosition() == 3);
TS_ASSERT(readICField.relativePosition() == 5);
DestinationField& readDstField1 = readSlot1.destinationField();
TS_ASSERT(readDstField1.hasNoOperationEncoding());
NOPEncoding& nopEncoding = readDstField1.noOperationEncoding();
TS_ASSERT(nopEncoding.encoding() == 0);
SourceField& readSrcField1 = readSlot1.sourceField();
TS_ASSERT(readSrcField1.componentIDPosition() == BinaryEncoding::LEFT);
TS_ASSERT(readSrcField1.bridgeEncodingCount() == 2);
SocketEncoding& readSocketEnc1 = readSrcField1.socketEncoding(socket1);
TS_ASSERT(readSocketEnc1.socketCodes().name() == scTableName);
TS_ASSERT(readSocketEnc1.encoding() == 2);
TS_ASSERT(readSocketEnc1.extraBits() == 1);
TS_ASSERT(readDstRegField1.usedByInstructionTemplate(iTemp1));
TS_ASSERT(
readDstRegField1.immediateUnit(iTemp1) == iu1 ||
readDstRegField1.immediateUnit(iTemp1) == iu2);
delete readBEM;
}
#endif
|
; Add safety check for the external Hlp_GetNpc in case a patch causes to save invalid symbol indices
%include "inc/macros.inc"
%if GOTHIC_BASE_VERSION == 1
%include "inc/symbols_g1.inc"
%elif GOTHIC_BASE_VERSION == 2
%include "inc/symbols_g2.inc"
%endif
%ifidn __OUTPUT_FORMAT__, bin
org g1g2(0x6587EC,0x6EEE4C)
%endif
bits 32
section .text align=1 ; Prevent auto-alignment
jmp fix_Hlp_GetNpc
nop
|
; A025783: Expansion of 1/((1-x)(1-x^6)(1-x^11)).
; 1,1,1,1,1,1,2,2,2,2,2,3,4,4,4,4,4,5,6,6,6,6,7,8,9,9,9,9,10,11,12,12,12,13,14,15,16,16,16,17,18,19,20,20,21,22,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39
mov $11,$0
add $11,1
lpb $11
clr $0,9
sub $11,1
sub $0,$11
lpb $0
mul $0,2
div $0,11
mul $0,6
mov $7,6
lpe
mov $6,1
sub $6,$7
add $6,2
mov $1,$6
trn $1,2
add $10,$1
lpe
mov $1,$10
|
; A203234: (n-1)-st elementary symmetric function of the first n terms of the periodic sequence (1,1,1,2,1,1,1,2,...).
; 1,2,3,7,9,11,13,28,32,36,40,84,92,100,108,224,240,256,272,560,592,624,656,1344,1408,1472,1536,3136,3264,3392,3520,7168,7424,7680,7936,16128,16640,17152,17664,35840,36864,37888,38912,78848,80896
mov $1,$0
add $0,1
div $0,4
add $1,1
mul $1,2
sub $1,$0
lpb $0
sub $0,1
mul $1,2
lpe
sub $1,2
div $1,2
add $1,1
|
; A017416: (11n+2)^4.
; 16,28561,331776,1500625,4477456,10556001,21381376,38950081,65610000,104060401,157351936,228886641,322417936,442050625,592240896,777796321,1003875856,1275989841,1600000000,1982119441
mul $0,11
add $0,2
pow $0,4
|
!to "via5a.prg", cbm
TESTID = 5
tmp=$fc
addr=$fd
add2=$f9
ERRBUF = $1f00
TMP = $2000 ; measured data on C64 side
DATA = $3000 ; reference data
TESTLEN = $20
NUMTESTS = 18 - 12
TESTSLOC = $1800
DTMP=screenmem
!src "common.asm"
* = TESTSLOC
;------------------------------------------
; before: --
; in the loop:
; [Timer B lo | Timer B hi] = loop counter
; start Timer B (set to count CLK)
; read [Timer B lo | Timer B hi | IRQ Flags]
!zone { ; M
.test ldx #0
.l1 stx viabase+$8 ; Timer B lo
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$8 ; Timer B lo
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; N
.test ldx #0
.l1 stx viabase+$8 ; Timer B lo
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$9 ; Timer B hi
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; O
.test ldx #0
.l1 stx viabase+$9 ; Timer B hi
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$8 ; Timer B lo
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; P
.test ldx #0
.l1 stx viabase+$9 ; Timer B hi
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$9 ; Timer B hi
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; Q
.test ldx #0
.l1 stx viabase+$8 ; Timer B lo
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$d ; IRQ Flags / ACK
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; R
.test ldx #0
.l1 stx viabase+$9 ; Timer B hi
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$d ; IRQ Flags / ACK
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
* = DATA
!bin "via5aref.bin", NUMTESTS * $0100, 2
|
; party menu icons
PUSHS
SECTION "Mon Menu Icons", ROMX
MonMenuIcons:
db ICON_BULBASAUR ; BULBASAUR
db ICON_BULBASAUR ; IVYSAUR
db ICON_BULBASAUR ; VENUSAUR
db ICON_CHARMANDER ; CHARMANDER
db ICON_CHARMANDER ; CHARMELEON
db ICON_BIGMON ; CHARIZARD
db ICON_SQUIRTLE ; SQUIRTLE
db ICON_SQUIRTLE ; WARTORTLE
db ICON_SQUIRTLE ; BLASTOISE
db ICON_CATERPILLAR ; CATERPIE
db ICON_CATERPILLAR ; METAPOD
db ICON_MOTH ; BUTTERFREE
db ICON_CATERPILLAR ; WEEDLE
db ICON_CATERPILLAR ; KAKUNA
db ICON_BUG ; BEEDRILL
db ICON_BIRD ; PIDGEY
db ICON_BIRD ; PIDGEOTTO
db ICON_BIRD ; PIDGEOT
db ICON_FOX ; RATTATA
db ICON_FOX ; RATICATE
db ICON_BIRD ; SPEAROW
db ICON_BIRD ; FEAROW
db ICON_SERPENT ; EKANS
db ICON_SERPENT ; ARBOK
db ICON_PIKACHU ; PIKACHU
db ICON_PIKACHU ; RAICHU
db ICON_MONSTER ; SANDSHREW
db ICON_MONSTER ; SANDSLASH
db ICON_FOX ; NIDORAN_F
db ICON_FOX ; NIDORINA
db ICON_MONSTER ; NIDOQUEEN
db ICON_FOX ; NIDORAN_M
db ICON_FOX ; NIDORINO
db ICON_MONSTER ; NIDOKING
db ICON_CLEFAIRY ; CLEFAIRY
db ICON_CLEFAIRY ; CLEFABLE
db ICON_FOX ; VULPIX
db ICON_FOX ; NINETALES
db ICON_JIGGLYPUFF ; JIGGLYPUFF
db ICON_JIGGLYPUFF ; WIGGLYTUFF
db ICON_BAT ; ZUBAT
db ICON_BAT ; GOLBAT
db ICON_ODDISH ; ODDISH
db ICON_ODDISH ; GLOOM
db ICON_ODDISH ; VILEPLUME
db ICON_BUG ; PARAS
db ICON_BUG ; PARASECT
db ICON_CATERPILLAR ; VENONAT
db ICON_MOTH ; VENOMOTH
db ICON_DIGLETT ; DIGLETT
db ICON_DIGLETT ; DUGTRIO
db ICON_FOX ; MEOWTH
db ICON_FOX ; PERSIAN
db ICON_MONSTER ; PSYDUCK
db ICON_MONSTER ; GOLDUCK
db ICON_FIGHTER ; MANKEY
db ICON_FIGHTER ; PRIMEAPE
db ICON_FOX ; GROWLITHE
db ICON_FOX ; ARCANINE
db ICON_POLIWAG ; POLIWAG
db ICON_POLIWAG ; POLIWHIRL
db ICON_POLIWAG ; POLIWRATH
db ICON_HUMANSHAPE ; ABRA
db ICON_HUMANSHAPE ; KADABRA
db ICON_HUMANSHAPE ; ALAKAZAM
db ICON_FIGHTER ; MACHOP
db ICON_FIGHTER ; MACHOKE
db ICON_FIGHTER ; MACHAMP
db ICON_ODDISH ; BELLSPROUT
db ICON_ODDISH ; WEEPINBELL
db ICON_ODDISH ; VICTREEBEL
db ICON_JELLYFISH ; TENTACOOL
db ICON_JELLYFISH ; TENTACRUEL
db ICON_GEODUDE ; GEODUDE
db ICON_GEODUDE ; GRAVELER
db ICON_GEODUDE ; GOLEM
db ICON_EQUINE ; PONYTA
db ICON_EQUINE ; RAPIDASH
db ICON_SLOWPOKE ; SLOWPOKE
db ICON_SLOWPOKE ; SLOWBRO
db ICON_VOLTORB ; MAGNEMITE
db ICON_VOLTORB ; MAGNETON
db ICON_BIRD ; FARFETCH_D
db ICON_BIRD ; DODUO
db ICON_BIRD ; DODRIO
db ICON_LAPRAS ; SEEL
db ICON_LAPRAS ; DEWGONG
db ICON_BLOB ; GRIMER
db ICON_BLOB ; MUK
db ICON_SHELL ; SHELLDER
db ICON_SHELL ; CLOYSTER
db ICON_GHOST ; GASTLY
db ICON_GHOST ; HAUNTER
db ICON_GHOST ; GENGAR
db ICON_SERPENT ; ONIX
db ICON_HUMANSHAPE ; DROWZEE
db ICON_HUMANSHAPE ; HYPNO
db ICON_SHELL ; KRABBY
db ICON_SHELL ; KINGLER
db ICON_VOLTORB ; VOLTORB
db ICON_VOLTORB ; ELECTRODE
db ICON_ODDISH ; EXEGGCUTE
db ICON_ODDISH ; EXEGGUTOR
db ICON_MONSTER ; CUBONE
db ICON_MONSTER ; MAROWAK
db ICON_FIGHTER ; HITMONLEE
db ICON_FIGHTER ; HITMONCHAN
db ICON_MONSTER ; LICKITUNG
db ICON_BLOB ; KOFFING
db ICON_BLOB ; WEEZING
db ICON_EQUINE ; RHYHORN
db ICON_MONSTER ; RHYDON
db ICON_CLEFAIRY ; CHANSEY
db ICON_ODDISH ; TANGELA
db ICON_MONSTER ; KANGASKHAN
db ICON_FISH ; HORSEA
db ICON_FISH ; SEADRA
db ICON_FISH ; GOLDEEN
db ICON_FISH ; SEAKING
db ICON_STARYU ; STARYU
db ICON_STARYU ; STARMIE
db ICON_HUMANSHAPE ; MR__MIME
db ICON_BUG ; SCYTHER
db ICON_HUMANSHAPE ; JYNX
db ICON_HUMANSHAPE ; ELECTABUZZ
db ICON_HUMANSHAPE ; MAGMAR
db ICON_BUG ; PINSIR
db ICON_EQUINE ; TAUROS
db ICON_FISH ; MAGIKARP
db ICON_GYARADOS ; GYARADOS
db ICON_LAPRAS ; LAPRAS
db ICON_BLOB ; DITTO
db ICON_FOX ; EEVEE
db ICON_FOX ; VAPOREON
db ICON_FOX ; JOLTEON
db ICON_FOX ; FLAREON
db ICON_VOLTORB ; PORYGON
db ICON_SHELL ; OMANYTE
db ICON_SHELL ; OMASTAR
db ICON_SHELL ; KABUTO
db ICON_SHELL ; KABUTOPS
db ICON_BIRD ; AERODACTYL
db ICON_SNORLAX ; SNORLAX
db ICON_BIRD ; ARTICUNO
db ICON_BIRD ; ZAPDOS
db ICON_BIRD ; MOLTRES
db ICON_SERPENT ; DRATINI
db ICON_SERPENT ; DRAGONAIR
db ICON_BIGMON ; DRAGONITE
db ICON_HUMANSHAPE ; MEWTWO
db ICON_HUMANSHAPE ; MEW
db ICON_ODDISH ; CHIKORITA
db ICON_ODDISH ; BAYLEEF
db ICON_ODDISH ; MEGANIUM
db ICON_FOX ; CYNDAQUIL
db ICON_FOX ; QUILAVA
db ICON_FOX ; TYPHLOSION
db ICON_MONSTER ; TOTODILE
db ICON_MONSTER ; CROCONAW
db ICON_MONSTER ; FERALIGATR
db ICON_FOX ; SENTRET
db ICON_FOX ; FURRET
db ICON_BIRD ; HOOTHOOT
db ICON_BIRD ; NOCTOWL
db ICON_BUG ; LEDYBA
db ICON_BUG ; LEDIAN
db ICON_BUG ; SPINARAK
db ICON_BUG ; ARIADOS
db ICON_BAT ; CROBAT
db ICON_FISH ; CHINCHOU
db ICON_FISH ; LANTURN
db ICON_PIKACHU ; PICHU
db ICON_CLEFAIRY ; CLEFFA
db ICON_JIGGLYPUFF ; IGGLYBUFF
db ICON_CLEFAIRY ; TOGEPI
db ICON_BIRD ; TOGETIC
db ICON_BIRD ; NATU
db ICON_BIRD ; XATU
db ICON_FOX ; MAREEP
db ICON_MONSTER ; FLAAFFY
db ICON_MONSTER ; AMPHAROS
db ICON_ODDISH ; BELLOSSOM
db ICON_JIGGLYPUFF ; MARILL
db ICON_JIGGLYPUFF ; AZUMARILL
db ICON_SUDOWOODO ; SUDOWOODO
db ICON_POLIWAG ; POLITOED
db ICON_ODDISH ; HOPPIP
db ICON_ODDISH ; SKIPLOOM
db ICON_ODDISH ; JUMPLUFF
db ICON_MONSTER ; AIPOM
db ICON_ODDISH ; SUNKERN
db ICON_ODDISH ; SUNFLORA
db ICON_BUG ; YANMA
db ICON_MONSTER ; WOOPER
db ICON_MONSTER ; QUAGSIRE
db ICON_FOX ; ESPEON
db ICON_FOX ; UMBREON
db ICON_BIRD ; MURKROW
db ICON_SLOWPOKE ; SLOWKING
db ICON_GHOST ; MISDREAVUS
db ICON_UNOWN ; UNOWN
db ICON_GHOST ; WOBBUFFET
db ICON_EQUINE ; GIRAFARIG
db ICON_BUG ; PINECO
db ICON_BUG ; FORRETRESS
db ICON_SERPENT ; DUNSPARCE
db ICON_BUG ; GLIGAR
db ICON_SERPENT ; STEELIX
db ICON_MONSTER ; SNUBBULL
db ICON_MONSTER ; GRANBULL
db ICON_FISH ; QWILFISH
db ICON_BUG ; SCIZOR
db ICON_BUG ; SHUCKLE
db ICON_BUG ; HERACROSS
db ICON_FOX ; SNEASEL
db ICON_MONSTER ; TEDDIURSA
db ICON_MONSTER ; URSARING
db ICON_BLOB ; SLUGMA
db ICON_BLOB ; MAGCARGO
db ICON_EQUINE ; SWINUB
db ICON_EQUINE ; PILOSWINE
db ICON_SHELL ; CORSOLA
db ICON_FISH ; REMORAID
db ICON_FISH ; OCTILLERY
db ICON_MONSTER ; DELIBIRD
db ICON_FISH ; MANTINE
db ICON_BIRD ; SKARMORY
db ICON_FOX ; HOUNDOUR
db ICON_FOX ; HOUNDOOM
db ICON_BIGMON ; KINGDRA
db ICON_EQUINE ; PHANPY
db ICON_EQUINE ; DONPHAN
db ICON_VOLTORB ; PORYGON2
db ICON_EQUINE ; STANTLER
db ICON_MONSTER ; SMEARGLE
db ICON_FIGHTER ; TYROGUE
db ICON_FIGHTER ; HITMONTOP
db ICON_HUMANSHAPE ; SMOOCHUM
db ICON_HUMANSHAPE ; ELEKID
db ICON_HUMANSHAPE ; MAGBY
db ICON_EQUINE ; MILTANK
db ICON_CLEFAIRY ; BLISSEY
db ICON_FOX ; RAIKOU
db ICON_FOX ; ENTEI
db ICON_FOX ; SUICUNE
db ICON_MONSTER ; LARVITAR
db ICON_MONSTER ; PUPITAR
db ICON_MONSTER ; TYRANITAR
db ICON_LUGIA ; LUGIA
db ICON_HO_OH ; HO_OH
db ICON_HUMANSHAPE ; CELEBI
db ICON_MONSTER ; TREECKO
db ICON_MONSTER ; GROVYLE
db ICON_MONSTER ; SCEPTILE
db ICON_BIRD ; TORCHIC
db ICON_MONSTER ; COMBUSKEN
db ICON_MONSTER ; BLAZIKEN
db ICON_SLOWPOKE ; MUDKIP
db ICON_SLOWPOKE ; MARSHTOMP
db ICON_MONSTER ; SWAMPERT
db ICON_FOX ; POOCHYENA
db ICON_FOX ; MIGHTYENA
db ICON_FOX ; ZIGZAGOON
db ICON_FOX ; LINOONE
db ICON_CATERPILLAR ; WURMPLE
db ICON_CATERPILLAR ; SILCOON
db ICON_MOTH ; BEAUTIFLY
db ICON_CATERPILLAR ; CASCOON
db ICON_MOTH ; DUSTOX
db ICON_SLOWPOKE ; LOTAD
db ICON_SLOWPOKE ; LOMBRE
db ICON_SLOWPOKE ; LUDICOLO
db ICON_ODDISH ; SEEDOT
db ICON_ODDISH ; NUZLEAF
db ICON_MONSTER ; SHIFTRY
db ICON_BIRD ; TAILLOW
db ICON_BIRD ; SWELLOW
db ICON_BIRD ; WINGULL
db ICON_BIRD ; PELIPPER
db ICON_HUMANSHAPE ; RALTS
db ICON_HUMANSHAPE ; KIRLIA
db ICON_HUMANSHAPE ; GARDEVOIR
db ICON_ODDISH ; SURSKIT
db ICON_MOTH ; MASQUERAIN
db ICON_ODDISH ; SHROOMISH
db ICON_MONSTER ; BRELOOM
db ICON_SLOWPOKE ; SLAKOTH
db ICON_FIGHTER ; VIGOROTH
db ICON_SNORLAX ; SLAKING
db ICON_BUG ; NINCADA
db ICON_BUG ; NINJASK
db ICON_BUG ; SHEDINJA
db ICON_CLEFAIRY ; WHISMUR
db ICON_MONSTER ; LOUDRED
db ICON_MONSTER ; EXPLOUD
db ICON_HUMANSHAPE ; MAKUHITA
db ICON_FIGHTER ; HARIYAMA
db ICON_JIGGLYPUFF ; AZURILL
db ICON_GEODUDE ; NOSEPASS
db ICON_FOX ; SKITTY
db ICON_FOX ; DELCATTY
db ICON_GHOST ; SABLEYE
db ICON_HUMANSHAPE ; MAWILE
db ICON_DIGLETT ; ARON
db ICON_MONSTER ; LAIRON
db ICON_MONSTER ; AGGRON
db ICON_HUMANSHAPE ; MEDITITE
db ICON_HUMANSHAPE ; MEDICHAM
db ICON_FOX ; ELECTRIKE
db ICON_FOX ; MANECTRIC
db ICON_CLEFAIRY ; PLUSLE
db ICON_CLEFAIRY ; MINUN
db ICON_HUMANSHAPE ; VOLBEAT
db ICON_HUMANSHAPE ; ILLUMISE
db ICON_ODDISH ; ROSELIA
db ICON_BLOB ; GULPIN
db ICON_BLOB ; SWALOT
db ICON_FISH ; CARVANHA
db ICON_FISH ; SHARPEDO
db ICON_LAPRAS ; WAILMER
db ICON_LAPRAS ; WAILORD
db ICON_EQUINE ; NUMEL
db ICON_EQUINE ; CAMERUPT
db ICON_EQUINE ; TORKOAL
db ICON_CLEFAIRY ; SPOINK
db ICON_CLEFAIRY ; GRUMPIG
db ICON_CLEFAIRY ; SPINDA
db ICON_DIGLETT ; TRAPINCH
db ICON_BUG ; VIBRAVA
db ICON_BIGMON ; FLYGON
db ICON_ODDISH ; CACNEA
db ICON_HUMANSHAPE ; CACTURNE
db ICON_BIRD ; SWABLU
db ICON_BIRD ; ALTARIA
db ICON_CLEFAIRY ; ZANGOOSE
db ICON_SERPENT ; SEVIPER
db ICON_STARYU ; LUNATONE
db ICON_STARYU ; SOLROCK
db ICON_FISH ; BARBOACH
db ICON_FISH ; WHISCASH
db ICON_SHELL ; CORPHISH
db ICON_SHELL ; CRAWDAUNT
db ICON_GEODUDE ; BALTOY
db ICON_GEODUDE ; CLAYDOL
db ICON_SUDOWOODO ; LILEEP
db ICON_SUDOWOODO ; CRADILY
db ICON_BUG ; ANORITH
db ICON_BUG ; ARMALDO
db ICON_FISH ; FEEBAS
db ICON_LAPRAS ; MILOTIC
db ICON_CLEFAIRY ; CASTFORM
db ICON_MONSTER ; KECLEON
db ICON_GHOST ; SHUPPET
db ICON_GHOST ; BANETTE
db ICON_GHOST ; DUSKULL
db ICON_GHOST ; DUSCLOPS
db ICON_MONSTER ; TROPIUS
db ICON_CLEFAIRY ; CHIMECHO
db ICON_FOX ; ABSOL
db ICON_CLEFAIRY ; WYNAUT
db ICON_HUMANSHAPE ; SNORUNT
db ICON_GEODUDE ; GLALIE
db ICON_CLEFAIRY ; SPHEAL
db ICON_MONSTER ; SEALEO
db ICON_MONSTER ; WALREIN
db ICON_SHELL ; CLAMPERL
db ICON_SERPENT ; HUNTAIL
db ICON_SERPENT ; GOREBYSS
db ICON_FISH ; RELICANTH
db ICON_FISH ; LUVDISC
db ICON_SERPENT ; BAGON
db ICON_GEODUDE ; SHELGON
db ICON_BIGMON ; SALAMENCE
db ICON_GEODUDE ; BELDUM
db ICON_GEODUDE ; METANG
db ICON_GEODUDE ; METAGROSS
db ICON_MONSTER ; REGIROCK
db ICON_MONSTER ; REGICE
db ICON_MONSTER ; REGISTEEL
db ICON_BIGMON ; LATIAS
db ICON_BIGMON ; LATIOS
db ICON_LAPRAS ; KYOGRE
db ICON_MONSTER ; GROUDON
db ICON_GYARADOS ; RAYQUAZA
db ICON_CLEFAIRY ; JIRACHI
db ICON_BUG ; DEOXYS
db ICON_ODDISH ; TURTWIG
db ICON_MONSTER ; GROTLE
db ICON_MONSTER ; TORTERRA
db ICON_HUMANSHAPE ; CHIMCHAR
db ICON_HUMANSHAPE ; MONFERNO
db ICON_HUMANSHAPE ; INFERNAPE
db ICON_CLEFAIRY ; PIPLUP
db ICON_CLEFAIRY ; PRINPLUP
db ICON_MONSTER ; EMPOLEON
db ICON_BIRD ; STARLY
db ICON_BIRD ; STARAVIA
db ICON_BIRD ; STARAPTOR
db ICON_FOX ; BIDOOF
db ICON_FOX ; BIBAREL
db ICON_CATERPILLAR ; KRICKETOT
db ICON_BUG ; KRICKETUNE
db ICON_FOX ; SHINX
db ICON_FOX ; LUXIO
db ICON_FOX ; LUXRAY
db ICON_ODDISH ; BUDEW
db ICON_ODDISH ; ROSERADE
db ICON_MONSTER ; CRANIDOS
db ICON_MONSTER ; RAMPARDOS
db ICON_MONSTER ; SHIELDON
db ICON_MONSTER ; BASTIODON
db ICON_ODDISH ; BURMY
db ICON_ODDISH ; WORMADAM
db ICON_MOTH ; MOTHIM
db ICON_BUG ; COMBEE
db ICON_BUG ; VESPIQUEN
db ICON_CLEFAIRY ; PACHIRISU
db ICON_FOX ; BUIZEL
db ICON_FOX ; FLOATZEL
db ICON_ODDISH ; CHERUBI
db ICON_ODDISH ; CHERRIM
db ICON_LAPRAS ; SHELLOS
db ICON_LAPRAS ; GASTRODON
db ICON_MONSTER ; AMBIPOM
db ICON_VOLTORB ; DRIFLOON
db ICON_VOLTORB ; DRIFBLIM
db ICON_CLEFAIRY ; BUNEARY
db ICON_CLEFAIRY ; LOPUNNY
db ICON_GHOST ; MISMAGIUS
db ICON_BIRD ; HONCHKROW
db ICON_FOX ; GLAMEOW
db ICON_FOX ; PURUGLY
db ICON_CLEFAIRY ; CHINGLING
db ICON_FOX ; STUNKY
db ICON_FOX ; SKUNTANK
db ICON_VOLTORB ; BRONZOR
db ICON_VOLTORB ; BRONZONG
db ICON_SUDOWOODO ; BONSLY
db ICON_HUMANSHAPE ; MIME_JR
db ICON_CLEFAIRY ; HAPPINY
db ICON_BIRD ; CHATOT
db ICON_GHOST ; SPIRITOMB
db ICON_MONSTER ; GIBLE
db ICON_MONSTER ; GABITE
db ICON_MONSTER ; GARCHOMP
db ICON_SNORLAX ; MUNCHLAX
db ICON_HUMANSHAPE ; RIOLU
db ICON_FIGHTER ; LUCARIO
db ICON_EQUINE ; HIPPOPOTAS
db ICON_EQUINE ; HIPPOWDON
db ICON_BUG ; SKORUPI
db ICON_BUG ; DRAPION
db ICON_HUMANSHAPE ; CROAGUNK
db ICON_FIGHTER ; TOXICROAK
db ICON_ODDISH ; CARNIVINE
db ICON_FISH ; FINNEON
db ICON_FISH ; LUMINEON
db ICON_FISH ; MANTYKE
db ICON_CLEFAIRY ; SNOVER
db ICON_MONSTER ; ABOMASNOW
db ICON_FOX ; WEAVILE
db ICON_VOLTORB ; MAGNEZONE
db ICON_MONSTER ; LICKILICKY
db ICON_MONSTER ; RHYPERIOR
db ICON_MONSTER ; TANGROWTH
db ICON_MONSTER ; ELECTIVIRE
db ICON_MONSTER ; MAGMORTAR
db ICON_BIRD ; TOGEKISS
db ICON_BUG ; YANMEGA
db ICON_FOX ; LEAFEON
db ICON_FOX ; GLACEON
db ICON_BAT ; GLISCOR
db ICON_EQUINE ; MAMOSWINE
db ICON_VOLTORB ; PORYGON_Z
db ICON_HUMANSHAPE ; GALLADE
db ICON_GEODUDE ; PROBOPASS
db ICON_GHOST ; DUSKNOIR
db ICON_HUMANSHAPE ; FROSLASS
db ICON_UNOWN ; ROTOM
db ICON_CLEFAIRY ; UXIE
db ICON_CLEFAIRY ; MESPRIT
db ICON_CLEFAIRY ; AZELF
db ICON_MONSTER ; DIALGA
db ICON_BIGMON ; PALKIA
db ICON_MONSTER ; HEATRAN
db ICON_MONSTER ; REGIGIGAS
db ICON_MONSTER ; GIRATINA
db ICON_LAPRAS ; CRESSELIA
db ICON_CLEFAIRY ; PHIONE
db ICON_CLEFAIRY ; MANAPHY
db ICON_GHOST ; DARKRAI
db ICON_CLEFAIRY ; SHAYMIN
db ICON_MONSTER ; ARCEUS
db ICON_FOX ; FLAMBEAR
db ICON_FOX ; VOLBEAR
db ICON_FOX ; DYNABEAR
db ICON_LAPRAS ; CRUIZE
db ICON_LAPRAS ; AQUALLO
db ICON_LAPRAS ; AQUARIUS
db ICON_FOX ; KOTORA
db ICON_FOX ; RAITORA
db ICON_LAPRAS ; BOMSHEAL
db ICON_FISH ; CORASUN
db ICON_FISH ; SUNMOLA
db ICON_FISH ; MAMBOKING
db ICON_SERPENT ; BITEEL
db ICON_SERPENT ; GROTESS
db ICON_FOX ; RINRING
db ICON_FOX ; BELLRUN
db ICON_JELLYFISH ; BLOTTLE
db ICON_JELLYFISH ; PENDRAKEN
db ICON_GHOST ; KURSTRAW
db ICON_GHOST ; PANGSHI
db ICON_MONSTER ; WOLFAN
db ICON_MONSTER ; WARWOLF
db ICON_BIRD ; CHEEP
db ICON_FIGHTER ; JABETTA
db ICON_JIGGLYPUFF ; SNOBIT
db ICON_JIGGLYPUFF ; BLIZBIT
db ICON_CLEFAIRY ; GLACIHARE
db ICON_SUDOWOODO ; STEMINEEL
db ICON_LAPRAS ; ARSKEED
db ICON_LAPRAS ; DRAKARVE
db ICON_EQUINE ; PETICORN
db ICON_FISH ; GUPGOLD
db ICON_FOX ; TRITALES
db ICON_BLOB ; GRIMBY
db ICON_BUG ; PARAMITE
db ICON_FOX ; NYANYA
db ICON_FOX ; PUDDIPUP
db ICON_BIRD ; CHIX
db ICON_BIRD ; KATU
db ICON_ODDISH ; TANGTRIP
db ICON_ODDISH ; TANGROWTH
db ICON_ODDISH ; BELMITT
db ICON_SHELL ; TURBAN
db ICON_BUG ; PRAXE
db ICON_FISH ; NUMBPUFF
db ICON_BLOB ; METTO
db ICON_BIRD ; MADAME
db ICON_MONSTER ; GUARDIA
db ICON_MONSTER ; OHMEGA
db ICON_PIKACHU ; PICHU_B
db ICON_BUG ; DEOXYS_A
db ICON_BUG ; DEOXYS_D
db ICON_BUG ; DEOXYS_S
db ICON_ODDISH ; BURMY_S
db ICON_ODDISH ; BURMY_T
db ICON_ODDISH ; WORMADAM_S
db ICON_ODDISH ; WORMADAM_T
db ICON_LAPRAS ; SHELLOS_E
db ICON_LAPRAS ; GASTRODON_E
db ICON_UNOWN ; ROTOM_FLY
db ICON_UNOWN ; ROTOM_FRE
db ICON_UNOWN ; ROTOM_GRS
db ICON_UNOWN ; ROTOM_ICE
db ICON_UNOWN ; ROTOM_WTR
db ICON_MONSTER ; GIRATINA_O
db ICON_CLEFAIRY ; SHAYMIN_S
db ICON_CLEFAIRY ; CASTFORM_RN
db ICON_CLEFAIRY ; CASTFORM_SN
db ICON_CLEFAIRY ; CASTFORM_SW
db ICON_ODDISH ; CHERRIM_S
POPS
|
; Small C+ Z88 Support Library
;
; Increment long on hl
; Kept little endian
;
; djm 26/2/2000
; aralbrec 01/2007
PUBLIC l_long_inc
.l_long_inc
inc (hl)
ret nz
inc hl
inc (hl)
ret nz
inc hl
inc (hl)
ret nz
inc hl
inc (hl)
ret
|
; A001794: Negated coefficients of Chebyshev T polynomials: [x^n](-T(n+6, x)), n >= 0.
; 1,7,32,120,400,1232,3584,9984,26880,70400,180224,452608,1118208,2723840,6553600,15597568,36765696,85917696,199229440,458752000,1049624576,2387607552,5402263552,12163481600,27262976000,60850962432,135291469824,299708186624,661693399040,1456262348800,3195455668224,6992206757888,15260018802688,33221572034560,72155450572800,156371169312768,338168545017856,729869562413056,1572301627719680,3380998255411200,7257876254949376
mov $1,$0
add $1,2
mov $2,$0
mov $4,$0
add $4,2
lpb $0
sub $0,1
mul $1,2
add $2,$4
add $2,3
add $5,1
lpe
mov $3,6
add $3,$5
add $3,$2
mul $3,2
mul $1,$3
sub $1,24
div $1,24
add $1,1
|
#include "TileRenderer.h"
#include <iostream>
namespace atlas {
TileRenderer::TileRenderer() {}
TileRenderer::~TileRenderer() {}
Image TileRenderer::renderTile(const Map *map, size_t x, size_t y, size_t zoom,
size_t width, size_t height) {
Image img(width, height);
#pragma omp parallel for
for (int64_t i = 0; i < int64_t(width * height); ++i) {
size_t px = i % width;
size_t py = i / width;
double pos_x = x * map->width(zoom) + double(px) / width * map->width(zoom);
double pos_y =
y * map->height(zoom) + double(py) / height * map->height(zoom);
float altitude = map->altitude(pos_x, pos_y);
Image::Pixel color;
if (altitude < map->seaLevel()) {
color.r = 0x1b;
color.g = 0x78;
color.b = 0xaf;
color.a = 255;
} else {
uint8_t c = (altitude - map->minAltitude()) /
(map->maxAltitude() - map->minAltitude()) * 255;
color.r = c;
color.g = c;
color.b = c;
color.a = 255;
}
img(px, py) = color;
}
img.save("/tmp/tile.png");
return img;
}
} // namespace atlas
|
m = $8000_0000
assert m == 1 << 31
assert m == -(1 << 31)
assert m == (-2)**31
println "{m}"
println "({12d:m})"
println "({-12d:m})"
|
//
// Copyright (c) 2022 Alan Freitas (alandefreitas@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/CPPAlliance/url
//
#include "test_suite.hpp"
//[snippet_headers_1
#include <boost/url.hpp>
//]
#include <iostream>
#include <cctype>
//[snippet_headers_3
#include <boost/url.hpp>
using namespace boost::urls;
//]
void
using_url_views()
{
//[snippet_parsing_1
string_view s = "https://user:pass@www.example.com:443/path/to/my%2dfile.txt?id=42&name=John%20Doe#page%20anchor";
//]
{
//[snippet_parsing_2
result<url_view> r = parse_uri( s );
//]
}
{
//[snippet_parsing_3
url_view u = parse_uri( s ).value();
//]
}
{
//[snippet_parsing_4
try
{
url_view u = parse_uri(s).value();
}
catch (std::invalid_argument const&)
{
// handle error
}
//]
}
{
//[snippet_parsing_5
result<url_view> r = parse_uri( s );
if (r.has_value())
{
url_view u = r.value();
}
else
{
// handle error
}
//]
}
url_view u = parse_uri( s ).value();
//[snippet_accessing_1
std::cout <<
"scheme : " << u.scheme() << "\n"
"authority : " << u.encoded_authority() << "\n"
"path : " << u.encoded_path() << "\n"
"query : " << u.encoded_query() << "\n"
"fragment : " << u.encoded_fragment() << "\n";
//]
{
//[snippet_accessing_2
url_view u1 = parse_uri( "http://www.example.com" ).value();
std::cout << "fragment 1 : " << u1.encoded_fragment() << "\n\n";
url_view u2 = parse_uri( "http://www.example.com/#" ).value();
std::cout << "fragment 2 : " << u2.encoded_fragment() << "\n\n";
//]
}
{
//[snippet_accessing_3
url_view u1 = parse_uri( "http://www.example.com" ).value();
std::cout << "has fragment 1 : " << u1.has_fragment() << "\n";
std::cout << "fragment 1 : " << u1.encoded_fragment() << "\n\n";
url_view u2 = parse_uri( "http://www.example.com/#" ).value();
std::cout << "has fragment 2 : " << u2.has_fragment() << "\n";
std::cout << "fragment 2 : " << u2.encoded_fragment() << "\n\n";
//]
}
//[snippet_decoding_1
std::cout <<
"query : " << u.query() << "\n"
"fragment : " << u.fragment() << "\n";
//]
{
//[snippet_allocators_1
static_pool< 1024 > sp;
std::cout <<
"query : " << u.query(sp.allocator()) << "\n"
"fragment : " << u.fragment(sp.allocator()) << "\n";
//]
}
{
//[snippet_compound_elements_1
segments_encoded_view segs = u.encoded_segments();
for( auto v : segs )
{
std::cout << v << "\n";
}
//]
}
{
//[snippet_encoded_compound_elements_1
segments_view segs = u.segments();
for( auto v : segs )
{
std::cout << v << "\n";
}
//]
}
{
//[snippet_encoded_compound_elements_2
static_pool< 1024 > pool;
segments_view segs = u.segments( pool.allocator() );
for( auto v : segs )
{
std::cout << v << "\n";
}
//]
}
{
//[snippet_encoded_compound_elements_3
params_encoded_view params = u.encoded_params();
for( auto v : params )
{
std::cout <<
"key = " << v.key <<
", value = " << v.value << "\n";
}
//]
}
{
//[snippet_encoded_compound_elements_4
static_pool< 1024 > pool;
params_view params = u.params( pool.allocator() );
for( auto v : params )
{
std::cout <<
"key = " << v.key <<
", value = " << v.value << "\n";
}
//]
}
}
void
using_urls()
{
string_view s = "https://user:pass@www.example.com:443/path/to/my%2dfile.txt?id=42&name=John%20Doe#page%20anchor";
//[snippet_modification_1
url u = parse_uri( s ).value();
//]
//[snippet_modification_2
u.set_scheme( "https" );
//]
//[snippet_modification_3
u.set_scheme( scheme::https ); // equivalent to u.set_scheme( "https" );
//]
//[snippet_modification_4
try
{
u.set_scheme( "100" ); // illegal, must start with a letter
}
catch( std::invalid_argument const& )
{
// handle error
}
//]
//[snippet_modification_5
u.set_host( parse_ipv4_address( "192.168.0.1" ).value() )
.set_port( 8080 )
.remove_userinfo();
//]
//[snippet_modification_6
params p = u.params();
p.emplace_at(p.find("name"), "name", "Vinnie Falco");
std::cout << u << "\n";
//]
}
void
parsing_urls()
{
//[snippet_parsing_url_1
result< url_view > r = parse_uri( "https://www.example.com/path/to/file.txt" );
if( r.has_value() ) // parsing was successful
{
url_view u = r.value(); // extract the url_view
std::cout << u; // format the URL to cout
}
else
{
std::cout << r.error().message(); // parsing failure; print error
}
//]
//[snippet_parsing_url_2
// This will hold our copy
std::shared_ptr<url_view const> sp;
{
std::string s = "/path/to/file.txt";
// result::value() will throw an exception if an error occurs
url_view u = parse_relative_ref( s ).value();
// create a copy with ownership and string lifetime extension
sp = u.collect();
// At this point the string goes out of scope
}
// but `*sp` remains valid since it has its own copy
std::cout << *sp << "\n";
//]
{
//[snippet_parsing_url_3
// This will hold our mutable copy
url v;
{
std::string s = "/path/to/file.txt";
// result::value() will throw an exception if an error occurs
v = parse_relative_ref(s).value();
// At this point the string goes out of scope
}
// but `v` remains valid since it has its own copy
std::cout << v << "\n";
// and it's mutable
v.set_encoded_fragment("anchor");
std::cout << v << "\n";
//]
}
}
void
parsing_scheme()
{
{
//[snippet_parsing_scheme_1
string_view s = "mailto:name@email.com";
url_view u = parse_uri( s ).value();
std::cout << u.scheme() << "\n";
//]
}
{
string_view s = "mailto:name@email.com";
//[snippet_parsing_scheme_2
url_view u = parse_uri( s ).value();
if (u.has_scheme())
{
std::cout << u.scheme() << "\n";
}
//]
}
{
//[snippet_parsing_scheme_3
string_view s = "file://host/path/to/file";
url_view u = parse_uri( s ).value();
if (u.scheme_id() == scheme::file)
{
// handle file
}
//]
}
}
void
parsing_authority()
{
{
//[snippet_parsing_authority_1
string_view s = "https:///path/to_resource";
url_view u = parse_uri( s ).value();
std::cout << u << "\n"
"scheme: " << u.scheme() << "\n"
"has authority: " << u.has_authority() << "\n"
"authority: " << u.encoded_authority() << "\n"
"path: " << u.encoded_path() << "\n";
//]
}
{
//[snippet_parsing_authority_2
string_view s = "https://www.boost.org";
url_view u = parse_uri( s ).value();
std::cout << "scheme: " << u.scheme() << "\n"
"has authority: " << u.has_authority() << "\n"
"authority: " << u.encoded_authority() << "\n"
"path: " << u.encoded_path() << "\n";
//]
}
{
//[snippet_parsing_authority_3
string_view s = "https://www.boost.org/users/download/";
url_view u = parse_uri( s ).value();
std::cout << u << "\n"
"scheme: " << u.scheme() << "\n"
"has authority: " << u.has_authority() << "\n"
"authority: " << u.encoded_authority() << "\n"
"path: " << u.encoded_path() << "\n";
//]
}
{
//[snippet_parsing_authority_4
string_view s = "https://www.boost.org/";
url_view u = parse_uri( s ).value();
std::cout << "scheme: " << u.scheme() << "\n"
"has authority: " << u.has_authority() << "\n"
"authority: " << u.encoded_authority() << "\n"
"path: " << u.encoded_path() << "\n";
//]
}
{
//[snippet_parsing_authority_5
string_view s = "mailto:John.Doe@example.com";
url_view u = parse_uri( s ).value();
std::cout << "scheme: " << u.scheme() << "\n"
"has authority: " << u.has_authority() << "\n"
"authority: " << u.encoded_authority() << "\n"
"path: " << u.encoded_path() << "\n";
//]
}
{
//[snippet_parsing_authority_6
string_view s = "mailto://John.Doe@example.com";
url_view u = parse_uri( s ).value();
std::cout << u << "\n"
"scheme: " << u.scheme() << "\n"
"has authority: " << u.has_authority() << "\n"
"authority: " << u.encoded_authority() << "\n"
"path: " << u.encoded_path() << "\n";
//]
}
{
//[snippet_parsing_authority_7
string_view s = "https://john.doe@www.example.com:123/forum/questions/";
url_view u = parse_uri( s ).value();
std::cout << "scheme: " << u.scheme() << "\n"
"has authority: " << u.has_authority() << "\n"
"authority: " << u.encoded_authority() << "\n"
"host: " << u.encoded_host() << "\n"
"userinfo: " << u.encoded_userinfo() << "\n"
"port: " << u.port() << "\n"
"path: " << u.encoded_path() << "\n";
//]
}
{
//[snippet_parsing_authority_8
string_view s = "https://john.doe@www.example.com:123/forum/questions/";
url_view u = parse_uri( s ).value();
std::cout << u << "\n"
"encoded host: " << u.encoded_host() << "\n"
"host: " << u.host() << "\n"
"host and port: " << u.encoded_host_and_port() << "\n"
"port: " << u.port() << "\n"
"port number: " << u.port_number() << "\n";
//]
}
{
//[snippet_parsing_authority_9
string_view s = "https://john.doe@192.168.2.1:123/forum/questions/";
url_view u = parse_uri( s ).value();
std::cout << u << "\n"
"encoded host: " << u.encoded_host() << "\n"
"host: " << u.host() << "\n"
"host and port: " << u.encoded_host_and_port() << "\n"
"port: " << u.port() << "\n"
"port number: " << u.port_number() << "\n";
//]
}
{
//[snippet_parsing_authority_10
string_view s = "https://www.boost.org/users/download/";
url_view u = parse_uri( s ).value();
switch (u.host_type())
{
case host_type::name:
// resolve name
case host_type::ipv4:
case host_type::ipv6:
case host_type::ipvfuture:
// connect to ip
break;
case host_type::none:
// handle empty host URL
break;
}
//]
}
{
//[snippet_parsing_authority_11
string_view s = "https://john.doe:123456@www.somehost.com/forum/questions/";
url_view u = parse_uri( s ).value();
std::cout << u << "\n\n"
// userinfo
"has_userinfo: " << u.has_userinfo() << "\n"
"encoded_userinfo: " << u.encoded_userinfo() << "\n"
"userinfo: " << u.userinfo() << "\n\n"
// user
"encoded_user: " << u.encoded_user() << "\n"
"user: " << u.user() << "\n\n"
// password
"has_password: " << u.has_password() << "\n"
"encoded_password: " << u.encoded_password() << "\n"
"password: " << u.password() << "\n";
//]
}
{
//[snippet_parsing_authority_12
string_view s = "www.example.com:80";
authority_view a = parse_authority( s ).value();
std::cout << a << "\n\n"
// host and port
"encoded_host_and_port: " << a.encoded_host_and_port() << "\n"
"encoded_host: " << a.encoded_host() << "\n"
"host: " << a.host() << "\n"
"port: " << a.port() << "\n"
"port number: " << a.port_number() << "\n\n"
// userinfo
"has_userinfo: " << a.has_userinfo() << "\n"
"encoded_userinfo: " << a.encoded_userinfo() << "\n"
"userinfo: " << a.userinfo() << "\n\n"
// user
"encoded_user: " << a.encoded_user() << "\n"
"user: " << a.user() << "\n\n"
// password
"has_password: " << a.has_password() << "\n"
"encoded_password: " << a.encoded_password() << "\n"
"password: " << a.password() << "\n";
//]
}
{
//[snippet_parsing_authority_13
string_view s = "user:pass@www.example.com:443";
authority_view a = parse_authority( s ).value();
std::cout << a << "\n\n"
// host and port
"encoded_host_and_port: " << a.encoded_host_and_port() << "\n"
"encoded_host: " << a.encoded_host() << "\n"
"host: " << a.host() << "\n"
"port: " << a.port() << "\n"
"port number: " << a.port_number() << "\n\n"
// userinfo
"has_userinfo: " << a.has_userinfo() << "\n"
"encoded_userinfo: " << a.encoded_userinfo() << "\n"
"userinfo: " << a.userinfo() << "\n\n"
// user
"encoded_user: " << a.encoded_user() << "\n"
"user: " << a.user() << "\n\n"
// password
"has_password: " << a.has_password() << "\n"
"encoded_password: " << a.encoded_password() << "\n"
"password: " << a.password() << "\n";
//]
}
}
void
parsing_path()
{
{
//[snippet_parsing_path_1
string_view s = "https://www.boost.org/doc/libs/";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
<< "path: " << u.encoded_path() << "\n"
<< "encoded segments: " << u.encoded_segments() << "\n"
<< "segments: " << u.segments() << "\n";
//]
//[snippet_parsing_path_1_b
std::cout << u.encoded_segments().size() << " segments\n";
for (auto seg: u.encoded_segments())
{
std::cout << "segment: " << seg << "\n";
}
//]
}
{
//[snippet_parsing_path_2
string_view s = "https://www.boost.org/doc/libs";
url_view u = parse_uri(s).value();
std::cout << u.encoded_segments().size() << " segments\n";
for (auto seg: u.encoded_segments())
{
std::cout << "segment: " << seg << "\n";
}
//]
}
{
//[snippet_parsing_path_3
string_view s = "https://www.boost.org";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
<< "path: " << u.encoded_path() << "\n"
<< "encoded segments: " << u.encoded_segments() << "\n"
<< "segments: " << u.segments() << "\n";
//]
}
{
//[snippet_parsing_path_4
string_view s = "https://www.boost.org//doc///libs";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"path: " << u.encoded_path() << "\n"
"encoded segments: " << u.encoded_segments() << "\n"
"segments: " << u.segments() << "\n";
std::cout << u.encoded_segments().size() << " segments\n";
for (auto seg: u.encoded_segments())
{
std::cout << "segment: " << seg << "\n";
}
//]
}
{
{
//[snippet_parsing_path_5_a
string_view s = "https://www.boost.org";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
<< "path: " << u.encoded_host() << "\n"
<< "path: " << u.encoded_path() << "\n"
<< "segments: " << u.encoded_segments().size() << "\n";
//]
}
{
//[snippet_parsing_path_5_b
string_view s = "https://www.boost.org/";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
<< "host: " << u.encoded_host() << "\n"
<< "path: " << u.encoded_path() << "\n"
<< "segments: " << u.encoded_segments().size() << "\n";
//]
}
{
//[snippet_parsing_path_5_c
string_view s = "https://www.boost.org//";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
<< "host: " << u.encoded_host() << "\n"
<< "path: " << u.encoded_path() << "\n"
<< "segments: " << u.encoded_segments().size() << "\n";
//]
}
}
{
//[snippet_parsing_path_6
string_view s = "https://www.boost.org//doc/libs/";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"authority: " << u.encoded_authority() << "\n"
"path: " << u.encoded_path() << "\n";
std::cout << u.encoded_segments().size() << " segments\n";
for (auto seg: u.encoded_segments())
{
std::cout << "segment: " << seg << "\n";
}
//]
}
{
//[snippet_parsing_path_7
string_view s = "https://doc/libs/";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"authority: " << u.encoded_authority() << "\n"
"path: " << u.encoded_path() << "\n";
std::cout << u.encoded_segments().size() << " segments\n";
for (auto seg: u.encoded_segments())
{
std::cout << "segment: " << seg << "\n";
}
//]
}
{
//[snippet_parsing_path_8
string_view s = "https://www.boost.org/doc@folder/libs:boost";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"authority: " << u.encoded_authority() << "\n"
"path: " << u.encoded_path() << "\n";
std::cout << u.encoded_segments().size() << " segments\n";
for (auto seg: u.encoded_segments())
{
std::cout << "segment: " << seg << "\n";
}
//]
}
{
//[snippet_parsing_path_9
string_view s = "/doc/libs";
segments_encoded_view p = parse_path(s).value();
std::cout << "path: " << p << "\n";
std::cout << p.size() << " segments\n";
for (auto seg: p)
{
std::cout << "segment: " << seg << "\n";
}
//]
}
}
void
parsing_query()
{
{
//[snippet_parsing_query_1
string_view s = "https://www.example.com/get-customer.php?id=409&name=Joe&individual";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"has query: " << u.has_query() << "\n"
"encoded query: " << u.encoded_query() << "\n"
"query: " << u.query() << "\n";
std::cout << u.encoded_params().size() << " parameters\n";
for (auto p: u.encoded_params())
{
if (p.has_value)
{
std::cout <<
"parameter: <" << p.key <<
", " << p.value << ">\n";
} else {
std::cout << "parameter: " << p.key << "\n";
}
}
//]
}
{
//[snippet_parsing_query_2
string_view s = "https://www.example.com/get-customer.php?key-1=value-1&key-2=&key-3&&=value-2";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"has query: " << u.has_query() << "\n"
"encoded query: " << u.encoded_query() << "\n"
"query: " << u.query() << "\n";
std::cout << u.encoded_params().size() << " parameters\n";
for (auto p: u.encoded_params())
{
if (p.has_value)
{
std::cout <<
"parameter: <" << p.key <<
", " << p.value << ">\n";
} else {
std::cout << "parameter: " << p.key << "\n";
}
}
//]
}
{
//[snippet_parsing_query_3
string_view s = "https://www.example.com/get-customer.php?email=joe@email.com&code=a:2@/!";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"has query: " << u.has_query() << "\n"
"encoded query: " << u.encoded_query() << "\n"
"query: " << u.query() << "\n";
std::cout << u.encoded_params().size() << " parameters\n";
for (auto p: u.encoded_params())
{
if (p.has_value)
{
std::cout <<
"parameter: <" << p.key <<
", " << p.value << ">\n";
} else {
std::cout << "parameter: " << p.key << "\n";
}
}
//]
}
{
//[snippet_parsing_query_4
string_view s = "https://www.example.com/get-customer.php?name=joe";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"encoded query: " << u.encoded_query() << "\n";
//]
}
{
//[snippet_parsing_query_5
string_view s = "https://www.example.com/get-customer.php";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"has query: " << u.has_query() << "\n"
"encoded query: " << u.encoded_query() << "\n";
//]
}
{
//[snippet_parsing_query_6
string_view s = "https://www.example.com/get-customer.php?name=John%20Doe";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"has query: " << u.has_query() << "\n"
"encoded query: " << u.encoded_query() << "\n"
"query: " << u.query() << "\n";
//]
}
{
//[snippet_parsing_query_7
string_view s = "https://www.example.com/get-customer.php?name=John%26Doe";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"has query: " << u.has_query() << "\n"
"encoded query: " << u.encoded_query() << "\n"
"query: " << u.query() << "\n";
//]
}
}
void
parsing_fragment()
{
{
//[snippet_parsing_fragment_1
string_view s = "https://www.example.com/index.html#section%202";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"has fragment: " << u.has_fragment() << "\n"
"encoded fragment: " << u.encoded_fragment() << "\n"
"fragment: " << u.fragment() << "\n";
//]
}
{
//[snippet_parsing_fragment_2_a
string_view s = "https://www.example.com/index.html#";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"has fragment: " << u.has_fragment() << "\n"
"encoded fragment: " << u.encoded_fragment() << "\n"
"fragment: " << u.fragment() << "\n";
//]
}
{
//[snippet_parsing_fragment_2_b
string_view s = "https://www.example.com/index.html";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"has fragment: " << u.has_fragment() << "\n"
"encoded fragment: " << u.encoded_fragment() << "\n"
"fragment: " << u.fragment() << "\n";
//]
}
{
//[snippet_parsing_fragment_3
string_view s = "https://www.example.com/index.html#code%20:a@b?c/d";
url_view u = parse_uri(s).value();
std::cout << u << "\n"
"has fragment: " << u.has_fragment() << "\n"
"encoded fragment: " << u.encoded_fragment() << "\n"
"fragment: " << u.fragment() << "\n";
//]
}
}
void
using_modifying()
{
{
//[snippet_modifying_1
string_view s = "https://www.example.com";
url_view u = parse_uri(s).value();
url v(u);
//]
//[snippet_modifying_2
std::cout << v << "\n"
"scheme: " << v.scheme() << "\n"
"has authority: " << v.has_authority() << "\n"
"authority: " << v.encoded_authority() << "\n"
"path: " << v.encoded_path() << "\n";
//]
//[snippet_modifying_3
v.set_scheme("http");
std::cout << v << "\n";
//]
//[snippet_modifying_4
try
{
v.set_scheme("http");
}
catch( std::exception const& )
{
// handle error
}
//]
//[snippet_modifying_5
v.set_host("www.my example.com");
std::cout << v << "\n";
//]
}
}
void
grammar_parse()
{
{
//[snippet_parse_1
string_view s = "http:after_scheme";
scheme_rule r;
const char* it = s.begin();
error_code ec;
if (grammar::parse(it, s.end(), ec, r))
{
std::cout << "scheme: " << r.scheme << '\n';
std::cout << "suffix: " << it << '\n';
}
//]
}
{
//[snippet_parse_2
string_view s = "?key=value#anchor";
query_part_rule r1;
fragment_part_rule r2;
const char* it = s.begin();
error_code ec;
if (grammar::parse(it, s.end(), ec, r1))
{
if (grammar::parse(it, s.end(), ec, r2))
{
std::cout << "query: " << r1.query_part << '\n';
std::cout << "fragment: " << r2.fragment.str << '\n';
}
}
//]
}
{
//[snippet_parse_3
string_view s = "?key=value#anchor";
query_part_rule r1;
fragment_part_rule r2;
const char* it = s.begin();
error_code ec;
if (grammar::parse(it, s.end(), ec, r1, r2))
{
std::cout << "query: " << r1.query_part << '\n';
std::cout << "fragment: " << r2.fragment.str << '\n';
}
//]
}
{
//[snippet_parse_4
string_view s = "http://www.boost.org";
uri_rule r;
error_code ec;
if (grammar::parse_string(s, ec, r))
{
std::cout << "scheme: " << r.scheme_part.scheme << '\n';
std::cout << "host: " << r.hier_part.authority.host.host_part << '\n';
}
//]
}
}
//[snippet_customization_1
struct lowercase_rule
{
string_view str;
friend
void
tag_invoke(
grammar::parse_tag const&,
char const*& it,
char const* const end,
error_code& ec,
lowercase_rule& t) noexcept
{
ec = {};
char const* begin = it;
while (it != end && std::islower(*it))
{
++it;
}
t.str = string_view(begin, it);
}
};
//]
void
grammar_customization()
{
{
//[snippet_customization_2
string_view s = "http:somelowercase";
scheme_rule r1;
lowercase_rule r2;
error_code ec;
if (grammar::parse_string(s, ec, r1, ':', r2))
{
std::cout << "scheme: " << r1.scheme << '\n';
std::cout << "lower: " << r2.str << '\n';
}
//]
}
}
//[snippet_charset_1
struct digit_chars_t
{
constexpr
bool
operator()( char c ) const noexcept
{
return c >= '0' && c <= '9';
}
};
//]
//[snippet_charset_4
struct CharSet
{
bool operator()( char c ) const noexcept;
char const* find_if ( char const* first, char const* last ) const noexcept;
char const* find_if_not ( char const* first, char const* last ) const noexcept;
};
//]
void
grammar_charset()
{
{
//[snippet_charset_2
query_chars_t cs;
assert(cs('a'));
assert(cs('='));
assert(!cs('#'));
//]
}
{
//[snippet_charset_3
string_view s = "key=the%20value";
pct_encoded_rule<query_chars_t> r;
error_code ec;
if (grammar::parse_string(s, ec, r))
{
std::cout << "query: " << r.s.str << '\n';
std::cout << "decoded size: " << r.s.decoded_size << '\n';
}
//]
}
}
void
modifying_path()
{
{
//[snippet_modifying_path_1
url_view u = parse_uri("https://www.boost.org").value();
//]
BOOST_TEST_NOT(u.is_path_absolute());
BOOST_TEST_EQ(u.encoded_segments().size(), 0u);
}
{
//[snippet_modifying_path_2
url_view u = parse_uri("https://www.boost.org/").value();
//]
BOOST_TEST(u.is_path_absolute());
BOOST_TEST_EQ(u.encoded_segments().size(), 0u);
}
{
//[snippet_modifying_path_3
url u = parse_uri("https://www.boost.org/./a/../b").value();
u.normalize();
//]
BOOST_TEST(u.is_path_absolute());
BOOST_TEST_EQ(u.string(), "https://www.boost.org/b");
BOOST_TEST_EQ(u.encoded_segments().size(), 1u);
}
{
//[snippet_modifying_path_4
// scheme and a relative path
url_view u = parse_uri("https:path/to/file.txt").value();
//]
BOOST_TEST_EQ(u.scheme(), "https");
BOOST_TEST_NOT(u.has_authority());
BOOST_TEST_NOT(u.is_path_absolute());
BOOST_TEST_EQ(u.encoded_segments().size(), 3u);
}
{
//[snippet_modifying_path_5
// scheme and an absolute path
url_view u = parse_uri("https:/path/to/file.txt").value();
//]
BOOST_TEST_EQ(u.scheme(), "https");
BOOST_TEST_NOT(u.has_authority());
BOOST_TEST(u.is_path_absolute());
BOOST_TEST_EQ(u.encoded_segments().size(), 3u);
}
{
//[snippet_modifying_path_6
// "//path" will be considered the authority component
url_view u = parse_uri("https://path/to/file.txt").value();
//]
BOOST_TEST_EQ(u.scheme(), "https");
BOOST_TEST(u.has_authority());
BOOST_TEST(u.is_path_absolute());
BOOST_TEST_EQ(u.encoded_segments().size(), 2u);
}
{
//[snippet_modifying_path_7
// only a relative path
url_view u = parse_uri_reference("path-to/file.txt").value();
//]
BOOST_TEST_NOT(u.has_scheme());
BOOST_TEST_NOT(u.has_authority());
BOOST_TEST_NOT(u.is_path_absolute());
BOOST_TEST_EQ(u.encoded_segments().size(), 2u);
}
{
//[snippet_modifying_path_8
// "path:" will be considered the scheme component
// instead of a substring of the first segment
url_view u = parse_uri_reference("path:to/file.txt").value();
//]
BOOST_TEST(u.has_scheme());
BOOST_TEST_NOT(u.has_authority());
BOOST_TEST_NOT(u.is_path_absolute());
BOOST_TEST_EQ(u.encoded_segments().size(), 2u);
}
{
//[snippet_modifying_path_9
// "path" should not become the authority component
url u = parse_uri("https:path/to/file.txt").value();
u.set_encoded_path("//path/to/file.txt");
//]
BOOST_TEST_EQ(u.scheme(), "https");
BOOST_TEST_NOT(u.has_authority());
BOOST_TEST(u.is_path_absolute());
BOOST_TEST_EQ(u.encoded_segments().size(), 4u);
}
{
//[snippet_modifying_path_10
// "path:to" should not make the scheme become "path:"
url u = parse_uri_reference("path-to/file.txt").value();
u.set_encoded_path("path:to/file.txt");
//]
BOOST_TEST_NOT(u.has_scheme());
BOOST_TEST_NOT(u.has_authority());
BOOST_TEST_NOT(u.is_path_absolute());
BOOST_TEST_EQ(u.encoded_segments().size(), 2u);
}
{
//[snippet_modifying_path_11
// should not insert as "pathto/file.txt"
url u = parse_uri_reference("to/file.txt").value();
segments segs = u.segments();
segs.insert(segs.begin(), "path");
//]
BOOST_TEST_NOT(u.has_scheme());
BOOST_TEST_NOT(u.has_authority());
BOOST_TEST_NOT(u.is_path_absolute());
BOOST_TEST_EQ(u.encoded_segments().size(), 3u);
}
}
namespace boost {
namespace urls {
class snippets_test
{
public:
void
run()
{
using_url_views();
using_urls();
parsing_urls();
parsing_scheme();
parsing_authority();
parsing_path();
parsing_query();
parsing_fragment();
grammar_parse();
grammar_customization();
grammar_charset();
modifying_path();
BOOST_TEST_PASS();
}
};
TEST_SUITE(snippets_test, "boost.url.snippets");
} // urls
} // boost
|
#importonce
.const screen = $0400
.const screen_0 = $0400
.const screen_1 = $0500
.const screen_2 = $0600
.const screen_3 = $0700
.label vic2_screen_control_register1 = $d011
.label vic2_screen_control_register2 = $d016
.label vic2_rasterline_register = $d012
.label vic2_interrupt_control_register = $d01a
.label vic2_interrupt_status_register = $d019
.macro stabilize_irq() {
start:
:mov16 #irq2 : $fffe
inc vic2_rasterline_register
asl vic2_interrupt_status_register
tsx
cli
:cycles(18)
irq2:
txs
:cycles(44)
test:
lda vic2_rasterline_register
cmp vic2_rasterline_register
beq next_instruction
next_instruction:
}
.macro set_raster(line_number) {
// Notice that only the 8 least significant bits are stored in the accumulator.
lda #line_number
sta vic2_rasterline_register
lda vic2_screen_control_register1
.if (line_number > 255) {
ora #%10000000
} else {
and #%01111111
}
sta vic2_screen_control_register1
}
.pseudocommand mov16 source : destination {
:_mov bits_to_bytes(16) : source : destination
}
.pseudocommand mov source : destination {
:_mov bits_to_bytes(8) : source : destination
}
.pseudocommand _mov bytes_count : source : destination {
.for (var i = 0; i < bytes_count.getValue(); i++) {
lda extract_byte_argument(source, i)
sta extract_byte_argument(destination, i)
}
}
.pseudocommand _add bytes_count : left : right : result {
clc
.for (var i = 0; i < bytes_count.getValue(); i++) {
lda extract_byte_argument(left, i)
adc extract_byte_argument(right, i)
sta extract_byte_argument(result, i)
}
}
.function extract_byte_argument(arg, byte_id) {
.if (arg.getType()==AT_IMMEDIATE) {
.return CmdArgument(arg.getType(), extract_byte(arg.getValue(), byte_id))
} else {
.return CmdArgument(arg.getType(), arg.getValue() + byte_id)
}
}
.function extract_byte(value, byte_id) {
.var bits = _bytes_to_bits(byte_id)
.eval value = value >> bits
.return value & $ff
}
.function _bytes_to_bits(bytes) {
.return bytes * 8
}
.function bits_to_bytes(bits) {
.return bits / 8
}
.macro clear_screen(char_code) {
ldx #0
lda #char_code
clear_next_char:
sta screen_0,x
sta screen_1,x
sta screen_2,x
sta screen_3,x
inx
bne clear_next_char
}
.macro nops(count) {
.for (var i = 0; i < count; i++) {
nop
}
}
.macro cycles(count) {
.if (count < 0) {
.error "The cycle count cannot be less than 0 (" + count + " given)."
}
.if (count == 1) {
.error "Can't wait only one cycle."
}
.if (mod(count, 2) != 0) {
bit $ea
.eval count -= 3
}
:nops(count/2)
}
|
_rm: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
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: bf 01 00 00 00 mov $0x1,%edi
16: 83 ec 08 sub $0x8,%esp
19: 8b 31 mov (%ecx),%esi
1b: 8b 59 04 mov 0x4(%ecx),%ebx
1e: 83 c3 04 add $0x4,%ebx
int i;
if(argc < 2){
21: 83 fe 01 cmp $0x1,%esi
24: 7e 3e jle 64 <main+0x64>
26: 8d 76 00 lea 0x0(%esi),%esi
29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
printf(2, "Usage: rm files...\n");
exit();
}
for(i = 1; i < argc; i++){
if(unlink(argv[i]) < 0){
30: 83 ec 0c sub $0xc,%esp
33: ff 33 pushl (%ebx)
35: e8 e8 02 00 00 call 322 <unlink>
3a: 83 c4 10 add $0x10,%esp
3d: 85 c0 test %eax,%eax
3f: 78 0f js 50 <main+0x50>
for(i = 1; i < argc; i++){
41: 83 c7 01 add $0x1,%edi
44: 83 c3 04 add $0x4,%ebx
47: 39 fe cmp %edi,%esi
49: 75 e5 jne 30 <main+0x30>
printf(2, "rm: %s failed to delete\n", argv[i]);
break;
}
}
exit();
4b: e8 82 02 00 00 call 2d2 <exit>
printf(2, "rm: %s failed to delete\n", argv[i]);
50: 50 push %eax
51: ff 33 pushl (%ebx)
53: 68 9c 07 00 00 push $0x79c
58: 6a 02 push $0x2
5a: e8 d1 03 00 00 call 430 <printf>
break;
5f: 83 c4 10 add $0x10,%esp
62: eb e7 jmp 4b <main+0x4b>
printf(2, "Usage: rm files...\n");
64: 52 push %edx
65: 52 push %edx
66: 68 88 07 00 00 push $0x788
6b: 6a 02 push $0x2
6d: e8 be 03 00 00 call 430 <printf>
exit();
72: e8 5b 02 00 00 call 2d2 <exit>
77: 66 90 xchg %ax,%ax
79: 66 90 xchg %ax,%ax
7b: 66 90 xchg %ax,%ax
7d: 66 90 xchg %ax,%ax
7f: 90 nop
00000080 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
80: 55 push %ebp
81: 89 e5 mov %esp,%ebp
83: 53 push %ebx
84: 8b 45 08 mov 0x8(%ebp),%eax
87: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
8a: 89 c2 mov %eax,%edx
8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
90: 83 c1 01 add $0x1,%ecx
93: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
97: 83 c2 01 add $0x1,%edx
9a: 84 db test %bl,%bl
9c: 88 5a ff mov %bl,-0x1(%edx)
9f: 75 ef jne 90 <strcpy+0x10>
;
return os;
}
a1: 5b pop %ebx
a2: 5d pop %ebp
a3: c3 ret
a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000000b0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
b0: 55 push %ebp
b1: 89 e5 mov %esp,%ebp
b3: 53 push %ebx
b4: 8b 55 08 mov 0x8(%ebp),%edx
b7: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
ba: 0f b6 02 movzbl (%edx),%eax
bd: 0f b6 19 movzbl (%ecx),%ebx
c0: 84 c0 test %al,%al
c2: 75 1c jne e0 <strcmp+0x30>
c4: eb 2a jmp f0 <strcmp+0x40>
c6: 8d 76 00 lea 0x0(%esi),%esi
c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
d0: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
d3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
d6: 83 c1 01 add $0x1,%ecx
d9: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
dc: 84 c0 test %al,%al
de: 74 10 je f0 <strcmp+0x40>
e0: 38 d8 cmp %bl,%al
e2: 74 ec je d0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
e4: 29 d8 sub %ebx,%eax
}
e6: 5b pop %ebx
e7: 5d pop %ebp
e8: c3 ret
e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
f0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
f2: 29 d8 sub %ebx,%eax
}
f4: 5b pop %ebx
f5: 5d pop %ebp
f6: c3 ret
f7: 89 f6 mov %esi,%esi
f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000100 <strlen>:
uint
strlen(char *s)
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
106: 80 39 00 cmpb $0x0,(%ecx)
109: 74 15 je 120 <strlen+0x20>
10b: 31 d2 xor %edx,%edx
10d: 8d 76 00 lea 0x0(%esi),%esi
110: 83 c2 01 add $0x1,%edx
113: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
117: 89 d0 mov %edx,%eax
119: 75 f5 jne 110 <strlen+0x10>
;
return n;
}
11b: 5d pop %ebp
11c: c3 ret
11d: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
120: 31 c0 xor %eax,%eax
}
122: 5d pop %ebp
123: c3 ret
124: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
12a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000130 <memset>:
void*
memset(void *dst, int c, uint n)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 57 push %edi
134: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
137: 8b 4d 10 mov 0x10(%ebp),%ecx
13a: 8b 45 0c mov 0xc(%ebp),%eax
13d: 89 d7 mov %edx,%edi
13f: fc cld
140: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
142: 89 d0 mov %edx,%eax
144: 5f pop %edi
145: 5d pop %ebp
146: c3 ret
147: 89 f6 mov %esi,%esi
149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000150 <strchr>:
char*
strchr(const char *s, char c)
{
150: 55 push %ebp
151: 89 e5 mov %esp,%ebp
153: 53 push %ebx
154: 8b 45 08 mov 0x8(%ebp),%eax
157: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
15a: 0f b6 10 movzbl (%eax),%edx
15d: 84 d2 test %dl,%dl
15f: 74 1d je 17e <strchr+0x2e>
if(*s == c)
161: 38 d3 cmp %dl,%bl
163: 89 d9 mov %ebx,%ecx
165: 75 0d jne 174 <strchr+0x24>
167: eb 17 jmp 180 <strchr+0x30>
169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
170: 38 ca cmp %cl,%dl
172: 74 0c je 180 <strchr+0x30>
for(; *s; s++)
174: 83 c0 01 add $0x1,%eax
177: 0f b6 10 movzbl (%eax),%edx
17a: 84 d2 test %dl,%dl
17c: 75 f2 jne 170 <strchr+0x20>
return (char*)s;
return 0;
17e: 31 c0 xor %eax,%eax
}
180: 5b pop %ebx
181: 5d pop %ebp
182: c3 ret
183: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000190 <gets>:
char*
gets(char *buf, int max)
{
190: 55 push %ebp
191: 89 e5 mov %esp,%ebp
193: 57 push %edi
194: 56 push %esi
195: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
196: 31 f6 xor %esi,%esi
198: 89 f3 mov %esi,%ebx
{
19a: 83 ec 1c sub $0x1c,%esp
19d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
1a0: eb 2f jmp 1d1 <gets+0x41>
1a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
1a8: 8d 45 e7 lea -0x19(%ebp),%eax
1ab: 83 ec 04 sub $0x4,%esp
1ae: 6a 01 push $0x1
1b0: 50 push %eax
1b1: 6a 00 push $0x0
1b3: e8 32 01 00 00 call 2ea <read>
if(cc < 1)
1b8: 83 c4 10 add $0x10,%esp
1bb: 85 c0 test %eax,%eax
1bd: 7e 1c jle 1db <gets+0x4b>
break;
buf[i++] = c;
1bf: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1c3: 83 c7 01 add $0x1,%edi
1c6: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
1c9: 3c 0a cmp $0xa,%al
1cb: 74 23 je 1f0 <gets+0x60>
1cd: 3c 0d cmp $0xd,%al
1cf: 74 1f je 1f0 <gets+0x60>
for(i=0; i+1 < max; ){
1d1: 83 c3 01 add $0x1,%ebx
1d4: 3b 5d 0c cmp 0xc(%ebp),%ebx
1d7: 89 fe mov %edi,%esi
1d9: 7c cd jl 1a8 <gets+0x18>
1db: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
1dd: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
1e0: c6 03 00 movb $0x0,(%ebx)
}
1e3: 8d 65 f4 lea -0xc(%ebp),%esp
1e6: 5b pop %ebx
1e7: 5e pop %esi
1e8: 5f pop %edi
1e9: 5d pop %ebp
1ea: c3 ret
1eb: 90 nop
1ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1f0: 8b 75 08 mov 0x8(%ebp),%esi
1f3: 8b 45 08 mov 0x8(%ebp),%eax
1f6: 01 de add %ebx,%esi
1f8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
1fa: c6 03 00 movb $0x0,(%ebx)
}
1fd: 8d 65 f4 lea -0xc(%ebp),%esp
200: 5b pop %ebx
201: 5e pop %esi
202: 5f pop %edi
203: 5d pop %ebp
204: c3 ret
205: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000210 <stat>:
int
stat(char *n, struct stat *st)
{
210: 55 push %ebp
211: 89 e5 mov %esp,%ebp
213: 56 push %esi
214: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
215: 83 ec 08 sub $0x8,%esp
218: 6a 00 push $0x0
21a: ff 75 08 pushl 0x8(%ebp)
21d: e8 f0 00 00 00 call 312 <open>
if(fd < 0)
222: 83 c4 10 add $0x10,%esp
225: 85 c0 test %eax,%eax
227: 78 27 js 250 <stat+0x40>
return -1;
r = fstat(fd, st);
229: 83 ec 08 sub $0x8,%esp
22c: ff 75 0c pushl 0xc(%ebp)
22f: 89 c3 mov %eax,%ebx
231: 50 push %eax
232: e8 f3 00 00 00 call 32a <fstat>
close(fd);
237: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
23a: 89 c6 mov %eax,%esi
close(fd);
23c: e8 b9 00 00 00 call 2fa <close>
return r;
241: 83 c4 10 add $0x10,%esp
}
244: 8d 65 f8 lea -0x8(%ebp),%esp
247: 89 f0 mov %esi,%eax
249: 5b pop %ebx
24a: 5e pop %esi
24b: 5d pop %ebp
24c: c3 ret
24d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
250: be ff ff ff ff mov $0xffffffff,%esi
255: eb ed jmp 244 <stat+0x34>
257: 89 f6 mov %esi,%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000260 <atoi>:
int
atoi(const char *s)
{
260: 55 push %ebp
261: 89 e5 mov %esp,%ebp
263: 53 push %ebx
264: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
267: 0f be 11 movsbl (%ecx),%edx
26a: 8d 42 d0 lea -0x30(%edx),%eax
26d: 3c 09 cmp $0x9,%al
n = 0;
26f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
274: 77 1f ja 295 <atoi+0x35>
276: 8d 76 00 lea 0x0(%esi),%esi
279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
280: 8d 04 80 lea (%eax,%eax,4),%eax
283: 83 c1 01 add $0x1,%ecx
286: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
28a: 0f be 11 movsbl (%ecx),%edx
28d: 8d 5a d0 lea -0x30(%edx),%ebx
290: 80 fb 09 cmp $0x9,%bl
293: 76 eb jbe 280 <atoi+0x20>
return n;
}
295: 5b pop %ebx
296: 5d pop %ebp
297: c3 ret
298: 90 nop
299: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000002a0 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
2a0: 55 push %ebp
2a1: 89 e5 mov %esp,%ebp
2a3: 56 push %esi
2a4: 53 push %ebx
2a5: 8b 5d 10 mov 0x10(%ebp),%ebx
2a8: 8b 45 08 mov 0x8(%ebp),%eax
2ab: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2ae: 85 db test %ebx,%ebx
2b0: 7e 14 jle 2c6 <memmove+0x26>
2b2: 31 d2 xor %edx,%edx
2b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
2b8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
2bc: 88 0c 10 mov %cl,(%eax,%edx,1)
2bf: 83 c2 01 add $0x1,%edx
while(n-- > 0)
2c2: 39 d3 cmp %edx,%ebx
2c4: 75 f2 jne 2b8 <memmove+0x18>
return vdst;
}
2c6: 5b pop %ebx
2c7: 5e pop %esi
2c8: 5d pop %ebp
2c9: c3 ret
000002ca <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2ca: b8 01 00 00 00 mov $0x1,%eax
2cf: cd 40 int $0x40
2d1: c3 ret
000002d2 <exit>:
SYSCALL(exit)
2d2: b8 02 00 00 00 mov $0x2,%eax
2d7: cd 40 int $0x40
2d9: c3 ret
000002da <wait>:
SYSCALL(wait)
2da: b8 03 00 00 00 mov $0x3,%eax
2df: cd 40 int $0x40
2e1: c3 ret
000002e2 <pipe>:
SYSCALL(pipe)
2e2: b8 04 00 00 00 mov $0x4,%eax
2e7: cd 40 int $0x40
2e9: c3 ret
000002ea <read>:
SYSCALL(read)
2ea: b8 05 00 00 00 mov $0x5,%eax
2ef: cd 40 int $0x40
2f1: c3 ret
000002f2 <write>:
SYSCALL(write)
2f2: b8 10 00 00 00 mov $0x10,%eax
2f7: cd 40 int $0x40
2f9: c3 ret
000002fa <close>:
SYSCALL(close)
2fa: b8 15 00 00 00 mov $0x15,%eax
2ff: cd 40 int $0x40
301: c3 ret
00000302 <kill>:
SYSCALL(kill)
302: b8 06 00 00 00 mov $0x6,%eax
307: cd 40 int $0x40
309: c3 ret
0000030a <exec>:
SYSCALL(exec)
30a: b8 07 00 00 00 mov $0x7,%eax
30f: cd 40 int $0x40
311: c3 ret
00000312 <open>:
SYSCALL(open)
312: b8 0f 00 00 00 mov $0xf,%eax
317: cd 40 int $0x40
319: c3 ret
0000031a <mknod>:
SYSCALL(mknod)
31a: b8 11 00 00 00 mov $0x11,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <unlink>:
SYSCALL(unlink)
322: b8 12 00 00 00 mov $0x12,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <fstat>:
SYSCALL(fstat)
32a: b8 08 00 00 00 mov $0x8,%eax
32f: cd 40 int $0x40
331: c3 ret
00000332 <link>:
SYSCALL(link)
332: b8 13 00 00 00 mov $0x13,%eax
337: cd 40 int $0x40
339: c3 ret
0000033a <mkdir>:
SYSCALL(mkdir)
33a: b8 14 00 00 00 mov $0x14,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <chdir>:
SYSCALL(chdir)
342: b8 09 00 00 00 mov $0x9,%eax
347: cd 40 int $0x40
349: c3 ret
0000034a <dup>:
SYSCALL(dup)
34a: b8 0a 00 00 00 mov $0xa,%eax
34f: cd 40 int $0x40
351: c3 ret
00000352 <getpid>:
SYSCALL(getpid)
352: b8 0b 00 00 00 mov $0xb,%eax
357: cd 40 int $0x40
359: c3 ret
0000035a <sbrk>:
SYSCALL(sbrk)
35a: b8 0c 00 00 00 mov $0xc,%eax
35f: cd 40 int $0x40
361: c3 ret
00000362 <sleep>:
SYSCALL(sleep)
362: b8 0d 00 00 00 mov $0xd,%eax
367: cd 40 int $0x40
369: c3 ret
0000036a <uptime>:
SYSCALL(uptime)
36a: b8 0e 00 00 00 mov $0xe,%eax
36f: cd 40 int $0x40
371: c3 ret
00000372 <date>:
SYSCALL(date)
372: b8 16 00 00 00 mov $0x16,%eax
377: cd 40 int $0x40
379: c3 ret
0000037a <getcwd>:
SYSCALL(getcwd)
37a: b8 17 00 00 00 mov $0x17,%eax
37f: cd 40 int $0x40
381: c3 ret
00000382 <halt>:
SYSCALL(halt)
382: b8 18 00 00 00 mov $0x18,%eax
387: cd 40 int $0x40
389: c3 ret
38a: 66 90 xchg %ax,%ax
38c: 66 90 xchg %ax,%ax
38e: 66 90 xchg %ax,%ax
00000390 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
390: 55 push %ebp
391: 89 e5 mov %esp,%ebp
393: 57 push %edi
394: 56 push %esi
395: 53 push %ebx
396: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
399: 85 d2 test %edx,%edx
{
39b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
39e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
3a0: 79 76 jns 418 <printint+0x88>
3a2: f6 45 08 01 testb $0x1,0x8(%ebp)
3a6: 74 70 je 418 <printint+0x88>
x = -xx;
3a8: f7 d8 neg %eax
neg = 1;
3aa: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
3b1: 31 f6 xor %esi,%esi
3b3: 8d 5d d7 lea -0x29(%ebp),%ebx
3b6: eb 0a jmp 3c2 <printint+0x32>
3b8: 90 nop
3b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
3c0: 89 fe mov %edi,%esi
3c2: 31 d2 xor %edx,%edx
3c4: 8d 7e 01 lea 0x1(%esi),%edi
3c7: f7 f1 div %ecx
3c9: 0f b6 92 bc 07 00 00 movzbl 0x7bc(%edx),%edx
}while((x /= base) != 0);
3d0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
3d2: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
3d5: 75 e9 jne 3c0 <printint+0x30>
if(neg)
3d7: 8b 45 c4 mov -0x3c(%ebp),%eax
3da: 85 c0 test %eax,%eax
3dc: 74 08 je 3e6 <printint+0x56>
buf[i++] = '-';
3de: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
3e3: 8d 7e 02 lea 0x2(%esi),%edi
3e6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
3ea: 8b 7d c0 mov -0x40(%ebp),%edi
3ed: 8d 76 00 lea 0x0(%esi),%esi
3f0: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
3f3: 83 ec 04 sub $0x4,%esp
3f6: 83 ee 01 sub $0x1,%esi
3f9: 6a 01 push $0x1
3fb: 53 push %ebx
3fc: 57 push %edi
3fd: 88 45 d7 mov %al,-0x29(%ebp)
400: e8 ed fe ff ff call 2f2 <write>
while(--i >= 0)
405: 83 c4 10 add $0x10,%esp
408: 39 de cmp %ebx,%esi
40a: 75 e4 jne 3f0 <printint+0x60>
putc(fd, buf[i]);
}
40c: 8d 65 f4 lea -0xc(%ebp),%esp
40f: 5b pop %ebx
410: 5e pop %esi
411: 5f pop %edi
412: 5d pop %ebp
413: c3 ret
414: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
418: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
41f: eb 90 jmp 3b1 <printint+0x21>
421: eb 0d jmp 430 <printf>
423: 90 nop
424: 90 nop
425: 90 nop
426: 90 nop
427: 90 nop
428: 90 nop
429: 90 nop
42a: 90 nop
42b: 90 nop
42c: 90 nop
42d: 90 nop
42e: 90 nop
42f: 90 nop
00000430 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
430: 55 push %ebp
431: 89 e5 mov %esp,%ebp
433: 57 push %edi
434: 56 push %esi
435: 53 push %ebx
436: 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++){
439: 8b 75 0c mov 0xc(%ebp),%esi
43c: 0f b6 1e movzbl (%esi),%ebx
43f: 84 db test %bl,%bl
441: 0f 84 b3 00 00 00 je 4fa <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
447: 8d 45 10 lea 0x10(%ebp),%eax
44a: 83 c6 01 add $0x1,%esi
state = 0;
44d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
44f: 89 45 d4 mov %eax,-0x2c(%ebp)
452: eb 2f jmp 483 <printf+0x53>
454: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
458: 83 f8 25 cmp $0x25,%eax
45b: 0f 84 a7 00 00 00 je 508 <printf+0xd8>
write(fd, &c, 1);
461: 8d 45 e2 lea -0x1e(%ebp),%eax
464: 83 ec 04 sub $0x4,%esp
467: 88 5d e2 mov %bl,-0x1e(%ebp)
46a: 6a 01 push $0x1
46c: 50 push %eax
46d: ff 75 08 pushl 0x8(%ebp)
470: e8 7d fe ff ff call 2f2 <write>
475: 83 c4 10 add $0x10,%esp
478: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
47b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
47f: 84 db test %bl,%bl
481: 74 77 je 4fa <printf+0xca>
if(state == 0){
483: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
485: 0f be cb movsbl %bl,%ecx
488: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
48b: 74 cb je 458 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
48d: 83 ff 25 cmp $0x25,%edi
490: 75 e6 jne 478 <printf+0x48>
if(c == 'd'){
492: 83 f8 64 cmp $0x64,%eax
495: 0f 84 05 01 00 00 je 5a0 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
49b: 81 e1 f7 00 00 00 and $0xf7,%ecx
4a1: 83 f9 70 cmp $0x70,%ecx
4a4: 74 72 je 518 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
4a6: 83 f8 73 cmp $0x73,%eax
4a9: 0f 84 99 00 00 00 je 548 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
4af: 83 f8 63 cmp $0x63,%eax
4b2: 0f 84 08 01 00 00 je 5c0 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
4b8: 83 f8 25 cmp $0x25,%eax
4bb: 0f 84 ef 00 00 00 je 5b0 <printf+0x180>
write(fd, &c, 1);
4c1: 8d 45 e7 lea -0x19(%ebp),%eax
4c4: 83 ec 04 sub $0x4,%esp
4c7: c6 45 e7 25 movb $0x25,-0x19(%ebp)
4cb: 6a 01 push $0x1
4cd: 50 push %eax
4ce: ff 75 08 pushl 0x8(%ebp)
4d1: e8 1c fe ff ff call 2f2 <write>
4d6: 83 c4 0c add $0xc,%esp
4d9: 8d 45 e6 lea -0x1a(%ebp),%eax
4dc: 88 5d e6 mov %bl,-0x1a(%ebp)
4df: 6a 01 push $0x1
4e1: 50 push %eax
4e2: ff 75 08 pushl 0x8(%ebp)
4e5: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4e8: 31 ff xor %edi,%edi
write(fd, &c, 1);
4ea: e8 03 fe ff ff call 2f2 <write>
for(i = 0; fmt[i]; i++){
4ef: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
4f3: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
4f6: 84 db test %bl,%bl
4f8: 75 89 jne 483 <printf+0x53>
}
}
}
4fa: 8d 65 f4 lea -0xc(%ebp),%esp
4fd: 5b pop %ebx
4fe: 5e pop %esi
4ff: 5f pop %edi
500: 5d pop %ebp
501: c3 ret
502: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
508: bf 25 00 00 00 mov $0x25,%edi
50d: e9 66 ff ff ff jmp 478 <printf+0x48>
512: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
518: 83 ec 0c sub $0xc,%esp
51b: b9 10 00 00 00 mov $0x10,%ecx
520: 6a 00 push $0x0
522: 8b 7d d4 mov -0x2c(%ebp),%edi
525: 8b 45 08 mov 0x8(%ebp),%eax
528: 8b 17 mov (%edi),%edx
52a: e8 61 fe ff ff call 390 <printint>
ap++;
52f: 89 f8 mov %edi,%eax
531: 83 c4 10 add $0x10,%esp
state = 0;
534: 31 ff xor %edi,%edi
ap++;
536: 83 c0 04 add $0x4,%eax
539: 89 45 d4 mov %eax,-0x2c(%ebp)
53c: e9 37 ff ff ff jmp 478 <printf+0x48>
541: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
548: 8b 45 d4 mov -0x2c(%ebp),%eax
54b: 8b 08 mov (%eax),%ecx
ap++;
54d: 83 c0 04 add $0x4,%eax
550: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
553: 85 c9 test %ecx,%ecx
555: 0f 84 8e 00 00 00 je 5e9 <printf+0x1b9>
while(*s != 0){
55b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
55e: 31 ff xor %edi,%edi
s = (char*)*ap;
560: 89 cb mov %ecx,%ebx
while(*s != 0){
562: 84 c0 test %al,%al
564: 0f 84 0e ff ff ff je 478 <printf+0x48>
56a: 89 75 d0 mov %esi,-0x30(%ebp)
56d: 89 de mov %ebx,%esi
56f: 8b 5d 08 mov 0x8(%ebp),%ebx
572: 8d 7d e3 lea -0x1d(%ebp),%edi
575: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
578: 83 ec 04 sub $0x4,%esp
s++;
57b: 83 c6 01 add $0x1,%esi
57e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
581: 6a 01 push $0x1
583: 57 push %edi
584: 53 push %ebx
585: e8 68 fd ff ff call 2f2 <write>
while(*s != 0){
58a: 0f b6 06 movzbl (%esi),%eax
58d: 83 c4 10 add $0x10,%esp
590: 84 c0 test %al,%al
592: 75 e4 jne 578 <printf+0x148>
594: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
597: 31 ff xor %edi,%edi
599: e9 da fe ff ff jmp 478 <printf+0x48>
59e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
5a0: 83 ec 0c sub $0xc,%esp
5a3: b9 0a 00 00 00 mov $0xa,%ecx
5a8: 6a 01 push $0x1
5aa: e9 73 ff ff ff jmp 522 <printf+0xf2>
5af: 90 nop
write(fd, &c, 1);
5b0: 83 ec 04 sub $0x4,%esp
5b3: 88 5d e5 mov %bl,-0x1b(%ebp)
5b6: 8d 45 e5 lea -0x1b(%ebp),%eax
5b9: 6a 01 push $0x1
5bb: e9 21 ff ff ff jmp 4e1 <printf+0xb1>
putc(fd, *ap);
5c0: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
5c3: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
5c6: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
5c8: 6a 01 push $0x1
ap++;
5ca: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
5cd: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
5d0: 8d 45 e4 lea -0x1c(%ebp),%eax
5d3: 50 push %eax
5d4: ff 75 08 pushl 0x8(%ebp)
5d7: e8 16 fd ff ff call 2f2 <write>
ap++;
5dc: 89 7d d4 mov %edi,-0x2c(%ebp)
5df: 83 c4 10 add $0x10,%esp
state = 0;
5e2: 31 ff xor %edi,%edi
5e4: e9 8f fe ff ff jmp 478 <printf+0x48>
s = "(null)";
5e9: bb b5 07 00 00 mov $0x7b5,%ebx
while(*s != 0){
5ee: b8 28 00 00 00 mov $0x28,%eax
5f3: e9 72 ff ff ff jmp 56a <printf+0x13a>
5f8: 66 90 xchg %ax,%ax
5fa: 66 90 xchg %ax,%ax
5fc: 66 90 xchg %ax,%ax
5fe: 66 90 xchg %ax,%ax
00000600 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
600: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
601: a1 6c 0a 00 00 mov 0xa6c,%eax
{
606: 89 e5 mov %esp,%ebp
608: 57 push %edi
609: 56 push %esi
60a: 53 push %ebx
60b: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
60e: 8d 4b f8 lea -0x8(%ebx),%ecx
611: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
618: 39 c8 cmp %ecx,%eax
61a: 8b 10 mov (%eax),%edx
61c: 73 32 jae 650 <free+0x50>
61e: 39 d1 cmp %edx,%ecx
620: 72 04 jb 626 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
622: 39 d0 cmp %edx,%eax
624: 72 32 jb 658 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
626: 8b 73 fc mov -0x4(%ebx),%esi
629: 8d 3c f1 lea (%ecx,%esi,8),%edi
62c: 39 fa cmp %edi,%edx
62e: 74 30 je 660 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
630: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
633: 8b 50 04 mov 0x4(%eax),%edx
636: 8d 34 d0 lea (%eax,%edx,8),%esi
639: 39 f1 cmp %esi,%ecx
63b: 74 3a je 677 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
63d: 89 08 mov %ecx,(%eax)
freep = p;
63f: a3 6c 0a 00 00 mov %eax,0xa6c
}
644: 5b pop %ebx
645: 5e pop %esi
646: 5f pop %edi
647: 5d pop %ebp
648: c3 ret
649: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
650: 39 d0 cmp %edx,%eax
652: 72 04 jb 658 <free+0x58>
654: 39 d1 cmp %edx,%ecx
656: 72 ce jb 626 <free+0x26>
{
658: 89 d0 mov %edx,%eax
65a: eb bc jmp 618 <free+0x18>
65c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
660: 03 72 04 add 0x4(%edx),%esi
663: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
666: 8b 10 mov (%eax),%edx
668: 8b 12 mov (%edx),%edx
66a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
66d: 8b 50 04 mov 0x4(%eax),%edx
670: 8d 34 d0 lea (%eax,%edx,8),%esi
673: 39 f1 cmp %esi,%ecx
675: 75 c6 jne 63d <free+0x3d>
p->s.size += bp->s.size;
677: 03 53 fc add -0x4(%ebx),%edx
freep = p;
67a: a3 6c 0a 00 00 mov %eax,0xa6c
p->s.size += bp->s.size;
67f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
682: 8b 53 f8 mov -0x8(%ebx),%edx
685: 89 10 mov %edx,(%eax)
}
687: 5b pop %ebx
688: 5e pop %esi
689: 5f pop %edi
68a: 5d pop %ebp
68b: c3 ret
68c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000690 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
690: 55 push %ebp
691: 89 e5 mov %esp,%ebp
693: 57 push %edi
694: 56 push %esi
695: 53 push %ebx
696: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
699: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
69c: 8b 15 6c 0a 00 00 mov 0xa6c,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6a2: 8d 78 07 lea 0x7(%eax),%edi
6a5: c1 ef 03 shr $0x3,%edi
6a8: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
6ab: 85 d2 test %edx,%edx
6ad: 0f 84 9d 00 00 00 je 750 <malloc+0xc0>
6b3: 8b 02 mov (%edx),%eax
6b5: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
6b8: 39 cf cmp %ecx,%edi
6ba: 76 6c jbe 728 <malloc+0x98>
6bc: 81 ff 00 10 00 00 cmp $0x1000,%edi
6c2: bb 00 10 00 00 mov $0x1000,%ebx
6c7: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
6ca: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
6d1: eb 0e jmp 6e1 <malloc+0x51>
6d3: 90 nop
6d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
6d8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
6da: 8b 48 04 mov 0x4(%eax),%ecx
6dd: 39 f9 cmp %edi,%ecx
6df: 73 47 jae 728 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
6e1: 39 05 6c 0a 00 00 cmp %eax,0xa6c
6e7: 89 c2 mov %eax,%edx
6e9: 75 ed jne 6d8 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
6eb: 83 ec 0c sub $0xc,%esp
6ee: 56 push %esi
6ef: e8 66 fc ff ff call 35a <sbrk>
if(p == (char*)-1)
6f4: 83 c4 10 add $0x10,%esp
6f7: 83 f8 ff cmp $0xffffffff,%eax
6fa: 74 1c je 718 <malloc+0x88>
hp->s.size = nu;
6fc: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
6ff: 83 ec 0c sub $0xc,%esp
702: 83 c0 08 add $0x8,%eax
705: 50 push %eax
706: e8 f5 fe ff ff call 600 <free>
return freep;
70b: 8b 15 6c 0a 00 00 mov 0xa6c,%edx
if((p = morecore(nunits)) == 0)
711: 83 c4 10 add $0x10,%esp
714: 85 d2 test %edx,%edx
716: 75 c0 jne 6d8 <malloc+0x48>
return 0;
}
}
718: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
71b: 31 c0 xor %eax,%eax
}
71d: 5b pop %ebx
71e: 5e pop %esi
71f: 5f pop %edi
720: 5d pop %ebp
721: c3 ret
722: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
728: 39 cf cmp %ecx,%edi
72a: 74 54 je 780 <malloc+0xf0>
p->s.size -= nunits;
72c: 29 f9 sub %edi,%ecx
72e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
731: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
734: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
737: 89 15 6c 0a 00 00 mov %edx,0xa6c
}
73d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
740: 83 c0 08 add $0x8,%eax
}
743: 5b pop %ebx
744: 5e pop %esi
745: 5f pop %edi
746: 5d pop %ebp
747: c3 ret
748: 90 nop
749: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
750: c7 05 6c 0a 00 00 70 movl $0xa70,0xa6c
757: 0a 00 00
75a: c7 05 70 0a 00 00 70 movl $0xa70,0xa70
761: 0a 00 00
base.s.size = 0;
764: b8 70 0a 00 00 mov $0xa70,%eax
769: c7 05 74 0a 00 00 00 movl $0x0,0xa74
770: 00 00 00
773: e9 44 ff ff ff jmp 6bc <malloc+0x2c>
778: 90 nop
779: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
780: 8b 08 mov (%eax),%ecx
782: 89 0a mov %ecx,(%edx)
784: eb b1 jmp 737 <malloc+0xa7>
|
; A158841: Triangle read by rows, matrix product of A145677 * A004736.
; Submitted by Christian Krause
; 1,3,1,7,4,2,13,9,6,3,21,16,12,8,4,31,25,20,15,10,5,43,36,30,24,18,12,6,57,49,42,35,28,21,14,7,73,64,56,48,40,32,24,16,8,91,81,72,63,54,45,36,27,18,9
lpb $0
add $2,1
sub $0,$2
lpe
mov $1,$2
sub $2,$0
add $2,1
mul $1,$2
mov $2,0
bin $2,$0
add $1,$2
mov $0,$1
|
// Copyright (c) 2011-2015 The Bitcoin Core developers
// Copyright (c) 2014-2021 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <qt/bitcoingui.h>
#include <qt/bitcoinunits.h>
#include <qt/clientmodel.h>
#include <qt/codesafe.h>
#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/modaloverlay.h>
#include <qt/networkstyle.h>
#include <qt/notificator.h>
#include <qt/openuridialog.h>
#include <qt/optionsdialog.h>
#include <qt/optionsmodel.h>
#include <qt/rpcconsole.h>
#include <qt/utilitydialog.h>
#ifdef ENABLE_WALLET
#include <qt/walletframe.h>
#include <qt/walletmodel.h>
#include <qt/walletview.h>
#endif // ENABLE_WALLET
#ifdef Q_OS_MAC
#include <qt/macdockiconhandler.h>
#endif
#include <chainparams.h>
#include <init.h>
#include <interfaces/handler.h>
#include <interfaces/node.h>
#include <miner.h>
#include <ui_interface.h>
#include <util.h>
#include <qt/masternodelist.h>
#include <validation.h>
#include <iostream>
#include <QAction>
#include <QApplication>
#include <QButtonGroup>
#include <QComboBox>
#include <QDateTime>
#include <QDesktopWidget>
#include <QDragEnterEvent>
#include <QListWidget>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QProgressDialog>
#include <QSettings>
#include <QShortcut>
#include <QStackedWidget>
#include <QStatusBar>
#include <QStyle>
#include <QTimer>
#include <QToolBar>
#include <QToolButton>
#include <QUrlQuery>
#include <QVBoxLayout>
const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
#if defined(Q_OS_MAC)
"macosx"
#elif defined(Q_OS_WIN)
"windows"
#else
"other"
#endif
;
BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle, QWidget* parent) :
QMainWindow(parent),
enableWallet(false),
m_node(node),
clientModel(0),
walletFrame(0),
unitDisplayControl(0),
labelWalletEncryptionIcon(0),
labelWalletHDStatusIcon(0),
labelConnectionsIcon(0),
labelBlocksIcon(0),
progressBarLabel(0),
progressBar(0),
progressDialog(0),
appMenuBar(0),
appToolBar(0),
appToolBarLogoAction(0),
overviewButton(0),
historyButton(0),
masternodeButton(0),
governanceButton(0),
quitAction(0),
sendCoinsButton(0),
coinJoinCoinsButton(0),
sendCoinsMenuAction(0),
coinJoinCoinsMenuAction(0),
usedSendingAddressesAction(0),
usedReceivingAddressesAction(0),
signMessageAction(0),
verifyMessageAction(0),
aboutAction(0),
receiveCoinsButton(0),
receiveCoinsMenuAction(0),
optionsAction(0),
toggleHideAction(0),
encryptWalletAction(0),
toggleStakingAction(0),
backupWalletAction(0),
changePassphraseAction(0),
aboutQtAction(0),
openRPCConsoleAction(0),
openAction(0),
showHelpMessageAction(0),
showCoinJoinHelpAction(0),
trayIcon(0),
trayIconMenu(0),
dockIconMenu(0),
notificator(0),
rpcConsole(0),
helpMessageDialog(0),
modalOverlay(0),
tabGroup(0),
timerConnecting(0),
timerSpinner(0)
{
GUIUtil::loadTheme(true);
QSettings settings;
if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
// Restore failed (perhaps missing setting), center the window
move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
}
QString windowTitle = tr(PACKAGE_NAME) + " - ";
#ifdef ENABLE_WALLET
enableWallet = WalletModel::isWalletEnabled();
#endif // ENABLE_WALLET
if(enableWallet)
{
windowTitle += tr("Wallet");
} else {
windowTitle += tr("Node");
}
QString userWindowTitle = QString::fromStdString(gArgs.GetArg("-windowtitle", ""));
if(!userWindowTitle.isEmpty()) windowTitle += " - " + userWindowTitle;
windowTitle += " " + networkStyle->getTitleAddText();
QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
setWindowIcon(networkStyle->getTrayAndWindowIcon());
setWindowTitle(windowTitle);
rpcConsole = new RPCConsole(node, this, enableWallet ? Qt::Window : Qt::Widget);
helpMessageDialog = new HelpMessageDialog(node, this, HelpMessageDialog::cmdline);
#ifdef ENABLE_WALLET
if(enableWallet)
{
/** Create wallet frame*/
walletFrame = new WalletFrame(this);
} else
#endif // ENABLE_WALLET
{
/* When compiled without wallet or -disablewallet is provided,
* the central widget is the rpc console.
*/
setCentralWidget(rpcConsole);
}
// Accept D&D of URIs
setAcceptDrops(true);
// Create actions for the toolbar, menu bar and tray/dock icon
// Needs walletFrame to be initialized
createActions();
// Create application menu bar
createMenuBar();
// Create the toolbars
createToolBars();
// Create system tray icon and notification
createTrayIcon(networkStyle);
// Create status bar
statusBar();
// Launch caller
caller();
// Disable size grip because it looks ugly and nobody needs it
statusBar()->setSizeGripEnabled(false);
// Status bar notification icons
QFrame *frameBlocks = new QFrame();
frameBlocks->setContentsMargins(0,0,0,0);
frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
frameBlocksLayout->setContentsMargins(3,0,3,0);
frameBlocksLayout->setSpacing(3);
unitDisplayControl = new UnitDisplayStatusBarControl();
labelStakingIcon = new QLabel();
labelWalletEncryptionIcon = new QLabel();
labelWalletHDStatusIcon = new QLabel();
labelConnectionsIcon = new GUIUtil::ClickableLabel();
labelBlocksIcon = new GUIUtil::ClickableLabel();
if(enableWallet)
{
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(unitDisplayControl);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
}
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelConnectionsIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelBlocksIcon);
frameBlocksLayout->addWidget(labelStakingIcon);
frameBlocksLayout->addStretch();
// Hide the spinner/synced icon by default to avoid
// that the spinner starts before we have any connections
labelBlocksIcon->hide();
// Progress bar and label for blocks download
progressBarLabel = new QLabel();
progressBarLabel->setVisible(true);
progressBarLabel->setObjectName("lblStatusBarProgress");
progressBar = new GUIUtil::ProgressBar();
progressBar->setAlignment(Qt::AlignCenter);
progressBar->setVisible(true);
// Override style sheet for progress bar for styles that have a segmented progress bar,
// as they make the text unreadable (workaround for issue #1071)
// See https://doc.qt.io/qt-5/gallery.html
QString curStyle = QApplication::style()->metaObject()->className();
if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
{
progressBar->setStyleSheet("QProgressBar { background-color: #F8F8F8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #00CCFF, stop: 1 #33CCFF); border-radius: 7px; margin: 0px; }");
}
statusBar()->addWidget(progressBarLabel);
statusBar()->addWidget(progressBar);
statusBar()->addPermanentWidget(frameBlocks);
// Install event filter to be able to catch status tip events (QEvent::StatusTip)
this->installEventFilter(this);
// Initially wallet actions should be disabled
setWalletActionsEnabled(false);
// Subscribe to notifications from core
subscribeToCoreSignals();
// Jump to peers tab by clicking on connections icon
connect(labelConnectionsIcon, SIGNAL(clicked(QPoint)), this, SLOT(showPeers()));
modalOverlay = new ModalOverlay(this->centralWidget());
#ifdef ENABLE_WALLET
if(enableWallet) {
connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, SLOT(showModalOverlay()));
connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
connect(progressBar, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
}
#endif
#ifdef Q_OS_MAC
m_app_nap_inhibitor = new CAppNapInhibitor;
#endif
QTimer* timerStakingIcon = new QTimer(labelStakingIcon);
connect(timerStakingIcon, SIGNAL(timeout()), this, SLOT(setStakingStatus()));
timerStakingIcon->start(10000);
setStakingStatus();
incomingTransactionsTimer = new QTimer(this);
incomingTransactionsTimer->setSingleShot(true);
connect(incomingTransactionsTimer, SIGNAL(timeout()), SLOT(showIncomingTransactions()));
bool fDebugCustomStyleSheets = gArgs.GetBoolArg("-debug-ui", false) && GUIUtil::isStyleSheetDirectoryCustom();
if (fDebugCustomStyleSheets) {
timerCustomCss = new QTimer(this);
QObject::connect(timerCustomCss, &QTimer::timeout, [=]() {
if (!m_node.shutdownRequested()) {
GUIUtil::loadStyleSheet();
}
});
timerCustomCss->start(200);
}
}
BitcoinGUI::~BitcoinGUI()
{
// Unsubscribe from notifications from core
unsubscribeFromCoreSignals();
QSettings settings;
settings.setValue("MainWindowGeometry", saveGeometry());
if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
trayIcon->hide();
#ifdef Q_OS_MAC
delete m_app_nap_inhibitor;
delete appMenuBar;
MacDockIconHandler::cleanup();
#endif
delete rpcConsole;
delete tabGroup;
}
void BitcoinGUI::startSpinner()
{
if (labelBlocksIcon == nullptr || labelBlocksIcon->isHidden() || timerSpinner != nullptr) {
return;
}
auto getNextFrame = []() {
static std::vector<std::unique_ptr<QPixmap>> vecFrames;
static std::vector<std::unique_ptr<QPixmap>>::iterator itFrame;
while (vecFrames.size() < SPINNER_FRAMES) {
QString&& strFrame = QString("spinner-%1").arg(vecFrames.size(), 3, 10, QChar('0'));
QPixmap&& frame = getIcon(strFrame, GUIUtil::ThemedColor::ORANGE, MOVIES_PATH).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
itFrame = vecFrames.insert(vecFrames.end(), std::make_unique<QPixmap>(frame));
}
assert(vecFrames.size() == SPINNER_FRAMES);
if (itFrame == vecFrames.end()) {
itFrame = vecFrames.begin();
}
return *itFrame++->get();
};
timerSpinner = new QTimer(this);
QObject::connect(timerSpinner, &QTimer::timeout, [=]() {
if (timerSpinner == nullptr) {
return;
}
labelBlocksIcon->setPixmap(getNextFrame());
});
timerSpinner->start(40);
}
void BitcoinGUI::stopSpinner()
{
if (timerSpinner == nullptr) {
return;
}
timerSpinner->deleteLater();
timerSpinner = nullptr;
}
void BitcoinGUI::startConnectingAnimation()
{
static int nStep{-1};
const int nAnimationSteps = 10;
if (timerConnecting != nullptr) {
return;
}
timerConnecting = new QTimer(this);
QObject::connect(timerConnecting, &QTimer::timeout, [=]() {
if (timerConnecting == nullptr) {
return;
}
QString strImage;
GUIUtil::ThemedColor color;
nStep = (nStep + 1) % (nAnimationSteps + 1);
if (nStep == 0) {
strImage = "connect_4";
color = GUIUtil::ThemedColor::ICON_ALTERNATIVE_COLOR;
} else if (nStep == nAnimationSteps / 2) {
strImage = "connect_1";
color = GUIUtil::ThemedColor::ORANGE;
} else {
return;
}
labelConnectionsIcon->setPixmap(GUIUtil::getIcon(strImage, color).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
});
timerConnecting->start(100);
}
void BitcoinGUI::stopConnectingAnimation()
{
if (timerConnecting == nullptr) {
return;
}
timerConnecting->deleteLater();
timerConnecting = nullptr;
}
void BitcoinGUI::toggleStaking() {
fGlobalStakingToggle = !fGlobalStakingToggle;
LogPrintf("Staking is now %s\n", fGlobalStakingToggle ? "enabled" : "disabled");
}
void BitcoinGUI::createActions()
{
sendCoinsMenuAction = new QAction(tr("&Send"), this);
sendCoinsMenuAction->setStatusTip(tr("Send coins to a PAC address"));
sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip());
coinJoinCoinsMenuAction = new QAction("&CoinJoin", this);
coinJoinCoinsMenuAction->setStatusTip(tr("Send %1 funds to a PAC address").arg("CoinJoin"));
coinJoinCoinsMenuAction->setToolTip(coinJoinCoinsMenuAction->statusTip());
receiveCoinsMenuAction = new QAction(tr("&Receive"), this);
receiveCoinsMenuAction->setStatusTip(tr("Request payments (generates QR codes and pac: URIs)"));
receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip());
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
// can be triggered from the tray menu, and need to show the GUI to be useful.
connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
connect(coinJoinCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(coinJoinCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoCoinJoinCoinsPage()));
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
quitAction = new QAction(tr("E&xit"), this);
quitAction->setStatusTip(tr("Quit application"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
quitAction->setMenuRole(QAction::QuitRole);
aboutAction = new QAction(tr("&About %1").arg(tr(PACKAGE_NAME)), this);
aboutAction->setStatusTip(tr("Show information about pacprotocol"));
aboutAction->setMenuRole(QAction::AboutRole);
aboutAction->setEnabled(false);
aboutQtAction = new QAction(tr("About &Qt"), this);
aboutQtAction->setStatusTip(tr("Show information about Qt"));
aboutQtAction->setMenuRole(QAction::AboutQtRole);
optionsAction = new QAction(tr("&Options..."), this);
optionsAction->setStatusTip(tr("Modify configuration options for %1").arg(tr(PACKAGE_NAME)));
optionsAction->setMenuRole(QAction::PreferencesRole);
optionsAction->setEnabled(false);
toggleHideAction = new QAction(tr("&Show / Hide"), this);
toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
encryptWalletAction = new QAction(tr(" &Encrypt Wallet..."), this);
encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
toggleStakingAction = new QAction(tr(" &Toggle staking..."), this);
toggleStakingAction->setStatusTip(tr("Enable/disable whether the wallet is permitted to stake"));
toggleStakingAction->setCheckable(true);
backupWalletAction = new QAction(tr("&Backup Wallet..."), this);
backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
changePassphraseAction = new QAction(tr("&Change Passphrase..."), this);
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
unlockWalletAction = new QAction(tr("&Unlock Wallet..."), this);
unlockWalletAction->setToolTip(tr("Unlock wallet"));
lockWalletAction = new QAction(tr("&Lock Wallet"), this);
signMessageAction = new QAction(tr("Sign &message..."), this);
signMessageAction->setStatusTip(tr("Sign messages with your PAC addresses to prove you own them"));
verifyMessageAction = new QAction(tr("&Verify message..."), this);
verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified PAC addresses"));
openInfoAction = new QAction(tr("&Information"), this);
openInfoAction->setStatusTip(tr("Show diagnostic information"));
openRPCConsoleAction = new QAction(tr("&Debug console"), this);
openRPCConsoleAction->setStatusTip(tr("Open debugging console"));
openGraphAction = new QAction(tr("&Network Monitor"), this);
openGraphAction->setStatusTip(tr("Show network monitor"));
openPeersAction = new QAction(tr("&Peers list"), this);
openPeersAction->setStatusTip(tr("Show peers info"));
openRepairAction = new QAction(tr("Wallet &Repair"), this);
openRepairAction->setStatusTip(tr("Show wallet repair options"));
openConfEditorAction = new QAction(tr("Open Wallet &Configuration File"), this);
openConfEditorAction->setStatusTip(tr("Open configuration file"));
// override TextHeuristicRole set by default which confuses this action with application settings
openConfEditorAction->setMenuRole(QAction::NoRole);
showBackupsAction = new QAction(tr("Show Automatic &Backups"), this);
showBackupsAction->setStatusTip(tr("Show automatically created wallet backups"));
// initially disable the debug window menu items
openInfoAction->setEnabled(false);
openRPCConsoleAction->setEnabled(false);
openGraphAction->setEnabled(false);
openPeersAction->setEnabled(false);
openRepairAction->setEnabled(false);
usedSendingAddressesAction = new QAction(tr("&Sending addresses..."), this);
usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
usedReceivingAddressesAction = new QAction(tr("&Receiving addresses..."), this);
usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
openAction = new QAction(tr("Open &URI..."), this);
openAction->setStatusTip(tr("Open a pac: URI or payment request"));
showHelpMessageAction = new QAction(tr("&Command-line options"), this);
showHelpMessageAction->setMenuRole(QAction::NoRole);
showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible PAC command-line options").arg(tr(PACKAGE_NAME)));
showCoinJoinHelpAction = new QAction(tr("%1 &information").arg("CoinJoin"), this);
showCoinJoinHelpAction->setMenuRole(QAction::NoRole);
showCoinJoinHelpAction->setStatusTip(tr("Show the %1 basic information").arg("CoinJoin"));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
connect(showHelpMessageAction, SIGNAL(triggered()), this, SLOT(showHelpMessageClicked()));
connect(showCoinJoinHelpAction, SIGNAL(triggered()), this, SLOT(showCoinJoinHelpClicked()));
// Jump directly to tabs in RPC-console
connect(openInfoAction, SIGNAL(triggered()), this, SLOT(showInfo()));
connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showConsole()));
connect(openGraphAction, SIGNAL(triggered()), this, SLOT(showGraph()));
connect(openPeersAction, SIGNAL(triggered()), this, SLOT(showPeers()));
connect(openRepairAction, SIGNAL(triggered()), this, SLOT(showRepair()));
// Open configs and backup folder from menu
connect(openConfEditorAction, SIGNAL(triggered()), this, SLOT(showConfEditor()));
connect(showBackupsAction, SIGNAL(triggered()), this, SLOT(showBackups()));
// Get restart command-line parameters and handle restart
connect(rpcConsole, SIGNAL(handleRestart(QStringList)), this, SLOT(handleRestart(QStringList)));
// prevents an open debug window from becoming stuck/unusable on client shutdown
connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));
#ifdef ENABLE_WALLET
if(walletFrame)
{
connect(encryptWalletAction, SIGNAL(triggered()), walletFrame, SLOT(encryptWallet()));
connect(toggleStakingAction, SIGNAL(triggered()), this, SLOT(toggleStaking()));
connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
connect(unlockWalletAction, SIGNAL(triggered()), walletFrame, SLOT(unlockWallet()));
connect(lockWalletAction, SIGNAL(triggered()), walletFrame, SLOT(lockWallet()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
}
#endif // ENABLE_WALLET
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I), this, SLOT(showInfo()));
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this, SLOT(showConsole()));
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G), this, SLOT(showGraph()));
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_P), this, SLOT(showPeers()));
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_R), this, SLOT(showRepair()));
}
void BitcoinGUI::createMenuBar()
{
#ifdef Q_OS_MAC
// Create a decoupled menu bar on Mac which stays even if the window is closed
appMenuBar = new QMenuBar();
#else
// Get the main window's menu bar on other platforms
appMenuBar = menuBar();
#endif
// Configure the menus
QMenu *file = appMenuBar->addMenu(tr("&File"));
if(walletFrame)
{
file->addAction(openAction);
file->addAction(backupWalletAction);
file->addAction(signMessageAction);
file->addAction(verifyMessageAction);
file->addSeparator();
file->addAction(usedSendingAddressesAction);
file->addAction(usedReceivingAddressesAction);
file->addSeparator();
}
file->addAction(quitAction);
QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
if(walletFrame)
{
settings->addAction(encryptWalletAction);
settings->addAction(toggleStakingAction);
settings->addAction(changePassphraseAction);
settings->addAction(unlockWalletAction);
settings->addAction(lockWalletAction);
settings->addSeparator();
}
settings->addAction(optionsAction);
if(walletFrame)
{
QMenu *tools = appMenuBar->addMenu(tr("&Tools"));
tools->addAction(openInfoAction);
tools->addAction(openRPCConsoleAction);
tools->addAction(openGraphAction);
tools->addAction(openPeersAction);
tools->addAction(openRepairAction);
tools->addSeparator();
tools->addAction(openConfEditorAction);
tools->addAction(showBackupsAction);
}
QMenu *help = appMenuBar->addMenu(tr("&Help"));
help->addAction(showHelpMessageAction);
help->addAction(showCoinJoinHelpAction);
help->addSeparator();
help->addAction(aboutAction);
help->addAction(aboutQtAction);
}
void BitcoinGUI::createToolBars()
{
#ifdef ENABLE_WALLET
if(walletFrame)
{
QToolBar *toolbar = new QToolBar(tr("Tabs toolbar"));
appToolBar = toolbar;
toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly);
toolbar->setMovable(false); // remove unused icon in upper left corner
tabGroup = new QButtonGroup(this);
overviewButton = new QToolButton(this);
overviewButton->setText(tr("&Overview"));
overviewButton->setStatusTip(tr("Show general overview of wallet"));
tabGroup->addButton(overviewButton);
sendCoinsButton = new QToolButton(this);
sendCoinsButton->setText(sendCoinsMenuAction->text());
sendCoinsButton->setStatusTip(sendCoinsMenuAction->statusTip());
tabGroup->addButton(sendCoinsButton);
receiveCoinsButton = new QToolButton(this);
receiveCoinsButton->setText(receiveCoinsMenuAction->text());
receiveCoinsButton->setStatusTip(receiveCoinsMenuAction->statusTip());
tabGroup->addButton(receiveCoinsButton);
historyButton = new QToolButton(this);
historyButton->setText(tr("&Transactions"));
historyButton->setStatusTip(tr("Browse transaction history"));
tabGroup->addButton(historyButton);
coinJoinCoinsButton = new QToolButton(this);
coinJoinCoinsButton->setText(coinJoinCoinsMenuAction->text());
coinJoinCoinsButton->setStatusTip(coinJoinCoinsMenuAction->statusTip());
tabGroup->addButton(coinJoinCoinsButton);
QSettings settings;
if (settings.value("fShowMasternodesTab").toBool()) {
masternodeButton = new QToolButton(this);
masternodeButton->setText(tr("&Masternodes"));
masternodeButton->setStatusTip(tr("Browse masternodes"));
tabGroup->addButton(masternodeButton);
connect(masternodeButton, SIGNAL(clicked()), this, SLOT(gotoMasternodePage()));
}
governanceButton = new QToolButton(this);
governanceButton->setText(tr("&Governance"));
governanceButton->setStatusTip(tr("Show governance items"));
governanceButton->setToolTip(governanceButton->statusTip());
governanceButton->setCheckable(true);
tabGroup->addButton(governanceButton);
connect(overviewButton, SIGNAL(clicked()), this, SLOT(gotoOverviewPage()));
connect(sendCoinsButton, SIGNAL(clicked()), this, SLOT(gotoSendCoinsPage()));
connect(coinJoinCoinsButton, SIGNAL(clicked()), this, SLOT(gotoCoinJoinCoinsPage()));
connect(receiveCoinsButton, SIGNAL(clicked()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyButton, SIGNAL(clicked()), this, SLOT(gotoHistoryPage()));
connect(governanceButton, SIGNAL(clicked()), this, SLOT(gotoGovernancePage()));
// Give the selected tab button a bolder font.
connect(tabGroup, SIGNAL(buttonToggled(QAbstractButton *, bool)), this, SLOT(highlightTabButton(QAbstractButton *, bool)));
for (auto button : tabGroup->buttons()) {
GUIUtil::setFont({button}, GUIUtil::FontWeight::Normal, 16);
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
button->setToolTip(button->statusTip());
button->setCheckable(true);
toolbar->addWidget(button);
}
overviewButton->setChecked(true);
GUIUtil::updateFonts();
#ifdef ENABLE_WALLET
m_wallet_selector = new QComboBox(this);
connect(m_wallet_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentWalletBySelectorIndex(int)));
QVBoxLayout* walletSelectorLayout = new QVBoxLayout(this);
walletSelectorLayout->addWidget(m_wallet_selector);
walletSelectorLayout->setSpacing(0);
walletSelectorLayout->setMargin(0);
walletSelectorLayout->setContentsMargins(5, 0, 5, 0);
QWidget* walletSelector = new QWidget(this);
walletSelector->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
walletSelector->setObjectName("walletSelector");
walletSelector->setLayout(walletSelectorLayout);
m_wallet_selector_action = appToolBar->insertWidget(appToolBarLogoAction, walletSelector);
m_wallet_selector_action->setVisible(false);
#endif
QLabel *logoLabel = new QLabel();
logoLabel->setObjectName("lblToolbarLogo");
logoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
appToolBarLogoAction = toolbar->addWidget(logoLabel);
/** Create additional container for toolbar and walletFrame and make it the central widget.
This is a workaround mostly for toolbar styling on Mac OS but should work fine for every other OSes too.
*/
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(toolbar);
layout->addWidget(walletFrame);
layout->setSpacing(0);
layout->setContentsMargins(QMargins());
QWidget *containerWidget = new QWidget();
containerWidget->setLayout(layout);
setCentralWidget(containerWidget);
}
#endif // ENABLE_WALLET
}
void BitcoinGUI::setClientModel(ClientModel *_clientModel)
{
this->clientModel = _clientModel;
if(_clientModel)
{
// Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
// while the client has not yet fully loaded
if (trayIcon) {
// do so only if trayIcon is already set
trayIconMenu = new QMenu(this);
trayIcon->setContextMenu(trayIconMenu);
createIconMenu(trayIconMenu);
#ifndef Q_OS_MAC
// Show main window on tray icon click
// Note: ignore this on Mac - this is not the way tray should work there
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
#else
// Note: On Mac, the dock icon is also used to provide menu functionality
// similar to one for tray icon
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
connect(dockIconHandler, SIGNAL(dockIconClicked()), this, SLOT(macosDockIconActivated()));
dockIconMenu = new QMenu(this);
dockIconMenu->setAsDockMenu();
createIconMenu(dockIconMenu);
#endif
}
// Keep up to date with client
updateNetworkState();
setNumConnections(_clientModel->getNumConnections());
connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool)));
modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime()));
setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false);
connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,QString,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,QString,double,bool)));
connect(_clientModel, SIGNAL(additionalDataSyncProgressChanged(double)), this, SLOT(setAdditionalDataSyncProgress(double)));
// Receive and report messages from client model
connect(_clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
// Show progress dialog
connect(_clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));
rpcConsole->setClientModel(_clientModel);
#ifdef ENABLE_WALLET
if(walletFrame)
{
walletFrame->setClientModel(_clientModel);
}
#endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel());
OptionsModel* optionsModel = _clientModel->getOptionsModel();
if(optionsModel)
{
// be aware of the tray icon disable state change reported by the OptionsModel object.
connect(optionsModel,SIGNAL(hideTrayIconChanged(bool)),this,SLOT(setTrayIconVisible(bool)));
// initialize the disable state of the tray icon with the current value in the model.
setTrayIconVisible(optionsModel->getHideTrayIcon());
connect(optionsModel, SIGNAL(coinJoinEnabledChanged()), this, SLOT(updateCoinJoinVisibility()));
}
} else {
// Disable possibility to show main window via action
toggleHideAction->setEnabled(false);
if(trayIconMenu)
{
// Disable context menu on tray icon
trayIconMenu->clear();
}
// Propagate cleared model to child objects
rpcConsole->setClientModel(nullptr);
#ifdef ENABLE_WALLET
if (walletFrame)
{
walletFrame->setClientModel(nullptr);
}
#endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(nullptr);
#ifdef Q_OS_MAC
if(dockIconMenu)
{
// Disable context menu on dock icon
dockIconMenu->clear();
}
#endif
}
updateCoinJoinVisibility();
}
#ifdef ENABLE_WALLET
bool BitcoinGUI::addWallet(WalletModel *walletModel)
{
if(!walletFrame)
return false;
const QString name = walletModel->getWalletName();
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
setWalletActionsEnabled(true);
m_wallet_selector->addItem(display_name, name);
if (m_wallet_selector->count() == 2) {
m_wallet_selector_action->setVisible(true);
}
rpcConsole->addWallet(walletModel);
return walletFrame->addWallet(walletModel);
}
bool BitcoinGUI::removeWallet(WalletModel* walletModel)
{
if (!walletFrame) return false;
QString name = walletModel->getWalletName();
int index = m_wallet_selector->findData(name);
m_wallet_selector->removeItem(index);
if (m_wallet_selector->count() == 0) {
setWalletActionsEnabled(false);
} else if (m_wallet_selector->count() == 1) {
m_wallet_selector_action->setVisible(false);
}
rpcConsole->removeWallet(walletModel);
return walletFrame->removeWallet(name);
}
bool BitcoinGUI::setCurrentWallet(const QString& name)
{
if(!walletFrame)
return false;
return walletFrame->setCurrentWallet(name);
}
bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
{
QString internal_name = m_wallet_selector->itemData(index).toString();
return setCurrentWallet(internal_name);
}
void BitcoinGUI::removeAllWallets()
{
if(!walletFrame)
return;
setWalletActionsEnabled(false);
walletFrame->removeAllWallets();
}
#endif // ENABLE_WALLET
void BitcoinGUI::setWalletActionsEnabled(bool enabled)
{
#ifdef ENABLE_WALLET
if (walletFrame != nullptr) {
overviewButton->setEnabled(enabled);
sendCoinsButton->setEnabled(enabled);
coinJoinCoinsButton->setEnabled(enabled && clientModel->coinJoinOptions().isEnabled());
receiveCoinsButton->setEnabled(enabled);
historyButton->setEnabled(enabled);
if (masternodeButton != nullptr) {
QSettings settings;
masternodeButton->setEnabled(enabled && settings.value("fShowMasternodesTab").toBool());
}
}
#endif // ENABLE_WALLET
sendCoinsMenuAction->setEnabled(enabled);
#ifdef ENABLE_WALLET
coinJoinCoinsMenuAction->setEnabled(enabled && clientModel->coinJoinOptions().isEnabled());
#else
coinJoinCoinsMenuAction->setEnabled(enabled);
#endif // ENABLE_WALLET
receiveCoinsMenuAction->setEnabled(enabled);
encryptWalletAction->setEnabled(enabled);
governanceButton->setEnabled(enabled);
toggleStakingAction->setEnabled(enabled);
backupWalletAction->setEnabled(enabled);
changePassphraseAction->setEnabled(enabled);
signMessageAction->setEnabled(enabled);
verifyMessageAction->setEnabled(enabled);
usedSendingAddressesAction->setEnabled(enabled);
usedReceivingAddressesAction->setEnabled(enabled);
openAction->setEnabled(enabled);
}
void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
{
trayIcon = new QSystemTrayIcon(this);
QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();
trayIcon->setToolTip(toolTip);
trayIcon->setIcon(networkStyle->getTrayAndWindowIcon());
trayIcon->hide();
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
}
void BitcoinGUI::createIconMenu(QMenu *pmenu)
{
// Configuration of the tray icon (or dock icon) icon menu
pmenu->addAction(toggleHideAction);
pmenu->addSeparator();
pmenu->addAction(sendCoinsMenuAction);
pmenu->addAction(coinJoinCoinsMenuAction);
pmenu->addAction(receiveCoinsMenuAction);
pmenu->addSeparator();
pmenu->addAction(signMessageAction);
pmenu->addAction(verifyMessageAction);
pmenu->addSeparator();
pmenu->addAction(optionsAction);
pmenu->addAction(openInfoAction);
pmenu->addAction(openRPCConsoleAction);
pmenu->addAction(openGraphAction);
pmenu->addAction(openPeersAction);
pmenu->addAction(openRepairAction);
pmenu->addSeparator();
pmenu->addAction(openConfEditorAction);
pmenu->addAction(showBackupsAction);
#ifndef Q_OS_MAC // This is built-in on Mac
pmenu->addSeparator();
pmenu->addAction(quitAction);
#endif
}
#ifndef Q_OS_MAC
void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
if(reason == QSystemTrayIcon::Trigger)
{
// Click on system tray icon triggers show/hide of the main window
toggleHidden();
}
}
#else
void BitcoinGUI::macosDockIconActivated()
{
showNormalIfMinimized();
activateWindow();
}
#endif
void BitcoinGUI::optionsClicked()
{
if(!clientModel || !clientModel->getOptionsModel())
return;
OptionsDialog dlg(this, enableWallet);
dlg.setModel(clientModel->getOptionsModel());
connect(&dlg, &OptionsDialog::appearanceChanged, [=]() {
updateWidth();
});
dlg.exec();
updateCoinJoinVisibility();
}
void BitcoinGUI::aboutClicked()
{
if(!clientModel)
return;
HelpMessageDialog dlg(m_node, this, HelpMessageDialog::about);
dlg.exec();
}
void BitcoinGUI::showDebugWindow()
{
GUIUtil::bringToFront(rpcConsole);
}
void BitcoinGUI::showInfo()
{
rpcConsole->setTabFocus(RPCConsole::TAB_INFO);
showDebugWindow();
}
void BitcoinGUI::showConsole()
{
rpcConsole->setTabFocus(RPCConsole::TAB_CONSOLE);
showDebugWindow();
}
void BitcoinGUI::showGraph()
{
rpcConsole->setTabFocus(RPCConsole::TAB_GRAPH);
showDebugWindow();
}
void BitcoinGUI::showPeers()
{
rpcConsole->setTabFocus(RPCConsole::TAB_PEERS);
showDebugWindow();
}
void BitcoinGUI::showRepair()
{
rpcConsole->setTabFocus(RPCConsole::TAB_REPAIR);
showDebugWindow();
}
void BitcoinGUI::showConfEditor()
{
GUIUtil::openConfigfile();
}
void BitcoinGUI::showBackups()
{
GUIUtil::showBackups();
}
void BitcoinGUI::showHelpMessageClicked()
{
helpMessageDialog->show();
}
void BitcoinGUI::showCoinJoinHelpClicked()
{
if(!clientModel)
return;
HelpMessageDialog dlg(m_node, this, HelpMessageDialog::pshelp);
dlg.exec();
}
#ifdef ENABLE_WALLET
void BitcoinGUI::openClicked()
{
OpenURIDialog dlg(this);
if(dlg.exec())
{
Q_EMIT receivedURI(dlg.getURI());
}
}
void BitcoinGUI::highlightTabButton(QAbstractButton *button, bool checked)
{
GUIUtil::setFont({button}, checked ? GUIUtil::FontWeight::Bold : GUIUtil::FontWeight::Normal, 16);
GUIUtil::updateFonts();
}
void BitcoinGUI::gotoOverviewPage()
{
overviewButton->setChecked(true);
if (walletFrame) walletFrame->gotoOverviewPage();
}
void BitcoinGUI::gotoHistoryPage()
{
historyButton->setChecked(true);
if (walletFrame) walletFrame->gotoHistoryPage();
}
void BitcoinGUI::gotoMasternodePage()
{
QSettings settings;
if (settings.value("fShowMasternodesTab").toBool() && masternodeButton) {
masternodeButton->setChecked(true);
if (walletFrame) walletFrame->gotoMasternodePage();
}
}
void BitcoinGUI::gotoGovernancePage()
{
governanceButton->setChecked(true);
if (walletFrame) walletFrame->gotoGovernancePage();
}
void BitcoinGUI::gotoReceiveCoinsPage()
{
receiveCoinsButton->setChecked(true);
if (walletFrame) walletFrame->gotoReceiveCoinsPage();
}
void BitcoinGUI::gotoSendCoinsPage(QString addr)
{
sendCoinsButton->setChecked(true);
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
}
void BitcoinGUI::gotoCoinJoinCoinsPage(QString addr)
{
coinJoinCoinsButton->setChecked(true);
if (walletFrame) walletFrame->gotoCoinJoinCoinsPage(addr);
}
void BitcoinGUI::gotoSignMessageTab(QString addr)
{
if (walletFrame) walletFrame->gotoSignMessageTab(addr);
}
void BitcoinGUI::gotoVerifyMessageTab(QString addr)
{
if (walletFrame) walletFrame->gotoVerifyMessageTab(addr);
}
#endif // ENABLE_WALLET
void BitcoinGUI::updateNetworkState()
{
if (clientModel == nullptr) {
return;
}
static int nCountPrev{0};
static bool fNetworkActivePrev{false};
int count = clientModel->getNumConnections();
bool fNetworkActive = m_node.getNetworkActive();
QString icon;
GUIUtil::ThemedColor color = GUIUtil::ThemedColor::ORANGE;
switch(count)
{
case 0: icon = "connect_4"; color = GUIUtil::ThemedColor::ICON_ALTERNATIVE_COLOR; break;
case 1: case 2: icon = "connect_1"; break;
case 3: case 4: case 5: icon = "connect_2"; break;
case 6: case 7: icon = "connect_3"; break;
default: icon = "connect_4"; color = GUIUtil::ThemedColor::GREEN; break;
}
labelBlocksIcon->setVisible(count > 0);
updateProgressBarVisibility();
bool fNetworkBecameActive = (!fNetworkActivePrev && fNetworkActive) || (nCountPrev == 0 && count > 0);
bool fNetworkBecameInactive = (fNetworkActivePrev && !fNetworkActive) || (nCountPrev > 0 && count == 0);
if (fNetworkBecameActive) {
// If the sync process still signals synced after five seconds represent it in the UI.
if (m_node.masternodeSync().isSynced()) {
QTimer::singleShot(5000, this, [&]() {
if (clientModel->getNumConnections() > 0 && m_node.masternodeSync().isSynced()) {
setAdditionalDataSyncProgress(1);
}
});
}
startSpinner();
} else if (fNetworkBecameInactive) {
labelBlocksIcon->hide();
stopSpinner();
}
if (fNetworkBecameActive || fNetworkBecameInactive) {
setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false);
}
nCountPrev = count;
fNetworkActivePrev = fNetworkActive;
if (fNetworkActive) {
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to PAC network", "", count));
} else {
labelConnectionsIcon->setToolTip(tr("Network activity disabled"));
icon = "connect_4";
color = GUIUtil::ThemedColor::RED;
}
if (fNetworkActive && count == 0) {
startConnectingAnimation();
}
if (!fNetworkActive || count > 0) {
stopConnectingAnimation();
labelConnectionsIcon->setPixmap(GUIUtil::getIcon(icon, color).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
}
}
void BitcoinGUI::setNumConnections(int count)
{
updateNetworkState();
}
void BitcoinGUI::setNetworkActive(bool networkActive)
{
updateNetworkState();
}
void BitcoinGUI::updateHeadersSyncProgressLabel()
{
int64_t headersTipTime = clientModel->getHeaderTipTime();
int headersTipHeight = clientModel->getHeaderTipHeight();
int estHeadersLeft = (GetTime() - headersTipTime) / Params().GetConsensus().nPowTargetSpacing;
if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)
progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
}
void BitcoinGUI::updateProgressBarVisibility()
{
if (clientModel == nullptr) {
return;
}
// Show the progress bar label if the network is active + we are out of sync or we have no connections.
bool fShowProgressBarLabel = m_node.getNetworkActive() && (!m_node.masternodeSync().isSynced() || clientModel->getNumConnections() == 0);
// Show the progress bar only if the the network active + we are not synced + we have any connection. Unlike with the label
// which gives an info text about the connecting phase there is no reason to show the progress bar if we don't have connections
// since it will not get any updates in this case.
bool fShowProgressBar = m_node.getNetworkActive() && !m_node.masternodeSync().isSynced() && clientModel->getNumConnections() > 0;
progressBarLabel->setVisible(fShowProgressBarLabel);
progressBar->setVisible(fShowProgressBar);
}
void BitcoinGUI::updateCoinJoinVisibility()
{
#ifdef ENABLE_WALLET
bool fEnabled = m_node.coinJoinOptions().isEnabled();
#else
bool fEnabled = false;
#endif
// CoinJoin button is the third QToolButton, show/hide the underlying QAction
// Hiding the QToolButton itself doesn't work for the GUI part
// but is still needed for shortcuts to work properly.
if (appToolBar != nullptr) {
appToolBar->actions()[4]->setVisible(fEnabled);
coinJoinCoinsButton->setVisible(fEnabled);
GUIUtil::updateButtonGroupShortcuts(tabGroup);
}
coinJoinCoinsMenuAction->setVisible(fEnabled);
showCoinJoinHelpAction->setVisible(fEnabled);
updateWidth();
}
void BitcoinGUI::updateWidth()
{
if (walletFrame == nullptr) {
return;
}
if (windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) {
return;
}
int nWidthWidestButton{0};
int nButtonsVisible{0};
for (QAbstractButton* button : tabGroup->buttons()) {
if (!button->isEnabled()) {
continue;
}
QFontMetrics fm(button->font());
nWidthWidestButton = std::max<int>(nWidthWidestButton, fm.width(button->text()));
++nButtonsVisible;
}
// Add 30 per button as padding and use minimum 980 which is the minimum required to show all tab's contents
// Use nButtonsVisible + 1 <- for the dash logo
int nWidth = std::max<int>(980, (nWidthWidestButton + 30) * (nButtonsVisible + 1));
setMinimumWidth(nWidth);
resize(nWidth, height());
}
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, const QString& blockHash, double nVerificationProgress, bool header)
{
#ifdef Q_OS_MAC
// Disabling macOS App Nap on initial sync, disk, reindex operations and mixing.
bool disableAppNap = !m_node.masternodeSync().isSynced();
#ifdef ENABLE_WALLET
for (const auto& wallet : m_node.getWallets()) {
disableAppNap |= wallet->coinJoin().isMixing();
}
#endif // ENABLE_WALLET
if (disableAppNap) {
m_app_nap_inhibitor->disableAppNap();
} else {
m_app_nap_inhibitor->enableAppNap();
}
#endif // Q_OS_MAC
if (modalOverlay)
{
if (header)
modalOverlay->setKnownBestHeight(count, blockDate);
else
modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
}
if (!clientModel)
return;
updateProgressBarVisibility();
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbled text)
statusBar()->clearMessage();
// Acquire current block source
enum BlockSource blockSource = clientModel->getBlockSource();
switch (blockSource) {
case BlockSource::NETWORK:
if (header) {
updateHeadersSyncProgressLabel();
return;
}
progressBarLabel->setText(tr("Synchronizing with network..."));
updateHeadersSyncProgressLabel();
break;
case BlockSource::DISK:
if (header) {
progressBarLabel->setText(tr("Indexing blocks on disk..."));
} else {
progressBarLabel->setText(tr("Processing blocks on disk..."));
}
break;
case BlockSource::REINDEX:
progressBarLabel->setText(tr("Reindexing blocks on disk..."));
break;
case BlockSource::NONE:
if (header) {
return;
}
progressBarLabel->setText(tr("Connecting to peers..."));
break;
}
QString tooltip;
QDateTime currentDate = QDateTime::currentDateTime();
qint64 secs = blockDate.secsTo(currentDate);
tooltip = tr("Processed %n block(s) of transaction history.", "", count);
// Set icon state: spinning if catching up, tick otherwise
#ifdef ENABLE_WALLET
if (walletFrame)
{
if(secs < 25*60) // 90*60 in bitcoin
{
modalOverlay->showHide(true, true);
// TODO instead of hiding it forever, we should add meaningful information about MN sync to the overlay
modalOverlay->hideForever();
}
else
{
modalOverlay->showHide();
}
}
#endif // ENABLE_WALLET
if(!m_node.masternodeSync().isBlockchainSynced())
{
QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs);
progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
progressBar->setMaximum(1000000000);
progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
tooltip = tr("Catching up...") + QString("<br>") + tooltip;
#ifdef ENABLE_WALLET
if(walletFrame)
{
walletFrame->showOutOfSyncWarning(true);
}
#endif // ENABLE_WALLET
tooltip += QString("<br>");
tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
tooltip += QString("<br>");
tooltip += tr("Transactions after this will not yet be visible.");
} else if (fDisableGovernance) {
setAdditionalDataSyncProgress(1);
}
// Don't word-wrap this (fixed-width) tooltip
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
labelBlocksIcon->setToolTip(tooltip);
progressBarLabel->setToolTip(tooltip);
progressBar->setToolTip(tooltip);
}
void BitcoinGUI::setAdditionalDataSyncProgress(double nSyncProgress)
{
if(!clientModel)
return;
// If masternodeSync.Reset() has been called make sure status bar shows the correct information.
if (nSyncProgress == -1) {
setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false);
if (clientModel->getNumConnections()) {
labelBlocksIcon->show();
startSpinner();
}
return;
}
// No additional data sync should be happening while blockchain is not synced, nothing to update
if(!m_node.masternodeSync().isBlockchainSynced())
return;
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
statusBar()->clearMessage();
QString tooltip;
// Set icon state: spinning if catching up, tick otherwise
QString strSyncStatus;
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
#ifdef ENABLE_WALLET
if(walletFrame)
walletFrame->showOutOfSyncWarning(false);
#endif // ENABLE_WALLET
updateProgressBarVisibility();
if(m_node.masternodeSync().isSynced()) {
stopSpinner();
labelBlocksIcon->setPixmap(GUIUtil::getIcon("synced", GUIUtil::ThemedColor::GREEN).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
} else {
progressBar->setFormat(tr("Synchronizing additional data: %p%"));
progressBar->setMaximum(1000000000);
progressBar->setValue(nSyncProgress * 1000000000.0 + 0.5);
}
strSyncStatus = QString(m_node.masternodeSync().getSyncStatus().c_str());
progressBarLabel->setText(strSyncStatus);
tooltip = strSyncStatus + QString("<br>") + tooltip;
// Don't word-wrap this (fixed-width) tooltip
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
labelBlocksIcon->setToolTip(tooltip);
progressBarLabel->setToolTip(tooltip);
progressBar->setToolTip(tooltip);
}
void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
{
QString strTitle = tr("pacprotocol"); // default title
// Default to information icon
int nMBoxIcon = QMessageBox::Information;
int nNotifyIcon = Notificator::Information;
QString msgType;
// Prefer supplied title over style based title
if (!title.isEmpty()) {
msgType = title;
}
else {
switch (style) {
case CClientUIInterface::MSG_ERROR:
msgType = tr("Error");
break;
case CClientUIInterface::MSG_WARNING:
msgType = tr("Warning");
break;
case CClientUIInterface::MSG_INFORMATION:
msgType = tr("Information");
break;
default:
break;
}
}
// Append title to "pacprotocol - "
if (!msgType.isEmpty())
strTitle += " - " + msgType;
// Check for error/warning icon
if (style & CClientUIInterface::ICON_ERROR) {
nMBoxIcon = QMessageBox::Critical;
nNotifyIcon = Notificator::Critical;
}
else if (style & CClientUIInterface::ICON_WARNING) {
nMBoxIcon = QMessageBox::Warning;
nNotifyIcon = Notificator::Warning;
}
// Display message
if (style & CClientUIInterface::MODAL) {
// Check for buttons, use OK as default, if none was supplied
QMessageBox::StandardButton buttons;
if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
buttons = QMessageBox::Ok;
showNormalIfMinimized();
QMessageBox mBox(static_cast<QMessageBox::Icon>(nMBoxIcon), strTitle, message, buttons, this);
mBox.setTextFormat(Qt::PlainText);
int r = mBox.exec();
if (ret != nullptr)
*ret = r == QMessageBox::Ok;
}
else
notificator->notify(static_cast<Notificator::Class>(nNotifyIcon), strTitle, message);
}
void BitcoinGUI::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
#ifndef Q_OS_MAC // Ignored on Mac
if(e->type() == QEvent::WindowStateChange)
{
if(clientModel && clientModel->getOptionsModel() && clientModel->getOptionsModel()->getMinimizeToTray())
{
QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
{
QTimer::singleShot(0, this, SLOT(hide()));
e->ignore();
}
else if((wsevt->oldState() & Qt::WindowMinimized) && !isMinimized())
{
QTimer::singleShot(0, this, SLOT(show()));
e->ignore();
}
}
}
#endif
if (e->type() == QEvent::StyleChange) {
updateNetworkState();
#ifdef ENABLE_WALLET
updateWalletStatus();
#endif
if (m_node.masternodeSync().isSynced()) {
labelBlocksIcon->setPixmap(GUIUtil::getIcon("synced", GUIUtil::ThemedColor::GREEN).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
}
}
}
void BitcoinGUI::closeEvent(QCloseEvent *event)
{
#ifndef Q_OS_MAC // Ignored on Mac
if(clientModel && clientModel->getOptionsModel())
{
if(!clientModel->getOptionsModel()->getMinimizeOnClose())
{
// close rpcConsole in case it was open to make some space for the shutdown window
rpcConsole->close();
QApplication::quit();
}
else
{
QMainWindow::showMinimized();
event->ignore();
}
}
#else
QMainWindow::closeEvent(event);
#endif
}
void BitcoinGUI::showEvent(QShowEvent *event)
{
// enable the debug window when the main window shows up
openInfoAction->setEnabled(true);
openRPCConsoleAction->setEnabled(true);
openGraphAction->setEnabled(true);
openPeersAction->setEnabled(true);
openRepairAction->setEnabled(true);
aboutAction->setEnabled(true);
optionsAction->setEnabled(true);
if (!event->spontaneous()) {
updateCoinJoinVisibility();
}
}
#ifdef ENABLE_WALLET
void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName)
{
IncomingTransactionMessage itx = {
date, unit, amount, type, address, label, walletName
};
incomingTransactions.emplace_back(itx);
if (incomingTransactions.size() == 1) {
// first TX since we last showed pending messages, let's wait 100ms and then show each individual message
incomingTransactionsTimer->start(100);
} else if (incomingTransactions.size() == 10) {
// we seem to have received 10 TXs in 100ms and we can expect even more, so let's pause for 1 sec and
// show a "Multiple TXs sent/received!" message instead of individual messages
incomingTransactionsTimer->start(1000);
}
}
void BitcoinGUI::showIncomingTransactions()
{
auto txs = std::move(this->incomingTransactions);
if (txs.empty()) {
return;
}
if (txs.size() >= 100) {
// Show one balloon for all transactions instead of showing one for each individual one
// (which would kill some systems)
CAmount sentAmount = 0;
CAmount receivedAmount = 0;
int sentCount = 0;
int receivedCount = 0;
for (auto& itx : txs) {
if (itx.amount < 0) {
sentAmount += itx.amount;
sentCount++;
} else {
receivedAmount += itx.amount;
receivedCount++;
}
}
QString title;
if (sentCount > 0 && receivedCount > 0) {
title = tr("Received and sent multiple transactions");
} else if (sentCount > 0) {
title = tr("Sent multiple transactions");
} else if (receivedCount > 0) {
title = tr("Received multiple transactions");
} else {
return;
}
// Use display unit of last entry
int unit = txs.back().unit;
QString msg;
if (sentCount > 0) {
msg += tr("Sent Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, sentAmount, true));
}
if (receivedCount > 0) {
msg += tr("Received Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, receivedAmount, true));
}
message(title, msg, CClientUIInterface::MSG_INFORMATION);
} else {
for (auto& itx : txs) {
// On new transaction, make an info balloon
QString msg = tr("Date: %1\n").arg(itx.date) +
tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(itx.unit, itx.amount, true));
if (m_node.getWallets().size() > 1 && !itx.walletName.isEmpty()) {
msg += tr("Wallet: %1\n").arg(itx.walletName);
}
msg += tr("Type: %1\n").arg(itx.type);
if (!itx.label.isEmpty())
msg += tr("Label: %1\n").arg(itx.label);
else if (!itx.address.isEmpty())
msg += tr("Address: %1\n").arg(itx.address);
message((itx.amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
msg, CClientUIInterface::MSG_INFORMATION);
}
}
}
#endif // ENABLE_WALLET
void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
{
// Accept only URIs
if(event->mimeData()->hasUrls())
event->acceptProposedAction();
}
void BitcoinGUI::dropEvent(QDropEvent *event)
{
if(event->mimeData()->hasUrls())
{
for (const QUrl &uri : event->mimeData()->urls())
{
Q_EMIT receivedURI(uri.toString());
}
}
event->acceptProposedAction();
}
bool BitcoinGUI::eventFilter(QObject *object, QEvent *event)
{
// Catch status tip events
if (event->type() == QEvent::StatusTip)
{
// Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff
if (progressBarLabel->isVisible() || progressBar->isVisible())
return true;
}
return QMainWindow::eventFilter(object, event);
}
#ifdef ENABLE_WALLET
bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
{
// URI has to be valid
if (walletFrame && walletFrame->handlePaymentRequest(recipient))
{
showNormalIfMinimized();
gotoSendCoinsPage();
return true;
}
return false;
}
void BitcoinGUI::setHDStatus(int hdEnabled)
{
if (hdEnabled) {
labelWalletHDStatusIcon->setPixmap(GUIUtil::getIcon("hd_enabled", GUIUtil::ThemedColor::GREEN).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelWalletHDStatusIcon->setToolTip(tr("HD key generation is <b>enabled</b>"));
}
labelWalletHDStatusIcon->setVisible(hdEnabled);
}
void BitcoinGUI::setStakingStatus()
{
if (nLastCoinStakeSearchInterval && isStakingEnabled()) {
labelStakingIcon->show();
labelStakingIcon->setPixmap(QIcon(":/icons/staking_active").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelStakingIcon->setToolTip(tr("Staking is active\n"));
} else {
labelStakingIcon->show();
labelStakingIcon->setPixmap(QIcon(":/icons/staking_inactive").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelStakingIcon->setToolTip(tr("Staking is inactive\n"));
}
}
void BitcoinGUI::setEncryptionStatus(int status)
{
switch(status)
{
case WalletModel::Unencrypted:
labelWalletEncryptionIcon->show();
labelWalletEncryptionIcon->setPixmap(GUIUtil::getIcon("lock_open", GUIUtil::ThemedColor::RED).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>unencrypted</b>"));
changePassphraseAction->setEnabled(false);
unlockWalletAction->setVisible(false);
lockWalletAction->setVisible(false);
encryptWalletAction->setEnabled(true);
break;
case WalletModel::Unlocked:
labelWalletEncryptionIcon->show();
labelWalletEncryptionIcon->setPixmap(GUIUtil::getIcon("lock_open", GUIUtil::ThemedColor::RED).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(false);
lockWalletAction->setVisible(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break;
case WalletModel::UnlockedForMixingOnly:
labelWalletEncryptionIcon->show();
labelWalletEncryptionIcon->setPixmap(GUIUtil::getIcon("lock_open", GUIUtil::ThemedColor::ORANGE).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b> for mixing only"));
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(true);
lockWalletAction->setVisible(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break;
case WalletModel::Locked:
labelWalletEncryptionIcon->show();
labelWalletEncryptionIcon->setPixmap(GUIUtil::getIcon("lock_closed", GUIUtil::ThemedColor::GREEN).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(true);
lockWalletAction->setVisible(false);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break;
}
}
void BitcoinGUI::updateWalletStatus()
{
if (!walletFrame) {
return;
}
WalletView * const walletView = walletFrame->currentWalletView();
if (!walletView) {
return;
}
WalletModel * const walletModel = walletView->getWalletModel();
setEncryptionStatus(walletModel->getEncryptionStatus());
setHDStatus(walletModel->wallet().hdEnabled());
}
#endif // ENABLE_WALLET
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
{
if(!clientModel)
return;
if (!isHidden() && !isMinimized() && !GUIUtil::isObscured(this) && fToggleHidden) {
hide();
} else {
GUIUtil::bringToFront(this);
}
}
void BitcoinGUI::toggleHidden()
{
showNormalIfMinimized(true);
}
void BitcoinGUI::detectShutdown()
{
if (m_node.shutdownRequested())
{
if(rpcConsole)
rpcConsole->hide();
qApp->quit();
}
}
void BitcoinGUI::showProgress(const QString &title, int nProgress)
{
if (nProgress == 0)
{
progressDialog = new QProgressDialog(title, "", 0, 100, this);
progressDialog->setWindowModality(Qt::ApplicationModal);
progressDialog->setMinimumDuration(0);
progressDialog->setCancelButton(0);
progressDialog->setAutoClose(false);
progressDialog->setValue(0);
}
else if (nProgress == 100)
{
if (progressDialog)
{
progressDialog->close();
progressDialog->deleteLater();
}
}
else if (progressDialog)
progressDialog->setValue(nProgress);
}
void BitcoinGUI::setTrayIconVisible(bool fHideTrayIcon)
{
if (trayIcon)
{
trayIcon->setVisible(!fHideTrayIcon);
}
}
void BitcoinGUI::showModalOverlay()
{
if (modalOverlay && (progressBar->isVisible() || modalOverlay->isLayerVisible()))
modalOverlay->toggleVisibility();
}
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
{
bool modal = (style & CClientUIInterface::MODAL);
// The SECURE flag has no effect in the Qt GUI.
// bool secure = (style & CClientUIInterface::SECURE);
style &= ~CClientUIInterface::SECURE;
bool ret = false;
// In case of modal message, use blocking connection to wait for user to click a button
QMetaObject::invokeMethod(gui, "message",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
Q_ARG(unsigned int, style),
Q_ARG(bool*, &ret));
return ret;
}
void BitcoinGUI::subscribeToCoreSignals()
{
// Connect signals to client
m_handler_message_box = m_node.handleMessageBox(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
m_handler_question = m_node.handleQuestion(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
}
void BitcoinGUI::unsubscribeFromCoreSignals()
{
// Disconnect signals from client
m_handler_message_box->disconnect();
m_handler_question->disconnect();
}
void BitcoinGUI::toggleNetworkActive()
{
m_node.setNetworkActive(!m_node.getNetworkActive());
}
/** Get restart command-line parameters and request restart */
void BitcoinGUI::handleRestart(QStringList args)
{
if (!m_node.shutdownRequested())
Q_EMIT requestedRestart(args);
}
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() :
optionsModel(0),
menu(0)
{
createContextMenu();
setToolTip(tr("Unit to show amounts in. Click to select another unit."));
QList<BitcoinUnits::Unit> units = BitcoinUnits::availableUnits();
int max_width = 0;
const QFontMetrics fm(GUIUtil::getFontNormal());
for (const BitcoinUnits::Unit unit : units)
{
max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit)));
}
setMinimumSize(max_width, 0);
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
}
/** So that it responds to button clicks */
void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
{
onDisplayUnitsClicked(event->pos());
}
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
void UnitDisplayStatusBarControl::createContextMenu()
{
menu = new QMenu(this);
for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
{
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
menuAction->setData(QVariant(u));
menu->addAction(menuAction);
}
connect(menu,SIGNAL(triggered(QAction*)),this,SLOT(onMenuSelection(QAction*)));
}
/** Lets the control know about the Options Model (and its signals) */
void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel *_optionsModel)
{
if (_optionsModel)
{
this->optionsModel = _optionsModel;
// be aware of a display unit change reported by the OptionsModel object.
connect(_optionsModel,SIGNAL(displayUnitChanged(int)),this,SLOT(updateDisplayUnit(int)));
// initialize the display units label with the current value in the model.
updateDisplayUnit(_optionsModel->getDisplayUnit());
}
}
/** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */
void UnitDisplayStatusBarControl::updateDisplayUnit(int newUnits)
{
setText(BitcoinUnits::name(newUnits));
}
/** Shows context menu with Display Unit options by the mouse coordinates */
void UnitDisplayStatusBarControl::onDisplayUnitsClicked(const QPoint& point)
{
QPoint globalPos = mapToGlobal(point);
menu->exec(globalPos);
}
/** Tells underlying optionsModel to update its current display unit. */
void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)
{
if (action)
{
optionsModel->setDisplayUnit(action->data());
}
}
|
;*****************************************************************
;* - Description: Device definition file for RC Calibration
;* - File: m649.asm
;* - AppNote: AVR053 - Production calibration of the
;* RC oscillator
;*
;* - Author: Atmel Corporation: http://www.atmel.com
;* Support email: avr@atmel.com
;*
;* $Name$
;* $Revision: 56 $
;* $RCSfile$
;* $Date: 2006-02-16 17:44:45 +0100 (to, 16 feb 2006) $
;*****************************************************************
.include "m649def.inc"
.include "Common\memoryMap.inc"
.include "Device specific\m169_family_pinout.inc"
.equ OSC_VER = 5
.equ TCCR0 = TCCR0A
.equ TIFR = TIFR0
.equ MCUCSR = MCUCR
|
#include "Platform.inc"
#include "FarCalls.inc"
#include "TailCalls.inc"
#include "Timer0.inc"
#include "PowerManagement.inc"
#include "Smps.inc"
radix decimal
Smps code
global enableSmps
global enableSmpsHighPowerMode
global disableSmps
global disableSmpsHighPowerMode
global isSmpsEnabled
enableSmpsHighPowerMode:
.safelySetBankFor enableSmpsHighPowerModeCount
incf enableSmpsHighPowerModeCount
decfsz enableSmpsHighPowerModeCount, W
goto enableSmps
bsf smpsFlags, SMPS_FLAG_HIGHPOWERMODE
enableSmps:
.safelySetBankFor SMPS_TRIS
bsf SMPS_TRIS, SMPS_EN_PIN_TRIS
.setBankFor enableSmpsCount
incf enableSmpsCount
decfsz enableSmpsCount, W
return
firstTimeSmpsHasBeenEnabled:
bsf smpsFlags, SMPS_FLAG_WAITFORSTABLEVDD
storeTimer0 smpsEnabledTimestamp
fcall ensureFastClock
tcall preventSleep
disableSmpsHighPowerMode:
.safelySetBankFor enableSmpsHighPowerModeCount
decfsz enableSmpsHighPowerModeCount
goto disableSmps
bsf smpsFlags, SMPS_FLAG_HIGHPOWERMODE
disableSmps:
.safelySetBankFor enableSmpsCount
decfsz enableSmpsCount
return
bcf smpsFlags, SMPS_FLAG_VDDSTABLE
bcf smpsFlags, SMPS_FLAG_WAITFORSTABLEVDD
.setBankFor SMPS_TRIS
bcf SMPS_TRIS, SMPS_EN_PIN_TRIS
.setBankFor SMPS_PORT
bcf SMPS_PORT, SMPS_EN_PIN
.setBankFor PIC_VDD_PORT
bcf PIC_VDD_PORT, PIC_VDD_SMPS_EN_PIN
.setBankFor PIC_VDD_TRIS
bcf PIC_VDD_TRIS, PIC_VDD_SMPS_EN_PIN_TRIS
return
isSmpsEnabled:
.safelySetBankFor smpsFlags
btfss smpsFlags, SMPS_FLAG_VDDSTABLE
retlw 0
retlw 1
end
|
; size_t dtoe(double x, char *buf, uint16_t prec, uint16_t flag)
SECTION code_stdlib
PUBLIC dtoe
EXTERN asm_dtoe, dread1b
dtoe:
ld hl,13
add hl,sp
call dread1b
pop af
pop bc
pop de
pop hl
push hl
push de
push bc
push af
jp asm_dtoe
|
.org $8000 ;code starts at $8000
;LABEL DEFINITIONS
PORTB = $6000
PORTA = $6001
DDRB = $6002
DDRA = $6003
E = %10000000
RW = %01000000
RS = %00100000
L = %00000001
reset:
;resets the processor
ldx #$ff;Reset stack pointer
txs
LDA #%11111111 ;set portB pins to output
STA DDRB
LDA #%11100001 ;set top 3 portA pins to output, plus light
STA DDRA
;Set up LCD
LDA #%00111000 ;8-bit mode, 2-line display, 5x8 font
jsr lcd_instruction
lda #%00001110 ;Display on, Cursor on, blink off
jsr lcd_instruction
lda #%00000110 ;Increment and shift cursor but not display
jsr lcd_instruction
lda #%00000001 ;Clear the display (In case this was triggered by resetting) of a reset
jsr lcd_instruction
lda #%00000010
jsr lcd_instruction
ldx #0
print:
lda message,x
beq done
jsr lcd_char
inx
jmp print
LDA #L
STA PORTA
LDX #$ff
LDY #$FF
loop:
DEX
BNE loop
DEY
BNE loop
ADC #1
AND #%00000001
STA PORTA
jmp loop
done:
jmp done
message: .asciiz "Hello, Maya!" ;DO NOT PUT THIS AT START OF CODE!!
;LCD SUBROUTINES
lcd_wait:
;Checks the LCD busy flag until it's not set.
pha ;don't overwrite the A register
lda #%00000000 ;set PORTB to input
sta DDRB
lcd_busy:
lda #(RW) ;Send Instruction
sta PORTA
lda #(RW | E)
sta PORTA
lda PORTB
and #%10000000 ; We only care about the busy flag
bne lcd_busy;if it's set, keep looping. Otherwise, the LCD is ready.
lda #(RW | L) ;Clear E bit
sta PORTA
lda #%11111111 ;set PORTB to output
sta DDRB
pla
rts
lcd_instruction:
;Sends an Instruction to the LCD
jsr lcd_wait ;wait until the LCD is available
sta PORTB
;Clear RS/RW/E, then Set E bit, then clear all.
lda #L
sta PORTA
lda #(E | L)
sta PORTA
lda #L
sta PORTA
rts
lcd_char:
;Sends a Character to the LCD
jsr lcd_wait ;wait until the LCD is available
sta PORTB
;Set RS, Clear RW/E, then Set E bit, then clear E bit.
lda #(RS | L)
STA PORTA
lda #(RS | E | L)
sta PORTA
lda #(RS | L)
sta PORTA
rts
;RESET VECTORS
.org $fffc
.word reset
.word $0000 ;pad it out to 32kb |
;
; buffer management for MSDOS
;
INCLUDE DOSSEG.ASM
CODE SEGMENT BYTE PUBLIC 'CODE'
ASSUME SS:DOSGROUP,CS:DOSGROUP
.xlist
.xcref
INCLUDE DOSSYM.ASM
INCLUDE DEVSYM.ASM
.cref
.list
i_need BuffHead,DWORD
i_need PreRead,WORD
i_need LastBuffer,DWORD
i_need CurBuf,DWORD
i_need WPErr,BYTE
SUBTTL SETVISIT,SKIPVISIT -- MANAGE BUFFER SCANS
PAGE
procedure SETVISIT,near
ASSUME DS:NOTHING,ES:NOTHING
; Inputs:
; None
; Function:
; Set up a scan of I/O buffers
; Outputs:
; All visit flags = 0
; NOTE: This pre-scan is needed because a hard disk error
; may cause a scan to stop in the middle leaving some
; visit flags set, and some not set.
; DS:DI Points to [BUFFHEAD]
; No other registers altered
LDS DI,[BUFFHEAD]
PUSH AX
XOR AX,AX
SETLOOP:
MOV [DI.VISIT],AL
LDS DI,[DI.NEXTBUF]
CMP DI,-1
JNZ SETLOOP
LDS DI,[BUFFHEAD]
POP AX
return
entry SKIPVISIT
ASSUME DS:NOTHING,ES:NOTHING
; Inputs:
; DS:DI Points to a buffer
; Function:
; Skip visited buffers
; Outputs:
; DS:DI Points to next unvisited buffer
; Zero is set if skip to LAST buffer
; No other registers altered
CMP DI,-1
retz
CMP [DI.VISIT],1
retnz
LDS DI,[DI.NEXTBUF]
JMP SHORT SKIPVISIT
return
SetVisit ENDP
SUBTTL SCANPLACE, PLACEBUF -- PUT A BUFFER BACK IN THE POOL
PAGE
procedure ScanPlace,near
ASSUME DS:NOTHING,ES:NOTHING
; Inputs:
; Same as PLACEBUF
; Function:
; Save scan location and call PLACEBUF
; Outputs:
; DS:DI Points to saved scan location
; SI destroyed, other registers unchanged
PUSH ES
LES SI,[DI.NEXTBUF] ; Save scan location
CALL PLACEBUF
PUSH ES
POP DS ; Restore scan location
MOV DI,SI
POP ES
return
ScanPlace ENDP
NRETJ: JMP SHORT NRET
procedure PLACEBUF,NEAR
ASSUME DS:NOTHING,ES:NOTHING
; Input:
; DS:DI points to buffer
; Function:
; Remove buffer from queue and re-insert it in proper place.
; If buffer doesn't go at end, and isn't free, decrement
; priorities.
; NO registers altered
;
; DS:SI -- Curbuf, current buffer in list
; ES:DI -- Buf, buffer passed as argument
; BP:CX -- Pointsave, saved Buf.nextbuf
; DX:BX -- Lastbuf, previous buffer in list
; AL -- Inserted, Buf has been inserted
; AH -- Removed, Buf has been removed
IF IBM
IF NOT IBM
invoke save_world
XOR AX,AX ; Inserted = Removed = FALSE
LES CX,[DI.NEXTBUF]
MOV BP,ES ; Pointsave = Buf.nextbuf
MOV SI,DS
MOV ES,SI ; Buf is ES:DI
LDS SI,[BUFFHEAD] ; Curbuf = HEAD
CALL POINTCOMP ; Buf == HEAD?
JNZ TNEWHEAD
CMP CX,-1 ; Buf is LAST?
JZ NRETJ ; Only one buffer, nothing to do
MOV WORD PTR [BUFFHEAD],CX
MOV WORD PTR [BUFFHEAD+2],BP ; HEAD = Pointsave
INC AH ; Removed = TRUE
MOV DS,BP
MOV SI,CX ; Curbuf = HEAD
TNEWHEAD:
MOV BL,ES:[DI.BUFPRI]
CMP BL,[SI.BUFPRI]
JGE BUFLOOP
NEWHEAD: ; If Buf.pri < HEAD.pri
MOV WORD PTR ES:[DI.NEXTBUF],SI
MOV WORD PTR ES:[DI.NEXTBUF+2],DS ; Buf.nextbuf = HEAD
MOV WORD PTR [BUFFHEAD],DI
MOV WORD PTR [BUFFHEAD+2],ES ; HEAD = Buf
INC AL ; Inserted = TRUE
OR AH,AH
JNZ NRET ; If Removed == TRUE
BUFLOOP:
PUSH DS
PUSH SI
LDS SI,[SI.NEXTBUF]
CALL POINTCOMP
POP SI
POP DS
JNZ TESTINS
MOV WORD PTR [SI.NEXTBUF],CX ; If Curbuf.nextbuf == buf
MOV WORD PTR [SI.NEXTBUF+2],BP ; Curbuf.nextbuf = Pointsave
INC AH ; Removed = TRUE
OR AL,AL
JNZ SHUFFLE ; If Inserted == TRUE
TESTINS:
OR AL,AL
JNZ LOOKBUF
PUSH CX ; If NOT Inserted
MOV CL,ES:[DI.BUFPRI]
CMP CL,[SI.BUFPRI]
POP CX
JGE LOOKBUF
PUSH DS ; If Buf.pri < Curbuf.pri
MOV DS,DX
MOV WORD PTR [BX.NEXTBUF],DI
MOV WORD PTR [BX.NEXTBUF+2],ES ; Lastbuf.nextbuf = Buf
POP DS
MOV WORD PTR ES:[DI.NEXTBUF],SI
MOV WORD PTR ES:[DI.NEXTBUF+2],DS ; Buf.nextbuf = Curbuf
INC AL ; Inserted = TRUE
OR AH,AH
JNZ SHUFFLE ; If Removed == TRUE
LOOKBUF:
MOV BX,SI
MOV DX,DS ; Lastbuf = Curbuf
CMP WORD PTR [SI.NEXTBUF],-1
JZ ISLAST
LDS SI,[SI.NEXTBUF] ; Curbuf = Curbuf.nextbuf
JMP SHORT BUFLOOP
ISLAST: ; If Curbuf is LAST
MOV WORD PTR [SI.NEXTBUF],DI
MOV WORD PTR [SI.NEXTBUF+2],ES ; Curbuf.nextbuf = Buf
MOV WORD PTR ES:[DI.NEXTBUF],-1
MOV WORD PTR ES:[DI.NEXTBUF+2],-1 ; Buf is LAST
NRET:
invoke restore_world
return
SHUFFLE:
LDS DI,[BUFFHEAD]
DECLOOP:
CMP [DI.BUFPRI],FREEPRI
JZ NODEC
DEC [DI.BUFPRI]
NODEC:
LDS DI,[DI.NEXTBUF]
CMP DI,-1
JNZ DECLOOP
JMP SHORT NRET
ENDIF
ENDIF
invoke save_world
LES CX,[DI.NEXTBUF]
CMP CX,-1 ; Buf is LAST?
JZ NRET ; Buffer already last
MOV BP,ES ; Pointsave = Buf.nextbuf
PUSH DS
POP ES ; Buf is ES:DI
LDS SI,[BUFFHEAD] ; Curbuf = HEAD
CALL POINTCOMP ; Buf == HEAD?
JNZ BUFLOOP
MOV WORD PTR [BUFFHEAD],CX
MOV WORD PTR [BUFFHEAD+2],BP ; HEAD = Pointsave
JMP SHORT LOOKEND
BUFLOOP:
PUSH DS
PUSH SI
LDS SI,[SI.NEXTBUF]
CALL POINTCOMP
JZ GOTTHEBUF
POP AX
POP AX
JMP SHORT BUFLOOP
GOTTHEBUF:
POP SI
POP DS
MOV WORD PTR [SI.NEXTBUF],CX ; If Curbuf.nextbuf == buf
MOV WORD PTR [SI.NEXTBUF+2],BP ; Curbuf.nextbuf = Pointsave
LOOKEND:
PUSH DS
PUSH SI
LDS SI,[SI.NEXTBUF]
CMP SI,-1
JZ GOTHEEND
POP AX
POP AX
JMP SHORT LOOKEND
GOTHEEND:
POP SI
POP DS
MOV WORD PTR [SI.NEXTBUF],DI
MOV WORD PTR [SI.NEXTBUF+2],ES ; Curbuf.nextbuf = Buf
MOV WORD PTR ES:[DI.NEXTBUF],-1
MOV WORD PTR ES:[DI.NEXTBUF+2],-1 ; Buf is LAST
NRET:
invoke restore_world
return
PLACEBUF ENDP
procedure PLACEHEAD,NEAR
ASSUME DS:NOTHING,ES:NOTHING
; SAME AS PLACEBUF except places buffer at head
invoke save_world
PUSH DS
POP ES
LDS SI,[BUFFHEAD]
MOV WORD PTR [BUFFHEAD],DI
MOV WORD PTR [BUFFHEAD+2],ES
MOV WORD PTR ES:[DI.NEXTBUF],SI
MOV WORD PTR ES:[DI.NEXTBUF+2],DS
LOOKEND2:
PUSH DS
PUSH SI
LDS SI,[SI.NEXTBUF]
CALL POINTCOMP
JZ GOTHEEND2
POP AX
POP AX
JMP SHORT LOOKEND2
GOTHEEND2:
POP SI
POP DS
MOV WORD PTR [SI.NEXTBUF],-1
MOV WORD PTR [SI.NEXTBUF+2],-1 ; Buf is LAST
JMP SHORT NRET
PLACEHEAD ENDP
SUBTTL POINTCOMP -- 20 BIT POINTER COMPARE
PAGE
procedure PointComp,NEAR
ASSUME DS:NOTHING,ES:NOTHING
; Compare DS:SI to ES:DI (or DS:DI to ES:SI) for equality
; DO NOT USE FOR < or >
; No Registers altered
CMP SI,DI
retnz
PUSH CX
PUSH DX
MOV CX,DS
MOV DX,ES
CMP CX,DX
POP DX
POP CX
return
PointComp ENDP
SUBTTL GETBUFFR -- GET A SECTOR INTO A BUFFER
PAGE
procedure GETBUFFR,NEAR
ASSUME DS:DOSGROUP,ES:NOTHING
; Input:
; AH = Priority buffer is to have
; AL = 0 means sector must be pre-read
; ELSE no pre-read
; DX = Desired physical sector number
; ES:BP = Pointer to drive parameters
; Function:
; Get the specified sector into one of the I/O buffers
; And shuffle the queue
; Output:
; [CURBUF] Points to the Buffer for the sector
; DX,ES:BP unchanged, all other registers destroyed
XOR SI,SI
entry GETBUFFRB
MOV [PREREAD],AX
MOV AL,ES:[BP.dpb_drive]
LDS DI,[LASTBUFFER]
ASSUME DS:NOTHING
CMP DI,-1 ; Recency pointer valid?
JZ SKBUF ; No
CMP DX,[DI.BUFSECNO]
JNZ SKBUF ; Wrong sector
CMP AL,[DI.BUFDRV]
JNZ SKBUF ; Wrong Drive
JMP SHORT JUSTBUF ; Just asked for same buffer
SKBUF:
LDS DI,[BUFFHEAD]
NXTBFF:
CMP DX,[DI.BUFSECNO]
JNZ BUMP
CMP AL,[DI.BUFDRV]
JNZ BUMP
JMP SHORT SETINF
BUMP:
LDS DI,[DI.NEXTBUF]
CMP DI,-1
JNZ NXTBFF
LDS DI,[BUFFHEAD]
PUSH SI
PUSH DX
PUSH BP
PUSH ES
CALL BUFWRITE ; Write out the dirty buffer
POP ES
POP BP
POP DX
POP SI
RDSEC: ; Read in the new sector
TEST BYTE PTR [PREREAD],-1
JNZ SETBUF
LEA BX,[DI.BufInSiz] ; Point at buffer
MOV CX,1
PUSH SI
PUSH DI
PUSH DX
OR SI,SI
JZ NORMSEC
invoke FATSECRD
JMP SHORT GOTTHESEC ; Buffer is marked free if read barfs
NORMSEC:
invoke DREAD ; Buffer is marked free if read barfs
GOTTHESEC:
POP DX
POP DI
POP SI
SETBUF:
MOV [DI.BUFSECNO],DX
MOV WORD PTR [DI.BUFDRVDP],BP
MOV WORD PTR [DI.BUFDRVDP+2],ES
XOR AH,AH
MOV AL,ES:[BP.dpb_drive]
MOV WORD PTR [DI.BUFDRV],AX
SETINF:
MOV AX,1 ; Default to not a FAT sector
OR SI,SI
JZ SETSTUFFOK
MOV AL,ES:[BP.dpb_FAT_count]
MOV AH,ES:[BP.dpb_FAT_size]
SETSTUFFOK:
MOV WORD PTR [DI.BUFWRTCNT],AX
CALL PLACEBUF
JUSTBUF:
MOV WORD PTR [CURBUF+2],DS
MOV WORD PTR [LASTBUFFER+2],DS
PUSH SS
POP DS
ASSUME DS:DOSGROUP
MOV WORD PTR [CURBUF],DI
MOV WORD PTR [LASTBUFFER],DI
return
GETBUFFR ENDP
SUBTTL FLUSHBUF -- WRITE OUT DIRTY BUFFERS
PAGE
procedure FlushBuf,NEAR
ASSUME DS:DOSGROUP,ES:NOTHING
; Input:
; DS = DOSGROUP
; AL = Physical unit number
; = -1 for all units
; Function:
; Write out all dirty buffers for unit, and flag them as clean
; DS Preserved, all others destroyed (ES too)
LDS DI,[BUFFHEAD]
ASSUME DS:NOTHING
MOV AH,-1
NXTBUFF:
CMP [DI.BUFDRV],AH
JZ SKIPBFF ; Skip free buffers
CMP AH,AL
JZ DOBUFFER ; Do all dirty buffers
CMP AL,[DI.BUFDRV]
JNZ SKIPBFF ; Buffer not for this unit
DOBUFFER:
CMP BYTE PTR [DI.BUFDIRTY],0
JZ SKIPBFF ; Buffer not dirty
PUSH AX
PUSH WORD PTR [DI.BUFDRV]
CALL BUFWRITE
POP AX
XOR AH,AH ; Buffer is clean
CMP AL,BYTE PTR [WPERR]
JNZ NOZAP
MOV AL,0FFH ; Invalidate buffer, it is inconsistent
NOZAP:
MOV WORD PTR [DI.BUFDRV],AX
POP AX ; Search info
SKIPBFF:
LDS DI,[DI.NEXTBUF]
CMP DI,-1
JNZ NXTBUFF
PUSH SS
POP DS
return
FlushBuf ENDP
SUBTTL BUFWRITE -- WRITE OUT A BUFFER IF DIRTY
PAGE
procedure BufWrite,NEAR
ASSUME DS:NOTHING,ES:NOTHING
; Input:
; DS:DI Points to the buffer
; Function:
; Write out all the buffer if dirty.
; Output:
; Buffer marked free
; DS:DI Preserved, ALL others destroyed (ES too)
MOV AX,00FFH
XCHG AX,WORD PTR [DI.BUFDRV] ; Free, in case write barfs
CMP AL,0FFH
retz ; Buffer is free.
OR AH,AH
retz ; Buffer is clean.
CMP AL,BYTE PTR [WPERR]
retz ; If in WP error zap buffer
LES BP,[DI.BUFDRVDP]
LEA BX,[DI.BufInSiz] ; Point at buffer
MOV DX,[DI.BUFSECNO]
MOV CX,WORD PTR [DI.BUFWRTCNT]
MOV AL,CH ; [DI.BUFWRTINC]
XOR CH,CH
MOV AH,CH
PUSH DI
WRTAGAIN:
PUSH CX
PUSH AX
MOV CX,1
PUSH BX
PUSH DX
invoke DWRITE ; Write out the dirty buffer
POP DX
POP BX
POP AX
POP CX
ADD DX,AX
LOOP WRTAGAIN
POP DI
return
BufWrite ENDP
do_ext
CODE ENDS
END
|
;-------------------------------
!zone
;-- clear screen using space characters
;--
clear_screen
lda #$20 ;-- space character
ldx #$00
.loop
sta SCR_BASE, x
sta SCR_BASE + $100, x
sta SCR_BASE + $200, x
sta SCR_BASE + $300, x
dex
bne .loop
rts
;-------------------------------
!zone
;-- clear color ram
;-- color has to be in A
;--
clear_color_ram
ldx #$00
.loop
sta $D800, x
sta $D900, x
sta $DA00, x
sta $DB00, x
dex
bne .loop
rts
;-------------------------------
!zone
;-- initialize screen stuff
;--
init_screen
;-- set screen colors to black
lda #BLK
sta $D020
sta $D021
;-- select VICBANK
lda $DD00
and #%11111100
ora #%00000010 ;-- xxxxxx10 = vic bank 1 at $4000-$7FFF
sta $DD00
;-- memory setup
lda $D018
and #%11110001
ora #%00000010 ;-- xxxx001x = char memory in $0800-$0FFF + VICBANK
;--sta $D018
;--lda $D018
and #%00001111
ora #%00000000 ;-- 0000xxxx = screen memory in $0000-$03FF + VICBANK
sta $D018
;-- reset sprites
lda #0
sta SPRITE_XF
sta SPR_ENAB
rts
;-------------------------------
!zone
;-- turn off screen
;--
turn_off_screen
lda $D011
and #%01101111 ;-- bit #7 = bit #8 of irq raster line, bit #4 = screen off/on
sta $D011
rts
;-- turn screen back on
;--
turn_on_screen
lda $D011
ora #%00010000
and #%01111111 ;-- always clear bit #8 of irq raster line
sta $D011
rts
;-------------------------------
!zone
turn_off_runstop_restore
lda #$C1
sta $0318
lda #$FE
sta $0319
rts
turn_off_charset_toggle ;-- shift + cbm
lda #$80
sta $0291
rts
;-------------------------------
!zone
copy_charset
sei
;-- make original charset visible to RAM
lda $01
and #%11111011
sta $01
;-- copy original charset to CHR_BASE
+MEMCOPY_HUGE $D000, $D800, CHR_BASE
;-- make original charset invisible again
lda $01
ora #%00000100
sta $01
cli
rts
;-------------------------------
!zone
get_joy_dir
lda $DC00 ;-- read joystick port 2
and #%00011111
cmp #%00011111 ;-- check for neutral position
beq .no_joy
;-- only write if it's a clear direction (no diagonals)
cmp #%00011011
bne +
lda #DIR_LEFT
rts
+ cmp #%00010111
bne +
lda #DIR_RIGHT
rts
+ cmp #%00011110
bne +
lda #DIR_UP
rts
+ cmp #%00011101
bne .no_joy
lda #DIR_DOWN
rts
.no_joy
lda #DIR_STOP
rts
;-------------------------------
!zone
;-- print string on screen
;--
invertmask !byte 0
print_str
clc
adc #<SCR_BASE
sta .o2 +1
sta .o3 +1 ;-- delta for LSB is 0
tya
adc #>SCR_BASE
sta .o2 +2
adc #(>COL_BASE) - (>SCR_BASE)
sta .o3 +2
ldx #$00
.loop
oo1 lda $FFFF, x
ora invertmask
cmp #$FF
beq .end
.o2 sta SCR_BASE, x
oo2 lda #$FF
.o3 sta COL_BASE, x
inx
jmp .loop
.end
rts
!macro STRING_OUTPUT .straddr, .x, .y, .c {
lda #<.straddr
sta oo1 +1
lda #>.straddr
sta oo1 +2
lda #.c
sta oo2 +1
lda #<(.x + .y * 40)
ldy #>(.x + .y * 40)
jsr print_str
}
!macro STRING_OUTPUT_INV .straddr, .x, .y, .c {
lda #%10000000
sta invertmask
+STRING_OUTPUT .straddr, .x, .y, .c
lda #$00
sta invertmask
}
!macro STRING_OUTPUT .straddr, .x, .y {
sta oo2 +1 ;-- color
lda #<.straddr
sta oo1 +1
lda #>.straddr
sta oo1 +2
lda #<(.x + .y * 40)
ldy #>(.x + .y * 40)
jsr print_str
}
straddr !word 0
.scraddr !word 0
HIGH = $22
LOW = $21
;-- non-macro version
;-- x and y have to be in x and y
;-- string address has to be put into straddr
;-- color has to be in a
string_output
sta oo2 +1 ;-- color
lda #0
sta HIGH
lda straddr
sta oo1 +1
lda straddr +1
sta oo1 +2
;-- y * 40
tya
sta LOW ;-- *1
asl
asl ;-- *4, carry clear (0..24 * 4)
adc LOW ;-- *5
asl
asl ;-- *20
rol HIGH ;-- save carry
asl ;-- *40
rol HIGH ;-- save carry
sta LOW
txa
adc LOW ;-- add X
sta LOW
lda HIGH
adc #$0
sta HIGH
;-- call the string function
lda LOW
ldy HIGH
jsr print_str
rts
|
[bits 32]
[extern main]
call main
jmp $ |
;
; This is free and unencumbered software released into the public domain.
;
; Anyone is free to copy, modify, publish, use, compile, sell, or
; distribute this software, either in source code form or as a compiled
; binary, for any purpose, commercial or non-commercial, and by any
; means.
; In jurisdictions that recognize copyright laws, the author or authors
; of this software dedicate any and all copyright interest in the
; software to the public domain. We make this dedication for the benefit
; of the public at large and to the detriment of our heirs and
; successors. We intend this dedication to be an overt act of
; relinquishment in perpetuity of all present and future rights to this
; software under copyright law.
;
; 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 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.
;
; For more information, please refer to <http://unlicense.org/>
;
; -----------------------------------------------
; AES-128 Encryption in AMD64 assembly
;
; -----------------------------------------------
;
bits 64
global aes_ecb_asm
; windows is defined by default
%define WIN
%ifdef WIN
; Microsoft x64 fastcall convention
%define arg_0 rcx
%define arg_1 rdx
%define arg_2 r8
%define arg_3 r9
%else
; Linux AMD64 calling convention
%define arg_0 rdi
%define arg_1 rsi
%define arg_2 rdx
%define arg_3 rcx
%endif
; *****************************
; void aes_ecb_asm(void *s)
; *****************************
aes_ecb_asm:
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
push rbp
push arg_0
pop rsi
xor ecx, ecx ; ecx = 0
mul ecx ; eax = 0, edx = 0
inc eax ; c = 1
mov cl, 4
sub rsp, 32 ; alloca(32)
; F(8)x[i]=((W*)s)[i]
push rsp
pop rdi
push rcx
push rsi
push rdi
rep movsq
pop rdi
pop rsi
pop rcx
; *****************************
; Multiplication over GF(2**8)
; *****************************
call $+21 ; save address
gf_mul:
push rcx ; save ecx
mov cl, 4 ; 4 bytes
add al, al ; al <<= 1
jnc $+4 ;
xor al, 27 ;
ror eax, 8 ; rotate for next byte
loop $-9 ;
pop rcx ; restore ecx
ret
pop rbp
enc_main:
; *****************************
; AddRoundKey, AddRoundConstant, ExpandRoundKey
; *****************************
; w=k[3];F(4)w=(w&-256)|S(w),w=R(w,8),((W*)s)[i]=x[i]^k[i]
; w=R(w,8)^c;F(4)w=k[i]^=w
push rax
push rcx
push rdx
push rsi
push rdi
xchg eax, edx
xchg rsi, rdi
mov eax, [rsi+16+12] ; w=R(k[3],8)
ror eax, 8
xor_key:
mov ebx, [rsi+16] ; t=k[i]
xor [rsi], ebx ; x[i]^=t
movsd ; s[i]=x[i]
; w=(w&-256)|S(w)
call S ; al=S(al)
ror eax, 8 ; w=R(w,8)
loop xor_key
; w=R(w,8)^c;
xor eax, edx ; w^=c
; F(4)w=k[i]^=w;
mov cl, 4
exp_key:
xor [rsi], eax ; k[i]^=w
lodsd ; w=k[i]
loop exp_key
pop rdi
pop rsi
pop rdx
pop rcx
pop rax
; ****************************
; if(c==108) break;
cmp al, 108
jne upd_con
add rsp, 32
pop rbp
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
ret
upd_con:
call rbp
; ***************************
; ShiftRows and SubBytes
; ***************************
; F(16)((B*)x)[(i%4)+(((i/4)-(i%4))%4)*4]=S(((B*)s)[i])
push rax
push rsi
shift_rows:
lodsb ; al = S(s[i])
call S
mov [rdi+rdx], al
sub edx, 3
and edx, 15
jnz shift_rows
pop rsi
pop rax
; *****************************
; if(c!=108){
cmp al, 108
je enc_main
; *****************************
; MixColumns
; *****************************
; F(4)w=x[i],x[i]=R(w,8)^R(w,16)^R(w,24)^M(R(w,8)^w)
push rax
push rcx
push rdx
push rdi
mix_cols:
mov eax, [rdi] ; w0 = x[i]
mov ebx, eax ; w1 = w0
ror eax, 8 ; w0 = R(w0,8)
mov edx, eax ; w2 = w0
xor eax, ebx ; w0^= w1
call rbp ; w0 = M(w0)
xor eax, edx ; w0^= w2
ror ebx, 16 ; w1 = R(w1,16)
xor eax, ebx ; w0^= w1
ror ebx, 8 ; w1 = R(w1,8)
xor eax, ebx ; w0^= w1
stosd ; x[i] = w0
loop mix_cols
pop rdi
pop rdx
pop rcx
pop rax
jmp enc_main
; *****************************
; B SubByte(B x)
; *****************************
S:
%ifndef DYNAMIC
push rbx
call init_sbox
db 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5
db 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76
db 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0
db 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0
db 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc
db 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15
db 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a
db 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75
db 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0
db 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84
db 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b
db 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf
db 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85
db 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8
db 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5
db 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2
db 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17
db 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73
db 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88
db 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb
db 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c
db 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79
db 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9
db 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08
db 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6
db 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a
db 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e
db 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e
db 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94
db 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf
db 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68
db 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
init_sbox:
pop rbx
xlatb
pop rbx
%else
push rax
push rcx
push rdx
test al, al # if(x){
jz sb_l6
xchg eax, edx
mov cl, -1 # i=255
; for(c=i=0,y=1;--i;y=(!c&&y==x)?c=1:y,y^=M(y))
sb_l0:
mov al, 1 # y=1
sb_l1:
test ah, ah # !c
jnz sb_l2
cmp al, dl # y!=x
setz ah
jz sb_l0
sb_l2:
mov dh, al # y^=M(y)
call M #
xor al, dh
loop sb_l1 # --i
; F(4)x^=y=(y<<1)|(y>>7);
mov dl, al # dl=y
mov cl, 4 # i=4
sb_l5:
rol dl, 1 # y=R(y,1)
xor al, dl # x^=y
loop sb_l5 # i--
sb_l6:
xor al, 99 # return x^99
mov [rsp+16], al
pop rdx
pop rcx
pop rax
%endif
ret
%ifdef CTR
global aes_ctr
; void aes_ctr(W len, B *ctr, B *in, B *key)
aes_ctr:
push rbx
push rbp
push rsi
push rdi
push arg_1 ; rsi/rcx or ctr
pop rbp
push arg_3 ; rcx/rdx or key
pop rsi
push arg_0 ; rdi/r8 or len
pop rcx
push arg_2 ; rdx/r9 or in
pop rdx
sub rsp, 32 ; alloca(32)
; copy master key to local buffer
; F(16)t[i+16]=key[i];
lea rdi, [rsp+16] ; edi = &t[16]
movsq
movsq
aes_l0:
xor eax, eax
jecxz aes_l3 ; while(len){
; copy counter+nonce to local buffer
; F(16)t[i]=ctr[i]
push rsp
pop rdi
push rbp
pop rsi
push rdi
movsq
movsq
pop rdi
; encrypt t
call aes_ecb_asm ; E(t)
aes_l1:
; xor plaintext with ciphertext
; r=len>16?16:len
; F(r)in[i]^=t[i]
mov bl, [rdi+rax] ;
xor [rdx], bl ; *in++^=t[i]
inc rdx
add al, 1
cmp al, 16 ;
loopne aes_l1 ; while(i!=16 && --ecx!=0)
; update counter
xchg eax, ecx ;
mov cl, 16
aes_l2:
inc byte[rbp+rcx-1] ;
loopz aes_l2 ; while(++c[i]==0 && --ecx!=0)
xchg eax, ecx
jmp aes_l0
aes_l3:
add rsp, 32
pop rdi
pop rsi
pop rbp
pop rbx
ret
%endif
|
; A000297: a(n) = (n+1)*(n+3)*(n+8)/6.
; 0,4,12,25,44,70,104,147,200,264,340,429,532,650,784,935,1104,1292,1500,1729,1980,2254,2552,2875,3224,3600,4004,4437,4900,5394,5920,6479,7072,7700,8364,9065,9804,10582,11400,12259,13160,14104,15092,16125,17204,18330,19504,20727,22000,23324,24700,26129,27612,29150,30744,32395,34104,35872,37700,39589,41540,43554,45632,47775,49984,52260,54604,57017,59500,62054,64680,67379,70152,73000,75924,78925,82004,85162,88400,91719,95120,98604,102172,105825,109564,113390,117304,121307,125400,129584,133860,138229,142692,147250,151904,156655,161504,166452,171500,176649,181900,187254,192712,198275,203944,209720,215604,221597,227700,233914,240240,246679,253232,259900,266684,273585,280604,287742,295000,302379,309880,317504,325252,333125,341124,349250,357504,365887,374400,383044,391820,400729,409772,418950,428264,437715,447304,457032,466900,476909,487060,497354,507792,518375,529104,539980,551004,562177,573500,584974,596600,608379,620312,632400,644644,657045,669604,682322,695200,708239,721440,734804,748332,762025,775884,789910,804104,818467,833000,847704,862580,877629,892852,908250,923824,939575,955504,971612,987900,1004369,1021020,1037854,1054872,1072075,1089464,1107040,1124804,1142757,1160900,1179234,1197760,1216479,1235392,1254500,1273804,1293305,1313004,1332902,1353000,1373299,1393800,1414504,1435412,1456525,1477844,1499370,1521104,1543047,1565200,1587564,1610140,1632929,1655932,1679150,1702584,1726235,1750104,1774192,1798500,1823029,1847780,1872754,1897952,1923375,1949024,1974900,2001004,2027337,2053900,2080694,2107720,2134979,2162472,2190200,2218164,2246365,2274804,2303482,2332400,2361559,2390960,2420604,2450492,2480625,2511004,2541630,2572504,2603627,2635000,2666624
mov $1,$0
add $0,5
bin $0,2
sub $0,3
mul $1,$0
div $1,3
|
; A209279: First inverse function (numbers of rows) for pairing function A185180.
; Submitted by Jon Maiga
; 1,1,2,2,1,3,2,3,1,4,3,2,4,1,5,3,4,2,5,1,6,4,3,5,2,6,1,7,4,5,3,6,2,7,1,8,5,4,6,3,7,2,8,1,9,5,6,4,7,3,8,2,9,1,10,6,5,7,4,8,3,9,2,10,1,11,6,7,5,8,4,9,3,10,2,11,1,12,7,6,8,5,9,4,10,3,11,2,12,1,13,7,8,6,9,5,10,4,11,3
seq $0,130328 ; Triangle of differences between powers of 2, read by rows.
seq $0,89215 ; Thue-Morse sequence on the integers.
sub $0,1
|
// Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2018-2019 The voi Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "bitcoingui.h"
#include "bitcoinunits.h"
#include "clientmodel.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "miner.h"
#include "networkstyle.h"
#include "notificator.h"
#include "openuridialog.h"
#include "optionsdialog.h"
#include "optionsmodel.h"
#include "rpcconsole.h"
#include "utilitydialog.h"
#include "toolspage.h"
#ifdef ENABLE_WALLET
#include "blockexplorer.h"
#include "walletframe.h"
#include "walletmodel.h"
#endif // ENABLE_WALLET
#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
#endif
#include "init.h"
#include "masternodelist.h"
#include "ui_interface.h"
#include "util.h"
#include "qssloader.h"
#include <iostream>
#include <QAction>
#include <QApplication>
#include <QDateTime>
#include <QDesktopWidget>
#include <QDragEnterEvent>
#include <QIcon>
#include <QListWidget>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QProgressBar>
#include <QProgressDialog>
#include <QSettings>
#include <QStackedWidget>
#include <QStatusBar>
#include <QStyle>
#include <QTimer>
#include <QToolBar>
#include <QVBoxLayout>
#include <QPalette>
#include <QPixmap>
#include <QFontDatabase>
#include <QFileInfo>
#if QT_VERSION < 0x050000
#include <QTextDocument>
#include <QUrl>
#else
#include <QUrlQuery>
#endif
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
BitcoinGUI::BitcoinGUI(const NetworkStyle* networkStyle, QWidget* parent) : QMainWindow(parent),
clientModel(0),
walletFrame(0),
labelStakingIcon(0),
labelEncryptionIcon(0),
labelConnectionsIcon(0),
labelBlocksIcon(0),
progressBarLabel(0),
progressBar(0),
progressDialog(0),
appMenuBar(0),
overviewAction(0),
historyAction(0),
masternodeAction(0),
quitAction(0),
sendCoinsAction(0),
usedSendingAddressesAction(0),
usedReceivingAddressesAction(0),
signMessageAction(0),
verifyMessageAction(0),
bip38ToolAction(0),
multisigCreateAction(0),
multisigSpendAction(0),
multisigSignAction(0),
aboutAction(0),
receiveCoinsAction(0),
optionsAction(0),
toggleHideAction(0),
encryptWalletAction(0),
backupWalletAction(0),
changePassphraseAction(0),
aboutQtAction(0),
openRPCConsoleAction(0),
openAction(0),
showHelpMessageAction(0),
multiSendAction(0),
trayIcon(0),
trayIconMenu(0),
notificator(0),
rpcConsole(0),
prevBlocks(0),
spinnerFrame(0)
{
/* Open CSS when configured */
this->setStyleSheet(GUIUtil::loadStyleSheet());
GUIUtil::restoreWindowGeometry("nWindow", QSize(1065, 670), this);
//this->setFixedSize(1065,670);
QFontDatabase::addApplicationFont(":/fonts/voi_font");
QString windowTitle = tr("voi Core") + " - ";
#ifdef ENABLE_WALLET
/* if compiled with wallet support, -disablewallet can still disable the wallet */
enableWallet = !GetBoolArg("-disablewallet", false);
#else
enableWallet = false;
#endif // ENABLE_WALLET
if (enableWallet) {
windowTitle += tr("Wallet");
} else {
windowTitle += tr("Node");
}
QString userWindowTitle = QString::fromStdString(GetArg("-windowtitle", ""));
if (!userWindowTitle.isEmpty()) windowTitle += " - " + userWindowTitle;
windowTitle += " " + networkStyle->getTitleAddText();
#ifndef Q_OS_MAC
QApplication::setWindowIcon(networkStyle->getAppIcon());
setWindowIcon(networkStyle->getAppIcon());
#else
MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
#endif
setWindowTitle(windowTitle);
#if defined(Q_OS_MAC) && QT_VERSION < 0x050000
// This property is not implemented in Qt 5. Setting it has no effect.
// A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
setUnifiedTitleAndToolBarOnMac(true);
#endif
rpcConsole = new RPCConsole(enableWallet ? this : 0);
#ifdef ENABLE_WALLET
if (enableWallet) {
/** Create wallet frame*/
walletFrame = new WalletFrame(this);
} else
#endif // ENABLE_WALLET
{
/* When compiled without wallet or -disablewallet is provided,
* the central widget is the rpc console.
*/
setCentralWidget(rpcConsole);
}
// Accept D&D of URIs
setAcceptDrops(true);
// Status bar notification icons
QFrame* frameBlocks = new QFrame();
frameBlocks->setContentsMargins(0, 0, 0, 0);
frameBlocks->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
QHBoxLayout* frameBlocksLayout = new QHBoxLayout(frameBlocks);
frameBlocksLayout->setContentsMargins(3, 0, 3, 0);
frameBlocksLayout->setSpacing(1);
labelStakingIcon = new QLabel();
labelEncryptionIcon = new QPushButton();
labelEncryptionIcon->setFlat(true); // Make the button look like a label, but clickable
labelEncryptionIcon->setObjectName(QStringLiteral("EncryptionIcon"));
labelEncryptionIcon->setFixedSize(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE);
labelEncryptionIcon->setIconSize(QSize(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelEncryptionIcon->setCursor(Qt::PointingHandCursor);
labelConnectionsIcon = new QPushButton();
labelConnectionsIcon->setFlat(true); // Make the button look like a label, but clickable
labelConnectionsIcon->setObjectName(QStringLiteral("ConnectionsIcon"));
labelConnectionsIcon->setFixedSize(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE);
labelConnectionsIcon->setIconSize(QSize(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelConnectionsIcon->setCursor(Qt::PointingHandCursor);
labelBlocksIcon = new QLabel();
labelBlocksIcon->setFixedSize(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE);
if (enableWallet) {
frameBlocksLayout->addWidget(labelEncryptionIcon);
}
frameBlocksLayout->addWidget(labelStakingIcon);
frameBlocksLayout->addWidget(labelBlocksIcon);
frameBlocksLayout->addWidget(labelConnectionsIcon);
frameBlocksLayout->setAlignment(Qt::AlignRight);
frameBlocksLayout->setSpacing(9);
// Progress bar and label for blocks download
progressBarLabel = new QLabel();
progressBarLabel->setObjectName(QStringLiteral("progressBarLabel"));
progressBarLabel->setVisible(true);
progressBar = new GUIUtil::ProgressBar();
progressBar->setVisible(true);
// Override style sheet for progress bar for styles that have a segmented progress bar,
// as they make the text unreadable (workaround for issue #1071)
// See https://qt-project.org/doc/qt-4.8/gallery.html
QString curStyle = QApplication::style()->metaObject()->className();
if (curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle") {
progressBar->setStyleSheet("QProgressBar { background-color: #F8F8F8; border: 1px solid black; border-radius: 0px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #00CCFF, stop: 1 #33CCFF); border-radius: 0px; margin: 0px; }");
}
//Put elements on bottom status bar
statusBar()->addWidget(progressBarLabel);
statusBar()->addWidget(progressBar);
statusBar()->setSizeGripEnabled(false);
// Create actions for the toolbar, menu bar and tray/dock icon
// Needs walletFrame to be initializeda
createActions(networkStyle);
// Create application menu bar
createMenuBar();
// Create the toolbars
createToolBars(frameBlocks);
// Create system tray icon and notification
createTrayIcon(networkStyle);
//create sync anymation
synctimer = new QTimer(this);
connect(synctimer, SIGNAL(timeout()), this, SLOT(updateSyncAnimation()));
synctimer->start(50);
// Jump directly to tabs in Toolpage
connect(openInfoAction, SIGNAL(triggered()), rpcConsole, SLOT(showInfo()));
connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(showConsole()));
connect(openNetworkAction, SIGNAL(triggered()), rpcConsole, SLOT(showNetwork()));
connect(openPeersAction, SIGNAL(triggered()), rpcConsole, SLOT(showPeers()));
connect(openRepairAction, SIGNAL(triggered()), rpcConsole, SLOT(showRepair()));
connect(openConfEditorAction, SIGNAL(triggered()), rpcConsole, SLOT(showConfEditor()));
connect(openMNConfEditorAction, SIGNAL(triggered()), rpcConsole, SLOT(showMNConfEditor()));
connect(showBackupsAction, SIGNAL(triggered()), rpcConsole, SLOT(showBackups()));
connect(labelConnectionsIcon, SIGNAL(clicked()), this, SLOT(showPeers()));
// Get restart command-line parameters and handle restart
connect(rpcConsole, SIGNAL(handleRestart(QStringList)), this, SLOT(handleRestart(QStringList)));
// prevents an open debug window from becoming stuck/unusable on client shutdown
connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));
connect(openBlockExplorerAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(openBlockExplorerAction, SIGNAL(triggered()), this, SLOT(gotoBlockExplorerPage()));
// Install event filter to be able to catch status tip events (QEvent::StatusTip)
this->installEventFilter(this);
// Initially wallet actions should be disabled
setWalletActionsEnabled(false);
// Subscribe to notifications from core
subscribeToCoreSignals();
//will be activate when pow ends
labelStakingIcon->hide();
QTimer* timerStakingIcon = new QTimer(labelStakingIcon);
connect(timerStakingIcon, SIGNAL(timeout()), this, SLOT(setStakingStatus()));
timerStakingIcon->start(10000);
setStakingStatus();
}
BitcoinGUI::~BitcoinGUI()
{
// Unsubscribe from notifications from core
unsubscribeFromCoreSignals();
GUIUtil::saveWindowGeometry("nWindow", this);
if (trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
trayIcon->hide();
#ifdef Q_OS_MAC
delete appMenuBar;
MacDockIconHandler::cleanup();
#endif
}
void BitcoinGUI::createActions(const NetworkStyle* networkStyle)
{
QActionGroup* tabGroup = new QActionGroup(this);
overviewAction = new QAction(QIcon(":/icons/overview"), "", this);
overviewAction->setStatusTip(tr("Show general overview of wallet"));
overviewAction->setToolTip(overviewAction->statusTip());
overviewAction->setCheckable(true);
#ifdef Q_OS_MAC
overviewAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_1));
#else
overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
#endif
tabGroup->addAction(overviewAction);
sendCoinsAction = new QAction(QIcon(":/icons/send"), "", this);
sendCoinsAction->setStatusTip(tr("Send coins to a voi address"));
sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
sendCoinsAction->setCheckable(true);
#ifdef Q_OS_MAC
sendCoinsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_2));
#else
sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
#endif
tabGroup->addAction(sendCoinsAction);
receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), "", this);
receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and voi: URIs)"));
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
receiveCoinsAction->setCheckable(true);
#ifdef Q_OS_MAC
receiveCoinsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_3));
#else
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
#endif
tabGroup->addAction(receiveCoinsAction);
historyAction = new QAction(QIcon(":/icons/history"), "", this);
historyAction->setStatusTip(tr("Browse transaction history"));
historyAction->setToolTip(historyAction->statusTip());
historyAction->setCheckable(true);
#ifdef Q_OS_MAC
historyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_4));
#else
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
#endif
tabGroup->addAction(historyAction);
toolsAction = new QAction(QIcon(":/icons/tools"), "", this);
toolsAction->setStatusTip(tr("Tools"));
toolsAction->setToolTip(toolsAction->statusTip());
toolsAction->setCheckable(true);
#ifdef Q_OS_MAC
toolsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_7));
#else
toolsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_7));
#endif
tabGroup->addAction(toolsAction);
#ifdef ENABLE_WALLET
QSettings settings;
if (settings.value("fShowMasternodesTab").toBool()) {
masternodeAction = new QAction(QIcon(":/icons/masternodes"), "", this);
masternodeAction->setStatusTip(tr("Browse masternodes"));
masternodeAction->setToolTip(masternodeAction->statusTip());
masternodeAction->setCheckable(true);
#ifdef Q_OS_MAC
masternodeAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_6));
#else
masternodeAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
#endif
tabGroup->addAction(masternodeAction);
connect(masternodeAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(masternodeAction, SIGNAL(triggered()), this, SLOT(gotoMasternodePage()));
}
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
// can be triggered from the tray menu, and need to show the GUI to be useful.
connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
connect(toolsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(toolsAction, SIGNAL(triggered()), this, SLOT(gotoToolsPage()));
#endif // ENABLE_WALLET
quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
quitAction->setStatusTip(tr("Quit application"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
quitAction->setMenuRole(QAction::QuitRole);
aboutAction = new QAction(networkStyle->getAppIcon(), tr("&About voi Core"), this);
aboutAction->setStatusTip(tr("Show information about voi Core"));
aboutAction->setMenuRole(QAction::AboutRole);
#if QT_VERSION < 0x050000
aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
#else
aboutQtAction = new QAction(QIcon(":/qt-project.org/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
#endif
aboutQtAction->setStatusTip(tr("Show information about Qt"));
aboutQtAction->setMenuRole(QAction::AboutQtRole);
optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
optionsAction->setStatusTip(tr("Modify configuration options for voi"));
optionsAction->setMenuRole(QAction::PreferencesRole);
toggleHideAction = new QAction(networkStyle->getAppIcon(), tr("&Show / Hide"), this);
toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
encryptWalletAction->setCheckable(true);
backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
unlockWalletAction = new QAction(tr("&Unlock Wallet..."), this);
unlockWalletAction->setToolTip(tr("Unlock wallet"));
lockWalletAction = new QAction(tr("&Lock Wallet"), this);
signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
signMessageAction->setStatusTip(tr("Sign messages with your voi addresses to prove you own them"));
verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);
verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified voi addresses"));
bip38ToolAction = new QAction(QIcon(":/icons/key"), tr("&BIP38 tool"), this);
bip38ToolAction->setToolTip(tr("Encrypt and decrypt private keys using a passphrase"));
multiSendAction = new QAction(QIcon(":/icons/edit"), tr("&MultiSend"), this);
multiSendAction->setToolTip(tr("MultiSend Settings"));
multiSendAction->setCheckable(true);
openInfoAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation), tr("&Information"), this);
openInfoAction->setStatusTip(tr("Show diagnostic information"));
openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug console"), this);
openRPCConsoleAction->setStatusTip(tr("Open debugging console"));
openNetworkAction = new QAction(QIcon(":/icons/connect_4"), tr("&Network Monitor"), this);
openNetworkAction->setStatusTip(tr("Show network monitor"));
openPeersAction = new QAction(QIcon(":/icons/connect_4"), tr("&Peers list"), this);
openPeersAction->setStatusTip(tr("Show peers info"));
openRepairAction = new QAction(QIcon(":/icons/options"), tr("Wallet &Repair"), this);
openRepairAction->setStatusTip(tr("Show wallet repair options"));
openConfEditorAction = new QAction(QIcon(":/icons/edit"), tr("Open Wallet &Configuration File"), this);
openConfEditorAction->setStatusTip(tr("Open configuration file"));
openMNConfEditorAction = new QAction(QIcon(":/icons/edit"), tr("Open &Masternode Configuration File"), this);
openMNConfEditorAction->setStatusTip(tr("Open Masternode configuration file"));
showBackupsAction = new QAction(QIcon(":/icons/browse"), tr("Show Automatic &Backups"), this);
showBackupsAction->setStatusTip(tr("Show automatically created wallet backups"));
usedSendingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Sending addresses..."), this);
usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
usedReceivingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Receiving addresses..."), this);
usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
multisigCreateAction = new QAction(QIcon(":/icons/address-book"), tr("&Multisignature creation..."), this);
multisigCreateAction->setStatusTip(tr("Create a new multisignature address and add it to this wallet"));
multisigSpendAction = new QAction(QIcon(":/icons/send"), tr("&Multisignature spending..."), this);
multisigSpendAction->setStatusTip(tr("Spend from a multisignature address"));
multisigSignAction = new QAction(QIcon(":/icons/editpaste"), tr("&Multisignature signing..."), this);
multisigSignAction->setStatusTip(tr("Sign with a multisignature address"));
openAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_FileIcon), tr("Open &URI..."), this);
openAction->setStatusTip(tr("Open a voi: URI or payment request"));
openBlockExplorerAction = new QAction(QIcon(":/icons/blockexplorer"), "", this);
openBlockExplorerAction->setStatusTip(tr("Blockchain explorer"));
openBlockExplorerAction->setToolTip(openBlockExplorerAction->statusTip());
openBlockExplorerAction->setCheckable(true);
#ifdef Q_OS_MAC
openBlockExplorerAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_8));
#else
openBlockExplorerAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_8));
#endif
tabGroup->addAction(openBlockExplorerAction);
showHelpMessageAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation), tr("&Command-line options"), this);
showHelpMessageAction->setMenuRole(QAction::NoRole);
showHelpMessageAction->setStatusTip(tr("Show the voi Core help message to get a list with possible voi command-line options"));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
connect(showHelpMessageAction, SIGNAL(triggered()), this, SLOT(showHelpMessageClicked()));
#ifdef ENABLE_WALLET
if (walletFrame) {
connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool)));
connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
connect(unlockWalletAction, SIGNAL(triggered()), walletFrame, SLOT(unlockWallet()));
connect(lockWalletAction, SIGNAL(triggered()), walletFrame, SLOT(lockWallet()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
connect(bip38ToolAction, SIGNAL(triggered()), this, SLOT(gotoBip38Tool()));
connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
connect(multiSendAction, SIGNAL(triggered()), this, SLOT(gotoMultiSendDialog()));
connect(multisigCreateAction, SIGNAL(triggered()), this, SLOT(gotoMultisigCreate()));
connect(multisigSpendAction, SIGNAL(triggered()), this, SLOT(gotoMultisigSpend()));
connect(multisigSignAction, SIGNAL(triggered()), this, SLOT(gotoMultisigSign()));
}
#endif // ENABLE_WALLET
}
void BitcoinGUI::createMenuBar()
{
#ifdef Q_OS_MAC
// Create a decoupled menu bar on Mac which stays even if the window is closed
appMenuBar = new QMenuBar();
#else
// Get the main window's menu bar on other platforms
appMenuBar = menuBar();
#endif
// Configure the menus
QMenu* file = appMenuBar->addMenu(tr("&File"));
if (walletFrame) {
file->addAction(openAction);
file->addAction(backupWalletAction);
file->addAction(signMessageAction);
file->addAction(verifyMessageAction);
file->addSeparator();
file->addAction(usedSendingAddressesAction);
file->addAction(usedReceivingAddressesAction);
file->addSeparator();
file->addAction(multisigCreateAction);
file->addAction(multisigSpendAction);
file->addAction(multisigSignAction);
file->addSeparator();
}
file->addAction(quitAction);
QMenu* settings = appMenuBar->addMenu(tr("&Settings"));
if (walletFrame) {
settings->addAction(encryptWalletAction);
settings->addAction(changePassphraseAction);
settings->addAction(unlockWalletAction);
settings->addAction(lockWalletAction);
settings->addAction(bip38ToolAction);
settings->addAction(multiSendAction);
settings->addSeparator();
}
settings->addAction(optionsAction);
if (walletFrame) {
QMenu* tools = appMenuBar->addMenu(tr("&Tools"));
tools->addAction(openConfEditorAction);
tools->addAction(openMNConfEditorAction);
tools->addAction(showBackupsAction);
}
QMenu* help = appMenuBar->addMenu(tr("&Help"));
help->addAction(showHelpMessageAction);
help->addSeparator();
help->addAction(aboutAction);
help->addAction(aboutQtAction);
}
void BitcoinGUI::createToolBars(QWidget *frameBlocks)
{
if (walletFrame) {
QToolBar* toolbar = new QToolBar(tr("Tabs toolbar"));
toolbar->setIconSize(QSize(35,35));
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
QWidget* hspacer = new QWidget;
hspacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
toolbar->addAction(overviewAction);
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
QSettings settings;
if (settings.value("fShowMasternodesTab").toBool()) {
toolbar->addAction(masternodeAction);
}
toolbar->addAction(toolsAction);
toolbar->addAction(openBlockExplorerAction);
toolbar->addWidget(hspacer);
toolbar->addWidget(frameBlocks);
toolbar->setMovable(false); // remove unused icon in upper left corner
overviewAction->setChecked(true);
/** Create additional container for toolbar and walletFrame and make it the central widget.
This is a workaround mostly for toolbar styling on Mac OS but should work fine for every other OSes too.
*/
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(toolbar);
layout->addWidget(walletFrame);
layout->setAlignment(toolbar,Qt::AlignBottom);
layout->setSpacing(0);
layout->setContentsMargins(QMargins());
QWidget* containerWidget = new QWidget();
containerWidget->setLayout(layout);
setCentralWidget(containerWidget);
}
}
void BitcoinGUI::setClientModel(ClientModel* clientModel)
{
this->clientModel = clientModel;
if (clientModel) {
// Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
// while the client has not yet fully loaded
createTrayIconMenu();
// Keep up to date with client
setNumConnections(clientModel->getNumConnections());
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
setNumBlocks(clientModel->getNumBlocks());
connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
// Receive and report messages from client model
connect(clientModel, SIGNAL(message(QString, QString, unsigned int)), this, SLOT(message(QString, QString, unsigned int)));
// Show progress dialog
connect(clientModel, SIGNAL(showProgress(QString, int)), this, SLOT(showProgress(QString, int)));
rpcConsole->setClientModel(clientModel);
#ifdef ENABLE_WALLET
if (walletFrame) {
walletFrame->setClientModel(clientModel);
}
#endif // ENABLE_WALLET
} else {
// Disable possibility to show main window via action
toggleHideAction->setEnabled(false);
if (trayIconMenu) {
// Disable context menu on tray icon
trayIconMenu->clear();
}
}
}
#ifdef ENABLE_WALLET
bool BitcoinGUI::addWallet(const QString& name, WalletModel* walletModel)
{
if (!walletFrame)
return false;
setWalletActionsEnabled(true);
return walletFrame->addWallet(name, walletModel);
}
bool BitcoinGUI::setCurrentWallet(const QString& name)
{
if (!walletFrame)
return false;
return walletFrame->setCurrentWallet(name);
}
void BitcoinGUI::removeAllWallets()
{
if (!walletFrame)
return;
setWalletActionsEnabled(false);
walletFrame->removeAllWallets();
}
#endif // ENABLE_WALLET
void BitcoinGUI::setWalletActionsEnabled(bool enabled)
{
overviewAction->setEnabled(enabled);
sendCoinsAction->setEnabled(enabled);
receiveCoinsAction->setEnabled(enabled);
historyAction->setEnabled(enabled);
QSettings settings;
if (settings.value("fShowMasternodesTab").toBool()) {
masternodeAction->setEnabled(enabled);
}
encryptWalletAction->setEnabled(enabled);
backupWalletAction->setEnabled(enabled);
changePassphraseAction->setEnabled(enabled);
signMessageAction->setEnabled(enabled);
verifyMessageAction->setEnabled(enabled);
multisigCreateAction->setEnabled(enabled);
multisigSpendAction->setEnabled(enabled);
multisigSignAction->setEnabled(enabled);
bip38ToolAction->setEnabled(enabled);
usedSendingAddressesAction->setEnabled(enabled);
usedReceivingAddressesAction->setEnabled(enabled);
openAction->setEnabled(enabled);
}
void BitcoinGUI::createTrayIcon(const NetworkStyle* networkStyle)
{
#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
QString toolTip = tr("voi Core client") + " " + networkStyle->getTitleAddText();
trayIcon->setToolTip(toolTip);
trayIcon->setIcon(networkStyle->getAppIcon());
trayIcon->show();
#endif
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
}
void BitcoinGUI::createTrayIconMenu()
{
#ifndef Q_OS_MAC
// return if trayIcon is unset (only on non-Mac OSes)
if (!trayIcon)
return;
trayIconMenu = new QMenu(this);
trayIcon->setContextMenu(trayIconMenu);
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
#else
// Note: On Mac, the dock icon is used to provide the tray's functionality.
MacDockIconHandler* dockIconHandler = MacDockIconHandler::instance();
dockIconHandler->setMainWindow((QMainWindow*)this);
trayIconMenu = dockIconHandler->dockMenu();
#endif
// Configuration of the tray icon (or dock icon) icon menu
trayIconMenu->addAction(toggleHideAction);
/*
trayIconMenu->addSeparator();
trayIconMenu->addAction(sendCoinsAction);
trayIconMenu->addAction(receiveCoinsAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(signMessageAction);
trayIconMenu->addAction(verifyMessageAction);
trayIconMenu->addAction(bip38ToolAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(optionsAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(openInfoAction);
trayIconMenu->addAction(openRPCConsoleAction);
trayIconMenu->addAction(openNetworkAction);
trayIconMenu->addAction(openPeersAction);
trayIconMenu->addAction(openRepairAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(openConfEditorAction);
trayIconMenu->addAction(openMNConfEditorAction);
trayIconMenu->addAction(showBackupsAction);
trayIconMenu->addAction(openBlockExplorerAction);
*/
#ifndef Q_OS_MAC // This is built-in on Mac
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
#endif
}
#ifndef Q_OS_MAC
void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
if (reason == QSystemTrayIcon::Trigger) {
// Click on system tray icon triggers show/hide of the main window
toggleHidden();
}
}
#endif
void BitcoinGUI::optionsClicked()
{
if (!clientModel || !clientModel->getOptionsModel())
return;
OptionsDialog dlg(this, enableWallet);
dlg.setModel(clientModel->getOptionsModel());
dlg.exec();
}
void BitcoinGUI::aboutClicked()
{
if (!clientModel)
return;
HelpMessageDialog dlg(this, true);
dlg.exec();
}
void BitcoinGUI::showHelpMessageClicked()
{
HelpMessageDialog* help = new HelpMessageDialog(this, false);
help->setAttribute(Qt::WA_DeleteOnClose);
help->show();
}
#ifdef ENABLE_WALLET
void BitcoinGUI::openClicked()
{
OpenURIDialog dlg(this);
if (dlg.exec()) {
emit receivedURI(dlg.getURI());
}
}
void BitcoinGUI::gotoOverviewPage()
{
overviewAction->setChecked(true);
if (walletFrame) walletFrame->gotoOverviewPage();
}
void BitcoinGUI::gotoHistoryPage()
{
historyAction->setChecked(true);
if (walletFrame) walletFrame->gotoHistoryPage();
}
void BitcoinGUI::gotoMasternodePage()
{
QSettings settings;
if (settings.value("fShowMasternodesTab").toBool()) {
masternodeAction->setChecked(true);
if (walletFrame) walletFrame->gotoMasternodePage();
}
}
void BitcoinGUI::gotoBlockExplorerPage()
{
openBlockExplorerAction->setChecked(true);
if(openBlockExplorerAction) walletFrame->gotoBlockExplorerPage();
}
void BitcoinGUI::gotoToolsPage()
{
toolsAction->setChecked(true);
if(toolsAction) walletFrame->gotoToolsPage();
}
void BitcoinGUI::showInfo()
{
toolsAction->setChecked(true);
walletFrame->gotoToolsPageTab(ToolsPage::TAB_INFO);
}
void BitcoinGUI::showConsole()
{
toolsAction->setChecked(true);
walletFrame->gotoToolsPageTab(ToolsPage::TAB_CONSOLE);
}
void BitcoinGUI::showGraph()
{
toolsAction->setChecked(true);
walletFrame->gotoToolsPageTab(ToolsPage::TAB_GRAPH);
}
void BitcoinGUI::showPeers()
{
toolsAction->setChecked(true);
walletFrame->gotoToolsPageTab(ToolsPage::TAB_PEERS);
}
void BitcoinGUI::showRepair()
{
toolsAction->setChecked(true);
walletFrame->gotoToolsPageTab(ToolsPage::TAB_REPAIR);
}
void BitcoinGUI::gotoReceiveCoinsPage()
{
receiveCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoReceiveCoinsPage();
}
void BitcoinGUI::gotoSendCoinsPage(QString addr)
{
sendCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
}
void BitcoinGUI::gotoSignMessageTab(QString addr)
{
if (walletFrame) walletFrame->gotoSignMessageTab(addr);
}
void BitcoinGUI::gotoVerifyMessageTab(QString addr)
{
if (walletFrame) walletFrame->gotoVerifyMessageTab(addr);
}
void BitcoinGUI::gotoMultisigCreate()
{
if(walletFrame) walletFrame->gotoMultisigDialog(0);
}
void BitcoinGUI::gotoMultisigSpend()
{
if(walletFrame) walletFrame->gotoMultisigDialog(1);
}
void BitcoinGUI::gotoMultisigSign()
{
if(walletFrame) walletFrame->gotoMultisigDialog(2);
}
void BitcoinGUI::gotoBip38Tool()
{
if (walletFrame) walletFrame->gotoBip38Tool();
}
void BitcoinGUI::gotoMultiSendDialog()
{
multiSendAction->setChecked(true);
if (walletFrame)
walletFrame->gotoMultiSendDialog();
}
#endif // ENABLE_WALLET
void BitcoinGUI::setNumConnections(int count)
{
QString icon;
switch (count) {
case 0:
icon = ":/icons/connect_0";
break;
case 1:
case 2:
case 3:
icon = ":/icons/connect_1";
break;
case 4:
case 5:
case 6:
icon = ":/icons/connect_2";
break;
case 7:
case 8:
case 9:
icon = ":/icons/connect_3";
break;
default:
icon = ":/icons/connect_4";
break;
}
QIcon connectionItem = QIcon(icon).pixmap(32, 32);
labelConnectionsIcon->setIcon(connectionItem);
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to voi network", "", count));
}
void BitcoinGUI::updateSyncAnimation()
{
if (!masternodeSync.IsBlockchainSynced() || !masternodeSync.IsSynced())
{
labelBlocksIcon->setPixmap(QIcon(QString(
":/movies/spinner-%1")
.arg(spinnerFrame, 3, 10, QChar('0')))
.pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
}
else disconnect(synctimer, SIGNAL(timeout()), 0, 0);
}
void BitcoinGUI::setNumBlocks(int count)
{
if (!clientModel)
return;
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
statusBar()->clearMessage();
// Acquire current block source
enum BlockSource blockSource = clientModel->getBlockSource();
switch (blockSource) {
case BLOCK_SOURCE_NETWORK:
progressBarLabel->setText(tr("Synchronizing with network..."));
break;
case BLOCK_SOURCE_DISK:
progressBarLabel->setText(tr("Importing blocks from disk..."));
break;
case BLOCK_SOURCE_REINDEX:
progressBarLabel->setText(tr("Reindexing blocks on disk..."));
break;
case BLOCK_SOURCE_NONE:
// Case: not Importing, not Reindexing and no network connection
progressBarLabel->setText(tr("No block source available..."));
break;
}
QString tooltip;
QDateTime lastBlockDate = clientModel->getLastBlockDate();
QDateTime currentDate = QDateTime::currentDateTime();
int secs = lastBlockDate.secsTo(currentDate);
tooltip = tr("Processed %n blocks of transaction history.", "", count);
// Set icon state: spinning if catching up, tick otherwise
// if(secs < 25*60) // 90*60 for bitcoin but we are 4x times faster
if (masternodeSync.IsBlockchainSynced()) {
QString strSyncStatus;
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
if (masternodeSync.IsSynced()) {
progressBarLabel->setVisible(false);
progressBar->setVisible(false);
labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
} else {
int nAttempt;
int progress = 0;
#ifdef ENABLE_WALLET
if (walletFrame)
walletFrame->showOutOfSyncWarning(false);
#endif // ENABLE_WALLET
nAttempt = masternodeSync.RequestedMasternodeAttempt < MASTERNODE_SYNC_THRESHOLD ?
masternodeSync.RequestedMasternodeAttempt + 1 :
MASTERNODE_SYNC_THRESHOLD;
progress = nAttempt + (masternodeSync.RequestedMasternodeAssets - 1) * MASTERNODE_SYNC_THRESHOLD;
progressBar->setMaximum(4 * MASTERNODE_SYNC_THRESHOLD);
progressBar->setFormat(tr("Synchronizing additional data: %p%"));
progressBar->setValue(progress);
}
strSyncStatus = QString(masternodeSync.GetSyncStatus().c_str());
progressBarLabel->setText(strSyncStatus);
tooltip = strSyncStatus + QString("<br>") + tooltip;
} else {
// Represent time from last generated block in human readable text
QString timeBehindText;
const int HOUR_IN_SECONDS = 60 * 60;
const int DAY_IN_SECONDS = 24 * 60 * 60;
const int WEEK_IN_SECONDS = 7 * 24 * 60 * 60;
const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
if (secs < 2 * DAY_IN_SECONDS) {
timeBehindText = tr("%n hour(s)", "", secs / HOUR_IN_SECONDS);
} else if (secs < 2 * WEEK_IN_SECONDS) {
timeBehindText = tr("%n day(s)", "", secs / DAY_IN_SECONDS);
} else if (secs < YEAR_IN_SECONDS) {
timeBehindText = tr("%n week(s)", "", secs / WEEK_IN_SECONDS);
} else {
int years = secs / YEAR_IN_SECONDS;
int remainder = secs % YEAR_IN_SECONDS;
timeBehindText = tr("%1 and %2").arg(tr("%n year(s)", "", years)).arg(tr("%n week(s)", "", remainder / WEEK_IN_SECONDS));
}
progressBarLabel->setVisible(true);
progressBar->setFormat(tr("%1 behind. Scanning block %2").arg(timeBehindText).arg(count));
progressBar->setMaximum(1000000000);
progressBar->setValue(clientModel->getVerificationProgress() * 1000000000.0 + 0.5);
progressBar->setVisible(true);
tooltip = tr("Catching up...") + QString("<br>") + tooltip;
prevBlocks = count;
#ifdef ENABLE_WALLET
if (walletFrame)
walletFrame->showOutOfSyncWarning(true);
#endif // ENABLE_WALLET
tooltip += QString("<br>");
tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
tooltip += QString("<br>");
tooltip += tr("Transactions after this will not yet be visible.");
}
// Don't word-wrap this (fixed-width) tooltip
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
labelBlocksIcon->setToolTip(tooltip);
progressBarLabel->setToolTip(tooltip);
progressBar->setToolTip(tooltip);
}
void BitcoinGUI::message(const QString& title, const QString& message, unsigned int style, bool* ret)
{
QString strTitle = tr("voi Core"); // default title
// Default to information icon
int nMBoxIcon = QMessageBox::Information;
int nNotifyIcon = Notificator::Information;
QString msgType;
// Prefer supplied title over style based title
if (!title.isEmpty()) {
msgType = title;
} else {
switch (style) {
case CClientUIInterface::MSG_ERROR:
msgType = tr("Error");
break;
case CClientUIInterface::MSG_WARNING:
msgType = tr("Warning");
break;
case CClientUIInterface::MSG_INFORMATION:
msgType = tr("Information");
break;
default:
break;
}
}
// Append title to "voi - "
if (!msgType.isEmpty())
strTitle += " - " + msgType;
// Check for error/warning icon
if (style & CClientUIInterface::ICON_ERROR) {
nMBoxIcon = QMessageBox::Critical;
nNotifyIcon = Notificator::Critical;
} else if (style & CClientUIInterface::ICON_WARNING) {
nMBoxIcon = QMessageBox::Warning;
nNotifyIcon = Notificator::Warning;
}
// Display message
if (style & CClientUIInterface::MODAL) {
// Check for buttons, use OK as default, if none was supplied
QMessageBox::StandardButton buttons;
if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
buttons = QMessageBox::Ok;
showNormalIfMinimized();
QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
int r = mBox.exec();
if (ret != NULL)
*ret = r == QMessageBox::Ok;
} else
notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
}
void BitcoinGUI::changeEvent(QEvent* e)
{
QMainWindow::changeEvent(e);
#ifndef Q_OS_MAC // Ignored on Mac
if (e->type() == QEvent::WindowStateChange) {
if (clientModel && clientModel->getOptionsModel() && clientModel->getOptionsModel()->getMinimizeToTray()) {
QWindowStateChangeEvent* wsevt = static_cast<QWindowStateChangeEvent*>(e);
if (!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) {
QTimer::singleShot(0, this, SLOT(hide()));
e->ignore();
}
}
}
#endif
}
void BitcoinGUI::closeEvent(QCloseEvent* event)
{
#ifndef Q_OS_MAC // Ignored on Mac
if (clientModel && clientModel->getOptionsModel()) {
if (!clientModel->getOptionsModel()->getMinimizeOnClose()) {
QApplication::quit();
}
}
#endif
QMainWindow::closeEvent(event);
}
#ifdef ENABLE_WALLET
void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address)
{
// On new transaction, make an info balloon
message((amount) < 0 ? (pwalletMain->fMultiSendNotify == true ? tr("Sent MultiSend transaction") : tr("Sent transaction")) : tr("Incoming transaction"),
tr("Date: %1\n"
"Amount: %2\n"
"Type: %3\n"
"Address: %4\n")
.arg(date)
.arg(BitcoinUnits::formatWithUnit(unit, amount, true))
.arg(type)
.arg(address),
CClientUIInterface::MSG_INFORMATION);
pwalletMain->fMultiSendNotify = false;
}
#endif // ENABLE_WALLET
void BitcoinGUI::dragEnterEvent(QDragEnterEvent* event)
{
// Accept only URIs
if (event->mimeData()->hasUrls())
event->acceptProposedAction();
}
void BitcoinGUI::dropEvent(QDropEvent* event)
{
if (event->mimeData()->hasUrls()) {
foreach (const QUrl& uri, event->mimeData()->urls()) {
emit receivedURI(uri.toString());
}
}
event->acceptProposedAction();
}
bool BitcoinGUI::eventFilter(QObject* object, QEvent* event)
{
// Catch status tip events
if (event->type() == QEvent::StatusTip) {
// Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff
if (progressBarLabel->isVisible() || progressBar->isVisible())
return true;
}
return QMainWindow::eventFilter(object, event);
}
void BitcoinGUI::setStakingStatus()
{
if (pwalletMain)
fMultiSend = pwalletMain->isMultiSendEnabled();
if (nLastCoinStakeSearchInterval) {
labelStakingIcon->show();
labelStakingIcon->setPixmap(QIcon(":/icons/staking_active").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelStakingIcon->setToolTip(tr("Staking is active\n MultiSend: %1").arg(fMultiSend ? tr("Active") : tr("Not Active")));
} else {
labelStakingIcon->show();
labelStakingIcon->setPixmap(QIcon(":/icons/staking_inactive").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelStakingIcon->setToolTip(tr("Staking is not active\n MultiSend: %1").arg(fMultiSend ? tr("Active") : tr("Not Active")));
}
}
#ifdef ENABLE_WALLET
bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
{
// URI has to be valid
if (walletFrame && walletFrame->handlePaymentRequest(recipient)) {
showNormalIfMinimized();
gotoSendCoinsPage();
return true;
}
return false;
}
void BitcoinGUI::setEncryptionStatus(int status)
{
switch (status) {
case WalletModel::Unencrypted:
labelEncryptionIcon->hide();
encryptWalletAction->setChecked(false);
changePassphraseAction->setEnabled(false);
unlockWalletAction->setVisible(false);
lockWalletAction->setVisible(false);
encryptWalletAction->setEnabled(true);
break;
case WalletModel::Unlocked:
labelEncryptionIcon->show();
labelEncryptionIcon->setIcon(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(false);
lockWalletAction->setVisible(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
disconnect(labelEncryptionIcon, SIGNAL(clicked()), walletFrame, SLOT(unlockWallet()));
connect(labelEncryptionIcon, SIGNAL(clicked()), walletFrame, SLOT(lockWallet()));
break;
case WalletModel::UnlockedForAnonymizationOnly:
labelEncryptionIcon->show();
labelEncryptionIcon->setIcon(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b> for anonimization and staking only"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(true);
lockWalletAction->setVisible(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
disconnect(labelEncryptionIcon, SIGNAL(clicked()), walletFrame, SLOT(lockWallet()));
connect(labelEncryptionIcon, SIGNAL(clicked()), walletFrame, SLOT(unlockWallet()));
break;
case WalletModel::Locked:
labelEncryptionIcon->show();
labelEncryptionIcon->setIcon(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(true);
lockWalletAction->setVisible(false);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
disconnect(labelEncryptionIcon, SIGNAL(clicked()), walletFrame, SLOT(lockWallet()));
connect(labelEncryptionIcon, SIGNAL(clicked()), walletFrame, SLOT(unlockWallet()));
break;
}
}
#endif // ENABLE_WALLET
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
{
if (!clientModel)
return;
// activateWindow() (sometimes) helps with keyboard focus on Windows
if (isHidden()) {
show();
activateWindow();
} else if (isMinimized()) {
showNormal();
activateWindow();
} else if (GUIUtil::isObscured(this)) {
raise();
activateWindow();
} else if (fToggleHidden)
hide();
}
void BitcoinGUI::toggleHidden()
{
showNormalIfMinimized(true);
}
void BitcoinGUI::detectShutdown()
{
if (ShutdownRequested()) {
if (rpcConsole)
rpcConsole->hide();
qApp->quit();
}
}
void BitcoinGUI::showProgress(const QString& title, int nProgress)
{
if (nProgress == 0) {
progressDialog = new QProgressDialog(title, "", 0, 100);
progressDialog->setWindowModality(Qt::ApplicationModal);
progressDialog->setMinimumDuration(0);
progressDialog->setCancelButton(0);
progressDialog->setAutoClose(false);
progressDialog->setValue(0);
} else if (nProgress == 100) {
if (progressDialog) {
progressDialog->close();
progressDialog->deleteLater();
}
} else if (progressDialog)
progressDialog->setValue(nProgress);
}
static bool ThreadSafeMessageBox(BitcoinGUI* gui, const std::string& message, const std::string& caption, unsigned int style)
{
bool modal = (style & CClientUIInterface::MODAL);
// The SECURE flag has no effect in the Qt GUI.
// bool secure = (style & CClientUIInterface::SECURE);
style &= ~CClientUIInterface::SECURE;
bool ret = false;
// In case of modal message, use blocking connection to wait for user to click a button
QMetaObject::invokeMethod(gui, "message",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
Q_ARG(unsigned int, style),
Q_ARG(bool*, &ret));
return ret;
}
void BitcoinGUI::subscribeToCoreSignals()
{
// Connect signals to client
uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
}
void BitcoinGUI::unsubscribeFromCoreSignals()
{
// Disconnect signals from client
uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
}
/** Get restart command-line parameters and request restart */
void BitcoinGUI::handleRestart(QStringList args)
{
if (!ShutdownRequested())
emit requestedRestart(args);
}
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() : optionsModel(0),
menu(0)
{
createContextMenu();
setToolTip(tr("Unit to show amounts in. Click to select another unit."));
}
/** So that it responds to button clicks */
void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent* event)
{
onDisplayUnitsClicked(event->pos());
}
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
void UnitDisplayStatusBarControl::createContextMenu()
{
menu = new QMenu();
foreach (BitcoinUnits::Unit u, BitcoinUnits::availableUnits()) {
QAction* menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
menuAction->setData(QVariant(u));
menu->addAction(menuAction);
}
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onMenuSelection(QAction*)));
}
/** Lets the control know about the Options Model (and its signals) */
void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel* optionsModel)
{
if (optionsModel) {
this->optionsModel = optionsModel;
// be aware of a display unit change reported by the OptionsModel object.
connect(optionsModel, SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit(int)));
// initialize the display units label with the current value in the model.
updateDisplayUnit(optionsModel->getDisplayUnit());
}
}
/** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */
void UnitDisplayStatusBarControl::updateDisplayUnit(int newUnits)
{
if (Params().NetworkID() == CBaseChainParams::MAIN) {
setPixmap(QIcon(":/icons/unit_" + BitcoinUnits::id(newUnits)).pixmap(39, STATUSBAR_ICONSIZE));
} else {
setPixmap(QIcon(":/icons/unit_t" + BitcoinUnits::id(newUnits)).pixmap(39, STATUSBAR_ICONSIZE));
}
}
/** Shows context menu with Display Unit options by the mouse coordinates */
void UnitDisplayStatusBarControl::onDisplayUnitsClicked(const QPoint& point)
{
QPoint globalPos = mapToGlobal(point);
menu->exec(globalPos);
}
/** Tells underlying optionsModel to update its current display unit. */
void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)
{
if (action) {
optionsModel->setDisplayUnit(action->data());
}
}
|
copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
014804 move.w (A1)+, D0 [base+6076, base+60F6, base+6176, base+61F6, base+6276, base+62F6, base+6376, base+63F6, base+6476, base+64F6, base+6576]
014806 add.w D0, ($69b2,A5) [base+607E, base+60FE, base+617E, base+61FE, base+627E, base+62FE, base+637E, base+63FE, base+647E, base+64FE, base+657E]
07E7E8 move.l D0, (A0)+
07E7EA dbra D1, $7e7e8
07EA78 move.w #$1, (A1)+ [base+607C, base+60FC, base+617C, base+61FC, base+627C, base+62FC, base+637C, base+63FC, base+647C, base+64FC]
07EA7C move.w #$6, (A1)+ [base+607E, base+60FE, base+617E, base+61FE, base+627E, base+62FE, base+637E, base+63FE, base+647E, base+64FE]
0AAACA move.l (A0), D2
0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAACE move.w D0, ($2,A0)
0AAAD2 cmp.l (A0), D0
0AAAD4 bne $aaafc
0AAAD8 move.l D2, (A0)+
0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAE6 move.l (A0), D2
0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAF4 move.l D2, (A0)+
0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
copyright zengfr site:http://github.com/zengfr/romhack
|
_getprocinfo_test: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.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
getprocinfo();
11: e8 1c 03 00 00 call 332 <getprocinfo>
exit();
16: e8 57 02 00 00 call 272 <exit>
1b: 66 90 xchg %ax,%ax
1d: 66 90 xchg %ax,%ax
1f: 90 nop
00000020 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
20: 55 push %ebp
21: 89 e5 mov %esp,%ebp
23: 53 push %ebx
24: 8b 45 08 mov 0x8(%ebp),%eax
27: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
2a: 89 c2 mov %eax,%edx
2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
30: 83 c1 01 add $0x1,%ecx
33: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
37: 83 c2 01 add $0x1,%edx
3a: 84 db test %bl,%bl
3c: 88 5a ff mov %bl,-0x1(%edx)
3f: 75 ef jne 30 <strcpy+0x10>
;
return os;
}
41: 5b pop %ebx
42: 5d pop %ebp
43: c3 ret
44: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
4a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000050 <strcmp>:
int
strcmp(const char *p, const char *q)
{
50: 55 push %ebp
51: 89 e5 mov %esp,%ebp
53: 53 push %ebx
54: 8b 55 08 mov 0x8(%ebp),%edx
57: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
5a: 0f b6 02 movzbl (%edx),%eax
5d: 0f b6 19 movzbl (%ecx),%ebx
60: 84 c0 test %al,%al
62: 75 1c jne 80 <strcmp+0x30>
64: eb 2a jmp 90 <strcmp+0x40>
66: 8d 76 00 lea 0x0(%esi),%esi
69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
70: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
73: 0f b6 02 movzbl (%edx),%eax
p++, q++;
76: 83 c1 01 add $0x1,%ecx
79: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
7c: 84 c0 test %al,%al
7e: 74 10 je 90 <strcmp+0x40>
80: 38 d8 cmp %bl,%al
82: 74 ec je 70 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
84: 29 d8 sub %ebx,%eax
}
86: 5b pop %ebx
87: 5d pop %ebp
88: c3 ret
89: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
90: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
92: 29 d8 sub %ebx,%eax
}
94: 5b pop %ebx
95: 5d pop %ebp
96: c3 ret
97: 89 f6 mov %esi,%esi
99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000000a0 <strlen>:
uint
strlen(const char *s)
{
a0: 55 push %ebp
a1: 89 e5 mov %esp,%ebp
a3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
a6: 80 39 00 cmpb $0x0,(%ecx)
a9: 74 15 je c0 <strlen+0x20>
ab: 31 d2 xor %edx,%edx
ad: 8d 76 00 lea 0x0(%esi),%esi
b0: 83 c2 01 add $0x1,%edx
b3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
b7: 89 d0 mov %edx,%eax
b9: 75 f5 jne b0 <strlen+0x10>
;
return n;
}
bb: 5d pop %ebp
bc: c3 ret
bd: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
c0: 31 c0 xor %eax,%eax
}
c2: 5d pop %ebp
c3: c3 ret
c4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
ca: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000000d0 <memset>:
void*
memset(void *dst, int c, uint n)
{
d0: 55 push %ebp
d1: 89 e5 mov %esp,%ebp
d3: 57 push %edi
d4: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
d7: 8b 4d 10 mov 0x10(%ebp),%ecx
da: 8b 45 0c mov 0xc(%ebp),%eax
dd: 89 d7 mov %edx,%edi
df: fc cld
e0: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
e2: 89 d0 mov %edx,%eax
e4: 5f pop %edi
e5: 5d pop %ebp
e6: c3 ret
e7: 89 f6 mov %esi,%esi
e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000000f0 <strchr>:
char*
strchr(const char *s, char c)
{
f0: 55 push %ebp
f1: 89 e5 mov %esp,%ebp
f3: 53 push %ebx
f4: 8b 45 08 mov 0x8(%ebp),%eax
f7: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
fa: 0f b6 10 movzbl (%eax),%edx
fd: 84 d2 test %dl,%dl
ff: 74 1d je 11e <strchr+0x2e>
if(*s == c)
101: 38 d3 cmp %dl,%bl
103: 89 d9 mov %ebx,%ecx
105: 75 0d jne 114 <strchr+0x24>
107: eb 17 jmp 120 <strchr+0x30>
109: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
110: 38 ca cmp %cl,%dl
112: 74 0c je 120 <strchr+0x30>
for(; *s; s++)
114: 83 c0 01 add $0x1,%eax
117: 0f b6 10 movzbl (%eax),%edx
11a: 84 d2 test %dl,%dl
11c: 75 f2 jne 110 <strchr+0x20>
return (char*)s;
return 0;
11e: 31 c0 xor %eax,%eax
}
120: 5b pop %ebx
121: 5d pop %ebp
122: c3 ret
123: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000130 <gets>:
char*
gets(char *buf, int max)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 57 push %edi
134: 56 push %esi
135: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
136: 31 f6 xor %esi,%esi
138: 89 f3 mov %esi,%ebx
{
13a: 83 ec 1c sub $0x1c,%esp
13d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
140: eb 2f jmp 171 <gets+0x41>
142: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
148: 8d 45 e7 lea -0x19(%ebp),%eax
14b: 83 ec 04 sub $0x4,%esp
14e: 6a 01 push $0x1
150: 50 push %eax
151: 6a 00 push $0x0
153: e8 32 01 00 00 call 28a <read>
if(cc < 1)
158: 83 c4 10 add $0x10,%esp
15b: 85 c0 test %eax,%eax
15d: 7e 1c jle 17b <gets+0x4b>
break;
buf[i++] = c;
15f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
163: 83 c7 01 add $0x1,%edi
166: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
169: 3c 0a cmp $0xa,%al
16b: 74 23 je 190 <gets+0x60>
16d: 3c 0d cmp $0xd,%al
16f: 74 1f je 190 <gets+0x60>
for(i=0; i+1 < max; ){
171: 83 c3 01 add $0x1,%ebx
174: 3b 5d 0c cmp 0xc(%ebp),%ebx
177: 89 fe mov %edi,%esi
179: 7c cd jl 148 <gets+0x18>
17b: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
17d: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
180: c6 03 00 movb $0x0,(%ebx)
}
183: 8d 65 f4 lea -0xc(%ebp),%esp
186: 5b pop %ebx
187: 5e pop %esi
188: 5f pop %edi
189: 5d pop %ebp
18a: c3 ret
18b: 90 nop
18c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
190: 8b 75 08 mov 0x8(%ebp),%esi
193: 8b 45 08 mov 0x8(%ebp),%eax
196: 01 de add %ebx,%esi
198: 89 f3 mov %esi,%ebx
buf[i] = '\0';
19a: c6 03 00 movb $0x0,(%ebx)
}
19d: 8d 65 f4 lea -0xc(%ebp),%esp
1a0: 5b pop %ebx
1a1: 5e pop %esi
1a2: 5f pop %edi
1a3: 5d pop %ebp
1a4: c3 ret
1a5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001b0 <stat>:
int
stat(const char *n, struct stat *st)
{
1b0: 55 push %ebp
1b1: 89 e5 mov %esp,%ebp
1b3: 56 push %esi
1b4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1b5: 83 ec 08 sub $0x8,%esp
1b8: 6a 00 push $0x0
1ba: ff 75 08 pushl 0x8(%ebp)
1bd: e8 f0 00 00 00 call 2b2 <open>
if(fd < 0)
1c2: 83 c4 10 add $0x10,%esp
1c5: 85 c0 test %eax,%eax
1c7: 78 27 js 1f0 <stat+0x40>
return -1;
r = fstat(fd, st);
1c9: 83 ec 08 sub $0x8,%esp
1cc: ff 75 0c pushl 0xc(%ebp)
1cf: 89 c3 mov %eax,%ebx
1d1: 50 push %eax
1d2: e8 f3 00 00 00 call 2ca <fstat>
close(fd);
1d7: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
1da: 89 c6 mov %eax,%esi
close(fd);
1dc: e8 b9 00 00 00 call 29a <close>
return r;
1e1: 83 c4 10 add $0x10,%esp
}
1e4: 8d 65 f8 lea -0x8(%ebp),%esp
1e7: 89 f0 mov %esi,%eax
1e9: 5b pop %ebx
1ea: 5e pop %esi
1eb: 5d pop %ebp
1ec: c3 ret
1ed: 8d 76 00 lea 0x0(%esi),%esi
return -1;
1f0: be ff ff ff ff mov $0xffffffff,%esi
1f5: eb ed jmp 1e4 <stat+0x34>
1f7: 89 f6 mov %esi,%esi
1f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000200 <atoi>:
int
atoi(const char *s)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 53 push %ebx
204: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
207: 0f be 11 movsbl (%ecx),%edx
20a: 8d 42 d0 lea -0x30(%edx),%eax
20d: 3c 09 cmp $0x9,%al
n = 0;
20f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
214: 77 1f ja 235 <atoi+0x35>
216: 8d 76 00 lea 0x0(%esi),%esi
219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
220: 8d 04 80 lea (%eax,%eax,4),%eax
223: 83 c1 01 add $0x1,%ecx
226: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
22a: 0f be 11 movsbl (%ecx),%edx
22d: 8d 5a d0 lea -0x30(%edx),%ebx
230: 80 fb 09 cmp $0x9,%bl
233: 76 eb jbe 220 <atoi+0x20>
return n;
}
235: 5b pop %ebx
236: 5d pop %ebp
237: c3 ret
238: 90 nop
239: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000240 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
240: 55 push %ebp
241: 89 e5 mov %esp,%ebp
243: 56 push %esi
244: 53 push %ebx
245: 8b 5d 10 mov 0x10(%ebp),%ebx
248: 8b 45 08 mov 0x8(%ebp),%eax
24b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
24e: 85 db test %ebx,%ebx
250: 7e 14 jle 266 <memmove+0x26>
252: 31 d2 xor %edx,%edx
254: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
258: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
25c: 88 0c 10 mov %cl,(%eax,%edx,1)
25f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
262: 39 d3 cmp %edx,%ebx
264: 75 f2 jne 258 <memmove+0x18>
return vdst;
}
266: 5b pop %ebx
267: 5e pop %esi
268: 5d pop %ebp
269: c3 ret
0000026a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
26a: b8 01 00 00 00 mov $0x1,%eax
26f: cd 40 int $0x40
271: c3 ret
00000272 <exit>:
SYSCALL(exit)
272: b8 02 00 00 00 mov $0x2,%eax
277: cd 40 int $0x40
279: c3 ret
0000027a <wait>:
SYSCALL(wait)
27a: b8 03 00 00 00 mov $0x3,%eax
27f: cd 40 int $0x40
281: c3 ret
00000282 <pipe>:
SYSCALL(pipe)
282: b8 04 00 00 00 mov $0x4,%eax
287: cd 40 int $0x40
289: c3 ret
0000028a <read>:
SYSCALL(read)
28a: b8 05 00 00 00 mov $0x5,%eax
28f: cd 40 int $0x40
291: c3 ret
00000292 <write>:
SYSCALL(write)
292: b8 10 00 00 00 mov $0x10,%eax
297: cd 40 int $0x40
299: c3 ret
0000029a <close>:
SYSCALL(close)
29a: b8 15 00 00 00 mov $0x15,%eax
29f: cd 40 int $0x40
2a1: c3 ret
000002a2 <kill>:
SYSCALL(kill)
2a2: b8 06 00 00 00 mov $0x6,%eax
2a7: cd 40 int $0x40
2a9: c3 ret
000002aa <exec>:
SYSCALL(exec)
2aa: b8 07 00 00 00 mov $0x7,%eax
2af: cd 40 int $0x40
2b1: c3 ret
000002b2 <open>:
SYSCALL(open)
2b2: b8 0f 00 00 00 mov $0xf,%eax
2b7: cd 40 int $0x40
2b9: c3 ret
000002ba <mknod>:
SYSCALL(mknod)
2ba: b8 11 00 00 00 mov $0x11,%eax
2bf: cd 40 int $0x40
2c1: c3 ret
000002c2 <unlink>:
SYSCALL(unlink)
2c2: b8 12 00 00 00 mov $0x12,%eax
2c7: cd 40 int $0x40
2c9: c3 ret
000002ca <fstat>:
SYSCALL(fstat)
2ca: b8 08 00 00 00 mov $0x8,%eax
2cf: cd 40 int $0x40
2d1: c3 ret
000002d2 <link>:
SYSCALL(link)
2d2: b8 13 00 00 00 mov $0x13,%eax
2d7: cd 40 int $0x40
2d9: c3 ret
000002da <mkdir>:
SYSCALL(mkdir)
2da: b8 14 00 00 00 mov $0x14,%eax
2df: cd 40 int $0x40
2e1: c3 ret
000002e2 <chdir>:
SYSCALL(chdir)
2e2: b8 09 00 00 00 mov $0x9,%eax
2e7: cd 40 int $0x40
2e9: c3 ret
000002ea <dup>:
SYSCALL(dup)
2ea: b8 0a 00 00 00 mov $0xa,%eax
2ef: cd 40 int $0x40
2f1: c3 ret
000002f2 <getpid>:
SYSCALL(getpid)
2f2: b8 0b 00 00 00 mov $0xb,%eax
2f7: cd 40 int $0x40
2f9: c3 ret
000002fa <sbrk>:
SYSCALL(sbrk)
2fa: b8 0c 00 00 00 mov $0xc,%eax
2ff: cd 40 int $0x40
301: c3 ret
00000302 <sleep>:
SYSCALL(sleep)
302: b8 0d 00 00 00 mov $0xd,%eax
307: cd 40 int $0x40
309: c3 ret
0000030a <uptime>:
SYSCALL(uptime)
30a: b8 0e 00 00 00 mov $0xe,%eax
30f: cd 40 int $0x40
311: c3 ret
00000312 <hello>:
SYSCALL(hello)
312: b8 16 00 00 00 mov $0x16,%eax
317: cd 40 int $0x40
319: c3 ret
0000031a <helloname>:
SYSCALL(helloname)
31a: b8 17 00 00 00 mov $0x17,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <getnumproc>:
SYSCALL(getnumproc)
322: b8 18 00 00 00 mov $0x18,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <getmaxpid>:
SYSCALL(getmaxpid)
32a: b8 19 00 00 00 mov $0x19,%eax
32f: cd 40 int $0x40
331: c3 ret
00000332 <getprocinfo>:
SYSCALL(getprocinfo)
332: b8 1a 00 00 00 mov $0x1a,%eax
337: cd 40 int $0x40
339: c3 ret
0000033a <setprio>:
SYSCALL(setprio)
33a: b8 1b 00 00 00 mov $0x1b,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <getprio>:
SYSCALL(getprio)
342: b8 1c 00 00 00 mov $0x1c,%eax
347: cd 40 int $0x40
349: c3 ret
34a: 66 90 xchg %ax,%ax
34c: 66 90 xchg %ax,%ax
34e: 66 90 xchg %ax,%ax
00000350 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
350: 55 push %ebp
351: 89 e5 mov %esp,%ebp
353: 57 push %edi
354: 56 push %esi
355: 53 push %ebx
356: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
359: 85 d2 test %edx,%edx
{
35b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
35e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
360: 79 76 jns 3d8 <printint+0x88>
362: f6 45 08 01 testb $0x1,0x8(%ebp)
366: 74 70 je 3d8 <printint+0x88>
x = -xx;
368: f7 d8 neg %eax
neg = 1;
36a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
371: 31 f6 xor %esi,%esi
373: 8d 5d d7 lea -0x29(%ebp),%ebx
376: eb 0a jmp 382 <printint+0x32>
378: 90 nop
379: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
380: 89 fe mov %edi,%esi
382: 31 d2 xor %edx,%edx
384: 8d 7e 01 lea 0x1(%esi),%edi
387: f7 f1 div %ecx
389: 0f b6 92 50 07 00 00 movzbl 0x750(%edx),%edx
}while((x /= base) != 0);
390: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
392: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
395: 75 e9 jne 380 <printint+0x30>
if(neg)
397: 8b 45 c4 mov -0x3c(%ebp),%eax
39a: 85 c0 test %eax,%eax
39c: 74 08 je 3a6 <printint+0x56>
buf[i++] = '-';
39e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
3a3: 8d 7e 02 lea 0x2(%esi),%edi
3a6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
3aa: 8b 7d c0 mov -0x40(%ebp),%edi
3ad: 8d 76 00 lea 0x0(%esi),%esi
3b0: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
3b3: 83 ec 04 sub $0x4,%esp
3b6: 83 ee 01 sub $0x1,%esi
3b9: 6a 01 push $0x1
3bb: 53 push %ebx
3bc: 57 push %edi
3bd: 88 45 d7 mov %al,-0x29(%ebp)
3c0: e8 cd fe ff ff call 292 <write>
while(--i >= 0)
3c5: 83 c4 10 add $0x10,%esp
3c8: 39 de cmp %ebx,%esi
3ca: 75 e4 jne 3b0 <printint+0x60>
putc(fd, buf[i]);
}
3cc: 8d 65 f4 lea -0xc(%ebp),%esp
3cf: 5b pop %ebx
3d0: 5e pop %esi
3d1: 5f pop %edi
3d2: 5d pop %ebp
3d3: c3 ret
3d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
3d8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
3df: eb 90 jmp 371 <printint+0x21>
3e1: eb 0d jmp 3f0 <printf>
3e3: 90 nop
3e4: 90 nop
3e5: 90 nop
3e6: 90 nop
3e7: 90 nop
3e8: 90 nop
3e9: 90 nop
3ea: 90 nop
3eb: 90 nop
3ec: 90 nop
3ed: 90 nop
3ee: 90 nop
3ef: 90 nop
000003f0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
3f0: 55 push %ebp
3f1: 89 e5 mov %esp,%ebp
3f3: 57 push %edi
3f4: 56 push %esi
3f5: 53 push %ebx
3f6: 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++){
3f9: 8b 75 0c mov 0xc(%ebp),%esi
3fc: 0f b6 1e movzbl (%esi),%ebx
3ff: 84 db test %bl,%bl
401: 0f 84 b3 00 00 00 je 4ba <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
407: 8d 45 10 lea 0x10(%ebp),%eax
40a: 83 c6 01 add $0x1,%esi
state = 0;
40d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
40f: 89 45 d4 mov %eax,-0x2c(%ebp)
412: eb 2f jmp 443 <printf+0x53>
414: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
418: 83 f8 25 cmp $0x25,%eax
41b: 0f 84 a7 00 00 00 je 4c8 <printf+0xd8>
write(fd, &c, 1);
421: 8d 45 e2 lea -0x1e(%ebp),%eax
424: 83 ec 04 sub $0x4,%esp
427: 88 5d e2 mov %bl,-0x1e(%ebp)
42a: 6a 01 push $0x1
42c: 50 push %eax
42d: ff 75 08 pushl 0x8(%ebp)
430: e8 5d fe ff ff call 292 <write>
435: 83 c4 10 add $0x10,%esp
438: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
43b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
43f: 84 db test %bl,%bl
441: 74 77 je 4ba <printf+0xca>
if(state == 0){
443: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
445: 0f be cb movsbl %bl,%ecx
448: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
44b: 74 cb je 418 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
44d: 83 ff 25 cmp $0x25,%edi
450: 75 e6 jne 438 <printf+0x48>
if(c == 'd'){
452: 83 f8 64 cmp $0x64,%eax
455: 0f 84 05 01 00 00 je 560 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
45b: 81 e1 f7 00 00 00 and $0xf7,%ecx
461: 83 f9 70 cmp $0x70,%ecx
464: 74 72 je 4d8 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
466: 83 f8 73 cmp $0x73,%eax
469: 0f 84 99 00 00 00 je 508 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
46f: 83 f8 63 cmp $0x63,%eax
472: 0f 84 08 01 00 00 je 580 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
478: 83 f8 25 cmp $0x25,%eax
47b: 0f 84 ef 00 00 00 je 570 <printf+0x180>
write(fd, &c, 1);
481: 8d 45 e7 lea -0x19(%ebp),%eax
484: 83 ec 04 sub $0x4,%esp
487: c6 45 e7 25 movb $0x25,-0x19(%ebp)
48b: 6a 01 push $0x1
48d: 50 push %eax
48e: ff 75 08 pushl 0x8(%ebp)
491: e8 fc fd ff ff call 292 <write>
496: 83 c4 0c add $0xc,%esp
499: 8d 45 e6 lea -0x1a(%ebp),%eax
49c: 88 5d e6 mov %bl,-0x1a(%ebp)
49f: 6a 01 push $0x1
4a1: 50 push %eax
4a2: ff 75 08 pushl 0x8(%ebp)
4a5: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4a8: 31 ff xor %edi,%edi
write(fd, &c, 1);
4aa: e8 e3 fd ff ff call 292 <write>
for(i = 0; fmt[i]; i++){
4af: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
4b3: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
4b6: 84 db test %bl,%bl
4b8: 75 89 jne 443 <printf+0x53>
}
}
}
4ba: 8d 65 f4 lea -0xc(%ebp),%esp
4bd: 5b pop %ebx
4be: 5e pop %esi
4bf: 5f pop %edi
4c0: 5d pop %ebp
4c1: c3 ret
4c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
4c8: bf 25 00 00 00 mov $0x25,%edi
4cd: e9 66 ff ff ff jmp 438 <printf+0x48>
4d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
4d8: 83 ec 0c sub $0xc,%esp
4db: b9 10 00 00 00 mov $0x10,%ecx
4e0: 6a 00 push $0x0
4e2: 8b 7d d4 mov -0x2c(%ebp),%edi
4e5: 8b 45 08 mov 0x8(%ebp),%eax
4e8: 8b 17 mov (%edi),%edx
4ea: e8 61 fe ff ff call 350 <printint>
ap++;
4ef: 89 f8 mov %edi,%eax
4f1: 83 c4 10 add $0x10,%esp
state = 0;
4f4: 31 ff xor %edi,%edi
ap++;
4f6: 83 c0 04 add $0x4,%eax
4f9: 89 45 d4 mov %eax,-0x2c(%ebp)
4fc: e9 37 ff ff ff jmp 438 <printf+0x48>
501: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
508: 8b 45 d4 mov -0x2c(%ebp),%eax
50b: 8b 08 mov (%eax),%ecx
ap++;
50d: 83 c0 04 add $0x4,%eax
510: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
513: 85 c9 test %ecx,%ecx
515: 0f 84 8e 00 00 00 je 5a9 <printf+0x1b9>
while(*s != 0){
51b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
51e: 31 ff xor %edi,%edi
s = (char*)*ap;
520: 89 cb mov %ecx,%ebx
while(*s != 0){
522: 84 c0 test %al,%al
524: 0f 84 0e ff ff ff je 438 <printf+0x48>
52a: 89 75 d0 mov %esi,-0x30(%ebp)
52d: 89 de mov %ebx,%esi
52f: 8b 5d 08 mov 0x8(%ebp),%ebx
532: 8d 7d e3 lea -0x1d(%ebp),%edi
535: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
538: 83 ec 04 sub $0x4,%esp
s++;
53b: 83 c6 01 add $0x1,%esi
53e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
541: 6a 01 push $0x1
543: 57 push %edi
544: 53 push %ebx
545: e8 48 fd ff ff call 292 <write>
while(*s != 0){
54a: 0f b6 06 movzbl (%esi),%eax
54d: 83 c4 10 add $0x10,%esp
550: 84 c0 test %al,%al
552: 75 e4 jne 538 <printf+0x148>
554: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
557: 31 ff xor %edi,%edi
559: e9 da fe ff ff jmp 438 <printf+0x48>
55e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
560: 83 ec 0c sub $0xc,%esp
563: b9 0a 00 00 00 mov $0xa,%ecx
568: 6a 01 push $0x1
56a: e9 73 ff ff ff jmp 4e2 <printf+0xf2>
56f: 90 nop
write(fd, &c, 1);
570: 83 ec 04 sub $0x4,%esp
573: 88 5d e5 mov %bl,-0x1b(%ebp)
576: 8d 45 e5 lea -0x1b(%ebp),%eax
579: 6a 01 push $0x1
57b: e9 21 ff ff ff jmp 4a1 <printf+0xb1>
putc(fd, *ap);
580: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
583: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
586: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
588: 6a 01 push $0x1
ap++;
58a: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
58d: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
590: 8d 45 e4 lea -0x1c(%ebp),%eax
593: 50 push %eax
594: ff 75 08 pushl 0x8(%ebp)
597: e8 f6 fc ff ff call 292 <write>
ap++;
59c: 89 7d d4 mov %edi,-0x2c(%ebp)
59f: 83 c4 10 add $0x10,%esp
state = 0;
5a2: 31 ff xor %edi,%edi
5a4: e9 8f fe ff ff jmp 438 <printf+0x48>
s = "(null)";
5a9: bb 48 07 00 00 mov $0x748,%ebx
while(*s != 0){
5ae: b8 28 00 00 00 mov $0x28,%eax
5b3: e9 72 ff ff ff jmp 52a <printf+0x13a>
5b8: 66 90 xchg %ax,%ax
5ba: 66 90 xchg %ax,%ax
5bc: 66 90 xchg %ax,%ax
5be: 66 90 xchg %ax,%ax
000005c0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5c0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5c1: a1 f4 09 00 00 mov 0x9f4,%eax
{
5c6: 89 e5 mov %esp,%ebp
5c8: 57 push %edi
5c9: 56 push %esi
5ca: 53 push %ebx
5cb: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
5ce: 8d 4b f8 lea -0x8(%ebx),%ecx
5d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5d8: 39 c8 cmp %ecx,%eax
5da: 8b 10 mov (%eax),%edx
5dc: 73 32 jae 610 <free+0x50>
5de: 39 d1 cmp %edx,%ecx
5e0: 72 04 jb 5e6 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5e2: 39 d0 cmp %edx,%eax
5e4: 72 32 jb 618 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
5e6: 8b 73 fc mov -0x4(%ebx),%esi
5e9: 8d 3c f1 lea (%ecx,%esi,8),%edi
5ec: 39 fa cmp %edi,%edx
5ee: 74 30 je 620 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
5f0: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
5f3: 8b 50 04 mov 0x4(%eax),%edx
5f6: 8d 34 d0 lea (%eax,%edx,8),%esi
5f9: 39 f1 cmp %esi,%ecx
5fb: 74 3a je 637 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
5fd: 89 08 mov %ecx,(%eax)
freep = p;
5ff: a3 f4 09 00 00 mov %eax,0x9f4
}
604: 5b pop %ebx
605: 5e pop %esi
606: 5f pop %edi
607: 5d pop %ebp
608: c3 ret
609: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
610: 39 d0 cmp %edx,%eax
612: 72 04 jb 618 <free+0x58>
614: 39 d1 cmp %edx,%ecx
616: 72 ce jb 5e6 <free+0x26>
{
618: 89 d0 mov %edx,%eax
61a: eb bc jmp 5d8 <free+0x18>
61c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
620: 03 72 04 add 0x4(%edx),%esi
623: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
626: 8b 10 mov (%eax),%edx
628: 8b 12 mov (%edx),%edx
62a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
62d: 8b 50 04 mov 0x4(%eax),%edx
630: 8d 34 d0 lea (%eax,%edx,8),%esi
633: 39 f1 cmp %esi,%ecx
635: 75 c6 jne 5fd <free+0x3d>
p->s.size += bp->s.size;
637: 03 53 fc add -0x4(%ebx),%edx
freep = p;
63a: a3 f4 09 00 00 mov %eax,0x9f4
p->s.size += bp->s.size;
63f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
642: 8b 53 f8 mov -0x8(%ebx),%edx
645: 89 10 mov %edx,(%eax)
}
647: 5b pop %ebx
648: 5e pop %esi
649: 5f pop %edi
64a: 5d pop %ebp
64b: c3 ret
64c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000650 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
650: 55 push %ebp
651: 89 e5 mov %esp,%ebp
653: 57 push %edi
654: 56 push %esi
655: 53 push %ebx
656: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
659: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
65c: 8b 15 f4 09 00 00 mov 0x9f4,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
662: 8d 78 07 lea 0x7(%eax),%edi
665: c1 ef 03 shr $0x3,%edi
668: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
66b: 85 d2 test %edx,%edx
66d: 0f 84 9d 00 00 00 je 710 <malloc+0xc0>
673: 8b 02 mov (%edx),%eax
675: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
678: 39 cf cmp %ecx,%edi
67a: 76 6c jbe 6e8 <malloc+0x98>
67c: 81 ff 00 10 00 00 cmp $0x1000,%edi
682: bb 00 10 00 00 mov $0x1000,%ebx
687: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
68a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
691: eb 0e jmp 6a1 <malloc+0x51>
693: 90 nop
694: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
698: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
69a: 8b 48 04 mov 0x4(%eax),%ecx
69d: 39 f9 cmp %edi,%ecx
69f: 73 47 jae 6e8 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
6a1: 39 05 f4 09 00 00 cmp %eax,0x9f4
6a7: 89 c2 mov %eax,%edx
6a9: 75 ed jne 698 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
6ab: 83 ec 0c sub $0xc,%esp
6ae: 56 push %esi
6af: e8 46 fc ff ff call 2fa <sbrk>
if(p == (char*)-1)
6b4: 83 c4 10 add $0x10,%esp
6b7: 83 f8 ff cmp $0xffffffff,%eax
6ba: 74 1c je 6d8 <malloc+0x88>
hp->s.size = nu;
6bc: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
6bf: 83 ec 0c sub $0xc,%esp
6c2: 83 c0 08 add $0x8,%eax
6c5: 50 push %eax
6c6: e8 f5 fe ff ff call 5c0 <free>
return freep;
6cb: 8b 15 f4 09 00 00 mov 0x9f4,%edx
if((p = morecore(nunits)) == 0)
6d1: 83 c4 10 add $0x10,%esp
6d4: 85 d2 test %edx,%edx
6d6: 75 c0 jne 698 <malloc+0x48>
return 0;
}
}
6d8: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
6db: 31 c0 xor %eax,%eax
}
6dd: 5b pop %ebx
6de: 5e pop %esi
6df: 5f pop %edi
6e0: 5d pop %ebp
6e1: c3 ret
6e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
6e8: 39 cf cmp %ecx,%edi
6ea: 74 54 je 740 <malloc+0xf0>
p->s.size -= nunits;
6ec: 29 f9 sub %edi,%ecx
6ee: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
6f1: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
6f4: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
6f7: 89 15 f4 09 00 00 mov %edx,0x9f4
}
6fd: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
700: 83 c0 08 add $0x8,%eax
}
703: 5b pop %ebx
704: 5e pop %esi
705: 5f pop %edi
706: 5d pop %ebp
707: c3 ret
708: 90 nop
709: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
710: c7 05 f4 09 00 00 f8 movl $0x9f8,0x9f4
717: 09 00 00
71a: c7 05 f8 09 00 00 f8 movl $0x9f8,0x9f8
721: 09 00 00
base.s.size = 0;
724: b8 f8 09 00 00 mov $0x9f8,%eax
729: c7 05 fc 09 00 00 00 movl $0x0,0x9fc
730: 00 00 00
733: e9 44 ff ff ff jmp 67c <malloc+0x2c>
738: 90 nop
739: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
740: 8b 08 mov (%eax),%ecx
742: 89 0a mov %ecx,(%edx)
744: eb b1 jmp 6f7 <malloc+0xa7>
|
; A205808: G.f.: Sum_{n=-oo..oo} q^(9*n^2 + 2*n).
; 1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0
mul $0,4
sub $0,2
mul $0,9
mov $2,$0
add $2,22
mov $1,$2
seq $1,93709 ; Characteristic function of squares or twice squares.
mov $0,$1
|
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <complex>
#include "CoreTypes.hpp"
namespace Microsoft
{
namespace Quantum
{
struct QIR_SHARED_API IRuntimeDriver
{
virtual ~IRuntimeDriver() {}
IRuntimeDriver() = default;
// Doesn't necessarily provide insight into the state of the qubit (for that look at IDiagnostics)
virtual std::string QubitToString(Qubit qubit) = 0;
// Qubit management
virtual Qubit AllocateQubit() = 0;
virtual void ReleaseQubit(Qubit qubit) = 0;
virtual void ReleaseResult(Result result) = 0;
virtual bool AreEqualResults(Result r1, Result r2) = 0;
virtual ResultValue GetResultValue(Result result) = 0;
// The caller *should not* release results obtained via these two methods. The
// results are guaranteed to be finalized to the corresponding ResultValue, but
// it's not required from the runtime to return same Result on subsequent calls.
virtual Result UseZero() = 0;
virtual Result UseOne() = 0;
private:
IRuntimeDriver& operator=(const IRuntimeDriver&) = delete;
IRuntimeDriver(const IRuntimeDriver&) = delete;
};
} // namespace Quantum
} // namespace Microsoft
|
; A041614: Numerators of continued fraction convergents to sqrt(326).
; Submitted by Jon Maiga
; 18,325,11718,211249,7616682,137311525,4950831582,89252280001,3218032911618,58013844689125,2091716441720118,37708909795651249,1359612469085165082,24510733353328622725,883746013188915583182,15931938970753809120001,574433548960326043903218,10355735820256622599377925,373380923078198739621508518,6731212351227833935786531249,242697025567280220427936633482,4375277672562271801638645933925,157752693237809065079419190254782,2843923755953125443231184070520001,102539007907550325021402045728974818
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
dif $2,2
mul $2,18
add $3,$2
lpe
mov $0,$3
|
SECTION code_fp_am9511
PUBLIC l_long_div_u
EXTERN cam32_sccz80_ldiv_u_callee
defc l_long_div_u = cam32_sccz80_ldiv_u_callee
|
; int in_key_pressed(uint16_t scancode)
SECTION code_input
PUBLIC in_key_pressed
EXTERN asm_in_key_pressed
defc in_key_pressed = asm_in_key_pressed
|
#################################################
# 1er Proyecto de Organización del Computador #
# Snake Version 2.0 #
# Germano Rojas & José Quevedo #
# Teclas para usar: #
# w (Arriba/up) #
# s (Abajo/down) #
# a (Derecha/right) #
# d (Izquierda/left) #
# p (Pausar/pause) #
# r (Reiniciar/restar) #
#################################################
#########################################################
# Uso de los Registros #
# 1. $t0 Indice para recorrer el tablero / Auxiliar #
# 2. $t1 Guarda los colores para rellenar el tablero #
# 3. $t2 Contador de cuadritos para el snake #
# 4. $t3 Indice para el movimiento #
# 5. $t4 Indice para borrar #
# 6. $t5 Contiene la Direrección del movimiento #
# 7. $t6 Para manejar la velocidad #
# 8. $t7 Auxiliar para las colisiones #
# 9. $t8 Auxiliar #
# 10. $t9 Para el Manejo del tiempo #
# 11. $s0 Acumulador del puntaje #
# 12. $s1 Lleva el conteo de las vidas #
# 13. $s3 Lleva el tamaño del snake #
# #
# Indices #
# #
# $t0 para recorrer el tablero #
# $t3 para el movimiento #
# $t4 para borrar el movimiento #
# "4" para el movimiento horizontal #
# "256" para el movimiento vertical #
#########################################################
principio:
.data
# Espacio de Memoria del tablero
tablero: .space 1048576
# Colores del Juego
Cborde: .word 0x00006400 # Bordes del Tablero
Cfondo: .word 0x0000FF00 # Fondo del Tablero
Cvidas: .word 0x00FF4500 # Rojo
Csnake: .word 0x00808000 # Oliva
Cpatilla: .word 0x00FF0000 # Rojo 2
Ccambur: .word 0x00FFFF00 # Amarillo
Cnaranja: .word 0x00FFA500 # Naraja
Cmora: .word 0x004400FF # Azul
Cpopo: .word 0x00794900 # Marrón
Cpiedras: .word 0x00808080 # Gris
TiempoI: .word 0
velocidad: .word 0
auxiliar: .word 0
movimiento: .word 0
# Mensaje de puntaje
Puntaje: .asciiz "El puntaje es: "
salto: .asciiz "\n"
# Mensaje de Reinicio
reinicio: .asciiz "Desea reiniciar el juego?"
mensajePausa: .asciiz "El juego esta pausado\nDele clic en <ok> para continuar "
Inicio: .asciiz "BIENVENIDO AL JUEGO CULEBRITA ISIS!\nElaborado por: Jose Quevedo y Germano Rojas\n Dele clic en <ok> para continuar"
.text
macros:
# Instrucción para "pintar" los bordes del tablero #
.macro bordes
li $t0, 0 # Registro auxiliar para indice de inicio del tablero
# Pintar todo el tablero como si fuese el fondo "
fondo:
lw $t1, Cfondo # Obtiene el color del fondo
sw $t1, tablero($t0) # Guarda en el tablero dicho color
addi $t0, $t0, 4 # Se posiciona en la siguiente posición a "pintar"
blt $t0, 16384, fondo # Condición para que solamente utilice el espacio necesario para el tablero
li $t0, 0 # Registro auxiliar para indice de inicio del tablero
# "Pinta" el borde del tablero #
horizontal:
lw $t1, Cborde # Obtiene el color del borde
sw $t1, tablero($t0) # Guarda en el tablero dicho color
addi $t0, $t0, 4 # Se posiciona en la siguiente posición a "pintar"
blt $t0, 1024, horizontal # Condición que permite pintar solamente la parte superior del tablero
beq $t0, 16384, finalbordes # Último recuadro del borde a pintar
bge $t0, 16128, horizontal # Condición para pintar el borde inferior del tablero
vertical:
# Borde lateral izquierdo #
lw $t1, Cborde # Obtiene el color del borde
sw $t1, tablero($t0) # Guarda en el tablero dicho color
add $t0, $t0, 252 # Se posiciona en la siguiente posición a "pintar"
# Borde lateral derecho #
lw $t1, Cborde # Obtiene el color del borde
sw $t1, tablero($t0) # Guarda en el tablero dicho color
add $t0, $t0, 4 # Se posiciona en la siguiente posición a "pintar"
blt $t0, 16128, vertical # En caso de no llegar al primer recuadro del borde inferior, continúa con los laterales
b horizontal # En caso de llegar al primer recuadro del borde inferior, salta a "horizontal"
finalbordes:
.end_macro
# Suma al puntaje general de acuerdo a los siguiente criterios:
# 1. Se suman puntos cada vez que el snake va creciendo
# 2. 3 pts por cada naranja comida
# 3. 4 pts por cada cambur comida
# 4. 5 pts por cada patilla comida
# 5. 10 pts por cada mora comida
.macro SumarPuntaje ($arg)
add $s0, $s0, $arg # Al registro de puntaje le suma los puntos especificados por $arg
.end_macro
# Esta macro arma el snake dado el tamaño deseado, puede mandar el tamaño como un ope inmediato o como un registro #
.macro Armar(%arg)
li $t3, 8064 # Punto de comienzo del snake
armar:
li $t8, 1 # Referencia 1 (hacia la derecha) --- ver Macro Mover
sb $t8, movimiento # Se guarda el byte en "Movimiento"
lw $t8, movimiento # Se obtiene el byte
sll $t8, $t8, 24 # Se corren 24 bits para poder guardar el color del Snake junto con la referencia a movimiento
lw $t1, Csnake # Se obtiene el color del Snake
add $t1, $t1, $t8 # Se le añade al byte corrido para guardarlo en el tablero
sw $t1, tablero($t3) # Se guarda en el tablero
addi $t3, $t3, 4 # $t3 funciona como indice para construir el snake, se aumente en 4 para ir con el oro cuadro
addi $t2, $t2, 1 # $t2 funciona como contador para saber cuantos cuadros falta por llenar
blt $t2, %arg, armar # Condición para seguir "pintando" cuadros en el tablero
subi $t3, $t3, 4 # Posiciona el indice de la cabeza del snake en la posición del último cuadro "pintado" (la cabeza)
li $t8, 64 # Proporciona un numero en ascii neutral para empezar a hacer el movimiento hacia la derecha desde el inicio
sw $t8, 0xFFFF0004 # Guarda dicho número
.end_macro
# Esta Macro pinta la cantidad de Vidas en el Tablero #
.macro Vidas
lw $t1, Cvidas
# "Pinta" de rojo los recuadros que indican la primera vida #
Vida1:
sw $t1, tablero+268
sw $t1, tablero+272
sw $t1, tablero+524
sw $t1, tablero+528
# "Pinta" de rojo los recuadros que indican la primera vida #
Vida2:
sw $t1, tablero+280
sw $t1, tablero+284
sw $t1, tablero+536
sw $t1, tablero+540
# "Pinta" de rojo los recuadros que indican la primera vida #
Vida3:
sw $t1, tablero+292
sw $t1, tablero+296
sw $t1, tablero+548
sw $t1, tablero+552
.end_macro
# Divide el tiempo de espera entre 5 y eso permite aumentar la veloidad del movimiento #
.macro aumentarVelocidad
# Si la velocidad es divible entre 5, la reduce, sino llegó al máximo
bgtz $t6, aumentar # Comprueba que la velocidad actual sea mayor a 0
b terminarMacro
aumentar:
li $t8, 0
# Comprueba que la velocidad sea divisible entre 5 #
rem $t8, $t6, 5
bgtz $t8, terminarMacro
div $t8, $t6, 5 # Realiza la división
sub $t6, $t6, $t8 # Sustrae el resultado de la división a la velocidad actual
terminarMacro:
.end_macro
# Genera las Frutas y las coloca aleatoriamente en el Tablero #
# Falta verificar que no haya nada en la posición generada :|
.macro frutasRandom
li $t8, 0 # Registro auxiliar a usarse luego
loopCantidadFRandom:
# Genera la cantidad de las frutas de forma aleatoria
li $a0, 1
li $a1, 10
li $v0, 42
syscall
move $t9, $a0
blt $t9, 2, loopCantidadFRandom # Condición para obtener más de dos frutas como mínimo
li $s5, 0 # Registro utilizado para contar cuántas frutas se han colocado en el tablero
loopCantidadF:
# Instrucciones para obtener la posición donde se colocarán las frutas #
loopRandom:
# Se obtiene la posición aleatoria #
li $a0, 1
li $a1, 4031
li $v0, 42
syscall
move $t7, $a0
mul $t7, $t7, 4 # El número de la posición debe ser múltiplo de 4
blt $t7, 1024, loopRandom # La posición debe estar debajo del borde superior, es decir en el tablero
# Evalua si en la posición establecida hay algún otro objeto #
lw $t1, Cfondo
lw $t8, tablero($t7)
bne $t8, $t1, loopRandom
# Determinación aleatoria de cuál furta colocar #
fruticasRandom:
especiales:
rem $t8, $s3, 3 # Como es una fruta especial, la condicion especial es que si el tamaño del Snake es múltiplo de 3, se pueden colocar moras
beqz $t8, mora # En caso que si sea múltiplo de 3, se coloca la mora
rem $t8, $s3, 5 # Como es un objeto especial, la condicion especial es que si el tamaño del Snake es múltiplo de 5, se pueden colocar popos
beqz $t8, popo # En caso que si sea múltiplo de 5, se coloca el popo que restará 5 pts. al puntaje
normales:
# Las frutas normales se manejan con un número aleatorio del 0 al 3"
li $a0, 1
li $a1, 4
li $v0, 42
syscall
move $t8, $a0
beqz $t8, finMacroFrutasR # En caso de arrojar 0, no se coloca fruta
beq $t8, 1, patilla # En caso de arrojar 1, se coloca un patilla
beq $t8, 2, cambur # En caso de arrojar 2, se coloca un cambur
beq $t8, 3, naraja # En caso de arrojar 3, se coloca una naranja
# Instrucciones para colocar las frutas en el tablero #
patilla:
lw $t1, Cpatilla
sw $t1, tablero($t7)
b finMacroFrutasR
cambur:
lw $t1, Ccambur($zero)
sw $t1, tablero($t7)
b finMacroFrutasR
naraja:
lw $t1, Cnaranja
sw $t1, tablero($t7)
b finMacroFrutasR
mora:
lw $t1, Cmora
sw $t1, tablero($t7)
b normales
popo:
lw $t1, Cpopo
sw $t1, tablero($t7)
b normales
finMacroFrutasR:
addi $s5, $s5, 1 # Contador para saber cuántas frutas se han colocado
blt $s5, $t9, loopCantidadF # Condición para colocar todas las frutas
.end_macro
# Genera Obstaculos y los coloca aleatoriamente en el Tablero #
.macro obstaculosRandom
loopcantidadRandom:
li $t8, 0
li $t0, 0
# Genera la cantidad de los obtaculos de forma aleatoria
li $a0, 1
move $a1, $s3
li $v0, 42
syscall
move $t9, $a0
beqz $t9, loopcantidadRandom
bgt $t9, 10, loopcantidadRandom
li $s5, 0 # Registro auxiliar para saber cuantos obstáculos se han colocado
loopCantidadO:
looptamanioRandom:
li $t8, 0
li $t0, 0
# Genera el tamaño de los obstaculos de forma aleatoria
li $a0, 1
li $a1, 8 # El tamaño está limitado por 8 cuadros
li $v0, 42
syscall
move $t0, $a0
beqz $t0, looptamanioRandom # El tamaño no puede ser igual a 0
# Genera la posicion aleatoria
loopRandomO:
li $a0, 1
li $a1, 4031
li $v0, 42
syscall
move $t7, $a0
mul $t7, $t7, 4 # La posición debe ser múltiplo de 4
blt $t7, 1024, loopcantidadRandom # En caso de arrojar una posición en el borde superior, buscar otra posición
sw $t7, auxiliar # Guarda la posición en memoria para usarla después
li $t2, 0 # Contador de piezas colocadas
# Comprueba si hay algún objeto que interfiera en el espacio del obstáculo #
comprobar:
lw $t1, Cfondo # Obtiene el color del fondo
lw $t8, tablero($t7) # Obtiene el color del tablero en la posición a poner el obstáculo
bne $t8, $t1, loopcantidadRandom # Compara para saber si hay algun objeto en el lugar
addi $t2, $t2, 1 # Contador para saber cuántas piezas del obstáculo se han evaluado
addi $t7, $t7, 4 # Mueve el indice de posicionamiento para evaluar la siguiente pieza
ble $t2, $t0, comprobar # Conidición para saber si faltan piezas por evaluar
li $t8, 0 # Contador para saber cuantás piezas faltan por colocar
lw $t7, auxiliar # Obtiene la posición inicial del obstáculo
# Una vez que se comprueba que el espacio total para poner el obstáculo está libre, se coloca el obstáculo #
loopTamanioO:
lw $t1, Cpiedras # Obtiene el color del obstáculo
sw $t1, tablero($t7) # Guarda el color en el tablero
addi $t7, $t7, 4 # Aumenta el indice de posicionamiento
addi $t8, $t8, 1 # Aumenta el contador
blt $t8, $t0, loopTamanioO # Loop para saber si ya las piezas se colocaron en su totalidad
# Averigua si faltan obstáculos por colocar #
addi $s5, $s5, 1 # Aumenta el contador de obstáculo por colocar en total
ble $s5, $t9, loopCantidadO # Loop para saber si ya los obstáculos se colocaron en su totalidad
.end_macro
# Macro para realizar movimientos #
.macro mover($arg)
inicioM:
colision($arg) # Intrucciones de colisiones
li $t8, 0 # Registro auxiliar, se usará luego
beq $arg, 4, der # En caso de quereserse mover a la derecha ($arg = 4), saltar a der
beq $arg, -4, izq # En caso de quereserse mover a la derecha ($arg = -4), saltar a izq
beq $arg, 256, aba # En caso de quereserse mover a la derecha ($arg = 256), saltar a aba
beq $arg, -256, arr # En caso de quereserse mover a la derecha ($arg = -256), saltar a arr
# Movimiento hacia la derecha #
der:
li $t8, 1 # Se carga un numeor de referencia (1) para guardarlo junto con el color del Snake en el tablero
sb $t8, movimiento # Se carga el byte al espacio en memoria "movimiento"
b moveS # Salta
# Movimiento hacia la izquierda #
izq:
li $t8, 2 # Se carga un numeor de referencia (2) para guardarlo junto con el color del Snake en el tablero
sb $t8, movimiento # Se carga el byte al espacio en memoria "movimiento"
b moveS # Salta
# Movimiento hacia la abajo #
aba:
li $t8, 3 # Se carga un numeor de referencia (3) para guardarlo junto con el color del Snake en el tablero
sb $t8, movimiento # Se carga el byte al espacio en memoria "movimiento"
b moveS # Salta
# Movimiento hacia la arriba #
arr:
li $t8, 4 # Se carga un numeor de referencia (4) para guardarlo junto con el color del Snake en el tablero
sb $t8, movimiento # Se carga el byte al espacio en memoria "movimiento"
b moveS # Salta
li $t8, 0 # Registro auxiliar, se lleva a 0
# Instrucciones para guardar el movimiento junto con el color del Snake #
moveS:
lw $t1, movimiento # Se obtiene la palabra de "movimiento" en este caso el numero de referencia
sll $t1, $t1, 24 # Dicha palabra se corre 24 bits para colocar el byte de referencia más hacia la izquierda (*)
lw $t7, Csnake
# (*) Se hace esto debido a que para "pintar" el tablero, el sistema lee los ultimos 3 bytes de izquierda a derecha, los byte del color #
add $t1, $t1, $t7 # Se añade el color al numero de referencia corrido
sw $t1, tablero($t3) # Se guarda el movimiento y el color en el tablero
add $t3, $t3, $arg # Se le suma al indice de la cabeza del snake el numero dependiendo de cuál es el movimiento que se quiere, de tal forma lo realiza
sw $t1, tablero($t3) # Se guarda el color del Snake en el recuadro del tablero dependiendo de $t3
beqz $t0, tiempo # En caso que no sea necesario aumentar el tamaño del Snake, se salta a "tiempo"
# En caso de aumentar el tamaño del snake se realiza lo siguiente #
addi $t8, $t8, 1 # $t8 funciona como contador
ble $t8, $t0, moveS # Hasta que el contador no alcance el tamaño de la serpiente, esta no accederá a las instrucciones de borrado por lo que "aumentará" de tamaño
# Determina su movimiento en relación al tiempo (velocidad) #
tiempo:
# Sleep que determina esta velocidad
li $v0, 32
la $a0, ($t6) # $t6 establece los milisegundos que se "dormirá" el proceso
syscall
# Inicio de las instrucciones de borrado #
lw $t1, Csnake # Obtiene el color del Snake para compararlo posteriormente
li $t8, 0
lw $t8, tablero($t4) # Obtiene lo que está contenido en el tablero en la posición establecida por el indice de borrado o cola ($t4)
# Condición para realizar el borrado #
derecha:
li $t7, 4 # Numero a sumarse para ir a la derecha
beq $t8, 25198592, borrar # Si el numero guardado en la posición del tablero dada por el índice es igual al mostrado, borrar hacia la derecha
izquierda:
li $t7, -4 # Numero a sumarse para ir a la izquierda
beq $t8, 41975808, borrar # Si el numero guardado en la posición del tablero dada por el índice es igual al mostrado, borrar hacia la izquierda
abajo:
li $t7, 256 # Numero a sumarse para ir a la abajo
beq $t8, 58753024, borrar # Si el numero guardado en la posición del tablero dada por el índice es igual al mostrado, borrar hacia la abajo
arriba:
li $t7, -256 # Numero a sumarse para ir a la arriba
beq $t8, 75530240, borrar # Si el numero guardado en la posición del tablero dada por el índice es igual al mostrado, borrar hacia la arriba
# Instrucción de borrado, de tal forma se da ilusión de movimiento dle snake #
borrar:
lw $t1, Cfondo # Obtiene el color del fondo del tablero
sw $t1, tablero($t4) # Guarda dicho color en la posición que se desea borrar
add $t4, $t4, $t7 # Cambia el índice de borrado o cola para la proxima posición a evaluar
.end_macro
# Verifica si el snake choco contra un borde o un obstaculo #
.macro colision($arg)
# Carga el color que esta proximo a la cabeza del snake #
add $t3, $t3, $arg # Obtiene el espacio próximo, según el movimiento, para saber si hay algo
lw $t1, tablero($t3) # Obtiene el color de ese espacio
sub $t3, $t3, $arg # Devuelve a la posición de antes
lw $t7, Cborde # Carga el color del borde
beq $t7, $t1, pierdeVida # Descuenta una Vida y reinicia al snake
lw $t7, Cpiedras # Carga el color de las piedras
beq $t7, $t1, pierdeVida # Descuenta una Vida y reinicia al snake
lw $t7, Csnake # Carga el color del snake
beq $t1, $t7, pierdeVida # Descuenta una Vida y reinicia al snake
li $t0, 0 # Se usa $t0 como registro auxiliar que permita determinar que tanto se aumenta el tamaño del snake #
lw $t7, Cfondo # Carga el color del fondo
beq $t1, $t7, finalMacro # Termina la macro si no choco
# En caso de "colisionar" o comer una fruta #
lw $t7, Cpatilla # Obtiene el color de la fruta
li $t0, 5 # Numero de cuadros extras en el Snake
addi $s3, $s3, 5 # Conserva el numero de cuadros que forman el snake, útil para obtener un puntaje mayor dependiendo del tamaño del snake
beq $t1, $t7, finalMacro # Salta las demas condiciones, en caso que esta esté acertada
lw $t7, Ccambur # Obtiene el color de la fruta
li $t0, 4 # Numero de cuadros extras en el Snake
addi $s3, $s3, 4 # Conserva el numero de cuadros que forman el snake, útil para obtener un puntaje mayor dependiendo del tamaño del snake
beq $t1, $t7, finalMacro # Salta las demas condiciones, en caso que esta esté acertada
lw $t7, Cnaranja # Obtiene el color de la fruta
li $t0, 3 # Numero de cuadros extras en el Snake
addi $s3, $s3, 3 # Conserva el numero de cuadros que forman el snake, útil para obtener un puntaje mayor dependiendo del tamaño del snake
beq $t1, $t7, finalMacro # Salta las demas condiciones, en caso que esta esté acertada
lw $t7, Cmora # Obtiene el color de la fruta
li $t0, 10 # Numero de cuadros extras en el Snake
addi $s3, $s3, 10 # Conserva el numero de cuadros que forman el snake, útil para obtener un puntaje mayor dependiendo del tamaño del snake
beq $t1, $t7, finalMacro # Salta las demas condiciones, en caso que esta esté acertada
lw $t7, Cpopo # Obtiene el color del objeto
li $t0, 1 # Numero de cuadros extras en el Snake
subi $s0, $s0, 5 # Resta 5 puntos
addi $s3, $s3, 1 # Conserva el numero de cuadros que forman el snake, útil para obtener un puntaje mayor dependiendo del tamaño del snake
beq $t1, $t7, finalMacro # Salta las demas condiciones, en caso que esta esté acertada
# Intrucciones en caso que haya una colisión #
pierdeVida:
subi $s1, $s1, 1 # Resta una vida
una:
bordes # Vuelve a poner el trablero como el inicio
Vidas # Pinta las vidas
li $t7, 0
# Resta el primer recuadro de las vidas #
sw $t7, tablero+268
sw $t7, tablero+272
sw $t7, tablero+524
sw $t7, tablero+528
ble $s1, 1, dos # En caso que sea la segunda vida perdida, salta a "dos"
b loopVidas # Continúa
dos:
li $t7, 0
# Resta el segundo recuadro de las vidas #
sw $t7, tablero+280
sw $t7, tablero+284
sw $t7, tablero+536
sw $t7, tablero+540
beq $s1, 0, tres # En caso que sea la tercera vida perdida, salta a "tres"
b loopVidas # Continúa
tres:
li $t7, 0
# Resta el segundo recuadro de las vidas #
sw $t7, tablero+292
sw $t7, tablero+296
sw $t7, tablero+548
sw $t7, tablero+552
b reiniciar # En este caso ya no quedan más vidas asi que salta a la pregunta de reiniciar o no
finalMacro:
SumarPuntaje ($t0) # En caso de obtener puntaje, lo suma
.end_macro
# Macro para reestablecer las condiciones del tablero sin obstáculos o frutas #
.macro reestablecer
li $t8, 1024
lw $t1, Cfondo # Color de fondo #
inicioRes:
lw $t0, tablero($t8) # Obtiene el contenido del recuadro en el tablero #
beq $t0, $t1, saltar
# Cuadros que no deben ser "borrados" del tablero #
li $t7, 25198592 # Numero resultante de la suma del numero decimal más el numero usado para referenciarse al respectivo movimiento (ver Macro de movimiento)
beq $t0, $t7, saltar
li $t7, 41975808 # Numero resultante de la suma del numero decimal más el numero usado para referenciarse al respectivo movimiento (ver Macro de movimiento)
beq $t0, $t7, saltar
li $t7, 58753024 # Numero resultante de la suma del numero decimal más el numero usado para referenciarse al respectivo movimiento (ver Macro de movimiento)
beq $t0, $t7, saltar
li $t7, 75530240 # Numero resultante de la suma del numero decimal más el numero usado para referenciarse al respectivo movimiento (ver Macro de movimiento)
beq $t0, $t7, saltar
lw $t7, Cborde # Color del borde #
beq $t0, $t7, saltar
# Pinta el fondo del tablero #
pintar:
sw $t1, tablero($t8)
# En caso de presentarse algún objeto que se debe conservar en el tablero, se salta al siguiente recuadro #
saltar:
addi $t8, $t8, 4
blt $t8, 16124, inicioRes
.end_macro
# Este es el comienzo del juego, al principio se inicializan las vidas y el puntaje #
inicio1:
la $a0, Inicio
li $a1, 2
li $v0, 55
syscall
bordes
main:
li $s0, 0 # Cantidad de Puntos acumulados
li $s1, 3 # Vidas del snake
li $s3, 5 # Cantidad de cuadritos del snake
Vidas
loopVidas:
li $t6, 1000 # Tiempo predeterminado para comenzar
li $s3, 5
star: # Inicio del Juego
li $t2, 0 # Contador de cuadritos para el snake
li $t3, 8064 # Indice para Avanzar (Primera Posicion)
li $t4, 8064 # Indice para Borrar
Armar(5) # Macro para armar al snake (Cantidad de cuadros)
pausa1:
lw $t9, 0xffff0000
beq $t9, 0, pausa1
beq $t9, 1, loopJuego
# Ciclo del juego, se lee hacia donde se quiere ir para luego realizar las instrucciones respectivas #
loopJuego:
#contar tiempo
li $t8, 0
li $v0, 30
syscall
move $t8, $a0
sw $t8, TiempoI
mientras: #loop para hacer un movimiento
lw $t9, 0xFFFF0004
move $t8, $t9
preguntar:
# Condiciones para moverse
beq $t9, 72, principio # Lleva al inicio del juego
beq $t9, 70, final # Finaliza el juego
beq $t9, 112, pausa # Pausa el juego, es necesario volver a apretar esta tecla para continuar
beq $t9, 119, arriba # Movimiento hacia arriba
beq $t9, 115, abajo # Movimiento hacia abajo
beq $t9, 64, inicio # Movimiento hacia la derecha
beq $t9, 100, derecha # Movimiento hacia la derecha 2
beq $t9, 97, izquierda # Movimiento hacia la izquierda
## En caso que se teclee alguna tecla errónea el juego continuará sin alteraciones ##
bne $t9, 72, siga2
bne $t9, 70, siga2
bne $t9, 112, siga2
bne $t9, 119, siga2
bne $t9, 115, siga2
bne $t9, 64, siga2
bne $t9, 100, siga2
bne $t9, 97, siga2
# Mensaje de pausa por consola #
pausa:
la $a0, mensajePausa
li $a1, 2
li $v0, 55 # Imprime mensaje de pausa
syscall
b pausa1 # Condicion para que el pueda seguir el juego
# Instrucciones de movimiento
arriba:
beq $s4, 256, siga2 # Condición para que no vaya en sentido contrario
li $s4, -256 # Se resta 256 a la posición actual para que suba el cuadrito
b siga2 # Continúa
abajo:
beq $s4, -256, siga2 # Condición para que no vaya en sentido contrario
li $s4, 256 # Se resta 256 a la posición actual para que suba el cuadrito
b siga2 # Continúa
derecha:
beq $s4, -4, siga2 # Condición para que no vaya en sentido contrario
li $s4, 4 # Se resta 256 a la posición actual para que suba el cuadrito
b siga2 # Continúa
izquierda:
beq $s4, 4, siga2 # Condición para que no vaya en sentido contrario
li $s4, -4 # Se resta 256 a la posición actual para que suba el cuadrito
b siga2
inicio:
li $s4, 4 # Se resta 256 a la posición actual para que suba el cuadrito
b siga2 # Continúa
siga2: # Loop para saltar cuando se sepa qué movimiento hacer
mover($s4) # Macro de movimiento, están las instrucciones que permiten el movimiento del Snake
bnez $t0, aparicion # En caso que se coma una fruta "aparición" salta al label para limpiar el tablero
# 2da toma de tiempo
li $v0, 30
syscall
move $t0, $a0
lw $t8, TiempoI
sub $t8, $t0, $t8 # Resta para saber si han pasado 10 segundos
blt $t8, 10000, mientras # Condicion de los 10 segundos
SumarPuntaje ($s3) #suma un punto por cada 10 segundos transcurridos dependiendo de la dificultad
aparicion: # Pasados 10 segundos o comida una fruta, pone en blanco el tablero para volver a poner las otras frutas/obstaculos
reestablecer # Pone en blanco el tablero y conserva la posicion del snake
obstaculosRandom # Coloca nuevos obstaculos
frutasRandom # Coloca nuevas frutas
# Imprime el puntaje por consola #
la $a0, salto # Salto para que se vea mas ordenado
li $v0, 4
syscall
la $a0, Puntaje
li $v0, 4
syscall
move $a0, $s0
li $v0, 1
syscall
la $a0, salto # Salto para que se vea mas ordenado
li $v0, 4
syscall
sw $zero, TiempoI # Retorna a 0 la posicion de memoria donde se guarda el tiempo para que se cuente a partir de ahí 10 segundos
blt $t6, 200, siga # Condicion para que la velocidad no disminuya menor a 0.20 segundos
aumentarVelocidad # Aumenta la velocidad
siga:
b loopJuego # Retorna para seguir jugando
# Condiciones del loop de vidas #
beqz $s1, reiniciar # Si llego a 0 vida pregunto para reiniciar
ble $s1, 3, loopVidas # Sino vuelvo a iniciar todo el proceso del juego
# Para reiniciar el Juego #
reiniciar:
la $a0, reinicio # Pregunto por otra partida
li $v0, 50
syscall
beqz $a0, otraPartida
# Para salir del juego #
final:
li $v0, 10
syscall
# Permite otra partida #
otraPartida:
b principio
|
<%
from pwnlib.shellcraft.aarch64.linux import syscall
%>
<%page args="algorithm"/>
<%docstring>
Invokes the syscall sched_get_priority_min. See 'man 2 sched_get_priority_min' for more information.
Arguments:
algorithm(int): algorithm
</%docstring>
${syscall('SYS_sched_get_priority_min', algorithm)}
|
__Z3vmlPmm:
pushq %rbp
movq %rsp, %rbp
movq %rsi, %rax
shrq $36, %rax
andl $4088, %eax
movq (%rdi,%rax), %rax
testb $1, %al
je error
andq $-4096, %rax
movq %rsi, %rcx
shrq $27, %rcx
andl $4088, %ecx
movq (%rax,%rcx), %rax
testb $1, %al
je error
andq $-4096, %rax
movq %rsi, %rcx
shrq $18, %rcx
andl $4088, %ecx
movq (%rax,%rcx), %rax
testb $1, %al
je error
andq $-4096, %rax
movq %rsi, %rcx
shrq $9, %rcx
andl $4088, %ecx
movq (%rax,%rcx), %rax
testb $1, %al
je error
andq $-4096, %rax
andl $4095, %esi
orq %rax, %rsi
done:
movq %rsi, %rax
popq %rbp
retq
error:
xorl %esi, %esi
jmp done
|
db "BIVALVE@" ; species name
dw 411, 2920 ; height, weight
db "Even a missile"
next "can't break the"
next "spikes it uses to"
page "stab opponents."
next "They're even hard-"
next "er than its shell.@"
|
.text
.globl swap
# Swaps contents of $a0 with $a1
swap:
lw $t0, 0($a0)
lw $t1, 0($a1)
sw $t1, 0($a0)
sw $t0, 0($a1)
jr $ra |
lui $1,55254
ori $1,$1,60629
lui $2,38275
ori $2,$2,61248
lui $3,52525
ori $3,$3,57097
lui $4,62604
ori $4,$4,37951
lui $5,51666
ori $5,$5,7983
lui $6,19026
ori $6,$6,39122
mthi $1
mtlo $2
sec0:
nop
nop
nop
or $5,$6,$6
sec1:
nop
nop
and $6,$3,$3
or $5,$6,$6
sec2:
nop
nop
xori $6,$1,11488
or $2,$6,$6
sec3:
nop
nop
mflo $6
or $4,$6,$6
sec4:
nop
nop
lbu $6,6($0)
or $2,$6,$6
sec5:
nop
addu $6,$1,$1
nop
or $3,$6,$6
sec6:
nop
sltu $6,$3,$3
and $6,$3,$6
or $0,$6,$6
sec7:
nop
addu $6,$1,$3
ori $6,$4,13123
or $2,$6,$6
sec8:
nop
nor $6,$3,$1
mfhi $6
or $1,$6,$6
sec9:
nop
nor $6,$5,$2
lw $6,4($0)
or $2,$6,$6
sec10:
nop
sltiu $6,$2,-28821
nop
or $2,$6,$6
sec11:
nop
slti $6,$2,10855
subu $6,$3,$3
or $3,$6,$6
sec12:
nop
ori $6,$2,65060
lui $6,26025
or $0,$6,$6
sec13:
nop
lui $6,12053
mflo $6
or $2,$6,$6
sec14:
nop
addiu $6,$3,-3312
lhu $6,10($0)
or $4,$6,$6
sec15:
nop
mflo $6
nop
or $2,$6,$6
sec16:
nop
mflo $6
or $6,$5,$5
or $4,$6,$6
sec17:
nop
mflo $6
ori $6,$3,13986
or $3,$6,$6
sec18:
nop
mfhi $6
mflo $6
or $4,$6,$6
sec19:
nop
mfhi $6
lw $6,0($0)
or $5,$6,$6
sec20:
nop
lh $6,8($0)
nop
or $4,$6,$6
sec21:
nop
lbu $6,0($0)
slt $6,$6,$2
or $2,$6,$6
sec22:
nop
lh $6,8($0)
xori $6,$0,60317
or $3,$6,$6
sec23:
nop
lb $6,11($0)
mfhi $6
or $2,$6,$6
sec24:
nop
lbu $6,5($0)
lh $6,8($0)
or $5,$6,$6
sec25:
xor $6,$0,$0
nop
nop
or $3,$6,$6
sec26:
subu $6,$4,$0
nop
nor $6,$2,$3
or $4,$6,$6
sec27:
or $6,$0,$2
nop
addiu $6,$4,32183
or $6,$6,$6
sec28:
nor $6,$2,$4
nop
mfhi $6
or $5,$6,$6
sec29:
nor $6,$3,$3
nop
lw $6,4($0)
or $4,$6,$6
sec30:
or $6,$1,$3
xor $6,$1,$6
nop
or $4,$6,$6
sec31:
and $6,$2,$2
addu $6,$3,$3
nor $6,$0,$2
or $3,$6,$6
sec32:
and $6,$3,$3
addu $6,$2,$1
slti $6,$5,-31143
or $2,$6,$6
sec33:
xor $6,$2,$1
sltu $6,$4,$2
mfhi $6
or $3,$6,$6
sec34:
xor $6,$2,$4
subu $6,$1,$4
lb $6,11($0)
or $0,$6,$6
sec35:
xor $6,$3,$1
addiu $6,$2,-21515
nop
or $2,$6,$6
sec36:
sltu $6,$5,$3
xori $6,$3,34035
sltu $6,$4,$2
or $4,$6,$6
sec37:
subu $6,$2,$4
lui $6,32224
lui $6,44202
or $3,$6,$6
sec38:
xor $6,$2,$0
addiu $6,$2,-22695
mflo $6
or $4,$6,$6
sec39:
slt $6,$2,$0
lui $6,21500
lh $6,14($0)
or $2,$6,$6
sec40:
nor $6,$2,$3
mflo $6
nop
or $2,$6,$6
sec41:
or $6,$3,$3
mfhi $6
addu $6,$6,$2
or $2,$6,$6
sec42:
xor $6,$2,$2
mfhi $6
slti $6,$2,-1466
or $2,$6,$6
sec43:
slt $6,$2,$3
mflo $6
mflo $6
or $3,$6,$6
sec44:
nor $6,$3,$5
mflo $6
lh $6,12($0)
or $3,$6,$6
sec45:
nor $6,$5,$5
lhu $6,10($0)
nop
or $3,$6,$6
sec46:
subu $6,$3,$1
lbu $6,3($0)
sltu $6,$4,$6
or $1,$6,$6
sec47:
xor $6,$3,$0
lhu $6,12($0)
lui $6,44966
or $4,$6,$6
sec48:
or $6,$3,$3
lbu $6,0($0)
mfhi $6
or $4,$6,$6
sec49:
slt $6,$2,$2
lw $6,8($0)
lbu $6,6($0)
or $4,$6,$6
sec50:
sltiu $6,$4,9305
nop
nop
or $4,$6,$6
sec51:
lui $6,7529
nop
or $6,$4,$2
or $2,$6,$6
sec52:
andi $6,$3,60622
nop
xori $6,$2,42391
or $6,$6,$6
sec53:
ori $6,$3,32420
nop
mfhi $6
or $1,$6,$6
sec54:
ori $6,$3,16247
nop
lbu $6,1($0)
or $3,$6,$6
sec55:
lui $6,52607
and $6,$0,$2
nop
or $3,$6,$6
sec56:
ori $6,$5,35728
subu $6,$2,$2
and $6,$3,$4
or $5,$6,$6
sec57:
addiu $6,$4,7046
slt $6,$5,$6
andi $6,$3,21489
or $4,$6,$6
sec58:
addiu $6,$3,-22773
and $6,$3,$0
mflo $6
or $2,$6,$6
sec59:
addiu $6,$1,6429
addu $6,$3,$2
lhu $6,2($0)
or $2,$6,$6
sec60:
lui $6,28795
addiu $6,$6,-23176
nop
or $0,$6,$6
sec61:
addiu $6,$1,-8901
addiu $6,$4,-18963
and $6,$3,$2
or $2,$6,$6
sec62:
andi $6,$1,1490
andi $6,$4,59385
addiu $6,$4,-18676
or $4,$6,$6
sec63:
xori $6,$6,42592
andi $6,$6,49778
mfhi $6
or $3,$6,$6
sec64:
ori $6,$1,25370
xori $6,$2,26140
lw $6,8($0)
or $5,$6,$6
sec65:
addiu $6,$4,-2646
mflo $6
nop
or $4,$6,$6
sec66:
lui $6,38481
mflo $6
xor $6,$4,$4
or $4,$6,$6
sec67:
sltiu $6,$3,5116
mflo $6
sltiu $6,$1,-7079
or $4,$6,$6
sec68:
ori $6,$1,62388
mfhi $6
mfhi $6
or $3,$6,$6
sec69:
xori $6,$4,40947
mfhi $6
lw $6,0($0)
or $6,$6,$6
sec70:
slti $6,$5,-11964
lh $6,0($0)
nop
or $0,$6,$6
sec71:
addiu $6,$3,-29501
lhu $6,16($0)
and $6,$2,$4
or $3,$6,$6
sec72:
addiu $6,$2,-2816
lbu $6,12($0)
andi $6,$4,38255
or $3,$6,$6
sec73:
slti $6,$4,22661
lh $6,6($0)
mfhi $6
or $6,$6,$6
sec74:
sltiu $6,$2,3314
lbu $6,14($0)
lw $6,4($0)
or $4,$6,$6
sec75:
mflo $6
nop
nop
or $6,$6,$6
sec76:
mfhi $6
nop
xor $6,$5,$3
or $0,$6,$6
sec77:
mflo $6
nop
andi $6,$5,30227
or $5,$6,$6
sec78:
mflo $6
nop
mfhi $6
or $2,$6,$6
sec79:
mflo $6
nop
lbu $6,11($0)
or $2,$6,$6
sec80:
mfhi $6
xor $6,$3,$2
nop
or $4,$6,$6
sec81:
mflo $6
sltu $6,$4,$4
xor $6,$1,$2
or $4,$6,$6
sec82:
mflo $6
sltu $6,$4,$2
ori $6,$3,30609
or $2,$6,$6
sec83:
mflo $6
or $6,$0,$4
mfhi $6
or $5,$6,$6
sec84:
mfhi $6
and $6,$2,$2
lb $6,15($0)
or $1,$6,$6
sec85:
mfhi $6
xori $6,$3,15171
nop
or $0,$6,$6
sec86:
mflo $6
lui $6,42500
nor $6,$3,$4
or $3,$6,$6
sec87:
mflo $6
slti $6,$5,-18126
slti $6,$5,13069
or $0,$6,$6
sec88:
mflo $6
xori $6,$3,61646
mfhi $6
or $0,$6,$6
sec89:
mfhi $6
andi $6,$6,22924
lw $6,4($0)
or $3,$6,$6
sec90:
mfhi $6
mflo $6
nop
or $5,$6,$6
sec91:
mfhi $6
mfhi $6
xor $6,$3,$2
or $2,$6,$6
sec92:
mflo $6
mfhi $6
sltiu $6,$2,5268
or $2,$6,$6
sec93:
mflo $6
mflo $6
mflo $6
or $0,$6,$6
sec94:
mfhi $6
mflo $6
lh $6,0($0)
or $1,$6,$6
sec95:
mflo $6
lhu $6,14($0)
nop
or $3,$6,$6
sec96:
mflo $6
lhu $6,14($0)
nor $6,$0,$5
or $5,$6,$6
sec97:
mfhi $6
lh $6,10($0)
slti $6,$1,-8179
or $2,$6,$6
sec98:
mfhi $6
lb $6,11($0)
mflo $6
or $3,$6,$6
sec99:
mfhi $6
lh $6,12($0)
lw $6,0($0)
or $3,$6,$6
sec100:
lhu $6,16($0)
nop
nop
or $4,$6,$6
sec101:
lb $6,13($0)
nop
addu $6,$3,$2
or $5,$6,$6
sec102:
lh $6,4($0)
nop
xori $6,$3,33900
or $5,$6,$6
sec103:
lw $6,0($0)
nop
mfhi $6
or $5,$6,$6
sec104:
lhu $6,14($0)
nop
lbu $6,8($0)
or $2,$6,$6
sec105:
lh $6,8($0)
subu $6,$0,$4
nop
or $2,$6,$6
sec106:
lw $6,4($0)
and $6,$2,$6
or $6,$2,$3
or $2,$6,$6
sec107:
lw $6,16($0)
sltu $6,$4,$2
andi $6,$1,17353
or $5,$6,$6
sec108:
lw $6,8($0)
or $6,$0,$3
mfhi $6
or $6,$6,$6
sec109:
lh $6,0($0)
addu $6,$3,$1
lbu $6,6($0)
or $0,$6,$6
sec110:
lw $6,16($0)
addiu $6,$3,17196
nop
or $5,$6,$6
sec111:
lw $6,4($0)
slti $6,$2,-15185
subu $6,$3,$2
or $1,$6,$6
sec112:
lh $6,6($0)
xori $6,$5,12374
lui $6,57206
or $2,$6,$6
sec113:
lb $6,3($0)
xori $6,$3,32348
mfhi $6
or $3,$6,$6
sec114:
lbu $6,12($0)
xori $6,$2,59734
lh $6,8($0)
or $5,$6,$6
sec115:
lh $6,4($0)
mfhi $6
nop
or $6,$6,$6
sec116:
lbu $6,10($0)
mfhi $6
sltu $6,$2,$2
or $0,$6,$6
sec117:
lhu $6,2($0)
mflo $6
ori $6,$4,46736
or $3,$6,$6
sec118:
lhu $6,10($0)
mflo $6
mflo $6
or $0,$6,$6
sec119:
lh $6,6($0)
mfhi $6
lw $6,8($0)
or $2,$6,$6
sec120:
lb $6,14($0)
lh $6,12($0)
nop
or $2,$6,$6
sec121:
lbu $6,5($0)
lh $6,2($0)
addu $6,$3,$1
or $1,$6,$6
sec122:
lh $6,16($0)
lhu $6,8($0)
andi $6,$1,62344
or $3,$6,$6
sec123:
lb $6,14($0)
lb $6,6($0)
mfhi $6
or $4,$6,$6
sec124:
lw $6,0($0)
lhu $6,4($0)
lbu $6,4($0)
or $1,$6,$6
|
#include <glm/gtx/euler_angles.hpp>
#include <Engine/Physics/Shapes.hpp>
#include <Engine/Graphics/Gizmos.hpp>
#include <Engine/Components/Transform.hpp>
#include <Engine/Components/Physics/Rigidbody.hpp>
#include <Engine/Components/Physics/BoxCollider.hpp>
#include <Engine/Components/Physics/PlaneCollider.hpp>
#include <Engine/Components/Physics/SphereCollider.hpp>
using namespace std;
using namespace glm;
using namespace Engine::Physics;
using namespace Engine::Graphics;
using namespace Engine::Components;
void BoxCollider::Added()
{
Collider::Added();
Transform* transform = GetTransform();
m_Bounds.Position = transform->GetGlobalPosition() + Offset;
m_Bounds.Extents = m_Extents * (m_PreviousScale = transform->GetGlobalScale());
vec3 rotation = transform->GetGlobalRotation();
m_Bounds.Orientation = eulerAngleXYZ(rotation.x, rotation.y, rotation.z);
CalculateInverseTensor();
}
void BoxCollider::DrawGizmos()
{
#ifndef NDEBUG
Transform* transform = GetTransform();
Gizmos::Colour = { 0, 1, 0, 1 };
Gizmos::DrawWireCube(
m_Bounds.Position,
m_Bounds.Extents,
m_Bounds.Orientation);
/*
// Vertices
Gizmos::Colour = { 1, 0, 1, 0.75f };
vector<vec3>& vertices = m_Bounds.GetVertices();
for (vec3& vertex : vertices)
Gizmos::DrawSphere(vertex, 0.05f);
// Edges
Gizmos::Colour = { 1, 1, 0, 0.75f };
vector<Line>& edges = m_Bounds.GetEdges();
for (Line& edge : edges)
Gizmos::DrawLine(edge.Start, edge.End);
*/
#endif
}
OBB& BoxCollider::GetOBB() { return m_Bounds; }
glm::vec3& BoxCollider::GetExtents() { return m_Extents; }
void BoxCollider::SetExtents(glm::vec3 value)
{
m_Extents = value;
CalculateInverseTensor();
}
void BoxCollider::FixedUpdate(float timestep)
{
Transform* transform = GetTransform();
m_Bounds.Position = transform->GetGlobalPosition() + Offset;
vec3 rotation = transform->GetGlobalRotation();
m_Bounds.Orientation = eulerAngleXYZ(rotation.x, rotation.y, rotation.z);
vec3 scale = transform->GetGlobalScale();
if (m_PreviousScale != scale)
{
m_PreviousScale = scale;
m_Bounds.Extents = m_Extents * scale;
CalculateInverseTensor();
}
}
bool BoxCollider::LineTest(Physics::Line& line) { return GetOBB().LineTest(line); }
bool BoxCollider::Raycast(Ray& ray, RaycastHit* outResult) { return GetOBB().Raycast(ray, outResult); }
OBB& BoxCollider::GetBounds() { return m_Bounds; }
mat4& BoxCollider::InverseTensor() { return m_InverseTensor; }
bool BoxCollider::IsPointInside(glm::vec3& point) const { return m_Bounds.IsPointInside(point); }
bool BoxCollider::CheckCollision(Collider* other) { return other->CheckCollision(this); }
bool BoxCollider::CheckCollision(BoxCollider* other)
{
return TestBoxBoxCollider(
m_Bounds,
other->m_Bounds
);
}
bool BoxCollider::CheckCollision(SphereCollider* other)
{
return TestSphereBoxCollider(
other->GetSphere(),
m_Bounds
);
}
bool BoxCollider::CheckCollision(PlaneCollider* other)
{
return TestBoxPlaneCollider(
m_Bounds,
other->GetPlane()
);
}
void BoxCollider::CalculateInverseTensor()
{
Rigidbody* rb = GetRigidbody();
float mass = 0.0f;
if (!rb || (mass = rb->GetMass()) == 0.0f)
{
m_InverseTensor = mat4(0.0f);
return;
}
vec3 size = m_Bounds.Extents * 2.0f;
float fraction = (1.0f / 12.0f);
float x2 = size.x * size.x;
float y2 = size.y * size.y;
float z2 = size.z * size.z;
// Box inverse tensor
m_InverseTensor = inverse(mat4(
(y2 + z2) * mass * fraction, 0, 0, 0,
0, (x2 + z2) * mass * fraction, 0, 0,
0, 0, (x2 + y2) * mass * fraction, 0,
0, 0, 0, 1.0f
));
}
|
;代码清单13-2
;文件名:c13_core.asm
;文件说明:保护模式微型核心程序
;创建日期:2011-10-26 12:11
;以下常量定义部分。内核的大部分内容都应当固定
user_app_address equ 8 ; logic-sector
core_code_seg_sel equ 0x38 ;内核代码段选择子
core_data_seg_sel equ 0x30 ;内核数据段选择子
sys_routine_seg_sel equ 0x28 ;系统公共例程代码段的选择子
video_ram_seg_sel equ 0x20 ;视频显示缓冲区的段选择子
core_stack_seg_sel equ 0x18 ;内核堆栈段选择子
mem_0_4_gb_seg_sel equ 0x08 ;整个0-4GB内存的段的选择子
;-------------------------------------------------------------------------------
;以下是系统核心的头部,用于加载核心程序
core_length dd core_end ;核心程序总长度#00
sys_routine_seg dd section.sys_routine.start
;系统公用例程段位置#04
core_data_seg dd section.core_data.start
;核心数据段位置#08
core_code_seg dd section.core_code.start
;核心代码段位置#0c
core_entry dd start ;核心代码段入口点#10
dw core_code_seg_sel
;===============================================================================
[bits 32]
;===============================================================================
SECTION sys_routine vstart=0 ;系统公共例程代码段
;-------------------------------------------------------------------------------
;字符串显示例程
put_string: ;显示0终止的字符串并移动光标
;输入:DS:EBX=串地址
push ecx
.getc:
mov cl,[ebx]
or cl,cl
jz .exit
call put_char
inc ebx
jmp .getc
.exit:
pop ecx
retf ;段间返回
;-------------------------------------------------------------------------------
put_char: ;在当前光标处显示一个字符,并推进
;光标。仅用于段内调用
;输入:CL=字符ASCII码
pushad
;以下取当前光标位置
mov dx,0x3d4
mov al,0x0e
out dx,al
inc dx ;0x3d5
in al,dx ;高字
mov ah,al
dec dx ;0x3d4
mov al,0x0f
out dx,al
inc dx ;0x3d5
in al,dx ;低字
mov bx,ax ;BX=代表光标位置的16位数
cmp cl,0x0d ;回车符?
jnz .put_0a
mov ax,bx
mov bl,80
div bl
mul bl
mov bx,ax
jmp .set_cursor
.put_0a:
cmp cl,0x0a ;换行符?
jnz .put_other
add bx,80
jmp .roll_screen
.put_other: ;正常显示字符
push es
mov eax,video_ram_seg_sel ;0xb8000段的选择子
mov es,eax
shl bx,1
mov [es:bx],cl
pop es
;以下将光标位置推进一个字符
shr bx,1
inc bx
.roll_screen:
cmp bx,2000 ;光标超出屏幕?滚屏
jl .set_cursor
push ds
push es
mov eax,video_ram_seg_sel
mov ds,eax
mov es,eax
cld
mov esi,0xa0 ;小心!32位模式下movsb/w/d
mov edi,0x00 ;使用的是esi/edi/ecx
mov ecx,1920
rep movsd
mov bx,3840 ;清除屏幕最底一行
mov ecx,80 ;32位程序应该使用ECX
.cls:
mov word[es:bx],0x0720
add bx,2
loop .cls
pop es
pop ds
mov bx,1920
.set_cursor:
mov dx,0x3d4
mov al,0x0e
out dx,al
inc dx ;0x3d5
mov al,bh
out dx,al
dec dx ;0x3d4
mov al,0x0f
out dx,al
inc dx ;0x3d5
mov al,bl
out dx,al
popad
ret
;-------------------------------------------------------------------------------
read_hard_disk_0: ;从硬盘读取一个逻辑扇区
;EAX=逻辑扇区号
;DS:EBX=目标缓冲区地址
;返回:EBX=EBX+512
push eax
push ecx
push edx
push eax
mov dx,0x1f2
mov al,1
out dx,al ;读取的扇区数
inc dx ;0x1f3
pop eax
out dx,al ;LBA地址7~0
inc dx ;0x1f4
mov cl,8
shr eax,cl
out dx,al ;LBA地址15~8
inc dx ;0x1f5
shr eax,cl
out dx,al ;LBA地址23~16
inc dx ;0x1f6
shr eax,cl
or al,0xe0 ;第一硬盘 LBA地址27~24
out dx,al
inc dx ;0x1f7
mov al,0x20 ;读命令
out dx,al
.waits:
in al,dx
and al,0x88
cmp al,0x08
jnz .waits ;不忙,且硬盘已准备好数据传输
mov ecx,256 ;总共要读取的字数
mov dx,0x1f0
.readw:
in ax,dx
mov [ebx],ax
add ebx,2
loop .readw
pop edx
pop ecx
pop eax
retf ;段间返回
;-------------------------------------------------------------------------------
;汇编语言程序是极难一次成功,而且调试非常困难。这个例程可以提供帮助
put_hex_dword: ;在当前光标处以十六进制形式显示
;一个双字并推进光标
;输入:EDX=要转换并显示的数字
;输出:无
pushad
push ds
mov ax,core_data_seg_sel ;切换到核心数据段
mov ds,ax
mov ebx,bin_hex ;指向核心数据段内的转换表
mov ecx,8
.xlt:
rol edx,4
mov eax,edx
and eax,0x0000000f
xlat
push ecx
mov cl,al
call put_char
pop ecx
loop .xlt
pop ds
popad
retf
;-------------------------------------------------------------------------------
allocate_memory: ;分配内存
;输入:ECX=希望分配的字节数
;输出:ECX=起始线性地址
push ds
push eax
push ebx
mov eax,core_data_seg_sel
mov ds,eax
mov eax,[ram_alloc]
add eax,ecx ;下一次分配时的起始地址
;这里应当有检测可用内存数量的指令
mov ecx,[ram_alloc] ;返回分配的起始地址
mov ebx,eax
and ebx,0xfffffffc
add ebx,4 ;强制对齐
test eax,0x00000003 ;下次分配的起始地址最好是4字节对齐
cmovnz eax,ebx ;如果没有对齐,则强制对齐
mov [ram_alloc],eax ;下次从该地址分配内存
;cmovcc指令可以避免控制转移
pop ebx
pop eax
pop ds
retf
;-------------------------------------------------------------------------------
set_up_gdt_descriptor: ;在GDT内安装一个新的描述符
;输入:EDX:EAX=描述符
;输出:CX=描述符的选择子
push eax
push ebx
push edx
push ds
push es
mov ebx,core_data_seg_sel ;切换到核心数据段
mov ds,ebx
sgdt [pgdt] ;以便开始处理GDT
mov ebx,mem_0_4_gb_seg_sel
mov es,ebx
movzx ebx,word [pgdt] ;GDT界限
inc bx ;GDT总字节数,也是下一个描述符偏移
add ebx,[pgdt+2] ;下一个描述符的线性地址
mov [es:ebx],eax
mov [es:ebx+4],edx
add word [pgdt],8 ;增加一个描述符的大小
lgdt [pgdt] ;对GDT的更改生效
mov ax,[pgdt] ;得到GDT界限值
xor dx,dx
mov bx,8
div bx ;除以8,去掉余数
mov cx,ax
shl cx,3 ;将索引号移到正确位置
pop es
pop ds
pop edx
pop ebx
pop eax
retf
;-------------------------------------------------------------------------------
make_seg_descriptor: ;构造存储器和系统的段描述符
;输入:EAX=线性基地址
; EBX=段界限
; ECX=属性。各属性位都在原始
; 位置,无关的位清零
;返回:EDX:EAX=描述符
mov edx,eax
shl eax,16
or ax,bx ;描述符前32位(EAX)构造完毕
and edx,0xffff0000 ;清除基地址中无关的位
rol edx,8
bswap edx ;装配基址的31~24和23~16 (80486+)
xor bx,bx
or edx,ebx ;装配段界限的高4位
or edx,ecx ;装配属性
retf
;===============================================================================
SECTION core_data vstart=0 ;系统核心的数据段
;-------------------------------------------------------------------------------
pgdt dw 0 ;用于设置和修改GDT
dd 0
ram_alloc dd 0x00100000 ;下次分配内存时的起始地址
;符号地址检索表
salt:
salt_1 db '@PrintString'
times 256-($-salt_1) db 0
dd put_string
dw sys_routine_seg_sel
salt_2 db '@ReadDiskData'
times 256-($-salt_2) db 0
dd read_hard_disk_0
dw sys_routine_seg_sel
salt_3 db '@PrintDwordAsHexString'
times 256-($-salt_3) db 0
dd put_hex_dword
dw sys_routine_seg_sel
salt_4 db '@TerminateProgram'
times 256-($-salt_4) db 0
dd return_point
dw core_code_seg_sel
salt_item_len equ $-salt_4
salt_items equ ($-salt)/salt_item_len
message_1 db ' If you seen this message,that means we '
db 'are now in protect mode,and the system '
db 'core is loaded,and the video display '
db 'routine works perfectly.',0x0d,0x0a,0
message_5 db ' Loading user program...',0
do_status db 'Done.',0x0d,0x0a,0
message_6 db 0x0d,0x0a,0x0d,0x0a,0x0d,0x0a
db ' User program terminated,control returned.',0
bin_hex db '0123456789ABCDEF'
;put_hex_dword子过程用的查找表
core_buf times 2048 db 0 ;内核用的缓冲区
esp_pointer dd 0 ;内核用来临时保存自己的栈指针
cpu_brnd0 db 0x0d,0x0a,' ',0
cpu_brand times 52 db 0
cpu_brnd1 db 0x0d,0x0a,0x0d,0x0a,0
;===============================================================================
SECTION core_code vstart=0
;-------------------------------------------------------------------------------
load_relocate_program: ;加载并重定位用户程序
;输入:ESI=起始逻辑扇区号
;返回:AX=指向用户程序头部的选择子
push ebx
push ecx
push edx
push esi
push edi
push ds
push es
mov eax,core_data_seg_sel
mov ds,eax ;切换DS到内核数据段
mov eax,esi ;读取程序头部数据
mov ebx,core_buf
call sys_routine_seg_sel:read_hard_disk_0
;以下判断整个程序有多大
mov eax,[core_buf] ;程序尺寸
mov ebx,eax
and ebx,0xfffffe00 ;使之512字节对齐(能被512整除的数,
add ebx,512 ;低9位都为0
test eax,0x000001ff ;程序的大小正好是512的倍数吗?
cmovnz eax,ebx ;不是。使用凑整的结果
mov ecx,eax ;实际需要申请的内存数量
call sys_routine_seg_sel:allocate_memory
mov ebx,ecx ;ebx -> 申请到的内存首地址
push ebx ;保存该首地址
xor edx,edx
mov ecx,512
div ecx
mov ecx,eax ;总扇区数
mov eax,mem_0_4_gb_seg_sel ;切换DS到0-4GB的段
mov ds,eax
mov eax,esi ;起始扇区号
.b1:
call sys_routine_seg_sel:read_hard_disk_0
inc eax
loop .b1 ;循环读,直到读完整个用户程序
;建立程序头部段描述符
pop edi ;恢复程序装载的首地址
mov eax,edi ;程序头部起始线性地址
mov ebx,[edi+0x04] ;段长度
dec ebx ;段界限
mov ecx,0x00409200 ;字节粒度的数据段描述符
call sys_routine_seg_sel:make_seg_descriptor
call sys_routine_seg_sel:set_up_gdt_descriptor
mov [edi+0x04],cx
;建立程序代码段描述符
mov eax,edi
add eax,[edi+0x14] ;代码起始线性地址
mov ebx,[edi+0x18] ;段长度
dec ebx ;段界限
mov ecx,0x00409800 ;字节粒度的代码段描述符
call sys_routine_seg_sel:make_seg_descriptor
call sys_routine_seg_sel:set_up_gdt_descriptor
mov [edi+0x14],cx
;建立程序数据段描述符
mov eax,edi
add eax,[edi+0x1c] ;数据段起始线性地址
mov ebx,[edi+0x20] ;段长度
dec ebx ;段界限
mov ecx,0x00409200 ;字节粒度的数据段描述符
call sys_routine_seg_sel:make_seg_descriptor
call sys_routine_seg_sel:set_up_gdt_descriptor
mov [edi+0x1c],cx
;------------------------------------ex01 start------------------------------
mov edx, [edi + 0x08] ; reading user stack-set bit
test edx, 0xffffffff
jz kernel_allocte_stack ; eax =? 0
mov eax, edi
add eax, [edi + edx] ; edx is pointer of address user_stack when eax != 0
; get line-base-address of max-top of user-stack
mov ecx, [edi + edx + 0x4] ; stack length
add eax, ecx ; get stack-base-address
mov ebx, 0xfffff ; get stack limit
sub ebx, ecx
; G=0 byte
mov ecx, 0x00409600 ; seg-d-s attribute
push edx ; save offset of user stack-enter
call sys_routine_seg_sel : make_seg_descriptor
call sys_routine_seg_sel : set_up_gdt_descriptor
pop edx
mov [edi + edx], cx ; rewrite seg-choice
jmp near relocate
;------------------------------------ex01 end--------------------------------
kernel_allocte_stack: ;建立程序堆栈段描述符
mov ecx,[edi+0x0c] ;4KB的倍率
mov ebx,0x000fffff
sub ebx,ecx ;得到段界限
mov eax,4096
mul dword [edi+0x0c]
mov ecx,eax ;准备为堆栈分配内存
call sys_routine_seg_sel:allocate_memory
add eax,ecx ;得到堆栈的高端物理地址
mov ecx,0x00c09600 ;4KB粒度的堆栈段描述符
call sys_routine_seg_sel:make_seg_descriptor
call sys_routine_seg_sel:set_up_gdt_descriptor
mov [edi+0x24],cx ; rewrite seg-choice
relocate:
;重定位SALT
mov eax,[edi+0x04]
mov es,eax ;es -> 用户程序头部
mov eax,core_data_seg_sel
mov ds,eax
cld
;-----------------------------------ex01 start--------------------------------
mov ecx,[es:0x2c] ;用户程序的SALT条目数
mov edi,0x30 ;用户程序内的SALT位于头部内0x30处
;-----------------------------------ex01 end---------------------------------
.b2:
push ecx
push edi
mov ecx,salt_items
mov esi,salt
.b3:
push edi
push esi
push ecx
mov ecx,64 ;检索表中,每条目的比较次数
repe cmpsd ;每次比较4字节
jnz .b4
mov eax,[esi] ;若匹配,esi恰好指向其后的地址数据
mov [es:edi-256],eax ;将字符串改写成偏移地址
mov ax,[esi+4]
mov [es:edi-252],ax ;以及段选择子
.b4:
pop ecx
pop esi
add esi,salt_item_len
pop edi ;从头比较
loop .b3
pop edi
add edi,256
pop ecx
loop .b2
mov ax,[es:0x04]
pop es ;恢复到调用此过程前的es段
pop ds ;恢复到调用此过程前的ds段
pop edi
pop esi
pop edx
pop ecx
pop ebx
ret
;-------------------------------------------------------------------------------
start:
mov ecx,core_data_seg_sel ;使ds指向核心数据段
mov ds,ecx
mov ebx,message_1
call sys_routine_seg_sel:put_string
;显示处理器品牌信息
mov eax,0x80000002
cpuid
mov [cpu_brand + 0x00],eax
mov [cpu_brand + 0x04],ebx
mov [cpu_brand + 0x08],ecx
mov [cpu_brand + 0x0c],edx
mov eax,0x80000003
cpuid
mov [cpu_brand + 0x10],eax
mov [cpu_brand + 0x14],ebx
mov [cpu_brand + 0x18],ecx
mov [cpu_brand + 0x1c],edx
mov eax,0x80000004
cpuid
mov [cpu_brand + 0x20],eax
mov [cpu_brand + 0x24],ebx
mov [cpu_brand + 0x28],ecx
mov [cpu_brand + 0x2c],edx
mov ebx,cpu_brnd0
call sys_routine_seg_sel:put_string
mov ebx,cpu_brand
call sys_routine_seg_sel:put_string
mov ebx,cpu_brnd1
call sys_routine_seg_sel:put_string
mov ebx,message_5
call sys_routine_seg_sel:put_string
mov esi,user_app_address ;用户程序位于的逻辑扇区
call load_relocate_program
mov ebx,do_status
call sys_routine_seg_sel:put_string
mov [esp_pointer],esp ;临时保存堆栈指针
mov ds,ax
jmp far [0x10] ;控制权交给用户程序(入口点)
;堆栈可能切换
return_point: ;用户程序返回点
mov eax,core_data_seg_sel ;使ds指向核心数据段
mov ds,eax
mov eax,core_stack_seg_sel ;切换回内核自己的堆栈
mov ss,eax
mov esp,[esp_pointer]
mov ebx,message_6
call sys_routine_seg_sel:put_string
;这里可以放置清除用户程序各种描述符的指令
;也可以加载并启动其它程序
hlt
;===============================================================================
SECTION core_trail
;-------------------------------------------------------------------------------
core_end:
|
# JMH version: 1.19
# VM version: JDK 1.8.0_131, VM 25.131-b11
# VM invoker: /usr/lib/jvm/java-8-oracle/jre/bin/java
# VM options: <none>
# Warmup: 20 iterations, 1 s each
# Measurement: 20 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: com.github.arnaudroger.re2j.Re2jFindRegex.testCombine
# Run progress: 0.00% complete, ETA 00:00:40
# Fork: 1 of 1
# Preparing profilers: LinuxPerfAsmProfiler
# Profilers consume stdout and stderr from target VM, use -v EXTRA to copy to console
# Warmup Iteration 1: 2205.942 ops/s
# Warmup Iteration 2: 3286.924 ops/s
# Warmup Iteration 3: 3307.612 ops/s
# Warmup Iteration 4: 3297.154 ops/s
# Warmup Iteration 5: 3317.879 ops/s
# Warmup Iteration 6: 3325.284 ops/s
# Warmup Iteration 7: 3325.789 ops/s
# Warmup Iteration 8: 3319.418 ops/s
# Warmup Iteration 9: 3331.484 ops/s
# Warmup Iteration 10: 3331.783 ops/s
# Warmup Iteration 11: 3330.961 ops/s
# Warmup Iteration 12: 3322.837 ops/s
# Warmup Iteration 13: 3307.463 ops/s
# Warmup Iteration 14: 3307.799 ops/s
# Warmup Iteration 15: 3307.250 ops/s
# Warmup Iteration 16: 3309.468 ops/s
# Warmup Iteration 17: 3235.318 ops/s
# Warmup Iteration 18: 3239.804 ops/s
# Warmup Iteration 19: 3239.840 ops/s
# Warmup Iteration 20: 3292.084 ops/s
Iteration 1: 3296.243 ops/s
Iteration 2: 3304.526 ops/s
Iteration 3: 3304.755 ops/s
Iteration 4: 3304.380 ops/s
Iteration 5: 3316.444 ops/s
Iteration 6: 3330.844 ops/s
Iteration 7: 3327.557 ops/s
Iteration 8: 3330.691 ops/s
Iteration 9: 3035.895 ops/s
Iteration 10: 3286.698 ops/s
Iteration 11: 3286.404 ops/s
Iteration 12: 3287.121 ops/s
Iteration 13: 3284.910 ops/s
Iteration 14: 3287.963 ops/s
Iteration 15: 3270.635 ops/s
Iteration 16: 3270.795 ops/s
Iteration 17: 2918.066 ops/s
Iteration 18: 3270.511 ops/s
Iteration 19: 3270.432 ops/s
Iteration 20: 3268.020 ops/s
# Processing profiler results: LinuxPerfAsmProfiler
Result "com.github.arnaudroger.re2j.Re2jFindRegex.testCombine":
3262.644 ±(99.9%) 88.218 ops/s [Average]
(min, avg, max) = (2918.066, 3262.644, 3330.844), stdev = 101.592
CI (99.9%): [3174.426, 3350.862] (assumes normal distribution)
Secondary result "com.github.arnaudroger.re2j.Re2jFindRegex.testCombine:·asm":
PrintAssembly processed: 195299 total address lines.
Perf output processed (skipped 23.306 seconds):
Column 1: cycles (20700 events)
Column 2: instructions (20689 events)
Hottest code regions (>10.00% "cycles" events):
....[Hottest Region 1]..............................................................................
C2, level 4, com.google.re2j.Machine::add, version 483 (259 bytes)
# parm4: rdi = int
# parm5: [sp+0x70] = 'com/google/re2j/Machine$Thread' (sp of caller)
0x00007fede4bd2be0: mov 0x8(%rsi),%r10d ; {no_reloc}
0x00007fede4bd2be4: shl $0x3,%r10
0x00007fede4bd2be8: cmp %r10,%rax
0x00007fede4bd2beb: jne 0x00007fede4a0ce20 ; {runtime_call}
0x00007fede4bd2bf1: data16 xchg %ax,%ax
0x00007fede4bd2bf4: nopl 0x0(%rax,%rax,1)
0x00007fede4bd2bfc: data16 data16 xchg %ax,%ax
[Verified Entry Point]
0.66% 0.59% 0x00007fede4bd2c00: mov %eax,-0x14000(%rsp)
1.34% 1.31% 0x00007fede4bd2c07: push %rbp
0.33% 0.31% 0x00007fede4bd2c08: sub $0x60,%rsp ;*synchronization entry
; - com.google.re2j.Machine::add@-1 (line 345)
0.89% 1.22% 0x00007fede4bd2c0c: mov %edi,0x38(%rsp)
0.52% 0.56% 0x00007fede4bd2c10: mov %r9,0x30(%rsp)
0.36% 0.38% 0x00007fede4bd2c15: mov %r8d,0x20(%rsp)
0.32% 0.37% 0x00007fede4bd2c1a: mov %rsi,0x8(%rsp)
0.69% 0.73% 0x00007fede4bd2c1f: mov %rdx,0x28(%rsp)
0.54% 0.59% 0x00007fede4bd2c24: mov %rcx,0x48(%rsp)
0.25% 0.21% 0x00007fede4bd2c29: mov 0x28(%rcx),%r11d ;*getfield pc
; - com.google.re2j.Machine::add@2 (line 345)
; implicit exception: dispatches to 0x00007fede4bd3169
0.32% 0.28% 0x00007fede4bd2c2d: mov 0x14(%rdx),%ebx ;*getfield sparse
; - com.google.re2j.Machine$Queue::contains@1 (line 46)
; - com.google.re2j.Machine::add@5 (line 345)
; implicit exception: dispatches to 0x00007fede4bd3179
0.63% 0.60% 0x00007fede4bd2c30: mov 0xc(%r12,%rbx,8),%r8d ; implicit exception: dispatches to 0x00007fede4bd318d
0.66% 0.65% 0x00007fede4bd2c35: cmp %r8d,%r11d
0x00007fede4bd2c38: jae 0x00007fede4bd2f86 ;*iaload
; - com.google.re2j.Machine$Queue::contains@5 (line 46)
; - com.google.re2j.Machine::add@5 (line 345)
0.42% 0.46% 0x00007fede4bd2c3e: mov 0x10(%rdx),%ecx ;*getfield dense
; - com.google.re2j.Machine$Queue::contains@18 (line 50)
; - com.google.re2j.Machine::add@5 (line 345)
0.31% 0.35% 0x00007fede4bd2c41: mov 0xc(%rdx),%r9d ;*getfield size
; - com.google.re2j.Machine$Queue::contains@9 (line 47)
; - com.google.re2j.Machine::add@5 (line 345)
0.61% 0.53% 0x00007fede4bd2c45: lea (%r12,%rbx,8),%rdi
0.43% 0.38% 0x00007fede4bd2c49: mov 0x10(%rdi,%r11,4),%ebp ;*iaload
; - com.google.re2j.Machine$Queue::contains@5 (line 46)
; - com.google.re2j.Machine::add@5 (line 345)
0.75% 0.70% 0x00007fede4bd2c4e: cmp %r9d,%ebp
╭ 0x00007fede4bd2c51: jl 0x00007fede4bd2cde ;*iastore
│ ; - com.google.re2j.Machine$Queue::add@18 (line 58)
│ ; - com.google.re2j.Machine::add@19 (line 348)
0.97% 0.80% │ ↗ 0x00007fede4bd2c57: mov %r9d,%edx
0.47% 0.47% │ │ 0x00007fede4bd2c5a: inc %edx
0.39% 0.40% │ │ 0x00007fede4bd2c5c: mov 0x28(%rsp),%r10
0.50% 0.43% │ │ 0x00007fede4bd2c61: mov %edx,0xc(%r10) ;*putfield size
│ │ ; - com.google.re2j.Machine$Queue::add@8 (line 57)
│ │ ; - com.google.re2j.Machine::add@19 (line 348)
0.74% 0.62% │ │ 0x00007fede4bd2c65: cmp %r8d,%r11d
│ │ 0x00007fede4bd2c68: jae 0x00007fede4bd2fb9
0.51% 0.58% │ │ 0x00007fede4bd2c6e: mov %r9d,0x10(%rdi,%r11,4) ;*iastore
│ │ ; - com.google.re2j.Machine$Queue::add@18 (line 58)
│ │ ; - com.google.re2j.Machine::add@19 (line 348)
0.55% 0.42% │ │ 0x00007fede4bd2c73: mov 0xc(%r12,%rcx,8),%r10d ; implicit exception: dispatches to 0x00007fede4bd31a1
0.34% 0.35% │ │ 0x00007fede4bd2c78: cmp %r10d,%r9d
│ │ 0x00007fede4bd2c7b: jae 0x00007fede4bd2ff9 ;*aaload
│ │ ; - com.google.re2j.Machine$Queue::add@24 (line 59)
│ │ ; - com.google.re2j.Machine::add@19 (line 348)
0.78% 0.69% │ │ 0x00007fede4bd2c81: lea (%r12,%rcx,8),%rdi ;*getfield dense
│ │ ; - com.google.re2j.Machine$Queue::contains@18 (line 50)
│ │ ; - com.google.re2j.Machine::add@5 (line 345)
0.42% 0.50% │ │ 0x00007fede4bd2c85: lea 0x10(%rdi,%r9,4),%rbp
0.43% 0.38% │ │ 0x00007fede4bd2c8a: mov 0x0(%rbp),%r8d ;*aaload
│ │ ; - com.google.re2j.Machine$Queue::add@24 (line 59)
│ │ ; - com.google.re2j.Machine::add@19 (line 348)
0.48% 0.51% │ │ 0x00007fede4bd2c8e: test %r8d,%r8d
│╭│ 0x00007fede4bd2c91: je 0x00007fede4bd2d0d ;*ifnonnull
│││ ; - com.google.re2j.Machine$Queue::add@27 (line 60)
│││ ; - com.google.re2j.Machine::add@19 (line 348)
0.84% 0.82% │││ 0x00007fede4bd2c93: lea (%r12,%r8,8),%rbx ;*aload_3
│││ ; - com.google.re2j.Machine$Queue::add@45 (line 63)
│││ ; - com.google.re2j.Machine::add@19 (line 348)
0.51% 0.61% │││ 0x00007fede4bd2c97: mov %r11d,0xc(%rbx) ;*putfield pc
│││ ; - com.google.re2j.Machine$Queue::add@52 (line 64)
│││ ; - com.google.re2j.Machine::add@19 (line 348)
2.82% 2.78% │││ 0x00007fede4bd2c9b: mov 0x48(%rsp),%r10
0.36% 0.29% │││ 0x00007fede4bd2ca0: mov 0xc(%r10),%r11d ;*getfield op
│││ ; - com.google.re2j.Machine::add@25 (line 349)
1.31% 1.48% │││ 0x00007fede4bd2ca4: mov %r12d,0x10(%rbx) ;*putfield thread
│││ ; - com.google.re2j.Machine$Queue::add@47 (line 63)
│││ ; - com.google.re2j.Machine::add@19 (line 348)
0.69% 0.74% │││ 0x00007fede4bd2ca8: mov %r11d,%r10d
0.54% 0.46% │││ 0x00007fede4bd2cab: dec %r10d
0.57% 0.60% │││ 0x00007fede4bd2cae: cmp $0xc,%r10d
│││ 0x00007fede4bd2cb2: jae 0x00007fede4bd3039 ;*tableswitch
│││ ; - com.google.re2j.Machine::add@28 (line 349)
0.82% 0.85% │││ 0x00007fede4bd2cb8: mov 0x48(%rsp),%r10
0.39% 0.47% │││ 0x00007fede4bd2cbd: mov 0x30(%r10),%r8d
0.59% 0.51% │││ 0x00007fede4bd2cc1: mov 0x14(%r10),%r9d ;*getfield arg
│││ ; - com.google.re2j.Machine::add@145 (line 363)
0.11% 0.14% │││ 0x00007fede4bd2cc5: movslq %r11d,%r10
0.78% 0.90% │││ 0x00007fede4bd2cc8: mov %r8,%rcx
0.50% 0.51% │││ 0x00007fede4bd2ccb: shl $0x3,%rcx ;*getfield outInst
│││ ; - com.google.re2j.Machine::add@180 (line 369)
0.42% 0.44% │││ 0x00007fede4bd2ccf: movabs $0x7fede4bd2b80,%r8 ; {section_word}
0.07% 0.11% │││ 0x00007fede4bd2cd9: jmpq *-0x8(%r8,%r10,8) ;*tableswitch
│││ ; - com.google.re2j.Machine::add@28 (line 349)
0.04% 0.03% ↘││ 0x00007fede4bd2cde: mov 0xc(%r12,%rcx,8),%r10d ; implicit exception: dispatches to 0x00007fede4bd320d
0.07% 0.09% ││ 0x00007fede4bd2ce3: cmp %r10d,%ebp
││ 0x00007fede4bd2ce6: jae 0x00007fede4bd3141
0.08% 0.04% ││ 0x00007fede4bd2cec: lea (%r12,%rcx,8),%r10
0.00% ││ 0x00007fede4bd2cf0: mov 0x10(%r10,%rbp,4),%ebp ;*aaload
││ ; - com.google.re2j.Machine$Queue::contains@22 (line 50)
││ ; - com.google.re2j.Machine::add@5 (line 345)
0.09% 0.10% ││ 0x00007fede4bd2cf5: mov 0xc(%r12,%rbp,8),%r10d ; implicit exception: dispatches to 0x00007fede4bd321d
0.41% 0.41% ││ 0x00007fede4bd2cfa: cmp %r11d,%r10d
│╰ 0x00007fede4bd2cfd: jne 0x00007fede4bd2c57
0.00% │ 0x00007fede4bd2d03: mov 0x70(%rsp),%rax
│ 0x00007fede4bd2d08: jmpq 0x00007fede4bd2f54
↘ 0x00007fede4bd2d0d: mov 0x60(%r15),%rbx
0x00007fede4bd2d11: mov %rbx,%r10
0x00007fede4bd2d14: add $0x18,%r10
0x00007fede4bd2d18: cmp 0x70(%r15),%r10
0x00007fede4bd2d1c: jae 0x00007fede4bd30e9
0x00007fede4bd2d22: mov %r10,0x60(%r15)
0x00007fede4bd2d26: prefetchnta 0xc0(%r10)
0x00007fede4bd2d2e: mov $0xf8019b53,%r10d ; {metadata('com/google/re2j/Machine$Queue$Entry')}
0x00007fede4bd2d34: shl $0x3,%r10
....................................................................................................
28.61% 28.77% <total for region 1>
....[Hottest Region 2]..............................................................................
C2, level 4, com.google.re2j.Machine::step, version 488 (494 bytes)
# parm6: [sp+0x78] = int
# parm7: [sp+0x80] = boolean
0x00007fede4bdd800: mov 0x8(%rsi),%r10d
0x00007fede4bdd804: shl $0x3,%r10
0x00007fede4bdd808: cmp %r10,%rax
0x00007fede4bdd80b: jne 0x00007fede4a0ce20 ; {runtime_call}
0x00007fede4bdd811: data16 xchg %ax,%ax
0x00007fede4bdd814: nopl 0x0(%rax,%rax,1)
0x00007fede4bdd81c: data16 data16 xchg %ax,%ax
[Verified Entry Point]
0.10% 0.12% 0x00007fede4bdd820: mov %eax,-0x14000(%rsp)
0.16% 0.14% 0x00007fede4bdd827: push %rbp
0.08% 0.12% 0x00007fede4bdd828: sub $0x60,%rsp ;*synchronization entry
; - com.google.re2j.Machine::step@-1 (line 269)
0.04% 0.05% 0x00007fede4bdd82c: mov %edi,0x20(%rsp)
0.05% 0.03% 0x00007fede4bdd830: mov %r9d,0x14(%rsp)
0.09% 0.09% 0x00007fede4bdd835: mov %rcx,0x18(%rsp)
0.05% 0.03% 0x00007fede4bdd83a: mov %r8d,0x10(%rsp)
0.06% 0.07% 0x00007fede4bdd83f: mov %rdx,0x8(%rsp)
0.06% 0x00007fede4bdd844: mov %rsi,0x28(%rsp)
0.16% 0.11% 0x00007fede4bdd849: mov 0x14(%rsi),%r11d ;*getfield re2
; - com.google.re2j.Machine::step@1 (line 269)
0.02% 0.05% 0x00007fede4bdd84d: movzbl 0x18(%r12,%r11,8),%r11d ;*getfield longest
; - com.google.re2j.Machine::step@4 (line 269)
; implicit exception: dispatches to 0x00007fede4bddf65
0.10% 0.07% 0x00007fede4bdd853: mov %r11d,0x24(%rsp)
0.05% 0.03% 0x00007fede4bdd858: mov 0xc(%rdx),%r10d ; implicit exception: dispatches to 0x00007fede4bddf75
0.16% 0.10% 0x00007fede4bdd85c: test %r10d,%r10d
0x00007fede4bdd85f: jle 0x00007fede4bddb31 ;*if_icmpge
; - com.google.re2j.Machine::step@18 (line 270)
0.05% 0.02% 0x00007fede4bdd865: xor %r10d,%r10d
0.03% 0.06% ╭ 0x00007fede4bdd868: jmpq 0x00007fede4bdd9b4
0.36% 0.47% │ ↗ 0x00007fede4bdd86d: cmp $0xc,%r9d
│╭ │ 0x00007fede4bdd871: je 0x00007fede4bdd8e2
0.09% 0.02% ││ │ 0x00007fede4bdd873: cmp $0xc,%r9d
││ │ 0x00007fede4bdd877: jg 0x00007fede4bddd7d
0.03% 0.00% ││ │ 0x00007fede4bdd87d: cmp $0xb,%r9d
││╭ │ 0x00007fede4bdd881: jne 0x00007fede4bdd892 ;*tableswitch
│││ │ ; - com.google.re2j.Machine::step@114 (line 285)
│││ │ 0x00007fede4bdd883: mov 0x20(%rsp),%r9d
│││ │ 0x00007fede4bdd888: cmp $0xa,%r9d
│││╭ │ 0x00007fede4bdd88c: je 0x00007fede4bdd925 ;*ifeq
││││ │ ; - com.google.re2j.Machine::step@363 (line 329)
0.47% 0.27% ││↘│ ↗↗ │ 0x00007fede4bdd892: mov %eax,0x74(%rsp)
0.28% 0.10% ││ │ ││ │ 0x00007fede4bdd896: mov %r10d,%ebp
││ │ ││ │ 0x00007fede4bdd899: mov 0x30(%r12,%rbx,8),%r8d
0.00% ││ │ ││ │ 0x00007fede4bdd89e: mov %r14,%r9
0.07% 0.04% ││ │ ││ │ 0x00007fede4bdd8a1: shl $0x3,%r9 ;*getfield cap
││ │ ││ │ ; - com.google.re2j.Machine::step@172 (line 292)
0.02% ││ │ ││ │ 0x00007fede4bdd8a5: mov %r8,%rcx
││ │ ││ │ 0x00007fede4bdd8a8: shl $0x3,%rcx ;*getfield outInst
││ │ ││ │ ; - com.google.re2j.Machine::step@370 (line 330)
││ │ ││ │ 0x00007fede4bdd8ac: mov 0x28(%rsp),%rsi
0.08% 0.05% ││ │ ││ │ 0x00007fede4bdd8b1: mov 0x18(%rsp),%rdx
0.02% ││ │ ││ │ 0x00007fede4bdd8b6: mov 0x14(%rsp),%r8d
0.00% ││ │ ││ │ 0x00007fede4bdd8bb: mov 0x70(%rsp),%edi
0.00% ││ │ ││ │ 0x00007fede4bdd8bf: mov %r11,(%rsp)
0.14% 0.06% ││ │ ││ │ 0x00007fede4bdd8c3: callq 0x00007fede4a0d020 ; OopMap{[8]=Oop [24]=Oop [40]=Oop off=200}
││ │ ││ │ ;*invokespecial add
││ │ ││ │ ; - com.google.re2j.Machine::step@384 (line 330)
││ │ ││ │ ; {optimized virtual_call}
0.00% ││ │ ││ │ 0x00007fede4bdd8c8: mov %rax,%rcx
0.01% ││ │ ││ │ 0x00007fede4bdd8cb: test %rax,%rax
││ │ ││ │ 0x00007fede4bdd8ce: je 0x00007fede4bddbe2 ;*ifnull
││ │ ││ │ ; - com.google.re2j.Machine::step@391 (line 332)
││ │ ││ │ 0x00007fede4bdd8d4: mov 0x20(%rsp),%r9d
││ │ ││ │ 0x00007fede4bdd8d9: mov %ebp,%r10d
││ │ ││ │ 0x00007fede4bdd8dc: mov 0x74(%rsp),%eax
││ │╭││ │ 0x00007fede4bdd8e0: jmp 0x00007fede4bdd928 ;*aload
││ ││││ │ ; - com.google.re2j.Machine::step@294 (line 311)
0.69% 0.78% │↘ ││││ │↗ 0x00007fede4bdd8e2: cmp $0xc,%r9d
│ ││││ ││ 0x00007fede4bdd8e6: jne 0x00007fede4bddd8d ;*if_icmpne
│ ││││ ││ ; - com.google.re2j.Inst::matchRune@29 (line 63)
│ ││││ ││ ; - com.google.re2j.Machine::step@298 (line 311)
0.31% 0.39% │ ││││ ││ 0x00007fede4bdd8ec: mov 0x18(%r12,%rbx,8),%ecx ;*getfield f0
│ ││││ ││ ; - com.google.re2j.Inst::matchRune@33 (line 64)
│ ││││ ││ ; - com.google.re2j.Machine::step@298 (line 311)
0.01% │ ││││ ││ 0x00007fede4bdd8f1: cmp 0x20(%rsp),%ecx
│ ││╰│ ││ 0x00007fede4bdd8f5: je 0x00007fede4bdd892 ;*if_icmpeq
│ ││ │ ││ ; - com.google.re2j.Inst::matchRune@37 (line 64)
│ ││ │ ││ ; - com.google.re2j.Machine::step@298 (line 311)
0.53% 0.58% │ ││ │ ││ 0x00007fede4bdd8f7: mov 0x1c(%r12,%rbx,8),%ecx ;*getfield f1
│ ││ │ ││ ; - com.google.re2j.Inst::matchRune@41 (line 64)
│ ││ │ ││ ; - com.google.re2j.Machine::step@298 (line 311)
0.17% 0.15% │ ││ │ ││ 0x00007fede4bdd8fc: cmp 0x20(%rsp),%ecx
0.16% 0.17% │ ││ ╰ ││ 0x00007fede4bdd900: je 0x00007fede4bdd892 ;*if_icmpeq
│ ││ ││ ; - com.google.re2j.Inst::matchRune@45 (line 64)
│ ││ ││ ; - com.google.re2j.Machine::step@298 (line 311)
0.69% 0.71% │ ││ ││ 0x00007fede4bdd902: mov 0x20(%r12,%rbx,8),%ebp ;*getfield f2
│ ││ ││ ; - com.google.re2j.Inst::matchRune@49 (line 64)
│ ││ ││ ; - com.google.re2j.Machine::step@298 (line 311)
0.05% 0.07% │ ││ ││ 0x00007fede4bdd907: cmp 0x20(%rsp),%ebp
│ ││ ││ 0x00007fede4bdd90b: je 0x00007fede4bdddd5 ;*if_icmpeq
│ ││ ││ ; - com.google.re2j.Inst::matchRune@53 (line 64)
│ ││ ││ ; - com.google.re2j.Machine::step@298 (line 311)
0.59% 0.59% │ ││ ││ 0x00007fede4bdd911: mov 0x24(%r12,%rbx,8),%ebp ;*getfield f3
│ ││ ││ ; - com.google.re2j.Inst::matchRune@57 (line 64)
│ ││ ││ ; - com.google.re2j.Machine::step@298 (line 311)
0.01% 0.02% │ ││ ││ 0x00007fede4bdd916: cmp 0x20(%rsp),%ebp
│ ││ ││ 0x00007fede4bdd91a: je 0x00007fede4bdde09 ;*if_icmpne
│ ││ ││ ; - com.google.re2j.Inst::matchRune@61 (line 64)
│ ││ ││ ; - com.google.re2j.Machine::step@298 (line 311)
0.35% 0.58% │ ││ ││ 0x00007fede4bdd920: mov 0x20(%rsp),%r9d ;*goto
│ ││ ││ ; - com.google.re2j.Machine::step@291 (line 307)
0.02% 0.01% │ ↘│ ││ 0x00007fede4bdd925: mov %r11,%rcx ;*aload
│ │ ││ ; - com.google.re2j.Machine::step@389 (line 332)
0.16% 0.29% │ ↘ ││ 0x00007fede4bdd928: mov 0x28(%rsp),%r11
0.02% 0.02% │ ││ 0x00007fede4bdd92d: mov 0x24(%r11),%ebx ;*getfield pool
│ ││ ; - com.google.re2j.Machine::free@5 (line 160)
│ ││ ; - com.google.re2j.Machine::step@397 (line 333)
0.60% 0.92% │ ││ 0x00007fede4bdd931: mov 0xc(%r12,%rbx,8),%r11d ;*arraylength
│ ││ ; - com.google.re2j.Machine::free@8 (line 160)
│ ││ ; - com.google.re2j.Machine::step@397 (line 333)
│ ││ ; implicit exception: dispatches to 0x00007fede4bddec9
0.04% 0.03% │ ││ 0x00007fede4bdd936: mov 0x28(%rsp),%r8
0.19% 0.15% │ ││ 0x00007fede4bdd93b: mov 0xc(%r8),%ebp ;*getfield poolSize
│ ││ ; - com.google.re2j.Machine::free@1 (line 160)
│ ││ ; - com.google.re2j.Machine::step@397 (line 333)
0.02% 0.02% │ ││ 0x00007fede4bdd93f: cmp %r11d,%ebp
│ ││ 0x00007fede4bdd942: jge 0x00007fede4bddd45 ;*if_icmplt
│ ││ ; - com.google.re2j.Machine::free@9 (line 160)
│ ││ ; - com.google.re2j.Machine::step@397 (line 333)
0.76% 0.86% │ ││ 0x00007fede4bdd948: mov %ebp,%r8d
0.01% 0.02% │ ││ 0x00007fede4bdd94b: inc %r8d
0.21% 0.25% │ ││ 0x00007fede4bdd94e: mov 0x28(%rsp),%rdi
0.01% 0.02% │ ││ 0x00007fede4bdd953: mov %r8d,0xc(%rdi) ;*putfield poolSize
│ ││ ; - com.google.re2j.Machine::free@45 (line 163)
│ ││ ; - com.google.re2j.Machine::step@397 (line 333)
0.59% 0.73% │ ││ 0x00007fede4bdd957: cmp %r11d,%ebp
│ ││ 0x00007fede4bdd95a: jae 0x00007fede4bddc49 ;*aastore
│ ││ ; - com.google.re2j.Machine::free@49 (line 163)
│ ││ ; - com.google.re2j.Machine::step@397 (line 333)
0.02% 0.02% │ ││ 0x00007fede4bdd960: mov %rcx,%r11
0.20% 0.26% │ ││ 0x00007fede4bdd963: shr $0x3,%r11
0.01% 0.02% │ ││ 0x00007fede4bdd967: lea (%r12,%rbx,8),%r10 ;*getfield pool
│ ││ ; - com.google.re2j.Machine::free@5 (line 160)
│ ││ ; - com.google.re2j.Machine::step@397 (line 333)
0.60% 0.64% │ ││ 0x00007fede4bdd96b: lea 0x10(%r10,%rbp,4),%r10
0.01% 0.00% │ ││ 0x00007fede4bdd970: mov %r11d,(%r10)
0.17% 0.21% │ ││ 0x00007fede4bdd973: shr $0x9,%r10
0.00% 0.01% │ ││ 0x00007fede4bdd977: movabs $0x7fede03f5000,%r11
0.63% 0.60% │ ││ 0x00007fede4bdd981: mov %r12b,(%r11,%r10,1) ;*aastore
│ ││ ; - com.google.re2j.Machine::free@49 (line 163)
│ ││ ; - com.google.re2j.Machine::step@397 (line 333)
0.11% 0.10% │ ││ 0x00007fede4bdd985: xor %r10d,%r10d
0.19% 0.12% │ ╭ ││ 0x00007fede4bdd988: jmp 0x00007fede4bdd994
0.37% 0.31% │ │↗││ 0x00007fede4bdd98a: mov 0x24(%rsp),%r10d
0.08% 0.03% │ ││││ 0x00007fede4bdd98f: mov 0x20(%rsp),%r9d ; OopMap{[8]=Oop [24]=Oop [40]=Oop off=404}
│ ││││ ;*goto
│ ││││ ; - com.google.re2j.Machine::step@403 (line 270)
0.20% 0.15% │ ↘│││ 0x00007fede4bdd994: test %eax,0x15fd5666(%rip) # 0x00007fedfabb3000
│ │││ ;*goto
│ │││ ; - com.google.re2j.Machine::step@403 (line 270)
│ │││ ; {poll}
0.67% 0.58% │ │││ 0x00007fede4bdd99a: mov 0x8(%rsp),%r10
0.39% 0.35% │ │││ 0x00007fede4bdd99f: mov 0xc(%r10),%r10d
0.43% 0.40% │ │││ 0x00007fede4bdd9a3: cmp %r10d,%eax
│ │││ 0x00007fede4bdd9a6: jge 0x00007fede4bddb31
0.25% 0.12% │ │││ 0x00007fede4bdd9ac: mov %r9d,0x20(%rsp)
0.54% 0.41% │ │││ 0x00007fede4bdd9b1: mov %eax,%r10d ;*aload_1
│ │││ ; - com.google.re2j.Machine::step@21 (line 271)
0.43% 0.43% ↘ │││ 0x00007fede4bdd9b4: mov 0x8(%rsp),%r11
0.40% 0.32% │││ 0x00007fede4bdd9b9: mov 0x10(%r11),%r11d ;*getfield dense
│││ ; - com.google.re2j.Machine::step@22 (line 271)
0.64% 0.48% │││ 0x00007fede4bdd9bd: mov 0xc(%r12,%r11,8),%r9d ; implicit exception: dispatches to 0x00007fede4bddea5
1.53% 1.51% │││ 0x00007fede4bdd9c2: cmp %r9d,%r10d
│││ 0x00007fede4bdd9c5: jae 0x00007fede4bddc0c
0.66% 0.58% │││ 0x00007fede4bdd9cb: shl $0x3,%r11
0.32% 0.23% │││ 0x00007fede4bdd9cf: mov 0x10(%r11,%r10,4),%r11d ;*aaload
│││ ; - com.google.re2j.Machine::step@27 (line 271)
0.24% 0.21% │││ 0x00007fede4bdd9d4: mov 0x10(%r12,%r11,8),%r8d ;*getfield thread
│││ ; - com.google.re2j.Machine::step@40 (line 275)
│││ ; implicit exception: dispatches to 0x00007fede4bdded9
2.10% 1.85% │││ 0x00007fede4bdd9d9: mov %r10d,%eax
0.43% 0.27% │││ 0x00007fede4bdd9dc: inc %eax ;*iadd
│││ ; - com.google.re2j.Machine::step@237 (line 298)
0.28% 0.16% │││ 0x00007fede4bdd9de: test %r8d,%r8d
╰││ 0x00007fede4bdd9e1: je 0x00007fede4bdd98a ;*ifnonnull
││ ; - com.google.re2j.Machine::step@47 (line 276)
0.26% 0.24% ││ 0x00007fede4bdd9e3: mov 0x24(%rsp),%r9d
0.43% 0.32% ││ 0x00007fede4bdd9e8: test %r9d,%r9d
││ 0x00007fede4bdd9eb: jne 0x00007fede4bddcfd ;*ifeq
││ ; - com.google.re2j.Machine::step@55 (line 279)
0.16% 0.11% ││ 0x00007fede4bdd9f1: mov 0x10(%r12,%r8,8),%ebx ;*getfield inst
││ ; - com.google.re2j.Machine::step@101 (line 283)
1.16% 1.27% ││ 0x00007fede4bdd9f6: mov 0xc(%r12,%rbx,8),%r9d ;*getfield op
││ ; - com.google.re2j.Machine::step@111 (line 285)
││ ; implicit exception: dispatches to 0x00007fede4bddeb9
3.16% 3.25% ││ 0x00007fede4bdd9fb: mov 0xc(%r12,%r8,8),%r14d ;*getfield cap
││ ; - com.google.re2j.Machine::step@172 (line 292)
0.17% 0.11% ││ 0x00007fede4bdda00: lea (%r12,%r8,8),%r11 ;*getfield thread
││ ; - com.google.re2j.Machine::step@40 (line 275)
0.00% ││ 0x00007fede4bdda04: cmp $0x9,%r9d
││ 0x00007fede4bdda08: je 0x00007fede4bddb07
0.93% 0.99% ││ 0x00007fede4bdda0e: cmp $0x9,%r9d
╰│ 0x00007fede4bdda12: jg 0x00007fede4bdd86d
│ 0x00007fede4bdda18: cmp $0x7,%r9d
│ 0x00007fede4bdda1c: je 0x00007fede4bddd7d
│ 0x00007fede4bdda22: cmp $0x7,%r9d
╰ 0x00007fede4bdda26: jg 0x00007fede4bdd8e2
0x00007fede4bdda2c: cmp $0x6,%r9d
0x00007fede4bdda30: jne 0x00007fede4bddd7d ;*tableswitch
; - com.google.re2j.Machine::step@114 (line 285)
0x00007fede4bdda36: mov 0x78(%rsp),%r9d
0x00007fede4bdda3b: cmp $0x2,%r9d
....................................................................................................
27.26% 26.17% <total for region 2>
....[Hottest Region 3]..............................................................................
C2, level 4, com.google.re2j.Machine::add, version 483 (348 bytes)
0x00007fede4bd2dea: mov %r10,(%rsp)
0x00007fede4bd2dee: nop
0x00007fede4bd2def: callq 0x00007fede4a0d020 ; OopMap{off=532}
;*invokespecial add
; - com.google.re2j.Machine::add@190 (line 369)
; {optimized virtual_call}
╭ 0x00007fede4bd2df4: jmpq 0x00007fede4bd2f54
│ 0x00007fede4bd2df9: mov 0x70(%rsp),%rax
│╭ 0x00007fede4bd2dfe: jmpq 0x00007fede4bd2f54 ;*tableswitch
││ ; - com.google.re2j.Machine::add@28 (line 349)
1.14% 1.00% ││ 0x00007fede4bd2e03: mov 0x8(%rsp),%rsi
0.18% 0.14% ││ 0x00007fede4bd2e08: mov 0x28(%rsp),%rdx
0.03% 0.04% ││ 0x00007fede4bd2e0d: mov 0x20(%rsp),%r8d
0.14% 0.08% ││ 0x00007fede4bd2e12: mov 0x30(%rsp),%r9
0.36% 0.33% ││ 0x00007fede4bd2e17: mov 0x38(%rsp),%edi
0.16% 0.08% ││ 0x00007fede4bd2e1b: mov 0x70(%rsp),%r10
0.06% ││ 0x00007fede4bd2e20: mov %r10,(%rsp)
0.11% 0.15% ││ 0x00007fede4bd2e24: mov %rsi,%rbp
0.37% 0.35% ││ 0x00007fede4bd2e27: callq 0x00007fede4a0d020 ; OopMap{rbp=Oop [40]=Oop [48]=Oop [72]=Oop off=588}
││ ;*invokespecial add
││ ; - com.google.re2j.Machine::add@118 (line 358)
││ ; {optimized virtual_call}
0.09% 0.08% ││ 0x00007fede4bd2e2c: mov 0x48(%rsp),%r10
0.20% 0.26% ││ 0x00007fede4bd2e31: mov 0x34(%r10),%r11d
0.45% 0.53% ││ 0x00007fede4bd2e35: mov %r11,%rcx
0.11% 0.06% ││ 0x00007fede4bd2e38: shl $0x3,%rcx ;*getfield argInst
││ ; - com.google.re2j.Machine::add@126 (line 359)
0.09% 0.12% ││ 0x00007fede4bd2e3c: mov %rbp,%rsi
0.14% 0.17% ││ 0x00007fede4bd2e3f: mov 0x28(%rsp),%rdx
0.36% 0.38% ││ 0x00007fede4bd2e44: mov 0x20(%rsp),%r8d
0.07% 0.09% ││ 0x00007fede4bd2e49: mov 0x30(%rsp),%r9
0.10% 0.16% ││ 0x00007fede4bd2e4e: mov 0x38(%rsp),%edi
0.12% 0.18% ││ 0x00007fede4bd2e52: mov %rax,(%rsp)
0.39% 0.45% ││ 0x00007fede4bd2e56: nop
0.05% 0.07% ││ 0x00007fede4bd2e57: callq 0x00007fede4a0d020 ; OopMap{off=636}
││ ;*invokespecial add
││ ; - com.google.re2j.Machine::add@136 (line 359)
││ ; {optimized virtual_call}
0.16% 0.15% ││╭ 0x00007fede4bd2e5c: jmpq 0x00007fede4bd2f54 ;*aload
│││ ; - com.google.re2j.Machine::add@274 (line 389)
1.81% 1.71% │││ 0x00007fede4bd2e61: mov 0x48(%rsp),%r10
0.27% 0.23% │││ 0x00007fede4bd2e66: mov %r10,%rcx
0.06% 0.05% │││ 0x00007fede4bd2e69: shr $0x3,%rcx ;*putfield inst
│││ ; - com.google.re2j.Machine::alloc@45 (line 154)
│││ ; - com.google.re2j.Machine::add@281 (line 390)
0.06% 0.09% │││ 0x00007fede4bd2e6d: mov 0x70(%rsp),%rbp
0.81% 0.71% │││ 0x00007fede4bd2e72: test %rbp,%rbp
│││╭ 0x00007fede4bd2e75: je 0x00007fede4bd2e91 ;*ifnonnull
││││ ; - com.google.re2j.Machine::add@276 (line 389)
0.03% 0.03% ││││ 0x00007fede4bd2e77: mov %ecx,0x10(%rbp)
0.03% 0.01% ││││ 0x00007fede4bd2e7a: mov %rbp,%r10
0.01% 0.00% ││││ 0x00007fede4bd2e7d: shr $0x9,%r10
0.06% 0.07% ││││ 0x00007fede4bd2e81: movabs $0x7fede03f5000,%r11
0.06% 0.01% ││││ 0x00007fede4bd2e8b: mov %r12b,(%r11,%r10,1) ;*putfield inst
││││ ; - com.google.re2j.Machine::add@292 (line 392)
0.00% 0.01% ││││╭ 0x00007fede4bd2e8f: jmp 0x00007fede4bd2ee5
0.21% 0.15% │││↘│ 0x00007fede4bd2e91: mov 0x8(%rsp),%r10
0.03% 0.07% │││ │ 0x00007fede4bd2e96: mov 0xc(%r10),%r8d ;*getfield poolSize
│││ │ ; - com.google.re2j.Machine::alloc@1 (line 148)
│││ │ ; - com.google.re2j.Machine::add@281 (line 390)
0.08% 0.06% │││ │ 0x00007fede4bd2e9a: test %r8d,%r8d
│││ │ 0x00007fede4bd2e9d: jle 0x00007fede4bd30a1 ;*ifle
│││ │ ; - com.google.re2j.Machine::alloc@4 (line 148)
│││ │ ; - com.google.re2j.Machine::add@281 (line 390)
0.51% 0.60% │││ │ 0x00007fede4bd2ea3: mov 0x24(%r10),%r9d ;*getfield pool
│││ │ ; - com.google.re2j.Machine::alloc@18 (line 150)
│││ │ ; - com.google.re2j.Machine::add@281 (line 390)
0.25% 0.18% │││ │ 0x00007fede4bd2ea7: mov %r8d,%ebp
0.05% 0.04% │││ │ 0x00007fede4bd2eaa: dec %ebp ;*isub
│││ │ ; - com.google.re2j.Machine::alloc@13 (line 149)
│││ │ ; - com.google.re2j.Machine::add@281 (line 390)
0.08% 0.07% │││ │ 0x00007fede4bd2eac: mov %ebp,0xc(%r10) ;*putfield poolSize
│││ │ ; - com.google.re2j.Machine::alloc@14 (line 149)
│││ │ ; - com.google.re2j.Machine::add@281 (line 390)
0.50% 0.61% │││ │ 0x00007fede4bd2eb0: mov 0xc(%r12,%r9,8),%r11d ; implicit exception: dispatches to 0x00007fede4bd31c5
0.24% 0.33% │││ │ 0x00007fede4bd2eb5: cmp %r11d,%ebp
│││ │ 0x00007fede4bd2eb8: jae 0x00007fede4bd3049
0.07% 0.05% │││ │ 0x00007fede4bd2ebe: lea (%r12,%r9,8),%r10
0.09% 0.07% │││ │ 0x00007fede4bd2ec2: mov 0xc(%r10,%r8,4),%r10d ;*aaload
│││ │ ; - com.google.re2j.Machine::alloc@25 (line 150)
│││ │ ; - com.google.re2j.Machine::add@281 (line 390)
0.49% 0.53% │││ │ 0x00007fede4bd2ec7: mov %ecx,0x10(%r12,%r10,8) ;*putfield inst
│││ │ ; - com.google.re2j.Machine::alloc@45 (line 154)
│││ │ ; - com.google.re2j.Machine::add@281 (line 390)
│││ │ ; implicit exception: dispatches to 0x00007fede4bd31d5
0.61% 0.61% │││ │ 0x00007fede4bd2ecc: lea (%r12,%r10,8),%rbp ;*aaload
│││ │ ; - com.google.re2j.Machine::alloc@25 (line 150)
│││ │ ; - com.google.re2j.Machine::add@281 (line 390)
0.03% 0.01% │││ │ 0x00007fede4bd2ed0: mov %rbp,%r10
0.05% 0.03% │││ │ 0x00007fede4bd2ed3: shr $0x9,%r10
0.47% 0.51% │││ │ 0x00007fede4bd2ed7: movabs $0x7fede03f5000,%r11
0.33% 0.26% │││ │ 0x00007fede4bd2ee1: mov %r12b,(%r11,%r10,1) ;*aload
│││ │ ; - com.google.re2j.Machine::add@295 (line 394)
0.26% 0.21% │││ ↘ 0x00007fede4bd2ee5: mov 0x30(%rsp),%rdi
0.13% 0.11% │││ 0x00007fede4bd2eea: mov 0xc(%rdi),%r10d ;*arraylength
│││ ; - com.google.re2j.Machine::add@297 (line 394)
│││ ; implicit exception: dispatches to 0x00007fede4bd31b5
0.47% 0.50% │││ 0x00007fede4bd2eee: test %r10d,%r10d
│││ 0x00007fede4bd2ef1: jle 0x00007fede4bd3086 ;*ifle
│││ ; - com.google.re2j.Machine::add@298 (line 394)
0.25% 0.26% │││ 0x00007fede4bd2ef7: mov 0xc(%rbp),%r8d ;*getfield cap
│││ ; - com.google.re2j.Machine::add@303 (line 394)
0.22% 0.22% │││ 0x00007fede4bd2efb: mov %r8,%r11
0.11% 0.14% │││ 0x00007fede4bd2efe: shl $0x3,%r11
0.45% 0.56% │││ 0x00007fede4bd2f02: cmp %rdi,%r11
│││ ╭ 0x00007fede4bd2f05: je 0x00007fede4bd2f32 ;*if_acmpeq
│││ │ ; - com.google.re2j.Machine::add@308 (line 394)
0.20% 0.22% │││ │ 0x00007fede4bd2f07: mov 0xc(%r12,%r8,8),%r11d ; implicit exception: dispatches to 0x00007fede4bd31e5
0.48% 0.58% │││ │ 0x00007fede4bd2f0c: lea (%r12,%r8,8),%rcx ;*getfield cap
│││ │ ; - com.google.re2j.Machine::add@303 (line 394)
0.05% 0.01% │││ │ 0x00007fede4bd2f10: cmp %r10d,%r11d
│││ │ 0x00007fede4bd2f13: jb 0x00007fede4bd3065
1.19% 1.03% │││ │ 0x00007fede4bd2f19: lea 0x10(%r12,%r8,8),%rsi
0.11% 0.09% │││ │ 0x00007fede4bd2f1e: add $0x10,%rdi
0.02% 0.05% │││ │ 0x00007fede4bd2f22: movslq %r10d,%rdx
0.04% 0.02% │││ │ 0x00007fede4bd2f25: movabs $0x7fede4a19640,%r10
0.71% 0.68% │││ │ 0x00007fede4bd2f2f: callq *%r10 ;*aload
│││ │ ; - com.google.re2j.Machine::add@326 (line 397)
0.01% 0.02% │││ ↘ 0x00007fede4bd2f32: mov %rbx,%r10
0.22% 0.21% │││ 0x00007fede4bd2f35: mov %rbp,%r8
0.46% 0.30% │││ 0x00007fede4bd2f38: shr $0x3,%r8
0.26% 0.21% │││ 0x00007fede4bd2f3c: mov %r8d,0x10(%rbx)
0.00% 0.02% │││ 0x00007fede4bd2f40: shr $0x9,%r10
0.17% 0.25% │││ 0x00007fede4bd2f44: movabs $0x7fede03f5000,%r11
0.51% 0.30% │││ 0x00007fede4bd2f4e: mov %r12b,(%r11,%r10,1) ;*putfield thread
│││ ; - com.google.re2j.Machine::add@330 (line 397)
0.21% 0.22% │││ 0x00007fede4bd2f52: xor %eax,%eax ;*invokevirtual contains
│││ ; - com.google.re2j.Machine::add@5 (line 345)
0.73% 0.95% ↘↘↘ 0x00007fede4bd2f54: add $0x60,%rsp
0.71% 0.86% 0x00007fede4bd2f58: pop %rbp
0.30% 0.35% 0x00007fede4bd2f59: test %eax,0x15fe00a1(%rip) # 0x00007fedfabb3000
; {poll_return}
0.84% 0.94% 0x00007fede4bd2f5f: retq ;*tableswitch
; - com.google.re2j.Machine::add@28 (line 349)
0x00007fede4bd2f60: mov 0x8(%rsp),%rsi
0x00007fede4bd2f65: mov 0x28(%rsp),%rdx
0x00007fede4bd2f6a: mov 0x20(%rsp),%r8d
0x00007fede4bd2f6f: mov 0x30(%rsp),%r9
0x00007fede4bd2f74: mov %ebx,%edi
0x00007fede4bd2f76: mov 0x70(%rsp),%r10
0x00007fede4bd2f7b: mov %r10,(%rsp)
0x00007fede4bd2f7f: callq 0x00007fede4a0d020 ; OopMap{off=932}
....................................................................................................
21.23% 21.36% <total for region 3>
....[Hottest Regions]...............................................................................
28.61% 28.77% C2, level 4 com.google.re2j.Machine::add, version 483 (259 bytes)
27.26% 26.17% C2, level 4 com.google.re2j.Machine::step, version 488 (494 bytes)
21.23% 21.36% C2, level 4 com.google.re2j.Machine::add, version 483 (348 bytes)
9.43% 10.66% C2, level 4 com.google.re2j.Machine::match, version 530 (820 bytes)
5.68% 5.54% runtime stub StubRoutines::jint_disjoint_arraycopy (128 bytes)
1.75% 1.92% C2, level 4 com.google.re2j.Machine::step, version 488 (62 bytes)
0.99% 0.98% [kernel.kallsyms] [unknown] (6 bytes)
0.49% 0.54% C2, level 4 com.google.re2j.Machine::add, version 483 (45 bytes)
0.38% 0.41% C2, level 4 com.google.re2j.Machine::match, version 530 (98 bytes)
0.29% 0.27% C2, level 4 com.google.re2j.Machine::step, version 488 (84 bytes)
0.16% 0.05% C2, level 4 com.google.re2j.Machine::init, version 534 (147 bytes)
0.15% 0.06% C2, level 4 com.google.re2j.Machine::init, version 534 (115 bytes)
0.13% 0.02% [kernel.kallsyms] [unknown] (45 bytes)
0.13% 0.05% [kernel.kallsyms] [unknown] (74 bytes)
0.11% 0.04% [kernel.kallsyms] [unknown] (0 bytes)
0.09% 0.02% [kernel.kallsyms] [unknown] (41 bytes)
0.08% 0.02% C2, level 4 com.google.re2j.Machine::init, version 534 (152 bytes)
0.06% 0.04% C2, level 4 com.google.re2j.Machine::init, version 534 (45 bytes)
0.05% 0.07% C2, level 4 com.google.re2j.Matcher::find, version 556 (20 bytes)
0.05% 0.15% libjvm.so _ZN13RelocIterator10initializeEP7nmethodPhS2_ (102 bytes)
2.88% 2.84% <...other 552 warm regions...>
....................................................................................................
100.00% 100.00% <totals>
....[Hottest Methods (after inlining)]..............................................................
50.33% 50.67% C2, level 4 com.google.re2j.Machine::add, version 483
29.31% 28.36% C2, level 4 com.google.re2j.Machine::step, version 488
9.94% 11.20% C2, level 4 com.google.re2j.Machine::match, version 530
5.68% 5.54% runtime stub StubRoutines::jint_disjoint_arraycopy
2.57% 2.02% [kernel.kallsyms] [unknown]
0.49% 0.18% C2, level 4 com.google.re2j.Machine::init, version 534
0.29% 0.19% C2, level 4 com.google.re2j.Matcher::find, version 556
0.10% 0.15% libc-2.26.so vfprintf
0.08% 0.06% hsdis-amd64.so [unknown]
0.07% 0.06% C2, level 4 com.google.re2j.MachineInput$UTF16Input::indexOf, version 566
0.06% 0.02% libjvm.so _ZN13xmlTextStream5writeEPKcm
0.06% 0.17% libjvm.so _ZN13RelocIterator10initializeEP7nmethodPhS2_
0.05% 0.03% C2, level 4 com.github.arnaudroger.re2j.Re2jFindRegex::testCombine, version 578
0.04% 0.00% libpthread-2.26.so __libc_write
0.04% 0.09% libjvm.so _ZN10fileStream5writeEPKcm
0.04% 0.02% libjvm.so _ZN18PSPromotionManager22copy_to_survivor_spaceILb0EEEP7oopDescS2_
0.04% 0.01% C2, level 4 java.util.Collections::shuffle, version 577
0.03% 0.02% libc-2.26.so __strchr_avx2
0.03% 0.10% libc-2.26.so _IO_fwrite
0.03% 0.01% libjvm.so _ZN7Monitor6unlockEv
0.71% 0.54% <...other 100 warm methods...>
....................................................................................................
100.00% 99.46% <totals>
....[Distribution by Source]........................................................................
90.57% 90.75% C2, level 4
5.69% 5.56% runtime stub
2.57% 2.02% [kernel.kallsyms]
0.64% 0.94% libjvm.so
0.30% 0.58% libc-2.26.so
0.09% 0.07% hsdis-amd64.so
0.09% 0.04% libpthread-2.26.so
0.04% 0.02% C1, level 3
0.01% 0.00% [vdso]
....................................................................................................
100.00% 100.00% <totals>
# Run complete. Total time: 00:00:45
Benchmark Mode Cnt Score Error Units
Re2jFindRegex.testCombine thrpt 20 3262.644 ± 88.218 ops/s
Re2jFindRegex.testCombine:·asm thrpt NaN ---
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <queue>
using namespace std;
/* Medium */
/* Definition for a binary tree node. */
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
// DFS
class Solution_1 {
public:
vector<int> rightSideView(TreeNode* root) {
vector<vector<int>> res;
levelOrder(root, 0, res);
vector<int> ans;
for (int i = 0; i < res.size(); ++i) {
ans.push_back(res[i][0]);
}
return ans;
}
void levelOrder(TreeNode* root, int level, vector<vector<int>>& res) {
if (root == nullptr) return;
if (res.size() == level) res.resize(level + 1);
res[level].push_back(root->val);
levelOrder(root->right, level + 1, res);
levelOrder(root->left, level + 1, res);
}
};
// BFS
/* 使用层序遍历,并只保留每层最后一个节点的值 */
vector<int> rightSideView(TreeNode* root) {
vector<int> res;
if (!root) return res;
queue<TreeNode*> q;
q.push(root);
while (!q.empty())
{
int size = q.size(); // 这个size是核心
res.push_back(q.front()->val);
/* 在while(size--)里面是先temp->right 然后 temp->left,
所以跳出这个循环后,第一个temp->right 之前的数据都pop出去了,
所以就是剩下q.front()->val 这个数字是最右边的数字了,
假如你是q.back()->val 不就是打印左子树嘛 */
while (size--) // 左右子树入队顺序调换
{
TreeNode* temp = q.front();
q.pop();
// 队列q 的填装顺序是按层序 从右往左 填装
if (temp->right) q.push(temp->right);
if (temp->left) q.push(temp->left);
}
}
return res;
}
class Solution_2 {
public:
vector<int> rightSideView(TreeNode* root) {
vector<int> res;
if (!root) return res;
queue<TreeNode*> q;
q.push(root);
while (!q.empty()) {
int size = q.size();
res.push_back(q.back()->val);
// while(size--)在层序遍历中的应用
while (size--) {
TreeNode *ptr = q.front();
q.pop();
// 队列q 的填装顺序是按层序 从左往右 填装
if (ptr->left) q.push(ptr->left);
if (ptr->right) q.push(ptr->right);
}
}
return res;
}
};
class Solution_3 {
public:
vector<int> rightSideView(TreeNode* root) {
unordered_map<int, int> rightmostValueAtDepth;
int max_depth = -1;
queue<TreeNode*> nodeQueue;
queue<int> depthQueue;
nodeQueue.push(root);
depthQueue.push(0);
while (!nodeQueue.empty()) {
TreeNode* node = nodeQueue.front();nodeQueue.pop();
int depth = depthQueue.front();depthQueue.pop();
if (node != NULL) {
// 维护二叉树的最大深度
max_depth = max(max_depth, depth);
// 由于每一层最后一个访问到的节点才是我们要的答案,因此不断更新对应深度的信息即可
rightmostValueAtDepth[depth] = node -> val;
nodeQueue.push(node -> left);
nodeQueue.push(node -> right);
depthQueue.push(depth + 1);
depthQueue.push(depth + 1);
}
}
vector<int> rightView;
for (int depth = 0; depth <= max_depth; ++depth) {
rightView.push_back(rightmostValueAtDepth[depth]);
}
return rightView;
}
}; |
extern m7_ippsAESDecryptCBC_CS3:function
extern n8_ippsAESDecryptCBC_CS3:function
extern y8_ippsAESDecryptCBC_CS3:function
extern e9_ippsAESDecryptCBC_CS3:function
extern l9_ippsAESDecryptCBC_CS3:function
extern n0_ippsAESDecryptCBC_CS3:function
extern k0_ippsAESDecryptCBC_CS3:function
extern ippcpJumpIndexForMergedLibs
extern ippcpSafeInit:function
segment .data
align 8
dq .Lin_ippsAESDecryptCBC_CS3
.Larraddr_ippsAESDecryptCBC_CS3:
dq m7_ippsAESDecryptCBC_CS3
dq n8_ippsAESDecryptCBC_CS3
dq y8_ippsAESDecryptCBC_CS3
dq e9_ippsAESDecryptCBC_CS3
dq l9_ippsAESDecryptCBC_CS3
dq n0_ippsAESDecryptCBC_CS3
dq k0_ippsAESDecryptCBC_CS3
segment .text
global ippsAESDecryptCBC_CS3:function (ippsAESDecryptCBC_CS3.LEndippsAESDecryptCBC_CS3 - ippsAESDecryptCBC_CS3)
.Lin_ippsAESDecryptCBC_CS3:
db 0xf3, 0x0f, 0x1e, 0xfa
call ippcpSafeInit wrt ..plt
align 16
ippsAESDecryptCBC_CS3:
db 0xf3, 0x0f, 0x1e, 0xfa
mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc]
movsxd rax, dword [rax]
lea r11, [rel .Larraddr_ippsAESDecryptCBC_CS3]
mov r11, qword [r11+rax*8]
jmp r11
.LEndippsAESDecryptCBC_CS3:
|
#include "PCH.h"
#include "Entity.h"
// Default constructor.
Entity::Entity() :
m_currentTextureIndex(static_cast<int>(ANIMATION_STATE::WALK_DOWN)),
m_health(0),
m_maxHealth(0),
m_mana(0),
m_maxMana(0),
m_attack(0),
m_defense(0),
m_strength(0),
m_dexterity(0),
m_stamina(0),
m_speed(0),
m_velocity({0.f, 0.f})
{
}
// Override the default Object::Update function.
void Entity::Update(float timeDelta)
{
// Choose animation state.
ANIMATION_STATE animState = static_cast<ANIMATION_STATE>(m_currentTextureIndex);
if ((m_velocity.x != 0) || (m_velocity.y != 0))
{
if (abs(m_velocity.x) > abs(m_velocity.y))
{
if (m_velocity.x <= 0)
{
animState = ANIMATION_STATE::WALK_LEFT;
}
else
{
animState = ANIMATION_STATE::WALK_RIGHT;
}
}
else
{
if (m_velocity.y <= 0)
{
animState = ANIMATION_STATE::WALK_UP;
}
else
{
animState = ANIMATION_STATE::WALK_DOWN;
}
}
}
// Set animation speed.
if ((m_velocity.x == 0) && (m_velocity.y == 0))
{
// The character is still.
if (IsAnimated())
{
// Update sprite to idle version.
m_currentTextureIndex += 4;
// Stop movement animations.
SetAnimated(false);
}
}
else
{
// The character is moving.
if (!IsAnimated())
{
// Update sprite to walking version.
m_currentTextureIndex -= 4;
// Start movement animations.
SetAnimated(true);
}
}
// Set the sprite.
if (m_currentTextureIndex != static_cast<int>(animState))
{
m_currentTextureIndex = static_cast<int>(animState);
m_sprite.setTexture(TextureManager::GetTexture(m_textureIDs[m_currentTextureIndex]));
}
}
// Gets the entities health.
int Entity::GetHealth() const
{
return m_health;
}
// Gets the entities max health.
int Entity::GetMaxHealth() const
{
return m_maxHealth;
}
// Gets the entities attack.
int Entity::GetAttack() const
{
return m_attack;
}
// Gets the entities defense.
int Entity::GetDefense() const
{
return m_defense;
}
// Gets the entities strength.
int Entity::GetStrength() const
{
return m_strength;
}
// Gets the entities dexterity.
int Entity::GetDexterity() const
{
return m_dexterity;
}
// Gets the entities stamina.
int Entity::GetStamina() const
{
return m_stamina;
}
// Sets the entities attack stat.
void Entity::SetAttack(int attackValue)
{
m_attack = attackValue;
}
// Sets the entities defense stat.
void Entity::SetDefense(int defenseValue)
{
m_defense = defenseValue;
}
// Sets the entities strength stat.
void Entity::SetStrength(int strengthValue)
{
m_strength = strengthValue;
}
// Sets the entities dexterity stat.
void Entity::SetDexterity(int dexterityValue)
{
m_dexterity = dexterityValue;
}
// Sets the entities stamina stat.
void Entity::SetStamina(int staminaValue)
{
m_stamina = staminaValue;
} |
;
; ANSI Video handling for the Sharp X1
; Karl Von Dyson (for X1s.org) - 24/10/2013
; Stefano Bodrato 10/2013
;
; set it up with:
; .__console_w = max columns
; .__console_h = max rows
;
; Display a char in location (__console_y),(__console_x)
; A=char to display
;
;
; $Id: f_ansi_char.asm,v 1.7 2016-07-20 05:45:02 stefano Exp $
;
SECTION code_clib
PUBLIC ansi_CHAR
PUBLIC ATTR
EXTERN __console_y
EXTERN __console_x
EXTERN __console_w
.ansi_CHAR
push af
ld hl,$3000
ld a,(__console_y)
and a
jr z,r_zero
ld b,a
ld d,l
ld a,(__console_w)
ld e,a
.r_loop
add hl,de
djnz r_loop
.r_zero
ld a,(__console_x)
ld d,0
ld e,a
add hl,de
pop af
.setout
ld (hl),a
ld b,h
ld c,l
out(c),a
res 4,b
.ATTR
;ld a,15
ld a,7
out(c),a
ret
|
SECTION code_fcntl
PUBLIC zx_01_input_inkey_stdio_msg_ictl
EXTERN console_01_input_stdio_msg_ictl, console_01_input_stdio_msg_ictl_0
EXTERN error_einval_zc, zx_01_input_inkey_stdio_msg_flsh
EXTERN zx_01_input_inkey_proc_getk_address, __stdio_nextarg_bc, __stdio_nextarg_de
zx_01_input_inkey_stdio_msg_ictl:
; ioctl messages understood:
;
; defc IOCTL_ITERM_RESET = $0101
; defc IOCTL_ITERM_GET_DELAY = $1081
; defc IOCTL_ITERM_SET_DELAY = $1001
;
; in addition to flags managed by stdio
; and messages understood by base class
;
; enter : ix = & FDSTRUCT.JP
; bc = first parameter
; de = request
; hl = void *arg (0 if stdio flags)
;
; exit : hl = return value
; carry set if ioctl rejected
;
; uses : af, bc, de, hl
; flags managed by stdio?
ld a,h
or l
jp z, console_01_input_stdio_msg_ictl
; check the message is specifically for an input terminal
ld a,e
and $07
cp $01 ; input terminals are type $01
jp nz, error_einval_zc
; interpret ioctl messages
ld a,d
dec a
jp z, zx_01_input_inkey_stdio_msg_flsh
cp $10 - 1
jp nz, console_01_input_stdio_msg_ictl_0
_ioctl_getset_delay:
; e & $80 = 1 for get
; bc = first parameter (debounce_ms)
; hl = void *arg
ld a,e
push hl
call zx_01_input_inkey_proc_getk_address
inc hl
inc hl ; hl = & getk_debounce_ms
add a,a
jr c, _ioctl_get_delay
_ioctl_set_delay:
pop de ; de = void *arg
ld (hl),c ; set debounce_ms
inc hl
ex de,hl
call __stdio_nextarg_bc
ex de,hl
ld (hl),c
inc hl
ld (hl),b ; set repeatbegin_ms
inc hl
ex de,hl
call __stdio_nextarg_bc
ex de,hl
ld (hl),c
inc hl
ld (hl),b ; set repeatperiod_ms
ret
_ioctl_get_delay:
ld a,(hl) ; a = debounce_ms
inc hl
ld (bc),a
inc bc
xor a
ld (bc),a ; write debounce_ms
ex (sp),hl ; hl = void *arg
call __stdio_nextarg_de
ex (sp),hl ; hl = & getk_repeatbegin_ms
ldi
ldi
ex (sp),hl ; hl = void *arg
call __stdio_nextarg_de
pop hl ; hl = & getk_repeatperiod_ms
ldi
ldi
ret
|
SECTION code_fp_math48
PUBLIC asm_dgt_s
EXTERN am48_dgt_s
defc asm_dgt_s = am48_dgt_s
|
.size 8000
.text@48
ld a, ff
ldff(45), a
jp lstatint
.text@100
jp lbegin
.data@143
80
.text@150
lbegin:
ld a, ff
ldff(45), a
ld b, 40
call lwaitly_b
ld a, 40
ldff(41), a
xor a, a
ldff(0f), a
ld a, 02
ldff(ff), a
ei
ld a, b
inc a
inc a
ldff(45), a
.text@1000
lstatint:
ld a, 30
ldff(41), a
.text@10cc
xor a, a
ldff(0f), a
nop
nop
nop
nop
nop
nop
nop
nop
nop
ldff a, (0f)
and a, 07
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
pop af
ld(9800), a
ld bc, 7a00
ld hl, 8000
ld d, a0
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
|
/*
* Copyright 2012 The WebRTC 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 "pc/test/fakeaudiocapturemodule.h"
#include "rtc_base/checks.h"
#include "rtc_base/refcount.h"
#include "rtc_base/thread.h"
#include "rtc_base/timeutils.h"
// Audio sample value that is high enough that it doesn't occur naturally when
// frames are being faked. E.g. NetEq will not generate this large sample value
// unless it has received an audio frame containing a sample of this value.
// Even simpler buffers would likely just contain audio sample values of 0.
static const int kHighSampleValue = 10000;
// Same value as src/modules/audio_device/main/source/audio_device_config.h in
// https://code.google.com/p/webrtc/
static const int kAdmMaxIdleTimeProcess = 1000;
// Constants here are derived by running VoE using a real ADM.
// The constants correspond to 10ms of mono audio at 44kHz.
static const int kTimePerFrameMs = 10;
static const uint8_t kNumberOfChannels = 1;
static const int kSamplesPerSecond = 44000;
static const int kTotalDelayMs = 0;
static const int kClockDriftMs = 0;
static const uint32_t kMaxVolume = 14392;
enum {
MSG_START_PROCESS,
MSG_RUN_PROCESS,
};
FakeAudioCaptureModule::FakeAudioCaptureModule()
: last_process_time_ms_(0),
audio_callback_(nullptr),
recording_(false),
playing_(false),
play_is_initialized_(false),
rec_is_initialized_(false),
current_mic_level_(kMaxVolume),
started_(false),
next_frame_time_(0),
frames_received_(0) {
}
FakeAudioCaptureModule::~FakeAudioCaptureModule() {
if (process_thread_) {
process_thread_->Stop();
}
}
rtc::scoped_refptr<FakeAudioCaptureModule> FakeAudioCaptureModule::Create() {
rtc::scoped_refptr<FakeAudioCaptureModule> capture_module(
new rtc::RefCountedObject<FakeAudioCaptureModule>());
if (!capture_module->Initialize()) {
return nullptr;
}
return capture_module;
}
int FakeAudioCaptureModule::frames_received() const {
rtc::CritScope cs(&crit_);
return frames_received_;
}
int64_t FakeAudioCaptureModule::TimeUntilNextProcess() {
const int64_t current_time = rtc::TimeMillis();
if (current_time < last_process_time_ms_) {
// TODO: wraparound could be handled more gracefully.
return 0;
}
const int64_t elapsed_time = current_time - last_process_time_ms_;
if (kAdmMaxIdleTimeProcess < elapsed_time) {
return 0;
}
return kAdmMaxIdleTimeProcess - elapsed_time;
}
void FakeAudioCaptureModule::Process() {
last_process_time_ms_ = rtc::TimeMillis();
}
int32_t FakeAudioCaptureModule::ActiveAudioLayer(
AudioLayer* /*audio_layer*/) const {
RTC_NOTREACHED();
return 0;
}
webrtc::AudioDeviceModule::ErrorCode FakeAudioCaptureModule::LastError() const {
RTC_NOTREACHED();
return webrtc::AudioDeviceModule::kAdmErrNone;
}
int32_t FakeAudioCaptureModule::RegisterEventObserver(
webrtc::AudioDeviceObserver* /*event_callback*/) {
// Only used to report warnings and errors. This fake implementation won't
// generate any so discard this callback.
return 0;
}
int32_t FakeAudioCaptureModule::RegisterAudioCallback(
webrtc::AudioTransport* audio_callback) {
rtc::CritScope cs(&crit_callback_);
audio_callback_ = audio_callback;
return 0;
}
int32_t FakeAudioCaptureModule::Init() {
// Initialize is called by the factory method. Safe to ignore this Init call.
return 0;
}
int32_t FakeAudioCaptureModule::Terminate() {
// Clean up in the destructor. No action here, just success.
return 0;
}
bool FakeAudioCaptureModule::Initialized() const {
RTC_NOTREACHED();
return 0;
}
int16_t FakeAudioCaptureModule::PlayoutDevices() {
RTC_NOTREACHED();
return 0;
}
int16_t FakeAudioCaptureModule::RecordingDevices() {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::PlayoutDeviceName(
uint16_t /*index*/,
char /*name*/[webrtc::kAdmMaxDeviceNameSize],
char /*guid*/[webrtc::kAdmMaxGuidSize]) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::RecordingDeviceName(
uint16_t /*index*/,
char /*name*/[webrtc::kAdmMaxDeviceNameSize],
char /*guid*/[webrtc::kAdmMaxGuidSize]) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SetPlayoutDevice(uint16_t /*index*/) {
// No playout device, just playing from file. Return success.
return 0;
}
int32_t FakeAudioCaptureModule::SetPlayoutDevice(WindowsDeviceType /*device*/) {
if (play_is_initialized_) {
return -1;
}
return 0;
}
int32_t FakeAudioCaptureModule::SetRecordingDevice(uint16_t /*index*/) {
// No recording device, just dropping audio. Return success.
return 0;
}
int32_t FakeAudioCaptureModule::SetRecordingDevice(
WindowsDeviceType /*device*/) {
if (rec_is_initialized_) {
return -1;
}
return 0;
}
int32_t FakeAudioCaptureModule::PlayoutIsAvailable(bool* /*available*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::InitPlayout() {
play_is_initialized_ = true;
return 0;
}
bool FakeAudioCaptureModule::PlayoutIsInitialized() const {
return play_is_initialized_;
}
int32_t FakeAudioCaptureModule::RecordingIsAvailable(bool* /*available*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::InitRecording() {
rec_is_initialized_ = true;
return 0;
}
bool FakeAudioCaptureModule::RecordingIsInitialized() const {
return rec_is_initialized_;
}
int32_t FakeAudioCaptureModule::StartPlayout() {
if (!play_is_initialized_) {
return -1;
}
{
rtc::CritScope cs(&crit_);
playing_ = true;
}
bool start = true;
UpdateProcessing(start);
return 0;
}
int32_t FakeAudioCaptureModule::StopPlayout() {
bool start = false;
{
rtc::CritScope cs(&crit_);
playing_ = false;
start = ShouldStartProcessing();
}
UpdateProcessing(start);
return 0;
}
bool FakeAudioCaptureModule::Playing() const {
rtc::CritScope cs(&crit_);
return playing_;
}
int32_t FakeAudioCaptureModule::StartRecording() {
if (!rec_is_initialized_) {
return -1;
}
{
rtc::CritScope cs(&crit_);
recording_ = true;
}
bool start = true;
UpdateProcessing(start);
return 0;
}
int32_t FakeAudioCaptureModule::StopRecording() {
bool start = false;
{
rtc::CritScope cs(&crit_);
recording_ = false;
start = ShouldStartProcessing();
}
UpdateProcessing(start);
return 0;
}
bool FakeAudioCaptureModule::Recording() const {
rtc::CritScope cs(&crit_);
return recording_;
}
int32_t FakeAudioCaptureModule::SetAGC(bool /*enable*/) {
// No AGC but not needed since audio is pregenerated. Return success.
return 0;
}
bool FakeAudioCaptureModule::AGC() const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::InitSpeaker() {
// No speaker, just playing from file. Return success.
return 0;
}
bool FakeAudioCaptureModule::SpeakerIsInitialized() const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::InitMicrophone() {
// No microphone, just playing from file. Return success.
return 0;
}
bool FakeAudioCaptureModule::MicrophoneIsInitialized() const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SpeakerVolumeIsAvailable(bool* /*available*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SetSpeakerVolume(uint32_t /*volume*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SpeakerVolume(uint32_t* /*volume*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::MaxSpeakerVolume(
uint32_t* /*max_volume*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::MinSpeakerVolume(
uint32_t* /*min_volume*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::MicrophoneVolumeIsAvailable(
bool* /*available*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SetMicrophoneVolume(uint32_t volume) {
rtc::CritScope cs(&crit_);
current_mic_level_ = volume;
return 0;
}
int32_t FakeAudioCaptureModule::MicrophoneVolume(uint32_t* volume) const {
rtc::CritScope cs(&crit_);
*volume = current_mic_level_;
return 0;
}
int32_t FakeAudioCaptureModule::MaxMicrophoneVolume(
uint32_t* max_volume) const {
*max_volume = kMaxVolume;
return 0;
}
int32_t FakeAudioCaptureModule::MinMicrophoneVolume(
uint32_t* /*min_volume*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SpeakerMuteIsAvailable(bool* /*available*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SetSpeakerMute(bool /*enable*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SpeakerMute(bool* /*enabled*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::MicrophoneMuteIsAvailable(bool* /*available*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SetMicrophoneMute(bool /*enable*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::MicrophoneMute(bool* /*enabled*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::StereoPlayoutIsAvailable(
bool* available) const {
// No recording device, just dropping audio. Stereo can be dropped just
// as easily as mono.
*available = true;
return 0;
}
int32_t FakeAudioCaptureModule::SetStereoPlayout(bool /*enable*/) {
// No recording device, just dropping audio. Stereo can be dropped just
// as easily as mono.
return 0;
}
int32_t FakeAudioCaptureModule::StereoPlayout(bool* /*enabled*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::StereoRecordingIsAvailable(
bool* available) const {
// Keep thing simple. No stereo recording.
*available = false;
return 0;
}
int32_t FakeAudioCaptureModule::SetStereoRecording(bool enable) {
if (!enable) {
return 0;
}
return -1;
}
int32_t FakeAudioCaptureModule::StereoRecording(bool* /*enabled*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SetRecordingChannel(
const ChannelType channel) {
if (channel != AudioDeviceModule::kChannelBoth) {
// There is no right or left in mono. I.e. kChannelBoth should be used for
// mono.
RTC_NOTREACHED();
return -1;
}
return 0;
}
int32_t FakeAudioCaptureModule::RecordingChannel(ChannelType* channel) const {
// Stereo recording not supported. However, WebRTC ADM returns kChannelBoth
// in that case. Do the same here.
*channel = AudioDeviceModule::kChannelBoth;
return 0;
}
int32_t FakeAudioCaptureModule::PlayoutDelay(uint16_t* delay_ms) const {
// No delay since audio frames are dropped.
*delay_ms = 0;
return 0;
}
int32_t FakeAudioCaptureModule::RecordingDelay(uint16_t* /*delay_ms*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SetRecordingSampleRate(
const uint32_t /*samples_per_sec*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::RecordingSampleRate(
uint32_t* /*samples_per_sec*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SetPlayoutSampleRate(
const uint32_t /*samples_per_sec*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::PlayoutSampleRate(
uint32_t* /*samples_per_sec*/) const {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::SetLoudspeakerStatus(bool /*enable*/) {
RTC_NOTREACHED();
return 0;
}
int32_t FakeAudioCaptureModule::GetLoudspeakerStatus(bool* /*enabled*/) const {
RTC_NOTREACHED();
return 0;
}
void FakeAudioCaptureModule::OnMessage(rtc::Message* msg) {
switch (msg->message_id) {
case MSG_START_PROCESS:
StartProcessP();
break;
case MSG_RUN_PROCESS:
ProcessFrameP();
break;
default:
// All existing messages should be caught. Getting here should never
// happen.
RTC_NOTREACHED();
}
}
bool FakeAudioCaptureModule::Initialize() {
// Set the send buffer samples high enough that it would not occur on the
// remote side unless a packet containing a sample of that magnitude has been
// sent to it. Note that the audio processing pipeline will likely distort the
// original signal.
SetSendBuffer(kHighSampleValue);
last_process_time_ms_ = rtc::TimeMillis();
return true;
}
void FakeAudioCaptureModule::SetSendBuffer(int value) {
Sample* buffer_ptr = reinterpret_cast<Sample*>(send_buffer_);
const size_t buffer_size_in_samples =
sizeof(send_buffer_) / kNumberBytesPerSample;
for (size_t i = 0; i < buffer_size_in_samples; ++i) {
buffer_ptr[i] = value;
}
}
void FakeAudioCaptureModule::ResetRecBuffer() {
memset(rec_buffer_, 0, sizeof(rec_buffer_));
}
bool FakeAudioCaptureModule::CheckRecBuffer(int value) {
const Sample* buffer_ptr = reinterpret_cast<const Sample*>(rec_buffer_);
const size_t buffer_size_in_samples =
sizeof(rec_buffer_) / kNumberBytesPerSample;
for (size_t i = 0; i < buffer_size_in_samples; ++i) {
if (buffer_ptr[i] >= value) return true;
}
return false;
}
bool FakeAudioCaptureModule::ShouldStartProcessing() {
return recording_ || playing_;
}
void FakeAudioCaptureModule::UpdateProcessing(bool start) {
if (start) {
if (!process_thread_) {
process_thread_ = rtc::Thread::Create();
process_thread_->Start();
}
process_thread_->Post(RTC_FROM_HERE, this, MSG_START_PROCESS);
} else {
if (process_thread_) {
process_thread_->Stop();
process_thread_.reset(nullptr);
}
started_ = false;
}
}
void FakeAudioCaptureModule::StartProcessP() {
RTC_CHECK(process_thread_->IsCurrent());
if (started_) {
// Already started.
return;
}
ProcessFrameP();
}
void FakeAudioCaptureModule::ProcessFrameP() {
RTC_CHECK(process_thread_->IsCurrent());
if (!started_) {
next_frame_time_ = rtc::TimeMillis();
started_ = true;
}
{
rtc::CritScope cs(&crit_);
// Receive and send frames every kTimePerFrameMs.
if (playing_) {
ReceiveFrameP();
}
if (recording_) {
SendFrameP();
}
}
next_frame_time_ += kTimePerFrameMs;
const int64_t current_time = rtc::TimeMillis();
const int64_t wait_time =
(next_frame_time_ > current_time) ? next_frame_time_ - current_time : 0;
process_thread_->PostDelayed(RTC_FROM_HERE, wait_time, this, MSG_RUN_PROCESS);
}
void FakeAudioCaptureModule::ReceiveFrameP() {
RTC_CHECK(process_thread_->IsCurrent());
{
rtc::CritScope cs(&crit_callback_);
if (!audio_callback_) {
return;
}
ResetRecBuffer();
size_t nSamplesOut = 0;
int64_t elapsed_time_ms = 0;
int64_t ntp_time_ms = 0;
if (audio_callback_->NeedMorePlayData(kNumberSamples, kNumberBytesPerSample,
kNumberOfChannels, kSamplesPerSecond,
rec_buffer_, nSamplesOut,
&elapsed_time_ms, &ntp_time_ms) != 0) {
RTC_NOTREACHED();
}
RTC_CHECK(nSamplesOut == kNumberSamples);
}
// The SetBuffer() function ensures that after decoding, the audio buffer
// should contain samples of similar magnitude (there is likely to be some
// distortion due to the audio pipeline). If one sample is detected to
// have the same or greater magnitude somewhere in the frame, an actual frame
// has been received from the remote side (i.e. faked frames are not being
// pulled).
if (CheckRecBuffer(kHighSampleValue)) {
rtc::CritScope cs(&crit_);
++frames_received_;
}
}
void FakeAudioCaptureModule::SendFrameP() {
RTC_CHECK(process_thread_->IsCurrent());
rtc::CritScope cs(&crit_callback_);
if (!audio_callback_) {
return;
}
bool key_pressed = false;
uint32_t current_mic_level = 0;
MicrophoneVolume(¤t_mic_level);
if (audio_callback_->RecordedDataIsAvailable(send_buffer_, kNumberSamples,
kNumberBytesPerSample,
kNumberOfChannels,
kSamplesPerSecond, kTotalDelayMs,
kClockDriftMs, current_mic_level,
key_pressed,
current_mic_level) != 0) {
RTC_NOTREACHED();
}
SetMicrophoneVolume(current_mic_level);
}
|
Name: ys_mapdt.asm
Type: file
Size: 76124
Last-Modified: '2016-05-13T04:50:38Z'
SHA-1: 41E94B0151DB079BE4F00A3F111FBD8E2C1BCD78
Description: null
|
// Copyright (c) 2011-2014 The Bogcoin developers
// Copyright (c) 2017 The PIVX developers
// Copyright (c) 2017-2019 The BogCoin Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "recentrequeststablemodel.h"
#include "bogcoinunits.h"
#include "clientversion.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "streams.h"
#include <boost/foreach.hpp>
RecentRequestsTableModel::RecentRequestsTableModel(CWallet* wallet, WalletModel* parent) : walletModel(parent)
{
Q_UNUSED(wallet);
nReceiveRequestsMaxId = 0;
// Load entries from wallet
std::vector<std::string> vReceiveRequests;
parent->loadReceiveRequests(vReceiveRequests);
BOOST_FOREACH (const std::string& request, vReceiveRequests)
addNewRequest(request);
/* These columns must match the indices in the ColumnIndex enumeration */
columns << tr("Date") << tr("Label") << tr("Address") << tr("Message") << getAmountTitle();
connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
}
RecentRequestsTableModel::~RecentRequestsTableModel()
{
/* Intentionally left empty */
}
int RecentRequestsTableModel::rowCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
return list.length();
}
int RecentRequestsTableModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
return columns.length();
}
QVariant RecentRequestsTableModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid() || index.row() >= list.length())
return QVariant();
const RecentRequestEntry* rec = &list[index.row()];
if (role == Qt::DisplayRole || role == Qt::EditRole) {
switch (index.column()) {
case Date:
return GUIUtil::dateTimeStr(rec->date);
case Label:
if (rec->recipient.label.isEmpty() && role == Qt::DisplayRole) {
return tr("(no label)");
} else {
return rec->recipient.label;
}
case Address:
return rec->recipient.address;
case Message:
if (rec->recipient.message.isEmpty() && role == Qt::DisplayRole) {
return tr("(no message)");
} else {
return rec->recipient.message;
}
case Amount:
if (rec->recipient.amount == 0 && role == Qt::DisplayRole)
return tr("(no amount)");
else if (role == Qt::EditRole)
return BogcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount, false, BogcoinUnits::separatorNever);
else
return BogcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount);
}
} else if (role == Qt::TextAlignmentRole) {
if (index.column() == Amount)
return (int)(Qt::AlignRight | Qt::AlignVCenter);
}
return QVariant();
}
bool RecentRequestsTableModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
return true;
}
QVariant RecentRequestsTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal) {
if (role == Qt::DisplayRole && section < columns.size()) {
return columns[section];
}
}
return QVariant();
}
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
void RecentRequestsTableModel::updateAmountColumnTitle()
{
columns[Amount] = getAmountTitle();
emit headerDataChanged(Qt::Horizontal, Amount, Amount);
}
/** Gets title for amount column including current display unit if optionsModel reference available. */
QString RecentRequestsTableModel::getAmountTitle()
{
QString amountTitle = tr("Amount");
if (this->walletModel->getOptionsModel() != nullptr) {
amountTitle += " (" + BogcoinUnits::name(this->walletModel->getOptionsModel()->getDisplayUnit()) + ")";
}
return amountTitle;
}
QModelIndex RecentRequestsTableModel::index(int row, int column, const QModelIndex& parent) const
{
Q_UNUSED(parent);
return createIndex(row, column);
}
bool RecentRequestsTableModel::removeRows(int row, int count, const QModelIndex& parent)
{
Q_UNUSED(parent);
if (count > 0 && row >= 0 && (row + count) <= list.size()) {
const RecentRequestEntry* rec;
for (int i = 0; i < count; ++i) {
rec = &list[row + i];
if (!walletModel->saveReceiveRequest(rec->recipient.address.toStdString(), rec->id, ""))
return false;
}
beginRemoveRows(parent, row, row + count - 1);
list.erase(list.begin() + row, list.begin() + row + count);
endRemoveRows();
return true;
} else {
return false;
}
}
Qt::ItemFlags RecentRequestsTableModel::flags(const QModelIndex& index) const
{
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}
// called when adding a request from the GUI
void RecentRequestsTableModel::addNewRequest(const SendCoinsRecipient& recipient)
{
RecentRequestEntry newEntry;
newEntry.id = ++nReceiveRequestsMaxId;
newEntry.date = QDateTime::currentDateTime();
newEntry.recipient = recipient;
CDataStream ss(SER_DISK, CLIENT_VERSION);
ss << newEntry;
if (!walletModel->saveReceiveRequest(recipient.address.toStdString(), newEntry.id, ss.str()))
return;
addNewRequest(newEntry);
}
// called from ctor when loading from wallet
void RecentRequestsTableModel::addNewRequest(const std::string& recipient)
{
std::vector<char> data(recipient.begin(), recipient.end());
CDataStream ss(data, SER_DISK, CLIENT_VERSION);
RecentRequestEntry entry;
ss >> entry;
if (entry.id == 0) // should not happen
return;
if (entry.id > nReceiveRequestsMaxId)
nReceiveRequestsMaxId = entry.id;
addNewRequest(entry);
}
// actually add to table in GUI
void RecentRequestsTableModel::addNewRequest(RecentRequestEntry& recipient)
{
beginInsertRows(QModelIndex(), 0, 0);
list.prepend(recipient);
endInsertRows();
}
void RecentRequestsTableModel::sort(int column, Qt::SortOrder order)
{
qSort(list.begin(), list.end(), RecentRequestEntryLessThan(column, order));
emit dataChanged(index(0, 0, QModelIndex()), index(list.size() - 1, NUMBER_OF_COLUMNS - 1, QModelIndex()));
}
void RecentRequestsTableModel::updateDisplayUnit()
{
updateAmountColumnTitle();
}
bool RecentRequestEntryLessThan::operator()(RecentRequestEntry& left, RecentRequestEntry& right) const
{
RecentRequestEntry* pLeft = &left;
RecentRequestEntry* pRight = &right;
if (order == Qt::DescendingOrder)
std::swap(pLeft, pRight);
switch (column) {
case RecentRequestsTableModel::Date:
return pLeft->date.toTime_t() < pRight->date.toTime_t();
case RecentRequestsTableModel::Label:
return pLeft->recipient.label < pRight->recipient.label;
case RecentRequestsTableModel::Address:
return pLeft->recipient.address < pRight->recipient.address;
case RecentRequestsTableModel::Message:
return pLeft->recipient.message < pRight->recipient.message;
case RecentRequestsTableModel::Amount:
return pLeft->recipient.amount < pRight->recipient.amount;
default:
return pLeft->id < pRight->id;
}
}
|
#include <ctime>
#include <iostream>
#include <string>
#include <boost/asio.hpp>
using boost::asio::ip::tcp;
std::string make_daytime_string() {
using namespace std; // For time_t, time and ctime;
time_t now = time(0);
return ctime(&now);
}
int main() {
try {
boost::asio::io_service io_service;
tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 23324));
for (;;) {
tcp::socket socket(io_service);
acceptor.accept(socket);
std::string message = make_daytime_string();
boost::system::error_code ignored_error;
boost::asio::write(socket, boost::asio::buffer(message),
ignored_error);
}
} catch (std::exception& e) {
std::cerr << e.what() << std::endl;
}
return 0;
}
|
// X-Cam Timer
origin 0x0185E0
base 0x8025D5E0
j Xcam // 1302
origin 0x0185F4
base 0x8025D5F4
j Xcam // 1307
origin 0x018608
base 0x8025D608
j Xcam // 1303
|
; A170685: Number of reduced words of length n in Coxeter group on 4 generators S_i with relations (S_i)^2 = (S_i S_j)^50 = I.
; 1,4,12,36,108,324,972,2916,8748,26244,78732,236196,708588,2125764,6377292,19131876,57395628,172186884,516560652,1549681956,4649045868,13947137604,41841412812,125524238436,376572715308,1129718145924,3389154437772,10167463313316,30502389939948,91507169819844,274521509459532,823564528378596,2470693585135788,7412080755407364
mov $1,3
pow $1,$0
mul $1,8
div $1,6
|
; A262333: Number of (n+3) X (1+3) 0..1 arrays with each row and column divisible by 9, read as a binary number with top and left being the most significant bits.
; 2,4,8,15,29,57,114,228,456,911,1821,3641,7282,14564,29128,58255,116509,233017,466034,932068,1864136,3728271,7456541,14913081,29826162,59652324,119304648,238609295,477218589,954437177,1908874354,3817748708,7635497416,15270994831,30541989661,61083979321,122167958642,244335917284,488671834568,977343669135,1954687338269,3909374676537,7818749353074,15637498706148,31274997412296,62549994824591,125099989649181,250199979298361,500399958596722,1000799917193444,2001599834386888,4003199668773775,8006399337547549
mov $1,2
pow $1,$0
mul $1,32
div $1,18
add $1,1
|
;
; Part of Metta OS. Check https://atta-metta.net for latest version.
;
; Copyright 2007 - 2017, Stanislav Karchebnyy <berkus@atta-metta.net>
;
; Distributed under the Boost Software License, Version 1.0.
; (See file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt)
;
; Rename functions so they don't clash with whatever builtins there might be.
; extern "C" int __sjljeh_setjmp(jmp_buf buf);
; extern "C" void __sjljeh_longjmp(jmp_buf buf, int retval) NEVER_RETURNS;
global __sjljeh_setjmp
global __sjljeh_longjmp
; FP -> return address
; FP+4 -> jmp_buf pointer
;
__sjljeh_setjmp:
mov ecx, [esp] ; return address to ECX
mov eax, [esp+4] ; jmp_buf address to EAX
mov [eax], ecx ; first word of jmp_buf = return address
; now save GP registers as required by C std
mov [eax+4], ebx
mov [eax+8], esi
mov [eax+12], edi
mov [eax+16], ebp
mov [eax+20], esp
xor eax, eax ; setjmp returns 0
ret
; FP -> return address
; FP+4 -> jmp_buf pointer
; FP+8 -> return value
;
__sjljeh_longjmp:
mov ecx, [esp+4] ; jmp_buf address in ECX
mov eax, [esp+8] ; return value in EAX
; now restore GP registers
mov ebx, [ecx+4]
mov esi, [ecx+8]
mov edi, [ecx+12]
mov ebp, [ecx+16]
mov esp, [ecx+20]
; restore stack frame
mov edx, [ecx] ; original return address in EDX
mov [esp], edx ; store original return address
mov [esp+4], ecx ; write over jmp_buf address (so that if compiler assumed it to be on the stack frame it won't fail)
; return value in EAX, if you longjmp with return value of 0 it's a logic error.
ret
|
; A025774: Expansion of 1/((1-x)(1-x^4)(1-x^9)).
; 1,1,1,1,2,2,2,2,3,4,4,4,5,6,6,6,7,8,9,9,10,11,12,12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,31,32,33,34,36,38,39,40,42,44,45,46,48,50,52,53,55,57,59,60,62
mov $5,$0
mov $7,$0
add $7,1
lpb $7,1
mov $0,$5
sub $7,1
sub $0,$7
mov $2,80
mov $3,$0
mov $0,44
add $2,$3
mov $4,$2
sub $4,4
mul $4,2
lpb $0,1
mov $0,$4
div $0,9
lpe
div $4,8
mov $2,$4
sub $2,$0
mov $6,$2
sub $6,2
add $1,$6
lpe
|
copyright zengfr site:http://github.com/zengfr/romhack
006D7C tst.b ($4db,A5)
006D80 bne $6e28
006DFC tst.b ($4db,A5)
006E00 bne $6e28
006E2A tst.b ($4db,A5)
006E2E bne $6eae
00AD24 bne $ad34 [base+4D9]
00AD34 rts [base+4DB]
08BDC8 move.b #$1, ($4db,A5) [base+4D5]
08BDCE move.b #$1, ($50e,A5) [base+4DB]
08C096 clr.b ($4db,A5) [base+4D5]
08C09A clr.b ($50e,A5) [base+4DB]
copyright zengfr site:http://github.com/zengfr/romhack
|
; A158409: a(n) = 900*n - 1.
; 899,1799,2699,3599,4499,5399,6299,7199,8099,8999,9899,10799,11699,12599,13499,14399,15299,16199,17099,17999,18899,19799,20699,21599,22499,23399,24299,25199,26099,26999,27899,28799,29699,30599,31499,32399,33299,34199,35099,35999,36899,37799,38699,39599,40499,41399,42299,43199,44099,44999,45899,46799,47699,48599,49499,50399,51299,52199,53099,53999,54899,55799,56699,57599,58499,59399,60299,61199,62099,62999,63899,64799,65699,66599,67499,68399,69299,70199,71099,71999,72899,73799,74699,75599,76499
mul $0,900
add $0,899
|
#include <stdlib.h>
#include <fstream>
#include "chip8.h"
// Load program
void chip8::loadProgram(char* romPath){
// Resets program counter, opcode, index register, an stack pointer
programCounter = 0x200;
I = 0;
stackPointer = 0;
// Opens a filestream
std::ifstream file(romPath, std::ios::binary | std::ios::ate);
if(file.is_open()){
// Loads program from file to system memory
std::streampos programSize = file.tellg();
char* buffer = new char[programSize];
file.seekg(0, std::ios::beg);
file.read(buffer, programSize);
file.close();
// Load program from system memory to CHIP-8 memory
for(int i = 0; i < programSize; i++) memory[programCounter+i] = buffer[i];
}
}
// Updates timers
void chip8::updateTimer(){
if(delayTimer != 0) delayTimer--;
if(soundTimer != 0) soundTimer--;
return;
}
// Emulates the CHIP-8 instruction set
bool chip8::processorCycle(){
// Fetch opcodes
unsigned short opcode = memory[programCounter] << 8 | memory[programCounter + 1];
// Decode opcodes (instruction set)
switch(opcode & 0xF000){
// Execute Opcodes
case 0x0000: // 0xxx
switch(opcode){
case 0x00E0: // Clear the display
memset(displayMap, 0, height*width);
disp.refreshScreen();
break;
case 0x00EE: // Return from subroutine
stackPointer--;
programCounter = stack[stackPointer];
break;
} break;
case 0x1000: // 1nnn: Sets program counter to nnn
programCounter = opcode & 0x0FFF;
break;
case 0x2000: // 2nnn: Executes subroutine at nnn
stackPointer++;
stack[stackPointer] = programCounter+2;
programCounter = opcode & 0x0FFF;
break;
case 0x3000: // 3xkk: if V[x] == kk, skip the next instruction
if(V[(opcode & 0x0F00) / 0x100] == opcode & 0x00FF) programCounter+=4;
else programCounter+=2;
break;
case 0x4000: // 4xkk: if V[x] != kk, skip the next instruction
if(V[(opcode & 0x0F00) / 0x100] == opcode & 0x00FF) programCounter+=4;
else programCounter+=2;
break;
case 0x5000: // 5xy0: if V[x] == V[y], skip the next instruction
if(V[(opcode & 0x0F00) / 0x100] == V[(opcode & 0x00F0) / 0x10]) programCounter+=4;
else programCounter+=2;
break;
case 0x6000: // 6xkk: sets V[x] to kk
V[(opcode & 0x0F00) / 0x100] = opcode & 0x00FF;
programCounter+=2;
break;
case 0x7000: // 7xkk: V[x] += kk
V[(opcode & 0x0F00) / 0x100] += opcode & 0x00FF;
programCounter+=2;
break;
case 0x8000: // 0xxx
switch(opcode & 0x000F){
case 0x0000: // 8xy0: V[x] = V[y]
V[(opcode & 0x0F00) / 0x0100] = V[(opcode & 0x00F0) / 0x0010];
programCounter+=2;
break;
case 0x0001: // 8xy1: V[x] = V[x] OR V[y]
V[(opcode & 0x0F00) / 0x0100] = V[(opcode & 0x0F00) / 0x0100] | V[(opcode & 0x00F0) / 0x0010];
programCounter+=2;
break;
case 0x0002: // 8xy2: V[x] = V[x] AND V[y]
V[(opcode & 0x0F00) / 0x0100] = V[(opcode & 0x0F00) / 0x0100] & V[(opcode & 0x00F0) / 0x0010];
programCounter+=2;
break;
case 0x0003: // 8xy3: V[x] = V[x] XOR V[y]
V[(opcode & 0x0F00) / 0x0100] = V[(opcode & 0x0F00) / 0x0100] ^ V[(opcode & 0x00F0) / 0x0010];
programCounter+=2;
break;
case 0x0004: // 8xy4: V[x] = V[x] + V[y], V[F] = integer overflow
int i = V[(opcode & 0x0F00) / 0x0100] + V[(opcode & 0x00F0) / 0x0010];
if(i > 255) V[0xF] = 1;
else V[0xF] = 0;
V[(opcode & 0x0F00) / 0x0100] = V[(opcode & 0x0F00) / 0x0100] + V[(opcode & 0x00F0) / 0x0010];
programCounter+=2;
break;
case 0x0005: //8xy4: V[x] = V[x] + V[y], V[F] = not borrowing
if(V[(opcode & 0x0F00) / 0x0100] < V[(opcode & 0x00F0) / 0x0010]){
V[0xF] = 0; // Borrow
V[(opcode & 0x0F00) / 0x0100] = V[(opcode & 0x00F0) / 0x0010] - V[(opcode & 0x0F00) / 0x0100];
}
else{
V[0xF] = 1; // Don't borrow
V[(opcode & 0x0F00) / 0x0100] = V[(opcode & 0x0F00) / 0x0100] - V[(opcode & 0x00F0) / 0x0010];
}
programCounter+=2;
break;
case 0x0006: //8xy6: V[F] = least significant bit of V[x], V[x] /= 2
V[(opcode & 0x0F00) / 0x0100] & 0x000F == 1 ? V[0xF] = 1 : V[0xF] == 0;
V[(opcode & 0x0F00) / 0x0100] /= 2;
programCounter+=2;
break;
case 0x0007: //8xy7:
if(V[(opcode & 0x00F0) / 0x0010] < V[(opcode & 0x0F00) / 0x0100]){
V[0xF] = 0; // Borrow
V[(opcode & 0x0F00) / 0x0100] = V[(opcode & 0x0F00) / 0x0100] - V[(opcode & 0x00F0) / 0x0010];
}
else{
V[0xF] = 1; // Don't borrow
V[(opcode & 0x0F00) / 0x0100] = V[(opcode & 0x00F0) / 0x0010] - V[(opcode & 0x0F00) / 0x0100];
}
programCounter+=2;
break;
case 0x000E: // 8xyE: V[F] = least significant bit of V[x], V[x] *= 2
V[(opcode & 0x0F00) / 0x0100] & 0x000F == 1 ? V[0xF] = 1 : V[0x000F] == 0;
V[(opcode & 0x0F00) / 0x0100] *= 2;
programCounter+=2;
break;
} break;
case 0x9000: // 9xy0: if V[x] != V[y], skip the next instruction
if(V[(opcode & 0x0F00) / 0x0100] != V[(opcode & 0x00F0) / 0x0010]) programCounter+=4;
programCounter+=2;
break;
case 0xA000: // Annn: set I = nnn
I = opcode & 0x0FFF;
programCounter+=2;
break;
case 0xB000: // Bnnn: set programCounter = nnn + V[0]
programCounter = (opcode & 0x0FFF) + V[0];
programCounter+=2;
break;
case 0xC000: // Cxkk: V[x] = rand % 255 & kk
V[opcode & 0x0F00 / 0x0100] = (rand() % 255) & (opcode & 0x00FF);
programCounter+=2;
break;
case 0xD000: // Dxyn: XORs a n-byte starting at I sprite onto the screen at x, y. V[F] = 1 if any pixels are erased
// DO SMTH
unsigned char bytes = opcode % 0x000F;
unsigned char x = opcode % 0x0F00 / 0x0100;
unsigned char y = opcode % 0x00F0 / 0x0010;
V[0x000F] = 0;
for(int line = 0; line < bytes; line++){
unsigned char thisline = memory[I+line];
for(int col = 0; col < 8; col++){
if(displayMap[V[x]+col][V[y]+line] == (thisline >> col)) V[0x000F] = 1;
displayMap[V[x]+col][V[y]+line] = displayMap[V[x]+col][V[y]+line] ^ (thisline >> col);
disp.addToQueue(col, line);
}
}
disp.updateScreen();
programCounter+=2;
break;
case 0xE000: // Exxx
switch(opcode & 0x00FF){
case 0x009E: // Ex9E: Skip the next instruction if the key indicated by V[x] is pressed
if(kb.isPressed(V[(opcode & 0x0F00) / 0x0100])) programCounter+=4;
else programCounter+=2;
break;
case 0x00A1: // ExA1: Skip the next instruction if the key indicated by V[x] is not pressed
if(!kb.isPressed(V[(opcode & 0x0F00) / 0x0100])) programCounter+=4;
else programCounter+=2;
break;
} break;
case 0xF000: // Fxxx
switch(opcode & 0x00FF){
case 0x0007: // Fx07: V[x] = delayTimer
V[(opcode & 0x0F00) / 0x0100] = delayTimer;
programCounter+=2;
break;
case 0x000A: // Fx0A: Waits for a keypress, pausing all other execution of instructions, and stores the key value in V[x]
char key = kb.readKey();
if(key != 255) V[(opcode & 0x0F00) / 0x0100] = key; programCounter+=2;
break;
case 0x0015: // Fx15: Sets the delayTimer to V[x]
delayTimer = V[(opcode & 0x0F00) / 0x0100];
programCounter+=2;
break;
case 0x0018: // Fx18: Sets soundTimer to V[x]
soundTimer = V[(opcode & 0x0F00) / 0x0100];
programCounter+=2;
break;
case 0x001E: // Fx1E: I = I + V[x]
I += V[(opcode & 0x0F00) / 0x0100];
programCounter+=2;
break;
case 0x0029: // Fx29: Sets I to the memory address of the character cooresponding to V[x]
I = V[(opcode & 0x0F00) / 0x0100] * 5;
programCounter+=2;
break;
case 0x0033: // Fx33: IN DECIMAL, NOT HEX, store the hundreds value of V[x] at I, the tens value at I+1, and the ones value at I+2
char hun, ten, one;
hun = V[(opcode & 0x0F00) / 0x0100] / 100;
ten = V[(opcode & 0x0F00) / 0x0100] % 100 / 10;
one = V[(opcode & 0x0F00) / 0x0100] % 10;
programCounter+=2;
break;
case 0x0055: // Fx55: Store V[0] thru V[x] inclusive to memory, starting at I
for(int i = 0; i <= (opcode & 0x0F00) / 0x0100; i++) memory[I+i] = V[i];
programCounter+=2;
break;
case 0x0065: // Fx65: Read x+1 bytes from memory to the V registers (V[0] to V[x]), starting from I
for(int i = 0; i <= (opcode & 0x0F00) / 0x0100; i++) V[i] = memory[I+i];
programCounter+=2;
break;
} break;
}
updateTimer();
return false;
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x58ea, %rsi
lea addresses_normal_ht+0x2ae6, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
inc %r13
mov $103, %rcx
rep movsl
nop
nop
dec %rax
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r8
push %rdi
push %rsi
// Faulty Load
lea addresses_US+0x126e6, %r10
clflush (%r10)
nop
xor $13932, %r8
mov (%r10), %rsi
lea oracles, %rdi
and $0xff, %rsi
shlq $12, %rsi
mov (%rdi,%rsi,1), %rsi
pop %rsi
pop %rdi
pop %r8
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_US', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_US', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
#include "data_structure/parallel/thread_pool.h"
#include "data_structure/parallel/time.h"
#include "uncoarsening/refinement/parallel_kway_graph_refinement/kway_graph_refinement_core.h"
#include "uncoarsening/refinement/parallel_kway_graph_refinement/multitry_kway_fm.h"
namespace parallel {
std::vector<thread_data_factory::statistics_type> thread_data_factory::m_statistics;
int multitry_kway_fm::perform_refinement(PartitionConfig& config, graph_access& G, boundary_type& boundary,
unsigned rounds, bool init_neighbors, unsigned alpha) {
double tmp_alpha = config.kway_adaptive_limits_alpha;
KWayStopRule tmp_stop = config.kway_stop_rule;
config.kway_adaptive_limits_alpha = alpha;
config.kway_stop_rule = KWAY_ADAPTIVE_STOP_RULE;
EdgeWeight overall_improvement = 0;
uint32_t iter = 0;
bool stop = false;
estimator<double> est;
while (!stop) {
CLOCK_START;
setup_start_nodes_all(G, config, boundary);
if (config.check_cut) {
boundary.check_boundary();
}
if (m_factory.queue.empty()) {
break;
}
m_factory.time_setup_start_nodes += CLOCK_END_TIME;
uint64_t accesses_before = m_factory.get_total_num_part_accesses();
CLOCK_START_N;
EdgeWeight improvement = start_more_locallized_search(G, config, init_neighbors, rounds);
m_factory.time_local_search += CLOCK_END_TIME;
uint64_t work = m_factory.get_total_num_part_accesses() - accesses_before;
if (improvement == 0) {
stop = true;
}
decide_if_stop(LoopType::Global, config, iter, rounds, est, work, improvement, overall_improvement, stop);
add_value(est, (work + 0.0) / improvement);
overall_improvement += improvement;
++iter;
}
config.kway_adaptive_limits_alpha = tmp_alpha;
config.kway_stop_rule = tmp_stop;
ASSERT_TRUE(overall_improvement >= 0);
return overall_improvement;
}
void multitry_kway_fm::decide_if_stop(LoopType type, PartitionConfig& config, uint32_t iter, uint32_t rounds, estimator<double>& est,
uint64_t work, EdgeWeight improvement, EdgeWeight overall_improvement, bool& stop) const {
MultitryKwayLoopStoppingRule stopping_rule;
if (type == LoopType::Global) {
stopping_rule = config.multitry_kway_global_loop_stopping_rule;
} else if (type == LoopType::Local) {
stopping_rule = config.multitry_kway_local_loop_stopping_rule;
} else {
throw std::logic_error("Undefined loop type");
}
// stop after a preset number of iterations is performed
if (stopping_rule == MultitryKwayLoopStoppingRule::ITERATION) {
if (iter + 1 == rounds) {
stop = true;
}
}
// quantile stop
if (stopping_rule == MultitryKwayLoopStoppingRule::QUANTILE) {
double qm = 0.0;
if (overall_improvement > 0 && improvement > 0) {
std::string loop_type;
double p = 0.0;
if (type == LoopType::Global) {
loop_type = "GLOBAL";
p = global_quantile;
}
if (type == LoopType::Local) {
loop_type = "LOCAL";
p = local_quantile;
}
qm = get_quantile(est, p);
if (distribution_type == DistributionType::LogNormal) {
}
}
if (overall_improvement > 0 && improvement > 0 && iter > 1 && qm < (work + 0.0) / improvement) {
stop = true;
}
}
// percentage stop
if (stopping_rule == MultitryKwayLoopStoppingRule::PERCENTAGE) {
if (type == LoopType::Global) {
if (overall_improvement * (config.stop_mls_global_threshold / 100.0) > improvement) {
stop = true;
}
}
if (type == LoopType::Local) {
if (overall_improvement * (config.stop_mls_local_threshold / 100.0) > improvement) {
stop = true;
}
}
}
}
//int multitry_kway_fm::perform_refinement_around_parts(PartitionConfig& config, graph_access& G,
// parallel::fast_sequential_boundary& boundary, bool init_neighbors,
// unsigned alpha,
// PartitionID& lhs, PartitionID& rhs) {
// unsigned tmp_alpha = config.kway_adaptive_limits_alpha;
// KWayStopRule tmp_stop = config.kway_stop_rule;
// config.kway_adaptive_limits_alpha = alpha;
// config.kway_stop_rule = KWAY_ADAPTIVE_STOP_RULE;
// int overall_improvement = 0;
//
// for (unsigned i = 0; i < config.local_multitry_rounds; i++) {
// CLOCK_START;
//
// setup_start_nodes_around_blocks(G, boundary, lhs, rhs);
//
// if (m_factory.queue.size() == 0) {
// break;
// }
// m_factory.time_setup_start_nodes += CLOCK_END_TIME;
//
//
// CLOCK_START_N;
// EdgeWeight improvement = start_more_locallized_search(config, G, boundary, init_neighbors, true);
//
// m_factory.time_local_search += CLOCK_END_TIME;
// if (improvement == 0) {
// break;
// }
//
// overall_improvement += improvement;
// }
// config.kway_adaptive_limits_alpha = tmp_alpha;
// config.kway_stop_rule = tmp_stop;
// ASSERT_TRUE(overall_improvement >= 0);
// return overall_improvement;
//}
int multitry_kway_fm::start_more_locallized_search(graph_access& G, PartitionConfig& config, bool init_neighbors, uint32_t rounds) {
uint32_t num_threads = config.num_threads;
parallel::kway_graph_refinement_core refinement_core;
int local_step_limit = 50;
CLOCK_START;
#ifdef COMPARE_WITH_SEQUENTIAL_KAHIP
m_factory.m_config.num_threads = 1;
num_threads = 1;
std::vector<NodeID> todolist;
todolist.reserve(m_factory.queue.size());
NodeID node;
while (m_factory.queue.try_pop(node, 0)) {
todolist.push_back(node);
}
std::sort(todolist.begin(), todolist.end());
auto it = std::unique(todolist.begin(), todolist.end());
todolist.resize(it - todolist.begin());
random_functions::permutate_vector_good(todolist, false);
#endif
Gain total_gain_improvement = 0;
estimator<double> est;
uint32_t iter = 0;
bool stop = false;
#ifdef COMPARE_WITH_SEQUENTIAL_KAHIP
while (!todolist.empty()) {
#else
// we need the external loop for move strategy when conflicted nodes are reactivated for the next
// parallel phase
while (!m_factory.queue.empty() && !stop) {
#endif
auto task = [&](uint32_t id) {
CLOCK_START;
NodeID node;
auto& td = m_factory.get_thread_data(id);
td.reset_thread_data();
td.step_limit = local_step_limit;
NodeID nodes_processed = 0;
bool res = false;
#ifdef COMPARE_WITH_SEQUENTIAL_KAHIP
while (!todolist.empty()) {
int random_idx = random_functions::nextInt(0, todolist.size() - 1);
NodeID node = todolist[random_idx];
#else
while (m_factory.queue.try_pop(node, id)) {
#endif
// this change changes num part accesses since it changes random source
#ifdef COMPARE_WITH_SEQUENTIAL_KAHIP
#else
if (!td.moved_idx[node].load(std::memory_order_relaxed)) {
#endif
PartitionID maxgainer;
EdgeWeight extdeg = 0;
PartitionID from = td.get_local_partition(node);
td.compute_gain(node, from, maxgainer, extdeg);
#ifdef COMPARE_WITH_SEQUENTIAL_KAHIP
if (!td.moved_idx[node].load(std::memory_order_relaxed) && extdeg > 0) {
#else
if (extdeg > 0) {
#endif
td.start_nodes.clear();
td.start_nodes.reserve(G.getNodeDegree(node) + 1);
td.start_nodes.push_back(node);
if (init_neighbors) {
forall_out_edges(G, e, node) {
++td.scaned_neighbours;
NodeID target = G.getEdgeTarget(e);
if (!td.moved_idx[target].load(std::memory_order_relaxed)) {
extdeg = 0;
PartitionID from = td.get_local_partition(target);
td.compute_gain(target, from, maxgainer, extdeg);
if (extdeg > 0) {
td.start_nodes.push_back(target);
}
}
} endfor
}
nodes_processed += td.start_nodes.size();
int improvement = 0;
int min_cut_index = 0;
NodeID tried_movements = 0;
size_t moved_before = td.moved.size();
std::tie(improvement, min_cut_index, tried_movements) =
refinement_core.single_kway_refinement_round(td);
if (improvement < 0) {
abort();
}
td.upper_bound_gain += improvement;
ALWAYS_ASSERT(!td.transpositions.empty());
td.min_cut_indices.emplace_back(min_cut_index, td.transpositions.size() - 1);
if (!td.config.kway_all_boundary_nodes_refinement) {
td.moved_count[id].get().fetch_add(td.moved.size() - moved_before,
std::memory_order_relaxed);
}
td.tried_movements += tried_movements;
}
#ifndef COMPARE_WITH_SEQUENTIAL_KAHIP
}
#endif
if (!td.config.kway_all_boundary_nodes_refinement) {
int overall_movement = 0;
for (uint32_t thread_id = 0; thread_id < num_threads; ++thread_id) {
int moved = td.moved_count[thread_id].get().load(std::memory_order_relaxed);
overall_movement += moved;
}
if (overall_movement > 0.05 * G.number_of_nodes()) {
++td.stop_faction_of_nodes_moved;
res = true;
break;
}
}
#ifdef COMPARE_WITH_SEQUENTIAL_KAHIP
std::swap(todolist[random_idx], todolist[todolist.size() - 1]);
todolist.pop_back();
#endif
}
td.num_threads_finished.fetch_add(1, std::memory_order_acq_rel);
td.total_thread_time += CLOCK_END_TIME;
return res;
};
CLOCK_START_N;
std::vector<std::future<bool>> futures;
futures.reserve(num_threads - 1);
auto accesses_before = m_factory.get_total_num_part_accesses();
for (uint32_t id = 1; id < num_threads; ++id) {
futures.push_back(parallel::g_thread_pool.Submit(id - 1, task, id));
}
bool is_more_that_5percent_moved = task(0);
{
CLOCK_START;
std::for_each(futures.begin(), futures.end(), [&](auto& future) {
if (future.get()) {
is_more_that_5percent_moved = true;
}
});
m_factory.time_wait += CLOCK_END_TIME;
}
m_factory.time_generate_moves += CLOCK_END_TIME;
std::vector<NodeID> reactivated_vertices;
reactivated_vertices.reserve(100);
int real_gain_improvement = 0;
CLOCK_START_N;
real_gain_improvement = refinement_core.apply_moves(num_threads, m_factory.get_all_threads_data(),
reactivated_vertices);
ALWAYS_ASSERT(real_gain_improvement >= 0);
uint64_t work = m_factory.get_total_num_part_accesses() - accesses_before;
if (config.kway_all_boundary_nodes_refinement && real_gain_improvement == 0) {
stop = true;
}
decide_if_stop(LoopType::Local, config, iter, rounds, est, work, real_gain_improvement, total_gain_improvement, stop);
++iter;
add_value(est, (work + 0.0) / real_gain_improvement);
total_gain_improvement += real_gain_improvement;
if (!stop) {
m_factory.partial_reset_global_data();
CLOCK_START;
m_factory.get_thread_data(0).rnd.shuffle(reactivated_vertices);
for (auto vertex : reactivated_vertices) {
m_factory.queue.push(vertex);
}
m_factory.time_reactivate_vertices += CLOCK_END_TIME;
}
m_factory.time_move_nodes += CLOCK_END_TIME;
if (!config.kway_all_boundary_nodes_refinement && is_more_that_5percent_moved) {
stop = true;
}
}
CLOCK_START_N;
refinement_core.update_boundary(m_factory.get_thread_data(0));
m_factory.time_move_nodes += CLOCK_END_TIME;
m_factory.reset_global_data();
ALWAYS_ASSERT(total_gain_improvement >= 0);
return total_gain_improvement;
}
void multitry_kway_fm::setup_start_nodes_all(graph_access& G, PartitionConfig& config, parallel::fast_sequential_boundary& boundary) {
auto& td = m_factory.get_thread_data(0);
ALWAYS_ASSERT(config.num_threads > 0);
for (const auto& boundary_pair : boundary) {
NodeID bnd_node = boundary_pair.first;
uint32_t bucket_one = td.rnd.random_number(0u, config.num_threads - 1);
uint32_t bucket_two = td.rnd.random_number(0u, config.num_threads - 1);
if (m_factory.queue[bucket_one].size() <= m_factory.queue[bucket_two].size()) {
m_factory.queue[bucket_one].push_back(bnd_node);
} else {
m_factory.queue[bucket_two].push_back(bnd_node);
}
}
parallel::submit_for_all([this](uint32_t thread_id) {
auto& td = m_factory.get_thread_data(thread_id);
auto& thread_container = m_factory.queue[thread_id];
td.rnd.shuffle(thread_container.begin(), thread_container.end());
});
shuffle_task_queue();
}
void multitry_kway_fm::setup_start_nodes_all(graph_access& G, PartitionConfig& config, parallel::fast_parallel_boundary& boundary) {
ALWAYS_ASSERT(config.num_threads > 0);
parallel::submit_for_all([this, &boundary](uint32_t thread_id) {
auto& thread_container = m_factory.queue[thread_id];
auto& ht = boundary[thread_id];
thread_container.reserve(ht.size());
for (const auto& elem : ht) {
thread_container.push_back(elem.first);
}
auto& td = m_factory.get_thread_data(thread_id);
td.rnd.shuffle(thread_container.begin(), thread_container.end());
});
shuffle_task_queue();
}
void multitry_kway_fm::setup_start_nodes_all(graph_access& G, PartitionConfig& config, parallel::fast_parallel_boundary_exp& boundary) {
ALWAYS_ASSERT(config.num_threads > 0);
std::atomic<size_t> offset(0);
parallel::submit_for_all([this, &boundary, &offset](uint32_t thread_id) {
auto& thread_container = m_factory.queue[thread_id];
auto& ht_hadle = boundary[thread_id];
size_t size = ht_hadle.capacity();
const size_t block_size = std::min<size_t>(sqrt(size), 1000);
size_t begin = offset.fetch_add(block_size);
while (begin < size)
{
auto it = ht_hadle.range(begin, begin + block_size);
for (; it != ht_hadle.range_end(); ++it) {
thread_container.push_back((*it).first);
}
begin = offset.fetch_add(block_size);
}
auto& td = m_factory.get_thread_data(thread_id);
td.rnd.shuffle(thread_container.begin(), thread_container.end());
});
shuffle_task_queue();
}
void multitry_kway_fm::shuffle_task_queue() {
auto& td = m_factory.get_thread_data(0);
td.rnd.shuffle(m_factory.queue.begin(), m_factory.queue.end());
}
int multitry_kway_fm::start_more_locallized_search_experimental(PartitionConfig& config,
graph_access& G,
bool init_neighbors,
std::vector<NodeID>& todolist) {
uint32_t num_threads = config.num_threads;
parallel::kway_graph_refinement_core refinement_core;
int local_step_limit = 50;
ALWAYS_ASSERT(config.apply_move_strategy != ApplyMoveStrategy::REACTIVE_VERTICES);
m_factory.reset_global_data();
// uint32_t not_moved_start = todolist.size();
// std::atomic<uint32_t> not_moved_cur = not_moved_start;
std::atomic_bool first_execution;
first_execution.store(true, std::memory_order_relaxed);
int total_gain_improvement = 0;
while (!todolist.empty()) {
//all experiments with this parameter:
//const uint32_t batch_multiplicative_const = 10;
const uint32_t batch_multiplicative_const = 1;
uint32_t batch_size = batch_multiplicative_const * num_threads;
//uint32_t batch_size = todolist.size();
CLOCK_START;
for (size_t i = 0; i < batch_size && !todolist.empty();) {
size_t random_idx = random_functions::nextInt(0, todolist.size() - 1);
NodeID node = todolist[random_idx];
if (first_execution.load(std::memory_order_relaxed) || !m_factory.is_moved(node)) {
m_factory.queue.push(node);
++i;
}
std::swap(todolist[random_idx], todolist.back());
todolist.pop_back();
}
m_factory.time_init += CLOCK_END_TIME;
auto task = [&](uint32_t id) {
CLOCK_START;
NodeID node;
auto& td = m_factory.get_thread_data(id);
if (first_execution.load(std::memory_order_relaxed)) {
td.reset_thread_data();
} else {
td.partial_reset_thread_data();
}
td.step_limit = local_step_limit;
NodeID nodes_processed = 0;
while (m_factory.queue.try_pop(node, id)) {
PartitionID maxgainer;
EdgeWeight extdeg = 0;
PartitionID from = td.get_local_partition(node);
td.compute_gain(node, from, maxgainer, extdeg);
if (!td.moved_idx[node].load(std::memory_order_relaxed) && extdeg > 0) {
td.start_nodes.clear();
td.start_nodes.reserve(G.getNodeDegree(node) + 1);
td.start_nodes.push_back(node);
if (init_neighbors) {
forall_out_edges(G, e, node) {
NodeID target = G.getEdgeTarget(e);
if (!td.moved_idx[target].load(std::memory_order_relaxed)) {
extdeg = 0;
PartitionID from = td.get_local_partition(target);
td.compute_gain(target, from, maxgainer, extdeg);
if (extdeg > 0) {
td.start_nodes.push_back(target);
}
}
} endfor
}
nodes_processed += td.start_nodes.size();
int improvement = 0;
int min_cut_index = 0;
uint32_t tried_movements = 0;
size_t moved_before = td.moved.size();
std::tie(improvement, min_cut_index, tried_movements) =
refinement_core.single_kway_refinement_round(td);
if (improvement < 0) {
}
td.upper_bound_gain += improvement;
ALWAYS_ASSERT(td.transpositions.size() > 0);
td.min_cut_indices.emplace_back(min_cut_index, td.transpositions.size() - 1);
td.moved_count[id].get().fetch_add(td.moved.size() - moved_before,
std::memory_order_relaxed);
td.tried_movements += tried_movements;
}
int overall_movement = 0;
for (uint32_t id = 0; id < num_threads; ++id) {
int moved = td.moved_count[id].get().load(std::memory_order_relaxed);
overall_movement += moved;
}
if (overall_movement > 0.05 * G.number_of_nodes()) {
td.total_thread_time += CLOCK_END_TIME;
++td.stop_faction_of_nodes_moved;
return true;
}
}
td.total_thread_time += CLOCK_END_TIME;
return false;
};
CLOCK_START_N;
std::vector<std::future<bool>> futures;
futures.reserve(num_threads - 1);
for (uint32_t id = 1; id < num_threads; ++id) {
futures.push_back(parallel::g_thread_pool.Submit(id - 1, task, id));
//futures.push_back(parallel::g_thread_pool.Submit(task, id));
}
bool is_more_that_5percent_moved = task(0);
std::for_each(futures.begin(), futures.end(), [&](auto& future) {
if (future.get()) {
is_more_that_5percent_moved = true;
}
});
m_factory.time_generate_moves += CLOCK_END_TIME;
std::vector<NodeID> reactivated_vertices;
int real_gain_improvement = 0;
CLOCK_START_N;
real_gain_improvement = refinement_core.apply_moves(num_threads, m_factory.get_all_threads_data(),
reactivated_vertices);
total_gain_improvement += real_gain_improvement;
first_execution.store(false, std::memory_order_release);
m_factory.partial_reset_global_data();
m_factory.time_move_nodes += CLOCK_END_TIME;
ALWAYS_ASSERT(real_gain_improvement >= 0);
if (is_more_that_5percent_moved) {
break;
}
}
ALWAYS_ASSERT(total_gain_improvement >= 0);
return total_gain_improvement;
}
//void multitry_kway_fm::setup_start_nodes_around_blocks(graph_access& G, complete_boundary& boundary, PartitionID & lhs,
// PartitionID & rhs) {
// std::vector<PartitionID> lhs_neighbors;
// boundary.getNeighbors(lhs, lhs_neighbors);
//
// std::vector<PartitionID> rhs_neighbors;
// boundary.getNeighbors(rhs, rhs_neighbors);
//
// auto sub_task = [this, &G, &boundary](uint32_t thread_id, std::atomic<size_t>& counter, PartitionID part,
// const std::vector<PartitionID>& neighbour_parts) {
// auto& thread_container = m_factory.queue[thread_id];
//
// size_t offset = counter.fetch_add(1, std::memory_order_relaxed);
//
// while (offset < neighbour_parts.size()) {
// PartitionID neighbor_part = neighbour_parts[offset];
//
// const PartialBoundary& partial_boundary_part =
// boundary.getDirectedBoundaryThreadSafe(part, part, neighbor_part);
//
// for (const auto& elem : partial_boundary_part.internal_boundary) {
// NodeID cur_bnd_node = elem.first;
// ALWAYS_ASSERT(G.getPartitionIndex(cur_bnd_node) == part);
// thread_container.push_back(cur_bnd_node);
// }
//
// const PartialBoundary& partial_boundary_neighbor_part =
// boundary.getDirectedBoundaryThreadSafe(neighbor_part, part, neighbor_part);
//
// for (const auto& elem : partial_boundary_neighbor_part.internal_boundary) {
// NodeID cur_bnd_node = elem.first;
// ALWAYS_ASSERT(G.getPartitionIndex(cur_bnd_node) == neighbor_part);
// thread_container.push_back(cur_bnd_node);
// }
// offset = counter.fetch_add(1, std::memory_order_relaxed);
// }
//
// auto& td = m_factory.get_thread_data(thread_id);
// td.rnd.shuffle(thread_container.begin(), thread_container.end());
// };
//
// std::atomic<size_t> lhs_counter(0);
// std::atomic<size_t> rhs_counter(0);
// auto task = [&](uint32_t thread_id) {
// sub_task(thread_id, lhs_counter, lhs, lhs_neighbors);
// sub_task(thread_id, rhs_counter, rhs, rhs_neighbors);
// };
//
// std::vector<std::future<void>> futures;
// futures.reserve(parallel::g_thread_pool.NumThreads());
//
// for (uint32_t id = 0; id < parallel::g_thread_pool.NumThreads(); ++id) {
// futures.push_back(parallel::g_thread_pool.Submit(id, task, id + 1));
// //futures.push_back(parallel::g_thread_pool.Submit(task, id + 1));
// }
//
// task(0);
// std::for_each(futures.begin(), futures.end(), [](auto& future) {
// future.get();
// });
//
// shuffle_task_queue();
//}
//
//void multitry_kway_fm::setup_start_nodes_all(graph_access& G, parallel::fast_sequential_boundary& boundary) {
// QuotientGraphEdges quotient_graph_edges;
// boundary.getQuotientGraphEdges(quotient_graph_edges);
//
// auto sub_task = [this, &G, &boundary, "ient_graph_edges](uint32_t thread_id, std::atomic<size_t>& counter) {
// auto& thread_container = m_factory.queue[thread_id];
//
// size_t offset = counter.fetch_add(1, std::memory_order_relaxed);
//
// while (offset < quotient_graph_edges.size()) {
// boundary_pair& ret_value = quotient_graph_edges[offset];
// PartitionID lhs = ret_value.lhs;
// PartitionID rhs = ret_value.rhs;
//
// auto& partial_boundary_lhs = boundary.getDirectedBoundaryThreadSafe(lhs, lhs, rhs);
// for (const auto& elem : partial_boundary_lhs.internal_boundary) {
// NodeID cur_bnd_node = elem.first;
// ALWAYS_ASSERT(G.getPartitionIndex(cur_bnd_node) == lhs);
//
// thread_container.push_back(cur_bnd_node);
// }
//
// auto& partial_boundary_rhs = boundary.getDirectedBoundaryThreadSafe(rhs, lhs, rhs);
// for (const auto& elem : partial_boundary_rhs.internal_boundary) {
// NodeID cur_bnd_node = elem.first;
// ALWAYS_ASSERT(G.getPartitionIndex(cur_bnd_node) == rhs);
//
// thread_container.push_back(cur_bnd_node);
// }
//
// offset = counter.fetch_add(1, std::memory_order_relaxed);
// }
//
// auto& td = m_factory.get_thread_data(thread_id);
// td.rnd.shuffle(thread_container.begin(), thread_container.end());
// };
//
// std::atomic<size_t> counter(0);
// auto task = [&](uint32_t thread_id) {
// sub_task(thread_id, counter);
// };
//
// std::vector<std::future<void>> futures;
// futures.reserve(parallel::g_thread_pool.NumThreads());
//
// for (uint32_t id = 0; id < parallel::g_thread_pool.NumThreads(); ++id) {
// futures.push_back(parallel::g_thread_pool.Submit(id, task, id + 1));
// //futures.push_back(parallel::g_thread_pool.Submit(task, id + 1));
// }
//
// task(0);
// std::for_each(futures.begin(), futures.end(), [](auto& future) {
// future.get();
// });
//
// shuffle_task_queue();
//}
}
|
; A017135: a(n) = (8*n + 5)^11.
; 48828125,1792160394037,350277500542221,12200509765705829,177917621779460413,1532278301220703125,9269035929372191597,43513917611435838661,168787390185178426269,564154396389137449973,1673432436896142578125,4501035456767426597157,11156683466653165551101,25804264053054077850709,56239892154164025151533,116415321826934814453125,230339304218442143770717,437935588474487527439541,803616698647447868139149,1428552404463186019525093,2467876294615567236328125,4154388758501693990272277,6830686029298982514463981,10992079124206967022251589,17343170265605241347130653,26871534751769943408203125,40942620682483067183061837,61420735191082762650784421,90821841990842470457948029,132504859553518749988128213,190909230887841213330078125,271847743804884990713499397,382864924217801243807760861,533672814240301731473788469,736677591779499338860277773,1007612299464980527001953125,1366292938960993269291344957,1837517363158923337459953301,2452128774972233608245132909,3248268229328068909082939333,4272843346683979034423828125,5583243494552763872208758517,7249334990994258712381121741,9355773444073799096880141349,12004674177479860045321072893,15318685818767563885595703125,19444516557322886668124300077,24556967328739840381780226181,30863531265827924755035773789,38609624189220868855209238453,48084516708184142230517578125,59628044680704813913766929637,73638181357622863863877426621,90579561525100676704093790229,110993055380142725966855596013,135506497742528825219189453125,164846686541113099864560007197,199852773331011222243920083061,241491177919137537737896750669,290872169017591458452425905573,349268263226601764001611328125,418134605590533958835165292757,499131506491608208145638755501,594149321766565107986044015109,705335875671998020885807527133,835126639705231189727783203125,986277894330592476397946946317,1161903115387181386900143203941,1365512842385582953099747743549,1601058302059584837582353420693,1872979077447320389547705078125,2186255130457228866167355527877,2546463504350983088080258388381,2959840051871614745048248895989,3433346554884341616308706146253,3974743622404285210611376953125,4592669775783920736778231997437,5296727152648625743048300468821,6097574284926333951333793232429,7007026431042644382390701863813,8038163968071713324068798828125,9205449376372141424226031714997,10524853377022476462245292805261,12013990811229843320753167312869,13692266880844888377187354333373,15581034400204330881069970703125,17703762741766936677696968440557,20086219191438000565629621957701,22756663464120116199753794497309,25746056165913143222338918914933,29088282026543209552764892578125,32820388764059014706376078334117,36982842483623672740953133686141,41619800553382238924952390945749,46779402942929633347037036568493,52514083053871981186303564453125,58880899117397849864481203955677,65941887280686237315442668950581,73764437552407555526504181618189,82421693827554704605804957854053
mul $0,8
add $0,5
pow $0,11
|
; A105752: Expansion of e.g.f. cos(i*log(1 + x)), i = sqrt(-1).
; 1,0,1,-3,12,-60,360,-2520,20160,-181440,1814400,-19958400,239500800,-3113510400,43589145600,-653837184000,10461394944000,-177843714048000,3201186852864000,-60822550204416000,1216451004088320000,-25545471085854720000,562000363888803840000,-12926008369442488320000,310224200866619719680000,-7755605021665492992000000,201645730563302817792000000,-5444434725209176080384000000,152444172305856930250752000000,-4420880996869850977271808000000,132626429906095529318154240000000
add $0,1
mov $3,$0
mov $4,1
lpb $3
mov $1,$4
cmp $5,0
cmp $5,0
pow $2,$5
sub $2,$0
sub $0,1
mul $4,$2
mov $2,$0
cmp $2,1
cmp $2,0
sub $3,$2
lpe
mov $0,$1
|
; $Id: SUPDrvA-os2.asm $
;; @file
; VBoxDrv - OS/2 assembly file, the first file in the link.
;
;
; Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
;
; 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.
;
;*******************************************************************************
;* Header Files *
;*******************************************************************************
%define RT_INCL_16BIT_SEGMENTS
%include "iprt/asmdefs.mac"
;*******************************************************************************
;* Structures and Typedefs *
;*******************************************************************************
;;
; Request packet header.
struc PKTHDR
.cb resb 1
.unit resb 1
.cmd resb 1
.status resw 1
.res1 resd 1
.link resd 1
endstruc
;;
; Init request packet - input.
struc PKTINITIN
.cb resb 1
.unit resb 1
.cmd resb 1
.status resw 1
.res1 resd 1
.link resd 1
.data_1 resb 1
.fpfnDevHlp resd 1
.fpszArgs resd 1
.data_2 resb 1
endstruc
;;
; Init request packet - output.
struc PKTINITOUT
.cb resb 1
.unit resb 1
.cmd resb 1
.status resw 1
.res1 resd 1
.link resd 1
.cUnits resb 1 ; block devs only.
.cbCode16 resw 1
.cbData16 resw 1
.fpaBPBs resd 1 ; block devs only.
.data_2 resb 1
endstruc
;;
; Open request packet.
struc PKTOPEN
.cb resb 1
.unit resb 1
.cmd resb 1
.status resw 1
.res1 resd 1
.link resd 1
.sfn resw 1
endstruc
;;
; Close request packet.
struc PKTCLOSE
.cb resb 1
.unit resb 1
.cmd resb 1
.status resw 1
.res1 resd 1
.link resd 1
.sfn resw 1
endstruc
;;
; IOCtl request packet.
struc PKTIOCTL
.cb resb 1
.unit resb 1
.cmd resb 1
.status resw 1
.res1 resd 1
.link resd 1
.cat resb 1
.fun resb 1
.pParm resd 1
.pData resd 1
.sfn resw 1
.cbParm resw 1
.cbData resw 1
endstruc
;;
; Read/Write request packet
struc PKTRW
.cb resb 1
.unit resb 1
.cmd resb 1
.status resw 1
.res1 resd 1
.link resd 1
.media resb 1
.PhysTrans resd 1
.cbTrans resw 1
.start resd 1
.sfn resw 1
endstruc
;;
; The two device headers.
segment DATA16
; Some devhdr.inc stuff.
%define DEVLEV_3 0180h
%define DEV_30 0800h
%define DEV_CHAR_DEV 8000h
%define DEV_16MB 0002h
%define DEV_IOCTL2 0001h
; Some dhcalls.h stuff.
%define DevHlp_VirtToLin 05bh
%define DevHlp_SAVE_MESSAGE 03dh
%define DevHlp_PhysToVirt 015h
; Fast IOCtl category, also defined in SUPDrvIOC.h
%define SUP_CTL_CATEGORY_FAST 0c1h
;*******************************************************************************
;* External Symbols *
;*******************************************************************************
extern KernThunkStackTo32
extern KernThunkStackTo16
extern DOS16OPEN
extern DOS16CLOSE
extern DOS16WRITE
extern NAME(VBoxDrvInit)
extern NAME(VBoxDrvOpen)
extern NAME(VBoxDrvClose)
extern NAME(VBoxDrvIOCtl)
extern NAME(VBoxDrvIOCtlFast)
;;
; Device headers. The first one is the one we'll be opening and the
; latter is only used for 32-bit initialization.
GLOBALNAME g_VBoxDrvHdr1
dw NAME(g_VBoxDrvHdr2) wrt DATA16 ; NextHeader.off
dw DATA16 ; NextHeader.sel
dw DEVLEV_3 | DEV_30 | DEV_CHAR_DEV; SDevAtt
dw NAME(VBoxDrvEP) wrt CODE16 ; StrategyEP
dw 0 ; InterruptEP
db 'vboxdrv$' ; DevName
dw 0 ; SDevProtCS
dw 0 ; SDevProtDS
dw 0 ; SDevRealCS
dw 0 ; SDevRealDS
dd DEV_16MB | DEV_IOCTL2 ; SDevCaps
align 4
GLOBALNAME g_VBoxDrvHdr2
dd 0ffffffffh ; NextHeader (NIL)
dw DEVLEV_3 | DEV_30 | DEV_CHAR_DEV; SDevAtt
dw NAME(VBoxDrvInitEP) wrt CODE16 ; StrategyEP
dw 0 ; InterruptEP
db 'vboxdr1$' ; DevName
dw 0 ; SDevProtCS
dw 0 ; SDevProtDS
dw 0 ; SDevRealCS
dw 0 ; SDevRealDS
dd DEV_16MB | DEV_IOCTL2 ; SDevCaps
;; Tristate 32-bit initialization indicator [0 = need init, -1 = init failed, 1 init succeeded].
; Check in the open path of the primary driver. The secondary driver will
; open the primary one during it's init and thereby trigger the 32-bit init.
GLOBALNAME g_fInitialized
db 0
align 4
;; Pointer to the device helper service routine
; This is set during the initialization of the 2nd device driver.
GLOBALNAME g_fpfnDevHlp
dd 0
;; Where we write to the log.
GLOBALNAME g_offLogHead
dw 0
;; Where we read from the log.
GLOBALNAME g_offLogTail
dw 0
;; The size of the log. (power of two!)
%define LOG_SIZE 16384
GLOBALNAME g_cchLogMax
dw LOG_SIZE
;; The log buffer.
GLOBALNAME g_szLog
times LOG_SIZE db 0
;
; The init data.
;
segment DATA16_INIT
GLOBALNAME g_InitDataStart
;; Far pointer to the device argument.
g_fpszArgs:
dd 0
%if 0
;; Message table for the Save_Message device helper.
GLOBALNAME g_MsgTab
dw 1178 ; MsgId - 'MSG_REPLACEMENT_STRING'.
dw 1 ; cMsgStrings
dw NAME(g_szInitText) ; MsgStrings[0]
dw seg NAME(g_szInitText)
%else
;; Far pointer to DOS16WRITE (corrected set before called).
; Just a temporary hack to work around a wlink issue.
GLOBALNAME g_fpfnDos16Write
dw DOS16WRITE
dw seg DOS16WRITE
%endif
;; Size of the text currently in the g_szInitText buffer.
GLOBALNAME g_cchInitText
dw 0
;; The max size of text that can fit into the g_szInitText buffer.
GLOBALNAME g_cchInitTextMax
dw 512
;; The init text buffer.
GLOBALNAME g_szInitText
times 512 db 0
;
; The 16-bit code segment.
;
segment CODE16
;;
; The strategy entry point (vboxdrv$).
;
; ss:bx -> request packet
; ds:si -> device header
;
; Can clobber any registers it likes except SP.
;
BEGINPROC VBoxDrvEP
push ebp
mov ebp, esp
push es ; bp - 2
push bx ; bp - 4
and sp, 0fffch
;
; Check for the most frequent first.
;
cmp byte [es:bx + PKTHDR.cmd], 10h ; Generic IOCtl
jne near VBoxDrvEP_NotGenIOCtl
;
; Generic I/O Control Request.
;
VBoxDrvEP_GenIOCtl:
; Fast IOCtl?
cmp byte [es:bx + PKTIOCTL.cat], SUP_CTL_CATEGORY_FAST
jne VBoxDrvEP_GenIOCtl_Other
;
; Fast IOCtl.
; DECLASM(int) VBoxDrvIOCtlFast(uint16_t sfn, uint8_t iFunction)
;
VBoxDrvEP_GenIOCtl_Fast:
; function.
movzx edx, byte [es:bx + PKTIOCTL.fun]
push edx ; 04h
; system file number.
movzx eax, word [es:bx + PKTIOCTL.sfn]
push eax ; 00h
; go to the 32-bit code
;jmp far dword NAME(VBoxDrvEP_GenIOCtl_Fast_32) wrt FLAT
db 066h
db 0eah
dd NAME(VBoxDrvEP_GenIOCtl_Fast_32) ;wrt FLAT
dw TEXT32 wrt FLAT
segment TEXT32
GLOBALNAME VBoxDrvEP_GenIOCtl_Fast_32
; switch stack to 32-bit.
mov ax, DATA32 wrt FLAT
mov ds, ax
mov es, ax
call KernThunkStackTo32
; call the C code (don't cleanup the stack).
call NAME(VBoxDrvIOCtlFast)
; switch back the stack.
push eax
call KernThunkStackTo16
pop eax
; jump back to the 16-bit code.
;jmp far dword NAME(VBoxDrvEP_GenIOCtl_Fast_16) wrt CODE16
db 066h
db 0eah
dw NAME(VBoxDrvEP_GenIOCtl_Fast_16) wrt CODE16
dw CODE16
segment CODE16
GLOBALNAME VBoxDrvEP_GenIOCtl_Fast_16
les bx, [bp - 4] ; Reload the packet pointer.
or eax, eax
jnz near VBoxDrvEP_GeneralFailure
; setup output stuff.
xor eax, eax
mov [es:bx + PKTIOCTL.cbParm], eax ; update cbParm and cbData.
mov word [es:bx + PKTHDR.status], 00100h ; done, ok.
mov sp, bp
pop ebp
retf
;
; Other IOCtl (slow)
;
VBoxDrvEP_GenIOCtl_Other:
mov eax, [es:bx + PKTIOCTL.cbParm] ; Load cbParm and cbData
push eax ; 1eh - in/out data size.
; 1ch - in/out parameter size.
push edx ; 18h - pointer to data size (filled in later).
push ecx ; 14h - pointer to param size (filled in later).
; pData (convert to flat 32-bit)
mov ax, word [es:bx + PKTIOCTL.pData + 2] ; selector
cmp ax, 3 ; <= 3 -> nil selector...
jbe .no_data
movzx esi, word [es:bx + PKTIOCTL.pData] ; offset
mov dl, DevHlp_VirtToLin
call far [NAME(g_fpfnDevHlp)]
jc near VBoxDrvEP_GeneralFailure
jmp .finish_data
.no_data:
xor eax, eax
.finish_data:
push eax ; 10h
; pParm (convert to flat 32-bit)
mov ax, word [es:bx + PKTIOCTL.pParm + 2] ; selector
cmp ax, 3 ; <= 3 -> nil selector...
jbe .no_parm
movzx esi, word [es:bx + PKTIOCTL.pParm] ; offset
mov dl, DevHlp_VirtToLin
call far [NAME(g_fpfnDevHlp)]
jc near VBoxDrvEP_GeneralFailure
jmp .finish_parm
.no_parm:
xor eax, eax
.finish_parm:
push eax ; 0ch
; function.
movzx edx, byte [es:bx + PKTIOCTL.fun]
push edx ; 08h
; category.
movzx ecx, byte [es:bx + PKTIOCTL.cat]
push ecx ; 04h
; system file number.
movzx eax, word [es:bx + PKTIOCTL.sfn]
push eax ; 00h
; go to the 32-bit code
;jmp far dword NAME(VBoxDrvEP_GenIOCtl_Other_32) wrt FLAT
db 066h
db 0eah
dd NAME(VBoxDrvEP_GenIOCtl_Other_32) ;wrt FLAT
dw TEXT32 wrt FLAT
segment TEXT32
GLOBALNAME VBoxDrvEP_GenIOCtl_Other_32
; switch stack to 32-bit.
mov ax, DATA32 wrt FLAT
mov ds, ax
mov es, ax
call KernThunkStackTo32
; update in/out parameter pointers
lea eax, [esp + 1ch]
mov [esp + 14h], eax
lea edx, [esp + 1eh]
mov [esp + 18h], edx
; call the C code (don't cleanup the stack).
call NAME(VBoxDrvIOCtl)
; switch back the stack.
push eax
call KernThunkStackTo16
pop eax
; jump back to the 16-bit code.
;jmp far dword NAME(VBoxDrvEP_GenIOCtl_Other_16) wrt CODE16
db 066h
db 0eah
dw NAME(VBoxDrvEP_GenIOCtl_Other_16) wrt CODE16
dw CODE16
segment CODE16
GLOBALNAME VBoxDrvEP_GenIOCtl_Other_16
les bx, [bp - 4] ; Reload the packet pointer.
or eax, eax
jnz near VBoxDrvEP_GeneralFailure
; setup output stuff.
mov edx, esp
mov eax, [ss:edx + 1ch] ; output sizes.
mov [es:bx + PKTIOCTL.cbParm], eax ; update cbParm and cbData.
mov word [es:bx + PKTHDR.status], 00100h ; done, ok.
mov sp, bp
pop ebp
retf
;
; Less Performance Critical Requests.
;
VBoxDrvEP_NotGenIOCtl:
cmp byte [es:bx + PKTHDR.cmd], 0dh ; Open
je VBoxDrvEP_Open
cmp byte [es:bx + PKTHDR.cmd], 0eh ; Close
je VBoxDrvEP_Close
cmp byte [es:bx + PKTHDR.cmd], 00h ; Init
je VBoxDrvEP_Init
cmp byte [es:bx + PKTHDR.cmd], 04h ; Read
je near VBoxDrvEP_Read
jmp near VBoxDrvEP_NotSupported
;
; Open Request. w/ ring-0 init.
;
VBoxDrvEP_Open:
cmp byte [NAME(g_fInitialized)], 1
jne VBoxDrvEP_OpenOther
; First argument, the system file number.
movzx eax, word [es:bx + PKTOPEN.sfn]
push eax
; go to the 32-bit code
;jmp far dword NAME(VBoxDrvEP_Open_32) wrt FLAT
db 066h
db 0eah
dd NAME(VBoxDrvEP_Open_32) ;wrt FLAT
dw TEXT32 wrt FLAT
segment TEXT32
GLOBALNAME VBoxDrvEP_Open_32
; switch stack to 32-bit.
mov ax, DATA32 wrt FLAT
mov ds, ax
mov es, ax
call KernThunkStackTo32
; call the C code.
call NAME(VBoxDrvOpen)
; switch back the stack.
push eax
call KernThunkStackTo16
pop eax
; jump back to the 16-bit code.
;jmp far dword NAME(VBoxDrvEP_Open_32) wrt CODE16
db 066h
db 0eah
dw NAME(VBoxDrvEP_Open_16) wrt CODE16
dw CODE16
segment CODE16
GLOBALNAME VBoxDrvEP_Open_16
les bx, [bp - 4] ; Reload the packet pointer.
or eax, eax
jnz near VBoxDrvEP_GeneralFailure
mov word [es:bx + PKTHDR.status], 00100h ; done, ok.
jmp near VBoxDrvEP_Done
; Initializing or failed init?
VBoxDrvEP_OpenOther:
cmp byte [NAME(g_fInitialized)], 0
jne VBoxDrvEP_OpenFailed
mov byte [NAME(g_fInitialized)], -1
call NAME(VBoxDrvRing0Init)
cmp byte [NAME(g_fInitialized)], 1
je VBoxDrvEP_Open
VBoxDrvEP_OpenFailed:
mov word [es:bx + PKTHDR.status], 0810fh ; error, done, init failed.
jmp near VBoxDrvEP_Done
;
; Close Request.
;
VBoxDrvEP_Close:
; First argument, the system file number.
movzx eax, word [es:bx + PKTOPEN.sfn]
push eax
; go to the 32-bit code
;jmp far dword NAME(VBoxDrvEP_Close_32) wrt FLAT
db 066h
db 0eah
dd NAME(VBoxDrvEP_Close_32) ;wrt FLAT
dw TEXT32 wrt FLAT
segment TEXT32
GLOBALNAME VBoxDrvEP_Close_32
; switch stack to 32-bit.
mov ax, DATA32 wrt FLAT
mov ds, ax
mov es, ax
call KernThunkStackTo32
; call the C code.
call NAME(VBoxDrvClose)
; switch back the stack.
push eax
call KernThunkStackTo16
pop eax
; jump back to the 16-bit code.
;jmp far dword NAME(VBoxDrvEP_Close_32) wrt CODE16
db 066h
db 0eah
dw NAME(VBoxDrvEP_Close_16) wrt CODE16
dw CODE16
segment CODE16
GLOBALNAME VBoxDrvEP_Close_16
les bx, [bp - 4] ; Reload the packet pointer.
or eax, eax
jnz near VBoxDrvEP_GeneralFailure
mov word [es:bx + PKTHDR.status], 00100h ; done, ok.
jmp near VBoxDrvEP_Done
;
; Init Request.
; The other driver header will do this.
;
VBoxDrvEP_Init:
mov word [es:bx + PKTHDR.status], 00100h ; done, ok.
mov byte [es:bx + PKTINITOUT.cUnits], 0
mov word [es:bx + PKTINITOUT.cbCode16], NAME(g_InitCodeStart) wrt CODE16
mov word [es:bx + PKTINITOUT.cbData16], NAME(g_InitDataStart) wrt DATA16
mov dword [es:bx + PKTINITOUT.fpaBPBs], 0
jmp near VBoxDrvEP_Done
;
; Read Request.
; Return log data.
;
VBoxDrvEP_Read:
; Any log data available?
xor dx, dx
mov ax, [NAME(g_offLogTail)]
cmp ax, [NAME(g_offLogHead)]
jz near .log_done
; create a temporary mapping of the physical buffer. Docs claims it trashes nearly everything...
push ebp
mov cx, [es:bx + PKTRW.cbTrans]
push cx
mov ax, [es:bx + PKTRW.PhysTrans + 2]
mov bx, [es:bx + PKTRW.PhysTrans]
mov dh, 1
mov dl, DevHlp_PhysToVirt
call far [NAME(g_fpfnDevHlp)]
pop bx ; bx = cbTrans
pop ebp
jc near .log_phystovirt_failed
; es:di -> the output buffer.
; setup the copy operation.
mov ax, [NAME(g_offLogTail)]
xor dx, dx ; dx tracks the number of bytes copied.
.log_loop:
mov cx, [NAME(g_offLogHead)]
cmp ax, cx
je .log_done
jb .log_loop_before
mov cx, LOG_SIZE
.log_loop_before: ; cx = end offset
sub cx, ax ; cx = sequential bytes to copy.
cmp cx, bx
jbe .log_loop_min
mov cx, bx ; output buffer is smaller than available data.
.log_loop_min:
mov si, NAME(g_szLog)
add si, ax ; ds:si -> the log buffer.
add dx, cx ; update output counter
add ax, cx ; calc new offLogTail
and ax, LOG_SIZE - 1
rep movsb ; do the copy
mov [NAME(g_offLogTail)], ax ; commit the read.
jmp .log_loop
.log_done:
les bx, [bp - 4] ; Reload the packet pointer.
mov word [es:bx + PKTRW.cbTrans], dx
mov word [es:bx + PKTHDR.status], 00100h ; done, ok.
jmp near VBoxDrvEP_Done
.log_phystovirt_failed:
les bx, [bp - 4] ; Reload the packet pointer.
jmp VBoxDrvEP_GeneralFailure
;
; Return 'unknown command' error.
;
VBoxDrvEP_NotSupported:
mov word [es:bx + PKTHDR.status], 08103h ; error, done, unknown command.
jmp VBoxDrvEP_Done
;
; Return 'general failure' error.
;
VBoxDrvEP_GeneralFailure:
mov word [es:bx + PKTHDR.status], 0810ch ; error, done, general failure.
jmp VBoxDrvEP_Done
;
; Non-optimized return path.
;
VBoxDrvEP_Done:
mov sp, bp
pop ebp
retf
ENDPROC VBoxDrvEP
;;
; The helper device entry point.
;
; This is only used to do the DosOpen on the main driver so we can
; do ring-3 init and report failures.
;
GLOBALNAME VBoxDrvInitEP
; The only request we're servicing is the 'init' one.
cmp word [es:bx + PKTHDR.cmd], 0
je near NAME(VBoxDrvInitEPServiceInitReq)
; Ok, it's not the init request, just fail it.
mov word [es:bx + PKTHDR.status], 08103h ; error, done, unknown command.
retf
;
; The 16-bit init code.
;
segment CODE16_INIT
GLOBALNAME g_InitCodeStart
;; The device name for DosOpen.
g_szDeviceName:
db '\DEV\vboxdrv$', 0
; icsdebug can't see where stuff starts otherwise. (kDevTest)
int3
int3
int3
int3
int3
int3
;;
; The Ring-3 init code.
;
BEGINPROC VBoxDrvInitEPServiceInitReq
push ebp
mov ebp, esp
push es ; bp - 2
push sp ; bp - 4
push -1 ; bp - 6: hfOpen
push 0 ; bp - 8: usAction
and sp, 0fffch
; check for the init package.
cmp word [es:bx + PKTHDR.cmd], 0
jne near .not_init
;
; Copy the data out of the init packet.
;
mov eax, [es:bx + PKTINITIN.fpfnDevHlp]
mov [NAME(g_fpfnDevHlp)], eax
mov edx, [es:bx + PKTINITIN.fpszArgs]
mov [g_fpszArgs], edx
;
; Open the first driver, close it, and check status.
;
; APIRET _Pascal DosOpen(PSZ pszFname, PHFILE phfOpen, PUSHORT pusAction,
; ULONG ulFSize, USHORT usAttr, USHORT fsOpenFlags,
; USHORT fsOpenMode, ULONG ulReserved);
push seg g_szDeviceName ; pszFname
push g_szDeviceName
push ss ; phfOpen
lea dx, [bp - 6]
push dx
push ss ; pusAction
lea dx, [bp - 8]
push dx
push dword 0 ; ulFSize
push 0 ; usAttr = FILE_NORMAL
push 1 ; fsOpenFlags = FILE_OPEN
push 00040h ; fsOpenMode = OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY
push dword 0 ; ulReserved
call far DOS16OPEN
push ax ; Quickly flush any text.
call NAME(VBoxDrvInitFlushText)
pop ax
or ax, ax
jnz .done_err
; APIRET APIENTRY DosClose(HFILE hf);
mov cx, [bp - 6]
push cx
call far DOS16CLOSE
or ax, ax
jnz .done_err ; This can't happen (I hope).
;
; Ok, we're good.
;
mov word [es:bx + PKTHDR.status], 00100h ; done, ok.
mov byte [es:bx + PKTINITOUT.cUnits], 0
mov word [es:bx + PKTINITOUT.cbCode16], NAME(g_InitCodeStart) wrt CODE16
mov word [es:bx + PKTINITOUT.cbData16], NAME(g_InitDataStart) wrt DATA16
mov dword [es:bx + PKTINITOUT.fpaBPBs], 0
jmp .done
;
; Init failure.
;
.done_err:
mov word [es:bx + PKTHDR.status], 0810fh ; error, done, init failed.
mov byte [es:bx + PKTINITOUT.cUnits], 0
mov word [es:bx + PKTINITOUT.cbCode16], 0
mov word [es:bx + PKTINITOUT.cbData16], 0
mov dword [es:bx + PKTINITOUT.fpaBPBs], 0
jmp .done
;
; Not init, return 'unknown command'.
;
.not_init:
mov word [es:bx + PKTHDR.status], 08103h ; error, done, unknown command.
jmp .done
;
; Request done.
;
.done:
mov sp, bp
pop ebp
retf
ENDPROC VBoxDrvInitEPServiceInitReq
;;
; The Ring-0 init code.
;
BEGINPROC VBoxDrvRing0Init
push es
push esi
push ebp
mov ebp, esp
and sp, 0fffch
;
; Thunk the argument string pointer first.
;
movzx esi, word [g_fpszArgs] ; offset
mov ax, [g_fpszArgs + 2] ; selector
mov dl, DevHlp_VirtToLin
call far [NAME(g_fpfnDevHlp)]
jc near VBoxDrvRing0Init_done ; eax is non-zero on failure (can't happen)
push eax ; 00h - pszArgs (for VBoxDrvInit).
;
; Do 16-bit init?
;
;
; Do 32-bit init
;
;jmp far dword NAME(VBoxDrvRing0Init_32) wrt FLAT
db 066h
db 0eah
dd NAME(VBoxDrvRing0Init_32) ;wrt FLAT
dw TEXT32 wrt FLAT
segment TEXT32
GLOBALNAME VBoxDrvRing0Init_32
; switch stack to 32-bit.
mov ax, DATA32 wrt FLAT
mov ds, ax
mov es, ax
call KernThunkStackTo32
; call the C code.
call NAME(VBoxDrvInit)
; switch back the stack and reload ds.
push eax
call KernThunkStackTo16
pop eax
mov dx, seg NAME(g_fInitialized)
mov ds, dx
; jump back to the 16-bit code.
;jmp far dword NAME(VBoxDrvRing0Init_16) wrt CODE16
db 066h
db 0eah
dw NAME(VBoxDrvRing0Init_16) wrt CODE16
dw CODE16_INIT
segment CODE16_INIT
GLOBALNAME VBoxDrvRing0Init_16
; check the result and set g_fInitialized on success.
or eax, eax
jnz VBoxDrvRing0Init_done
mov byte [NAME(g_fInitialized)], 1
VBoxDrvRing0Init_done:
mov sp, bp
pop ebp
pop esi
pop es
ret
ENDPROC VBoxDrvRing0Init
;;
; Flush any text in the text buffer.
;
BEGINPROC VBoxDrvInitFlushText
push bp
mov bp, sp
; Anything in the buffer?
mov ax, [NAME(g_cchInitText)]
or ax, ax
jz .done
%if 1
; Write it to STDOUT.
; APIRET _Pascal DosWrite(HFILE hf, PVOID pvBuf, USHORT cbBuf, PUSHORT pcbBytesWritten);
push ax ; bp - 2 : cbBytesWritten
mov cx, sp
push 1 ; STDOUT
push seg NAME(g_szInitText) ; pvBuf
push NAME(g_szInitText)
push ax ; cbBuf
push ss ; pcbBytesWritten
push cx
%if 0 ; wlink generates a non-aliased fixup here which results in 16-bit offset with the flat 32-bit selector.
call far DOS16WRITE
%else
; convert flat pointer to a far pointer using the tiled algorithm.
push ds
mov ax, DATA32 wrt FLAT
mov ds, ax
mov eax, g_pfnDos16Write wrt FLAT
movzx eax, word [eax + 2] ; High word of the flat address (in DATA32).
shl ax, 3
or ax, 0007h
pop ds
mov [NAME(g_fpfnDos16Write) + 2], ax ; Update the selector (in DATA16_INIT).
; do the call
call far [NAME(g_fpfnDos16Write)]
%endif
%else ; alternative workaround for the wlink issue.
; Use the save message devhlp.
push esi
push ebx
xor bx, bx
mov si, NAME(g_MsgTab)
mov dx, seg NAME(g_MsgTab)
mov ds, dx
mov dl, DevHlp_SAVE_MESSAGE
call far [NAME(g_fpfnDevHlp)]
pop ebx
pop esi
%endif
; Empty the buffer.
mov word [NAME(g_cchInitText)], 0
mov byte [NAME(g_szInitText)], 0
.done:
mov sp, bp
pop bp
ret
ENDPROC VBoxDrvInitFlushText
;;
; This must be present
segment DATA32
g_pfnDos16Write:
dd DOS16WRITE ; flat
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x282, %rsi
lea addresses_A_ht+0xa282, %rdi
nop
nop
inc %r10
mov $65, %rcx
rep movsb
nop
cmp $17425, %rax
lea addresses_normal_ht+0x1282, %rsi
sub $28690, %r13
mov (%rsi), %rcx
nop
xor %rax, %rax
lea addresses_WT_ht+0x8882, %rsi
nop
nop
nop
nop
nop
dec %rbx
movb $0x61, (%rsi)
nop
nop
nop
add $40026, %r10
lea addresses_WT_ht+0x1bd82, %rcx
nop
and %r13, %r13
vmovups (%rcx), %ymm7
vextracti128 $0, %ymm7, %xmm7
vpextrq $0, %xmm7, %rax
nop
nop
nop
xor %rdi, %rdi
lea addresses_normal_ht+0x1ee50, %rdi
nop
nop
xor %rbx, %rbx
movups (%rdi), %xmm6
vpextrq $0, %xmm6, %rax
nop
nop
nop
nop
xor $61009, %r10
lea addresses_WT_ht+0x1ee82, %r10
nop
xor %rcx, %rcx
vmovups (%r10), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $1, %xmm1, %rbx
nop
nop
nop
nop
nop
and $17244, %r13
lea addresses_normal_ht+0xb474, %rsi
lea addresses_WT_ht+0xb282, %rdi
clflush (%rdi)
nop
dec %r9
mov $127, %rcx
rep movsb
nop
lfence
lea addresses_WC_ht+0x125ae, %rdi
nop
nop
nop
and $64780, %rax
movl $0x61626364, (%rdi)
inc %rcx
lea addresses_WC_ht+0x1ce82, %rcx
nop
xor %rbx, %rbx
movups (%rcx), %xmm1
vpextrq $1, %xmm1, %rax
nop
sub %rbx, %rbx
lea addresses_WT_ht+0x19682, %rsi
lea addresses_WC_ht+0xe73a, %rdi
clflush (%rdi)
nop
xor %r9, %r9
mov $20, %rcx
rep movsq
nop
nop
nop
nop
nop
add $8091, %r10
lea addresses_WT_ht+0x14585, %rsi
lea addresses_WT_ht+0x1bf82, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
sub %r10, %r10
mov $13, %rcx
rep movsq
and %rax, %rax
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r15
push %r9
push %rax
// Store
lea addresses_A+0x36e2, %r12
nop
nop
nop
cmp %r15, %r15
mov $0x5152535455565758, %r9
movq %r9, %xmm2
vmovups %ymm2, (%r12)
nop
nop
nop
cmp %r15, %r15
// Store
lea addresses_UC+0x1aa82, %r10
nop
nop
nop
sub %rax, %rax
movl $0x51525354, (%r10)
nop
nop
inc %r10
// Store
lea addresses_WT+0x140ca, %r15
nop
nop
nop
sub %r12, %r12
mov $0x5152535455565758, %r9
movq %r9, %xmm7
vmovups %ymm7, (%r15)
nop
nop
dec %r10
// Faulty Load
lea addresses_UC+0x1aa82, %r10
nop
nop
dec %r12
mov (%r10), %r13d
lea oracles, %rax
and $0xff, %r13
shlq $12, %r13
mov (%rax,%r13,1), %r13
pop %rax
pop %r9
pop %r15
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5, 'same': False, 'type': 'addresses_A'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_UC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3, 'same': False, 'type': 'addresses_WT'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_UC'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 11, 'same': True, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 10, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 2, 'same': True, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'}
{'54': 21829}
54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
*/
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r14
push %r15
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x16358, %rsi
lea addresses_WT_ht+0xc040, %rdi
add $545, %r13
mov $0, %rcx
rep movsb
nop
sub %r11, %r11
lea addresses_UC_ht+0xb098, %r13
nop
nop
nop
nop
inc %r14
mov (%r13), %rsi
nop
nop
nop
mfence
lea addresses_D_ht+0x18f80, %r11
nop
nop
nop
nop
nop
sub %r15, %r15
mov (%r11), %di
nop
nop
nop
add $52909, %rsi
lea addresses_UC_ht+0x19d18, %r11
nop
add $4502, %r15
movb $0x61, (%r11)
nop
sub $43073, %rdi
lea addresses_D_ht+0x16b43, %r13
nop
nop
nop
dec %rsi
mov $0x6162636465666768, %r14
movq %r14, %xmm6
and $0xffffffffffffffc0, %r13
vmovntdq %ymm6, (%r13)
xor %rcx, %rcx
lea addresses_A_ht+0xf498, %r14
clflush (%r14)
nop
nop
nop
nop
nop
sub %r11, %r11
movups (%r14), %xmm0
vpextrq $1, %xmm0, %rsi
nop
nop
nop
nop
nop
xor %r14, %r14
lea addresses_UC_ht+0x3d08, %r15
nop
nop
nop
nop
cmp $8446, %r13
mov $0x6162636465666768, %r14
movq %r14, %xmm6
vmovups %ymm6, (%r15)
nop
nop
nop
nop
nop
cmp $51443, %rcx
lea addresses_WC_ht+0x169d8, %r13
nop
nop
cmp %r15, %r15
mov (%r13), %r11d
nop
nop
dec %r11
lea addresses_WC_ht+0x325c, %r13
nop
nop
nop
inc %rsi
mov (%r13), %r15
nop
cmp %rcx, %rcx
lea addresses_UC_ht+0x15038, %rsi
lea addresses_UC_ht+0x17d65, %rdi
add %rbx, %rbx
mov $107, %rcx
rep movsl
nop
nop
and %r14, %r14
lea addresses_D_ht+0x2398, %r15
inc %r14
mov (%r15), %r11w
nop
inc %r11
lea addresses_WC_ht+0x7518, %rsi
nop
nop
nop
add %rcx, %rcx
mov $0x6162636465666768, %r15
movq %r15, %xmm0
movups %xmm0, (%rsi)
nop
nop
xor %r13, %r13
lea addresses_WC_ht+0x194a8, %rsi
lea addresses_WT_ht+0x592e, %rdi
nop
and %rbx, %rbx
mov $92, %rcx
rep movsq
nop
and %r13, %r13
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r15
pop %r14
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %r8
push %r9
push %rax
push %rbp
push %rcx
// Store
lea addresses_UC+0x10f38, %rcx
nop
nop
nop
add %rax, %rax
movw $0x5152, (%rcx)
nop
and %r9, %r9
// Store
lea addresses_PSE+0xb0d8, %r15
and %rcx, %rcx
mov $0x5152535455565758, %r12
movq %r12, %xmm7
vmovups %ymm7, (%r15)
nop
nop
nop
nop
sub $34474, %rcx
// Store
lea addresses_WC+0x13698, %r12
nop
nop
nop
nop
dec %r8
mov $0x5152535455565758, %rcx
movq %rcx, (%r12)
nop
cmp %r12, %r12
// Faulty Load
lea addresses_D+0x7c98, %rax
and $51730, %rbp
vmovntdqa (%rax), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $1, %xmm2, %r9
lea oracles, %rbp
and $0xff, %r9
shlq $12, %r9
mov (%rbp,%r9,1), %r9
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r8
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 7}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 32, 'NT': True, 'type': 'addresses_D', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 2}}
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 8}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': True, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': True, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': True, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'OP': 'LOAD', 'src': {'size': 8, 'NT': True, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 0}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 0}}
{'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
*/
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r8
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x17a5e, %rax
nop
nop
nop
cmp %r10, %r10
mov $0x6162636465666768, %r8
movq %r8, %xmm0
movups %xmm0, (%rax)
nop
nop
nop
and %r11, %r11
lea addresses_WT_ht+0x94ee, %rbx
nop
nop
nop
nop
add %r9, %r9
movb $0x61, (%rbx)
nop
nop
nop
nop
inc %r9
lea addresses_UC_ht+0x1e266, %rsi
lea addresses_UC_ht+0xf16, %rdi
nop
nop
nop
nop
nop
xor %rbx, %rbx
mov $60, %rcx
rep movsq
and $3369, %rbx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r8
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r8
push %rax
push %rbx
push %rcx
// Store
lea addresses_WT+0x12a26, %r10
xor $51672, %rbx
movl $0x51525354, (%r10)
nop
nop
inc %r8
// Faulty Load
lea addresses_normal+0x15226, %r8
nop
nop
nop
dec %r10
mov (%r8), %rbx
lea oracles, %rax
and $0xff, %rbx
shlq $12, %rbx
mov (%rax,%rbx,1), %rbx
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 9}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': True, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': True, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 1}}
{'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
*/
|
MODULE xxx
Kip: ; label xxx.Kip
ld hl,@Kip ; global Kip
ld hl,@Kop ; global Kop
ld hl,Kop ; xxx.Kop
Kop: ; label xxx.Kop
ld hl,Kip ; xxx.Kip
ld hl,yyy.Kip ; yyy.Kip
ld hl,nested.Kip ; xxx.nested.Kip
MODULE nested
Kip: ret ; label xxx.nested.Kip
ENDMODULE
ENDMODULE
MODULE yyy
Kip: ret ; label yyy.Kip
@Kop: ret ; label Kop (global one, no module prefix)
@xxx.Kop: nop ; ERROR: duplicate: label xxx.Kop
ENDMODULE
Kip ret ; global label Kip
; invalid since v1.14.0
MODULE older.version
fn1: ret ; final label: @older.version.fn1
ENDMODULE
; can be replaced in v1.14.0 with
MODULE new
MODULE version
fn1: ret ; final label: @new.version.fn1
ENDMODULE
ENDMODULE
; or you can just rename "older.version" to something like "older_version" instead
Kep: ; "Kep" label (global one), and also works as "non-local" prefix for local labels
MODULE zzz
.local: ; in v1.14.0 this will be "zzz._.local" label, previously it was "zzz.Kep.local"
Kup: ; this is "zzz.Kup", but also defines "non-local" prefix as "Kup"
.local ; this is "zzz.Kup.local"
ENDMODULE
.local: ; in v1.14.0 this will be "_.local" label, previously it was "Kup.local"
|
; A164096: Partial sums of A164095.
; 5,11,21,33,53,77,117,165,245,341,501,693,1013,1397,2037,2805,4085,5621,8181,11253,16373,22517,32757,45045,65525,90101,131061,180213,262133,360437,524277,720885,1048565,1441781,2097141,2883573,4194293,5767157,8388597,11534325,16777205,23068661,33554421,46137333,67108853,92274677,134217717,184549365,268435445,369098741,536870901,738197493,1073741813,1476394997,2147483637,2952790005,4294967285,5905580021,8589934581,11811160053,17179869173,23622320117,34359738357,47244640245,68719476725,94489280501,137438953461,188978561013,274877906933,377957122037,549755813877,755914244085,1099511627765,1511828488181,2199023255541,3023656976373,4398046511093,6047313952757,8796093022197,12094627905525,17592186044405,24189255811061,35184372088821,48378511622133,70368744177653,96757023244277,140737488355317,193514046488565,281474976710645,387028092977141,562949953421301,774056185954293,1125899906842613,1548112371908597,2251799813685237,3096224743817205,4503599627370485,6192449487634421,9007199254740981
mov $1,5
mov $3,6
lpb $0,1
sub $0,1
mov $2,$1
mov $1,$3
mul $1,2
sub $1,1
add $2,3
mov $3,3
add $3,$2
lpe
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x1df0c, %rsi
lea addresses_UC_ht+0x1458c, %rdi
nop
nop
nop
nop
nop
sub %r13, %r13
mov $104, %rcx
rep movsw
nop
add %r8, %r8
lea addresses_WC_ht+0x1b89e, %r15
nop
nop
cmp %rax, %rax
movb $0x61, (%r15)
nop
nop
nop
nop
and $48109, %r8
lea addresses_D_ht+0x3edc, %rax
inc %r15
movb (%rax), %cl
nop
nop
nop
nop
add %rax, %rax
lea addresses_WT_ht+0x458c, %rsi
lea addresses_D_ht+0x3636, %rdi
and %rax, %rax
mov $102, %rcx
rep movsb
nop
nop
nop
nop
cmp %rax, %rax
lea addresses_WC_ht+0x978c, %rcx
nop
nop
nop
xor %r8, %r8
mov (%rcx), %r13d
nop
nop
nop
inc %rax
lea addresses_D_ht+0xd88c, %rsi
lea addresses_WC_ht+0x218c, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
sub $26835, %rbx
mov $31, %rcx
rep movsw
nop
nop
nop
add $60875, %rax
lea addresses_UC_ht+0x258c, %rbx
nop
nop
nop
nop
and $59510, %r15
vmovups (%rbx), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $1, %xmm1, %r13
nop
nop
inc %rax
lea addresses_A_ht+0x7dcc, %rsi
lea addresses_WT_ht+0x1ca8c, %rdi
nop
nop
nop
and $63248, %rbx
mov $75, %rcx
rep movsb
nop
and $23399, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r15
push %rax
push %rbx
push %rdi
// Faulty Load
lea addresses_WC+0x14d8c, %rdi
nop
cmp $14801, %rax
mov (%rdi), %r15d
lea oracles, %r12
and $0xff, %r15
shlq $12, %r15
mov (%r12,%r15,1), %r15
pop %rdi
pop %rbx
pop %rax
pop %r15
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': True, 'congruent': 7, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 1}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}, 'dst': {'same': True, 'congruent': 10, 'type': 'addresses_WC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}}
{'38': 21829}
38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38
*/
|
; A024378: a(n) = 2nd elementary symmetric function of the first n+1 positive integers congruent to 1 mod 4.
; 5,59,254,730,1675,3325,5964,9924,15585,23375,33770,47294,64519,86065,112600,144840,183549,229539,283670,346850,420035,504229,600484,709900,833625,972855,1128834,1302854,1496255,1710425,1946800,2206864,2492149
mov $5,4
mov $7,$0
lpb $0
add $1,6
add $1,$0
add $5,$0
sub $0,1
add $5,3
add $1,$5
add $6,3
lpe
add $1,$6
add $1,2
add $1,$6
add $1,3
mov $4,$7
mov $8,$7
lpb $4
add $2,$8
sub $4,1
lpe
mov $3,20
mov $8,$2
lpb $3
add $1,$8
sub $3,1
lpe
mov $2,0
mov $4,$7
lpb $4
add $2,$8
sub $4,1
lpe
mov $3,11
mov $8,$2
lpb $3
add $1,$8
sub $3,1
lpe
mov $2,0
mov $4,$7
lpb $4
add $2,$8
sub $4,1
lpe
mov $3,2
mov $8,$2
lpb $3
add $1,$8
sub $3,1
lpe
mov $0,$1
|
; A023805: Xenodromes: all digits in base 11 are different.
; 0,1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23,25,26,27,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,46,47,49,50,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,69,70,71,73,74
mov $1,$0
sub $1,1
div $1,11
add $0,$1
|
;;
;; Copyright (c) 2018-2020, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%include "include/os.asm"
%define NO_AESNI_RENAME
%include "include/aesni_emu.inc"
%include "include/clear_regs.asm"
%include "include/cet.inc"
;;; Routines to generate subkeys for AES-CMAC.
;;; See RFC 4493 for more details.
;; In System V AMD64 ABI
;; callee saves: RBX, RBP, R12-R15
;; Windows x64 ABI
;; callee saves: RBX, RBP, RDI, RSI, RSP, R12-R15
;;
;; Registers: RAX RBX RCX RDX RBP RSI RDI R8 R9 R10 R11 R12 R13 R14 R15
;; -----------------------------------------------------------
;; Windows clobbers:
;; Windows preserves: RAX RBX RCX RDX RBP RSI RDI R8 R9 R10 R11 R12 R13 R14 R15
;; -----------------------------------------------------------
;; Linux clobbers:
;; Linux preserves: RAX RBX RCX RDX RBP RSI RDI R8 R9 R10 R11 R12 R13 R14 R15
;; -----------------------------------------------------------
;;
;; Linux/Windows clobbers: xmm0, xmm1, xmm2
;;
%ifdef LINUX
%define arg1 rdi
%define arg2 rsi
%define arg3 rdx
%define arg4 rcx
%define arg5 r8
%else
%define arg1 rcx
%define arg2 rdx
%define arg3 r8
%define arg4 r9
%define arg5 [rsp + 5*8]
%endif
%define KEY_EXP arg1
%define KEY1 arg2
%define KEY2 arg3
%define XL xmm0
%define XKEY1 xmm1
%define XKEY2 xmm2
section .data
default rel
align 16
xmm_bit127:
;ddq 0x80000000000000000000000000000000
dq 0x0000000000000000, 0x8000000000000000
align 16
xmm_bit63:
;ddq 0x00000000000000008000000000000000
dq 0x8000000000000000, 0x0000000000000000
align 16
xmm_bit64:
;ddq 0x00000000000000010000000000000000
dq 0x0000000000000000, 0x0000000000000001
align 16
const_Rb:
;ddq 0x00000000000000000000000000000087
dq 0x0000000000000087, 0x0000000000000000
align 16
byteswap_const:
;DDQ 0x000102030405060708090A0B0C0D0E0F
dq 0x08090A0B0C0D0E0F, 0x0001020304050607
section .text
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; void aes_cmac_subkey_gen(const void *key_exp, void *key1, void *key2)
;;;
;;; key_exp : IN : address of expanded encryption key structure
;;; key1 : OUT : address to store subkey 1 (16 bytes)
;;; key2 : OUT : address to store subkey 2 (16 bytes)
;;;
;;; RFC 4493 Figure 2.2 describing function operations at highlevel
;;;
;;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;; + Algorithm Generate_Subkey +
;;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;; + +
;;; + Input : K (128/256-bit key) +
;;; + Output : K1 (128-bit first subkey) +
;;; + K2 (128-bit second subkey) +
;;; +--------------------------------------------------------------------+
;;; + +
;;; + Constants: const_Zero is 0x00000000000000000000000000000000 +
;;; + const_Rb is 0x00000000000000000000000000000087 +
;;; + Variables: L for output of AES-128/256 applied to 0^128 +
;;; + +
;;; + Step 1. L := AES-128/256(K, const_Zero) ; +
;;; + Step 2. if MSB(L) is equal to 0 +
;;; + then K1 := L << 1 ; +
;;; + else K1 := (L << 1) XOR const_Rb ; +
;;; + Step 3. if MSB(K1) is equal to 0 +
;;; + then K2 := K1 << 1 ; +
;;; + else K2 := (K1 << 1) XOR const_Rb ; +
;;; + Step 4. return K1, K2 ; +
;;; + +
;;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%macro AES_CMAC_SUBKEY_GEN_SSE 1-2
%define %%NROUNDS %1
%define %%ARCH %2
%ifdef SAFE_PARAM
cmp KEY_EXP, 0
jz %%_aes_cmac_subkey_gen_sse_return
cmp KEY1, 0
jz %%_aes_cmac_subkey_gen_sse_return
cmp KEY2, 0
jz %%_aes_cmac_subkey_gen_sse_return
%endif
%ifidn %%ARCH, no_aesni
%define AESENC EMULATE_AESENC
%define AESENCLAST EMULATE_AESENCLAST
%else
%define AESENC aesenc
%define AESENCLAST aesenclast
%endif
;; Step 1. L := AES-128(K, const_Zero) ;
movdqa XL, [KEY_EXP + 16*0] ; 0. ARK xor const_Zero
AESENC XL, [KEY_EXP + 16*1] ; 1. ENC
AESENC XL, [KEY_EXP + 16*2] ; 2. ENC
AESENC XL, [KEY_EXP + 16*3] ; 3. ENC
AESENC XL, [KEY_EXP + 16*4] ; 4. ENC
AESENC XL, [KEY_EXP + 16*5] ; 5. ENC
AESENC XL, [KEY_EXP + 16*6] ; 6. ENC
AESENC XL, [KEY_EXP + 16*7] ; 7. ENC
AESENC XL, [KEY_EXP + 16*8] ; 8. ENC
AESENC XL, [KEY_EXP + 16*9] ; 9. ENC
%if %%NROUNDS == 13 ;; CMAC-256
AESENC XL, [KEY_EXP + 16*10] ; 10. ENC
AESENC XL, [KEY_EXP + 16*11] ; 11. ENC
AESENC XL, [KEY_EXP + 16*12] ; 12. ENC
AESENC XL, [KEY_EXP + 16*13] ; 13. ENC
AESENCLAST XL, [KEY_EXP + 16*14] ; 14. ENC
%else ;; CMAC-128
AESENCLAST XL, [KEY_EXP + 16*10] ; 10. ENC
%endif
;; Step 2. if MSB(L) is equal to 0
;; then K1 := L << 1 ;
;; else K1 := (L << 1) XOR const_Rb ;
pshufb XL, [rel byteswap_const]
movdqa XKEY1, XL
psllq XKEY1, 1
ptest XL, [rel xmm_bit63]
jz %%_K1_no_carry_bit_sse
;; set carry bit
por XKEY1, [rel xmm_bit64]
%%_K1_no_carry_bit_sse:
ptest XL, [rel xmm_bit127]
jz %%_K1_msb_is_zero_sse
;; XOR const_Rb
pxor XKEY1, [rel const_Rb]
%%_K1_msb_is_zero_sse:
;; Step 3. if MSB(K1) is equal to 0
;; then K2 := K1 << 1 ;
;; else K2 := (K1 << 1) XOR const_Rb ;
movdqa XKEY2, XKEY1
psllq XKEY2, 1
ptest XKEY1, [rel xmm_bit63]
jz %%_K2_no_carry_bit_sse
;; set carry bit
por XKEY2, [rel xmm_bit64]
%%_K2_no_carry_bit_sse:
ptest XKEY1, [rel xmm_bit127]
jz %%_K2_msb_is_zero_sse
;; XOR const_Rb
pxor XKEY2, [rel const_Rb]
%%_K2_msb_is_zero_sse:
;; Step 4. return K1, K2
pshufb XKEY1, [rel byteswap_const]
pshufb XKEY2, [rel byteswap_const]
movdqu [KEY1], XKEY1
movdqu [KEY2], XKEY2
%%_aes_cmac_subkey_gen_sse_return:
%ifdef SAFE_DATA
clear_scratch_gps_asm
clear_scratch_xmms_sse_asm
%endif
%endmacro
%macro AES_CMAC_SUBKEY_GEN_AVX 1
%define %%NROUNDS %1
%ifdef SAFE_PARAM
cmp KEY_EXP, 0
jz %%_aes_cmac_subkey_gen_avx_return
cmp KEY1, 0
jz %%_aes_cmac_subkey_gen_avx_return
cmp KEY2, 0
jz %%_aes_cmac_subkey_gen_avx_return
%endif
;; Step 1. L := AES-128(K, const_Zero) ;
vmovdqa XL, [KEY_EXP + 16*0] ; 0. ARK xor const_Zero
vaesenc XL, [KEY_EXP + 16*1] ; 1. ENC
vaesenc XL, [KEY_EXP + 16*2] ; 2. ENC
vaesenc XL, [KEY_EXP + 16*3] ; 3. ENC
vaesenc XL, [KEY_EXP + 16*4] ; 4. ENC
vaesenc XL, [KEY_EXP + 16*5] ; 5. ENC
vaesenc XL, [KEY_EXP + 16*6] ; 6. ENC
vaesenc XL, [KEY_EXP + 16*7] ; 7. ENC
vaesenc XL, [KEY_EXP + 16*8] ; 8. ENC
vaesenc XL, [KEY_EXP + 16*9] ; 9. ENC
%if %%NROUNDS == 13 ;; CMAC-256
vaesenc XL, [KEY_EXP + 16*10] ; 10. ENC
vaesenc XL, [KEY_EXP + 16*11] ; 11. ENC
vaesenc XL, [KEY_EXP + 16*12] ; 12. ENC
vaesenc XL, [KEY_EXP + 16*13] ; 13. ENC
vaesenclast XL, [KEY_EXP + 16*14] ; 14. ENC
%else ;; CMAC-128
vaesenclast XL, [KEY_EXP + 16*10] ; 10. ENC
%endif
;; Step 2. if MSB(L) is equal to 0
;; then K1 := L << 1 ;
;; else K1 := (L << 1) XOR const_Rb ;
vpshufb XL, [rel byteswap_const]
vmovdqa XKEY1, XL
vpsllq XKEY1, 1
vptest XL, [rel xmm_bit63]
jz %%_K1_no_carry_bit_avx
;; set carry bit
vpor XKEY1, [rel xmm_bit64]
%%_K1_no_carry_bit_avx:
vptest XL, [rel xmm_bit127]
jz %%_K1_msb_is_zero_avx
;; XOR const_Rb
vpxor XKEY1, [rel const_Rb]
%%_K1_msb_is_zero_avx:
;; Step 3. if MSB(K1) is equal to 0
;; then K2 := K1 << 1 ;
;; else K2 := (K1 << 1) XOR const_Rb ;
vmovdqa XKEY2, XKEY1
vpsllq XKEY2, 1
vptest XKEY1, [rel xmm_bit63]
jz %%_K2_no_carry_bit_avx
;; set carry bit
vpor XKEY2, [rel xmm_bit64]
%%_K2_no_carry_bit_avx:
vptest XKEY1, [rel xmm_bit127]
jz %%_K2_msb_is_zero_avx
;; XOR const_Rb
vpxor XKEY2, [rel const_Rb]
%%_K2_msb_is_zero_avx:
;; Step 4. return K1, K2
vpshufb XKEY1, [rel byteswap_const]
vpshufb XKEY2, [rel byteswap_const]
vmovdqu [KEY1], XKEY1
vmovdqu [KEY2], XKEY2
%%_aes_cmac_subkey_gen_avx_return:
%ifdef SAFE_DATA
clear_scratch_gps_asm
clear_scratch_xmms_avx_asm
%endif
%endmacro
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; void aes_cmac_subkey_gen_sse(const void *key_exp, void *key1, void *key2)
;;;
;;; key_exp : IN : address of expanded encryption key structure (AES 128)
;;; key1 : OUT : address to store subkey 1 (AES128 - 16 bytes)
;;; key2 : OUT : address to store subkey 2 (AES128 - 16 bytes)
;;;
;;; See aes_cmac_subkey_gen() above for operation details
MKGLOBAL(aes_cmac_subkey_gen_sse,function,)
align 32
aes_cmac_subkey_gen_sse:
endbranch64
AES_CMAC_SUBKEY_GEN_SSE 9
ret
MKGLOBAL(aes_cmac_subkey_gen_sse_no_aesni,function,)
align 32
aes_cmac_subkey_gen_sse_no_aesni:
endbranch64
AES_CMAC_SUBKEY_GEN_SSE 9, no_aesni
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; void aes_cmac_256_subkey_gen_sse(const void *key_exp,
;;; void *key1,
;;; void *key2)
;;;
;;; key_exp : IN : address of expanded encryption key structure (AES 256)
;;; key1 : OUT : address to store subkey 1 (AES256 - 16 bytes)
;;; key2 : OUT : address to store subkey 2 (AES256 - 16 bytes)
;;;
;;; See aes_cmac_subkey_gen() above for operation details
MKGLOBAL(aes_cmac_256_subkey_gen_sse,function,)
align 32
aes_cmac_256_subkey_gen_sse:
endbranch64
AES_CMAC_SUBKEY_GEN_SSE 13
ret
MKGLOBAL(aes_cmac_256_subkey_gen_sse_no_aesni,function,)
align 32
aes_cmac_256_subkey_gen_sse_no_aesni:
endbranch64
AES_CMAC_SUBKEY_GEN_SSE 13, no_aesni
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; void aes_cmac_subkey_gen_avx(const void *key_exp, void *key1, void *key2)
;;;
;;; key_exp : IN : address of expanded encryption key structure (AES 128)
;;; key1 : OUT : address to store subkey 1 (AES128 - 16 bytes)
;;; key2 : OUT : address to store subkey 2 (AES128 - 16 bytes)
;;;
;;; See aes_cmac_subkey_gen() above for operation details
MKGLOBAL(aes_cmac_subkey_gen_avx,function,)
MKGLOBAL(aes_cmac_subkey_gen_avx2,function,)
MKGLOBAL(aes_cmac_subkey_gen_avx512,function,)
align 32
aes_cmac_subkey_gen_avx:
aes_cmac_subkey_gen_avx2:
aes_cmac_subkey_gen_avx512:
endbranch64
AES_CMAC_SUBKEY_GEN_AVX 9
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; void aes_cmac_256_subkey_gen_avx(const void *key_exp,
;;; void *key1,
;;; void *key2)
;;;
;;; key_exp : IN : address of expanded encryption key structure (AES 256)
;;; key1 : OUT : address to store subkey 1 (AES256 - 16 bytes)
;;; key2 : OUT : address to store subkey 2 (AES256 - 16 bytes)
;;;
;;; See aes_cmac_subkey_gen() above for operation details
MKGLOBAL(aes_cmac_256_subkey_gen_avx,function,)
MKGLOBAL(aes_cmac_256_subkey_gen_avx2,function,)
MKGLOBAL(aes_cmac_256_subkey_gen_avx512,function,)
align 32
aes_cmac_256_subkey_gen_avx:
aes_cmac_256_subkey_gen_avx2:
aes_cmac_256_subkey_gen_avx512:
endbranch64
AES_CMAC_SUBKEY_GEN_AVX 13
ret
%ifdef LINUX
section .note.GNU-stack noalloc noexec nowrite progbits
%endif
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x14176, %rsi
lea addresses_WC_ht+0x1dc36, %rdi
add $43980, %r9
mov $52, %rcx
rep movsw
nop
add %rcx, %rcx
lea addresses_normal_ht+0x2baf, %r13
and %r10, %r10
movups (%r13), %xmm6
vpextrq $0, %xmm6, %r11
nop
nop
nop
inc %r13
lea addresses_A_ht+0x15c36, %rsi
lea addresses_A_ht+0x137d6, %rdi
nop
nop
nop
nop
sub $34464, %rax
mov $65, %rcx
rep movsw
nop
cmp $25881, %rsi
lea addresses_normal_ht+0x43b6, %rsi
lea addresses_WT_ht+0x19eb6, %rdi
nop
nop
and %r10, %r10
mov $119, %rcx
rep movsw
nop
and $682, %r13
lea addresses_D_ht+0x155b6, %rax
clflush (%rax)
nop
nop
nop
nop
nop
and %rcx, %rcx
movb (%rax), %r10b
nop
nop
and %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r14
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
// Store
lea addresses_PSE+0xe636, %r14
xor %rdi, %rdi
mov $0x5152535455565758, %r12
movq %r12, %xmm3
movups %xmm3, (%r14)
nop
nop
nop
cmp $56322, %r12
// REPMOV
lea addresses_RW+0x129b6, %rsi
lea addresses_D+0x5b6, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
dec %rax
mov $77, %rcx
rep movsb
nop
cmp %r11, %r11
// Store
lea addresses_A+0x175b6, %rsi
nop
add %r12, %r12
movw $0x5152, (%rsi)
nop
cmp %rdi, %rdi
// Load
lea addresses_D+0x10db6, %rcx
nop
nop
nop
add $25051, %rdi
movb (%rcx), %r11b
nop
nop
nop
nop
dec %r14
// Store
lea addresses_WC+0x36, %r11
nop
add $64007, %rcx
mov $0x5152535455565758, %r12
movq %r12, (%r11)
nop
nop
nop
nop
nop
cmp %rax, %rax
// Load
lea addresses_A+0x12b6, %r12
nop
nop
cmp %rcx, %rcx
movaps (%r12), %xmm6
vpextrq $1, %xmm6, %rbp
nop
nop
nop
nop
nop
and $17599, %r14
// Store
mov $0xb36, %rax
nop
nop
nop
xor %r11, %r11
movl $0x51525354, (%rax)
nop
nop
nop
nop
add $15191, %rdi
// Store
lea addresses_PSE+0x14036, %r11
nop
nop
dec %rsi
mov $0x5152535455565758, %rbp
movq %rbp, %xmm6
movups %xmm6, (%r11)
nop
nop
inc %r12
// Store
lea addresses_A+0xa46a, %rax
nop
nop
sub $16888, %rcx
movl $0x51525354, (%rax)
sub $57887, %r12
// Store
lea addresses_WC+0x57f6, %r12
and %r14, %r14
mov $0x5152535455565758, %r11
movq %r11, (%r12)
nop
nop
nop
nop
nop
and $47567, %rdi
// Faulty Load
lea addresses_D+0x10db6, %rax
cmp %r12, %r12
mov (%rax), %cx
lea oracles, %r11
and $0xff, %rcx
shlq $12, %rcx
mov (%r11,%rcx,1), %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r14
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_RW', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_D', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'36': 10}
36 36 36 36 36 36 36 36 36 36
*/
|
;
; OZ-7xx DK emulation layer for Z88DK
; by Stefano Bodrato - Oct. 2003
;
; void ozcircle(int x,int y,byte r,byte color);
;
; ------
; $Id: ozcircle.asm,v 1.1 2003/10/27 16:56:57 stefano Exp $
;
XLIB ozcircle
LIB swapgfxbk
LIB swapgfxbk1
LIB draw_circle
LIB ozplotpixel
LIB ozpointcolor
.ozcircle
ld ix,0
add ix,sp
ld a,(ix+2)
and 4
push af
call ozpointcolor
ld e,1 ;skip
ld d,(ix+4) ;radius
ld c,(ix+6) ;y
ld b,(ix+8) ;x
ld ix,ozplotpixel
call swapgfxbk
pop af
jr nz,filloop
call draw_circle
jp swapgfxbk1
.filloop
push bc
push de
call draw_circle
pop de
pop bc
dec d
jr nz,filloop
jp swapgfxbk1
|
; double __FASTCALL__ expm1(double x)
SECTION code_clib
SECTION code_fp_math48
PUBLIC cm48_sccz80_expm1
EXTERN am48_expm1
defc cm48_sccz80_expm1 = am48_expm1
|
// Generated code. Do not edit
// Create the model
Model createTestModel() {
const std::vector<Operand> operands = {
{
.type = OperandType::TENSOR_QUANT8_ASYMM,
.dimensions = {1, 5, 2, 1},
.numberOfConsumers = 1,
.scale = 1.0f,
.zeroPoint = 0,
.lifetime = OperandLifeTime::MODEL_INPUT,
.location = {.poolIndex = 0, .offset = 0, .length = 0},
},
{
.type = OperandType::TENSOR_INT32,
.dimensions = {2},
.numberOfConsumers = 1,
.scale = 0.0f,
.zeroPoint = 0,
.lifetime = OperandLifeTime::CONSTANT_COPY,
.location = {.poolIndex = 0, .offset = 0, .length = 8},
},
{
.type = OperandType::TENSOR_INT32,
.dimensions = {2, 2},
.numberOfConsumers = 1,
.scale = 0.0f,
.zeroPoint = 0,
.lifetime = OperandLifeTime::CONSTANT_COPY,
.location = {.poolIndex = 0, .offset = 8, .length = 16},
},
{
.type = OperandType::TENSOR_QUANT8_ASYMM,
.dimensions = {6, 2, 2, 1},
.numberOfConsumers = 0,
.scale = 1.0f,
.zeroPoint = 0,
.lifetime = OperandLifeTime::MODEL_OUTPUT,
.location = {.poolIndex = 0, .offset = 0, .length = 0},
}
};
const std::vector<Operation> operations = {
{
.type = OperationType::SPACE_TO_BATCH_ND,
.inputs = {0, 1, 2},
.outputs = {3},
}
};
const std::vector<uint32_t> inputIndexes = {0};
const std::vector<uint32_t> outputIndexes = {3};
std::vector<uint8_t> operandValues = {
3, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0
};
const std::vector<hidl_memory> pools = {};
return {
.operands = operands,
.operations = operations,
.inputIndexes = inputIndexes,
.outputIndexes = outputIndexes,
.operandValues = operandValues,
.pools = pools,
};
}
bool is_ignored(int i) {
static std::set<int> ignore = {};
return ignore.find(i) != ignore.end();
}
|
Music_PokeMart:
dbw $c0, Music_PokeMart_Ch1
dbw $01, Music_PokeMart_Ch2
dbw $02, Music_PokeMart_Ch3
dbw $03, Music_PokeMart_Ch4
Music_PokeMart_Ch1:
tempo $90
volume $77
dutycycle 1
notetype $C, $B2
;Channel1_Bar1:
octave 4
note C#, 4
note C#, 4
note C_, 2
note C_, 4
octave 3
note B_, 6
;Channel1_Bar2:
note A#, 12
;Channel1_Bar3:
Music_PokeMart_Loop1:
note D#, 4
octave 2
note A#, 2
octave 3
note D#, 4
octave 2
note F#, 4
octave 3
note D#, 4
;Channel1_Bar4:
octave 2
note F#, 2
note B_, 2
note F#, 4
octave 3
note D#, 4
octave 2
note B_, 2
;Channel1_Bar5:
note A_, 4
note F#, 2
octave 3
note D#, 4
octave 2
note A_, 4
octave 3
note D#, 4
;Channel1_Bar6:
octave 2
note F#, 2
note A_, 2
note F#, 4
octave 3
note D#, 4
octave 2
note A_, 2
;Channel1_Bar7:
note G#, 4
note B_, 2
note E_, 4
note B_, 4
note G#, 4
;Channel1_Bar8:
note F_, 2
octave 3
note D_, 2
octave 2
note G#, 4
octave 3
note D_, 4
note F_, 2
;Channel1_Bar9:
note B_, 4
note F#, 2
note B_, 2
note F#, 2
intensity $B4
note F_, 2
note F#, 2
note G#, 2
;Channel1_Bar10:
note A#, 16
;Channel1_Bar11:
dutycycle 2
note A#, 4
note B_, 2
note D#, 4
note F#, 4
note D#, 1
note F#, 1
;Channel1_Bar12:
note B_, 2
note F#, 2
note B_, 2
octave 4
note C#, 4
octave 3
note B_, 2
octave 4
note C#, 2
note D#, 2
;Channel1_Bar13:
octave 3
note A_, 4
note B_, 2
note D#, 4
note F#, 4
note D#, 1
note F#, 1
;Channel1_Bar14:
note A_, 2
note D#, 2
note F#, 2
note B_, 4
note A_, 4
note F#, 1
note A_, 1
;Channel1_Bar15:
note B_, 4
note B_, 2
note E_, 4
note B_, 4
note E_, 4
;Channel1_Bar16:
octave 2
note F_, 2
octave 3
note D_, 2
note F_, 4
note D_, 4
note G#, 2
;Channel1_Bar17:
note B_, 4
note F#, 2
octave 4
note C#, 1
octave 3
note B_, 1
note F#, 2
note F_, 2
note F#, 2
note G#, 2
;Channel1_Bar18:
note A#, 8
note E_, 2
note C#, 2
note F#, 2
note E_, 2
;Channel1_Bar19:
intensity $B1
dutycycle 0
note D#, 2
octave 2
note G_, 2
note A#, 2
note G_, 4
note A#, 4
octave 3
note D#, 4
;Channel1_Bar20:
octave 2
note G_, 2
note A#, 2
note G_, 4
octave 3
note D#, 4
octave 2
note A#, 2
;Channel1_Bar21:
octave 3
note D#, 2
octave 2
note G#, 2
note B_, 2
note G#, 4
octave 3
note D#, 4
octave 2
note B_, 4
;Channel1_Bar22:
note G#, 2
note B_, 2
note G#, 4
octave 3
note D#, 4
octave 2
note G#, 2
;Channel1_Bar23:
intensity $B4
dutycycle 1
octave 3
note G_, 2
note D#, 2
note G_, 2
note D#, 2
note A#, 2
note A_, 2
note A#, 2
octave 4
note D#, 2
;Channel1_Bar24:
octave 3
note D#, 2
octave 2
note A#, 2
octave 4
note D#, 1
note D_, 1
note D#, 2
note F_, 1
note E_, 1
note F_, 2
note G_, 1
note F#, 1
note G_, 2
;Channel1_Bar25:
note C#, 2
octave 3
note G#, 2
octave 4
note D#, 2
octave 3
note B_, 4
note D#, 4
note C#, 4
;Channel1_Bar26:
octave 4
note C#, 2
note D#, 2
octave 3
note B_, 4
note D#, 4
octave 2
note G#, 2
;Channel1_Bar27:
intensity $B2
octave 3
note D#, 2
octave 2
note B_, 2
octave 3
note D#, 2
note G#, 4
note B_, 4
note D#, 2
;Channel1_Bar28:
note D_, 2
octave 2
note B_, 2
octave 3
note D_, 2
note G#, 4
note F_, 4
note D_, 2
;Channel1_Bar29:
note C#, 2
octave 2
note F#, 2
note A#, 2
octave 3
note C#, 2
note F#, 2
note B_, 2
octave 4
note C#, 2
octave 3
note B_, 2
;Channel1_Bar30:
octave 4
note C#, 2
octave 3
note B_, 4
note A#, 10
;Channel1_Bar31:
loopchannel 0, Music_PokeMart_Loop1
Music_PokeMart_Ch2:
dutycycle 2
notetype $C, $B1
;Channel2_Bar1:
octave 4
note F#, 4
note F#, 4
note F#, 2
note F#, 4
note F#, 6
;Channel2_Bar2:
intensity $C5
note F#, 6
dutycycle 1
octave 3
note F#, 2
note G#, 2
note A#, 2
;Channel2_Bar3:
Music_PokeMart_Loop2:
octave 4
note C#, 3
octave 3
note F#, 1
octave 4
note D#, 2
octave 3
note B_, 8
note B_, 1
octave 4
note C#, 1
;Channel2_Bar4:
note D#, 2
note D_, 2
note D#, 2
note E_, 6
note D#, 1
note E_, 1
note F#, 2
;Channel2_Bar5:
note C#, 3
octave 3
note F#, 1
octave 4
note D#, 2
octave 3
note B_, 8
note B_, 1
octave 4
note C#, 1
;Channel2_Bar6:
note D#, 2
note D_, 2
note D#, 2
note G#, 6
note E_, 1
note D#, 1
note C#, 2
;Channel2_Bar7:
note D#, 3
octave 3
note G#, 1
octave 4
note E_, 2
note C#, 12
;Channel2_Bar8:
octave 3
note G#, 6
note A#, 4
note B_, 4
;Channel2_Bar9:
octave 4
note D#, 6
note E_, 1
note D#, 1
note C#, 2
octave 3
note B_, 2
note A#, 2
note B_, 2
;Channel2_Bar10:
intensity $C2
octave 4
note C#, 8
note B_, 2
note F#, 2
note E_, 2
note D#, 2
;Channel2_Bar11:
intensity $C5
note C#, 3
octave 3
note F#, 1
octave 4
note D#, 2
octave 3
note B_, 8
note B_, 1
octave 4
note C#, 1
;Channel2_Bar12:
note D#, 6
note E_, 4
note D#, 2
note E_, 2
note F#, 2
;Channel2_Bar13:
note C#, 3
octave 3
note F#, 1
octave 4
note D#, 2
octave 3
note B_, 8
note B_, 1
octave 4
note C#, 1
;Channel2_Bar14:
notetype 6, $C5
note D#, 11
note G_, 1
note G#, 8
note F#, 8
octave 3
note B_, 2
octave 4
note C#, 2
;Channel2_Bar15:
note D#, 6
octave 3
note G#, 2
octave 4
note E_, 4
note C#, 16
note __, 8
;Channel2_Bar16:
octave 3
note G#, 4
note G_, 4
note G#, 4
note A#, 4
note G#, 4
note A#, 4
note B_, 3
octave 4
note D_, 1
;Channel2_Bar17:
note D#, 12
note E_, 2
note D#, 2
note C#, 4
octave 3
note B_, 4
note A#, 4
note B_, 4
;Channel2_Bar18:
notetype $C, $C5
octave 4
note C#, 12
dutycycle 2
octave 3
note B_, 2
octave 4
note C#, 2
;Channel2_Bar19:
note D#, 4
note D#, 4
note D#, 2
note D_, 2
notetype 6, $C5
note D#, 3
note G#, 1
note A#, 12
;Channel2_Bar20:
note G_, 8
note D#, 8
note C#, 8
;Channel2_Bar21:
note C#, 6
note C#, 1
note D_, 1
note D#, 4
octave 3
note B_, 8
note A#, 4
note B_, 4
octave 4
note C#, 12
;Channel2_Bar22:
note D#, 4
note G#, 12
octave 3
note B_, 4
octave 4
note C#, 4
;Channel2_Bar23:
note D#, 8
note D#, 8
note D#, 4
note D_, 4
note D#, 3
note G#, 1
note A#, 12
;Channel2_Bar24:
note G_, 2
note F#, 2
note G_, 4
note G#, 2
note G_, 2
note G#, 4
note A#, 2
note A_, 2
note A#, 4
;Channel2_Bar25:
note A#, 8
note B_, 4
note G#, 8
note G_, 4
note G#, 4
note A#, 12
;Channel2_Bar26:
note B_, 4
note G#, 7
dutycycle 0
octave 5
note C_, 1
note C#, 4
octave 4
note B_, 4
note A#, 4
;Channel2_Bar27:
notetype $C, $C5
note B_, 15
notetype 6, $C5
note G#, 1
note A#, 1
;Channel2_Bar28:
notetype $C, $C5
note B_, 10
note G#, 2
note A#, 2
note B_, 2
;Channel2_Bar29:
note A#, 10
note G#, 2
note A#, 2
note G#, 2
;Channel2_Bar30:
note A#, 2
note G#, 4
note F#, 10
;Channel2_Bar31:
dutycycle 1
loopchannel 0, Music_PokeMart_Loop2
Music_PokeMart_Ch3:
notetype $C, $14
;Channel3_Bar1:
octave 4
note D#, 1
note __, 3
note D#, 1
note __, 3
note D_, 1
note __, 1
note D_, 1
note __, 3
note C#, 1
note __, 5
;Channel3_Bar2:
octave 3
note F#, 5
note __, 7
;Channel3_Bar3:
Music_PokeMart_Loop3:
octave 2
note B_, 4
note __, 2
note B_, 1
note __, 1
note F#, 4
note __, 2
note F#, 1
note __, 1
;Channel3_Bar4:
note B_, 4
note __, 2
note B_, 1
note __, 1
note F#, 4
note __, 2
note F#, 1
note __, 1
;Channel3_Bar5:
note B_, 4
note __, 2
note B_, 1
note __, 1
note F#, 4
note __, 2
note F#, 1
note __, 1
;Channel3_Bar6:
note B_, 4
note __, 2
note B_, 1
note __, 1
note F#, 4
note __, 2
note F#, 1
note __, 1
;Channel3_Bar7:
note E_, 4
note __, 2
note E_, 1
note __, 1
note B_, 4
note __, 2
note B_, 1
note __, 1
;Channel3_Bar8:
note F_, 4
note __, 2
note F_, 1
note __, 1
note B_, 4
note __, 2
note B_, 1
note __, 1
;Channel3_Bar9:
note F#, 4
note __, 2
note F#, 1
note __, 1
octave 3
note F#, 4
note __, 2
note F#, 1
note __, 1
;Channel3_Bar10:
octave 2
note F#, 2
note __, 14
callchannel Music_PokeMart_Branch
callchannel Music_PokeMart_Branch
callchannel Music_PokeMart_Branch
callchannel Music_PokeMart_Branch
;Channel3_Bar15:
note E_, 4
intensity $24
octave 6
note G#, 1
intensity $14
octave 2
note __, 1
note E_, 1
note __, 1
note B_, 4
intensity $24
octave 5
note G#, 1
intensity $14
octave 2
note __, 1
note B_, 1
note __, 1
;Channel3_Bar16:
note F_, 4
intensity $24
octave 6
note G#, 1
intensity $14
octave 2
note __, 1
note F_, 1
note __, 1
note B_, 4
intensity $24
octave 5
note G#, 1
intensity $14
octave 2
note __, 1
note B_, 1
note __, 1
;Channel3_Bar17:
note F#, 4
intensity $24
octave 6
note F#, 1
intensity $14
octave 2
note __, 1
note F#, 1
note __, 1
octave 3
note F#, 4
intensity $24
octave 5
note F#, 1
intensity $14
octave 2
note __, 1
octave 3
note F#, 1
octave 2
note __, 1
;Channel3_Bar18:
note F#, 2
note __, 6
octave 3
note C#, 4
octave 2
note F#, 4
;Channel3_Bar19:
note D#, 4
note __, 2
note D#, 1
note __, 1
note G_, 4
note __, 2
note G_, 1
note __, 1
;Channel3_Bar20:
note A#, 4
note __, 2
note A#, 1
note __, 1
note D#, 4
note G_, 4
;Channel3_Bar21:
note G#, 4
note __, 2
note G#, 1
note __, 1
note G_, 4
note __, 2
note G_, 1
note __, 1
;Channel3_Bar22:
note F#, 4
note __, 2
note F#, 1
note __, 1
note F_, 4
note E_, 4
;Channel3_Bar23:
note D#, 4
octave 4
note A#, 1
octave 2
note __, 1
note D#, 1
note __, 1
note G_, 4
octave 4
note G_, 1
octave 2
note __, 1
note G_, 1
note __, 1
;Channel3_Bar24:
note A#, 4
octave 4
note A#, 1
octave 2
note __, 1
note A#, 1
note __, 1
note D#, 4
note G_, 4
;Channel3_Bar25:
note G#, 4
intensity $24
octave 6
note D#, 1
intensity $14
octave 2
note __, 1
note G#, 1
note __, 1
note G_, 4
intensity $24
octave 6
note D#, 1
intensity $14
octave 2
note __, 1
note G_, 1
note __, 1
;Channel3_Bar26:
note F#, 4
intensity $24
octave 6
note D#, 1
intensity $14
octave 2
note __, 1
note F#, 1
note __, 1
note F_, 4
intensity $24
octave 6
note D#, 1
intensity $14
octave 2
note __, 1
note F_, 1
note __, 1
;Channel3_Bar27:
note E_, 4
intensity $24
octave 6
note G#, 1
intensity $14
octave 2
note __, 1
note E_, 1
note __, 1
octave 1
note B_, 4
intensity $24
octave 5
note G#, 1
intensity $14
octave 1
note __, 1
note B_, 1
note __, 1
;Channel3_Bar28:
octave 2
note F_, 4
intensity $24
octave 6
note G#, 1
intensity $14
octave 2
note __, 1
note F_, 1
note __, 1
octave 1
note B_, 4
intensity $24
octave 6
note D_, 1
intensity $14
octave 1
note __, 1
note B_, 1
note __, 1
;Channel3_Bar29:
octave 2
note F#, 4
intensity $24
octave 6
note F#, 1
intensity $14
octave 2
note __, 1
note F#, 1
note __, 1
octave 3
note C#, 4
intensity $24
octave 5
note F#, 1
intensity $14
octave 3
note __, 1
note C#, 1
note __, 1
;Channel3_Bar30:
octave 2
note F#, 1
note __, 1
note F#, 1
note __, 3
note F#, 3
note __, 1
note F#, 1
note __, 1
note G#, 1
note __, 1
note A#, 1
note __, 1
;Channel3_Bar31:
loopchannel 0, Music_PokeMart_Loop3
Music_PokeMart_Branch:
note B_, 4
intensity $24
octave 6
note F#, 1
intensity $14
octave 2
note __, 1
note B_, 1
note __, 1
note F#, 4
intensity $24
octave 5
note F#, 1
intensity $14
octave 2
note __, 1
note F#, 1
note __, 1
endchannel
Music_PokeMart_Ch4:
notetype $C
togglenoise 0
;Channel4_Bar1:
note G_, 4
note G_, 4
note G_, 2
note G_, 4
note G_, 6
;Channel4_Bar2:
note A#, 12
;Channel4_Bar3:
Music_PokeMart_Loop4:
note A#, 4
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
;Channel4_Bar4:
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
;Channel4_Bar5:
note G_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
;Channel4_Bar6:
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
;Channel4_Bar7:
note G_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
;Channel4_Bar8:
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
;Channel4_Bar9:
note G_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
;Channel4_Bar10:
note G_, 16
;Channel4_Bar11:
note G_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
;Channel4_Bar12:
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
;Channel4_Bar13:
note G_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
;Channel4_Bar14:
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
;Channel4_Bar15:
note G_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
;Channel4_Bar16:
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
;Channel4_Bar17:
note G_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
note G_, 2
note D_, 2
note D_, 2
;Channel4_Bar18:
note G_, 16
;Channel4_Bar19:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar20:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar21:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar22:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar23:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar24:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar25:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar26:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar27:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar28:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar29:
note A#, 4
note G_, 2
note D_, 2
note A#, 4
note G_, 2
note D_, 2
;Channel4_Bar30:
note G_, 2
note A#, 4
note A#, 4
note D_, 2
note G_, 2
note G_, 2
;Channel4_Bar31:
loopchannel 0, Music_PokeMart_Loop4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.